Skip to content
Snippets Groups Projects
Commit cf718326 authored by Ke Du's avatar Ke Du
Browse files

extcon: lt8711uxe2: fix usb role issue when usb cable disconnect


Currently usb role only can be set device mode and host mode,
if remove usb cable, usb role is still device mode, this is
incorrect.

Through connected state, host_mode and device_mode value to set
usb role, can help fix usb suspend issue.

Change-Id: I6958e3e107db243ea5135c25d3c721b22e8f31ec
Signed-off-by: default avatarKe Du <quic_kedu@quicinc.com>
parent dc6ac79f
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,6 @@ struct lt8711uxe2 {
u32 cc_finished_gpio;
int cc_irq;
bool usb_role;
bool is_cc_finished;
};
......@@ -1131,6 +1130,9 @@ static void lt8711uxe2_check_state(struct lt8711uxe2 *pdata)
union extcon_property_value flip;
union extcon_property_value ss_func;
u8 flip_reg_val = 0;
bool host_mode = false;
bool device_mode = false;
bool connected = false;
bool flipped = false;
unsigned int extcon_id = EXTCON_NONE;
u32 dp_lane = gpio_get_value(pdata->dp_lane_sel_gpio);
......@@ -1146,16 +1148,23 @@ static void lt8711uxe2_check_state(struct lt8711uxe2 *pdata)
switch (data_role) {
case LT8711UXE2_DISCONNECTED:
pr_debug("%s LT8711UXE2_DISCONNECTED\n", __func__);
host_mode = false;
device_mode = false;
connected = false;
break;
case LT8711UXE2_DFP_ATTACHED:
pr_debug("%s LT8711UXE2_DFP_ATTACH (device mode)\n", __func__);
extcon_id = EXTCON_USB;
pdata->usb_role = false;
host_mode = false;
device_mode = true;
connected = true;
break;
case LT8711UXE2_UFP_ATTACHED:
pr_debug("%s LT8711UXE2_UFP_ATTACH (host mode)\n", __func__);
extcon_id = EXTCON_USB_HOST;
pdata->usb_role = true;
host_mode = true;
device_mode = false;
connected = true;
break;
default:
dev_err(pdata->dev, "Unknown state: %#x\n", data_role);
......@@ -1168,8 +1177,9 @@ static void lt8711uxe2_check_state(struct lt8711uxe2 *pdata)
return;
}
extcon_set_state(pdata->edev, EXTCON_USB_HOST, pdata->usb_role);
extcon_set_state(pdata->edev, EXTCON_USB, !pdata->usb_role);
extcon_set_state(pdata->edev, EXTCON_USB_HOST, host_mode);
extcon_set_state(pdata->edev, EXTCON_USB, device_mode);
if (pdata->usb_ss_support) {
if (dp_lane == LT8711UXE2_DP_2LANE)
ss_func.intval = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment