* [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers
@ 2026-11-24 4:41 Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs Joseph Telaak via B4 Relay
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Joseph Telaak, Conor Dooley
The Siflower SF19A2890, a MIPS SoC for home routers, has a clock manager
with its PLLs and the muxes and dividers that feed the CPU, the buses
and the peripherals, and for each peripheral block a small clock and
reset manager with its gates, its resets and a bus output enable. This
series adds bindings and drivers for both. The peripheral managers'
resets have a reset driver of their own, which binds to an auxiliary
device that their clock driver creates.
The drivers are based on Chuanhong Guo's, from his SF19A2890 branch [1].
The peripheral managers' binding is rewritten: Chuanhong's described
every block with one compatible and its bit layout in properties
(siflower,valid-gates, siflower,reset-masks and so on); here each block
has its own compatible and the layouts are tables in the drivers. Clock
N of a block is its input clock N, gated.
Following Conor's review of Chuanhong's SF21 clock binding, the header
has no count at its end.
The GIC timer runs from the CPU clock and probes before the platform
bus, so the clock manager registers that clock and its PLLs from
CLK_OF_DECLARE_DRIVER and the other clocks from a platform driver.
Patch 1 adds MACH_SIFLOWER_MIPS, which the drivers depend on. It is
patch 2 of the MIPS series [2], which will carry the same patch in its
next version, so that whichever of the clk and MIPS trees takes it first
can put it on an immutable branch for the other. Thomas, would you ack
it for that?
Tested on a GL.iNet GL-SFT1200: the rates in clk_summary match the
vendor firmware's (CMN PLL 1.5 GHz, buses 300, 300 and 375 MHz, PBUS
100 MHz, UART 125 MHz, GMAC reference 125 MHz, USB PHY reference
50 MHz), and the CPU clock reads 800 MHz, the rate the GIC timer was
checked at against a reference clock with the MIPS series; the console,
DDR and buses survive the unused clock sweep; the UART, SPI NAND, I2C,
GPIO, GMAC, USB and watchdog drivers probe with these clocks and resets;
and the I2C controller works again after an unbind and bind, which
cycles its reset. v4 was booted again on the same board: the GIC timer
runs from the early CPU clock (0.02 s off the host over 292 s), the
other clocks come from the platform driver at the same rates, with no
orphans or deferred devices, and the same drivers probe.
v5 was booted on the same board too: each of the twelve peripheral
clock and reset managers binds and gets a reset device of its own, which
the new reset driver serves, at the same rates and with no orphans or
deferred devices, and an I2C unbind and bind asserts and releases its
reset bit.
[1] https://github.com/981213/linux/commits/siflower-7.1
[2] https://patch.msgid.link/20261111-sf19a2890-mips-v2-0-36730fa4f5a6@telaak.dev
---
Changes in v5:
- Patches 2 to 5 were patches 1 to 4 in v4.
- Patch 1 (new): add MACH_SIFLOWER_MIPS, patch 2 of the MIPS series
without its MAINTAINERS line, for an immutable branch between the clk
and MIPS trees (Brian, Sashiko).
- Patches 3 and 5: make myself the author, with Chuanhong's
Co-developed-by and Signed-off-by and a Link to his commit, in place of
the lists of my changes (Brian).
- Patch 3: hand out each clock registered at probe as soon as it is
registered, and leave the orphans to the clock framework (Brian,
Sashiko).
- Patch 5: describe the driver at a higher level in the commit message
(Brian).
- Patch 5: move the resets to a reset driver, patch 6, which binds to an
auxiliary device that the clock driver creates; drop Philipp's
Reviewed-by, since the reset code moved (Brian).
- Link to v4: https://patch.msgid.link/20261122-sf19a2890-sysm-v4-0-bbfe1c495e2e@telaak.dev
Changes in v4:
- Patch 2: register only the CPU clock and the PLLs it may run from
early, from CLK_OF_DECLARE_DRIVER, and the other clocks from a
platform driver (Brian).
- Patch 2: compute the PLL rate with div_u64() on the parent rate,
without first dividing it by refdiv (Brian).
- Patch 2: map the mux values with a table and clk_mux_val_to_index()
and clk_mux_index_to_val(); a value outside the table now leaves the
clock an orphan instead of reading as the 40 MHz oscillator (Brian).
- Patch 2: change only the source field when setting a mux parent,
keeping MUXDIV_USE_NCO (Brian).
- Patch 2: drop CLK_SET_RATE_PARENT from the CPU clock, which had no
effect: the PLLs cannot change rate (Brian).
- Patch 2: join lines that fit and add blank lines (Brian).
- Link to v3: https://patch.msgid.link/20261116-sf19a2890-sysm-v3-0-b07bc7833a87@telaak.dev
Changes in v3:
- Patches 1 and 2: name the NPU clock CLK_MUXDIV_NPU_PE, without the _CLK
suffix that no other clock has (Brian).
- Patch 3: add Conor's Ack.
- Patch 4: take the spinlock with guard(spinlock_irqsave) (Philipp).
- Patch 4: explain each multi-bit reset group in the commit message, not
just the GMAC's (Philipp).
- Patch 4: add Philipp's Reviewed-by.
- Link to v2: https://patch.msgid.link/20261111-sf19a2890-sysm-v2-0-d2fcb723e4f1@telaak.dev
Changes in v2:
- Write my notes on Chuanhong's patches as lists, with Co-developed-by.
- Use GPL-2.0-only, not the deprecated GPL-2.0 identifier, in the clock
header's SPDX line.
- Add a MAINTAINERS entry for the drivers, their bindings and the
headers, with an F: line per driver, since drivers/clk/siflower/ will
also hold the SF21 drivers.
- Include <linux/device-id/of.h> instead of <linux/mod_devicetable.h>
(Uwe).
- Word the error messages the same way, and use the current SPDX
identifiers in the new files.
- Explain in the commit message why some resets cover more than one bit
(Philipp, Chuanhong).
- Patch 1: add Conor's Ack.
- Patch 2: with the PLL's fractional modulator on, scale the fraction by
the reference rate, not by the integer VCO rate; and reject a rate of 0
in the mux dividers instead of dividing by it.
- Patch 3: add include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h,
naming the clocks and resets of each manager, instead of listing the
resets in the description; patch 4 indexes its tables by it (Conor).
- Patch 4: no comma after the match table's sentinel (Uwe).
- Link to v1: https://patch.msgid.link/20261104-sf19a2890-sysm-v1-0-a4fac07df823@telaak.dev
---
Chuanhong Guo (1):
MIPS: Add support for Siflower MIPS SoCs
Joseph Telaak (5):
dt-bindings: clock: Add Siflower SF19A2890 clock manager
clk: siflower: Add SF19A2890 clock manager driver
dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers
clk: siflower: Add SF19A2890 peripheral clock driver
reset: Add Siflower SF19A2890 peripheral reset driver
.../bindings/clock/siflower,sf19a2890-clk.yaml | 57 +++
.../clock/siflower,sf19a2890-periph-crm.yaml | 166 +++++++
MAINTAINERS | 12 +
arch/mips/Kconfig | 32 ++
arch/mips/generic/Platform | 1 +
arch/mips/include/asm/mach-siflower/kmalloc.h | 9 +
drivers/clk/Kconfig | 1 +
drivers/clk/Makefile | 1 +
drivers/clk/siflower/Kconfig | 23 +
drivers/clk/siflower/Makefile | 3 +
drivers/clk/siflower/clk-sf19a2890-periphcrm.c | 306 +++++++++++++
drivers/clk/siflower/clk-sf19a2890.c | 494 +++++++++++++++++++++
drivers/reset/Kconfig | 11 +
drivers/reset/Makefile | 1 +
drivers/reset/reset-sf19a2890-periphcrm.c | 194 ++++++++
include/dt-bindings/clock/siflower,sf19a2890-clk.h | 27 ++
.../clock/siflower,sf19a2890-periph-crm.h | 87 ++++
17 files changed, 1425 insertions(+)
---
base-commit: fc1f8f0ceb3b949b58c2f7819976644f5cf84249
change-id: 20261102-sf19a2890-sysm-ac1fbcb21dd5
Best regards,
--
Joseph Telaak <joseph@telaak.dev>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
@ 2026-11-24 4:41 ` Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 2/6] dt-bindings: clock: Add Siflower SF19A2890 clock manager Joseph Telaak via B4 Relay
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Joseph Telaak
From: Chuanhong Guo <gch981213@gmail.com>
Siflower MIPS SoCs like SF19A2890 use a dual-core MIPS InterAptiv
processor, built-in GMAC, USB, dual-band WiFi and various other
peripherals.
Notably, they use some ARM PLxxx peripherals, and ARM_AMBA is
selected for the drivers.
Most devices on the market with this chip come with 64M or less
DRAM. A kmalloc.h with malloc alignment override is added to
conserve memory, and a MACH_SIFLOWER_MIPS is created with reduced
features instead of using the generic kernel.
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
[Joseph Telaak:
- rebase on v7.4-rc1 and use the "MIPS:" prefix
- longer Kconfig help
- commit message grammar and paragraphs]
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
arch/mips/Kconfig | 32 +++++++++++++++++++++++++++
arch/mips/generic/Platform | 1 +
arch/mips/include/asm/mach-siflower/kmalloc.h | 9 ++++++++
3 files changed, 42 insertions(+)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ed17c9b1624c..e10145edeb53 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -937,6 +937,38 @@ config SIBYTE_BIGSUR
select ZONE_DMA32 if 64BIT
select SWIOTLB if ARCH_DMA_ADDR_T_64BIT && PCI
+config MACH_SIFLOWER_MIPS
+ bool "Siflower MIPS SoCs"
+ select MIPS_GENERIC
+ select MACH_GENERIC_CORE
+ select ARM_AMBA
+ select BOOT_RAW
+ select CEVT_R4K
+ select CLKSRC_MIPS_GIC
+ select COMMON_CLK
+ select CPU_MIPSR2_IRQ_EI
+ select CPU_MIPSR2_IRQ_VI
+ select CSRC_R4K
+ select DMA_NONCOHERENT
+ select IRQ_MIPS_CPU
+ select MIPS_CPU_SCACHE
+ select MIPS_GIC
+ select MIPS_L1_CACHE_SHIFT_5
+ select NO_EXCEPT_FILL
+ select SMP_UP if SMP
+ select SYS_HAS_CPU_MIPS32_R2
+ select SYS_SUPPORTS_32BIT_KERNEL
+ select SYS_SUPPORTS_LITTLE_ENDIAN
+ select SYS_SUPPORTS_MIPS16
+ select SYS_SUPPORTS_MIPS_CPS
+ select SYS_SUPPORTS_MULTITHREADING
+ select USE_OF
+ help
+ Select this to build a kernel which supports SoCs from Siflower
+ with MIPS InterAptiv cores, like Siflower SF19A2890. These have
+ ARM PrimeCell peripherals, so ARM_AMBA is selected, and 32-byte
+ cache lines, which allows a smaller kmalloc alignment.
+
config SNI_RM
bool "SNI RM200/300/400"
select ARC_MEMORY
diff --git a/arch/mips/generic/Platform b/arch/mips/generic/Platform
index 0c03623f3897..c09a8484db9b 100644
--- a/arch/mips/generic/Platform
+++ b/arch/mips/generic/Platform
@@ -10,6 +10,7 @@
# Note: order matters, keep the asm/mach-generic include last.
cflags-$(CONFIG_MACH_INGENIC_SOC) += -I$(srctree)/arch/mips/include/asm/mach-ingenic
+cflags-$(CONFIG_MACH_SIFLOWER_MIPS) += -I$(srctree)/arch/mips/include/asm/mach-siflower
cflags-$(CONFIG_MIPS_GENERIC) += -I$(srctree)/arch/mips/include/asm/mach-generic
load-$(CONFIG_MIPS_GENERIC) += 0xffffffff80100000
diff --git a/arch/mips/include/asm/mach-siflower/kmalloc.h b/arch/mips/include/asm/mach-siflower/kmalloc.h
new file mode 100644
index 000000000000..0887ae3575d7
--- /dev/null
+++ b/arch/mips/include/asm/mach-siflower/kmalloc.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_MACH_SIFLOWER_KMALLOC_H
+#define __ASM_MACH_SIFLOWER_KMALLOC_H
+
+#ifdef CONFIG_DMA_NONCOHERENT
+#define ARCH_DMA_MINALIGN 32
+#endif
+
+#endif /* __ASM_MACH_SIFLOWER_KMALLOC_H */
--
Git-155)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 2/6] dt-bindings: clock: Add Siflower SF19A2890 clock manager
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs Joseph Telaak via B4 Relay
@ 2026-11-24 4:41 ` Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver Joseph Telaak via B4 Relay
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Conor Dooley, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
The clock manager of the Siflower SF19A2890 holds the SoC's PLLs and
the muxes and dividers that derive the bus, CPU and peripheral clocks
from them. The peripherals' own gates and resets are in separate
blocks.
The header is Chuanhong Guo's, from his SF19A2890 branch, and keeps his
license. It drops the count at its end, and names the NPU clock
CLK_MUXDIV_NPU_PE, without the _CLK suffix that no other clock has.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
.../bindings/clock/siflower,sf19a2890-clk.yaml | 57 ++++++++++++++++++++++
MAINTAINERS | 7 +++
include/dt-bindings/clock/siflower,sf19a2890-clk.h | 27 ++++++++++
3 files changed, 91 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml b/Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
new file mode 100644
index 000000000000..9b72f14c2bd9
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/siflower,sf19a2890-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Siflower SF19A2890 clock manager
+
+maintainers:
+ - Joseph Telaak <joseph@telaak.dev>
+
+description: |
+ The clock manager of the Siflower SF19A2890 holds the SoC's three PLLs
+ (CPU, DDR and common) and the clock muxes with dividers that derive the
+ bus, CPU and peripheral clocks from them. The peripherals' own clock
+ gates and resets are in separate peripheral clock and reset managers.
+
+ The clocks are defined in include/dt-bindings/clock/siflower,sf19a2890-clk.h.
+
+properties:
+ compatible:
+ const: siflower,sf19a2890-clk
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: 12 MHz oscillator
+ - description: 40 MHz oscillator
+
+ clock-names:
+ items:
+ - const: osc12m
+ - const: osc40m
+
+ "#clock-cells":
+ const: 1
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ clock-controller@19e01000 {
+ compatible = "siflower,sf19a2890-clk";
+ reg = <0x19e01000 0x800>;
+ clocks = <&osc12m>, <&osc40m>;
+ clock-names = "osc12m", "osc40m";
+ #clock-cells = <1>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..ce8d0596939c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25698,6 +25698,13 @@ N: sifive
K: fu[57]40
K: [^@]sifive
+SIFLOWER SF19A2890 CLOCK DRIVERS
+M: Joseph Telaak <joseph@telaak.dev>
+L: linux-clk@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
+F: include/dt-bindings/clock/siflower,sf19a2890-clk.h
+
SILEAD TOUCHSCREEN DRIVER
M: Hans de Goede <hansg@kernel.org>
L: linux-input@vger.kernel.org
diff --git a/include/dt-bindings/clock/siflower,sf19a2890-clk.h b/include/dt-bindings/clock/siflower,sf19a2890-clk.h
new file mode 100644
index 000000000000..94bbebd0c1cc
--- /dev/null
+++ b/include/dt-bindings/clock/siflower,sf19a2890-clk.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+#ifndef __DT_BINDINGS_CLOCK_SIFLOWER_SF19A2890_CLK_H
+#define __DT_BINDINGS_CLOCK_SIFLOWER_SF19A2890_CLK_H
+
+#define CLK_PLL_CPU 0
+#define CLK_PLL_DDR 1
+#define CLK_PLL_CMN 2
+#define CLK_MUXDIV_BUS1 3
+#define CLK_MUXDIV_BUS2 4
+#define CLK_MUXDIV_BUS3 5
+#define CLK_MUXDIV_CPU 6
+#define CLK_MUXDIV_PBUS 7
+#define CLK_MUXDIV_MEM_PHY 8
+#define CLK_MUXDIV_UART 9
+#define CLK_MUXDIV_ETH_REF 10
+#define CLK_MUXDIV_ETH_BYP_REF 11
+#define CLK_MUXDIV_ETH_TSU 12
+#define CLK_MUXDIV_GMAC_BYP_REF 13
+#define CLK_MUXDIV_M6250_0 14
+#define CLK_MUXDIV_M6250_1 15
+#define CLK_MUXDIV_WLAN24_PLF 16
+#define CLK_MUXDIV_WLAN5_PLF 17
+#define CLK_MUXDIV_USBPHY_REF 18
+#define CLK_MUXDIV_TCLK 19
+#define CLK_MUXDIV_NPU_PE 20
+
+#endif /* __DT_BINDINGS_CLOCK_SIFLOWER_SF19A2890_CLK_H */
--
Git-155)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 2/6] dt-bindings: clock: Add Siflower SF19A2890 clock manager Joseph Telaak via B4 Relay
@ 2026-11-24 4:41 ` Joseph Telaak via B4 Relay
2026-11-24 4:58 ` sashiko-bot
2026-11-24 4:41 ` [PATCH v5 4/6] dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers Joseph Telaak via B4 Relay
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
Add a driver for the clock manager of the Siflower SF19A2890: the CPU,
DDR and common PLLs, and the muxes with dividers that derive the bus,
CPU and peripheral clocks from them. The GIC timer probes before the
platform bus and needs the CPU clock, so the driver registers that clock
and its PLLs early, from CLK_OF_DECLARE_DRIVER, and the other clocks from
a platform driver.
Based on the driver in Chuanhong Guo's SF19A2890 branch.
Link: https://github.com/981213/linux/commit/0466d6303c25
Co-developed-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
MAINTAINERS | 1 +
drivers/clk/Kconfig | 1 +
drivers/clk/Makefile | 1 +
drivers/clk/siflower/Kconfig | 11 +
drivers/clk/siflower/Makefile | 2 +
drivers/clk/siflower/clk-sf19a2890.c | 494 +++++++++++++++++++++++++++++++++++
6 files changed, 510 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index ce8d0596939c..de087d1c255d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25703,6 +25703,7 @@ M: Joseph Telaak <joseph@telaak.dev>
L: linux-clk@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
+F: drivers/clk/siflower/clk-sf19a2890.c
F: include/dt-bindings/clock/siflower,sf19a2890-clk.h
SILEAD TOUCHSCREEN DRIVER
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 37a8e35d4178..8e73490cb702 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -536,6 +536,7 @@ source "drivers/clk/renesas/Kconfig"
source "drivers/clk/rockchip/Kconfig"
source "drivers/clk/samsung/Kconfig"
source "drivers/clk/sifive/Kconfig"
+source "drivers/clk/siflower/Kconfig"
source "drivers/clk/socfpga/Kconfig"
source "drivers/clk/sophgo/Kconfig"
source "drivers/clk/spacemit/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 52d138d4ffc8..d2f07584783e 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -160,6 +160,7 @@ obj-y += renesas/
obj-$(CONFIG_COMMON_CLK_ROCKCHIP) += rockchip/
obj-$(CONFIG_COMMON_CLK_SAMSUNG) += samsung/
obj-$(CONFIG_CLK_SIFIVE) += sifive/
+obj-y += siflower/
obj-y += socfpga/
obj-y += sophgo/
obj-y += spacemit/
diff --git a/drivers/clk/siflower/Kconfig b/drivers/clk/siflower/Kconfig
new file mode 100644
index 000000000000..ad1b04b4bb9b
--- /dev/null
+++ b/drivers/clk/siflower/Kconfig
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config CLK_SF19A2890
+ bool "Clock driver for Siflower SF19A2890"
+ depends on MACH_SIFLOWER_MIPS || COMPILE_TEST
+ default MACH_SIFLOWER_MIPS
+ help
+ Supports the clock manager of the Siflower SF19A2890: its PLLs
+ and the muxes and dividers that feed the CPU, the buses and the
+ peripherals. The GIC timer runs from the CPU clock, so a kernel
+ for this SoC needs it built in.
diff --git a/drivers/clk/siflower/Makefile b/drivers/clk/siflower/Makefile
new file mode 100644
index 000000000000..3f4d689f7d9b
--- /dev/null
+++ b/drivers/clk/siflower/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_CLK_SF19A2890) += clk-sf19a2890.o
diff --git a/drivers/clk/siflower/clk-sf19a2890.c b/drivers/clk/siflower/clk-sf19a2890.c
new file mode 100644
index 000000000000..3ccb768331ad
--- /dev/null
+++ b/drivers/clk/siflower/clk-sf19a2890.c
@@ -0,0 +1,494 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) "sf19a2890-clk: " fmt
+
+#include <linux/bitfield.h>
+#include <linux/clk-provider.h>
+#include <linux/device-id/of.h>
+#include <linux/io.h>
+#include <linux/math64.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <dt-bindings/clock/siflower,sf19a2890-clk.h>
+
+#define CLK_SF19A2890_NR_CLKS (CLK_MUXDIV_NPU_PE + 1)
+
+#define REG_PLL_BASE 0x0
+#define REG_PLL_PD 0x0
+#define PLL_PD BIT(0)
+#define PLL_PD_VCO BIT(1)
+#define PLL_PD_POSTDIV BIT(2)
+#define PLL_PD_4PHASE BIT(3)
+#define PLL_PD_DAC BIT(4)
+#define PLL_PD_DSM BIT(5)
+
+/*
+ * PLL_PARAM is a 48-bit value put into 6 registers, 8-bit per register:
+ * REFDIV = PLL_PARAM[47:42]
+ * POSTDIV2 = PLL_PARAM[41:39]
+ * POSTDIV1 = PLL_PARAM[38:36]
+ * FRAC = PLL_PARAM[35:12]
+ * FBDIV = PLL_PARAM[11:0]
+ */
+
+#define REG_PLL_PARAM(_x) (0x4 + (_x) * 4)
+#define PLL_REFDIV_HI 47
+#define PLL_REFDIV_LO 42
+#define PLL_POSTDIV2_HI 41
+#define PLL_POSTDIV2_LO 39
+#define PLL_POSTDIV1_HI 38
+#define PLL_POSTDIV1_LO 36
+#define PLL_FRAC_HI 35
+#define PLL_FRAC_LO 12
+#define PLL_FRAC_BITS (PLL_FRAC_HI - PLL_FRAC_LO + 1)
+#define PLL_FBDIV_HI 11
+#define PLL_FBDIV_LO 0
+
+#define REG_PLL_CFG 0x1c
+#define PLL_CFG_BYPASS BIT(0)
+#define PLL_CFG_SRC GENMASK(2, 1)
+#define PLL_CFG_OCLK_SEL BIT(3)
+#define PLL_CFG_OCLK_GATE BIT(4)
+#define PLL_CFG_LOAD_DIVS BIT(5)
+
+#define REG_PLL_LOCK 0x20
+
+/*
+ * Read-only register indicating the value of the hardware clock source
+ * override pin. When the first bit of this register is set, PLL clock
+ * source is forced to the 40M oscillator regardless of PLL_CFG_SRC
+ * value.
+ */
+#define REG_PLL_SRC_OVERRIDE 0x24
+
+struct sf_clk_common {
+ void __iomem *base;
+ struct clk_hw hw;
+};
+
+struct sf19a2890_clk {
+ struct sf_clk_common common;
+ u32 offset;
+};
+
+#define SF_CLK_COMMON(_name, _parents, _op, _flags) \
+ { \
+ .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, _parents, _op, \
+ _flags), \
+ }
+
+static inline struct sf_clk_common *hw_to_sf_clk_common(struct clk_hw *hw)
+{
+ return container_of(hw, struct sf_clk_common, hw);
+}
+
+static inline struct sf19a2890_clk *cmn_to_clk(struct sf_clk_common *cmn_priv)
+{
+ return container_of(cmn_priv, struct sf19a2890_clk, common);
+}
+
+static inline u32 sf_readl(struct sf_clk_common *priv, u32 reg)
+{
+ return readl(priv->base + reg);
+}
+
+static inline void sf_writel(struct sf_clk_common *priv, u32 reg, u32 val)
+{
+ writel(val, priv->base + reg);
+}
+
+static u32 sf_pll_param_get(struct sf19a2890_clk *priv, u32 hi, u32 lo)
+{
+ struct sf_clk_common *cmn = &priv->common;
+ u32 ret = 0;
+ int reg_hi = hi / 8;
+ int reg_lo = lo / 8;
+ u32 reg_hi_pos = hi % 8;
+ u32 reg_lo_pos = lo % 8;
+ int i;
+
+ if (reg_hi == reg_lo) {
+ u32 mask = (BIT(reg_hi_pos - reg_lo_pos + 1)) - 1;
+ u32 reg_val = sf_readl(cmn, priv->offset + REG_PLL_PARAM(reg_hi));
+
+ return (reg_val >> reg_lo_pos) & mask;
+ }
+
+ ret = sf_readl(cmn, priv->offset + REG_PLL_PARAM(reg_hi)) & (BIT(reg_hi_pos + 1) - 1);
+ for (i = reg_hi - 1; i > reg_lo; i--)
+ ret = (ret << 8) | sf_readl(cmn, priv->offset + REG_PLL_PARAM(i));
+ ret = (ret << (8 - reg_lo_pos)) |
+ (sf_readl(cmn, priv->offset + REG_PLL_PARAM(reg_lo)) >> reg_lo_pos);
+
+ return ret;
+}
+
+static unsigned long sf19a28_pll_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+ u32 refdiv = sf_pll_param_get(priv, PLL_REFDIV_HI, PLL_REFDIV_LO);
+ u32 fbdiv = sf_pll_param_get(priv, PLL_FBDIV_HI, PLL_FBDIV_LO);
+ u32 postdiv1 = sf_pll_param_get(priv, PLL_POSTDIV1_HI, PLL_POSTDIV1_LO);
+ u32 postdiv2 = sf_pll_param_get(priv, PLL_POSTDIV2_HI, PLL_POSTDIV2_LO);
+ u32 pll_pd = sf_readl(cmn_priv, priv->offset + REG_PLL_PD);
+ u64 rate;
+ u32 frac;
+
+ if (!refdiv || !postdiv1 || !postdiv2)
+ return 0;
+
+ rate = div_u64((u64)parent_rate * fbdiv, refdiv);
+
+ /* With the DSM on, the VCO runs at parent / refdiv * (fbdiv + frac / 2^24) */
+ if (!(pll_pd & PLL_PD_DSM)) {
+ frac = sf_pll_param_get(priv, PLL_FRAC_HI, PLL_FRAC_LO);
+ rate += div_u64((u64)parent_rate * frac, refdiv) >> PLL_FRAC_BITS;
+ }
+
+ return div_u64(rate, postdiv1 * postdiv2);
+}
+
+static u8 sf19a28_pll_get_parent(struct clk_hw *hw)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+ u32 cfg;
+
+ if (sf_readl(cmn_priv, priv->offset + REG_PLL_SRC_OVERRIDE))
+ return 1;
+
+ cfg = sf_readl(cmn_priv, priv->offset + REG_PLL_CFG);
+
+ return (FIELD_GET(PLL_CFG_SRC, cfg) == 1);
+}
+
+static const struct clk_ops sf19a28_pll_ops = {
+ .recalc_rate = sf19a28_pll_recalc_rate,
+ .get_parent = sf19a28_pll_get_parent,
+};
+
+static const struct clk_parent_data clk_pll_parents[] = {
+ { .fw_name = "osc12m" },
+ { .fw_name = "osc40m" },
+};
+
+#define SF19A28_PLL(_name, _offset, _flags) \
+ struct sf19a2890_clk _name = { \
+ .common = SF_CLK_COMMON(#_name, clk_pll_parents, \
+ &sf19a28_pll_ops, _flags), \
+ .offset = REG_PLL_BASE + (_offset), \
+ }
+
+static SF19A28_PLL(pll_cpu, 0x0, 0);
+static SF19A28_PLL(pll_ddr, 0x40, 0);
+static SF19A28_PLL(pll_cmn, 0x80, 0);
+
+#define REG_MUXDIV_BASE 0x400
+#define REG_MUXDIV_CFG 0x0
+#define MUXDIV_USE_NCO BIT(3)
+#define MUXDIV_SRC_SEL GENMASK(2, 0)
+#define REG_MUXDIV_RATIO 0x4
+#define MUXDIV_RATIO_MAX 0xff
+#define REG_MUXDIV_NCO_V 0x8
+#define REG_MUXDIV_EN 0xc
+#define REG_MUXDIV_XN_DIV_RATIO 0x10
+#define MUXDIV_XN_DIV_MAX 3
+
+static unsigned long sf19a28_muxdiv_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+ u32 div;
+
+ div = sf_readl(cmn_priv, priv->offset + REG_MUXDIV_RATIO) + 1;
+ return parent_rate / div;
+}
+
+static int sf19a28_muxdiv_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
+{
+ unsigned int div;
+
+ if (!req->rate)
+ div = MUXDIV_RATIO_MAX + 1;
+ else
+ div = DIV_ROUND_CLOSEST(req->best_parent_rate, req->rate);
+
+ if (!div)
+ div = 1;
+ else if (div > MUXDIV_RATIO_MAX + 1)
+ div = MUXDIV_RATIO_MAX + 1;
+
+ req->rate = req->best_parent_rate / div;
+ return 0;
+}
+
+static int sf19a28_muxdiv_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+ unsigned int div;
+
+ if (!rate)
+ return -EINVAL;
+
+ div = DIV_ROUND_CLOSEST(parent_rate, rate);
+ if (div < 1)
+ div = 1;
+ else if (div > MUXDIV_RATIO_MAX + 1)
+ div = MUXDIV_RATIO_MAX + 1;
+ div -= 1;
+
+ sf_writel(cmn_priv, priv->offset + REG_MUXDIV_RATIO, div);
+
+ return 0;
+}
+
+static int sf19a28_muxdiv_enable(struct clk_hw *hw)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+
+ sf_writel(cmn_priv, priv->offset + REG_MUXDIV_EN, 1);
+ return 0;
+}
+
+static void sf19a28_muxdiv_disable(struct clk_hw *hw)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+
+ sf_writel(cmn_priv, priv->offset + REG_MUXDIV_EN, 0);
+}
+
+static int sf19a28_muxdiv_is_enabled(struct clk_hw *hw)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+
+ return !!sf_readl(cmn_priv, priv->offset + REG_MUXDIV_EN);
+}
+
+/* MUXDIV_SRC_SEL values of clk_muxdiv_parents */
+static const u32 sf19a28_muxdiv_table[] = { 0, 1, 2, 4, 6 };
+
+static u8 sf19a28_muxdiv_get_parent(struct clk_hw *hw)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+ u32 cfg = sf_readl(cmn_priv, priv->offset + REG_MUXDIV_CFG);
+
+ return clk_mux_val_to_index(hw, sf19a28_muxdiv_table, 0, FIELD_GET(MUXDIV_SRC_SEL, cfg));
+}
+
+static int sf19a28_muxdiv_set_parent(struct clk_hw *hw, u8 index)
+{
+ struct sf_clk_common *cmn_priv = hw_to_sf_clk_common(hw);
+ struct sf19a2890_clk *priv = cmn_to_clk(cmn_priv);
+ u32 cfg = sf_readl(cmn_priv, priv->offset + REG_MUXDIV_CFG);
+
+ /* Keep MUXDIV_USE_NCO */
+ cfg &= ~MUXDIV_SRC_SEL;
+ cfg |= FIELD_PREP(MUXDIV_SRC_SEL, clk_mux_index_to_val(sf19a28_muxdiv_table, 0, index));
+ sf_writel(cmn_priv, priv->offset + REG_MUXDIV_CFG, cfg);
+
+ return 0;
+}
+
+static const struct clk_parent_data clk_muxdiv_parents[] = {
+ { .hw = &pll_cpu.common.hw },
+ { .hw = &pll_ddr.common.hw },
+ { .hw = &pll_cmn.common.hw },
+ { .fw_name = "osc12m" },
+ { .fw_name = "osc40m" },
+};
+
+static const struct clk_ops sf19a28_muxdiv_ops = {
+ .recalc_rate = sf19a28_muxdiv_recalc_rate,
+ .determine_rate = sf19a28_muxdiv_determine_rate,
+ .set_rate = sf19a28_muxdiv_set_rate,
+ .enable = sf19a28_muxdiv_enable,
+ .disable = sf19a28_muxdiv_disable,
+ .is_enabled = sf19a28_muxdiv_is_enabled,
+ .get_parent = sf19a28_muxdiv_get_parent,
+ .set_parent = sf19a28_muxdiv_set_parent,
+};
+
+#define SF19A28_MUXDIV(_name, _offset, _flags) \
+ struct sf19a2890_clk _name = { \
+ .common = SF_CLK_COMMON(#_name, clk_muxdiv_parents, \
+ &sf19a28_muxdiv_ops, _flags), \
+ .offset = REG_MUXDIV_BASE + (_offset), \
+ }
+
+static SF19A28_MUXDIV(muxdiv_bus1, 0x0, CLK_IS_CRITICAL);
+static SF19A28_MUXDIV(muxdiv_bus2, 0x20, CLK_IS_CRITICAL);
+static SF19A28_MUXDIV(muxdiv_bus3, 0x40, CLK_IS_CRITICAL);
+static SF19A28_MUXDIV(muxdiv_cpu, 0x100, CLK_SET_RATE_NO_REPARENT);
+static SF19A28_MUXDIV(muxdiv_pbus, 0x120, CLK_IS_CRITICAL);
+static SF19A28_MUXDIV(muxdiv_mem_phy, 0x140, CLK_IS_CRITICAL);
+static SF19A28_MUXDIV(muxdiv_uart, 0x180, 0);
+static SF19A28_MUXDIV(muxdiv_eth_ref, 0x200, 0);
+static SF19A28_MUXDIV(muxdiv_eth_byp_ref, 0x220, 0);
+static SF19A28_MUXDIV(muxdiv_eth_tsu, 0x240, 0);
+static SF19A28_MUXDIV(muxdiv_gmac_byp_ref, 0x260, 0);
+static SF19A28_MUXDIV(muxdiv_m6250_0, 0x280, 0);
+static SF19A28_MUXDIV(muxdiv_m6250_1, 0x2a0, 0);
+static SF19A28_MUXDIV(muxdiv_wlan24_plf, 0x2c0, 0);
+static SF19A28_MUXDIV(muxdiv_wlan5_plf, 0x2e0, 0);
+static SF19A28_MUXDIV(muxdiv_usbphy_ref, 0x300, 0);
+static SF19A28_MUXDIV(muxdiv_tclk, 0x320, 0);
+static SF19A28_MUXDIV(muxdiv_npu_pe, 0x340, 0);
+
+static struct clk_hw *const sf19a2890_hws[CLK_SF19A2890_NR_CLKS] = {
+ [CLK_PLL_CPU] = &pll_cpu.common.hw,
+ [CLK_PLL_DDR] = &pll_ddr.common.hw,
+ [CLK_PLL_CMN] = &pll_cmn.common.hw,
+ [CLK_MUXDIV_BUS1] = &muxdiv_bus1.common.hw,
+ [CLK_MUXDIV_BUS2] = &muxdiv_bus2.common.hw,
+ [CLK_MUXDIV_BUS3] = &muxdiv_bus3.common.hw,
+ [CLK_MUXDIV_CPU] = &muxdiv_cpu.common.hw,
+ [CLK_MUXDIV_PBUS] = &muxdiv_pbus.common.hw,
+ [CLK_MUXDIV_MEM_PHY] = &muxdiv_mem_phy.common.hw,
+ [CLK_MUXDIV_UART] = &muxdiv_uart.common.hw,
+ [CLK_MUXDIV_ETH_REF] = &muxdiv_eth_ref.common.hw,
+ [CLK_MUXDIV_ETH_BYP_REF] = &muxdiv_eth_byp_ref.common.hw,
+ [CLK_MUXDIV_ETH_TSU] = &muxdiv_eth_tsu.common.hw,
+ [CLK_MUXDIV_GMAC_BYP_REF] = &muxdiv_gmac_byp_ref.common.hw,
+ [CLK_MUXDIV_M6250_0] = &muxdiv_m6250_0.common.hw,
+ [CLK_MUXDIV_M6250_1] = &muxdiv_m6250_1.common.hw,
+ [CLK_MUXDIV_WLAN24_PLF] = &muxdiv_wlan24_plf.common.hw,
+ [CLK_MUXDIV_WLAN5_PLF] = &muxdiv_wlan5_plf.common.hw,
+ [CLK_MUXDIV_USBPHY_REF] = &muxdiv_usbphy_ref.common.hw,
+ [CLK_MUXDIV_TCLK] = &muxdiv_tclk.common.hw,
+ [CLK_MUXDIV_NPU_PE] = &muxdiv_npu_pe.common.hw,
+};
+
+/*
+ * The MIPS GIC timer runs from the CPU clock and probes from
+ * TIMER_OF_DECLARE() in time_init(), before the platform bus. Register that
+ * clock and the PLLs it may run from early, and the others at probe.
+ */
+static const unsigned int sf19a2890_early_clks[] __initconst = {
+ CLK_PLL_CPU,
+ CLK_PLL_DDR,
+ CLK_PLL_CMN,
+ CLK_MUXDIV_CPU,
+};
+
+static struct clk_hw_onecell_data *sf19a2890_clk_data;
+static void __iomem *sf19a2890_clk_base;
+
+static void __init sf19a2890_clk_early_init(struct device_node *node)
+{
+ struct clk_hw_onecell_data *data;
+ void __iomem *base;
+ unsigned int i;
+ int ret;
+
+ data = kzalloc_flex(*data, hws, CLK_SF19A2890_NR_CLKS);
+ if (!data)
+ return;
+
+ data->num = CLK_SF19A2890_NR_CLKS;
+ /* The clocks registered at probe defer until then */
+ for (i = 0; i < data->num; i++)
+ data->hws[i] = ERR_PTR(-EPROBE_DEFER);
+
+ base = of_iomap(node, 0);
+ if (!base) {
+ pr_err("failed to map the registers\n");
+ goto err_free;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(sf19a2890_early_clks); i++) {
+ unsigned int id = sf19a2890_early_clks[i];
+ struct clk_hw *hw = sf19a2890_hws[id];
+
+ hw_to_sf_clk_common(hw)->base = base;
+ ret = of_clk_hw_register(node, hw);
+ if (ret) {
+ pr_err("failed to register clock %u: %d\n", id, ret);
+ goto err_unregister;
+ }
+ data->hws[id] = hw;
+ }
+
+ ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
+ if (ret) {
+ pr_err("failed to add the clock provider: %d\n", ret);
+ goto err_unregister;
+ }
+
+ sf19a2890_clk_data = data;
+ sf19a2890_clk_base = base;
+ return;
+
+err_unregister:
+ while (i--)
+ clk_hw_unregister(data->hws[sf19a2890_early_clks[i]]);
+ iounmap(base);
+err_free:
+ kfree(data);
+}
+
+CLK_OF_DECLARE_DRIVER(sf19a2890_clk, "siflower,sf19a2890-clk", sf19a2890_clk_early_init);
+
+static void sf19a2890_clk_unpublish(void *data)
+{
+ struct clk_hw **hw = data;
+
+ *hw = ERR_PTR(-EPROBE_DEFER);
+}
+
+static int sf19a2890_clk_probe(struct platform_device *pdev)
+{
+ struct clk_hw_onecell_data *data = sf19a2890_clk_data;
+ struct device *dev = &pdev->dev;
+ unsigned int i;
+ int ret;
+
+ if (!data)
+ return -ENODEV;
+
+ for (i = 0; i < data->num; i++) {
+ struct clk_hw *hw = sf19a2890_hws[i];
+
+ /* Registered early */
+ if (!IS_ERR(data->hws[i]))
+ continue;
+
+ hw_to_sf_clk_common(hw)->base = sf19a2890_clk_base;
+ ret = devm_clk_hw_register(dev, hw);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to register clock %u\n", i);
+
+ data->hws[i] = hw;
+ ret = devm_add_action_or_reset(dev, sf19a2890_clk_unpublish, &data->hws[i]);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct of_device_id sf19a2890_clk_dt_ids[] = {
+ { .compatible = "siflower,sf19a2890-clk" },
+ { /* sentinel */ }
+};
+
+static struct platform_driver sf19a2890_clk_driver = {
+ .probe = sf19a2890_clk_probe,
+ .driver = {
+ .name = "sf19a2890-clk",
+ .of_match_table = sf19a2890_clk_dt_ids,
+ .suppress_bind_attrs = true,
+ },
+};
+builtin_platform_driver(sf19a2890_clk_driver);
--
Git-155)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 4/6] dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
` (2 preceding siblings ...)
2026-11-24 4:41 ` [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver Joseph Telaak via B4 Relay
@ 2026-11-24 4:41 ` Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 5/6] clk: siflower: Add SF19A2890 peripheral clock driver Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver Joseph Telaak via B4 Relay
5 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Conor Dooley, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
Each peripheral block of the Siflower SF19A2890 has a clock and reset
manager of its own, with a reset register, a clock gate register and a
bus output enable. The blocks differ in which gate and reset bits they
use, so each has its own compatible, and clock N of a manager is its
input clock N, gated. The header names the clocks and resets of each
manager, since their meaning depends on the manager.
Based on Chuanhong Guo's binding, which described every block with one
compatible and its bit layout in properties.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
.../clock/siflower,sf19a2890-periph-crm.yaml | 166 +++++++++++++++++++++
MAINTAINERS | 2 +
.../clock/siflower,sf19a2890-periph-crm.h | 87 +++++++++++
3 files changed, 255 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/siflower,sf19a2890-periph-crm.yaml b/Documentation/devicetree/bindings/clock/siflower,sf19a2890-periph-crm.yaml
new file mode 100644
index 000000000000..f464cfffb2a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/siflower,sf19a2890-periph-crm.yaml
@@ -0,0 +1,166 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/siflower,sf19a2890-periph-crm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Siflower SF19A2890 peripheral clock and reset manager
+
+maintainers:
+ - Joseph Telaak <joseph@telaak.dev>
+
+description: |
+ Each peripheral, or group of peripherals, of the Siflower SF19A2890 has
+ a clock and reset manager of its own: a reset register, a clock gate
+ register, and a bus output enable that the peripherals need as well as
+ their clocks to answer bus requests.
+
+ Clock N of the manager is input clock N, gated. The clocks and resets of
+ each manager are defined in
+ include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h.
+
+properties:
+ compatible:
+ enum:
+ - siflower,sf19a2890-gmac-crm
+ - siflower,sf19a2890-gpio-crm
+ - siflower,sf19a2890-i2c-crm
+ - siflower,sf19a2890-pwm-crm
+ - siflower,sf19a2890-rf-crm
+ - siflower,sf19a2890-spi-crm
+ - siflower,sf19a2890-timer-crm
+ - siflower,sf19a2890-uart-crm
+ - siflower,sf19a2890-usb-crm
+ - siflower,sf19a2890-wdt-crm
+ - siflower,sf19a2890-wlan24-crm
+ - siflower,sf19a2890-wlan5-crm
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ minItems: 1
+ maxItems: 6
+
+ "#clock-cells":
+ const: 1
+
+ "#reset-cells":
+ const: 1
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - "#clock-cells"
+ - "#reset-cells"
+
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: siflower,sf19a2890-gmac-crm
+ then:
+ properties:
+ clocks:
+ items:
+ - description: GMAC bus clock
+ - description: GMAC register clock
+ - description: RGMII transmit reference clock
+ - description: Timestamp unit clock
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - siflower,sf19a2890-wlan24-crm
+ - siflower,sf19a2890-wlan5-crm
+ then:
+ properties:
+ clocks:
+ items:
+ - description: AXI slave clock
+ - description: AXI master clock
+ - description: Radio platform clock
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: siflower,sf19a2890-rf-crm
+ then:
+ properties:
+ clocks:
+ items:
+ - description: Test clock
+ - description: AXI slave clock
+ - description: Boot clock
+ - description: Low-power clock
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: siflower,sf19a2890-usb-crm
+ then:
+ properties:
+ clocks:
+ items:
+ - description: USB controller clock
+ - description: AXI master clock
+ - description: USB PHY reference clock
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: siflower,sf19a2890-spi-crm
+ then:
+ properties:
+ clocks:
+ items:
+ - description: APB clock
+ - description: SSP clock
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: siflower,sf19a2890-uart-crm
+ then:
+ properties:
+ clocks:
+ items:
+ - description: UART0 APB clock
+ - description: UART1 APB clock
+ - description: UART2 APB clock
+ - description: UART0 clock
+ - description: UART1 clock
+ - description: UART2 clock
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - siflower,sf19a2890-gpio-crm
+ - siflower,sf19a2890-i2c-crm
+ - siflower,sf19a2890-pwm-crm
+ - siflower,sf19a2890-timer-crm
+ - siflower,sf19a2890-wdt-crm
+ then:
+ properties:
+ clocks:
+ maxItems: 1
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/siflower,sf19a2890-clk.h>
+
+ clock-controller@19e24c00 {
+ compatible = "siflower,sf19a2890-uart-crm";
+ reg = <0x19e24c00 0x10>;
+ clocks = <&clk CLK_MUXDIV_PBUS>, <&clk CLK_MUXDIV_PBUS>,
+ <&clk CLK_MUXDIV_PBUS>, <&clk CLK_MUXDIV_UART>,
+ <&clk CLK_MUXDIV_UART>, <&clk CLK_MUXDIV_UART>;
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index de087d1c255d..47a3a72a5d08 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25703,8 +25703,10 @@ M: Joseph Telaak <joseph@telaak.dev>
L: linux-clk@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
+F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-periph-crm.yaml
F: drivers/clk/siflower/clk-sf19a2890.c
F: include/dt-bindings/clock/siflower,sf19a2890-clk.h
+F: include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h
SILEAD TOUCHSCREEN DRIVER
M: Hans de Goede <hansg@kernel.org>
diff --git a/include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h b/include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h
new file mode 100644
index 000000000000..1cf54761fe72
--- /dev/null
+++ b/include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h
@@ -0,0 +1,87 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+#ifndef __DT_BINDINGS_CLOCK_SIFLOWER_SF19A2890_PERIPH_CRM_H
+#define __DT_BINDINGS_CLOCK_SIFLOWER_SF19A2890_PERIPH_CRM_H
+
+/* siflower,sf19a2890-gmac-crm */
+#define CLK_GMAC_BUS 0
+#define CLK_GMAC_REG 1
+#define CLK_GMAC_TX_REF 2
+#define CLK_GMAC_TSU 3
+
+#define RST_GMAC 0
+
+/* siflower,sf19a2890-gpio-crm */
+#define CLK_GPIO 0
+
+#define RST_GPIO 0
+
+/* siflower,sf19a2890-i2c-crm */
+#define CLK_I2C 0
+
+#define RST_I2C 0
+
+/* siflower,sf19a2890-pwm-crm */
+#define CLK_PWM 0
+
+#define RST_PWM 0
+
+/* siflower,sf19a2890-rf-crm */
+#define CLK_RF_TEST 0
+#define CLK_RF_AXIS 1
+#define CLK_RF_BOOT 2
+#define CLK_RF_LP 3
+
+#define RST_RF 0
+
+/* siflower,sf19a2890-spi-crm */
+#define CLK_SPI_APB 0
+#define CLK_SPI_SSP 1
+
+#define RST_SPI 0
+
+/* siflower,sf19a2890-timer-crm */
+#define CLK_TIMER 0
+
+#define RST_TIMER 0
+
+/* siflower,sf19a2890-uart-crm */
+#define CLK_UART0_APB 0
+#define CLK_UART1_APB 1
+#define CLK_UART2_APB 2
+#define CLK_UART0 3
+#define CLK_UART1 4
+#define CLK_UART2 5
+
+#define RST_UART0 0
+#define RST_UART1 1
+#define RST_UART2 2
+
+/* siflower,sf19a2890-usb-crm */
+#define CLK_USB 0
+#define CLK_USB_AXIM 1
+#define CLK_USB_PHY_REF 2
+
+#define RST_USB 0
+#define RST_USB_PHY_POR 1
+#define RST_USB_PHY 2
+
+/* siflower,sf19a2890-wdt-crm */
+#define CLK_WDT 0
+
+#define RST_WDT 0
+
+/* siflower,sf19a2890-wlan24-crm */
+#define CLK_WLAN24_AXIS 0
+#define CLK_WLAN24_AXIM 1
+#define CLK_WLAN24_PLF 2
+
+#define RST_WLAN24 0
+
+/* siflower,sf19a2890-wlan5-crm */
+#define CLK_WLAN5_AXIS 0
+#define CLK_WLAN5_AXIM 1
+#define CLK_WLAN5_PLF 2
+
+#define RST_WLAN5 0
+
+#endif /* __DT_BINDINGS_CLOCK_SIFLOWER_SF19A2890_PERIPH_CRM_H */
--
Git-155)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 5/6] clk: siflower: Add SF19A2890 peripheral clock driver
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
` (3 preceding siblings ...)
2026-11-24 4:41 ` [PATCH v5 4/6] dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers Joseph Telaak via B4 Relay
@ 2026-11-24 4:41 ` Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver Joseph Telaak via B4 Relay
5 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
Each peripheral block of the Siflower SF19A2890 has a clock and reset
manager with the block's clock gates, its resets and a bus output enable
that the block needs to answer bus requests. Add a driver for the clock
gates. It turns the bus output on with the first gate and off with the
last, and leaves the resets to a reset driver, through an auxiliary
device.
Based on the driver in Chuanhong Guo's SF19A2890 branch, which handled
the resets too and described each block's bits with properties.
Link: https://github.com/981213/linux/commit/37c81bebaf54
Co-developed-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
MAINTAINERS | 1 +
drivers/clk/siflower/Kconfig | 12 +
drivers/clk/siflower/Makefile | 1 +
drivers/clk/siflower/clk-sf19a2890-periphcrm.c | 306 +++++++++++++++++++++++++
4 files changed, 320 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 47a3a72a5d08..34ff7ec0b60e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25704,6 +25704,7 @@ L: linux-clk@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-periph-crm.yaml
+F: drivers/clk/siflower/clk-sf19a2890-periphcrm.c
F: drivers/clk/siflower/clk-sf19a2890.c
F: include/dt-bindings/clock/siflower,sf19a2890-clk.h
F: include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h
diff --git a/drivers/clk/siflower/Kconfig b/drivers/clk/siflower/Kconfig
index ad1b04b4bb9b..fa09bca275b4 100644
--- a/drivers/clk/siflower/Kconfig
+++ b/drivers/clk/siflower/Kconfig
@@ -9,3 +9,15 @@ config CLK_SF19A2890
and the muxes and dividers that feed the CPU, the buses and the
peripherals. The GIC timer runs from the CPU clock, so a kernel
for this SoC needs it built in.
+
+config CLK_SF19A2890_PERIPHCRM
+ bool "Clock driver for Siflower SF19A2890 peripherals"
+ depends on MACH_SIFLOWER_MIPS || COMPILE_TEST
+ default MACH_SIFLOWER_MIPS
+ select AUXILIARY_BUS
+ select RESET_CONTROLLER
+ help
+ Supports the clocks of the peripheral clock and reset managers of
+ the Siflower SF19A2890. Each peripheral block has one, with its
+ clock gates, its resets and the bus output enable it needs to
+ answer bus requests. The resets have a driver of their own.
diff --git a/drivers/clk/siflower/Makefile b/drivers/clk/siflower/Makefile
index 3f4d689f7d9b..c4f4e0b8820d 100644
--- a/drivers/clk/siflower/Makefile
+++ b/drivers/clk/siflower/Makefile
@@ -1,2 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_CLK_SF19A2890) += clk-sf19a2890.o
+obj-$(CONFIG_CLK_SF19A2890_PERIPHCRM) += clk-sf19a2890-periphcrm.o
diff --git a/drivers/clk/siflower/clk-sf19a2890-periphcrm.c b/drivers/clk/siflower/clk-sf19a2890-periphcrm.c
new file mode 100644
index 000000000000..95b3c6927067
--- /dev/null
+++ b/drivers/clk/siflower/clk-sf19a2890-periphcrm.c
@@ -0,0 +1,306 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Siflower SF19A2890 peripheral clock and reset manager driver.
+ *
+ * Each managed block has three registers:
+ * RESET at base + 0x0 - per-peripheral reset bitmasks
+ * CLK_GATE at base + 0x4 - one bit per clock gate
+ * BOE at base + 0xc - shared Bus Output Enable; bits [1:0] must be set
+ * for any APB peripheral in the block to respond
+ *
+ * The resets are left to the reset driver, through an auxiliary device.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/clk-provider.h>
+#include <linux/device-id/of.h>
+#include <linux/idr.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#include <dt-bindings/clock/siflower,sf19a2890-periph-crm.h>
+
+#define REG_CLK_GATE 0x4
+#define REG_BOE 0xc
+#define BOE_EN GENMASK(1, 0)
+
+struct sf19a2890_periphcrm_gate {
+ const char *name;
+ u8 bit;
+ unsigned long flags;
+};
+
+struct sf19a2890_periphcrm_data {
+ const struct sf19a2890_periphcrm_gate *gates;
+ unsigned int num_gates;
+};
+
+struct sf19a2890_periphcrm {
+ void __iomem *base;
+ spinlock_t lock; /* serializes gate and BOE updates */
+ struct clk_hw_onecell_data clk_data;
+};
+
+struct sf19a2890_periphclk {
+ struct sf19a2890_periphcrm *crm;
+ struct clk_hw hw;
+ u32 idx;
+};
+
+static inline struct sf19a2890_periphclk *hw_to_periphclk(struct clk_hw *hw)
+{
+ return container_of(hw, struct sf19a2890_periphclk, hw);
+}
+
+static int sf19a2890_periphclk_enable(struct clk_hw *hw)
+{
+ struct sf19a2890_periphclk *gate = hw_to_periphclk(hw);
+ struct sf19a2890_periphcrm *crm = gate->crm;
+ u32 reg;
+
+ guard(spinlock_irqsave)(&crm->lock);
+ reg = readl(crm->base + REG_CLK_GATE);
+ writel(reg | BIT(gate->idx), crm->base + REG_CLK_GATE);
+ writel(BOE_EN, crm->base + REG_BOE);
+ return 0;
+}
+
+static void sf19a2890_periphclk_disable(struct clk_hw *hw)
+{
+ struct sf19a2890_periphclk *gate = hw_to_periphclk(hw);
+ struct sf19a2890_periphcrm *crm = gate->crm;
+ u32 reg;
+
+ guard(spinlock_irqsave)(&crm->lock);
+ reg = readl(crm->base + REG_CLK_GATE);
+ reg &= ~BIT(gate->idx);
+ writel(reg, crm->base + REG_CLK_GATE);
+ if (reg == 0)
+ writel(0, crm->base + REG_BOE);
+}
+
+static int sf19a2890_periphclk_is_enabled(struct clk_hw *hw)
+{
+ struct sf19a2890_periphclk *gate = hw_to_periphclk(hw);
+ struct sf19a2890_periphcrm *crm = gate->crm;
+
+ return !!(readl(crm->base + REG_CLK_GATE) & BIT(gate->idx));
+}
+
+static const struct clk_ops sf19a2890_periphclk_ops = {
+ .enable = sf19a2890_periphclk_enable,
+ .disable = sf19a2890_periphclk_disable,
+ .is_enabled = sf19a2890_periphclk_is_enabled,
+};
+
+#define GATE(_name, _bit, _flags) { .name = _name, .bit = _bit, .flags = _flags }
+
+#define CRM_DATA(_g) \
+ { \
+ .gates = sf19a2890_##_g##_gates, \
+ .num_gates = ARRAY_SIZE(sf19a2890_##_g##_gates), \
+ }
+
+static const struct sf19a2890_periphcrm_gate sf19a2890_gmac_gates[] = {
+ [CLK_GMAC_BUS] = GATE("gmac", 0, 0),
+ [CLK_GMAC_REG] = GATE("gmac_pclk", 1, 0),
+ [CLK_GMAC_TX_REF] = GATE("gmac_byp_ref", 2, 0),
+ [CLK_GMAC_TSU] = GATE("ethtsu", 3, 0),
+};
+
+static const struct sf19a2890_periphcrm_data sf19a2890_gmac_crm =
+ CRM_DATA(gmac);
+
+static const struct sf19a2890_periphcrm_gate sf19a2890_wlan24_gates[] = {
+ [CLK_WLAN24_AXIS] = GATE("wlan24_axis", 0, 0),
+ [CLK_WLAN24_AXIM] = GATE("wlan24_axim", 1, 0),
+ [CLK_WLAN24_PLF] = GATE("wlan24_plf", 2, 0),
+};
+
+static const struct sf19a2890_periphcrm_gate sf19a2890_wlan5_gates[] = {
+ [CLK_WLAN5_AXIS] = GATE("wlan5_axis", 0, 0),
+ [CLK_WLAN5_AXIM] = GATE("wlan5_axim", 1, 0),
+ [CLK_WLAN5_PLF] = GATE("wlan5_plf", 2, 0),
+};
+
+static const struct sf19a2890_periphcrm_data sf19a2890_wlan24_crm =
+ CRM_DATA(wlan24);
+
+static const struct sf19a2890_periphcrm_data sf19a2890_wlan5_crm =
+ CRM_DATA(wlan5);
+
+static const struct sf19a2890_periphcrm_gate sf19a2890_rf_gates[] = {
+ [CLK_RF_TEST] = GATE("rf_dft", 0, 0),
+ [CLK_RF_AXIS] = GATE("rf_axis", 1, 0),
+ [CLK_RF_BOOT] = GATE("rf_boot", 2, 0),
+ [CLK_RF_LP] = GATE("rf_lp", 3, 0),
+};
+
+static const struct sf19a2890_periphcrm_data sf19a2890_rf_crm =
+ CRM_DATA(rf);
+
+/* Nothing describes a consumer of usb_axim, and gating it is not safe */
+static const struct sf19a2890_periphcrm_gate sf19a2890_usb_gates[] = {
+ [CLK_USB] = GATE("usb", 0, 0),
+ [CLK_USB_AXIM] = GATE("usb_axim", 2, CLK_IS_CRITICAL),
+ [CLK_USB_PHY_REF] = GATE("usbphy_ref", 3, 0),
+};
+
+static const struct sf19a2890_periphcrm_data sf19a2890_usb_crm =
+ CRM_DATA(usb);
+
+static const struct sf19a2890_periphcrm_gate sf19a2890_spi_gates[] = {
+ [CLK_SPI_APB] = GATE("spi_apb", 4, 0),
+ [CLK_SPI_SSP] = GATE("spi_ssp", 5, 0),
+};
+
+static const struct sf19a2890_periphcrm_data sf19a2890_spi_crm =
+ CRM_DATA(spi);
+
+/* UART0 carries the console from the bootloader on */
+static const struct sf19a2890_periphcrm_gate sf19a2890_uart_gates[] = {
+ [CLK_UART0_APB] = GATE("uart0_apb", 0, CLK_IS_CRITICAL),
+ [CLK_UART1_APB] = GATE("uart1_apb", 1, 0),
+ [CLK_UART2_APB] = GATE("uart2_apb", 2, 0),
+ [CLK_UART0] = GATE("uart0", 4, CLK_IS_CRITICAL),
+ [CLK_UART1] = GATE("uart1", 5, 0),
+ [CLK_UART2] = GATE("uart2", 6, 0),
+};
+
+static const struct sf19a2890_periphcrm_data sf19a2890_uart_crm =
+ CRM_DATA(uart);
+
+#define SINGLE_CRM(_name) \
+ static const struct sf19a2890_periphcrm_gate sf19a2890_##_name##_gates[] = { \
+ GATE(#_name, 0, 0), \
+ }; \
+ static const struct sf19a2890_periphcrm_data sf19a2890_##_name##_crm = \
+ CRM_DATA(_name)
+
+SINGLE_CRM(i2c0);
+SINGLE_CRM(pwm);
+SINGLE_CRM(timer);
+SINGLE_CRM(wdt);
+SINGLE_CRM(gpio);
+
+static DEFINE_IDA(sf19a2890_periphcrm_ida);
+
+static void sf19a2890_periphcrm_ida_free(void *data)
+{
+ ida_free(&sf19a2890_periphcrm_ida, (uintptr_t)data);
+}
+
+static int sf19a2890_periphcrm_probe(struct platform_device *pdev)
+{
+ const struct sf19a2890_periphcrm_data *data;
+ struct auxiliary_device *adev;
+ struct device *dev = &pdev->dev;
+ struct sf19a2890_periphclk *gates;
+ struct sf19a2890_periphcrm *crm;
+ u32 valid_gates = 0;
+ unsigned int i;
+ int ret, id;
+ u32 reg;
+
+ data = device_get_match_data(dev);
+ if (!data)
+ return -EINVAL;
+
+ crm = devm_kzalloc(dev, struct_size(crm, clk_data.hws, data->num_gates),
+ GFP_KERNEL);
+ if (!crm)
+ return -ENOMEM;
+
+ crm->clk_data.num = data->num_gates;
+
+ gates = devm_kcalloc(dev, data->num_gates, sizeof(*gates), GFP_KERNEL);
+ if (!gates)
+ return -ENOMEM;
+
+ crm->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(crm->base))
+ return PTR_ERR(crm->base);
+
+ spin_lock_init(&crm->lock);
+
+ /*
+ * Clear any stale bits outside the block's gates so the BOE-disable
+ * check in periphclk_disable() works correctly.
+ */
+ for (i = 0; i < data->num_gates; i++)
+ valid_gates |= BIT(data->gates[i].bit);
+ reg = readl(crm->base + REG_CLK_GATE) & valid_gates;
+ writel(reg, crm->base + REG_CLK_GATE);
+
+ for (i = 0; i < data->num_gates; i++) {
+ const struct clk_parent_data parent = { .index = i };
+ struct clk_init_data init = {
+ .name = data->gates[i].name,
+ .ops = &sf19a2890_periphclk_ops,
+ .parent_data = &parent,
+ .num_parents = 1,
+ .flags = data->gates[i].flags,
+ };
+
+ gates[i].crm = crm;
+ gates[i].idx = data->gates[i].bit;
+ gates[i].hw.init = &init;
+
+ ret = devm_clk_hw_register(dev, &gates[i].hw);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to register gate %u\n", i);
+
+ crm->clk_data.hws[i] = &gates[i].hw;
+ }
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+ &crm->clk_data);
+ if (ret)
+ return ret;
+
+ /* Each block gets a reset device of its own, so they need distinct IDs */
+ id = ida_alloc(&sf19a2890_periphcrm_ida, GFP_KERNEL);
+ if (id < 0)
+ return id;
+
+ ret = devm_add_action_or_reset(dev, sf19a2890_periphcrm_ida_free,
+ (void *)(uintptr_t)id);
+ if (ret)
+ return ret;
+
+ adev = __devm_auxiliary_device_create(dev, KBUILD_MODNAME, "reset",
+ (void __force *)crm->base, id);
+ if (!adev)
+ return dev_err_probe(dev, -ENODEV, "failed to create the reset device\n");
+
+ return 0;
+}
+
+static const struct of_device_id sf19a2890_periphcrm_dt_ids[] = {
+ { .compatible = "siflower,sf19a2890-gmac-crm", .data = &sf19a2890_gmac_crm },
+ { .compatible = "siflower,sf19a2890-gpio-crm", .data = &sf19a2890_gpio_crm },
+ { .compatible = "siflower,sf19a2890-i2c-crm", .data = &sf19a2890_i2c0_crm },
+ { .compatible = "siflower,sf19a2890-pwm-crm", .data = &sf19a2890_pwm_crm },
+ { .compatible = "siflower,sf19a2890-rf-crm", .data = &sf19a2890_rf_crm },
+ { .compatible = "siflower,sf19a2890-spi-crm", .data = &sf19a2890_spi_crm },
+ { .compatible = "siflower,sf19a2890-timer-crm", .data = &sf19a2890_timer_crm },
+ { .compatible = "siflower,sf19a2890-uart-crm", .data = &sf19a2890_uart_crm },
+ { .compatible = "siflower,sf19a2890-usb-crm", .data = &sf19a2890_usb_crm },
+ { .compatible = "siflower,sf19a2890-wdt-crm", .data = &sf19a2890_wdt_crm },
+ { .compatible = "siflower,sf19a2890-wlan24-crm", .data = &sf19a2890_wlan24_crm },
+ { .compatible = "siflower,sf19a2890-wlan5-crm", .data = &sf19a2890_wlan5_crm },
+ { /* sentinel */ }
+};
+
+static struct platform_driver sf19a2890_periphcrm_driver = {
+ .probe = sf19a2890_periphcrm_probe,
+ .driver = {
+ .name = "sf19a2890-periph-crm",
+ .of_match_table = sf19a2890_periphcrm_dt_ids,
+ },
+};
+builtin_platform_driver(sf19a2890_periphcrm_driver);
--
Git-155)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
` (4 preceding siblings ...)
2026-11-24 4:41 ` [PATCH v5 5/6] clk: siflower: Add SF19A2890 peripheral clock driver Joseph Telaak via B4 Relay
@ 2026-11-24 4:41 ` Joseph Telaak via B4 Relay
2026-11-24 4:52 ` sashiko-bot
5 siblings, 1 reply; 10+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-11-24 4:41 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
Thomas Bogendoerfer
Cc: Paul Burton, Jiaxun Yang, Chuanhong Guo, Yao Zi,
Uwe Kleine-König, linux-mips, linux-clk, devicetree,
linux-kernel, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
Add a driver for the resets of the Siflower SF19A2890 peripheral clock
and reset managers. It binds to the auxiliary device that their clock
driver creates and uses the registers that driver has mapped. Where an
IP has a reset line for each of its clock domains, as the PL011 UARTs
and the PL022 SPI controller do, one reset drives all of them, since
they have to be asserted together.
Based on the reset part of the driver in Chuanhong Guo's SF19A2890
branch.
Link: https://github.com/981213/linux/commit/37c81bebaf54
Co-developed-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
MAINTAINERS | 1 +
drivers/reset/Kconfig | 11 ++
drivers/reset/Makefile | 1 +
drivers/reset/reset-sf19a2890-periphcrm.c | 194 ++++++++++++++++++++++++++++++
4 files changed, 207 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 34ff7ec0b60e..ae47322d15dd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25706,6 +25706,7 @@ F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-clk.yaml
F: Documentation/devicetree/bindings/clock/siflower,sf19a2890-periph-crm.yaml
F: drivers/clk/siflower/clk-sf19a2890-periphcrm.c
F: drivers/clk/siflower/clk-sf19a2890.c
+F: drivers/reset/reset-sf19a2890-periphcrm.c
F: include/dt-bindings/clock/siflower,sf19a2890-clk.h
F: include/dt-bindings/clock/siflower,sf19a2890-periph-crm.h
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index eda9c698a95f..6e2f6cceb3cb 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -295,6 +295,17 @@ config RESET_SCMI
This driver uses SCMI Message Protocol to interact with the
firmware controlling all the reset signals.
+config RESET_SF19A2890_PERIPHCRM
+ tristate "Siflower SF19A2890 peripheral reset controller"
+ depends on MACH_SIFLOWER_MIPS || COMPILE_TEST
+ select AUXILIARY_BUS
+ default CLK_SF19A2890_PERIPHCRM
+ help
+ Supports the resets of the peripheral clock and reset managers of
+ the Siflower SF19A2890, one manager for each peripheral block.
+ The driver binds to the auxiliary device that their clock driver
+ creates, so it needs CLK_SF19A2890_PERIPHCRM to do anything.
+
config RESET_SIMPLE
bool "Simple Reset Controller Driver" if COMPILE_TEST || EXPERT
default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_REALTEK || ARCH_SOPHGO || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 489fafd6bbe3..d4b707505c3d 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
obj-$(CONFIG_RESET_RZG2L_USBPHY_CTRL) += reset-rzg2l-usbphy-ctrl.o
obj-$(CONFIG_RESET_RZV2H_USB2PHY) += reset-rzv2h-usb2phy.o
obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
+obj-$(CONFIG_RESET_SF19A2890_PERIPHCRM) += reset-sf19a2890-periphcrm.o
obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
obj-$(CONFIG_RESET_SKY1) += reset-sky1.o
obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o
diff --git a/drivers/reset/reset-sf19a2890-periphcrm.c b/drivers/reset/reset-sf19a2890-periphcrm.c
new file mode 100644
index 000000000000..54b476237bd4
--- /dev/null
+++ b/drivers/reset/reset-sf19a2890-periphcrm.c
@@ -0,0 +1,194 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Siflower SF19A2890 peripheral reset driver
+ *
+ * The peripheral clock and reset managers keep their resets in the first
+ * register of the block. Their clock driver creates an auxiliary device for
+ * them and passes the mapped registers in its platform data.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+#include <dt-bindings/clock/siflower,sf19a2890-periph-crm.h>
+
+#define REG_RESET 0x0
+
+struct sf19a2890_periphrst_data {
+ const u32 *masks;
+ unsigned int num_resets;
+};
+
+struct sf19a2890_periphrst {
+ struct reset_controller_dev rcdev;
+ void __iomem *base;
+ spinlock_t lock; /* serializes reset register updates */
+ const u32 *masks;
+};
+
+static inline struct sf19a2890_periphrst *
+rcdev_to_periphrst(struct reset_controller_dev *rcdev)
+{
+ return container_of(rcdev, struct sf19a2890_periphrst, rcdev);
+}
+
+static int sf19a2890_periphrst_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ struct sf19a2890_periphrst *rst = rcdev_to_periphrst(rcdev);
+ u32 reg;
+
+ guard(spinlock_irqsave)(&rst->lock);
+ reg = readl(rst->base + REG_RESET);
+ if (assert)
+ reg |= rst->masks[id];
+ else
+ reg &= ~rst->masks[id];
+ writel(reg, rst->base + REG_RESET);
+ return 0;
+}
+
+static int sf19a2890_periphrst_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return sf19a2890_periphrst_update(rcdev, id, true);
+}
+
+static int sf19a2890_periphrst_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return sf19a2890_periphrst_update(rcdev, id, false);
+}
+
+static int sf19a2890_periphrst_status(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct sf19a2890_periphrst *rst = rcdev_to_periphrst(rcdev);
+
+ return !!(readl(rst->base + REG_RESET) & rst->masks[id]);
+}
+
+static const struct reset_control_ops sf19a2890_periphrst_ops = {
+ .assert = sf19a2890_periphrst_assert,
+ .deassert = sf19a2890_periphrst_deassert,
+ .status = sf19a2890_periphrst_status,
+};
+
+#define RST_DATA(_name) \
+ static const struct sf19a2890_periphrst_data sf19a2890_##_name##_rst = { \
+ .masks = sf19a2890_##_name##_masks, \
+ .num_resets = ARRAY_SIZE(sf19a2890_##_name##_masks), \
+ }
+
+/*
+ * A reset that covers several bits drives the reset lines of all the clock
+ * domains of one IP, which have to be asserted together.
+ */
+static const u32 sf19a2890_single_masks[] = { BIT(0) };
+
+RST_DATA(single);
+
+/* The two sides of an asynchronous AXI bridge */
+static const u32 sf19a2890_gmac_masks[] = { [RST_GMAC] = GENMASK(1, 0) };
+
+RST_DATA(gmac);
+
+/* The AXI slave, AXI master and platform domains */
+static const u32 sf19a2890_wlan_masks[] = { GENMASK(2, 0) };
+
+RST_DATA(wlan);
+
+/* The DWC2 controller's clock domains, then the PHY's */
+static const u32 sf19a2890_usb_masks[] = {
+ [RST_USB] = GENMASK(2, 0),
+ [RST_USB_PHY_POR] = BIT(3),
+ [RST_USB_PHY] = BIT(4),
+};
+
+RST_DATA(usb);
+
+/* The PL022's PRESETn and nSSPRST */
+static const u32 sf19a2890_spi_masks[] = { [RST_SPI] = GENMASK(5, 4) };
+
+RST_DATA(spi);
+
+/* Each PL011's PRESETn and nUARTRST */
+static const u32 sf19a2890_uart_masks[] = {
+ [RST_UART0] = BIT(0) | BIT(4),
+ [RST_UART1] = BIT(1) | BIT(5),
+ [RST_UART2] = BIT(2) | BIT(6),
+};
+
+RST_DATA(uart);
+
+static const struct of_device_id sf19a2890_periphrst_ids[] = {
+ { .compatible = "siflower,sf19a2890-gmac-crm", .data = &sf19a2890_gmac_rst },
+ { .compatible = "siflower,sf19a2890-gpio-crm", .data = &sf19a2890_single_rst },
+ { .compatible = "siflower,sf19a2890-i2c-crm", .data = &sf19a2890_single_rst },
+ { .compatible = "siflower,sf19a2890-pwm-crm", .data = &sf19a2890_single_rst },
+ { .compatible = "siflower,sf19a2890-rf-crm", .data = &sf19a2890_wlan_rst },
+ { .compatible = "siflower,sf19a2890-spi-crm", .data = &sf19a2890_spi_rst },
+ { .compatible = "siflower,sf19a2890-timer-crm", .data = &sf19a2890_single_rst },
+ { .compatible = "siflower,sf19a2890-uart-crm", .data = &sf19a2890_uart_rst },
+ { .compatible = "siflower,sf19a2890-usb-crm", .data = &sf19a2890_usb_rst },
+ { .compatible = "siflower,sf19a2890-wdt-crm", .data = &sf19a2890_single_rst },
+ { .compatible = "siflower,sf19a2890-wlan24-crm", .data = &sf19a2890_wlan_rst },
+ { .compatible = "siflower,sf19a2890-wlan5-crm", .data = &sf19a2890_wlan_rst },
+ { /* sentinel */ }
+};
+
+static int sf19a2890_periphrst_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ const struct sf19a2890_periphrst_data *data;
+ struct device *dev = &adev->dev;
+ const struct of_device_id *match;
+ struct sf19a2890_periphrst *rst;
+
+ /* The OF node is the parent's, so device_get_match_data() cannot be used */
+ match = of_match_node(sf19a2890_periphrst_ids, dev->of_node);
+ if (!match)
+ return -ENODEV;
+ data = match->data;
+
+ rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
+ if (!rst)
+ return -ENOMEM;
+
+ rst->base = (void __iomem __force *)dev_get_platdata(dev);
+ if (!rst->base)
+ return -EINVAL;
+
+ spin_lock_init(&rst->lock);
+ rst->masks = data->masks;
+ rst->rcdev.owner = THIS_MODULE;
+ rst->rcdev.nr_resets = data->num_resets;
+ rst->rcdev.ops = &sf19a2890_periphrst_ops;
+ rst->rcdev.of_node = dev->of_node;
+ rst->rcdev.dev = dev;
+
+ return devm_reset_controller_register(dev, &rst->rcdev);
+}
+
+static const struct auxiliary_device_id sf19a2890_periphrst_aux_ids[] = {
+ { .name = "clk_sf19a2890_periphcrm.reset" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(auxiliary, sf19a2890_periphrst_aux_ids);
+
+static struct auxiliary_driver sf19a2890_periphrst_driver = {
+ .probe = sf19a2890_periphrst_probe,
+ .id_table = sf19a2890_periphrst_aux_ids,
+};
+module_auxiliary_driver(sf19a2890_periphrst_driver);
+
+MODULE_AUTHOR("Chuanhong Guo <gch981213@gmail.com>");
+MODULE_AUTHOR("Joseph Telaak <joseph@telaak.dev>");
+MODULE_DESCRIPTION("Siflower SF19A2890 peripheral reset driver");
+MODULE_LICENSE("GPL");
--
Git-155)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver
2026-11-24 4:41 ` [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver Joseph Telaak via B4 Relay
@ 2026-11-24 4:52 ` sashiko-bot
0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-24 4:52 UTC (permalink / raw)
To: Joseph Telaak; +Cc: linux-clk, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] reset: sf19a2890: unused sf19a2890_periphrst_ids when CONFIG_OF
is disabled
--
commit eb59c76c1f50a7fd2445c0b31eb22084d7fc905e
Author: Joseph Telaak <joseph@telaak.dev>
reset: Add Siflower SF19A2890 peripheral reset driver
This commit adds an auxiliary-bus reset controller driver for the Siflower
SF19A2890 peripheral clock and reset managers.
Link: https://github.com/981213/linux/commit/37c81bebaf54
> diff --git a/drivers/reset/reset-sf19a2890-periphcrm.c b/drivers/reset/reset-sf19a2890-periphcrm.c
> new file mode 100644
> index 0000000000000..54b476237bd48
> --- /dev/null
> +++ b/drivers/reset/reset-sf19a2890-periphcrm.c
[ ... ]
> +static const struct of_device_id sf19a2890_periphrst_ids[] = {
> + { .compatible = "siflower,sf19a2890-gmac-crm", .data = &sf19a2890_gmac_rst },
> + { .compatible = "siflower,sf19a2890-gpio-crm", .data = &sf19a2890_single_rst },
> + { .compatible = "siflower,sf19a2890-i2c-crm", .data = &sf19a2890_single_rst },
> + { .compatible = "siflower,sf19a2890-pwm-crm", .data = &sf19a2890_single_rst },
> + { .compatible = "siflower,sf19a2890-rf-crm", .data = &sf19a2890_wlan_rst },
> + { .compatible = "siflower,sf19a2890-spi-crm", .data = &sf19a2890_spi_rst },
> + { .compatible = "siflower,sf19a2890-timer-crm", .data = &sf19a2890_single_rst },
> + { .compatible = "siflower,sf19a2890-uart-crm", .data = &sf19a2890_uart_rst },
> + { .compatible = "siflower,sf19a2890-usb-crm", .data = &sf19a2890_usb_rst },
> + { .compatible = "siflower,sf19a2890-wdt-crm", .data = &sf19a2890_single_rst },
> + { .compatible = "siflower,sf19a2890-wlan24-crm", .data = &sf19a2890_wlan_rst },
> + { .compatible = "siflower,sf19a2890-wlan5-crm", .data = &sf19a2890_wlan_rst },
> + { /* sentinel */ }
> +};
> +
> +static int sf19a2890_periphrst_probe(struct auxiliary_device *adev,
> + const struct auxiliary_device_id *id)
> +{
> + const struct sf19a2890_periphrst_data *data;
> + struct device *dev = &adev->dev;
> + const struct of_device_id *match;
> + struct sf19a2890_periphrst *rst;
> +
> + /* The OF node is the parent's, so device_get_match_data() cannot be used */
> + match = of_match_node(sf19a2890_periphrst_ids, dev->of_node);
[Severity: Low]
Will sf19a2890_periphrst_ids trigger a -Wunused-const-variable warning when
built with CONFIG_COMPILE_TEST=y and CONFIG_OF=n? When CONFIG_OF is
disabled, of_match_node() expands to NULL without evaluating its first
argument, and sf19a2890_periphrst_ids is not referenced anywhere else.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-sf19a2890-sysm-v5-0-4ba44a0db17d@telaak.dev?part=6
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver
2026-11-24 4:41 ` [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver Joseph Telaak via B4 Relay
@ 2026-11-24 4:58 ` sashiko-bot
2026-11-24 5:24 ` Joseph Telaak
0 siblings, 1 reply; 10+ messages in thread
From: sashiko-bot @ 2026-11-24 4:58 UTC (permalink / raw)
To: Joseph Telaak; +Cc: linux-clk, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: siflower: broken late clock publication and defaults in
sf19a2890
--
commit 99941c15178fb0fa3ccc19a6c27f477a30815152
Author: Joseph Telaak <joseph@telaak.dev>
clk: siflower: Add SF19A2890 clock manager driver
This commit adds a clock driver for the Siflower SF19A2890 SoC, registering
the CPU clock and its parent PLLs early via CLK_OF_DECLARE_DRIVER and the
remaining mux/divider clocks from a platform driver.
Link: https://github.com/981213/linux/commit/0466d6303c25
> diff --git a/drivers/clk/siflower/clk-sf19a2890.c b/drivers/clk/siflower/clk-sf19a2890.c
> new file mode 100644
> index 0000000000000..3ccb768331ad3
> --- /dev/null
> +++ b/drivers/clk/siflower/clk-sf19a2890.c
[ ... ]
> +static void __init sf19a2890_clk_early_init(struct device_node *node)
> +{
> + struct clk_hw_onecell_data *data;
> + void __iomem *base;
> + unsigned int i;
> + int ret;
> +
> + data = kzalloc_flex(*data, hws, CLK_SF19A2890_NR_CLKS);
> + if (!data)
> + return;
> +
> + data->num = CLK_SF19A2890_NR_CLKS;
> + /* The clocks registered at probe defer until then */
> + for (i = 0; i < data->num; i++)
> + data->hws[i] = ERR_PTR(-EPROBE_DEFER);
> +
> + base = of_iomap(node, 0);
> + if (!base) {
> + pr_err("failed to map the registers\n");
> + goto err_free;
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(sf19a2890_early_clks); i++) {
> + unsigned int id = sf19a2890_early_clks[i];
> + struct clk_hw *hw = sf19a2890_hws[id];
> +
> + hw_to_sf_clk_common(hw)->base = base;
> + ret = of_clk_hw_register(node, hw);
> + if (ret) {
> + pr_err("failed to register clock %u: %d\n", id, ret);
> + goto err_unregister;
> + }
> + data->hws[id] = hw;
> + }
> +
> + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
> + if (ret) {
> + pr_err("failed to add the clock provider: %d\n", ret);
> + goto err_unregister;
> + }
> +
> + sf19a2890_clk_data = data;
> + sf19a2890_clk_base = base;
> + return;
> +
> +err_unregister:
> + while (i--)
> + clk_hw_unregister(data->hws[sf19a2890_early_clks[i]]);
> + iounmap(base);
> +err_free:
> + kfree(data);
> +}
> +
> +CLK_OF_DECLARE_DRIVER(sf19a2890_clk, "siflower,sf19a2890-clk", sf19a2890_clk_early_init);
> +
> +static void sf19a2890_clk_unpublish(void *data)
> +{
> + struct clk_hw **hw = data;
> +
> + *hw = ERR_PTR(-EPROBE_DEFER);
> +}
> +
> +static int sf19a2890_clk_probe(struct platform_device *pdev)
> +{
> + struct clk_hw_onecell_data *data = sf19a2890_clk_data;
> + struct device *dev = &pdev->dev;
> + unsigned int i;
> + int ret;
> +
> + if (!data)
> + return -ENODEV;
> +
> + for (i = 0; i < data->num; i++) {
> + struct clk_hw *hw = sf19a2890_hws[i];
> +
> + /* Registered early */
> + if (!IS_ERR(data->hws[i]))
> + continue;
> +
> + hw_to_sf_clk_common(hw)->base = sf19a2890_clk_base;
> + ret = devm_clk_hw_register(dev, hw);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to register clock %u\n", i);
> +
> + data->hws[i] = hw;
[Severity: Medium]
As reported by Brian Masney on v4 [1], can setting data->hws[i] = hw after
devm_clk_hw_register() and registering the OF provider while late clocks
are still ERR_PTR(-EPROBE_DEFER) break orphan reparenting and
assigned-clocks defaults?
devm_clk_hw_register() runs clk_core_reparent_orphans_nolock() before
returning. Because data->hws[i] is still ERR_PTR(-EPROBE_DEFER) during
that call, any already-registered orphan clock parented by the last clock
(CLK_MUXDIV_NPU_PE) cannot resolve its parent via the OF provider and
remains orphaned.
In addition, of_clk_add_hw_provider() in sf19a2890_clk_early_init() calls
of_clk_set_defaults(node, true) while the 17 late clocks are still
ERR_PTR(-EPROBE_DEFER). If the clock controller DT node specifies
assigned-clocks for any late clock, of_clk_add_hw_provider() fails with
-EPROBE_DEFER and tears down all early clocks including the CPU clock;
even when early init succeeds, sf19a2890_clk_probe() never re-runs
of_clk_set_defaults() after registering the late clocks.
[1] https://lore.kernel.org/r/179545199778.209212.13754058672210050271.b4-review@b4
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-sf19a2890-sysm-v5-0-4ba44a0db17d@telaak.dev?part=3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver
2026-11-24 4:58 ` sashiko-bot
@ 2026-11-24 5:24 ` Joseph Telaak
0 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak @ 2026-11-24 5:24 UTC (permalink / raw)
To: sashiko-reviews
Cc: Stephen Boyd, Brian Masney, Rob Herring, Conor Dooley, linux-clk,
devicetree
> devm_clk_hw_register() runs clk_core_reparent_orphans_nolock() before
> returning. Because data->hws[i] is still ERR_PTR(-EPROBE_DEFER) during
> that call, any already-registered orphan clock parented by the last clock
> (CLK_MUXDIV_NPU_PE) cannot resolve its parent via the OF provider and
> remains orphaned.
No clock in this driver has a late clock as its parent: the muxes take
the PLLs by clk_hw and the oscillators through "clocks". An orphan in
another driver that looks a late clock up through the provider is
picked up by the next clock registration, as with any driver that
registers its clocks before adding its provider. Nothing on the SoC
runs from the NPU clock. On the GL-SFT1200, clk_orphan_summary and
devices_deferred are empty with v5.
> In addition, of_clk_add_hw_provider() in sf19a2890_clk_early_init() calls
> of_clk_set_defaults(node, true) while the 17 late clocks are still
> ERR_PTR(-EPROBE_DEFER). If the clock controller DT node specifies
> assigned-clocks for any late clock, of_clk_add_hw_provider() fails with
> -EPROBE_DEFER and tears down all early clocks including the CPU clock;
Right: assigned-clocks in the controller's own node can only name the
four early clocks, as with clk-eyeq, which publishes its late clocks the
same way. No device tree sets them there; a consumer's assigned-clocks
are in its own node and applied when it probes.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-24 5:24 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 2/6] dt-bindings: clock: Add Siflower SF19A2890 clock manager Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver Joseph Telaak via B4 Relay
2026-11-24 4:58 ` sashiko-bot
2026-11-24 5:24 ` Joseph Telaak
2026-11-24 4:41 ` [PATCH v5 4/6] dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 5/6] clk: siflower: Add SF19A2890 peripheral clock driver Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver Joseph Telaak via B4 Relay
2026-11-24 4:52 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox