From patchwork Sun Feb 18 18:44:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10226895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4EE5A60244 for ; Sun, 18 Feb 2018 18:49:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CE02286EE for ; Sun, 18 Feb 2018 18:49:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EDAC2891B; Sun, 18 Feb 2018 18:49:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A46A3286EE for ; Sun, 18 Feb 2018 18:49:40 +0000 (UTC) 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=GGJbp8nD2DBc3Y+CoXDfQZnhejvzBPxYmHx/88Cmbh0=; b=E9YWnZu0ztDYXFLTEZ8/ytqOmx HHaQsIckz5JGc+NvIMh0ienpiawAcQYMknaH74PJAHOtMKptb3z864NdmKVRzi4IBnPVY6/qy5ZvU Onm84ae3ODK/fVhsW1p1biLYjGrTKR3omvDg/Bi9oOUl/N3p1T8LhVyY16FXp7IFidwlu6SfYOPTL pb0UT4h3tHThCfWqiD2rj08pOgt6VOMEZxdGIL+IXWcJHAqV8SKY850lhEDgvss4HwBC+qmhvaCSC 8eTUyT96kSnDn967ztt4i4vNgHyO8agOYKOm9YTd0IF4rPso8mYSZ950v7zyo0mK1fNX86R0bcCBb NVYHQYbg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1enU1n-0008Q4-Mb; Sun, 18 Feb 2018 18:49:35 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1enTxu-0006QQ-JK; Sun, 18 Feb 2018 18:45:41 +0000 Received: by mail-wm0-x244.google.com with SMTP id t3so11389704wmc.2; Sun, 18 Feb 2018 10:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C4BxOXgpSlKCYjKGgaR/0magH5fwaUaJqlABAB+pCJ4=; b=rmKFtWS0QWbz5WtbCp0j+r6PH1FmdyDeca/mWWANNg9ZvSulYBwbov5/LwIvoQBSGG aC0sXGEPGxFYB/LR+mEKj1IEPhaU2mlhknuYFOnuCvPPrE4G8lpn/UvgXt51YxRpNUaW QOGpWCvN5G/lOQDOM0yedLl89P7z7sP5uHHcE/TlS1vX7aKCTR5HLAza9wIjJJKvn+4O Jn52hqDqmsYrP9KOcRKIwfErviFbPn7HTRuOwkwUcxYpBfqPo3etT3fX0yAZ1cCRQ0pM uMmLQhnaVkp/HVjIw+3EP+wnig9OZduZk8X07n+xnBOD3ZoAfTj/iTjOtXToT8HZpkb7 KY5g== 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=C4BxOXgpSlKCYjKGgaR/0magH5fwaUaJqlABAB+pCJ4=; b=sJnxtLx6OAT69vdxG0am1/SYpkuxqBbwKypu8feplHKb+jnF3tTpz4FEdCq0fVZtYf g8UzqWS/s9dta+Kj3YPetW+dOyVKrjN1OXUykxkIduByqtltYV76gXx2uYmsglR/CQJE Cs25Z403AJcYyFizI/2vwyDPEjzT6T9ocOClQslE/a1r7cRM0DDzeMMenj9UUV2nFV5L 2pyhqKYIrXsCzUEWG9NgBUEewGXnAQ2xP38Z82twXP0NbmKD3vuMOBkCGGCRn334uftS TqBrlnFfuk258q/MCRu2QTh7QBm+flG7C3AJ4MlthF+9MpLwCjSwHfa2b8qCmsBZcvEI GqtA== X-Gm-Message-State: APf1xPDWp5YkRaYnTTZlxH93eDtNAPTnZqlBtqE1xpbBKuoeowNBQYW7 G2X2GfBk6zFFT9ARshUu3Bg= X-Google-Smtp-Source: AH8x225cSP9YnO3j9EjLtBF3lRygIWn45CkI3phFXCWKmKAFaFyN8R06/1i8vQ54yvb2DzJto1X6IQ== X-Received: by 10.28.193.134 with SMTP id r128mr1221292wmf.85.1518979520533; Sun, 18 Feb 2018 10:45:20 -0800 (PST) Received: from blackbox.darklights.net (p200300DCD7404304DD6DB7B324975560.dip0.t-ipconnect.de. [2003:dc:d740:4304:dd6d:b7b3:2497:5560]) by smtp.googlemail.com with ESMTPSA id 63sm22860290wms.46.2018.02.18.10.45.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Feb 2018 10:45:19 -0800 (PST) From: Martin Blumenstingl To: linux-usb@vger.kernel.org, mathias.nyman@intel.com, arnd@arndb.de, gregkh@linuxfoundation.org, felipe.balbi@linux.intel.com Subject: [PATCH usb-next v10 2/8] usb: add a flag to skip PHY initialization to struct usb_hcd Date: Sun, 18 Feb 2018 19:44:58 +0100 Message-Id: <20180218184504.3331-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218184504.3331-1-martin.blumenstingl@googlemail.com> References: <20180218184504.3331-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180218_104534_724179_E2A5B130 X-CRM114-Status: GOOD ( 16.80 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Peter.Chen@nxp.com, Martin Blumenstingl , narmstrong@baylibre.com, yixun.lan@amlogic.com, robh+dt@kernel.org, jonathanh@nvidia.com, linux@prisktech.co.nz, matthias.bgg@gmail.com, thierry.reding@gmail.com, linux-mediatek@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-tegra@vger.kernel.org, stern@rowland.harvard.edu, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The USB HCD core driver parses the device-tree node for "phys" and "usb-phys" properties. It also manages the power state of these PHYs automatically. However, drivers may opt-out of this behavior by setting "phy" or "usb_phy" in struct usb_hcd to a non-null value. An example where this is required is the "Qualcomm USB2 controller", implemented by the chipidea driver. The hardware requires that the PHY is only powered on after the "reset completed" event from the controller is received. A follow-up patch will allow the USB HCD core driver to manage more than one PHY. Add a new "skip_phy_initialization" bitflag to struct usb_hcd so drivers can opt-out of any PHY management provided by the USB HCD core driver. This also updates the existing drivers so they use the new flag if they want to opt out of the PHY management provided by the USB HCD core driver. This means that for these drivers the new "multiple PHY" handling (which will be added in a follow-up patch) will be disabled as well. Signed-off-by: Martin Blumenstingl Acked-by: Peter Chen --- drivers/usb/chipidea/host.c | 6 ++---- drivers/usb/core/hcd.c | 4 ++-- drivers/usb/host/ehci-fsl.c | 2 ++ drivers/usb/host/ehci-platform.c | 4 ++-- drivers/usb/host/ehci-tegra.c | 1 + drivers/usb/host/ohci-omap.c | 1 + drivers/usb/host/ohci-platform.c | 4 ++-- drivers/usb/host/xhci-plat.c | 1 + include/linux/usb/hcd.h | 6 ++++++ 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 19d60ed7e41f..af45aa3222b5 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -124,10 +124,8 @@ static int host_start(struct ci_hdrc *ci) hcd->power_budget = ci->platdata->power_budget; hcd->tpl_support = ci->platdata->tpl_support; - if (ci->phy) - hcd->phy = ci->phy; - else - hcd->usb_phy = ci->usb_phy; + if (ci->phy || ci->usb_phy) + hcd->skip_phy_initialization = 1; ehci = hcd_to_ehci(hcd); ehci->caps = ci->hw_bank.cap; diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index fc32391a34d5..f2307470a31e 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2727,7 +2727,7 @@ int usb_add_hcd(struct usb_hcd *hcd, int retval; struct usb_device *rhdev; - if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->usb_phy) { + if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->skip_phy_initialization) { struct usb_phy *phy = usb_get_phy_dev(hcd->self.sysdev, 0); if (IS_ERR(phy)) { @@ -2745,7 +2745,7 @@ int usb_add_hcd(struct usb_hcd *hcd, } } - if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->phy) { + if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->skip_phy_initialization) { struct phy *phy = phy_get(hcd->self.sysdev, "usb"); if (IS_ERR(phy)) { diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index c5094cb88cd5..0a9fd2022acf 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -155,6 +155,8 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) retval = -ENODEV; goto err2; } + + hcd->skip_phy_initialization = 1; } #endif return retval; diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index b065a960adc2..b91eea8c73ae 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -219,9 +219,9 @@ static int ehci_platform_probe(struct platform_device *dev) if (IS_ERR(priv->phys[phy_num])) { err = PTR_ERR(priv->phys[phy_num]); goto err_put_hcd; - } else if (!hcd->phy) { + } else { /* Avoiding phy_get() in usb_add_hcd() */ - hcd->phy = priv->phys[phy_num]; + hcd->skip_phy_initialization = 1; } } diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index c809f7d2f08f..a6f4389f7e88 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -461,6 +461,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) goto cleanup_clk_en; } hcd->usb_phy = u_phy; + hcd->skip_phy_initialization = 1; tegra->needs_double_reset = of_property_read_bool(pdev->dev.of_node, "nvidia,needs-double-reset"); diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 0201c49bc4fc..d8d35d456456 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -230,6 +230,7 @@ static int ohci_omap_reset(struct usb_hcd *hcd) } else { return -EPROBE_DEFER; } + hcd->skip_phy_initialization = 1; ohci->start_hnp = start_hnp; } #endif diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 1e6c954f4b3f..62ef36a9333f 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c @@ -186,9 +186,9 @@ static int ohci_platform_probe(struct platform_device *dev) if (IS_ERR(priv->phys[phy_num])) { err = PTR_ERR(priv->phys[phy_num]); goto err_put_hcd; - } else if (!hcd->phy) { + } else { /* Avoiding phy_get() in usb_add_hcd() */ - hcd->phy = priv->phys[phy_num]; + hcd->skip_phy_initialization = 1; } } diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 6f038306c14d..6700e5ee82ad 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -284,6 +284,7 @@ static int xhci_plat_probe(struct platform_device *pdev) ret = usb_phy_init(hcd->usb_phy); if (ret) goto put_usb3_hcd; + hcd->skip_phy_initialization = 1; } ret = usb_add_hcd(hcd, irq, IRQF_SHARED); diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 176900528822..693502c84c04 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -151,6 +151,12 @@ struct usb_hcd { unsigned msix_enabled:1; /* driver has MSI-X enabled? */ unsigned msi_enabled:1; /* driver has MSI enabled? */ unsigned remove_phy:1; /* auto-remove USB phy */ + /* + * do not manage the PHY state in the HCD core, instead let the driver + * handle this (for example if the PHY can only be turned on after a + * specific event) + */ + unsigned skip_phy_initialization:1; /* The next flag is a stopgap, to be removed when all the HCDs * support the new root-hub polling mechanism. */