summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c')
-rw-r--r--firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
index 17cdb4d645..7ad9479a96 100644
--- a/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
+++ b/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
@@ -62,7 +62,8 @@ void power_init(void)
62 /* FIXME: Copy paste from M3K. Probably not necessary */ 62 /* FIXME: Copy paste from M3K. Probably not necessary */
63 axp_modify(AXP_REG_DCDCMODE, 0, 0xc0); 63 axp_modify(AXP_REG_DCDCMODE, 0, 0xc0);
64 64
65 /* Power on required supplies */ 65 /* Power on required supplies
66 * TODO: This should be checked, though likely all but EXTEN are needed */
66 axp_set_enabled_supplies( 67 axp_set_enabled_supplies(
67 (1 << AXP_SUPPLY_EXTEN) | 68 (1 << AXP_SUPPLY_EXTEN) |
68 (1 << AXP_SUPPLY_DCDC1) | 69 (1 << AXP_SUPPLY_DCDC1) |
@@ -81,6 +82,10 @@ void power_init(void)
81 (1 << AXP_ADC_INTERNAL_TEMP) | 82 (1 << AXP_ADC_INTERNAL_TEMP) |
82 (1 << AXP_ADC_APS_VOLTAGE)); 83 (1 << AXP_ADC_APS_VOLTAGE));
83 84
85 /* Configure USB charging */
86 axp_set_vhold_level(4400);
87 usb_charging_maxcurrent_change(100);
88
84 /* Delay to give power outputs time to stabilize. 89 /* Delay to give power outputs time to stabilize.
85 * With the power thread delay, this can apparently go as low as 50, 90 * With the power thread delay, this can apparently go as low as 50,
86 * Keeping a higher value here just to ensure the bootloader works 91 * Keeping a higher value here just to ensure the bootloader works
@@ -91,7 +96,22 @@ void power_init(void)
91#ifdef HAVE_USB_CHARGING_ENABLE 96#ifdef HAVE_USB_CHARGING_ENABLE
92void usb_charging_maxcurrent_change(int maxcurrent) 97void usb_charging_maxcurrent_change(int maxcurrent)
93{ 98{
94 axp_set_charge_current(maxcurrent); 99 int vbus_limit;
100 int charge_current;
101
102 /* Note that the charge current setting is a maximum: it will be
103 * reduced dynamically by the AXP192 so the combined load is less
104 * than the set VBUS current limit. */
105 if(maxcurrent <= 100) {
106 vbus_limit = AXP_VBUS_LIMIT_100mA;
107 charge_current = 550;
108 } else {
109 vbus_limit = AXP_VBUS_LIMIT_500mA;
110 charge_current = 550;
111 }
112
113 axp_set_vbus_limit(vbus_limit);
114 axp_set_charge_current(charge_current);
95} 115}
96#endif 116#endif
97 117