From patchwork Wed Dec 23 01:52:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 1419542 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0x6r4ZJNz9sVY for ; Wed, 23 Dec 2020 12:52:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DF63827B3; Wed, 23 Dec 2020 02:52:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 94D1A827BA; Wed, 23 Dec 2020 02:52:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by phobos.denx.de (Postfix) with ESMTP id 2B5BC82771 for ; Wed, 23 Dec 2020 02:52:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=chunfeng.yun@mediatek.com X-UUID: 91ef056ddde4431e88aef4cc3b2ace2b-20201223 X-UUID: 91ef056ddde4431e88aef4cc3b2ace2b-20201223 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1980470305; Wed, 23 Dec 2020 09:52:25 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Dec 2020 09:52:24 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Dec 2020 09:52:23 +0800 From: Chunfeng Yun To: Bin Meng , Marek Vasut CC: , GSS_MTK_Uboot_upstream , Frank Wunderlich , Ryder Lee , Weijie Gao , Chunfeng Yun Subject: [RESEND PATCH 1/2] usb: xhci-mtk: support option to disable ports Date: Wed, 23 Dec 2020 09:52:20 +0800 Message-ID: <1608688341-19580-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-TM-SNTS-SMTP: A95BEED7472D61C039E4D729E18F6CE94963DB1049152ECF1D2AE46FC530DAE22000:8 X-MTK: N X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 --- drivers/usb/host/xhci-mtk.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index f62e232d21..ebda80f2af 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -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; } From patchwork Wed Dec 23 01:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 1419543 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0x6v5rC2z9sVY for ; Wed, 23 Dec 2020 12:52:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C8CD9827CA; Wed, 23 Dec 2020 02:52:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 92C00827BD; Wed, 23 Dec 2020 02:52:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by phobos.denx.de (Postfix) with ESMTP id 2D465827B3 for ; Wed, 23 Dec 2020 02:52:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=chunfeng.yun@mediatek.com X-UUID: d3c190f5fe97492c8fb0a86c1686e362-20201223 X-UUID: d3c190f5fe97492c8fb0a86c1686e362-20201223 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1979912373; Wed, 23 Dec 2020 09:52:25 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Dec 2020 09:52:20 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Dec 2020 09:52:23 +0800 From: Chunfeng Yun To: Bin Meng , Marek Vasut CC: , GSS_MTK_Uboot_upstream , Frank Wunderlich , Ryder Lee , Weijie Gao , Chunfeng Yun Subject: [RESEND PATCH 2/2] dt-bindings: usb: mtk-xhci: add optional properies to disable ports Date: Wed, 23 Dec 2020 09:52:21 +0800 Message-ID: <1608688341-19580-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1608688341-19580-1-git-send-email-chunfeng.yun@mediatek.com> References: <1608688341-19580-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 --- doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt b/doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt index 0447468a2d..2a298f7b16 100644 --- a/doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt +++ b/doc/device-tree-bindings/usb/mediatek,mtk-xhci.txt @@ -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@1a0c0000 {