Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6772951pxv; Fri, 30 Jul 2021 01:53:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCRHBaQTZlziWKhDj4earNlefE+aIPN+zaqm5HQyleqI0iEv3tln7c4/77hTGnz8+uDlSa X-Received: by 2002:a5d:9e4f:: with SMTP id i15mr1626931ioi.58.1627635227372; Fri, 30 Jul 2021 01:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627635227; cv=none; d=google.com; s=arc-20160816; b=VIBXsr93VzrhWrvTHSEODg58yQ3STKI/DPbAsYd7jvrP5UDXgoCaCNIWP0VjdAfu/v J2gmyDB37zxgsNOO/dbw8DYJErHLmlqdoibZNvRcRNlSivxsdEJuZ5yGO2XQnpX71zqf wBrZp8x26j90SIHe5WJRPp9DyRsPL1marrQdXbkioBAIHnxSBk1GnSqGAsAL3OimQGZc BzHhE9xHbWB328iU7M4h1lPIdpu+lO46kgelaTwedBIPe4BYfw6eiVol2IgCUP4eZNSJ rOoeJ14x60B2ADdVLC4DOdLH9ytRYUxGJd6gmIUzpJiCDx2FGhx6Zh+ep2PnLReeJLKd PfDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=FDaGm636g049w7yVuULZVwO1AotE7F6fM3geIbOaaZc=; b=L9CPwtIN/L1SnnZj6AERSZDbLeFO2XttROUNehEHeAfbqSIrIEgjnQ0HxJJiF4Gh1s Sz0LgwCrFU+8/AeWfTmSNBv7DQKNhWEcGkIoXpFnHmZ5b5ExVwuu7m9TdMrrwH+UBjCd Y0txP1hVwNokUy3OdPcyWnrUSv1NkIr9GDTpMobZJt0/xmCqKc2rnWr9+OKzIKS2tdGP 0ehxo4YATznl7l+hOhR7zTRJI/sIg3V+wMmm/hVOga9qYAn1iMrCgpjk55kSEyX1QZLX pfuDxQePbPloz+Q1Y3f0+PlnNhRt/3zPVkkgsQphMsJwMqWDpLHT5K97+2Y/7/Q0dGLU KayA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si1112174ilm.119.2021.07.30.01.53.34; Fri, 30 Jul 2021 01:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238265AbhG3IvO (ORCPT + 99 others); Fri, 30 Jul 2021 04:51:14 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:41602 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S238115AbhG3Iuv (ORCPT ); Fri, 30 Jul 2021 04:50:51 -0400 X-UUID: fedee033f5f9437e8db3da4b2322d6ba-20210730 X-UUID: fedee033f5f9437e8db3da4b2322d6ba-20210730 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 503012025; Fri, 30 Jul 2021 16:50:42 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 30 Jul 2021 16:50:41 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 30 Jul 2021 16:50:40 +0800 From: Chunfeng Yun To: Rob Herring , Mathias Nyman CC: Chunfeng Yun , Greg Kroah-Hartman , Matthias Brugger , , , , , , Eddie Hung Subject: [PATCH 06/11] usb: xhci-mtk: support option to disable usb2 ports Date: Fri, 30 Jul 2021 16:49:57 +0800 Message-ID: <1627635002-24521-6-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1627635002-24521-1-git-send-email-chunfeng.yun@mediatek.com> References: <1627635002-24521-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to disable specific usb2 host ports, it's useful when a usb2 port is disabled on some platforms, but enabled on others for the same SoC. Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk.c | 12 ++++++++++-- drivers/usb/host/xhci-mtk.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index f6d161670c4e..12b691547438 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -116,8 +116,11 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) writel(value, &ippc->u3_ctrl_p[i]); } - /* power on and enable all u2 ports */ + /* power on and enable all u2 ports except skipped ones */ for (i = 0; i < mtk->num_u2_ports; i++) { + if (BIT(i) & mtk->u2p_dis_msk) + continue; + value = readl(&ippc->u2_ctrl_p[i]); value &= ~(CTRL_U2_PORT_PDN | CTRL_U2_PORT_DIS); value |= CTRL_U2_PORT_HOST_SEL; @@ -164,8 +167,11 @@ static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) writel(value, &ippc->u3_ctrl_p[i]); } - /* power down all u2 ports */ + /* power down all u2 ports except skipped ones */ for (i = 0; i < mtk->num_u2_ports; i++) { + if (BIT(i) & mtk->u2p_dis_msk) + continue; + value = readl(&ippc->u2_ctrl_p[i]); value |= CTRL_U2_PORT_PDN; writel(value, &ippc->u2_ctrl_p[i]); @@ -445,6 +451,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) /* optional property, ignore the error if it does not exist */ of_property_read_u32(node, "mediatek,u3p-dis-msk", &mtk->u3p_dis_msk); + of_property_read_u32(node, "mediatek,u2p-dis-msk", + &mtk->u2p_dis_msk); ret = usb_wakeup_of_property_parse(mtk, node); if (ret) { diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index ace432356c41..0466bc8f7500 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -138,6 +138,7 @@ struct xhci_hcd_mtk { struct mu3c_ippc_regs __iomem *ippc_regs; int num_u2_ports; int num_u3_ports; + int u2p_dis_msk; int u3p_dis_msk; struct regulator *vusb33; struct regulator *vbus; -- 2.18.0