[U-Boot] [PATCH 7/7] omap_hsmmc: add driver check for write protection

Nikita Kiryanov nikita at compulab.co.il
Mon Dec 3 13:19:47 CET 2012


Add check for write protection in omap mmc driver.

Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg at compulab.co.il>
---
 arch/arm/cpu/armv7/am33xx/board.c            |    4 ++--
 arch/arm/cpu/armv7/omap-common/boot-common.c |    4 ++--
 arch/arm/cpu/armv7/omap3/board.c             |    4 ++--
 arch/arm/include/asm/omap_mmc.h              |    3 ++-
 board/cm_t35/cm_t35.c                        |    2 +-
 board/comelit/dig297/dig297.c                |    2 +-
 board/corscience/tricorder/tricorder.c       |    2 +-
 board/htkw/mcx/mcx.c                         |    2 +-
 board/isee/igep0020/igep0020.c               |    2 +-
 board/isee/igep0030/igep0030.c               |    2 +-
 board/logicpd/am3517evm/am3517evm.c          |    2 +-
 board/logicpd/omap3som/omap3logic.c          |    2 +-
 board/logicpd/zoom1/zoom1.c                  |    2 +-
 board/logicpd/zoom2/zoom2.c                  |    2 +-
 board/matrix_vision/mvblx/mvblx.c            |    4 ++--
 board/nokia/rx51/rx51.c                      |    4 ++--
 board/overo/overo.c                          |    2 +-
 board/pandora/pandora.c                      |    2 +-
 board/technexion/twister/twister.c           |    2 +-
 board/teejet/mt_ventoux/mt_ventoux.c         |    2 +-
 board/ti/am3517crane/am3517crane.c           |    2 +-
 board/ti/beagle/beagle.c                     |    2 +-
 board/ti/evm/evm.c                           |    2 +-
 board/ti/omap5_evm/evm.c                     |    4 ++--
 board/ti/panda/panda.c                       |    2 +-
 board/ti/sdp3430/sdp.c                       |    2 +-
 board/ti/sdp4430/sdp.c                       |    4 ++--
 board/timll/devkit8000/devkit8000.c          |    2 +-
 drivers/mmc/omap_hsmmc.c                     |   14 ++++++++++++--
 29 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c
index 928ff9f..99325c4 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -50,11 +50,11 @@ int cpu_mmc_init(bd_t *bis)
 {
 	int ret;
 
-	ret = omap_mmc_init(0, 0, 0, -1);
+	ret = omap_mmc_init(0, 0, 0, -1, -1);
 	if (ret)
 		return ret;
 
-	return omap_mmc_init(1, 0, 0, -1);
+	return omap_mmc_init(1, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c
index dc2ee0d..25253b6 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -60,11 +60,11 @@ int board_mmc_init(bd_t *bis)
 {
 	switch (spl_boot_device()) {
 	case BOOT_DEVICE_MMC1:
-		omap_mmc_init(0, 0, 0, -1);
+		omap_mmc_init(0, 0, 0, -1, -1);
 		break;
 	case BOOT_DEVICE_MMC2:
 	case BOOT_DEVICE_MMC2_2:
-		omap_mmc_init(1, 0, 0, -1);
+		omap_mmc_init(1, 0, 0, -1, -1);
 		break;
 	}
 	return 0;
diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c
index e95cc50..84e3bcb 100644
--- a/arch/arm/cpu/armv7/omap3/board.c
+++ b/arch/arm/cpu/armv7/omap3/board.c
@@ -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, -1);
+		omap_mmc_init(0, 0, 0, -1, -1);
 		break;
 	case BOOT_DEVICE_MMC2:
 	case BOOT_DEVICE_MMC2_2:
-		omap_mmc_init(1, 0, 0, -1);
+		omap_mmc_init(1, 0, 0, -1, -1);
 		break;
 	}
 	return 0;
diff --git a/arch/arm/include/asm/omap_mmc.h b/arch/arm/include/asm/omap_mmc.h
index 8d86de1..617e22f 100644
--- a/arch/arm/include/asm/omap_mmc.h
+++ b/arch/arm/include/asm/omap_mmc.h
@@ -161,7 +161,8 @@ 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 cd_gpio);
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
+		int wp_gpio);
 
 
 #endif /* OMAP_MMC_H_ */
diff --git a/board/cm_t35/cm_t35.c b/board/cm_t35/cm_t35.c
index 50c0990..6b3617c 100644
--- a/board/cm_t35/cm_t35.c
+++ b/board/cm_t35/cm_t35.c
@@ -357,7 +357,7 @@ int board_mmc_getcd(struct mmc *mmc)
 
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, 59);
 }
 #endif
 
diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
index 2a55cb8..2dca275 100644
--- a/board/comelit/dig297/dig297.c
+++ b/board/comelit/dig297/dig297.c
@@ -147,7 +147,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/corscience/tricorder/tricorder.c b/board/corscience/tricorder/tricorder.c
index 7a79139..092f82e 100644
--- a/board/corscience/tricorder/tricorder.c
+++ b/board/corscience/tricorder/tricorder.c
@@ -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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/htkw/mcx/mcx.c b/board/htkw/mcx/mcx.c
index 5cf5bb6..46fa7e4 100644
--- a/board/htkw/mcx/mcx.c
+++ b/board/htkw/mcx/mcx.c
@@ -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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/isee/igep0020/igep0020.c b/board/isee/igep0020/igep0020.c
index 54e2daf..a025c24 100644
--- a/board/isee/igep0020/igep0020.c
+++ b/board/isee/igep0020/igep0020.c
@@ -134,7 +134,7 @@ static void setup_net_chip(void)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/isee/igep0030/igep0030.c b/board/isee/igep0030/igep0030.c
index 670e0dd..87f6774 100644
--- a/board/isee/igep0030/igep0030.c
+++ b/board/isee/igep0030/igep0030.c
@@ -88,7 +88,7 @@ void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c
index 837fe21..c9858cc 100644
--- a/board/logicpd/am3517evm/am3517evm.c
+++ b/board/logicpd/am3517evm/am3517evm.c
@@ -79,6 +79,6 @@ 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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
diff --git a/board/logicpd/omap3som/omap3logic.c b/board/logicpd/omap3som/omap3logic.c
index fc11812..6e83aa2 100644
--- a/board/logicpd/omap3som/omap3logic.c
+++ b/board/logicpd/omap3som/omap3logic.c
@@ -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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
index e02dc34..c79a261 100644
--- a/board/logicpd/zoom1/zoom1.c
+++ b/board/logicpd/zoom1/zoom1.c
@@ -92,7 +92,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/logicpd/zoom2/zoom2.c b/board/logicpd/zoom2/zoom2.c
index a622b9a..ad6ae36 100644
--- a/board/logicpd/zoom2/zoom2.c
+++ b/board/logicpd/zoom2/zoom2.c
@@ -183,7 +183,7 @@ void set_muxconf_regs (void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/matrix_vision/mvblx/mvblx.c b/board/matrix_vision/mvblx/mvblx.c
index cb1e0c8..49af384 100644
--- a/board/matrix_vision/mvblx/mvblx.c
+++ b/board/matrix_vision/mvblx/mvblx.c
@@ -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, -1);
-	omap_mmc_init(1, 0, 0, -1);
+	omap_mmc_init(0, 0, 0, -1, -1);
+	omap_mmc_init(1, 0, 0, -1, -1);
 	return 0;
 }
 #endif
diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c
index f303e1e..48eb65f 100644
--- a/board/nokia/rx51/rx51.c
+++ b/board/nokia/rx51/rx51.c
@@ -671,7 +671,7 @@ int rx51_kp_getc(void)
  */
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0, 0, 0, -1);
-	omap_mmc_init(1, 0, 0, -1);
+	omap_mmc_init(0, 0, 0, -1, -1);
+	omap_mmc_init(1, 0, 0, -1, -1);
 	return 0;
 }
diff --git a/board/overo/overo.c b/board/overo/overo.c
index ef6f77c..c6a4e3a 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -393,6 +393,6 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
diff --git a/board/pandora/pandora.c b/board/pandora/pandora.c
index e2feff8..9ff5dd7 100644
--- a/board/pandora/pandora.c
+++ b/board/pandora/pandora.c
@@ -139,6 +139,6 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
diff --git a/board/technexion/twister/twister.c b/board/technexion/twister/twister.c
index b9c543d..242c04e 100644
--- a/board/technexion/twister/twister.c
+++ b/board/technexion/twister/twister.c
@@ -143,7 +143,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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/teejet/mt_ventoux/mt_ventoux.c b/board/teejet/mt_ventoux/mt_ventoux.c
index 0a03c89..5c5383a 100644
--- a/board/teejet/mt_ventoux/mt_ventoux.c
+++ b/board/teejet/mt_ventoux/mt_ventoux.c
@@ -299,7 +299,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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/ti/am3517crane/am3517crane.c b/board/ti/am3517crane/am3517crane.c
index 91b6822..0b94245 100644
--- a/board/ti/am3517crane/am3517crane.c
+++ b/board/ti/am3517crane/am3517crane.c
@@ -78,6 +78,6 @@ 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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 639c127..7829261 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -483,7 +483,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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
index 12a433f..d2959ba 100644
--- a/board/ti/evm/evm.c
+++ b/board/ti/evm/evm.c
@@ -278,6 +278,6 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
diff --git a/board/ti/omap5_evm/evm.c b/board/ti/omap5_evm/evm.c
index 45d4704..55337c0 100644
--- a/board/ti/omap5_evm/evm.c
+++ b/board/ti/omap5_evm/evm.c
@@ -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, -1);
-	omap_mmc_init(1, 0, 0, -1);
+	omap_mmc_init(0, 0, 0, -1, -1);
+	omap_mmc_init(1, 0, 0, -1, -1);
 	return 0;
 }
 #endif
diff --git a/board/ti/panda/panda.c b/board/ti/panda/panda.c
index ebbb8b1..cab0598 100644
--- a/board/ti/panda/panda.c
+++ b/board/ti/panda/panda.c
@@ -179,7 +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)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/board/ti/sdp3430/sdp.c b/board/ti/sdp3430/sdp.c
index e256815..052efc5 100644
--- a/board/ti/sdp3430/sdp.c
+++ b/board/ti/sdp3430/sdp.c
@@ -209,6 +209,6 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0, 0, 0, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
diff --git a/board/ti/sdp4430/sdp.c b/board/ti/sdp4430/sdp.c
index 167f3cb..4c1a4f7 100644
--- a/board/ti/sdp4430/sdp.c
+++ b/board/ti/sdp4430/sdp.c
@@ -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, -1);
-	omap_mmc_init(1, 0, 0, -1);
+	omap_mmc_init(0, 0, 0, -1, -1);
+	omap_mmc_init(1, 0, 0, -1, -1);
 	return 0;
 }
 #endif
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index c6f7158..0b81e56 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -136,7 +136,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, -1);
+	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index fcbd133..d0b2820 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -42,6 +42,7 @@
 struct omap_hsmmc_data {
 	struct hsmmc *base_addr;
 	int cd_gpio;
+	int wp_gpio;
 };
 
 /* If we fail after 1 second wait, something is really bad */
@@ -74,6 +75,12 @@ 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);
 }
+
+static int omap_mmc_getwp(struct mmc *mmc)
+{
+	int wp_gpio = ((struct omap_hsmmc_data *)mmc->priv)->wp_gpio;
+	return gpio_get_value(wp_gpio);
+}
 #else
 static inline int omap_mmc_setup_gpio_in(int gpio, const char *label)
 {
@@ -81,6 +88,7 @@ static inline int omap_mmc_setup_gpio_in(int gpio, const char *label)
 }
 
 #define omap_mmc_getcd NULL
+#define omap_mmc_getwp NULL
 #endif
 
 #if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
@@ -580,7 +588,8 @@ 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 cd_gpio)
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
+		int wp_gpio)
 {
 	struct mmc *mmc = &hsmmc_dev[dev_index];
 	struct omap_hsmmc_data *priv_data = &hsmmc_dev_data[dev_index];
@@ -590,7 +599,7 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio)
 	mmc->set_ios = mmc_set_ios;
 	mmc->init = mmc_init_setup;
 	mmc->getcd = omap_mmc_getcd;
-	mmc->getwp = NULL;
+	mmc->getwp = omap_mmc_getwp;
 	mmc->priv = priv_data;
 
 	switch (dev_index) {
@@ -612,6 +621,7 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio)
 		return 1;
 	}
 	priv_data->cd_gpio = omap_mmc_setup_gpio_in(cd_gpio, "mmc_cd");
+	priv_data->wp_gpio = omap_mmc_setup_gpio_in(wp_gpio, "mmc_wp");
 	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;
-- 
1.7.10.4



More information about the U-Boot mailing list