Commit b6e76f10 authored by Marek Vasut's avatar Marek Vasut Committed by Chris Ball

mmc: mxs-mmc: Add wp-inverted property

The write-protect GPIO is inverted on some boards. Handle such case.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 9a0985b7
...@@ -164,16 +164,23 @@ struct mxs_mmc_host { ...@@ -164,16 +164,23 @@ struct mxs_mmc_host {
spinlock_t lock; spinlock_t lock;
int sdio_irq_en; int sdio_irq_en;
int wp_gpio; int wp_gpio;
bool wp_inverted;
}; };
static int mxs_mmc_get_ro(struct mmc_host *mmc) static int mxs_mmc_get_ro(struct mmc_host *mmc)
{ {
struct mxs_mmc_host *host = mmc_priv(mmc); struct mxs_mmc_host *host = mmc_priv(mmc);
int ret;
if (!gpio_is_valid(host->wp_gpio)) if (!gpio_is_valid(host->wp_gpio))
return -EINVAL; return -EINVAL;
return gpio_get_value(host->wp_gpio); ret = gpio_get_value(host->wp_gpio);
if (host->wp_inverted)
ret = !ret;
return ret;
} }
static int mxs_mmc_get_cd(struct mmc_host *mmc) static int mxs_mmc_get_cd(struct mmc_host *mmc)
...@@ -708,6 +715,7 @@ static int mxs_mmc_probe(struct platform_device *pdev) ...@@ -708,6 +715,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
int ret = 0, irq_err, irq_dma; int ret = 0, irq_err, irq_dma;
dma_cap_mask_t mask; dma_cap_mask_t mask;
struct regulator *reg_vmmc; struct regulator *reg_vmmc;
enum of_gpio_flags flags;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
...@@ -796,7 +804,10 @@ static int mxs_mmc_probe(struct platform_device *pdev) ...@@ -796,7 +804,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps |= MMC_CAP_4_BIT_DATA; mmc->caps |= MMC_CAP_4_BIT_DATA;
else if (bus_width == 8) else if (bus_width == 8)
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0); host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0,
&flags);
if (flags & OF_GPIO_ACTIVE_LOW)
host->wp_inverted = 1;
} else { } else {
if (pdata->flags & SLOTF_8_BIT_CAPABLE) if (pdata->flags & SLOTF_8_BIT_CAPABLE)
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment