David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB |
| 3 | */ |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/module.h> |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/platform_device.h> |
| 8 | #include <linux/dma-mapping.h> |
| 9 | |
| 10 | #include <linux/usb/musb.h> |
| 11 | #include <linux/usb/otg.h> |
| 12 | |
| 13 | #include <mach/common.h> |
| 14 | #include <mach/hardware.h> |
David Brownell | d0e58ae | 2009-01-18 17:29:10 +0100 | [diff] [blame] | 15 | #include <mach/irqs.h> |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 16 | |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 17 | #define DAVINCI_USB_OTG_BASE 0x01C64000 |
| 18 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 19 | #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) |
| 20 | static struct musb_hdrc_eps_bits musb_eps[] = { |
| 21 | { "ep1_tx", 8, }, |
| 22 | { "ep1_rx", 8, }, |
| 23 | { "ep2_tx", 8, }, |
| 24 | { "ep2_rx", 8, }, |
| 25 | { "ep3_tx", 5, }, |
| 26 | { "ep3_rx", 5, }, |
| 27 | { "ep4_tx", 5, }, |
| 28 | { "ep4_rx", 5, }, |
| 29 | }; |
| 30 | |
| 31 | static struct musb_hdrc_config musb_config = { |
| 32 | .multipoint = true, |
| 33 | .dyn_fifo = true, |
| 34 | .soft_con = true, |
| 35 | .dma = true, |
| 36 | |
| 37 | .num_eps = 5, |
| 38 | .dma_channels = 8, |
| 39 | .ram_bits = 10, |
| 40 | .eps_bits = musb_eps, |
| 41 | }; |
| 42 | |
| 43 | static struct musb_hdrc_platform_data usb_data = { |
| 44 | #if defined(CONFIG_USB_MUSB_OTG) |
| 45 | /* OTG requires a Mini-AB connector */ |
| 46 | .mode = MUSB_OTG, |
| 47 | #elif defined(CONFIG_USB_MUSB_PERIPHERAL) |
| 48 | .mode = MUSB_PERIPHERAL, |
| 49 | #elif defined(CONFIG_USB_MUSB_HOST) |
| 50 | .mode = MUSB_HOST, |
| 51 | #endif |
David Brownell | 34f32c9 | 2009-02-20 13:45:17 -0800 | [diff] [blame] | 52 | .clock = "usb", |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 53 | .config = &musb_config, |
| 54 | }; |
| 55 | |
| 56 | static struct resource usb_resources[] = { |
| 57 | { |
| 58 | /* physical address */ |
| 59 | .start = DAVINCI_USB_OTG_BASE, |
| 60 | .end = DAVINCI_USB_OTG_BASE + 0x5ff, |
| 61 | .flags = IORESOURCE_MEM, |
| 62 | }, |
| 63 | { |
| 64 | .start = IRQ_USBINT, |
| 65 | .flags = IORESOURCE_IRQ, |
| 66 | }, |
| 67 | }; |
| 68 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 69 | static u64 usb_dmamask = DMA_BIT_MASK(32); |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 70 | |
| 71 | static struct platform_device usb_dev = { |
| 72 | .name = "musb_hdrc", |
| 73 | .id = -1, |
| 74 | .dev = { |
| 75 | .platform_data = &usb_data, |
| 76 | .dma_mask = &usb_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 77 | .coherent_dma_mask = DMA_BIT_MASK(32), |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 78 | }, |
| 79 | .resource = usb_resources, |
| 80 | .num_resources = ARRAY_SIZE(usb_resources), |
| 81 | }; |
| 82 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 83 | void __init setup_usb(unsigned mA, unsigned potpgt_msec) |
| 84 | { |
| 85 | usb_data.power = mA / 2; |
| 86 | usb_data.potpgt = potpgt_msec / 2; |
| 87 | platform_device_register(&usb_dev); |
| 88 | } |
| 89 | |
| 90 | #else |
| 91 | |
| 92 | void __init setup_usb(unsigned mA, unsigned potpgt_msec) |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | #endif /* CONFIG_USB_MUSB_HDRC */ |
| 97 | |