ec: Fix VBUS detection / notification |
||||||
Issue descriptionWe have three methods of VBUS detection: - GPIO (VBUS connected directly to GPIO, GPIO interrupt routine detects) - Charger (Charger IC asserts interrupt pin, wakes USB_CHG task, USB_CHG task detects) - TCPC (TCPC asserts alert interrupt pin, wakes PD_CMD task, calls tcpc_alert() which detects) All three methods are interrupt-based, but the second two involve other tasks, because checking VBUS level involves i2c. When a VBUS change occurs, other modules / tasks need to be informed: - PD tasks need to be told VBUS went low (record keeping of PD_FLAGS_VBUS_NEVER_LOW) - Corresponding PD task needs to be woken. - Corresponding USB charger task needs to be woken. - charge_manager needs to be told of the change. The code to do this informing is spread out, and in some cases incomplete or completely missing. Ideally we should have a single common routine that takes all of these actions, which will be called in a similar way regardless of the VBUS detect method used. Let's try to implement that.
,
Jan 18 2018
Also hook_notify(HOOK_AC_CHANGE) may need to be called, if extpower_gpio module isn't used.
,
Jan 18 2018
We should add a new module, something like "extpower_tracker".
enum vbus_detector {
DETECTOR_TCPC,
DETECTOR_CHARGER,
DETECTOR_GPIO,
DETECTOR_COUNT
};
static int vbus_level[DETECTOR_COUNT];
extpower_tracker_update_vbus(enum vbus_detector detector, int port, int level);
Other modules that are deciders of VBUS presence will call extpower_tracker_update_vbus() when they think VBUS has changed, then extpower_tracker_update_vbus() will take certain actions if (1) VBUS has in fact changed and (2) we care about the change (see DETECT_TCPC vs DETECT_CHARGER).
Such a module would also be helpful for debug (eg. cases where the TCPC says VBUS is present, but the charger says no?). We've run into such cases before.
,
Jan 30 2018
Grunt is using a 4th method of VBUS detection: CONFIG_USB_PD_VBUS_DETECT_PPC, see https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/887938
,
Jan 30 2018
,
Jan 30 2018
,
Jan 31 2018
,
Feb 7 2018
,
Nov 2
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by sha...@chromium.org
, Dec 1 2017Labels: -Pri-3 OS-Chrome Pri-1
Status: Started (was: Untriaged)