Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 6307/1: mmci: allow the card detect GPIO value not to be inverted

On some platforms, the GPIO value from the gpio_cd pin doesn't need to
be inverted to get it active high. Add a cd_invert platform data
parameter and change existing platforms using GPIO for CD (only
Realview) to enable it.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Rabin Vincent and committed by
Russell King
29719445 d4348c67

+7 -2
+2
arch/arm/mach-realview/core.c
··· 259 259 .status = realview_mmc_status, 260 260 .gpio_wp = 17, 261 261 .gpio_cd = 16, 262 + .cd_invert = true, 262 263 }; 263 264 264 265 struct mmci_platform_data realview_mmc1_plat_data = { ··· 267 266 .status = realview_mmc_status, 268 267 .gpio_wp = 19, 269 268 .gpio_cd = 18, 269 + .cd_invert = true, 270 270 }; 271 271 272 272 /*
+3 -2
drivers/mmc/host/mmci.c
··· 570 570 static int mmci_get_cd(struct mmc_host *mmc) 571 571 { 572 572 struct mmci_host *host = mmc_priv(mmc); 573 + struct mmci_platform_data *plat = host->plat; 573 574 unsigned int status; 574 575 575 576 if (host->gpio_cd == -ENOSYS) 576 - status = host->plat->status(mmc_dev(host->mmc)); 577 + status = plat->status(mmc_dev(host->mmc)); 577 578 else 578 - status = !gpio_get_value(host->gpio_cd); 579 + status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert; 579 580 580 581 /* 581 582 * Use positive logic throughout - status is zero for no card,
+2
include/linux/amba/mmci.h
··· 24 24 * whether a card is present in the MMC slot or not 25 25 * @gpio_wp: read this GPIO pin to see if the card is write protected 26 26 * @gpio_cd: read this GPIO pin to detect card insertion 27 + * @cd_invert: true if the gpio_cd pin value is active low 27 28 * @capabilities: the capabilities of the block as implemented in 28 29 * this platform, signify anything MMC_CAP_* from mmc/host.h 29 30 */ ··· 36 35 unsigned int (*status)(struct device *); 37 36 int gpio_wp; 38 37 int gpio_cd; 38 + bool cd_invert; 39 39 unsigned long capabilities; 40 40 }; 41 41