Skip to contentSkip to conversation

PL022 DT fixes for seattle, lg and lpc platform

PATCH Applied Kuldeep Singh 7 participants 21 messages Mar 11, 2022 – Mar 27, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover PL022 DT fixes for seattle, lg and lpc platform

This patchset is an attempt to fix DTs which are not compliant with pl022 spi binding. Please note, there are other fixes required also which are sent from other trees.
As git trees for these platforms are not available, Rob advised me to seek help from soc tree maintainers.

Arnd and Olof, could you please help in reviewing and merging this patchset.

These patches are base on
git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git, arm/dt

Link to v1 below:
https://lore.kernel.org/linux-devicetree/20220311025932.GD54098@9a2d8922b8f1/T/#m734e470b3be87b7591b3e6d618e4c777f8e61981

Patch1: Fix spi clock for amd seattle platform
Patch2: Fix spi clock for lg platforms
Patch3: Fix spi clock for lpc platform

Kuldeep Singh (3):
arm64: dts: seattle: Update spi clock properties
arm64: dts: lg131x: Update spi clock properties
ARM: dts: lpc32xx: Update spi clock properties

 arch/arm/boot/dts/lpc32xx.dtsi               | 8 ++++----
 arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi | 8 ++++----
 arch/arm64/boot/dts/lg/lg1312.dtsi           | 8 ++++----
 arch/arm64/boot/dts/lg/lg1313.dtsi           | 8 ++++----
 4 files changed, 16 insertions(+), 16 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 arm64: dts: seattle: Update spi clock properties

PL022 binding require two clocks to be defined but AMD seattle platform does't comply with binding and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

---
v2:
- Resend to soc ML
- Add Rob's acked-by tag

 arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi +4 -4
index b664e7af74eb..2aa21d98d560 100644
@@ -113,8 +113,8 @@ spi0: spi@e1020000 {
 			reg = <0 0xe1020000 0 0x1000>;
 			spi-controller;
 			interrupts = <0 330 4>;
-			clocks = <&uartspiclk_100mhz>;
-			clock-names = "apb_pclk";
+			clocks = <&uartspiclk_100mhz>, <&uartspiclk_100mhz>;
+			clock-names = "sspclk", "apb_pclk";
 		};
 
 		spi1: spi@e1030000 {
@@ -123,8 +123,8 @@ spi1: spi@e1030000 {
 			reg = <0 0xe1030000 0 0x1000>;
 			spi-controller;
 			interrupts = <0 329 4>;
-			clocks = <&uartspiclk_100mhz>;
-			clock-names = "apb_pclk";
+			clocks = <&uartspiclk_100mhz>, <&uartspiclk_100mhz>;
+			clock-names = "sspclk", "apb_pclk";
 			num-cs = <1>;
 			#address-cells = <1>;
 			#size-cells = <0>;
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/3 arm64: dts: lg131x: Update spi clock properties

In reply to Kuldeep Singh

PL022 binding require two clocks to be defined but LG1312 and LG1313 platforms don't comply with bindings and define only one clock.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

---
v2:
- Resend to soc ML
- Add Rob's acked-by tag

 arch/arm64/boot/dts/lg/lg1312.dtsi | 8 ++++----
 arch/arm64/boot/dts/lg/lg1313.dtsi | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
arch/arm64/boot/dts/lg/lg1312.dtsi +4 -4
index bec97480a960..e4de0f98c685 100644
@@ -172,15 +172,15 @@ spi0: spi@fe800000 {
 			compatible = "arm,pl022", "arm,primecell";
 			reg = <0x0 0xfe800000 0x1000>;
 			interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk_bus>;
-			clock-names = "apb_pclk";
+			clocks = <&clk_bus>, <&clk_bus>;
+			clock-names = "sspclk", "apb_pclk";
 		};
 		spi1: spi@fe900000 {
 			compatible = "arm,pl022", "arm,primecell";
 			reg = <0x0 0xfe900000 0x1000>;
 			interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk_bus>;
-			clock-names = "apb_pclk";
+			clocks = <&clk_bus>, <&clk_bus>;
+			clock-names = "sspclk", "apb_pclk";
 		};
 		dmac0: dma-controller@c1128000 {
 			compatible = "arm,pl330", "arm,primecell";
arch/arm64/boot/dts/lg/lg1313.dtsi +4 -4
index ada3d4dc6305..873baae75035 100644
@@ -172,15 +172,15 @@ spi0: spi@fe800000 {
 			compatible = "arm,pl022", "arm,primecell";
 			reg = <0x0 0xfe800000 0x1000>;
 			interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk_bus>;
-			clock-names = "apb_pclk";
+			clocks = <&clk_bus>, <&clk_bus>;
+			clock-names = "sspclk", "apb_pclk";
 		};
 		spi1: spi@fe900000 {
 			compatible = "arm,pl022", "arm,primecell";
 			reg = <0x0 0xfe900000 0x1000>;
 			interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk_bus>;
-			clock-names = "apb_pclk";
+			clocks = <&clk_bus>, <&clk_bus>;
+			clock-names = "sspclk", "apb_pclk";
 		};
 		dmac0: dma-controller@c1128000 {
 			compatible = "arm,pl330", "arm,primecell";
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/3 ARM: dts: lpc32xx: Update spi clock properties

In reply to Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

 arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +4 -4
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
 				compatible = "arm,pl022", "arm,primecell";
 				reg = <0x20084000 0x1000>;
 				interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-				clocks = <&clk LPC32XX_CLK_SSP0>;
-				clock-names = "apb_pclk";
+				clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+				clock-names = "sspclk", "apb_pclk";
 				#address-cells = <1>;
 				#size-cells = <0>;
 				status = "disabled";
@@ -202,8 +202,8 @@ ssp1: spi@2008c000 {
 				compatible = "arm,pl022", "arm,primecell";
 				reg = <0x2008c000 0x1000>;
 				interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;
-				clocks = <&clk LPC32XX_CLK_SSP1>;
-				clock-names = "apb_pclk";
+				clocks = <&clk LPC32XX_CLK_SSP1>, <&clk LPC32XX_CLK_SSP1>;
+				clock-names = "sspclk", "apb_pclk";
 				#address-cells = <1>;
 				#size-cells = <0>;
 				status = "disabled";
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 21 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

  arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +0 -0
index c87066d6c995..30958e02d5e2 100644

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 7 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
  				compatible = "arm,pl022", "arm,primecell";
  				reg = <0x20084000 0x1000>;
  				interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-				clocks = <&clk LPC32XX_CLK_SSP0>;
-				clock-names = "apb_pclk";
+				clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+				clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

	pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Quoted 5 lines
arch/arm/boot/dts/lpc32xx.dtsi +0 -0
  				#address-cells = <1>;
  				#size-cells = <0>;
  				status = "disabled";

arch/arm/boot/dts/lpc32xx.dtsi ssp1: spi@2008c000 { · line 209

Quoted 10 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
@@ -202,8 +202,8 @@ ssp1: spi@2008c000 {
  				compatible = "arm,pl022", "arm,primecell";
  				reg = <0x2008c000 0x1000>;
  				interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;
-				clocks = <&clk LPC32XX_CLK_SSP1>;
-				clock-names = "apb_pclk";
+				clocks = <&clk LPC32XX_CLK_SSP1>, <&clk LPC32XX_CLK_SSP1>;
+				clock-names = "sspclk", "apb_pclk";
  				#address-cells = <1>;
  				#size-cells = <0>;
  				status = "disabled";

--
Best wishes,
Vladimir

#5 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 18 lines · Vladimir Zapolskiy
Quoted 16 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

  arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 16 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 12 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                              compatible = "arm,pl022", "arm,primecell";
                              reg = <0x20084000 0x1000>;
                              interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 6 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

        pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Looking at the driver, I also see that this refers to the clock as "SSP/SPI bus clock", and it reads the rate from that.

In case of the LG platform, my impression is that the clocks listed in DT don't reflect the system at all, they all refer to the same fixed clock node at 198000000HZ, which is also used as for the UART and timer nodes. Changing the name on that one doesn't really make it correct, but should not hurt either.

Arnd

#6 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 42 lines · Arnd Bergmann
Quoted 18 lines · Vladimir Zapolskiy
Quoted 16 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

   arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
   1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 16 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 12 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                               compatible = "arm,pl022", "arm,primecell";
                               reg = <0x20084000 0x1000>;
                               interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 3 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

Quoted 8 lines
Quoted 3 lines
         pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD), plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it, firstly fix the schema by removing "apb_pclk" clock. It will leave just one clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

Quoted 2 lines

Looking at the driver, I also see that this refers to the clock as "SSP/SPI bus clock", and it reads the rate from that.

Yes, that's correct, it's a SPI bus clock with an option to set a rate.

Quoted 8 lines

In case of the LG platform, my impression is that the clocks listed in DT don't reflect the system at all, they all refer to the same fixed clock node at 198000000HZ, which is also used as for the UART and timer nodes. Changing the name on that one doesn't really make it correct, but should not hurt either.

Arnd

--
Best wishes,
Vladimir

#7 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 40 lines · Vladimir Zapolskiy
Quoted 39 lines · Arnd Bergmann
Quoted 18 lines · Vladimir Zapolskiy
Quoted 16 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

   arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
   1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 16 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 12 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                               compatible = "arm,pl022", "arm,primecell";
                               reg = <0x20084000 0x1000>;
                               interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

         pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Drivers do not describe the hardware. Bindings should not be modeled on drivers, but on actual hardware, so the example is not convincing.

Quoted 22 lines
Quoted 5 lines

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD), plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it, firstly fix the schema by removing "apb_pclk" clock. It will leave just one clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

Quoted 4 lines
Quoted 2 lines

Looking at the driver, I also see that this refers to the clock as "SSP/SPI bus clock", and it reads the rate from that.

Yes, that's correct, it's a SPI bus clock with an option to set a rate.

It seems versioning of this patchset lacks proper references to previous discussions:
https://lore.kernel.org/linux-devicetree/Yip2MZdQNjMz%[email protected]/

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 44 lines · Krzysztof Kozlowski
Quoted 43 lines · Vladimir Zapolskiy
Quoted 42 lines · Arnd Bergmann
Quoted 18 lines · Vladimir Zapolskiy
Quoted 16 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

    arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 16 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 12 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                compatible = "arm,pl022", "arm,primecell";
                                reg = <0x20084000 0x1000>;
                                interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 3 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
          pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Drivers do not describe the hardware. Bindings should not be modeled on drivers, but on actual hardware, so the example is not convincing.

My concern is that fixing the bindings can break the driver and all its users, is it clear enough how it can happen in assumption that the driver uses just one clock at the moment?

--
Best wishes,
Vladimir

#9 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 47 lines · Vladimir Zapolskiy
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Vladimir Zapolskiy
Quoted 44 lines · Arnd Bergmann
Quoted 18 lines · Vladimir Zapolskiy
Quoted 16 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

    arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 16 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 12 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                compatible = "arm,pl022", "arm,primecell";
                                reg = <0x20084000 0x1000>;
                                interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 5 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

          pl022->clk = devm_clk_get(&adev->dev, NULL);
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

So, I would vote to fix the device tree bindings schema.

Drivers do not describe the hardware. Bindings should not be modeled on drivers, but on actual hardware, so the example is not convincing.

My concern is that fixing the bindings can break the driver and all its users, is it clear enough how it can happen in assumption that the driver uses just one clock at the moment?

You meant fixing the DTS? We do not consider here "fixing bindings" because they look correct. About DTS, using the same clock twice should not cause negative effect.

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 50 lines · Krzysztof Kozlowski
Quoted 49 lines · Vladimir Zapolskiy
Quoted 48 lines · Krzysztof Kozlowski
Quoted 46 lines · Vladimir Zapolskiy
Quoted 45 lines · Arnd Bergmann
Quoted 18 lines · Vladimir Zapolskiy
Quoted 16 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

     arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 16 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 12 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                 compatible = "arm,pl022", "arm,primecell";
                                 reg = <0x20084000 0x1000>;
                                 interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 6 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

           pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Drivers do not describe the hardware. Bindings should not be modeled on drivers, but on actual hardware, so the example is not convincing.

My concern is that fixing the bindings can break the driver and all its users, is it clear enough how it can happen in assumption that the driver uses just one clock at the moment?

You meant fixing the DTS? We do not consider here "fixing bindings"

Yes, I meant fixing the DTS, sorry for confusion.

Quoted 2 lines

because they look correct. About DTS, using the same clock twice should not cause negative effect.

But it is erroneous to specify the SSP clock as APB clock, so this v2 is incorrect, and I've mentioned above in the discussion that the APB clock shall be HCLK on the platform.

To avoid any unpleasant uncertainties I expect to get a change in the driver firstly, the driver shall work according to the bindings, at the moment it is obviously broken.

--
Best wishes,
Vladimir

#11 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

In reply to Vladimir Zapolskiy
Quoted 61 lines · Vladimir Zapolskiy
Quoted 43 lines · Arnd Bergmann
Quoted 27 lines · Vladimir Zapolskiy
Quoted 25 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

   arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----

   1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +0 -1
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                compatible = "arm,pl022", "arm,primecell";
                                reg = <0x20084000 0x1000>;
                                interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
Quoted 8 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 182

Quoted 4 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -1
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>, 
 <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock is used for both the SPI bus and the APB bus.

Quoted 3 lines

Apparently just one clock is wanted on all observed platforms and cases, this is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

Quoted 8 lines
Quoted 3 lines

         pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD), plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

Quoted 7 lines

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it, firstly fix the schema by removing "apb_pclk" clock. It will leave just one clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

No, "apb_pclk" is part of the common AMBA binding, and is required by the "arm,primecell" compatible. You won't (usually) find it referenced in drivers because it's dealt with by amba_get_enable_pclk() via amba_probe().

Robin.

#12 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 78 lines · Robin Murphy
Quoted 69 lines · Vladimir Zapolskiy
Quoted 50 lines · Arnd Bergmann
Quoted 31 lines · Vladimir Zapolskiy
Quoted 29 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

    arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +1 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                compatible = "arm,pl022",
 "arm,primecell";
                                reg = <0x20084000 0x1000>;
                                interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>,
Quoted 8 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 184

Quoted 2 lines
arch/arm/boot/dts/lpc32xx.dtsi +1 -0
 <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit
cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong
schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock
is used for both the SPI bus and the APB bus.

Quoted 5 lines

Apparently just one clock is wanted on all observed platforms and cases, this
is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

Quoted 8 lines
Quoted 3 lines

         pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device

nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD), plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

Quoted 7 lines

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it, firstly fix the schema by removing "apb_pclk" clock. It will leave just one clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

Quoted 5 lines

No, "apb_pclk" is part of the common AMBA binding, and is required by the "arm,primecell" compatible. You won't (usually) find it referenced in drivers because it's dealt with by amba_get_enable_pclk() via amba_probe().

Thank you, it explains, why "apb_pclk" is required for all PrimeCell controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was misidentified with the sspclk clock, the latter one is the only clock explicitly utilized by the driver in 2015 and till today. Fixes in dts files should be preceded by a fix in the driver.

--
Best wishes,
Vladimir

#13 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 85 lines · Vladimir Zapolskiy
Quoted 78 lines · Robin Murphy
Quoted 69 lines · Vladimir Zapolskiy
Quoted 50 lines · Arnd Bergmann
Quoted 31 lines · Vladimir Zapolskiy
Quoted 29 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

    arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----

    1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +1 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                 compatible = "arm,pl022",
 "arm,primecell";
                                 reg = <0x20084000 0x1000>;
                                 interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>,
Quoted 8 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 184

Quoted 2 lines
arch/arm/boot/dts/lpc32xx.dtsi +1 -0
 <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit
cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong
schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock
is used for both the SPI bus and the APB bus.

Quoted 5 lines

Apparently just one clock is wanted on all observed platforms and cases, this
is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

Quoted 8 lines
Quoted 3 lines

          pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device

nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD), plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

Quoted 7 lines

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it, firstly fix the schema by removing "apb_pclk" clock. It will leave just one clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

Quoted 5 lines

No, "apb_pclk" is part of the common AMBA binding, and is required by the "arm,primecell" compatible. You won't (usually) find it referenced in drivers because it's dealt with by amba_get_enable_pclk() via amba_probe().

Quoted 5 lines

Thank you, it explains, why "apb_pclk" is required for all PrimeCell controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was misidentified with the sspclk clock, the latter one is the only clock explicitly utilized by the driver in 2015 and till today. Fixes in dts files should be preceded by a fix in the driver.

There's nothing to fix in the driver, though. In fact it can only be working today because the Linux driver isn't very strict and simply assumes that the first clock entry is SSPCLK *without* considering its name (other consumers of the binding might be stricter; I don't know), and because presumably the HCLK happens to be enabled already anyway. Changing the driver behaviour would only stand to cause functional regressions.

There are effectively two bugs in the DTS here, firstly that it only has one clock entry when it should have two, and secondly that the clock entry which *is* present has the wrong name (or the wrong clock specifier, depending on how you look at it). Kuldeep's patch merely fixes the first one by fully describing the way it's currently working in practice, so it's really just a choice of whether to treat "respect the binding" and "describe the hardware correctly" as separate issues and have a follow-up patch to correctly reference HCLK as the second clock, or whether they're trivial enough to squash together.

Robin.

#14 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 10 lines · Robin Murphy
Quoted 8 lines · Vladimir Zapolskiy

On 3/14/22 1:43 PM, Robin Murphy wrote:

Thank you, it explains, why "apb_pclk" is required for all PrimeCell controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was misidentified with the sspclk clock, the latter one is the only clock explicitly utilized by the driver in 2015 and till today. Fixes in dts files should be preceded by a fix in the driver.

Quoted 7 lines

There's nothing to fix in the driver, though. In fact it can only be working today because the Linux driver isn't very strict and simply assumes that the first clock entry is SSPCLK *without* considering its name (other consumers of the binding might be stricter; I don't know), and because presumably the HCLK happens to be enabled already anyway. Changing the driver behaviour would only stand to cause functional regressions.

We can change the driver to look for an sspclk by name first, and then fall back to the first clk if none is found. This would be backwards compatible and allow new dts files to have an arbitrary order, though we still need to be careful about changing the existing dts files after that, to avoid breaking older kernels.

Arnd

#15 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 19 lines · Arnd Bergmann
Quoted 10 lines · Robin Murphy
Quoted 8 lines · Vladimir Zapolskiy

On 3/14/22 1:43 PM, Robin Murphy wrote:

Thank you, it explains, why "apb_pclk" is required for all PrimeCell controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was misidentified with the sspclk clock, the latter one is the only clock explicitly utilized by the driver in 2015 and till today. Fixes in dts files should be preceded by a fix in the driver.

Quoted 7 lines

There's nothing to fix in the driver, though. In fact it can only be working today because the Linux driver isn't very strict and simply assumes that the first clock entry is SSPCLK *without* considering its name (other consumers of the binding might be stricter; I don't know), and because presumably the HCLK happens to be enabled already anyway. Changing the driver behaviour would only stand to cause functional regressions.

Quoted 5 lines

We can change the driver to look for an sspclk by name first, and then fall back to the first clk if none is found. This would be backwards compatible and allow new dts files to have an arbitrary order, though we still need to be careful about changing the existing dts files after that, to avoid breaking older kernels.

Yeah, I discounted that since schema is strict about the order of entries even when they're named, so we'd have nothing to gain except the potential to break compatibility in one direction and annoy users in the other. There's little point in having code to look up a clock by name when we know that for compatibility reasons it has to be the first clock, so it would be functionally identical to the fallback code that we also still have to have. All it could offer is additionally printing a message about it, and experience says that that achieves little except the aforementioned annoyance of users - I look as far as my Rockchip boards that have all been screaming an error at me every boot for nearly 4 years now, where the ethernet driver fails to get a clock that only exists on some SoCs *other* than the ones I have :(

Robin.

#16 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

In reply to Robin Murphy
Quoted 101 lines · Robin Murphy
Quoted 94 lines · Vladimir Zapolskiy
Quoted 87 lines · Robin Murphy
Quoted 79 lines · Vladimir Zapolskiy
Quoted 54 lines · Arnd Bergmann
Quoted 34 lines · Vladimir Zapolskiy
Quoted 32 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't
comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock
reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

     arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +1 -2
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                 compatible = "arm,pl022",
 "arm,primecell";
                                 reg = <0x20084000 0x1000>;
                                 interrupts = <20
 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>,
Quoted 8 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 185

Quoted 2 lines
arch/arm/boot/dts/lpc32xx.dtsi +1 -0
 <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen that the commit
cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong
schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock
is used for both the SPI bus and the APB bus.

Quoted 5 lines

Apparently just one clock is wanted on all observed platforms and cases, this
is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

Quoted 8 lines
Quoted 3 lines

          pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device

nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell
controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD),
plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

Quoted 6 lines

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it, firstly fix the schema by removing "apb_pclk" clock. It will leave just one
clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

Quoted 5 lines

No, "apb_pclk" is part of the common AMBA binding, and is required by the "arm,primecell" compatible. You won't (usually) find it referenced in drivers because it's dealt with by amba_get_enable_pclk() via amba_probe().

Quoted 5 lines

Thank you, it explains, why "apb_pclk" is required for all PrimeCell controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was misidentified with the sspclk clock, the latter one is the only clock explicitly utilized by the driver in 2015 and till today. Fixes in dts files should be preceded by a fix in the driver.

Quoted 4 lines

There's nothing to fix in the driver, though. In fact it can only be working today because the Linux driver isn't very strict and simply assumes that the first clock entry is SSPCLK *without* considering its name (other consumers of the binding might be stricter; I don't know),

Here I'm a bit ignorant, would it be totally reliable to assume that clk_get(dev, NULL) gets the first clock from the list, and will it never happen that one day it takes e.g. the last entry?

I'm kind of surprised that the asked fix in the driver meets such a resistance.

Quoted 1 line

and because presumably the HCLK happens to be enabled already anyway.

Yes, that's the case here.

Quoted 13 lines

Changing the driver behaviour would only stand to cause functional regressions.

There are effectively two bugs in the DTS here, firstly that it only has one clock entry when it should have two, and secondly that the clock entry which *is* present has the wrong name (or the wrong clock specifier, depending on how you look at it). Kuldeep's patch merely fixes the first one by fully describing the way it's currently working in practice, so it's really just a choice of whether to treat "respect the binding" and "describe the hardware correctly" as separate issues and have a follow-up patch to correctly reference HCLK as the second clock, or whether they're trivial enough to squash together.

The two problems in the DTS are not argued, the chosen way to correct them is questionable though. Well, I won't object to see it split into two changes, but please send them at least in one series then, so that it won't be left forgotten.

--
Best wishes,
Vladimir

#17 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Quoted 135 lines · Vladimir Zapolskiy
Quoted 36 lines · Robin Murphy
Quoted 35 lines · Vladimir Zapolskiy
Quoted 34 lines · Robin Murphy
Quoted 33 lines · Vladimir Zapolskiy
Quoted 32 lines · Arnd Bergmann
Quoted 30 lines · Vladimir Zapolskiy
Quoted 28 lines · Kuldeep Singh

PL022 binding require two clocks to be defined but lpc platform doesn't
comply with bindings and define only one clock i.e apb_pclk.

Update spi clocks and clocks-names property by adding appropriate clock
reference to make it compliant with bindings.

CC Vladimir Zapolskiy <[email protected]>

---
v2:
- New patch with similar changeset
- Send to soc ML

     arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/lpc32xx.dtsi +0 -0
index c87066d6c995..30958e02d5e2 100644
@@ -178,8 +178,8 @@ ssp0: spi@20084000 {
                                 compatible = "arm,pl022",
 "arm,primecell";
                                 reg = <0x20084000 0x1000>;
                                 interrupts = <20
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

arch/arm/boot/dts/lpc32xx.dtsi ssp0: spi@20084000 { · line 185

Quoted 6 lines
arch/arm/boot/dts/lpc32xx.dtsi +2 -2
 IRQ_TYPE_LEVEL_HIGH>;
-                             clocks = <&clk LPC32XX_CLK_SSP0>;
-                             clock-names = "apb_pclk";
+                             clocks = <&clk LPC32XX_CLK_SSP0>,
 <&clk LPC32XX_CLK_SSP0>;
+                             clock-names = "sspclk", "apb_pclk";

In fact I'm uncertain if it is the right change, could it happen

that

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines

the commit
cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema") sets a wrong
schema pattern?

Good pointm this doesn't quite seem right: it is unlikely that the same clock
is used for both the SPI bus and the APB bus.

Quoted 8 lines

Apparently just one clock is wanted on all observed platforms and cases, this
is implicitly confirmed by clock handling in the drivers/spi/spi-pl022.c :

           pl022->clk = devm_clk_get(&adev->dev, NULL);

So, I would vote to fix the device tree bindings schema.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Isn't this just using the wrong name? The name of the macro LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock rather than the APB clock, so we only need to change clock-names property here and leave it unchanged otherwise.

Yes, the name is wrong, here I'm ready to take the blame:

Fixes 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to

device

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

nodes")

Noteworthy the commit above presets the same clock name to other PrimeCell
controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x (SD),
plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in fact.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

On LPC32xx the bus clock source and function clock source for SSP is HCLK.

My guess is that the misnamed "apb_pclk" migrated into the schema from the lpc32xx.dtsi, so I'd suggest, unless some platform really needs

it,

Quoted 17 lines
Quoted 11 lines
Quoted 10 lines
Quoted 4 lines

firstly fix the schema by removing "apb_pclk" clock. It will leave just one
clock, so "clock-names" property can be set as optional, and the drop the property from the lpc32xx.dtsi.

No, "apb_pclk" is part of the common AMBA binding, and is required by the "arm,primecell" compatible. You won't (usually) find it referenced in drivers because it's dealt with by amba_get_enable_pclk() via amba_probe().

Quoted 5 lines

Thank you, it explains, why "apb_pclk" is required for all PrimeCell controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was misidentified with the sspclk clock, the latter one is the only clock explicitly utilized by the driver in 2015 and till today. Fixes in dts files should be preceded by a fix in the driver.

Quoted 4 lines

There's nothing to fix in the driver, though. In fact it can only be working today because the Linux driver isn't very strict and simply assumes that the first clock entry is SSPCLK *without* considering its name (other consumers of the binding might be stricter; I don't know),

Here I'm a bit ignorant, would it be totally reliable to assume that clk_get(dev, NULL) gets the first clock from the list, and will it never happen that one day it takes e.g. the last entry?

I'm kind of surprised that the asked fix in the driver meets such a resistance.

Quoted 1 line

and because presumably the HCLK happens to be enabled already anyway.

Yes, that's the case here.

Quoted 13 lines

Changing the driver behaviour would only stand to cause functional regressions.

There are effectively two bugs in the DTS here, firstly that it only has one clock entry when it should have two, and secondly that the clock entry which *is* present has the wrong name (or the wrong clock specifier, depending on how you look at it). Kuldeep's patch merely fixes the first one by fully describing the way it's currently working in practice, so it's really just a choice of whether to treat "respect the binding" and "describe the hardware correctly" as separate issues and have a follow-up patch to correctly reference HCLK as the second clock, or whether they're trivial enough to squash together.

Quoted 9 lines

The two problems in the DTS are not argued, the chosen way to correct them is questionable though. Well, I won't object to see it split into two changes, but please send them at least in one series then, so that it won't be left forgotten.

--
Best wishes,
Vladimir

On the lpc32xx both the SPI and SSP peripherals are APB devices (low-speed)

[image: lpc32xx-apb-peripherals.png]
The APB devices on this SoC are driven by the PERIPH_CLK which can be derived from either the HCLK or the SYSCLK.

[image: lpc32xx-clock.png]
The default on reset is for PERIPH_CLK to be derived from the SYSCLK but both U-Boot and Linux run in "normal" mode, which is to say that PERIPH_CLK, HCLK, ARM_CLK, and DDRAM_CLK are derived from the HCLK PLL.

There is no separate SSP clock, the SSP is driven by one clock: the PERIPH_CLK (or "apb_pclk").

#18 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Hi Trevor,

Quoted 144 lines · Trevor Woerner

On Tue, Mar 15, 2022 at 2:00 AM Vladimir Zapolskiy <[email protected] <mailto:[email protected]>> wrote:

    On 3/14/22 2:20 PM, Robin Murphy wrote:
     > On 2022-03-14 11:50, Vladimir Zapolskiy wrote:
     >> On 3/14/22 1:43 PM, Robin Murphy wrote:
     >>> On 2022-03-11 14:07, Vladimir Zapolskiy wrote:
     >>>> On 3/11/22 3:38 PM, Arnd Bergmann wrote:
     >>>>> On Fri, Mar 11, 2022 at 2:20 PM Vladimir Zapolskiy <[email protected] <mailto:[email protected]>>
     >>>>> wrote:
     >>>>>>
     >>>>>> On 3/11/22 11:38 AM, Kuldeep Singh wrote:
     >>>>>>> PL022 binding require two clocks to be defined but lpc platform
     >>>>>>> doesn't
     >>>>>>> comply with bindings and define only one clock i.e apb_pclk.
     >>>>>>>
     >>>>>>> Update spi clocks and clocks-names property by adding appropriate
     >>>>>>> clock
     >>>>>>> reference to make it compliant with bindings.
     >>>>>>>
     >>>>>>> CC: Vladimir Zapolskiy <[email protected] <mailto:[email protected]>>
     >>>>>>> Signed-off-by: Kuldeep Singh <[email protected] <mailto:[email protected]>>
     >>>>>>> ---
     >>>>>>> v2:
     >>>>>>> - New patch with similar changeset
     >>>>>>> - Send to soc ML
     >>>>>>>
     >>>>>>>      arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
     >>>>>>>      1 file changed, 4 insertions(+), 4 deletions(-)
     >>>>>>>
     >>>>>>> diff --git a/arch/arm/boot/dts/lpc32xx.dtsi
     >>>>>>> b/arch/arm/boot/dts/lpc32xx.dtsi
     >>>>>>> index c87066d6c995..30958e02d5e2 100644
     >>>>>>> --- a/arch/arm/boot/dts/lpc32xx.dtsi
     >>>>>>> +++ b/arch/arm/boot/dts/lpc32xx.dtsi
     >>>>>>> @@ -178,8 +178,8 @@ ssp0: spi@20084000 {
     >>>>>>>                                  compatible = "arm,pl022",
     >>>>>>> "arm,primecell";
     >>>>>>>                                  reg = <0x20084000 0x1000>;
     >>>>>>>                                  interrupts = <20
     >>>>>>> IRQ_TYPE_LEVEL_HIGH>;
     >>>>>>> -                             clocks = <&clk LPC32XX_CLK_SSP0>;
     >>>>>>> -                             clock-names = "apb_pclk";
     >>>>>>> +                             clocks = <&clk LPC32XX_CLK_SSP0>,
     >>>>>>> <&clk LPC32XX_CLK_SSP0>;
     >>>>>>> +                             clock-names = "sspclk", "apb_pclk";
     >>>>>>
     >>>>>> In fact I'm uncertain if it is the right change, could it happen that
     >>>>>> the commit
     >>>>>> cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema")
     >>>>>> sets a wrong
     >>>>>> schema pattern?
     >>>>>
     >>>>> Good pointm this doesn't quite seem right: it is unlikely that the
     >>>>> same clock
     >>>>> is used for both the SPI bus and the APB bus.
     >>>>>
     >>>>>> Apparently just one clock is wanted on all observed platforms and
     >>>>>> cases, this
     >>>>>> is implicitly confirmed by clock handling in the
     >>>>>> drivers/spi/spi-pl022.c :
     >>>>>>
     >>>>>>            pl022->clk = devm_clk_get(&adev->dev, NULL);
     >>>>>>
     >>>>>> So, I would vote to fix the device tree bindings schema.
     >>>>>
     >>>>> Isn't this just using the wrong name? The name of the macro
     >>>>> LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock
     >>>>> rather than the APB clock, so we only need to change clock-names
     >>>>> property here and leave it unchanged otherwise.
     >>>>
     >>>> Yes, the name is wrong, here I'm ready to take the blame:
     >>>>
     >>>> Fixes: 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device
     >>>> nodes")
     >>>>
     >>>> Noteworthy the commit above presets the same clock name to other
     >>>> PrimeCell
     >>>> controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x
     >>>> (SD),
     >>>> plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in
     >>>> fact.
     >>>>
     >>>> On LPC32xx the bus clock source and function clock source for SSP is
     >>>> HCLK.
     >>>>
     >>>> My guess is that the misnamed "apb_pclk" migrated into the schema from
     >>>> the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it,
     >>>> firstly fix the schema by removing "apb_pclk" clock. It will leave
     >>>> just one
     >>>> clock, so "clock-names" property can be set as optional, and the drop
     >>>> the property from the lpc32xx.dtsi.
     >>>
     >>> No, "apb_pclk" is part of the common AMBA binding, and is required by
     >>> the "arm,primecell" compatible. You won't (usually) find it referenced
     >>> in drivers because it's dealt with by amba_get_enable_pclk() via
     >>> amba_probe().
     >>>
     >>
     >> Thank you, it explains, why "apb_pclk" is required for all PrimeCell
     >> controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was
     >> misidentified with the sspclk clock, the latter one is the only clock
     >> explicitly utilized by the driver in 2015 and till today. Fixes in dts
     >> files should be preceded by a fix in the driver.
     >
     > There's nothing to fix in the driver, though. In fact it can only be
     > working today because the Linux driver isn't very strict and simply
     > assumes that the first clock entry is SSPCLK *without* considering its
     > name (other consumers of the binding might be stricter; I don't know),

    Here I'm a bit ignorant, would it be totally reliable to assume that
    clk_get(dev, NULL) gets the first clock from the list, and will it never
    happen that one day it takes e.g. the last entry?

    I'm kind of surprised that the asked fix in the driver meets such a
    resistance.

     > and because presumably the HCLK happens to be enabled already anyway.

    Yes, that's the case here.

     > Changing the driver behaviour would only stand to cause functional
     > regressions.
     >
     > There are effectively two bugs in the DTS here, firstly that it only has
     > one clock entry when it should have two, and secondly that the clock
     > entry which *is* present has the wrong name (or the wrong clock
     > specifier, depending on how you look at it). Kuldeep's patch merely
     > fixes the first one by fully describing the way it's currently working
     > in practice, so it's really just a choice of whether to treat "respect
     > the binding" and "describe the hardware correctly" as separate issues
     > and have a follow-up patch to correctly reference HCLK as the second
     > clock, or whether they're trivial enough to squash together.
     >

    The two problems in the DTS are not argued, the chosen way to correct them
    is questionable though. Well, I won't object to see it split into two
    changes, but please send them at least in one series then, so that it
    won't be left forgotten.

    --
    Best wishes,
    Vladimir
Quoted 5 lines

On the lpc32xx both the SPI and SSP peripherals are APB devices (low-speed)

lpc32xx-apb-peripherals.png
The APB devices on this SoC are driven by the PERIPH_CLK which can be derived from either the HCLK or the SYSCLK.

thank you for the data, I'd like to reference to Table 14, which says that both bus clock source and function clock source for SSP0 and SSP1 are a non-selectable HCLK. I'm unsure if for instance PERIPH_CLK can be set as a function clock source for SSPx.

Quoted 5 lines

lpc32xx-clock.png
The default on reset is for PERIPH_CLK to be derived from the SYSCLK but
both U-Boot and Linux run in "normal" mode, which is to say that
PERIPH_CLK, HCLK, ARM_CLK, and DDRAM_CLK are derived from the HCLK PLL.> There is no separate SSP clock, the SSP is driven by one clock: the PERIPH_CLK (or "apb_pclk").

Right, there is no separate SSP clock in sense of a bus clock, it is correct to get HCLK clock (or equally its child SSP clock) rate as a bus clock rate, and the reason for introduction of SSP0/SSP1 clocks is that these clocks are gated.

If I'm correct above, what does it mean in connection to LPC32xx device tree bindings? The first or single clock source shall remain to be SSPx clock, either the former is "sspclk" or "apb_pclk".

--
Best wishes,
Vladimir

#19 lore raw

Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties

Hi Vladimir,

Quoted 5 lines · Vladimir Zapolskiy

Hi Trevor,

Quoted 2 lines · Trevor Woerner

On the lpc32xx both the SPI and SSP peripherals are APB devices (low-speed)

Quoted 8 lines
Quoted 3 lines

lpc32xx-apb-peripherals.png
The APB devices on this SoC are driven by the PERIPH_CLK which can be derived from either the HCLK or the SYSCLK.

thank you for the data, I'd like to reference to Table 14, which says that both bus clock source and function clock source for SSP0 and SSP1 are a non-selectable HCLK. I'm unsure if for instance PERIPH_CLK can be set as a function clock source for SSPx.

Interesting. I see that I had assumed that all APB peripherals would be driven by the PERIPH_CLK since the diagram shows that clock as going to all APB peripherals.

In the SSP chapter, for example, there is a clock prescale register, which says:

This register controls the factor by which the prescaler divides the AHB clock HCLK to yield the prescaler clock that is, in turn, divided by the SCR factor in SSPnCR0, to determine the bit clock.

So that confirms that the clock driving the SSP (an APB peripheral) is the AHB's HCLK!

Section 21.7 of the SPI chapter also clearly shows the SPI clock as being derived from the HCLK as well.

Thanks for the clarification :-)

Quoted 7 lines
Quoted 6 lines

lpc32xx-clock.png
The default on reset is for PERIPH_CLK to be derived from the SYSCLK but both U-Boot and Linux run in "normal" mode, which is to say that PERIPH_CLK, HCLK, ARM_CLK, and DDRAM_CLK are derived from the HCLK PLL.> There is no separate SSP clock, the SSP is driven by one clock: the PERIPH_CLK (or "apb_pclk").

Quoted 8 lines

Right, there is no separate SSP clock in sense of a bus clock, it is correct to get HCLK clock (or equally its child SSP clock) rate as a bus clock rate, and the reason for introduction of SSP0/SSP1 clocks is that these clocks are gated.

If I'm correct above, what does it mean in connection to LPC32xx device tree bindings? The first or single clock source shall remain to be SSPx clock, either the former is "sspclk" or "apb_pclk".

Doesn't this mean the apb_pclk should not be specified as the SSP/SPI clock? If sspclk is a synonym for HCLK, then sspclk and apb_pclk are completely different clocks. On my device HCLK is 260MHz and PERIPH_CLK is 13MHz.

#20 lore raw
In reply to Kuldeep Singh
This series was applied to soc/soc.git (for-next) by Arnd Bergmann <[email protected]>:

Hello:

This series was applied to soc/soc.git (for-next)
by Arnd Bergmann <[email protected]>:

Quoted 10 lines · On Fri, 11 Mar 2022 15:07:57 +0530 you wrote:

This patchset is an attempt to fix DTs which are not compliant with pl022 spi binding. Please note, there are other fixes required also which are sent from other trees.
As git trees for these platforms are not available, Rob advised me to seek help from soc tree maintainers.

Arnd and Olof, could you please help in reviewing and merging this patchset.

[...]

Here is the summary with links:
- [v2,1/3] arm64: dts: seattle: Update spi clock properties

    https://git.kernel.org/soc/soc/c/2201faa9fd72
  - [v2,2/3] arm64: dts: lg131x: Update spi clock properties
    https://git.kernel.org/soc/soc/c/19297aab805a
  - [v2,3/3] ARM: dts: lpc32xx: Update spi clock properties
    https://git.kernel.org/soc/soc/c/dc89633b8a1c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html