mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 13:45:03 -05:00
axp173 driver: rename to "axp-pmu" + other changes
The old name was a bit misleading. AXP173 is sort of the lowest common denominator of a series of related chips. The M3K uses an AXP192 which has a few extra features vs. the AXP173. New voltage regulator stuff was added for the sake of the Shanling Q1 native port (that player also uses an AXP192). Change-Id: Id0c162c23094bb03d13fae2d6c332e3047968d6e
This commit is contained in:
parent
2066465b78
commit
0187fca640
10 changed files with 853 additions and 624 deletions
|
|
@ -148,7 +148,9 @@ static bool dbg_cpuidle(void)
|
|||
|
||||
#ifdef FIIO_M3K
|
||||
extern bool dbg_fiiom3k_touchpad(void);
|
||||
extern bool axp173_debug_menu(void);
|
||||
#endif
|
||||
#ifdef HAVE_AXP_PMU
|
||||
extern bool axp_debug_menu(void);
|
||||
#endif
|
||||
|
||||
/* Menu definition */
|
||||
|
|
@ -164,7 +166,9 @@ static const struct {
|
|||
{"Audio", &dbg_audio},
|
||||
#ifdef FIIO_M3K
|
||||
{"Touchpad", &dbg_fiiom3k_touchpad},
|
||||
{"Power stats", &axp173_debug_menu},
|
||||
#endif
|
||||
#ifdef HAVE_AXP_PMU
|
||||
{"Power stats", &axp_debug_menu},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include "backlight.h"
|
||||
#include "powermgmt.h"
|
||||
#include "panic.h"
|
||||
#include "axp173.h"
|
||||
#include "axp-pmu.h"
|
||||
#include "gpio-x1000.h"
|
||||
#include "i2c-x1000.h"
|
||||
#include <string.h>
|
||||
|
|
@ -418,7 +418,7 @@ static uint8_t hp_detect_reg = 0x00;
|
|||
static int hp_detect_tmo_cb(struct timeout* tmo)
|
||||
{
|
||||
i2c_descriptor* d = (i2c_descriptor*)tmo->data;
|
||||
i2c_async_queue(AXP173_BUS, TIMEOUT_NOBLOCK, I2C_Q_ADD, 0, d);
|
||||
i2c_async_queue(AXP_PMU_BUS, TIMEOUT_NOBLOCK, I2C_Q_ADD, 0, d);
|
||||
return HPD_POLL_TIME;
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ static void hp_detect_init(void)
|
|||
static struct timeout tmo;
|
||||
static const uint8_t gpio_reg = AXP192_REG_GPIOSTATE1;
|
||||
static i2c_descriptor desc = {
|
||||
.slave_addr = AXP173_ADDR,
|
||||
.slave_addr = AXP_PMU_ADDR,
|
||||
.bus_cond = I2C_START | I2C_STOP,
|
||||
.tran_mode = I2C_READ,
|
||||
.buffer[0] = (void*)&gpio_reg,
|
||||
|
|
@ -440,10 +440,10 @@ static void hp_detect_init(void)
|
|||
};
|
||||
|
||||
/* Headphone detect is wired to AXP192 GPIO: set it to input state */
|
||||
i2c_reg_write1(AXP173_BUS, AXP173_ADDR, AXP192_REG_GPIO2FUNCTION, 0x01);
|
||||
i2c_reg_write1(AXP_PMU_BUS, AXP_PMU_ADDR, AXP192_REG_GPIO2FUNCTION, 0x01);
|
||||
|
||||
/* Get an initial reading before startup */
|
||||
int r = i2c_reg_read1(AXP173_BUS, AXP173_ADDR, gpio_reg);
|
||||
int r = i2c_reg_read1(AXP_PMU_BUS, AXP_PMU_ADDR, gpio_reg);
|
||||
if(r >= 0)
|
||||
hp_detect_reg = r;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#define FT6x06_BUS 1
|
||||
#define FT6x06_ADDR 0x38
|
||||
|
||||
#define AXP173_BUS 2
|
||||
#define AXP173_ADDR 0x34
|
||||
#define AXP_PMU_BUS 2
|
||||
#define AXP_PMU_ADDR 0x34
|
||||
|
||||
#endif /* __I2C_TARGET_H__ */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||
# include "usb_core.h"
|
||||
#endif
|
||||
#include "axp173.h"
|
||||
#include "axp-pmu.h"
|
||||
#include "i2c-x1000.h"
|
||||
#include "gpio-x1000.h"
|
||||
|
||||
|
|
@ -53,32 +53,32 @@ const unsigned short percent_to_volt_charge[11] =
|
|||
3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
|
||||
};
|
||||
|
||||
#define AXP173_IRQ_PORT GPIO_B
|
||||
#define AXP173_IRQ_PIN (1 << 10)
|
||||
#define AXP_IRQ_PORT GPIO_B
|
||||
#define AXP_IRQ_PIN (1 << 10)
|
||||
|
||||
void power_init(void)
|
||||
{
|
||||
/* Initialize driver */
|
||||
i2c_x1000_set_freq(2, I2C_FREQ_400K);
|
||||
axp173_init();
|
||||
axp_init();
|
||||
|
||||
/* Set lowest sample rate */
|
||||
axp173_adc_set_rate(AXP173_ADC_RATE_25HZ);
|
||||
axp_adc_set_rate(AXP_ADC_RATE_25HZ);
|
||||
|
||||
/* Ensure battery voltage ADC is enabled */
|
||||
int bits = axp173_adc_get_enabled();
|
||||
int bits = axp_adc_get_enabled();
|
||||
bits |= (1 << ADC_BATTERY_VOLTAGE);
|
||||
axp173_adc_set_enabled(bits);
|
||||
axp_adc_set_enabled(bits);
|
||||
|
||||
/* Turn on all power outputs */
|
||||
i2c_reg_modify1(AXP173_BUS, AXP173_ADDR,
|
||||
AXP173_REG_PWROUTPUTCTRL, 0, 0x5f, NULL);
|
||||
i2c_reg_modify1(AXP173_BUS, AXP173_ADDR,
|
||||
AXP173_REG_DCDCWORKINGMODE, 0, 0xc0, NULL);
|
||||
i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
|
||||
AXP_REG_PWROUTPUTCTRL2, 0, 0x5f, NULL);
|
||||
i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
|
||||
AXP_REG_DCDCWORKINGMODE, 0, 0xc0, NULL);
|
||||
|
||||
/* Set the default charging current. This is the same as the
|
||||
* OF's setting, although it's not strictly within the USB spec. */
|
||||
axp173_set_charge_current(780);
|
||||
axp_set_charge_current(780);
|
||||
|
||||
/* Short delay to give power outputs time to stabilize */
|
||||
mdelay(5);
|
||||
|
|
@ -87,7 +87,7 @@ void power_init(void)
|
|||
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||
void usb_charging_maxcurrent_change(int maxcurrent)
|
||||
{
|
||||
axp173_set_charge_current(maxcurrent);
|
||||
axp_set_charge_current(maxcurrent);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -97,18 +97,16 @@ void adc_init(void)
|
|||
|
||||
void power_off(void)
|
||||
{
|
||||
/* Set the shutdown bit */
|
||||
i2c_reg_setbit1(AXP173_BUS, AXP173_ADDR,
|
||||
AXP173_REG_SHUTDOWNLEDCTRL, 7, 1, NULL);
|
||||
axp_power_off();
|
||||
while(1);
|
||||
}
|
||||
|
||||
bool charging_state(void)
|
||||
{
|
||||
return axp173_battery_status() == AXP173_BATT_CHARGING;
|
||||
return axp_battery_status() == AXP_BATT_CHARGING;
|
||||
}
|
||||
|
||||
int _battery_voltage(void)
|
||||
{
|
||||
return axp173_adc_read(ADC_BATTERY_VOLTAGE);
|
||||
return axp_adc_read(ADC_BATTERY_VOLTAGE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue