diff options
Diffstat (limited to 'firmware/target/arm/imx233/powermgmt-imx233.c')
-rw-r--r-- | firmware/target/arm/imx233/powermgmt-imx233.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c index 8980124b33..9819406974 100644 --- a/firmware/target/arm/imx233/powermgmt-imx233.c +++ b/firmware/target/arm/imx233/powermgmt-imx233.c | |||
@@ -44,19 +44,46 @@ int _battery_voltage(void) | |||
44 | return BF_RD(POWER_BATTMONITOR, BATT_VAL) * 8; | 44 | return BF_RD(POWER_BATTMONITOR, BATT_VAL) * 8; |
45 | } | 45 | } |
46 | 46 | ||
47 | void powermgmt_init_target(void) | 47 | void imx233_powermgmt_init(void) |
48 | { | 48 | { |
49 | imx233_power_set_charge_current(IMX233_CHARGE_CURRENT); | 49 | imx233_power_set_charge_current(IMX233_CHARGE_CURRENT); |
50 | imx233_power_set_stop_current(IMX233_STOP_CURRENT); | 50 | imx233_power_set_stop_current(IMX233_STOP_CURRENT); |
51 | #if IMX233_SUBTARGET >= 3780 | ||
52 | /* assume that adc_init was called and battery monitoring via LRADC setup */ | 51 | /* assume that adc_init was called and battery monitoring via LRADC setup */ |
53 | BF_WR(POWER_BATTMONITOR, EN_BATADJ, 1); | 52 | BF_WR(POWER_BATTMONITOR, EN_BATADJ, 1); |
53 | #if IMX233_SUBTARGET >= 3700 | ||
54 | /* setup linear regulator offsets to 25 mV below to prevent contention between | ||
55 | * linear regulators and DCDC */ | ||
56 | BF_WR(POWER_VDDDCTRL, LINREG_OFFSET, 2); | ||
57 | BF_WR(POWER_VDDACTRL, LINREG_OFFSET, 2); | ||
58 | BF_WR(POWER_VDDIOCTRL, LINREG_OFFSET, 2); | ||
59 | /* enable DCDC (more efficient) */ | ||
60 | BF_SET(POWER_5VCTRL, ENABLE_DCDC); | ||
61 | BF_CLR(POWER_5VCTRL, DCDC_XFER); | ||
62 | #else | ||
63 | BF_SET(POWER_5VCTRL, LINREG_OFFSET); | ||
64 | BF_SET(POWER_5VCTRL, EN_DCDC1); | ||
65 | BF_SET(POWER_5VCTRL, EN_DCDC2); | ||
66 | #endif | ||
67 | |||
68 | #if IMX233_SUBTARGET >= 3780 | ||
69 | /* enable a few bits controlling the DC-DC as recommended by Freescale */ | ||
70 | BF_SET(POWER_LOOPCTRL, TOGGLE_DIF); | ||
71 | BF_SET(POWER_LOOPCTRL, EN_CM_HYST); | ||
72 | BF_CLR(POWER_LOOPCTRL, EN_RCSCALE); | ||
73 | BF_SETV(POWER_LOOPCTRL, EN_RCSCALE, 1); | ||
74 | /* adjust arbitration between 4.2 and battery */ | ||
75 | BF_WR(POWER_DCDC4P2, CMPTRIP, 0); /* 85% */ | ||
76 | BF_WR(POWER_DCDC4P2, DROPOUT_CTRL, 0xe); /* select greater, 200 mV drop */ | ||
54 | /* make sure we are in a known state: disable charger and 4p2 */ | 77 | /* make sure we are in a known state: disable charger and 4p2 */ |
55 | BF_SET(POWER_CHARGE, PWD_BATTCHRG); | 78 | BF_SET(POWER_CHARGE, PWD_BATTCHRG); |
56 | BF_WR(POWER_DCDC4P2, ENABLE_DCDC, 0); | 79 | BF_WR(POWER_DCDC4P2, ENABLE_DCDC, 0); |
57 | BF_WR(POWER_DCDC4P2, ENABLE_4P2, 0); | 80 | BF_WR(POWER_DCDC4P2, ENABLE_4P2, 0); |
58 | BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2); | 81 | BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2); |
59 | #endif | 82 | #endif |
83 | } | ||
84 | |||
85 | void powermgmt_init_target(void) | ||
86 | { | ||
60 | charge_state = DISCHARGING; | 87 | charge_state = DISCHARGING; |
61 | } | 88 | } |
62 | 89 | ||
@@ -106,9 +133,6 @@ void charging_algorithm_step(void) | |||
106 | { | 133 | { |
107 | logf("pwrmgmt: enable dcdc and charger"); | 134 | logf("pwrmgmt: enable dcdc and charger"); |
108 | logf("pwrmgmt: trickle -> charging"); | 135 | logf("pwrmgmt: trickle -> charging"); |
109 | /* adjust arbitration between 4.2 and battery */ | ||
110 | BF_WR(POWER_DCDC4P2, CMPTRIP, 0); /* 85% */ | ||
111 | BF_WR(POWER_DCDC4P2, DROPOUT_CTRL, 0xe); /* select greater, 200 mV drop */ | ||
112 | BF_CLR(POWER_5VCTRL, DCDC_XFER); | 136 | BF_CLR(POWER_5VCTRL, DCDC_XFER); |
113 | BF_SET(POWER_5VCTRL, ENABLE_DCDC); | 137 | BF_SET(POWER_5VCTRL, ENABLE_DCDC); |
114 | /* enable battery charging */ | 138 | /* enable battery charging */ |