diff options
author | Marek Vasut <marex@denx.de> | 2012-07-19 11:11:39 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-07-22 16:42:46 -0400 |
commit | b6e76f10afbdc510df9288ab4df3e94a89c20909 (patch) | |
tree | 25cefb8efe95546f56ec68fae410cf04a739d996 /drivers/mmc/host | |
parent | 9a0985b78d70209db1e0d870f7be80272a0e7642 (diff) |
mmc: mxs-mmc: Add wp-inverted property
The write-protect GPIO is inverted on some boards. Handle such case.
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r-- | drivers/mmc/host/mxs-mmc.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 2247c50f9869..a51f9309ffbb 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c | |||
@@ -164,16 +164,23 @@ struct mxs_mmc_host { | |||
164 | spinlock_t lock; | 164 | spinlock_t lock; |
165 | int sdio_irq_en; | 165 | int sdio_irq_en; |
166 | int wp_gpio; | 166 | int wp_gpio; |
167 | bool wp_inverted; | ||
167 | }; | 168 | }; |
168 | 169 | ||
169 | static int mxs_mmc_get_ro(struct mmc_host *mmc) | 170 | static int mxs_mmc_get_ro(struct mmc_host *mmc) |
170 | { | 171 | { |
171 | struct mxs_mmc_host *host = mmc_priv(mmc); | 172 | struct mxs_mmc_host *host = mmc_priv(mmc); |
173 | int ret; | ||
172 | 174 | ||
173 | if (!gpio_is_valid(host->wp_gpio)) | 175 | if (!gpio_is_valid(host->wp_gpio)) |
174 | return -EINVAL; | 176 | return -EINVAL; |
175 | 177 | ||
176 | return gpio_get_value(host->wp_gpio); | 178 | ret = gpio_get_value(host->wp_gpio); |
179 | |||
180 | if (host->wp_inverted) | ||
181 | ret = !ret; | ||
182 | |||
183 | return ret; | ||
177 | } | 184 | } |
178 | 185 | ||
179 | static int mxs_mmc_get_cd(struct mmc_host *mmc) | 186 | static int mxs_mmc_get_cd(struct mmc_host *mmc) |
@@ -708,6 +715,7 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
708 | int ret = 0, irq_err, irq_dma; | 715 | int ret = 0, irq_err, irq_dma; |
709 | dma_cap_mask_t mask; | 716 | dma_cap_mask_t mask; |
710 | struct regulator *reg_vmmc; | 717 | struct regulator *reg_vmmc; |
718 | enum of_gpio_flags flags; | ||
711 | 719 | ||
712 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 720 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
713 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 721 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
@@ -796,7 +804,10 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
796 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 804 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
797 | else if (bus_width == 8) | 805 | else if (bus_width == 8) |
798 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; | 806 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; |
799 | host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0); | 807 | host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, |
808 | &flags); | ||
809 | if (flags & OF_GPIO_ACTIVE_LOW) | ||
810 | host->wp_inverted = 1; | ||
800 | } else { | 811 | } else { |
801 | if (pdata->flags & SLOTF_8_BIT_CAPABLE) | 812 | if (pdata->flags & SLOTF_8_BIT_CAPABLE) |
802 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; | 813 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; |