Subject: Re: SecretLab 2.6.24 with USB

From: Aaron Sells <[email-masked]>
Date: Thu, 24 Apr 2008 12:04:23 -0400

Peter Korsgaard wrote:
> I don't see anything with platform devices for the c67x00 driver.

I added the relevant struct information.  The patch is attached.

> Either you do this by hand or you
> create XPAR_* macros which take the needed info out of xparameter.h
> (sorry, I don't have an xparameters.h with those defines at hand).

I generate the xparameters_ml403.h file using Xilinx's EDK base system 
builder wizard.  However, the wizard does not automatically enable the 
Cypress device to be interrupt driven.  I have manually done this as 
described in the attached patch.

The resulting xparameters_ml403.h has the following defines:

sellsa@SS-SBIR-Ubuntu:~/spacesuit/linux-2.6-xlnx$ cat 
arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h | grep USB
/* Definitions for peripheral CYPRESS_USB */
#define XPAR_CYPRESS_USB_PRH0_BASEADDR 0x80800000
#define XPAR_CYPRESS_USB_PRH0_HIGHADDR 0x8080FFFF
#define XPAR_SYSTEM_USB_INT_PIN_MASK 0X000001
#define XPAR_XPS_INTC_0_SYSTEM_USB_INT_PIN_INTR 0

When I boot the Xilinx ML403 board up, I get the following:

[    9.256329] ------------[ cut here ]------------
[    9.260000] Badness at drivers/usb/c67x00/c67x00-ll-hpi.c:244
[    9.260000] NIP: c01b5d6c LR: c01b5d60 CTR: c00170f4
[    9.260000] REGS: c3c19d70 TRAP: 0700   Not tainted 
(2.6.24-rc8-xlnx-dirty)
[    9.260000] MSR: 00029030 <EE,ME,IR,DR>  CR: 24000082  XER: 20000073
[    9.260000] TASK = c3c178a0[1] 'swapper' THREAD: c3c18000
[    9.260000] GPR00: 00000001 c3c19e20 c3c178a0 00000000 c032f518 
c0372730 27b38fa6 00000001
[    9.260000] GPR08: 00000000 00200200 c3d2b164 c3d2b164 24000082 
ffffcd64 c02d4c5c c02d4c6c
[    9.260000] GPR16: c02d4c90 c02d4c98 c02d4ca8 c02d4cd4 c02d4ce8 
00000000 c02d7114 c0370e78
[    9.260000] GPR24: c0360000 c02d4c54 c0330724 00000000 c3d2b148 
00000000 c3d2b140 c0330708
[    9.260000] NIP [c01b5d6c] c67x00_ll_reset+0x48/0x88
[    9.260000] LR [c01b5d60] c67x00_ll_reset+0x3c/0x88
[    9.260000] Call Trace:
[    9.260000] [c3c19e20] [c01b5d60] c67x00_ll_reset+0x3c/0x88 (unreliable)
[    9.260000] [c3c19e40] [c02885e0] c67x00_drv_probe+0x16c/0x2d8
[    9.260000] [c3c19e70] [c01694b0] platform_drv_probe+0x20/0x30
[    9.260000] [c3c19e80] [c01674f8] driver_probe_device+0xec/0x194
[    9.260000] [c3c19ea0] [c0167750] __driver_attach+0x88/0xf4
[    9.260000] [c3c19ec0] [c0166648] bus_for_each_dev+0x58/0x98
[    9.260000] [c3c19ef0] [c01672f4] driver_attach+0x24/0x34
[    9.260000] [c3c19f00] [c016706c] bus_add_driver+0xb4/0x218
[    9.260000] [c3c19f20] [c0167a64] driver_register+0x78/0x10c
[    9.260000] [c3c19f40] [c016982c] platform_driver_register+0x9c/0xac
[    9.260000] [c3c19f50] [c035fa44] c67x00_init+0x18/0x28
[    9.260000] [c3c19f60] [c034e200] kernel_init+0xfc/0x294
[    9.260000] [c3c19ff0] [c00047d8] kernel_thread+0x44/0x60
[    9.260000] Instruction dump:
[    9.260000] 90010024 480d56c5 38800000 7fa3eb78 6084fa50 4bfff2f5 
387d0020 388004e2
[    9.260000] 480d48d9 707dffff 7c000026 54001ffe <0f000000> 3c00ffff 
7fbd00d0 60000005
[   11.316192] c67x00 c67x00.0: Device reset failed
[   11.364172] c67x00: probe of c67x00.0 failed with error 65531

Sam, since you have this working, any help would be greatly appreciated. 
  What else do I need to do in order to get USB host working on this board?
--- arch/ppc/syslib/virtex_devices.c.old	2008-04-24 11:37:03.000000000 -0400
+++ arch/ppc/syslib/virtex_devices.c	2008-04-24 11:10:09.000000000 -0400
@@ -18,6 +18,7 @@
 #include <syslib/virtex_devices.h>
 #include <platforms/4xx/xparameters/xparameters.h>
 #include <linux/xilinx_devices.h>
+#include <linux/usb/c67x00.h>
 #include <asm/io.h>
 
 /*
@@ -320,6 +321,31 @@
 	}, \
 }
 
+/*
+ * Cypress USB C67x00 shortcut macro for single instance
+ */
+#define XPAR_C67x00_USB(num) { \
+	.name = "c67x00", \
+	.id = num, \
+	.num_resources = 2, \
+	.resource = (struct resource[]) { \
+		{ \
+			.start	= XPAR_CYPRESS_USB_PRH0_BASEADDR, \
+			.end	= XPAR_CYPRESS_USB_PRH0_BASEADDR + 0xf, \
+			.flags	= IORESOURCE_MEM, \
+		}, \
+		{ \
+			.start  = XPAR_XPS_INTC_0_SYSTEM_USB_INT_PIN_INTR, \
+			.end    = XPAR_XPS_INTC_0_SYSTEM_USB_INT_PIN_INTR, \
+			.flags  = IORESOURCE_IRQ, \
+		}, \
+	}, \
+	.dev.platform_data	= &(struct c67x00_platform_data) { \
+		.sie_config	= C67X00_SIE1_HOST | C67X00_SIE2_PERIPHERAL, \
+		.hpi_regstep	= 0x02, /* A0 not connected on 16bit bus */ \
+	}, \
+}
+
 /* UART 8250 driver platform data table */
 struct plat_serial8250_port virtex_serial_platform_data[] = {
 #if defined(XPAR_UARTNS550_0_BASEADDR)
@@ -511,6 +537,13 @@
 #if defined(XPAR_OPB_AC97_CONTROLLER_REF_1_BASEADDR)
 	XPAR_AC97_CONTROLLER_REFERENCE(1),
 #endif
+
+#if defined(XPAR_CYPRESS_USB_PRH0_BASEADDR)
+	XPAR_C67x00_USB(0),
+#endif
+#if defined(XPAR_CYPRESS_USB_PRH1_BASEADDR)
+	XPAR_C67x00_USB(1),
+#endif
 };
 
 /* Early serial support functions */
diff -Naur ml403project.old/data/system.ucf ml403project/data/system.ucf
--- ml403project.old/data/system.ucf	2008-04-24 11:29:30.000000000 -0400
+++ ml403project/data/system.ucf	2008-04-24 11:28:04.000000000 -0400
@@ -599,6 +599,10 @@
 Net fpga_0_FLASH_Mem_CE_pin<0> SLEW = FAST;
 Net fpga_0_FLASH_Mem_CE_pin<0> DRIVE = 8;
 
+###NET USB interrupt
+Net USB_INT_pin LOC=V5;
+Net USB_INT_pin IOSTANDARD = LVCMOS33;
+
 #### New GMAC Coregen Derived Constraints
 		
 NET "*tx_gmii_mii_clk*"    			TNM_NET = "clk_phy_tx_clk0";
diff -Naur ml403project.old/system.mhs ml403project/system.mhs
--- ml403project.old/system.mhs	2008-04-24 11:29:08.000000000 -0400
+++ ml403project/system.mhs	2008-04-24 11:28:29.000000000 -0400
@@ -18,6 +18,7 @@
  PARAMETER VERSION = 2.1.0

+ PORT USB_INT_pin = USB_INT, DIR = I
  PORT fpga_0_RS232_Uart_RX_pin = fpga_0_RS232_Uart_RX, DIR = I
  PORT fpga_0_RS232_Uart_TX_pin = fpga_0_RS232_Uart_TX, DIR = O
  PORT fpga_0_LEDs_4Bit_GPIO_IO_pin = fpga_0_LEDs_4Bit_GPIO_IO, DIR = IO, VEC = [0:3]
@@ -421,6 +422,6 @@
  PARAMETER C_HIGHADDR = 0x8180ffff
  BUS_INTERFACE SPLB = plb
  PORT Irq = EICC405EXTINPUTIRQ
- PORT Intr = RS232_Uart_Interrupt & LEDs_4Bit_IP2INTC_Irpt & LEDs_Positions_IP2INTC_Irpt & Push_Buttons_Position_IP2INTC_Irpt & IIC_EEPROM_IIC2INTC_Irpt & TriMode_MAC_GMII_TemacIntc0_Irpt & xps_timer_1_Interrupt & TriMode_MAC_GMII_fifo_IP2INTC_Irpt
+ PORT Intr = RS232_Uart_Interrupt & LEDs_4Bit_IP2INTC_Irpt & LEDs_Positions_IP2INTC_Irpt & Push_Buttons_Position_IP2INTC_Irpt & IIC_EEPROM_IIC2INTC_Irpt & TriMode_MAC_GMII_TemacIntc0_Irpt & xps_timer_1_Interrupt & TriMode_MAC_GMII_fifo_IP2INTC_Irpt & USB_INT
 END