Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux
@ 2026-11-18 11:59 Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 1/6] dt-bindings: arm: stm32: Add clock inputs to STM32MP2 SYSCFG Gabriel Fernandez
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

On STM32MP23x and STM32MP25x, the LTDC pixel clock is selected in the
SYSCFG DISPLAYCLKCR register among the LTDC kernel clock (RGB output),
the LVDS PHY pixel clock (reset value) and the DSI PHY byte lane clock.
The SYSCFG node is already described as the provider of this clock, used
as the LTDC "ref" clock, but no driver registers it, so the RGB output
can't be used.

This series adds a clock driver for this mux. It is based on the RFC
sent by Dario [1] and on the driver delivered in the ST downstream
kernel.

The SYSCFG node remains the clock provider ('#clock-cells = <0>'), and
the inputs of the mux are described by its "clocks" property, so the
ones which don't exist on a SoC (no LVDS/DSI on STM32MP231/233 and
STM32MP251/253) are simply omitted. As the SYSCFG node is bound to the
STM32MP2 SYSCFG driver, the clock driver is an auxiliary driver, whose
device is created by the SYSCFG driver. The LTDC "ref" clock is left
unchanged.

As the SYSCFG node is a syscon, the syscon core would take the first
clock of the node, i.e. the LTDC kernel clock, as the clock of the SYSCFG
registers. The SYSCFG driver therefore creates the SYSCFG regmap itself
and registers it with the syscon core, without any clock.

Changes compared to the RFC [1]:
- parents described by clocks/clock-names instead of global names
- auxiliary device created on STM32MP23x too
- SoC devicetrees updated, Engicam board patches dropped

[1] https://lore.kernel.org/all/20261028135915.2665857-1-dario.binacchi@amarulasolutions.com/

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
---
Changes in v3:
- Drop the clock-controller sub-node, its binding and the dt-bindings
  header: describe the mux inputs in the SYSCFG node, which remains the
  clock provider with '#clock-cells = <0>' (Krzysztof, Conor)
- Keep '#clock-cells' in the SoC devicetrees and the SYSCFG node as LTDC
  "ref" clock, not to break the existing users (Krzysztof)
- Make the clock driver an auxiliary driver, whose device is created by
  the STM32MP2 SYSCFG driver (RFC patch 3/4 from Dario)
- New patch: create the SYSCFG regmap in the STM32MP2 SYSCFG driver, so
  that the syscon core doesn't attach the LTDC kernel clock to it
- clk driver: depend on SOC_STM32MP2 || COMPILE_TEST, check the
  regmap_read() return value, drop the redundant CLK_SET_RATE_NO_REPARENT
  flag, fix the copyright year and the order of the local variables
  (Brian). The of_get_parent() change doesn't apply anymore, the driver
  using the SYSCFG node directly
- clk driver: drop <linux/mod_devicetable.h> (Uwe)
- Link to v2: https://lore.kernel.org/r/20261110-ups_mp25_clk_syscfg-v2-0-624559bb8ec7@foss.st.com

Changes in v2:
- Deprecate the '#clock-cells' property of the SYSCFG node and remove it
  from the SoC devicetrees, the clock-controller sub-node being the only
  provider of the LTDC pixel clock (Sashiko)
- Explain why the mux needs a sub-node: its inputs can't be described by
  the "clocks" property of the SYSCFG node, which is a syscon (Sashiko)
- Link to v1: https://lore.kernel.org/r/20261110-ups_mp25_clk_syscfg-v1-0-667829cd290a@foss.st.com

---
Dario Binacchi (1):
      soc: st: stm32mp2-syscfg: register the clock device

Gabriel Fernandez (5):
      dt-bindings: arm: stm32: Add clock inputs to STM32MP2 SYSCFG
      soc: st: stm32mp2-syscfg: register the syscon regmap
      clk: stm32: Add STM32MP25 SYSCFG clock driver
      arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp23
      arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp25

 .../bindings/arm/stm32/st,stm32-syscon.yaml        |  28 ++++-
 arch/arm64/boot/dts/st/stm32mp231.dtsi             |   2 +
 arch/arm64/boot/dts/st/stm32mp235.dtsi             |   5 +
 arch/arm64/boot/dts/st/stm32mp251.dtsi             |   2 +
 arch/arm64/boot/dts/st/stm32mp255.dtsi             |   7 +-
 drivers/clk/stm32/Kconfig                          |  13 +++
 drivers/clk/stm32/Makefile                         |   1 +
 drivers/clk/stm32/clk-stm32mp25-syscfg.c           | 125 +++++++++++++++++++++
 drivers/soc/st/Kconfig                             |   5 +-
 drivers/soc/st/stm32mp2-syscfg.c                   |  57 +++++++++-
 10 files changed, 240 insertions(+), 5 deletions(-)
---
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
change-id: 20261103-ups_mp25_clk_syscfg-6a4224156431

Best regards,
-- 
Gabriel Fernandez <gabriel.fernandez@foss.st.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/6] dt-bindings: arm: stm32: Add clock inputs to STM32MP2 SYSCFG
  2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
@ 2026-11-18 11:59 ` Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap Gabriel Fernandez
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

The SYSCFG of the STM32MP23x and STM32MP25x SoCs is the provider of the
LTDC pixel clock, which it selects in its DISPLAYCLKCR register among
the LTDC kernel clock, the LVDS PHY pixel clock and the DSI PHY byte
lane clock.

Describe these inputs with the clocks and clock-names properties. The
LVDS and the DSI don't exist on STM32MP231/233 and STM32MP251/253, which
use the same SYSCFG compatibles as STM32MP235 and STM32MP255. So the
inputs are listed in the "ltdc", "lvds", "dsi" order, and the missing
ones are omitted at the end of the list.

The inputs are required, the LTDC kernel clock being always an input of
the mux. This doesn't break the users of existing devicetrees: no driver
registered the SYSCFG clock so far, and the clock driver doesn't need
these properties to probe.

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
---
 .../bindings/arm/stm32/st,stm32-syscon.yaml        | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml b/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml
index a559f8b03b84..e94d668d51e0 100644
--- a/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml
+++ b/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml
@@ -34,7 +34,12 @@ properties:
     maxItems: 1
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    maxItems: 3
+
+  clock-names:
+    minItems: 1
+    maxItems: 3
 
   "#clock-cells":
     const: 0
@@ -62,6 +67,8 @@ allOf:
             enum:
               - st,stm32mp157-syscfg
               - st,stm32f4-gcan
+              - st,stm32mp23-syscfg
+              - st,stm32mp25-syscfg
     then:
       required:
         - clocks
@@ -76,10 +83,26 @@ allOf:
               - st,stm32mp23-syscfg
               - st,stm32mp25-syscfg
     then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: LTDC kernel clock
+            - description: LVDS PHY pixel clock
+            - description: DSI PHY byte lane clock
+
+        clock-names:
+          minItems: 1
+          items:
+            - const: ltdc
+            - const: lvds
+            - const: dsi
+
       required:
         - "#address-cells"
         - "#clock-cells"
         - "#size-cells"
+        - clock-names
         - phy@2400
         - phy@2800
     else:
@@ -87,6 +110,9 @@ allOf:
         '#address-cells': false
         '#clock-cells': false
         '#size-cells': false
+        clocks:
+          maxItems: 1
+        clock-names: false
         phy@2400: false
         phy@2800: false
 

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap
  2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 1/6] dt-bindings: arm: stm32: Add clock inputs to STM32MP2 SYSCFG Gabriel Fernandez
@ 2026-11-18 11:59 ` Gabriel Fernandez
  2026-11-18 12:37   ` sashiko-bot
  2026-11-18 11:59 ` [PATCH v3 3/6] clk: stm32: Add STM32MP25 SYSCFG clock driver Gabriel Fernandez
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

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@foss.st.com>
---
 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@nabladev.com>");
 MODULE_DESCRIPTION("ST STM32MP2 SYSCFG driver");

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/6] clk: stm32: Add STM32MP25 SYSCFG clock driver
  2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 1/6] dt-bindings: arm: stm32: Add clock inputs to STM32MP2 SYSCFG Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap Gabriel Fernandez
@ 2026-11-18 11:59 ` Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 4/6] soc: st: stm32mp2-syscfg: register the clock device Gabriel Fernandez
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

On STM32MP23x and STM32MP25x, the LTDC pixel clock is selected in the
SYSCFG DISPLAYCLKCR register among the DSI PHY byte lane clock, the LVDS
PHY pixel clock (reset value) and the LTDC kernel clock, the latter
being the one needed by the RGB (DPI) output.

The SYSCFG node is described as the provider of this clock, but no
driver registers it, so the selection can't be changed from its reset
value and a display connected to the LTDC RGB output can't work.

Add a driver registering this clock as a mux. The SYSCFG node is bound
to the STM32MP2 SYSCFG driver, so this driver is an auxiliary driver,
probed from an auxiliary device which shares the SYSCFG node. The mux
parents are taken from the "clocks" property of the SYSCFG node, which
remains the clock provider.

Co-developed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
---
 drivers/clk/stm32/Kconfig                |  13 ++++
 drivers/clk/stm32/Makefile               |   1 +
 drivers/clk/stm32/clk-stm32mp25-syscfg.c | 125 +++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)

diff --git a/drivers/clk/stm32/Kconfig b/drivers/clk/stm32/Kconfig
index 5dbd75cde657..18289816f030 100644
--- a/drivers/clk/stm32/Kconfig
+++ b/drivers/clk/stm32/Kconfig
@@ -39,5 +39,18 @@ config COMMON_CLK_STM32MP257
 	help
 	  Support for stm32mp25x SoC family clocks.
 
+config COMMON_CLK_STM32MP25_SYSCFG
+	tristate "Clock driver for stm32mp25x SYSCFG clocks"
+	depends on COMMON_CLK_STM32MP257
+	depends on SOC_STM32MP2 || COMPILE_TEST
+	select AUXILIARY_BUS
+	select MFD_SYSCON
+	default COMMON_CLK_STM32MP257
+	help
+	  Support for the clocks provided by the stm32mp25x SYSCFG, i.e.
+	  the LTDC pixel clock source selection between the LTDC kernel
+	  clock (RGB output), the LVDS PHY pixel clock and the DSI byte
+	  lane clock.
+
 endif
 
diff --git a/drivers/clk/stm32/Makefile b/drivers/clk/stm32/Makefile
index e04727b59449..8088d172651f 100644
--- a/drivers/clk/stm32/Makefile
+++ b/drivers/clk/stm32/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_COMMON_CLK_STM32MP135)	+= clk-stm32mp13.o clk-stm32-core.o reset-st
 obj-$(CONFIG_COMMON_CLK_STM32MP157)	+= clk-stm32mp1.o reset-stm32.o
 obj-$(CONFIG_COMMON_CLK_STM32MP215)	+= clk-stm32mp21.o clk-stm32-core.o reset-stm32.o
 obj-$(CONFIG_COMMON_CLK_STM32MP257)	+= clk-stm32mp25.o clk-stm32-core.o reset-stm32.o
+obj-$(CONFIG_COMMON_CLK_STM32MP25_SYSCFG)	+= clk-stm32mp25-syscfg.o
diff --git a/drivers/clk/stm32/clk-stm32mp25-syscfg.c b/drivers/clk/stm32/clk-stm32mp25-syscfg.c
new file mode 100644
index 000000000000..41f40325a10f
--- /dev/null
+++ b/drivers/clk/stm32/clk-stm32mp25-syscfg.c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) STMicroelectronics 2026 - All Rights Reserved
+ * Author: Gabriel Fernandez <gabriel.fernandez@foss.st.com> for STMicroelectronics.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/err.h>
+#include <linux/limits.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <linux/regmap.h>
+
+#define SYSCFG_DISPLAYCLKCR		0x5000
+#define DISPLAYCLKCR_DPIVSLVDS		GENMASK(1, 0)
+
+/*
+ * The LTDC pixel clock source is selected in SYSCFG_DISPLAYCLKCR among
+ * the DSI byte lane clock, the LVDS PHY pixel clock (reset value) and
+ * the LTDC kernel clock, which is used with the RGB (DPI) output.
+ *
+ * The parents are listed in the DPIVSLVDS field order, while .index refers
+ * to the "clocks" property of the SYSCFG node, ordered "ltdc", "lvds", "dsi"
+ * so that the inputs missing on a SoC can be omitted at the end of the list.
+ */
+static const struct clk_parent_data clk_pix_ltdc_parents[] = {
+	{ .index = 2 },	/* dsi */
+	{ .index = 1 },	/* lvds */
+	{ .index = 0 },	/* ltdc */
+};
+
+struct stm32mp25_syscfg_mux {
+	struct clk_hw hw;
+	struct regmap *regmap;
+};
+
+static inline struct stm32mp25_syscfg_mux *to_syscfg_mux(struct clk_hw *hw)
+{
+	return container_of(hw, struct stm32mp25_syscfg_mux, hw);
+}
+
+static u8 stm32mp25_syscfg_mux_get_parent(struct clk_hw *hw)
+{
+	struct stm32mp25_syscfg_mux *mux = to_syscfg_mux(hw);
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(mux->regmap, SYSCFG_DISPLAYCLKCR, &val);
+	if (ret) {
+		pr_err("%s: failed to read the parent: %pe\n",
+		       clk_hw_get_name(hw), ERR_PTR(ret));
+		/* An out of range index leaves the clock orphan */
+		return U8_MAX;
+	}
+
+	return FIELD_GET(DISPLAYCLKCR_DPIVSLVDS, val);
+}
+
+static int stm32mp25_syscfg_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+	struct stm32mp25_syscfg_mux *mux = to_syscfg_mux(hw);
+
+	return regmap_update_bits(mux->regmap, SYSCFG_DISPLAYCLKCR,
+				  DISPLAYCLKCR_DPIVSLVDS,
+				  FIELD_PREP(DISPLAYCLKCR_DPIVSLVDS, index));
+}
+
+static const struct clk_ops stm32mp25_syscfg_mux_ops = {
+	.get_parent = stm32mp25_syscfg_mux_get_parent,
+	.set_parent = stm32mp25_syscfg_mux_set_parent,
+	.determine_rate = clk_hw_determine_rate_no_reparent,
+};
+
+static int stm32mp25_syscfg_clk_probe(struct auxiliary_device *adev,
+				      const struct auxiliary_device_id *id)
+{
+	struct stm32mp25_syscfg_mux *mux;
+	struct device *dev = &adev->dev;
+	struct clk_init_data init = { };
+	int ret;
+
+	mux = devm_kzalloc_obj(dev, *mux);
+	if (!mux)
+		return -ENOMEM;
+
+	/* The auxiliary device shares the node of the SYSCFG */
+	mux->regmap = syscon_node_to_regmap(dev->of_node);
+	if (IS_ERR(mux->regmap))
+		return dev_err_probe(dev, PTR_ERR(mux->regmap),
+				     "failed to get the SYSCFG regmap\n");
+
+	init.name = "clk_pix_ltdc";
+	init.ops = &stm32mp25_syscfg_mux_ops;
+	init.parent_data = clk_pix_ltdc_parents;
+	init.num_parents = ARRAY_SIZE(clk_pix_ltdc_parents);
+	init.flags = CLK_SET_RATE_PARENT;
+	mux->hw.init = &init;
+
+	ret = devm_clk_hw_register(dev, &mux->hw);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to register %s\n",
+				     init.name);
+
+	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &mux->hw);
+}
+
+static const struct auxiliary_device_id stm32mp25_syscfg_clk_ids[] = {
+	{ .name = "stm32mp2_syscfg.clk" },
+	{ }
+};
+MODULE_DEVICE_TABLE(auxiliary, stm32mp25_syscfg_clk_ids);
+
+static struct auxiliary_driver stm32mp25_syscfg_clk_driver = {
+	.probe = stm32mp25_syscfg_clk_probe,
+	.id_table = stm32mp25_syscfg_clk_ids,
+};
+module_auxiliary_driver(stm32mp25_syscfg_clk_driver);
+
+MODULE_AUTHOR("Gabriel Fernandez <gabriel.fernandez@foss.st.com>");
+MODULE_DESCRIPTION("STM32MP25 SYSCFG clock driver");
+MODULE_LICENSE("GPL");

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/6] soc: st: stm32mp2-syscfg: register the clock device
  2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
                   ` (2 preceding siblings ...)
  2026-11-18 11:59 ` [PATCH v3 3/6] clk: stm32: Add STM32MP25 SYSCFG clock driver Gabriel Fernandez
@ 2026-11-18 11:59 ` Gabriel Fernandez
  2026-11-18 12:13   ` sashiko-bot
  2026-11-18 11:59 ` [PATCH v3 5/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp23 Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 6/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp25 Gabriel Fernandez
  5 siblings, 1 reply; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

From: Dario Binacchi <dario.binacchi@amarulasolutions.com>

The STM32MP23x and STM32MP25x SYSCFG provides the LTDC pixel clock mux,
whose driver is an auxiliary driver since the SYSCFG node is bound to
this driver.

Create the auxiliary device for the clock driver.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
[gabriel.fernandez@foss.st.com: create the device on STM32MP23x too]
---
 drivers/soc/st/Kconfig           |  1 +
 drivers/soc/st/stm32mp2-syscfg.c | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/st/Kconfig b/drivers/soc/st/Kconfig
index db3ce8e8111f..c132a6a1334e 100644
--- a/drivers/soc/st/Kconfig
+++ b/drivers/soc/st/Kconfig
@@ -5,6 +5,7 @@ config SOC_STM32MP2
 	bool "STM32MP2 SoC family support"
 	depends on ARCH_STM32 || COMPILE_TEST
 	default ARCH_STM32 && ARM64
+	select AUXILIARY_BUS
 	select MFD_SYSCON
 	select REGMAP_MMIO
 	select SOC_BUS
diff --git a/drivers/soc/st/stm32mp2-syscfg.c b/drivers/soc/st/stm32mp2-syscfg.c
index 0d45fdef46b7..285561fb9f17 100644
--- a/drivers/soc/st/stm32mp2-syscfg.c
+++ b/drivers/soc/st/stm32mp2-syscfg.c
@@ -3,6 +3,7 @@
  * Copyright 2026 Marek Vasut
  */
 
+#include <linux/auxiliary_bus.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
@@ -51,7 +52,15 @@ static int stm32mp2_syscfg_probe(struct platform_device *pdev)
 	else if (ret)
 		return dev_err_probe(dev, ret, "failed to register the regmap\n");
 
-	return devm_of_platform_populate(dev);
+	ret = devm_of_platform_populate(dev);
+	if (ret)
+		return ret;
+
+	if (!devm_auxiliary_device_create(dev, "clk", NULL))
+		return dev_err_probe(dev, -ENODEV,
+				     "failed to register the clock device\n");
+
+	return 0;
 }
 
 static const struct of_device_id stm32mp2_syscfg_ids[] = {

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 5/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp23
  2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
                   ` (3 preceding siblings ...)
  2026-11-18 11:59 ` [PATCH v3 4/6] soc: st: stm32mp2-syscfg: register the clock device Gabriel Fernandez
@ 2026-11-18 11:59 ` Gabriel Fernandez
  2026-11-18 11:59 ` [PATCH v3 6/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp25 Gabriel Fernandez
  5 siblings, 0 replies; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

Describe the inputs of the LTDC pixel clock mux in the SYSCFG node,
which is the provider of the LTDC "ref" clock.

Only the LTDC kernel clock is available on STM32MP231; the LVDS and DSI
clocks are added on STM32MP235.

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 2 ++
 arch/arm64/boot/dts/st/stm32mp235.dtsi | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/st/stm32mp231.dtsi b/arch/arm64/boot/dts/st/stm32mp231.dtsi
index fefbf6f4f153..128b14ecd353 100644
--- a/arch/arm64/boot/dts/st/stm32mp231.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp231.dtsi
@@ -1121,6 +1121,8 @@ exti1: interrupt-controller@44220000 {
 		syscfg: syscon@44230000 {
 			compatible = "st,stm32mp23-syscfg", "syscon";
 			reg = <0x44230000 0x10000>;
+			clocks = <&rcc CK_KER_LTDC>;
+			clock-names = "ltdc";
 			#clock-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <1>;
diff --git a/arch/arm64/boot/dts/st/stm32mp235.dtsi b/arch/arm64/boot/dts/st/stm32mp235.dtsi
index 7a87c344a4fe..d974f979330a 100644
--- a/arch/arm64/boot/dts/st/stm32mp235.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp235.dtsi
@@ -32,3 +32,8 @@ vdec: vdec@480d0000 {
 		access-controllers = <&rifsc 89>;
 	};
 };
+
+&syscfg {
+	clocks = <&rcc CK_KER_LTDC>, <&lvds>, <&clk_dsi_txbyte>;
+	clock-names = "ltdc", "lvds", "dsi";
+};

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 6/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp25
  2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
                   ` (4 preceding siblings ...)
  2026-11-18 11:59 ` [PATCH v3 5/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp23 Gabriel Fernandez
@ 2026-11-18 11:59 ` Gabriel Fernandez
  5 siblings, 0 replies; 9+ messages in thread
From: Gabriel Fernandez @ 2026-11-18 11:59 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Maxime Coquelin,
	Alexandre Torgue, Christophe Roullier, patrick.delaunay,
	yannick.fertre
  Cc: Dario Binacchi, linux-clk, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, Gabriel Fernandez

Describe the inputs of the LTDC pixel clock mux in the SYSCFG node,
which is the provider of the LTDC "ref" clock.

Only the LTDC kernel clock is available on STM32MP251; the LVDS and DSI
clocks are added on STM32MP255.

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
---
 arch/arm64/boot/dts/st/stm32mp251.dtsi | 2 ++
 arch/arm64/boot/dts/st/stm32mp255.dtsi | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi b/arch/arm64/boot/dts/st/stm32mp251.dtsi
index dac3d2d23ff0..7a91c29309fe 100644
--- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
@@ -2076,6 +2076,8 @@ exti1: interrupt-controller@44220000 {
 		syscfg: syscon@44230000 {
 			compatible = "st,stm32mp25-syscfg", "syscon";
 			reg = <0x44230000 0x10000>;
+			clocks = <&rcc CK_KER_LTDC>;
+			clock-names = "ltdc";
 			#clock-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <1>;
diff --git a/arch/arm64/boot/dts/st/stm32mp255.dtsi b/arch/arm64/boot/dts/st/stm32mp255.dtsi
index 7a598f53a2a0..e9c8ed9882c9 100644
--- a/arch/arm64/boot/dts/st/stm32mp255.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp255.dtsi
@@ -40,4 +40,9 @@ venc: venc@480e0000 {
 		clocks = <&rcc CK_BUS_VENC>;
 		access-controllers = <&rifsc 90>;
 	};
-};
\ No newline at end of file
+};
+
+&syscfg {
+	clocks = <&rcc CK_KER_LTDC>, <&lvds>, <&clk_dsi_txbyte>;
+	clock-names = "ltdc", "lvds", "dsi";
+};

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 4/6] soc: st: stm32mp2-syscfg: register the clock device
  2026-11-18 11:59 ` [PATCH v3 4/6] soc: st: stm32mp2-syscfg: register the clock device Gabriel Fernandez
@ 2026-11-18 12:13   ` sashiko-bot
  0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-18 12:13 UTC (permalink / raw)
  To: Gabriel Fernandez; +Cc: linux-clk, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] soc: st: stm32mp2-syscfg: missing Signed-off-by trailer for
  patch handler
- [Medium] soc: st: stm32mp2-syscfg: dangling syscon regmap on
  stm32mp2_syscfg_probe() error
--

commit 21aab13c70f2bda74a29260c2c7a004a36470fe5
Author: Dario Binacchi <dario.binacchi@amarulasolutions.com>

> soc: st: stm32mp2-syscfg: register the clock device
>
> The STM32MP23x and STM32MP25x SYSCFG provides the LTDC pixel clock mux,
> whose driver is an auxiliary driver since the SYSCFG node is bound to
> this driver.
>
> Create the auxiliary device for the clock driver.
>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> [gabriel.fernandez@foss.st.com: create the device on STM32MP23x too]

[Severity: High]
Since Gabriel Fernandez modified and handled this patch in the delivery
path, a Signed-off-by trailer from Gabriel Fernandez is required after
the modification note to satisfy the Developer's Certificate of Origin
chain.

> diff --git a/drivers/soc/st/stm32mp2-syscfg.c b/drivers/soc/st/stm32mp2-syscfg.c
> index 0d45fdef46b73..285561fb9f17a 100644
> --- a/drivers/soc/st/stm32mp2-syscfg.c
> +++ b/drivers/soc/st/stm32mp2-syscfg.c
[ ... ]
> @@ -51,7 +52,15 @@ static int stm32mp2_syscfg_probe(struct platform_device *pdev)
>  	else if (ret)
>  		return dev_err_probe(dev, ret, "failed to register the regmap\n");
>  
> -	return devm_of_platform_populate(dev);
> +	ret = devm_of_platform_populate(dev);
> +	if (ret)
> +		return ret;
> +
> +	if (!devm_auxiliary_device_create(dev, "clk", NULL))
> +		return dev_err_probe(dev, -ENODEV,
> +				     "failed to register the clock device\n");
> +
> +	return 0;
>  }

[Severity: Medium]
Can a failure in devm_of_platform_populate() or
devm_auxiliary_device_create() leave a dangling regmap pointer in the
global syscon_list?

stm32mp2_syscfg_probe() allocates regmap with devm_regmap_init_mmio() and
publishes it to syscon_list via of_syscon_register_regmap(), which has no
unregistration helper.  If either of the later calls fails, devres
releases regmap and unmaps base while syscon_list retains the pointer,
causing a use-after-free on subsequent syscon regmap lookups.  Calling
of_syscon_register_regmap() last in stm32mp2_syscfg_probe() would avoid
publishing the regmap before fallible setup completes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-ups_mp25_clk_syscfg-v3-0-935de791a4ce@foss.st.com?part=4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap
  2026-11-18 11:59 ` [PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap Gabriel Fernandez
@ 2026-11-18 12:37   ` sashiko-bot
  0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-18 12:37 UTC (permalink / raw)
  To: Gabriel Fernandez; +Cc: linux-clk, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] soc: st: leak of ioremap and regmap on -EEXIST in
  stm32mp2_syscfg_probe()
- [Medium] soc: st: dangling regmap in syscon_list on
  stm32mp2_syscfg_probe() failure
- [Medium] soc: st: stm32mp2-syscfg: fw_devlink and initcall order let
  consumers create clock-attached syscon regmap first
--

commit 3074d10104a5aee141b2e91cda96d7c4ea358a2e
Author: Gabriel Fernandez <gabriel.fernandez@foss.st.com>

soc: st: stm32mp2-syscfg: register the syscon regmap

This commit creates an MMIO regmap in stm32mp2_syscfg_probe() and registers
it with the syscon core before populating subnodes so that syscon does not
attach the node's first clock to the regmap.

> diff --git a/drivers/soc/st/stm32mp2-syscfg.c b/drivers/soc/st/stm32mp2-syscfg.c
> index 770321a4a6f71..0d45fdef46b73 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");

[Severity: Medium]
Does the -EEXIST path leave the newly mapped base and regmap allocated on
dev?

When a consumer has already called syscon_node_to_regmap(),
stm32mp2_syscfg_probe() logs a warning and returns 0 via
devm_of_platform_populate(dev) without releasing regmap or unmapping base.
Because the driver is built-in with suppress_bind_attrs = true, the
duplicate 64 KiB mapping, regmap, and debugfs entry remain allocated for
the lifetime of the system, and dev_get_regmap(dev, NULL) points to the
unused regmap instead of the active one in syscon_list.

> +	else if (ret)
> +		return dev_err_probe(dev, ret, "failed to register the regmap\n");
> +
> +	return devm_of_platform_populate(dev);

[Severity: Medium]
If devm_of_platform_populate(dev) fails after of_syscon_register_regmap()
has succeeded, can syscon_list be left with a dangling regmap pointer?

There is no API to unregister a regmap from syscon_list, while a negative
return from stm32mp2_syscfg_probe() triggers devres_release_all(dev),
freeing regmap and unmapping base.  Any later syscon lookup for this node
then returns the freed regmap pointer and causes a use-after-free.

>  }
>  
>  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);

[Severity: Medium]
Will consumers still create the clock-attached syscon regmap before
stm32mp2_syscfg_probe() runs?

Once the SYSCFG DT node lists clocks = <&rcc CK_KER_LTDC>, <&lvds>,
<&clk_dsi_txbyte>, fw_devlink creates supplier links from rcc (and lvds
when enabled) to syscfg.  Because rcc depends on scmi_clk, it is not bound
when device_initcall runs through drivers/phy/, drivers/pci/, and
drivers/soc/.  Built-in consumers such as phy-stm32-combophy and
pcie-stm32 defer on rcc ahead of syscfg, have no fw_devlink dependency on
syscfg (they look it up via syscon_regmap_lookup_by_compatible() or vendor
properties), and probe first once rcc binds.  Because the syscfg node
retains "syscon" in its compatible list, syscon_node_to_regmap() creates
the generic regmap with CK_KER_LTDC attached instead of returning
-EPROBE_DEFER:

drivers/mfd/syscon.c:syscon_node_to_regmap() {
	return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true);
}

As a result, stm32mp2_syscfg_probe() hits -EEXIST and CK_KER_LTDC stays
prepared and toggled on every SYSCFG access; in addition, if lvds is
enabled without a consumer cycle (for example when CONFIG_DRM_STM_LVDS is
disabled or modular), fw_devlink blocks stm32mp2_syscfg_probe() and delays
populating the USB2 PHY child nodes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-ups_mp25_clk_syscfg-v3-0-935de791a4ce@foss.st.com?part=2

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-18 12:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 11:59 [PATCH v3 0/6] clk: stm32: Add the STM32MP2 SYSCFG LTDC pixel clock mux Gabriel Fernandez
2026-11-18 11:59 ` [PATCH v3 1/6] dt-bindings: arm: stm32: Add clock inputs to STM32MP2 SYSCFG Gabriel Fernandez
2026-11-18 11:59 ` [PATCH v3 2/6] soc: st: stm32mp2-syscfg: register the syscon regmap Gabriel Fernandez
2026-11-18 12:37   ` sashiko-bot
2026-11-18 11:59 ` [PATCH v3 3/6] clk: stm32: Add STM32MP25 SYSCFG clock driver Gabriel Fernandez
2026-11-18 11:59 ` [PATCH v3 4/6] soc: st: stm32mp2-syscfg: register the clock device Gabriel Fernandez
2026-11-18 12:13   ` sashiko-bot
2026-11-18 11:59 ` [PATCH v3 5/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp23 Gabriel Fernandez
2026-11-18 11:59 ` [PATCH v3 6/6] arm64: dts: st: add LTDC pixel clock mux inputs on stm32mp25 Gabriel Fernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox