mmc: sdhci-pxav3: dt: Support "cd-gpios" property

Tested on OLPC XO-4/MMP3, where the card detection pin for one of
the controllers is a sideband GPIO.  The third cell in the cd-gpios
property controls whether the GPIO is active high/active low.

(Also, pass host_caps2 through from platdata to the mmc host.)

Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
[kliu5@marvell.com: Compile fix]
Signed-off-by: Chris Ball <cjb@laptop.org>
This commit is contained in:
Chris Ball 2012-09-19 16:29:12 +08:00
parent 15e8a8e429
commit 8f63795c60
2 changed files with 26 additions and 0 deletions

View File

@ -24,12 +24,14 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/mmc/card.h> #include <linux/mmc/card.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
#include <linux/mmc/slot-gpio.h>
#include <linux/platform_data/pxa_sdhci.h> #include <linux/platform_data/pxa_sdhci.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h>
#include "sdhci.h" #include "sdhci.h"
#include "sdhci-pltfm.h" #include "sdhci-pltfm.h"
@ -182,6 +184,7 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
u32 bus_width; u32 bus_width;
u32 clk_delay_cycles; u32 clk_delay_cycles;
enum of_gpio_flags gpio_flags;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) if (!pdata)
@ -198,6 +201,10 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
if (clk_delay_cycles > 0) if (clk_delay_cycles > 0)
pdata->clk_delay_cycles = clk_delay_cycles; pdata->clk_delay_cycles = clk_delay_cycles;
pdata->ext_cd_gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &gpio_flags);
if (gpio_flags != OF_GPIO_ACTIVE_LOW)
pdata->host_caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
return pdata; return pdata;
} }
#else #else
@ -266,8 +273,19 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
host->quirks |= pdata->quirks; host->quirks |= pdata->quirks;
if (pdata->host_caps) if (pdata->host_caps)
host->mmc->caps |= pdata->host_caps; host->mmc->caps |= pdata->host_caps;
if (pdata->host_caps2)
host->mmc->caps2 |= pdata->host_caps2;
if (pdata->pm_caps) if (pdata->pm_caps)
host->mmc->pm_caps |= pdata->pm_caps; host->mmc->pm_caps |= pdata->pm_caps;
if (gpio_is_valid(pdata->ext_cd_gpio)) {
ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio);
if (ret) {
dev_err(mmc_dev(host->mmc),
"failed to allocate card detect gpio\n");
goto err_cd_req;
}
}
} }
host->ops = &pxav3_sdhci_ops; host->ops = &pxav3_sdhci_ops;
@ -285,6 +303,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
err_add_host: err_add_host:
clk_disable_unprepare(clk); clk_disable_unprepare(clk);
clk_put(clk); clk_put(clk);
mmc_gpio_free_cd(host->mmc);
err_cd_req:
err_clk_get: err_clk_get:
sdhci_pltfm_free(pdev); sdhci_pltfm_free(pdev);
kfree(pxa); kfree(pxa);
@ -296,11 +316,16 @@ static int __devexit sdhci_pxav3_remove(struct platform_device *pdev)
struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_pxa *pxa = pltfm_host->priv; struct sdhci_pxa *pxa = pltfm_host->priv;
struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
sdhci_remove_host(host, 1); sdhci_remove_host(host, 1);
clk_disable_unprepare(pltfm_host->clk); clk_disable_unprepare(pltfm_host->clk);
clk_put(pltfm_host->clk); clk_put(pltfm_host->clk);
if (gpio_is_valid(pdata->ext_cd_gpio))
mmc_gpio_free_cd(host->mmc);
sdhci_pltfm_free(pdev); sdhci_pltfm_free(pdev);
kfree(pxa); kfree(pxa);

View File

@ -49,6 +49,7 @@ struct sdhci_pxa_platdata {
bool ext_cd_gpio_invert; bool ext_cd_gpio_invert;
unsigned int max_speed; unsigned int max_speed;
unsigned int host_caps; unsigned int host_caps;
unsigned int host_caps2;
unsigned int quirks; unsigned int quirks;
unsigned int pm_caps; unsigned int pm_caps;
}; };