mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
bd9d1746c7
commit
b28e92a855
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user