[PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap

From: Gabriel Fernandez

Date: Wed Nov 18 2026 - 07:00:16 EST


The "clocks" property of the SYSCFG node lists the parents of the LTDC
pixel clock mux. When the syscon core creates the regmap of the node, it
attaches the first one, the LTDC kernel clock, which then stays prepared
and gets enabled and disabled around each SYSCFG register access,
although the SYSCFG registers do not need any clock.

Create the MMIO regmap in the driver and register it with the syscon
core before populating the subnodes, so that syscon_node_to_regmap()
returns it instead of creating one with the clock attached. If a
consumer already created the regmap, keep it and warn since its clock
stays attached.

As the syscon core does, map the registers without requesting the
region: the SDMMC delay blocks lie in the SYSCFG range and are requested
by the SDMMC driver.

The regmap cannot be unregistered from the syscon core, so make the
driver built-in and suppress its bind attributes.

Select MFD_SYSCON, without which of_syscon_register_regmap() returns
-EOPNOTSUPP, and REGMAP_MMIO.

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@xxxxxxxxxxx>
---
drivers/soc/st/Kconfig | 4 +++-
drivers/soc/st/stm32mp2-syscfg.c | 48 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/st/Kconfig b/drivers/soc/st/Kconfig
index 2a9d6a77be45..db3ce8e8111f 100644
--- a/drivers/soc/st/Kconfig
+++ b/drivers/soc/st/Kconfig
@@ -2,9 +2,11 @@
menu "ST SoC drivers"

config SOC_STM32MP2
- tristate "STM32MP2 SoC family support"
+ bool "STM32MP2 SoC family support"
depends on ARCH_STM32 || COMPILE_TEST
default ARCH_STM32 && ARM64
+ select MFD_SYSCON
+ select REGMAP_MMIO
select SOC_BUS
help
If you say yes here, you get support for the ST STM32MP2 family
diff --git a/drivers/soc/st/stm32mp2-syscfg.c b/drivers/soc/st/stm32mp2-syscfg.c
index 770321a4a6f7..0d45fdef46b7 100644
--- a/drivers/soc/st/stm32mp2-syscfg.c
+++ b/drivers/soc/st/stm32mp2-syscfg.c
@@ -3,13 +3,55 @@
* Copyright 2026 Marek Vasut
*/

+#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+static const struct regmap_config stm32mp2_syscfg_regmap_config = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+};

static int stm32mp2_syscfg_probe(struct platform_device *pdev)
{
- return devm_of_platform_populate(&pdev->dev);
+ struct regmap_config config = stm32mp2_syscfg_regmap_config;
+ struct device *dev = &pdev->dev;
+ struct regmap *regmap;
+ struct resource *res;
+ void __iomem *base;
+ int ret;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ /* Not requested: the SDMMC delay blocks lie in the SYSCFG range */
+ base = devm_ioremap(dev, res->start, resource_size(res));
+ if (!base)
+ return -ENOMEM;
+
+ config.max_register = resource_size(res) - config.reg_stride;
+
+ regmap = devm_regmap_init_mmio(dev, base, &config);
+ if (IS_ERR(regmap))
+ return dev_err_probe(dev, PTR_ERR(regmap),
+ "failed to init the regmap\n");
+
+ /*
+ * The SYSCFG registers need no clock, but the generic syscon regmap
+ * would enable the first clock of the node, the LTDC kernel clock
+ * which is only a parent of the pixel clock mux, around each access.
+ */
+ ret = of_syscon_register_regmap(dev->of_node, regmap);
+ if (ret == -EEXIST)
+ dev_warn(dev, "syscon regmap already created, its clock stays attached\n");
+ else if (ret)
+ return dev_err_probe(dev, ret, "failed to register the regmap\n");
+
+ return devm_of_platform_populate(dev);
}

static const struct of_device_id stm32mp2_syscfg_ids[] = {
@@ -23,10 +65,12 @@ static struct platform_driver stm32mp2_syscfg_driver = {
.driver = {
.name = "stm32mp2_syscfg",
.of_match_table = stm32mp2_syscfg_ids,
+ /* The consumers keep using the regmap */
+ .suppress_bind_attrs = true,
},
.probe = stm32mp2_syscfg_probe,
};
-module_platform_driver(stm32mp2_syscfg_driver);
+builtin_platform_driver(stm32mp2_syscfg_driver);

MODULE_AUTHOR("Marek Vasut <marex@xxxxxxxxxxxx>");
MODULE_DESCRIPTION("ST STM32MP2 SYSCFG driver");

--
2.43.0