Sdmmc3 initial regulator state

Hi, I would like to enable sdmmc3 on my custom carrier board. It seems to work except when sd card is already inserted before boot. In which case, VDD is out lo. How can I enable vmmc regulator when card is already inserted before boot?

I have GPIO06 for sdmmc_vdd_en connected to load switch. And GPIO03 for sdmmc_cd, which gets pulled to ground when card is inserted.

I configured GPIO06(PC.04) is POR=pd, Output, Drive 0 and GPIO03(PL.02) is POR=z, Input, Int PU with the pinmux spreadsheet and commented out / disabled conflicting assignments.

Also write the following regulator:

p3636_sdmmc_vdd_en: regulator@126 {
compatible = “regulator-fixed-sync”;
reg = <126>;
regulator-name = “sdmmc-vdd-en”;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
gpio = <&tegra_main_gpio TEGRA_MAIN_GPIO(C, 4) 0>;
enable-active-high;
};

and

sdhci@344000 {
/delete-property/ non-removable;
/delete-property/ force-non-removable-rescan;
status = “okay”;
};

and

sdmmc3: sdhci@3440000 {
mmc-ocr-mask = <0x0>;
cd-inverted;
cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(L, 2) 0>;
vmmc-supply = <&p3636_sdmmc_vdd_en>;
status = “okay”;
};

inserting and removing card leaves messages
mmc1: Enabling vmmc regulator
and
mmc1: Disabling vmmc regulator

It is only when the card is inserted before boot, cd pin is in lo and sdmmc-vdd-en is out lo. I have to remove and reinsert card to fix. Is there a way to force rescan? Or am I missing something?

if I make the following changes:

p3636_sdmmc_vdd_en: regulator@126 {
compatible = “regulator-fixed-sync”;
reg = <126>;
regulator-name = “sdmmc-vdd-en”;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
gpio = <&tegra_main_gpio TEGRA_MAIN_GPIO(C, 4) 0>;
//enable-active-high;
};

sdmmc3: sdhci@3440000 {
mmc-ocr-mask = <0x0>;
//cd-inverted;
cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(L, 2) 1>;
vmmc-supply = <&p3636_sdmmc_vdd_en>;
status = “okay”;
};

sdmmc-vdd-en is hi when I boot whether the card is in or not. Also, removing the card with cause mmc1: Enabling vmmc regulator. This doesn’t seem right.

Looking at sdhci-tegra.c, I think card detect is wrong when there is no cd_cap_invert property. SDHCI standard specifies active low. So, for example in this block of code:

/*
If there is no card detect gpio, assume that the
card is always present.
*/
if (!gpio_is_valid(tegra_host->cd_gpio)) {
host->mmc->rem_card_present = 1;
} else {
if (!host->mmc->cd_cap_invert)
host->mmc->rem_card_present =
(mmc_gpio_get_cd(host->mmc) == 0);
else
host->mmc->rem_card_present =
mmc_gpio_get_cd(host->mmc);
}

will always be rem_card_present=0. I think it should be

rem_card_present = !mmc_gpio_get_cd(host->mmc)

this check happens more than once in sdhci-tegra.c file.

Hi mhd0425,

What’s your Jetpack version in use?

Do you want to use SD to be flashed or used for storage?
Please share the full dmesg for further check.

I am using r32.7.4, and I want to use the SD car for extra storage. I don’t know if it would make any difference but I am testing now without load-switch soldered onto the board. I was just checking power sequence probing the pad. Also, was noticing unexpected behavior when I don’t use cd-inverted.

I can share dmesg in a few hours. Thank you.

If your behavior is wrong with cd-inverted, then please remove it.

For example, if you see the power got enabled when you remove the card, then it is inverted behavior. Please do not use cd-inverted.

I tried so many combinations of setting I lost track. I think I see that inverted behavior when cd-inverted is not used.

Right now the problem is the regulator doesn’t get enabled until the card it re-inserted after boot.

Hi,

Could you check

  1. Whether 0 here is correct one?

cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(L, 2) 0>;

  1. Could you use /proc/device-tree on your jetson to check the runtime device tree instead of relying on using dtsi to track? It could be defined in multiple files and you didn’t notice. For example, you deleted cd-inverted in file A but actually file B still has it. So your deletion has no effect.

Thank you, I will report back in a few hours.

I am really sorry to have wasted your time 🙈 and opened a non-issue. simply soldering load switch fixed the issue. Card now shows up on boot. However, I am still trying to understand why cd-inverted works the way it does.

  1. I can confirm that my cd-inverted is taking effect. When I enable cd-inverted, I see it in proc/device-tree/sdhci@3440000. conversely when I comment out cd-inverted, it is not in proc/device-tree/sdhci@3440000.

Having said that, If I remove cd-inverted from device tree, but keep

cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(L, 2) 0>;

I see the same behavior as if I kept cd-inverted. That is, inserting card enables vmmc regulator and removing card disables vmmc regulator.

If I remove cd-inverted and change it to

cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(L, 2) 1>;

I get inverted behavior: removing card enables vmmc regulator and inserting card disables vmmc regulator.

The same is true if cd-inverted and

cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(L, 2) 1>;

the 0/1 in cd-gpios indicate active high or low. Thus, actually it is similar to cd-inverted behavior too.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.