diff options
Diffstat (limited to 'rbutil/mkimxboot/dualboot/dualboot.c')
-rw-r--r-- | rbutil/mkimxboot/dualboot/dualboot.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/rbutil/mkimxboot/dualboot/dualboot.c b/rbutil/mkimxboot/dualboot/dualboot.c index e841b12d74..0e3cca2bd9 100644 --- a/rbutil/mkimxboot/dualboot/dualboot.c +++ b/rbutil/mkimxboot/dualboot/dualboot.c | |||
@@ -22,10 +22,13 @@ | |||
22 | #include "regs-power.h" | 22 | #include "regs-power.h" |
23 | #include "regs-lradc.h" | 23 | #include "regs-lradc.h" |
24 | #include "regs-digctl.h" | 24 | #include "regs-digctl.h" |
25 | #include "regs-clkctrl.h" | ||
25 | 26 | ||
26 | #define BOOT_ROM_CONTINUE 0 /* continue boot */ | 27 | #define BOOT_ROM_CONTINUE 0 /* continue boot */ |
27 | #define BOOT_ROM_SECTION 1 /* switch to new section *result_id */ | 28 | #define BOOT_ROM_SECTION 1 /* switch to new section *result_id */ |
28 | 29 | ||
30 | #define BOOT_ARG_CHARGE ('c' | 'h' << 8 | 'r' << 16 | 'g' << 24) | ||
31 | |||
29 | typedef unsigned long uint32_t; | 32 | typedef unsigned long uint32_t; |
30 | 33 | ||
31 | // target specific boot context | 34 | // target specific boot context |
@@ -225,8 +228,43 @@ static inline enum context_t get_context(void) | |||
225 | #endif | 228 | #endif |
226 | } | 229 | } |
227 | 230 | ||
231 | /** | ||
232 | * Charging function | ||
233 | */ | ||
234 | static inline void do_charge(void) | ||
235 | { | ||
236 | BF_CLR(LRADC_CTRL0, SFTRST); | ||
237 | BF_CLR(LRADC_CTRL0, CLKGATE); | ||
238 | BF_WRn(LRADC_DELAYn, 0, TRIGGER_LRADCS, 0x80); | ||
239 | BF_WRn(LRADC_DELAYn, 0, TRIGGER_DELAYS, 0x1); | ||
240 | BF_WRn(LRADC_DELAYn, 0, DELAY, 200); | ||
241 | BF_SETn(LRADC_DELAYn, 0, KICK); | ||
242 | BF_SET(LRADC_CONVERSION, AUTOMATIC); | ||
243 | BF_WR_V(LRADC_CONVERSION, SCALE_FACTOR, LI_ION); | ||
244 | BF_WR(POWER_CHARGE, STOP_ILIMIT, 1); | ||
245 | BF_WR(POWER_CHARGE, BATTCHRG_I, 0x10); | ||
246 | BF_CLR(POWER_CHARGE, PWD_BATTCHRG); | ||
247 | #if IMX233_SUBTARGET >= 3780 | ||
248 | BF_WR(POWER_DCDC4P2, ENABLE_4P2, 1); | ||
249 | BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2); | ||
250 | BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT, 0x10); | ||
251 | #endif | ||
252 | while(1) | ||
253 | { | ||
254 | BF_WR(CLKCTRL_CPU, INTERRUPT_WAIT, 1); | ||
255 | asm volatile ( | ||
256 | "mcr p15, 0, %0, c7, c0, 4 \n" /* Wait for interrupt */ | ||
257 | "nop\n" /* Datasheet unclear: "The lr sent to handler points here after RTI"*/ | ||
258 | "nop\n" | ||
259 | : : "r"(0) | ||
260 | ); | ||
261 | } | ||
262 | } | ||
263 | |||
228 | int main(uint32_t arg, uint32_t *result_id) | 264 | int main(uint32_t arg, uint32_t *result_id) |
229 | { | 265 | { |
266 | if(arg == BOOT_ARG_CHARGE) | ||
267 | do_charge(); | ||
230 | switch(boot_decision(get_context())) | 268 | switch(boot_decision(get_context())) |
231 | { | 269 | { |
232 | case BOOT_ROCK: | 270 | case BOOT_ROCK: |