Skip to content

Commit

Permalink
ARM: 6307/1: mmci: allow the card detect GPIO value not to be inverted
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rabin Vincent authored and Russell King committed Aug 26, 2010
1 parent d4348c6 commit 2971944
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions arch/arm/mach-realview/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ struct mmci_platform_data realview_mmc0_plat_data = {
.status = realview_mmc_status,
.gpio_wp = 17,
.gpio_cd = 16,
.cd_invert = true,
};

struct mmci_platform_data realview_mmc1_plat_data = {
.ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
.status = realview_mmc_status,
.gpio_wp = 19,
.gpio_cd = 18,
.cd_invert = true,
};

/*
Expand Down
5 changes: 3 additions & 2 deletions drivers/mmc/host/mmci.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,13 @@ static int mmci_get_ro(struct mmc_host *mmc)
static int mmci_get_cd(struct mmc_host *mmc)
{
struct mmci_host *host = mmc_priv(mmc);
struct mmci_platform_data *plat = host->plat;
unsigned int status;

if (host->gpio_cd == -ENOSYS)
status = host->plat->status(mmc_dev(host->mmc));
status = plat->status(mmc_dev(host->mmc));
else
status = !gpio_get_value(host->gpio_cd);
status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;

/*
* Use positive logic throughout - status is zero for no card,
Expand Down
2 changes: 2 additions & 0 deletions include/linux/amba/mmci.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* whether a card is present in the MMC slot or not
* @gpio_wp: read this GPIO pin to see if the card is write protected
* @gpio_cd: read this GPIO pin to detect card insertion
* @cd_invert: true if the gpio_cd pin value is active low
* @capabilities: the capabilities of the block as implemented in
* this platform, signify anything MMC_CAP_* from mmc/host.h
*/
Expand All @@ -35,6 +36,7 @@ struct mmci_platform_data {
unsigned int (*status)(struct device *);
int gpio_wp;
int gpio_cd;
bool cd_invert;
unsigned long capabilities;
};

Expand Down

0 comments on commit 2971944

Please sign in to comment.