ARM:OMAP+:MMC: Add parameters to MMC init
authorJonathan Solnit <jsolnit@gmail.com>
Fri, 24 Feb 2012 11:30:18 +0000 (11:30 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Tue, 15 May 2012 06:31:22 +0000 (08:31 +0200)
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.

Signed-off-by: Jonathan Solnit <jsolnit@gmail.com>
30 files changed:
arch/arm/cpu/armv7/am33xx/board.c
arch/arm/cpu/armv7/omap-common/spl_mmc.c
arch/arm/include/asm/arch-am33xx/mmc_host_def.h
arch/arm/include/asm/arch-omap3/mmc_host_def.h
arch/arm/include/asm/arch-omap4/mmc_host_def.h
arch/arm/include/asm/arch-omap5/mmc_host_def.h
board/cm_t35/cm_t35.c
board/comelit/dig297/dig297.c
board/corscience/tricorder/tricorder.c
board/htkw/mcx/mcx.c
board/isee/igep0020/igep0020.c
board/isee/igep0030/igep0030.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/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 d64ae6936c5924e948026cbd0b770901b8131d02..6b7a494d7ccd44068a3cdb04e4bdebc8abf7129e 100644 (file)
@@ -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
 
index 6f5b43e559f3b80b44b67f90f55844b1d3c12553..4bd0602a92ca05e9e2eda2a6f58c4a390e8a9178 100644 (file)
@@ -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;
index 943526b94a497a33edf207b57ad5fcea87ed6265..26cc300e70fc170746b766b91d4e6ff81954f9bf 100644 (file)
@@ -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 */
index f8c42c0d20621c483d5eb028075f5629b2343456..3ce1f07b8a372ae84b8d7d70f7044f6d2bb22f38 100644 (file)
@@ -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 */
index ce1bce1fddd64c74302f899499499e898c507bd4..2114046e7130bc0cefee070a1ab4ce7343f29377 100644 (file)
@@ -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 */
index ce1bce1fddd64c74302f899499499e898c507bd4..2114046e7130bc0cefee070a1ab4ce7343f29377 100644 (file)
@@ -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 */
index 7af1f41af2f9932590ebe4c82ffa76fbe554c697..d81b555fb9334016e3b407a8ec073ef9e58253fb 100644 (file)
@@ -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
 
index 65482813d249c22993955b650df95501953e79cf..c6c10717b783655e7ba9a50ca99775a82ac0113e 100644 (file)
@@ -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
index 435711a2ab4f563c1b3fab9efd1d827398c19393..aaff2e868ba2e99e90e55afad877a9111838b058 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);
+       return omap_mmc_init(0, 0, 0);
 }
 #endif
 
index e593b43d48d3701d68d113e709ae1ca3edcd81f2..8f0b52702b02c92cef6493b5e12cea08910db138 100644 (file)
@@ -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
 
index 6a3777eb8c7cb14385573ceb8098fda5cfdc0f1e..1919085d5cadc75ed5479a1d31cff624d01abc24 100644 (file)
@@ -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
index 6a927350b4d29b2d23604201c5e4087b5cc19fd4..492d9d40ffaa482e858f35cc274ba3bc3dd725f3 100644 (file)
@@ -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
index 0a105bf2818314f6584ddbf8408884f6eb13ae7d..d316f33cd11dfdf4b49b9c1c01fd3f25bd226d47 100644 (file)
@@ -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
index bc7ec68f141f994b4a52663b86585f38e7cfa7e1..89b114bf6d713ae60e35fc893e8cd8eb4f1f7f4d 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);
+       return omap_mmc_init(0, 0, 0);
 }
 #endif
 
index dec0b2611f8930057a923d31bd4e37db274b4cc3..90b6b0fde57617c44c18fcc6150b490f84d9f63f 100644 (file)
@@ -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
index be3083d9c339f52de0399d7eb0518bc89e7f1b18..8e1801980139b252b068909cd8b6ad8643128e0d 100644 (file)
@@ -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
index 74b5b19be224b323aebbcab7b59338b7c89a8e74..f68f3122158ed3a91c9e3d36d4287289dd04a194 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);
-       omap_mmc_init(1);
+       omap_mmc_init(0, 0, 0);
+       omap_mmc_init(1, 0, 0);
        return 0;
 }
 #endif
index 7b4064cdb1213c773ba00d50e3ea48652ad6964f..f973870830c0c05a08af1081a6a70dc4e1338e5b 100644 (file)
@@ -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
index 58a676d45535dcc2c1ae2a10e73e6c1400bdac52..f369598d77e825f20580fa764421246b33438303 100644 (file)
@@ -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
index b92758692d57a49d1611b999aeb0cf979be3ce22..c2b10ac1eaaca35e63146d39557a875f985831b9 100644 (file)
@@ -133,7 +133,7 @@ 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
 
index c5eb42c362030b75e0c4695f3b88fec182061687..c7aedc95a625dc7ecf782312255ff57d57a4e872 100644 (file)
@@ -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
index 436645a83f7c4f37310f6f38d4bdfcd4f0545a03..888398deac25f2f15c87bd93299d39ba46dcead7 100644 (file)
@@ -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
index e26b38793474bf073c455d472eabf26c22a67c9f..9edd3c5c4f6b5eb4196572ec1ba164b5bb96d918 100644 (file)
@@ -477,7 +477,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
index 8497aee6de8dd45cc8bb3dfb1e3f55b84497bbf8..61fc7b55310f7748770c06ce457e623f6816988e 100644 (file)
@@ -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
index ea0cb13b437ca09589803b13acc940dc1809b38a..88dac80225e4c62fb4f9a8d4d9e73f319e005085 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);
-       omap_mmc_init(1);
+       omap_mmc_init(0, 0, 0);
+       omap_mmc_init(1, 0, 0);
        return 0;
 }
 #endif
index ca4b8b35ebdb51ab1d630a8c719046ef9693f0d2..ee82771b08d8c1c2f24e75b2cc90bc123c35bc14 100644 (file)
@@ -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
index d73f5018193ffa158ee9c88cb470eae823d73d0d..9a1c0121452e79c910f039399589815181d112b9 100644 (file)
@@ -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
index 9ae9e2c602c3dc10706b62cd2d60a6b99947fcc7..982c771a73286921004bb55015fa78c6a2634503 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);
-       omap_mmc_init(1);
+       omap_mmc_init(0, 0, 0);
+       omap_mmc_init(1, 0, 0);
        return 0;
 }
 #endif
index d75e86b32e69d4cf590ac1b6254ef0da06d16077..35f5e15fc24b61e132cdb7b6947a2f0d61e576cd 100644 (file)
@@ -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)
 {
-       omap_mmc_init(0);
+       omap_mmc_init(0, 0, 0);
        return 0;
 }
 #endif
index 2400db2f35671df76a6b9e8bb927e1438f397b58..b8ab7bc3ded2764cbefdbf82ac27ab8bc291334f 100644 (file)
@@ -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;