From patchwork Fri Oct 31 13:26:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 5204461 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 79CD69F349 for ; Fri, 31 Oct 2014 13:29:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A91C20160 for ; Fri, 31 Oct 2014 13:29:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A743F2012B for ; Fri, 31 Oct 2014 13:29:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XkCEV-0002r5-Uu; Fri, 31 Oct 2014 13:27:15 +0000 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XkCEN-0002ng-UN for linux-arm-kernel@lists.infradead.org; Fri, 31 Oct 2014 13:27:09 +0000 Received: by mail-pd0-f177.google.com with SMTP id v10so7159853pde.8 for ; Fri, 31 Oct 2014 06:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=lfdnfhK7fYbv0cFhSSwIlOvd7D3CcE/10cqAYogY1Ww=; b=CyKP/05hc6wrpAFQ4+Z9oRpxHBNzbE85VMXmJiMoBuRBCtGlRKlskeqAdZm9TArT7U kPEcePkn0wA99ZFoYRJyR4u1A/k0W4rm0p+EauqH78svHrAPohU1IL1DfynYYAVXwLZ1 w+3+rSHZYdGqVnhDjy++QgUC25VpcTN3aqt246QxVTjoyKKpxZA3d63pvJbqyhtc0MKz xltmMKtZN4oyw5Porq+rVlT/OjCag4ThR2TfL2R+rG6fAoKPibWr3K8+PTP3geup4MwF Sz+PFfI6Knz5TuLH2KLfrv8y6bldEcJA6IKAE7iHw726a2T9rIGeyHHhr7heO8h8UIuv Gh2A== X-Received: by 10.68.197.170 with SMTP id iv10mr24812557pbc.135.1414762006595; Fri, 31 Oct 2014 06:26:46 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id hz4sm9952490pbc.22.2014.10.31.06.26.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 06:26:45 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org Subject: [PATCH v7 1/2] usb: host: xhci-plat: Get PHYs for xhci's hcds Date: Fri, 31 Oct 2014 18:56:28 +0530 Message-Id: <1414761989-21088-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1414761989-21088-1-git-send-email-gautam.vivek@samsung.com> References: <1414761989-21088-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141031_062708_060329_77591B8F X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -0.4 (/) Cc: linux-samsung-soc@vger.kernel.org, sergei.shtylyov@cogentembedded.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, jg1.han@samsung.com, linux-kernel@vger.kernel.org, balbi@ti.com, kishon@ti.com, jwerner@google.com, kgene.kim@samsung.com, stern@rowland.harvard.edu, Vivek Gautam , heikki.krogerus@linux.intel.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The host controller by itself may sometimes need to handle PHY and re-initialize it to re-configure some of the PHY parameters to get full support out of the PHY controller. Therefore, facilitate getting the two possible PHYs, viz. USB 2.0 type (UTMI+) and USB 3.0 type (PIPE3), and initialize them. Signed-off-by: Vivek Gautam --- drivers/usb/host/xhci-plat.c | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 3d78b0c..5207d5b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -129,10 +130,41 @@ static int xhci_plat_probe(struct platform_device *pdev) goto put_hcd; } + /* Get possile USB 2.0 type PHY (UTMI+) available with xhci */ + hcd->phy = devm_phy_get(&pdev->dev, "usb2-phy"); + if (IS_ERR(hcd->phy)) { + ret = PTR_ERR(hcd->phy); + if (ret == -EPROBE_DEFER) { + goto disable_clk; + } else if (ret != -ENOSYS && ret != -ENODEV) { + hcd->phy = NULL; + dev_warn(&pdev->dev, + "Error retrieving usb2 phy: %d\n", ret); + } + } + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) goto disable_clk; + /* + * Initialize and power-on USB 2.0 PHY + * FIXME: Isn't this a hacky way of initializing the PHY again ? + * xhci's parent would have already initialized the PHY, but we + * wanna do it again. + */ + hcd->phy->init_count = 0; + ret = phy_init(hcd->phy); + if (ret) + goto dealloc_usb2_hcd; + + hcd->phy->power_count = 0; + ret = phy_power_on(hcd->phy); + if (ret) { + phy_exit(hcd->phy); + goto dealloc_usb2_hcd; + } + device_wakeup_enable(hcd->self.controller); /* USB 2.0 roothub is stored in the platform_device now. */ @@ -158,12 +190,41 @@ static int xhci_plat_probe(struct platform_device *pdev) if (HCC_MAX_PSA(xhci->hcc_params) >= 4) xhci->shared_hcd->can_do_streams = 1; + /* Get possile USB 3.0 type PHY (PIPE3) available with xhci */ + xhci->shared_hcd->phy = devm_phy_get(&pdev->dev, "usb3-phy"); + if (IS_ERR(xhci->shared_hcd->phy)) { + ret = PTR_ERR(xhci->shared_hcd->phy); + if (ret == -EPROBE_DEFER) { + goto put_usb3_hcd; + } else if (ret != -ENOSYS && ret != -ENODEV) { + xhci->shared_hcd->phy = NULL; + dev_warn(&pdev->dev, + "Error retrieving usb3 phy: %d\n", ret); + } + } + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); if (ret) goto put_usb3_hcd; + /* Initialize and power-on USB 3.0 PHY */ + xhci->shared_hcd->phy->init_count = 0; + ret = phy_init(xhci->shared_hcd->phy); + if (ret) + goto dealloc_usb3_hcd; + + xhci->shared_hcd->phy->power_count = 0; + ret = phy_power_on(xhci->shared_hcd->phy); + if (ret) { + phy_exit(xhci->shared_hcd->phy); + goto dealloc_usb3_hcd; + } + return 0; +dealloc_usb3_hcd: + usb_remove_hcd(xhci->shared_hcd); + put_usb3_hcd: usb_put_hcd(xhci->shared_hcd); @@ -186,9 +247,15 @@ static int xhci_plat_remove(struct platform_device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct clk *clk = xhci->clk; + phy_power_off(xhci->shared_hcd->phy); + phy_exit(xhci->shared_hcd->phy); + usb_remove_hcd(xhci->shared_hcd); usb_put_hcd(xhci->shared_hcd); + phy_power_off(hcd->phy); + phy_exit(hcd->phy); + usb_remove_hcd(hcd); if (!IS_ERR(clk)) clk_disable_unprepare(clk); @@ -204,6 +271,8 @@ static int xhci_plat_suspend(struct device *dev) struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + phy_exit(hcd->phy); + return xhci_suspend(xhci); } @@ -211,6 +280,11 @@ static int xhci_plat_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + + ret = phy_init(hcd->phy); + if (ret) + return ret; return xhci_resume(xhci, 0); }