mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
usb: typec: tcpm: allow switching to mode accessory to mux properly
commit 8a50da849151e7e12b43c1d8fe7ad302223aef6b upstream. The funciton tcpm_acc_attach is not setting the proper state when calling tcpm_set_role. The function tcpm_set_role is currently only handling TYPEC_STATE_USB. For the tcpm_acc_attach to switch into other modal states tcpm_set_role needs to be extended by an extra state parameter. This patch is handling the proper state change when calling tcpm_acc_attach. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20250404-ml-topic-tcpm-v1-3-b99f44badce8@pengutronix.de Stable-dep-of: bec15191d523 ("usb: typec: tcpm: apply vbus before data bringup in tcpm_src_attach") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8f65f4565c
commit
457d02e71a
@@ -1041,7 +1041,7 @@ static int tcpm_set_attached_state(struct tcpm_port *port, bool attached)
|
||||
port->data_role);
|
||||
}
|
||||
|
||||
static int tcpm_set_roles(struct tcpm_port *port, bool attached,
|
||||
static int tcpm_set_roles(struct tcpm_port *port, bool attached, int state,
|
||||
enum typec_role role, enum typec_data_role data)
|
||||
{
|
||||
enum typec_orientation orientation;
|
||||
@@ -1078,7 +1078,7 @@ static int tcpm_set_roles(struct tcpm_port *port, bool attached,
|
||||
}
|
||||
}
|
||||
|
||||
ret = tcpm_mux_set(port, TYPEC_STATE_USB, usb_role, orientation);
|
||||
ret = tcpm_mux_set(port, state, usb_role, orientation);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -3622,7 +3622,8 @@ static int tcpm_src_attach(struct tcpm_port *port)
|
||||
|
||||
tcpm_enable_auto_vbus_discharge(port, true);
|
||||
|
||||
ret = tcpm_set_roles(port, true, TYPEC_SOURCE, tcpm_data_role_for_source(port));
|
||||
ret = tcpm_set_roles(port, true, TYPEC_STATE_USB,
|
||||
TYPEC_SOURCE, tcpm_data_role_for_source(port));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -3780,7 +3781,8 @@ static int tcpm_snk_attach(struct tcpm_port *port)
|
||||
|
||||
tcpm_enable_auto_vbus_discharge(port, true);
|
||||
|
||||
ret = tcpm_set_roles(port, true, TYPEC_SINK, tcpm_data_role_for_sink(port));
|
||||
ret = tcpm_set_roles(port, true, TYPEC_STATE_USB,
|
||||
TYPEC_SINK, tcpm_data_role_for_sink(port));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -3804,6 +3806,7 @@ static int tcpm_acc_attach(struct tcpm_port *port)
|
||||
int ret;
|
||||
enum typec_role role;
|
||||
enum typec_data_role data;
|
||||
int state = TYPEC_STATE_USB;
|
||||
|
||||
if (port->attached)
|
||||
return 0;
|
||||
@@ -3812,7 +3815,13 @@ static int tcpm_acc_attach(struct tcpm_port *port)
|
||||
data = tcpm_port_is_sink(port) ? tcpm_data_role_for_sink(port)
|
||||
: tcpm_data_role_for_source(port);
|
||||
|
||||
ret = tcpm_set_roles(port, true, role, data);
|
||||
if (tcpm_port_is_audio(port))
|
||||
state = TYPEC_MODE_AUDIO;
|
||||
|
||||
if (tcpm_port_is_debug(port))
|
||||
state = TYPEC_MODE_DEBUG;
|
||||
|
||||
ret = tcpm_set_roles(port, true, state, role, data);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -4514,7 +4523,7 @@ static void run_state_machine(struct tcpm_port *port)
|
||||
*/
|
||||
tcpm_set_vconn(port, false);
|
||||
tcpm_set_vbus(port, false);
|
||||
tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE,
|
||||
tcpm_set_roles(port, port->self_powered, TYPEC_STATE_USB, TYPEC_SOURCE,
|
||||
tcpm_data_role_for_source(port));
|
||||
/*
|
||||
* If tcpc fails to notify vbus off, TCPM will wait for PD_T_SAFE_0V +
|
||||
@@ -4546,7 +4555,7 @@ static void run_state_machine(struct tcpm_port *port)
|
||||
tcpm_set_vconn(port, false);
|
||||
if (port->pd_capable)
|
||||
tcpm_set_charge(port, false);
|
||||
tcpm_set_roles(port, port->self_powered, TYPEC_SINK,
|
||||
tcpm_set_roles(port, port->self_powered, TYPEC_STATE_USB, TYPEC_SINK,
|
||||
tcpm_data_role_for_sink(port));
|
||||
/*
|
||||
* VBUS may or may not toggle, depending on the adapter.
|
||||
@@ -4652,10 +4661,10 @@ static void run_state_machine(struct tcpm_port *port)
|
||||
case DR_SWAP_CHANGE_DR:
|
||||
tcpm_unregister_altmodes(port);
|
||||
if (port->data_role == TYPEC_HOST)
|
||||
tcpm_set_roles(port, true, port->pwr_role,
|
||||
tcpm_set_roles(port, true, TYPEC_STATE_USB, port->pwr_role,
|
||||
TYPEC_DEVICE);
|
||||
else
|
||||
tcpm_set_roles(port, true, port->pwr_role,
|
||||
tcpm_set_roles(port, true, TYPEC_STATE_USB, port->pwr_role,
|
||||
TYPEC_HOST);
|
||||
tcpm_ams_finish(port);
|
||||
tcpm_set_state(port, ready_state(port), 0);
|
||||
|
||||
Reference in New Issue
Block a user