linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: chao.xie@marvell.com (Chao Xie)
To: linux-arm-kernel@lists.infradead.org
Subject: [V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation
Date: Sun, 7 Apr 2013 06:29:40 -0400	[thread overview]
Message-ID: <1365330586-649-7-git-send-email-chao.xie@marvell.com> (raw)
In-Reply-To: <1365330586-649-1-git-send-email-chao.xie@marvell.com>

The phy_init and phy_deinit APIs are removed from the pdata.
Directly get the phy driver and invoke the callbacks of phy
drivers for phy initialization and shutdown.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 drivers/usb/gadget/mv_u3d.h      |    3 +-
 drivers/usb/gadget/mv_u3d_core.c |   54 ++++++++++++++-----------------------
 2 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/gadget/mv_u3d.h b/drivers/usb/gadget/mv_u3d.h
index e32a787..0a0c7e3 100644
--- a/drivers/usb/gadget/mv_u3d.h
+++ b/drivers/usb/gadget/mv_u3d.h
@@ -251,7 +251,6 @@ struct mv_u3d {
 	struct mv_u3d_cap_regs __iomem	*cap_regs;
 	struct mv_u3d_op_regs __iomem	*op_regs;
 	struct mv_u3d_vuc_regs __iomem	*vuc_regs;
-	void __iomem			*phy_regs;
 
 	unsigned int			max_eps;
 	struct mv_u3d_ep_context	*ep_context;
@@ -283,6 +282,8 @@ struct mv_u3d {
 	struct mv_usb_addon_irq *vbus;
 	unsigned int		power;
 
+	struct usb_phy		*phy;
+
 	struct clk		*clk;
 };
 
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 58288e9..bb92c5b 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -24,6 +24,7 @@
 #include <linux/device.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
+#include <linux/usb/phy.h>
 #include <linux/pm.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -1109,7 +1110,6 @@ static int mv_u3d_controller_reset(struct mv_u3d *u3d)
 
 static int mv_u3d_enable(struct mv_u3d *u3d)
 {
-	struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
 	int retval;
 
 	if (u3d->active)
@@ -1122,14 +1122,12 @@ static int mv_u3d_enable(struct mv_u3d *u3d)
 
 	dev_dbg(u3d->dev, "enable u3d\n");
 	clk_enable(u3d->clk);
-	if (pdata->phy_init) {
-		retval = pdata->phy_init(u3d->phy_regs);
-		if (retval) {
-			dev_err(u3d->dev,
-				"init phy error %d\n", retval);
-			clk_disable(u3d->clk);
-			return retval;
-		}
+	retval = usb_phy_init(u3d->phy);
+	if (retval) {
+		dev_err(u3d->dev,
+			"init phy error %d\n", retval);
+		clk_disable(u3d->clk);
+		return retval;
 	}
 	u3d->active = 1;
 
@@ -1138,11 +1136,9 @@ static int mv_u3d_enable(struct mv_u3d *u3d)
 
 static void mv_u3d_disable(struct mv_u3d *u3d)
 {
-	struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
 	if (u3d->clock_gating && u3d->active) {
 		dev_dbg(u3d->dev, "disable u3d\n");
-		if (pdata->phy_deinit)
-			pdata->phy_deinit(u3d->phy_regs);
+		usb_phy_shutdown(u3d->phy);
 		clk_disable(u3d->clk);
 		u3d->active = 0;
 	}
@@ -1246,7 +1242,6 @@ static int mv_u3d_start(struct usb_gadget *g,
 		struct usb_gadget_driver *driver)
 {
 	struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget);
-	struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
 	unsigned long flags;
 
 	if (u3d->driver)
@@ -1256,8 +1251,7 @@ static int mv_u3d_start(struct usb_gadget *g,
 
 	if (!u3d->clock_gating) {
 		clk_enable(u3d->clk);
-		if (pdata->phy_init)
-			pdata->phy_init(u3d->phy_regs);
+		usb_phy_init(u3d->phy);
 	}
 
 	/* hook up the driver ... */
@@ -1277,7 +1271,6 @@ static int mv_u3d_stop(struct usb_gadget *g,
 		struct usb_gadget_driver *driver)
 {
 	struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget);
-	struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
 	unsigned long flags;
 
 	u3d->vbus_valid_detect = 0;
@@ -1285,8 +1278,7 @@ static int mv_u3d_stop(struct usb_gadget *g,
 
 	/* enable clock to access controller register */
 	clk_enable(u3d->clk);
-	if (pdata->phy_init)
-		pdata->phy_init(u3d->phy_regs);
+	usb_phy_init(u3d->phy);
 
 	mv_u3d_controller_stop(u3d);
 	/* stop all usb activities */
@@ -1294,8 +1286,7 @@ static int mv_u3d_stop(struct usb_gadget *g,
 	mv_u3d_stop_activity(u3d, driver);
 	mv_u3d_disable(u3d);
 
-	if (pdata->phy_deinit)
-		pdata->phy_deinit(u3d->phy_regs);
+	usb_phy_shutdown(u3d->phy);
 	clk_disable(u3d->clk);
 
 	spin_unlock_irqrestore(&u3d->lock, flags);
@@ -1827,7 +1818,7 @@ static int mv_u3d_probe(struct platform_device *dev)
 		goto err_get_clk;
 	}
 
-	r = platform_get_resource_byname(dev, IORESOURCE_MEM, "capregs");
+	r = platform_get_resource_byname(dev, IORESOURCE_MEM, 0);
 	if (!r) {
 		dev_err(&dev->dev, "no I/O memory resource defined\n");
 		retval = -ENODEV;
@@ -1846,15 +1837,14 @@ static int mv_u3d_probe(struct platform_device *dev)
 			(unsigned long) u3d->cap_regs);
 	}
 
-	/* we will access controller register, so enable the u3d controller */
-	clk_enable(u3d->clk);
+	u3d->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB3);
+	if (IS_ERR_OR_NULL(u3d->phy))
+		goto err_u3d_enable;
 
-	if (pdata->phy_init) {
-		retval = pdata->phy_init(u3d->phy_regs);
-		if (retval) {
-			dev_err(&dev->dev, "init phy error %d\n", retval);
-			goto err_u3d_enable;
-		}
+	retval = usb_phy_init(u3d->phy);
+	if (retval) {
+		dev_err(&dev->dev, "init phy error %d\n", retval);
+		goto err_u3d_enable;
 	}
 
 	u3d->op_regs = (struct mv_u3d_op_regs __iomem *)(u3d->cap_regs
@@ -1872,8 +1862,7 @@ static int mv_u3d_probe(struct platform_device *dev)
 	mv_u3d_controller_stop(u3d);
 	iowrite32(0xFFFFFFFF, &u3d->vuc_regs->intrcause);
 
-	if (pdata->phy_deinit)
-		pdata->phy_deinit(u3d->phy_regs);
+	usb_phy_shutdown(u3d->phy);
 	clk_disable(u3d->clk);
 
 	size = u3d->max_eps * sizeof(struct mv_u3d_ep_context) * 2;
@@ -1988,8 +1977,7 @@ err_alloc_trb_pool:
 	dma_free_coherent(&dev->dev, u3d->ep_context_size,
 		u3d->ep_context, u3d->ep_context_dma);
 err_alloc_ep_context:
-	if (pdata->phy_deinit)
-		pdata->phy_deinit(u3d->phy_regs);
+	usb_phy_shutdown(u3d->phy);
 	clk_disable(u3d->clk);
 err_u3d_enable:
 	iounmap(u3d->cap_regs);
-- 
1.7.4.1

  parent reply	other threads:[~2013-04-07 10:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 10:29 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
2013-04-07 10:29 ` [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces Chao Xie
2013-04-07 10:29 ` [V9 PATCH 02/12] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller Chao Xie
2013-04-07 10:29 ` [V9 PATCH 03/12] usb: gadget: mv_udc: use PHY driver for udc Chao Xie
2013-04-07 10:29 ` [V9 PATCH 04/12] usb: ehci: ehci-mv: use PHY driver for ehci Chao Xie
2013-04-07 10:29 ` [V9 PATCH 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg Chao Xie
2013-04-07 10:29 ` Chao Xie [this message]
2013-04-07 10:29 ` [V9 PATCH 07/12] arm: mmp2: change the defintion of usb devices Chao Xie
2013-04-07 10:29 ` [V9 PATCH 08/12] arm: pxa910: " Chao Xie
2013-04-07 10:29 ` [V9 PATCH 09/12] arm: ttc_dkb: modify usb support Chao Xie
2013-04-07 10:29 ` [V9 PATCH 10/12] arm: mmp: remove unused usb devices Chao Xie
2013-04-07 10:29 ` [V9 PATCH 11/12] arm: brownstone: add usb support for the board Chao Xie
2013-04-07 10:29 ` [V9 PATCH 12/12] usb: mv_usb: remove the phy callbacks in pdata Chao Xie
     [not found] ` <CADApbeg4BSUubbTw8tC-fuQ06JrRtAW9+rOdg=3rP_0Dr=LwkQ@mail.gmail.com>
2013-04-17  1:22   ` [V9 PATCH 00/12] mv-usb phy driver Chao Xie
2013-05-15 14:35     ` Felipe Balbi
  -- strict thread matches above, loose matches on Subject: below --
2013-04-24  6:23 Chao Xie
2013-04-24  6:23 ` [V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation Chao Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1365330586-649-7-git-send-email-chao.xie@marvell.com \
    --to=chao.xie@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).