diff options
author | Jett Rink <jettrink@chromium.org> | 2019-08-02 16:20:50 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-20 15:53:16 +0000 |
commit | 2a7996a3caf25d358164a48e80723758e8be1fd1 (patch) | |
tree | a6dd0682b7ab1c3cc408450137e5f10988cf9da7 /include/usb_prl_sm.h | |
parent | a1aea89ae15c85d56f52976289a329e7c58bc8f6 (diff) | |
download | chrome-ec-2a7996a3caf25d358164a48e80723758e8be1fd1.tar.gz |
usb: update state machine framework
- OBJ is renamed to context (CTX) for current and last state
- State definition now includes its parent (no need for the boiler
plate function that takes in a signal)
- The init_state, set_state, and exe_state have been re-written to take
advantages of new state machine definition. I had to add more logic to
handle hierarchical states fully.
- Explicitly create the USB states at the bottom of the file with all
of the statics. Don't need to use macros (even though I did suggest them)
- Use NULL when we do_nothing instead of calling into a function
- Created a "private" enum in the C file that lists all of the states
in the file, that we can use to refer to a state (it is also the
index into the states array for that state).
- Changed prototype of state function to return void, since we aren't
really using the return value and it cleans up a lot of return 0 that
aren't needed.
- Add const to int port since we can and should
- Moves struct definition to implementation file only to keep
implementation details private. We can access data through accessor if
needed.
BRANCH=none
BUG=none
TEST=all unit tests passes
Change-Id: I482a63e08f7d63022d5102b891a2fac0b0faa46f
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1733744
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'include/usb_prl_sm.h')
-rw-r--r-- | include/usb_prl_sm.h | 108 |
1 files changed, 1 insertions, 107 deletions
diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h index 28f3a44078..4116bbe1a3 100644 --- a/include/usb_prl_sm.h +++ b/include/usb_prl_sm.h @@ -11,58 +11,6 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" -enum prl_tx_state_id { - PRL_TX_PHY_LAYER_RESET, - PRL_TX_WAIT_FOR_MESSAGE_REQUEST, - PRL_TX_LAYER_RESET_FOR_TRANSMIT, - PRL_TX_CONSTRUCT_MESSAGE, - PRL_TX_WAIT_FOR_PHY_RESPONSE, - PRL_TX_MATCH_MESSAGE_ID, - PRL_TX_MESSAGE_SENT, - PRL_TX_CHECK_RETRY_COUNTER, - PRL_TX_TRANSMISSION_ERROR, - PRL_TX_DISCARD_MESSAGE, - - PRL_TX_SRC_SINK_TX, - PRL_TX_SRC_SOURCE_TX, - PRL_TX_SRC_PENDING, - - PRL_TX_SNK_START_OF_AMS, - PRL_TX_SNK_PENDING, -}; - -enum prl_hr_state_id { - PRL_HR_WAIT_FOR_REQUEST, - PRL_HR_RESET_LAYER, - PRL_HR_INDICATE_HARD_RESET, - PRL_HR_WAIT_FOR_PHY_HARD_RESET_COMPLETE, - PRL_HR_PHY_HARD_RESET_REQUESTED, - PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE, - PRL_HR_PE_HARD_RESET_COMPLETE, -}; - -enum rch_state_id { - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER, - RCH_PASS_UP_MESSAGE, - RCH_PROCESSING_EXTENDED_MESSAGE, - RCH_REQUESTING_CHUNK, - RCH_WAITING_CHUNK, - RCH_REPORT_ERROR, -}; - -enum tch_state_id { - TCH_WAIT_FOR_MESSAGE_REQUEST_FROM_PE, - TCH_PASS_DOWN_MESSAGE, - TCH_WAIT_FOR_TRANSMISSION_COMPLETE, - TCH_MESSAGE_SENT, - TCH_PREPARE_TO_SEND_CHUNKED_MESSAGE, - TCH_CONSTRUCT_CHUNKED_MESSAGE, - TCH_SENDING_CHUNKED_MESSAGE, - TCH_WAIT_CHUNK_REQUEST, - TCH_MESSAGE_RECEIVED, - TCH_REPORT_ERROR, -}; - /* * Number of times the Protocol Layer will try to transmit a message * before giving up and signaling an error @@ -70,67 +18,13 @@ enum tch_state_id { #define N_RETRY_COUNT 2 /** - * Initialize the Protocol Layer State Machine - * - * @param port USB-C port number - */ -void prl_init(int port); - -/** - * Resets the Protocol Layer State Machine - * - * @param port USB-C port number - */ -void prl_reset(int port); - -/** - * Get Chunked Rx State Machine state id - * - * @param port USB-C port number - * @return id - */ -enum rch_state_id get_rch_state_id(int port); - -/** - * Get Chunked Tx State Machine state id - * - * @param port USB-C port number - * @return id - */ -enum tch_state_id get_tch_state_id(int port); - -/** - * Get Message Transmission State Machine state id - * - * @param port USB-C port number - * @return id - */ -enum prl_tx_state_id get_prl_tx_state_id(int port); - -/** - * Get Hard Reset State Machine state id - * - * @param port USB-C port number - * @return id - */ -enum prl_hr_state_id get_prl_hr_state_id(int port); - -/** - * Returns the state of the PRL state machine - * @return SM_INIT for initializing - * SM_RUN for running - * SM_PAUSED for paused - */ -enum sm_local_state prl_get_local_state(int port); - -/** * Runs the Protocol Layer State Machine * * @param port USB-C port number * @param evt system event, ie: PD_EVENT_RX * @param en 0 to disable the machine, 1 to enable the machine */ -void usbc_protocol_layer(int port, int evt, int en); +void prl_run(int port, int evt, int en); /** * Set the PD revision |