Skip to contentSkip to conversation

arm64: dts: qcom: qrb5165-rb5: use GPIO as SPI0 CS

PATCH Superseded Dmitry Baryshkov 3 participants 10 messages Feb 9, 2021 – Feb 10, 2021

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover arm64: dts: qcom: qrb5165-rb5: use GPIO as SPI0 CS

GENI SPI controller shows several issues if it manages the CS on its own (see 37dd4b777942 ("arm64: dts: qcom: sc7180: Provide pinconf for SPI to use GPIO for CS") for the details). Configure SPI0 CS pin as a GPIO.

Changes since v2:
- Move pinctrl-names to the board file.
- Reorder CS/CS-gpio/data-clk nodes to follow alphabetical sort.

Changes since v1:
- Split sm8250's spi pin config into mux/config parts, split away CS handling from main SPI pinctrl nodes.

----------------------------------------------------------------
Dmitry Baryshkov (4):
arm64: dts: qcom: sm8250: split spi pinctrl config
arm64: dts: qcom: sm8250: further split of spi pinctrl config
arm64: dts: qcom: sm8250: add pinctrl for SPI using GPIO as a CS
arm64: dts: qcom: qrb5165-rb5: switch into using GPIO for SPI0 CS

 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts |  13 +
 arch/arm64/boot/dts/qcom/sm8250.dtsi     | 521 +++++++++++++++----------------
 2 files changed, 273 insertions(+), 261 deletions(-)
#1 lore raw

PATCH v3 1/4 arm64: dts: qcom: sm8250: split spi pinctrl config

As discussed on linux-arm-msm list, start splitting sm8250 pinctrl settings into generic and board-specific parts. The first part to receive such treatment is the spi, so split spi pinconf to the board device tree.

---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts |   5 +
 arch/arm64/boot/dts/qcom/sm8250.dtsi     | 300 +++++------------------
 2 files changed, 65 insertions(+), 240 deletions(-)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +5 -0
index 2f0528d01299..787da8ccba54 100644
@@ -815,6 +815,11 @@ &pm8150_rtc {
 	status = "okay";
 };
 
+&qup_spi0_default {
+	drive-strength = <6>;
+	bias-disable;
+};
+
 &qupv3_id_0 {
 	status = "okay";
 };
arch/arm64/boot/dts/qcom/sm8250.dtsi +60 -240

363 lines not on this page · raw message

Signature · 1 line
2.30.0
Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH v3 1/4] arm64: dts: qcom: sm8250: split spi pinctrl config

Hi,

Quoted 17 lines · Dmitry Baryshkov

As discussed on linux-arm-msm list, start splitting sm8250 pinctrl settings into generic and board-specific parts. The first part to receive such treatment is the spi, so split spi pinconf to the board device tree.

---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts |   5 +
 arch/arm64/boot/dts/qcom/sm8250.dtsi     | 300 +++++------------------
 2 files changed, 65 insertions(+), 240 deletions(-)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +0 -0
index 2f0528d01299..787da8ccba54 100644

arch/arm64/boot/dts/qcom/qrb5165-rb5.dts &pm8150_rtc { · line 822

Quoted 8 lines
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +5 -0
@@ -815,6 +815,11 @@ &pm8150_rtc {
        status = "okay";
 };
 
+&qup_spi0_default {
+       drive-strength = <6>;
+       bias-disable;
+};
+

Optional nit that I personally prefer that all of the pinctrl stuff be grouped together (with separate sorting) at the bottom of board device tree files. To me it's weird to mix them with peripheral enables.

#3 lore raw

Re: [PATCH v3 1/4] arm64: dts: qcom: sm8250: split spi pinctrl config

Quoted 24 lines · Doug Anderson

Hi,

Quoted 20 lines · Dmitry Baryshkov

As discussed on linux-arm-msm list, start splitting sm8250 pinctrl settings into generic and board-specific parts. The first part to receive such treatment is the spi, so split spi pinconf to the board device tree.

---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts |   5 +
 arch/arm64/boot/dts/qcom/sm8250.dtsi     | 300 +++++------------------
 2 files changed, 65 insertions(+), 240 deletions(-)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +0 -0
index 2f0528d01299..787da8ccba54 100644
@@ -815,6 +815,11 @@ &pm8150_rtc {
        status = "okay";
 };
 
Quoted 10 lines

arch/arm64/boot/dts/qcom/qrb5165-rb5.dts &pm8150_rtc { · line 822

Quoted 5 lines
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +5 -0
+&qup_spi0_default {
+       drive-strength = <6>;
+       bias-disable;
+};
+

Optional nit that I personally prefer that all of the pinctrl stuff be grouped together (with separate sorting) at the bottom of board device tree files. To me it's weird to mix them with peripheral enables.

I share this preference, but let's figure out how to document these "guidelines" and take that as a separate change.

Regards,
Bjorn

Quoted 1 line
#4 lore raw

PATCH v3 2/4 arm64: dts: qcom: sm8250: further split of spi pinctrl config

In reply to Dmitry Baryshkov

Split "default" device tree nodes into common "data-clk" nodes and "cs" nodes which might differ from board to board depending on how the slave chips are wired.

---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts |   9 +-
 arch/arm64/boot/dts/qcom/sm8250.dtsi     | 201 ++++++++++++++++-------
 2 files changed, 148 insertions(+), 62 deletions(-)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +8 -1
index 787da8ccba54..922f329d623a 100644
@@ -815,7 +815,12 @@ &pm8150_rtc {
 	status = "okay";
 };
 
-&qup_spi0_default {
+&qup_spi0_cs {
+	drive-strength = <6>;
+	bias-disable;
+};
+
+&qup_spi0_data_clk {
 	drive-strength = <6>;
 	bias-disable;
 };
@@ -957,6 +962,8 @@ codec {
 /* CAN */
 &spi0 {
 	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&qup_spi0_data_clk>, <&qup_spi0_cs>;
 
 	can@0 {
 		compatible = "microchip,mcp2518fd";
arch/arm64/boot/dts/qcom/sm8250.dtsi +140 -61

404 lines not on this page · raw message

Signature · 1 line
2.30.0
#5 lore raw

Re: [PATCH v3 2/4] arm64: dts: qcom: sm8250: further split of spi pinctrl config

Hi,

Quoted 10 lines · Dmitry Baryshkov
arch/arm64/boot/dts/qcom/sm8250.dtsi +0 -1
@@ -715,7 +710,6 @@ spi19: spi@894000 {
                                clock-names = "se";
                                clocks = <&gcc GCC_QUPV3_WRAP2_S5_CLK>;
                                pinctrl-names = "default";
-                               pinctrl-0 = <&qup_spi19_default>;
                                interrupts = <GIC_SPI 587 IRQ_TYPE_LEVEL_HIGH>;
                                #address-cells = <1>;
                                #size-cells = <0>;

arch/arm64/boot/dts/qcom/sm8250.dtsi spi0: spi@980000 { · line 759

Quoted 5 lines
arch/arm64/boot/dts/qcom/sm8250.dtsi +0 -2
@@ -755,8 +749,6 @@ spi0: spi@980000 {
                                reg = <0 0x00980000 0 0x4000>;
                                clock-names = "se";
                                clocks = <&gcc GCC_QUPV3_WRAP0_S0_CLK>;
-                               pinctrl-names = "default";
-                               pinctrl-0 = <&qup_spi0_default>;

Why only this one removes "pinctrl-names" but all the other ones don't?

#6 lore raw

PATCH v3 3/4 arm64: dts: qcom: sm8250: add pinctrl for SPI using GPIO as a CS

In reply to Dmitry Baryshkov

GENI SPI controller shows several issues if it manages the CS on its own (see 37dd4b777942 ("arm64: dts: qcom: sc7180: Provide pinconf for SPI to use GPIO for CS")) for the details. Provide pinctrl entries for SPI controllers using the same CS pin but in GPIO mode.

---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 100 +++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
arch/arm64/boot/dts/qcom/sm8250.dtsi +100 -0
index e4320629d687..0874350f66fe 100644
@@ -2967,6 +2967,11 @@ qup_spi0_cs: qup-spi0-cs {
 				function = "qup0";
 			};
 
+			qup_spi0_cs_gpio: qup-spi0-cs-gpio {
+				pins = "gpio31";
+				function = "gpio";
+			};
+
 			qup_spi0_data_clk: qup-spi0-data-clk {
 				pins = "gpio28", "gpio29",
 				       "gpio30";
@@ -2978,6 +2983,11 @@ qup_spi1_cs: qup-spi1-cs {
 				function = "qup1";
 			};
 
+			qup_spi1_cs_gpio: qup-spi1-cs-gpio {
+				pins = "gpio7";
+				function = "gpio";
+			};
+
 			qup_spi1_data_clk: qup-spi1-data-clk {
 				pins = "gpio4", "gpio5",
 				       "gpio6";
@@ -2989,6 +2999,11 @@ qup_spi2_cs: qup-spi2-cs {
 				function = "qup2";
 			};
 
+			qup_spi2_cs_gpio: qup-spi2-cs-gpio {
+				pins = "gpio118";
+				function = "gpio";
+			};
+
 			qup_spi2_data_clk: qup-spi2-data-clk {
 				pins = "gpio115", "gpio116",
 				       "gpio117";
@@ -3000,6 +3015,11 @@ qup_spi3_cs: qup-spi3-cs {
 				function = "qup3";
 			};
 
+			qup_spi3_cs_gpio: qup-spi3-cs-gpio {
+				pins = "gpio122";
+				function = "gpio";
+			};
+
 			qup_spi3_data_clk: qup-spi3-data-clk {
 				pins = "gpio119", "gpio120",
 				       "gpio121";
@@ -3011,6 +3031,11 @@ qup_spi4_cs: qup-spi4-cs {
 				function = "qup4";
 			};
 
+			qup_spi4_cs_gpio: qup-spi4-cs-gpio {
+				pins = "gpio11";
+				function = "gpio";
+			};
+
 			qup_spi4_data_clk: qup-spi4-data-clk {
 				pins = "gpio8", "gpio9",
 				       "gpio10";
@@ -3022,6 +3047,11 @@ qup_spi5_cs: qup-spi5-cs {
 				function = "qup5";
 			};
 
+			qup_spi5_cs_gpio: qup-spi5-cs-gpio {
+				pins = "gpio15";
+				function = "gpio";
+			};
+
 			qup_spi5_data_clk: qup-spi5-data-clk {
 				pins = "gpio12", "gpio13",
 				       "gpio14";
@@ -3033,6 +3063,11 @@ qup_spi6_cs: qup-spi6-cs {
 				function = "qup6";
 			};
 
+			qup_spi6_cs_gpio: qup-spi6-cs-gpio {
+				pins = "gpio19";
+				function = "gpio";
+			};
+
 			qup_spi6_data_clk: qup-spi6-data-clk {
 				pins = "gpio16", "gpio17",
 				       "gpio18";
@@ -3044,6 +3079,11 @@ qup_spi7_cs: qup-spi7-cs {
 				function = "qup7";
 			};
 
+			qup_spi7_cs_gpio: qup-spi7-cs-gpio {
+				pins = "gpio23";
+				function = "gpio";
+			};
+
 			qup_spi7_data_clk: qup-spi7-data-clk {
 				pins = "gpio20", "gpio21",
 				       "gpio22";
@@ -3055,6 +3095,11 @@ qup_spi8_cs: qup-spi8-cs {
 				function = "qup8";
 			};
 
+			qup_spi8_cs_gpio: qup-spi8-cs-gpio {
+				pins = "gpio27";
+				function = "gpio";
+			};
+
 			qup_spi8_data_clk: qup-spi8-data-clk {
 				pins = "gpio24", "gpio25",
 				       "gpio26";
@@ -3066,6 +3111,11 @@ qup_spi9_cs: qup-spi9-cs {
 				function = "qup9";
 			};
 
+			qup_spi9_cs_gpio: qup-spi9-cs-gpio {
+				pins = "gpio128";
+				function = "gpio";
+			};
+
 			qup_spi9_data_clk: qup-spi9-data-clk {
 				pins = "gpio125", "gpio126",
 				       "gpio127";
@@ -3077,6 +3127,11 @@ qup_spi10_cs: qup-spi10-cs {
 				function = "qup10";
 			};
 
+			qup_spi10_cs_gpio: qup-spi10-cs-gpio {
+				pins = "gpio132";
+				function = "gpio";
+			};
+
 			qup_spi10_data_clk: qup-spi10-data-clk {
 				pins = "gpio129", "gpio130",
 				       "gpio131";
@@ -3088,6 +3143,11 @@ qup_spi11_cs: qup-spi11-cs {
 				function = "qup11";
 			};
 
+			qup_spi11_cs_gpio: qup-spi11-cs-gpio {
+				pins = "gpio63";
+				function = "gpio";
+			};
+
 			qup_spi11_data_clk: qup-spi11-data-clk {
 				pins = "gpio60", "gpio61",
 				       "gpio62";
@@ -3099,6 +3159,11 @@ qup_spi12_cs: qup-spi12-cs {
 				function = "qup12";
 			};
 
+			qup_spi12_cs_gpio: qup-spi12-cs-gpio {
+				pins = "gpio35";
+				function = "gpio";
+			};
+
 			qup_spi12_data_clk: qup-spi12-data-clk {
 				pins = "gpio32", "gpio33",
 				       "gpio34";
@@ -3110,6 +3175,11 @@ qup_spi13_cs: qup-spi13-cs {
 				function = "qup13";
 			};
 
+			qup_spi13_cs_gpio: qup-spi13-cs-gpio {
+				pins = "gpio39";
+				function = "gpio";
+			};
+
 			qup_spi13_data_clk: qup-spi13-data-clk {
 				pins = "gpio36", "gpio37",
 				       "gpio38";
@@ -3121,6 +3191,11 @@ qup_spi14_cs: qup-spi14-cs {
 				function = "qup14";
 			};
 
+			qup_spi14_cs_gpio: qup-spi14-cs-gpio {
+				pins = "gpio43";
+				function = "gpio";
+			};
+
 			qup_spi14_data_clk: qup-spi14-data-clk {
 				pins = "gpio40", "gpio41",
 				       "gpio42";
@@ -3132,6 +3207,11 @@ qup_spi15_cs: qup-spi15-cs {
 				function = "qup15";
 			};
 
+			qup_spi15_cs_gpio: qup-spi15-cs-gpio {
+				pins = "gpio47";
+				function = "gpio";
+			};
+
 			qup_spi15_data_clk: qup-spi15-data-clk {
 				pins = "gpio44", "gpio45",
 				       "gpio46";
@@ -3143,6 +3223,11 @@ qup_spi16_cs: qup-spi16-cs {
 				function = "qup16";
 			};
 
+			qup_spi16_cs_gpio: qup-spi16-cs-gpio {
+				pins = "gpio51";
+				function = "gpio";
+			};
+
 			qup_spi16_data_clk: qup-spi16-data-clk {
 				pins = "gpio48", "gpio49",
 				       "gpio50";
@@ -3154,6 +3239,11 @@ qup_spi17_cs: qup-spi17-cs {
 				function = "qup17";
 			};
 
+			qup_spi17_cs_gpio: qup-spi17-cs-gpio {
+				pins = "gpio55";
+				function = "gpio";
+			};
+
 			qup_spi17_data_clk: qup-spi17-data-clk {
 				pins = "gpio52", "gpio53",
 				       "gpio54";
@@ -3165,6 +3255,11 @@ qup_spi18_cs: qup-spi18-cs {
 				function = "qup18";
 			};
 
+			qup_spi18_cs_gpio: qup-spi18-cs-gpio {
+				pins = "gpio59";
+				function = "gpio";
+			};
+
 			qup_spi18_data_clk: qup-spi18-data-clk {
 				pins = "gpio56", "gpio57",
 				       "gpio58";
@@ -3176,6 +3271,11 @@ qup_spi19_cs: qup-spi19-cs {
 				function = "qup19";
 			};
 
+			qup_spi19_cs_gpio: qup-spi19-cs-gpio {
+				pins = "gpio3";
+				function = "gpio";
+			};
+
 			qup_spi19_data_clk: qup-spi19-data-clk {
 				pins = "gpio0", "gpio1",
 				       "gpio2";
Signature · 1 line
2.30.0
Reviewed-by on v3 3/4
#7 lore raw

Re: [PATCH v3 3/4] arm64: dts: qcom: sm8250: add pinctrl for SPI using GPIO as a CS

Hi

Quoted 10 lines · Dmitry Baryshkov

GENI SPI controller shows several issues if it manages the CS on its own (see 37dd4b777942 ("arm64: dts: qcom: sc7180: Provide pinconf for SPI to use GPIO for CS")) for the details. Provide pinctrl entries for SPI controllers using the same CS pin but in GPIO mode.

---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 100 +++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
#8 lore raw

PATCH v3 4/4 arm64: dts: qcom: qrb5165-rb5: switch into using GPIO for SPI0 CS

In reply to Dmitry Baryshkov

GENI SPI controller shows several issues if it manages the CS on its own (see 37dd4b777942 ("arm64: dts: qcom: sc7180: Provide pinconf for SPI to use GPIO for CS")) for the details. Configure SPI0 CS pin as a GPIO.

---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +3 -2
index 922f329d623a..d329829c61fa 100644
@@ -815,7 +815,7 @@ &pm8150_rtc {
 	status = "okay";
 };
 
-&qup_spi0_cs {
+&qup_spi0_cs_gpio {
 	drive-strength = <6>;
 	bias-disable;
 };
@@ -963,7 +963,8 @@ codec {
 &spi0 {
 	status = "okay";
 	pinctrl-names = "default";
-	pinctrl-0 = <&qup_spi0_data_clk>, <&qup_spi0_cs>;
+	pinctrl-0 = <&qup_spi0_data_clk>, <&qup_spi0_cs_gpio>;
+	cs-gpios = <&tlmm 31 GPIO_ACTIVE_LOW>;
 
 	can@0 {
 		compatible = "microchip,mcp2518fd";
Signature · 1 line
2.30.0
Reviewed-by on v3 4/4
#9 lore raw

Re: [PATCH v3 4/4] arm64: dts: qcom: qrb5165-rb5: switch into using GPIO for SPI0 CS

Hi,

Quoted 4 lines · Dmitry Baryshkov

GENI SPI controller shows several issues if it manages the CS on its own (see 37dd4b777942 ("arm64: dts: qcom: sc7180: Provide pinconf for SPI to use GPIO for CS")) for the details. Configure SPI0 CS pin as a GPIO.

Slight nit that it might be nice to mention that (presumably) the only reason this actually fixed any bugs for you is because you have extra non-mainline patches to the SPI driver that (presumably) break non-GPIO chip select. If it's the same non-mainline patch that I reviewed to add GPI/GSI support to the SPI driver then I'm not terribly surprised. I believe when I reviewed it I found that it was breaking the non-GPI/GSI code paths.

See <https://lore.kernel.org/r/CAD=FV=XmfpQXhK_tKor-ta+5dqT-aq7OnV1e=VY-vMuXmUQEfQ@mail.gmail.com>
where I said "Why are you changing this? [...] I'd imagine this
change breaks stuff?"

Really the only benefit from this change _should_ be better performance.

Quoted 4 lines
---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Other than the nit about the CL desc: