From f1b622231b6ac70aaf2d2aa23448146a7600a500 Mon Sep 17 00:00:00 2001 From: Jaehoon Kim Date: Mon, 6 Jan 2014 19:20:45 +0900 Subject: Pit: Add Green LED function in tps65090 charger driver From DV2 board of pit, we'll use 3 color-LED instead of power LED on keyboard. So, we have to add the function to control 3 color-LED in pmu driver. BUG=chrome-os-partner:24855 TEST=Tested on the pi and pit board about all power status. BRANCH=pit Change-Id: I7b1df39de8fa56eab73779abfa52cf8f72427b44 Signed-off-by: Jaehoon Kim Reviewed-on: https://chromium-review.googlesource.com/181588 Tested-by: Katie Roberts-Hoffman Reviewed-by: Randall Spangler Commit-Queue: Wonjoon Lee --- board/pit/board.c | 2 +- board/pit/board.h | 3 ++- common/pmu_tps65090_charger.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/board/pit/board.c b/board/pit/board.c index 8f5ed840e7..2d1984f2c8 100644 --- a/board/pit/board.c +++ b/board/pit/board.c @@ -70,7 +70,7 @@ const struct gpio_info gpio_list[] = { {"I2C1_SDA", GPIO_B, (1<<7), GPIO_ODR_HIGH, NULL}, {"I2C2_SCL", GPIO_B, (1<<10), GPIO_ODR_HIGH, NULL}, {"I2C2_SDA", GPIO_B, (1<<11), GPIO_ODR_HIGH, NULL}, - {"LED_POWER_L", GPIO_A, (1<<2), GPIO_OUT_HIGH, NULL}, + {"CHARGING_LED",GPIO_A, (1<<2), GPIO_OUT_LOW, NULL}, {"PMIC_PWRON", GPIO_A, (1<<12), GPIO_OUT_LOW, NULL}, {"PMIC_RESET", GPIO_A, (1<<15), GPIO_OUT_LOW, NULL}, {"KB_OUT00", GPIO_B, (1<<0), GPIO_KB_OUTPUT, NULL}, diff --git a/board/pit/board.h b/board/pit/board.h index 52ef14ecaf..85f20b3895 100644 --- a/board/pit/board.h +++ b/board/pit/board.h @@ -22,6 +22,7 @@ #define CONFIG_PMU_HARD_RESET #define CONFIG_PMU_POWERINFO #define CONFIG_PMU_TPS65090 +#define CONFIG_PMU_TPS65090_CHARGING_LED #define CONFIG_SPI #define CONFIG_VBOOT_HASH @@ -79,7 +80,7 @@ enum gpio_signal { GPIO_I2C1_SDA, GPIO_I2C2_SCL, GPIO_I2C2_SDA, - GPIO_LED_POWER_L, + GPIO_CHARGING_LED, GPIO_PMIC_PWRON, GPIO_PMIC_RESET, GPIO_KB_OUT00, diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c index a55edfc426..8a07653a80 100644 --- a/common/pmu_tps65090_charger.c +++ b/common/pmu_tps65090_charger.c @@ -52,6 +52,21 @@ static int has_pending_event; static enum charging_state current_state = ST_IDLE0; +#ifdef CONFIG_PMU_TPS65090_CHARGING_LED +static void update_battery_led(void) +{ + int alarm; + int led_on = 0; + if(extpower_is_present()){ + battery_status(&alarm); + if((alarm & ALARM_CHARGED) && !gpio_get_level(GPIO_CHARGER_EN)) + led_on = 1; + } + + gpio_set_level(GPIO_CHARGING_LED, led_on); +} +#endif + static void enable_charging(int enable) { enable = enable ? 1 : 0; @@ -409,6 +424,9 @@ void charger_task(void) extpower_charge_update(0); #endif +#ifdef CONFIG_PMU_TPS65090_CHARGING_LED + update_battery_led(); +#endif /* * When battery is extremely low, the internal voltage can not * power on its gas guage IC. Charging loop will enable the -- cgit v1.2.1