diff mbox

[U-Boot,07/11] omap: hsmmc: assume cd gpio is active low

Message ID 1415007147-12562-8-git-send-email-grinberg@compulab.co.il
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Igor Grinberg Nov. 3, 2014, 9:32 a.m. UTC
Switch the default CD GPIO polarity to active low.

The current hsmmc driver assumption that the CD GPIO is active high, but
in the real hardware, usually the opposite holds.
The usual SD card socket has a mechanical switch which is grounded as
soon as a card is inserted.
Of course there might be some board logic which inverts the signal, but
as far as current users are concerned, there is no such logic.

Current U-Boot users either not using the CD functionality, or have a
different way (e.g. external to SoC GPIO controller) for checking the
card presence.

This patch also brings the polarity assumption in line with the Linux
kernel and adds appropriate comments.

This patch also might spare issues once the TWL GPIO driver will be
converted to the DM.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Dmitry Lifshitz <lifshitz@compulab.co.il>
---
 board/compulab/cm_t54/cm_t54.c | 7 +------
 drivers/mmc/omap_hsmmc.c       | 4 +++-
 2 files changed, 4 insertions(+), 7 deletions(-)

Comments

Tom Rini Nov. 4, 2014, 4:45 p.m. UTC | #1
On Mon, Nov 03, 2014 at 11:32:23AM +0200, Igor Grinberg wrote:

> Switch the default CD GPIO polarity to active low.
> 
> The current hsmmc driver assumption that the CD GPIO is active high, but
> in the real hardware, usually the opposite holds.
> The usual SD card socket has a mechanical switch which is grounded as
> soon as a card is inserted.
> Of course there might be some board logic which inverts the signal, but
> as far as current users are concerned, there is no such logic.
> 
> Current U-Boot users either not using the CD functionality, or have a
> different way (e.g. external to SoC GPIO controller) for checking the
> card presence.
> 
> This patch also brings the polarity assumption in line with the Linux
> kernel and adds appropriate comments.
> 
> This patch also might spare issues once the TWL GPIO driver will be
> converted to the DM.
> 
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Dmitry Lifshitz <lifshitz@compulab.co.il>

Reviewed-by: Tom Rini <trini@ti.com>
Tom Rini Nov. 5, 2014, 9:31 p.m. UTC | #2
On Mon, Nov 03, 2014 at 11:32:23AM +0200, Igor Grinberg wrote:

> Switch the default CD GPIO polarity to active low.
> 
> The current hsmmc driver assumption that the CD GPIO is active high, but
> in the real hardware, usually the opposite holds.
> The usual SD card socket has a mechanical switch which is grounded as
> soon as a card is inserted.
> Of course there might be some board logic which inverts the signal, but
> as far as current users are concerned, there is no such logic.
> 
> Current U-Boot users either not using the CD functionality, or have a
> different way (e.g. external to SoC GPIO controller) for checking the
> card presence.
> 
> This patch also brings the polarity assumption in line with the Linux
> kernel and adds appropriate comments.
> 
> This patch also might spare issues once the TWL GPIO driver will be
> converted to the DM.
> 
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Dmitry Lifshitz <lifshitz@compulab.co.il>
> Reviewed-by: Tom Rini <trini@ti.com>

Applied to u-boot-ti/master, thanks!
diff mbox

Patch

diff --git a/board/compulab/cm_t54/cm_t54.c b/board/compulab/cm_t54/cm_t54.c
index 944b723..b1a067d 100644
--- a/board/compulab/cm_t54/cm_t54.c
+++ b/board/compulab/cm_t54/cm_t54.c
@@ -100,16 +100,11 @@  uint mmc_get_env_part(struct mmc *mmc)
 #define SB_T54_CD_GPIO 228
 #define SB_T54_WP_GPIO 229
 
-int board_mmc_getcd(struct mmc *mmc)
-{
-	return !gpio_get_value(SB_T54_CD_GPIO);
-}
-
 int board_mmc_init(bd_t *bis)
 {
 	int ret0, ret1;
 
-	ret0 = omap_mmc_init(0, 0, 0, -1, SB_T54_WP_GPIO);
+	ret0 = omap_mmc_init(0, 0, 0, SB_T54_CD_GPIO, SB_T54_WP_GPIO);
 	if (ret0)
 		printf("cm_t54: failed to initialize mmc0\n");
 
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index ef2cbf9..ffb5284 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -611,7 +611,8 @@  static int omap_hsmmc_getcd(struct mmc *mmc)
 	if (cd_gpio < 0)
 		return 1;
 
-	return gpio_get_value(cd_gpio);
+	/* NOTE: assumes card detect signal is active-low */
+	return !gpio_get_value(cd_gpio);
 }
 
 static int omap_hsmmc_getwp(struct mmc *mmc)
@@ -624,6 +625,7 @@  static int omap_hsmmc_getwp(struct mmc *mmc)
 	if (wp_gpio < 0)
 		return 0;
 
+	/* NOTE: assumes write protect signal is active-high */
 	return gpio_get_value(wp_gpio);
 }
 #endif