Skip to contentSkip to conversation

Add NPCM8XX clock driver

PATCH Superseded Tomer Maimon 2 participants 15 messages Jul 1, 2024 – Jul 4, 2024

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Tomer Maimon

author maintainer
#0 lore raw

cover Add NPCM8XX clock driver

This patchset adds clock support for the Nuvoton Arbel NPCM8XX Board Management controller (BMC) SoC family.

The NPCM8xx clock controller is created using the auxiliary device framework and set up in the npcm reset driver since the NPCM8xx clock is using the same register region.

This patchset based on NPCM8xx clock controller V25.

This patchset was tested on the Arbel NPCM8XX evaluation board.

Tomer Maimon (6):
dt-bindings: reset: npcm: add clock properties
dt-bindings: clock: npcm845: Add reference 25m clock property
arm64: dts: add clock-cell property to reset node
arm64: dts: modify clock property in modules node
reset: npcm: register npcm8xx clock auxiliary bus device
clk: npcm8xx: add clock controller

 .../bindings/reset/nuvoton,npcm750-reset.yaml |  18 +
 .../dts/nuvoton/nuvoton-common-npcm8xx.dtsi   |  26 +-
 .../boot/dts/nuvoton/nuvoton-npcm845-evb.dts  |   7 +
 .../boot/dts/nuvoton/nuvoton-npcm845.dtsi     |   8 +-
 drivers/clk/Kconfig                           |   8 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-npcm8xx.c                     | 430 ++++++++++++++++++
 drivers/reset/reset-npcm.c                    |  72 ++-
 8 files changed, 553 insertions(+), 17 deletions(-)
 create mode 100644 drivers/clk/clk-npcm8xx.c
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/6 dt-bindings: reset: npcm: add clock properties

This commit adds a 25MHz reference clock and clock-cell properties to the NPCM reset document. The addition is necessitated by the integration of the NPCM8xx clock auxiliary bus device into the NPCM reset driver.

The inclusion of the NPCM8xx clock properties in the reset document is crucial as the reset block also serves as a clock provider for the NPCM8xx clock. This enhancement is intended to facilitate the use of the NPCM8xx clock driver.

---
 .../bindings/reset/nuvoton,npcm750-reset.yaml  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/reset/nuvoton,npcm750-reset.yaml +18 -0
index d82e65e37cc0..72523f1bbc18 100644
@@ -21,6 +21,13 @@ properties:
   '#reset-cells':
     const: 2
 
+  '#clock-cells':
+    const: 1
+
+  clocks:
+    items:
+      - description: specify external 25MHz reference clock.
+
   nuvoton,sysgcr:
     $ref: /schemas/types.yaml#/definitions/phandle
     description: a phandle to access GCR registers.
@@ -39,6 +46,17 @@ required:
   - '#reset-cells'
   - nuvoton,sysgcr
 
+if:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - nuvoton,npcm845-reset
+then:
+  required:
+    - '#clock-cells'
+    - clocks
+
 additionalProperties: false
 
 examples:
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 2/6 dt-bindings: clock: npcm845: Add reference 25m clock property

In reply to Tomer Maimon

The NPCM8XX clock driver uses a 25Mhz external clock, therefore adding clock property.

The new required clock property does not break the NPCM8XX clock ABI since the NPCM8XX clock driver hasn't merged yet to the Linux vanilla.

---
 arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi | 9 +++++----
 arch/arm64/boot/dts/nuvoton/nuvoton-npcm845-evb.dts     | 7 +++++++
 2 files changed, 12 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi +5 -4
index ecd171b2feba..41d345448430 100644
@@ -52,6 +52,7 @@ rstc: reset-controller@f0801000 {
 			reg = <0x0 0xf0801000 0x0 0x78>;
 			#reset-cells = <2>;
 			nuvoton,sysgcr = <&gcr>;
+			clocks = <&refclk>;
 		};
 
 		clk: clock-controller@f0801000 {
@@ -81,7 +82,7 @@ timer0: timer@8000 {
 				compatible = "nuvoton,npcm845-timer";
 				interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
 				reg = <0x8000 0x1C>;
-				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				clocks = <&refclk>;
 				clock-names = "refclk";
 			};
 
@@ -153,7 +154,7 @@ watchdog0: watchdog@801c {
 				interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
 				reg = <0x801c 0x4>;
 				status = "disabled";
-				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				clocks = <&refclk>;
 				syscon = <&gcr>;
 			};
 
@@ -162,7 +163,7 @@ watchdog1: watchdog@901c {
 				interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
 				reg = <0x901c 0x4>;
 				status = "disabled";
-				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				clocks = <&refclk>;
 				syscon = <&gcr>;
 			};
 
@@ -171,7 +172,7 @@ watchdog2: watchdog@a01c {
 				interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
 				reg = <0xa01c 0x4>;
 				status = "disabled";
-				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				clocks = <&refclk>;
 				syscon = <&gcr>;
 			};
 		};
arch/arm64/boot/dts/nuvoton/nuvoton-npcm845-evb.dts +7 -0
index a5ab2bc0f835..83c2f4e138e5 100644
@@ -19,6 +19,13 @@ chosen {
 	memory {
 		reg = <0x0 0x0 0x0 0x40000000>;
 	};
+
+	refclk: refclk-25mhz {
+		compatible = "fixed-clock";
+		clock-output-names = "ref";
+		clock-frequency = <25000000>;
+		#clock-cells = <0>;
+	};
 };
 
 &serial0 {
Signature · 1 line
2.34.1
maintainer
#3 lore raw

Re: [linux dev-6.6 v1 2/6] dt-bindings: clock: npcm845: Add reference 25m clock property

Quoted 10 lines · Tomer Maimon

The NPCM8XX clock driver uses a 25Mhz external clock, therefore adding clock property.

The new required clock property does not break the NPCM8XX clock ABI since the NPCM8XX clock driver hasn't merged yet to the Linux vanilla.

---
 arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi | 9 +++++----
 arch/arm64/boot/dts/nuvoton/nuvoton-npcm845-evb.dts     | 7 +++++++

The patch subject is quite misleading - this isn't modifying the binding at all, rather the actual devicetrees.

Has this work been sent upstream?

arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi rstc: reset-controller@f0801000 { · line 55

Quoted 11 lines
 2 files changed, 12 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi +1 -0
index ecd171b2feba..41d345448430 100644
@@ -52,6 +52,7 @@ rstc: reset-controller@f0801000 {
 			reg = <0x0 0xf0801000 0x0 0x78>;
 			#reset-cells = <2>;
 			nuvoton,sysgcr = <&gcr>;
+			clocks = <&refclk>;

Why not add #clock-cells here while we're at it (squash patch 3/6 into this one)?

Andrew

author maintainer
#4 lore raw

Re: [linux dev-6.6 v1 2/6] dt-bindings: clock: npcm845: Add reference 25m clock property

Hi Andrew,

Quoted 13 lines · Andrew Jeffery
Quoted 10 lines · Tomer Maimon

The NPCM8XX clock driver uses a 25Mhz external clock, therefore adding clock property.

The new required clock property does not break the NPCM8XX clock ABI since the NPCM8XX clock driver hasn't merged yet to the Linux vanilla.

---
 arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi | 9 +++++----
 arch/arm64/boot/dts/nuvoton/nuvoton-npcm845-evb.dts     | 7 +++++++
Quoted 4 lines

The patch subject is quite misleading - this isn't modifying the binding at all, rather the actual devicetrees.

Has this work been sent upstream?

It was sent months ago but is added to the clock node and not the reset node. Now the clock reference is represented in the reset node but since the clock driver has so many versions I am not sure this solution will be accepted :-(
This is why I prefer to wait until the clock maintainer approves the driver and then I could proceed with the other clock device tree patches.

but with the OpenBMC Linux kernel is a different story since we have customers that need to use the clock driver we need to send the current full solution and not part like I did with the Vanilla upstream.

Quoted 15 lines

arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi rstc: reset-controller@f0801000 { · line 55

Quoted 12 lines
 2 files changed, 12 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi +1 -0
index ecd171b2feba..41d345448430 100644
@@ -52,6 +52,7 @@ rstc: reset-controller@f0801000 {
                      reg = <0x0 0xf0801000 0x0 0x78>;
                      #reset-cells = <2>;
                      nuvoton,sysgcr = <&gcr>;
+                     clocks = <&refclk>;

Why not add #clock-cells here while we're at it (squash patch 3/6 into this one)?

because it is not part of the clock reference

Quoted 2 lines

Andrew

appreicate your understanding!

Tomer

author maintainer
#5 lore raw

PATCH 3/6 arm64: dts: add clock-cell property to reset node

In reply to Tomer Maimon

Add clock-cell property to reset node, The addition is necessitated by the integration of the NPCM8xx clock auxiliary bus device into the NPCM reset driver.

---
 arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi +1 -0
index 41d345448430..84a2a5172597 100644
@@ -53,6 +53,7 @@ rstc: reset-controller@f0801000 {
 			#reset-cells = <2>;
 			nuvoton,sysgcr = <&gcr>;
 			clocks = <&refclk>;
+			#clock-cells = <1>;
 		};
 
 		clk: clock-controller@f0801000 {
Signature · 1 line
2.34.1
author maintainer
#6 lore raw

PATCH 4/6 arm64: dts: modify clock property in modules node

In reply to Tomer Maimon

Modify clock property handler in UART, CPU, PECI modules to reset controller.

---
 .../boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi | 16 ++++++++--------
 arch/arm64/boot/dts/nuvoton/nuvoton-npcm845.dtsi |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)
arch/arm64/boot/dts/nuvoton/nuvoton-common-npcm8xx.dtsi +8 -8
index 84a2a5172597..ed9f0edf1888 100644
@@ -74,7 +74,7 @@ peci: peci-controller@100000 {
 				compatible = "nuvoton,npcm845-peci";
 				reg = <0x100000 0x1000>;
 				interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
-				clocks = <&clk NPCM8XX_CLK_APB3>;
+				clocks = <&rstc NPCM8XX_CLK_APB3>;
 				cmd-timeout-ms = <1000>;
 				status = "disabled";
 			};
@@ -90,7 +90,7 @@ timer0: timer@8000 {
 			serial0: serial@0 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x0 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART>;
 				interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
@@ -99,7 +99,7 @@ serial0: serial@0 {
 			serial1: serial@1000 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x1000 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART>;
 				interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
@@ -108,7 +108,7 @@ serial1: serial@1000 {
 			serial2: serial@2000 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x2000 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART>;
 				interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
@@ -117,7 +117,7 @@ serial2: serial@2000 {
 			serial3: serial@3000 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x3000 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART>;
 				interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
@@ -126,7 +126,7 @@ serial3: serial@3000 {
 			serial4: serial@4000 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x4000 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART>;
 				interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
@@ -135,7 +135,7 @@ serial4: serial@4000 {
 			serial5: serial@5000 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x5000 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART>;
 				interrupts = <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
@@ -144,7 +144,7 @@ serial5: serial@5000 {
 			serial6: serial@6000 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x6000 0x1000>;
-				clocks = <&clk NPCM8XX_CLK_UART>;
+				clocks = <&rstc NPCM8XX_CLK_UART2>;
 				interrupts = <GIC_SPI 198 IRQ_TYPE_LEVEL_HIGH>;
 				reg-shift = <2>;
 				status = "disabled";
arch/arm64/boot/dts/nuvoton/nuvoton-npcm845.dtsi +4 -4
index 383938dcd3ce..3cbcea65eba2 100644
@@ -14,7 +14,7 @@ cpus {
 		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a35";
-			clocks = <&clk NPCM8XX_CLK_CPU>;
+			clocks = <&rstc NPCM8XX_CLK_CPU>;
 			reg = <0x0 0x0>;
 			next-level-cache = <&l2>;
 			enable-method = "psci";
@@ -23,7 +23,7 @@ cpu0: cpu@0 {
 		cpu1: cpu@1 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a35";
-			clocks = <&clk NPCM8XX_CLK_CPU>;
+			clocks = <&rstc NPCM8XX_CLK_CPU>;
 			reg = <0x0 0x1>;
 			next-level-cache = <&l2>;
 			enable-method = "psci";
@@ -32,7 +32,7 @@ cpu1: cpu@1 {
 		cpu2: cpu@2 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a35";
-			clocks = <&clk NPCM8XX_CLK_CPU>;
+			clocks = <&rstc NPCM8XX_CLK_CPU>;
 			reg = <0x0 0x2>;
 			next-level-cache = <&l2>;
 			enable-method = "psci";
@@ -41,7 +41,7 @@ cpu2: cpu@2 {
 		cpu3: cpu@3 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a35";
-			clocks = <&clk NPCM8XX_CLK_CPU>;
+			clocks = <&rstc NPCM8XX_CLK_CPU>;
 			reg = <0x0 0x3>;
 			next-level-cache = <&l2>;
 			enable-method = "psci";
Signature · 1 line
2.34.1
maintainer
#7 lore raw

Re: [linux dev-6.6 v1 4/6] arm64: dts: modify clock property in modules node

Quoted 2 lines · Tomer Maimon

Modify clock property handler in UART, CPU, PECI modules to reset controller.

Sooo... I'm not sure how much of a hack this is, as it's not clear to me that the devicetree spec allows multiple labels on a node, but dtc seems to accept it.

You can reduce this patch to a short diff with:

- rstc: reset-controller@f0801000 {
+ clk: rstc: reset-controller@f0801000 {

and leave the rest of the phandles in-tact.

Again, something to investigate for yourself and maybe see how it flies upstream...

Andrew

maintainer
#8 lore raw

Re: [linux dev-6.6 v1 4/6] arm64: dts: modify clock property in modules node

Quoted 13 lines · Andrew Jeffery
Quoted 2 lines · Tomer Maimon

Modify clock property handler in UART, CPU, PECI modules to reset controller.

Sooo... I'm not sure how much of a hack this is, as it's not clear to me that the devicetree spec allows multiple labels on a node, but dtc seems to accept it.

You can reduce this patch to a short diff with:

(quoted diff) +1 -1
-               rstc: reset-controller@f0801000 {
+               clk: rstc: reset-controller@f0801000 {
Quoted 2 lines

and leave the rest of the phandles in-tact.

Well, there is some precedent:

```
$ git grep -E '.+: .+: .+ \{' -- arch/arm/boot/dts/
arch/arm/boot/dts/arm/arm-realview-eb.dtsi:             charlcd: fpga_charlcd: charlcd@10008000 {
arch/arm/boot/dts/arm/vexpress-v2p-ca9.dts:             smbclk: oscclk2: tcrefclk {
arch/arm/boot/dts/rockchip/rk3188-bqedison2qc.dts:                      vcc_io: vcc_hdmi: REG4 {
arch/arm/boot/dts/rockchip/rk3288-firefly-reload-core.dtsi:                     vccio_wl: vcc_18: REG11 {
arch/arm/boot/dts/rockchip/rk3288-firefly-reload.dts:   vcc_5v: vcc_sys: vsys-regulator {
arch/arm/boot/dts/rockchip/rk3288-firefly.dtsi: vbat_wl: vcc_sys: vsys-regulator {
arch/arm/boot/dts/rockchip/rk3288-firefly.dtsi:                 vccio_wl: vcc_18: REG11 {
arch/arm/boot/dts/rockchip/rk3288-rock2-som.dtsi:                       vcc_io: vccio_codec: REG2 {
arch/arm/boot/dts/rockchip/rk3288-veyron.dtsi:                  vcc18_wl: vcc18_flashio: vcc_18: DCDC_REG4 {
arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts:                     vqmmc_sdcard: ldo4_reg: LDO4 {
arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts:                      vqmmc_sdcard: ldo4_reg: LDO4 {
```

Andrew

author maintainer
#9 lore raw

Re: [linux dev-6.6 v1 4/6] arm64: dts: modify clock property in modules node

Hi Andrew,

Great suggestion :-) i will try it!

Thanks,

Tomer

Quoted 36 lines · Andrew Jeffery
Quoted 13 lines · Andrew Jeffery
Quoted 2 lines · Tomer Maimon

Modify clock property handler in UART, CPU, PECI modules to reset controller.

Sooo... I'm not sure how much of a hack this is, as it's not clear to me that the devicetree spec allows multiple labels on a node, but dtc seems to accept it.

You can reduce this patch to a short diff with:

(quoted diff) +1 -1
-               rstc: reset-controller@f0801000 {
+               clk: rstc: reset-controller@f0801000 {
Quoted 2 lines

and leave the rest of the phandles in-tact.

Well, there is some precedent:

```
$ git grep -E '.+: .+: .+ \{' -- arch/arm/boot/dts/
arch/arm/boot/dts/arm/arm-realview-eb.dtsi:             charlcd: fpga_charlcd: charlcd@10008000 {
arch/arm/boot/dts/arm/vexpress-v2p-ca9.dts:             smbclk: oscclk2: tcrefclk {
arch/arm/boot/dts/rockchip/rk3188-bqedison2qc.dts:                      vcc_io: vcc_hdmi: REG4 {
arch/arm/boot/dts/rockchip/rk3288-firefly-reload-core.dtsi:                     vccio_wl: vcc_18: REG11 {
arch/arm/boot/dts/rockchip/rk3288-firefly-reload.dts:   vcc_5v: vcc_sys: vsys-regulator {
arch/arm/boot/dts/rockchip/rk3288-firefly.dtsi: vbat_wl: vcc_sys: vsys-regulator {
arch/arm/boot/dts/rockchip/rk3288-firefly.dtsi:                 vccio_wl: vcc_18: REG11 {
arch/arm/boot/dts/rockchip/rk3288-rock2-som.dtsi:                       vcc_io: vccio_codec: REG2 {
arch/arm/boot/dts/rockchip/rk3288-veyron.dtsi:                  vcc18_wl: vcc18_flashio: vcc_18: DCDC_REG4 {
arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts:                     vqmmc_sdcard: ldo4_reg: LDO4 {
arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts:                      vqmmc_sdcard: ldo4_reg: LDO4 {
```

Andrew

author maintainer
#10 lore raw

Re: [linux dev-6.6 v1 4/6] arm64: dts: modify clock property in modules node

Hi Andrew,

One more question, for this change the clock node should be removed.

I am afraid that removing the clock node could cause an ABI break, not?

Thanks,

Tomer

Quoted 46 lines · Tomer Maimon

Hi Andrew,

Great suggestion :-) i will try it!

Thanks,

Tomer

Quoted 36 lines · Andrew Jeffery
Quoted 13 lines · Andrew Jeffery
Quoted 2 lines · Tomer Maimon

Modify clock property handler in UART, CPU, PECI modules to reset controller.

Sooo... I'm not sure how much of a hack this is, as it's not clear to me that the devicetree spec allows multiple labels on a node, but dtc seems to accept it.

You can reduce this patch to a short diff with:

(quoted diff) +1 -1
-               rstc: reset-controller@f0801000 {
+               clk: rstc: reset-controller@f0801000 {
Quoted 2 lines

and leave the rest of the phandles in-tact.

Well, there is some precedent:

```
$ git grep -E '.+: .+: .+ \{' -- arch/arm/boot/dts/
arch/arm/boot/dts/arm/arm-realview-eb.dtsi:             charlcd: fpga_charlcd: charlcd@10008000 {
arch/arm/boot/dts/arm/vexpress-v2p-ca9.dts:             smbclk: oscclk2: tcrefclk {
arch/arm/boot/dts/rockchip/rk3188-bqedison2qc.dts:                      vcc_io: vcc_hdmi: REG4 {
arch/arm/boot/dts/rockchip/rk3288-firefly-reload-core.dtsi:                     vccio_wl: vcc_18: REG11 {
arch/arm/boot/dts/rockchip/rk3288-firefly-reload.dts:   vcc_5v: vcc_sys: vsys-regulator {
arch/arm/boot/dts/rockchip/rk3288-firefly.dtsi: vbat_wl: vcc_sys: vsys-regulator {
arch/arm/boot/dts/rockchip/rk3288-firefly.dtsi:                 vccio_wl: vcc_18: REG11 {
arch/arm/boot/dts/rockchip/rk3288-rock2-som.dtsi:                       vcc_io: vccio_codec: REG2 {
arch/arm/boot/dts/rockchip/rk3288-veyron.dtsi:                  vcc18_wl: vcc18_flashio: vcc_18: DCDC_REG4 {
arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts:                     vqmmc_sdcard: ldo4_reg: LDO4 {
arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts:                      vqmmc_sdcard: ldo4_reg: LDO4 {
```

Andrew

maintainer
#11 lore raw

Re: [linux dev-6.6 v1 4/6] arm64: dts: modify clock property in modules node

Quoted 5 lines · Tomer Maimon

Hi Andrew,

One more question, for this change the clock node should be removed.

I am afraid that removing the clock node could cause an ABI break, not?

Possibly it could break other devicetrees, depending on how they're constructed.

I'm hesitant to merge these patches to the OpenBMC tree without them being accepted upstream because of the potential for further breaks down the track. The situation is already too murky for my taste, and I'd prefer we keep things to a single break with whatever's accepted upstream.

I recognise that's probably frustrating for you, but I think it focuses the effort in the right area (getting the changes merged upstream).

I'm not sure how you best get Stephen's attention though.

Andrew

author maintainer
#12 lore raw

Re: [linux dev-6.6 v1 4/6] arm64: dts: modify clock property in modules node

Hi Andrew,

Quoted 8 lines · Andrew Jeffery
Quoted 5 lines · Tomer Maimon

Hi Andrew,

One more question, for this change the clock node should be removed.

I am afraid that removing the clock node could cause an ABI break, not?

Quoted 8 lines

Possibly it could break other devicetrees, depending on how they're constructed.

I'm hesitant to merge these patches to the OpenBMC tree without them being accepted upstream because of the potential for further breaks down the track. The situation is already too murky for my taste, and I'd prefer we keep things to a single break with whatever's accepted upstream.

Yes, I understand you, I believe this saga will end soon we are doing our best for a happy ending :-)

Quoted 7 lines

I recognise that's probably frustrating for you, but I think it focuses the effort in the right area (getting the changes merged upstream).

I'm not sure how you best get Stephen's attention though.

Andrew

Best regards,

Tomer

author maintainer
#13 lore raw

PATCH 5/6 reset: npcm: register npcm8xx clock auxiliary bus device

In reply to Tomer Maimon

Add NPCM8xx clock controller auxiliary bus device registration.

The NPCM8xx clock controller is registered as an aux device because the reset and the clock controller share the same register region.

---
 drivers/reset/reset-npcm.c | 72 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)
drivers/reset/reset-npcm.c +71 -1
index f6c4f854f2be..4c6ac6767f81 100644
@@ -15,6 +15,8 @@
 #include <linux/regmap.h>
 #include <linux/of_address.h>
 
+#include <soc/nuvoton/clock-npcm8xx.h>
+
 /* NPCM7xx GCR registers */
 #define NPCM_MDLR_OFFSET	0x7C
 #define NPCM7XX_MDLR_USBD0	BIT(9)
@@ -89,6 +91,7 @@ struct npcm_rc_data {
 	const struct npcm_reset_info *info;
 	struct regmap *gcr_regmap;
 	u32 sw_reset_number;
+	struct device *dev;
 	void __iomem *base;
 	spinlock_t lock;
 };
@@ -373,6 +376,67 @@ static const struct reset_control_ops npcm_rc_ops = {
 	.status		= npcm_rc_status,
 };
 
+static void npcm_clock_unregister_adev(void *_adev)
+{
+	struct auxiliary_device *adev = _adev;
+
+	auxiliary_device_delete(adev);
+	auxiliary_device_uninit(adev);
+}
+
+static void npcm_clock_adev_release(struct device *dev)
+{
+	struct auxiliary_device *adev = to_auxiliary_dev(dev);
+	struct npcm_clock_adev *rdev = to_npcm_clock_adev(adev);
+
+	kfree(rdev);
+}
+
+static struct auxiliary_device *npcm_clock_adev_alloc(struct npcm_rc_data *rst_data, char *clk_name)
+{
+	struct npcm_clock_adev *rdev;
+	struct auxiliary_device *adev;
+	int ret;
+
+	rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
+	if (!rdev)
+		return ERR_PTR(-ENOMEM);
+
+	rdev->base = rst_data->base;
+
+	adev = &rdev->adev;
+	adev->name = clk_name;
+	adev->dev.parent = rst_data->dev;
+	adev->dev.release = npcm_clock_adev_release;
+	adev->id = 555u;
+
+	ret = auxiliary_device_init(adev);
+	if (ret) {
+		kfree(rdev);
+		return ERR_PTR(ret);
+	}
+
+	return adev;
+}
+
+static int npcm8xx_clock_controller_register(struct npcm_rc_data *rst_data, char *clk_name)
+{
+	struct auxiliary_device *adev;
+	int ret;
+
+	adev = npcm_clock_adev_alloc(rst_data, clk_name);
+	if (IS_ERR(adev))
+		return PTR_ERR(adev);
+
+	ret = auxiliary_device_add(adev);
+	if (ret) {
+		auxiliary_device_uninit(adev);
+		return ret;
+	}
+
+	return devm_add_action_or_reset(rst_data->dev, npcm_clock_unregister_adev, adev);
+}
+
 static int npcm_rc_probe(struct platform_device *pdev)
 {
 	struct npcm_rc_data *rc;
@@ -393,6 +457,7 @@ static int npcm_rc_probe(struct platform_device *pdev)
 	rc->rcdev.of_node = pdev->dev.of_node;
 	rc->rcdev.of_reset_n_cells = 2;
 	rc->rcdev.of_xlate = npcm_reset_xlate;
+	rc->dev = &pdev->dev;
 
 	ret = devm_reset_controller_register(&pdev->dev, &rc->rcdev);
 	if (ret) {
@@ -414,7 +479,12 @@ static int npcm_rc_probe(struct platform_device *pdev)
 		}
 	}
 
-	return ret;
+	switch (rc->info->bmc_id) {
+	case BMC_NPCM8XX:
+		return npcm8xx_clock_controller_register(rc, "clk-npcm8xx");
+	default:
+		return ret;
+	}
 }
 
 static struct platform_driver npcm_rc_driver = {
Signature · 1 line
2.34.1
author maintainer
#14 lore raw

PATCH 6/6 clk: npcm8xx: add clock controller

In reply to Tomer Maimon

Add auxiliary driver to support Nuvoton Arbel BMC NPCM8XX contains an integrated clock controller which generates and supplies clocks to all modules within the BMC.

The NPCM8xx clock controller is created using the auxiliary device framework and set up in the npcm reset driver since the NPCM8xx clock is using the same register region.

---
 drivers/clk/Kconfig       |   8 +
 drivers/clk/Makefile      |   1 +
 drivers/clk/clk-npcm8xx.c | 430 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 439 insertions(+)
 create mode 100644 drivers/clk/clk-npcm8xx.c
drivers/clk/Kconfig +8 -0
index c30099866174..9bc5f2dfc7e2 100644
@@ -325,6 +325,14 @@ config COMMON_CLK_LOCHNAGAR
 	  This driver supports the clocking features of the Cirrus Logic
 	  Lochnagar audio development board.
 
+config COMMON_CLK_NPCM8XX
+	tristate "Clock driver for the NPCM8XX SoC Family"
+	depends on ARCH_NPCM || COMPILE_TEST
+	help
+	  This driver supports the clocks on the Nuvoton BMC NPCM8XX SoC Family,
+	  all the clocks are initialized by the bootloader, so this driver
+	  allows only reading of current settings directly from the hardware.
+
 config COMMON_CLK_LOONGSON2
 	bool "Clock driver for Loongson-2 SoC"
 	depends on LOONGARCH || COMPILE_TEST
drivers/clk/Makefile +1 -0
index 18969cbd4bb1..e2cbc6cceb8c 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_ARCH_MILBEAUT_M10V)	+= clk-milbeaut.o
 obj-$(CONFIG_ARCH_MOXART)		+= clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK)		+= clk-nomadik.o
 obj-$(CONFIG_ARCH_NPCM7XX)	    	+= clk-npcm7xx.o
+obj-$(CONFIG_COMMON_CLK_NPCM8XX)	+= clk-npcm8xx.o
 obj-$(CONFIG_ARCH_NSPIRE)		+= clk-nspire.o
 obj-$(CONFIG_COMMON_CLK_PALMAS)		+= clk-palmas.o
 obj-$(CONFIG_CLK_LS1028A_PLLDIG)	+= clk-plldig.o
drivers/clk/clk-npcm8xx.c new file +430 -0

430 lines not on this page · raw message

Signature · 1 line
2.34.1