summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-09-19 09:41:11 -0700
committerGerrit <chrome-bot@google.com>2012-09-20 07:14:18 -0700
commitc350c20f443eb69429727f2f967522e7b2817515 (patch)
tree2726920511b4b2299f330889db46f77a952f79fe /common
parent07cae3f8e1f7e8b53c8b60752d4e7d519ff01a74 (diff)
downloadchrome-ec-c350c20f443eb69429727f2f967522e7b2817515.tar.gz
tpschrome: AC detection is board specific.
the PMU VACG signal used to detect AC state is connected to a GPIO, so it's a board specific configuration. On top of that, Daisy variants have custom logic on that line which is not present on the next boards, so we need to update it before doing BSP for next-gen boards. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:14313 TEST=make BOARD=snow && make BOARD=daisy on snow EC console, type "pmu" command with AC plugge and unplugged, see that the "ac gpio" line reflects the right value. BRANCH=none Change-Id: If1e19b89b2f2de45d8dddc8340931e56c5f7f0a5 Reviewed-on: https://gerrit.chromium.org/gerrit/33630 Reviewed-by: David Hendricks <dhendrix@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/pmu_tps65090.c39
-rw-r--r--common/pmu_tps65090_charger.c12
2 files changed, 8 insertions, 43 deletions
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c
index 8d6d27a170..97e3292c54 100644
--- a/common/pmu_tps65090.c
+++ b/common/pmu_tps65090.c
@@ -366,47 +366,12 @@ int pmu_low_current_charging(int enable)
void pmu_irq_handler(enum gpio_signal signal)
{
#ifdef CONFIG_AC_POWER_STATUS
- gpio_set_level(GPIO_AC_STATUS, pmu_get_ac());
+ gpio_set_level(GPIO_AC_STATUS, board_get_ac());
#endif
task_wake(TASK_ID_PMU_TPS65090_CHARGER);
CPRINTF("Charger IRQ received.\n");
}
-int pmu_get_ac(void)
-{
- /*
- * Detect AC state using combined gpio pins
- *
- * On daisy and snow, there's no single gpio signal to detect AC.
- * GPIO_AC_PWRBTN_L provides AC on and PWRBTN release.
- * GPIO_KB_PWR_ON_L provides PWRBTN release.
- *
- * When AC plugged, both GPIOs will be high.
- *
- * One drawback of this detection is, when press-and-hold power
- * button. AC state will be unknown. This function will fallback
- * to PMU VACG.
- *
- * TODO(rongchang): move board related function to board/ and common
- * interface to system_get_ac()
- */
-
- int ac_good = 1, battery_good;
-
- if (gpio_get_level(GPIO_KB_PWR_ON_L))
- return gpio_get_level(GPIO_AC_PWRBTN_L);
-
- /* Check PMU VACG */
- if (!in_interrupt_context())
- pmu_get_power_source(&ac_good, &battery_good);
-
- /*
- * Charging task only interacts with AP in discharging state. So
- * return 1 when AC status can not be detected by GPIO or VACG.
- */
- return ac_good;
-}
-
int pmu_shutdown(void)
{
int offset, failure = 0;
@@ -591,7 +556,7 @@ static int command_pmu(int argc, char **argv)
if (rv)
return rv;
CPRINTF("pmu events b%08b\n", value);
- CPRINTF("ac gpio %d\n", pmu_get_ac());
+ CPRINTF("ac gpio %d\n", board_get_ac());
if (rv)
ccprintf("Failed - error %d\n", rv);
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index be3abd0bb2..d710262954 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -194,7 +194,7 @@ static int calc_next_state(int state)
switch (state) {
case ST_IDLE:
/* Check AC and chiset state */
- if (!pmu_get_ac()) {
+ if (!board_get_ac()) {
if (chipset_in_state(CHIPSET_STATE_ON))
return ST_DISCHARGING;
return ST_IDLE;
@@ -231,7 +231,7 @@ static int calc_next_state(int state)
return ST_IDLE;
case ST_PRE_CHARGING:
- if (!pmu_get_ac())
+ if (!board_get_ac())
return ST_IDLE;
/* If the battery goes online after enable the charger,
@@ -252,7 +252,7 @@ static int calc_next_state(int state)
case ST_CHARGING:
/* Go back to idle state when AC is unplugged */
- if (!pmu_get_ac())
+ if (!board_get_ac())
return ST_IDLE;
/*
@@ -305,7 +305,7 @@ static int calc_next_state(int state)
* - battery temperature is in start charging range
* - no battery alarm
*/
- if (pmu_get_ac()) {
+ if (board_get_ac()) {
if (battery_status(&alarm))
return ST_CHARGING_ERROR;
@@ -326,7 +326,7 @@ static int calc_next_state(int state)
case ST_DISCHARGING:
/* Go back to idle state when AC is plugged */
- if (pmu_get_ac())
+ if (board_get_ac())
return ST_IDLE;
/* Prepare EC sleep after system stopped discharging */
@@ -453,7 +453,7 @@ void pmu_charger_task(void)
pre_charging_count++;
break;
default:
- if (pmu_get_ac()) {
+ if (board_get_ac()) {
wait_time = T1_USEC;
break;
} else if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {