All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
@ 2012-03-22 15:50 Stefan Roese
       [not found] ` <1332431402-20606-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Roese @ 2012-03-22 15:50 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: Viresh Kumar, devicetree-discuss-mnsaURCQ41sdnm+yROfE0A,
	spear-devel-nkJGhpqTU55BDgjK7y7TUQ

This patch adds support to configure the SPEAr EHCI & OHCI driver via
device-tree instead of platform_data.

Signed-off-by: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
Cc: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
---
 .../devicetree/bindings/usb/spear-usb.txt          |   39 ++++++++++++++++++++
 drivers/usb/host/ehci-spear.c                      |   32 +++++++++++++---
 drivers/usb/host/ohci-spear.c                      |   32 +++++++++++++---
 3 files changed, 91 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/spear-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/spear-usb.txt b/Documentation/devicetree/bindings/usb/spear-usb.txt
new file mode 100644
index 0000000..f8a464a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/spear-usb.txt
@@ -0,0 +1,39 @@
+ST SPEAr SoC USB controllers:
+-----------------------------
+
+EHCI:
+-----
+
+Required properties:
+- compatible: "st,spear600-ehci"
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the EHCI interrupt
+
+Example:
+
+	ehci@e1800000 {
+		compatible = "st,spear600-ehci", "usb-ehci";
+		reg = <0xe1800000 0x1000>;
+		interrupt-parent = <&vic1>;
+		interrupts = <27>;
+	};
+
+
+OHCI:
+-----
+
+Required properties:
+- compatible: "st,spear600-ohci"
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the OHCI interrupt
+
+Example:
+
+	ohci@e1900000 {
+		compatible = "st,spear600-ohci", "usb-ohci";
+		reg = <0xe1800000 0x1000>;
+		interrupt-parent = <&vic1>;
+		interrupts = <26>;
+	};
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 6e92855..2e3c89a 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -13,6 +13,7 @@
 
 #include <linux/clk.h>
 #include <linux/jiffies.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 
@@ -168,6 +169,8 @@ static int ehci_spear_drv_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend,
 		ehci_spear_drv_resume);
 
+static u64 spear_ehci_dma_mask = DMA_BIT_MASK(32);
+
 static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
 {
 	struct usb_hcd *hcd ;
@@ -175,12 +178,9 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct clk *usbh_clk;
 	const struct hc_driver *driver = &ehci_spear_hc_driver;
-	int *pdata = pdev->dev.platform_data;
 	int irq, retval;
 	char clk_name[20] = "usbh_clk";
-
-	if (pdata == NULL)
-		return -EFAULT;
+	static int instance = -1;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -191,8 +191,22 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
 		goto fail_irq_get;
 	}
 
-	if (*pdata >= 0)
-		sprintf(clk_name, "usbh.%01d_clk", *pdata);
+	/*
+	 * Right now device-tree probed devices don't get dma_mask set.
+	 * Since shared usb code relies on it, set it here for now.
+	 * Once we have dma capability bindings this can go away.
+	 */
+	if (!pdev->dev.dma_mask)
+		pdev->dev.dma_mask = &spear_ehci_dma_mask;
+
+	/*
+	 * Increment the device instance, when probing via device-tree
+	 */
+	if (pdev->id < 0)
+		instance++;
+	else
+		instance = pdev->id;
+	sprintf(clk_name, "usbh.%01d_clk", instance);
 
 	usbh_clk = clk_get(NULL, clk_name);
 	if (IS_ERR(usbh_clk)) {
@@ -277,6 +291,11 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static struct of_device_id spear_ehci_id_table[] __devinitdata = {
+	{ .compatible = "st,spear600-ehci", },
+	{ },
+};
+
 static struct platform_driver spear_ehci_hcd_driver = {
 	.probe		= spear_ehci_hcd_drv_probe,
 	.remove		= spear_ehci_hcd_drv_remove,
@@ -285,6 +304,7 @@ static struct platform_driver spear_ehci_hcd_driver = {
 		.name = "spear-ehci",
 		.bus = &platform_bus_type,
 		.pm = &ehci_spear_pm_ops,
+		.of_match_table = of_match_ptr(spear_ehci_id_table),
 	}
 };
 
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 95c1648..eb4640b 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -14,6 +14,7 @@
 #include <linux/signal.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/of.h>
 
 struct spear_ohci {
 	struct ohci_hcd ohci;
@@ -90,6 +91,8 @@ static const struct hc_driver ohci_spear_hc_driver = {
 	.start_port_reset	= ohci_start_port_reset,
 };
 
+static u64 spear_ohci_dma_mask = DMA_BIT_MASK(32);
+
 static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
 {
 	const struct hc_driver *driver = &ohci_spear_hc_driver;
@@ -98,11 +101,8 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
 	struct spear_ohci *ohci_p;
 	struct resource *res;
 	int retval, irq;
-	int *pdata = pdev->dev.platform_data;
 	char clk_name[20] = "usbh_clk";
-
-	if (pdata == NULL)
-		return -EFAULT;
+	static int instance = -1;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
@@ -110,8 +110,22 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
 		goto fail_irq_get;
 	}
 
-	if (*pdata >= 0)
-		sprintf(clk_name, "usbh.%01d_clk", *pdata);
+	/*
+	 * Right now device-tree probed devices don't get dma_mask set.
+	 * Since shared usb code relies on it, set it here for now.
+	 * Once we have dma capability bindings this can go away.
+	 */
+	if (!pdev->dev.dma_mask)
+		pdev->dev.dma_mask = &spear_ohci_dma_mask;
+
+	/*
+	 * Increment the device instance, when probing via device-tree
+	 */
+	if (pdev->id < 0)
+		instance++;
+	else
+		instance = pdev->id;
+	sprintf(clk_name, "usbh.%01d_clk", instance);
 
 	usbh_clk = clk_get(NULL, clk_name);
 	if (IS_ERR(usbh_clk)) {
@@ -222,6 +236,11 @@ static int spear_ohci_hcd_drv_resume(struct platform_device *dev)
 }
 #endif
 
+static struct of_device_id spear_ohci_id_table[] __devinitdata = {
+	{ .compatible = "st,spear600-ohci", },
+	{ },
+};
+
 /* Driver definition to register with the platform bus */
 static struct platform_driver spear_ohci_hcd_driver = {
 	.probe =	spear_ohci_hcd_drv_probe,
@@ -233,6 +252,7 @@ static struct platform_driver spear_ohci_hcd_driver = {
 	.driver = {
 		.owner = THIS_MODULE,
 		.name = "spear-ohci",
+		.of_match_table = of_match_ptr(spear_ohci_id_table),
 	},
 };
 
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found] ` <1332431402-20606-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>
@ 2012-03-23  3:48   ` Viresh Kumar
       [not found]     ` <4F6BF275.9040007-qxv4g6HH51o@public.gmane.org>
  2012-04-13  3:59   ` Viresh Kumar
  1 sibling, 1 reply; 8+ messages in thread
From: Viresh Kumar @ 2012-03-23  3:48 UTC (permalink / raw)
  To: Stefan Roese
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, spear-devel,
	deepak sikri

On 3/22/2012 9:20 PM, Stefan Roese wrote:
> +static struct of_device_id spear_ohci_id_table[] __devinitdata = {
> +	{ .compatible = "st,spear600-ohci", },

Hi Stefan,

I have this question for other drivers (fsmc, stmmac...) as well:
Why do we name it spear600-ohci and not spear-ohci?
Because i believe we have same version of USB on all SPEAr SoCs.

-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found]     ` <4F6BF275.9040007-qxv4g6HH51o@public.gmane.org>
@ 2012-03-23  8:00       ` Stefan Roese
       [not found]         ` <201203230900.02280.sr-ynQEQJNshbs@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Roese @ 2012-03-23  8:00 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, spear-devel,
	deepak sikri

Hi Viresh,

On Friday 23 March 2012 04:48:05 Viresh Kumar wrote:
> On 3/22/2012 9:20 PM, Stefan Roese wrote:
> > +static struct of_device_id spear_ohci_id_table[] __devinitdata = {
> > +	{ .compatible = "st,spear600-ohci", },
> 
> Hi Stefan,
> 
> I have this question for other drivers (fsmc, stmmac...) as well:
> Why do we name it spear600-ohci and not spear-ohci?
> Because i believe we have same version of USB on all SPEAr SoCs.

There could be differences between the IP cores integrated into the SoCs. I 
only tested on spear600, so thats what I integrated into the drivers. While 
supporting more SoCs (SPEAr300 etc) to those drivers, you should add the 
specific compatible properties to the lists.

If the IP core doesn't differ between those SoCs, then it might make sense to 
change this property to something more general, like "st,spear-ohci" (etc). 
Not 100% sure though. Other DT experts might have more insight here.

Thanks,
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found]         ` <201203230900.02280.sr-ynQEQJNshbs@public.gmane.org>
@ 2012-03-23  8:07           ` Viresh Kumar
       [not found]             ` <4F6C2F25.8030402-qxv4g6HH51o@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Viresh Kumar @ 2012-03-23  8:07 UTC (permalink / raw)
  To: Stefan Roese
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, spear-devel,
	Deepak SIKRI

On 3/23/2012 1:30 PM, Stefan Roese wrote:
> There could be differences between the IP cores integrated into the SoCs. I 
> only tested on spear600, so thats what I integrated into the drivers. While 
> supporting more SoCs (SPEAr300 etc) to those drivers, you should add the 
> specific compatible properties to the lists.

Ya. That's what i was expecting.

> If the IP core doesn't differ between those SoCs, then it might make sense to 
> change this property to something more general, like "st,spear-ohci" (etc). 
> Not 100% sure though. Other DT experts might have more insight here.

Ok. FSMC version is same for 3xx and 6xx. Is different for 13xx.
But driver is capable of detecting the version itself and so we might
go ahead with "st,spear-fsmc there"

SMI, EHCI and OHCI have exactly the same version for all three families of SoC's.
So, we must better name them "st,spear-***"

-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found]             ` <4F6C2F25.8030402-qxv4g6HH51o@public.gmane.org>
@ 2012-03-23 14:17               ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2012-03-23 14:17 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Stefan Roese, linux-usb-u79uwXL29TY76Z2rM5mHXA, spear-devel,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Deepak SIKRI

On 03/23/2012 03:07 AM, Viresh Kumar wrote:
> On 3/23/2012 1:30 PM, Stefan Roese wrote:
>> There could be differences between the IP cores integrated into the SoCs. I 
>> only tested on spear600, so thats what I integrated into the drivers. While 
>> supporting more SoCs (SPEAr300 etc) to those drivers, you should add the 
>> specific compatible properties to the lists.
> 
> Ya. That's what i was expecting.
> 
>> If the IP core doesn't differ between those SoCs, then it might make sense to 
>> change this property to something more general, like "st,spear-ohci" (etc). 
>> Not 100% sure though. Other DT experts might have more insight here.
> 
> Ok. FSMC version is same for 3xx and 6xx. Is different for 13xx.
> But driver is capable of detecting the version itself and so we might
> go ahead with "st,spear-fsmc there"
> 
> SMI, EHCI and OHCI have exactly the same version for all three families of SoC's.
> So, we must better name them "st,spear-***"

No, it's better to be safe and be more specific. You have to think of it
as if you created the DT entries as the h/w came out. Define the
compatible string in terms of the 1st version. Then if the 2nd SOC
happens to have the same version, you can re-use the compatible string
and not change the driver.

Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found] ` <1332431402-20606-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>
  2012-03-23  3:48   ` Viresh Kumar
@ 2012-04-13  3:59   ` Viresh Kumar
       [not found]     ` <4F87A48E.3090300-qxv4g6HH51o@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Viresh Kumar @ 2012-04-13  3:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Stefan Roese, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, spear-devel

On 3/22/2012 9:20 PM, Stefan Roese wrote:
> This patch adds support to configure the SPEAr EHCI & OHCI driver via
> device-tree instead of platform_data.
> 
> Signed-off-by: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
> Cc: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
> ---
>  .../devicetree/bindings/usb/spear-usb.txt          |   39 ++++++++++++++++++++
>  drivers/usb/host/ehci-spear.c                      |   32 +++++++++++++---
>  drivers/usb/host/ohci-spear.c                      |   32 +++++++++++++---
>  3 files changed, 91 insertions(+), 12 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/spear-usb.txt

Hi Greg,

Have you applied this patch?

-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found]     ` <4F87A48E.3090300-qxv4g6HH51o@public.gmane.org>
@ 2012-04-13 18:26       ` Greg KH
       [not found]         ` <20120413182655.GA5444-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2012-04-13 18:26 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Stefan Roese, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, spear-devel

On Fri, Apr 13, 2012 at 09:29:10AM +0530, Viresh Kumar wrote:
> On 3/22/2012 9:20 PM, Stefan Roese wrote:
> > This patch adds support to configure the SPEAr EHCI & OHCI driver via
> > device-tree instead of platform_data.
> > 
> > Signed-off-by: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
> > Cc: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
> > ---
> >  .../devicetree/bindings/usb/spear-usb.txt          |   39 ++++++++++++++++++++
> >  drivers/usb/host/ehci-spear.c                      |   32 +++++++++++++---
> >  drivers/usb/host/ohci-spear.c                      |   32 +++++++++++++---
> >  3 files changed, 91 insertions(+), 12 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/usb/spear-usb.txt
> 
> Hi Greg,
> 
> Have you applied this patch?

No, should I?

If so, please resend it, as it's not in any of my inboxes...

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear
       [not found]         ` <20120413182655.GA5444-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
@ 2012-04-16  3:44           ` Viresh Kumar
  0 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2012-04-16  3:44 UTC (permalink / raw)
  To: Greg KH
  Cc: Stefan Roese, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, spear-devel

On 4/13/2012 11:56 PM, Greg KH wrote:
> No, should I?

Yes.

> If so, please resend it, as it's not in any of my inboxes...

I would do that. It was sent directly to linux-usb by Stefan, didn't
kept you in cc or to.

--
viresh
-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-04-16  3:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-22 15:50 [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear Stefan Roese
     [not found] ` <1332431402-20606-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>
2012-03-23  3:48   ` Viresh Kumar
     [not found]     ` <4F6BF275.9040007-qxv4g6HH51o@public.gmane.org>
2012-03-23  8:00       ` Stefan Roese
     [not found]         ` <201203230900.02280.sr-ynQEQJNshbs@public.gmane.org>
2012-03-23  8:07           ` Viresh Kumar
     [not found]             ` <4F6C2F25.8030402-qxv4g6HH51o@public.gmane.org>
2012-03-23 14:17               ` Rob Herring
2012-04-13  3:59   ` Viresh Kumar
     [not found]     ` <4F87A48E.3090300-qxv4g6HH51o@public.gmane.org>
2012-04-13 18:26       ` Greg KH
     [not found]         ` <20120413182655.GA5444-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2012-04-16  3:44           ` Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.