Hi. I also have a few USB devices.
Flash disks:
Bus 001 Device 043: ID 0781:5150 SanDisk Corp.
Bus 001 Device 044: ID 05dc:0080 Lexar Media, Inc.
(wireless optical) Mouse:
Bus 001 Device 045: ID 045e:006a Microsoft Corp.
802.11b/g adapter:
Bus 001 Device 046: ID 0707:ee06 Standard Microsystems Corp
USB 1.1 hub:
Bus 001 Device 041: ID 0451:2077 Texas Instruments TUSB2077 Hub
ellisys USB tracker:
Bus 001 Device 042: ID 0aba:8001
(which is very useful in snooping actual USB bus traffic)
I don't have any isochronous devices, though.
Attached is my patch. Comments are welcome!
Mike
diff -urN 2681_prepatch/linux/arch/arm/Makefile
2681_patch_creation/linux/arch/arm/Makefile
--- 2681_prepatch/linux/arch/arm/Makefile 2004-11-12 17:25:56.000000000
-0600
+++ 2681_patch_creation/linux/arch/arm/Makefile 2004-11-12 14:45:36.000000000
-0600
@@ -55,8 +55,8 @@
tune-$(CONFIG_CPU_V6) :=-mtune=strongarm
# Need -Uarm for gcc < 3.x
-CFLAGS +=-mapcs-32 $(arch-y) $(tune-y) $(call
check_gcc,-malignment-traps,-mshort-load-bytes) -msoft-float -Wa,-mno-fpu -Uarm
-AFLAGS +=-mapcs-32 $(arch-y) $(tune-y) -msoft-float -Wa,-mno-fpu
+CFLAGS +=-mapcs-32 $(arch-y) $(tune-y) $(call
check_gcc,-malignment-traps,-mshort-load-bytes) -msoft-float -Uarm
+AFLAGS +=-mapcs-32 $(arch-y) $(tune-y) -msoft-float
CHECK := $(CHECK) -D__arm__=1
diff -urN 2681_prepatch/linux/arch/arm/mach-lh7a40x/arch-oscar.c
2681_patch_creation/linux/arch/arm/mach-lh7a40x/arch-oscar.c
--- 2681_prepatch/linux/arch/arm/mach-lh7a40x/arch-oscar.c 2004-11-12
17:42:08.000000000 -0600
+++ 2681_patch_creation/linux/arch/arm/mach-lh7a40x/arch-oscar.c
2004-11-12 14:51:06.000000000 -0600
@@ -4,10 +4,12 @@
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
- */
+ * 2004-10-07, MWM - Added platform_device definitions for USB driver
+*/
#include <linux/tty.h>
#include <linux/init.h>
#include <linux/device.h>
+#include <linux/usb.h>
#include <asm/hardware.h>
#include <asm/setup.h>
@@ -17,17 +19,68 @@
#include <asm/mach/irq.h>
#include <asm/mach/map.h>
+/* These functions call the board specific IRQ initialization functions. */
extern void lh7a400_init_irq(void);
+extern void lh7a40x_init_time(void);
+// static physical to virtual memory mapping
static struct map_desc oscar_io_desc[] __initdata = {
- { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE },
+ { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE },
+ { OSCAR_USB_VIRT, OSCAR_USB_PHYS, OSCAR_USB_SIZE, MT_DEVICE },
+ { BUSDELAY_VIRT, BUSDELAY_PHYS, BUSDELAY_SIZE, MT_DEVICE }, // for
explicit bus delays (e.g. USB driver)
};
+
void __init oscar_map_io(void)
{
iotable_init( oscar_io_desc, ARRAY_SIZE( oscar_io_desc ) );
}
+// Resource / platform_device for USB...
+static struct resource ohci_isp1362_resources[] = {
+ { // address register
+ .start = OSCAR_USB_PHYS + 0x02, // address register
+ .end = OSCAR_USB_PHYS + 0x02, // data register + 0x02
+ .flags = IORESOURCE_MEM,
+ },
+ { // IRQ for host controller
+ .start = IRQ_USB1,
+ .end = IRQ_USB1,
+ .flags = IORESOURCE_IRQ,
+ },
+ /* non-existant: (but for example)
+ { // DMA
+ .name= "dma",
+ .start= -1,
+ .end= -1,
+ .flags= IORESOURCE_DMA,
+ },
+ */
+};
+
+static struct ohci_chip_info ohci_isp1362_data = {
+ .hw_reset = NULL,
+ .clock_enable = NULL,
+ .clock_disable = NULL,
+};
+
+static u64 usb_dma_mask = 0xffffffff;
+
+static struct platform_device ohci_isp1362_device = {
+ .name = "isp1362-ohci",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(ohci_isp1362_resources),
+ .resource = ohci_isp1362_resources,
+ .dev = {
+ .platform_data = &ohci_isp1362_data,
+ .dma_mask = &usb_dma_mask,
+ .coherent_dma_mask = 0xffffffff,
+ }
+};
+
+static struct platform_device *oscar_platform_devices[] __initdata = {
+ &ohci_isp1362_device,
+ };
void __init lh7a40x_init_board_irq(void)
{
@@ -39,15 +92,40 @@
GPIO_INTTYPE1 &= 0xC1; // INT1-5 are level sensitive
GPIO_INTTYPE2 &= 0xC1; // INT1-5 are active low
barrier();
+ /* * - unconfigured
+ - *PF0 - tied to PF1 (redundant)
+ - PF1 - INT_L (goes to MSP)
+ - PF2 - CAN_IRQ_L
+ - PF3 - RXD3
+ - PF4 - USB_IRQ2
+ - PF5 - USB_IRQ1
+ - *PF6 - tied high
+ - *PF7 - LCD_VCC_EN_L (used as GPIO)
+ - */
GPIO_GPIOFINTEN |= 0x3E; // Enable the GPIO interrupts
}
+static void __init oscar_init (void)
+{
+ /* I'm not sure how to share this data with the entire kernel,
+ so this is done every time it's used.
+
+ // Detect the board revision
+ int board_rev = 7 - ((GPIO_PA_PIND & 0x70) >> 4);
+ */
+
+ // Add our platform devices defined above
+ (void) platform_add_devices( oscar_platform_devices,
ARRAY_SIZE(oscar_platform_devices) );
+}
+
MACHINE_START (OSCAR, "Vansco's 'Oscar'")
- MAINTAINER ("Michael Moedt, Vansco Electronics ([EMAIL PROTECTED])")
- BOOT_MEM (0xc0000000, IO_PHYS, IO_VIRT)
- BOOT_PARAMS (0xc0000100)
- MAPIO (oscar_map_io)
- INITIRQ (lh7a400_init_irq)
+ MAINTAINER ("Michael Moedt, Vansco Electronics ([EMAIL PROTECTED])")
+ BOOT_MEM (0xc0000000, IO_PHYS, IO_VIRT)
+ BOOT_PARAMS (0xc0000100)
+ MAPIO (oscar_map_io)
+ INITIRQ (lh7a400_init_irq)
+ INITTIME (lh7a40x_init_time)
+ INIT_MACHINE(oscar_init)
MACHINE_END
diff -urN 2681_prepatch/linux/drivers/usb/Kconfig
2681_patch_creation/linux/drivers/usb/Kconfig
--- 2681_prepatch/linux/drivers/usb/Kconfig 2004-11-12 17:26:21.000000000
-0600
+++ 2681_patch_creation/linux/drivers/usb/Kconfig 2004-11-12
14:51:48.000000000 -0600
@@ -7,7 +7,6 @@
# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
config USB
tristate "Support for Host-side USB"
- depends on PCI || SA1111 || ARCH_OMAP1510 || ARCH_OMAP1610 ||
ARCH_LH7A404
---help---
Universal Serial Bus (USB) is a specification for a serial bus
subsystem which offers higher speeds and more features than the
@@ -40,6 +39,11 @@
To compile this driver as a module, choose M here: the
module will be called usbcore.
+config USB_PXA
+ tristate
+ default y
+ depends on USB
+
source "drivers/usb/core/Kconfig"
source "drivers/usb/host/Kconfig"
diff -urN 2681_prepatch/linux/drivers/usb/core/hub.c
2681_patch_creation/linux/drivers/usb/core/hub.c
--- 2681_prepatch/linux/drivers/usb/core/hub.c 2004-11-12 17:26:21.000000000
-0600
+++ 2681_patch_creation/linux/drivers/usb/core/hub.c 2004-11-12
14:53:32.000000000 -0600
@@ -1445,7 +1445,10 @@
*/
for (i = 0; i < GET_DESCRIPTOR_TRIES; ++i) {
for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
- retval = hub_set_address(udev);
+
+ printk("ENUM 1: Set address. ---\n");
+
+ retval = hub_set_address(udev);
if (retval >= 0)
break;
msleep(200);
@@ -1456,7 +1459,9 @@
udev->devnum, retval);
goto fail;
}
-
+
+ printk("ENUM 2: Get dev. descriptor. (8)---\n");
+
/* cope with hardware quirkiness:
* - let SET_ADDRESS settle, some device hardware wants it
* - read ep0 maxpacket even for high and low speed,
@@ -1485,7 +1490,9 @@
udev->epmaxpacketout[0] = udev->descriptor.bMaxPacketSize0;
}
- retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
+ printk("ENUM 3: Get dev. descriptor (USB_DT_DEVICE_SIZE). ---\n");
+
+ retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
if (retval < (signed)sizeof(udev->descriptor)) {
dev_err(&udev->dev, "device descriptor read/%s, error %d\n",
"all", retval);
diff -urN 2681_prepatch/linux/drivers/usb/host/Kconfig
2681_patch_creation/linux/drivers/usb/host/Kconfig
--- 2681_prepatch/linux/drivers/usb/host/Kconfig 2004-11-12
17:26:21.000000000 -0600
+++ 2681_patch_creation/linux/drivers/usb/host/Kconfig 2004-11-12
15:39:12.000000000 -0600
@@ -65,6 +65,26 @@
To compile this driver as a module, choose M here: the
module will be called ohci-hcd.
+choice
+ prompt "USB HCD chip type"
+ default USB_OHCI_PCI
+ depends on USB_OHCI_HCD
+
+ config USB_OHCI_PCI
+ bool "Generic PCI OHCI controller"
+ depends on PCI
+
+ config USB_OHCI_SL811
+ bool "Cypress HCSL811HS"
+
+ config USB_OHCI_ISP1362
+ bool "Philips ISP1362"
+endchoice
+
+config USB_OHCI_DMA
+ bool "Enable DMA transfer mode"
+ depends on USB_OHCI_HCD && USB_OHCI_ISP1362
+
config USB_UHCI_HCD
tristate "UHCI HCD (most Intel and VIA) support"
depends on USB
diff -urN 2681_prepatch/linux/drivers/usb/host/ohci-isp1362-emu.c
2681_patch_creation/linux/drivers/usb/host/ohci-isp1362-emu.c
--- 2681_prepatch/linux/drivers/usb/host/ohci-isp1362-emu.c 2004-11-12
17:41:47.000000000 -0600
+++ 2681_patch_creation/linux/drivers/usb/host/ohci-isp1362-emu.c
2004-11-12 16:02:03.000000000 -0600
@@ -324,9 +324,9 @@
1 << (dev->atl_queue.num_bufs - 1));
//__isp1362_write_reg32(dev, HCATLLAST, 1 <<
(dev->atl_queue.num_bufs - 1));
_DPRINTK("%s: Enabling ATL Interrupt\n", __FUNCTION__);
- //dev->int_mask |= HCuPINT_ATL;
+ dev->int_mask |= HCuPINT_ATL; // MWM, debug
_DPRINTK("%s: Writing %d to HCATLDTCTO\n", __FUNCTION__, 255);
- //__isp1362_write_reg16(dev, HCATLDTCTO, 255);
+ __isp1362_write_reg16(dev, HCATLDTCTO, 255); // MWM, debug
//__isp1362_set_mask16(dev, HCBUFSTAT, HCBUFSTAT_ATL_ACTIVE);
//isp1362_show_reg(dev, HCBUFSTAT);
ret = ++dev->atl_queue.active_ptds;
@@ -923,6 +923,14 @@
dev->atl_queue.active_ptds = 0;
}
+ DPRINTK("%s: Enable EOT interrupt handling\n", __FUNCTION__); //mwm
+ dev->int_mask |= HCuPINT_EOT; //mwm
+
+ // MWM, DEBUG- toggle the LED, so we can trigger off of it for
debugging.
+ // The LED is hooked up to Port G, bit 0
+ GPIO_PGDR ^= 0x01;
+ // </DEBUG>
+
return ret;
}
@@ -1133,6 +1141,8 @@
//u32 ohci_int_status = 0;
u16 old_mask;
+ DPRINTK("INT! ");
+
/*
* To ensure that no interrupts are lost, all interrupts are disabled
* upon entering the interrupt handler thus deasserting the INT output
@@ -1223,7 +1233,8 @@
}
if (svc_mask & HCuPINT_ATL) {
- u32 done_map = __isp1362_read_reg32(dev, HCATLDONE);
+ // NOTE: ATLDoneMap is only valid if we've recently
received an ATL interrupt!
+ u32 done_map = __isp1362_read_reg32(dev, HCATLDONE);
u32 skip_map = __isp1362_read_reg32(dev, HCATLSKIP);
svc_mask &= ~HCuPINT_ATL;
@@ -1234,7 +1245,14 @@
__isp1362_write_reg32(dev, HCATLSKIP, skip_map);
__isp1362_write_reg16(dev, HCATLDTCTO, 0);
- finish_ptds(hcd, &dev->atl_queue, done_map);
+ //<mwm, debug>
+ do {
+ char debug_buf[20];
+ __isp1362_read_buffer(dev, debug_buf, 0, 0xa60,
20);
+ } while (0);
+ //</mwm, debug>
+
+ finish_ptds(hcd, &dev->atl_queue, done_map);
if (dev->atl_queue.skip_map & ~skip_map) {
skip_map |= dev->atl_queue.skip_map;
DPRINTK("%s: Writing %08x to ATLSKIP\n",
__FUNCTION__, skip_map);
diff -urN 2681_prepatch/linux/drivers/usb/host/ohci-isp1362-regs.h
2681_patch_creation/linux/drivers/usb/host/ohci-isp1362-regs.h
--- 2681_prepatch/linux/drivers/usb/host/ohci-isp1362-regs.h 2004-11-12
17:41:47.000000000 -0600
+++ 2681_patch_creation/linux/drivers/usb/host/ohci-isp1362-regs.h
2004-11-12 16:02:03.000000000 -0600
@@ -318,7 +318,10 @@
if (val & (OHCI_BLF | OHCI_CLF)) {
DPRINTK("%s: Enabling SOF interrupts\n", __FUNCTION__);
__isp1362_set_mask16(dev, HCuPINTENB, HCuPINT_SOF);
- }
- __ohci_isp1362_write_masked(ohci, cmdstatus, HCCMDSTAT, val);
+ // Q. Should this go here?
//mwm
+ DPRINTK("%s: Enabling ATL interrupts (mwm)\n", __FUNCTION__);
//mwm
+ __isp1362_set_mask16(dev, HCuPINTENB, HCuPINT_ATL);
//mwm
+ }
+ __ohci_isp1362_write_masked(ohci, cmdstatus, HCCMDSTAT, val);
local_irq_restore(flags);
}
diff -urN 2681_prepatch/linux/drivers/usb/host/ohci-isp1362.c
2681_patch_creation/linux/drivers/usb/host/ohci-isp1362.c
--- 2681_prepatch/linux/drivers/usb/host/ohci-isp1362.c 2004-11-12
17:41:47.000000000 -0600
+++ 2681_patch_creation/linux/drivers/usb/host/ohci-isp1362.c 2004-11-12
16:45:22.000000000 -0600
@@ -89,7 +89,8 @@
unsigned long flags;
u16 pattern;
unsigned long start_time;
-
+ int cs; //mwm, debug
+
printk(KERN_DEBUG "%s: Probing for ISP1362HS Chip\n", __FUNCTION__);
isp1362_set_hw_reset(dev);
@@ -100,7 +101,10 @@
mdelay(10);
isp1362_clr_hw_reset(dev);
-
+
+// On 'Oscar', we'll skip this check.
+#if ! defined(CONFIG_MACH_OSCAR)
+
start_time = jiffies;
do {
if (isp1362_read_reg16(dev, HCuPINT) & HCuPINT_CLKRDY) {
@@ -113,35 +117,45 @@
jiffies_to_msecs(jiffies - start_time));
return ret;
}
-
- val = isp1362_read_reg16(dev, HCCHIPID);
- if ((val & HCCHIPID_MASK) != HCCHIPID_ISP1362_MAGIC) {
+#endif
+
+ // <MWM, DEBUG>
+ // Only continue once 3 _consequtive_ successes are met for each
+ for ( cs = 0; ( cs < 3 ); )
+ {
+ val = isp1362_read_reg16(dev, HCCHIPID);
+ if ((val & HCCHIPID_MASK) != HCCHIPID_ISP1362_MAGIC) {
printk(KERN_WARNING "%s: Invalid chip ID %04x\n", __FUNCTION__,
val);
- return -ENODEV;
- } else {
+ //return -ENODEV;
+ cs = 0;
+ } else {
printk(KERN_DEBUG "%s: Found chip ID %04x\n", __FUNCTION__,
val);
- }
- dev->hw_rev = val & ~HCCHIPID_MASK;
-
- pattern = 0xe52a;
-
- isp1362_write_reg16(dev, HCSCRATCH, pattern);
- val = isp1362_read_reg16(dev, HCSCRATCH);
- if (val != pattern) {
+ cs++
+ }
+ dev->hw_rev = val & ~HCCHIPID_MASK;
+
+ pattern = 0xe52a;
+
+ isp1362_write_reg16(dev, HCSCRATCH, pattern);
+ val = isp1362_read_reg16(dev, HCSCRATCH);
+ if (val != pattern) {
printk(KERN_WARNING "%s: Bad value read back from HCSCRATCH @
%02x: %04x (wrote: %04x)\n",
__FUNCTION__, ISP1362_REG_HCSCRATCH, val, pattern);
- return -ENODEV;
- }
-
- pattern = ~pattern;
- isp1362_write_reg16(dev, HCSCRATCH, pattern);
- val = isp1362_read_reg16(dev, HCSCRATCH);
- if (val != pattern) {
+ //return -ENODEV;
+ cs = 0;
+ }
+
+ pattern = ~pattern;
+ isp1362_write_reg16(dev, HCSCRATCH, pattern);
+ val = isp1362_read_reg16(dev, HCSCRATCH);
+ if (val != pattern) {
printk(KERN_WARNING "%s: Bad value read back from HCSCRATCH @
%02x: %04x (wrote: %04x)\n",
__FUNCTION__, ISP1362_REG_HCSCRATCH, val, pattern);
- return -ENODEV;
- }
-
+ //return -ENODEV;
+ cs = 0;
+ }
+ }
+
if (dev->irq == NO_IRQ) {
dev->irq = isp1362_irq_probe(dev);
if (dev->irq == NO_IRQ) {
@@ -353,6 +367,11 @@
isp1362_write_reg16(dev, HCuPINTENB, HCuPINT_OPR | HCuPINT_SUSP);
+ // < Added by MWM > ** I think this is important.
+ isp1362_write_reg32(dev, HCFMINTVL, 0x27782edf); // reset default:
00002edf
+ isp1362_write_reg32(dev, HCLSTHRESH, 0x00000628); // this is the reset
default, but it doesn't hurt!
+ // < / Added by MWM >
+
return ret;
}
@@ -379,7 +398,7 @@
isp1362_stop_clock(dev);
}
-#define RH_A_POTPGT_(n) ((n) & 0xff << 24)
+#define RH_A_POTPGT_(n) (((n) & 0xff) << 24)
/*
* initialize the emulated OHCI registers
@@ -394,11 +413,15 @@
cold ? "cold" : "warm");
if (cold) {
- memset(regs, 0, sizeof(struct ohci_regs));
+ // Perform a software reset of the chip. (resetting all
registers)
+ isp1362_write_reg16(dev, HCSWRES, HCSWRES_MAGIC);
+
+ memset(regs, 0, sizeof(struct ohci_regs));
//regs->periodicstart = ((9 * FI) / 10) & 0x3fff;
regs->revision = isp1362_read_reg32(dev, HCREVISION);
isp1362_write_reg32(dev, HCRHDESCA, RH_A_POTPGT_(5) | RH_A_OCPM
| RH_A_PSM);
- isp1362_show_reg(dev, HCRHDESCA);
+// isp1362_write_reg32(dev, HCRHDESCA, RH_A_POTPGT_(25) |
RH_A_OCPM | RH_A_PSM); // this matches the 2.4 driver
+ isp1362_show_reg(dev, HCRHDESCA);
isp1362_write_reg32(dev, HCRHDESCB, 0x00060002);
isp1362_show_reg(dev, HCRHDESCB);
//isp1362_write_reg32(dev, HCFMINTVL, 0x27782edf);
@@ -1096,7 +1119,8 @@
printk(DRIVER_INFO " (HC-ISP1362)\n");
ret = hc_isp1362_driver_register(&ohci_hcd_isp1362_driver);
-
+ printk(KERN_DEBUG "driver_register returned %d\n", ret );
+
return ret;
}
diff -urN 2681_prepatch/linux/drivers/usb/host/ohci-isp1362.h
2681_patch_creation/linux/drivers/usb/host/ohci-isp1362.h
--- 2681_prepatch/linux/drivers/usb/host/ohci-isp1362.h 2004-11-12
17:41:47.000000000 -0600
+++ 2681_patch_creation/linux/drivers/usb/host/ohci-isp1362.h 2004-11-12
17:02:19.000000000 -0600
@@ -255,19 +255,24 @@
* them here for conveniently changing them according to the
* machine type.
*/
-#ifdef CONFIG_ARCH_KARO
-#define HCHWCFG_INIT_VAL (HCHWCFG_DREQ_POL | HCHWCFG_DBWIDTH(1) |
HCHWCFG_INT_ENABLE)
-#define HCDMACFG_INIT_VAL (HCDMACFG_BUF_DIRECT | HCDMACFG_BURST_LEN_4)
-
-#define CAN_USE_32BIT 1
-#define CHIP_TYPE CHIP_TYPE_ISP1362
-
+#if defined(CONFIG_ARCH_KARO)
+# define HCHWCFG_INIT_VAL (HCHWCFG_DREQ_POL | HCHWCFG_DBWIDTH(1) |
HCHWCFG_INT_ENABLE)
+# define HCDMACFG_INIT_VAL (HCDMACFG_BUF_DIRECT | HCDMACFG_BURST_LEN_4)
+# define CAN_USE_32BIT 1
+# define CHIP_TYPE CHIP_TYPE_ISP1362
+#elif defined(CONFIG_MACH_OSCAR)
+# define HCHWCFG_INIT_VAL (HCHWCFG_DISABLE_SUSPEND | HCHWCFG_DBWIDTH(1) \
+ | HCHWCFG_PULLDOWN_DS1 | HCHWCFG_PULLDOWN_DS2
| HCHWCFG_INT_ENABLE \
+ | HCHWCFG_ANALOG_OC | HCHWCFG_DREQ_POL )
+# define HCDMACFG_INIT_VAL (0) // DMA is disabled
+# define CAN_USE_32BIT 0
+# define CHIP_TYPE CHIP_TYPE_ISP1362
#else
-#error Specify appropriate initialization values for HW configuration registers
-#define HCHWCFG_INIT_VAL ()
-#define HCDMACFG_INIT_VAL ()
-
-#define CAN_USE_32BIT ?
+# error Specify appropriate initialization values for HW configuration
registers
+# define HCHWCFG_INIT_VAL ()
+# define HCDMACFG_INIT_VAL ()
+# define CAN_USE_32BIT ?
+# define CHIP_TYPE ?
#endif
#define ohci_to_hcd(ohci) (&(ohci)->hcd)
@@ -431,18 +436,55 @@
* ISP1362 HW Interface
*/
+#if 0
+# define hc_isp1362_addr_reg (dev->addr_reg)
+# define hc_isp1362_data_reg (dev->data_reg)
+#else
+# define hc_isp1362_addr_reg ((volatile void*)OSCAR_USB_VIRT + 2)
+# define hc_isp1362_data_reg ((volatile void*)OSCAR_USB_VIRT)
+#endif
+
+// delay300ns was taken verbatim from the 2.4 driver (hc_isp1362.h)
+static inline void delay300ns(void)
+{
+#ifdef HC_MEM_FENCE_BASE
+ outw(0,HC_MEM_FENCE_BASE); //80ns access time for 1st access
+ outw(0,HC_MEM_FENCE_BASE); //140ns delay between CS, 80 access
time for 2nd access
+ outw(0,HC_MEM_FENCE_BASE); //1 more for luck
+#else
+ static int cnt=0;
+ cnt++;
+ udelay (1);
+#endif
+}
+
#if 1
-#define hc_isp1362_addr_reg (dev->addr_reg)
-#define hc_isp1362_data_reg (dev->data_reg)
+# define isp_writew( data, addr ) ({ writew( data, addr ); udelay(1); })
+# define isp_readw( addr ) ({ u16 val_ = readw( addr ); udelay(1);
val_; })
#else
-#define hc_isp1362_addr_reg ((volatile void*)UAT_USB_BASE + 4)
-#define hc_isp1362_data_reg ((volatile void*)UAT_USB_BASE)
+# define isp_writew( data, addr ) ({ writew( data, addr ); writew(
0xffffffff, BUSDELAY_VIRT ); })
+# define isp_readw( addr ) ({ readw( addr ); writew( 0xffffffff,
BUSDELAY_VIRT ); })
#endif
+#define isp_writel( data, addr ) writel( data, addr );
+#define isp_readl( addr ) readl( addr );
+
+//#define _DPRINTK(fmt...) do { printk(KERN_INFO fmt); } while(0)
+#define DPRINTK(fmt...) do { printk(KERN_INFO fmt); } while(0)
+#define DDPRINTK(fmt...) do { printk(KERN_INFO fmt); } while(0)
-//#define _DPRINTK DPRINTK
#ifndef _DPRINTK
-#define _DPRINTK(fmt...) do {} while(0)
+# define _DPRINTK(fmt...) do {} while(0)
+#endif
+#ifndef DPRINTK
+# define DPRINTK(fmt...) do {} while(0)
+#endif
+#ifndef DDPRINTK
+# define DDPRINTK(fmt...) do {} while(0)
#endif
+#ifndef MEMDUMP
+# define MEMDUMP(fmt...) do {} while(0)
+#endif
+
// basic access functions for ISP1362 chip registers
/* NOTE: The contents of the command register cannot read back! The driver
must ensure,
@@ -455,14 +497,16 @@
_BUG_ON((reg & ISP1362_REG_WRITE_OFFSET) && !(reg & REG_ACCESS_W));
_BUG_ON(!(reg & CHIP_TYPE));
_BUG_ON(!irqs_disabled());
- writew(reg & REG_NO_MASK, hc_isp1362_addr_reg);
- _DPRINTK("A>[EMAIL PROTECTED]", reg & REG_NO_MASK, (u32)
hc_isp1362_addr_reg);
+ isp_writew(reg & REG_NO_MASK, hc_isp1362_addr_reg);
+ _DPRINTK("ohci-isp1362: reg %02x ", (reg & REG_NO_MASK & ~0x80) );
+ //_DPRINTK("A>[EMAIL PROTECTED]", reg & REG_NO_MASK, (u32)
hc_isp1362_addr_reg);
}
static inline void HC_ISP1362_WRITE_DATA16(struct hc_isp1362_dev *dev, u16 val)
{
- _DPRINTK("D>[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
- writew(val, hc_isp1362_data_reg);
+ _DPRINTK("= %04x\n", val );
+ //_DPRINTK("D>[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
+ isp_writew((val), hc_isp1362_data_reg);
}
static inline u16 HC_ISP1362_READ_DATA16(struct hc_isp1362_dev *dev)
@@ -470,8 +514,9 @@
u16 val;
_BUG_ON(!irqs_disabled());
- val = readw(hc_isp1362_data_reg);
- _DPRINTK("D<[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
+ val = isp_readw(hc_isp1362_data_reg);
+ _DPRINTK("= %04x\n", (val) );
+ //_DPRINTK("D<[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
return val;
}
@@ -479,12 +524,13 @@
static inline void HC_ISP1362_WRITE_DATA32(struct hc_isp1362_dev *dev, u32 val)
{
_BUG_ON(!irqs_disabled());
- _DPRINTK("D>[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
+ _DPRINTK("= %08x\n", val);
+ //_DPRINTK("D>[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
#if CAN_USE_32BIT
- writel(val, hc_isp1362_data_reg);
+ isp_writel(val, hc_isp1362_data_reg);
#else
- writew((u16) val, hc_isp1362_data_reg);
- writew((u16) (val >> 16), hc_isp1362_data_reg);
+ isp_writew((u16) val, hc_isp1362_data_reg);
+ isp_writew((u16) (val >> 16), hc_isp1362_data_reg);
#endif
}
@@ -494,12 +540,13 @@
_BUG_ON(!irqs_disabled());
#if CAN_USE_32BIT
- val = readl(hc_isp1362_data_reg);
+ val = isp_readl(hc_isp1362_data_reg);
#else
- val = (u32) readw(hc_isp1362_data_reg);
- val |= (u32) readw(hc_isp1362_data_reg) << 16;
+ val = (u32) isp_readw(hc_isp1362_data_reg);
+ val |= (u32) isp_readw(hc_isp1362_data_reg) << 16;
#endif
- _DPRINTK("D<[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
+ _DPRINTK("is %08x\n", val);
+ //_DPRINTK("D<[EMAIL PROTECTED]", val, (u32) hc_isp1362_data_reg);
return val;
}
@@ -512,7 +559,7 @@
_BUG_ON(((ISP1362_REG_##r) & REG_WIDTH_MASK) != REG_WIDTH_16); \
HC_ISP1362_WRITE_ADDR(d, ISP1362_REG_##r); \
__v = HC_ISP1362_READ_DATA16(d); \
-/*DPRINTK("%s: Read %04x from %s\n", __FUNCTION__, __v, #r);*/ \
+DPRINTK("%s: Read %04x from %s [%02x]\n", __FUNCTION__, __v, #r,
(ISP1362_REG_##r) & 0xff ); \
__v; \
})
@@ -531,7 +578,7 @@
_BUG_ON(((ISP1362_REG_##r) & REG_WIDTH_MASK) != REG_WIDTH_32); \
HC_ISP1362_WRITE_ADDR(d, ISP1362_REG_##r); \
__v = HC_ISP1362_READ_DATA32(d); \
-/*DPRINTK("%s: Read %08x from %s\n", __FUNCTION__, __v, #r);*/\
+DPRINTK("%s: Read %08x from %s [%02x]\n", __FUNCTION__, __v, #r,
(ISP1362_REG_##r) & 0xff ); \
__v; \
})
@@ -549,7 +596,7 @@
_BUG_ON(((ISP1362_REG_##r) & REG_WIDTH_MASK) != REG_WIDTH_16);
\
HC_ISP1362_WRITE_ADDR(d, (ISP1362_REG_##r) | ISP1362_REG_WRITE_OFFSET);
\
HC_ISP1362_WRITE_DATA16(d, (u16)(v));
\
-/*DPRINTK("%s: Wrote %04x to %s\n", __FUNCTION__, (u16)(v), #r);*/
\
+DPRINTK("%s: Wrote %04x to %s [%02x]\n", __FUNCTION__, (u16)(v), #r,
(ISP1362_REG_##r) & 0xff ); \
}
#define isp1362_write_reg16(d, r, v) { \
@@ -564,7 +611,7 @@
_BUG_ON(((ISP1362_REG_##r) & REG_WIDTH_MASK) != REG_WIDTH_32);
\
HC_ISP1362_WRITE_ADDR(d, (ISP1362_REG_##r) | ISP1362_REG_WRITE_OFFSET);
\
HC_ISP1362_WRITE_DATA32(d, (u32)(v));
\
-/*DPRINTK("%s: Wrote %08x to %s\n", __FUNCTION__, (u32)(v), #r);*/\
+DPRINTK("%s: Wrote %08x to %s\n", __FUNCTION__, (u32)(v), #r,
(ISP1362_REG_##r) & 0xff ); \
}
#define isp1362_write_reg32(d, r, v) { \
@@ -649,8 +696,8 @@
__isp1362_write_reg16(dev, HCXFERCTR, len);
}
- _DPRINTK("%s: Reading %d byte from buffer[%02x] @ %04x to memory @
%08x\n",
- __FUNCTION__, len, reg & REG_NO_MASK, offset, (u32) buf);
+ DPRINTK("%s: Reading %d byte from buffer[%02x] @ %04x to memory @
%08x\n",
+ __FUNCTION__, len, reg & REG_NO_MASK, offset, (u32) buf);
HC_ISP1362_WRITE_ADDR(dev, reg ? reg : ISP1362_REG_HCDIRDATA);
udelay(1);
@@ -662,7 +709,9 @@
len / 2);
while (len > 1) {
*dp16 = HC_ISP1362_READ_DATA16(dev);
- dp16++;
+ DPRINTK("%s: Read %04x from buffer @ %04x\n",
+ __FUNCTION__, *dp16, offset);
+ dp16++;
len -= 2;
offset++;
}
@@ -706,7 +755,8 @@
#define isp1362_show_buffer(dev, buf, reg, offset, len) ({ \
int __ret; \
__ret = isp1362_read_buffer(dev, buf, reg, offset, len); \
- _memdump(buf, len, offset); \
+ /*_memdump(buf, len, offset);*/ \
+ MEMDUMP(buf, len, offset); \
__ret; \
})
@@ -723,7 +773,7 @@
__isp1362_write_reg16(dev, HCXFERCTR, len);
}
- _DPRINTK("%s: Writing %d byte to buffer[%02x] @ %04x from memory @
%08x\n",
+ DPRINTK("%s: Writing %d byte to buffer[%02x] @ %04x from memory @
%08x\n",
__FUNCTION__, len, reg & REG_NO_MASK, offset, (u32) buf);
HC_ISP1362_WRITE_ADDR(dev,
@@ -738,6 +788,8 @@
len / 2);
while (len > 1) {
HC_ISP1362_WRITE_DATA16(dev, *dp16);
+ DPRINTK("%s: Wrote %04x to buffer @ %04x\n",
+ __FUNCTION__, *dp16, offset);
dp16++;
len -= 2;
offset++;
@@ -780,7 +832,8 @@
__ret; \
})
-#define __isp1362_show_reg(d,r) {
\
+#if 0
+# define __isp1362_show_reg(d,r) {
\
if ((ISP1362_REG_##r & REG_WIDTH_MASK) == REG_WIDTH_32) {
\
DDPRINTK("%-12s[%02x]: %08x\n", #r,
\
ISP1362_REG_##r & REG_NO_MASK, __isp1362_read_reg32(d,
r)); \
@@ -789,6 +842,17 @@
ISP1362_REG_##r & REG_NO_MASK, __isp1362_read_reg16(d,
r)); \
}
\
}
+#else
+# define __isp1362_show_reg(d,r) \
+do { \
+ u32 _myreg_; \
+ if ((ISP1362_REG_##r & REG_WIDTH_MASK) == REG_WIDTH_32) { \
+ _myreg_ = __isp1362_read_reg32(d, r)); \
+ } else { \
+ _myreg_ = __isp1362_read_reg16(d, r)); \
+ } \
+} while ( 0 )
+#endif
#define isp1362_show_reg(d,r) { \
unsigned long __flags; \
@@ -879,6 +943,12 @@
}
}
+#if defined(CONFIG_MACH_OSCAR)
+# define isp1362_set_hw_reset(dev) do {} while (0)
+# define isp1362_clr_hw_reset(dev) do {} while (0)
+# define isp1362_start_clock(dev) do {} while (0)
+# define isp1362_stop_clock(dev) do {} while (0)
+#else
static void isp1362_set_hw_reset(struct hc_isp1362_dev *dev)
{
struct platform_device *pdev = to_platform_device(dev->dev.parent);
@@ -918,6 +988,7 @@
chip_info->clock_disable(pdev->id);
}
}
+#endif
//static void clear_ptd_queue(struct hc_isp1362_dev *dev, struct ptd_queue
*ptd_q, int xfer_type, int index);
static void clear_ptd_queue(struct usb_hcd *hcd, struct ptd_queue *ptd_q,
diff -urN 2681_prepatch/linux/drivers/usb/host/ohci.h
2681_patch_creation/linux/drivers/usb/host/ohci.h
--- 2681_prepatch/linux/drivers/usb/host/ohci.h 2004-11-12 17:26:21.000000000
-0600
+++ 2681_patch_creation/linux/drivers/usb/host/ohci.h 2004-11-12
17:21:21.000000000 -0600
@@ -7,6 +7,8 @@
* This file is licenced under the GPL.
*/
+#define OHCI_VERBOSE_DEBUG
+
/*
* OHCI Endpoint Descriptor (ED) ... holds TD queue
* See OHCI spec, section 4.2
diff -urN 2681_prepatch/linux/include/linux/usb.h
2681_patch_creation/linux/include/linux/usb.h
--- 2681_prepatch/linux/include/linux/usb.h 2004-11-12 17:26:05.000000000
-0600
+++ 2681_patch_creation/linux/include/linux/usb.h 2004-11-12
17:18:33.000000000 -0600
@@ -25,6 +25,13 @@
/*-------------------------------------------------------------------------*/
+// 2004-10-13, MWM - Added this structure which is needed by the USB HC driver
+struct ohci_chip_info {
+ void (*hw_reset) (int devid, int set);
+ void (*clock_enable) (int devid);
+ void (*clock_disable) (int devid);
+};
+
/*
* Host-side wrappers for standard USB descriptors ... these are parsed
* from the data provided by devices. Parsing turns them from a flat