usb: mtu3: support option to disable usb3 ports

Add support to disable specific usb3 ports, it's useful when
usb3 phy is shared with PCIe or SATA, because we should disable
the corresponding usb3 port if the phy is used by PCIe or SATA.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Chunfeng Yun 2017-10-13 17:10:38 +08:00 коммит произвёл Felipe Balbi
Родитель c162ff0aaa
Коммит 076f1a8903
3 изменённых файлов: 22 добавлений и 5 удалений

Просмотреть файл

@ -210,6 +210,8 @@ struct otg_switch_mtk {
* host only, device only or dual-role mode * host only, device only or dual-role mode
* @u2_ports: number of usb2.0 host ports * @u2_ports: number of usb2.0 host ports
* @u3_ports: number of usb3.0 host ports * @u3_ports: number of usb3.0 host ports
* @u3p_dis_msk: mask of disabling usb3 ports, for example, bit0==1 to
* disable u3port0, bit1==1 to disable u3port1,... etc
* @dbgfs_root: only used when supports manual dual-role switch via debugfs * @dbgfs_root: only used when supports manual dual-role switch via debugfs
* @wakeup_en: it's true when supports remote wakeup in host mode * @wakeup_en: it's true when supports remote wakeup in host mode
* @wk_deb_p0: port0's wakeup debounce clock * @wk_deb_p0: port0's wakeup debounce clock
@ -232,6 +234,7 @@ struct ssusb_mtk {
bool is_host; bool is_host;
int u2_ports; int u2_ports;
int u3_ports; int u3_ports;
int u3p_dis_msk;
struct dentry *dbgfs_root; struct dentry *dbgfs_root;
/* usb wakeup for host mode */ /* usb wakeup for host mode */
bool wakeup_en; bool wakeup_en;

Просмотреть файл

@ -151,6 +151,7 @@ int ssusb_host_enable(struct ssusb_mtk *ssusb)
void __iomem *ibase = ssusb->ippc_base; void __iomem *ibase = ssusb->ippc_base;
int num_u3p = ssusb->u3_ports; int num_u3p = ssusb->u3_ports;
int num_u2p = ssusb->u2_ports; int num_u2p = ssusb->u2_ports;
int u3_ports_disabed;
u32 check_clk; u32 check_clk;
u32 value; u32 value;
int i; int i;
@ -158,8 +159,14 @@ int ssusb_host_enable(struct ssusb_mtk *ssusb)
/* power on host ip */ /* power on host ip */
mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL1, SSUSB_IP_HOST_PDN); mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL1, SSUSB_IP_HOST_PDN);
/* power on and enable all u3 ports */ /* power on and enable u3 ports except skipped ones */
u3_ports_disabed = 0;
for (i = 0; i < num_u3p; i++) { for (i = 0; i < num_u3p; i++) {
if ((0x1 << i) & ssusb->u3p_dis_msk) {
u3_ports_disabed++;
continue;
}
value = mtu3_readl(ibase, SSUSB_U3_CTRL(i)); value = mtu3_readl(ibase, SSUSB_U3_CTRL(i));
value &= ~(SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_DIS); value &= ~(SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_DIS);
value |= SSUSB_U3_PORT_HOST_SEL; value |= SSUSB_U3_PORT_HOST_SEL;
@ -175,7 +182,7 @@ int ssusb_host_enable(struct ssusb_mtk *ssusb)
} }
check_clk = SSUSB_XHCI_RST_B_STS; check_clk = SSUSB_XHCI_RST_B_STS;
if (num_u3p) if (num_u3p > u3_ports_disabed)
check_clk = SSUSB_U3_MAC_RST_B_STS; check_clk = SSUSB_U3_MAC_RST_B_STS;
return ssusb_check_clocks(ssusb, check_clk); return ssusb_check_clocks(ssusb, check_clk);
@ -190,8 +197,11 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
int ret; int ret;
int i; int i;
/* power down and disable all u3 ports */ /* power down and disable u3 ports except skipped ones */
for (i = 0; i < num_u3p; i++) { for (i = 0; i < num_u3p; i++) {
if ((0x1 << i) & ssusb->u3p_dis_msk)
continue;
value = mtu3_readl(ibase, SSUSB_U3_CTRL(i)); value = mtu3_readl(ibase, SSUSB_U3_CTRL(i));
value |= SSUSB_U3_PORT_PDN; value |= SSUSB_U3_PORT_PDN;
value |= suspend ? 0 : SSUSB_U3_PORT_DIS; value |= suspend ? 0 : SSUSB_U3_PORT_DIS;

Просмотреть файл

@ -276,6 +276,10 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
if (ret) if (ret)
return ret; return ret;
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
&ssusb->u3p_dis_msk);
if (ssusb->dr_mode != USB_DR_MODE_OTG) if (ssusb->dr_mode != USB_DR_MODE_OTG)
return 0; return 0;
@ -304,8 +308,8 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
} }
} }
dev_info(dev, "dr_mode: %d, is_u3_dr: %d\n", dev_info(dev, "dr_mode: %d, is_u3_dr: %d, u3p_dis_msk:%x\n",
ssusb->dr_mode, otg_sx->is_u3_drd); ssusb->dr_mode, otg_sx->is_u3_drd, ssusb->u3p_dis_msk);
return 0; return 0;
} }