From patchwork Sun Feb 11 21:06:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10211607 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 7921760329 for ; Sun, 11 Feb 2018 21:30:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D1CF28A74 for ; Sun, 11 Feb 2018 21:30:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5183828AE2; Sun, 11 Feb 2018 21:30:09 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9089728A74 for ; Sun, 11 Feb 2018 21:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=9Gqv3rls/EayZ+NyV6o0c2fahQm4DEhcNRpwJNvkZBc=; b=j3z6KxiVAXpM0DeRgtHTqapUD2 umpu+ndWCi2cu48L6k2kNh1KmFWfvZBlE7U4IDjqe4nl73bVXF4CjD1WC0B6grw9JDm8YWGz8Z1fz o6exAehj55DJPja0rzhOt9iGbxd3I1fZEBetGFmUxxkFxwDLZ+gpli4tgcR/E5GTjUSasWJpCkoSM V1I30M5qJ7mlqn+F53sQ5fAI0dh97YBInHlakArVh4A7K39lUHZN8sy+QS+ETnUFmcJDBdVcWfaE0 Jnb+mDBYPAuOJXmoveUnyYjsxbEjd+AWUZSKXr0yaDMW1rZaFLJ1R5z13a57BiWA7UybdLdKWdoVP lK8rsyrQ==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ekzCI-000837-P2 for patchwork-linux-mediatek@patchwork.kernel.org; Sun, 11 Feb 2018 21:30:06 +0000 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=9Gqv3rls/EayZ+NyV6o0c2fahQm4DEhcNRpwJNvkZBc=; b=iu8+Tpt6qrpPPhPTdp73Z0juju BERVZkX0mfDiec+w/YRrwcDyrXe6z/qREF6OIseDb2G0KhXFOzVHGS5zX9HS5ftumTcXM9TtxHdDO Q3bL189asWBzmjNesYOEXnKi3Orfj/zGMzl2RP+XEtqvgyL2ixCNoqh+S4HmqFmmKcx95Ksgs2G6g 4x85WBuJpLbDsbZ0/O6Lj13ELV0IYKbgUNt1LWdCA+RqF2Zdei3dg953r3SKgvjm8Eo/K2Pxp+rl3 5cFWb+eGtG4t6hakf3v/SVaCYafE5AQhvtIdxPkfst407MrYf+LkdQTaFv/6dglX8m6B+dfiH0by0 cZPYQhOQ==; 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 1ekys4-0000j6-CY; Sun, 11 Feb 2018 21:09:12 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ekyrI-0007xt-59; Sun, 11 Feb 2018 21:08:26 +0000 Received: by mail-wr0-x244.google.com with SMTP id k32so6795185wrk.4; Sun, 11 Feb 2018 13:08:13 -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=3OZwHl2qMp3UlH+lM3uhd1zdX4MDm+Bejwtnfk5yweQ=; b=K84li+j8q10vRbSHdesTPzineuWyRi/zj00u+7EJn8CxhJgpYljakyde0CeSeV894i uTQLS+mQzHUESUAaWj7NXkWQb4H8qGralTQ8Jn3taUur+oCsyIDCQd9YM3Hds9bdIKtH IgHQIhnwI1xXUdXtl5hRL2xX1JyaNkQfOO3sSXfw1+m8kHRLJ4+PIWEH3DyYmwveVfXY JthiWFImlTfyibtwhuYxy0jW3FNFg4cq2baFTnJShQAPY9nPFkdD3fF2zfYKhSvQpvny X1ogo7IiBgNhMI22kQy1VRbkW32MMplHeP5Lr41Hw1dAC5mp/zieS4e8Dr/4Fnpfimra M/FA== 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=3OZwHl2qMp3UlH+lM3uhd1zdX4MDm+Bejwtnfk5yweQ=; b=AzUUv0z378t02ibbOT7O/PmaT19rwG2h91EwQzy09/UXMmdZSvP1EeZ0bMY6i5HQu5 BiNdStLtMHDwSU2wnudKVtxxGY7eu62IlwOkejA+lG+5T4Kz6tcb7RCpCvVmdFDsTp/R b7Kn+TYtr0rjn8Ub9+ChVnEi1APUR5g6iQdKYHeJx1RLpJnwz8UGisU/Bv6nV6eljEdX huWx96tu0sJPHWBdaSrBwTeApPjETmJv7qRGUYfDTzy71IEozZavCYAlokRSwEKsKRXN KB3HOgZ9w8a70Ns63ORMifchJnjvoSMhXgabaHFjX6nR4T8YgDG3cIuHN1ZnCcrLVW+d j/zA== X-Gm-Message-State: APf1xPCAo24++K5O/lb+RBMD6JFgaotF9dZ+j77h4xWy8Pj+1qXfiBSn vsFo6FQY87DPSOIQJOpBQ+k= X-Google-Smtp-Source: AH8x226vKa0SFMPvRZGeMupWrPGW8M8zUWCnsqdZm+vAagTbFTgaUA5soqsRhru5ayNCm3X3Y4uxBw== X-Received: by 10.223.173.75 with SMTP id p69mr1919735wrc.222.1518383292251; Sun, 11 Feb 2018 13:08:12 -0800 (PST) Received: from blackbox.darklights.net (p5B056154.dip0.t-ipconnect.de. [91.5.97.84]) by smtp.googlemail.com with ESMTPSA id k13sm6301773wrd.61.2018.02.11.13.08.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2018 13:08:11 -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 v9 2/8] usb: add a flag to skip PHY initialization to struct usb_hcd Date: Sun, 11 Feb 2018 22:06:45 +0100 Message-Id: <20180211210651.2046-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180211210651.2046-1-martin.blumenstingl@googlemail.com> References: <20180211210651.2046-1-martin.blumenstingl@googlemail.com> X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=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 "bool skip_phy_initialization" field to struct usb_hcd so drivers can opt-out of any PHY management provided by the USB HCD core driver. The new field will be used in that patch as well. 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 --- drivers/usb/chipidea/host.c | 5 +---- 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, 18 insertions(+), 10 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 19d60ed7e41f..493ef826ef4c 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -124,10 +124,7 @@ 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; + hcd->skip_phy_initialization = ci->phy || ci->usb_phy; 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..009de5e4e136 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 = true; } #endif return retval; diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index b065a960adc2..40fbc4925378 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 = true; } } diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index c809f7d2f08f..9a8442a66b14 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 = true; 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..2255cbd73fb5 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 = true; ohci->start_hnp = start_hnp; } #endif diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 1e6c954f4b3f..bd605e79ae7d 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 = true; } } diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 6f038306c14d..ef01bc18bcf3 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 = true; } ret = usb_add_hcd(hcd, irq, IRQF_SHARED); diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 176900528822..b46fb6dd43ab 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -98,6 +98,12 @@ struct usb_hcd { */ const struct hc_driver *driver; /* hw-specific hooks */ + /* + * 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) + */ + bool skip_phy_initialization; /* * OTG and some Host controllers need software interaction with phys; * other external phys should be software-transparent