usb: roles: intel_xhci: Determine current role by DUAL_ROLE_CFG1
Hi,
Quoted 9 lines · Yu Wang
The USB PHY mux switch depend on both USB2/USB3 PHY state and xHCI/xDCI controller state. The role can't be switched if related states haven't satisfied. That is why we need to poll the
DUAL_ROLE_CFG1to check if the role switched successful or not.So the
SW_IDPINandSW_VBUS_VALIDbits can't determine the current acting role.This patch changes the logic for getting role logic.
I guess this matches up with the recent patches to change the role-switching on non Cherry Trail devices to use the DRD_CONFIG bits instead of the SW_IDPIN bit?
AFAIK under normal circumstances with our current code, DUAL_ROLE_CFG1 will always follow SW_IDPIN, so I'm not entirly sure what you are trying to fix here?
IOW what problem are you seeing without this patch and how does this fix it ?
If this is related to the patch to use the DRD_CONFIG bits on non Cherry Trail devices, then please first submit a new version of the patch for that which leaves the functionality on CHT devices as is (as discussed before).
Regards,
Hans
Quoted 36 lines
Signed-off-by Yu Wang <[email protected]>--- drivers/usb/roles/intel-xhci-usb-role-switch.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/usb/roles/intel-xhci-usb-role-switch.c +10
-6@@ -110,14 +110,18 @@ static enum usb_role intel_xhci_usb_get_role(struct device *dev)pm_runtime_get_sync (dev); val =readl (data->base +DUAL_ROLE_CFG0 ); -pm_runtime_put (dev); -if (!(val &SW_IDPIN )) - role =USB_ROLE_HOST ; -else if (val &SW_VBUS_VALID ) - role =USB_ROLE_DEVICE ; -else +if ((val &SW_IDPIN ) && !(val &SW_VBUS_VALID )) role =USB_ROLE_NONE ; +else { + val =readl (data->base +DUAL_ROLE_CFG1 ); +if (val &HOST_MODE ) + role =USB_ROLE_HOST ; +else + role =USB_ROLE_DEVICE ; + } + +pm_runtime_put (dev);return role; }