From patchwork Fri Nov 15 18:42:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9DB61393 for ; Fri, 15 Nov 2019 18:43:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC6FF20732 for ; Fri, 15 Nov 2019 18:43:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kTY/TUWG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oJyyZRy5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC6FF20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VunCCt8Wrlr68WTjwEEM4SQEYTNd2nhGXi313G3SOKs=; b=kTY/TUWGOs9+JN3wpcaPOoXXYZ X3adyUQ/esdG2CFAJ4dNMV40HLq9puQwuG5rirejHRFJMgo6R3PoOK7mYEnMHxw//qeeXqozsHlgk vBUEp4nMngPIlI/SRtj4KfVE2gWlDKbCqv5nN3cO+lWpS5X3w64uRIMaBvLBIs9ppOpaZIVR15x86 me6Lj2+bKcBd7R4/3ntnsdielqeQOq0tZzxT/+H1E2QrZwMYcqteIGp3eUsFn953fj/SeBb+cN9W6 toiiQJsublEyntQIwxjtMwKXO17vnn0FpgaJfzCSyoLS+b7HdAPjr9mP36EQ7lHDIPrxPRAmAf/TK rJxkkgIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZS-0003gL-GF; Fri, 15 Nov 2019 18:43:50 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZC-0003TW-6N for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:35 +0000 Received: by mail-wr1-x442.google.com with SMTP id s5so12069469wrw.2 for ; Fri, 15 Nov 2019 10:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z4v4wVl3s1hArrGKDQlCf3SAy+2jZtyPSY8RHpRjW/c=; b=oJyyZRy5EXzkcQq3r2IC4zfXoQLCh1o4QQleaHojeFxcrNSrx3byV0e6gSDEZIYwe/ MssPxJ+9G6DF44CaOrNyRZyjyN8Da73LyY8SEh9RGDSzOLKR4AkSKQQoDSVxgdYUxqBj 3bnpa0wkNnYplEgViPNUKhpwwtZbpBgdV08n+oImk0a8q637fcLWaywnIoQrt/3EhRa3 sItgCcV5Zqm5J9PydN/h5w4f03vZ52TVCdA0IriGrrmVa5gFXmp9e+teu0kVXRKi6pAH M0EJs6nMxRGdipijRvnmN0E5jJKyKd+SgoHAFbIu1aVKLOl/nBJ85flVsF+5uHzFARs0 E4kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z4v4wVl3s1hArrGKDQlCf3SAy+2jZtyPSY8RHpRjW/c=; b=hdBTjDaxGAJi27gDlaPcIyguZf4IDdL6VsY1Fz/kTwPsqOOBa91JqM+5zUp9kl5oGJ 0TL9xRHlxVrWUKT7FJigWrd+rsk6a0qpCP2pWY2sajg7rdIMsZvDHSjzgJ0aYT1la6b+ W9zU4iB5OmAa11jTD4qeMltim3VPomIlvVt4BtymUPiUn5GSF5wDnX4o3Yz7B99IPHxl j16TNjNFTtY0IPQslXQVR8tLkKrGD2/TsM/bow0ATvpxu2kqIJXKVGKppp46nDcs4tUn Vk/VFtR3MTv5kwndKKiztVRzmg2O6oGLtHjbctRPXlOsaNXKWIBe1YcMrYIKL+dUJGC4 2Weg== X-Gm-Message-State: APjAAAVutswoBPX4JzNC8ifMJUx3olqBhrZC70cnn/SdRMYaBrPu0Utw k1bR1JZt9FBjcrF3AE0+ErQ= X-Google-Smtp-Source: APXvYqypblj+WoRCfg8ok56bDPdDYClw6eGKjG7CX6ktYZwwTyMpcN2qvlPf5Eli0dUJmUmAifJA0w== X-Received: by 2002:a5d:6412:: with SMTP id z18mr16823980wru.30.1573843412929; Fri, 15 Nov 2019 10:43:32 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:32 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 01/13] phy: usb: EHCI DMA may lose a burst of DMA data for 7255xA0 family Date: Fri, 15 Nov 2019 13:42:11 -0500 Message-Id: <20191115184223.41504-2-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104334_243176_7382022F X-CRM114-Status: GOOD ( 14.65 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When the EHCI controller received a 512 byte USB packet that had to be broken into 2 256 byte bursts across the SCB bus AND there was a following 512 byte USB packet, the second burst of data from the first packet was sometimes being lost. If the burst size was changed to 128 bytes via the EBR_SCB_SIZE field in the USB_CTRL_EBRIDGE register we'd see the 4th 128 byte burst of the first packet being lost. This problem became much worse if other threads were running that accessed memory, like a memcpy test. Setting the EBR_SCB_SIZE to 512, which prevents breaking the EHCI USB packet (max size of 512 bytes) into bursts, fixed the problem. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb-init.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c index 3c53625f8bc2..56d9b314a8d0 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c @@ -42,6 +42,7 @@ #define USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK 0x80000000 /* option */ #define USB_CTRL_EBRIDGE 0x0c #define USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK 0x00020000 /* option */ +#define USB_CTRL_EBRIDGE_EBR_SCB_SIZE_MASK 0x00000f80 /* option */ #define USB_CTRL_OBRIDGE 0x10 #define USB_CTRL_OBRIDGE_LS_KEEP_ALIVE_MASK 0x08000000 #define USB_CTRL_MDIO 0x14 @@ -176,6 +177,7 @@ static const struct id_to_type id_to_type_table[] = { { 0x33900000, BRCM_FAMILY_3390A0 }, { 0x72500010, BRCM_FAMILY_7250B0 }, { 0x72600000, BRCM_FAMILY_7260A0 }, + { 0x72550000, BRCM_FAMILY_7260A0 }, { 0x72680000, BRCM_FAMILY_7271A0 }, { 0x72710000, BRCM_FAMILY_7271A0 }, { 0x73640000, BRCM_FAMILY_7364A0 }, @@ -948,6 +950,17 @@ void brcm_usb_init_eohci(struct brcm_usb_init_params *params) if (params->selected_family == BRCM_FAMILY_7271A0) /* Enable LS keep alive fix for certain keyboards */ USB_CTRL_SET(ctrl, OBRIDGE, LS_KEEP_ALIVE); + + if (params->family_id == 0x72550000) { + /* + * Make the burst size 512 bytes to fix a hardware bug + * on the 7255a0. See HW7255-24. + */ + reg = brcmusb_readl(USB_CTRL_REG(ctrl, EBRIDGE)); + reg &= ~USB_CTRL_MASK(EBRIDGE, EBR_SCB_SIZE); + reg |= 0x800; + brcmusb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE)); + } } void brcm_usb_init_xhci(struct brcm_usb_init_params *params) From patchwork Fri Nov 15 18:42:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 310AF1393 for ; Fri, 15 Nov 2019 18:44:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C679420748 for ; Fri, 15 Nov 2019 18:44:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ADBZLBG8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C9ATRsYZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C679420748 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=u9R3CFtCBgQVsJSJWeCS7G3A9OQazTvGGdA3jINaiKY=; b=ADBZLBG8PO9thQmF3ZgEzEQKfY 0/lQRB41w2J3A5EdSO+rtIcqM44HVddHpnB4QpIEQa/AuZpq10OqTnVR+J42553CekBBucPZnAIIZ rtkftowcPXahjKAAlqZcmjmihw2I8yjnR1IRBVwyjMAjtBgZsd0D3yL8dgWv/w9oVI3T+0e42XRGo rbZcWYMH5p4OaOTq0nLOLH0EGbSHDheJWQUqklpXS6eAe53IFezs1PuXHCQFl8Bi8Nw4PMzsjQ1EK PBnwnfQzXBE+gpkZPlvWBlGmJGOCNjaVVXI71TXUuQVIEGQ25CnVmB1rThzC78msNpTvFgn9JVAOi 51bRdGug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZl-0003yZ-Ll; Fri, 15 Nov 2019 18:44:09 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZE-0003Ug-8e for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:37 +0000 Received: by mail-wr1-x442.google.com with SMTP id s5so12069561wrw.2 for ; Fri, 15 Nov 2019 10:43:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jJrtiyNSy3kb+yNwZbjKaE7PnY4m0t7haj0Vxh+WdWs=; b=C9ATRsYZH/OrMHOZETIezEvXsLqR4T4sS6Frz/FBhKg51pxXHcLd7y4t06fTHG0pnA fdTu2HPEvyRbIyXz5qZ7pbDZ1kOV+5kdUkKZ6OLrje7nzpSpGp47BHxAu9eMvNn9jrxJ vbfGY4s8dq8+XWvjbUR4HNt9sBo3XhNaMBVhNGrQpWfeNefMClxNO3/gCsyowPL3lUn6 v752E+gJEBnBS+wdMo/S50QFxOEgzB/MwfHQMVH6A9TbUeVwxYRJa8F8IIUmggjJ6KRR QlQQDS73/gDeQm540a5bSwaHjZYs8KN3/zI9kDjO77U92feum41HNH60bixq0aoOUDxb j3Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jJrtiyNSy3kb+yNwZbjKaE7PnY4m0t7haj0Vxh+WdWs=; b=aHWJTpiEYYcqOuGz9ZiR1c4fIz49uO5W8RYkgKyJ/O/wH8rdUWM7e+YkhprmwSIeGf QtSqRG3cuBoRJD33vCb75odJc/TYf1IPzFD4K+FW4MVPQguZgNsvcLHpF4dujBNKBPkV foNaqN7/dPZiEIRqGSuYyIZPaQeJHv5cEg7fyVsDlMGt7pp4GZ4DaaCk6S2bz0ZQc4Vj HE3Cj8gkb+ufg+7QMtrbZnpiZRsUoeoItV9KHdlnfx3vDzTJEGhzLuYYBbeqjvc62GLJ X47AnBenFxqvgK6C4dn9dOKH1mBfBQEqKDxfB3d7OT1rGz26RwqnTo/EexyurHRacdDS SQog== X-Gm-Message-State: APjAAAVUYAgoLxGtEOwG5CHHsVS5QcaFKX+Uupx0dQHlhvEZj68TCKEN ucKC9Shq6furZN4mcixKRUM= X-Google-Smtp-Source: APXvYqwxdV+JKop5BR8N2MhmkUjQn0btJGaNIVjC/AU3LC5pxMukp/B1JSfM8g+rzCLnNHjqFXy6EA== X-Received: by 2002:adf:9527:: with SMTP id 36mr16506548wrs.398.1573843414944; Fri, 15 Nov 2019 10:43:34 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:34 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 02/13] phy: usb: Get all drivers that use USB clks using correct enable/disable Date: Fri, 15 Nov 2019 13:42:12 -0500 Message-Id: <20191115184223.41504-3-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104336_344249_D83D24B9 X-CRM114-Status: GOOD ( 13.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The BRCM USB Phy, ohci, ehci and xhci drivers all use the USB clocks but not all drivers use the clk_prepare_enable/clk_disable_unprepare versions to enable/disable the clocks. This change gets all drivers using the prepare version. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index f5c1f2983a1d..217e3702ef4e 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -74,8 +74,8 @@ static int brcm_usb_phy_init(struct phy *gphy) */ mutex_lock(&priv->mutex); if (priv->init_count++ == 0) { - clk_enable(priv->usb_20_clk); - clk_enable(priv->usb_30_clk); + clk_prepare_enable(priv->usb_20_clk); + clk_prepare_enable(priv->usb_30_clk); brcm_usb_init_common(&priv->ini); } mutex_unlock(&priv->mutex); @@ -106,8 +106,8 @@ static int brcm_usb_phy_exit(struct phy *gphy) mutex_lock(&priv->mutex); if (--priv->init_count == 0) { brcm_usb_uninit_common(&priv->ini); - clk_disable(priv->usb_20_clk); - clk_disable(priv->usb_30_clk); + clk_disable_unprepare(priv->usb_20_clk); + clk_disable_unprepare(priv->usb_30_clk); } mutex_unlock(&priv->mutex); phy->inited = false; @@ -360,8 +360,8 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) if (priv->has_eohci) brcm_usb_uninit_eohci(&priv->ini); brcm_usb_uninit_common(&priv->ini); - clk_disable(priv->usb_20_clk); - clk_disable(priv->usb_30_clk); + clk_disable_unprepare(priv->usb_20_clk); + clk_disable_unprepare(priv->usb_30_clk); phy_provider = devm_of_phy_provider_register(dev, brcm_usb_phy_xlate); @@ -381,8 +381,8 @@ static int brcm_usb_phy_suspend(struct device *dev) struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); if (priv->init_count) { - clk_disable(priv->usb_20_clk); - clk_disable(priv->usb_30_clk); + clk_disable_unprepare(priv->usb_20_clk); + clk_disable_unprepare(priv->usb_30_clk); } return 0; } @@ -391,8 +391,8 @@ static int brcm_usb_phy_resume(struct device *dev) { struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); - clk_enable(priv->usb_20_clk); - clk_enable(priv->usb_30_clk); + clk_prepare_enable(priv->usb_20_clk); + clk_prepare_enable(priv->usb_30_clk); brcm_usb_init_ipp(&priv->ini); /* @@ -405,13 +405,13 @@ static int brcm_usb_phy_resume(struct device *dev) brcm_usb_init_eohci(&priv->ini); } else if (priv->has_eohci) { brcm_usb_uninit_eohci(&priv->ini); - clk_disable(priv->usb_20_clk); + clk_disable_unprepare(priv->usb_20_clk); } if (priv->phys[BRCM_USB_PHY_3_0].inited) { brcm_usb_init_xhci(&priv->ini); } else if (priv->has_xhci) { brcm_usb_uninit_xhci(&priv->ini); - clk_disable(priv->usb_30_clk); + clk_disable_unprepare(priv->usb_30_clk); } } else { if (priv->has_xhci) @@ -419,8 +419,8 @@ static int brcm_usb_phy_resume(struct device *dev) if (priv->has_eohci) brcm_usb_uninit_eohci(&priv->ini); brcm_usb_uninit_common(&priv->ini); - clk_disable(priv->usb_20_clk); - clk_disable(priv->usb_30_clk); + clk_disable_unprepare(priv->usb_20_clk); + clk_disable_unprepare(priv->usb_30_clk); } return 0; From patchwork Fri Nov 15 18:42:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AC5813BD for ; Fri, 15 Nov 2019 18:44:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27C412072B for ; Fri, 15 Nov 2019 18:44:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XYM5Wm9Q"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZutM+W0o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27C412072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=R5Luxcf9R0QGgZYntjF6eBaK+H9UR1LmiziKC43uf0Y=; b=XYM5Wm9Qz3+FquePTG0tyFcoyZ cp45xI/C4z9SSnStMZxL+TMEGD1Y1HH5sKje/xjk4aDAO821I3TQyL4Zw9WR0z7Z/NdcvVFkayIOF ojgIPVNzYqqb1iOSFUKEGqXKngIIf9HKc1XGQblYZiKKaEktxFB0xVthd4G2hQE47oV+CIhPXbdP1 8Q8po0ACkMqmJpu8e29YGAvDy5Xmu2fz6L5eMO52DUeEssWKCfZljEHYy1yUytdLMc1oZBRevQxvL DzvbPbnFVnHqGmOtG61rR5wTYHTFJXhuB5sKhUCOiuMT09lQcU8IoWp63nBFSqgOD8UY/WmJ1YI64 X8ZPd+jg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgaC-0004Jx-SB; Fri, 15 Nov 2019 18:44:36 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZH-0003XH-4T for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:40 +0000 Received: by mail-wr1-x443.google.com with SMTP id i10so12058920wrs.7 for ; Fri, 15 Nov 2019 10:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n5G8vs80VS3sA4MhM4cgPCr2IxsX3rpduYhIhTGIkuI=; b=ZutM+W0ogPUSZhV90V1adFu/zwBzRsYtRS1uAYlG4aef/VnkwGi2d9gVcYL64IM5ll m2i0Z+rY50kkNny175k25dNuaVBnetIp0+m8QhytKMEuwA3cBODcKz8wOsTCUDQGzGg1 zNASyVhOUr7HnLrm5Ytn9eVGogET5az9wq5YG9yBY7nDksALNmrVThs9RkaXneV8XeS2 +9ZysXdX8tFqAA8T3BvGaw3LfMR0fxgcUgKOHEOTg+PPiiFzgwDwLbokI6bQc33FOFwU /kR6778Nn+1XcGfYe+lu/3wv8BXPH9Q0A7M/zz9Kyb3LF98Bp33cB2W4AfX8WmZIewAI yqhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n5G8vs80VS3sA4MhM4cgPCr2IxsX3rpduYhIhTGIkuI=; b=XOSDJv0zlDF7bkj6uIWcs7x7wGb8HPJR6nBvPAjMSwNxnOcj1RGfEsAqGEcEsxHlqi 24vnj0ce7pvy+JlAL2siwp3G14On3y/4HvgGu6Scf75QQePZtsIb3asK+eBns55VIrvO f7eP1I7qsOl16CQUVpkhogrBqlkmvjSWZJhA4utsm987xFjSuvwGJw0xMX5Yo0AOQc+f nlbVR0aEbiJDh8MkDtXZw/dDod9Uv+ppo+vRv6pJEbKd67Rm5SU0De5PgQAaWJLPCsoN sOV/6e+ukcLW5crF45XqlaCYSC8/rTAnjtPcHQAGoyQot8LhOQTuH2MNWbQ8E/2OugWr p8bA== X-Gm-Message-State: APjAAAVwvKY7STCqS3ALqFsTSABKW3C0on5tHAQWuRmec825uniK71xO RoeMArpzj03CdxYmsJZHRv8= X-Google-Smtp-Source: APXvYqxhxd3N9xQeLfTjyCbbyVKUcioEYABPKnqb31gT+D/B4XCLxBys89EN1Ei8Fg3lKybqS4gl8w== X-Received: by 2002:a05:6000:1206:: with SMTP id e6mr16943372wrx.113.1573843416930; Fri, 15 Nov 2019 10:43:36 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:36 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 03/13] phy: usb: Put USB phys into IDDQ on suspend to save power in S2 mode Date: Fri, 15 Nov 2019 13:42:13 -0500 Message-Id: <20191115184223.41504-4-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104339_213649_6998003D X-CRM114-Status: GOOD ( 14.85 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently the Phy driver will put the USB phys into the max power saving mode (IDDQ) when there is no corresponding XHCI, EHCI or OHCI client (through rmmod, unbind or if the driver is not builtin). This change will also put the Phys into IDDQ mode on suspend so that S2 will get the additional power savings. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb-init.c | 2 -- drivers/phy/broadcom/phy-brcm-usb.c | 11 +++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c index 56d9b314a8d0..0e6b921072be 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c @@ -1002,8 +1002,6 @@ void brcm_usb_uninit_common(struct brcm_usb_init_params *params) void brcm_usb_uninit_eohci(struct brcm_usb_init_params *params) { - if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB20_HC_RESETB)) - USB_CTRL_UNSET_FAMILY(params, USB_PM, USB20_HC_RESETB); } void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params) diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index 217e3702ef4e..634afc803778 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -381,8 +381,15 @@ static int brcm_usb_phy_suspend(struct device *dev) struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); if (priv->init_count) { - clk_disable_unprepare(priv->usb_20_clk); - clk_disable_unprepare(priv->usb_30_clk); + if (priv->phys[BRCM_USB_PHY_3_0].inited) + brcm_usb_uninit_xhci(&priv->ini); + if (priv->phys[BRCM_USB_PHY_2_0].inited) + brcm_usb_uninit_eohci(&priv->ini); + brcm_usb_uninit_common(&priv->ini); + if (priv->phys[BRCM_USB_PHY_3_0].inited) + clk_disable_unprepare(priv->usb_30_clk); + if (priv->phys[BRCM_USB_PHY_2_0].inited) + clk_disable_unprepare(priv->usb_20_clk); } return 0; } From patchwork Fri Nov 15 18:42:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F41F13BD for ; Fri, 15 Nov 2019 18:44:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DCDE2072B for ; Fri, 15 Nov 2019 18:44:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G1FPdRW7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sZaIW1fM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DCDE2072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wtIhOinbm/U3O6Vrot3fZEwLHn+277r2BLQDxrP+dz0=; b=G1FPdRW7Mp5u9iodLlCEobpMwJ n7wrm+xxQ0qe3EsOhHB+xSwrB5w9TLtaf2qVFCJDPKOk9XJbnbQzbpUsErl0HOk5MzewQVVlk6hxN c/Aq42sU+Jvx409axAvJrhlnHmti4et0udJ+Mf58LDXdGOGhnyjXNFZOMKkUZcqqnJdP/mk5yugXL jssN4I16/LcwZAz73IVwtbHcn0bLelbAJ8z17xPn58aPYxysRZTdlccg22IfA4wj2DyIx/D9CSw+n mP/1DBcNuEZ5kULnPTI+9za/Q5IrGSzrRwp5wySvmuyCTH/wHc3PaAFU4WULEqcivxdSIAczl9ajy /PU/FSaw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgaQ-0004bz-3Z; Fri, 15 Nov 2019 18:44:50 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZI-0003ZU-K7 for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:42 +0000 Received: by mail-wm1-x342.google.com with SMTP id q70so10630072wme.1 for ; Fri, 15 Nov 2019 10:43:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+hMwPgRaMykXSn7DE5c3kA8l5sH3/EjUvphsNHwNa6U=; b=sZaIW1fMT7fXOZYenOECIMP4wK71NQvTFdaRLp6GGjNPW0//YiJsKGlAOhoDb1IzZJ /NGZRwqyZ+ETS4m/9MDOxwSGUEY9TY5ApDdTOmKcKnb1h/eqAM5CScttoVSG9uuR9dLe JrQoTpIX67wu97MfXC6fqvIJCTImUtmuGRqRR/gf4vezTOasAePTH36c3W/QGb67uWbR iFiFv0e4Dy3/RhUSDlNpw/fmXlz34WcxuahvfxsioJzonVIGk6Wj1FMUVzzYFhIrgJiv Rb/OEWOr6Ltj8tDLnTxMMR0pB2LFHYDq1Zz+pvXHCGb50bfXGEgtxItJsR18VXyDeRrU 1FKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+hMwPgRaMykXSn7DE5c3kA8l5sH3/EjUvphsNHwNa6U=; b=Lv1ceC8gK6WUNGTi2pATobO5cEe/c90td5ISZkXHt33qk6rQXTLgGtuaU/Mk+bVYpo XE5U0UpNMHAW4a6f9SY+Stiz26OpNiNA/hPjOdD7gxicf/KhGwXAgMjLqEEohx5iyTN0 elfBr8skYimpmFAixlkXVtnQwOxU3FNEmIaErkhDMQmE2oGFx3jfYzDe2K8CoAbX4Dlu EByG1opqdviTtswb68ZdmA+iSmh0RWnWmC59zm2uV71XhZM2WeFSHbpQNOFGwhe8arx0 7NxrJf2O0X7r+9ELLiMIWUD/UVsb3DZsOn+UJ2Z2fyO+QhDtx0ZRnXKpe8G5hshHIdne SDUw== X-Gm-Message-State: APjAAAWSSey3LXSxZWogh6G/ZOKG3NGh8HECaeXvTa8iGAxTQ0qWjJl4 F77H47GbXZDoiZzTr4rlsR4= X-Google-Smtp-Source: APXvYqxJIxeVusoVL9CDwm2MTlp1cb0mCKqfmVfkuzw72kTT8cgWpKo2VgpQUT51zzEc1uHVH4QuKQ== X-Received: by 2002:a1c:a9cb:: with SMTP id s194mr17345696wme.92.1573843418873; Fri, 15 Nov 2019 10:43:38 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:38 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 04/13] phy: usb: Add "wake on" functionality Date: Fri, 15 Nov 2019 13:42:14 -0500 Message-Id: <20191115184223.41504-5-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104340_888751_83A5BBB6 X-CRM114-Status: GOOD ( 21.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:342 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add the ability to handle USB wake events from USB devices when in S2 mode. Typically there is some additional configuration needed to tell the USB device to generate the wake event when suspended but this varies with the different USB device classes. For example, on USB Ethernet dongles, ethtool should be used to enable the magic packet wake functionality in the dongle. NOTE: This requires that the "power/wakeup" sysfs entry for the USB device generating the wakeup be set to "enabled". This functionality requires a special hardware sideband path that will trigger the AON_PM_L2 interrupt needed to wake the system from S2 even though the USB host controllers are in IDDQ (low power state) and most USB related clocks are shut off. For the sideband signaling to work we need to leave the usbx_freerun clock running, but this clock consumes very little power by design. There's a bug in the XHCI wake hardware so only EHCI/OHCI wake is currently supported. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb-init.c | 17 +++++++++ drivers/phy/broadcom/phy-brcm-usb-init.h | 1 + drivers/phy/broadcom/phy-brcm-usb.c | 48 ++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c index 0e6b921072be..6ad5978ded9b 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c @@ -58,6 +58,8 @@ #define USB_CTRL_USB_PM_SOFT_RESET_MASK 0x40000000 /* option */ #define USB_CTRL_USB_PM_USB20_HC_RESETB_MASK 0x30000000 /* option */ #define USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK 0x00300000 /* option */ +#define USB_CTRL_USB_PM_RMTWKUP_EN_MASK 0x00000001 +#define USB_CTRL_USB_PM_STATUS 0x38 #define USB_CTRL_USB30_CTL1 0x60 #define USB_CTRL_USB30_CTL1_PHY3_PLL_SEQ_START_MASK 0x00000010 #define USB_CTRL_USB30_CTL1_PHY3_RESETB_MASK 0x00010000 @@ -855,6 +857,10 @@ void brcm_usb_init_common(struct brcm_usb_init_params *params) u32 reg; void __iomem *ctrl = params->ctrl_regs; + /* Clear any pending wake conditions */ + reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); + brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS)); + /* Take USB out of power down */ if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) { USB_CTRL_UNSET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN); @@ -1010,6 +1016,17 @@ void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params) USB_CTRL_SET(params->ctrl_regs, USB30_PCTL, PHY3_IDDQ_OVERRIDE); } +void brcm_usb_wake_enable(struct brcm_usb_init_params *params, + int enable) +{ + void __iomem *ctrl = params->ctrl_regs; + + if (enable) + USB_CTRL_SET(ctrl, USB_PM, RMTWKUP_EN); + else + USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN); +} + void brcm_usb_set_family_map(struct brcm_usb_init_params *params) { int fam; diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index f4f4f6d5d258..f473e0c51f0b 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -38,5 +38,6 @@ void brcm_usb_init_xhci(struct brcm_usb_init_params *ini); void brcm_usb_uninit_common(struct brcm_usb_init_params *ini); void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini); void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini); +void brcm_usb_wake_enable(struct brcm_usb_init_params *params, int enable); #endif /* _USB_BRCM_COMMON_INIT_H */ diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index 634afc803778..cca04d60f2d2 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -57,11 +57,22 @@ struct brcm_usb_phy_data { bool has_xhci; struct clk *usb_20_clk; struct clk *usb_30_clk; + struct clk *suspend_clk; struct mutex mutex; /* serialize phy init */ int init_count; + int wake_irq; struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX]; }; +static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id) +{ + struct phy *gphy = dev_id; + + pm_wakeup_event(&gphy->dev, 0); + + return IRQ_HANDLED; +} + static int brcm_usb_phy_init(struct phy *gphy) { struct brcm_usb_phy *phy = phy_get_drvdata(gphy); @@ -76,6 +87,7 @@ static int brcm_usb_phy_init(struct phy *gphy) if (priv->init_count++ == 0) { clk_prepare_enable(priv->usb_20_clk); clk_prepare_enable(priv->usb_30_clk); + clk_prepare_enable(priv->suspend_clk); brcm_usb_init_common(&priv->ini); } mutex_unlock(&priv->mutex); @@ -108,6 +120,7 @@ static int brcm_usb_phy_exit(struct phy *gphy) brcm_usb_uninit_common(&priv->ini); clk_disable_unprepare(priv->usb_20_clk); clk_disable_unprepare(priv->usb_30_clk); + clk_disable_unprepare(priv->suspend_clk); } mutex_unlock(&priv->mutex); phy->inited = false; @@ -228,11 +241,12 @@ static const struct attribute_group brcm_usb_phy_group = { .attrs = brcm_usb_phy_attrs, }; -static int brcm_usb_phy_dvr_init(struct device *dev, +static int brcm_usb_phy_dvr_init(struct platform_device *pdev, struct brcm_usb_phy_data *priv, struct device_node *dn) { - struct phy *gphy; + struct device *dev = &pdev->dev; + struct phy *gphy = NULL; int err; priv->usb_20_clk = of_clk_get_by_name(dn, "sw_usb"); @@ -275,6 +289,28 @@ static int brcm_usb_phy_dvr_init(struct device *dev, if (err) return err; } + + priv->suspend_clk = clk_get(dev, "usb0_freerun"); + if (IS_ERR(priv->suspend_clk)) { + dev_err(dev, "Suspend Clock not found in Device Tree\n"); + priv->suspend_clk = NULL; + } + + priv->wake_irq = platform_get_irq_byname(pdev, "wake"); + if (priv->wake_irq < 0) + priv->wake_irq = platform_get_irq_byname(pdev, "wakeup"); + if (priv->wake_irq >= 0) { + err = devm_request_irq(dev, priv->wake_irq, + brcm_usb_phy_wake_isr, 0, + dev_name(dev), gphy); + if (err < 0) + return err; + device_set_wakeup_capable(dev, 1); + } else { + dev_info(dev, + "Wake interrupt missing, system wake not supported\n"); + } + return 0; } @@ -335,7 +371,7 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) if (of_property_read_bool(dn, "brcm,has-eohci")) priv->has_eohci = true; - err = brcm_usb_phy_dvr_init(dev, priv, dn); + err = brcm_usb_phy_dvr_init(pdev, priv, dn); if (err) return err; @@ -386,10 +422,13 @@ static int brcm_usb_phy_suspend(struct device *dev) if (priv->phys[BRCM_USB_PHY_2_0].inited) brcm_usb_uninit_eohci(&priv->ini); brcm_usb_uninit_common(&priv->ini); + brcm_usb_wake_enable(&priv->ini, true); if (priv->phys[BRCM_USB_PHY_3_0].inited) clk_disable_unprepare(priv->usb_30_clk); if (priv->phys[BRCM_USB_PHY_2_0].inited) clk_disable_unprepare(priv->usb_20_clk); + if (priv->wake_irq >= 0) + enable_irq_wake(priv->wake_irq); } return 0; } @@ -400,6 +439,7 @@ static int brcm_usb_phy_resume(struct device *dev) clk_prepare_enable(priv->usb_20_clk); clk_prepare_enable(priv->usb_30_clk); + brcm_usb_wake_enable(&priv->ini, false); brcm_usb_init_ipp(&priv->ini); /* @@ -407,6 +447,8 @@ static int brcm_usb_phy_resume(struct device *dev) * Uninitialize anything that wasn't previously initialized. */ if (priv->init_count) { + if (priv->wake_irq >= 0) + disable_irq_wake(priv->wake_irq); brcm_usb_init_common(&priv->ini); if (priv->phys[BRCM_USB_PHY_2_0].inited) { brcm_usb_init_eohci(&priv->ini); From patchwork Fri Nov 15 18:42:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59AAF13B2 for ; Fri, 15 Nov 2019 18:45:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C8382072B for ; Fri, 15 Nov 2019 18:45:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NDUhBoQH"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X1Xw7UUV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C8382072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Vs5Usg6z9aBk5wtR23QYBjWdnBprTc6aQgUjVXPeWTs=; b=NDUhBoQHxcEnveilKXvbl24UBk o09h1YPzq4bHQD9cpxYsqo9g0sNErP8qYmygNJmfNMc/OFsSB8+LjFeMMj/b/cBz9jx+PKukjBX83 v0+nrz1e4W9NPW2Ijl3vDV3t1dL2FILAvF1pwQi1gnXIO8YUTBT8sHMGFnur+CcQ2r/7Yr21Vg+Px 4Lolb70qphWVYCiPROM72uq9u+omy/vx7lJBd/5qZq8ezZXQJsGIk+5qcJCR2Elm6BLH+M6xPs3KV /ca2dJcwH+twbeXr2b0Um/dyzrfr4ce0OO+GkHiAbR7dlb7Ouf/wvtkETMDbSLOpizs6NfVm1QV32 0KbM1slw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgai-0004qL-Sy; Fri, 15 Nov 2019 18:45:09 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZM-0003bT-Bs for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:47 +0000 Received: by mail-wm1-x344.google.com with SMTP id 8so11505425wmo.0 for ; Fri, 15 Nov 2019 10:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h1w1IMOh9uAH2ZhtkpdQP5kC2zy5JqYg8a82ZJQZ4gg=; b=X1Xw7UUVzpzl4ejpLblA0T/xj0uJnXiB+bsJY2/bpXMp6DrFCyVTQvHkFHJpej1LY7 8MvE9Ux+/iZAcaJqofcmqd7vwVLH4xYFaTCoSyllxFvDd5e4de9k6FFd7Vei/A2ZeR0n /H+2Vb5zHiYtWQ2Nw0R0O6ekjw5pUpIJg+/MNuRxLcX7nLFyqadQ6pG7GvuNo3d4su4A KhHFeM00ZiEpeDAeQLjJHI60vdS9pILwjM+LTWKj6+pX6X01G+s+vZYmB+1Gi4eqAyqj 2Wt8NQThBbVpYhzMQjtBKKrspxJ9G3fcVJjwKKTw9aRCDGisCRDTQgG9V2qVpx/YKI8c h5oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h1w1IMOh9uAH2ZhtkpdQP5kC2zy5JqYg8a82ZJQZ4gg=; b=Gd53kYUF3a2sa6JyG3MEZnqy8IILum9RcwGZ9TPaZLFa7IjdSTUx54Z+MGHsdTtDC3 XvhijMpHolC8TZZYq3n1ExZBfAQaQKEC3psm9Iao+6ap0W+BKUEa7GErIBrVphuFSE6+ 2uwXws2Acqmf3gmKlqisu+8Q39DgtNJKrmGkkz5bKvMeVyBmFpRfGStvO1uazPCLWR3I BpSLC+JOfTB/KiQrP5zLcNw7v/wkJf4/9/7BuXatTeW9s1Yh8jWjg+3aCUQj+0EOBsKF rDHxRi5aNJpMcQPPoyKhI9iwZgz1YQKBAKL27vA2/VUB7qTbgtPoc6ylP+r8EX0vMyeM Hmpg== X-Gm-Message-State: APjAAAX9qPyYQwL+cz9qsG1kl3mAAJsRK6CT+gsqjLyrKTboFKzNEWmb DBjTlnbeh6nYWxTvMMSy7K4= X-Google-Smtp-Source: APXvYqx9Mz6we813vzbixhoz3wfnykde0BoeQZdW1JZnT/0sIOGZica5eCmXZ5BqYyAbqP4M4skBsQ== X-Received: by 2002:a1c:48c1:: with SMTP id v184mr16332802wma.120.1573843421159; Fri, 15 Nov 2019 10:43:41 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:40 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 05/13] phy: usb: Restructure in preparation for adding 7216 USB support Date: Fri, 15 Nov 2019 13:42:15 -0500 Message-Id: <20191115184223.41504-6-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104344_529795_4F601990 X-CRM114-Status: GOOD ( 19.51 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The driver is being restructured in preparation for adding support for the new Synopsis USB conroller on the 7216. Since all the bugs and work-arounds in previous STB chips are supposed to be fixed, most of the code in phy-brcm-usb-init.c is not needed. Instead of adding more complexity to the already complicated phy-brcm-usb-init.c module, the driver will be restructured to use a vector table to dispatch into different C modules for the different controllers. There was also some general cleanup done including some ipp setup code that was incorrect. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb-init.c | 191 ++++++++++------------- drivers/phy/broadcom/phy-brcm-usb-init.h | 140 +++++++++++++++-- drivers/phy/broadcom/phy-brcm-usb.c | 6 +- 3 files changed, 214 insertions(+), 123 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c index 6ad5978ded9b..5d5a916ed46f 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c @@ -129,10 +129,6 @@ enum { USB_CTRL_SELECTOR_COUNT, }; -#define USB_CTRL_REG(base, reg) ((void *)base + USB_CTRL_##reg) -#define USB_XHCI_EC_REG(base, reg) ((void *)base + USB_XHCI_EC_##reg) -#define USB_CTRL_MASK(reg, field) \ - USB_CTRL_##reg##_##field##_MASK #define USB_CTRL_MASK_FAMILY(params, reg, field) \ (params->usb_reg_bits_map[USB_CTRL_##reg##_##field##_SELECTOR]) @@ -143,13 +139,6 @@ enum { usb_ctrl_unset_family(params, USB_CTRL_##reg, \ USB_CTRL_##reg##_##field##_SELECTOR) -#define USB_CTRL_SET(base, reg, field) \ - usb_ctrl_set(USB_CTRL_REG(base, reg), \ - USB_CTRL_##reg##_##field##_MASK) -#define USB_CTRL_UNSET(base, reg, field) \ - usb_ctrl_unset(USB_CTRL_REG(base, reg), \ - USB_CTRL_##reg##_##field##_MASK) - #define MDIO_USB2 0 #define MDIO_USB3 BIT(31) @@ -405,26 +394,14 @@ usb_reg_bits_map_table[BRCM_FAMILY_COUNT][USB_CTRL_SELECTOR_COUNT] = { }, }; -static inline u32 brcmusb_readl(void __iomem *addr) -{ - return readl(addr); -} - -static inline void brcmusb_writel(u32 val, void __iomem *addr) -{ - writel(val, addr); -} - static inline void usb_ctrl_unset_family(struct brcm_usb_init_params *params, u32 reg_offset, u32 field) { u32 mask; - void *reg; mask = params->usb_reg_bits_map[field]; - reg = params->ctrl_regs + reg_offset; - brcmusb_writel(brcmusb_readl(reg) & ~mask, reg); + brcm_usb_ctrl_unset(params->ctrl_regs + reg_offset, mask); }; static inline @@ -432,45 +409,27 @@ void usb_ctrl_set_family(struct brcm_usb_init_params *params, u32 reg_offset, u32 field) { u32 mask; - void *reg; mask = params->usb_reg_bits_map[field]; - reg = params->ctrl_regs + reg_offset; - brcmusb_writel(brcmusb_readl(reg) | mask, reg); + brcm_usb_ctrl_set(params->ctrl_regs + reg_offset, mask); }; -static inline void usb_ctrl_set(void __iomem *reg, u32 field) -{ - u32 value; - - value = brcmusb_readl(reg); - brcmusb_writel(value | field, reg); -} - -static inline void usb_ctrl_unset(void __iomem *reg, u32 field) -{ - u32 value; - - value = brcmusb_readl(reg); - brcmusb_writel(value & ~field, reg); -} - static u32 brcmusb_usb_mdio_read(void __iomem *ctrl_base, u32 reg, int mode) { u32 data; data = (reg << 16) | mode; - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); data |= (1 << 24); - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); data &= ~(1 << 24); /* wait for the 60MHz parallel to serial shifter */ usleep_range(10, 20); - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); /* wait for the 60MHz parallel to serial shifter */ usleep_range(10, 20); - return brcmusb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff; + return brcm_usb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff; } static void brcmusb_usb_mdio_write(void __iomem *ctrl_base, u32 reg, @@ -479,14 +438,14 @@ static void brcmusb_usb_mdio_write(void __iomem *ctrl_base, u32 reg, u32 data; data = (reg << 16) | val | mode; - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); data |= (1 << 25); - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); data &= ~(1 << 25); /* wait for the 60MHz parallel to serial shifter */ usleep_range(10, 20); - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); /* wait for the 60MHz parallel to serial shifter */ usleep_range(10, 20); } @@ -713,12 +672,12 @@ static void brcmusb_usb3_otp_fix(struct brcm_usb_init_params *params) if (params->family_id != 0x74371000 || xhci_ec_base == 0) return; - brcmusb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR)); - val = brcmusb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); + brcm_usb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR)); + val = brcm_usb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); /* set cfg_pick_ss_lock */ val |= (1 << 27); - brcmusb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); + brcm_usb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); /* Reset USB 3.0 PHY for workaround to take effect */ USB_CTRL_UNSET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB); @@ -751,7 +710,7 @@ static void brcmusb_xhci_soft_reset(struct brcm_usb_init_params *params, * - default chip/rev. * NOTE: The minor rev is always ignored. */ -static enum brcm_family_type brcmusb_get_family_type( +static enum brcm_family_type get_family_type( struct brcm_usb_init_params *params) { int last_type = -1; @@ -779,7 +738,7 @@ static enum brcm_family_type brcmusb_get_family_type( return last_type; } -void brcm_usb_init_ipp(struct brcm_usb_init_params *params) +static void usb_init_ipp(struct brcm_usb_init_params *params) { void __iomem *ctrl = params->ctrl_regs; u32 reg; @@ -795,7 +754,7 @@ void brcm_usb_init_ipp(struct brcm_usb_init_params *params) USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IPP); } - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); orig_reg = reg; if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_CC_DRD_MODE_ENABLE_SEL)) /* Never use the strap, it's going away. */ @@ -803,8 +762,8 @@ void brcm_usb_init_ipp(struct brcm_usb_init_params *params) SETUP, STRAP_CC_DRD_MODE_ENABLE_SEL)); if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_IPP_SEL)) + /* override ipp strap pin (if it exits) */ if (params->ipp != 2) - /* override ipp strap pin (if it exits) */ reg &= ~(USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_IPP_SEL)); @@ -812,54 +771,26 @@ void brcm_usb_init_ipp(struct brcm_usb_init_params *params) reg &= ~(USB_CTRL_MASK(SETUP, IPP) | USB_CTRL_MASK(SETUP, IOC)); if (params->ioc) reg |= USB_CTRL_MASK(SETUP, IOC); - if (params->ipp == 1 && ((reg & USB_CTRL_MASK(SETUP, IPP)) == 0)) + if (params->ipp == 1) reg |= USB_CTRL_MASK(SETUP, IPP); - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); /* * If we're changing IPP, make sure power is off long enough * to turn off any connected devices. */ - if (reg != orig_reg) + if ((reg ^ orig_reg) & USB_CTRL_MASK(SETUP, IPP)) msleep(50); } -int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params) -{ - void __iomem *ctrl = params->ctrl_regs; - u32 reg = 0; - - if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); - reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, - PORT_MODE); - } - return reg; -} - -void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params, - int mode) -{ - void __iomem *ctrl = params->ctrl_regs; - u32 reg; - - if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); - reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, - PORT_MODE); - reg |= mode; - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); - } -} - -void brcm_usb_init_common(struct brcm_usb_init_params *params) +static void usb_init_common(struct brcm_usb_init_params *params) { u32 reg; void __iomem *ctrl = params->ctrl_regs; /* Clear any pending wake conditions */ - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS)); + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS)); /* Take USB out of power down */ if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) { @@ -885,7 +816,7 @@ void brcm_usb_init_common(struct brcm_usb_init_params *params) /* Block auto PLL suspend by USB2 PHY (Sasi) */ USB_CTRL_SET(ctrl, PLL_CTL, PLL_SUSPEND_EN); - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); if (params->selected_family == BRCM_FAMILY_7364A0) /* Suppress overcurrent indication from USB30 ports for A0 */ reg |= USB_CTRL_MASK_FAMILY(params, SETUP, OC3_DISABLE); @@ -901,16 +832,16 @@ void brcm_usb_init_common(struct brcm_usb_init_params *params) reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN); if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN)) reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN); - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); brcmusb_memc_fix(params); if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE); reg |= params->mode; - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); } if (USB_CTRL_MASK_FAMILY(params, USB_PM, BDC_SOFT_RESETB)) { switch (params->mode) { @@ -932,7 +863,7 @@ void brcm_usb_init_common(struct brcm_usb_init_params *params) } } -void brcm_usb_init_eohci(struct brcm_usb_init_params *params) +static void usb_init_eohci(struct brcm_usb_init_params *params) { u32 reg; void __iomem *ctrl = params->ctrl_regs; @@ -948,10 +879,10 @@ void brcm_usb_init_eohci(struct brcm_usb_init_params *params) USB_CTRL_SET(ctrl, EBRIDGE, ESTOP_SCB_REQ); /* Setup the endian bits */ - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); reg &= ~USB_CTRL_SETUP_ENDIAN_BITS; reg |= USB_CTRL_MASK_FAMILY(params, SETUP, ENDIAN); - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); if (params->selected_family == BRCM_FAMILY_7271A0) /* Enable LS keep alive fix for certain keyboards */ @@ -962,14 +893,14 @@ void brcm_usb_init_eohci(struct brcm_usb_init_params *params) * Make the burst size 512 bytes to fix a hardware bug * on the 7255a0. See HW7255-24. */ - reg = brcmusb_readl(USB_CTRL_REG(ctrl, EBRIDGE)); + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, EBRIDGE)); reg &= ~USB_CTRL_MASK(EBRIDGE, EBR_SCB_SIZE); reg |= 0x800; - brcmusb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE)); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE)); } } -void brcm_usb_init_xhci(struct brcm_usb_init_params *params) +static void usb_init_xhci(struct brcm_usb_init_params *params) { void __iomem *ctrl = params->ctrl_regs; @@ -997,7 +928,7 @@ void brcm_usb_init_xhci(struct brcm_usb_init_params *params) brcmusb_usb3_otp_fix(params); } -void brcm_usb_uninit_common(struct brcm_usb_init_params *params) +static void usb_uninit_common(struct brcm_usb_init_params *params) { if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN)) USB_CTRL_SET_FAMILY(params, USB_PM, USB_PWRDN); @@ -1006,17 +937,47 @@ void brcm_usb_uninit_common(struct brcm_usb_init_params *params) USB_CTRL_SET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN); } -void brcm_usb_uninit_eohci(struct brcm_usb_init_params *params) +static void usb_uninit_eohci(struct brcm_usb_init_params *params) { } -void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params) +static void usb_uninit_xhci(struct brcm_usb_init_params *params) { brcmusb_xhci_soft_reset(params, 1); USB_CTRL_SET(params->ctrl_regs, USB30_PCTL, PHY3_IDDQ_OVERRIDE); } -void brcm_usb_wake_enable(struct brcm_usb_init_params *params, +static int usb_get_dual_select(struct brcm_usb_init_params *params) +{ + void __iomem *ctrl = params->ctrl_regs; + u32 reg = 0; + + pr_debug("%s\n", __func__); + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, + PORT_MODE); + } + return reg; +} + +static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) +{ + void __iomem *ctrl = params->ctrl_regs; + u32 reg; + + pr_debug("%s\n", __func__); + + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, + PORT_MODE); + reg |= mode; + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + } +} + +static void usb_wake_enable(struct brcm_usb_init_params *params, int enable) { void __iomem *ctrl = params->ctrl_regs; @@ -1027,13 +988,29 @@ void brcm_usb_wake_enable(struct brcm_usb_init_params *params, USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN); } -void brcm_usb_set_family_map(struct brcm_usb_init_params *params) +static const struct brcm_usb_init_ops bcm7445_ops = { + .init_ipp = usb_init_ipp, + .init_common = usb_init_common, + .init_eohci = usb_init_eohci, + .init_xhci = usb_init_xhci, + .uninit_common = usb_uninit_common, + .uninit_eohci = usb_uninit_eohci, + .uninit_xhci = usb_uninit_xhci, + .get_dual_select = usb_get_dual_select, + .set_dual_select = usb_set_dual_select, + .wake_enable = usb_wake_enable, +}; + +void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params) { int fam; - fam = brcmusb_get_family_type(params); + pr_debug("%s\n", __func__); + + fam = get_family_type(params); params->selected_family = fam; params->usb_reg_bits_map = &usb_reg_bits_map_table[fam][0]; params->family_name = family_names[fam]; + params->ops = &bcm7445_ops; } diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index f473e0c51f0b..8fab5ff76b2b 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -13,6 +13,33 @@ struct brcm_usb_init_params; +#define USB_CTRL_REG(base, reg) ((void *)base + USB_CTRL_##reg) +#define USB_XHCI_EC_REG(base, reg) ((void *)base + USB_XHCI_EC_##reg) +#define USB_CTRL_MASK(reg, field) \ + USB_CTRL_##reg##_##field##_MASK +#define USB_CTRL_SET(base, reg, field) \ + brcm_usb_ctrl_set(USB_CTRL_REG(base, reg), \ + USB_CTRL_##reg##_##field##_MASK) +#define USB_CTRL_UNSET(base, reg, field) \ + brcm_usb_ctrl_unset(USB_CTRL_REG(base, reg), \ + USB_CTRL_##reg##_##field##_MASK) + +struct brcm_usb_init_params; + +struct brcm_usb_init_ops { + void (*init_ipp)(struct brcm_usb_init_params *params); + void (*init_common)(struct brcm_usb_init_params *params); + void (*init_eohci)(struct brcm_usb_init_params *params); + void (*init_xhci)(struct brcm_usb_init_params *params); + void (*uninit_common)(struct brcm_usb_init_params *params); + void (*uninit_eohci)(struct brcm_usb_init_params *params); + void (*uninit_xhci)(struct brcm_usb_init_params *params); + int (*get_dual_select)(struct brcm_usb_init_params *params); + void (*set_dual_select)(struct brcm_usb_init_params *params, int mode); + void (*wake_enable)(struct brcm_usb_init_params *params, + int enable); +}; + struct brcm_usb_init_params { void __iomem *ctrl_regs; void __iomem *xhci_ec_regs; @@ -24,20 +51,107 @@ struct brcm_usb_init_params { int selected_family; const char *family_name; const u32 *usb_reg_bits_map; + const struct brcm_usb_init_ops *ops; }; -void brcm_usb_set_family_map(struct brcm_usb_init_params *params); -int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params); -void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params, - int mode); - -void brcm_usb_init_ipp(struct brcm_usb_init_params *ini); -void brcm_usb_init_common(struct brcm_usb_init_params *ini); -void brcm_usb_init_eohci(struct brcm_usb_init_params *ini); -void brcm_usb_init_xhci(struct brcm_usb_init_params *ini); -void brcm_usb_uninit_common(struct brcm_usb_init_params *ini); -void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini); -void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini); -void brcm_usb_wake_enable(struct brcm_usb_init_params *params, int enable); +void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params); + +static inline u32 brcm_usb_readl(void __iomem *addr) +{ + /* + * MIPS endianness is configured by boot strap, which also reverses all + * bus endianness (i.e., big-endian CPU + big endian bus ==> native + * endian I/O). + * + * Other architectures (e.g., ARM) either do not support big endian, or + * else leave I/O in little endian mode. + */ + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) + return __raw_readl(addr); + else + return readl_relaxed(addr); +} + +static inline void brcm_usb_writel(u32 val, void __iomem *addr) +{ + /* See brcmnand_readl() comments */ + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) + __raw_writel(val, addr); + else + writel_relaxed(val, addr); +} + +static inline void brcm_usb_ctrl_unset(void __iomem *reg, u32 mask) +{ + brcm_usb_writel(brcm_usb_readl(reg) & ~(mask), reg); +}; + +static inline void brcm_usb_ctrl_set(void __iomem *reg, u32 mask) +{ + brcm_usb_writel(brcm_usb_readl(reg) | (mask), reg); +}; + +static inline void brcm_usb_init_ipp(struct brcm_usb_init_params *ini) +{ + if (ini->ops->init_ipp) + ini->ops->init_ipp(ini); +} + +static inline void brcm_usb_init_common(struct brcm_usb_init_params *ini) +{ + if (ini->ops->init_common) + ini->ops->init_common(ini); +} + +static inline void brcm_usb_init_eohci(struct brcm_usb_init_params *ini) +{ + if (ini->ops->init_eohci) + ini->ops->init_eohci(ini); +} + +static inline void brcm_usb_init_xhci(struct brcm_usb_init_params *ini) +{ + if (ini->ops->init_xhci) + ini->ops->init_xhci(ini); +} + +static inline void brcm_usb_uninit_common(struct brcm_usb_init_params *ini) +{ + if (ini->ops->uninit_common) + ini->ops->uninit_common(ini); +} + +static inline void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini) +{ + if (ini->ops->uninit_eohci) + ini->ops->uninit_eohci(ini); +} + +static inline void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini) +{ + if (ini->ops->uninit_xhci) + ini->ops->uninit_xhci(ini); +} + +static inline void brcm_usb_wake_enable(struct brcm_usb_init_params *ini, + int enable) +{ + if (ini->ops->wake_enable) + ini->ops->wake_enable(ini, enable); +} + +static inline int brcm_usb_get_dual_select(struct brcm_usb_init_params *ini) +{ + if (ini->ops->get_dual_select) + return ini->ops->get_dual_select(ini); + return 0; +} + +static inline void brcm_usb_set_dual_select(struct brcm_usb_init_params *ini, + int mode) +{ + if (ini->ops->set_dual_select) + ini->ops->set_dual_select(ini, mode); +} #endif /* _USB_BRCM_COMMON_INIT_H */ diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index cca04d60f2d2..9d93c5599511 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -207,7 +207,7 @@ static ssize_t dual_select_store(struct device *dev, res = name_to_value(&brcm_dual_mode_to_name[0], ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value); if (!res) { - brcm_usb_init_set_dual_select(&priv->ini, value); + brcm_usb_set_dual_select(&priv->ini, value); res = len; } mutex_unlock(&sysfs_lock); @@ -222,7 +222,7 @@ static ssize_t dual_select_show(struct device *dev, int value; mutex_lock(&sysfs_lock); - value = brcm_usb_init_get_dual_select(&priv->ini); + value = brcm_usb_get_dual_select(&priv->ini); mutex_unlock(&sysfs_lock); return sprintf(buf, "%s\n", value_to_name(&brcm_dual_mode_to_name[0], @@ -331,7 +331,7 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) priv->ini.family_id = brcmstb_get_family_id(); priv->ini.product_id = brcmstb_get_product_id(); - brcm_usb_set_family_map(&priv->ini); + brcm_usb_dvr_init_7445(&priv->ini); dev_dbg(dev, "Best mapping table is for %s\n", priv->ini.family_name); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); From patchwork Fri Nov 15 18:42:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9585717E8 for ; Fri, 15 Nov 2019 18:45:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51A3A20732 for ; Fri, 15 Nov 2019 18:45:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="byyZkjcH"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nMz2ArNK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51A3A20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vFGzX7C4YTORXv0onS4IWlyajZBE6KsTNZzHrHU1JLM=; b=byyZkjcHiS5bQ/5kFNTi3X7Uff 0FoDNfAasfmJt86+dqiFQhwmLejG06d7gTxUOYiEDdFMUrQGe+4dv36NmNFFDiWFAgsegD2eT4dTk tLaSQndn1JDIGWFujL4olhubdtuZBUtxVTki3TKu5OCKmmVe1wHB8eNNHO5WXzFpryVKJ9JYxd1TD 1Lnjn42jNLtllFna71HNfcv5EEKzZa6R27D+MYu/R927boWb04t2IFtJI/1zAGXmUOLG7ixaJ6k22 MM2qghHQeR87z+J/WmwWCzqF+sXbiOlP/2TjlKTEhO1wyuO/yRfrJmVBhrIztHseTR+h9UIAryX4O cOxNiUMQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgay-0005Tn-Ur; Fri, 15 Nov 2019 18:45:24 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZM-0003d4-Mc for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:47 +0000 Received: by mail-wr1-x443.google.com with SMTP id z10so12026290wrs.12 for ; Fri, 15 Nov 2019 10:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7uRAh6au5S8VHEFJ8kt0g9ojSmzLPUJCgOM93b79zJ8=; b=nMz2ArNKaiV116nGTM8su2jslxeFG/M61PGYDogyk/BLEJNVxMoc4e7cFlghVJXYjS 7e4VSE83UCk0ciOYv1A/mrsO+BfCJauy8VHlByENSTwgwZ7HZVJoeU5anWSBThOWVdnn fqC0norUEM7Hluv+SUxv2s5lrXHVnz93LzA+QKGSB3WMtro5ACeiJoVXLR+EzqSd9IQ+ tdplTH5bewiyeaqr70ywFwN/dJVGCrx52kA1FVNtNeEP5zlQEmlNdQFjGoupQz38giMD NYrHwcpnEt2otbqNf74mS54keFdMFStUURry54mmDFx7OXEUEADyXYI5oild3+lCbwbu 3PHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7uRAh6au5S8VHEFJ8kt0g9ojSmzLPUJCgOM93b79zJ8=; b=XqHvZ1eqIy1zTM3M64jEanmPr9MbUoSCNDNJUSjt+KNlBXhwZ40Fgdf4L40ztq3AYR jYdAKZ8CkWKZ84xklEiK24dwqx1fLPkLcrNguTOdnDj4tTzhHwx8V9EKA/lK4VLVB6JS KREzXcB981TioEV3HqM1tpyag06FRd2rG/9sKX7yvuWhDbFXMet4DgcfEkYgQrSSo6Bn AkikQv/afs0QpuOHjB3M7a7HJU3V9VECSKlrG12bUHrckcxHBR+Wd4IDd4kRmWN5KNN/ jP2yS+9Rc1VOnZ7lRWQiFOZi59J2tZ4AmKiGT+fgESbai4+iZSQ4J8SoMEdqWRRsrWeR EInA== X-Gm-Message-State: APjAAAUXS7dnWaYNRcW+ObmIpRtjTi+sfxf6G585Hjo6phZh+l0BByPd cXkDqvRDm/62yBaHA562ORk= X-Google-Smtp-Source: APXvYqzEVU7XFzQk8e6hFqD9pMZEDS4KMA9Qh/5s4IAIaXif8/fdlJpD9FsxAPMdvuVLGSG4E29isQ== X-Received: by 2002:adf:e387:: with SMTP id e7mr16750930wrm.180.1573843423211; Fri, 15 Nov 2019 10:43:43 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:42 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 06/13] dt-bindings: Add Broadcom STB USB PHY binding document Date: Fri, 15 Nov 2019 13:42:16 -0500 Message-Id: <20191115184223.41504-7-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104344_783619_6975DDE4 X-CRM114-Status: GOOD ( 14.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support for bcm7216 and bcm7211 Signed-off-by: Al Cooper Reviewed-by: Rob Herring --- .../bindings/phy/brcm,brcmstb-usb-phy.txt | 69 +++++++++++++++---- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt index 24a0d06acd1d..698aacbdcfc4 100644 --- a/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt +++ b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt @@ -1,30 +1,49 @@ Broadcom STB USB PHY Required properties: - - compatible: brcm,brcmstb-usb-phy - - reg: two offset and length pairs. - The first pair specifies a manditory set of memory mapped - registers used for general control of the PHY. - The second pair specifies optional registers used by some of - the SoCs that support USB 3.x - - #phy-cells: Shall be 1 as it expects one argument for setting - the type of the PHY. Possible values are: - - PHY_TYPE_USB2 for USB1.1/2.0 PHY - - PHY_TYPE_USB3 for USB3.x PHY +- compatible: should be one of + "brcm,brcmstb-usb-phy" + "brcm,bcm7216-usb-phy" + "brcm,bcm7211-usb-phy" + +- reg and reg-names properties requirements are specific to the + compatible string. + "brcm,brcmstb-usb-phy": + - reg: 1 or 2 offset and length pairs. One for the base CTRL registers + and an optional pair for systems with USB 3.x support + - reg-names: not specified + "brcm,bcm7216-usb-phy": + - reg: 3 offset and length pairs for CTRL, XHCI_EC and XHCI_GBL + registers + - reg-names: "ctrl", "xhci_ec", "xhci_gbl" + "brcm,bcm7211-usb-phy": + - reg: 5 offset and length pairs for CTRL, XHCI_EC, XHCI_GBL, + USB_PHY and USB_MDIO registers and an optional pair + for the BDC registers + - reg-names: "ctrl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec" + +- #phy-cells: Shall be 1 as it expects one argument for setting + the type of the PHY. Possible values are: + - PHY_TYPE_USB2 for USB1.1/2.0 PHY + - PHY_TYPE_USB3 for USB3.x PHY Optional Properties: - clocks : clock phandles. - clock-names: String, clock name. +- interrupts: wakeup interrupt +- interrupt-names: "wakeup" - brcm,ipp: Boolean, Invert Port Power. Possible values are: 0 (Don't invert), 1 (Invert) - brcm,ioc: Boolean, Invert Over Current detection. Possible values are: 0 (Don't invert), 1 (Invert) -NOTE: one or both of the following two properties must be set -- brcm,has-xhci: Boolean indicating the phy has an XHCI phy. -- brcm,has-eohci: Boolean indicating the phy has an EHCI/OHCI phy. - dr_mode: String, PHY Device mode. Possible values are: "host", "peripheral ", "drd" or "typec-pd" If this property is not defined, the phy will default to "host" mode. +- brcm,syscon-piarbctl: phandle to syscon for handling config registers +NOTE: one or both of the following two properties must be set +- brcm,has-xhci: Boolean indicating the phy has an XHCI phy. +- brcm,has-eohci: Boolean indicating the phy has an EHCI/OHCI phy. + Example: @@ -41,3 +60,27 @@ usbphy_0: usb-phy@f0470200 { clocks = <&usb20>, <&usb30>; clock-names = "sw_usb", "sw_usb3"; }; + +usb-phy@29f0200 { + reg = <0x29f0200 0x200>, + <0x29c0880 0x30>, + <0x29cc100 0x534>, + <0x2808000 0x24>, + <0x2980080 0x8>; + reg-names = "ctrl", + "xhci_ec", + "xhci_gbl", + "usb_phy", + "usb_mdio"; + brcm,ioc = <0x0>; + brcm,ipp = <0x0>; + compatible = "brcm,bcm7211-usb-phy"; + interrupts = <0x30>; + interrupt-parent = <&vpu_intr1_nosec_intc>; + interrupt-names = "wake"; + #phy-cells = <0x1>; + brcm,has-xhci; + syscon-piarbctl = <&syscon_piarbctl>; + clocks = <&scmi_clk 256>; + clock-names = "sw_usb"; +}; From patchwork Fri Nov 15 18:42:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBFFF1393 for ; Fri, 15 Nov 2019 18:45:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B62842072B for ; Fri, 15 Nov 2019 18:45:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BZsEARad"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZAq2qk4o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B62842072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7JP9Kk7IUB1vVFvxEexwuTMlZqkMtAc1UjxbABQMOWQ=; b=BZsEARadA2q1Y8Q1c3+XR4VRqL SD3j37L1uk+MF6YrvH4JJcoEQylnpSO9kEJZz3ej9WOx7Gq5SCnOyO0r0qCNnAk8AoPvIfyPqKMDz xyt7k3ShPNl7ejS63v3SjtQ2/hlEkBO9pb1nBVYuBGbAyyLknQFd8+lxzO9XTq+2vG9HuyknYwOAL yuI9WTGBE+KbTUnxdRfUznvXo/jNWo778z6+At/+TSI7YIskry1B0+aC9356ix01YfhpHYtdisRm9 AoKDfT8j+9G9DI89m9vwRZ9gCw/jxsmlwr8DUvBM1yhwPuckgJ6iWZ5su9uVnMMc04VFkjb5gyGkk OM5UuRMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgb9-0005oL-Nm; Fri, 15 Nov 2019 18:45:35 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZP-0003fD-5P for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:49 +0000 Received: by mail-wm1-x341.google.com with SMTP id b11so10630270wmb.5 for ; Fri, 15 Nov 2019 10:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AJUCH/K/W4ArkzBqFTVeXPUp7ehqV40f+G+epdnvqqU=; b=ZAq2qk4o2IdIEApHSybbkmhFFOoX1Ry3aS1yos+P8Ypy3YVcH0aU1pTsIWC5rujel2 QVQzBYPuwib9Bmrkgx6gqZimn6unQpEm9NvyIiQKJfqhnoFU+4bli6vcSRVcDsj7VVkd QUgTV3SvFAAgvpnoLokR4gIVay70LN4hIEtyb5UigeRlXx5mL2hFxnrRNakzVPfV/55o 6LfiIWdl/h2fFrb7No57x/su8c5dDu71QAQvcKxPcHY7aYOQBFzqwsElr/Pi9RysHPBz xKe6orK3PSLUpaU1lCy2WVpGSKtRh6eAEfr3AnKjjXrQjUiCa9ZrGJEWY6zdgYdvMqhj he8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AJUCH/K/W4ArkzBqFTVeXPUp7ehqV40f+G+epdnvqqU=; b=SZkjHLaC/bHR+BtY2H3CAT+jy+nPeAFiKrjFbPrzZU7ClBYO1ipiwIIEjn6LbYeL8E LipMVYfYI7ZexRbsngfg4H9bPZCsG7I/BNKALiIK/YX5EeknsebvEfpQ68G8sIsc7cNE A34PbZ8rkrYOqfGGdjr6lp733IO8DCZSmbjaU7ctkVrOH0b1FF+dO9TKZbDPjepASySt U/RMXbCMMAzle7Ck5Wpmh72YfTPlZ2n35qOYGWKBKPePwTYCIbQ9t+2cjXGNGW/QZHdt nWs5ayJjtJ241RtYeMAdh0q+hsfV+7bYvKWSjxtqfzkpqbFOmiPx0ldycd6KHHufB5BJ 33SQ== X-Gm-Message-State: APjAAAUkaXMpSL2kWhP9IHvaYaox2uFcQvZQU8HMK9KHSTPAVompP6B9 HE9MlkCvgllxvL6Xffwk7V1jm55GN9s= X-Google-Smtp-Source: APXvYqxTKsfrkB/M3WwAIAO10Xg5xlqf+/7FUAfvGI0sPlxCPRMCg0G0YMxUxlAk1Q8UtrmoUARk4g== X-Received: by 2002:a1c:7f94:: with SMTP id a142mr15738636wmd.33.1573843425232; Fri, 15 Nov 2019 10:43:45 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:44 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 07/13] phy: usb: Add support for new Synopsis USB controller on the 7216 Date: Fri, 15 Nov 2019 13:42:17 -0500 Message-Id: <20191115184223.41504-8-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104347_235794_E81BDF5B X-CRM114-Status: GOOD ( 24.13 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The 7216 has the new USB XHCI controller from Synopsis. While this new controller and the PHY are similar to the STB versions, the major differences are: - Many of the registers and fields in the CTRL block have been removed or changed. - A new set of Synopsis control registers, BCHP_USB_XHCI_GBL, were added. - MDIO functionality has been replaced with direct access registers in the BCHP_USB_XHCI_GBL block. - Power up PHY defaults that had to be changed by MDIO in previous chips will now power up with the correct defaults. A new init module was created for this new Synopsis USB controller. A new compatible string was added and the driver will dispatch into one of two init modules based on it. A "reg-names" field was added so the driver can more easily get optional registers. A DT bindings document was also added for this driver. Signed-off-by: Al Cooper --- drivers/phy/broadcom/Makefile | 2 +- .../phy/broadcom/phy-brcm-usb-init-synopsis.c | 171 ++++++++++++++++++ drivers/phy/broadcom/phy-brcm-usb-init.h | 2 + drivers/phy/broadcom/phy-brcm-usb.c | 70 +++++-- 4 files changed, 227 insertions(+), 18 deletions(-) create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile index f453c7d3ffff..88523e2be861 100644 --- a/drivers/phy/broadcom/Makefile +++ b/drivers/phy/broadcom/Makefile @@ -8,7 +8,7 @@ obj-$(CONFIG_PHY_NS2_USB_DRD) += phy-bcm-ns2-usbdrd.o obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o obj-$(CONFIG_PHY_BRCM_USB) += phy-brcm-usb-dvr.o -phy-brcm-usb-dvr-objs := phy-brcm-usb.o phy-brcm-usb-init.o +phy-brcm-usb-dvr-objs := phy-brcm-usb.o phy-brcm-usb-init.o phy-brcm-usb-init-synopsis.o obj-$(CONFIG_PHY_BCM_SR_PCIE) += phy-bcm-sr-pcie.o obj-$(CONFIG_PHY_BCM_SR_USB) += phy-bcm-sr-usb.o diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c new file mode 100644 index 000000000000..57663492b228 --- /dev/null +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c @@ -0,0 +1,171 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, Broadcom */ + +/* + * This module contains USB PHY initialization for power up and S3 resume + * for newer Synopsis based USB hardware first used on the bcm7216. + */ + +#include +#include + +#include +#include "phy-brcm-usb-init.h" + +/* Register definitions for the USB CTRL block */ +#define USB_CTRL_SETUP 0x00 +#define USB_CTRL_SETUP_STRAP_IPP_SEL_MASK 0x02000000 +#define USB_CTRL_SETUP_SCB2_EN_MASK 0x00008000 +#define USB_CTRL_SETUP_SCB1_EN_MASK 0x00004000 +#define USB_CTRL_SETUP_SOFT_SHUTDOWN_MASK 0x00000200 +#define USB_CTRL_SETUP_IPP_MASK 0x00000020 +#define USB_CTRL_SETUP_IOC_MASK 0x00000010 +#define USB_CTRL_USB_PM 0x04 +#define USB_CTRL_USB_PM_USB_PWRDN_MASK 0x80000000 +#define USB_CTRL_USB_PM_SOFT_RESET_MASK 0x40000000 +#define USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK 0x00800000 +#define USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK 0x00400000 +#define USB_CTRL_USB_PM_STATUS 0x08 +#define USB_CTRL_USB_DEVICE_CTL1 0x10 +#define USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK 0x00000003 + + +static void xhci_soft_reset(struct brcm_usb_init_params *params, + int on_off) +{ + void __iomem *ctrl = params->ctrl_regs; + + /* Assert reset */ + if (on_off) + USB_CTRL_UNSET(ctrl, USB_PM, XHC_SOFT_RESETB); + /* De-assert reset */ + else + USB_CTRL_SET(ctrl, USB_PM, XHC_SOFT_RESETB); +} + +static void usb_init_ipp(struct brcm_usb_init_params *params) +{ + void __iomem *ctrl = params->ctrl_regs; + u32 reg; + u32 orig_reg; + + pr_debug("%s\n", __func__); + + orig_reg = reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); + if (params->ipp != 2) + /* override ipp strap pin (if it exits) */ + reg &= ~(USB_CTRL_MASK(SETUP, STRAP_IPP_SEL)); + + /* Override the default OC and PP polarity */ + reg &= ~(USB_CTRL_MASK(SETUP, IPP) | USB_CTRL_MASK(SETUP, IOC)); + if (params->ioc) + reg |= USB_CTRL_MASK(SETUP, IOC); + if (params->ipp == 1) + reg |= USB_CTRL_MASK(SETUP, IPP); + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); + + /* + * If we're changing IPP, make sure power is off long enough + * to turn off any connected devices. + */ + if ((reg ^ orig_reg) & USB_CTRL_MASK(SETUP, IPP)) + msleep(50); +} + +static void usb_init_common(struct brcm_usb_init_params *params) +{ + u32 reg; + void __iomem *ctrl = params->ctrl_regs; + + pr_debug("%s\n", __func__); + + USB_CTRL_UNSET(ctrl, USB_PM, USB_PWRDN); + /* 1 millisecond - for USB clocks to settle down */ + usleep_range(1000, 2000); + + if (USB_CTRL_MASK(USB_DEVICE_CTL1, PORT_MODE)) { + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + reg &= ~USB_CTRL_MASK(USB_DEVICE_CTL1, PORT_MODE); + reg |= params->mode; + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + } + switch (params->mode) { + case USB_CTLR_MODE_HOST: + USB_CTRL_UNSET(ctrl, USB_PM, BDC_SOFT_RESETB); + break; + default: + USB_CTRL_UNSET(ctrl, USB_PM, BDC_SOFT_RESETB); + USB_CTRL_SET(ctrl, USB_PM, BDC_SOFT_RESETB); + break; + } +} + +static void usb_init_xhci(struct brcm_usb_init_params *params) +{ + pr_debug("%s\n", __func__); + + xhci_soft_reset(params, 0); +} + +static void usb_uninit_common(struct brcm_usb_init_params *params) +{ + void __iomem *ctrl = params->ctrl_regs; + + pr_debug("%s\n", __func__); + + USB_CTRL_SET(ctrl, USB_PM, USB_PWRDN); + +} + +static void usb_uninit_xhci(struct brcm_usb_init_params *params) +{ + + pr_debug("%s\n", __func__); + + xhci_soft_reset(params, 1); +} + +static int usb_get_dual_select(struct brcm_usb_init_params *params) +{ + void __iomem *ctrl = params->ctrl_regs; + u32 reg = 0; + + pr_debug("%s\n", __func__); + + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + reg &= USB_CTRL_MASK(USB_DEVICE_CTL1, PORT_MODE); + return reg; +} + +static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) +{ + void __iomem *ctrl = params->ctrl_regs; + u32 reg; + + pr_debug("%s\n", __func__); + + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); + reg &= ~USB_CTRL_MASK(USB_DEVICE_CTL1, PORT_MODE); + reg |= mode; + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); +} + + +static const struct brcm_usb_init_ops bcm7216_ops = { + .init_ipp = usb_init_ipp, + .init_common = usb_init_common, + .init_xhci = usb_init_xhci, + .uninit_common = usb_uninit_common, + .uninit_xhci = usb_uninit_xhci, + .get_dual_select = usb_get_dual_select, + .set_dual_select = usb_set_dual_select, +}; + +void brcm_usb_dvr_init_7216(struct brcm_usb_init_params *params) +{ + + pr_debug("%s\n", __func__); + + params->family_name = "7216"; + params->ops = &bcm7216_ops; +} diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index 8fab5ff76b2b..571ccae48e3f 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -43,6 +43,7 @@ struct brcm_usb_init_ops { struct brcm_usb_init_params { void __iomem *ctrl_regs; void __iomem *xhci_ec_regs; + void __iomem *xhci_gbl_regs; int ioc; int ipp; int mode; @@ -55,6 +56,7 @@ struct brcm_usb_init_params { }; void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params); +void brcm_usb_dvr_init_7216(struct brcm_usb_init_params *params); static inline u32 brcm_usb_readl(void __iomem *addr) { diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index 9d93c5599511..64379ede480e 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -241,6 +241,15 @@ static const struct attribute_group brcm_usb_phy_group = { .attrs = brcm_usb_phy_attrs, }; +static const struct of_device_id brcm_usb_dt_ids[] = { + { + .compatible = "brcm,bcm7216-usb-phy", + .data = &brcm_usb_dvr_init_7216, + }, + { .compatible = "brcm,brcmstb-usb-phy" }, + { /* sentinel */ } +}; + static int brcm_usb_phy_dvr_init(struct platform_device *pdev, struct brcm_usb_phy_data *priv, struct device_node *dn) @@ -316,13 +325,16 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev, static int brcm_usb_phy_probe(struct platform_device *pdev) { - struct resource *res; + struct resource *res_ctrl; + struct resource *res_xhciec = NULL; + struct resource *res_xhcigbl = NULL; struct device *dev = &pdev->dev; struct brcm_usb_phy_data *priv; struct phy_provider *phy_provider; struct device_node *dn = pdev->dev.of_node; int err; const char *mode; + const struct of_device_id *match; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -331,30 +343,59 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) priv->ini.family_id = brcmstb_get_family_id(); priv->ini.product_id = brcmstb_get_product_id(); - brcm_usb_dvr_init_7445(&priv->ini); + + match = of_match_node(brcm_usb_dt_ids, dev->of_node); + if (match && match->data) { + void (*dvr_init)(struct brcm_usb_init_params *params); + + dvr_init = match->data; + (*dvr_init)(&priv->ini); + } else { + brcm_usb_dvr_init_7445(&priv->ini); + } + dev_dbg(dev, "Best mapping table is for %s\n", priv->ini.family_name); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "can't get USB_CTRL base address\n"); - return -EINVAL; + + /* Newer DT node has reg-names. xhci_ec and xhci_gbl are optional. */ + res_ctrl = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl"); + if (res_ctrl != NULL) { + res_xhciec = platform_get_resource_byname(pdev, + IORESOURCE_MEM, + "xhci_ec"); + res_xhcigbl = platform_get_resource_byname(pdev, + IORESOURCE_MEM, + "xhci_gbl"); + } else { + /* Older DT node without reg-names, use index */ + res_ctrl = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res_ctrl == NULL) { + dev_err(dev, "can't get CTRL base address\n"); + return -EINVAL; + } + res_xhciec = platform_get_resource(pdev, IORESOURCE_MEM, 1); } - priv->ini.ctrl_regs = devm_ioremap_resource(dev, res); + priv->ini.ctrl_regs = devm_ioremap_resource(dev, res_ctrl); if (IS_ERR(priv->ini.ctrl_regs)) { dev_err(dev, "can't map CTRL register space\n"); return -EINVAL; } - - /* The XHCI EC registers are optional */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (res) { + if (res_xhciec) { priv->ini.xhci_ec_regs = - devm_ioremap_resource(dev, res); + devm_ioremap_resource(dev, res_xhciec); if (IS_ERR(priv->ini.xhci_ec_regs)) { dev_err(dev, "can't map XHCI EC register space\n"); return -EINVAL; } } + if (res_xhcigbl) { + priv->ini.xhci_gbl_regs = + devm_ioremap_resource(dev, res_xhcigbl); + if (IS_ERR(priv->ini.xhci_gbl_regs)) { + dev_err(dev, "can't map XHCI Global register space\n"); + return -EINVAL; + } + } of_property_read_u32(dn, "brcm,ipp", &priv->ini.ipp); of_property_read_u32(dn, "brcm,ioc", &priv->ini.ioc); @@ -480,11 +521,6 @@ static const struct dev_pm_ops brcm_usb_phy_pm_ops = { SET_LATE_SYSTEM_SLEEP_PM_OPS(brcm_usb_phy_suspend, brcm_usb_phy_resume) }; -static const struct of_device_id brcm_usb_dt_ids[] = { - { .compatible = "brcm,brcmstb-usb-phy" }, - { /* sentinel */ } -}; - MODULE_DEVICE_TABLE(of, brcm_usb_dt_ids); static struct platform_driver brcm_usb_driver = { From patchwork Fri Nov 15 18:42:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246961 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7293C1393 for ; Fri, 15 Nov 2019 18:45:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4304F2072B for ; Fri, 15 Nov 2019 18:45:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XEab5ZTh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z9m2adkJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4304F2072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zbah4jo+GkJ3tw8opeQ/JRnyqTm3CLiVpWu+EWfNoHo=; b=XEab5ZThs1Jmk2Ykiu3/QgriBY Hq74k4O9tuOtaUHMoUQ/z6dbsq9xvQaodi6jz/igvLWBs4jw3URcjAnqqxV376BMgV1x9eFn+xfC2 v16k95QcjHnex3ZGWI6oyebHh+9BU+QH2w1HesTOPTIyJcRh2BADADA+HGFYca/13mSrUX9cOfa+T rqaVCFPOxB29JLZ+KyaNBDn4LJOXpq/txHxVfXLVMVc4XmdCaNL8+UYerhGpuoxT+/HKylq4mRoJe VQa8MlBvgsH8VekPZPfSCh17Inm0gRiCvW8legOXyBZ+tMym1siK2SArnnmHczA8O3EOyyyEGn9Od UkuFU/pw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgbJ-00061H-HY; Fri, 15 Nov 2019 18:45:45 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZR-0003h1-Qf for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:53 +0000 Received: by mail-wm1-x343.google.com with SMTP id b11so10630350wmb.5 for ; Fri, 15 Nov 2019 10:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6JIWvS5gH0KtbFtTwsZtf2gcj/Uvgr4doorGGY2pkwI=; b=Z9m2adkJXy6nzjB//U9lEkovpr2GuzEkgrGrIjw96qSt1RFgxaQRtblt9VQo+0BvDC ipmeORR3kVLt5LD9sWqpAkIGwRC9dfhxo9xadWfittKBsfpmsIoodg3vYw3RkzNyMUe3 BBmgdytq4n0MAwH187bAVi727GonVuZyK8N8OO29r5tJlTU1qSUaqyT6iU1mpk9k3+4o +jEZZO+WKc7FqTABoSvQo1F15S5Rt53EVjeUB4OtNC/G0NQsQzHdaZ5wVeyxLnOfpct8 u7kfnH2NkMh3z68sCvqDv5WMG+RPzseFGnHMzzU7V02BRe+PGrFJrYkta31XTJNQ3ij+ e6yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6JIWvS5gH0KtbFtTwsZtf2gcj/Uvgr4doorGGY2pkwI=; b=hK3yGS1okFN68ePM6I33bQcb4U0sMt6NBS+Jzb2XDRO6Kvk6OlCq9vrndPACYnIubo J4Qnv99p606BKreHEHwtPhQj3XSHOWKsPkpUGqPnp/sslYW8hr3sx5lcU4Mra1xTDe7G RQPYwoxj7Ywn54w4+Ng6ISJxg9lnaVeVgWNsmNoD8RBH883MzQhKVkyOiILqgZUcxTEn XuC+qpC/jHegU6Z7Cg6mST2UtbyaKZfRHqGh+0WnvWv6IutSR7cfmRaVJnC/7L+UGWzZ aq2Hihy/1UYsZa1x8mk45AJcI98W89+CLvwrSMEu0M1fC7z6RYlB/0rxzrBHSyVuOru8 44sA== X-Gm-Message-State: APjAAAV4vkmN5DUJad/LaBlndRvARnXgmMsfhX64M/BtZl9M+pGWW7LS leRvtTaDigOxOcmKEu/2BHXErJ25rxg= X-Google-Smtp-Source: APXvYqyzVsxBLNtmbzNASHIhtFblSH7IeP6+NxDk81/j01SfxdZpH+r3QSk599Uvhq8yMxX+EtFUkA== X-Received: by 2002:a7b:c748:: with SMTP id w8mr17264254wmk.114.1573843427246; Fri, 15 Nov 2019 10:43:47 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:46 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 08/13] phy: usb: Add support for new Synopsis USB controller on the 7211b0 Date: Fri, 15 Nov 2019 13:42:18 -0500 Message-Id: <20191115184223.41504-9-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104349_892518_50A56410 X-CRM114-Status: GOOD ( 19.94 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The 7211b0 has added the STB XHCI Synopsis controller and it will be used instead of the RPi based DWC USB controller. The new Synopsis XHCI controller core is the same one that is used on the 7216, but because of the way the STB USB PHY is used on both the A0 and B0, some of the PHY control is different. Signed-off-by: Al Cooper --- .../phy/broadcom/phy-brcm-usb-init-synopsis.c | 163 +++++++++++++++++- drivers/phy/broadcom/phy-brcm-usb-init.c | 31 ++-- drivers/phy/broadcom/phy-brcm-usb-init.h | 17 +- drivers/phy/broadcom/phy-brcm-usb.c | 162 +++++++++++------ 4 files changed, 295 insertions(+), 78 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c index 57663492b228..bf138867efb1 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c @@ -12,10 +12,33 @@ #include #include "phy-brcm-usb-init.h" +#define PHY_LOCK_TIMEOUT_MS 200 + +/* Register definitions for syscon piarbctl registers */ +#define PIARBCTL_CAM 0x00 +#define PIARBCTL_SPLITTER 0x04 +#define PIARBCTL_MISC 0x08 +#define PIARBCTL_MISC_SECURE_MASK 0x80000000 +#define PIARBCTL_MISC_USB_SELECT_MASK 0x40000000 +#define PIARBCTL_MISC_USB_4G_SDRAM_MASK 0x20000000 +#define PIARBCTL_MISC_USB_PRIORITY_MASK 0x000f0000 +#define PIARBCTL_MISC_USB_MEM_PAGE_MASK 0x0000f000 +#define PIARBCTL_MISC_CAM1_MEM_PAGE_MASK 0x00000f00 +#define PIARBCTL_MISC_CAM0_MEM_PAGE_MASK 0x000000f0 +#define PIARBCTL_MISC_SATA_PRIORITY_MASK 0x0000000f +#define PIARBCTL_USB_M_ASB_CTRL 0x10 + +#define PIARBCTL_MISC_USB_ONLY_MASK \ + (PIARBCTL_MISC_USB_SELECT_MASK | \ + PIARBCTL_MISC_USB_4G_SDRAM_MASK | \ + PIARBCTL_MISC_USB_PRIORITY_MASK | \ + PIARBCTL_MISC_USB_MEM_PAGE_MASK) + /* Register definitions for the USB CTRL block */ #define USB_CTRL_SETUP 0x00 #define USB_CTRL_SETUP_STRAP_IPP_SEL_MASK 0x02000000 #define USB_CTRL_SETUP_SCB2_EN_MASK 0x00008000 +#define USB_CTRL_SETUP_tca_drv_sel_MASK 0x01000000 #define USB_CTRL_SETUP_SCB1_EN_MASK 0x00004000 #define USB_CTRL_SETUP_SOFT_SHUTDOWN_MASK 0x00000200 #define USB_CTRL_SETUP_IPP_MASK 0x00000020 @@ -29,11 +52,73 @@ #define USB_CTRL_USB_DEVICE_CTL1 0x10 #define USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK 0x00000003 +/* Register definitions for the USB_PHY block in 7211b0 */ +#define USB_PHY_PLL_LDO_CTL 0x08 +#define USB_PHY_PLL_LDO_CTL_AFE_CORERDY_MASK 0x00000004 +#define USB_PHY_UTMI_CTL_1 0x04 +#define USB_PHY_UTMI_CTL_1_PHY_MODE_MASK 0x0000000c +#define USB_PHY_UTMI_CTL_1_PHY_MODE_SHIFT 2 +#define USB_PHY_STATUS 0x20 +#define USB_PHY_STATUS_pll_lock_MASK 0x00000001 + +/* Register definitions for the MDIO registers in the DWC2 block of + * the 7211b0. + * NOTE: The PHY's MDIO registers are only accessible through the + * legacy DesignWare USB controller even though it's not being used. + */ +#define USB_GMDIOCSR 0 +#define USB_GMDIOGEN 4 + + +static void usb_mdio_write_7211b0(struct brcm_usb_init_params *params, + uint8_t addr, uint16_t data) +{ + void __iomem *usb_mdio = params->regs[BRCM_REGS_USB_MDIO]; + + addr &= 0x1f; /* 5-bit address */ + brcm_usb_writel(0xffffffff, usb_mdio + USB_GMDIOGEN); + while (brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & (1<<31)) + ; + brcm_usb_writel(0x59020000 | (addr << 18) | data, + usb_mdio + USB_GMDIOGEN); + while (brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & (1<<31)) + ; + brcm_usb_writel(0x00000000, usb_mdio + USB_GMDIOGEN); + while (brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & (1<<31)) + ; +} + +static uint16_t __maybe_unused usb_mdio_read_7211b0( + struct brcm_usb_init_params *params, uint8_t addr) +{ + void __iomem *usb_mdio = params->regs[BRCM_REGS_USB_MDIO]; + + addr &= 0x1f; /* 5-bit address */ + brcm_usb_writel(0xffffffff, usb_mdio + USB_GMDIOGEN); + while (brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & (1<<31)) + ; + brcm_usb_writel(0x69020000 | (addr << 18), usb_mdio + USB_GMDIOGEN); + while (brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & (1<<31)) + ; + brcm_usb_writel(0x00000000, usb_mdio + USB_GMDIOGEN); + while (brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & (1<<31)) + ; + return brcm_usb_readl(usb_mdio + USB_GMDIOCSR) & 0xffff; +} + +static void usb2_eye_fix_7211b0(struct brcm_usb_init_params *params) +{ + /* select bank */ + usb_mdio_write_7211b0(params, 0x1f, 0x80a0); + + /* Set the eye */ + usb_mdio_write_7211b0(params, 0x0a, 0xc6a0); +} static void xhci_soft_reset(struct brcm_usb_init_params *params, int on_off) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; /* Assert reset */ if (on_off) @@ -45,7 +130,7 @@ static void xhci_soft_reset(struct brcm_usb_init_params *params, static void usb_init_ipp(struct brcm_usb_init_params *params) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; u32 reg; u32 orig_reg; @@ -72,10 +157,18 @@ static void usb_init_ipp(struct brcm_usb_init_params *params) msleep(50); } +static void syscon_piarbctl_init(struct regmap *rmap) +{ + /* Switch from legacy USB OTG controller to new STB USB controller */ + regmap_update_bits(rmap, PIARBCTL_MISC, PIARBCTL_MISC_USB_ONLY_MASK, + PIARBCTL_MISC_USB_SELECT_MASK | + PIARBCTL_MISC_USB_4G_SDRAM_MASK); +} + static void usb_init_common(struct brcm_usb_init_params *params) { u32 reg; - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; pr_debug("%s\n", __func__); @@ -100,6 +193,45 @@ static void usb_init_common(struct brcm_usb_init_params *params) } } +static void usb_init_common_7211b0(struct brcm_usb_init_params *params) +{ + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; + void __iomem *usb_phy = params->regs[BRCM_REGS_USB_PHY]; + int timeout_ms = PHY_LOCK_TIMEOUT_MS; + u32 reg; + + if (params->syscon_piarbctl) + syscon_piarbctl_init(params->syscon_piarbctl); + + /* Init the PHY */ + reg = brcm_usb_readl(usb_phy + USB_PHY_PLL_LDO_CTL); + reg |= USB_PHY_PLL_LDO_CTL_AFE_CORERDY_MASK; + brcm_usb_writel(reg, usb_phy + USB_PHY_PLL_LDO_CTL); + + /* wait for lock */ + while (timeout_ms-- > 0) { + reg = brcm_usb_readl(usb_phy + USB_PHY_STATUS); + if (reg & USB_PHY_STATUS_pll_lock_MASK) + break; + usleep_range(1000, 2000); + } + + /* Set the PHY_MODE */ + reg = brcm_usb_readl(usb_phy + USB_PHY_UTMI_CTL_1); + reg &= ~USB_PHY_UTMI_CTL_1_PHY_MODE_MASK; + reg |= params->mode << USB_PHY_UTMI_CTL_1_PHY_MODE_SHIFT; + brcm_usb_writel(reg, usb_phy + USB_PHY_UTMI_CTL_1); + + /* Fix the incorrect default */ + reg = brcm_usb_readl(ctrl + USB_CTRL_SETUP); + reg &= ~USB_CTRL_SETUP_tca_drv_sel_MASK; + brcm_usb_writel(reg, ctrl + USB_CTRL_SETUP); + + usb_init_common(params); + + usb2_eye_fix_7211b0(params); +} + static void usb_init_xhci(struct brcm_usb_init_params *params) { pr_debug("%s\n", __func__); @@ -109,7 +241,7 @@ static void usb_init_xhci(struct brcm_usb_init_params *params) static void usb_uninit_common(struct brcm_usb_init_params *params) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; pr_debug("%s\n", __func__); @@ -127,7 +259,7 @@ static void usb_uninit_xhci(struct brcm_usb_init_params *params) static int usb_get_dual_select(struct brcm_usb_init_params *params) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; u32 reg = 0; pr_debug("%s\n", __func__); @@ -139,7 +271,7 @@ static int usb_get_dual_select(struct brcm_usb_init_params *params) static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; u32 reg; pr_debug("%s\n", __func__); @@ -161,6 +293,16 @@ static const struct brcm_usb_init_ops bcm7216_ops = { .set_dual_select = usb_set_dual_select, }; +static const struct brcm_usb_init_ops bcm7211b0_ops = { + .init_ipp = usb_init_ipp, + .init_common = usb_init_common_7211b0, + .init_xhci = usb_init_xhci, + .uninit_common = usb_uninit_common, + .uninit_xhci = usb_uninit_xhci, + .get_dual_select = usb_get_dual_select, + .set_dual_select = usb_set_dual_select, +}; + void brcm_usb_dvr_init_7216(struct brcm_usb_init_params *params) { @@ -169,3 +311,12 @@ void brcm_usb_dvr_init_7216(struct brcm_usb_init_params *params) params->family_name = "7216"; params->ops = &bcm7216_ops; } + +void brcm_usb_dvr_init_7211b0(struct brcm_usb_init_params *params) +{ + + pr_debug("%s\n", __func__); + + params->family_name = "7211"; + params->ops = &bcm7211b0_ops; +} diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c index 5d5a916ed46f..e28e4b1a3f21 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c @@ -401,7 +401,7 @@ void usb_ctrl_unset_family(struct brcm_usb_init_params *params, u32 mask; mask = params->usb_reg_bits_map[field]; - brcm_usb_ctrl_unset(params->ctrl_regs + reg_offset, mask); + brcm_usb_ctrl_unset(params->regs[BRCM_REGS_CTRL] + reg_offset, mask); }; static inline @@ -411,7 +411,7 @@ void usb_ctrl_set_family(struct brcm_usb_init_params *params, u32 mask; mask = params->usb_reg_bits_map[field]; - brcm_usb_ctrl_set(params->ctrl_regs + reg_offset, mask); + brcm_usb_ctrl_set(params->regs[BRCM_REGS_CTRL] + reg_offset, mask); }; static u32 brcmusb_usb_mdio_read(void __iomem *ctrl_base, u32 reg, int mode) @@ -544,7 +544,7 @@ static void brcmusb_usb3_pll_54mhz(struct brcm_usb_init_params *params) { u32 ofs; int ii; - void __iomem *ctrl_base = params->ctrl_regs; + void __iomem *ctrl_base = params->regs[BRCM_REGS_CTRL]; /* * On newer B53 based SoC's, the reference clock for the @@ -625,7 +625,7 @@ static void brcmusb_usb3_ssc_enable(void __iomem *ctrl_base) static void brcmusb_usb3_phy_workarounds(struct brcm_usb_init_params *params) { - void __iomem *ctrl_base = params->ctrl_regs; + void __iomem *ctrl_base = params->regs[BRCM_REGS_CTRL]; brcmusb_usb3_pll_fix(ctrl_base); brcmusb_usb3_pll_54mhz(params); @@ -667,7 +667,7 @@ static void brcmusb_memc_fix(struct brcm_usb_init_params *params) static void brcmusb_usb3_otp_fix(struct brcm_usb_init_params *params) { - void __iomem *xhci_ec_base = params->xhci_ec_regs; + void __iomem *xhci_ec_base = params->regs[BRCM_REGS_XHCI_EC]; u32 val; if (params->family_id != 0x74371000 || xhci_ec_base == 0) @@ -680,8 +680,8 @@ static void brcmusb_usb3_otp_fix(struct brcm_usb_init_params *params) brcm_usb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); /* Reset USB 3.0 PHY for workaround to take effect */ - USB_CTRL_UNSET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB); - USB_CTRL_SET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB); + USB_CTRL_UNSET(params->regs[BRCM_REGS_CTRL], USB30_CTL1, PHY3_RESETB); + USB_CTRL_SET(params->regs[BRCM_REGS_CTRL], USB30_CTL1, PHY3_RESETB); } static void brcmusb_xhci_soft_reset(struct brcm_usb_init_params *params, @@ -740,7 +740,7 @@ static enum brcm_family_type get_family_type( static void usb_init_ipp(struct brcm_usb_init_params *params) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; u32 reg; u32 orig_reg; @@ -786,7 +786,7 @@ static void usb_init_ipp(struct brcm_usb_init_params *params) static void usb_init_common(struct brcm_usb_init_params *params) { u32 reg; - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; /* Clear any pending wake conditions */ reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); @@ -866,7 +866,7 @@ static void usb_init_common(struct brcm_usb_init_params *params) static void usb_init_eohci(struct brcm_usb_init_params *params) { u32 reg; - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB20_HC_RESETB)) USB_CTRL_SET_FAMILY(params, USB_PM, USB20_HC_RESETB); @@ -902,7 +902,7 @@ static void usb_init_eohci(struct brcm_usb_init_params *params) static void usb_init_xhci(struct brcm_usb_init_params *params) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; USB_CTRL_UNSET(ctrl, USB30_PCTL, PHY3_IDDQ_OVERRIDE); /* 1 millisecond - for USB clocks to settle down */ @@ -944,12 +944,13 @@ static void usb_uninit_eohci(struct brcm_usb_init_params *params) static void usb_uninit_xhci(struct brcm_usb_init_params *params) { brcmusb_xhci_soft_reset(params, 1); - USB_CTRL_SET(params->ctrl_regs, USB30_PCTL, PHY3_IDDQ_OVERRIDE); + USB_CTRL_SET(params->regs[BRCM_REGS_CTRL], USB30_PCTL, + PHY3_IDDQ_OVERRIDE); } static int usb_get_dual_select(struct brcm_usb_init_params *params) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; u32 reg = 0; pr_debug("%s\n", __func__); @@ -963,7 +964,7 @@ static int usb_get_dual_select(struct brcm_usb_init_params *params) static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; u32 reg; pr_debug("%s\n", __func__); @@ -980,7 +981,7 @@ static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) static void usb_wake_enable(struct brcm_usb_init_params *params, int enable) { - void __iomem *ctrl = params->ctrl_regs; + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; if (enable) USB_CTRL_SET(ctrl, USB_PM, RMTWKUP_EN); diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index 571ccae48e3f..66363b04d778 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -6,12 +6,21 @@ #ifndef _USB_BRCM_COMMON_INIT_H #define _USB_BRCM_COMMON_INIT_H +#include + #define USB_CTLR_MODE_HOST 0 #define USB_CTLR_MODE_DEVICE 1 #define USB_CTLR_MODE_DRD 2 #define USB_CTLR_MODE_TYPEC_PD 3 -struct brcm_usb_init_params; +enum brcmusb_reg_sel { + BRCM_REGS_CTRL = 0, + BRCM_REGS_XHCI_EC, + BRCM_REGS_XHCI_GBL, + BRCM_REGS_USB_PHY, + BRCM_REGS_USB_MDIO, + BRCM_REGS_MAX +}; #define USB_CTRL_REG(base, reg) ((void *)base + USB_CTRL_##reg) #define USB_XHCI_EC_REG(base, reg) ((void *)base + USB_XHCI_EC_##reg) @@ -41,9 +50,7 @@ struct brcm_usb_init_ops { }; struct brcm_usb_init_params { - void __iomem *ctrl_regs; - void __iomem *xhci_ec_regs; - void __iomem *xhci_gbl_regs; + void __iomem *regs[BRCM_REGS_MAX]; int ioc; int ipp; int mode; @@ -53,10 +60,12 @@ struct brcm_usb_init_params { const char *family_name; const u32 *usb_reg_bits_map; const struct brcm_usb_init_ops *ops; + struct regmap *syscon_piarbctl; }; void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params); void brcm_usb_dvr_init_7216(struct brcm_usb_init_params *params); +void brcm_usb_dvr_init_7211b0(struct brcm_usb_init_params *params); static inline u32 brcm_usb_readl(void __iomem *addr) { diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index 64379ede480e..5f7bfa09494d 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "phy-brcm-usb-init.h" @@ -32,6 +33,11 @@ struct value_to_name_map { const char *name; }; +struct match_chip_info { + void *init_func; + u8 required_regs[BRCM_REGS_MAX + 1]; +}; + static struct value_to_name_map brcm_dr_mode_to_name[] = { { USB_CTLR_MODE_HOST, "host" }, { USB_CTLR_MODE_DEVICE, "peripheral" }, @@ -64,6 +70,10 @@ struct brcm_usb_phy_data { struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX]; }; +static s8 *node_reg_names[BRCM_REGS_MAX] = { + "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio" +}; + static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id) { struct phy *gphy = dev_id; @@ -241,15 +251,86 @@ static const struct attribute_group brcm_usb_phy_group = { .attrs = brcm_usb_phy_attrs, }; +static struct match_chip_info chip_info_7216 = { + .init_func = &brcm_usb_dvr_init_7216, + .required_regs = { + BRCM_REGS_CTRL, + BRCM_REGS_XHCI_EC, + BRCM_REGS_XHCI_GBL, + -1, + }, +}; + +static struct match_chip_info chip_info_7211b0 = { + .init_func = &brcm_usb_dvr_init_7211b0, + .required_regs = { + BRCM_REGS_CTRL, + BRCM_REGS_XHCI_EC, + BRCM_REGS_XHCI_GBL, + BRCM_REGS_USB_PHY, + BRCM_REGS_USB_MDIO, + -1, + }, +}; + +static struct match_chip_info chip_info_7445 = { + .init_func = &brcm_usb_dvr_init_7445, + .required_regs = { + BRCM_REGS_CTRL, + BRCM_REGS_XHCI_EC, + -1, + }, +}; + static const struct of_device_id brcm_usb_dt_ids[] = { { .compatible = "brcm,bcm7216-usb-phy", - .data = &brcm_usb_dvr_init_7216, + .data = &chip_info_7216, + }, + { + .compatible = "brcm,bcm7211-usb-phy", + .data = &chip_info_7211b0, + }, + { + .compatible = "brcm,brcmstb-usb-phy", + .data = &chip_info_7445, }, - { .compatible = "brcm,brcmstb-usb-phy" }, { /* sentinel */ } }; +static int brcm_usb_get_regs(struct platform_device *pdev, + enum brcmusb_reg_sel regs, + struct brcm_usb_init_params *ini) +{ + struct resource *res; + + /* Older DT nodes have ctrl and optional xhci_ec by index only */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + node_reg_names[regs]); + if (res == NULL) { + if (regs == BRCM_REGS_CTRL) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + } else if (regs == BRCM_REGS_XHCI_EC) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + /* XHCI_EC registers are optional */ + if (res == NULL) + return 0; + } + if (res == NULL) { + dev_err(&pdev->dev, "can't get %s base address\n", + node_reg_names[regs]); + return 1; + } + } + ini->regs[regs] = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ini->regs[regs])) { + dev_err(&pdev->dev, "can't map %s register space\n", + node_reg_names[regs]); + return 1; + } + return 0; +} + static int brcm_usb_phy_dvr_init(struct platform_device *pdev, struct brcm_usb_phy_data *priv, struct device_node *dn) @@ -325,9 +406,6 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev, static int brcm_usb_phy_probe(struct platform_device *pdev) { - struct resource *res_ctrl; - struct resource *res_xhciec = NULL; - struct resource *res_xhcigbl = NULL; struct device *dev = &pdev->dev; struct brcm_usb_phy_data *priv; struct phy_provider *phy_provider; @@ -335,6 +413,10 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) int err; const char *mode; const struct of_device_id *match; + void (*dvr_init)(struct brcm_usb_init_params *params); + const struct match_chip_info *info; + struct regmap *rmap; + int x; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -345,58 +427,13 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) priv->ini.product_id = brcmstb_get_product_id(); match = of_match_node(brcm_usb_dt_ids, dev->of_node); - if (match && match->data) { - void (*dvr_init)(struct brcm_usb_init_params *params); - - dvr_init = match->data; - (*dvr_init)(&priv->ini); - } else { - brcm_usb_dvr_init_7445(&priv->ini); - } + info = match->data; + dvr_init = info->init_func; + (*dvr_init)(&priv->ini); dev_dbg(dev, "Best mapping table is for %s\n", priv->ini.family_name); - /* Newer DT node has reg-names. xhci_ec and xhci_gbl are optional. */ - res_ctrl = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl"); - if (res_ctrl != NULL) { - res_xhciec = platform_get_resource_byname(pdev, - IORESOURCE_MEM, - "xhci_ec"); - res_xhcigbl = platform_get_resource_byname(pdev, - IORESOURCE_MEM, - "xhci_gbl"); - } else { - /* Older DT node without reg-names, use index */ - res_ctrl = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res_ctrl == NULL) { - dev_err(dev, "can't get CTRL base address\n"); - return -EINVAL; - } - res_xhciec = platform_get_resource(pdev, IORESOURCE_MEM, 1); - } - priv->ini.ctrl_regs = devm_ioremap_resource(dev, res_ctrl); - if (IS_ERR(priv->ini.ctrl_regs)) { - dev_err(dev, "can't map CTRL register space\n"); - return -EINVAL; - } - if (res_xhciec) { - priv->ini.xhci_ec_regs = - devm_ioremap_resource(dev, res_xhciec); - if (IS_ERR(priv->ini.xhci_ec_regs)) { - dev_err(dev, "can't map XHCI EC register space\n"); - return -EINVAL; - } - } - if (res_xhcigbl) { - priv->ini.xhci_gbl_regs = - devm_ioremap_resource(dev, res_xhcigbl); - if (IS_ERR(priv->ini.xhci_gbl_regs)) { - dev_err(dev, "can't map XHCI Global register space\n"); - return -EINVAL; - } - } - of_property_read_u32(dn, "brcm,ipp", &priv->ini.ipp); of_property_read_u32(dn, "brcm,ioc", &priv->ini.ioc); @@ -412,6 +449,16 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) if (of_property_read_bool(dn, "brcm,has-eohci")) priv->has_eohci = true; + for (x = 0; x < BRCM_REGS_MAX; x++) { + if (info->required_regs[x] >= BRCM_REGS_MAX) + break; + + err = brcm_usb_get_regs(pdev, info->required_regs[x], + &priv->ini); + if (err) + return -EINVAL; + } + err = brcm_usb_phy_dvr_init(pdev, priv, dn); if (err) return err; @@ -431,6 +478,15 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) if (err) dev_warn(dev, "Error creating sysfs attributes\n"); + /* Get piarbctl syscon if it exists */ + rmap = syscon_regmap_lookup_by_phandle(dev->of_node, + "syscon-piarbctl"); + if (IS_ERR(rmap)) + rmap = syscon_regmap_lookup_by_phandle(dev->of_node, + "brcm,syscon-piarbctl"); + if (!IS_ERR(rmap)) + priv->ini.syscon_piarbctl = rmap; + /* start with everything off */ if (priv->has_xhci) brcm_usb_uninit_xhci(&priv->ini); From patchwork Fri Nov 15 18:42:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D95111393 for ; Fri, 15 Nov 2019 18:46:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B81602072B for ; Fri, 15 Nov 2019 18:46:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ugKJ7OsA"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iYDe8W6L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B81602072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wYFCeaWfr8rrjXVOzLPBBFuZDVlSe8uewS+PZd5+SW0=; b=ugKJ7OsA+zzQJNtfIPNp2Hp3jP vCjpn+LOgQrvfC2xQxp9EGKo+ZhzkF11854AYxcJcvZcXkUCDR5EKHOL4JW+Nkwx5gTNDO7OZY1bf VA2sJrHeNdnYVdxulY4a/poAp4Y37Wgcxg8ZtRjkmvjd6tdkG1LkMMI+kDArpuneEVUhNn8/s4J55 Dsf/8yhLDrAkcd6cQ8gsHpKzaKrxGFN0p1AzN+olsx9dnBPb/9j3QzEBSLo1wUlSUwVyM6aYo2fff aED8FqVI4gVT1atdiOrTOGMxD07iys1DshHICRdEl+hB/EH3YLjW3HFYPaDk77FNid2VEuB/YceP3 nTGs+NUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgbb-00075f-CS; Fri, 15 Nov 2019 18:46:03 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZT-0003ia-AM for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:54 +0000 Received: by mail-wr1-x441.google.com with SMTP id n1so12020569wra.10 for ; Fri, 15 Nov 2019 10:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RT3uMjCTNXctwL3ki3eO315EjLjo+qSfc5PPzuNqLtA=; b=iYDe8W6LdvP9DjVd6RsD4kC6QCPG2iOBqAvsM7kyB60OiQXRjlFCGKm7sLWB/FxO9V CgwGMyXZTq9Xgz8sYEWY2nEn8qalf/IQxoujraqnEVco/XiP8p0ujp9fOrvW6n6wz32p 8wzjaJuoG40z1SLiVg9inXiZhR0l/2NCMb5mI1wk1paN96/j9X58n/3Y6e2BBwY4WeF9 FaG82siK+7rEkDhwy9kKWajCmTwPzD4/VBwltdVImfWs3SAGHAIqvPgUCsCMdn5Ru6iX 3h3F/dzzc6MsJxC9F97Vg/KWKO4vxx+kDlRL4UfXNCZF2fOMgMOk9XqdrejhJXiuSjOK KDtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RT3uMjCTNXctwL3ki3eO315EjLjo+qSfc5PPzuNqLtA=; b=oBt7mjQSiXcg6q2wsr8ZIy/lqY4265elgLiube/Uqq8A3upsy3S/tdUD8A7URGYonm U70OWbajE7ZoTziJitIOUFu6bi4VwIMxzHyvXkDhN2i9+wgCfSWndztwg5FKnHMkQ9eI QNvaB6NwoHYusDm3YSayhPXhtefaJrnQBfZOS+othhmadZ/95znQa5DT0palC2QXNlbS f8ZANTuZBtE8z64PWNKosbm97vgFSS5ST37XhVm2MR/3PxVGfhkcpsnFmUKKvEm+4vTQ oVP2zKWOerj4BiNtfn9AoHvIifb7vWMonhN80J7SExdEzaPQPWr8qnrhQFkVMDpCRVd8 IQ9g== X-Gm-Message-State: APjAAAUu62J9pjgwi8ukipQwdTs4V5+St20ZwcqrPCQl3u7rD0RkI1Vv et2+eatMZ7l0Z1NUl2fRYE8IphtXFX8= X-Google-Smtp-Source: APXvYqx1O7NWz3OUqruHqZXfbPWuSF7kLyTjWS2L9IkOwef3woCiL3C8rFG9rh07B5vhajz2ChFeNg== X-Received: by 2002:adf:f60a:: with SMTP id t10mr16735033wrp.29.1573843429463; Fri, 15 Nov 2019 10:43:49 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:49 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 09/13] phy: usb: fix driver to defer on clk_get defer Date: Fri, 15 Nov 2019 13:42:19 -0500 Message-Id: <20191115184223.41504-10-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104351_373915_F818B116 X-CRM114-Status: GOOD ( 11.58 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Handle defer on clk_get because the new SCMI clock driver comes up after this driver. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index 5f7bfa09494d..c82d7ec15334 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -341,6 +341,8 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev, priv->usb_20_clk = of_clk_get_by_name(dn, "sw_usb"); if (IS_ERR(priv->usb_20_clk)) { + if (PTR_ERR(priv->usb_20_clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; dev_info(dev, "Clock not found in Device Tree\n"); priv->usb_20_clk = NULL; } @@ -371,6 +373,8 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev, priv->usb_30_clk = of_clk_get_by_name(dn, "sw_usb3"); if (IS_ERR(priv->usb_30_clk)) { + if (PTR_ERR(priv->usb_30_clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; dev_info(dev, "USB3.0 clock not found in Device Tree\n"); priv->usb_30_clk = NULL; @@ -382,6 +386,8 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev, priv->suspend_clk = clk_get(dev, "usb0_freerun"); if (IS_ERR(priv->suspend_clk)) { + if (PTR_ERR(priv->suspend_clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; dev_err(dev, "Suspend Clock not found in Device Tree\n"); priv->suspend_clk = NULL; } From patchwork Fri Nov 15 18:42:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A7DB13B2 for ; Fri, 15 Nov 2019 18:46:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 392112072B for ; Fri, 15 Nov 2019 18:46:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="byruiEoS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AUJy6L0F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 392112072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RBeNdZ5HoXtmHiw9zl+hzoiz17QmI2lc1nH2yc4I0gs=; b=byruiEoSdIkOrThsk0or4Np0RA J1uucoZRx2Gt0XlSbFlqDo40kR284po5bZxnF1V2BCfjgW3NXrQIltdOlGLPKFDiEajHK8HRlUQa0 4Jzzksg8ZXSqyYXSLQ5mYKk4Xnwbgaf5F4e7Rf8Msm5v/Qy+pHmcoRkJXfvlSgAMStpzvbm6L+uTF bhRH1I9RkTBZrY5I29KE/L98U7729qlsuQDUERc8LfA55L2aWo7VDdgu1lvyiHgYAH6wCY2375eTh KWwCTbIQdteIBVKimH8laZ1tbFvuewKKzYvfhH0oxijPXbFyhmyQvSkGVexfyjvF6cWZTeUxIaZoS ywNC/IzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgbp-0007eD-H0; Fri, 15 Nov 2019 18:46:17 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZV-0003kb-0a for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:55 +0000 Received: by mail-wm1-x343.google.com with SMTP id u18so10655680wmc.3 for ; Fri, 15 Nov 2019 10:43:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=44lDiZC/HyWHizJUTFlT+jmrIvxAJf5o2GDXJq7Fi20=; b=AUJy6L0FiPANesawRIslnabTIItR6XMOS4WHYQ3D6pc8miNDb/Z5X11gNI1eTl9q5q n3GmIiY8X9Nr7Lk5icpkz585MPqmz9RqdiCLJ+JJBHr9Yfk9/vSAAugoXB1FA5L7dSqi 2AO3pQaBc65xkk/eh4X21dXAGMs0Nls620cHZyeBymyKKUUjHI/E+zU/NFppB9oTvxt3 5jyhjIxeYtTiYjsC6NiptPWC8kjJRQBCIg2oiqPBsr8M0YOQlhj3CjhgSHI4ZWL4tWyK /EPJEkyZQSoNIel0I+TSbq8m8cRC/Q1U3lboURLdfxOxeVrtMYWNI5m420a24NxJGUS1 G9Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=44lDiZC/HyWHizJUTFlT+jmrIvxAJf5o2GDXJq7Fi20=; b=PNbOHWUTq8fjBbQA9DnVqcZohE44YOD+2U3LZZ3rW86WykwKaIWALJ1T6DTaEbSBVz zeobg/0cFqcVWAATWQHU95wp/bNITrLVhFmJA8N/mMghCW5eMvX/RGUkG/lghLQ//S4c fqAV0MuIRdHN+AaqRa2t2EjRy7Jwgznk4tHv9dE1y20LsdQ1z3+dclp9+70SbH4ipxJp 6Zfbx8q7g4rHSlgPbkLZEl9nMdgOQwLesmHB5+vJWeVNm1etENEHPu5tJP92TwmDCOHj ISTQgo8Y5EJzwfjNCenl1V6cWw4erQ8dzufnLsMfi2zu1dgWLW/IZ9IBOSVlxJFv2vw9 5EyQ== X-Gm-Message-State: APjAAAWjZ014fcUE3N3bk8DZoLjC8m8BT1jUwCTc1zxzvPTfjRYO8d9O CxEkfG26/v/3UYaQ1nm+vO0= X-Google-Smtp-Source: APXvYqwsBuwArKC2zsEagHcuDz0VELwiJxoMPPhcSFoPYDNRSb2qkuibjkIOivEmh4xMhP4E639SOg== X-Received: by 2002:a05:600c:2041:: with SMTP id p1mr15806760wmg.11.1573843431625; Fri, 15 Nov 2019 10:43:51 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:51 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 10/13] phy: usb: PHY's MDIO registers not accessible without device installed Date: Fri, 15 Nov 2019 13:42:20 -0500 Message-Id: <20191115184223.41504-11-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104353_096798_014B87B2 X-CRM114-Status: GOOD ( 13.33 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When there is no device connected and FSM is enabled, the XHCI puts the PHY into suspend mode. When the PHY is put into suspend mode the USB LDO powers down the PHY. This causes the MDIO to be inaccessible and its registers reset to default. The fix is to disable FSM. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c index bf138867efb1..fe3f653c64a7 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c @@ -56,6 +56,7 @@ #define USB_PHY_PLL_LDO_CTL 0x08 #define USB_PHY_PLL_LDO_CTL_AFE_CORERDY_MASK 0x00000004 #define USB_PHY_UTMI_CTL_1 0x04 +#define USB_PHY_UTMI_CTL_1_POWER_UP_FSM_EN_MASK 0x00000800 #define USB_PHY_UTMI_CTL_1_PHY_MODE_MASK 0x0000000c #define USB_PHY_UTMI_CTL_1_PHY_MODE_SHIFT 2 #define USB_PHY_STATUS 0x20 @@ -229,6 +230,14 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) usb_init_common(params); + /* + * Disable FSM, otherwise the PHY will auto suspend when no + * device is connected and will be reset on resume. + */ + reg = brcm_usb_readl(usb_phy + USB_PHY_UTMI_CTL_1); + reg &= ~USB_PHY_UTMI_CTL_1_POWER_UP_FSM_EN_MASK; + brcm_usb_writel(reg, usb_phy + USB_PHY_UTMI_CTL_1); + usb2_eye_fix_7211b0(params); } From patchwork Fri Nov 15 18:42:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90D9913B2 for ; Fri, 15 Nov 2019 18:46:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D1312072B for ; Fri, 15 Nov 2019 18:46:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AoN4Jk4D"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mr86IiEk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D1312072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Ev2W98bnpp9pSmLpVAP+rz/M5E7e41UOQe6CB7CFzZw=; b=AoN4Jk4DuR7l3QW4/5e0Zf603N IM4HksVfV/yFuDYpo59gPU62XE8DgCtGpn4I6e7T3ybrGp1eiuG9RjzRhTyUOiuDhnvnrqfu9ig51 IU+I5MMe/AWBzNgy8w2hRu+JQKFFemtvavhxFq0ChQLke5tWeI3HIIkdhh2j/a0rwPyJw6JsdnYlJ RTK41tBHHbvpKeY1ODlTuRyW1ybKwoeRm0He+/X1i4T157VBzwNYVIMlmxS8qPQvPomPIvt/595Hy wYJpn8l/ivf/FbKXypByQRHjcyZZS7+Ou3qRX7574TVpr7YYfWZ+q9r21e85drpA5O0EbTar18JFX 1BZ6hM6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgc5-0007tc-3e; Fri, 15 Nov 2019 18:46:33 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZX-0003mG-DC for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:57 +0000 Received: by mail-wm1-x343.google.com with SMTP id z26so10613760wmi.4 for ; Fri, 15 Nov 2019 10:43:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MFlnOn0CAyQafh0Ou2lpY54Ga03K/6YVfFICBBVyXck=; b=mr86IiEkh6BMzmVhCk3kgov07rgov4gwotKNoFw+me9PSEVD86+veJHoXHDyaY8vle BaSP7G7ZjnZP0j9WMGLdxvykaNUocXqaCCXUSci7TRPOeFbN8HUtxpvVemnzyHPURVFT gghQLhflIrHtxfkRBv2xTBRdBYxUN7U8WGNiK6rRri+yCgTJU3ISFKtJa9W7ukJA9Yj/ NFbLkEWxlIfTTkh732tcDcrFebUHb9sA17rVudEFd5Y+3KdkQXfGusVgx/WMjI/EETGt l5dg4b5SzcCPARD4+RHCKSuSBBE0zDEfaEn44ojlOhuEb/QFhRiIF4moOzz5ibPCQKGs u31g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MFlnOn0CAyQafh0Ou2lpY54Ga03K/6YVfFICBBVyXck=; b=o473UAdy49XJYSgBC12sBqzPr8gGliKtYgtLVU4HI9Pd8iVyh2cXtx+3JKmokiVcgg U8+UEDbNkx2xniZDYkN3rmtgv9S5QVmsJqUlxdRo+dgt8O/UDMhSSuXUEE2/SYsbQMbC 4S+Bl/Xx9Q9SrDM5CSMDbXGxVpnqZEbV2c9AXbIW7Ixj0ZkloDdYk+XPur6ICoKv/nPI VoNfN7nwBCc8blsRsXsLK/+A5tR7ZlHhD+9cL5yBiW8bCDVQ2c0/bOEBNewzAjWV3Rp+ J5/nD8FZJmQjc0QZj2tUQURpYks4ssbSd0+j5Zcxv0Rhup9+w/ZoCQ+yloo/5NgEMwO+ 3kcw== X-Gm-Message-State: APjAAAVwIwIt4RewYLXJ0p/axv6aXvmayPDNAtMd17zeFjNCFIH7abe5 r97jq4ZzD3dbyCe/vj5m9Jg= X-Google-Smtp-Source: APXvYqw3Oh5ANrOKWgIZchBUqjbmhrA+8Tx4boW7ZEkB/jUJhDm2lKldwdzgc97981Uz5S5BPS488g== X-Received: by 2002:a1c:dd06:: with SMTP id u6mr17059416wmg.109.1573843433848; Fri, 15 Nov 2019 10:43:53 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:53 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 11/13] phy: usb: bdc: Fix occasional failure with BDC on 7211 Date: Fri, 15 Nov 2019 13:42:21 -0500 Message-Id: <20191115184223.41504-12-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104355_489792_506621CA X-CRM114-Status: GOOD ( 18.19 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The BDC "Read Transaction Size" needs to be changed from 1024 bytes to 256 bytes to prevent occasional transaction failures. Signed-off-by: Al Cooper --- .../phy/broadcom/phy-brcm-usb-init-synopsis.c | 18 +++++++++++++++ drivers/phy/broadcom/phy-brcm-usb-init.h | 1 + drivers/phy/broadcom/phy-brcm-usb.c | 23 +++++++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c index fe3f653c64a7..c6504649d307 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c @@ -70,6 +70,11 @@ #define USB_GMDIOCSR 0 #define USB_GMDIOGEN 4 +/* Register definitions for the BDC EC block in 7211b0 */ +#define BDC_EC_AXIRDA 0x0c +#define BDC_EC_AXIRDA_RTS_MASK 0xf0000000 +#define BDC_EC_AXIRDA_RTS_SHIFT 28 + static void usb_mdio_write_7211b0(struct brcm_usb_init_params *params, uint8_t addr, uint16_t data) @@ -198,6 +203,7 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) { void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; void __iomem *usb_phy = params->regs[BRCM_REGS_USB_PHY]; + void __iomem *bdc_ec = params->regs[BRCM_REGS_BDC_EC]; int timeout_ms = PHY_LOCK_TIMEOUT_MS; u32 reg; @@ -230,6 +236,18 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) usb_init_common(params); + /* + * The BDC controller will get occasional failures with + * the default "Read Transaction Size" of 6 (1024 bytes). + * Set it to 4 (256 bytes). + */ + if ((params->mode != USB_CTLR_MODE_HOST) && bdc_ec) { + reg = brcm_usb_readl(bdc_ec + BDC_EC_AXIRDA); + reg &= ~BDC_EC_AXIRDA_RTS_MASK; + reg |= (0x4 << BDC_EC_AXIRDA_RTS_SHIFT); + brcm_usb_writel(reg, bdc_ec + BDC_EC_AXIRDA); + } + /* * Disable FSM, otherwise the PHY will auto suspend when no * device is connected and will be reset on resume. diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index 66363b04d778..570bd9d8c9ec 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -19,6 +19,7 @@ enum brcmusb_reg_sel { BRCM_REGS_XHCI_GBL, BRCM_REGS_USB_PHY, BRCM_REGS_USB_MDIO, + BRCM_REGS_BDC_EC, BRCM_REGS_MAX }; diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index c82d7ec15334..cc5763ace3ad 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -36,6 +36,7 @@ struct value_to_name_map { struct match_chip_info { void *init_func; u8 required_regs[BRCM_REGS_MAX + 1]; + u8 optional_reg; }; static struct value_to_name_map brcm_dr_mode_to_name[] = { @@ -71,7 +72,7 @@ struct brcm_usb_phy_data { }; static s8 *node_reg_names[BRCM_REGS_MAX] = { - "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio" + "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec" }; static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id) @@ -271,6 +272,7 @@ static struct match_chip_info chip_info_7211b0 = { BRCM_REGS_USB_MDIO, -1, }, + .optional_reg = BRCM_REGS_BDC_EC, }; static struct match_chip_info chip_info_7445 = { @@ -300,7 +302,8 @@ static const struct of_device_id brcm_usb_dt_ids[] = { static int brcm_usb_get_regs(struct platform_device *pdev, enum brcmusb_reg_sel regs, - struct brcm_usb_init_params *ini) + struct brcm_usb_init_params *ini, + bool optional) { struct resource *res; @@ -317,7 +320,13 @@ static int brcm_usb_get_regs(struct platform_device *pdev, return 0; } if (res == NULL) { - dev_err(&pdev->dev, "can't get %s base address\n", + if (optional) { + dev_dbg(&pdev->dev, + "Optional reg %s not found\n", + node_reg_names[regs]); + return 0; + } + dev_err(&pdev->dev, "can't get %s base addr\n", node_reg_names[regs]); return 1; } @@ -460,7 +469,13 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) break; err = brcm_usb_get_regs(pdev, info->required_regs[x], - &priv->ini); + &priv->ini, false); + if (err) + return -EINVAL; + } + if (info->optional_reg) { + err = brcm_usb_get_regs(pdev, info->optional_reg, + &priv->ini, true); if (err) return -EINVAL; } From patchwork Fri Nov 15 18:42:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7230E1393 for ; Fri, 15 Nov 2019 18:46:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CB7E2072D for ; Fri, 15 Nov 2019 18:46:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z9Linsur"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZfQzyGBT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CB7E2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=nc+AtbV5aSaYV6OM6MnSGAcrPG3VAXIXyShXeOZzDGY=; b=Z9LinsurDauvBzPCZj5cv3tgVu D9Ewe90JrTadzryMhjS+Q1DzIf9MNMV70QN0M+YvK2qhS2ebQ8edPYFz1ZS1zNCOOGHK46ebOInJr QHicBOShprl/ihOcjHQJEsHq0GOeyftNwqXKGaqUC6GK1RCnsJWOV7uKf5trxv3+Fn+sn6JjBnjbs ksMN4dlVzjZXctJaM+VR9ZUYQ2ezrbJ011vRqBS2eoW6Vv0Tf9GgnkXbi93kJKvN/m70cycOLdWsI l5cUoF3PD9rM4sNVMiSOm1yUAG13dGZC0ixkIXfaAa4ktq05rbWAgWSNtntrctKhcmtPYD612NZw8 +2toKseg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgcM-0008C9-Jb; Fri, 15 Nov 2019 18:46:50 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZZ-0003oE-QY for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:43:59 +0000 Received: by mail-wr1-x441.google.com with SMTP id s5so12070491wrw.2 for ; Fri, 15 Nov 2019 10:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wS4OYwLXLEvBtINm/7GwVk3W/9nI5ZzRdQ3AYe/w/RE=; b=ZfQzyGBTDq2JsmAF6Eh9iDl+Q8ae6hWrlfyq1qDABegjvni4ncRQe7VfUvjwF8NZOm zqDIxIfzys9VdjodVY+M+y+H4Y23arlmvL4yTcmzZyH2WBG+dCAvYIUxSV1UPQjw5zI6 2kUubxMAG/576F7xmvw+IHx3iBzS7qPXTzLjKhM44OHG7CY4rBS77k9gnqwkvOI9KDYZ WrtUkiK5hOPFyrrW3YC8xUVygOMuS3UWCsnlpQbBSCGcX9bP0WvjSN13B2FpG/b2FkAp 0Rr/XhxLZFXTZSWI0CiMysGIAvsl1do3BL0JXEYwRQRsvYnTS/FiHQ+fZGe9NBuJWEUH pPSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wS4OYwLXLEvBtINm/7GwVk3W/9nI5ZzRdQ3AYe/w/RE=; b=jh0CawW7lOOoxdzlY2PtjT+3fuW1GZnsKXg12zDAQYnZyCXCq43lcts1LoAOzEKmxg hCy5YoQCnvC+Vf6acA2tFwARaum+DEPsbYEbM1g0fnbCC6iAkx4rHshdxqko00virPws yK8yTojkRDJ80N9gUtoYI4chfCiUYB5oUGj3W7LsOUIYyelVJh/aE84dlxvJF+Hp+LOU 3jFpH2f+sf3gtQPVa7Rr58c97l1Y193aPFnNbGFZxjWHPVNEdrYB+pHwovNMpqpjCndV 2leCr929ZKxBJdRWxey9AqLWRaxUuCbNNm0fHIUz0mMs+xpsjBfjDiggXQo9CDs3pJys sKMg== X-Gm-Message-State: APjAAAUKEt3WTYVpVsvGK8NtxR2iC0f5t4xv2wCVXB7Ye2kC1UhVwHap v8Ufkvd/NFt6Bmo4E7JHit0= X-Google-Smtp-Source: APXvYqx5Ackgu5oO7MlkxDLNeqrXtQzAqtgQjJXWKc6eQCl5NZT10rv9zLGyYs9Wmoopnoh/iyFT7A== X-Received: by 2002:adf:de86:: with SMTP id w6mr16923037wrl.220.1573843436058; Fri, 15 Nov 2019 10:43:56 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:55 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 12/13] phy: usb: USB driver is crashing during S3 resume on 7216 Date: Fri, 15 Nov 2019 13:42:22 -0500 Message-Id: <20191115184223.41504-13-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104357_934556_0CC3120D X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This is a result of the USB 2.0 clocks not being disabled/enabled during suspend/resume on XHCI only systems. Signed-off-by: Al Cooper --- drivers/phy/broadcom/phy-brcm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index cc5763ace3ad..1ab44f54244b 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -543,7 +543,7 @@ static int brcm_usb_phy_suspend(struct device *dev) brcm_usb_wake_enable(&priv->ini, true); if (priv->phys[BRCM_USB_PHY_3_0].inited) clk_disable_unprepare(priv->usb_30_clk); - if (priv->phys[BRCM_USB_PHY_2_0].inited) + if (priv->phys[BRCM_USB_PHY_2_0].inited || !priv->has_eohci) clk_disable_unprepare(priv->usb_20_clk); if (priv->wake_irq >= 0) enable_irq_wake(priv->wake_irq); From patchwork Fri Nov 15 18:42:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11246971 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A127713B2 for ; Fri, 15 Nov 2019 18:47:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F9812072D for ; Fri, 15 Nov 2019 18:47:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k91I64P8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gHY5niVY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F9812072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=CgdaAYxpr8IqVK469TXABSUE2ym/adKpwGnrbVX19+Y=; b=k91I64P8MA0ZV34SB15DDBSjId 701nojF4WrO607Lkz8qMNKJAL7Lrv+Lf4hzYK+E+U6ei4Jr3edsFNWadlky6p+NpgJJyk8ft9fgCW p7jbMh8ZCSAswHZO6EhT7V/IGSQkcIvdx5jN/a8eifiPcs6mUkgHvIzsFRGUA57Ht7BeKpiNLgcPE rxaRnVQMIHvp1dA2ec75aQ8tTCX3cyXtgfj/8TfgAm5e2kn0kRfyFYzIzJ1Dkippl5iOWR3uQwILJ ePeZJJI9fvNQUFiKQ0NQKDnyYIABv7KmdpvDGJR3aqcSoq/XzalpNs+DgRrenQMkvHu1N1y8IyyBA uOEhpLPw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgcb-0008Q7-6X; Fri, 15 Nov 2019 18:47:05 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVgZb-0003pv-Lx for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2019 18:44:02 +0000 Received: by mail-wr1-x441.google.com with SMTP id w9so12088690wrr.0 for ; Fri, 15 Nov 2019 10:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jnU8lpfvsI3p3uFx40QLgxidbuLZorgCLXQH1JXWdS8=; b=gHY5niVYpeIW9a1rFX7pd4UOx9Nhba5Su7FqLRhuR6Uv12zmoaqT3rmAwyDRJT4akr PgiwmP606LtANttI2lRfjQPgK3ROuvaonLJzBuTS+EZtdy98O+3K5KHgKTb9oyxlqD9l aPRWWNkqdiKPPVwymI8ISuEa4px6OanQa104HWEOvwSySiKMed9HIX9Y+UJNyLXA393S furEAvBqnBPzibQJKY+qvJTglzwshQ4KpDnFFvOIJeIs5yQFqbYVcZ/YoZCh3BV+wWDs 4fNLpxf4hrC6fAdG0KpTXc4Z/PR4nbOfUdZ1FFQpmA+CxOmg3UcAKodKHrKUnD3tCeTL dWSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jnU8lpfvsI3p3uFx40QLgxidbuLZorgCLXQH1JXWdS8=; b=c6YjJh7y14HvLoy2hObx8yWIPLRezWadrjaQv2i6HMdsJ7EvEo/SYbCLC4O/x7DuQA y2WputH3aIgSXEbs9Pe3nXv+yRgu1I0wscX08yqso5/aluOIrHanefrm/VF+yTG4URAv FCZKX5N05ioxhIhooLjd/laJ1ISyJfKD1xDVIQA61kJaT9WfP0eYCOsuoUN9I4aOrXii /jkcsW405l8I2fBFLPH534Bv3GXSZ0e6yoKA4ZOQnwdziaYpJfhSAkswIDE2oztvCNqi AIvmJprrVG+GJv0avvkYkZEwT5ythnD7+pgZt6ItzUVGXPDUoWWatVQvcQRRzJryFme4 vNRA== X-Gm-Message-State: APjAAAX1ZcKJwLjqlRgndEiI/3Ny6fuieonOWg7L9hQMDbmoxUqhr/eW FRkXMuM2nmg14SwnB6dmLE1vNWIz1Ro= X-Google-Smtp-Source: APXvYqxWOKhdlwoRyC6uWlKb5qF8E2/R7lpoHFSwL9WOPvBnKrCjsR8NCWVDjZNH6pV8ziCrcysY8w== X-Received: by 2002:adf:ec4b:: with SMTP id w11mr16404455wrn.243.1573843438174; Fri, 15 Nov 2019 10:43:58 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id g138sm2620989wmg.11.2019.11.15.10.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 10:43:57 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Subject: [PATCH v2 13/13] phy: usb: Add support for wake and USB low power mode for 7211 S2/S5 Date: Fri, 15 Nov 2019 13:42:23 -0500 Message-Id: <20191115184223.41504-14-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115184223.41504-1-alcooperx@gmail.com> References: <20191115184223.41504-1-alcooperx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_104359_855077_7530103C X-CRM114-Status: GOOD ( 21.06 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alcooperx[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Florian Fainelli , Al Cooper , Kishon Vijay Abraham I , Rob Herring , bcm-kernel-feedback-list@broadcom.com, Srinath Mannam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support for 7211 USB wake. Disable all possible 7211 USB logic for S2/S5 if USB wake is not enabled. On the 7211, the XHCI wake signal was not connected properly and only goes to the USB1_USB1_CTRL_TP_DIAG1 diagonstic register. The workaround is to have VPU code running that polls for the proper bit in the DIAG register and to wake the system when the bit is asserted. Signed-off-by: Al Cooper --- .../phy/broadcom/phy-brcm-usb-init-synopsis.c | 77 +++++++++++++++++-- drivers/phy/broadcom/phy-brcm-usb-init.c | 26 ++++--- drivers/phy/broadcom/phy-brcm-usb-init.h | 11 +-- drivers/phy/broadcom/phy-brcm-usb.c | 25 ++++-- 4 files changed, 105 insertions(+), 34 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c index c6504649d307..a2f96fce8c2f 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c @@ -26,7 +26,6 @@ #define PIARBCTL_MISC_CAM1_MEM_PAGE_MASK 0x00000f00 #define PIARBCTL_MISC_CAM0_MEM_PAGE_MASK 0x000000f0 #define PIARBCTL_MISC_SATA_PRIORITY_MASK 0x0000000f -#define PIARBCTL_USB_M_ASB_CTRL 0x10 #define PIARBCTL_MISC_USB_ONLY_MASK \ (PIARBCTL_MISC_USB_SELECT_MASK | \ @@ -51,14 +50,27 @@ #define USB_CTRL_USB_PM_STATUS 0x08 #define USB_CTRL_USB_DEVICE_CTL1 0x10 #define USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK 0x00000003 +#define USB_CTRL_TEST_PORT_CTL 0x30 +#define USB_CTRL_TEST_PORT_CTL_TPOUT_SEL_MASK 0x000000ff +#define USB_CTRL_TEST_PORT_CTL_TPOUT_SEL_PME_GEN_MASK 0x0000002e +#define USB_CTRL_TP_DIAG1 0x34 +#define USB_CTLR_TP_DIAG1_wake_MASK 0x00000002 +#define USB_CTRL_CTLR_CSHCR 0x50 +#define USB_CTRL_CTLR_CSHCR_ctl_pme_en_MASK 0x00040000 /* Register definitions for the USB_PHY block in 7211b0 */ +#define USB_PHY_PLL_CTL 0x00 +#define USB_PHY_PLL_CTL_PLL_RESETB_MASK 0x40000000 #define USB_PHY_PLL_LDO_CTL 0x08 #define USB_PHY_PLL_LDO_CTL_AFE_CORERDY_MASK 0x00000004 +#define USB_PHY_PLL_LDO_CTL_AFE_LDO_PWRDWNB_MASK 0x00000002 +#define USB_PHY_PLL_LDO_CTL_AFE_BG_PWRDWNB_MASK 0x00000001 #define USB_PHY_UTMI_CTL_1 0x04 #define USB_PHY_UTMI_CTL_1_POWER_UP_FSM_EN_MASK 0x00000800 #define USB_PHY_UTMI_CTL_1_PHY_MODE_MASK 0x0000000c #define USB_PHY_UTMI_CTL_1_PHY_MODE_SHIFT 2 +#define USB_PHY_IDDQ 0x1c +#define USB_PHY_IDDQ_phy_iddq_MASK 0x00000001 #define USB_PHY_STATUS 0x20 #define USB_PHY_STATUS_pll_lock_MASK 0x00000001 @@ -199,6 +211,17 @@ static void usb_init_common(struct brcm_usb_init_params *params) } } +static void usb_wake_enable_7211b0(struct brcm_usb_init_params *params, + bool enable) +{ + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; + + if (enable) + USB_CTRL_SET(ctrl, CTLR_CSHCR, ctl_pme_en); + else + USB_CTRL_UNSET(ctrl, CTLR_CSHCR, ctl_pme_en); +} + static void usb_init_common_7211b0(struct brcm_usb_init_params *params) { void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; @@ -210,9 +233,27 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) if (params->syscon_piarbctl) syscon_piarbctl_init(params->syscon_piarbctl); + USB_CTRL_UNSET(ctrl, USB_PM, USB_PWRDN); + + usb_wake_enable_7211b0(params, false); + if (!params->wake_enabled) { + + /* undo possible suspend settings */ + brcm_usb_writel(0, usb_phy + USB_PHY_IDDQ); + reg = brcm_usb_readl(usb_phy + USB_PHY_PLL_CTL); + reg |= USB_PHY_PLL_CTL_PLL_RESETB_MASK; + brcm_usb_writel(reg, usb_phy + USB_PHY_PLL_CTL); + + /* temporarily enable FSM so PHY comes up properly */ + reg = brcm_usb_readl(usb_phy + USB_PHY_UTMI_CTL_1); + reg |= USB_PHY_UTMI_CTL_1_POWER_UP_FSM_EN_MASK; + brcm_usb_writel(reg, usb_phy + USB_PHY_UTMI_CTL_1); + } + /* Init the PHY */ - reg = brcm_usb_readl(usb_phy + USB_PHY_PLL_LDO_CTL); - reg |= USB_PHY_PLL_LDO_CTL_AFE_CORERDY_MASK; + reg = USB_PHY_PLL_LDO_CTL_AFE_CORERDY_MASK | + USB_PHY_PLL_LDO_CTL_AFE_LDO_PWRDWNB_MASK | + USB_PHY_PLL_LDO_CTL_AFE_BG_PWRDWNB_MASK; brcm_usb_writel(reg, usb_phy + USB_PHY_PLL_LDO_CTL); /* wait for lock */ @@ -276,12 +317,36 @@ static void usb_uninit_common(struct brcm_usb_init_params *params) } +static void usb_uninit_common_7211b0(struct brcm_usb_init_params *params) +{ + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; + void __iomem *usb_phy = params->regs[BRCM_REGS_USB_PHY]; + u32 reg; + + pr_debug("%s\n", __func__); + + if (params->wake_enabled) { + USB_CTRL_SET(ctrl, TEST_PORT_CTL, TPOUT_SEL_PME_GEN); + usb_wake_enable_7211b0(params, true); + } else { + USB_CTRL_SET(ctrl, USB_PM, USB_PWRDN); + brcm_usb_writel(0, usb_phy + USB_PHY_PLL_LDO_CTL); + reg = brcm_usb_readl(usb_phy + USB_PHY_PLL_CTL); + reg &= ~USB_PHY_PLL_CTL_PLL_RESETB_MASK; + brcm_usb_writel(reg, usb_phy + USB_PHY_PLL_CTL); + brcm_usb_writel(USB_PHY_IDDQ_phy_iddq_MASK, + usb_phy + USB_PHY_IDDQ); + } + +} + static void usb_uninit_xhci(struct brcm_usb_init_params *params) { pr_debug("%s\n", __func__); - xhci_soft_reset(params, 1); + if (!params->wake_enabled) + xhci_soft_reset(params, 1); } static int usb_get_dual_select(struct brcm_usb_init_params *params) @@ -309,7 +374,6 @@ static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); } - static const struct brcm_usb_init_ops bcm7216_ops = { .init_ipp = usb_init_ipp, .init_common = usb_init_common, @@ -324,7 +388,7 @@ static const struct brcm_usb_init_ops bcm7211b0_ops = { .init_ipp = usb_init_ipp, .init_common = usb_init_common_7211b0, .init_xhci = usb_init_xhci, - .uninit_common = usb_uninit_common, + .uninit_common = usb_uninit_common_7211b0, .uninit_xhci = usb_uninit_xhci, .get_dual_select = usb_get_dual_select, .set_dual_select = usb_set_dual_select, @@ -346,4 +410,5 @@ void brcm_usb_dvr_init_7211b0(struct brcm_usb_init_params *params) params->family_name = "7211"; params->ops = &bcm7211b0_ops; + params->suspend_with_clocks = true; } diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c index e28e4b1a3f21..b477c1684825 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c @@ -783,12 +783,24 @@ static void usb_init_ipp(struct brcm_usb_init_params *params) msleep(50); } +static void usb_wake_enable(struct brcm_usb_init_params *params, + bool enable) +{ + void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; + + if (enable) + USB_CTRL_SET(ctrl, USB_PM, RMTWKUP_EN); + else + USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN); +} + static void usb_init_common(struct brcm_usb_init_params *params) { u32 reg; void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; /* Clear any pending wake conditions */ + usb_wake_enable(params, false); reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS)); @@ -935,6 +947,8 @@ static void usb_uninit_common(struct brcm_usb_init_params *params) if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) USB_CTRL_SET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN); + if (params->wake_enabled) + usb_wake_enable(params, true); } static void usb_uninit_eohci(struct brcm_usb_init_params *params) @@ -978,17 +992,6 @@ static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) } } -static void usb_wake_enable(struct brcm_usb_init_params *params, - int enable) -{ - void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; - - if (enable) - USB_CTRL_SET(ctrl, USB_PM, RMTWKUP_EN); - else - USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN); -} - static const struct brcm_usb_init_ops bcm7445_ops = { .init_ipp = usb_init_ipp, .init_common = usb_init_common, @@ -999,7 +1002,6 @@ static const struct brcm_usb_init_ops bcm7445_ops = { .uninit_xhci = usb_uninit_xhci, .get_dual_select = usb_get_dual_select, .set_dual_select = usb_set_dual_select, - .wake_enable = usb_wake_enable, }; void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index 570bd9d8c9ec..2955fdc8479b 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -46,8 +46,6 @@ struct brcm_usb_init_ops { void (*uninit_xhci)(struct brcm_usb_init_params *params); int (*get_dual_select)(struct brcm_usb_init_params *params); void (*set_dual_select)(struct brcm_usb_init_params *params, int mode); - void (*wake_enable)(struct brcm_usb_init_params *params, - int enable); }; struct brcm_usb_init_params { @@ -62,6 +60,8 @@ struct brcm_usb_init_params { const u32 *usb_reg_bits_map; const struct brcm_usb_init_ops *ops; struct regmap *syscon_piarbctl; + bool wake_enabled; + bool suspend_with_clocks; }; void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params); @@ -145,13 +145,6 @@ static inline void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini) ini->ops->uninit_xhci(ini); } -static inline void brcm_usb_wake_enable(struct brcm_usb_init_params *ini, - int enable) -{ - if (ini->ops->wake_enable) - ini->ops->wake_enable(ini, enable); -} - static inline int brcm_usb_get_dual_select(struct brcm_usb_init_params *ini) { if (ini->ops->get_dual_select) diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index 1ab44f54244b..491bbd46c5b3 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -535,16 +535,26 @@ static int brcm_usb_phy_suspend(struct device *dev) struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); if (priv->init_count) { + priv->ini.wake_enabled = device_may_wakeup(dev); if (priv->phys[BRCM_USB_PHY_3_0].inited) brcm_usb_uninit_xhci(&priv->ini); if (priv->phys[BRCM_USB_PHY_2_0].inited) brcm_usb_uninit_eohci(&priv->ini); brcm_usb_uninit_common(&priv->ini); - brcm_usb_wake_enable(&priv->ini, true); - if (priv->phys[BRCM_USB_PHY_3_0].inited) - clk_disable_unprepare(priv->usb_30_clk); - if (priv->phys[BRCM_USB_PHY_2_0].inited || !priv->has_eohci) - clk_disable_unprepare(priv->usb_20_clk); + + /* + * Handle the clocks unless needed for wake. This has + * to work for both older XHCI->3.0-clks, EOHCI->2.0-clks + * and newer XHCI->2.0-clks/3.0-clks. + */ + + if (!priv->ini.suspend_with_clocks) { + if (priv->phys[BRCM_USB_PHY_3_0].inited) + clk_disable_unprepare(priv->usb_30_clk); + if (priv->phys[BRCM_USB_PHY_2_0].inited || + !priv->has_eohci) + clk_disable_unprepare(priv->usb_20_clk); + } if (priv->wake_irq >= 0) enable_irq_wake(priv->wake_irq); } @@ -557,7 +567,6 @@ static int brcm_usb_phy_resume(struct device *dev) clk_prepare_enable(priv->usb_20_clk); clk_prepare_enable(priv->usb_30_clk); - brcm_usb_wake_enable(&priv->ini, false); brcm_usb_init_ipp(&priv->ini); /* @@ -579,6 +588,8 @@ static int brcm_usb_phy_resume(struct device *dev) } else if (priv->has_xhci) { brcm_usb_uninit_xhci(&priv->ini); clk_disable_unprepare(priv->usb_30_clk); + if (!priv->has_eohci) + clk_disable_unprepare(priv->usb_20_clk); } } else { if (priv->has_xhci) @@ -589,7 +600,7 @@ static int brcm_usb_phy_resume(struct device *dev) clk_disable_unprepare(priv->usb_20_clk); clk_disable_unprepare(priv->usb_30_clk); } - + priv->ini.wake_enabled = false; return 0; } #endif /* CONFIG_PM_SLEEP */