diff options
-rw-r--r-- | firmware/target/arm/imx233/debug-imx233.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c index a97907b775..979f743601 100644 --- a/firmware/target/arm/imx233/debug-imx233.c +++ b/firmware/target/arm/imx233/debug-imx233.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "lcd.h" | 26 | #include "lcd.h" |
27 | #include "font.h" | 27 | #include "font.h" |
28 | #include "adc.h" | 28 | #include "adc.h" |
29 | #include "usb.h" | ||
29 | #include "power-imx233.h" | 30 | #include "power-imx233.h" |
30 | #include "clkctrl-imx233.h" | 31 | #include "clkctrl-imx233.h" |
31 | #include "powermgmt-imx233.h" | 32 | #include "powermgmt-imx233.h" |
@@ -45,6 +46,7 @@ | |||
45 | 46 | ||
46 | #include "regs/usbphy.h" | 47 | #include "regs/usbphy.h" |
47 | #include "regs/timrot.h" | 48 | #include "regs/timrot.h" |
49 | #include "regs/power.h" | ||
48 | 50 | ||
49 | #define ACT_NONE 0 | 51 | #define ACT_NONE 0 |
50 | #define ACT_CANCEL 1 | 52 | #define ACT_CANCEL 1 |
@@ -418,6 +420,91 @@ bool dbg_hw_info_powermgmt(void) | |||
418 | } | 420 | } |
419 | } | 421 | } |
420 | 422 | ||
423 | bool dbg_hw_info_power2(void) | ||
424 | { | ||
425 | lcd_setfont(FONT_SYSFIXED); | ||
426 | bool holding_select = false; | ||
427 | int select_hold_time = 0; | ||
428 | |||
429 | while(1) | ||
430 | { | ||
431 | int button = my_get_action(HZ / 10); | ||
432 | if(button == ACT_NEXT || button == ACT_PREV) | ||
433 | { | ||
434 | lcd_setfont(FONT_UI); | ||
435 | return true; | ||
436 | } | ||
437 | else if(button == ACT_CANCEL) | ||
438 | { | ||
439 | lcd_setfont(FONT_UI); | ||
440 | return false; | ||
441 | } | ||
442 | |||
443 | button = my_get_status(); | ||
444 | if(button == ACT_OK && !holding_select) | ||
445 | { | ||
446 | holding_select = true; | ||
447 | select_hold_time = current_tick; | ||
448 | } | ||
449 | else if(button != ACT_OK && holding_select) | ||
450 | { | ||
451 | holding_select = false; | ||
452 | } | ||
453 | |||
454 | /* disable feature if unsafe: we need 4.2 and dcdc fully operational */ | ||
455 | bool feat_safe = usb_detect() == USB_INSERTED && BF_RD(POWER_DCDC4P2, ENABLE_DCDC) | ||
456 | && BF_RD(POWER_DCDC4P2, ENABLE_4P2) && BF_RD(POWER_5VCTRL, ENABLE_DCDC) | ||
457 | && !BF_RD(POWER_5VCTRL, PWD_CHARGE_4P2); | ||
458 | bool batt_disabled = (BF_RD(POWER_DCDC4P2, DROPOUT_CTRL) == 0xc); | ||
459 | if(holding_select && TIME_AFTER(current_tick, select_hold_time + HZ)) | ||
460 | { | ||
461 | if(batt_disabled) | ||
462 | { | ||
463 | BF_CLR(POWER_CHARGE, PWD_BATTCHRG); /* enable charger again */ | ||
464 | BF_WR(POWER_DCDC4P2, DROPOUT_CTRL(0xe)); /* select greater, 200 mV drop */ | ||
465 | } | ||
466 | else if(feat_safe) | ||
467 | { | ||
468 | BF_WR(POWER_DCDC4P2, DROPOUT_CTRL(0xc)); /* always select 4.2, 200 mV drop */ | ||
469 | BF_SET(POWER_CHARGE, PWD_BATTCHRG); /* disable charger */ | ||
470 | } | ||
471 | holding_select = false; | ||
472 | /* return to the beginning of the loop to gather more information | ||
473 | * about HW state before displaying it */ | ||
474 | continue; | ||
475 | } | ||
476 | |||
477 | lcd_clear_display(); | ||
478 | if(!batt_disabled) | ||
479 | { | ||
480 | lcd_putsf(0, 0, "Hold select for 1 sec"); | ||
481 | lcd_putsf(0, 1, "to disable battery"); | ||
482 | lcd_putsf(0, 1, "and battery charger."); | ||
483 | lcd_putsf(0, 2, "The device will run"); | ||
484 | lcd_putsf(0, 3, "entirely from USB."); | ||
485 | lcd_putsf(0, 5, "WARNING"); | ||
486 | lcd_putsf(0, 6, "This is a debug"); | ||
487 | lcd_putsf(0, 7, "feature !"); | ||
488 | if(!feat_safe) | ||
489 | { | ||
490 | lcd_putsf(0, 9, "NOTE: unavailable"); | ||
491 | lcd_putsf(0, 10, "Plug USB to enable."); | ||
492 | } | ||
493 | } | ||
494 | else | ||
495 | { | ||
496 | lcd_putsf(0, 0, "Battery is DISABLED."); | ||
497 | lcd_putsf(0, 1, "Hold select for 1 sec"); | ||
498 | lcd_putsf(0, 2, "to renable battery."); | ||
499 | lcd_putsf(0, 4, "WARNING"); | ||
500 | lcd_putsf(0, 5, "Do not unplug USB !"); | ||
501 | } | ||
502 | |||
503 | lcd_update(); | ||
504 | yield(); | ||
505 | } | ||
506 | } | ||
507 | |||
421 | bool dbg_hw_info_rtc(void) | 508 | bool dbg_hw_info_rtc(void) |
422 | { | 509 | { |
423 | lcd_setfont(FONT_SYSFIXED); | 510 | lcd_setfont(FONT_SYSFIXED); |
@@ -1105,6 +1192,7 @@ static struct | |||
1105 | {"dma", dbg_hw_info_dma}, | 1192 | {"dma", dbg_hw_info_dma}, |
1106 | {"lradc", dbg_hw_info_lradc}, | 1193 | {"lradc", dbg_hw_info_lradc}, |
1107 | {"power", dbg_hw_info_power}, | 1194 | {"power", dbg_hw_info_power}, |
1195 | {"power2", dbg_hw_info_power2}, | ||
1108 | {"powermgmt", dbg_hw_info_powermgmt}, | 1196 | {"powermgmt", dbg_hw_info_powermgmt}, |
1109 | {"rtc", dbg_hw_info_rtc}, | 1197 | {"rtc", dbg_hw_info_rtc}, |
1110 | {"dcp", dbg_hw_info_dcp}, | 1198 | {"dcp", dbg_hw_info_dcp}, |