diff options
author | Peter Marheine <pmarheine@chromium.org> | 2023-03-15 17:38:25 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-15 22:28:08 +0000 |
commit | fe14c338c7837f649441a637665ac5ccc97dbd5f (patch) | |
tree | 1e9691f8293d80c5118cd99c7b38e274a9da7066 /include | |
parent | bf1232c2b16696c1f36b94ad3d412c743009320e (diff) | |
download | chrome-ec-fe14c338c7837f649441a637665ac5ccc97dbd5f.tar.gz |
usb_charger: support processing events synchronously
Some hardware topologies require that high-priority tasks be able to
process BC1.2 interrupts at higher priority than the BC1.2 task runs at,
but increasing the priority of the BC1.2 task may not be appropriate.
This adds a synchronous version of usb_charger_task_set_event suitable
for those devices' needs.
BUG=b:269064073
TEST=Nissa devices using the new function on shared USB-C IRQs no longer
experience priority inversion that sometimes causes incorrect
behavior.
BRANCH=nissa
Change-Id: I191fb0500c3d793d521168b37e9e8ed3fdd28473
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4339477
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/usb_charge.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/usb_charge.h b/include/usb_charge.h index cd022d5f51..290471c1c9 100644 --- a/include/usb_charge.h +++ b/include/usb_charge.h @@ -187,6 +187,20 @@ static inline int usb_charger_ramp_max(int port, int supplier, int sup_curr) void usb_charger_task_set_event(int port, uint8_t event); /** + * Synchronously handle an event for a specific USB charger port. + * + * This is the same as using usb_charger_task_set_event for a given port + * and event, but executes synchronously (on the calling thread) instead of + * asynchronously (on the dedicated USB charger thread). + * + * Most users should prefer to use the asynchronous equivalent, but it is + * sometimes necessary to use this version in order to avoid priority inversion + * when a higher-priority task must ensure BC1.2 processing completes before + * continuing. + */ +void usb_charger_task_set_event_sync(int port, uint8_t event); + +/** * Reset available BC 1.2 chargers on all ports * * @param port |