Skip to contentSkip to conversation

ARM:OMAP+:MMC: Add parameters to MMC init

PATCH New Jonathan Solnit 2 participants 4 messages Feb 24, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM:OMAP+:MMC: Add parameters to MMC init

Add parameters to the OMAP MMC initialization function so the board can mask host capabilities and set the maximum clock frequency. While the OMAP supports a certain set of MMC host capabilities, individual boards may be more restricted and the OMAP may need to be configured to match the board. The PRG_SDMMC1_SPEEDCTRL bit in the OMAP3 is an example.

---
 arch/arm/cpu/armv7/am33xx/board.c               |    2 +-
 arch/arm/cpu/armv7/omap-common/spl_mmc.c        |    4 +-
 arch/arm/include/asm/arch-am33xx/mmc_host_def.h |    2 +-
 arch/arm/include/asm/arch-omap3/mmc_host_def.h  |    8 +++++-
 arch/arm/include/asm/arch-omap4/mmc_host_def.h  |    2 +-
 arch/arm/include/asm/arch-omap5/mmc_host_def.h  |    2 +-
 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/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                        |   24 +++++++++++++++++++---
 30 files changed, 58 insertions(+), 38 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +1 -1
index d64ae69..6b7a494 100644
@@ -105,7 +105,7 @@ void init_timer(void)
 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
 
arch/arm/cpu/armv7/omap-common/spl_mmc.c +2 -2
index 6f5b43e..4bd0602 100644
@@ -39,10 +39,10 @@ int board_mmc_init(bd_t *bis)
 {
 	switch (omap_boot_device()) {
 	case BOOT_DEVICE_MMC1:
-		omap_mmc_init(0);
+		omap_mmc_init(0, 0, 0);
 		break;
 	case BOOT_DEVICE_MMC2:
-		omap_mmc_init(1);
+		omap_mmc_init(1, 0, 0);
 		break;
 	}
 	return 0;
arch/arm/include/asm/arch-am33xx/mmc_host_def.h +1 -1
index 943526b..26cc300 100644
@@ -159,6 +159,6 @@ typedef struct hsmmc {
 #define mmc_reg_out(addr, mask, val)\
 	writel((readl(addr) & (~(mask))) | ((val) & (mask)), (addr))
 
-int omap_mmc_init(int dev_index);
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max);
 
 #endif /* MMC_HOST_DEF_H */
arch/arm/include/asm/arch-omap3/mmc_host_def.h +6 -2
index f8c42c0..3ce1f07 100644
@@ -33,7 +33,9 @@ typedef struct t2 {
 	unsigned int devconf0;		/* 0x274 */
 	unsigned char res2[0x060];	/* 0x278 */
 	unsigned int devconf1;		/* 0x2D8 */
-	unsigned char res3[0x244];	/* 0x2DC */
+	unsigned char res3[0x16C];	/* 0x2DC */
+	unsigned int ctl_prog_io1;	/* 0x448 */
+	unsigned char res4[0x0D4];	/* 0x44C */
 	unsigned int pbias_lite;	/* 0x520 */
 } t2_t;
 
@@ -48,6 +50,8 @@ typedef struct t2 {
 #define PBIASSPEEDCTRL0			(1 << 2)
 #define PBIASLITEPWRDNZ1		(1 << 9)
 
+#define CTLPROGIO1SPEEDCTRL		(1 << 20)
+
 /*
  * OMAP HSMMC register definitions
  */
@@ -191,6 +195,6 @@ struct hsmmc {
 #define mmc_reg_out(addr, mask, val)\
 	writel((readl(addr) & (~(mask))) | ((val) & (mask)), (addr))
 
-int omap_mmc_init(int dev_index);
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max);
 
 #endif /* MMC_HOST_DEF_H */
arch/arm/include/asm/arch-omap4/mmc_host_def.h +1 -1
index ce1bce1..2114046 100644
@@ -169,6 +169,6 @@ struct hsmmc {
 #define mmc_reg_out(addr, mask, val)\
 	writel((readl(addr) & (~(mask))) | ((val) & (mask)), (addr))
 
-int omap_mmc_init(int dev_index);
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max);
 
 #endif /* MMC_HOST_DEF_H */
arch/arm/include/asm/arch-omap5/mmc_host_def.h +1 -1
index ce1bce1..2114046 100644
@@ -169,6 +169,6 @@ struct hsmmc {
 #define mmc_reg_out(addr, mask, val)\
 	writel((readl(addr) & (~(mask))) | ((val) & (mask)), (addr))
 
-int omap_mmc_init(int dev_index);
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max);
 
 #endif /* MMC_HOST_DEF_H */
board/cm_t35/cm_t35.c +1 -1
index 0a04994..7a2fed7 100644
@@ -318,7 +318,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
 
board/comelit/dig297/dig297.c +1 -1
index 6548281..c6c1071 100644
@@ -147,7 +147,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/corscience/tricorder/tricorder.c +1 -1
index 435711a..aaff2e8 100644
@@ -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);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
 
board/htkw/mcx/mcx.c +1 -1
index e593b43..8f0b527 100644
@@ -93,7 +93,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);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
 
board/isee/igep0020/igep0020.c +1 -1
index 6a3777e..1919085 100644
@@ -96,7 +96,7 @@ static void setup_net_chip(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/isee/igep0030/igep0030.c +1 -1
index 6a92735..492d9d4 100644
@@ -50,7 +50,7 @@ int board_init(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/logicpd/am3517evm/am3517evm.c +1 -1
index 0a105bf..d316f33 100644
@@ -79,7 +79,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);
+       omap_mmc_init(0, 0, 0);
        return 0;
 }
 #endif
board/logicpd/omap3som/omap3logic.c +1 -1
index bc7ec68..89b114b 100644
@@ -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);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
 
board/logicpd/zoom1/zoom1.c +1 -1
index dec0b26..90b6b0f 100644
@@ -92,7 +92,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/logicpd/zoom2/zoom2.c +1 -1
index be3083d..8e18019 100644
@@ -183,7 +183,7 @@ void set_muxconf_regs (void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/matrix_vision/mvblx/mvblx.c +2 -2
index 74b5b19..f68f312 100644
@@ -106,8 +106,8 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
-	omap_mmc_init(1);
+	omap_mmc_init(0, 0, 0);
+	omap_mmc_init(1, 0, 0);
 	return 0;
 }
 #endif
board/overo/overo.c +1 -1
index 7b4064c..f973870 100644
@@ -403,7 +403,7 @@ 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);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/pandora/pandora.c +1 -1
index 58a676d..f369598 100644
@@ -108,7 +108,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/technexion/twister/twister.c +1 -1
index 50c70ab..b61ffca 100644
@@ -133,6 +133,6 @@ int board_eth_init(bd_t *bis)
 	!defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
board/teejet/mt_ventoux/mt_ventoux.c +1 -1
index c5eb42c..c7aedc9 100644
@@ -228,6 +228,6 @@ int board_eth_init(bd_t *bis)
 	!defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
 {
-	return omap_mmc_init(0);
+	return omap_mmc_init(0, 0, 0);
 }
 #endif
board/ti/am3517crane/am3517crane.c +1 -1
index 436645a..888398d 100644
@@ -78,7 +78,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);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/ti/beagle/beagle.c +1 -1
index 8757876..a255f57 100644
@@ -442,7 +442,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);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/ti/evm/evm.c +1 -1
index 8497aee..61fc7b5 100644
@@ -278,7 +278,7 @@ 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);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/ti/omap5_evm/evm.c +2 -2
index ea0cb13..88dac80 100644
@@ -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);
-	omap_mmc_init(1);
+	omap_mmc_init(0, 0, 0);
+	omap_mmc_init(1, 0, 0);
 	return 0;
 }
 #endif
board/ti/panda/panda.c +1 -1
index ca4b8b3..ee82771 100644
@@ -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)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/ti/sdp3430/sdp.c +1 -1
index d73f501..9a1c012 100644
@@ -209,7 +209,7 @@ void set_muxconf_regs(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	omap_mmc_init(0);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
board/ti/sdp4430/sdp.c +2 -2
index 9ae9e2c..982c771 100644
@@ -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);
-	omap_mmc_init(1);
+	omap_mmc_init(0, 0, 0);
+	omap_mmc_init(1, 0, 0);
 	return 0;
 }
 #endif
board/timll/devkit8000/devkit8000.c +1 -1
index 10f189e..a9b50ca 100644
@@ -128,7 +128,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);
+	omap_mmc_init(0, 0, 0);
 	return 0;
 }
 #endif
drivers/mmc/omap_hsmmc.c +20 -4
index 2400db2..b8ab7bc 100644
@@ -80,6 +80,11 @@ unsigned char mmc_board_init(struct mmc *mmc)
 	writel(readl(&t2_base->devconf1) | MMCSDIO2ADPCLKISEL,
 		&t2_base->devconf1);
 
+	/* Change from default of 52MHz to 26MHz if necessary */
+	if (!(mmc->host_caps & MMC_MODE_HS_52MHz))
+		writel(readl(&t2_base->ctl_prog_io1) & ~CTLPROGIO1SPEEDCTRL,
+			&t2_base->ctl_prog_io1);
+
 	writel(readl(&prcm_base->fclken1_core) |
 		EN_MMC1 | EN_MMC2 | EN_MMC3,
 		&prcm_base->fclken1_core);
@@ -463,7 +468,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)
+int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max)
 {
 	struct mmc *mmc;
 
@@ -494,11 +499,22 @@ int omap_mmc_init(int dev_index)
 		return 1;
 	}
 	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;
+	mmc->host_caps = (MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS |
+				MMC_MODE_HC) & ~host_caps_mask;
 
 	mmc->f_min = 400000;
-	mmc->f_max = 52000000;
+
+	if (f_max != 0)
+		mmc->f_max = f_max;
+	else {
+		if (mmc->host_caps & MMC_MODE_HS) {
+			if (mmc->host_caps & MMC_MODE_HS_52MHz)
+				mmc->f_max = 52000000;
+			else
+				mmc->f_max = 26000000;
+		} else
+			mmc->f_max = 20000000;
+	}
 
 	mmc->b_max = 0;
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 ARM:OMAP+:MMC: Add parameters to MMC init

Quoted 7 lines · Jonathan Solnit

Add parameters to the OMAP MMC initialization function so the board can mask host capabilities and set the maximum clock frequency. ?While the OMAP supports a certain set of MMC host capabilities, individual boards may be more restricted and the OMAP may need to be configured to match the board. ?The PRG_SDMMC1_SPEEDCTRL bit in the OMAP3 is an example.

What changed between this version and the last
(http://www.denx.de/wiki/U-Boot/Patches) ? Thanks.

Signature · 1 line
Tom
#2 lore raw

PATCH 1/1 ARM:OMAP+:MMC: Add parameters to MMC init

Just the commit comment. The part about needing this for rail-to-rail swing was inaccurate.

Quoted 16 lines · Tom Rini
Quoted 7 lines · Jonathan Solnit

Add parameters to the OMAP MMC initialization function so the board can mask host capabilities and set the maximum clock frequency. While the OMAP supports a certain set of MMC host capabilities, individual boards may be more restricted and the OMAP may need to be configured to match the board. The PRG_SDMMC1_SPEEDCTRL bit in the OMAP3 is an example.

What changed between this version and the last
(http://www.denx.de/wiki/U-Boot/Patches) ? Thanks.

--
Tom

#3 lore raw

PATCH 1/1 ARM:OMAP+:MMC: Add parameters to MMC init

I just tried to re-submit a v2 following the patch update guidelines and may or may not have made a mess of things. Let me know if you need me to do anything.

Quoted 24 lines · Jonathan Solnit

Just the commit comment. The part about needing this for rail-to-rail swing was inaccurate.

Quoted 16 lines · Tom Rini
Quoted 7 lines · Jonathan Solnit

Add parameters to the OMAP MMC initialization function so the board can mask host capabilities and set the maximum clock frequency. While the OMAP supports a certain set of MMC host capabilities, individual boards may be more restricted and the OMAP may need to be configured to match the board. The PRG_SDMMC1_SPEEDCTRL bit in the OMAP3 is an example.

What changed between this version and the last
(http://www.denx.de/wiki/U-Boot/Patches) ? Thanks.

--
Tom