diff options
author | Vic Yang <victoryang@chromium.org> | 2013-09-10 16:20:13 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-09-12 13:28:57 +0000 |
commit | b28e92a855ea43b9003dd9bae73fefe3c304fd53 (patch) | |
tree | 69117009985ff219ccc5fdd7eea68ea8df1ce3cb | |
parent | bd9d1746c7a6cddc15d68949dc59877d52e26429 (diff) | |
download | chrome-ec-b28e92a855ea43b9003dd9bae73fefe3c304fd53.tar.gz |
kirby: Detect OTG dongle on EC boot
This fixes the problem that after an EC reboot, OTG dongle stops
working.
BUG=chrome-os-partner:21964
TEST=Reboot EC and boot from OTG dongle.
BRANCH=None
Change-Id: Ieec43f612d01114d13afb40293acfd0b3e324e8c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168737
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | common/extpower_kirby.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/common/extpower_kirby.c b/common/extpower_kirby.c index ceb4220b4f..a10e42b1d3 100644 --- a/common/extpower_kirby.c +++ b/common/extpower_kirby.c @@ -26,15 +26,29 @@ int extpower_is_present(void) return !gpio_get_level(GPIO_AC_PRESENT_L); } +static void extpower_update_otg(void) +{ + int dev_type, is_otg; + + dev_type = tsu6721_get_device_type(); + is_otg = dev_type & TSU6721_TYPE_OTG; + + if (is_otg && !gpio_get_level(GPIO_BCHGR_OTG)) { + charger_enable_otg_power(1); + CPRINTF("[%T OTG power enabled]\n"); + } else if (!is_otg && gpio_get_level(GPIO_BCHGR_OTG)) { + charger_enable_otg_power(0); + CPRINTF("[%T OTG power disabled]\n"); + } +} + static void extpower_deferred(void) { - int int_val, dev_type, is_otg; + int int_val; int ac; static int last_ac = -1; int_val = tsu6721_get_interrupts(); - dev_type = tsu6721_get_device_type(); - is_otg = dev_type & TSU6721_TYPE_OTG; ac = extpower_is_present(); if (last_ac != ac) { @@ -45,13 +59,7 @@ static void extpower_deferred(void) if (!int_val) return; - if (is_otg && !gpio_get_level(GPIO_BCHGR_OTG)) { - charger_enable_otg_power(1); - CPRINTF("[%T OTG power enabled]\n"); - } else if (!is_otg && gpio_get_level(GPIO_BCHGR_OTG)) { - charger_enable_otg_power(0); - CPRINTF("[%T OTG power disabled]\n"); - } + extpower_update_otg(); } DECLARE_DEFERRED(extpower_deferred); @@ -60,9 +68,10 @@ DECLARE_DEFERRED(extpower_deferred); static void extpower_init(void) { - tsu6721_init(); + tsu6721_reset(); gpio_enable_interrupt(GPIO_USB_CHG_INT); gpio_enable_interrupt(GPIO_AC_PRESENT_L); + extpower_update_otg(); } DECLARE_HOOK(HOOK_INIT, extpower_init, HOOK_PRIO_LAST); |