TI:OMAP: [PATCH] API to select twl4030 voltage and dev group

From cc1b24cb290d428f2e1aefec9c7878b46380f592 Mon Sep 17 00:00:00 2001

From cc1b24cb290d428f2e1aefec9c7878b46380f592 Mon Sep 17 00:00:00 2001
From: Syed Mohammed Khasim <khasim@ti.com>
Date: Sat, 9 Jan 2010 09:28:03 +0530
Subject: [PATCH] API to select twl4030 voltage and dev group

Adds a new API "twl4030_pmrecv_vsel_cfg" to select voltage
and its device group

Signed-off-by: Syed Mohammed Khasim <khasim@ti.com>
---

<snip>

@@ -113,3 +104,18 @@ void twl4030_power_mmc_init(void)
twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
TWL4030_PM_RECEIVER_VMMC1_DEDICATED);
}
+
+/*
+ * Generic function to select Device Group and Voltage
+ */
+void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
+ u8 dev_grp, u8 dev_grp_sel)
+{
+ /* Select the Device Group */
+ twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel,
+ dev_grp);
+
+ /* Select the Voltage */
+ twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
+ vsel_reg);
+}

I was always wondering why TI code first sets the device group (which
effectively enables the supply), and configures voltage after that.
Doesn't that cause wrong voltage output for a short interval of time
(knowing that i2c transfers take some time to complete)? What happens
if second write fails due to some i2c error?

Good / Wonderful Catch, I will correct them in my patch.

Regards,
Khasim