[U-Boot] [PATCH 03/27] power: twl6030: Device-index-specific MMC power initialization

Paul Kocialkowski contact at paulk.fr
Sat Feb 27 19:18:51 CET 2016


Not every device has multiple MMC slots available, so it makes sense to enable
only the required LDOs for the available slots. Generic code in omap_hsmmc will
enable both VMMC and VAUX1, in doubt.

Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
---
 drivers/mmc/omap_hsmmc.c |  4 ++--
 drivers/power/twl6030.c  | 50 +++++++++++++++++++++++++-----------------------
 include/twl6030.h        |  2 +-
 3 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 5038a9f..0ea3101 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -104,8 +104,8 @@ static void omap4_vmmc_pbias_config(struct mmc *mmc)
 	value = readl((*ctrl)->control_pbiaslite);
 	value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
 	writel(value, (*ctrl)->control_pbiaslite);
-	/* set VMMC to 3V */
-	twl6030_power_mmc_init();
+	twl6030_power_mmc_init(0);
+	twl6030_power_mmc_init(1);
 	value = readl((*ctrl)->control_pbiaslite);
 	value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
 	writel(value, (*ctrl)->control_pbiaslite);
diff --git a/drivers/power/twl6030.c b/drivers/power/twl6030.c
index 2fb3967..7ed9129 100644
--- a/drivers/power/twl6030.c
+++ b/drivers/power/twl6030.c
@@ -212,34 +212,36 @@ void twl6030_init_battery_charging(void)
 	return;
 }
 
-void twl6030_power_mmc_init()
+void twl6030_power_mmc_init(int dev_index)
 {
 	u8 value = 0;
 
-	/* 3.0V voltage output for VMMC */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VMMC_CFG_VOLTAGE,
-		TWL6030_CFG_VOLTAGE_30);
-
-	/* Enable P1 output for VMMC */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VMMC_CFG_STATE,
-		TWL6030_CFG_STATE_P1 | TWL6030_CFG_STATE_ON);
-
-	twl6030_i2c_read_u8(TWL6030_CHIP_PM, TWL6030_PH_STS_BOOT, &value);
-
-	/* BOOT2 indicates 1.8V/2.8V VAUX1 for eMMC */
-	if (value & TWL6030_PH_STS_BOOT2) {
-		/* 1.8V voltage output for VAUX1 */
-		twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VAUX1_CFG_VOLTAGE,
-			TWL6030_CFG_VOLTAGE_18);
-	} else {
-		/* 2.8V voltage output for VAUX1 */
-		twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VAUX1_CFG_VOLTAGE,
-			TWL6030_CFG_VOLTAGE_28);
+	if (dev_index == 0) {
+		/* 3.0V voltage output for VMMC */
+		twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VMMC_CFG_VOLTAGE,
+			TWL6030_CFG_VOLTAGE_30);
+
+		/* Enable P1 output for VMMC */
+		twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VMMC_CFG_STATE,
+			TWL6030_CFG_STATE_P1 | TWL6030_CFG_STATE_ON);
+
+		twl6030_i2c_read_u8(TWL6030_CHIP_PM, TWL6030_PH_STS_BOOT, &value);
+	} else if (dev_index == 1) {
+		/* BOOT2 indicates 1.8V/2.8V VAUX1 for eMMC */
+		if (value & TWL6030_PH_STS_BOOT2) {
+			/* 1.8V voltage output for VAUX1 */
+			twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VAUX1_CFG_VOLTAGE,
+				TWL6030_CFG_VOLTAGE_18);
+		} else {
+			/* 2.8V voltage output for VAUX1 */
+			twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VAUX1_CFG_VOLTAGE,
+				TWL6030_CFG_VOLTAGE_28);
+		}
+
+		/* Enable P1 output for VAUX */
+		twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VAUX1_CFG_STATE,
+			TWL6030_CFG_STATE_P1 | TWL6030_CFG_STATE_ON);
 	}
-
-	/* Enable P1 output for VAUX */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_VAUX1_CFG_STATE,
-		TWL6030_CFG_STATE_P1 | TWL6030_CFG_STATE_ON);
 }
 
 void twl6030_usb_device_settings()
diff --git a/include/twl6030.h b/include/twl6030.h
index a17a9b5..04295c9 100644
--- a/include/twl6030.h
+++ b/include/twl6030.h
@@ -185,6 +185,6 @@ 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);
+void twl6030_power_mmc_init(int dev_index);
 
 #endif /* TWL6030_H */
-- 
2.6.4



More information about the U-Boot mailing list