All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 05/11] ARM: OMAP4+: Add support for getting pbias info from board
Date: Wed, 23 Nov 2016 13:25:28 +0530	[thread overview]
Message-ID: <20161123075534.1124-6-lokeshvutla@ti.com> (raw)
In-Reply-To: <20161123075534.1124-1-lokeshvutla@ti.com>

Palmas driver assumes it is always TPS659xx regulator on all DRA7xx based
boards to enable mmc regulator. This is not true always like in case of
DRA71x-evm. So get this information based on the board.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/include/asm/omap_mmc.h    |  2 +-
 arch/arm/mach-omap2/omap4/hwinit.c | 13 +++++++++++++
 arch/arm/mach-omap2/omap5/hwinit.c | 34 ++++++++++++++++++++++++++++++++++
 drivers/mmc/omap_hsmmc.c           | 33 ++-------------------------------
 drivers/power/palmas.c             | 21 ++++++++++++++++++++-
 include/palmas.h                   | 13 ++++++++++++-
 6 files changed, 82 insertions(+), 34 deletions(-)

diff --git a/arch/arm/include/asm/omap_mmc.h b/arch/arm/include/asm/omap_mmc.h
index b69d073..f2bf645 100644
--- a/arch/arm/include/asm/omap_mmc.h
+++ b/arch/arm/include/asm/omap_mmc.h
@@ -167,5 +167,5 @@ struct hsmmc {
 int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
 		int wp_gpio);
 
-
+void vmmc_pbias_config(uint voltage);
 #endif /* OMAP_MMC_H_ */
diff --git a/arch/arm/mach-omap2/omap4/hwinit.c b/arch/arm/mach-omap2/omap4/hwinit.c
index 7c6638c..67ab1cc 100644
--- a/arch/arm/mach-omap2/omap4/hwinit.c
+++ b/arch/arm/mach-omap2/omap4/hwinit.c
@@ -12,6 +12,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <palmas.h>
 #include <asm/armv7.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
@@ -175,3 +176,15 @@ void v7_outer_cache_disable(void)
 	omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 0);
 }
 #endif /* !CONFIG_SYS_L2CACHE_OFF */
+
+void vmmc_pbias_config(uint voltage)
+{
+	u32 value = 0;
+
+	value = readl((*ctrl)->control_pbiaslite);
+	value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
+	writel(value, (*ctrl)->control_pbiaslite);
+	value = readl((*ctrl)->control_pbiaslite);
+	value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
+	writel(value, (*ctrl)->control_pbiaslite);
+}
diff --git a/arch/arm/mach-omap2/omap5/hwinit.c b/arch/arm/mach-omap2/omap5/hwinit.c
index e3ac8bb..839d79d 100644
--- a/arch/arm/mach-omap2/omap5/hwinit.c
+++ b/arch/arm/mach-omap2/omap5/hwinit.c
@@ -13,6 +13,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <palmas.h>
 #include <asm/armv7.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/sys_proto.h>
@@ -451,3 +452,36 @@ void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb,
 #endif
 	omap_smc1(OMAP5_SERVICE_ACR_SET, acr);
 }
+
+#if defined(CONFIG_PALMAS_POWER)
+void vmmc_pbias_config(uint voltage)
+{
+	u32 value = 0;
+	struct vcores_data const *vcores = *omap_vcores;
+
+	value = readl((*ctrl)->control_pbias);
+	value &= ~SDCARD_PWRDNZ;
+	writel(value, (*ctrl)->control_pbias);
+	udelay(10); /* wait 10 us */
+	value &= ~SDCARD_BIAS_PWRDNZ;
+	writel(value, (*ctrl)->control_pbias);
+
+	if (vcores->core.pmic->i2c_slave_addr == 0x60) {
+		if (voltage == LDO_VOLT_3V0)
+			voltage = 0x19;
+		else if (voltage == LDO_VOLT_1V8)
+			voltage = 0xa;
+		lp873x_mmc1_poweron_ldo(voltage);
+	} else {
+		palmas_mmc1_poweron_ldo(voltage);
+	}
+
+	value = readl((*ctrl)->control_pbias);
+	value |= SDCARD_BIAS_PWRDNZ;
+	writel(value, (*ctrl)->control_pbias);
+	udelay(150); /* wait 150 us */
+	value |= SDCARD_PWRDNZ;
+	writel(value, (*ctrl)->control_pbias);
+	udelay(150); /* wait 150 us */
+}
+#endif
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index fceafe1..0d824a6 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -110,30 +110,6 @@ static void omap4_vmmc_pbias_config(struct mmc *mmc)
 }
 #endif
 
-#if defined(CONFIG_OMAP54XX) && defined(CONFIG_PALMAS_POWER)
-static void omap5_pbias_config(struct mmc *mmc)
-{
-	u32 value = 0;
-
-	value = readl((*ctrl)->control_pbias);
-	value &= ~SDCARD_PWRDNZ;
-	writel(value, (*ctrl)->control_pbias);
-	udelay(10); /* wait 10 us */
-	value &= ~SDCARD_BIAS_PWRDNZ;
-	writel(value, (*ctrl)->control_pbias);
-
-	palmas_mmc1_poweron_ldo();
-
-	value = readl((*ctrl)->control_pbias);
-	value |= SDCARD_BIAS_PWRDNZ;
-	writel(value, (*ctrl)->control_pbias);
-	udelay(150); /* wait 150 us */
-	value |= SDCARD_PWRDNZ;
-	writel(value, (*ctrl)->control_pbias);
-	udelay(150); /* wait 150 us */
-}
-#endif
-
 static unsigned char mmc_board_init(struct mmc *mmc)
 {
 #if defined(CONFIG_OMAP34XX)
@@ -173,14 +149,10 @@ static unsigned char mmc_board_init(struct mmc *mmc)
 		&prcm_base->iclken1_core);
 #endif
 
-#if defined(CONFIG_OMAP44XX)
+#if defined(CONFIG_OMAP54XX) || defined(CONFIG_OMAP44XX)
 	/* PBIAS config needed for MMC1 only */
 	if (mmc->block_dev.devnum == 0)
-		omap4_vmmc_pbias_config(mmc);
-#endif
-#if defined(CONFIG_OMAP54XX) && defined(CONFIG_PALMAS_POWER)
-	if (mmc->block_dev.devnum == 0)
-		omap5_pbias_config(mmc);
+		vmmc_pbias_config(LDO_VOLT_3V0);
 #endif
 
 	return 0;
@@ -214,7 +186,6 @@ void mmc_init_stream(struct hsmmc *mmc_base)
 	writel(readl(&mmc_base->con) & ~INIT_INITSTREAM, &mmc_base->con);
 }
 
-
 static int omap_hsmmc_init_setup(struct mmc *mmc)
 {
 	struct hsmmc *mmc_base;
diff --git a/drivers/power/palmas.c b/drivers/power/palmas.c
index 6430fe0..70cc6e9 100644
--- a/drivers/power/palmas.c
+++ b/drivers/power/palmas.c
@@ -23,7 +23,26 @@ void palmas_init_settings(void)
 #endif
 }
 
-int palmas_mmc1_poweron_ldo(void)
+#if defined(CONFIG_OMAP54XX)
+int lp873x_mmc1_poweron_ldo(uint voltage)
+{
+	if (palmas_i2c_write_u8(LP873X_LDO1_ADDR, LP873X_LDO1_VOLTAGE,
+				voltage)) {
+		printf("lp873x: could not set LDO1 voltage.\n");
+		return 1;
+	}
+	/* TURN ON LDO1 */
+	if (palmas_i2c_write_u8(LP873X_LDO1_ADDR, LP873X_LDO1_CTRL,
+				LP873X_LDO_CTRL_EN | LP873X_LDO_CTRL_RDIS_EN)) {
+		printf("lp873x: could not turn on LDO1.\n");
+		return 1;
+	}
+	return 0;
+
+}
+#endif
+
+int palmas_mmc1_poweron_ldo(uint voltage)
 {
 	u8 val = 0;
 
diff --git a/include/palmas.h b/include/palmas.h
index cca3f9a..d676617 100644
--- a/include/palmas.h
+++ b/include/palmas.h
@@ -24,6 +24,16 @@
 #define LDO1_CTRL		0x50
 #define LDO1_VOLTAGE		0x51
 
+/* LDO1 control/voltage for LP873x */
+#define LP873X_LDO1_ADDR	0x60
+#define LP873X_LDO1_CTRL	0x9
+#define LP873X_LDO1_VOLTAGE	0xa
+#define LP873X_LDO_VOLT_3V0	0x19
+#define LP873X_LDO_VOLT_1V8	0xa
+#define LP873X_LDO_CTRL_EN	(0x1 << 0)
+#define LP873X_LDO_CTRL_EN_PINCTRL	(0x1 << 1)
+#define LP873X_LDO_CTRL_RDIS_EN	(0x1 << 2)
+
 /* LDO2 control/voltage */
 #define LDO2_CTRL		0x52
 #define LDO2_VOLTAGE		0x53
@@ -119,7 +129,8 @@ static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 }
 
 void palmas_init_settings(void);
-int palmas_mmc1_poweron_ldo(void);
+int palmas_mmc1_poweron_ldo(uint voltage);
+int lp873x_mmc1_poweron_ldo(uint voltage);
 int twl603x_mmc1_set_ldo9(u8 vsel);
 int twl603x_audio_power(u8 on);
 int twl603x_enable_bb_charge(u8 bb_fields);
-- 
2.10.1

  parent reply	other threads:[~2016-11-23  7:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23  7:55 [U-Boot] [PATCH 00/11] ARM: ti: dra71: Add support for dra71-evm Lokesh Vutla
2016-11-23  7:55 ` [U-Boot] [PATCH 01/11] board: ti: dra71x-evm: Add epprom support Lokesh Vutla
2016-11-26 16:17   ` Tom Rini
2016-12-04 23:20   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 02/11] board: ti: dra71x-evm: Add mux settings Lokesh Vutla
2016-11-26 16:18   ` Tom Rini
2016-12-04 23:20   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 03/11] board: ti: dra72: Introduce optimization for rgmii timing for rev C Lokesh Vutla
2016-11-26 16:19   ` Tom Rini
2016-12-04 23:20   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 04/11] board: ti: dra71x-evm: Add PMIC support Lokesh Vutla
2016-11-26 16:19   ` Tom Rini
2016-12-04 23:21   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` Lokesh Vutla [this message]
2016-11-26 16:23   ` [U-Boot] [PATCH 05/11] ARM: OMAP4+: Add support for getting pbias info from board Tom Rini
2016-12-04 23:22   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 06/11] ARM: dts: dra7xx: sync DT with latest Linux Lokesh Vutla
2016-11-26 16:23   ` Tom Rini
2016-12-04 23:22   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 07/11] ARM: dts: dra71x-evm: Add DT support Lokesh Vutla
2016-11-26 16:27   ` Tom Rini
2016-12-04 23:23   ` [U-Boot] [U-Boot,07/11] " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 08/11] configs: ti_omap5_common: Select dtb name for dra71x Lokesh Vutla
2016-11-26 16:28   ` Tom Rini
2016-12-04 23:25   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 09/11] configs: dra7xx: hs: Enable DM_ETH Lokesh Vutla
2016-11-26 16:29   ` Tom Rini
2016-12-04 23:25   ` [U-Boot] [U-Boot,09/11] " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 10/11] configs: dra7xx: Enable pmic/regulator options Lokesh Vutla
2016-11-26 16:29   ` Tom Rini
2016-12-04 23:25   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-23  7:55 ` [U-Boot] [PATCH 11/11] configs: dra7xx: Enable lp873x options Lokesh Vutla
2016-11-26 16:30   ` Tom Rini
2016-12-04 23:26   ` [U-Boot] [U-Boot,11/11] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161123075534.1124-6-lokeshvutla@ti.com \
    --to=lokeshvutla@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.