linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lubomir Rintel <lkundrak@v3.sk>
To: linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Eric Miao <eric.y.miao@gmail.com>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Lubomir Rintel <lkundrak@v3.sk>
Subject: [PATCH 08/14] USB: EHCI: ehci-mv: use phy-pxa-usb
Date: Wed, 22 Aug 2018 22:43:01 +0200	[thread overview]
Message-ID: <20180822204307.13251-9-lkundrak@v3.sk> (raw)
In-Reply-To: <20180822204307.13251-1-lkundrak@v3.sk>

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 11 +---------
 drivers/usb/host/ehci-mv.c  | 44 ++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index d162fabd38e7..822b8be042b9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -298,21 +298,12 @@ struct platform_device pxa168_device_u2o = {
 
 #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
 struct resource pxa168_u2oehci_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 705d1b43b2dd..43b300c90875 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -18,6 +18,9 @@
 
 #include "ehci.h"
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 #define CAPLENGTH_MASK         (0xff)
 
 #define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
@@ -26,13 +29,14 @@ struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
 
 	struct mv_usb_platform_data *pdata;
+	struct phy *phy;
 
 	struct clk *clk;
 };
@@ -49,22 +53,13 @@ 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 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);
+	phy_exit(ehci_mv->phy);
 	ehci_clock_disable(ehci_mv);
 }
 
@@ -121,6 +116,14 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
 
+	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(ehci_mv->phy)) {
+		retval = PTR_ERR(ehci_mv->phy);
+		if (retval != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get phy.\n");
+		goto err_put_hcd;
+	}
+
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
 		dev_err(&pdev->dev, "error getting clock\n");
@@ -128,17 +131,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
-	ehci_mv->phy_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->phy_regs)) {
-		retval = PTR_ERR(ehci_mv->phy_regs);
-		goto err_put_hcd;
-	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs");
-	ehci_mv->cap_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->cap_regs)) {
-		retval = PTR_ERR(ehci_mv->cap_regs);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ehci_mv->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(ehci_mv->base)) {
+		retval = PTR_ERR(ehci_mv->base);
 		goto err_put_hcd;
 	}
 
@@ -148,6 +146,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
+	ehci_mv->cap_regs =
+		(void __iomem *) ((unsigned long) ehci_mv->base + U2x_CAPREGS_OFFSET);
 	offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK;
 	ehci_mv->op_regs =
 		(void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset);
-- 
2.17.1


  parent reply	other threads:[~2018-08-22 20:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-22 20:42 [PATCH 00/14] Convert ehci-mv to DT Lubomir Rintel
2018-08-22 20:42 ` [PATCH 01/14] phy: phy-pxa-usb: add a new driver Lubomir Rintel
2018-09-25  5:23   ` Kishon Vijay Abraham I
2018-10-07 18:47     ` Lubomir Rintel
2018-10-08 13:21       ` Greg Kroah-Hartman
2018-10-09 14:51         ` Lubomir Rintel
2018-10-09 14:57           ` Greg Kroah-Hartman
2018-08-22 20:42 ` [PATCH 02/14] dt-bindings: phy-pxa-usb: add bindings Lubomir Rintel
2018-11-05  9:19   ` Pavel Machek
2018-08-22 20:42 ` [PATCH 03/14] USB: EHCI: make ehci-mv a separate driver Lubomir Rintel
2018-08-22 20:42 ` [PATCH 04/14] ARM: mmp: add a pxa-usb-phy device Lubomir Rintel
2018-08-22 20:42 ` [PATCH 05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy Lubomir Rintel
2018-11-05  9:19   ` Pavel Machek
2018-08-22 20:42 ` [PATCH 06/14] ARM: aspenite: " Lubomir Rintel
2018-11-05  9:19   ` Pavel Machek
2018-08-22 20:43 ` [PATCH 07/14] USB: EHCI: ehci-mv: remove private_init Lubomir Rintel
2018-08-22 20:43 ` Lubomir Rintel [this message]
2018-08-22 20:43 ` [PATCH 09/14] USB: phy-mv-usb: use phy-pxa-usb Lubomir Rintel
2018-11-05  9:19   ` Pavel Machek
2018-08-22 20:43 ` [PATCH 10/14] USB: gadget: mv-udc: " Lubomir Rintel
2018-11-05  9:20   ` Pavel Machek
2018-08-22 20:43 ` [PATCH 11/14] USB: EHCI: ehci-mv: add DT support Lubomir Rintel
2018-08-22 20:43 ` [PATCH 12/14] dt-bindings: ehci-mv: add bindings Lubomir Rintel
2018-11-02 20:47   ` Pavel Machek
2018-08-22 20:43 ` [PATCH 13/14] DT: marvell,mmp2: add OTG PHY Lubomir Rintel
2018-11-05  9:20   ` Pavel Machek
2018-08-22 20:43 ` [PATCH 14/14] DT: marvell,mmp2: add USB OTG host controller Lubomir Rintel
2018-11-05  9:20   ` Pavel Machek
2018-08-28 15:04 ` [PATCH 00/14] Convert ehci-mv to DT Alan Stern

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=20180822204307.13251-9-lkundrak@v3.sk \
    --to=lkundrak@v3.sk \
    --cc=eric.y.miao@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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).