]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i.MX28: Reorder battery status functions in SPL
authorMarek Vasut <marek.vasut@gmail.com>
Tue, 1 May 2012 11:09:50 +0000 (11:09 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Tue, 15 May 2012 06:31:36 +0000 (08:31 +0200)
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c

index dfb62eb9aa3feb323718d2fead7b762447feb070..ac942b42a98eb5b59d294554a366d43fffc7643a 100644 (file)
@@ -104,6 +104,62 @@ void mx28_power_set_linreg(void)
                        POWER_VDDIOCTRL_LINREG_OFFSET_1STEPS_BELOW);
 }
 
+int mx28_get_batt_volt(void)
+{
+       struct mx28_power_regs *power_regs =
+               (struct mx28_power_regs *)MXS_POWER_BASE;
+       uint32_t volt = readl(&power_regs->hw_power_battmonitor);
+       volt &= POWER_BATTMONITOR_BATT_VAL_MASK;
+       volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET;
+       volt *= 8;
+       return volt;
+}
+
+int mx28_is_batt_ready(void)
+{
+       return (mx28_get_batt_volt() >= 3600);
+}
+
+int mx28_is_batt_good(void)
+{
+       struct mx28_power_regs *power_regs =
+               (struct mx28_power_regs *)MXS_POWER_BASE;
+       uint32_t volt = mx28_get_batt_volt();
+
+       if ((volt >= 2400) && (volt <= 4300))
+               return 1;
+
+       clrsetbits_le32(&power_regs->hw_power_5vctrl,
+               POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK,
+               0x3 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET);
+       writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK,
+               &power_regs->hw_power_5vctrl_clr);
+
+       clrsetbits_le32(&power_regs->hw_power_charge,
+               POWER_CHARGE_STOP_ILIMIT_MASK | POWER_CHARGE_BATTCHRG_I_MASK,
+               POWER_CHARGE_STOP_ILIMIT_10MA | 0x3);
+
+       writel(POWER_CHARGE_PWD_BATTCHRG, &power_regs->hw_power_charge_clr);
+       writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK,
+               &power_regs->hw_power_5vctrl_clr);
+
+       early_delay(500000);
+
+       volt = mx28_get_batt_volt();
+
+       if (volt >= 3500)
+               return 0;
+
+       if (volt >= 2400)
+               return 1;
+
+       writel(POWER_CHARGE_STOP_ILIMIT_MASK | POWER_CHARGE_BATTCHRG_I_MASK,
+               &power_regs->hw_power_charge_clr);
+       writel(POWER_CHARGE_PWD_BATTCHRG, &power_regs->hw_power_charge_set);
+
+       return 0;
+}
+
 void mx28_power_setup_5v_detect(void)
 {
        struct mx28_power_regs *power_regs =
@@ -486,22 +542,6 @@ void mx28_handle_5v_conflict(void)
        }
 }
 
-int mx28_get_batt_volt(void)
-{
-       struct mx28_power_regs *power_regs =
-               (struct mx28_power_regs *)MXS_POWER_BASE;
-       uint32_t volt = readl(&power_regs->hw_power_battmonitor);
-       volt &= POWER_BATTMONITOR_BATT_VAL_MASK;
-       volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET;
-       volt *= 8;
-       return volt;
-}
-
-int mx28_is_batt_ready(void)
-{
-       return (mx28_get_batt_volt() >= 3600);
-}
-
 void mx28_5v_boot(void)
 {
        struct mx28_power_regs *power_regs =
@@ -553,54 +593,6 @@ void mx28_switch_vddd_to_dcdc_source(void)
                POWER_VDDDCTRL_DISABLE_STEPPING);
 }
 
-int mx28_is_batt_good(void)
-{
-       struct mx28_power_regs *power_regs =
-               (struct mx28_power_regs *)MXS_POWER_BASE;
-       uint32_t volt;
-
-       volt = readl(&power_regs->hw_power_battmonitor);
-       volt &= POWER_BATTMONITOR_BATT_VAL_MASK;
-       volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET;
-       volt *= 8;
-
-       if ((volt >= 2400) && (volt <= 4300))
-               return 1;
-
-       clrsetbits_le32(&power_regs->hw_power_5vctrl,
-               POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK,
-               0x3 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET);
-       writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK,
-               &power_regs->hw_power_5vctrl_clr);
-
-       clrsetbits_le32(&power_regs->hw_power_charge,
-               POWER_CHARGE_STOP_ILIMIT_MASK | POWER_CHARGE_BATTCHRG_I_MASK,
-               POWER_CHARGE_STOP_ILIMIT_10MA | 0x3);
-
-       writel(POWER_CHARGE_PWD_BATTCHRG, &power_regs->hw_power_charge_clr);
-       writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK,
-               &power_regs->hw_power_5vctrl_clr);
-
-       early_delay(500000);
-
-       volt = readl(&power_regs->hw_power_battmonitor);
-       volt &= POWER_BATTMONITOR_BATT_VAL_MASK;
-       volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET;
-       volt *= 8;
-
-       if (volt >= 3500)
-               return 0;
-
-       if (volt >= 2400)
-               return 1;
-
-       writel(POWER_CHARGE_STOP_ILIMIT_MASK | POWER_CHARGE_BATTCHRG_I_MASK,
-               &power_regs->hw_power_charge_clr);
-       writel(POWER_CHARGE_PWD_BATTCHRG, &power_regs->hw_power_charge_set);
-
-       return 0;
-}
-
 void mx28_power_configure_power_source(void)
 {
        mx28_src_power_init();