Here is another cut at an ssb ehci driver. Hope this is closer.
Steve
diff --git a/target/linux/brcm47xx/config-2.6.25 b/target/linux/brcm47xx/config-2.6.25 index 6ddcd22..720d961 100644 --- a/target/linux/brcm47xx/config-2.6.25 +++ b/target/linux/brcm47xx/config-2.6.25 @@ -257,10 +257,13 @@ CONFIG_TICK_ONESHOT=y CONFIG_TRAD_SIGNALS=y CONFIG_USB=m # CONFIG_USB_ACM is not set +CONFIG_EXPERIMENTAL=y CONFIG_USB_EHCI_HCD=m +CONFIG_USB_EHCI_HCD_SSB=y # CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set # CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set CONFIG_USB_OHCI_HCD=m +CONFIG_USB_OHCI_HCD_SSB=y # CONFIG_USB_R8A66597_HCD is not set # CONFIG_USB_UHCI_HCD is not set # CONFIG_VGASTATE is not set diff --git a/target/linux/brcm47xx/patches-2.6.25/270-ehci-ssb.patch b/target/linux/brcm47xx/patches-2.6.25/270-ehci-ssb.patch new file mode 100644 index 0000000..fabfb18 --- /dev/null +++ b/target/linux/brcm47xx/patches-2.6.25/270-ehci-ssb.patch @@ -0,0 +1,495 @@ +diff -ur ../openwrt-25/build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/ehci-hcd.c build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/ehci-hcd.c +--- linux-2.6.25.4/drivers/usb/host/ehci-hcd.c 2008-05-15 08:00:12.000000000 -0700 ++++ linux-2.6.25.4/drivers/usb/host/ehci-hcd.c 2008-06-04 09:09:02.000000000 -0700 +@@ -1043,8 +1043,15 @@ + #define PLATFORM_DRIVER ixp4xx_ehci_driver + #endif + +-#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ +- !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) ++#ifdef CONFIG_USB_EHCI_HCD_SSB ++#include "ehci-ssb.c" ++#define SSB_EHCI_DRIVER ssb_ehci_driver ++#endif ++ ++#if !defined(PCI_DRIVER) && \ ++ !defined(PLATFORM_DRIVER) && \ ++ !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ ++ !defined(SSB_EHCI_DRIVER) + #error "missing bus glue for ehci-hcd" + #endif + +@@ -1086,8 +1093,19 @@ + if (retval < 0) + goto clean3; + #endif ++ ++#ifdef SSB_EHCI_DRIVER ++ retval = ssb_driver_register(&SSB_EHCI_DRIVER); ++ if (retval < 0) ++ goto clean4; ++#endif ++ + return retval; + ++#ifdef SSB_EHCI_DRIVER ++clean4: ++ ssb_driver_unregister(&SSB_EHCI_DRIVER); ++#endif + #ifdef OF_PLATFORM_DRIVER + /* of_unregister_platform_driver(&OF_PLATFORM_DRIVER); */ + clean3: +@@ -1129,6 +1147,9 @@ + #ifdef DEBUG + debugfs_remove(ehci_debug_root); + #endif ++#ifdef SSB_EHCI_DRIVER ++ ssb_driver_unregister(&SSB_EHCI_DRIVER); ++#endif + } + module_exit(ehci_hcd_cleanup); + +diff -ur ../openwrt-25/build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/ehci-ssb.c build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/ehci-ssb.c +--- /dev/null 2008-06-04 13:14:59.000000000 -0700 ++++ linux-2.6.25.4/drivers/usb/host/ehci-ssb.c 2008-06-04 12:37:26.000000000 -0700 +@@ -0,0 +1,344 @@ ++/* ++ * Sonics Silicon Backplane ++ * Broadcom USB-core EHCI driver (SSB bus glue) ++ * ++ * Copyright 2007 Steven Brown <[EMAIL PROTECTED]> ++ * ++ * Derived from the OHCI-SSB driver ++ * Copyright 2007 Michael Buesch <[EMAIL PROTECTED]> ++ * ++ * Derived from the EHCI-PCI driver ++ * Copyright (c) 2000-2004 by David Brownell ++ * ++ * Derived from the OHCI-PCI driver ++ * Copyright 1999 Roman Weissgaerber ++ * Copyright 2000-2002 David Brownell ++ * Copyright 1999 Linus Torvalds ++ * Copyright 1999 Gregory P. Smith ++ * ++ * Derived from the USBcore related parts of Broadcom-SB ++ * Copyright 2005 Broadcom Corporation ++ * ++ * Licensed under the GNU/GPL. See COPYING for details. ++ */ ++#include <linux/ssb/ssb.h> ++ ++extern int ssb_ohci_attach(struct ssb_device *dev); ++extern void ssb_ohci_detach(struct ssb_device *dev); ++ ++#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29) ++ ++struct ssb_ehci_device { ++ struct ehci_hcd ehci; /* _must_ be at the beginning. */ ++ ++ u32 enable_flags; ++}; ++ ++static inline ++struct ssb_ehci_device *hcd_to_ssb_ehci(struct usb_hcd *hcd) ++{ ++ return (struct ssb_ehci_device *)(hcd->hcd_priv); ++} ++ ++ ++static int ssb_ehci_reset(struct usb_hcd *hcd) ++{ ++ struct ehci_hcd *ehci = hcd_to_ehci(hcd); ++ int err; ++ ++ ehci->caps = hcd->regs; ++ ehci->regs = hcd->regs + ++ HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); ++ ++ dbg_hcs_params(ehci, "reset"); ++ dbg_hcc_params(ehci, "reset"); ++ ++ ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); ++ ++ err = ehci_halt(ehci); ++ ++ if (err) ++ return err; ++ ++ err = ehci_init(hcd); ++ ++ if (err) ++ return err; ++ ++ ehci_port_power(ehci, 0); ++ ++ return err; ++} ++ ++static int ssb_ehci_start(struct usb_hcd *hcd) ++{ ++ struct ehci_hcd *ehci = hcd_to_ehci(hcd); ++ int err; ++ ++ err = ehci_run(hcd); ++ if (err < 0) { ++ ehci_err(ehci, "can't start\n"); ++ ehci_stop(hcd); ++ } ++ ++ return err; ++} ++ ++#ifdef CONFIG_PM ++static int ssb_ehci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) ++{ ++ struct ssb_ehci_device *ehcidev = hcd_to_ssb_ehci(hcd); ++ struct ehci_hcd *ehci = &ehcidev->ehci; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&ehci->lock, flags); ++ ++ ehci_writel(ehci, EHCI_INTR_MIE, &ehci->regs->intrdisable); ++ ehci_readl(ehci, &ehci->regs->intrdisable); /* commit write */ ++ ++ /* make sure snapshot being resumed re-enumerates everything */ ++ if (message.event == PM_EVENT_PRETHAW) ++ ehci_usb_reset(ehci); ++ ++ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); ++ ++ spin_unlock_irqrestore(&ehci->lock, flags); ++ return 0; ++} ++ ++static int ssb_ehci_hcd_resume(struct usb_hcd *hcd) ++{ ++ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); ++ usb_hcd_resume_root_hub(hcd); ++ return 0; ++} ++#endif /* CONFIG_PM */ ++ ++static const struct hc_driver ssb_ehci_hc_driver = { ++ .description = "ssb-usb-ehci", ++ .product_desc = "SSB EHCI Controller", ++ .hcd_priv_size = sizeof(struct ssb_ehci_device), ++ ++ .irq = ehci_irq, ++ .flags = HCD_MEMORY | HCD_USB2, ++ ++ .reset = ssb_ehci_reset, ++ .start = ssb_ehci_start, ++ .stop = ehci_stop, ++ .shutdown = ehci_shutdown, ++ ++#ifdef CONFIG_PM ++ .suspend = ssb_ehci_hcd_suspend, ++ .resume = ssb_ehci_hcd_resume, ++#endif ++ ++ .urb_enqueue = ehci_urb_enqueue, ++ .urb_dequeue = ehci_urb_dequeue, ++ .endpoint_disable = ehci_endpoint_disable, ++ ++ .get_frame_number = ehci_get_frame, ++ ++ .hub_status_data = ehci_hub_status_data, ++ .hub_control = ehci_hub_control, ++// .hub_irq_enable = ehci_rhsc_enable, ++#ifdef CONFIG_PM ++ .bus_suspend = ehci_bus_suspend, ++ .bus_resume = ehci_bus_resume, ++#endif ++ ++// .start_port_reset = ehci_start_port_reset, ++}; ++ ++static void ssb_ehci_detach(struct ssb_device *dev) ++{ ++ struct usb_hcd *hcd = ssb_get_drvdata(dev); ++ ++ usb_remove_hcd(hcd); ++ iounmap(hcd->regs); ++ usb_put_hcd(hcd); ++ ++/* ++ * Also detach the companion ohci device ++ */ ++ ssb_ohci_detach(dev->companion); ++// ssb_device_disable(dev, 0); ++} ++ ++static int ssb_ehci_attach(struct ssb_device *dev) ++{ ++ struct ssb_ehci_device *ehcidev; ++ struct usb_hcd *hcd; ++ int err = -ENOMEM; ++ u32 tmp, flags = 0; ++ ++ /* ++ * THE FOLLOWING COMMENTS PRESERVED FROM GPL SOURCE RELEASE ++ * ++ * The USB core requires a special bit to be set during core ++ * reset to enable host (OHCI) mode. Resetting the SB core in ++ * pcibios_enable_device() is a hack for compatibility with ++ * vanilla usb-ohci so that it does not have to know about ++ * SB. A driver that wants to use the USB core in device mode ++ * should know about SB and should reset the bit back to 0 ++ * after calling pcibios_enable_device(). ++ */ ++ ++ /* ++ * USB 2.0 special considerations: ++ * ++ * 1. Since the core supports both OHCI and EHCI functions, it must ++ * only be reset once. ++ * ++ * 2. In addition to the standard SB reset sequence, the Host Control ++ * Register must be programmed to bring the USB core and various ++ * phy components out of reset. ++ */ ++ ++ if (ssb_device_is_enabled(dev)) ++ goto core_already_enabled; ++ ++ ssb_device_enable(dev, 0); ++ ssb_write32(dev, 0x200, 0x7ff); ++ udelay(1); ++ if (dev->id.revision == 1) { // bug in rev 1 ++ ++ /* Change Flush control reg */ ++ tmp = ssb_read32(dev, 0x400); ++ tmp &= ~8; ++ ssb_write32(dev, 0x400, tmp); ++ tmp = ssb_read32(dev, 0x400); ++ printk("USB20H fcr: 0x%0x\n", tmp); ++ ++ /* Change Shim control reg */ ++ tmp = ssb_read32(dev, 0x304); ++ tmp &= ~0x100; ++ ssb_write32(dev, 0x304, tmp); ++ tmp = ssb_read32(dev, 0x304); ++ printk("USB20H shim: 0x%0x\n", tmp); ++ } ++ ++core_already_enabled: ++ /* ++ * Try to understand the dma mask stuff ++ */ ++ tmp = ssb_read32(dev, SSB_TMSHIGH); ++ err = ssb_dma_set_mask(dev, DMA_32BIT_MASK); ++ if (err) ++ return -EOPNOTSUPP; ++ ++ hcd = usb_create_hcd(&ssb_ehci_hc_driver, dev->dev, ++ dev->dev->bus_id); ++ if (!hcd) ++ goto err_dev_disable; ++ ehcidev = hcd_to_ssb_ehci(hcd); ++ ehcidev->enable_flags = flags; ++ ++ tmp = ssb_read32(dev, SSB_ADMATCH0); ++ hcd->rsrc_start = ssb_admatch_base(tmp) + 0x800; // offset for ehci core ++ hcd->rsrc_len = 0x100 /*ssb_admatch_size(tmp)*/; // size of ehci reg block ++ /* ++ * start & size modified per sbutils.c ++ */ ++ hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); ++ if (!hcd->regs) ++ goto err_put_hcd; ++ err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED | IRQF_DISABLED); ++ if (err) ++ goto err_iounmap; ++ ++ ssb_set_drvdata(dev, hcd); ++ ++ /* ++ * attach ohci (companion) device in this core ++ * ++ * add new device as a copy of the ehci device ++ * change coreid to SSB_DEV_USB11_HOSTDEV ++ * call ohci_ssb_attach(dev) to attach ohci device in this core ++ */ ++ ++ dev->companion = &dev->bus->devices[dev->bus->nr_devices]; ++ dev->bus->nr_devices++; ++ if (dev->bus->nr_devices > ARRAY_SIZE(dev->bus->devices)) { ++ printk(KERN_ERR ++ "More than %d devs, could not create ohci dev (%d)\n", ++ SSB_MAX_NR_CORES, dev->bus->nr_devices); ++ return err; ++ } ++ memcpy(dev->companion, dev, sizeof(struct ssb_device)); ++ dev->companion->id.coreid = SSB_DEV_USB11_HOSTDEV; ++ err = ssb_ohci_attach(dev->companion); ++ return err; ++ ++err_iounmap: ++ iounmap(hcd->regs); ++err_put_hcd: ++ usb_put_hcd(hcd); ++err_dev_disable: ++ ssb_device_disable(dev, flags); ++ return err; ++} ++ ++static int ssb_ehci_probe(struct ssb_device *dev, ++ const struct ssb_device_id *id) ++{ ++ int err; ++ u16 chipid_top; ++ ++ /* USBcores are only connected on embedded devices. */ ++ chipid_top = (dev->bus->chip_id & 0xFF00); ++ if (chipid_top != 0x4700 && chipid_top != 0x5300) ++ return -ENODEV; ++ ++ /* TODO: Probably need checks here; is the core connected? */ ++ ++ if (usb_disabled()) ++ return -ENODEV; ++ ++ err = ssb_ehci_attach(dev); ++ ++ return err; ++} ++ ++static void ssb_ehci_remove(struct ssb_device *dev) ++{ ++ ssb_ehci_detach(dev); ++} ++ ++#ifdef CONFIG_PM ++ ++static int ssb_ehci_suspend(struct ssb_device *dev, pm_message_t state) ++{ ++ ssb_device_disable(dev, 0); ++ ++ return 0; ++} ++ ++static int ssb_ehci_resume(struct ssb_device *dev) ++{ ++ struct usb_hcd *hcd = ssb_get_drvdata(dev); ++ struct ssb_ehci_device *ehcidev = hcd_to_ssb_ehci(hcd); ++ ++ ssb_device_enable(dev, ehcidev->enable_flags); ++ ++ return 0; ++} ++ ++#else /* !CONFIG_PM */ ++#define ssb_ehci_suspend NULL ++#define ssb_ehci_resume NULL ++#endif /* CONFIG_PM */ ++ ++static const struct ssb_device_id ssb_ehci_table[] = { ++ SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), ++ SSB_DEVTABLE_END ++}; ++MODULE_DEVICE_TABLE(ssb, ssb_ehci_table); ++ ++static struct ssb_driver ssb_ehci_driver = { ++ .name = KBUILD_MODNAME, ++ .id_table = ssb_ehci_table, ++ .probe = ssb_ehci_probe, ++ .remove = ssb_ehci_remove, ++ .suspend = ssb_ehci_suspend, ++ .resume = ssb_ehci_resume, ++}; +diff -ur ../openwrt-25/build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/Kconfig build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/Kconfig +--- linux-2.6.25.4/drivers/usb/host/Kconfig 2008-05-15 08:00:12.000000000 -0700 ++++ linux-2.6.25.4/drivers/usb/host/Kconfig 2008-06-04 09:09:02.000000000 -0700 +@@ -83,6 +83,19 @@ + Enables support for the USB controller present on the PowerPC + OpenFirmware platform bus. + ++config USB_EHCI_HCD_SSB ++ bool "EHCI support for Broadcom SSB EHCI core" ++ depends on USB_EHCI_HCD && SSB && EXPERIMENTAL ++ default n ++ ---help--- ++ Support for the Sonics Silicon Backplane (SSB) attached ++ Broadcom USB EHCI core. ++ ++ This device is present in some embedded devices with ++ Broadcom based SSB bus. ++ ++ If unsure, say N. ++ + config USB_ISP116X_HCD + tristate "ISP116X HCD support" + depends on USB +diff -ur ../openwrt-25/build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/ohci-ssb.c build_dir/linux-brcm47xx/linux-2.6.25.4/drivers/usb/host/ohci-ssb.c +--- linux-2.6.25.4/drivers/usb/host/ohci-ssb.c 2008-06-04 12:52:54.000000000 -0700 ++++ linux-2.6.25.4/drivers/usb/host/ohci-ssb.c 2008-06-04 13:00:05.000000000 -0700 +@@ -132,16 +132,19 @@ + usb_remove_hcd(hcd); + iounmap(hcd->regs); + usb_put_hcd(hcd); +- ssb_device_disable(dev, 0); + } + +-static int ssb_ohci_attach(struct ssb_device *dev) ++EXPORT_SYMBOL_GPL(ssb_ohci_detach); ++ ++int ssb_ohci_attach(struct ssb_device *dev) + { + struct ssb_ohci_device *ohcidev; + struct usb_hcd *hcd; + int err = -ENOMEM; + u32 tmp, flags = 0; + ++ if (!(ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_RESET)) ++ goto core_already_enabled; + /* + * THE FOLLOWING COMMENTS PRESERVED FROM GPL SOURCE RELEASE + * +@@ -170,8 +173,9 @@ + * phy components out of reset. + */ + +- else if (dev->id.coreid == SSB_DEV_USB20_HOST) { +-#warning FIX ME need test for core being up & exit ++ else if (dev->id.coreid == SSB_DEV_USB11_HOST) { ++ if (ssb_device_is_enabled(dev)) ++ goto core_already_enabled; + ssb_device_enable(dev, 0); + ssb_write32(dev, 0x200, 0x7ff); + udelay(1); +@@ -195,6 +199,7 @@ + else + ssb_device_enable(dev, 0); + ++core_already_enabled: + /* + * Set dma mask - 32 bit mask is just an assumption + */ +@@ -231,6 +236,8 @@ + return err; + } + ++EXPORT_SYMBOL_GPL(ssb_ohci_attach); ++ + static int ssb_ohci_probe(struct ssb_device *dev, + const struct ssb_device_id *id) + { +@@ -290,7 +297,6 @@ + static const struct ssb_device_id ssb_ohci_table[] = { + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), +- SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), + SSB_DEVTABLE_END + }; + MODULE_DEVICE_TABLE(ssb, ssb_ohci_table); +diff -ur ../openwrt-25/build_dir/linux-brcm47xx/linux-2.6.25.4/include/linux/ssb/ssb.h build_dir/linux-brcm47xx/linux-2.6.25.4/include/linux/ssb/ssb.h +--- linux-2.6.25.4/include/linux/ssb/ssb.h 2008-06-04 12:52:54.000000000 -0700 ++++ linux-2.6.25.4/include/linux/ssb/ssb.h 2008-06-04 11:44:59.000000000 -0700 +@@ -144,6 +144,7 @@ + /* Internal-only stuff follows. */ + void *drvdata; /* Per-device data */ + void *devtypedata; /* Per-devicetype (eg 802.11) data */ ++ struct ssb_device *companion; /* ohci companion device, used by ssb_ehci driver */ + }; + + /* Go from struct device to struct ssb_device. */
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel