mmc: omap: config VMMC, MMC1_PBIAS
authorBalaji T K <balajitk@ti.com>
Thu, 8 Sep 2011 06:34:57 +0000 (06:34 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Fri, 30 Sep 2011 20:00:55 +0000 (22:00 +0200)
Config VMMC voltage to 3V for MMC/SD card slot
and PBIAS settings needed for OMAP4
Fixes MMC/SD detection on boot from eMMC.

Signed-off-by: Balaji T K <balajitk@ti.com>
Signed-off-by: Aneesh V <aneesh@ti.com>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
arch/arm/include/asm/arch-omap4/omap4.h
drivers/mmc/omap_hsmmc.c
drivers/power/twl6030.c
include/configs/omap4_common.h
include/configs/omap4_sdp4430.h
include/twl6030.h

index a6e1e42..fc9c555 100644 (file)
 /* CONTROL_EFUSE_2 */
 #define CONTROL_EFUSE_2_NMOS_PMOS_PTV_CODE_1           0x00ffc000
 
 /* CONTROL_EFUSE_2 */
 #define CONTROL_EFUSE_2_NMOS_PMOS_PTV_CODE_1           0x00ffc000
 
+#define MMC1_PWRDNZ                                    (1 << 26)
+#define MMC1_PBIASLITE_PWRDNZ                          (1 << 22)
+#define MMC1_PBIASLITE_VMODE                           (1 << 21)
+
 #ifndef __ASSEMBLY__
 
 struct s32ktimer {
 #ifndef __ASSEMBLY__
 
 struct s32ktimer {
@@ -141,7 +145,9 @@ struct omap4_sys_ctrl_regs {
        unsigned int control_ldosram_iva_voltage_ctrl;  /* 0x4A002320 */
        unsigned int control_ldosram_mpu_voltage_ctrl;  /* 0x4A002324 */
        unsigned int control_ldosram_core_voltage_ctrl; /* 0x4A002328 */
        unsigned int control_ldosram_iva_voltage_ctrl;  /* 0x4A002320 */
        unsigned int control_ldosram_mpu_voltage_ctrl;  /* 0x4A002324 */
        unsigned int control_ldosram_core_voltage_ctrl; /* 0x4A002328 */
-       unsigned int pad3[260341];
+       unsigned int pad3[260277];
+       unsigned int control_pbiaslite;                 /* 0x4A100600 */
+       unsigned int pad4[63];
        unsigned int control_efuse_1;                   /* 0x4A100700 */
        unsigned int control_efuse_2;                   /* 0x4A100704 */
 };
        unsigned int control_efuse_1;                   /* 0x4A100700 */
        unsigned int control_efuse_2;                   /* 0x4A100704 */
 };
index 6627905..5d4cf51 100644 (file)
@@ -28,6 +28,7 @@
 #include <part.h>
 #include <i2c.h>
 #include <twl4030.h>
 #include <part.h>
 #include <i2c.h>
 #include <twl4030.h>
+#include <twl6030.h>
 #include <asm/io.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
 static int mmc_read_data(hsmmc_t *mmc_base, char *buf, unsigned int size);
 static int mmc_write_data(hsmmc_t *mmc_base, const char *buf, unsigned int siz);
 static struct mmc hsmmc_dev[2];
 static int mmc_read_data(hsmmc_t *mmc_base, char *buf, unsigned int size);
 static int mmc_write_data(hsmmc_t *mmc_base, const char *buf, unsigned int siz);
 static struct mmc hsmmc_dev[2];
-unsigned char mmc_board_init(hsmmc_t *mmc_base)
+
+#if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
+static void omap4_vmmc_pbias_config(struct mmc *mmc)
+{
+       u32 value = 0;
+       struct omap4_sys_ctrl_regs *const ctrl =
+               (struct omap4_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE;
+
+
+       value = readl(&ctrl->control_pbiaslite);
+       value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
+       writel(value, &ctrl->control_pbiaslite);
+       /* set VMMC to 3V */
+       twl6030_power_mmc_init();
+       value = readl(&ctrl->control_pbiaslite);
+       value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
+       writel(value, &ctrl->control_pbiaslite);
+}
+#endif
+
+unsigned char mmc_board_init(struct mmc *mmc)
 {
 #if defined(CONFIG_TWL4030_POWER)
        twl4030_power_mmc_init();
 {
 #if defined(CONFIG_TWL4030_POWER)
        twl4030_power_mmc_init();
@@ -67,7 +88,11 @@ unsigned char mmc_board_init(hsmmc_t *mmc_base)
                &prcm_base->iclken1_core);
 #endif
 
                &prcm_base->iclken1_core);
 #endif
 
-/* TODO add appropriate OMAP4 init - none currently necessary */
+#if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
+       /* PBIAS config needed for MMC1 only */
+       if (mmc->block_dev.dev == 0)
+               omap4_vmmc_pbias_config(mmc);
+#endif
 
        return 0;
 }
 
        return 0;
 }
@@ -108,7 +133,7 @@ static int mmc_init_setup(struct mmc *mmc)
        unsigned int dsor;
        ulong start;
 
        unsigned int dsor;
        ulong start;
 
-       mmc_board_init(mmc_base);
+       mmc_board_init(mmc);
 
        writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
                &mmc_base->sysconfig);
 
        writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
                &mmc_base->sysconfig);
index fef57b4..c5a0038 100644 (file)
@@ -182,6 +182,13 @@ void twl6030_init_battery_charging(void)
        return;
 }
 
        return;
 }
 
+void twl6030_power_mmc_init()
+{
+       /* set voltage to 3.0 and turnon for APP */
+       twl6030_i2c_write_u8(TWL6030_CHIP_PM, 0x15, VMMC_CFG_VOLTATE);
+       twl6030_i2c_write_u8(TWL6030_CHIP_PM, 0x21, VMMC_CFG_STATE);
+}
+
 void twl6030_usb_device_settings()
 {
        u8 data = 0;
 void twl6030_usb_device_settings()
 {
        u8 data = 0;
index d8ac8c0..228eac5 100644 (file)
@@ -98,7 +98,9 @@
 #define CONFIG_I2C_MULTI_BUS           1
 
 /* TWL6030 */
 #define CONFIG_I2C_MULTI_BUS           1
 
 /* TWL6030 */
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_TWL6030_POWER           1
 #define CONFIG_TWL6030_POWER           1
+#endif
 
 /* MMC */
 #define CONFIG_GENERIC_MMC             1
 
 /* MMC */
 #define CONFIG_GENERIC_MMC             1
index 39d7154..9e03291 100644 (file)
@@ -37,7 +37,9 @@
 #include <configs/omap4_common.h>
 
 /* Battery Charger */
 #include <configs/omap4_common.h>
 
 /* Battery Charger */
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_CMD_BAT                 1
 #define CONFIG_CMD_BAT                 1
+#endif
 
 /* ENV related config options */
 #define CONFIG_ENV_IS_IN_MMC           1
 
 /* ENV related config options */
 #define CONFIG_ENV_IS_IN_MMC           1
index 6ed68a0..a9fcadb 100644 (file)
@@ -33,6 +33,8 @@
 #define TWL6030_CHIP_PWM       0x49
 
 /* Slave Address 0x48 */
 #define TWL6030_CHIP_PWM       0x49
 
 /* Slave Address 0x48 */
+#define VMMC_CFG_STATE         0x9A
+#define VMMC_CFG_VOLTATE       0x9B
 #define VUSB_CFG_STATE         0xA2
 
 #define MISC1                  0xE4
 #define VUSB_CFG_STATE         0xA2
 
 #define MISC1                  0xE4
@@ -130,3 +132,4 @@ void twl6030_start_usb_charging(void);
 void twl6030_stop_usb_charging(void);
 int twl6030_get_battery_voltage(void);
 int twl6030_get_battery_current(void);
 void twl6030_stop_usb_charging(void);
 int twl6030_get_battery_voltage(void);
 int twl6030_get_battery_current(void);
+void twl6030_power_mmc_init(void);