* [PATCH 0/3] usb: ehci ppc device-tree-aware driver @ 2007-09-17 12:50 Valentine Barshak 2007-09-17 12:55 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Valentine Barshak ` (2 more replies) 0 siblings, 3 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-17 12:50 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel Some PowerPC systems have a built-in EHCI controller. This is a device tree aware version of the EHCI controller driver. Currently it's been tested on the PowerPC 440EPx Sequoia board. Other platforms can be added later. The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-17 12:50 [PATCH 0/3] usb: ehci ppc device-tree-aware driver Valentine Barshak @ 2007-09-17 12:55 ` Valentine Barshak 2007-09-17 13:00 ` [PATCH 2/3] usb: ehci-ppc-of dts bindings Valentine Barshak 2007-09-17 13:28 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Stephen Rothwell 2007-09-17 13:02 ` [PATCH 3/3] Add PowerPC 440EPx Sequoia ehci dts entry Valentine Barshak 2007-09-22 23:00 ` [PATCH 0/3] usb: ehci ppc device-tree-aware driver Hollis Blanchard 2 siblings, 2 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-17 12:55 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel This adds ehci-ppc-of driver. The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. Signed-off-by: Stefan Roese <sr@denx.de> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com> --- 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.000000000 +0400 +++ linux-2.6/drivers/usb/host/ehci.h 2007-09-15 15:12:04.000000000 +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.000000000 +0400 +++ linux-2.6/drivers/usb/host/ehci-hcd.c 2007-09-15 15:12:04.000000000 +0400 @@ -944,11 +944,16 @@ #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver #endif -#ifdef CONFIG_440EPX +#if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) #include "ehci-ppc-soc.c" #define PLATFORM_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.000000000 +0300 +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.000000000 +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 <vbarshak@ru.mvista.com> + * + * Based on "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de> + * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com> + * + * This file is licenced under the GPL. + */ + +#include <linux/signal.h> + +#include <asm/of_platform.h> +#include <asm/prom.h> + +/* 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; + + if (usb_disabled()) + return -ENODEV; + + dev_dbg(&op->dev, "initializing PPC-OF USB Controller\n"); + + rv = of_address_to_resource(dn, 0, &res); + if (rv) + return rv; + + hcd = usb_create_hcd(&ehci_ppc_of_hc_driver, &op->dev, "PPC-OF USB"); + if (!hcd) + return -ENOMEM; + + hcd->rsrc_start = res.start; + hcd->rsrc_len = res.end - res.start + 1; + + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { + printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); + rv = -EBUSY; + goto err_rmr; + } + + irq = irq_of_parse_and_map(dn, 0); + if (irq == NO_IRQ) { + printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); + rv = -EBUSY; + goto err_irq; + } + + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); + if (!hcd->regs) { + printk(KERN_ERR __FILE__ ": ioremap failed\n"); + rv = -ENOMEM; + goto err_ioremap; + } + + ehci = hcd_to_ehci(hcd); + if (of_device_is_compatible(dn, "ehci-be-desc")) + ehci->big_endian_desc = 1; + if (of_get_property(dn, "big-endian", NULL)) + ehci->big_endian_mmio = 1; + + ehci->caps = hcd->regs; + ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); + + /* cache this readonly data; minimize chip reads */ + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); + + if (of_device_is_compatible(dn, "ibm,ehci-440epx")) { + /* + * 440EPx Errata USBH_3 + * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 + */ + out_be32((void *)((ulong)(&ehci->regs->command) + 0x8c), (1 << 0)); + ehci_dbg(ehci, "Break Memory Transfer (BMT) has beed enabled!\n"); + } + + rv = usb_add_hcd(hcd, irq, 0); + if (rv == 0) + return 0; + + iounmap(hcd->regs); +err_ioremap: + irq_dispose_mapping(irq); +err_irq: + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); +err_rmr: + usb_put_hcd(hcd); + + return rv; +} + + +static int ehci_hcd_ppc_of_remove(struct of_device *op) +{ + struct usb_hcd *hcd = dev_get_drvdata(&op->dev); + dev_set_drvdata(&op->dev, NULL); + + dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); + + usb_remove_hcd(hcd); + + iounmap(hcd->regs); + irq_dispose_mapping(hcd->irq); + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + + usb_put_hcd(hcd); + + return 0; +} + + +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); + + return 0; +} + + +static struct of_device_id ehci_hcd_ppc_of_match[] = { + { + .type = "usb", + .compatible = "ehci", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, ehci_hcd_ppc_of_match); + + +static struct of_platform_driver ehci_hcd_ppc_of_driver = { + .name = "ppc-of-ehci", + .match_table = ehci_hcd_ppc_of_match, + .probe = ehci_hcd_ppc_of_probe, + .remove = ehci_hcd_ppc_of_remove, + .shutdown = ehci_hcd_ppc_of_shutdown, +#ifdef CONFIG_PM + /*.suspend = ehci_hcd_ppc_of_drv_suspend,*/ + /*.resume = ehci_hcd_ppc_of_drv_resume,*/ +#endif + .driver = { + .name = "ppc-of-ehci", + .owner = THIS_MODULE, + }, +}; + diff -ruN linux-2.6.orig/drivers/usb/host/Kconfig linux-2.6/drivers/usb/host/Kconfig --- linux-2.6.orig/drivers/usb/host/Kconfig 2007-09-15 14:28:42.000000000 +0400 +++ linux-2.6/drivers/usb/host/Kconfig 2007-09-15 15:12:04.000000000 +0400 @@ -84,6 +84,14 @@ ---help--- Variation of ARC USB block used in some Freescale chips. +config USB_EHCI_HCD_PPC_OF + bool "EHCI support for PPC USB controller on OF platform bus" + depends on USB_EHCI_HCD && PPC_OF + default y + ---help--- + Enables support for the USB controller PowerPC present on the + OpenFirmware platform bus. + config USB_ISP116X_HCD tristate "ISP116X HCD support" depends on USB ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-17 12:55 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Valentine Barshak @ 2007-09-17 13:00 ` Valentine Barshak 2007-09-19 0:25 ` Segher Boessenkool 2007-09-17 13:28 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Stephen Rothwell 1 sibling, 1 reply; 23+ messages in thread From: Valentine Barshak @ 2007-09-17 13:00 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com> --- Documentation/powerpc/booting-without-of.txt | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff -ruN linux-2.6.orig/Documentation/powerpc/booting-without-of.txt linux-2.6.new/Documentation/powerpc/booting-without-of.txt --- linux-2.6.orig/Documentation/powerpc/booting-without-of.txt 2007-09-15 14:27:57.000000000 +0400 +++ linux-2.6.new/Documentation/powerpc/booting-without-of.txt 2007-09-15 17:19:06.000000000 +0400 @@ -52,6 +52,7 @@ i) Freescale QUICC Engine module (QE) j) CFI or JEDEC memory-mapped NOR flash k) Global Utilities Block + l) USB EHCI controllers VII - Specifying interrupt information for devices 1) interrupts property @@ -1848,6 +1849,35 @@ fsl,has-rstcr; }; + l) USB EHCI controllers + + Required properties: + - device_type : should be "usb". + - compatible : should be "ehci". + - reg : Offset and length of the register set for the device + - interrupts : <a b> where a is the interrupt number and b is a + field that represents an encoding of the sense and level + information for the interrupt. This should be encoded based on + the information in section 2) depending on the type of interrupt + controller you have. + - interrupt-parent : the phandle for the interrupt controller that + services interrupts for this device. + If device registers are implemented in big endian mode, the device + node should have "big-endian" property. + If controller implementation operates with big endian descriptors, + compatible should also have "ehci-be-desc" + + Example (Sequoia 440EPx): + ehci@e0000300 { + device_type = "usb"; + compatible = "ibm,ehci-440epx", "ehci-be-desc", "ehci"; + interrupts = <1a 4>; + interrupt-parent = <&UIC0>; + reg = <0 e0000300 ff>; + big-endian; + }; + + More devices will be defined as this spec matures. VII - Specifying interrupt information for devices ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-17 13:00 ` [PATCH 2/3] usb: ehci-ppc-of dts bindings Valentine Barshak @ 2007-09-19 0:25 ` Segher Boessenkool 2007-09-19 13:52 ` Valentine Barshak 0 siblings, 1 reply; 23+ messages in thread From: Segher Boessenkool @ 2007-09-19 0:25 UTC (permalink / raw) To: Valentine Barshak; +Cc: linuxppc-dev, linux-usb-devel > + l) USB EHCI controllers > + > + Required properties: > + - device_type : should be "usb". No device_type please. The published USB binding doesn't define one on purpose. > + - compatible : should be "ehci". Just "ehci" isn't enough -- compare to OHCI, which is the name for a kind of USB host controller as well as for a kind of Firewire host controller. Maybe "usb-ehci" is best -- can anyone think of a better name? > + - reg : Offset and length of the register set for the device Address and length. You also should declare here how the optional EHCI register blocks should be encoded (the USB debug port, etc.) > + - interrupts : <a b> where a is the interrupt number and b is a > + field that represents an encoding of the sense and level > + information for the interrupt. This is incorrect; not all interrupt domains use two cells, and not all that do have this meaning for those cells. Instead, you should just say how many interrupts should be here, and which is which in the EHCI standard. > + - interrupt-parent : the phandle for the interrupt controller that > + services interrupts for this device. Not every EHCI node needs this; just don't mention this at all, interrupt mapping is fully defined for all devices elsewhere already (in the "interrupt mapping" recommended practice). > + If device registers are implemented in big endian mode, the device > + node should have "big-endian" property. > + If controller implementation operates with big endian descriptors, > + compatible should also have "ehci-be-desc" Ah, I understand what this is about, finally. Don't put this in "compatible"; instead, do a "big-endian-descriptors" property similar to the "big-endian" property. That last one should maybe be "big-endian-registers" here then, to avoid confusion. Or make "big-endian" mean both big-endian registers *and* big-endian descriptors. I have no opinion which is best; it depends on what configurations actually exist, and how popular those are. > + ehci@e0000300 { > + device_type = "usb"; > + compatible = "ibm,ehci-440epx", "ehci-be-desc", "ehci"; > + interrupts = <1a 4>; > + interrupt-parent = <&UIC0>; > + reg = <0 e0000300 ff>; Length should be 100 here. > + big-endian; > + }; Segher ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-19 0:25 ` Segher Boessenkool @ 2007-09-19 13:52 ` Valentine Barshak 2007-09-19 16:50 ` Segher Boessenkool 0 siblings, 1 reply; 23+ messages in thread From: Valentine Barshak @ 2007-09-19 13:52 UTC (permalink / raw) To: Segher Boessenkool; +Cc: linuxppc-dev, linux-usb-devel Segher Boessenkool wrote: >> + l) USB EHCI controllers >> + >> + Required properties: >> + - device_type : should be "usb". > > No device_type please. The published USB binding doesn't define > one on purpose. > Could you please, explain why? Sorry, I don't think I get the concept of device description here. >> + - compatible : should be "ehci". > > Just "ehci" isn't enough -- compare to OHCI, which is the name for > a kind of USB host controller as well as for a kind of Firewire > host controller. Actually, I though device type="usb" + compatible="ehci" would be enough. > > Maybe "usb-ehci" is best -- can anyone think of a better name? Again, why not type="usb", compatible="ehci"? > >> + - reg : Offset and length of the register set for the device > > Address and length. You also should declare here how the optional > EHCI register blocks should be encoded (the USB debug port, etc.) > >> + - interrupts : <a b> where a is the interrupt number and b is a >> + field that represents an encoding of the sense and level >> + information for the interrupt. > > This is incorrect; not all interrupt domains use two cells, and > not all that do have this meaning for those cells. Well, this was just copied from other descriptions in Documentation/powerpc/booting-without-of.txt Do we need to fix them all? > > Instead, you should just say how many interrupts should be here, > and which is which in the EHCI standard. > >> + - interrupt-parent : the phandle for the interrupt controller that >> + services interrupts for this device. > > Not every EHCI node needs this; just don't mention this at all, > interrupt mapping is fully defined for all devices elsewhere > already (in the "interrupt mapping" recommended practice). > >> + If device registers are implemented in big endian mode, the device >> + node should have "big-endian" property. >> + If controller implementation operates with big endian descriptors, >> + compatible should also have "ehci-be-desc" > > Ah, I understand what this is about, finally. > > Don't put this in "compatible"; instead, do a "big-endian-descriptors" > property similar to the "big-endian" property. That last one should > maybe be "big-endian-registers" here then, to avoid confusion. > > Or make "big-endian" mean both big-endian registers *and* big-endian > descriptors. But doesn't "big-endian" property actually mean "big-endian-registers"? Do we have to overload property meaning in this case? > > I have no opinion which is best; it depends on what configurations > actually exist, and how popular those are. > >> + ehci@e0000300 { >> + device_type = "usb"; >> + compatible = "ibm,ehci-440epx", "ehci-be-desc", "ehci"; >> + interrupts = <1a 4>; >> + interrupt-parent = <&UIC0>; >> + reg = <0 e0000300 ff>; > > Length should be 100 here. > >> + big-endian; >> + }; > > > Segher > Thanks, Valentine. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-19 13:52 ` Valentine Barshak @ 2007-09-19 16:50 ` Segher Boessenkool 2007-09-19 16:55 ` Valentine Barshak 2007-09-20 0:52 ` David Gibson 0 siblings, 2 replies; 23+ messages in thread From: Segher Boessenkool @ 2007-09-19 16:50 UTC (permalink / raw) To: Valentine Barshak; +Cc: linuxppc-dev, linux-usb-devel >>> + Required properties: >>> + - device_type : should be "usb". >> No device_type please. The published USB binding doesn't define >> one on purpose. > > Could you please, explain why? > Sorry, I don't think I get the concept of device description here. "device_type" is meant to be used only by OF for determining the OF programming model for a device. No such thing has been defined for USB busses, so the USB binding does not define a "device_type" either. Nothing in a flat device tree should ever define a device_type, except perhaps for compatibility with legacy kernel code. >>> + - compatible : should be "ehci". >> Just "ehci" isn't enough -- compare to OHCI, which is the name for >> a kind of USB host controller as well as for a kind of Firewire >> host controller. > > Actually, I though device type="usb" + compatible="ehci" would be > enough. "compatible" values are their own namespace, you should in principle be able to find a driver for a device with them without having to look at other properties. >> Maybe "usb-ehci" is best -- can anyone think of a better name? > > Again, why not type="usb", compatible="ehci"? Because an OF client (i.e., the Linux kernel) is not supposed to use "device_type" at all for its own driver matching. >>> + - interrupts : <a b> where a is the interrupt number and b is a >>> + field that represents an encoding of the sense and level >>> + information for the interrupt. >> This is incorrect; not all interrupt domains use two cells, and >> not all that do have this meaning for those cells. > > Well, this was just copied from other descriptions in > Documentation/powerpc/booting-without-of.txt > Do we need to fix them all? Sounds like it, yes. >>> + If device registers are implemented in big endian mode, the device >>> + node should have "big-endian" property. >>> + If controller implementation operates with big endian descriptors, >>> + compatible should also have "ehci-be-desc" >> Ah, I understand what this is about, finally. >> Don't put this in "compatible"; instead, do a "big-endian-descriptors" >> property similar to the "big-endian" property. That last one should >> maybe be "big-endian-registers" here then, to avoid confusion. >> Or make "big-endian" mean both big-endian registers *and* big-endian >> descriptors. > > But doesn't "big-endian" property actually mean "big-endian-registers"? > Do we have to overload property meaning in this case? It doesn't *have* a standard meaning, it is defined per device binding that uses it. Just make it mean whatever is most logical for this device. >> I have no opinion which is best; it depends on what configurations >> actually exist, and how popular those are. Segher ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-19 16:50 ` Segher Boessenkool @ 2007-09-19 16:55 ` Valentine Barshak 2007-09-24 19:32 ` [linux-usb-devel] " Valentine Barshak 2007-09-20 0:52 ` David Gibson 1 sibling, 1 reply; 23+ messages in thread From: Valentine Barshak @ 2007-09-19 16:55 UTC (permalink / raw) To: Segher Boessenkool; +Cc: linuxppc-dev, linux-usb-devel Segher Boessenkool wrote: >>>> + Required properties: >>>> + - device_type : should be "usb". >>> No device_type please. The published USB binding doesn't define >>> one on purpose. >> >> Could you please, explain why? >> Sorry, I don't think I get the concept of device description here. > > "device_type" is meant to be used only by OF for determining the OF > programming model for a device. No such thing has been defined for > USB busses, so the USB binding does not define a "device_type" either. > > Nothing in a flat device tree should ever define a device_type, except > perhaps for compatibility with legacy kernel code. > >>>> + - compatible : should be "ehci". >>> Just "ehci" isn't enough -- compare to OHCI, which is the name for >>> a kind of USB host controller as well as for a kind of Firewire >>> host controller. >> >> Actually, I though device type="usb" + compatible="ehci" would be enough. > > "compatible" values are their own namespace, you should in principle > be able to find a driver for a device with them without having to look > at other properties. > >>> Maybe "usb-ehci" is best -- can anyone think of a better name? >> >> Again, why not type="usb", compatible="ehci"? > > Because an OF client (i.e., the Linux kernel) is not supposed to use > "device_type" at all for its own driver matching. > >>>> + - interrupts : <a b> where a is the interrupt number and b is a >>>> + field that represents an encoding of the sense and level >>>> + information for the interrupt. >>> This is incorrect; not all interrupt domains use two cells, and >>> not all that do have this meaning for those cells. >> >> Well, this was just copied from other descriptions in >> Documentation/powerpc/booting-without-of.txt >> Do we need to fix them all? > > Sounds like it, yes. > >>>> + If device registers are implemented in big endian mode, the device >>>> + node should have "big-endian" property. >>>> + If controller implementation operates with big endian descriptors, >>>> + compatible should also have "ehci-be-desc" >>> Ah, I understand what this is about, finally. >>> Don't put this in "compatible"; instead, do a "big-endian-descriptors" >>> property similar to the "big-endian" property. That last one should >>> maybe be "big-endian-registers" here then, to avoid confusion. >>> Or make "big-endian" mean both big-endian registers *and* big-endian >>> descriptors. >> >> But doesn't "big-endian" property actually mean "big-endian-registers"? >> Do we have to overload property meaning in this case? > > It doesn't *have* a standard meaning, it is defined per device binding > that uses it. Just make it mean whatever is most logical for this > device. > >>> I have no opinion which is best; it depends on what configurations >>> actually exist, and how popular those are. > > > Segher > OK, thanks a lot for the explanations. I'll modify the code. I think may be usb-ohci compatible values should be made properties as well, so that both drivers follow the same rules. Thanks, Valentine. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [linux-usb-devel] [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-19 16:55 ` Valentine Barshak @ 2007-09-24 19:32 ` Valentine Barshak 0 siblings, 0 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-24 19:32 UTC (permalink / raw) To: Segher Boessenkool; +Cc: linuxppc-dev, linux-usb-devel, David Gibson Valentine Barshak wrote: > Segher Boessenkool wrote: >>>>> + Required properties: >>>>> + - device_type : should be "usb". >>>> No device_type please. The published USB binding doesn't define >>>> one on purpose. >>> Could you please, explain why? >>> Sorry, I don't think I get the concept of device description here. >> "device_type" is meant to be used only by OF for determining the OF >> programming model for a device. No such thing has been defined for >> USB busses, so the USB binding does not define a "device_type" either. >> >> Nothing in a flat device tree should ever define a device_type, except >> perhaps for compatibility with legacy kernel code. >> >>>>> + - compatible : should be "ehci". >>>> Just "ehci" isn't enough -- compare to OHCI, which is the name for >>>> a kind of USB host controller as well as for a kind of Firewire >>>> host controller. >>> Actually, I though device type="usb" + compatible="ehci" would be enough. >> "compatible" values are their own namespace, you should in principle >> be able to find a driver for a device with them without having to look >> at other properties. >> >>>> Maybe "usb-ehci" is best -- can anyone think of a better name? >>> Again, why not type="usb", compatible="ehci"? >> Because an OF client (i.e., the Linux kernel) is not supposed to use >> "device_type" at all for its own driver matching. >> >>>>> + - interrupts : <a b> where a is the interrupt number and b is a >>>>> + field that represents an encoding of the sense and level >>>>> + information for the interrupt. >>>> This is incorrect; not all interrupt domains use two cells, and >>>> not all that do have this meaning for those cells. >>> Well, this was just copied from other descriptions in >>> Documentation/powerpc/booting-without-of.txt >>> Do we need to fix them all? >> Sounds like it, yes. >> >>>>> + If device registers are implemented in big endian mode, the device >>>>> + node should have "big-endian" property. >>>>> + If controller implementation operates with big endian descriptors, >>>>> + compatible should also have "ehci-be-desc" >>>> Ah, I understand what this is about, finally. >>>> Don't put this in "compatible"; instead, do a "big-endian-descriptors" >>>> property similar to the "big-endian" property. That last one should >>>> maybe be "big-endian-registers" here then, to avoid confusion. >>>> Or make "big-endian" mean both big-endian registers *and* big-endian >>>> descriptors. >>> But doesn't "big-endian" property actually mean "big-endian-registers"? >>> Do we have to overload property meaning in this case? >> It doesn't *have* a standard meaning, it is defined per device binding >> that uses it. Just make it mean whatever is most logical for this >> device. >> >>>> I have no opinion which is best; it depends on what configurations >>>> actually exist, and how popular those are. >> >> Segher >> > > OK, thanks a lot for the explanations. > I'll modify the code. > I think may be usb-ohci compatible values should be made properties as well, > so that both drivers follow the same rules. > Thanks, > Valentine. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > linux-usb-devel@lists.sourceforge.net > To unsubscribe, use the last form field at: > https://lists.sourceforge.net/lists/listinfo/linux-usb-devel I've resubmitted the patches. (http://ozlabs.org/pipermail/linuxppc-dev/2007-September/thread.html) Please, take a look. Thanks, Valentine. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-19 16:50 ` Segher Boessenkool 2007-09-19 16:55 ` Valentine Barshak @ 2007-09-20 0:52 ` David Gibson 2007-09-24 21:40 ` Segher Boessenkool 1 sibling, 1 reply; 23+ messages in thread From: David Gibson @ 2007-09-20 0:52 UTC (permalink / raw) To: Segher Boessenkool; +Cc: linuxppc-dev, linux-usb-devel On Wed, Sep 19, 2007 at 06:50:02PM +0200, Segher Boessenkool wrote: > >>> + Required properties: > >>> + - device_type : should be "usb". > >> No device_type please. The published USB binding doesn't define > >> one on purpose. > > > > Could you please, explain why? > > Sorry, I don't think I get the concept of device description here. > > "device_type" is meant to be used only by OF for determining the OF > programming model for a device. No such thing has been defined for > USB busses, so the USB binding does not define a "device_type" either. > > Nothing in a flat device tree should ever define a device_type, except > perhaps for compatibility with legacy kernel code. This is not necessarily true. As Segher says, device_type originally indicated the OF programming model for a device. However, we've extended the notion for the flat device tree to allow device_type to cover "device classes" which could have certain common properties and semantics. However, in this case, a meaningful class binding must already be defined: it might make sense for usb to have a defined device_type, but it's not been defined so far, so for now you must omit device_type (if a device_type is defined in future, it's easier to add legacy hooks that will include devices which are missing the relevant device_type marker than to work around devices which *do* have the marker, but pre-date and don't follow the defined class binding). > >>> + - compatible : should be "ehci". > >> Just "ehci" isn't enough -- compare to OHCI, which is the name for > >> a kind of USB host controller as well as for a kind of Firewire > >> host controller. > > > > Actually, I though device type="usb" + compatible="ehci" would be > > enough. > > "compatible" values are their own namespace, you should in principle > be able to find a driver for a device with them without having to look > at other properties. Yes. Regardless of the state of any class / device_type binding, the compatible property *alone* should be sufficient to select a driver. -- 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 ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-20 0:52 ` David Gibson @ 2007-09-24 21:40 ` Segher Boessenkool 0 siblings, 0 replies; 23+ messages in thread From: Segher Boessenkool @ 2007-09-24 21:40 UTC (permalink / raw) To: David Gibson; +Cc: linuxppc-dev, linux-usb-devel >> Nothing in a flat device tree should ever define a device_type, except >> perhaps for compatibility with legacy kernel code. > > This is not necessarily true. As Segher says, device_type originally > indicated the OF programming model for a device. However, we've > extended the notion for the flat device tree to allow device_type to > cover "device classes" which could have certain common properties and > semantics. Such device classes are already handled by the "generic names" recommended practice. Reusing device_type for a different purpose is dangerous: before you know it, you'll end up with a conflict, as was nicely demonstrated today with device_type "rtc". > However, in this case, a meaningful class binding must > already be defined: it might make sense for usb to have a defined > device_type, but it's not been defined so far, so for now you must > omit device_type (if a device_type is defined in future, it's easier > to add legacy hooks that will include devices which are missing the > relevant device_type marker than to work around devices which *do* > have the marker, but pre-date and don't follow the defined class > binding). Nothing in the kernel should assume it can find all devices of a certain "class" any other way than by exhaustively matching on possible "compatible" values. I'm not sure why you would want to, anyway: you need "compatible" to select which driver to use, already. Segher ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-17 12:55 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Valentine Barshak 2007-09-17 13:00 ` [PATCH 2/3] usb: ehci-ppc-of dts bindings Valentine Barshak @ 2007-09-17 13:28 ` Stephen Rothwell 2007-09-17 14:00 ` Josh Boyer ` (2 more replies) 1 sibling, 3 replies; 23+ messages in thread From: Stephen Rothwell @ 2007-09-17 13:28 UTC (permalink / raw) To: Valentine Barshak; +Cc: linuxppc-dev, linux-usb-devel [-- Attachment #1: Type: text/plain, Size: 683 bytes --] On Mon, 17 Sep 2007 16:55:43 +0400 Valentine Barshak <vbarshak@ru.mvista.com> wrote: > > +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.000000000 +0400 > @@ -0,0 +1,220 @@ > + > +#include <asm/of_platform.h> > +#include <asm/prom.h> 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 sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-17 13:28 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Stephen Rothwell @ 2007-09-17 14:00 ` Josh Boyer 2007-09-17 18:17 ` Valentine Barshak 2007-09-17 18:18 ` Valentine Barshak 2 siblings, 0 replies; 23+ messages in thread From: Josh Boyer @ 2007-09-17 14:00 UTC (permalink / raw) To: Stephen Rothwell; +Cc: linuxppc-dev, linux-usb-devel On Mon, 17 Sep 2007 23:28:09 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote: > On Mon, 17 Sep 2007 16:55:43 +0400 Valentine Barshak <vbarshak@ru.mvista.com> wrote: > > > > +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.000000000 +0400 > > @@ -0,0 +1,220 @@ > > + > > +#include <asm/of_platform.h> > > +#include <asm/prom.h> > > 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 ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-17 13:28 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Stephen Rothwell 2007-09-17 14:00 ` Josh Boyer @ 2007-09-17 18:17 ` Valentine Barshak 2007-09-18 4:26 ` Stephen Rothwell 2007-09-17 18:18 ` Valentine Barshak 2 siblings, 1 reply; 23+ messages in thread From: Valentine Barshak @ 2007-09-17 18:17 UTC (permalink / raw) To: Stephen Rothwell; +Cc: linuxppc-dev, linux-usb-devel Stephen Rothwell wrote: > On Mon, 17 Sep 2007 16:55:43 +0400 Valentine Barshak <vbarshak@ru.mvista.com> wrote: >> +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.000000000 +0400 >> @@ -0,0 +1,220 @@ >> + >> +#include <asm/of_platform.h> >> +#include <asm/prom.h> > > 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. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-17 18:17 ` Valentine Barshak @ 2007-09-18 4:26 ` Stephen Rothwell 2007-09-18 5:39 ` David Gibson 0 siblings, 1 reply; 23+ messages in thread From: Stephen Rothwell @ 2007-09-18 4:26 UTC (permalink / raw) To: Valentine Barshak; +Cc: linuxppc-dev, linux-usb-devel [-- Attachment #1: Type: text/plain, Size: 417 bytes --] On Mon, 17 Sep 2007 22:17:15 +0400 Valentine Barshak <vbarshak@ru.mvista.com> 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 sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-18 4:26 ` Stephen Rothwell @ 2007-09-18 5:39 ` David Gibson 0 siblings, 0 replies; 23+ messages in thread From: David Gibson @ 2007-09-18 5:39 UTC (permalink / raw) To: Stephen Rothwell; +Cc: linuxppc-dev, linux-usb-devel [-- Attachment #1: Type: text/plain, Size: 713 bytes --] On Tue, Sep 18, 2007 at 02:26:06PM +1000, Stephen Rothwell wrote: > On Mon, 17 Sep 2007 22:17:15 +0400 Valentine Barshak <vbarshak@ru.mvista.com> 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 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/3] usb: add device-tree-aware ehci driver 2007-09-17 13:28 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Stephen Rothwell 2007-09-17 14:00 ` Josh Boyer 2007-09-17 18:17 ` Valentine Barshak @ 2007-09-17 18:18 ` Valentine Barshak 2 siblings, 0 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-17 18:18 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel This adds ehci-ppc-of driver. The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. Signed-off-by: Stefan Roese <sr@denx.de> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com> --- 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.000000000 +0400 +++ linux-2.6/drivers/usb/host/ehci.h 2007-09-15 15:12:04.000000000 +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.000000000 +0400 +++ linux-2.6/drivers/usb/host/ehci-hcd.c 2007-09-15 15:12:04.000000000 +0400 @@ -944,11 +944,16 @@ #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver #endif -#ifdef CONFIG_440EPX +#if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) #include "ehci-ppc-soc.c" #define PLATFORM_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.000000000 +0300 +++ linux-2.6/drivers/usb/host/ehci-ppc-of.c 2007-09-15 16:12:56.000000000 +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 <vbarshak@ru.mvista.com> + * + * Based on "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de> + * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com> + * + * This file is licenced under the GPL. + */ + +#include <linux/signal.h> + +#include <linux/of.h> +#include <linux/of_platform.h> + +/* 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; + + if (usb_disabled()) + return -ENODEV; + + dev_dbg(&op->dev, "initializing PPC-OF USB Controller\n"); + + rv = of_address_to_resource(dn, 0, &res); + if (rv) + return rv; + + hcd = usb_create_hcd(&ehci_ppc_of_hc_driver, &op->dev, "PPC-OF USB"); + if (!hcd) + return -ENOMEM; + + hcd->rsrc_start = res.start; + hcd->rsrc_len = res.end - res.start + 1; + + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { + printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); + rv = -EBUSY; + goto err_rmr; + } + + irq = irq_of_parse_and_map(dn, 0); + if (irq == NO_IRQ) { + printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); + rv = -EBUSY; + goto err_irq; + } + + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); + if (!hcd->regs) { + printk(KERN_ERR __FILE__ ": ioremap failed\n"); + rv = -ENOMEM; + goto err_ioremap; + } + + ehci = hcd_to_ehci(hcd); + if (of_device_is_compatible(dn, "ehci-be-desc")) + ehci->big_endian_desc = 1; + if (of_get_property(dn, "big-endian", NULL)) + ehci->big_endian_mmio = 1; + + ehci->caps = hcd->regs; + ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); + + /* cache this readonly data; minimize chip reads */ + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); + + if (of_device_is_compatible(dn, "ibm,ehci-440epx")) { + /* + * 440EPx Errata USBH_3 + * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 + */ + out_be32((void *)((ulong)(&ehci->regs->command) + 0x8c), (1 << 0)); + ehci_dbg(ehci, "Break Memory Transfer (BMT) has beed enabled!\n"); + } + + rv = usb_add_hcd(hcd, irq, 0); + if (rv == 0) + return 0; + + iounmap(hcd->regs); +err_ioremap: + irq_dispose_mapping(irq); +err_irq: + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); +err_rmr: + usb_put_hcd(hcd); + + return rv; +} + + +static int ehci_hcd_ppc_of_remove(struct of_device *op) +{ + struct usb_hcd *hcd = dev_get_drvdata(&op->dev); + dev_set_drvdata(&op->dev, NULL); + + dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); + + usb_remove_hcd(hcd); + + iounmap(hcd->regs); + irq_dispose_mapping(hcd->irq); + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + + usb_put_hcd(hcd); + + return 0; +} + + +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); + + return 0; +} + + +static struct of_device_id ehci_hcd_ppc_of_match[] = { + { + .type = "usb", + .compatible = "ehci", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, ehci_hcd_ppc_of_match); + + +static struct of_platform_driver ehci_hcd_ppc_of_driver = { + .name = "ppc-of-ehci", + .match_table = ehci_hcd_ppc_of_match, + .probe = ehci_hcd_ppc_of_probe, + .remove = ehci_hcd_ppc_of_remove, + .shutdown = ehci_hcd_ppc_of_shutdown, +#ifdef CONFIG_PM + /*.suspend = ehci_hcd_ppc_of_drv_suspend,*/ + /*.resume = ehci_hcd_ppc_of_drv_resume,*/ +#endif + .driver = { + .name = "ppc-of-ehci", + .owner = THIS_MODULE, + }, +}; + diff -ruN linux-2.6.orig/drivers/usb/host/Kconfig linux-2.6/drivers/usb/host/Kconfig --- linux-2.6.orig/drivers/usb/host/Kconfig 2007-09-15 14:28:42.000000000 +0400 +++ linux-2.6/drivers/usb/host/Kconfig 2007-09-15 15:12:04.000000000 +0400 @@ -84,6 +84,14 @@ ---help--- Variation of ARC USB block used in some Freescale chips. +config USB_EHCI_HCD_PPC_OF + bool "EHCI support for PPC USB controller on OF platform bus" + depends on USB_EHCI_HCD && PPC_OF + default y + ---help--- + Enables support for the USB controller PowerPC present on the + OpenFirmware platform bus. + config USB_ISP116X_HCD tristate "ISP116X HCD support" depends on USB ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 3/3] Add PowerPC 440EPx Sequoia ehci dts entry. 2007-09-17 12:50 [PATCH 0/3] usb: ehci ppc device-tree-aware driver Valentine Barshak 2007-09-17 12:55 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Valentine Barshak @ 2007-09-17 13:02 ` Valentine Barshak 2007-09-22 23:00 ` [PATCH 0/3] usb: ehci ppc device-tree-aware driver Hollis Blanchard 2 siblings, 0 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-17 13:02 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel The patch adds usb ehci entry to PowerPC440EPx Sequoia DTS. Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com> --- arch/powerpc/boot/dts/sequoia.dts | 9 +++++++++ 1 file changed, 9 insertions(+) diff -ruN linux-2.6.orig/arch/powerpc/boot/dts/sequoia.dts linux-2.6/arch/powerpc/boot/dts/sequoia.dts --- linux-2.6.orig/arch/powerpc/boot/dts/sequoia.dts 2007-09-15 14:28:06.000000000 +0400 +++ linux-2.6/arch/powerpc/boot/dts/sequoia.dts 2007-09-15 16:20:19.000000000 +0400 @@ -122,6 +122,15 @@ interrupt-map-mask = <ffffffff>; }; + USB0: ehci@e0000300 { + device_type = "usb"; + compatible = "ibm,ehci-440epx", "ehci-be-desc", "ehci"; + interrupt-parent = <&UIC0>; + interrupts = <1a 4>; + reg = <0 e0000300 ff>; + big-endian; + }; + POB0: opb { compatible = "ibm,opb-440epx", "ibm,opb"; #address-cells = <1>; ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/3] usb: ehci ppc device-tree-aware driver 2007-09-17 12:50 [PATCH 0/3] usb: ehci ppc device-tree-aware driver Valentine Barshak 2007-09-17 12:55 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Valentine Barshak 2007-09-17 13:02 ` [PATCH 3/3] Add PowerPC 440EPx Sequoia ehci dts entry Valentine Barshak @ 2007-09-22 23:00 ` Hollis Blanchard 2007-09-24 10:33 ` Valentine Barshak 2007-10-08 18:15 ` Jerone Young 2 siblings, 2 replies; 23+ messages in thread From: Hollis Blanchard @ 2007-09-22 23:00 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel On Mon, 17 Sep 2007 16:50:39 +0400, Valentine Barshak wrote: > Some PowerPC systems have a built-in EHCI controller. > This is a device tree aware version of the EHCI controller driver. > Currently it's been tested on the PowerPC 440EPx Sequoia board. > Other platforms can be added later. > The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. We're having a strange issue on our Sequoia where the network stops functioning when USB is active. Jerone can supply more detail... Have you seen anything like that? -- Hollis Blanchard IBM Linux Technology Center ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/3] usb: ehci ppc device-tree-aware driver 2007-09-22 23:00 ` [PATCH 0/3] usb: ehci ppc device-tree-aware driver Hollis Blanchard @ 2007-09-24 10:33 ` Valentine Barshak 2007-10-08 18:15 ` Jerone Young 1 sibling, 0 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-24 10:33 UTC (permalink / raw) To: Hollis Blanchard; +Cc: linuxppc-dev, linux-usb-devel Hollis Blanchard wrote: > On Mon, 17 Sep 2007 16:50:39 +0400, Valentine Barshak wrote: > >> Some PowerPC systems have a built-in EHCI controller. >> This is a device tree aware version of the EHCI controller driver. >> Currently it's been tested on the PowerPC 440EPx Sequoia board. >> Other platforms can be added later. >> The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. > > We're having a strange issue on our Sequoia where the network stops > functioning when USB is active. Jerone can supply more detail... OK. This possibly could be caused by the plb write pipelining errata. Please, take a look at: http://ozlabs.org/pipermail/linuxppc-dev/2007-September/042999.html > > Have you seen anything like that? No, I haven't. > Thanks, Valentine. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/3] usb: ehci ppc device-tree-aware driver 2007-09-22 23:00 ` [PATCH 0/3] usb: ehci ppc device-tree-aware driver Hollis Blanchard 2007-09-24 10:33 ` Valentine Barshak @ 2007-10-08 18:15 ` Jerone Young 2007-10-08 18:18 ` Valentine Barshak 1 sibling, 1 reply; 23+ messages in thread From: Jerone Young @ 2007-10-08 18:15 UTC (permalink / raw) To: Hollis Blanchard; +Cc: linuxppc-dev, linux-usb-devel So the issue here with the Sequoia board is that if you load a kernel or initrd from usb stick while under u-boot environment, when Linux boots it will see the network adapter & even set an ip for it. But no matter what it is unable to access any outside ip. The way we recreated this scenario was: - Have a USB stick with - partition 1 is fat partition with our kernel & initrd - partition 2 is ext3 with our root filesystem 1) Boot Sequoia board with USB stick plugged in. Go to u-boot prompt. 2) start usb using "usb start" 3) Load kernel off usb stick using "fatload" command in uboot * Optionally load initrd off of usb stick * Example: fatload usb 0:1 4000000 cuImage.sequoia 4) stop usb using "usb stop" 5) Then boot kernel using bootm Now from this point linux loads and will mount the filesystem on the usb stick. But if you want to use networking in anyway you have a problem. You can start the telnet daemon and access from the board using 127.0.0.1 address (loopback). Trying to access the telnet from an outside ip is unsuccessful. Also, if you have it setup so that the root filesystem is on a nfs root, the kernel is never able to get to the nfs root. Basically something is really borked. I'm a little late getting back to this email :-0 On Sat, 2007-09-22 at 23:00 +0000, Hollis Blanchard wrote: > On Mon, 17 Sep 2007 16:50:39 +0400, Valentine Barshak wrote: > > > Some PowerPC systems have a built-in EHCI controller. > > This is a device tree aware version of the EHCI controller driver. > > Currently it's been tested on the PowerPC 440EPx Sequoia board. > > Other platforms can be added later. > > The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. > > We're having a strange issue on our Sequoia where the network stops > functioning when USB is active. Jerone can supply more detail... > > Have you seen anything like that? > ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/3] usb: ehci ppc device-tree-aware driver 2007-10-08 18:15 ` Jerone Young @ 2007-10-08 18:18 ` Valentine Barshak 2007-10-08 18:22 ` Valentine Barshak 0 siblings, 1 reply; 23+ messages in thread From: Valentine Barshak @ 2007-10-08 18:18 UTC (permalink / raw) To: jyoung5; +Cc: linuxppc-dev, linux-usb-devel, Hollis Blanchard Jerone Young wrote: > So the issue here with the Sequoia board is that if you load a kernel or > initrd from usb stick while under u-boot environment, when Linux boots > it will see the network adapter & even set an ip for it. But no matter > what it is unable to access any outside ip. > > The way we recreated this scenario was: > > - Have a USB stick with > - partition 1 is fat partition with our kernel & initrd > - partition 2 is ext3 with our root filesystem > > 1) Boot Sequoia board with USB stick plugged in. Go to u-boot prompt. > 2) start usb using "usb start" > 3) Load kernel off usb stick using "fatload" command in uboot > * Optionally load initrd off of usb stick > * Example: > fatload usb 0:1 4000000 cuImage.sequoia > > 4) stop usb using "usb stop" > 5) Then boot kernel using bootm > > Now from this point linux loads and will mount the filesystem on the usb > stick. But if you want to use networking in anyway you have a problem. > You can start the telnet daemon and access from the board using > 127.0.0.1 address (loopback). Trying to access the telnet from an > outside ip is unsuccessful. > > Also, if you have it setup so that the root filesystem is on a nfs root, > the kernel is never able to get to the nfs root. Basically something is > really borked. > > I'm a little late getting back to this email :-0 > > On Sat, 2007-09-22 at 23:00 +0000, Hollis Blanchard wrote: >> On Mon, 17 Sep 2007 16:50:39 +0400, Valentine Barshak wrote: >> >>> Some PowerPC systems have a built-in EHCI controller. >>> This is a device tree aware version of the EHCI controller driver. >>> Currently it's been tested on the PowerPC 440EPx Sequoia board. >>> Other platforms can be added later. >>> The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. >> We're having a strange issue on our Sequoia where the network stops >> functioning when USB is active. Jerone can supply more detail... >> >> Have you seen anything like that? >> > Please try this patch: http://ozlabs.org/pipermail/linuxppc-dev/2007-October/043435.html Thanks, Valentine. > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/3] usb: ehci ppc device-tree-aware driver 2007-10-08 18:18 ` Valentine Barshak @ 2007-10-08 18:22 ` Valentine Barshak 0 siblings, 0 replies; 23+ messages in thread From: Valentine Barshak @ 2007-10-08 18:22 UTC (permalink / raw) To: jyoung5; +Cc: linuxppc-dev, linux-usb-devel, Hollis Blanchard Valentine Barshak wrote: > Jerone Young wrote: >> So the issue here with the Sequoia board is that if you load a kernel or >> initrd from usb stick while under u-boot environment, when Linux boots >> it will see the network adapter & even set an ip for it. But no matter >> what it is unable to access any outside ip. >> >> The way we recreated this scenario was: >> >> - Have a USB stick with >> - partition 1 is fat partition with our kernel & initrd >> - partition 2 is ext3 with our root filesystem >> >> 1) Boot Sequoia board with USB stick plugged in. Go to u-boot prompt. >> 2) start usb using "usb start" >> 3) Load kernel off usb stick using "fatload" command in uboot >> * Optionally load initrd off of usb stick >> * Example: >> fatload usb 0:1 4000000 cuImage.sequoia >> >> 4) stop usb using "usb stop" >> 5) Then boot kernel using bootm >> >> Now from this point linux loads and will mount the filesystem on the usb >> stick. But if you want to use networking in anyway you have a problem. >> You can start the telnet daemon and access from the board using >> 127.0.0.1 address (loopback). Trying to access the telnet from an >> outside ip is unsuccessful. >> >> Also, if you have it setup so that the root filesystem is on a nfs root, >> the kernel is never able to get to the nfs root. Basically something is >> really borked. >> >> I'm a little late getting back to this email :-0 >> >> On Sat, 2007-09-22 at 23:00 +0000, Hollis Blanchard wrote: >>> On Mon, 17 Sep 2007 16:50:39 +0400, Valentine Barshak wrote: >>> >>>> Some PowerPC systems have a built-in EHCI controller. >>>> This is a device tree aware version of the EHCI controller driver. >>>> Currently it's been tested on the PowerPC 440EPx Sequoia board. >>>> Other platforms can be added later. >>>> The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. >>> We're having a strange issue on our Sequoia where the network stops >>> functioning when USB is active. Jerone can supply more detail... >>> >>> Have you seen anything like that? >>> > Please try this patch: > http://ozlabs.org/pipermail/linuxppc-dev/2007-October/043435.html > Thanks, > Valentine. Also please, don't forget to uncomment this line: # select IBM_NEW_EMAC_RGMII It's commented out in the original patch since new EMAC support hasn't been merged yet. Thanks, Valentine. >> _______________________________________________ >> Linuxppc-dev mailing list >> Linuxppc-dev@ozlabs.org >> https://ozlabs.org/mailman/listinfo/linuxppc-dev > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 0/3] usb: ehci ppc device-tree-aware driver @ 2007-09-24 19:25 Valentine Barshak 2007-09-24 19:27 ` [PATCH 2/3] usb: ehci-ppc-of dts bindings Valentine Barshak 0 siblings, 1 reply; 23+ messages in thread From: Valentine Barshak @ 2007-09-24 19:25 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel Some PowerPC systems have a built-in EHCI controller. This is a device tree aware version of the EHCI controller driver. Currently it's been tested on the PowerPC 440EPx Sequoia board. Other platforms can be added later. The code is based on the ehci-ppc-soc driver by Stefan Roese <sr@denx.de>. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/3] usb: ehci-ppc-of dts bindings. 2007-09-24 19:25 Valentine Barshak @ 2007-09-24 19:27 ` Valentine Barshak 0 siblings, 0 replies; 23+ messages in thread From: Valentine Barshak @ 2007-09-24 19:27 UTC (permalink / raw) To: linuxppc-dev; +Cc: linux-usb-devel Adds EHCI OF bindings to documentation. Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com> --- Documentation/powerpc/booting-without-of.txt | 28 +++++++++++++++++++++++++++ 1 files changed, 28 insertions(+) diff -ruN linux-2.6.orig/Documentation/powerpc/booting-without-of.txt linux-2.6/Documentation/powerpc/booting-without-of.txt --- linux-2.6.orig/Documentation/powerpc/booting-without-of.txt 2007-09-24 14:55:04.000000000 +0400 +++ linux-2.6/Documentation/powerpc/booting-without-of.txt 2007-09-24 22:42:35.000000000 +0400 @@ -52,6 +52,7 @@ i) Freescale QUICC Engine module (QE) j) CFI or JEDEC memory-mapped NOR flash k) Global Utilities Block + l) USB EHCI controllers VII - Specifying interrupt information for devices 1) interrupts property @@ -1848,6 +1849,33 @@ fsl,has-rstcr; }; + l) USB EHCI controllers + + Required properties: + - compatible : should be "usb-ehci". + - reg : should contain at least address and length of the standard EHCI + register set for the device. Optional platform-dependent registers + (debug-port or other) can be also specified here, but only after + definition of standard EHCI registers. + - interrupts : one EHCI interrupt should be described here. + If device registers are implemented in big endian mode, the device + node should have "big-endian-regs" property. + If controller implementation operates with big endian descriptors, + "big-endian-desc" property should be specified. + If both big endian registers and descriptors are used by the controller + implementation, "big-endian" property can be specified instead of having + both "big-endian-regs" and "big-endian-desc". + + Example (Sequoia 440EPx): + ehci@e0000300 { + compatible = "ibm,usb-ehci-440epx", "usb-ehci"; + interrupt-parent = <&UIC0>; + interrupts = <1a 4>; + reg = <0 e0000300 90 0 e0000390 70>; + big-endian; + }; + + More devices will be defined as this spec matures. VII - Specifying interrupt information for devices ^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2007-10-08 18:23 UTC | newest] Thread overview: 23+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-09-17 12:50 [PATCH 0/3] usb: ehci ppc device-tree-aware driver Valentine Barshak 2007-09-17 12:55 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Valentine Barshak 2007-09-17 13:00 ` [PATCH 2/3] usb: ehci-ppc-of dts bindings Valentine Barshak 2007-09-19 0:25 ` Segher Boessenkool 2007-09-19 13:52 ` Valentine Barshak 2007-09-19 16:50 ` Segher Boessenkool 2007-09-19 16:55 ` Valentine Barshak 2007-09-24 19:32 ` [linux-usb-devel] " Valentine Barshak 2007-09-20 0:52 ` David Gibson 2007-09-24 21:40 ` Segher Boessenkool 2007-09-17 13:28 ` [PATCH 1/3] usb: add device-tree-aware ehci driver Stephen Rothwell 2007-09-17 14:00 ` Josh Boyer 2007-09-17 18:17 ` Valentine Barshak 2007-09-18 4:26 ` Stephen Rothwell 2007-09-18 5:39 ` David Gibson 2007-09-17 18:18 ` Valentine Barshak 2007-09-17 13:02 ` [PATCH 3/3] Add PowerPC 440EPx Sequoia ehci dts entry Valentine Barshak 2007-09-22 23:00 ` [PATCH 0/3] usb: ehci ppc device-tree-aware driver Hollis Blanchard 2007-09-24 10:33 ` Valentine Barshak 2007-10-08 18:15 ` Jerone Young 2007-10-08 18:18 ` Valentine Barshak 2007-10-08 18:22 ` Valentine Barshak -- strict thread matches above, loose matches on Subject: below -- 2007-09-24 19:25 Valentine Barshak 2007-09-24 19:27 ` [PATCH 2/3] usb: ehci-ppc-of dts bindings Valentine Barshak
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).