David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB |
| 3 | */ |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 4 | #include <linux/init.h> |
| 5 | #include <linux/platform_device.h> |
| 6 | #include <linux/dma-mapping.h> |
| 7 | |
| 8 | #include <linux/usb/musb.h> |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 9 | |
| 10 | #include <mach/common.h> |
David Brownell | d0e58ae | 2009-01-18 17:29:10 +0100 | [diff] [blame] | 11 | #include <mach/irqs.h> |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 12 | #include <mach/cputype.h> |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame] | 13 | #include <mach/usb.h> |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 14 | |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame] | 15 | #define DAVINCI_USB_OTG_BASE 0x01c64000 |
| 16 | #define DA8XX_USB1_BASE 0x01e25000 |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 17 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 18 | #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) |
| 19 | static struct musb_hdrc_eps_bits musb_eps[] = { |
| 20 | { "ep1_tx", 8, }, |
| 21 | { "ep1_rx", 8, }, |
| 22 | { "ep2_tx", 8, }, |
| 23 | { "ep2_rx", 8, }, |
| 24 | { "ep3_tx", 5, }, |
| 25 | { "ep3_rx", 5, }, |
| 26 | { "ep4_tx", 5, }, |
| 27 | { "ep4_rx", 5, }, |
| 28 | }; |
| 29 | |
| 30 | static struct musb_hdrc_config musb_config = { |
| 31 | .multipoint = true, |
| 32 | .dyn_fifo = true, |
| 33 | .soft_con = true, |
| 34 | .dma = true, |
| 35 | |
| 36 | .num_eps = 5, |
| 37 | .dma_channels = 8, |
| 38 | .ram_bits = 10, |
| 39 | .eps_bits = musb_eps, |
| 40 | }; |
| 41 | |
| 42 | static struct musb_hdrc_platform_data usb_data = { |
| 43 | #if defined(CONFIG_USB_MUSB_OTG) |
| 44 | /* OTG requires a Mini-AB connector */ |
| 45 | .mode = MUSB_OTG, |
| 46 | #elif defined(CONFIG_USB_MUSB_PERIPHERAL) |
| 47 | .mode = MUSB_PERIPHERAL, |
| 48 | #elif defined(CONFIG_USB_MUSB_HOST) |
| 49 | .mode = MUSB_HOST, |
| 50 | #endif |
David Brownell | 34f32c9 | 2009-02-20 13:45:17 -0800 | [diff] [blame] | 51 | .clock = "usb", |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 52 | .config = &musb_config, |
| 53 | }; |
| 54 | |
| 55 | static struct resource usb_resources[] = { |
| 56 | { |
| 57 | /* physical address */ |
| 58 | .start = DAVINCI_USB_OTG_BASE, |
| 59 | .end = DAVINCI_USB_OTG_BASE + 0x5ff, |
| 60 | .flags = IORESOURCE_MEM, |
| 61 | }, |
| 62 | { |
| 63 | .start = IRQ_USBINT, |
| 64 | .flags = IORESOURCE_IRQ, |
| 65 | }, |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 66 | { |
| 67 | /* placeholder for the dedicated CPPI IRQ */ |
| 68 | .flags = IORESOURCE_IRQ, |
| 69 | }, |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 72 | static u64 usb_dmamask = DMA_BIT_MASK(32); |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 73 | |
| 74 | static struct platform_device usb_dev = { |
| 75 | .name = "musb_hdrc", |
| 76 | .id = -1, |
| 77 | .dev = { |
| 78 | .platform_data = &usb_data, |
| 79 | .dma_mask = &usb_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 80 | .coherent_dma_mask = DMA_BIT_MASK(32), |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 81 | }, |
| 82 | .resource = usb_resources, |
| 83 | .num_resources = ARRAY_SIZE(usb_resources), |
| 84 | }; |
| 85 | |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame^] | 86 | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 87 | { |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame^] | 88 | usb_data.power = mA > 510 ? 255 : mA / 2; |
| 89 | usb_data.potpgt = (potpgt_ms + 1) / 2; |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 90 | |
| 91 | if (cpu_is_davinci_dm646x()) { |
| 92 | /* Override the defaults as DM6467 uses different IRQs. */ |
| 93 | usb_dev.resource[1].start = IRQ_DM646X_USBINT; |
| 94 | usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT; |
| 95 | } else /* other devices don't have dedicated CPPI IRQ */ |
| 96 | usb_dev.num_resources = 2; |
| 97 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 98 | platform_device_register(&usb_dev); |
| 99 | } |
| 100 | |
| 101 | #else |
| 102 | |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame^] | 103 | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 104 | { |
| 105 | } |
| 106 | |
| 107 | #endif /* CONFIG_USB_MUSB_HDRC */ |
| 108 | |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame] | 109 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
| 110 | static struct resource da8xx_usb11_resources[] = { |
| 111 | [0] = { |
| 112 | .start = DA8XX_USB1_BASE, |
| 113 | .end = DA8XX_USB1_BASE + SZ_4K - 1, |
| 114 | .flags = IORESOURCE_MEM, |
| 115 | }, |
| 116 | [1] = { |
| 117 | .start = IRQ_DA8XX_IRQN, |
| 118 | .end = IRQ_DA8XX_IRQN, |
| 119 | .flags = IORESOURCE_IRQ, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32); |
| 124 | |
| 125 | static struct platform_device da8xx_usb11_device = { |
| 126 | .name = "ohci", |
| 127 | .id = 0, |
| 128 | .dev = { |
| 129 | .dma_mask = &da8xx_usb11_dma_mask, |
| 130 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 131 | }, |
| 132 | .num_resources = ARRAY_SIZE(da8xx_usb11_resources), |
| 133 | .resource = da8xx_usb11_resources, |
| 134 | }; |
| 135 | |
| 136 | int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) |
| 137 | { |
| 138 | da8xx_usb11_device.dev.platform_data = pdata; |
| 139 | return platform_device_register(&da8xx_usb11_device); |
| 140 | } |
| 141 | #endif /* CONFIG_DAVINCI_DA8XX */ |