summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2012-03-19 03:37:40 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-03-27 22:05:29 +0200
commit61712bcad48d2874fbd9e2dc90255f0885b716b0 (patch)
treed447331637e43055e5e0e5647edfacc62c1c17bd
parentf7dad8f12164d08577b42492ae8d350a002e9d99 (diff)
downloadtalos-obmc-uboot-61712bcad48d2874fbd9e2dc90255f0885b716b0.tar.gz
talos-obmc-uboot-61712bcad48d2874fbd9e2dc90255f0885b716b0.zip
twl4030: fix potential power supply handling issues
twl4030_pmrecv_vsel_cfg currently first sets up device group (effectively enabling the supply), and only then sets vsel (selects voltage). This could lead to wrong voltage for a short time, or even long time if second i2c write fails. Fix this by writing vsel first and device group after that. Also introduce error checking to not enable the supply if we failed to set the voltage, and start logging errors as power supply problems are usually important. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
-rw-r--r--drivers/power/twl4030.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/power/twl4030.c b/drivers/power/twl4030.c
index 4a4ddeb91f..36b2144947 100644
--- a/drivers/power/twl4030.c
+++ b/drivers/power/twl4030.c
@@ -65,13 +65,23 @@ void twl4030_power_reset_init(void)
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);
+ int ret;
/* Select the Voltage */
- twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
+ ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
vsel_reg);
+ if (ret != 0) {
+ printf("Could could not write vsel to reg %02x (%d)\n",
+ vsel_reg, ret);
+ return;
+ }
+
+ /* Select the Device Group (enable the supply if dev_grp_sel != 0) */
+ ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel,
+ dev_grp);
+ if (ret != 0)
+ printf("Could could not write grp_sel to reg %02x (%d)\n",
+ dev_grp, ret);
}
void twl4030_power_init(void)
OpenPOWER on IntegriCloud