From patchwork Mon May 13 05:51:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Xie X-Patchwork-Id: 2556511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 70A0DDF2E5 for ; Mon, 13 May 2013 06:09:24 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ublvg-0000zv-Dx; Mon, 13 May 2013 06:08:18 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ubljm-0004Y0-Ag; Mon, 13 May 2013 05:55:54 +0000 Received: from na3sys009aog133.obsmtp.com ([74.125.149.82]) by merlin.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ublji-0004Ws-RI for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2013 05:55:51 +0000 Received: from SC-OWA01.marvell.com ([199.233.58.136]) (using TLSv1) by na3sys009aob133.postini.com ([74.125.148.12]) with SMTP ID DSNKUZCARDneGw8AxqMpZgjTRMFz2wfPaaTo@postini.com; Sun, 12 May 2013 22:55:50 PDT Received: from maili.marvell.com (10.93.76.43) by sc-owa01.marvell.com (10.93.76.21) with Microsoft SMTP Server id 8.3.213.0; Sun, 12 May 2013 22:52:01 -0700 Received: from localhost (unknown [10.38.36.239]) by maili.marvell.com (Postfix) with ESMTP id C9BEE4E517; Sun, 12 May 2013 22:52:01 -0700 (PDT) From: Chao Xie To: , , , , , , Subject: [PATCh V10 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg Date: Mon, 13 May 2013 01:51:36 -0400 Message-ID: <1368424303-10629-6-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_015551_032808_FD20A3DD X-CRM114-Status: GOOD ( 15.56 ) 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.82 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, otg 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 otg driver. Signed-off-by: Chao Xie --- drivers/usb/phy/phy-mv-usb.c | 53 ++++++++++++++++++----------------------- drivers/usb/phy/phy-mv-usb.h | 2 +- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index c987bbe..9938904 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "phy-mv-usb.h" @@ -255,15 +256,14 @@ static int mv_otg_enable_internal(struct mv_otg *mvotg) dev_dbg(&mvotg->pdev->dev, "otg enabled\n"); otg_clock_enable(mvotg); - if (mvotg->pdata->phy_init) { - retval = mvotg->pdata->phy_init(mvotg->phy_regs); - if (retval) { - dev_err(&mvotg->pdev->dev, - "init phy error %d\n", retval); - otg_clock_disable(mvotg); - return retval; - } + retval = usb_phy_init(mvotg->outer_phy); + if (retval) { + dev_err(&mvotg->pdev->dev, + "failed to initialize phy %d\n", retval); + otg_clock_disable(mvotg); + return retval; } + mvotg->active = 1; return 0; @@ -282,8 +282,7 @@ static void mv_otg_disable_internal(struct mv_otg *mvotg) { if (mvotg->active) { dev_dbg(&mvotg->pdev->dev, "otg disabled\n"); - if (mvotg->pdata->phy_deinit) - mvotg->pdata->phy_deinit(mvotg->phy_regs); + usb_phy_shutdown(mvotg->outer_phy); otg_clock_disable(mvotg); mvotg->active = 0; } @@ -715,6 +714,7 @@ static int mv_otg_probe(struct platform_device *pdev) /* OTG common part */ mvotg->pdev = pdev; mvotg->phy.dev = &pdev->dev; + mvotg->phy.type = USB_PHY_TYPE_USB2; mvotg->phy.otg = otg; mvotg->phy.label = driver_name; mvotg->phy.state = OTG_STATE_UNDEFINED; @@ -727,23 +727,8 @@ static int mv_otg_probe(struct platform_device *pdev) for (i = 0; i < OTG_TIMER_NUM; i++) init_timer(&mvotg->otg_ctrl.timer[i]); - r = platform_get_resource_byname(mvotg->pdev, - IORESOURCE_MEM, "phyregs"); - if (r == NULL) { - dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); - retval = -ENODEV; - goto err_destroy_workqueue; - } - - mvotg->phy_regs = devm_ioremap(&pdev->dev, r->start, resource_size(r)); - if (mvotg->phy_regs == NULL) { - dev_err(&pdev->dev, "failed to map phy I/O memory\n"); - retval = -EFAULT; - goto err_destroy_workqueue; - } - - r = platform_get_resource_byname(mvotg->pdev, - IORESOURCE_MEM, "capregs"); + r = platform_get_resource(mvotg->pdev, + IORESOURCE_MEM, 0); if (r == NULL) { dev_err(&pdev->dev, "no I/O memory resource defined\n"); retval = -ENODEV; @@ -757,6 +742,14 @@ static int mv_otg_probe(struct platform_device *pdev) goto err_destroy_workqueue; } + mvotg->outer_phy = devm_usb_get_phy_dev(&pdev->dev, MV_USB2_PHY_INDEX); + if (IS_ERR_OR_NULL(mvotg->outer_phy)) { + retval = PTR_ERR(mvotg->outer_phy); + if (retval != -EPROBE_DEFER) + dev_err(&pdev->dev, "can not find outer phy\n"); + goto err_destroy_workqueue; + } + /* we will acces controller register, so enable the udc controller */ retval = mv_otg_enable_internal(mvotg); if (retval) { @@ -816,7 +809,7 @@ static int mv_otg_probe(struct platform_device *pdev) goto err_disable_clk; } - retval = usb_add_phy(&mvotg->phy, USB_PHY_TYPE_USB2); + retval = usb_add_phy_dev(&mvotg->phy); if (retval < 0) { dev_err(&pdev->dev, "can't register transceiver, %d\n", retval); @@ -827,7 +820,7 @@ static int mv_otg_probe(struct platform_device *pdev) if (retval < 0) { dev_dbg(&pdev->dev, "Can't register sysfs attr group: %d\n", retval); - goto err_remove_phy; + goto err_remove_otg_phy; } spin_lock_init(&mvotg->wq_lock); @@ -842,7 +835,7 @@ static int mv_otg_probe(struct platform_device *pdev) return 0; -err_remove_phy: +err_remove_otg_phy: usb_remove_phy(&mvotg->phy); err_disable_clk: mv_otg_disable_internal(mvotg); diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h index 551da6e..6df6219 100644 --- a/drivers/usb/phy/phy-mv-usb.h +++ b/drivers/usb/phy/phy-mv-usb.h @@ -137,10 +137,10 @@ struct mv_otg_regs { struct mv_otg { struct usb_phy phy; + struct usb_phy *outer_phy; struct mv_otg_ctrl otg_ctrl; /* base address */ - void __iomem *phy_regs; void __iomem *cap_regs; struct mv_otg_regs __iomem *op_regs;