Skip to contentSkip to conversation

spacemit: k1: fix SD Card Detection for MusePi Pro

PATCH New Yixun Lan 1 participant 1 message Nov 11 RISC-V

lore
Share & tools
lore

Yixun Lan

author
#0 lore raw

PATCH 1/1 spacemit: k1: fix SD Card Detection for MusePi Pro

Previously, on the MusePi Pro board, reading the value from the SD Card Dectect pin always returned 0, and cd-gpio is overrided in dts as active low, causing the system to always treat the SD Card exist regardless of whether it was actually inserted or not.

With GPIO bias patch[1], the GPIO_PULL_UP flag can be passed down at the Card Dectect pin request through "cd-gpios" property. So with correct pull up settings, the SD card CD pin is just work fine, no need to override the DT property, so use the default from dts upstream.

---
This patch try to fix SD Card Dectect pin for MusePi Pro board, Please note the GPIO bias patch[1] is needed along with this one.

Previously, without the fix, SD Card Dectect pin is configured as active low, so it assume SD card always exist no matter being inserted or not. And it will abort at later command phase when no card.

Here are U-Boot logs for cases without or with patches applied

Case A) Before, the patches are not applied

=> gpio input 80
gpio: pin 80 (gpio 80) already claimed by '[email protected]'
gpio: pin 80 (gpio 80) value is 0
=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device

=> gpio input 80
gpio: pin 80 (gpio 80) already claimed by '[email protected]'
gpio: pin 80 (gpio 80) value is 0
=> mmc dev 1
Card did not respond to voltage select! : -110

Case B) After this patch and GPIO bias patch applied:

=> gpio input 80
gpio: pin 80 (gpio 80) already claimed by '[email protected]'
gpio: pin 80 (gpio 80) value is 1
=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device

=> gpio input 80
gpio: pin 80 (gpio 80) already claimed by '[email protected]'
gpio: pin 80 (gpio 80) value is 0
=> mmc dev 1
MMC: no card present

---
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +0 -1
index 200836cc204..f2688a1868f 100644
@@ -131,7 +131,6 @@
 
 &sdhci0 {
 	bootph-pre-ram;
-	cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
 	max-frequency = <204800000>;
 };
 

---
base-commit: 26a75ef02a879b08f1140508aaf9f0051f73d5d5
change-id: 20261111-02-k1-sdcard-fix-cd-2a6fd1272a99

Best regards,

Signature · 1 line
Yixun Lan <[email protected]>