Skip to content

Commit c914a27

Browse files
linuswstorulf
authored andcommitted
mmc: pxamci: Support getting GPIO descs for RO and WP
This implements the code path for the PXAMCI hostso that it can retrieve GPIO descriptors rather than use the global GPIO numberspace for GPIO lines. If the GPIO descriptor is present, it will take precedence and get used in place of the platform data GPIO number. We move the code around a bit so we request the card detect first and the write protect second. We keep the code setting the host flag for the write protect polarity inversion semantics since the slot GPIO core needs to be refactored to deal with this before we can get rid of this. Cc: Daniel Mack <daniel@zonque.org> Cc: Robert Jarzmik <robert.jarzmik@free.fr> Cc: Bartosz Golaszewski <brgl@bgdev.pl> Cc: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 58e2d87 commit c914a27

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

drivers/mmc/host/pxamci.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/gpio.h>
3434
#include <linux/gfp.h>
3535
#include <linux/of.h>
36-
#include <linux/of_gpio.h>
3736
#include <linux/of_device.h>
3837

3938
#include <asm/sizes.h>
@@ -63,6 +62,7 @@ struct pxamci_host {
6362
unsigned int imask;
6463
unsigned int power_mode;
6564
unsigned long detect_delay_ms;
65+
bool use_ro_gpio;
6666
struct pxamci_platform_data *pdata;
6767

6868
struct mmc_request *mrq;
@@ -432,7 +432,7 @@ static int pxamci_get_ro(struct mmc_host *mmc)
432432
{
433433
struct pxamci_host *host = mmc_priv(mmc);
434434

435-
if (host->pdata && gpio_is_valid(host->pdata->gpio_card_ro))
435+
if (host->use_ro_gpio)
436436
return mmc_gpio_get_ro(mmc);
437437
if (host->pdata && host->pdata->get_ro)
438438
return !!host->pdata->get_ro(mmc_dev(mmc));
@@ -749,33 +749,47 @@ static int pxamci_probe(struct platform_device *pdev)
749749
host->pdata->gpio_power_invert);
750750
}
751751

752-
if (gpio_is_valid(gpio_ro)) {
752+
/* FIXME: should we pass detection delay to debounce? */
753+
ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
754+
if (ret && ret != -ENOENT) {
755+
dev_err(dev, "Failed requesting gpio_cd\n");
756+
goto out;
757+
}
758+
if (ret == -ENOENT && gpio_is_valid(gpio_cd)) {
759+
ret = mmc_gpio_request_cd(mmc, gpio_cd, 0);
760+
if (ret) {
761+
dev_err(dev, "Failed requesting gpio_cd %d\n",
762+
gpio_cd);
763+
}
764+
}
765+
766+
ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL);
767+
if (ret && ret != -ENOENT) {
768+
dev_err(dev, "Failed requesting gpio_ro\n");
769+
goto out;
770+
}
771+
/* Try platform data instead */
772+
if (ret == -ENOENT && gpio_is_valid(gpio_ro)) {
753773
ret = mmc_gpio_request_ro(mmc, gpio_ro);
754774
if (ret) {
755775
dev_err(dev,
756776
"Failed requesting gpio_ro %d\n",
757777
gpio_ro);
758778
goto out;
759-
} else {
760-
mmc->caps2 |= host->pdata->gpio_card_ro_invert ?
761-
0 : MMC_CAP2_RO_ACTIVE_HIGH;
762779
}
763780
}
764-
765-
if (gpio_is_valid(gpio_cd))
766-
ret = mmc_gpio_request_cd(mmc, gpio_cd, 0);
767-
if (ret) {
768-
dev_err(dev, "Failed requesting gpio_cd %d\n",
769-
gpio_cd);
770-
goto out;
781+
if (!ret) {
782+
host->use_ro_gpio = true;
783+
mmc->caps2 |= host->pdata->gpio_card_ro_invert ?
784+
0 : MMC_CAP2_RO_ACTIVE_HIGH;
771785
}
772786

773787
if (host->pdata->init)
774788
host->pdata->init(dev, pxamci_detect_irq, mmc);
775789

776790
if (gpio_is_valid(gpio_power) && host->pdata->setpower)
777791
dev_warn(dev, "gpio_power and setpower() both defined\n");
778-
if (gpio_is_valid(gpio_ro) && host->pdata->get_ro)
792+
if (host->use_ro_gpio && host->pdata->get_ro)
779793
dev_warn(dev, "gpio_ro and get_ro() both defined\n");
780794
}
781795

0 commit comments

Comments
 (0)