blob: fe20cc2e8385a3758a4d953396cf556b0960426a [file] [log] [blame]
David Brownellcece6e52008-09-07 23:41:57 -07001/*
2 * USB
3 */
David Brownellcece6e52008-09-07 23:41:57 -07004#include <linux/init.h>
5#include <linux/platform_device.h>
6#include <linux/dma-mapping.h>
7
8#include <linux/usb/musb.h>
David Brownellcece6e52008-09-07 23:41:57 -07009
10#include <mach/common.h>
David Brownelld0e58ae2009-01-18 17:29:10 +010011#include <mach/irqs.h>
Sergei Shtylyovefd91182009-07-16 19:58:53 +040012#include <mach/cputype.h>
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040013#include <mach/usb.h>
David Brownellcece6e52008-09-07 23:41:57 -070014
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040015#define DAVINCI_USB_OTG_BASE 0x01c64000
16#define DA8XX_USB1_BASE 0x01e25000
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050017
David Brownellcece6e52008-09-07 23:41:57 -070018#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
19static 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
30static 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
42static 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 Brownell34f32c92009-02-20 13:45:17 -080051 .clock = "usb",
David Brownellcece6e52008-09-07 23:41:57 -070052 .config = &musb_config,
53};
54
55static 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 Shtylyovefd91182009-07-16 19:58:53 +040066 {
67 /* placeholder for the dedicated CPPI IRQ */
68 .flags = IORESOURCE_IRQ,
69 },
David Brownellcece6e52008-09-07 23:41:57 -070070};
71
Yang Hongyang284901a2009-04-06 19:01:15 -070072static u64 usb_dmamask = DMA_BIT_MASK(32);
David Brownellcece6e52008-09-07 23:41:57 -070073
74static 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 Hongyang284901a2009-04-06 19:01:15 -070080 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownellcece6e52008-09-07 23:41:57 -070081 },
82 .resource = usb_resources,
83 .num_resources = ARRAY_SIZE(usb_resources),
84};
85
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040086void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070087{
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040088 usb_data.power = mA > 510 ? 255 : mA / 2;
89 usb_data.potpgt = (potpgt_ms + 1) / 2;
Sergei Shtylyovefd91182009-07-16 19:58:53 +040090
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 Brownellcece6e52008-09-07 23:41:57 -070098 platform_device_register(&usb_dev);
99}
100
101#else
102
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +0400103void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -0700104{
105}
106
107#endif /* CONFIG_USB_MUSB_HDRC */
108
Sergei Shtylyove5d3d252009-09-25 23:14:02 +0400109#ifdef CONFIG_ARCH_DAVINCI_DA8XX
110static 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
123static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
124
125static 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
136int __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 */