mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
pd: Refactor exit mode.
Refactor pd_exit_mode to be only a DFP function. Additionally make pe_init a public function and call it during hard reset. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33946 TEST=manual, using pdsetmode from later patches see proper exit and resetting of pe struct. Change-Id: I45afe1f82926f1c32f4d84eb60c65f1f39b19d81 Reviewed-on: https://chromium-review.googlesource.com/236958 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
fdb504e24a
commit
d63c3b4f92
@@ -175,7 +175,7 @@ static struct pd_policy pe[PD_PORT_COUNT];
|
||||
|
||||
#define AMODE_VALID(port) (pe[port].amode.index != -1)
|
||||
|
||||
static void pe_init(int port)
|
||||
void pd_dfp_pe_init(int port)
|
||||
{
|
||||
memset(&pe[port], 0, sizeof(struct pd_policy));
|
||||
pe[port].amode.index = -1;
|
||||
@@ -184,7 +184,7 @@ static void pe_init(int port)
|
||||
static void dfp_consume_identity(int port, uint32_t *payload)
|
||||
{
|
||||
int ptype = PD_IDH_PTYPE(payload[VDO_I(IDH)]);
|
||||
pe_init(port);
|
||||
pd_dfp_pe_init(port);
|
||||
memcpy(&pe[port].identity, payload + 1, sizeof(pe[port].identity));
|
||||
switch (ptype) {
|
||||
case IDH_PTYPE_AMA:
|
||||
@@ -318,7 +318,7 @@ static void dfp_consume_attention(int port, uint32_t *payload)
|
||||
pe[port].amode.fx->attention(port, payload);
|
||||
}
|
||||
|
||||
int pd_exit_mode(int port, uint32_t *payload)
|
||||
uint32_t pd_dfp_exit_mode(int port)
|
||||
{
|
||||
struct svdm_amode_data *modep = &pe[port].amode;
|
||||
if (!modep->fx)
|
||||
@@ -326,11 +326,19 @@ int pd_exit_mode(int port, uint32_t *payload)
|
||||
|
||||
modep->fx->exit(port);
|
||||
|
||||
if (payload)
|
||||
payload[0] = VDO(modep->fx->svid, 1,
|
||||
CMD_EXIT_MODE | VDO_OPOS(pd_alt_mode(port)));
|
||||
modep->index = -1;
|
||||
return 1;
|
||||
/*
|
||||
* TODO(crosbug.com/p/33946) : below needs revisited to allow multiple
|
||||
* mode entry. Additionally it should honor OPOS == 7 as DFP's request
|
||||
* to exit all modes.
|
||||
*/
|
||||
if (pd_is_connected(port)) {
|
||||
modep->index = -1;
|
||||
return VDO(modep->fx->svid, 1,
|
||||
(CMD_EXIT_MODE | VDO_OPOS(pd_alt_mode(port))));
|
||||
} else {
|
||||
pd_dfp_pe_init(port);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CMD_USB_PD_PE
|
||||
@@ -578,16 +586,6 @@ void pd_usb_billboard_deferred(void)
|
||||
}
|
||||
DECLARE_DEFERRED(pd_usb_billboard_deferred);
|
||||
|
||||
#ifndef CONFIG_USB_PD_ALT_MODE_DFP
|
||||
int pd_exit_mode(int port, uint32_t *payload)
|
||||
{
|
||||
#ifdef CONFIG_USB_PD_ALT_MODE
|
||||
svdm_rsp.exit_mode(port, payload);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif /* !CONFIG_USB_PD_ALT_MODE_DFP */
|
||||
|
||||
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
|
||||
static int hc_remote_pd_discovery(struct host_cmd_handler_args *args)
|
||||
{
|
||||
|
||||
@@ -369,7 +369,9 @@ static inline void set_state(int port, enum pd_states next_state)
|
||||
#endif
|
||||
pd[port].dev_id = 0;
|
||||
pd[port].flags &= ~PD_FLAGS_RESET_ON_DISCONNECT_MASK;
|
||||
pd_exit_mode(port, NULL);
|
||||
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
|
||||
pd_dfp_exit_mode(port);
|
||||
#endif
|
||||
#ifdef CONFIG_USBC_SS_MUX
|
||||
board_set_usb_mux(port, TYPEC_MUX_NONE,
|
||||
pd[port].polarity);
|
||||
@@ -784,7 +786,10 @@ static void execute_hard_reset(int port)
|
||||
CPRINTF("HARD RESET (RECV)!\n");
|
||||
|
||||
pd[port].msg_id = 0;
|
||||
pd_exit_mode(port, NULL);
|
||||
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
|
||||
pd_dfp_exit_mode(port);
|
||||
pd_dfp_pe_init(port);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_PD_DUAL_ROLE
|
||||
if (pd[port].power_role == PD_ROLE_SINK) {
|
||||
|
||||
@@ -892,13 +892,19 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload);
|
||||
int pd_custom_flash_vdm(int port, int cnt, uint32_t *payload);
|
||||
|
||||
/**
|
||||
* Exit alternate mode
|
||||
* Exit alternate mode on DFP
|
||||
*
|
||||
* @param port USB-C port number
|
||||
* @param payload payload data.
|
||||
* @return if >0, number of VDOs to send back.
|
||||
* @return VDO to send to UFP or zero if none
|
||||
*/
|
||||
int pd_exit_mode(int port, uint32_t *payload);
|
||||
uint32_t pd_dfp_exit_mode(int port);
|
||||
|
||||
/**
|
||||
* Initialize policy engine for DFP
|
||||
*
|
||||
* @param port USB-C port number
|
||||
*/
|
||||
void pd_dfp_pe_init(int port);
|
||||
|
||||
/**
|
||||
* Store Device ID & RW hash of device
|
||||
|
||||
Reference in New Issue
Block a user