]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
soc: sunxi: sram: register regmap as syscon
authorChen-Yu Tsai <wens@csie.org>
Mon, 8 Sep 2025 18:10:53 +0000 (02:10 +0800)
committerChen-Yu Tsai <wens@csie.org>
Wed, 10 Sep 2025 12:51:26 +0000 (20:51 +0800)
If the system controller had a ethernet controller glue layer control
register, a limited access regmap would be registered and tied to the
system controller struct device for the ethernet driver to use.

Until now, for the ethernet driver to acquire this regmap, it had to
do a of_parse_phandle() + find device + dev_get_regmap() sequence.
Since the syscon framework allows a provider to register a custom
regmap for its device node, and the ethernet driver already uses
syscon for one platform, this provides a much more easier way to
pass the regmap.

Use of_syscon_register_regmap() to register our regmap with the
syscon framework so that consumers can retrieve it that way.

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20250908181059.1785605-5-wens@kernel.org
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
drivers/soc/sunxi/sunxi_sram.c

index 16144a0a0d37137d09ed84b6bdba7369f8a56a15..446b9fc1f17595cf86d04dfd6daea366fc4d9dfb 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/io.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -367,6 +368,7 @@ static int __init sunxi_sram_probe(struct platform_device *pdev)
        const struct sunxi_sramc_variant *variant;
        struct device *dev = &pdev->dev;
        struct regmap *regmap;
+       int ret;
 
        sram_dev = &pdev->dev;
 
@@ -384,6 +386,10 @@ static int __init sunxi_sram_probe(struct platform_device *pdev)
                regmap = devm_regmap_init_mmio(dev, base, &sunxi_sram_regmap_config);
                if (IS_ERR(regmap))
                        return PTR_ERR(regmap);
+
+               ret = of_syscon_register_regmap(dev->of_node, regmap);
+               if (ret)
+                       return ret;
        }
 
        of_platform_populate(dev->of_node, NULL, NULL, dev);