usb: xhci-mtk: support option to disable ports
Subsystems (4)
Chunfeng Yun
maintainerPATCH 1/2 usb: xhci-mtk: support option to disable ports
Add support to disable specific ports, it's useful for some scenarios:
1. usb3 PHY is shared whith PCIe or SATA, the corresponding usb3 port can be disabled;
2. some usb2 or usb3 ports are not used on special platforms, they should be disabled to save power.
Signed-off-by Chunfeng Yun <[email protected]>
--- drivers/usb/host/xhci-mtk.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-mtk.c +20 -3
@@ -61,10 +61,13 @@ struct mtk_xhci {struct phy_bulk phys;int num_u2ports;int num_u3ports; +u32 u3p_dis_msk; +u32 u2p_dis_msk; };static int xhci_mtk_host_enable (struct mtk_xhci *mtk) { +int u3_ports_disabed =0 ;u32 value;u32 check_val;int ret;
@@ -73,15 +76,23 @@ static int xhci_mtk_host_enable(struct mtk_xhci *mtk)/* power on host ip */ clrbits_le32 (mtk->ippc +IPPC_IP_PW_CTRL1 ,CTRL1_IP_HOST_PDN ); -/* power on and enable all u3 ports */ +/* power on and enable u3 ports except skipped ones */ for (i =0 ; i < mtk->num_u3ports; i++) { +if (BIT (i) & mtk->u3p_dis_msk) { + u3_ports_disabed++; +continue ; + } +clrsetbits_le32 (mtk->ippc +IPPC_U3_CTRL (i),CTRL_U3_PORT_PDN |CTRL_U3_PORT_DIS ,CTRL_U3_PORT_HOST_SEL ); } -/* power on and enable all u2 ports */ +/* power on and enable u2 ports except skipped ones */ for (i =0 ; i < mtk->num_u2ports; i++) { +if (BIT (i) & mtk->u2p_dis_msk) +continue ; +clrsetbits_le32 (mtk->ippc +IPPC_U2_CTRL (i),CTRL_U2_PORT_PDN |CTRL_U2_PORT_DIS ,CTRL_U2_PORT_HOST_SEL );
@@ -94,7 +105,7 @@ static int xhci_mtk_host_enable(struct mtk_xhci *mtk) check_val =STS1_SYSPLL_STABLE |STS1_REF_RST |STS1_SYS125_RST |STS1_XHCI_RST ; -if (mtk->num_u3ports) +if (mtk->num_u3ports > u3_ports_disabed) check_val |=STS1_U3_MAC_RST ; ret = readl_poll_timeout(mtk->ippc + IPPC_IP_PW_STS1, value,
@@ -176,6 +187,12 @@ static int xhci_mtk_ofdata_get(struct mtk_xhci *mtk)if (ret)debug ("can't get vbus regulator %d!\n" , ret); +/* optional properties to disable ports, ignore the error */ +dev_read_u32 (dev,"mediatek,u3p-dis-msk" , &mtk->u3p_dis_msk); +dev_read_u32 (dev,"mediatek,u2p-dis-msk" , &mtk->u2p_dis_msk); +dev_info (dev,"ports disabled mask: u3p-0x%x, u2p-0x%x\n" , + mtk->u3p_dis_msk, mtk->u2p_dis_msk); +return 0 ; }
Signature · 1 line
2.18.0
Chunfeng Yun
maintainerPATCH 2/2 dt-bindings: usb: mtk-xhci: add optional properies to disable ports
Add optional properies to disable usb2 or usb3 ports, they are used when provided ports are not used on some special platforms.
Signed-off-by Chunfeng Yun <[email protected]>
--- doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt | 4 ++++ 1 file changed, 4 insertions(+)
doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt +4 -0
@@ -25,6 +25,10 @@ Required properties: Optional properties: - vbus-supply : reference to the VBUS regulator; + - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0, + bit1 for u3port1, ... etc; + - mediatek,u2p-dis-msk : mask to disable u2ports, bit0 for u2port0, + bit1 for u2port1, ... etc; Example: xhci: usb at 1a0c0000 {
Signature · 1 line
2.18.0