summaryrefslogtreecommitdiff
path: root/common/usb_charger.c
diff options
context:
space:
mode:
authorRong Chang <rongchang@chromium.org>2015-08-19 23:34:29 +0800
committerchrome-bot <chrome-bot@chromium.org>2015-09-03 04:24:34 -0700
commit229bac23f15a7636ccb25b6861655e3e0923a0e9 (patch)
tree9b56587f1ec55ed77da369c1d9122b5ca70ec7d0 /common/usb_charger.c
parenta572c882e46b11ec2cdcc2f5d84ce1f47ecc14d2 (diff)
downloadchrome-ec-229bac23f15a7636ccb25b6861655e3e0923a0e9.tar.gz
oak: handle USB BC 1.2 status change
Before oak rev4, BC 1.2 status change was polled on VBUS change. The designed is changed to use a single interrupt pin for both ports. BRANCH=none BUG=chrome-os-partner:42610 TEST=manual make EXTRA_CFLAGS=-DBOARD_REV=3 BOARD=oak -j emerge-oak chromeos-ec load on oak rev3 and check BC 1.2 charging current Change-Id: I9e6cdbb83468b5e4086cc86caadf7f2e3cbe6e48 Signed-off-by: Rong Chang <rongchang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/294442
Diffstat (limited to 'common/usb_charger.c')
-rw-r--r--common/usb_charger.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/common/usb_charger.c b/common/usb_charger.c
index 99263fafc9..0474bc18b8 100644
--- a/common/usb_charger.c
+++ b/common/usb_charger.c
@@ -100,9 +100,6 @@ static void usb_charger_bc12_detect(int port)
charge.voltage = USB_CHARGER_VOLTAGE_MV;
- /* Read interrupt register to clear on chip */
- pi3usb9281_get_interrupts(port);
-
if (usb_charger_port_is_sourcing_vbus(port)) {
/* If we're sourcing VBUS then we're not charging */
device_type = charger_status = 0;
@@ -203,7 +200,9 @@ static void usb_charger_bc12_detect(int port)
void usb_charger_task(void)
{
+ const int attach_mask = PI3USB9281_INT_ATTACH | PI3USB9281_INT_DETACH;
int port = (task_get_current() == TASK_ID_USB_CHG_P0 ? 0 : 1);
+ int interrupt;
uint32_t evt;
/* Initialize chip and enable interrupts */
@@ -214,8 +213,16 @@ void usb_charger_task(void)
while (1) {
/* Wait for interrupt */
evt = task_wait_event(-1);
+ /* Read interrupt register to clear on chip */
+ interrupt = pi3usb9281_get_interrupts(port);
+
+ /* Interrupt from the Pericom chip, determine interrupt type */
+ if (evt & USB_CHG_EVENT_INTR) {
+ if (interrupt & attach_mask)
+ usb_charger_bc12_detect(port);
+ }
- /* Interrupt from the Pericom chip, determine charger type */
+ /* Ignore interrupt status and determine charger type */
if (evt & USB_CHG_EVENT_BC12)
usb_charger_bc12_detect(port);