From patchwork Mon Aug 14 22:45:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9900379 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 C3C17603FB for ; Mon, 14 Aug 2017 22:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5E902875A for ; Mon, 14 Aug 2017 22:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA94C28773; Mon, 14 Aug 2017 22:46:32 +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=-2.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 0ADF02876F for ; Mon, 14 Aug 2017 22:46:31 +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=u6anUiBL+Yyafp/LR6Dsx+pdBbG3GsqOZJvFXZ750MI=; b=vC9gpH/jcsPrTyGBKeKQt/m6Lf RKqbn9AmSMiwN7pgzeeW0OznaCXz7GMK92T7UG9/EdWn2zNgbRKjJlhesIEQ+MCTWhjZ2A26DoT8r AWADsUB9nz16vURkIB+m4A1Ej5CuO7a7KMh+X4VksVdQGq0Tt2IdTasyQSCw/BCm+ZsXWXKo3AuIr 6Ij+Pt7TexZ31Po7Mea9Mrn1Fvkkl8pZhqKm7KUxjGKSt2zVjZhl6TfxTf1AwJQlLGcckHljIAeLg BTQKvR3hkF8w25yuB/SUHYNTmYIJdpV25Ts+nL1VMZjt7VhqlanTjduBihs4BgQWKDJGA6/FdVb99 hSojhDQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dhO7q-0001fN-Fd; Mon, 14 Aug 2017 22:46:22 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhO7m-0001cG-0R for linux-amlogic@lists.infradead.org; Mon, 14 Aug 2017 22:46:20 +0000 Received: by mail-wm0-x241.google.com with SMTP id r77so15986559wmd.2 for ; Mon, 14 Aug 2017 15:46:01 -0700 (PDT) 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=Y6pUZdpItX12EODHlI3957jo+w4GV3gRCuXp+abRtBQ=; b=C2IA1bJxjXnFTo6UYLPtTMU14ptLKtQvSUF84Ub7xOIzSMnbvjF7U04r7q0Oq6N14o wWb7X+a7KmxiwSG3817nTa0tPgucw+T+5MjbzuKeH0kYMW5MtG8OrNs3OTcv0GJxOOg9 kyauzjbknLYfMPi5b9mDkcNwha80et3xi5Bvb6jZ+/D5yvzuuhuDxN2bqx/CVoEsdybc WOgTtc6JEwblC2aFBa+9B92Nt9KzzZSn60Va7EkkpHVjqakGCT884TRm6bwI+BWkfDRT evBFcRPjNMI1VxyDzuDNWSXwudKfBLBikPtzNYiKhAVVvaizEe9oZ0GbPf8gWN8q3ntC BjQw== 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=Y6pUZdpItX12EODHlI3957jo+w4GV3gRCuXp+abRtBQ=; b=IWGrsqz495BtA/+KtAmiD4nznIKTWjmf880ukLxjZ5U7WidByT4RPvFzW4lOAPrzRd 2aOUaW9VuL2chIq4t/0fV4eHAZcagMoqoydZd7LiS/ECjDNMB4TGaxzNo4C4uiiU4Cqv IkMYJkUdQt88gh5ekSfHJlopWq+retvG8+gvvvvts+J/wu7lcrD2cU4S3I9DFqg07w7Y YaxYE/NVcCnYl4WXOeVoHS0eB0FTCujLhqLJyWrPvYfaW8ddVllX53rG7NAm5EoQLJF6 X7abNOUPSEzN40rFKy3x76Zo6PF/EGij2X6CzevCM5elWLsEng65Q0QWRWiuUn89R9Vh /pUQ== X-Gm-Message-State: AHYfb5jY2rggeTVpFeCh4vfPtmK37m0n4HmkaUglIW/Fstb7LzJVcM9H UjuZYk6mm2jgIg== X-Received: by 10.28.21.72 with SMTP id 69mr214984wmv.75.1502750759836; Mon, 14 Aug 2017 15:45:59 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3C22104BDB11DC365F26026.dip0.t-ipconnect.de. [2003:dc:d3c2:2104:bdb1:1dc3:65f2:6026]) by smtp.googlemail.com with ESMTPSA id a134sm1004905wma.47.2017.08.14.15.45.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 15:45:59 -0700 (PDT) From: Martin Blumenstingl To: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, felipe.balbi@linux.intel.com, mathias.nyman@intel.com Subject: [RFCv3 usb-next 3/3] usb: host: xhci: plat: integrate the platform-roothub Date: Tue, 15 Aug 2017 00:45:42 +0200 Message-Id: <20170814224542.18257-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170814224542.18257-1-martin.blumenstingl@googlemail.com> References: <20170814224542.18257-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170814_154618_229295_A900662C X-CRM114-Status: GOOD ( 16.13 ) 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, arnd@arndb.de, Martin Blumenstingl , robh+dt@kernel.org, chunfeng.yun@mediatek.com, linux-amlogic@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 This enables the platform-roothub for the xhci-plat driver. This allows specifying a PHY for each port via devicetree. All PHYs will then be enabled/disabled by the platform-roothub driver. One example where this is required is the Amlogic GXL and GXM SoCs: They are using a dwc3 USB controller with up to three ports enabled on the internal roothub. Using only the top-level "phy" properties does not work here since one can only specify one "usb2-phy" and one "usb3-phy", while actually at least two "usb2-phy" have to be specified. Signed-off-by: Martin Blumenstingl Acked-by: Rob Herring --- Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 +++++ drivers/usb/host/Kconfig | 1 + drivers/usb/host/xhci-plat.c | 35 ++++++++++++++++++++-- drivers/usb/host/xhci.h | 2 ++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index 2d80b60eeabe..31b4f681e9ca 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -29,6 +29,13 @@ Optional properties: - usb3-lpm-capable: determines if platform is USB3 LPM capable - quirk-broken-port-ped: set if the controller has broken port disable mechanism +sub-nodes: +- optionally there can be a node for the root-hub, see usb-roothub.txt in the + current directory +- one or more nodes with reg 1-31 for each port to which a device is connected. + See usb-device.txt in the current directory for more information. + + Example: usb@f0931000 { compatible = "generic-xhci"; diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index b8b05c786b2a..3bdc49e89c0f 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -36,6 +36,7 @@ config USB_XHCI_PCI config USB_XHCI_PLATFORM tristate "Generic xHCI driver for a platform device" select USB_XHCI_RCAR if ARCH_RENESAS + select USB_PLATFORM_ROOTHUB ---help--- Adds an xHCI host driver for a generic platform device, which provides a memory space and an irq. diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index c04144b25a67..daf5bbcc310a 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -21,6 +21,7 @@ #include #include +#include "platform-roothub.h" #include "xhci.h" #include "xhci-plat.h" #include "xhci-mvebu.h" @@ -285,9 +286,19 @@ static int xhci_plat_probe(struct platform_device *pdev) goto put_usb3_hcd; } + xhci->platform_roothub = platform_roothub_init(sysdev); + if (IS_ERR(xhci->platform_roothub)) { + ret = PTR_ERR(xhci->platform_roothub); + goto disable_usb_phy; + } + + ret = platform_roothub_power_on(xhci->platform_roothub); + if (ret) + goto exit_plat_roothub; + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) - goto disable_usb_phy; + goto disable_plat_roothub; if (HCC_MAX_PSA(xhci->hcc_params) >= 4) xhci->shared_hcd->can_do_streams = 1; @@ -311,6 +322,12 @@ static int xhci_plat_probe(struct platform_device *pdev) dealloc_usb2_hcd: usb_remove_hcd(hcd); +disable_plat_roothub: + platform_roothub_power_off(xhci->platform_roothub); + +exit_plat_roothub: + platform_roothub_exit(xhci->platform_roothub); + disable_usb_phy: usb_phy_shutdown(hcd->usb_phy); @@ -342,6 +359,9 @@ static int xhci_plat_remove(struct platform_device *dev) usb_remove_hcd(xhci->shared_hcd); usb_phy_shutdown(hcd->usb_phy); + platform_roothub_power_off(xhci->platform_roothub); + platform_roothub_exit(xhci->platform_roothub); + usb_remove_hcd(hcd); usb_put_hcd(xhci->shared_hcd); @@ -374,7 +394,14 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) clk_disable_unprepare(xhci->clk); - return ret; + if (ret) + return ret; + + ret = platform_roothub_power_off(xhci->platform_roothub); + if (ret) + return ret; + + return 0; } static int __maybe_unused xhci_plat_resume(struct device *dev) @@ -386,6 +413,10 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) clk_prepare_enable(xhci->clk); + ret = platform_roothub_power_on(xhci->platform_roothub); + if (ret) + return ret; + ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index e3e935291ed6..76118e254a54 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1725,6 +1725,8 @@ struct xhci_hcd { int msix_count; /* optional clock */ struct clk *clk; + /* optional platform root-hub */ + struct platform_roothub *platform_roothub; /* data structures */ struct xhci_device_context_array *dcbaa; struct xhci_ring *cmd_ring;