summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2019-10-11 16:46:01 -0600
committerCommit Bot <commit-bot@chromium.org>2019-10-15 22:23:11 +0000
commit246e451f5229a392bbcded28eaa16c8c47c4d5d1 (patch)
treeb11f75dcf1da3f760d6a1d77378282474c2cda8d
parent5a649192d901cdf099ac77d81791cdf647f97d52 (diff)
downloadchrome-ec-246e451f5229a392bbcded28eaa16c8c47c4d5d1.tar.gz
usbc: remove evt_timeout from struct type_c
Simplify the pd_task loop timeout by making it a fixed 5 milliseconds. If there is nothing to do then it shouldn't take long to realize this. This allows removal of evt_timeout, tc_set_timeout, tc_get_timeout. BRANCH=none BUG=none TEST=usbc unit tests (make -j runhosttests) Change-Id: I067309b191e5118fbe9e89a92a650fa837fb75fa Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1857216 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c7
-rw-r--r--common/usbc/usb_tc_ctvpd_sm.c24
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c13
-rw-r--r--common/usbc/usb_tc_vpd_sm.c13
-rw-r--r--common/usbc/usbc_task.c4
-rw-r--r--include/usb_tc_sm.h16
6 files changed, 3 insertions, 74 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 8bbece96e3..cf72a11967 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -1325,7 +1325,6 @@ static void pe_src_ready_entry(int port)
/* NOTE: PPS Implementation should be added here. */
- tc_set_timeout(port, 5 * MSEC);
}
static void pe_src_ready_run(int port)
@@ -1501,8 +1500,6 @@ static void pe_src_ready_exit(int port)
*/
if (!PE_CHK_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS))
prl_start_ams(port);
-
- tc_set_timeout(port, 2 * MSEC);
}
/**
@@ -2004,8 +2001,6 @@ static void pe_snk_ready_entry(int port)
* 1) Initialize and run the SinkPPSPeriodicTimer.
* NOTE: PPS Implementation should be added here.
*/
-
- tc_set_timeout(port, 5 * MSEC);
}
static void pe_snk_ready_run(int port)
@@ -2183,8 +2178,6 @@ static void pe_snk_ready_exit(int port)
{
if (!PE_CHK_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS))
prl_start_ams(port);
-
- tc_set_timeout(port, 2 * MSEC);
}
/**
diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c
index 33f1253e27..2c9dd611c5 100644
--- a/common/usbc/usb_tc_ctvpd_sm.c
+++ b/common/usbc/usb_tc_ctvpd_sm.c
@@ -45,8 +45,6 @@ static struct type_c {
uint8_t data_role;
/* Higher-level power deliver state machines are enabled if true. */
uint8_t pd_enable;
- /* event timeout */
- uint64_t evt_timeout;
/* port flags, see TC_FLAGS_* */
uint32_t flags;
/*
@@ -169,16 +167,6 @@ void tc_set_power_role(int port, int role)
tc[port].power_role = role;
}
-uint64_t tc_get_timeout(int port)
-{
- return tc[port].evt_timeout;
-}
-
-void tc_set_timeout(int port, uint64_t timeout)
-{
- tc[port].evt_timeout = timeout;
-}
-
void tc_reset_support_timer(int port)
{
tc[port].support_timer_reset |= SUPPORT_TIMER_RESET_REQUEST;
@@ -197,7 +185,6 @@ void tc_state_init(int port)
/* Disable pd state machines */
tc[port].pd_enable = 0;
- tc[port].evt_timeout = 10*MSEC;
tc[port].power_role = PD_PLUG_CABLE_VPD;
tc[port].data_role = 0; /* Reserved for VPD */
tc[port].billboard_presented = 0;
@@ -450,9 +437,6 @@ static void tc_attached_snk_entry(const int port)
/* Start Charge-Through support timer */
tc[port].support_timer_reset = SUPPORT_TIMER_RESET_INIT;
tc[port].support_timer = get_time().val + PD_T_AME;
-
- /* Sample host CC every 2ms */
- tc_set_timeout(port, 2*MSEC);
}
static void tc_attached_snk_run(const int port)
@@ -528,8 +512,6 @@ static void tc_attached_snk_run(const int port)
static void tc_attached_snk_exit(const int port)
{
- /* Reset timeout value to 10ms */
- tc_set_timeout(port, 10*MSEC);
tc[port].billboard_presented = 0;
vpd_present_billboard(BB_NONE);
}
@@ -1405,9 +1387,6 @@ static void tc_ct_attach_wait_vpd_entry(const int port)
set_polarity(port, 0);
tc[port].cc_state = PD_CC_UNSET;
-
- /* Sample CCs every 2ms */
- tc_set_timeout(port, 2 * MSEC);
}
static void tc_ct_attach_wait_vpd_run(const int port)
@@ -1478,9 +1457,6 @@ static void tc_ct_attach_wait_vpd_exit(const int port)
{
/* Disable PD */
tc[port].pd_enable = 0;
-
- /* Reset timeout value to 10ms */
- tc_set_timeout(port, 10 * MSEC);
}
/**
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 54e95820ed..6e5b1c67d1 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -134,8 +134,6 @@ static struct type_c {
uint8_t polarity;
/* port flags, see TC_FLAGS_* */
uint32_t flags;
- /* event timeout */
- uint64_t evt_timeout;
/* Role toggle timer */
uint64_t next_role_swap;
/* Generic timer */
@@ -668,7 +666,6 @@ static void restart_tc_sm(int port, enum usb_tc_state start_state)
}
tc[port].flags = 0;
- tc[port].evt_timeout = 5*MSEC;
#ifdef CONFIG_USB_PE_SM
tc[port].pd_enable = 0;
@@ -707,16 +704,6 @@ void tc_set_power_role(int port, int role)
tc[port].power_role = role;
}
-uint64_t tc_get_timeout(int port)
-{
- return tc[port].evt_timeout;
-}
-
-void tc_set_timeout(int port, uint64_t timeout)
-{
- tc[port].evt_timeout = timeout;
-}
-
/*
* Private Functions
*/
diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c
index 479701d6b8..51847aa23c 100644
--- a/common/usbc/usb_tc_vpd_sm.c
+++ b/common/usbc/usb_tc_vpd_sm.c
@@ -39,8 +39,6 @@ static struct type_c {
uint8_t data_role;
/* Higher-level power deliver state machines are enabled if true. */
uint8_t pd_enable;
- /* event timeout */
- uint64_t evt_timeout;
/* port flags, see TC_FLAGS_* */
uint32_t flags;
/* Time a port shall wait before it can determine it is attached */
@@ -95,7 +93,6 @@ void tc_state_init(int port)
/* Disable pd state machines */
tc[port].pd_enable = 0;
- tc[port].evt_timeout = 10*MSEC;
tc[port].power_role = PD_PLUG_CABLE_VPD;
tc[port].data_role = 0; /* Reserved for VPD */
tc[port].flags = 0;
@@ -128,16 +125,6 @@ void tc_set_power_role(int port, int role)
tc[port].power_role = role;
}
-uint64_t tc_get_timeout(int port)
-{
- return tc[port].evt_timeout;
-}
-
-void tc_set_timeout(int port, uint64_t timeout)
-{
- tc[port].evt_timeout = timeout;
-}
-
void tc_event_check(int port, int evt)
{
/* Do Nothing */
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c
index f34bdee088..48c53af3d2 100644
--- a/common/usbc/usbc_task.c
+++ b/common/usbc/usbc_task.c
@@ -32,6 +32,8 @@
#include "usbc_ppc.h"
#include "version.h"
+#define USBC_EVENT_TIMEOUT (5 * MSEC)
+
int tc_restart_tcpc(int port)
{
return tcpm_init(port);
@@ -162,7 +164,7 @@ void pd_task(void *u)
while (1) {
/* wait for next event/packet or timeout expiration */
- const uint32_t evt = task_wait_event(tc_get_timeout(port));
+ const uint32_t evt = task_wait_event(USBC_EVENT_TIMEOUT);
/* handle events that affect the state machine as a whole */
tc_event_check(port, evt);
diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h
index 38fbe270a0..d8a68b08d3 100644
--- a/include/usb_tc_sm.h
+++ b/include/usb_tc_sm.h
@@ -107,14 +107,6 @@ void tc_set_data_role(int port, int role);
void set_usb_mux_with_current_data_role(int port);
/**
- * Get loop timeout value
- *
- * @param port USB-C port number
- * @return time in ms
- */
-uint64_t tc_get_timeout(int port);
-
-/**
* Policy Engine informs the Type-C state machine if the port partner
* is dualrole power.
*
@@ -160,14 +152,6 @@ void tc_partner_dr_data(int port, int en);
void tc_pd_connection(int port, int en);
/**
- * Set loop timeout value
- *
- * @param port USB-C port number
- * @timeout time in ms
- */
-void tc_set_timeout(int port, uint64_t timeout);
-
-/**
* Initiates a Power Role Swap from Attached.SRC to Attached.SNK. This function
* has no effect if the current Type-C state is not Attached.SRC.
*