FS#13535: AXP2101: ADC / reporting improvements

Improve ADC behavior, add correct conversion
for die temperature, add readout of EGauge to debug screen.

Add delay to give ADC time to get a good reading. Initial reading
may still be 1-3% optimistic, which is probably ok.

EGauge appears to be pretty good, but no great need to convert
to using it either.

Change-Id: Iab9d50e2427f656ad0875f9a623b03545fc69881
This commit is contained in:
Dana Conrad 2024-12-30 03:16:20 +00:00 committed by Solomon Peachy
parent d038aa47fe
commit f2dd489120
2 changed files with 36 additions and 20 deletions

View file

@ -97,10 +97,6 @@ void power_init(void)
}
// These match the OF as far as I can discern
// TODO: These values are set in EFUSE apparently, could
// do a "check then set if necessary"...
// Also if we had a fresh device we could verify what
// the OF sets.
axp2101_supply_set_voltage(AXP2101_SUPPLY_DCDC1, 3300);
axp2101_supply_set_voltage(AXP2101_SUPPLY_DCDC2, 1200);
axp2101_supply_set_voltage(AXP2101_SUPPLY_DCDC3, 2800);
@ -123,6 +119,12 @@ void power_init(void)
/* Set the default charging current. This is the same as the
* OF's setting, although it's not strictly within the USB spec. */
axp2101_set_charge_current(780);
/* delay to allow ADC to get a good sample -
* may give bogus (high) readings otherwise. */
#ifndef BOOTLOADER
mdelay(150);
#endif
} else {
axp_init();
/* Set lowest sample rate */
@ -138,7 +140,6 @@ void power_init(void)
(1 << ADC_INTERNAL_TEMP) |
(1 << ADC_APS_VOLTAGE));
/* TODO: Set Output Voltages! */
i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
AXP_REG_PWROUTPUTCTRL2, 0, 0x5f, NULL);
i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,