New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 791109 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug



Sign in to add a comment

ec: Fix VBUS detection / notification

Project Member Reported by sha...@chromium.org, Dec 1 2017

Issue description

We 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.
 
Components: OS>Firmware>EC
Labels: -Pri-3 OS-Chrome Pri-1
Status: Started (was: Untriaged)

Comment 2 by sha...@chromium.org, Jan 18 2018

Also hook_notify(HOOK_AC_CHANGE) may need to be called, if extpower_gpio module isn't used.

Comment 3 by sha...@chromium.org, 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.

Comment 4 by ecgh@google.com, 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

Comment 5 by ecgh@google.com, Jan 30 2018

Cc: ecgh@chromium.org
Cc: aaboagye@chromium.org
Cc: jettrink@chromium.org
Owner: ----
Status: Available (was: Started)
Owner: shu...@chromium.org
Status: Assigned (was: Available)

Sign in to add a comment