mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 04:23:35 +02:00
i.MX drivers changes for 6.13:
- A series from Marek Vasut to probe soc-imx8m as platform driver, so that it works properly with 'driver_async_probe' kernel parameter. -----BEGIN PGP SIGNATURE----- iQFIBAABCgAyFiEEFmJXigPl4LoGSz08UFdYWoewfM4FAmcoes8UHHNoYXduZ3Vv QGtlcm5lbC5vcmcACgkQUFdYWoewfM6Lewf/d2egLTwCS8M7oN3IkZWBPZ4uGjbF p1mKI1TcQgOmPpd9gvBbXRwt+lHIb7nn2Z3xrS5eNVP5iiWSInuB5czjUyy9Unwx vF6Vp8r+QgzPJg5wmw/qIqRvjiC0yntiLa2hrVjNSYu1ox2mFGF+JR5WTh28SqVq 5vswGFiYEfkI773fpiOG9T6LIDovLjmvaahjXDJVERmihHe2OTnfxQ6lElmWov8R zm9rl59sJALbVI0XFu/prEZtODEmzqw2HUEykNyxU3rs8xxsVg+F+QSQpA+nT8Po 3GC/wtL7KMIE9hyUPNXoEeNRTYT9Wbd45fPaegp57VAKQt+58G+XbFiSOA== =KusR -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEiK/NIGsWEZVxh/FrYKtH/8kJUicFAmcozWgACgkQYKtH/8kJ UifeTBAAtvd3Wt4JLH4DqVJRPgnIHf3PPQGTckVVG8F+RSBfdtRhUzyVK6P3BDDP kmz/X23wZzLdQry1X9rjiAlGDcE3dpOXsCwtITVFpleRpPmMdSs+Qxk2c8hcYP2n FV3WzQhZ8h/cvIbIKcijgNtCpF1y7odzLRwqYnDI37vi860ONy5MaEhupKbRW6F8 ZcIEXAUt1TnMcaWF6lkPUd8zq5FLaB5n7s88tTFAai/UGuAvIzNMVtl/FHDqweVN /U1shsMvtzPXsKXKTZx3t0TJWwLZDRPw5STcbCNsL6N20Ezaz2AiZWz9/Cr5OdJp l/NpFLbwCebzmOk/1mZIuk4RgG4c1wdUspvWSSV5ewYiU9zjTR1ERuaPMPltLYou PrYi3JIsY6TIttNjgR9zSuKQoyCidO/uWFRMZIyFTHZKAIQGZBghmrqqprYvvuIT OGkquyXo00ZQo3al+pwBEqhm6Dy5FgKKgoZTf8YQ+Dx6zo6vG60iYiWlMYbl6iPh wfzNoENYrxATbUr5+8yMSE1EioATuTdVDC+qTvuho39EHI9BZNSGKv9DNI7cHRfb K2GJSok6E+4M04jMLYJBoR3NTu0HyLy6ZTTD3Yz62YkJJ8L9Jh8ter1Y4RQ1SFA8 8fo3LVWLTkPN4hXMHLUdQZF6fYqnw8YGAg2vqD5My54Rmzn/ubA= =AXrg -----END PGP SIGNATURE----- Merge tag 'imx-drivers-6.13' of https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux into arm/drivers i.MX drivers changes for 6.13: - A series from Marek Vasut to probe soc-imx8m as platform driver, so that it works properly with 'driver_async_probe' kernel parameter. * tag 'imx-drivers-6.13' of https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux: soc: imx8m: Use devm_* to simplify probe failure handling soc: imx8m: Remove global soc_uid soc: imx8m: Probe the SoC driver as platform driver Link: https://lore.kernel.org/r/20241104090055.1881860-1-shawnguo2@yeah.net Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
f402711c4b
|
|
@ -30,11 +30,9 @@
|
|||
|
||||
struct imx8_soc_data {
|
||||
char *name;
|
||||
u32 (*soc_revision)(void);
|
||||
int (*soc_revision)(u32 *socrev, u64 *socuid);
|
||||
};
|
||||
|
||||
static u64 soc_uid;
|
||||
|
||||
#ifdef CONFIG_HAVE_ARM_SMCCC
|
||||
static u32 imx8mq_soc_revision_from_atf(void)
|
||||
{
|
||||
|
|
@ -51,24 +49,27 @@ static u32 imx8mq_soc_revision_from_atf(void)
|
|||
static inline u32 imx8mq_soc_revision_from_atf(void) { return 0; };
|
||||
#endif
|
||||
|
||||
static u32 __init imx8mq_soc_revision(void)
|
||||
static int imx8mq_soc_revision(u32 *socrev, u64 *socuid)
|
||||
{
|
||||
struct device_node *np;
|
||||
struct device_node *np __free(device_node) =
|
||||
of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
|
||||
void __iomem *ocotp_base;
|
||||
u32 magic;
|
||||
u32 rev;
|
||||
struct clk *clk;
|
||||
int ret;
|
||||
|
||||
np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
|
||||
if (!np)
|
||||
return 0;
|
||||
return -EINVAL;
|
||||
|
||||
ocotp_base = of_iomap(np, 0);
|
||||
WARN_ON(!ocotp_base);
|
||||
if (!ocotp_base)
|
||||
return -EINVAL;
|
||||
|
||||
clk = of_clk_get_by_name(np, NULL);
|
||||
if (IS_ERR(clk)) {
|
||||
WARN_ON(IS_ERR(clk));
|
||||
return 0;
|
||||
ret = PTR_ERR(clk);
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
clk_prepare_enable(clk);
|
||||
|
|
@ -84,71 +85,78 @@ static u32 __init imx8mq_soc_revision(void)
|
|||
rev = REV_B1;
|
||||
}
|
||||
|
||||
soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH);
|
||||
soc_uid <<= 32;
|
||||
soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
|
||||
*socuid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH);
|
||||
*socuid <<= 32;
|
||||
*socuid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
|
||||
|
||||
*socrev = rev;
|
||||
|
||||
clk_disable_unprepare(clk);
|
||||
clk_put(clk);
|
||||
iounmap(ocotp_base);
|
||||
of_node_put(np);
|
||||
|
||||
return rev;
|
||||
return 0;
|
||||
|
||||
err_clk:
|
||||
iounmap(ocotp_base);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __init imx8mm_soc_uid(void)
|
||||
static int imx8mm_soc_uid(u64 *socuid)
|
||||
{
|
||||
struct device_node *np __free(device_node) =
|
||||
of_find_compatible_node(NULL, NULL, "fsl,imx8mm-ocotp");
|
||||
void __iomem *ocotp_base;
|
||||
struct device_node *np;
|
||||
struct clk *clk;
|
||||
int ret = 0;
|
||||
u32 offset = of_machine_is_compatible("fsl,imx8mp") ?
|
||||
IMX8MP_OCOTP_UID_OFFSET : 0;
|
||||
|
||||
np = of_find_compatible_node(NULL, NULL, "fsl,imx8mm-ocotp");
|
||||
if (!np)
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
ocotp_base = of_iomap(np, 0);
|
||||
WARN_ON(!ocotp_base);
|
||||
if (!ocotp_base)
|
||||
return -EINVAL;
|
||||
|
||||
clk = of_clk_get_by_name(np, NULL);
|
||||
if (IS_ERR(clk)) {
|
||||
WARN_ON(IS_ERR(clk));
|
||||
return;
|
||||
ret = PTR_ERR(clk);
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
clk_prepare_enable(clk);
|
||||
|
||||
soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset);
|
||||
soc_uid <<= 32;
|
||||
soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
|
||||
*socuid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset);
|
||||
*socuid <<= 32;
|
||||
*socuid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
|
||||
|
||||
clk_disable_unprepare(clk);
|
||||
clk_put(clk);
|
||||
|
||||
err_clk:
|
||||
iounmap(ocotp_base);
|
||||
of_node_put(np);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u32 __init imx8mm_soc_revision(void)
|
||||
static int imx8mm_soc_revision(u32 *socrev, u64 *socuid)
|
||||
{
|
||||
struct device_node *np;
|
||||
struct device_node *np __free(device_node) =
|
||||
of_find_compatible_node(NULL, NULL, "fsl,imx8mm-anatop");
|
||||
void __iomem *anatop_base;
|
||||
u32 rev;
|
||||
|
||||
np = of_find_compatible_node(NULL, NULL, "fsl,imx8mm-anatop");
|
||||
if (!np)
|
||||
return 0;
|
||||
return -EINVAL;
|
||||
|
||||
anatop_base = of_iomap(np, 0);
|
||||
WARN_ON(!anatop_base);
|
||||
if (!anatop_base)
|
||||
return -EINVAL;
|
||||
|
||||
rev = readl_relaxed(anatop_base + ANADIG_DIGPROG_IMX8MM);
|
||||
*socrev = readl_relaxed(anatop_base + ANADIG_DIGPROG_IMX8MM);
|
||||
|
||||
iounmap(anatop_base);
|
||||
of_node_put(np);
|
||||
|
||||
imx8mm_soc_uid();
|
||||
|
||||
return rev;
|
||||
return imx8mm_soc_uid(socuid);
|
||||
}
|
||||
|
||||
static const struct imx8_soc_data imx8mq_soc_data = {
|
||||
|
|
@ -179,21 +187,23 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = {
|
|||
{ }
|
||||
};
|
||||
|
||||
#define imx8_revision(soc_rev) \
|
||||
soc_rev ? \
|
||||
kasprintf(GFP_KERNEL, "%d.%d", (soc_rev >> 4) & 0xf, soc_rev & 0xf) : \
|
||||
#define imx8_revision(dev, soc_rev) \
|
||||
(soc_rev) ? \
|
||||
devm_kasprintf((dev), GFP_KERNEL, "%d.%d", ((soc_rev) >> 4) & 0xf, (soc_rev) & 0xf) : \
|
||||
"unknown"
|
||||
|
||||
static int __init imx8_soc_init(void)
|
||||
static int imx8m_soc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct soc_device_attribute *soc_dev_attr;
|
||||
struct soc_device *soc_dev;
|
||||
const struct of_device_id *id;
|
||||
u32 soc_rev = 0;
|
||||
const struct imx8_soc_data *data;
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct of_device_id *id;
|
||||
struct soc_device *soc_dev;
|
||||
u32 soc_rev = 0;
|
||||
u64 soc_uid = 0;
|
||||
int ret;
|
||||
|
||||
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
|
||||
soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
|
||||
if (!soc_dev_attr)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -201,38 +211,33 @@ static int __init imx8_soc_init(void)
|
|||
|
||||
ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
|
||||
if (ret)
|
||||
goto free_soc;
|
||||
return ret;
|
||||
|
||||
id = of_match_node(imx8_soc_match, of_root);
|
||||
if (!id) {
|
||||
ret = -ENODEV;
|
||||
goto free_soc;
|
||||
}
|
||||
if (!id)
|
||||
return -ENODEV;
|
||||
|
||||
data = id->data;
|
||||
if (data) {
|
||||
soc_dev_attr->soc_id = data->name;
|
||||
if (data->soc_revision)
|
||||
soc_rev = data->soc_revision();
|
||||
if (data->soc_revision) {
|
||||
ret = data->soc_revision(&soc_rev, &soc_uid);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
soc_dev_attr->revision = imx8_revision(soc_rev);
|
||||
if (!soc_dev_attr->revision) {
|
||||
ret = -ENOMEM;
|
||||
goto free_soc;
|
||||
}
|
||||
soc_dev_attr->revision = imx8_revision(dev, soc_rev);
|
||||
if (!soc_dev_attr->revision)
|
||||
return -ENOMEM;
|
||||
|
||||
soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
|
||||
if (!soc_dev_attr->serial_number) {
|
||||
ret = -ENOMEM;
|
||||
goto free_rev;
|
||||
}
|
||||
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX", soc_uid);
|
||||
if (!soc_dev_attr->serial_number)
|
||||
return -ENOMEM;
|
||||
|
||||
soc_dev = soc_device_register(soc_dev_attr);
|
||||
if (IS_ERR(soc_dev)) {
|
||||
ret = PTR_ERR(soc_dev);
|
||||
goto free_serial_number;
|
||||
}
|
||||
if (IS_ERR(soc_dev))
|
||||
return PTR_ERR(soc_dev);
|
||||
|
||||
pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
|
||||
soc_dev_attr->revision);
|
||||
|
|
@ -241,15 +246,38 @@ static int __init imx8_soc_init(void)
|
|||
platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
free_serial_number:
|
||||
kfree(soc_dev_attr->serial_number);
|
||||
free_rev:
|
||||
if (strcmp(soc_dev_attr->revision, "unknown"))
|
||||
kfree(soc_dev_attr->revision);
|
||||
free_soc:
|
||||
kfree(soc_dev_attr);
|
||||
return ret;
|
||||
static struct platform_driver imx8m_soc_driver = {
|
||||
.probe = imx8m_soc_probe,
|
||||
.driver = {
|
||||
.name = "imx8m-soc",
|
||||
},
|
||||
};
|
||||
|
||||
static int __init imx8_soc_init(void)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
int ret;
|
||||
|
||||
/* No match means this is non-i.MX8M hardware, do nothing. */
|
||||
if (!of_match_node(imx8_soc_match, of_root))
|
||||
return 0;
|
||||
|
||||
ret = platform_driver_register(&imx8m_soc_driver);
|
||||
if (ret) {
|
||||
pr_err("Failed to register imx8m-soc platform driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pdev = platform_device_register_simple("imx8m-soc", -1, NULL, 0);
|
||||
if (IS_ERR(pdev)) {
|
||||
pr_err("Failed to register imx8m-soc platform device: %ld\n", PTR_ERR(pdev));
|
||||
platform_driver_unregister(&imx8m_soc_driver);
|
||||
return PTR_ERR(pdev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
device_initcall(imx8_soc_init);
|
||||
MODULE_DESCRIPTION("NXP i.MX8M SoC driver");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user