summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/shanlingq1
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-01-09 16:03:30 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-01-09 19:58:34 +0000
commiteaee5e7339aec46b4b67f06b139b8708810a4c2e (patch)
tree28bac18b6a68caae4689c712b4b7d2ab80fed583 /firmware/target/mips/ingenic_x1000/shanlingq1
parent8f063d49c2e1dffb5548e40b69782963e18b1171 (diff)
downloadrockbox-eaee5e7339aec46b4b67f06b139b8708810a4c2e.tar.gz
rockbox-eaee5e7339aec46b4b67f06b139b8708810a4c2e.zip
Revert "AXP PMU rewrite (again)"
This caused LCD problems on the ErosQ, where the screen would go white until being put through a sleep/wake cycle. The exact reason for this isn't obvious, but the problem didn't exist prior to the AXP driver rewrite. The two dependent changes, 42999913ba - x1000: Increase USB current limit to 500 mA at all times 90dd2f84a9 - x1000: Correctly limit USB charging current ended up bringing the USB charging situation back to where it was prior to the rewrite, so the cleanest option is to revert the whole lot. This reverts commit 42999913ba3a76221fceb04b1f935ed4e0e71476. This reverts commit 90dd2f84a9174c38dbfb07d582ec6ee7697b1939. This reverts commit 2d891439623bb76d38b98202ca5f3eea3c01c5f0. Change-Id: I1cff2bfdd1b189df14bcf8cce42db725caa470d7
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/shanlingq1')
-rw-r--r--firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c8
-rw-r--r--firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c70
2 files changed, 24 insertions, 54 deletions
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c
index 1976dde793..13b0cdd078 100644
--- a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c
+++ b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c
@@ -23,7 +23,7 @@
23#include "button.h" 23#include "button.h"
24#include "touchscreen.h" 24#include "touchscreen.h"
25#include "ft6x06.h" 25#include "ft6x06.h"
26#include "axp192.h" 26#include "axp-pmu.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "backlight.h" 28#include "backlight.h"
29#include "powermgmt.h" 29#include "powermgmt.h"
@@ -57,7 +57,7 @@ static void hp_detect_init(void)
57{ 57{
58 /* TODO: replace this copy paste cruft with an API in axp-pmu */ 58 /* TODO: replace this copy paste cruft with an API in axp-pmu */
59 static struct timeout tmo; 59 static struct timeout tmo;
60 static const uint8_t gpio_reg = AXP_REG_GPIOLEVEL1; 60 static const uint8_t gpio_reg = AXP192_REG_GPIOSTATE1;
61 static i2c_descriptor desc = { 61 static i2c_descriptor desc = {
62 .slave_addr = AXP_PMU_ADDR, 62 .slave_addr = AXP_PMU_ADDR,
63 .bus_cond = I2C_START | I2C_STOP, 63 .bus_cond = I2C_START | I2C_STOP,
@@ -72,10 +72,10 @@ static void hp_detect_init(void)
72 }; 72 };
73 73
74 /* Headphone detect is wired to AXP192 GPIO: set it to input state */ 74 /* Headphone detect is wired to AXP192 GPIO: set it to input state */
75 axp_set_gpio_function(1, AXP_GPIO_INPUT); 75 i2c_reg_write1(AXP_PMU_BUS, AXP_PMU_ADDR, AXP192_REG_GPIO1FUNCTION, 0x01);
76 76
77 /* Get an initial reading before startup */ 77 /* Get an initial reading before startup */
78 int r = axp_read(gpio_reg); 78 int r = i2c_reg_read1(AXP_PMU_BUS, AXP_PMU_ADDR, gpio_reg);
79 if(r >= 0) 79 if(r >= 0)
80 hp_detect_reg = r; 80 hp_detect_reg = r;
81 81
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c
index 86ee84c37a..75f8031dd9 100644
--- a/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c
+++ b/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c
@@ -22,7 +22,7 @@
22#include "power.h" 22#include "power.h"
23#include "adc.h" 23#include "adc.h"
24#include "system.h" 24#include "system.h"
25#include "axp192.h" 25#include "axp-pmu.h"
26#ifdef HAVE_CW2015 26#ifdef HAVE_CW2015
27# include "cw2015.h" 27# include "cw2015.h"
28#endif 28#endif
@@ -73,34 +73,24 @@ const unsigned short percent_to_volt_charge[11] =
73void power_init(void) 73void power_init(void)
74{ 74{
75 i2c_x1000_set_freq(AXP_PMU_BUS, I2C_FREQ_400K); 75 i2c_x1000_set_freq(AXP_PMU_BUS, I2C_FREQ_400K);
76 axp_init();
76#ifdef HAVE_CW2015 77#ifdef HAVE_CW2015
77 cw2015_init(); 78 cw2015_init();
78#endif 79#endif
79 80
80 /* Set DCDC2 to 1.2 V to match OF settings. */ 81 /* Change supply voltage from the default of 1250 mV to 1200 mV,
81 axp_set_supply_voltage(AXP_SUPPLY_DCDC2, 1200); 82 * this matches the original firmware's settings. Didn't observe
82 83 * any obviously bad behavior at 1250 mV, but better to be safe. */
83 /* Power on required supplies */ 84 axp_supply_set_voltage(AXP_SUPPLY_DCDC2, 1200);
84 axp_set_enabled_supplies( 85
85 (1 << AXP_SUPPLY_DCDC1) | /* SD bus (3.3 V) */ 86 /* For now, just turn everything on... definitely the touchscreen
86 (1 << AXP_SUPPLY_DCDC2) | /* LCD (1.2 V) */ 87 * is powered by one of the outputs */
87 (1 << AXP_SUPPLY_DCDC3) | /* CPU (1.8 V) */ 88 i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
88 (1 << AXP_SUPPLY_LDO2) | /* Touchscreen (3.3 V) */ 89 AXP_REG_PWROUTPUTCTRL1, 0, 0x05, NULL);
89 (1 << AXP_SUPPLY_LDO3)); /* USB analog (2.5 V) */ 90 i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
90 91 AXP_REG_PWROUTPUTCTRL2, 0, 0x0f, NULL);
91 /* Enable required ADCs */ 92 i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
92 axp_set_enabled_adcs( 93 AXP_REG_DCDCWORKINGMODE, 0, 0xc0, NULL);
93 (1 << AXP_ADC_BATTERY_VOLTAGE) |
94 (1 << AXP_ADC_CHARGE_CURRENT) |
95 (1 << AXP_ADC_DISCHARGE_CURRENT) |
96 (1 << AXP_ADC_VBUS_VOLTAGE) |
97 (1 << AXP_ADC_VBUS_CURRENT) |
98 (1 << AXP_ADC_INTERNAL_TEMP) |
99 (1 << AXP_ADC_APS_VOLTAGE));
100
101 /* Configure USB charging */
102 axp_set_vhold_level(4400);
103 usb_charging_maxcurrent_change(100);
104 94
105 /* Delay to give power output time to stabilize */ 95 /* Delay to give power output time to stabilize */
106 mdelay(20); 96 mdelay(20);
@@ -109,22 +99,7 @@ void power_init(void)
109#ifdef HAVE_USB_CHARGING_ENABLE 99#ifdef HAVE_USB_CHARGING_ENABLE
110void usb_charging_maxcurrent_change(int maxcurrent) 100void usb_charging_maxcurrent_change(int maxcurrent)
111{ 101{
112 int vbus_limit; 102 axp_set_charge_current(maxcurrent);
113 int charge_current;
114
115 /* Note that the charge current setting is a maximum: it will be
116 * reduced dynamically by the AXP192 so the combined load is less
117 * than the set VBUS current limit. */
118 if(maxcurrent <= 100) {
119 vbus_limit = AXP_VBUS_LIMIT_500mA;
120 charge_current = 100;
121 } else {
122 vbus_limit = AXP_VBUS_LIMIT_500mA;
123 charge_current = 550;
124 }
125
126 axp_set_vbus_limit(vbus_limit);
127 axp_set_charge_current(charge_current);
128} 103}
129#endif 104#endif
130 105
@@ -136,28 +111,23 @@ void power_off(void)
136 111
137bool charging_state(void) 112bool charging_state(void)
138{ 113{
139 return axp_is_charging(); 114 return axp_battery_status() == AXP_BATT_CHARGING;
140}
141
142unsigned int power_input_status(void)
143{
144 return axp_power_input_status();
145} 115}
146 116
147int _battery_voltage(void) 117int _battery_voltage(void)
148{ 118{
149 /* CW2015 can also read battery voltage, but the AXP consistently 119 /* CW2015 can also read battery voltage, but the AXP consistently
150 * reads ~20-30 mV higher so I suspect it's the "real" voltage. */ 120 * reads ~20-30 mV higher so I suspect it's the "real" voltage. */
151 return axp_read_adc(AXP_ADC_BATTERY_VOLTAGE); 121 return axp_adc_read(ADC_BATTERY_VOLTAGE);
152} 122}
153 123
154#if CONFIG_BATTERY_MEASURE & CURRENT_MEASURE 124#if CONFIG_BATTERY_MEASURE & CURRENT_MEASURE
155int _battery_current(void) 125int _battery_current(void)
156{ 126{
157 if(charging_state()) 127 if(charging_state())
158 return axp_read_adc(AXP_ADC_CHARGE_CURRENT); 128 return axp_adc_read(ADC_CHARGE_CURRENT);
159 else 129 else
160 return axp_read_adc(AXP_ADC_DISCHARGE_CURRENT); 130 return axp_adc_read(ADC_DISCHARGE_CURRENT);
161} 131}
162#endif 132#endif
163 133