]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
omap_hsmmc: implement driver check for card detection
authorNikita Kiryanov <nikita@compulab.co.il>
Mon, 3 Dec 2012 02:19:44 +0000 (02:19 +0000)
committerTom Rini <trini@ti.com>
Fri, 8 Mar 2013 21:41:13 +0000 (16:41 -0500)
Implement driver check for card detection.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
28 files changed:
arch/arm/cpu/armv7/am33xx/board.c
arch/arm/cpu/armv7/omap-common/boot-common.c
arch/arm/cpu/armv7/omap3/board.c
arch/arm/include/asm/omap_mmc.h
board/cm_t35/cm_t35.c
board/comelit/dig297/dig297.c
board/corscience/tricorder/tricorder.c
board/htkw/mcx/mcx.c
board/isee/igep00x0/igep00x0.c
board/logicpd/am3517evm/am3517evm.c
board/logicpd/omap3som/omap3logic.c
board/logicpd/zoom1/zoom1.c
board/logicpd/zoom2/zoom2.c
board/matrix_vision/mvblx/mvblx.c
board/nokia/rx51/rx51.c
board/overo/overo.c
board/pandora/pandora.c
board/technexion/twister/twister.c
board/teejet/mt_ventoux/mt_ventoux.c
board/ti/am3517crane/am3517crane.c
board/ti/beagle/beagle.c
board/ti/evm/evm.c
board/ti/omap5_evm/evm.c
board/ti/panda/panda.c
board/ti/sdp3430/sdp.c
board/ti/sdp4430/sdp.c
board/timll/devkit8000/devkit8000.c
drivers/mmc/omap_hsmmc.c

index ab313265d0c43553cc89b507570b05e3c0acfadb..7def17ebaca84584efff11bdfe173f5d5dadc569 100644 (file)
@@ -56,11 +56,11 @@ int cpu_mmc_init(bd_t *bis)
 {
        int ret;
 
-       ret = omap_mmc_init(0, 0, 0);
+       ret = omap_mmc_init(0, 0, 0, -1);
        if (ret)
                return ret;
 
-       return omap_mmc_init(1, 0, 0);
+       return omap_mmc_init(1, 0, 0, -1);
 }
 #endif
 
index 1c8b6177dd5f8912046222569ecf505a3dc27f86..793e82e95cd36620f5dbe5973e52ee62bb9050f4 100644 (file)
@@ -64,11 +64,11 @@ int board_mmc_init(bd_t *bis)
 {
        switch (spl_boot_device()) {
        case BOOT_DEVICE_MMC1:
-               omap_mmc_init(0, 0, 0);
+               omap_mmc_init(0, 0, 0, -1);
                break;
        case BOOT_DEVICE_MMC2:
        case BOOT_DEVICE_MMC2_2:
-               omap_mmc_init(1, 0, 0);
+               omap_mmc_init(1, 0, 0, -1);
                break;
        }
        return 0;
index 89c587e3108aca523f71a3f3823a2e220fb43c6a..f9f7aae776b8a71ad4369d4dfd364060c3c0a6f2 100644 (file)
@@ -98,11 +98,11 @@ int board_mmc_init(bd_t *bis)
 {
        switch (spl_boot_device()) {
        case BOOT_DEVICE_MMC1:
-               omap_mmc_init(0, 0, 0);
+               omap_mmc_init(0, 0, 0, -1);
                break;
        case BOOT_DEVICE_MMC2:
        case BOOT_DEVICE_MMC2_2:
-               omap_mmc_init(1, 0, 0);
+               omap_mmc_init(1, 0, 0, -1);
                break;
        }
        return 0;
index 83726ee0a241b41f09932b260decea96c07777be..8d86de1b1189c42941f76415c2d30caacabd2aa4 100644 (file)
@@ -161,7 +161,7 @@ struct hsmmc {
 #define mmc_reg_out(addr, mask, val)\
        writel((readl(addr) & (~(mask))) | ((val) & (mask)), (addr))
 
-int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max);
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio);
 
 
 #endif /* OMAP_MMC_H_ */
index edbb941985c103e8d18ab2069471f7bd6ef95fa2..89e0fd30a8f4d174f1e4c266114afc950c70d483 100644 (file)
@@ -379,7 +379,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       return omap_mmc_init(0, 0, 0);
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index c6c10717b783655e7ba9a50ca99775a82ac0113e..2a55cb8b7bfc79b3ca3b3390ac8397d5f31fa2b6 100644 (file)
@@ -147,8 +147,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 56fe495277ee7d6ad84df39ab4494de81f2f6784..23e15be77045d3b26ede2ac26bc2c18c68b3dffb 100644 (file)
@@ -80,7 +80,7 @@ void set_muxconf_regs(void)
 #if defined(CONFIG_GENERIC_MMC) && !(defined(CONFIG_SPL_BUILD))
 int board_mmc_init(bd_t *bis)
 {
-       return omap_mmc_init(0, 0, 0);
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 9fe6408ecf9d866acb6d943815f1151686de9d4d..5cf5bb6c4c7b3aa0e82fb45d1d53b18b0cad14ec 100644 (file)
@@ -114,7 +114,7 @@ void set_muxconf_regs(void)
 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       return omap_mmc_init(0, 0, 0);
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 49fcf348930e95a085d3b682eaa537bf94256fe5..3a2a023b641180be7a84fd9539e72240cee56e47 100644 (file)
@@ -150,8 +150,7 @@ static inline void setup_net_chip(void) {}
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 0b3721ed854004f9110d2a4a490f71dc7f060cc0..26f0289d45465425b94a8127b65e65d046f2a232 100644 (file)
@@ -135,8 +135,7 @@ void set_muxconf_regs(void)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 12bcfcb877382e206a3411fedbb7ee720af9c11d..fc1181215bfdbf8e305bc9e646e46fb1a36362f5 100644 (file)
@@ -140,7 +140,7 @@ int board_init(void)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       return omap_mmc_init(0, 0, 0);
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 90b6b0fde57617c44c18fcc6150b490f84d9f63f..e02dc349096cce6d2dfbfac36a6e97e3b74062a0 100644 (file)
@@ -92,8 +92,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 8e1801980139b252b068909cd8b6ad8643128e0d..a622b9a7bb928e4ac60d1e500cf3ab0701ed142f 100644 (file)
@@ -183,8 +183,7 @@ void set_muxconf_regs (void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index f68f3122158ed3a91c9e3d36d4287289dd04a194..cb1e0c8420a3814ef8f19baf86169665c172aaa6 100644 (file)
@@ -106,8 +106,8 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       omap_mmc_init(1, 0, 0);
+       omap_mmc_init(0, 0, 0, -1);
+       omap_mmc_init(1, 0, 0, -1);
        return 0;
 }
 #endif
index b2fe1c531a1b2f2589929bb4dbb0d1957e2bb225..f303e1ebc7678e04964a9c251791d5f3c3f07752 100644 (file)
@@ -671,7 +671,7 @@ int rx51_kp_getc(void)
  */
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       omap_mmc_init(1, 0, 0);
+       omap_mmc_init(0, 0, 0, -1);
+       omap_mmc_init(1, 0, 0, -1);
        return 0;
 }
index fdf46a2aae92101bc2957eab45144f3a6c6571eb..c5b4d5b757fcf04796b93cf21d627071327cea7b 100644 (file)
@@ -392,7 +392,6 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
index 3a62e9d6330b7b326cfd570a95e9f7f9d238116e..e2feff8cae7ecfcf38489ccd70e91ce84bcdef21 100644 (file)
@@ -139,7 +139,6 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
index c9eea9b3045d92ed18845184f839a6154f83a09a..0d44bae1817954037ee78dc860ed39d3d8e664b5 100644 (file)
@@ -147,7 +147,7 @@ int board_eth_init(bd_t *bis)
        !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       return omap_mmc_init(0, 0, 0);
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index c516c75a0066d2341365057fdb7d27e61734253f..6f6c5150a0a427cf1a0c57a7b9cf5cab4bcfec35 100644 (file)
@@ -304,7 +304,7 @@ int board_eth_init(bd_t *bis)
        !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       return omap_mmc_init(0, 0, 0);
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 888398deac25f2f15c87bd93299d39ba46dcead7..91b6822af3f4185c50073dd502d7a423dbf4de06 100644 (file)
@@ -78,7 +78,6 @@ void set_muxconf_regs(void)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
index 58bd55620847d1a352d61f32028065b8b811f0ed..51dbd5df6ef8c9c910b29cef9ff9329b7e706dde 100644 (file)
@@ -532,8 +532,7 @@ void set_muxconf_regs(void)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 8a3aa0c5bfdad3234d424f0b98e34e58ab3b3791..42a98ffabfced1dd1dd48e344dee333e324a30f1 100644 (file)
@@ -277,7 +277,6 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
index c8dfdf814299f83ecb78a8f93ef9629e9c264ad7..45d4704772f8cf4c25e86e0f79aaa84d34b3c622 100644 (file)
@@ -94,8 +94,8 @@ void set_muxconf_regs_non_essential(void)
 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       omap_mmc_init(1, 0, 0);
+       omap_mmc_init(0, 0, 0, -1);
+       omap_mmc_init(1, 0, 0, -1);
        return 0;
 }
 #endif
index 4feef78efe4593d2b27d960d6d3fc8d07053c980..ebbb8b190274ea942945a84825b21f9890fa9eb7 100644 (file)
@@ -179,8 +179,7 @@ void set_muxconf_regs_non_essential(void)
 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 9a1c0121452e79c910f039399589815181d112b9..e256815347641751e112748b1e920986a82ed676 100644 (file)
@@ -209,7 +209,6 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
index 982c771a73286921004bb55015fa78c6a2634503..167f3cbe1554c3a2266b7be6a6b2ca26e92bde03 100644 (file)
@@ -108,8 +108,8 @@ void set_muxconf_regs_non_essential(void)
 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       omap_mmc_init(1, 0, 0);
+       omap_mmc_init(0, 0, 0, -1);
+       omap_mmc_init(1, 0, 0, -1);
        return 0;
 }
 #endif
index 85685ee7c05193ae8b353ef45ec6874ba88dbac4..0fb80657ffceeb082bd25a74d2c00daf9cab9554 100644 (file)
@@ -136,8 +136,7 @@ void set_muxconf_regs(void)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-       omap_mmc_init(0, 0, 0);
-       return 0;
+       return omap_mmc_init(0, 0, 0, -1);
 }
 #endif
 
index 0fdbac391260e51126ea6a5d151b0fd5c9417ee0..cb1a7bdd6544ac00631c88006bc3c06cac22b7b6 100644 (file)
@@ -30,6 +30,7 @@
 #include <twl4030.h>
 #include <twl6030.h>
 #include <twl6035.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
@@ -40,6 +41,7 @@
 
 struct omap_hsmmc_data {
        struct hsmmc *base_addr;
+       int cd_gpio;
 };
 
 /* If we fail after 1 second wait, something is really bad */
@@ -51,6 +53,36 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
 static struct mmc hsmmc_dev[3];
 static struct omap_hsmmc_data hsmmc_dev_data[3];
 
+#if (defined(CONFIG_OMAP_GPIO) && !defined(CONFIG_SPL_BUILD)) || \
+       (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO_SUPPORT))
+static int omap_mmc_setup_gpio_in(int gpio, const char *label)
+{
+       if (!gpio_is_valid(gpio))
+               return -1;
+
+       if (gpio_request(gpio, label) < 0)
+               return -1;
+
+       if (gpio_direction_input(gpio) < 0)
+               return -1;
+
+       return gpio;
+}
+
+static int omap_mmc_getcd(struct mmc *mmc)
+{
+       int cd_gpio = ((struct omap_hsmmc_data *)mmc->priv)->cd_gpio;
+       return gpio_get_value(cd_gpio);
+}
+#else
+static inline int omap_mmc_setup_gpio_in(int gpio, const char *label)
+{
+       return -1;
+}
+
+#define omap_mmc_getcd NULL
+#endif
+
 #if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
 static void omap4_vmmc_pbias_config(struct mmc *mmc)
 {
@@ -548,7 +580,7 @@ static void mmc_set_ios(struct mmc *mmc)
        writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl);
 }
 
-int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max)
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio)
 {
        struct mmc *mmc = &hsmmc_dev[dev_index];
        struct omap_hsmmc_data *priv_data = &hsmmc_dev_data[dev_index];
@@ -557,7 +589,7 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max)
        mmc->send_cmd = mmc_send_cmd;
        mmc->set_ios = mmc_set_ios;
        mmc->init = mmc_init_setup;
-       mmc->getcd = NULL;
+       mmc->getcd = omap_mmc_getcd;
        mmc->priv = priv_data;
 
        switch (dev_index) {
@@ -578,6 +610,7 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max)
                priv_data->base_addr = (struct hsmmc *)OMAP_HSMMC1_BASE;
                return 1;
        }
+       priv_data->cd_gpio = omap_mmc_setup_gpio_in(cd_gpio, "mmc_cd");
        mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
        mmc->host_caps = (MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS |
                                MMC_MODE_HC) & ~host_caps_mask;