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: add feature to disable device's usb3 port

We may want to disable device's usb3 port when the combo phy is switched
from usb3 mode to pcie mode for some projects.
Meanwhile rename member @is_u3_ip to @u3_capable to avoid misleading, due
to the member's value may be changed when disable usb3 port, but the
controller is still a usb3 IP which also tells us how to manage the fifo.

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

authored by

Chunfeng Yun and committed by
Greg Kroah-Hartman
269f49ff 3cb79822

+24 -16
+3 -1
drivers/usb/mtu3/mtu3.h
··· 317 317 * @ep0_req: dummy request used while handling standard USB requests 318 318 * for GET_STATUS and SET_SEL 319 319 * @setup_buf: ep0 response buffer for GET_STATUS and SET_SEL requests 320 + * @u3_capable: is capable of supporting USB3 320 321 */ 321 322 struct mtu3 { 322 323 spinlock_t lock; ··· 354 353 unsigned softconnect:1; 355 354 unsigned u1_enable:1; 356 355 unsigned u2_enable:1; 357 - unsigned is_u3_ip:1; 356 + unsigned u3_capable:1; 358 357 unsigned delayed_status:1; 359 358 unsigned gen2cp:1; 360 359 unsigned connected:1; 361 360 unsigned async_callbacks:1; 361 + unsigned separate_fifo:1; 362 362 363 363 u8 address; 364 364 u8 test_mode_nr;
+19 -13
drivers/usb/mtu3/mtu3_core.c
··· 100 100 101 101 mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); 102 102 103 - if (mtu->is_u3_ip) { 103 + if (mtu->u3_capable) { 104 104 check_clk = SSUSB_U3_MAC_RST_B_STS; 105 105 mtu3_clrbits(ibase, SSUSB_U3_CTRL(0), 106 106 (SSUSB_U3_PORT_DIS | SSUSB_U3_PORT_PDN | ··· 112 112 113 113 if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) { 114 114 mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); 115 - if (mtu->is_u3_ip) 115 + if (mtu->u3_capable) 116 116 mtu3_setbits(ibase, SSUSB_U3_CTRL(0), 117 117 SSUSB_U3_PORT_DUAL_MODE); 118 118 } ··· 124 124 { 125 125 void __iomem *ibase = mtu->ippc_base; 126 126 127 - if (mtu->is_u3_ip) 127 + if (mtu->u3_capable) 128 128 mtu3_setbits(ibase, SSUSB_U3_CTRL(0), 129 129 (SSUSB_U3_PORT_DIS | SSUSB_U3_PORT_PDN)); 130 130 ··· 133 133 134 134 if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) { 135 135 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); 136 - if (mtu->is_u3_ip) 136 + if (mtu->u3_capable) 137 137 mtu3_clrbits(ibase, SSUSB_U3_CTRL(0), 138 138 SSUSB_U3_PORT_DUAL_MODE); 139 139 } ··· 146 146 void __iomem *ibase = mtu->ippc_base; 147 147 148 148 mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); 149 - if (mtu->is_u3_ip) 149 + if (mtu->u3_capable) 150 150 mtu3_clrbits(ibase, SSUSB_U3_CTRL(0), SSUSB_U3_PORT_PDN); 151 151 152 152 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_PDN); ··· 156 156 { 157 157 void __iomem *ibase = mtu->ippc_base; 158 158 159 - if (mtu->is_u3_ip) 159 + if (mtu->u3_capable) 160 160 mtu3_setbits(ibase, SSUSB_U3_CTRL(0), SSUSB_U3_PORT_PDN); 161 161 162 162 mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_PDN); ··· 213 213 value = SUSPEND_INTR | RESUME_INTR | RESET_INTR; 214 214 mtu3_writel(mbase, U3D_COMMON_USB_INTR_ENABLE, value); 215 215 216 - if (mtu->is_u3_ip) { 216 + if (mtu->u3_capable) { 217 217 /* Enable U3 LTSSM interrupts */ 218 218 value = HOT_RST_INTR | WARM_RST_INTR | 219 219 ENTER_U3_INTR | EXIT_U3_INTR; ··· 273 273 { 274 274 void __iomem *mbase = mtu->mac_base; 275 275 276 - if (mtu->is_u3_ip) { 276 + if (mtu->u3_capable) { 277 277 /* disable LGO_U1/U2 by default */ 278 278 mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL, 279 279 SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE); ··· 341 341 342 342 void mtu3_dev_on_off(struct mtu3 *mtu, int is_on) 343 343 { 344 - if (mtu->is_u3_ip && mtu->speed >= USB_SPEED_SUPER) 344 + if (mtu->u3_capable && mtu->speed >= USB_SPEED_SUPER) 345 345 mtu3_ss_func_set(mtu, is_on); 346 346 else 347 347 mtu3_hs_softconn_set(mtu, is_on); ··· 544 544 struct mtu3_fifo_info *rx_fifo; 545 545 u32 fifosize; 546 546 547 - if (mtu->is_u3_ip) { 547 + if (mtu->separate_fifo) { 548 548 fifosize = mtu3_readl(mtu->mac_base, U3D_CAP_EPNTXFFSZ); 549 549 tx_fifo = &mtu->tx_fifo; 550 550 tx_fifo->base = 0; ··· 821 821 822 822 static void mtu3_check_params(struct mtu3 *mtu) 823 823 { 824 + /* device's u3 port (port0) is disabled */ 825 + if (mtu->u3_capable && (mtu->ssusb->u3p_dis_msk & BIT(0))) 826 + mtu->u3_capable = 0; 827 + 824 828 /* check the max_speed parameter */ 825 829 switch (mtu->max_speed) { 826 830 case USB_SPEED_FULL: ··· 842 838 break; 843 839 } 844 840 845 - if (!mtu->is_u3_ip && (mtu->max_speed > USB_SPEED_HIGH)) 841 + if (!mtu->u3_capable && (mtu->max_speed > USB_SPEED_HIGH)) 846 842 mtu->max_speed = USB_SPEED_HIGH; 847 843 848 844 mtu->speed = mtu->max_speed; ··· 861 857 mtu->gen2cp = !!(mtu->hw_version >= MTU3_TRUNK_VERS_1003); 862 858 863 859 value = mtu3_readl(mtu->ippc_base, U3D_SSUSB_IP_DEV_CAP); 864 - mtu->is_u3_ip = !!SSUSB_IP_DEV_U3_PORT_NUM(value); 860 + mtu->u3_capable = !!SSUSB_IP_DEV_U3_PORT_NUM(value); 861 + /* usb3 ip uses separate fifo */ 862 + mtu->separate_fifo = mtu->u3_capable; 865 863 866 864 dev_info(mtu->dev, "IP version 0x%x(%s IP)\n", mtu->hw_version, 867 - mtu->is_u3_ip ? "U3" : "U2"); 865 + mtu->u3_capable ? "U3" : "U2"); 868 866 869 867 mtu3_check_params(mtu); 870 868
+2 -2
drivers/usb/mtu3/mtu3_plat.c
··· 244 244 if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN) 245 245 ssusb->dr_mode = USB_DR_MODE_OTG; 246 246 247 + of_property_read_u32(node, "mediatek,u3p-dis-msk", &ssusb->u3p_dis_msk); 248 + 247 249 if (ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) 248 250 goto out; 249 251 ··· 257 255 } 258 256 259 257 /* optional property, ignore the error if it does not exist */ 260 - of_property_read_u32(node, "mediatek,u3p-dis-msk", 261 - &ssusb->u3p_dis_msk); 262 258 of_property_read_u32(node, "mediatek,u2p-dis-msk", 263 259 &ssusb->u2p_dis_msk); 264 260