[PATCH 1/3] usb: add device-tree-aware ehci driver
This adds device-tree-aware ehci-ppc-of driver. The code is based on the ehci-ppc-soc driver by Stefan Roese <[EMAIL PROTECTED]>. Signed-off-by: Stefan Roese <[EMAIL PROTECTED]> Signed-off-by: Valentine Barshak <[EMAIL PROTECTED]> --- drivers/usb/host/Kconfig |8 + drivers/usb/host/ehci-hcd.c| 16 ++ drivers/usb/host/ehci-ppc-of.c | 243 + drivers/usb/host/ehci.h|2 4 files changed, 267 insertions(+), 2 deletions(-) diff -ruN linux-2.6.orig/drivers/usb/host/ehci.h linux-2.6/drivers/usb/host/ehci.h --- linux-2.6.orig/drivers/usb/host/ehci.h 2007-09-24 14:55:44.0 +0400 +++ linux-2.6/drivers/usb/host/ehci.h 2007-09-24 23:07:16.0 +0400 @@ -725,7 +725,7 @@ * definition below can die once the 4xx support is * finally ported over. */ -#if defined(CONFIG_PPC) +#if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) #define readl_be(addr) in_be32((__force unsigned *)addr) #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) #endif diff -ruN linux-2.6.orig/drivers/usb/host/ehci-hcd.c linux-2.6/drivers/usb/host/ehci-hcd.c --- linux-2.6.orig/drivers/usb/host/ehci-hcd.c 2007-09-24 14:55:44.0 +0400 +++ linux-2.6/drivers/usb/host/ehci-hcd.c 2007-09-24 23:07:16.0 +0400 @@ -944,11 +944,16 @@ #definePS3_SYSTEM_BUS_DRIVER ps3_ehci_driver #endif -#ifdef CONFIG_440EPX +#if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) #include "ehci-ppc-soc.c" #definePLATFORM_DRIVER ehci_ppc_soc_driver #endif +#ifdef CONFIG_USB_EHCI_HCD_PPC_OF +#include "ehci-ppc-of.c" +#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver +#endif + #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ !defined(PS3_SYSTEM_BUS_DRIVER) #error "missing bus glue for ehci-hcd" @@ -963,6 +968,12 @@ sizeof(struct ehci_qh), sizeof(struct ehci_qtd), sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); +#ifdef OF_PLATFORM_DRIVER + retval = of_register_platform_driver(&OF_PLATFORM_DRIVER); + if (retval < 0) + return retval; +#endif + #ifdef PLATFORM_DRIVER retval = platform_driver_register(&PLATFORM_DRIVER); if (retval < 0) @@ -998,6 +1009,9 @@ static void __exit ehci_hcd_cleanup(void) { +#ifdef OF_PLATFORM_DRIVER + of_unregister_platform_driver(&OF_PLATFORM_DRIVER); +#endif #ifdef PLATFORM_DRIVER platform_driver_unregister(&PLATFORM_DRIVER); #endif diff -ruN linux-2.6.orig/drivers/usb/host/ehci-ppc-of.c linux-2.6/drivers/usb/host/ehci-ppc-of.c --- linux-2.6.orig/drivers/usb/host/ehci-ppc-of.c 1970-01-01 03:00:00.0 +0300 +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c2007-09-24 23:13:31.0 +0400 @@ -0,0 +1,243 @@ +/* + * EHCI HCD (Host Controller Driver) for USB. + * + * Bus Glue for PPC On-Chip EHCI driver on the of_platform bus + * Tested on AMCC PPC 440EPx + * + * Valentine Barshak <[EMAIL PROTECTED]> + * + * Based on "ehci-ppc-soc.c" by Stefan Roese <[EMAIL PROTECTED]> + * and "ohci-ppc-of.c" by Sylvain Munaut <[EMAIL PROTECTED]> + * + * This file is licenced under the GPL. + */ + +#include + +#include +#include + +/* called during probe() after chip reset completes */ +static int ehci_ppc_of_setup(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int retval; + + retval = ehci_halt(ehci); + if (retval) + return retval; + + retval = ehci_init(hcd); + if (retval) + return retval; + + ehci->sbrn = 0x20; + return ehci_reset(ehci); +} + + +static const struct hc_driver ehci_ppc_of_hc_driver = { + .description = hcd_name, + .product_desc = "OF EHCI", + .hcd_priv_size = sizeof(struct ehci_hcd), + + /* +* generic hardware linkage +*/ + .irq = ehci_irq, + .flags = HCD_MEMORY | HCD_USB2, + + /* +* basic lifecycle operations +*/ + .reset = ehci_ppc_of_setup, + .start = ehci_run, + .stop = ehci_stop, + .shutdown = ehci_shutdown, + + /* +* managing i/o requests and associated device resources +*/ + .urb_enqueue = ehci_urb_enqueue, + .urb_dequeue = ehci_urb_dequeue, + .endpoint_disable = ehci_endpoint_disable, + + /* +* scheduling support +*/ + .get_frame_number = ehci_get_frame, + + /* +* root hub support +*/ + .hub_status_data = ehci_hub_status_data, + .hub_control = ehci_hub_control, +#ifdef CONFIG_PM + .hub_suspend = ehci_hub_suspend, + .hub_resume = ehci_hub_resume, +#endif +}; + + +/* + * 440EPx Errata USBH_3 + * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 + */ +#define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) +static int __devinit +ppc44x_enable_bmt(struct device_node *dn) +{ + __iomem u32 *insreg_virt; + + i
Re: [PATCH 1/3] usb: add device-tree-aware ehci driver
On Tue, Sep 18, 2007 at 02:26:06PM +1000, Stephen Rothwell wrote: > On Mon, 17 Sep 2007 22:17:15 +0400 Valentine Barshak <[EMAIL PROTECTED]> > wrote: > > > > Looks like we'll need a patch that replaces asm/prom.h and > > asm/of_platform.h with linux/of.h and linux/of_platform.h > > in other drivers. > > Yeah, but at the moment I am just stopping the infection spreading > :-) Patching the existing instances would probably help with that, since it would mean less bad examples for people to copy. -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson signature.asc Description: Digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/3] usb: add device-tree-aware ehci driver
On Mon, 17 Sep 2007 22:17:15 +0400 Valentine Barshak <[EMAIL PROTECTED]> wrote: > > Looks like we'll need a patch that replaces asm/prom.h and > asm/of_platform.h with linux/of.h and linux/of_platform.h > in other drivers. Yeah, but at the moment I am just stopping the infection spreading :-) -- Cheers, Stephen Rothwell[EMAIL PROTECTED] http://www.canb.auug.org.au/~sfr/ pgpTV5d1K3jie.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH 1/3] usb: add device-tree-aware ehci driver
This adds ehci-ppc-of driver. The code is based on the ehci-ppc-soc driver by Stefan Roese <[EMAIL PROTECTED]>. Signed-off-by: Stefan Roese <[EMAIL PROTECTED]> Signed-off-by: Valentine Barshak <[EMAIL PROTECTED]> --- drivers/usb/host/Kconfig |8 + drivers/usb/host/ehci-hcd.c| 16 ++ drivers/usb/host/ehci-ppc-of.c | 220 + drivers/usb/host/ehci.h|2 4 files changed, 244 insertions(+), 2 deletions(-) diff -ruN linux-2.6.orig/drivers/usb/host/ehci.h linux-2.6/drivers/usb/host/ehci.h --- linux-2.6.orig/drivers/usb/host/ehci.h 2007-09-15 14:28:42.0 +0400 +++ linux-2.6/drivers/usb/host/ehci.h 2007-09-15 15:12:04.0 +0400 @@ -725,7 +725,7 @@ * definition below can die once the 4xx support is * finally ported over. */ -#if defined(CONFIG_PPC) +#if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) #define readl_be(addr) in_be32((__force unsigned *)addr) #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) #endif diff -ruN linux-2.6.orig/drivers/usb/host/ehci-hcd.c linux-2.6/drivers/usb/host/ehci-hcd.c --- linux-2.6.orig/drivers/usb/host/ehci-hcd.c 2007-09-15 14:28:42.0 +0400 +++ linux-2.6/drivers/usb/host/ehci-hcd.c 2007-09-15 15:12:04.0 +0400 @@ -944,11 +944,16 @@ #definePS3_SYSTEM_BUS_DRIVER ps3_ehci_driver #endif -#ifdef CONFIG_440EPX +#if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) #include "ehci-ppc-soc.c" #definePLATFORM_DRIVER ehci_ppc_soc_driver #endif +#ifdef CONFIG_USB_EHCI_HCD_PPC_OF +#include "ehci-ppc-of.c" +#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver +#endif + #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ !defined(PS3_SYSTEM_BUS_DRIVER) #error "missing bus glue for ehci-hcd" @@ -963,6 +968,12 @@ sizeof(struct ehci_qh), sizeof(struct ehci_qtd), sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); +#ifdef OF_PLATFORM_DRIVER + retval = of_register_platform_driver(&OF_PLATFORM_DRIVER); + if (retval < 0) + return retval; +#endif + #ifdef PLATFORM_DRIVER retval = platform_driver_register(&PLATFORM_DRIVER); if (retval < 0) @@ -998,6 +1009,9 @@ static void __exit ehci_hcd_cleanup(void) { +#ifdef OF_PLATFORM_DRIVER + of_unregister_platform_driver(&OF_PLATFORM_DRIVER); +#endif #ifdef PLATFORM_DRIVER platform_driver_unregister(&PLATFORM_DRIVER); #endif diff -ruN linux-2.6.orig/drivers/usb/host/ehci-ppc-of.c linux-2.6/drivers/usb/host/ehci-ppc-of.c --- linux-2.6.orig/drivers/usb/host/ehci-ppc-of.c 1970-01-01 03:00:00.0 +0300 +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c2007-09-15 16:12:56.0 +0400 @@ -0,0 +1,220 @@ +/* + * EHCI HCD (Host Controller Driver) for USB. + * + * Bus Glue for PPC On-Chip EHCI driver on the of_platform bus + * Tested on AMCC PPC 440EPx + * + * Valentine Barshak <[EMAIL PROTECTED]> + * + * Based on "ehci-ppc-soc.c" by Stefan Roese <[EMAIL PROTECTED]> + * and "ohci-ppc-of.c" by Sylvain Munaut <[EMAIL PROTECTED]> + * + * This file is licenced under the GPL. + */ + +#include + +#include +#include + +/* called during probe() after chip reset completes */ +static int ehci_ppc_of_setup(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int retval; + + retval = ehci_halt(ehci); + if (retval) + return retval; + + retval = ehci_init(hcd); + if (retval) + return retval; + + ehci->sbrn = 0x20; + return ehci_reset(ehci); +} + + +static const struct hc_driver ehci_ppc_of_hc_driver = { + .description = hcd_name, + .product_desc = "OF EHCI", + .hcd_priv_size = sizeof(struct ehci_hcd), + + /* +* generic hardware linkage +*/ + .irq = ehci_irq, + .flags = HCD_MEMORY | HCD_USB2, + + /* +* basic lifecycle operations +*/ + .reset = ehci_ppc_of_setup, + .start = ehci_run, + .stop = ehci_stop, + .shutdown = ehci_shutdown, + + /* +* managing i/o requests and associated device resources +*/ + .urb_enqueue = ehci_urb_enqueue, + .urb_dequeue = ehci_urb_dequeue, + .endpoint_disable = ehci_endpoint_disable, + + /* +* scheduling support +*/ + .get_frame_number = ehci_get_frame, + + /* +* root hub support +*/ + .hub_status_data = ehci_hub_status_data, + .hub_control = ehci_hub_control, +#ifdef CONFIG_PM + .hub_suspend = ehci_hub_suspend, + .hub_resume = ehci_hub_resume, +#endif +}; + + +static int __devinit +ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) +{ + struct device_node *dn = op->node; + struct usb_hcd *hcd; + struct ehci_hcd *ehci; + struct resource res; + int irq; + int rv; + +
Re: [PATCH 1/3] usb: add device-tree-aware ehci driver
Stephen Rothwell wrote: > On Mon, 17 Sep 2007 16:55:43 +0400 Valentine Barshak <[EMAIL PROTECTED]> > wrote: >> +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.0 >> +0400 >> @@ -0,0 +1,220 @@ >> + >> +#include >> +#include > > Please use linux/of.h and linux/of_platform.h instead. > >> +static int ehci_hcd_ppc_of_shutdown(struct of_device *op) >> +{ >> +struct usb_hcd *hcd = dev_get_drvdata(&op->dev); >> + >> +if (hcd->driver->shutdown) >> +hcd->driver->shutdown(hcd); > > White space has gone a bit funny here. > Corrected... Sending new patch in a minute. Looks like we'll need a patch that replaces asm/prom.h and asm/of_platform.h with linux/of.h and linux/of_platform.h in other drivers. ohci-ppc-of is definitely gonna need it. BTW, I think the ohci_hcd_ppc_of_match stuff for ohci-ppc-of.c has to be modified. I think it should be .type="usb" instead of .name="usb" and .compatible="ohci-littlendian" doesn't look good to me either. Thanks, Valentine. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/3] usb: add device-tree-aware ehci driver
On Mon, 17 Sep 2007 23:28:09 +1000 Stephen Rothwell <[EMAIL PROTECTED]> wrote: > On Mon, 17 Sep 2007 16:55:43 +0400 Valentine Barshak <[EMAIL PROTECTED]> > wrote: > > > > +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c2007-09-15 > > 16:12:56.0 +0400 > > @@ -0,0 +1,220 @@ > > + > > +#include > > +#include > > Please use linux/of.h and linux/of_platform.h instead. This seems to be a common error these days. Perhaps a #warning in the asm/ files if _LINUX_OF_PLATFORM_H and _LINUX_OF_H aren't defined would be helpful. josh ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/3] usb: add device-tree-aware ehci driver
On Mon, 17 Sep 2007 16:55:43 +0400 Valentine Barshak <[EMAIL PROTECTED]> wrote: > > +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.0 > +0400 > @@ -0,0 +1,220 @@ > + > +#include > +#include Please use linux/of.h and linux/of_platform.h instead. > +static int ehci_hcd_ppc_of_shutdown(struct of_device *op) > +{ > + struct usb_hcd *hcd = dev_get_drvdata(&op->dev); > + > +if (hcd->driver->shutdown) > +hcd->driver->shutdown(hcd); White space has gone a bit funny here. -- Cheers, Stephen Rothwell[EMAIL PROTECTED] http://www.canb.auug.org.au/~sfr/ pgpsoKRuufWfJ.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH 1/3] usb: add device-tree-aware ehci driver
This adds ehci-ppc-of driver. The code is based on the ehci-ppc-soc driver by Stefan Roese <[EMAIL PROTECTED]>. Signed-off-by: Stefan Roese <[EMAIL PROTECTED]> Signed-off-by: Valentine Barshak <[EMAIL PROTECTED]> --- drivers/usb/host/Kconfig |8 + drivers/usb/host/ehci-hcd.c| 16 ++ drivers/usb/host/ehci-ppc-of.c | 220 + drivers/usb/host/ehci.h|2 4 files changed, 244 insertions(+), 2 deletions(-) diff -ruN linux-2.6.orig/drivers/usb/host/ehci.h linux-2.6/drivers/usb/host/ehci.h --- linux-2.6.orig/drivers/usb/host/ehci.h 2007-09-15 14:28:42.0 +0400 +++ linux-2.6/drivers/usb/host/ehci.h 2007-09-15 15:12:04.0 +0400 @@ -725,7 +725,7 @@ * definition below can die once the 4xx support is * finally ported over. */ -#if defined(CONFIG_PPC) +#if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) #define readl_be(addr) in_be32((__force unsigned *)addr) #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) #endif diff -ruN linux-2.6.orig/drivers/usb/host/ehci-hcd.c linux-2.6/drivers/usb/host/ehci-hcd.c --- linux-2.6.orig/drivers/usb/host/ehci-hcd.c 2007-09-15 14:28:42.0 +0400 +++ linux-2.6/drivers/usb/host/ehci-hcd.c 2007-09-15 15:12:04.0 +0400 @@ -944,11 +944,16 @@ #definePS3_SYSTEM_BUS_DRIVER ps3_ehci_driver #endif -#ifdef CONFIG_440EPX +#if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) #include "ehci-ppc-soc.c" #definePLATFORM_DRIVER ehci_ppc_soc_driver #endif +#ifdef CONFIG_USB_EHCI_HCD_PPC_OF +#include "ehci-ppc-of.c" +#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver +#endif + #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ !defined(PS3_SYSTEM_BUS_DRIVER) #error "missing bus glue for ehci-hcd" @@ -963,6 +968,12 @@ sizeof(struct ehci_qh), sizeof(struct ehci_qtd), sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); +#ifdef OF_PLATFORM_DRIVER + retval = of_register_platform_driver(&OF_PLATFORM_DRIVER); + if (retval < 0) + return retval; +#endif + #ifdef PLATFORM_DRIVER retval = platform_driver_register(&PLATFORM_DRIVER); if (retval < 0) @@ -998,6 +1009,9 @@ static void __exit ehci_hcd_cleanup(void) { +#ifdef OF_PLATFORM_DRIVER + of_unregister_platform_driver(&OF_PLATFORM_DRIVER); +#endif #ifdef PLATFORM_DRIVER platform_driver_unregister(&PLATFORM_DRIVER); #endif diff -ruN linux-2.6.orig/drivers/usb/host/ehci-ppc-of.c linux-2.6/drivers/usb/host/ehci-ppc-of.c --- linux-2.6.orig/drivers/usb/host/ehci-ppc-of.c 1970-01-01 03:00:00.0 +0300 +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c2007-09-15 16:12:56.0 +0400 @@ -0,0 +1,220 @@ +/* + * EHCI HCD (Host Controller Driver) for USB. + * + * Bus Glue for PPC On-Chip EHCI driver on the of_platform bus + * Tested on AMCC PPC 440EPx + * + * Valentine Barshak <[EMAIL PROTECTED]> + * + * Based on "ehci-ppc-soc.c" by Stefan Roese <[EMAIL PROTECTED]> + * and "ohci-ppc-of.c" by Sylvain Munaut <[EMAIL PROTECTED]> + * + * This file is licenced under the GPL. + */ + +#include + +#include +#include + +/* called during probe() after chip reset completes */ +static int ehci_ppc_of_setup(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int retval; + + retval = ehci_halt(ehci); + if (retval) + return retval; + + retval = ehci_init(hcd); + if (retval) + return retval; + + ehci->sbrn = 0x20; + return ehci_reset(ehci); +} + + +static const struct hc_driver ehci_ppc_of_hc_driver = { + .description = hcd_name, + .product_desc = "OF EHCI", + .hcd_priv_size = sizeof(struct ehci_hcd), + + /* +* generic hardware linkage +*/ + .irq = ehci_irq, + .flags = HCD_MEMORY | HCD_USB2, + + /* +* basic lifecycle operations +*/ + .reset = ehci_ppc_of_setup, + .start = ehci_run, + .stop = ehci_stop, + .shutdown = ehci_shutdown, + + /* +* managing i/o requests and associated device resources +*/ + .urb_enqueue = ehci_urb_enqueue, + .urb_dequeue = ehci_urb_dequeue, + .endpoint_disable = ehci_endpoint_disable, + + /* +* scheduling support +*/ + .get_frame_number = ehci_get_frame, + + /* +* root hub support +*/ + .hub_status_data = ehci_hub_status_data, + .hub_control = ehci_hub_control, +#ifdef CONFIG_PM + .hub_suspend = ehci_hub_suspend, + .hub_resume = ehci_hub_resume, +#endif +}; + + +static int __devinit +ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) +{ + struct device_node *dn = op->node; + struct usb_hcd *hcd; + struct ehci_hcd *ehci; + struct resource res; + int irq; + int rv; + +