summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-05-02 21:56:20 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-05-28 17:38:29 +0200
commitcdca7cee7112d6625bbb9884cc90886571769061 (patch)
tree2fb3cd474516972c65e0d9c0a6fcc29e34b955a1 /firmware/target/arm
parent2dcc9fc39ffadc3828bde52df4843d91f5f66216 (diff)
downloadrockbox-cdca7cee7112d6625bbb9884cc90886571769061.tar.gz
rockbox-cdca7cee7112d6625bbb9884cc90886571769061.zip
imx233: add new power debug screen
This screen allows to put the device in a special mode where: - charging is disabled - device only draws power from 5V (thus battery is untouched) This is useful to measure the device consumption by measuring directly the usb power consumption. Change-Id: I2716ced0a5bb33c3c9a2607f2d17a0ce02f5689c
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/imx233/debug-imx233.c88
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 @@
#include "lcd.h"
#include "font.h"
#include "adc.h"
+#include "usb.h"
#include "power-imx233.h"
#include "clkctrl-imx233.h"
#include "powermgmt-imx233.h"
@@ -45,6 +46,7 @@
#include "regs/usbphy.h"
#include "regs/timrot.h"
+#include "regs/power.h"
#define ACT_NONE 0
#define ACT_CANCEL 1
@@ -418,6 +420,91 @@ bool dbg_hw_info_powermgmt(void)
}
}
+bool dbg_hw_info_power2(void)
+{
+ lcd_setfont(FONT_SYSFIXED);
+ bool holding_select = false;
+ int select_hold_time = 0;
+
+ while(1)
+ {
+ int button = my_get_action(HZ / 10);
+ if(button == ACT_NEXT || button == ACT_PREV)
+ {
+ lcd_setfont(FONT_UI);
+ return true;
+ }
+ else if(button == ACT_CANCEL)
+ {
+ lcd_setfont(FONT_UI);
+ return false;
+ }
+
+ button = my_get_status();
+ if(button == ACT_OK && !holding_select)
+ {
+ holding_select = true;
+ select_hold_time = current_tick;
+ }
+ else if(button != ACT_OK && holding_select)
+ {
+ holding_select = false;
+ }
+
+ /* disable feature if unsafe: we need 4.2 and dcdc fully operational */
+ bool feat_safe = usb_detect() == USB_INSERTED && BF_RD(POWER_DCDC4P2, ENABLE_DCDC)
+ && BF_RD(POWER_DCDC4P2, ENABLE_4P2) && BF_RD(POWER_5VCTRL, ENABLE_DCDC)
+ && !BF_RD(POWER_5VCTRL, PWD_CHARGE_4P2);
+ bool batt_disabled = (BF_RD(POWER_DCDC4P2, DROPOUT_CTRL) == 0xc);
+ if(holding_select && TIME_AFTER(current_tick, select_hold_time + HZ))
+ {
+ if(batt_disabled)
+ {
+ BF_CLR(POWER_CHARGE, PWD_BATTCHRG); /* enable charger again */
+ BF_WR(POWER_DCDC4P2, DROPOUT_CTRL(0xe)); /* select greater, 200 mV drop */
+ }
+ else if(feat_safe)
+ {
+ BF_WR(POWER_DCDC4P2, DROPOUT_CTRL(0xc)); /* always select 4.2, 200 mV drop */
+ BF_SET(POWER_CHARGE, PWD_BATTCHRG); /* disable charger */
+ }
+ holding_select = false;
+ /* return to the beginning of the loop to gather more information
+ * about HW state before displaying it */
+ continue;
+ }
+
+ lcd_clear_display();
+ if(!batt_disabled)
+ {
+ lcd_putsf(0, 0, "Hold select for 1 sec");
+ lcd_putsf(0, 1, "to disable battery");
+ lcd_putsf(0, 1, "and battery charger.");
+ lcd_putsf(0, 2, "The device will run");
+ lcd_putsf(0, 3, "entirely from USB.");
+ lcd_putsf(0, 5, "WARNING");
+ lcd_putsf(0, 6, "This is a debug");
+ lcd_putsf(0, 7, "feature !");
+ if(!feat_safe)
+ {
+ lcd_putsf(0, 9, "NOTE: unavailable");
+ lcd_putsf(0, 10, "Plug USB to enable.");
+ }
+ }
+ else
+ {
+ lcd_putsf(0, 0, "Battery is DISABLED.");
+ lcd_putsf(0, 1, "Hold select for 1 sec");
+ lcd_putsf(0, 2, "to renable battery.");
+ lcd_putsf(0, 4, "WARNING");
+ lcd_putsf(0, 5, "Do not unplug USB !");
+ }
+
+ lcd_update();
+ yield();
+ }
+}
+
bool dbg_hw_info_rtc(void)
{
lcd_setfont(FONT_SYSFIXED);
@@ -1105,6 +1192,7 @@ static struct
{"dma", dbg_hw_info_dma},
{"lradc", dbg_hw_info_lradc},
{"power", dbg_hw_info_power},
+ {"power2", dbg_hw_info_power2},
{"powermgmt", dbg_hw_info_powermgmt},
{"rtc", dbg_hw_info_rtc},
{"dcp", dbg_hw_info_dcp},