Micro SD card issues on custom TX2i-based board

Hello!
I have a custom board based on the TX2i module. I have an micro SD card reader connected at the same pins as the dev kit, but I have issues making it work.
In particular, at U-Boot when no SD card is inserted, I have a message:
Card did not respond to voltage select!
if it is inserted, I get instead:
MMC: no card present

When Linux boots, I have several messages like:

[ 2.498959] mmc1: CMD CRC or end bit error, int mask 0xc0000

Then, checking the GPIOs in sysfs, when I turn on the card with no SD card I get (the Card Detect GPIO value is correct, it is not inverted for the card reader I use):

gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-412 (                    |vdd-usb0-5v         ) out lo    
 gpio-413 (                    |vdd-usb1-5v         ) out lo    
 gpio-420 (                    |eqos_phy_reset      ) out hi    
 gpio-445 (                    |cd                  ) in  lo    
 gpio-446 (                    |en-vdd-sd           ) out lo    
 gpio-479 (                    |external-connection:) in  lo

then if I insert the card:

gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-412 (                    |vdd-usb0-5v         ) out lo    
 gpio-413 (                    |vdd-usb1-5v         ) out lo    
 gpio-420 (                    |eqos_phy_reset      ) out hi    
 gpio-445 (                    |cd                  ) in  hi    
 gpio-446 (                    |en-vdd-sd           ) out lo    
 gpio-479 (                    |external-connection:) in  lo

and when I remove it again I have in syslog
Sep 25 13:50:04 drone kernel: [ 338.164840] mmc2: Enabling vmmc regulator
and in sysfs:

gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-412 (                    |vdd-usb0-5v         ) out lo    
 gpio-413 (                    |vdd-usb1-5v         ) out lo    
 gpio-420 (                    |eqos_phy_reset      ) out hi    
 gpio-445 (                    |cd                  ) in  lo    
 gpio-446 (                    |en-vdd-sd           ) out hi    
 gpio-479 (                    |external-connection:) in  lo  

Checking the voltages on the pins I do have values that match those shown in sysfs.

The pins have been configured as in figure:

Please find in attachment the current DTB decompiled and the dmesg logs.

Could you please help me out? I’ve tried searching quite a while on the Internet, but I was unable to find a relevant result.

Thanks a lot in advance and have a nice week-end!
Rob

dmesg_log.txt (55.8 KB)
dtb_dump.txt (338.7 KB)

Hi,

Could you directly share what you’ve added to device tree?

Hello WayneWWW,
Sure!

I’ve commented out three lines in tegra186-quill-common.dtsi:

sdhci@3400000 {
		cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
        // wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
		// cd-inverted;
		// wp-inverted;
		uhs-mask = <0x8>;
		status = "okay";
	};

(we have no write protect and the Card Detect is not inverted) and that’s basically it, no further changes (I expected it to behave similarly to the SD reader in the devkit…).

Thanks and have a nice day!
Rob

Could you also share the board schematic?

Hello,
Here’s the schematic for the SD card part (the negation on the DET pin is a mistake in the schematic given the component we have selected)


The pins are connected as follows:

  • SDCARD_PWEN: H16
  • SDCARD_DAT0: H18
  • SDCARD_DAT1: H17
  • SDCARD_DAT2: F19
  • SDCARD_DAT3: F18
  • SDCARD_CMD: G19
  • SDCARD_CLK: G18
  • SDCARD_DET: F17

Please note that I have not changed the en_vdd_sdcard1: regulator@1 entry in tegra186-cvb-prod-p2597-b00-p3489-1000-a00-00, even though the GPIO number is wrong, since this value is overridden by tegra186-quill-p3489-1000-a00-00-base.dts.

If you need any additional information, please do not hesitate to ask!
Thanks again in advance,
Rob

Could you compare the device tree under /proc/device-tree between your board and devkit and see what is the diff?

I’ve flashed a second module with the same config (except for the CardDetect) and put the module in a dev kit.
I’ve inserted an SD card an this is what I get in dmesg:


Also, in sysfs I have:

 gpio-445 (                    |cd                  ) in  lo    
 gpio-446 (                    |en-vdd-sd           ) out hi 

I do guess therefore that the issue could be in a configuration required by the new design that is missing, but I cannot see what it could be…

The device tree extracted with the dtc -I fs /sys/firmware/devicetree/base command on the two boards are attached.

custom_board_dts.txt (356.0 KB)
devkit_dts.txt (356.0 KB)

Do you want me to do a diff wrt the original configuration files?

Hi,

Only diff the sdhci controller part of your sdcard slot should be fine. Please help check.

Actually, there are very few differences, below are the diffs for the related parts (original vs. modified)

file: sources/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi

622,625c661,664
< 		cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 6) 0>;
< 		wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
< 		cd-inverted;
< 		wp-inverted;
---
> 		cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
> 		// wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
> 		// cd-inverted;
> 		// wp-inverted;

file: sources/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-cvb-prod-p2597-b00-p3489-1000-a00-00.dtsi

142c152
< 			gpio = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
---
> 			gpio = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 6) 0>;

Have a nice day!
Rob

Hi,

Do not compare in such way.

Just compare the result from /proc/device-tree for sdhci part.

Hello,

Here’s the diff you’ve asked:

:~$ diff dev_kit.txt custom.txt 
22c22
< 		phandle = <0xf8>;
---
> 		phandle = <0xdc>;
32d31
< 		cd-inverted;
35c34
< 		linux,phandle = <0xf8>;
---
> 		linux,phandle = <0xdc>;
37d35
< 		wp-inverted;
42d39
< 		wp-gpios = <0x1b 0x7c 0x0>;

– full nodes –

DTB from /proc from the devkit, original configuration:

sdhci@3400000 {
	nvidia,ddr-tap-delay = <0xb>;
	nvidia,en-periodic-calib;
	cap-mmc-highspeed;
	compatible = "nvidia,tegra186-sdhci";
	clocks = <0x10 0x34 0x10 0x10d 0x10 0x80>;
	cap-sd-highspeed;
	nvidia,cd-wakeup-capable;
	resets = <0x10 0x21>;
	pinctrl-1 = <0x1a>;
	clock-names = "sdmmc", "pll_p", "sdmmc_legacy_tm";
	pll_source = "pll_p";
	cd-gpios = <0x1b 0x7d 0x0>;
	keep-power-in-suspend;
	nvidia,min-tap-delay = <0x54>;
	ddr-clk-limit = <0x2dc6c00>;
	status = "okay";
	nvidia,max-tap-delay = <0x88>;
	interrupts = <0x0 0x3e 0x4>;
	bus-width = <0x4>;
	ddr-trim-delay = <0x5>;
	phandle = <0xf8>;
	tap-delay = <0xb>;
	reg = <0x0 0x3400000 0x0 0x210>;
	iommus = <0x11 0x1a>;
	pinctrl-0 = <0x19>;
	mmc-ocr-mask = <0x3>;
	compad-vref-1v8 = <0x2>;
	trim-delay = <0x5>;
	pwrdet-support;
	reset-names = "sdhci";
	cd-inverted;
	vmmc-supply = <0x1d>;
	uhs-mask = <0x8>;
	linux,phandle = <0xf8>;
	ignore-pm-notify;
	wp-inverted;
	compad-vref-3v3 = <0x1>;
	vqmmc-supply = <0x1c>;
	pinctrl-names = "sdmmc_e_33v_enable", "sdmmc_e_33v_disable";
	max-clk-limit = <0xc28cb00>;
	wp-gpios = <0x1b 0x7c 0x0>;

	prod-settings {
		#prod-cells = <0x3>;

		prod_c_sdr104 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x4000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000503>;
		};

		prod {
			prod = <0x100 0x1fff002e 0x5090028 0x1c0 0xbfc1ff8 0x8000050 0x1c4 0x77 0x0 0x120 0x20001 0x1 0x128 0x43000000 0x0>;
		};

		prod_c_hs {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr50 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x8000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ddr52 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr12 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ds {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr25 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};
	};
};

DTB from /proc on the custom board, as I have modified it:

sdhci@3400000 {
	nvidia,ddr-tap-delay = <0xb>;
	nvidia,en-periodic-calib;
	cap-mmc-highspeed;
	compatible = "nvidia,tegra186-sdhci";
	clocks = <0x10 0x34 0x10 0x10d 0x10 0x80>;
	cap-sd-highspeed;
	nvidia,cd-wakeup-capable;
	resets = <0x10 0x21>;
	pinctrl-1 = <0x1a>;
	clock-names = "sdmmc", "pll_p", "sdmmc_legacy_tm";
	pll_source = "pll_p";
	cd-gpios = <0x1b 0x7d 0x0>;
	keep-power-in-suspend;
	nvidia,min-tap-delay = <0x54>;
	ddr-clk-limit = <0x2dc6c00>;
	status = "okay";
	nvidia,max-tap-delay = <0x88>;
	interrupts = <0x0 0x3e 0x4>;
	bus-width = <0x4>;
	ddr-trim-delay = <0x5>;
	phandle = <0xdc>;
	tap-delay = <0xb>;
	reg = <0x0 0x3400000 0x0 0x210>;
	iommus = <0x11 0x1a>;
	pinctrl-0 = <0x19>;
	mmc-ocr-mask = <0x3>;
	compad-vref-1v8 = <0x2>;
	trim-delay = <0x5>;
	pwrdet-support;
	reset-names = "sdhci";
	vmmc-supply = <0x1d>;
	uhs-mask = <0x8>;
	linux,phandle = <0xdc>;
	ignore-pm-notify;
	compad-vref-3v3 = <0x1>;
	vqmmc-supply = <0x1c>;
	pinctrl-names = "sdmmc_e_33v_enable", "sdmmc_e_33v_disable";
	max-clk-limit = <0xc28cb00>;

	prod-settings {
		#prod-cells = <0x3>;

		prod_c_sdr104 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x4000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000503>;
		};

		prod {
			prod = <0x100 0x1fff002e 0x5090028 0x1c0 0xbfc1ff8 0x8000050 0x1c4 0x77 0x0 0x120 0x20001 0x1 0x128 0x43000000 0x0>;
		};

		prod_c_hs {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr50 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x8000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ddr52 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr12 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ds {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr25 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};
	};
};

Is the polarity of SDCARD_DET_n inverted on your board? It is pulled to low when card inserted on dev kit.

Dear Trumany,
No, that’s a mistake in the schematics we are aware of. The part we chose has no inverted polarity (that’s why I’ve removed the cd-inverted from the device tree).

Hello,
We finally solved the issue, it is a bug in the kernel shipped with the board. We solved it by setting the parameter override_active_level to false in the call to mmc_gpiod_request_cd in the mmc_gpiod_request_cd() call at drivers/mmc/core/host.c:236. (there are most likely more elegant ways to patch this, but we had already wasted enough time on this…).
In the device tree, the values we used are:

sdhci@3400000 {
	cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
   	// wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
	cd-inverted;
	// wp-inverted;
	uhs-mask = <0x8>;
	status = "okay";
};

Best,
Rob