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 /include/usb_tc_sm.h | |
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 'include/usb_tc_sm.h')
-rw-r--r-- | include/usb_tc_sm.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h index 08e9ebbf54..4a2af0fa6f 100644 --- a/include/usb_tc_sm.h +++ b/include/usb_tc_sm.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_USB_TC_H #define __CROS_EC_USB_TC_H +#include "usb_sm.h" + enum typec_state_id { DISABLED, UNATTACHED_SNK, @@ -45,6 +47,34 @@ enum typec_state_id { TC_STATE_COUNT, }; +extern const char * const tc_state_names[]; + +#define TC_SET_FLAG(port, flag) atomic_or(&tc[port].flags, (flag)) +#define TC_CLR_FLAG(port, flag) atomic_clear(&tc[port].flags, (flag)) +#define TC_CHK_FLAG(port, flag) (tc[port].flags & (flag)) + +/* + * TC_OBJ is a convenience macro to access struct sm_obj, which + * must be the first member of struct type_c. + */ +#define TC_OBJ(port) (SM_OBJ(tc[port])) + +/* + * Type C supply voltage (mV) + * + * This is the maximum voltage a sink can request + * while charging. + */ +#define TYPE_C_VOLTAGE 5000 /* mV */ + +/* + * Type C default sink current (mA) + * + * This is the maximum current a sink can draw if charging + * while in the Audio Accessory State. + */ +#define TYPE_C_AUDIO_ACC_CURRENT 500 /* mA */ + /** * Get the id of the current Type-C state * @@ -76,6 +106,48 @@ int tc_get_power_role(int port); */ void tc_set_timeout(int port, uint64_t timeout); +/** + * Returns the polarity of a Sink. + * + * @param cc1 value of CC1 set by tcpm_get_cc + * @param cc2 value of CC2 set by tcpm_get_cc + * @return 0 if cc1 is connected, else 1 for cc2 + */ +enum pd_cc_polarity_type get_snk_polarity(int cc1, int cc2); + +/** + * Restarts the TCPC + * + * @param port USB-C port number + * @returns EC_SUCCESS on success + */ +int tc_restart_tcpc(int port); + +/** + * Sets the polarity of the port + * + * @param port USB-C port number + * @param polarity 0 for CC1, else 1 for CC2 + */ +void set_polarity(int port, int polarity); + +/** + * Called by the state machine framework to initialize the + * TypeC state machine + * + * @param port USB-C port number + */ +void tc_state_init(int port); + +/** + * Called by the state machine framework to handle events + * that affect the state machine as a whole + * + * @param port USB-C port number + * @param evt event + */ +void tc_event_check(int port, int evt); + #ifdef CONFIG_USB_TYPEC_CTVPD /** * Resets the charge-through support timer. This can be |