linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Marek Vasut <marex@denx.de>, Shawn Guo <shawn.guo@linaro.org>,
	Fabio Estevam <fabio.estevam@freescale.com>,
	linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>
Subject: [PATCH] mmc: mxs-mmc: Add wp-inverted property
Date: Mon, 21 May 2012 05:36:06 +0200	[thread overview]
Message-ID: <1337571366-7779-1-git-send-email-marex@denx.de> (raw)

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

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: linux-mmc@vger.kernel.org
Cc: Chris Ball <cjb@laptop.org>
---
 Documentation/devicetree/bindings/mmc/mxs-mmc.txt |    1 +
 drivers/mmc/host/mxs-mmc.c                        |   11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

V2: Adjust the subject, Cc linux-mmc

diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
index 14d870a..0a7d2cd 100644
--- a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
@@ -13,6 +13,7 @@ Required properties:
 
 Optional properties:
 - wp-gpios: Specify GPIOs for write protection
+- wp-inverted: Set if the write protection GPIO is inverted
 
 Examples:
 
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 277161d..119beb9 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -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)
@@ -786,6 +793,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		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);
+		if (of_find_property(np, "wp-inverted", NULL))
+			host->wp_inverted = 1;
 	} else {
 		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
 			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
-- 
1.7.10


             reply	other threads:[~2012-05-21  3:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21  3:36 Marek Vasut [this message]
2012-05-21  3:45 ` [PATCH] mmc: mxs-mmc: Add wp-inverted property Chris Ball
2012-05-21  3:49   ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2012-05-21 21:01 Marek Vasut
2012-05-21 21:17 ` Guennadi Liakhovetski
2012-06-08 18:55 Marek Vasut
2012-07-19 11:50 ` Marek Vasut
2012-07-19 15:02 ` Chris Ball
2012-07-19 15:06   ` Marek Vasut
2012-07-19 15:12     ` Chris Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337571366-7779-1-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=cjb@laptop.org \
    --cc=fabio.estevam@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).