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: 871811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b="K84li+j8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zfhHS367Mz9t3F for ; Mon, 12 Feb 2018 08:08:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932262AbeBKVIS (ORCPT ); Sun, 11 Feb 2018 16:08:18 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:42920 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932257AbeBKVIO (ORCPT ); Sun, 11 Feb 2018 16:08:14 -0500 Received: by mail-wr0-f194.google.com with SMTP id 41so13282941wrc.9; 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=Dmoa7nxgx73+iVkHleA68CsgjUm+GyLzxQPHJInQKfXhKB8tMD4JK4dMWts/B0GUXp Lf6mzqpz86IpaQ9XTcdbSNy5DC+RxmPRmcipWgtxrvnQqFobezyxwVtR4pL8YmVTDgck ws/WnOXfoPMYkEmICD+Mda/xQ4dMqRo6GPtmgnUHmFt273FBAJXGZIViGxOWCKNIGFFw T7RV/aUS7jBJ9yhibGnYtN2SKZ7hJOtFMukPHxSpcHgCTo6+gpak/BTiKLjGh8YMJlHc Zt/t2uMRZU0bNPO/wwmxSB4HNPsfRXiOdBf/pRD73Kq1q866jfOF5HHU+Xhj+U5a41xz WGqQ== X-Gm-Message-State: APf1xPDxyr/NyoIHW1PSdKYi+TllyT2/YfUbO1Zou1CVm9HRFQMN+Bi3 eUBCZmsFqzB4fqMpBEsMVBxakww5 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 Cc: linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, jonathanh@nvidia.com, thierry.reding@gmail.com, stern@rowland.harvard.edu, linux@prisktech.co.nz, Peter.Chen@nxp.com, matthias.bgg@gmail.com, mark.rutland@arm.com, robh+dt@kernel.org, narmstrong@baylibre.com, linux-amlogic@lists.infradead.org, yixun.lan@amlogic.com, Martin Blumenstingl 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> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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