usb_c: Fix DPM request handlers
Processing the common DPM request handler in the Sink DPM request handler. Signed-off-by: Sam Hurst <sbh1187@gmail.com>
This commit is contained in:
parent
f04da7f7ab
commit
c27a3a31d3
3 changed files with 26 additions and 10 deletions
|
@ -21,7 +21,7 @@ static const struct smf_state pe_states[];
|
|||
/**
|
||||
* @brief Handle common DPM requests
|
||||
*
|
||||
* @retval True if the request was handled, else False
|
||||
* @retval true if request was handled, else false
|
||||
*/
|
||||
bool common_dpm_requests(const struct device *dev)
|
||||
{
|
||||
|
@ -33,10 +33,11 @@ bool common_dpm_requests(const struct device *dev)
|
|||
|
||||
if (pe->dpm_request == REQUEST_PE_DR_SWAP) {
|
||||
pe_set_state(dev, PE_DRS_SEND_SWAP);
|
||||
return true;
|
||||
} else if (pe->dpm_request == REQUEST_PE_SOFT_RESET_SEND) {
|
||||
pe_set_state(dev, PE_SEND_SOFT_RESET);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -143,6 +144,9 @@ void pe_run(const struct device *dev, const int32_t dpm_request)
|
|||
break;
|
||||
}
|
||||
|
||||
/* Get any DPM Requests */
|
||||
pe->dpm_request = dpm_request;
|
||||
|
||||
/*
|
||||
* 8.3.3.3.8 PE_SNK_Hard_Reset State
|
||||
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset
|
||||
|
@ -151,14 +155,11 @@ void pe_run(const struct device *dev, const int32_t dpm_request)
|
|||
*/
|
||||
if (dpm_request == REQUEST_PE_HARD_RESET_SEND) {
|
||||
pe_set_state(dev, PE_SNK_HARD_RESET);
|
||||
} else {
|
||||
/* Pass the DPM request along to the state machine */
|
||||
pe->dpm_request = dpm_request;
|
||||
common_dpm_requests(dev);
|
||||
}
|
||||
|
||||
/* Run state machine */
|
||||
smf_run_state(SMF_CTX(pe));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,4 +310,12 @@ bool policy_is_snk_at_default(const struct device *dev);
|
|||
*/
|
||||
void policy_get_snk_cap(const struct device *dev, uint32_t **pdos, int *num_pdos);
|
||||
|
||||
/**
|
||||
* @brief Handle common DPM requests
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @retval true if request was handled, else false
|
||||
*/
|
||||
bool common_dpm_requests(const struct device *dev);
|
||||
|
||||
#endif /* ZEPHYR_SUBSYS_USBC_PE_COMMON_INTERNAL_H_ */
|
||||
|
|
|
@ -18,21 +18,28 @@ LOG_MODULE_DECLARE(usbc_stack, CONFIG_USBC_STACK_LOG_LEVEL);
|
|||
/**
|
||||
* @brief Handle sink-specific DPM requests
|
||||
*/
|
||||
bool sink_dpm_requests(const struct device *dev)
|
||||
void sink_dpm_requests(const struct device *dev)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct policy_engine *pe = data->pe;
|
||||
|
||||
/*
|
||||
* Handle any common DPM Requests
|
||||
*/
|
||||
if (common_dpm_requests(dev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle Sink DPM Requests
|
||||
*/
|
||||
if (pe->dpm_request > REQUEST_TC_END) {
|
||||
atomic_set_bit(pe->flags, PE_FLAGS_DPM_INITIATED_AMS);
|
||||
|
||||
if (pe->dpm_request == REQUEST_PE_GET_SRC_CAPS) {
|
||||
pe_set_state(dev, PE_SNK_GET_SOURCE_CAP);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue