diff options
Diffstat (limited to 'common/usbc_ppc.c')
-rw-r--r-- | common/usbc_ppc.c | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/common/usbc_ppc.c b/common/usbc_ppc.c index 73dbf9d1c0..0281ceaf64 100644 --- a/common/usbc_ppc.c +++ b/common/usbc_ppc.c @@ -40,16 +40,6 @@ int ppc_err_prints(const char *string, int port, int error) #endif } -/* - * A per-port table that indicates how many VBUS overcurrent events have - * occurred. This table is cleared after detecting a physical disconnect of the - * sink. - */ -static uint8_t oc_event_cnt_tbl[CONFIG_USB_PD_PORT_MAX_COUNT]; - -/* A flag for ports with sink device connected. */ -static uint32_t snk_connected_ports; - /* Simple wrappers to dispatch to the drivers. */ int ppc_init(int port) @@ -74,63 +64,6 @@ int ppc_init(int port) return rv; } -int ppc_add_oc_event(int port) -{ - if ((port < 0) || (port >= ppc_cnt)) { - CPRINTS("%s(%d) Invalid port!", __func__, port); - return EC_ERROR_INVAL; - } - - oc_event_cnt_tbl[port]++; - - /* The port overcurrented, so don't clear it's OC events. */ - atomic_clear_bits(&snk_connected_ports, 1 << port); - - if (oc_event_cnt_tbl[port] >= PPC_OC_CNT_THRESH) - ppc_prints("OC event limit reached! " - "Source path disabled until physical disconnect.", - port); - return EC_SUCCESS; -} - -static void clear_oc_tbl(void) -{ - int port; - - for (port = 0; port < ppc_cnt; port++) - /* - * Only clear the table if the port partner is no longer - * attached after debouncing. - */ - if ((!(BIT(port) & snk_connected_ports)) && - oc_event_cnt_tbl[port]) { - oc_event_cnt_tbl[port] = 0; - ppc_prints("OC events cleared", port); - } -} -DECLARE_DEFERRED(clear_oc_tbl); - -int ppc_clear_oc_event_counter(int port) -{ - if ((port < 0) || (port >= ppc_cnt)) { - CPRINTS("%s(%d) Invalid port!", __func__, port); - return EC_ERROR_INVAL; - } - - /* - * If we are clearing our event table in quick succession, we may be in - * an overcurrent loop where we are also detecting a disconnect on the - * CC pins. Therefore, let's not clear it just yet and the let the - * limit be reached. This way, we won't send the hard reset and - * actually detect the physical disconnect. - */ - if (oc_event_cnt_tbl[port]) { - hook_call_deferred(&clear_oc_tbl_data, - PPC_OC_COOLDOWN_DELAY_US); - } - return EC_SUCCESS; -} - int ppc_is_sourcing_vbus(int port) { int rv = 0; @@ -201,16 +134,6 @@ int ppc_discharge_vbus(int port, int enable) return rv; } -int ppc_is_port_latched_off(int port) -{ - if ((port < 0) || (port >= ppc_cnt)) { - CPRINTS("%s(%d) Invalid port!", __func__, port); - return 0; - } - - return oc_event_cnt_tbl[port] >= PPC_OC_CNT_THRESH; -} - #ifdef CONFIG_USBC_PPC_SBU int ppc_set_sbu(int port, int enable) { @@ -241,15 +164,6 @@ int ppc_set_vconn(int port, int enable) return EC_ERROR_INVAL; } - /* - * Check our OC event counter. If we've exceeded our threshold, then - * let's latch our source path off to prevent continuous cycling. When - * the PD state machine detects a disconnection on the CC lines, we will - * reset our OC event counter. - */ - if (enable && ppc_is_port_latched_off(port)) - return EC_ERROR_ACCESS_DENIED; - ppc = &ppc_chips[port]; if (ppc->drv->set_vconn) rv = ppc->drv->set_vconn(port, enable); @@ -268,12 +182,6 @@ int ppc_dev_is_connected(int port, enum ppc_device_role dev) return EC_ERROR_INVAL; } - if (dev == PPC_DEV_SNK) - atomic_or(&snk_connected_ports, 1 << port); - else - /* clear flag if it transitions to SRC or disconnected */ - atomic_clear_bits(&snk_connected_ports, 1 << port); - ppc = &ppc_chips[port]; if (ppc->drv->dev_is_connected) rv = ppc->drv->dev_is_connected(port, dev); @@ -325,15 +233,6 @@ int ppc_vbus_source_enable(int port, int enable) return EC_ERROR_INVAL; } - /* - * Check our OC event counter. If we've exceeded our threshold, then - * let's latch our source path off to prevent continuous cycling. When - * the PD state machine detects a disconnection on the CC lines, we will - * reset our OC event counter. - */ - if (enable && ppc_is_port_latched_off(port)) - return EC_ERROR_ACCESS_DENIED; - ppc = &ppc_chips[port]; if (ppc->drv->vbus_source_enable) rv = ppc->drv->vbus_source_enable(port, enable); |