[PATCH net-next v2 04/10] soc: sunxi: sram: register regmap as syscon

Chen-Yu Tsai posted 10 patches 5 months, 4 weeks ago
There is a newer version of this series
[PATCH net-next v2 04/10] soc: sunxi: sram: register regmap as syscon
Posted by Chen-Yu Tsai 5 months, 4 weeks ago
From: Chen-Yu Tsai <wens@csie.org>

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>

---
Changes since v1:
- Fix check on return value
- Expand commit message
---
 drivers/soc/sunxi/sunxi_sram.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
index 4f8d510b7e1e..1837e1b5dce8 100644
--- a/drivers/soc/sunxi/sunxi_sram.c
+++ b/drivers/soc/sunxi/sunxi_sram.c
@@ -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>
@@ -377,6 +378,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;
 
@@ -394,6 +396,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);
-- 
2.39.5
Re: [PATCH net-next v2 04/10] soc: sunxi: sram: register regmap as syscon
Posted by Jernej Škrabec 5 months, 4 weeks ago
Dne sreda, 13. avgust 2025 ob 16:55:34 Srednjeevropski poletni čas je Chen-Yu Tsai napisal(a):
> From: Chen-Yu Tsai <wens@csie.org>
> 
> 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.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

> 
> ---
> Changes since v1:
> - Fix check on return value
> - Expand commit message
> ---
>  drivers/soc/sunxi/sunxi_sram.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
> index 4f8d510b7e1e..1837e1b5dce8 100644
> --- a/drivers/soc/sunxi/sunxi_sram.c
> +++ b/drivers/soc/sunxi/sunxi_sram.c
> @@ -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>
> @@ -377,6 +378,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;
>  
> @@ -394,6 +396,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);
>