Skip to contentSkip to conversation

sdhci-tegra and power-gpios

DISCUSSION Chris Ball 2 participants 2 messages Oct 1, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Chris Ball

author
#0 lore raw

Hi Stephen, tegra folks,

sdhci-tegra uses a power-gpios property in the DT:

        sdhci@c8000400 {
                status = "okay";
                cd-gpios = <&gpio 69 0>; /* gpio PI5 */
                wp-gpios = <&gpio 57 0>; /* gpio PH1 */
                power-gpios = <&gpio 70 0>; /* gpio PI6 */
                bus-width = <4>;
        };

which it turns on at probe-time in the driver:

        plat->power_gpio = of_get_named_gpio(np, "power-gpios", 0);
        ...
	if (gpio_is_valid(plat->power_gpio)) {
		rc = gpio_request(plat->power_gpio, "sdhci_power");
		if (rc) {
			dev_err(mmc_dev(host->mmc),
				"failed to allocate power gpio\n");
			goto err_power_req;
		}
		gpio_direction_output(plat->power_gpio, 1);
	}

and then leaves on forever. Seems like this should instead be a fixed regulator (vmmc-supply) -- the MMC core would handle powering it up and down as needed, and it's cleaner to let the regulator subsystem handle power changes like this. It might save you some power, too.

It's quite easy to set up a regulator and attach it to an MMC node:

        vmmc1: fixedregulator@0 {
                compatible = "regulator-fixed";
                regulator-name = "fixed-supply";
                regulator-min-microvolt = <2200000>;
                regulator-max-microvolt = <2200000>;
                gpio = <&gpio 70 0>; /* gpio PI6 */
                startup-delay-us = <70000>;
                vin-supply = <&parent_reg>;
        };
..
        sdhci@c8000400 {
                status = "okay";
                cd-gpios = <&gpio 69 0>; /* gpio PI5 */
                wp-gpios = <&gpio 57 0>; /* gpio PH1 */
		vmmc-supply = <&vmmc1>;
                bus-width = <4>;
        };

Any interest in making this change? I've asked other drivers (sdhci-pxav3 and sdhci-spear) to do the same thing (although they hadn't merged their use of power-gpios yet and tegra has).

Thanks,

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · Chris Ball

Hi Stephen, tegra folks,

sdhci-tegra uses a power-gpios property in the DT:

        sdhci@c8000400 {

...

Quoted 1 line
                power-gpios = <&gpio 70 0>; /* gpio PI6 */

...

Quoted 1 line

It's quite easy to set up a regulator and attach it to an MMC node:

...

Quoted 1 line
        sdhci@c8000400 {

...

Quoted 1 line
		vmmc-supply = <&vmmc1>;

...

Quoted 1 line

Any interest in making this change?

Yes, it's certainly something we should be doing. Most Tegra boards will only have all the regulators defined in device tree for the first time in kernel 3.7, and so we've been holding off making any of the client nodes use regulators because of that. Now that we have all the regulators defined, I do hope we will quickly move to using them for SDHCI. Pavan (now CC'd) will hopefully be doing this.