Skip to content

Commit 1beecfe

Browse files
superna9999andersson
authored andcommitted
soc: qcom: pmic_glink_altmode: handle safe mode when disconnect
On some Qcom SoCs, the Altmode event mode is set to 0xff when the Type-C port is disconnected. Handle this specific mode and translate it as the SAFE mode. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20230601-topic-sm8550-upstream-type-c-v5-1-9221cd300903@linaro.org Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 668e08c commit 1beecfe

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

drivers/soc/qcom/pmic_glink_altmode.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,30 @@ static void pmic_glink_altmode_enable_usb(struct pmic_glink_altmode *altmode,
174174
dev_err(altmode->dev, "failed to switch mux to USB\n");
175175
}
176176

177+
static void pmic_glink_altmode_safe(struct pmic_glink_altmode *altmode,
178+
struct pmic_glink_altmode_port *port)
179+
{
180+
int ret;
181+
182+
port->state.alt = NULL;
183+
port->state.data = NULL;
184+
port->state.mode = TYPEC_STATE_SAFE;
185+
186+
ret = typec_mux_set(port->typec_mux, &port->state);
187+
if (ret)
188+
dev_err(altmode->dev, "failed to switch mux to safe mode\n");
189+
}
190+
177191
static void pmic_glink_altmode_worker(struct work_struct *work)
178192
{
179193
struct pmic_glink_altmode_port *alt_port = work_to_altmode_port(work);
180194
struct pmic_glink_altmode *altmode = alt_port->altmode;
181195

182196
typec_switch_set(alt_port->typec_switch, alt_port->orientation);
183197

184-
if (alt_port->svid == USB_TYPEC_DP_SID)
198+
if (alt_port->svid == USB_TYPEC_DP_SID && alt_port->mode == 0xff)
199+
pmic_glink_altmode_safe(altmode, alt_port);
200+
else if (alt_port->svid == USB_TYPEC_DP_SID)
185201
pmic_glink_altmode_enable_dp(altmode, alt_port, alt_port->mode,
186202
alt_port->hpd_state, alt_port->hpd_irq);
187203
else

0 commit comments

Comments
 (0)