davinci: dm646x-evm: Add platform data for NAND
[safe/jmp/linux-2.6] / arch / arm / mach-davinci / usb.c
1 /*
2  * USB
3  */
4 #include <linux/init.h>
5 #include <linux/platform_device.h>
6 #include <linux/dma-mapping.h>
7
8 #include <linux/usb/musb.h>
9
10 #include <mach/common.h>
11 #include <mach/irqs.h>
12 #include <mach/cputype.h>
13 #include <mach/usb.h>
14
15 #define DAVINCI_USB_OTG_BASE    0x01c64000
16 #define DA8XX_USB1_BASE         0x01e25000
17
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
51         .clock          = "usb",
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         },
66         {
67                 /* placeholder for the dedicated CPPI IRQ */
68                 .flags          = IORESOURCE_IRQ,
69         },
70 };
71
72 static u64 usb_dmamask = DMA_BIT_MASK(32);
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,
80                 .coherent_dma_mask      = DMA_BIT_MASK(32),
81         },
82         .resource       = usb_resources,
83         .num_resources  = ARRAY_SIZE(usb_resources),
84 };
85
86 void __init setup_usb(unsigned mA, unsigned potpgt_msec)
87 {
88         usb_data.power = mA / 2;
89         usb_data.potpgt = potpgt_msec / 2;
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
98         platform_device_register(&usb_dev);
99 }
100
101 #else
102
103 void __init setup_usb(unsigned mA, unsigned potpgt_msec)
104 {
105 }
106
107 #endif  /* CONFIG_USB_MUSB_HDRC */
108
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 */