From 9fe368792369fc5b81e752328ae80062bce56201 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sat, 8 Mar 2014 18:21:44 +0100 Subject: [PATCH] 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 --- firmware/target/arm/imx233/power-imx233.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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) { @@ -392,6 +405,10 @@ void imx233_power_set_regulator(enum imx233_regulator_t reg, unsigned value_mv, yield(); 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 }