[JP36.3] AGX Orin Industrial SDcard unplug is not detected

I’m not able to make SD card reader to detected SD cards after system is booted. Card is detected during boot-up, but after boot up I’m not able to detect is it taken off sdcard slot or not. I configured card detect pin in linux kernel device tree:

		mmc@3400000 {
			status = "okay";
			bus-width = <4>;
			cd-gpios = <&gpio TEGRA234_MAIN_GPIO(G, 7) GPIO_ACTIVE_LOW>;
			disable-wp;
		};

I tried to add G7 pin to gpio as input:

/ {
	gpio@2200000 {
		gpio-init-names = "default";
		gpio-init-0 = <&gpio_main_default>;

		gpio_main_default: default {
			gpio-input = <
				TEGRA234_MAIN_GPIO(B, 0)
				TEGRA234_MAIN_GPIO(P, 4)
				TEGRA234_MAIN_GPIO(Q, 7)
				TEGRA234_MAIN_GPIO(R, 1)
				TEGRA234_MAIN_GPIO(N, 4)
				TEGRA234_MAIN_GPIO(M, 3)
				TEGRA234_MAIN_GPIO(M, 5)
				TEGRA234_MAIN_GPIO(M, 6)
				TEGRA234_MAIN_GPIO(N, 1)
				TEGRA234_MAIN_GPIO(G, 0)
				TEGRA234_MAIN_GPIO(G, 1)
				TEGRA234_MAIN_GPIO(G, 2)
				TEGRA234_MAIN_GPIO(G, 4)
				TEGRA234_MAIN_GPIO(G, 7)
				TEGRA234_MAIN_GPIO(H, 0)
				TEGRA234_MAIN_GPIO(AC, 4)
				TEGRA234_MAIN_GPIO(AC, 5)
				TEGRA234_MAIN_GPIO(AC, 7)
				TEGRA234_MAIN_GPIO(AE, 0)
				TEGRA234_MAIN_GPIO(AE, 1)
				TEGRA234_MAIN_GPIO(K, 0)
				TEGRA234_MAIN_GPIO(K, 1)
				TEGRA234_MAIN_GPIO(L, 2)
				TEGRA234_MAIN_GPIO(L, 3)
				>;

I tested few combinations with pinmux:

			soc_gpio20_pg7 {
				nvidia,pins = "soc_gpio20_pg7";
				nvidia,function = "sdmmc1";
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};
			soc_gpio20_pg7 {
				nvidia,pins = "soc_gpio20_pg7";
				nvidia,function = "rsvd0";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

I tried pinmux and gpio generated from orin excel, but even with it, I’m not able to hotplug sdcard. I’m only able to detected SDcard during boot.

Schematics:


image
image

share your dmesg and the log after hotplug.

Also use /sys/kernel/debug/gpio to see if the pin statue got toggled when you hotplug the card.

#Card insert
test@ubuntu:~$ sudo cat /sys/kernel/debug/gpio|grep PG.07
 gpio-390 (PG.07               |cd                  ) in  lo IRQ ACTIVE LOW
#Card pullout
test@ubuntu:~$ sudo cat /sys/kernel/debug/gpio|grep PG.07
gpio-390 (PG.07               |cd                  ) in  lo IRQ ACTIVE LOW
#Card insert 
test@ubuntu:~$ sudo cat /sys/kernel/debug/gpio|grep PG.07
gpio-390 (PG.07               |cd                  ) in  lo IRQ ACTIVE LOW

Dmesg
dmesg.log (63.2 KB)

sudo cat /sys/kernel/debug/mmc1/ios
clock:		195250195 Hz
actual clock:	195250195 Hz
vdd:		21 (3.3 ~ 3.4 V)
bus mode:	2 (push-pull)
chip select:	0 (don't care)
power mode:	2 (on)
bus width:	2 (4 bits)
timing spec:	6 (sd uhs SDR104)
signal voltage:	1 (1.80 V)
driver type:	0 (driver type B)

The state does not change in the whole process. Are you sure the hardware design is correct?

I’ve asked the electronics team to verify the schematics and hardware design. Once I receive a response from them, I’ll update you on the issue.

1 Like

There was some problem with HW design, they fixed it. Because of used specific SD Card slot both card_detection pins where always grounded, so state didn’t changed.

After HW fix:

#Card insert
wbuser@ubuntu:~$ sudo cat /sys/kernel/debug/gpio|grep PG.07
 gpio-390 (PG.07               |cd                  ) in  hi IRQ ACTIVE LOW
#Card taken out
wbuser@ubuntu:~$ sudo cat /sys/kernel/debug/gpio|grep PG.07
 gpio-390 (PG.07               |cd                  ) in  lo IRQ ACTIVE LOW
#Card insert
wbuser@ubuntu:~$ sudo cat /sys/kernel/debug/gpio|grep PG.07
 gpio-390 (PG.07               |cd                  ) in  hi IRQ ACTIVE LOW

But it didn’t detect sdcard:

sudo cat /sys/kernel/debug/mmc1/ios
clock:          0 Hz
vdd:            0 (invalid)
bus mode:       2 (push-pull)
chip select:    0 (don't care)
power mode:     0 (off)
bus width:      0 (1 bits)
timing spec:    0 (legacy)
signal voltage: 0 (3.30 V)
driver type:    0 (driver type B)

Then you should share dmesg again. This thing is always the most important thing…

dmesg_hw_fix.log (58.6 KB)

Just want to clarify this again.

Your card detection currently is set to low active. Are you sure this is what you want?

1 Like

I updated configuration after some testing and it is working fine.

kernel dts:

		mmc@3400000 {
			status = "okay";
			bus-width = <4>;
			cd-gpios = <&gpio TEGRA234_MAIN_GPIO(G, 7) GPIO_ACTIVE_HIGH>;
			disable-wp;
			cap-sd-highspeed;
		};

pinmux:

            //SD Card Chip Detect 
			soc_gpio20_pg7 {
				nvidia,pins = "soc_gpio20_pg7";
				nvidia,function = "sdmmc1";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};
sudo dmesg|grep mmc
[    4.075804] sdhci-tegra 3460000.mmc: Adding to iommu group 2
[    4.088295] mmc0: CQHCI version 5.10
[    4.101454] sdhci-tegra 3400000.mmc: Adding to iommu group 4
[    4.588821] sdhci-tegra 3400000.mmc: Got CD GPIO
[    4.605473] mmc0: SDHCI controller on 3460000.mmc [3460000.mmc] using ADMA 64-bit
[    4.639513] mmc1: SDHCI controller on 3400000.mmc [3400000.mmc] using ADMA 64-bit
[    4.715607] mmc0: Command Queue Engine enabled
[    4.715616] mmc0: new HS400 Enhanced strobe MMC card at address 0001
[    4.715895] mmcblk0: mmc0:0001 G1J38E 59.3 GiB 
[    4.720598]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15
[    4.724360] mmcblk0boot0: mmc0:0001 G1J38E 31.5 MiB 
[    4.724826] mmcblk0boot1: mmc0:0001 G1J38E 31.5 MiB 
[    4.725263] mmcblk0rpmb: mmc0:0001 G1J38E 4.00 MiB, chardev (511:0)
[    4.886080] mmc1: new ultra high speed SDR104 SDXC card at address aaaa
[    4.886312] mmcblk1: mmc1:aaaa SD01T 954 GiB 
[    4.893913]  mmcblk1: p1
[    8.578072] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[    9.399383] EXT4-fs (mmcblk0p1): re-mounted. Opts: (null). Quota mode: none.
[   74.504503] mmc1: card aaaa removed
[  122.826585] mmc1: new ultra high speed SDR104 SDXC card at address aaaa
[  122.827359] mmcblk1: mmc1:aaaa SD01T 954 GiB 
[  122.833469]  mmcblk1: p1
[  237.311282] mmc1: card aaaa removed
[  240.312326] mmc1: error -110 whilst initialising SD card
[  247.975036] mmc1: error -110 whilst initialising SD card
[  264.105695] mmc1: new ultra high speed SDR104 SDXC card at address aaaa
[  264.106520] mmcblk1: mmc1:aaaa SD01T 954 GiB 
[  264.113453]  mmcblk1: p1
1 Like