From: Milan Svoboda This patch adds platform device ixp4xx_gadget that uses pxa2xx-udc device driver. Also pxa2xx_udc.c is updated so it can be compiled without errors on IXP4XX architecture. Signed-off-by: Milan Svoboda Cc: Greg KH Cc: Russell King Signed-off-by: Andrew Morton --- arch/arm/mach-ixp4xx/common.c | 37 ++++++++++++++++++++++++++- drivers/usb/gadget/pxa2xx_udc.c | 8 ++++- include/asm-arm/arch-ixp4xx/irqs.h | 6 ++++ include/asm-arm/arch-ixp4xx/udc.h | 18 +++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff -puN arch/arm/mach-ixp4xx/common.c~usb-gadget-update-pxa2xx_udcc-and-arch-dependent-files arch/arm/mach-ixp4xx/common.c --- 25/arch/arm/mach-ixp4xx/common.c~usb-gadget-update-pxa2xx_udcc-and-arch-dependent-files Thu May 25 11:58:31 2006 +++ 25-akpm/arch/arm/mach-ixp4xx/common.c Thu May 25 11:58:31 2006 @@ -39,6 +39,8 @@ #include #include +#include + /************************************************************************* * IXP4xx chipset I/O mapping *************************************************************************/ @@ -337,8 +339,41 @@ static struct platform_device ixp46x_i2c .resource = ixp46x_i2c_resources }; +static struct resource ixp4xx_gadget_resources[] = { + [0] = { + .start = 0xc800b000, + .end = 0xc800bfff, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_USB, + .end = IRQ_USB, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct pxa2xx_udc_mach_info ixp4xx_udc_info = { + .udc_is_connected = NULL, + .udc_command = NULL, +}; + +/* + * USB device controller. The IXP46x uses the same controller as PXA2XX, + * so we just use the same device name. + */ +static struct platform_device ixp4xx_gadget = { + .name = "pxa2xx-udc", + .id = -1, + .num_resources = 2, + .resource = ixp4xx_gadget_resources, + .dev = { + .platform_data = &ixp4xx_udc_info, + }, +}; + static struct platform_device *ixp46x_devices[] __initdata = { - &ixp46x_i2c_controller + &ixp46x_i2c_controller, + &ixp4xx_gadget, }; unsigned long ixp4xx_exp_bus_size; diff -puN drivers/usb/gadget/pxa2xx_udc.c~usb-gadget-update-pxa2xx_udcc-and-arch-dependent-files drivers/usb/gadget/pxa2xx_udc.c --- 25/drivers/usb/gadget/pxa2xx_udc.c~usb-gadget-update-pxa2xx_udcc-and-arch-dependent-files Thu May 25 11:58:31 2006 +++ 25-akpm/drivers/usb/gadget/pxa2xx_udc.c Thu May 25 11:58:31 2006 @@ -53,7 +53,9 @@ #include #include #include +#ifdef CONFIG_ARCH_PXA #include +#endif #include #include @@ -2431,7 +2433,7 @@ static struct pxa2xx_udc memory = { /* * probe - binds to the platform device */ -static int __init pxa2xx_udc_probe(struct platform_device *pdev) +static int pxa2xx_udc_probe(struct platform_device *pdev) { struct pxa2xx_udc *dev = &memory; int retval, out_dma = 1; @@ -2563,7 +2565,7 @@ static void pxa2xx_udc_shutdown(struct p pullup_off(); } -static int __exit pxa2xx_udc_remove(struct platform_device *pdev) +static int pxa2xx_udc_remove(struct platform_device *pdev) { struct pxa2xx_udc *dev = platform_get_drvdata(pdev); @@ -2575,10 +2577,12 @@ static int __exit pxa2xx_udc_remove(stru free_irq(IRQ_USB, dev); dev->got_irq = 0; } +#ifdef CONFIG_ARCH_LUBBOCK if (machine_is_lubbock()) { free_irq(LUBBOCK_USB_DISC_IRQ, dev); free_irq(LUBBOCK_USB_IRQ, dev); } +#endif platform_set_drvdata(pdev, NULL); the_controller = NULL; return 0; diff -puN include/asm-arm/arch-ixp4xx/irqs.h~usb-gadget-update-pxa2xx_udcc-and-arch-dependent-files include/asm-arm/arch-ixp4xx/irqs.h --- 25/include/asm-arm/arch-ixp4xx/irqs.h~usb-gadget-update-pxa2xx_udcc-and-arch-dependent-files Thu May 25 11:58:31 2006 +++ 25-akpm/include/asm-arm/arch-ixp4xx/irqs.h Thu May 25 11:58:31 2006 @@ -109,4 +109,10 @@ #define IRQ_NAS100D_PCI_INTD IRQ_IXP4XX_GPIO8 #define IRQ_NAS100D_PCI_INTE IRQ_IXP4XX_GPIO7 +/* + * This is used in pxa2xx usb device controller driver, so it + * doesn't follow ixp4xx naming convetions. + */ +#define IRQ_USB IRQ_IXP4XX_USB + #endif diff -puN /dev/null include/asm-arm/arch-ixp4xx/udc.h --- /dev/null Thu Apr 11 07:25:15 2002 +++ 25-akpm/include/asm-arm/arch-ixp4xx/udc.h Thu May 25 11:58:31 2006 @@ -0,0 +1,18 @@ +/* + * linux/include/asm-arm/arch-pxa/udc.h + * + * This supports machine-specific differences in how the PXA2xx + * USB Device Controller (UDC) is wired. + * + * It is set in linux/arch/arm/mach-pxa/.c and used in + * the probe routine of linux/drivers/usb/gadget/pxa2xx_udc.c + */ +struct pxa2xx_udc_mach_info { + int (*udc_is_connected)(void); /* do we see host? */ + void (*udc_command)(int cmd); +#define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */ +#define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */ +}; + +extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info); + _