Skip to contentSkip to conversation

ARM: dts: exynos: Add CD and WP pins to Odroid XU SD card

PATCH In review Krzysztof Kozlowski 2 participants 3 messages Sep 21, 2018 – Sep 26, 2018

Subsystems (2)
lore
Share & tools
lore

Krzysztof Kozlowski

author maintainer
#0 lore raw

PATCH 1/1 ARM: dts: exynos: Add CD and WP pins to Odroid XU SD card

Defining card-detect and write-protect GPIO pins in Odroid XU SD Card does not change anything from functional point of view - dw-mmc driver was reading the state from registers. Adding cd-gpios and wp-gpios properties changes only internal driver behavior to access the pins directly.

Add them to DTS only to comprehensively describe the hardware. Minor benefit is that write-protect pin configuration makes sure that it will be properly pulled up to indicate write access.

This also removes debug messages:
dwmmc_exynos 12220000.mmc: No GPIO consumer cd found dwmmc_exynos 12220000.mmc: No GPIO consumer wp found

---
 arch/arm/boot/dts/exynos5410-odroidxu.dts | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/boot/dts/exynos5410-odroidxu.dts +11 -1
index a2046f5f998c..dae360f29a47 100644
@@ -525,12 +525,14 @@
 
 &mmc_2 {
 	status = "okay";
+	wp-gpios = <&gpm5 0 GPIO_ACTIVE_LOW>;
+	cd-gpios = <&gpc2 2 GPIO_ACTIVE_LOW>;
 	card-detect-delay = <200>;
 	samsung,dw-mshc-ciu-div = <3>;
 	samsung,dw-mshc-sdr-timing = <0 4>;
 	samsung,dw-mshc-ddr-timing = <0 2>;
 	pinctrl-names = "default";
-	pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus1 &sd2_bus4>;
+	pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus1 &sd2_bus4 &sd2_wp>;
 	bus-width = <4>;
 	cap-sd-highspeed;
 	vmmc-supply = <&ldo21_reg>;
@@ -573,6 +575,14 @@
 		samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
 		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>;
 	};
+
+	sd2_wp: sd2-wp {
+		samsung,pins = "gpm5-0";
+		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
+		/* Pin is floating so pull it up to disable write-protect */
+		samsung,pin-pud = <EXYNOS_PIN_PULL_UP>;
+		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV4>;
+	};
 };
 
 &pwm {
Signature · 1 line
2.17.1
#1 lore raw

Hi Krzysztof,

Quoted 26 lines · Krzysztof Kozlowski

Defining card-detect and write-protect GPIO pins in Odroid XU SD Card does not change anything from functional point of view - dw-mmc driver was reading the state from registers. Adding cd-gpios and wp-gpios properties changes only internal driver behavior to access the pins directly.

Add them to DTS only to comprehensively describe the hardware. Minor benefit is that write-protect pin configuration makes sure that it will be properly pulled up to indicate write access.

This also removes debug messages:
dwmmc_exynos 12220000.mmc: No GPIO consumer cd found dwmmc_exynos 12220000.mmc: No GPIO consumer wp found

---
  arch/arm/boot/dts/exynos5410-odroidxu.dts | 12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/boot/dts/exynos5410-odroidxu.dts +0 -0
index a2046f5f998c..dae360f29a47 100644
@@ -525,12 +525,14 @@
 
  &mmc_2 {

arch/arm/boot/dts/exynos5410-odroidxu.dts line 535

Quoted 10 lines
arch/arm/boot/dts/exynos5410-odroidxu.dts +3 -1
  	status = "okay";
+	wp-gpios = <&gpm5 0 GPIO_ACTIVE_LOW>;
+	cd-gpios = <&gpc2 2 GPIO_ACTIVE_LOW>;
  	card-detect-delay = <200>;
  	samsung,dw-mshc-ciu-div = <3>;
  	samsung,dw-mshc-sdr-timing = <0 4>;
  	samsung,dw-mshc-ddr-timing = <0 2>;
  	pinctrl-names = "default";
-	pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus1 &sd2_bus4>;
+	pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus1 &sd2_bus4 &sd2_wp>;

IMHO there is no point adding cd-gpios property if CD line is already assigned to this device via respective pin ctrl entry (as special function).

Handling of WP line is even more controversial imho. Ideally the drivers or mmc core should check somehow if WP line is available or not and act respectively. WP line is not available on uSD card connector so there is no point describing it.

Quoted 8 lines
arch/arm/boot/dts/exynos5410-odroidxu.dts +1 -0
  	bus-width = <4>;
  	cap-sd-highspeed;
  	vmmc-supply = <&ldo21_reg>;
@@ -573,6 +575,14 @@
  		samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
  		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>;
  	};
+

arch/arm/boot/dts/exynos5410-odroidxu.dts line 588

Quoted 10 lines
arch/arm/boot/dts/exynos5410-odroidxu.dts +7 -0
+	sd2_wp: sd2-wp {
+		samsung,pins = "gpm5-0";
+		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
+		/* Pin is floating so pull it up to disable write-protect */
+		samsung,pin-pud = <EXYNOS_PIN_PULL_UP>;
+		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV4>;
+	};
  };
 
  &pwm {

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
author maintainer
#2 lore raw
Quoted 43 lines · Marek Szyprowski

Hi Krzysztof,

Quoted 26 lines · Krzysztof Kozlowski

Defining card-detect and write-protect GPIO pins in Odroid XU SD Card does not change anything from functional point of view - dw-mmc driver was reading the state from registers. Adding cd-gpios and wp-gpios properties changes only internal driver behavior to access the pins directly.

Add them to DTS only to comprehensively describe the hardware. Minor benefit is that write-protect pin configuration makes sure that it will be properly pulled up to indicate write access.

This also removes debug messages:
dwmmc_exynos 12220000.mmc: No GPIO consumer cd found dwmmc_exynos 12220000.mmc: No GPIO consumer wp found

---
  arch/arm/boot/dts/exynos5410-odroidxu.dts | 12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/boot/dts/exynos5410-odroidxu.dts +0 -0
index a2046f5f998c..dae360f29a47 100644
@@ -525,12 +525,14 @@
 
  &mmc_2 {

arch/arm/boot/dts/exynos5410-odroidxu.dts line 535

Quoted 10 lines
arch/arm/boot/dts/exynos5410-odroidxu.dts +3 -1
  	status = "okay";
+	wp-gpios = <&gpm5 0 GPIO_ACTIVE_LOW>;
+	cd-gpios = <&gpc2 2 GPIO_ACTIVE_LOW>;
  	card-detect-delay = <200>;
  	samsung,dw-mshc-ciu-div = <3>;
  	samsung,dw-mshc-sdr-timing = <0 4>;
  	samsung,dw-mshc-ddr-timing = <0 2>;
  	pinctrl-names = "default";
-	pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus1 &sd2_bus4>;
+	pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus1 &sd2_bus4 &sd2_wp>;

IMHO there is no point adding cd-gpios property if CD line is already assigned to this device via respective pin ctrl entry (as special function).

Quoted 4 lines

Handling of WP line is even more controversial imho. Ideally the drivers or mmc core should check somehow if WP line is available or not and act respectively. WP line is not available on uSD card connector so there is no point describing it.

Thanks for comments. In that case I'll add only the pin configuration to be sure that pin stays pulled up.

Best regards,
Krzysztof

Quoted 25 lines
Quoted 9 lines
arch/arm/boot/dts/exynos5410-odroidxu.dts +1 -0
  	bus-width = <4>;
  	cap-sd-highspeed;
  	vmmc-supply = <&ldo21_reg>;
@@ -573,6 +575,14 @@
  		samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
  		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>;
  	};
+

arch/arm/boot/dts/exynos5410-odroidxu.dts line 588

Quoted 10 lines
arch/arm/boot/dts/exynos5410-odroidxu.dts +7 -0
+	sd2_wp: sd2-wp {
+		samsung,pins = "gpm5-0";
+		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
+		/* Pin is floating so pull it up to disable write-protect */
+		samsung,pin-pud = <EXYNOS_PIN_PULL_UP>;
+		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV4>;
+	};
  };
 
  &pwm {

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland