SD Card not detected

Hi,

We have a custom-made carrier board with nano(emmc),and BSP version is R32.2.1

We use GPIO06 to detect SD card

According to these links:
https://devtalk.nvidia.com/default/topic/1067459/jetson-nano/sd-card-not-detected/1

https://devtalk.nvidia.com/default/topic/1062120/jetson-nano/microsd-card-not-detected-on-jetson-nano-production-module/post/5380051/#5380051

We modify dts:

diff --git a/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi b/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi
index 63ebabe..c0634a7
--- a/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi
+++ b/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi
@@ -131,7 +131,7 @@
                uhs-mask = <0x1c>;
                power-off-rail;
                nvidia,update-pinctrl-settings;
-               status = "disabled";
+               status = "okay";
        };

        sdhci@700b0200 {

diff --git a/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0000-b00.dtsi b/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0000-b00.dtsi
index d3f9ef2..cb57b1c 100755
--- a/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0000-b00.dtsi
+++ b/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0000-b00.dtsi
@@ -59,6 +59,7 @@
                                TEGRA_GPIO(H, 5)
                                TEGRA_GPIO(H, 6)
                                TEGRA_GPIO(CC, 4)
+                               TEGRA_GPIO(I, 0)^M
                                >;
                        gpio-output-low = <
                                TEGRA_GPIO(S, 7)
@@ -68,7 +69,6 @@
                                TEGRA_GPIO(H, 3)
                                TEGRA_GPIO(H, 4)
                                TEGRA_GPIO(H, 7)
-                               TEGRA_GPIO(I, 0)
                                TEGRA_GPIO(I, 2)
                                >;
                        gpio-output-high = <
diff --git a/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi b/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
old mode 100644
new mode 100755
index 67283d4..e3d0361
--- a/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
+++ b/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
@@ -308,6 +308,7 @@
                        override@1 {
                                target = <&sdhci2>;
                                _overlay_ {
+                                       status = "okay";
                                        vmmc-supply = <&max77620_ldo6>;
                                        no-sdio;
                                        no-mmc;
diff --git a/kernel-dts/tegra210-porg-p3448-common.dtsi b/kernel-dts/tegra210-porg-p3448-common.dtsi
old mode 100644
new mode 100755
index 9ff3f7a..47ce893
--- a/kernel-dts/tegra210-porg-p3448-common.dtsi
+++ b/kernel-dts/tegra210-porg-p3448-common.dtsi
@@ -251,9 +251,22 @@
        };

        sdhci@700b0400 {
-               status = "disabled";
+               status = "okay";
                /delete-property/ keep-power-in-suspend;
                /delete-property/ non-removable;
+               mmc-ddr-1_8v;
+               mmc-ocr-mask = <3>;
+               uhs-mask = <0x0>;
+               max-clk-limit = <400000>;
+               cd-gpios = <&gpio TEGRA_GPIO(I, 0) GPIO_ACTIVE_LOW>;
+               tap-delay = <3>;
+               no-sdio;
+               no-mmc;
+               mmc-ocr-mask=<0>;
+               sd-uhs-sdr104;
+               sd-uhs-sdr50;
+               sd-uhs-sdr25;
+               sd-uhs-sdr12;
        };

        sdhci@700b0200 { /* SDMMC2 for Wifi */
		

diff --git a/kernel-dts/tegra210-soc/tegra210-sdhci.dtsi b/kernel-dts/tegra210-soc/tegra210-sdhci.dtsi
old mode 100644
new mode 100755
index c65c30e..5932a1e
--- a/kernel-dts/tegra210-soc/tegra210-sdhci.dtsi
+++ b/kernel-dts/tegra210-soc/tegra210-sdhci.dtsi
@@ -93,8 +93,8 @@
                 cd-inverted;
                 wp-inverted;
                pwrdet-support;
-               nvidia,min-tap-delay = <106>;
-               nvidia,max-tap-delay = <185>;
+               /delete-property/ nvidia,min-tap-delay;
+               /delete-property/ nvidia,max-tap-delay;
                pinctrl-names = "sdmmc_schmitt_enable", "sdmmc_schmitt_disable", "sdmmc_clk_schmitt_enable", "sdmmc_clk_schmitt_disable", "sdmmc_drv_code", "sdmmc_default_drv_code", "sdmmc_e_33v_enable", "sdmmc_e_33v_disable";
                pinctrl-0 = <&sdmmc3_schmitt_enable_state>;
                pinctrl-1 = <&sdmmc3_schmitt_disable_state>;

and still can’t detect sd card
dmesg.txt (53.9 KB)

Please only follow the patches from this user. (same as your second link)
https://devtalk.nvidia.com/default/topic/1071232

Actually, I think your patch does not have big problem here. Then we should suspect the dtb does not update correctly.

Please try to check the runtime device tree through node /proc/device-tree and check whether your patch in #1 is added correctly or not.

btw, I don’t think you need to delete nvidia,max-tap-delay and nvidia,min-tap-delay at this moment.

Hi WayneWWW,

We want to detect SD card through GPIO06 interrupt, but it has some problem

case 1:
if I just patch these dts, it can detect sd card:

diff --git a/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi b/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi
old mode 100644
new mode 100755
index 63ebabe..c0634a7
--- a/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi
+++ b/kernel-dts/t210-common-platforms/tegra210-p2530-common.dtsi
@@ -131,7 +131,7 @@
                uhs-mask = <0x1c>;
                power-off-rail;
                nvidia,update-pinctrl-settings;
-               status = "disabled";
+               status = "okay";
        };

        sdhci@700b0200 {

diff --git a/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi b/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
old mode 100644
new mode 100755
index 67283d4..e3d0361
--- a/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
+++ b/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
@@ -308,6 +308,7 @@
                        override@1 {
                                target = <&sdhci2>;
                                _overlay_ {
+                                       status = "okay";
                                        vmmc-supply = <&max77620_ldo6>;
                                        no-sdio;
                                        no-mmc;
diff --git a/kernel-dts/tegra210-porg-p3448-common.dtsi b/kernel-dts/tegra210-porg-p3448-common.dtsi
old mode 100644
new mode 100755
index 9ff3f7a..6adce57
--- a/kernel-dts/tegra210-porg-p3448-common.dtsi
+++ b/kernel-dts/tegra210-porg-p3448-common.dtsi
@@ -251,9 +251,15 @@
        };

        sdhci@700b0400 {
-               status = "disabled";
+               status = "okay";
                /delete-property/ keep-power-in-suspend;
                /delete-property/ non-removable;
+               mmc-ddr-1_8v;
+               mmc-ocr-mask = <3>;
+               uhs-mask = <0x0>;
+               max-clk-limit = <400000>;
+               tap-delay = <3>;
        };

        sdhci@700b0200 { /* SDMMC2 for Wifi */

case 2:
but add cd-gpios in tegra210-porg-p3448-common.dtsi, it can’t detect sd card and have error messege in demesg:

diff --git a/kernel-dts/tegra210-porg-p3448-common.dtsi b/kernel-dts/tegra210-porg-p3448-common.dtsi
old mode 100644
new mode 100755
index 9ff3f7a..6adce57
--- a/kernel-dts/tegra210-porg-p3448-common.dtsi
+++ b/kernel-dts/tegra210-porg-p3448-common.dtsi
@@ -251,9 +251,15 @@
        };

        sdhci@700b0400 {
-               status = "disabled";
+               status = "okay";
                /delete-property/ keep-power-in-suspend;
                /delete-property/ non-removable;
+               mmc-ddr-1_8v;
+               mmc-ocr-mask = <3>;
+               uhs-mask = <0x0>;
+               max-clk-limit = <400000>;
+               tap-delay = <3>;
+               cd-gpios = <&gpio TEGRA_GPIO(I, 0) GPIO_ACTIVE_LOW>;
        };

        sdhci@700b0200 { /* SDMMC2 for Wifi */

case_1_dmesg.txt (58.8 KB)
case_2_dmesg.txt (56.4 KB)

The only change between case 1 and case 2 is the cd-gpios

Actually, I don’t think you need to modify “tegra210-p2530-common.dtsi”. I see no nano dts refers to this file.

Below is the error after you added gpio. Could you try to look into “kernel/kernel-4.9/drivers/mmc/host/sdhci-tegra.c” -> sdhci_tegra_probe () and see why it get failed here?

[    1.789948] sdhci-tegra: probe of sdhci-tegra.2 failed with error -16

We have modified these files and can successfully detect the SD card

It seems that the problem is that we set the wrong cd-gpios value

diff --git a/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi b/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
old mode 100644
new mode 100755
index 67283d4..128ce87
--- a/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
+++ b/kernel-dts/porg-plugin-manager/tegra210-porg-plugin-manager.dtsi
@@ -308,6 +308,7 @@
                        override@1 {
                                target = <&sdhci2>;
                                _overlay_ {
+                                       status = "okay";
                                        vmmc-supply = <&max77620_ldo6>;
                                        no-sdio;
                                        no-mmc;
@@ -526,12 +527,12 @@
                                };
                        };
                        /* gpio based i2c mux */
-                       override@29 {
+                       /*override@29 {
                                target = <&{/cam_i2cmux}>;
                                _overlay_ {
                                        status = "okay";
                                };
-                       };
+                       };*/
                        override@30 {
                                target = <&i2c_0>;
                                _overlay_ {
diff --git a/kernel-dts/tegra210-porg-p3448-common.dtsi b/kernel-dts/tegra210-porg-p3448-common.dtsi
old mode 100644
new mode 100755
index 9ff3f7a..f8946cd
--- a/kernel-dts/tegra210-porg-p3448-common.dtsi
+++ b/kernel-dts/tegra210-porg-p3448-common.dtsi
@@ -251,9 +251,15 @@
        };

        sdhci@700b0400 {
-               status = "disabled";
+               status = "okay";
                /delete-property/ keep-power-in-suspend;
                /delete-property/ non-removable;
+               mmc-ddr-1_8v;
+               mmc-ocr-mask = <3>;
+               uhs-mask = <0x0>;
+               tap-delay = <3>;
+               cd-gpios = <&gpio TEGRA_GPIO(I, 0) GPIO_ACTIVE_HIGH>;
        };

        sdhci@700b0200 { /* SDMMC2 for Wifi */