summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-03-08 18:21:44 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-03-08 18:51:54 +0100
commit9fe368792369fc5b81e752328ae80062bce56201 (patch)
treed20d03069a9e54cb6778321c07b0210c4fae2fc1 /firmware/target/arm
parent4b2f59b3db7d378a42dfebd39e4e3b4ccc8280f8 (diff)
imx233: fix regulator code on stmp3700
For some reason the power subsystem needs to know the relationship between the VDD{D,A,IO} and uses a weird register to do so. Change-Id: I7fcc75f6cc0460b4997914986deda7ca544a4940
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/imx233/power-imx233.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index 0a4482fa08..c374644c0b 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -355,6 +355,19 @@ void imx233_power_get_regulator(enum imx233_regulator_t reg, unsigned *value_mv,
*brownout_mv = 0;
}
+#if IMX233_SUBTARGET >= 3700 && IMX233_SUBTARGET < 3780
+static void update_dcfuncv(void)
+{
+ int vddd, vdda, vddio;
+ imx233_power_get_regulator(REGULATOR_VDDD, &vddd, NULL);
+ imx233_power_get_regulator(REGULATOR_VDDA, &vdda, NULL);
+ imx233_power_get_regulator(REGULATOR_VDDIO, &vddio, NULL);
+ // assume Li-Ion, to divide by 6.25, do *100 and /625
+ HW_POWER_DCFUNCV = BF_OR2(POWER_DCFUNCV, VDDIO(((vddio - vdda) * 100) / 625),
+ VDDD(((vdda - vddd) * 100) / 625));
+}
+#endif
+
void imx233_power_set_regulator(enum imx233_regulator_t reg, unsigned value_mv,
unsigned brownout_mv)
{
@@ -393,6 +406,10 @@ void imx233_power_set_regulator(enum imx233_regulator_t reg, unsigned value_mv,
if(!BF_RD(POWER_STS, DC1_OK) || !BF_RD(POWER_STS, DC2_OK))
panicf("regulator %d: failed to stabilize", reg);
#endif
+ /* On STMP37xx, we need to update the weird HW_POWER_DCFUNCV register */
+#if IMX233_SUBTARGET >= 3700 && IMX233_SUBTARGET < 3780
+ update_dcfuncv();
+#endif
}
// offset is -1,0 or 1