diff options
author | Aseda Aboagye <aaboagye@google.com> | 2022-01-10 17:26:56 -0600 |
---|---|---|
committer | Aseda Aboagye <aaboagye@google.com> | 2022-01-10 17:26:56 -0600 |
commit | dc11829e169a9c425860ec5cca949ef80df9e0b7 (patch) | |
tree | 0517b0831c6e52b347926a1b727741df380e908c /driver/usb_mux/usb_mux.c | |
parent | c5bd23a4b204565dab616f7fa4ee8a0b7b433d4c (diff) | |
parent | b44d10f8f79cadb259cc7ab79714a0919fc0c4c8 (diff) | |
download | chrome-ec-firmware-keeby-14119.B-main.tar.gz |
Merge remote-tracking branch cros/main into firmware-keeby-14119.B-mainfirmware-keeby-14119.B-main
Relevant changes:
git log --oneline c5bd23a4b..b44d10f8f -- baseboard/dedede board/cappy2
board/corori board/driblee board/gooey board/haboki board/lalala
board/waddledoo2 common/charge_state_v2.c common/mkbp_* common/ocpc.c
common/usbc/usb_tc_drp_acc_trysrc_sm.c common/usbc/usb_sm.c
common/usbc/*_pd_* common/usbc/dp_alt_mode.c common/usbc/usb_prl_sm.c
common/usbc/usb_pe_drp_sm.c common/usb_charger.c common/usb_common.c
common/usbc_ocp.c driver/charger/sm5803.* driver/charger/isl923x.*
driver/tcpm/raa489000.* driver/tcpm/it83* include/power/icelake.h
include/intel_x86.h power/icelake.c power/intel_x86.c util/getversion.sh
42d03a001 config: change temp_sensor_power from config to gpio
e296efb28 usb_common: Fix CONFIG_USB_PD_DISCHARGE_TCPC typo
c346481f4 atomic: cast to unsigned when shifting
9b972a0f2 driver/tcpm/it83xx, it8xxx2: ITE inactive port return from HOOK
a499d8fd4 driver/tcpm/it83xx, it8xxx2: set sleep mask for mixed TCPC case
ed62e2583 TCPMv2: don't set the sleep mask for TCPC embedded in EC
c962696e8 motion_sensor: Remove |int_signal| field
86b216794 ocpc: modify pre-charge target condition
6f8336eb4 dedede: Set MKBP event wake mask to 0
02d034df0 dedede: add stylus fw_config
4f7cd7509 atomic: use atomic_t where it is possible
e3ffa0519 mkbp: change the type fifo_entries to atomic_t
bb4c47af0 usb: use atomic_t where possible
c6e513ee2 power/icelake: Add SLP_S5 as a watched power signal
d89e49b20 power: Introduce S4 as a real power state
ba8a3c9c0 chgstv2: Use chipset_in_state instead of naming states
23a975d12 i2c: Use declared initializers for i2c_ports: boards a-l
35865dbec TCPMv2: Guard DATA_RESET using CONFIG_USB_PD_DATA_RESET_MSG
d4d8243ed i2c: Use declared initializers for i2c_ports: baseboards
eba8d0305 RAA489000: Fixed RAA489000 max charging current
e78b83e0f TCPMv2: Delay Data Reset until mode entry request
6230e60fc TCPMv2: Support Data Reset as DFP, initiator
412246836 intel_x86: Apply chipset resume init and suspend complete hooks
f2809b72c config: rename CONFIG_HOSTCMD_ESPI to CONFIG_HOST_INTERFACE_ESPI
BRANCH=None
BUG=b:202796060 b:207805856 b:167983049 b:208318528 b:181983966
BUG=b:207328258 b:195416058 b:205285137 b:199919093 b:207055975
BUG=b:129159505 b:204947672 b:141363146 b:207082842 b:205675485
TEST=`make -j buildall`
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: I980351977e11088a130e478df0701be4715f049b
Diffstat (limited to 'driver/usb_mux/usb_mux.c')
-rw-r--r-- | driver/usb_mux/usb_mux.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c index ee7f96b905..58cc91a396 100644 --- a/driver/usb_mux/usb_mux.c +++ b/driver/usb_mux/usb_mux.c @@ -32,7 +32,7 @@ static int enable_debug_prints; * Flags will reset to 0 after sysjump; This works for current flags as LPM will * get reset in the init method which is called during PD task startup. */ -static uint32_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static atomic_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Device is in low power mode. */ #define USB_MUX_FLAG_IN_LPM BIT(0) @@ -317,9 +317,6 @@ static int configure_mux(int port, break; } - if (ack_required) - ack_task[port] = task_get_current(); - /* Apply board specific setting */ if (mux_ptr->board_set) rv = mux_ptr->board_set(mux_ptr, lcl_state); @@ -343,7 +340,8 @@ static int configure_mux(int port, case USB_MUX_HPD_UPDATE: if (mux_ptr->hpd_update) - mux_ptr->hpd_update(mux_ptr, *mux_state); + mux_ptr->hpd_update(mux_ptr, *mux_state, + &ack_required); } @@ -351,6 +349,8 @@ static int configure_mux(int port, mutex_unlock(&mux_lock[port]); if (ack_required) { + ack_task[port] = task_get_current(); + /* * This should only be called from the PD task or usb * mux task @@ -358,8 +358,15 @@ static int configure_mux(int port, if (IS_ENABLED(HAS_TASK_USB_MUX)) { assert(task_get_current() == TASK_ID_USB_MUX); } else { +#if defined(CONFIG_ZEPHYR) && defined(TEST_BUILD) + assert(port == + TASK_ID_TO_PD_PORT(task_get_current()) || + task_get_current() == + TASK_ID_TEST_RUNNER); +#else assert(port == TASK_ID_TO_PD_PORT(task_get_current())); +#endif /* defined(CONFIG_ZEPHYR) && defined(TEST_BUILD) */ } /* @@ -530,23 +537,29 @@ bool usb_mux_set_completed(int port) return !sets_pending; } -mux_state_t usb_mux_get(int port) +static enum ec_error_list try_usb_mux_get(int port, mux_state_t *mux_state) { - mux_state_t mux_state; - int rv; - - if (port >= board_get_usb_pd_port_count()) { - return USB_PD_MUX_NONE; - } + if (port >= board_get_usb_pd_port_count()) + return EC_ERROR_INVAL; /* Perform initialization if not initialized yet */ if (!(flags[port] & USB_MUX_FLAG_INIT)) usb_mux_init(port); - if (flags[port] & USB_MUX_FLAG_IN_LPM) - return USB_PD_MUX_NONE; + if (flags[port] & USB_MUX_FLAG_IN_LPM) { + *mux_state = USB_PD_MUX_NONE; + return EC_SUCCESS; + } - rv = configure_mux(port, USB_MUX_GET_MODE, &mux_state); + return configure_mux(port, USB_MUX_GET_MODE, mux_state); +} + +mux_state_t usb_mux_get(int port) +{ + mux_state_t mux_state; + enum ec_status rv; + + rv = try_usb_mux_get(port, &mux_state); return rv ? USB_PD_MUX_NONE : mux_state; } @@ -718,9 +731,8 @@ static enum ec_status hc_usb_pd_mux_info(struct host_cmd_handler_args *args) if (port >= board_get_usb_pd_port_count()) return EC_RES_INVALID_PARAM; - if (configure_mux(port, USB_MUX_GET_MODE, &mux_state)) + if (try_usb_mux_get(port, &mux_state)) return EC_RES_ERROR; - r->flags = mux_state; /* Clear HPD IRQ event since we're about to inform host of it. */ |