* Re: [PATCH] Request OMAP MMC Write-protect pin
2006-09-22 20:08 [PATCH] Request OMAP MMC Write-protect pin andrzej zaborowski
@ 2006-09-22 20:10 ` andrzej zaborowski
2006-10-18 19:12 ` Tony Lindgren
0 siblings, 1 reply; 3+ messages in thread
From: andrzej zaborowski @ 2006-09-22 20:10 UTC (permalink / raw)
To: Linux-OMAP
[-- Attachment #1: Type: text/plain, Size: 239 bytes --]
[Sorry, forgot about the actual diff]
Adds code that requests and frees the WP GPIO pin in OMAP MMC host
driver, similarly to how the MMC Power and MMC Cover-switch GPIOs are
treated.
Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
[-- Attachment #2: linux-omap-wppin.patch --]
[-- Type: application/octet-stream, Size: 1521 bytes --]
diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
index ae08a37..a01682b 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -1009,7 +1009,7 @@ static int mmc_omap_get_ro(struct mmc_ho
{
struct mmc_omap_host *host = mmc_priv(mmc);
- return host->wp_pin && omap_get_gpio_datain(host->wp_pin);
+ return (host->wp_pin >= 0) && omap_get_gpio_datain(host->wp_pin);
}
static struct mmc_host_ops mmc_omap_ops = {
@@ -1117,9 +1117,19 @@ static int __init mmc_omap_probe(struct
omap_set_gpio_direction(host->power_pin, 0);
}
+ if (host->wp_pin >= 0) {
+ if ((ret = omap_request_gpio(host->wp_pin)) != 0) {
+ dev_err(mmc_dev(host->mmc),
+ "Unable to get GPIO pin for MMC "
+ "write-protect switch\n");
+ goto err_free_power_gpio;
+ }
+ omap_set_gpio_direction(host->wp_pin, 1);
+ }
+
ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host);
if (ret)
- goto err_free_power_gpio;
+ goto err_free_wp_gpio;
host->dev = &pdev->dev;
platform_set_drvdata(pdev, host);
@@ -1175,6 +1185,9 @@ no_switch:
mmc_free_host(host->mmc);
}
+err_free_wp_gpio:
+ if (host->wp_pin >= 0)
+ omap_free_gpio(host->wp_pin);
err_free_power_gpio:
if (host->power_pin >= 0)
omap_free_gpio(host->power_pin);
@@ -1203,6 +1216,8 @@ static int mmc_omap_remove(struct platfo
mmc_remove_host(host->mmc);
free_irq(host->irq, host);
+ if (host->wp_pin >= 0)
+ omap_free_gpio(host->wp_pin);
if (host->power_pin >= 0)
omap_free_gpio(host->power_pin);
if (host->switch_pin >= 0) {
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread