[RFC,2/4] clk: stm32: add STM32MP25 SYSCFG clock driver
Commit Message
On STM32MP25 the LTDC pixel clock is selected in the SYSCFG
DISPLAYCLKCR register among the DSI 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 already provides this clock ("#clock-cells = <0>"),
referenced by the LTDC as "ref" clock, but no driver registers it, so
the selection is stuck at the 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
already bound to the STM32MP2 SYSCFG driver, so the clock driver is
bound to an auxiliary device created by the latter, which shares the
SYSCFG node and regmap.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
drivers/clk/stm32/Kconfig | 12 +++
drivers/clk/stm32/Makefile | 1 +
drivers/clk/stm32/clk-stm32mp25-syscfg.c | 111 +++++++++++++++++++++++
3 files changed, 124 insertions(+)
create mode 100644 drivers/clk/stm32/clk-stm32mp25-syscfg.c
@@ -39,5 +39,17 @@ 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
+ 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
@@ -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
new file mode 100644
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * STM32MP25 SYSCFG clocks
+ *
+ * Copyright (C) 2026 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/err.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.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.
+ */
+static const char * const clk_pix_ltdc_parents[] = {
+ "txbyteclk", "clk_pix_lvds", "ck_ker_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;
+
+ regmap_read(mux->regmap, SYSCFG_DISPLAYCLKCR, &val);
+
+ 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 device *dev = &adev->dev;
+ struct clk_init_data init = { };
+ struct stm32mp25_syscfg_mux *mux;
+ int ret;
+
+ mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
+ if (!mux)
+ return -ENOMEM;
+
+ 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_names = clk_pix_ltdc_parents;
+ init.num_parents = ARRAY_SIZE(clk_pix_ltdc_parents);
+ init.flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT;
+ 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("Dario Binacchi <dario.binacchi@amarulasolutions.com>");
+MODULE_DESCRIPTION("STM32MP25 SYSCFG clock driver");
+MODULE_LICENSE("GPL");