forked from len0rd/rockbox
Minor enhancements to axp173 driver
- Added register names to reduce usage of magic numbers - Added function to control max charging current, needed for USB - Corrected comment about axp173, since FiiO M3K has an axp192 Change-Id: I6604ce8d44e5a2ee84061cf042d17ccc4734ac57
This commit is contained in:
parent
f6d3680cb8
commit
088ebb5fac
4 changed files with 120 additions and 32 deletions
|
|
@ -23,13 +23,14 @@
|
|||
#include "kernel.h"
|
||||
#include "backlight.h"
|
||||
#include "panic.h"
|
||||
#include "lcd.h"
|
||||
#include "axp173.h"
|
||||
#include "gpio-x1000.h"
|
||||
#include "i2c-x1000.h"
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
# include "lcd.h"
|
||||
# include "font.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -409,7 +410,7 @@ static int hp_detect_tmo_cb(struct timeout* tmo)
|
|||
static void hp_detect_init(void)
|
||||
{
|
||||
static struct timeout tmo;
|
||||
static const uint8_t gpio_reg = 0x94;
|
||||
static const uint8_t gpio_reg = AXP192_REG_GPIOSTATE1;
|
||||
static i2c_descriptor desc = {
|
||||
.slave_addr = AXP173_ADDR,
|
||||
.bus_cond = I2C_START | I2C_STOP,
|
||||
|
|
@ -423,9 +424,8 @@ static void hp_detect_init(void)
|
|||
.next = NULL,
|
||||
};
|
||||
|
||||
/* Headphone detect is wired to an undocumented GPIO on the AXP173.
|
||||
* This sets it to input mode so we can see the pin state. */
|
||||
i2c_reg_write1(AXP173_BUS, AXP173_ADDR, 0x93, 0x01);
|
||||
/* Headphone detect is wired to AXP192 GPIO: set it to input state */
|
||||
i2c_reg_write1(AXP173_BUS, AXP173_ADDR, AXP192_REG_GPIO2FUNCTION, 0x01);
|
||||
|
||||
/* Get an initial reading before startup */
|
||||
int r = i2c_reg_read1(AXP173_BUS, AXP173_ADDR, gpio_reg);
|
||||
|
|
|
|||
|
|
@ -68,8 +68,14 @@ void power_init(void)
|
|||
axp173_adc_set_enabled(bits);
|
||||
|
||||
/* Turn on all power outputs */
|
||||
i2c_reg_modify1(AXP173_BUS, AXP173_ADDR, 0x12, 0, 0x5f, NULL);
|
||||
i2c_reg_modify1(AXP173_BUS, AXP173_ADDR, 0x80, 0, 0xc0, NULL);
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Short delay to give power outputs time to stabilize */
|
||||
mdelay(5);
|
||||
|
|
@ -82,7 +88,8 @@ void adc_init(void)
|
|||
void power_off(void)
|
||||
{
|
||||
/* Set the shutdown bit */
|
||||
i2c_reg_setbit1(AXP173_BUS, AXP173_ADDR, 0x32, 7, 1, NULL);
|
||||
i2c_reg_setbit1(AXP173_BUS, AXP173_ADDR,
|
||||
AXP173_REG_SHUTDOWNLEDCTRL, 7, 1, NULL);
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue