Skip to contentSkip to conversation

mmc: omap: config VMMC, MMC1_PBIAS

PATCH New Balaji T K 3 participants 3 messages Aug 25, 2011

Subsystems (2)
lore
Share & tools
lore

Balaji T K

author
#0 lore raw

PATCH 1/1 mmc: omap: config VMMC, MMC1_PBIAS

Config VMMC voltage to 3V for MMC/SD card slot and PBIAS settings needed for OMAP4 Fixes MMC/SD detection on boot from eMMC.

---
 arch/arm/include/asm/arch-omap4/omap4.h |    1 +
 drivers/mmc/omap_hsmmc.c                |   28 +++++++++++++++++++++++++---
 drivers/power/twl6030.c                 |    7 +++++++
 include/configs/omap4_sdp4430.h         |    2 ++
 include/twl6030.h                       |    3 +++
 5 files changed, 38 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-omap4/omap4.h +1 -0
index 9aad0e6..13fc8c9 100644
@@ -55,6 +55,7 @@
 #define LPDDR2_IO_REGS_BASE	0x4A100638
 
 #define CONTROL_EFUSE_2		0x4A100704
+#define CONTROL_PBIASLITE	0x4A100600
 
 /* CONTROL_ID_CODE */
 #define CONTROL_ID_CODE		0x4A002204
drivers/mmc/omap_hsmmc.c +25 -3
index 6627905..95bb661 100644
@@ -28,6 +28,7 @@
 #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>
@@ -38,7 +39,24 @@
 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;
+
+	value = readl(CONTROL_PBIASLITE);
+	value &= ~((1 << 22) | (1 << 26));
+	writel(value, CONTROL_PBIASLITE);
+	/* set VMMC to 3V */
+	twl6030_power_mmc_init();
+	value = readl(CONTROL_PBIASLITE);
+	value |= (1 << 21) | (1 << 22) | (1 << 26);
+	writel(value, CONTROL_PBIASLITE);
+}
+#endif
+
+unsigned char mmc_board_init(struct mmc *mmc)
 {
 #if defined(CONFIG_TWL4030_POWER)
 	twl4030_power_mmc_init();
@@ -67,7 +85,11 @@ unsigned char mmc_board_init(hsmmc_t *mmc_base)
 		&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;
 }
@@ -108,7 +130,7 @@ static int mmc_init_setup(struct mmc *mmc)
 	unsigned int dsor;
 	ulong start;
 
-	mmc_board_init(mmc_base);
+	mmc_board_init(mmc);
 
 	writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
 		&mmc_base->sysconfig);
drivers/power/twl6030.c +7 -0
index fef57b4..c5a0038 100644
@@ -182,6 +182,13 @@ void twl6030_init_battery_charging(void)
 	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;
include/configs/omap4_sdp4430.h +2 -0
index 5b3110c..50797ab 100644
@@ -98,8 +98,10 @@
 #define CONFIG_I2C_MULTI_BUS		1
 
 /* TWL6030 */
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_TWL6030_POWER		1
 #define CONFIG_CMD_BAT			1
+#endif
 
 /* MMC */
 #define CONFIG_GENERIC_MMC		1
include/twl6030.h +3 -0
index 6ed68a0..a9fcadb 100644
@@ -33,6 +33,8 @@
 #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
@@ -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_power_mmc_init(void);
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 mmc: omap: config VMMC, MMC1_PBIAS

Quoted 20 lines · Balaji T K

Config VMMC voltage to 3V for MMC/SD card slot and PBIAS settings needed for OMAP4 Fixes MMC/SD detection on boot from eMMC.

---
 arch/arm/include/asm/arch-omap4/omap4.h |    1 +
 drivers/mmc/omap_hsmmc.c                |   28
+++++++++++++++++++++++++--- drivers/power/twl6030.c                 |   
7 +++++++
 include/configs/omap4_sdp4430.h         |    2 ++
 include/twl6030.h                       |    3 +++
 5 files changed, 38 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-omap4/omap4.h index 9aad0e6..13fc8c9 100644

arch/arm/include/asm/arch-omap4/omap4.h line 58

Quoted 4 lines
arch/arm/include/asm/arch-omap4/omap4.h +1 -0
@@ -55,6 +55,7 @@
 #define LPDDR2_IO_REGS_BASE	0x4A100638
 
 #define CONTROL_EFUSE_2		0x4A100704
+#define CONTROL_PBIASLITE	0x4A100600

Can't you use struct omap_something_regs { ... } like most of U-Boot code ?

Quoted 18 lines
arch/arm/include/asm/arch-omap4/omap4.h +0 -0
 /* CONTROL_ID_CODE */
 #define CONTROL_ID_CODE		0x4A002204
drivers/mmc/omap_hsmmc.c +1 -0
index 6627905..95bb661 100644
@@ -28,6 +28,7 @@
 #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>
@@ -38,7 +39,24 @@
 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

drivers/mmc/omap_hsmmc.c line 49

Quoted 10 lines
drivers/mmc/omap_hsmmc.c +8 -1
 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;
+
+	value = readl(CONTROL_PBIASLITE);
+	value &= ~((1 << 22) | (1 << 26));

What's this magic ?

drivers/mmc/omap_hsmmc.c line 54

Quoted 5 lines
drivers/mmc/omap_hsmmc.c +5 -0
+	writel(value, CONTROL_PBIASLITE);
+	/* set VMMC to 3V */
+	twl6030_power_mmc_init();
+	value = readl(CONTROL_PBIASLITE);
+	value |= (1 << 21) | (1 << 22) | (1 << 26);

And this magic ?

Quoted 9 lines
drivers/mmc/omap_hsmmc.c +5 -0
+	writel(value, CONTROL_PBIASLITE);
+}
+#endif
+
+unsigned char mmc_board_init(struct mmc *mmc)
 {
 #if defined(CONFIG_TWL4030_POWER)
 	twl4030_power_mmc_init();

drivers/mmc/omap_hsmmc.c unsigned char mmc_board_init(hsmmc_t *mmc_base) · line 89

Quoted 6 lines
drivers/mmc/omap_hsmmc.c +2 -1
@@ -67,7 +85,11 @@ unsigned char mmc_board_init(hsmmc_t *mmc_base)
 		&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 */

You have == 0 below ... so you're numbering from 1 here ? It's a bit confusing.

drivers/mmc/omap_hsmmc.c static int mmc_init_setup(struct mmc *mmc) · line 133

Quoted 12 lines
drivers/mmc/omap_hsmmc.c +4 -1
+	if (mmc->block_dev.dev == 0)
+		omap4_vmmc_pbias_config(mmc);
+#endif
 
 	return 0;
 }
@@ -108,7 +130,7 @@ static int mmc_init_setup(struct mmc *mmc)
 	unsigned int dsor;
 	ulong start;
 
-	mmc_board_init(mmc_base);
+	mmc_board_init(mmc);

Is this a bugfix ?

Quoted 50 lines
drivers/mmc/omap_hsmmc.c +0 -0
 	writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
 		&mmc_base->sysconfig);
drivers/power/twl6030.c +7 -0
index fef57b4..c5a0038 100644
@@ -182,6 +182,13 @@ void twl6030_init_battery_charging(void)
 	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;
(quoted diff) +0 -0

b/include/configs/omap4_sdp4430.h index 5b3110c..50797ab 100644

include/configs/omap4_sdp4430.h +2 -0
@@ -98,8 +98,10 @@
 #define CONFIG_I2C_MULTI_BUS		1
 
 /* TWL6030 */
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_TWL6030_POWER		1
 #define CONFIG_CMD_BAT			1
+#endif
 
 /* MMC */
 #define CONFIG_GENERIC_MMC		1
include/twl6030.h +2 -0
index 6ed68a0..a9fcadb 100644
@@ -33,6 +33,8 @@
 #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

include/twl6030.h void twl6030_start_usb_charging(void); · line 135

Quoted 4 lines
include/twl6030.h +1 -0
@@ -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_power_mmc_init(void);

Thanks! Cheers!

#2 lore raw

PATCH 1/1 mmc: omap: config VMMC, MMC1_PBIAS

Quoted 24 lines · Marek Vasut
Quoted 22 lines · Balaji T K

Config VMMC voltage to 3V for MMC/SD card slot and PBIAS settings needed for OMAP4 Fixes MMC/SD detection on boot from eMMC.

---
?arch/arm/include/asm/arch-omap4/omap4.h | ? ?1 + ?drivers/mmc/omap_hsmmc.c ? ? ? ? ? ? ? ?| ? 28 +++++++++++++++++++++++++--- drivers/power/twl6030.c ? ? ? ? ? ? ? ? | 7 +++++++
?include/configs/omap4_sdp4430.h ? ? ? ? | ? ?2 ++ ?include/twl6030.h ? ? ? ? ? ? ? ? ? ? ? | ? ?3 +++
?5 files changed, 38 insertions(+), 3 deletions(-)

(quoted diff) +0 -0

b/arch/arm/include/asm/arch-omap4/omap4.h index 9aad0e6..13fc8c9 100644

arch/arm/include/asm/arch-omap4/omap4.h +0 -0
@@ -55,6 +55,7 @@

?#define LPDDR2_IO_REGS_BASE ?0x4A100638

Quoted 4 lines
Quoted 2 lines

?#define CONTROL_EFUSE_2 ? ? ? ? ? ? ?0x4A100704 +#define CONTROL_PBIASLITE ? ?0x4A100600

Can't you use struct omap_something_regs { ... } like most of U-Boot code ?

Currently only these 3 registers are used in u-boot for this CONTROL module IP. Above 3 registers don't have such API with base address(0x4a100000) But I think there is a patch coming soon. Should this patch wait until then ?

Quoted 23 lines
Quoted 23 lines

?/* CONTROL_ID_CODE */
?#define CONTROL_ID_CODE ? ? ? ? ? ? ?0x4A002204

drivers/mmc/omap_hsmmc.c +0 -0
index 6627905..95bb661 100644
@@ -28,6 +28,7 @@

?#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>

drivers/mmc/omap_hsmmc.c +0 -0
@@ -38,7 +39,24 @@
 ?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];

drivers/mmc/omap_hsmmc.c +2 -1
-unsigned char mmc_board_init(hsmmc_t *mmc_base)
+
+#if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
Quoted 9 lines

drivers/mmc/omap_hsmmc.c

Quoted 6 lines
drivers/mmc/omap_hsmmc.c +6 -0
+static void omap4_vmmc_pbias_config(struct mmc *mmc)
+{
+ ? ? u32 value = 0;
+
+ ? ? value = readl(CONTROL_PBIASLITE);
+ ? ? value &= ~((1 << 22) | (1 << 26));

What's this magic ?

will use #define

Quoted 7 lines
Quoted 5 lines

+ ? ? writel(value, CONTROL_PBIASLITE);
+ ? ? /* set VMMC to 3V */
+ ? ? twl6030_power_mmc_init();
+ ? ? value = readl(CONTROL_PBIASLITE);
+ ? ? value |= (1 << 21) | (1 << 22) | (1 << 26);

And this magic ?

will use #define

Quoted 13 lines
Quoted 13 lines

+ ? ? writel(value, CONTROL_PBIASLITE);

drivers/mmc/omap_hsmmc.c +4 -0
+}
+#endif
+
+unsigned char mmc_board_init(struct mmc *mmc)

?{
?#if defined(CONFIG_TWL4030_POWER)
? ? ? twl4030_power_mmc_init();

drivers/mmc/omap_hsmmc.c +0 -0
@@ -67,7 +85,11 @@ unsigned char mmc_board_init(hsmmc_t *mmc_base)
 ? ? ? ? ? ? ? &prcm_base->iclken1_core);

?#endif

Quoted 5 lines

drivers/mmc/omap_hsmmc.c unsigned char mmc_board_init(hsmmc_t *mmc_base)

Quoted 3 lines
drivers/mmc/omap_hsmmc.c +2 -1
-/* TODO add appropriate OMAP4 init - none currently necessary */
+#if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
+ ? ? /* PBIAS config needed for MMC1 only */

You have == 0 below ... so you're numbering from 1 here ? It's a bit confusing.

uboot mmc starts numbering from 0, But OMAP data manual starts the IP numbering from 1

Quoted 11 lines
Quoted 11 lines

+ ? ? if (mmc->block_dev.dev == 0)
+ ? ? ? ? ? ? omap4_vmmc_pbias_config(mmc); +#endif

? ? ? return 0;
?}

drivers/mmc/omap_hsmmc.c +0 -0
@@ -108,7 +130,7 @@ static int mmc_init_setup(struct mmc *mmc)
 ? ? ? unsigned int dsor;
 ? ? ? ulong start;
 
Quoted 4 lines

drivers/mmc/omap_hsmmc.c static int mmc_init_setup(struct mmc *mmc) · line 133

Quoted 2 lines
drivers/mmc/omap_hsmmc.c +1 -1
- ? ? mmc_board_init(mmc_base);
+ ? ? mmc_board_init(mmc);

Is this a bugfix ?

I changed the prototype for checking mmc->block_dev.dev in mmc_board_init. Without this change, regulator to MMC is not set to correct voltage, MMC/SD fails to get detected. mmc_init fails and read/write also fails.

Quoted 57 lines
Quoted 51 lines
drivers/mmc/omap_hsmmc.c +0 -0
 ? ? ? writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
 ? ? ? ? ? ? ? &mmc_base->sysconfig);
drivers/power/twl6030.c +7 -0
index fef57b4..c5a0038 100644
@@ -182,6 +182,13 @@ void twl6030_init_battery_charging(void)
 ? ? ? 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;
(quoted diff) +0 -0

b/include/configs/omap4_sdp4430.h index 5b3110c..50797ab 100644

include/configs/omap4_sdp4430.h +0 -0
@@ -98,8 +98,10 @@

?#define CONFIG_I2C_MULTI_BUS ? ? ? ? 1

?/* TWL6030 */
+#ifndef CONFIG_SPL_BUILD
?#define CONFIG_TWL6030_POWER ? ? ? ? 1 ?#define CONFIG_CMD_BAT ? ? ? ? ? ? ? ? ? ? ? 1 +#endif

?/* MMC */
?#define CONFIG_GENERIC_MMC ? ? ? ? ? 1

include/twl6030.h +0 -0
index 6ed68a0..a9fcadb 100644
@@ -33,6 +33,8 @@

?#define TWL6030_CHIP_PWM ? ? 0x49

?/* Slave Address 0x48 */

include/twl6030.h +2 -0
+#define VMMC_CFG_STATE ? ? ? ? ? ? ? 0x9A
+#define VMMC_CFG_VOLTATE ? ? 0x9B

?#define VUSB_CFG_STATE ? ? ? ? ? ? ? 0xA2

?#define MISC1 ? ? ? ? ? ? ? ? ? ? ? ?0xE4

include/twl6030.h void twl6030_start_usb_charging(void); · line 135

Quoted 4 lines
include/twl6030.h +1 -0
@@ -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_power_mmc_init(void);

Thanks! Cheers!