From patchwork Mon May 13 05:51:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Xie X-Patchwork-Id: 2558311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 1DE633FC5A for ; Mon, 13 May 2013 12:08:23 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ublvh-00006X-FK; Mon, 13 May 2013 06:08:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UbliB-0004RV-Kc; Mon, 13 May 2013 05:54:15 +0000 Received: from na3sys009aog124.obsmtp.com ([74.125.149.151]) by merlin.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ubli8-0004Qh-SX for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2013 05:54:13 +0000 Received: from SC-OWA.marvell.com ([199.233.58.135]) (using TLSv1) by na3sys009aob124.postini.com ([74.125.148.12]) with SMTP ID DSNKUZB/7OfDVJgEX3YZxffwcG2iEE6Jza9A@postini.com; Sun, 12 May 2013 22:54:12 PDT Received: from maili.marvell.com (10.93.76.43) by SC-OWA.marvell.com (10.93.76.28) with Microsoft SMTP Server id 8.3.213.0; Sun, 12 May 2013 22:52:00 -0700 Received: from localhost (unknown [10.38.36.239]) by maili.marvell.com (Postfix) with ESMTP id A03DC4E51A; Sun, 12 May 2013 22:52:00 -0700 (PDT) From: Chao Xie To: , , , , , , Subject: [PATCh V10 04/12] usb: ehci: ehci-mv: use PHY driver for ehci Date: Mon, 13 May 2013 01:51:35 -0400 Message-ID: <1368424303-10629-5-git-send-email-chao.xie@marvell.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1368424303-10629-1-git-send-email-chao.xie@marvell.com> References: <1368424303-10629-1-git-send-email-chao.xie@marvell.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130513_015413_065927_49574F94 X-CRM114-Status: GOOD ( 14.71 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.151 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Chao Xie X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Originaly, ehci driver will call the callbacks in platform data for PHY initialization and shut down. With PHY driver, it will call the APIs provided by PHY driver for PHY initialization and shutdown. It removes the callbacks in platform data, and at same time it removes one block in the way of enabling device tree for ehci driver. Signed-off-by: Chao Xie --- drivers/usb/host/ehci-mv.c | 49 +++++++++++++++---------------------------- 1 files changed, 17 insertions(+), 32 deletions(-) diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index 6bad41a..adfc11f 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c @@ -15,17 +15,18 @@ #include #include #include +#include #include #define CAPLENGTH_MASK (0xff) struct ehci_hcd_mv { struct usb_hcd *hcd; + struct usb_phy *phy; /* Which mode does this ehci running OTG/Host ? */ int mode; - void __iomem *phy_regs; void __iomem *cap_regs; void __iomem *op_regs; @@ -48,22 +49,15 @@ static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) { - int retval; - ehci_clock_enable(ehci_mv); - if (ehci_mv->pdata->phy_init) { - retval = ehci_mv->pdata->phy_init(ehci_mv->phy_regs); - if (retval) - return retval; - } - return 0; + return usb_phy_init(ehci_mv->phy); } static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv) { - if (ehci_mv->pdata->phy_deinit) - ehci_mv->pdata->phy_deinit(ehci_mv->phy_regs); + usb_phy_shutdown(ehci_mv->phy); + ehci_clock_disable(ehci_mv); } @@ -169,22 +163,7 @@ static int mv_ehci_probe(struct platform_device *pdev) goto err_clear_drvdata; } - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs"); - if (r == NULL) { - dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); - retval = -ENODEV; - goto err_clear_drvdata; - } - - ehci_mv->phy_regs = devm_ioremap(&pdev->dev, r->start, - resource_size(r)); - if (ehci_mv->phy_regs == 0) { - dev_err(&pdev->dev, "failed to map phy I/O memory\n"); - retval = -EFAULT; - goto err_clear_drvdata; - } - - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs"); + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) { dev_err(&pdev->dev, "no I/O memory resource defined\n"); retval = -ENODEV; @@ -199,6 +178,14 @@ static int mv_ehci_probe(struct platform_device *pdev) goto err_clear_drvdata; } + ehci_mv->phy = devm_usb_get_phy_dev(&pdev->dev, MV_USB2_PHY_INDEX); + if (IS_ERR_OR_NULL(ehci_mv->phy)) { + retval = PTR_ERR(ehci_mv->phy); + if (retval != -EPROBE_DEFER) + dev_err(&pdev->dev, "failed to get the outer phy\n"); + goto err_clear_drvdata; + } + retval = mv_ehci_enable(ehci_mv); if (retval) { dev_err(&pdev->dev, "init phy error %d\n", retval); @@ -225,14 +212,15 @@ static int mv_ehci_probe(struct platform_device *pdev) ehci_mv->mode = pdata->mode; if (ehci_mv->mode == MV_USB_MODE_OTG) { - ehci_mv->otg = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); + ehci_mv->otg = devm_usb_get_phy_dev(&pdev->dev, + MV_USB2_OTG_PHY_INDEX); if (IS_ERR(ehci_mv->otg)) { retval = PTR_ERR(ehci_mv->otg); if (retval == -ENXIO) dev_info(&pdev->dev, "MV_USB_MODE_OTG " "must have CONFIG_USB_PHY enabled\n"); - else + else if (retval != -EPROBE_DEFER) dev_err(&pdev->dev, "unable to find transceiver\n"); goto err_disable_clk; @@ -259,9 +247,6 @@ static int mv_ehci_probe(struct platform_device *pdev) } } - if (pdata->private_init) - pdata->private_init(ehci_mv->op_regs, ehci_mv->phy_regs); - dev_info(&pdev->dev, "successful find EHCI device with regs 0x%p irq %d" " working in %s mode\n", hcd->regs, hcd->irq,