Skip to contentSkip to conversation

mmc: mxs-mmc: Add wp-inverted property

PATCH In review Marek Vasut 2 participants 5 messages Jun 8, 2012 – Jul 19, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: mxs-mmc: Add wp-inverted property

The write-protect GPIO is inverted on some boards. Handle such case.

Cc Shawn Guo <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Chris Ball <[email protected]>
Cc Lothar Waßmann <[email protected]>
---
 drivers/mmc/host/mxs-mmc.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +13 -2
index 34a9026..c6964e1 100644
@@ -164,16 +164,23 @@ struct mxs_mmc_host {
 	spinlock_t			lock;
 	int				sdio_irq_en;
 	int				wp_gpio;
+	int				wp_inverted:1;
 };
 
 static int mxs_mmc_get_ro(struct mmc_host *mmc)
 {
 	struct mxs_mmc_host *host = mmc_priv(mmc);
+	int ret;
 
 	if (!gpio_is_valid(host->wp_gpio))
 		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)
@@ -707,6 +714,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	struct pinctrl *pinctrl;
 	int ret = 0, irq_err, irq_dma;
 	dma_cap_mask_t mask;
+	enum of_gpio_flags flags;
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
@@ -785,7 +793,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 			mmc->caps |= MMC_CAP_4_BIT_DATA;
 		else if (bus_width == 8)
 			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 {
 		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
 			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
Signature · 1 line
1.7.10
#2 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 17 lines · Marek Vasut

The write-protect GPIO is inverted on some boards. Handle such case.

Cc Shawn Guo <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Chris Ball <[email protected]>
Cc Lothar Waßmann <[email protected]>
---
 drivers/mmc/host/mxs-mmc.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +0 -0
index 34a9026..c6964e1 100644

drivers/mmc/host/mxs-mmc.c struct mxs_mmc_host { · line 167

Quoted 4 lines
drivers/mmc/host/mxs-mmc.c +1 -0
@@ -164,16 +164,23 @@ struct mxs_mmc_host {
 	spinlock_t			lock;
 	int				sdio_irq_en;
 	int				wp_gpio;
+	int				wp_inverted:1;

Mind if I change this to "bool wp_inverted;"? Other than that, looks fine and I'll merge it for 3.6.

Thanks,

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#3 lore raw

Dear Chris Ball,

Quoted 22 lines

Hi Marek,

Quoted 19 lines · Marek Vasut

The write-protect GPIO is inverted on some boards. Handle such case.

Cc Shawn Guo <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Chris Ball <[email protected]>
Cc Lothar Waßmann <[email protected]>

---

 drivers/mmc/host/mxs-mmc.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +0 -0
index 34a9026..c6964e1 100644
@@ -164,16 +164,23 @@ struct mxs_mmc_host {
 
Quoted 8 lines

drivers/mmc/host/mxs-mmc.c struct mxs_mmc_host {

Quoted 5 lines
drivers/mmc/host/mxs-mmc.c +1 -0
 	spinlock_t			lock;
 	int				sdio_irq_en;
 	int				wp_gpio;
 
+	int				wp_inverted:1;

Mind if I change this to "bool wp_inverted;"? Other than that, looks fine and I'll merge it for 3.6.

That should be fine. Thanks!

Quoted 3 lines

Thanks,

- Chris.

Best regards,
Marek Vasut

#4 lore raw

Hi,

Quoted 10 lines · Marek Vasut
Quoted 10 lines
Quoted 10 lines
drivers/mmc/host/mxs-mmc.c +0 -0
index 34a9026..c6964e1 100644
@@ -164,16 +164,23 @@ struct mxs_mmc_host {
 
 	spinlock_t			lock;
 	int				sdio_irq_en;
 	int				wp_gpio;
 
Quoted 6 lines
Quoted 4 lines

drivers/mmc/host/mxs-mmc.c struct mxs_mmc_host { · line 167

Quoted 1 line
drivers/mmc/host/mxs-mmc.c +1 -0
+	int				wp_inverted:1;

Mind if I change this to "bool wp_inverted;"? Other than that, looks fine and I'll merge it for 3.6.

That should be fine. Thanks!

Thanks, pushed to mmc-next for 3.6.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child