diff options
author | Sam Hurst <shurst@google.com> | 2019-05-22 14:13:40 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-05 21:43:03 +0000 |
commit | d76c396bf65e912c2aa2ca1e905daa74996cdb27 (patch) | |
tree | c34654adeebeb793d548215c2eaf6f4f4ba3bdfe /common/usb_tc_sm.c | |
parent | 184701a33a0f77dfbe38d231d05741db1f8ddbc6 (diff) | |
download | chrome-ec-d76c396bf65e912c2aa2ca1e905daa74996cdb27.tar.gz |
chocodile_vpdmcu: Firmware refactoring
Move code in header files into c source files.
BUG=b:133341676
BRANCH=none
TEST=manual
Charge-Through was tested on an Atlas running a DRP USB-C/PD state
machine with CTUnattached.SNK and CTAttached.SNK states.
Change-Id: Ib1b51a778b937e02908f0bc8866bc91a39831163
Signed-off-by: Sam Hurst <shurst@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1626036
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Diffstat (limited to 'common/usb_tc_sm.c')
-rw-r--r-- | common/usb_tc_sm.c | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/common/usb_tc_sm.c b/common/usb_tc_sm.c index 4f7039a546..68912b0c63 100644 --- a/common/usb_tc_sm.c +++ b/common/usb_tc_sm.c @@ -23,7 +23,6 @@ #include "usb_charge.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_tcpm.h" #include "usb_prl_sm.h" #include "tcpm.h" #include "usb_pe_sm.h" @@ -32,23 +31,25 @@ #include "usb_tc_sm.h" #include "version.h" +/* Include USB Type-C State Machine Header File */ +#if defined(CONFIG_USB_TYPEC_CTVPD) +#include "usb_tc_ctvpd_sm.h" +#elif defined(CONFIG_USB_TYPEC_VPD) +#include "usb_tc_vpd_sm.h" +#else +#error "A USB Type-C State Machine must be defined." +#endif + #ifdef CONFIG_COMMON_RUNTIME -#define CPRINTF(format, args...) cprintf(CC_HOOK, format, ## args) -#define CPRINTS(format, args...) cprints(CC_HOOK, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_USB, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USB, format, ## args) #else /* CONFIG_COMMON_RUNTIME */ #define CPRINTF(format, args...) #define CPRINTS(format, args...) #endif -/* Private Function Prototypes */ - -static inline int cc_is_rp(int cc); -static inline enum pd_cc_polarity_type get_snk_polarity(int cc1, int cc2); -static int tc_restart_tcpc(int port); -static void set_polarity(int port, int polarity); - #ifdef CONFIG_COMMON_RUNTIME -static const char * const tc_state_names[] = { +const char * const tc_state_names[] = { "Disabled", "Unattached.SNK", "AttachWait.SNK", @@ -85,15 +86,6 @@ static const char * const tc_state_names[] = { BUILD_ASSERT(ARRAY_SIZE(tc_state_names) == TC_STATE_COUNT); #endif -/* Include USB Type-C State Machine */ -#if defined(CONFIG_USB_TYPEC_CTVPD) -#include "usb_tc_ctvpd_sm.h" -#elif defined(CONFIG_USB_TYPEC_VPD) -#include "usb_tc_vpd_sm.h" -#else -#error "A USB Type-C State Machine must be defined." -#endif - /* Public Functions */ int tc_get_power_role(int port) @@ -116,8 +108,6 @@ enum typec_state_id get_typec_state_id(int port) return tc[port].state_id; } -/* Private Functions */ - /* * CC values for regular sources and Debug sources (aka DTS) * @@ -131,10 +121,7 @@ enum typec_state_id get_typec_state_id(int port) * DTS USB-C @ 3 A Rp3A0 RpUSB */ -/** - * Returns the polarity of a Sink. - */ -static inline enum pd_cc_polarity_type get_snk_polarity(int cc1, int cc2) +inline enum pd_cc_polarity_type get_snk_polarity(int cc1, int cc2) { /* the following assumes: * TYPEC_CC_VOLT_RP_3_0 > TYPEC_CC_VOLT_RP_1_5 @@ -144,12 +131,12 @@ static inline enum pd_cc_polarity_type get_snk_polarity(int cc1, int cc2) return (cc2 > cc1) ? POLARITY_CC2 : POLARITY_CC1; } -static int tc_restart_tcpc(int port) +int tc_restart_tcpc(int port) { return tcpm_init(port); } -static void set_polarity(int port, int polarity) +void set_polarity(int port, int polarity) { tcpm_set_polarity(port, polarity); #ifdef CONFIG_USBC_PPC_POLARITY |