diff options
author | Rong Chang <rongchang@chromium.org> | 2012-07-03 19:39:27 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-03 23:51:19 -0700 |
commit | 717e556759304490548ee23973895d995ee88a05 (patch) | |
tree | 54d1ff404a50bfca53116be3fb2dd30ea9eb84bf | |
parent | b4789cf1f731d120f074831dc4b9552f6bcb8163 (diff) | |
download | chrome-ec-717e556759304490548ee23973895d995ee88a05.tar.gz |
Initialize PMU default settings using board configuration
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11749
TEST=on snow with fully discharged dead battery
plug ac power and check if it can charge to full
Change-Id: Ie90255614bff879780edbd2bf1fc77bf8e2c04c8
Reviewed-on: https://gerrit.chromium.org/gerrit/26674
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | board/snow/board.c | 40 | ||||
-rw-r--r-- | board/snow/board.h | 4 | ||||
-rw-r--r-- | common/pmu_tps65090.c | 36 | ||||
-rw-r--r-- | common/pmu_tps65090_charger.c | 6 | ||||
-rw-r--r-- | include/pmu_tpschrome.h | 18 |
5 files changed, 86 insertions, 18 deletions
diff --git a/board/snow/board.c b/board/snow/board.c index 4231ee4b2a..1e29c3ebed 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -11,6 +11,7 @@ #include "dma.h" #include "gpio.h" #include "i2c.h" +#include "pmu_tpschrome.h" #include "registers.h" #include "spi.h" #include "timer.h" @@ -240,4 +241,41 @@ void board_i2c_release(int port) gpio_set_level(GPIO_EC_CLAIM, 1); } } -#endif +#endif /* CONFIG_ARBITRATE_I2C */ + +#ifdef CONFIG_PMU_BOARD_INIT +/** + * Initialize PMU register settings + * + * PMU init settings depend on board configuration. This function should be + * called inside PMU init function. + */ +void board_pmu_init(void) +{ + /** + * Explanation: + * + * 1. Timeout is by default 2hrs. This increases to 3hrs. At 1.8A + * charging, this should be long enough for the 4000mA-hr battery, + * assuming it spends about 30mins in the CC mode, but doesn't + * allow for much margin. + * 2. Change temp range T23 (0C-40C), to 1.8A max charge. This is + * currently set to 2.4A which is higher than the recommend charge + * current of 2A. + * 3. Change temp range T34 (40C-60C) to 1.8A max charge, and change + * charge voltage to 8.6V. This is currently set to 1.2A/8.49V. + * Because the NTC is on the board, this is quickly reached so + * slow charging may occur. The battery is rated for 2A charging + * up to 60C. + * 4. Set NOITERM bit. On a fully dead battery, the pack goes into a + * mode where it only lets in a very small current via there is a + * different charge path. This fools the charger into thinking + * the current vs voltage is bad. This bit corrects this. + */ + pmu_write(0x04, 0x06); + pmu_write(0x07, 0xbd); + pmu_write(0x08, 0xfd); + pmu_write(0x09, 0xe0); +} +#endif /* CONFIG_BOARD_PMU_INIT */ + diff --git a/board/snow/board.h b/board/snow/board.h index c78a30f574..1c9f0ca11e 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -44,6 +44,7 @@ /* Charging */ #define CONFIG_SMART_BATTERY #define CONFIG_PMU_TPS65090 +#define CONFIG_PMU_BOARD_INIT /* #define CONFIG_I2C_HOST_AUTO */ /* #define I2C_PORT_HOST board_i2c_host_port() */ #define I2C_PORT_HOST 1 @@ -108,6 +109,9 @@ void board_interrupt_host(int active); /* Auto detect EC i2c host port */ int board_i2c_host_port(void); +/* Initialize PMU registers using board settings */ +void board_pmu_init(void); + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index 93d9886699..e674da9ff4 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -9,6 +9,7 @@ #include "console.h" #include "common.h" #include "i2c.h" +#include "pmu_tpschrome.h" #include "util.h" #define CPUTS(outstr) cputs(CC_CHARGER, outstr) @@ -39,17 +40,6 @@ /* Charger alarm */ #define CHARGER_ALARM 3 -/* Read/write tps65090 register */ -static inline int pmu_read(int reg, int *value) -{ - return i2c_read8(I2C_PORT_CHARGER, TPS65090_I2C_ADDR, reg, value); -} - -static inline int pmu_write(int reg, int value) -{ - return i2c_write8(I2C_PORT_CHARGER, TPS65090_I2C_ADDR, reg, value); -} - /* Clear tps65090 irq */ static inline int pmu_clear_irq(void) { @@ -82,6 +72,17 @@ static int pmu_get_event(int *event) return EC_SUCCESS; } +/* Read/write tps65090 register */ +int pmu_read(int reg, int *value) +{ + return i2c_read8(I2C_PORT_CHARGER, TPS65090_I2C_ADDR, reg, value); +} + +int pmu_write(int reg, int value) +{ + return i2c_write8(I2C_PORT_CHARGER, TPS65090_I2C_ADDR, reg, value); +} + int pmu_is_charger_alarm(void) { int status; @@ -129,6 +130,9 @@ int pmu_enable_charger(int enable) void pmu_init(void) { +#ifdef CONFIG_PMU_BOARD_INIT + board_pmu_init(); +#else /* Init configuration * Fast charge timer : 2 hours * Charger : disable @@ -137,13 +141,13 @@ void pmu_init(void) * TODO: move settings to battery pack specific init */ pmu_write(CG_CTRL0, 2); - - /* Enable interrupt mask */ - pmu_write(IRQ1MASK, 0xff); - pmu_write(IRQ2MASK, 0xff); - /* Limit full charge current to 50% * TODO: remove this temporary hack. */ pmu_write(CG_CTRL3, 0xbb); +#endif + /* Enable interrupt mask */ + pmu_write(IRQ1MASK, 0xff); + pmu_write(IRQ2MASK, 0xff); + } diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c index bb473b5c2a..28bcfafe0b 100644 --- a/common/pmu_tps65090_charger.c +++ b/common/pmu_tps65090_charger.c @@ -56,7 +56,11 @@ static void enable_charging(int enable) if (gpio_get_level(GPIO_CHARGER_EN) != enable) gpio_set_level(GPIO_CHARGER_EN, enable); - pmu_enable_charger(enable); + /* With NOITERM bit set, charger can be controlled by gpio. + * Hence following charger enable command can be removed. + * + * pmu_enable_charger(enable); + */ } diff --git a/include/pmu_tpschrome.h b/include/pmu_tpschrome.h index 0c066beff0..9d8e90890b 100644 --- a/include/pmu_tpschrome.h +++ b/include/pmu_tpschrome.h @@ -12,6 +12,24 @@ #define FET_LCD_PANEL 6 /** + * Read pmu register + * + * @param reg register offset + * @param value pointer to output value + * @return return EC_SUCCESS on success, err code otherwise + */ +int pmu_read(int reg, int *value); + +/** + * Write pmu register + * + * @param reg register offset + * @param value new register value + * @return return EC_SUCCESS on success, err code otherwise + */ +int pmu_write(int reg, int value); + +/** * Check pmu charger alarm * * @return 0 if there's no charging alarm or pmu access failed |