summaryrefslogtreecommitdiffstats
path: root/drivers/soc/renesas
diff options
context:
space:
mode:
authorBiju Das <biju.das.jz@bp.renesas.com>2022-01-21 01:41:17 +0000
committerGeert Uytterhoeven <geert+renesas@glider.be>2022-02-08 09:43:06 +0100
commitcb5508e47e60b85ac033edd8c52245ad51360eb4 (patch)
tree32fb9148d68b232b461b01a6ffbe3657574c45b3 /drivers/soc/renesas
parent860122d80251c64484883324128ca82fa35423ef (diff)
downloadlinux-stable-cb5508e47e60b85ac033edd8c52245ad51360eb4.tar.gz
linux-stable-cb5508e47e60b85ac033edd8c52245ad51360eb4.tar.bz2
linux-stable-cb5508e47e60b85ac033edd8c52245ad51360eb4.zip
soc: renesas: Add support for reading product revision for RZ/G2L family
As per RZ/G2L HW manual (Rev.1.00 Sep, 2021) DEV_ID [31:28] indicates product revision. Use this information to populate the revision info for RZ/G2L family. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://lore.kernel.org/r/20220121014117.21248-1-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Diffstat (limited to 'drivers/soc/renesas')
-rw-r--r--drivers/soc/renesas/renesas-soc.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c
index 8a672d0a4dae..92c7b42250ee 100644
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
@@ -393,9 +393,11 @@ static int __init renesas_soc_init(void)
const struct renesas_soc *soc;
const struct renesas_id *id;
void __iomem *chipid = NULL;
+ const char *rev_prefix = "";
struct soc_device *soc_dev;
struct device_node *np;
const char *soc_id;
+ int ret;
match = of_match_node(renesas_socs, of_root);
if (!match)
@@ -416,6 +418,17 @@ static int __init renesas_soc_init(void)
chipid = ioremap(family->reg, 4);
}
+ soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+ if (!soc_dev_attr)
+ return -ENOMEM;
+
+ np = of_find_node_by_path("/");
+ of_property_read_string(np, "model", &soc_dev_attr->machine);
+ of_node_put(np);
+
+ soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
+ soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
+
if (chipid) {
product = readl(chipid + id->offset);
iounmap(chipid);
@@ -430,41 +443,39 @@ static int __init renesas_soc_init(void)
eshi = ((product >> 4) & 0x0f) + 1;
eslo = product & 0xf;
+ soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u",
+ eshi, eslo);
+ } else if (id == &id_rzg2l) {
+ eshi = ((product >> 28) & 0x0f);
+ soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u",
+ eshi);
+ rev_prefix = "Rev ";
}
if (soc->id &&
((product & id->mask) >> __ffs(id->mask)) != soc->id) {
pr_warn("SoC mismatch (product = 0x%x)\n", product);
- return -ENODEV;
+ ret = -ENODEV;
+ goto free_soc_dev_attr;
}
}
- soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
- if (!soc_dev_attr)
- return -ENOMEM;
-
- np = of_find_node_by_path("/");
- of_property_read_string(np, "model", &soc_dev_attr->machine);
- of_node_put(np);
-
- soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
- soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
- if (eshi)
- soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi,
- eslo);
-
- pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family,
- soc_dev_attr->soc_id, soc_dev_attr->revision ?: "");
+ pr_info("Detected Renesas %s %s %s%s\n", soc_dev_attr->family,
+ soc_dev_attr->soc_id, rev_prefix, soc_dev_attr->revision ?: "");
soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR(soc_dev)) {
- kfree(soc_dev_attr->revision);
- kfree_const(soc_dev_attr->soc_id);
- kfree_const(soc_dev_attr->family);
- kfree(soc_dev_attr);
- return PTR_ERR(soc_dev);
+ ret = PTR_ERR(soc_dev);
+ goto free_soc_dev_attr;
}
return 0;
+
+free_soc_dev_attr:
+ kfree(soc_dev_attr->revision);
+ kfree_const(soc_dev_attr->soc_id);
+ kfree_const(soc_dev_attr->family);
+ kfree(soc_dev_attr);
+ return ret;
}
early_initcall(renesas_soc_init);