Skip to contentSkip to conversation

ARM: OMAP5: Power: Add more functionality to Palmas driver

PATCH New Lubomir Popov 2 participants 2 messages Jun 6, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ARM: OMAP5: Power: Add more functionality to Palmas driver

Add some useful functions, and the corresponding definitions.

Add support for powering on the dra7xx_evm SD/MMC LDO (courtesy Lokesh Vutla <[email protected]>).

---
V4 checkpatch-clean (except for one long printf string). V3 does some cleanup and adds support for the dra7xx_evm
board (power on LDO1 used for the SD/MMC interface).
V2 aligns to changed PMIC name (and file names accordingly)
from twl6035 to Palmas and is based on current u-boot-ti master.

 drivers/power/palmas.c |  134 +++++++++++++++++++++++++++++++++++++++++++-----
 include/palmas.h       |   90 +++++++++++++++++++++++++++++---
 2 files changed, 205 insertions(+), 19 deletions(-)
drivers/power/palmas.c +122 -12
index 09c832d..07b9815 100644
@@ -25,28 +25,138 @@
 
 void palmas_init_settings(void)
 {
-	return;
+#ifdef CONFIG_PALMAS_SMPS7_FPWM
+	int err;
+	/*
+	 * Set SMPS7 (1.8 V I/O supply on platforms with TWL6035/37) to
+	 * forced PWM mode. This reduces noise (but affects efficiency).
+	 */
+	u8 val = SMPS_MODE_SLP_FPWM | SMPS_MODE_ACT_FPWM;
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, SMPS7_CTRL, val);
+	if (err)
+		printf("palmas: could not force PWM for SMPS7: err = %d\n",
+		       err);
+#endif
 }
 
 int palmas_mmc1_poweron_ldo(void)
 {
 	u8 val = 0;
 
-	/* set LDO9 TWL6035 to 3V */
-	val = 0x2b; /* (3 -.9)*28 +1 */
-
-	if (palmas_i2c_write_u8(0x48, LDO9_VOLTAGE, val)) {
-		printf("twl6035: could not set LDO9 voltage.\n");
+#if defined(CONFIG_DRA7XX)
+	/*
+	 * Currently valid for the dra7xx_evm board:
+	 * Set TPS659038 LDO1 to 3.0 V
+	 */
+	val = LDO_VOLT_3V0;
+	if (palmas_i2c_write_u8(TPS65903X_CHIP_P1, LDO1_VOLTAGE, val)) {
+		printf("tps65903x: could not set LDO1 voltage.\n");
+		return 1;
+	}
+	/* TURN ON LDO1 */
+	val = RSC_MODE_SLEEP | RSC_MODE_ACTIVE;
+	if (palmas_i2c_write_u8(TPS65903X_CHIP_P1, LDO1_CTRL, val)) {
+		printf("tps65903x: could not turn on LDO1.\n");
 		return 1;
 	}
+	return 0;
+#else
+	/*
+	 * We assume that this is a OMAP543X + TWL603X board:
+	 * Set TWL6035/37 LDO9 to 3.0 V
+	 */
+	val = LDO_VOLT_3V0;
+	return twl603x_mmc1_set_ldo9(val);
+#endif
+}
 
-	/* TURN ON LDO9 */
-	val = LDO_ON | LDO_MODE_SLEEP | LDO_MODE_ACTIVE;
+/*
+ * On some OMAP5 + TWL603X hardware the SD card socket and LDO9_IN are
+ * powered by an external 3.3 V regulator, while the output of LDO9
+ * supplies VDDS_SDCARD for the OMAP5 interface only. This implies that
+ * LDO9 could be set to 'bypass' mode when required (e.g. for 3.3 V cards).
+ */
+int twl603x_mmc1_set_ldo9(u8 vsel)
+{
+	u8 cval = 0, vval = 0;	/* Off by default */
+	int err;
 
-	if (palmas_i2c_write_u8(0x48, LDO9_CTRL, val)) {
-		printf("twl6035: could not turn on LDO9.\n");
-		return 1;
+	if (vsel) {
+		/* Turn on */
+		if (vsel > LDO_VOLT_3V3) {
+			/* Put LDO9 in bypass */
+			cval = LDO9_BYP_EN | RSC_MODE_SLEEP | RSC_MODE_ACTIVE;
+			vval = LDO_VOLT_3V3;
+		} else {
+			cval = RSC_MODE_SLEEP | RSC_MODE_ACTIVE;
+			vval = vsel & 0x3f;
+		}
+	}
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, LDO9_VOLTAGE, vval);
+	if (err) {
+		printf("twl603x: could not set LDO9 %s: err = %d\n",
+		       vsel > LDO_VOLT_3V3 ? "bypass" : "voltage", err);
+		return err;
 	}
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, LDO9_CTRL, cval);
+	if (err)
+		printf("twl603x: could not turn %s LDO9: err = %d\n",
+		       cval ? "on" : "off", err);
+	return err;
+}
 
-	return 0;
+#ifdef CONFIG_PALMAS_AUDPWR
+/*
+ * Turn audio codec power and 32 kHz clock on/off. Use for
+ * testing OMAP543X + TWL603X + TWL604X boards only.
+ */
+int twl603x_audio_power(u8 on)
+{
+	u8 cval = 0, vval = 0, c32k = 0;
+	int err;
+
+	if (on) {
+		vval = SMPS_VOLT_2V1;
+		cval = SMPS_MODE_SLP_AUTO | SMPS_MODE_ACT_AUTO;
+		c32k = RSC_MODE_SLEEP | RSC_MODE_ACTIVE;
+	}
+	/* Set SMPS9 to 2.1 V (for TWL604x), or to 0 (off) */
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, SMPS9_VOLTAGE, vval);
+	if (err) {
+		printf("twl603x: could not set SMPS9 voltage: err = %d\n",
+		       err);
+		return err;
+	}
+	/* Turn on or off SMPS9 */
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, SMPS9_CTRL, cval);
+	if (err) {
+		printf("twl603x: could not turn SMPS9 %s: err = %d\n",
+		       cval ? "on" : "off", err);
+		return err;
+	}
+	/* Output 32 kHz clock on or off */
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, CLK32KGAUDIO_CTRL, c32k);
+	if (err)
+		printf("twl603x: could not turn CLK32KGAUDIO %s: err = %d\n",
+		       c32k ? "on" : "off", err);
+	return err;
 }
+#endif
+
+/*
+ * Enable/disable back-up battery (or super cap) charging on TWL6035/37.
+ * Please use defined BB_xxx values.
+ */
+int twl603x_enable_bb_charge(u8 bb_fields)
+{
+	u8 val = bb_fields & 0x0f;
+	int err;
+
+	val |= (VRTC_EN_SLP | VRTC_EN_OFF | VRTC_PWEN);
+	err = palmas_i2c_write_u8(TWL603X_CHIP_P1, BB_VRTC_CTRL, val);
+	if (err)
+		printf("twl603x: could not set BB_VRTC_CTRL to 0x%02x: err = %d\n",
+		       val, err);
+	return err;
+}
+
include/palmas.h +83 -7

105 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v4 1/1 ARM: OMAP5: Power: Add more functionality to Palmas driver

Quoted 6 lines · Lubomir Popov

Add some useful functions, and the corresponding definitions.

Add support for powering on the dra7xx_evm SD/MMC LDO (courtesy Lokesh Vutla <[email protected]>).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130606/f1efaaf0/attachment.pgp>