From patchwork Mon Feb 2 12:42:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 5760901 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5EFFFBF440 for ; Mon, 2 Feb 2015 12:38:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F537201FB for ; Mon, 2 Feb 2015 12:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BC8D20212 for ; Mon, 2 Feb 2015 12:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932153AbbBBMir (ORCPT ); Mon, 2 Feb 2015 07:38:47 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:55646 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753815AbbBBMip (ORCPT ); Mon, 2 Feb 2015 07:38:45 -0500 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NJ500HY29SJQIB0@mailout1.samsung.com>; Mon, 02 Feb 2015 21:38:43 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 30.1F.19034.3DF6FC45; Mon, 02 Feb 2015 21:38:43 +0900 (KST) X-AuditID: cbfee691-f79b86d000004a5a-88-54cf6fd3ad25 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 36.74.20081.3DF6FC45; Mon, 02 Feb 2015 21:38:43 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NJ500DQR9PEXA50@mmp1.samsung.com>; Mon, 02 Feb 2015 21:38:43 +0900 (KST) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, stern@rowland.harvard.edu, balbi@ti.com, kgene.kim@samsung.com, kishon@ti.com, mathias.nyman@intel.com, heikki.krogerus@linux.intel.com, sergei.shtylyov@cogentembedded.com, jg1.han@samsung.com Subject: [PATCH V7 RESEND 1/2] usb: host: xhci-plat: Get PHYs for xhci's hcds Date: Mon, 02 Feb 2015 18:12:03 +0530 Message-id: <1422880924-14212-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 2.2.0 In-reply-to: <1422880924-14212-1-git-send-email-gautam.vivek@samsung.com> References: <1422880924-14212-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeLIzCtJLcpLzFFi42JZI2JSq3s5/3yIwapb6hYH79dbNC9ez2bR tXoni8XlhZdYLXoXXGWzuPC0h83i8q45bBYzzu9jsli0rJXZonnTFFaLM6tusVtM+H2BzYHH 48HU/0wei/e8ZPKYdzLQY//cNewes+/+YPTo27KK0eP4je1MHp83yQVwRHHZpKTmZJalFunb JXBl/Nz4nL1gnWLF3+mvWRsYf0p1MXJySAiYSOw4vZgJwhaTuHBvPVsXIxeHkMBSRokjS76w wRS1PPjGApFYxCjR2NnIDOFMYJJ4tXQmWDubgK5E09tdjCC2iICDxJKld8BGMQu0MEks3/+H GSQhLOArcej/VhYQm0VAVeL19m9gcV4BD4mlH74yQ6yTk9hy6xE7iM0p4Clx7lcfK4gtBFRz dvIBsDMkBK6xS3y+sYkNYpCAxLfJ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AxNGXkm8obGJuamxqaWJhYmZpZI4r5J9W4iQQHpiSWp2ampBahFMHxMHp1QD4y6uR28m 2MTpCZ1SFA+cEnh+alnonU4vDv1LTTsvOGucXebEs9vx1Snus2Ehx4TmRDlopbx+rcdyPjXH 9VmgjHP7ZkuzJ+UXPy523uax7sq7fy9Lyh6m/DV4/vFBycIPlRMSv34M2LlkV3/18mTTvF8n 3/xetNZsqYKxvBs7x3oTo6Vhn+/dX63EUpyRaKjFXFScCACgeMLL4AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 08d402b..c478627 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 @@ -127,10 +128,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. */ @@ -156,12 +188,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); @@ -184,9 +245,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); @@ -202,6 +269,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); + /* * xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. Since xhci_plat_suspend is currently @@ -217,6 +286,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); }