diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-01-30 17:42:01 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-31 06:57:51 +0000 |
commit | c9adf202e3b1d50bda52fda9cb2f9cff918d64b4 (patch) | |
tree | 0c6dde5559b0b503a1ba0a54d242bd84fef6f8c8 | |
parent | 7ad29b56aeaa26ff2461257bdc070e9277a41782 (diff) | |
download | chrome-ec-c9adf202e3b1d50bda52fda9cb2f9cff918d64b4.tar.gz |
samus_pd: Do one auto port re-detection if an SDP port is detected
Non-SDP ports can be identified as SDP on slow plug insertion. To ensure
no long-term misdetection, automatically do a single re-detection 30
seconds after detecting an SDP port.
BUG=chrome-os-partner:36166
TEST=Manual on Samus. Slow-plug a 1A Apple charger, verify that
detection is originally 500mA. After 30s, verify that detection becomes
1000mA. Also verify that only one additional re-detection is triggered.
BRANCH=Samus
Change-Id: I2babaecdf2252436d1f6b35f5654c14eff9c526b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/245153
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | board/samus_pd/board.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index b11a1d0c78..d89527dfc2 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -128,15 +128,22 @@ void set_usb_switches(int port, int open) */ #define USB_CHG_RESET_DELAY_MS 100 +/* Automatically do one redetection after a timeout period, for SDP ports. */ +#define USB_CHG_AUTO_REDETECT_TIMEOUT (30 * SECOND) + void usb_charger_task(void) { int port = (task_get_current() == TASK_ID_USB_CHG_P0 ? 0 : 1); int device_type, charger_status; struct charge_port_info charge; - int type; + int type, redetect_timeout; + uint32_t wake_event = 0; charge.voltage = USB_BC12_CHARGE_VOLTAGE; while (1) { + /* By default, don't do automatic redetection */ + redetect_timeout = -1; + /* Read interrupt register to clear on chip */ pi3usb9281_get_interrupts(port); @@ -148,7 +155,13 @@ void usb_charger_task(void) if (device_type || PI3USB9281_CHG_STATUS_ANY(charger_status)) { msleep(USB_CHG_DEBOUNCE_DELAY_MS); - /* Trigger chip reset to refresh detection registers */ + /* + * Trigger chip reset to refresh detection registers. + * WARNING: This reset is acceptable for samus_pd, + * but may not be acceptable for devices that have + * an OTG / device mode, as we may be interrupting + * the connection. + */ pi3usb9281_reset(port); /* * Restore data switch settings - switches return to @@ -184,8 +197,18 @@ void usb_charger_task(void) type = CHARGE_SUPPLIER_BC12_CDP; else if (device_type & PI3USB9281_TYPE_DCP) type = CHARGE_SUPPLIER_BC12_DCP; - else if (device_type & PI3USB9281_TYPE_SDP) + else if (device_type & PI3USB9281_TYPE_SDP) { + /* + * Automatically do one redetection after a timeout + * period when an SDP port is identified, since + * pin contact order may have caused + * misidentification. + */ + if (wake_event != TASK_EVENT_TIMER) + redetect_timeout = + USB_CHG_AUTO_REDETECT_TIMEOUT; type = CHARGE_SUPPLIER_BC12_SDP; + } else type = CHARGE_SUPPLIER_OTHER; @@ -217,7 +240,7 @@ void usb_charger_task(void) pd_send_host_event(PD_EVENT_POWER_CHANGE); /* Wait for interrupt */ - task_wait_event(-1); + wake_event = task_wait_event(redetect_timeout); } } |