Skip to contentSkip to conversation

Enable SD crd slot on msm8998 MTP

PATCH Superseded Jeffrey Hugo 3 participants 12 messages Nov 15, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Enable SD crd slot on msm8998 MTP

A short series to enable the SD card slot on the msm8998 MTP so that there is some storage media to play with.

Jeffrey Hugo (4):
arm64: dts: qcom: msm8998: correct xo clock name
arm64: dts: qcom: msm8998: Add SDCC2
arm64: dts: qcom: msm8998: Add SDC2 control pins
arm64: dts: qcom: msm8998-mtp: Add external SD

 arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi  | 13 +++++
 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi | 78 ++++++++++++++++++++++++++++++
 arch/arm64/boot/dts/qcom/msm8998.dtsi      | 22 ++++++++-
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#1 lore raw

PATCH 1/4 arm64: dts: qcom: msm8998: correct xo clock name

The root parent clock of most msm8998 clock is the "xo" clock. The DT node is incorrectly named "xo_board", which prevents Linux from correctly parsing the clock tree, resulting in most clocks being unparented and unable to be manipulated. The end result is that we can't turn on clocks for peripherals like SD, so init usually fails.

Fixes 4807c71cc688 (arm64: dts: Add msm8998 SoC and MTP board support)
---
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8998.dtsi +1 -1
index 78227cc..a948d4b 100644
@@ -53,7 +53,7 @@
 	};
 
 	clocks {
-		xo_board {
+		xo {
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 			clock-frequency = <19200000>;
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw

PATCH 2/4 arm64: dts: qcom: msm8998: Add SDCC2

In reply to Jeffrey Hugo

SDCC2 is typically used as the controller for an external SD card slot.

---
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8998.dtsi +18 -1
index a948d4b..09deee0 100644
@@ -53,7 +53,7 @@
 	};
 
 	clocks {
-		xo {
+		xo: xo {
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 			clock-frequency = <19200000>;
@@ -605,6 +605,23 @@
 			#mbox-cells = <1>;
 		};
 
+		sdhc2: sdhci@c0a4900 {
+			compatible = "qcom,sdhci-msm-v4";
+			reg = <0xc0a4900 0x314>, <0xc0a4000 0x800>;
+			reg-names = "hc_mem", "core_mem";
+
+			interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 221 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "hc_irq", "pwr_irq";
+
+			clock-names = "iface", "core", "xo";
+			clocks = <&gcc GCC_SDCC2_AHB_CLK>,
+				 <&gcc GCC_SDCC2_APPS_CLK>,
+				 <&xo>;
+			bus-width = <4>;
+			status = "disabled";
+		};
+
 		blsp2_uart1: serial@c1b0000 {
 			compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
 			reg = <0xc1b0000 0x1000>;
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#5 lore raw

PATCH 3/4 arm64: dts: qcom: msm8998: Add SDC2 control pins

In reply to Jeffrey Hugo

The SDC2 control pins are typically used to manage sleep.

---
 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi | 78 ++++++++++++++++++++++++++++++
 arch/arm64/boot/dts/qcom/msm8998.dtsi      |  2 +
 2 files changed, 80 insertions(+)
 create mode 100644 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +78 -0
new file mode 100644
index 0000000..a22abf9
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */
+
+&tlmm {
+	sdc2_clk_on: sdc2_clk_on {
+		config {
+			pins = "sdc2_clk";
+			bias-disable;           /* NO pull */
+			drive-strength = <16>;  /* 16 MA */
+		};
+	};
+
+	sdc2_clk_off: sdc2_clk_off {
+		config {
+			pins = "sdc2_clk";
+			bias-disable;           /* NO pull */
+			drive-strength = <2>;   /* 2 MA */
+		};
+	};
+
+	sdc2_cmd_on: sdc2_cmd_on {
+		config {
+			pins = "sdc2_cmd";
+			bias-pull-up;           /* pull up */
+			drive-strength = <10>;  /* 10 MA */
+		};
+	};
+
+	sdc2_cmd_off: sdc2_cmd_off {
+		config {
+			pins = "sdc2_cmd";
+			bias-pull-up;           /* pull up */
+			drive-strength = <2>;   /* 2 MA */
+		};
+	};
+
+	sdc2_data_on: sdc2_data_on {
+		config {
+			pins = "sdc2_data";
+			bias-pull-up;           /* pull up */
+			drive-strength = <10>;  /* 10 MA */
+		};
+	};
+
+	sdc2_data_off: sdc2_data_off {
+		config {
+			pins = "sdc2_data";
+			bias-pull-up;           /* pull up */
+			drive-strength = <2>;   /* 2 MA */
+		};
+	};
+
+	sdc2_cd_on: sdc2_cd_on {
+		mux {
+			pins = "gpio95";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio95";
+			bias-pull-up;           /* pull up */
+			drive-strength = <2>;   /* 2 MA */
+		};
+	};
+
+	sdc2_cd_off: sdc2_cd_off {
+		mux {
+			pins = "gpio95";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio95";
+			bias-pull-up;           /* pull up */
+			drive-strength = <2>;   /* 2 MA */
+		};
+	};
+};
arch/arm64/boot/dts/qcom/msm8998.dtsi +2 -0
index 09deee0..94827f4 100644
@@ -705,3 +705,5 @@
 		};
 	};
 };
+
+#include "msm8998-pins.dtsi"
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#8 lore raw

PATCH 4/4 arm64: dts: qcom: msm8998-mtp: Add external SD

In reply to Jeffrey Hugo

The externally accessible SD card slot on the MTP is driven by SDCC2. Wire it up for use.

---
 arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi | 13 +++++++++++++
 arch/arm64/boot/dts/qcom/msm8998.dtsi     |  1 +
 2 files changed, 14 insertions(+)
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +13 -0
index b4276da..a90b427 100644
@@ -241,3 +241,16 @@
 		};
 	};
 };
+
+&sdhc2 {
+	status = "okay";
+        cd-gpios = <&tlmm 95 GPIO_ACTIVE_LOW>;
+
+        vmmc-supply = <&vreg_l21a_2p95>;
+        vqmmc-supply = <&vreg_l13a_2p95>;
+
+        pinctrl-names = "default", "sleep";
+        pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on  &sdc2_data_on  &sdc2_cd_on>;
+        pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;
+};
+
arch/arm64/boot/dts/qcom/msm8998.dtsi +1 -0
index 94827f4..8e7d788 100644
@@ -3,6 +3,7 @@
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/clock/qcom,gcc-msm8998.h>
+#include <dt-bindings/gpio/gpio.h>
 
 / {
 	interrupt-parent = <&intc>;
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] arm64: dts: qcom: msm8998: correct xo clock name

In reply to Jeffrey Hugo
Quoted 9 lines · Jeffrey Hugo

The root parent clock of most msm8998 clock is the "xo" clock. The DT node is incorrectly named "xo_board", which prevents Linux from correctly parsing the clock tree, resulting in most clocks being unparented and unable to be manipulated. The end result is that we can't turn on clocks for peripherals like SD, so init usually fails.

Fixes 4807c71cc688 (arm64: dts: Add msm8998 SoC and MTP board support)

---

arch/arm64/boot/dts/qcom/msm8998.dtsi line 56

Quoted 13 lines
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8998.dtsi +1 -1
index 78227cc..a948d4b 100644
@@ -53,7 +53,7 @@
 	};
 
 	clocks {
-		xo_board {
+		xo {

You could have taken the opportunity and added the label here...

arch/arm64/boot/dts/qcom/msm8998.dtsi line 59

Quoted 3 lines
arch/arm64/boot/dts/qcom/msm8998.dtsi +0 -0
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 			clock-frequency = <19200000>;

Regards,
Bjorn

Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: msm8998: Add SDCC2

In reply to Jeffrey Hugo
Quoted 4 lines · Jeffrey Hugo

SDCC2 is typically used as the controller for an external SD card slot.

---

Regards,
Bjorn

Quoted 45 lines
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8998.dtsi +18 -1
index a948d4b..09deee0 100644
@@ -53,7 +53,7 @@
 	};
 
 	clocks {
-		xo {
+		xo: xo {
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 			clock-frequency = <19200000>;
@@ -605,6 +605,23 @@
 			#mbox-cells = <1>;
 		};
 
+		sdhc2: sdhci@c0a4900 {
+			compatible = "qcom,sdhci-msm-v4";
+			reg = <0xc0a4900 0x314>, <0xc0a4000 0x800>;
+			reg-names = "hc_mem", "core_mem";
+
+			interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 221 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "hc_irq", "pwr_irq";
+
+			clock-names = "iface", "core", "xo";
+			clocks = <&gcc GCC_SDCC2_AHB_CLK>,
+				 <&gcc GCC_SDCC2_APPS_CLK>,
+				 <&xo>;
+			bus-width = <4>;
+			status = "disabled";
+		};
+
 		blsp2_uart1: serial@c1b0000 {
 			compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
 			reg = <0xc1b0000 0x1000>;
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#9 lore raw

Re: [PATCH 4/4] arm64: dts: qcom: msm8998-mtp: Add external SD

In reply to Jeffrey Hugo
Quoted 18 lines · Jeffrey Hugo

The externally accessible SD card slot on the MTP is driven by SDCC2. Wire it up for use.

---
 arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi | 13 +++++++++++++
 arch/arm64/boot/dts/qcom/msm8998.dtsi     |  1 +
 2 files changed, 14 insertions(+)
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +1 -0
index b4276da..a90b427 100644
@@ -241,3 +241,16 @@
 		};
 	};
 };
+

arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi line 254

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +10 -0
+&sdhc2 {
+	status = "okay";
+        cd-gpios = <&tlmm 95 GPIO_ACTIVE_LOW>;
+
+        vmmc-supply = <&vreg_l21a_2p95>;
+        vqmmc-supply = <&vreg_l13a_2p95>;
+
+        pinctrl-names = "default", "sleep";
+        pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on  &sdc2_data_on  &sdc2_cd_on>;
+        pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;

Fix to use tabs instead of spaces.

Regards,
Andy

#6 lore raw

Re: [PATCH 3/4] arm64: dts: qcom: msm8998: Add SDC2 control pins

In reply to Jeffrey Hugo
Quoted 5 lines · Jeffrey Hugo

The SDC2 control pins are typically used to manage sleep.

---
 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi | 78 ++++++++++++++++++++++++++++++

Rather than adding a -pins file, add the pinctrl states the individual dts(i) directly.

Quoted 10 lines
 arch/arm64/boot/dts/qcom/msm8998.dtsi      |  2 +
 2 files changed, 80 insertions(+)
 create mode 100644 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +0 -0
new file mode 100644
index 0000000..a22abf9

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 5

Quoted 5 lines
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +5 -0
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */
+
+&tlmm {
+	sdc2_clk_on: sdc2_clk_on {

Use _ in labels, - in node names.

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 6

Quoted 1 line
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +1 -0
+		config {

You don't have to put the pinctrl state properties in an additional subnode anymore, so feel free to remove the extra subnode level.

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 9

Quoted 3 lines
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +3 -0
+			pins = "sdc2_clk";
+			bias-disable;           /* NO pull */
+			drive-strength = <16>;  /* 16 MA */

Please push electrical properties to the board dts instead of the platform one, as they might be board specific.

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 11

Quoted 2 lines
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +2 -0
+		};
+	};

Apart from this the patch loogs good.

Regards,
Bjorn

Reviewed-by on v1 4/4
#11 lore raw

Re: [PATCH 4/4] arm64: dts: qcom: msm8998-mtp: Add external SD

In reply to Jeffrey Hugo
Quoted 14 lines · Jeffrey Hugo

The externally accessible SD card slot on the MTP is driven by SDCC2. Wire it up for use.

---
 arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi | 13 +++++++++++++
 arch/arm64/boot/dts/qcom/msm8998.dtsi     |  1 +
 2 files changed, 14 insertions(+)
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +0 -0
index b4276da..a90b427 100644

arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi line 246

Quoted 6 lines
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +3 -0
@@ -241,3 +241,16 @@
 		};
 	};
 };
+
+&sdhc2 {
+	status = "okay";

Please fix the indentation of the rest of the properties in this block.

arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi line 255

Quoted 9 lines
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +9 -0
+        cd-gpios = <&tlmm 95 GPIO_ACTIVE_LOW>;
+
+        vmmc-supply = <&vreg_l21a_2p95>;
+        vqmmc-supply = <&vreg_l13a_2p95>;
+
+        pinctrl-names = "default", "sleep";
+        pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on  &sdc2_data_on  &sdc2_cd_on>;
+        pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;
+};

With that,

Regards,
Bjorn

#10 lore raw

Re: [PATCH 4/4] arm64: dts: qcom: msm8998-mtp: Add external SD

In reply to Andy Gross
Quoted 23 lines · Andy Gross
Quoted 22 lines · Jeffrey Hugo

The externally accessible SD card slot on the MTP is driven by SDCC2. Wire it up for use.

---
  arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi | 13 +++++++++++++
  arch/arm64/boot/dts/qcom/msm8998.dtsi     |  1 +
  2 files changed, 14 insertions(+)
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +5 -0
index b4276da..a90b427 100644
@@ -241,3 +241,16 @@
  		};
  	};
  };
+
+&sdhc2 {
+	status = "okay";
+        cd-gpios = <&tlmm 95 GPIO_ACTIVE_LOW>;
+
Quoted 8 lines

arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi line 254

Quoted 6 lines
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi +6 -0
+        vmmc-supply = <&vreg_l21a_2p95>;
+        vqmmc-supply = <&vreg_l13a_2p95>;
+
+        pinctrl-names = "default", "sleep";
+        pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on  &sdc2_data_on  &sdc2_cd_on>;
+        pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;

Fix to use tabs instead of spaces.

Doh. Nice catch. I see I didn't commit that change in my tree. I'll send out a V2 with this and any other fixes folks comment on.

Signature · 4 lines
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#7 lore raw

Re: [PATCH 3/4] arm64: dts: qcom: msm8998: Add SDC2 control pins

In reply to Bjorn Andersson
Quoted 41 lines · Bjorn Andersson
Quoted 5 lines · Jeffrey Hugo

The SDC2 control pins are typically used to manage sleep.

---
  arch/arm64/boot/dts/qcom/msm8998-pins.dtsi | 78 ++++++++++++++++++++++++++++++

Rather than adding a -pins file, add the pinctrl states the individual dts(i) directly.

Quoted 10 lines
  arch/arm64/boot/dts/qcom/msm8998.dtsi      |  2 +
  2 files changed, 80 insertions(+)

create mode 100644 arch/arm64/boot/dts/qcom/msm8998-pins.dtsi

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +0 -0
new file mode 100644
index 0000000..a22abf9

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 5

Quoted 5 lines
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +5 -0
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */
+
+&tlmm {
+	sdc2_clk_on: sdc2_clk_on {

Use _ in labels, - in node names.

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 6

Quoted 1 line
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +1 -0
+		config {

You don't have to put the pinctrl state properties in an additional subnode anymore, so feel free to remove the extra subnode level.

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 9

Quoted 3 lines
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +3 -0
+			pins = "sdc2_clk";
+			bias-disable;           /* NO pull */
+			drive-strength = <16>;  /* 16 MA */

Please push electrical properties to the board dts instead of the platform one, as they might be board specific.

Quoted 5 lines

arch/arm64/boot/dts/qcom/msm8998-pins.dtsi line 11

Quoted 2 lines
arch/arm64/boot/dts/qcom/msm8998-pins.dtsi new file +2 -0
+		};
+	};

Apart from this the patch loogs good.

Thanks for the guidance. This all makes sense to me. I'll roll this all into v2.

Signature · 4 lines
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.