Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: mtu3: check capability of usb3 dual role

It is capable of supporting usb3 dual role if there is at least one
usb3 port for device and xhci controller, we can check it from the
controller's capability, so no need the property "mediatek,usb3-drd"
anymore, but I find the property is not decribed in dt-binding.
Meanwhile, also take into account if the u3 port is disabled when the
u3 phy is shared with pcie.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20220708071903.25752-4-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chunfeng Yun and committed by
Greg Kroah-Hartman
683ff6e4 269f49ff

+28 -4
+28 -4
drivers/usb/mtu3/mtu3_plat.c
··· 190 190 mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); 191 191 } 192 192 193 + static void ssusb_u3_drd_check(struct ssusb_mtk *ssusb) 194 + { 195 + struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; 196 + u32 dev_u3p_num; 197 + u32 host_u3p_num; 198 + u32 value; 199 + 200 + /* u3 port0 is disabled */ 201 + if (ssusb->u3p_dis_msk & BIT(0)) { 202 + otg_sx->is_u3_drd = false; 203 + goto out; 204 + } 205 + 206 + value = mtu3_readl(ssusb->ippc_base, U3D_SSUSB_IP_DEV_CAP); 207 + dev_u3p_num = SSUSB_IP_DEV_U3_PORT_NUM(value); 208 + 209 + value = mtu3_readl(ssusb->ippc_base, U3D_SSUSB_IP_XHCI_CAP); 210 + host_u3p_num = SSUSB_IP_XHCI_U3_PORT_NUM(value); 211 + 212 + otg_sx->is_u3_drd = !!(dev_u3p_num && host_u3p_num); 213 + 214 + out: 215 + dev_info(ssusb->dev, "usb3-drd: %d\n", otg_sx->is_u3_drd); 216 + } 217 + 193 218 static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) 194 219 { 195 220 struct device_node *node = pdev->dev.of_node; ··· 295 270 goto out; 296 271 297 272 /* if dual-role mode is supported */ 298 - otg_sx->is_u3_drd = of_property_read_bool(node, "mediatek,usb3-drd"); 299 273 otg_sx->manual_drd_enabled = 300 274 of_property_read_bool(node, "enable-manual-drd"); 301 275 otg_sx->role_sw_used = of_property_read_bool(node, "usb-role-switch"); ··· 314 290 } 315 291 316 292 out: 317 - dev_info(dev, "dr_mode: %d, is_u3_dr: %d, drd: %s\n", 318 - ssusb->dr_mode, otg_sx->is_u3_drd, 319 - otg_sx->manual_drd_enabled ? "manual" : "auto"); 293 + dev_info(dev, "dr_mode: %d, drd: %s\n", ssusb->dr_mode, 294 + otg_sx->manual_drd_enabled ? "manual" : "auto"); 320 295 dev_info(dev, "u2p_dis_msk: %x, u3p_dis_msk: %x\n", 321 296 ssusb->u2p_dis_msk, ssusb->u3p_dis_msk); 322 297 ··· 376 353 } 377 354 378 355 ssusb_ip_sw_reset(ssusb); 356 + ssusb_u3_drd_check(ssusb); 379 357 380 358 if (IS_ENABLED(CONFIG_USB_MTU3_HOST)) 381 359 ssusb->dr_mode = USB_DR_MODE_HOST;