blob: 34509ffba221e18fb65670b5760870b71460f032 [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>
Arnd Bergmannec2a0832012-08-24 15:11:34 +020013#include <linux/platform_data/usb-davinci.h>
David Brownellcece6e52008-09-07 23:41:57 -070014
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040015#define DAVINCI_USB_OTG_BASE 0x01c64000
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +040016
17#define DA8XX_USB0_BASE 0x01e00000
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040018#define DA8XX_USB1_BASE 0x01e25000
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050019
David Brownellcece6e52008-09-07 23:41:57 -070020#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
21static struct musb_hdrc_eps_bits musb_eps[] = {
22 { "ep1_tx", 8, },
23 { "ep1_rx", 8, },
24 { "ep2_tx", 8, },
25 { "ep2_rx", 8, },
26 { "ep3_tx", 5, },
27 { "ep3_rx", 5, },
28 { "ep4_tx", 5, },
29 { "ep4_rx", 5, },
30};
31
32static struct musb_hdrc_config musb_config = {
33 .multipoint = true,
34 .dyn_fifo = true,
35 .soft_con = true,
36 .dma = true,
37
38 .num_eps = 5,
39 .dma_channels = 8,
40 .ram_bits = 10,
41 .eps_bits = musb_eps,
42};
43
44static struct musb_hdrc_platform_data usb_data = {
David Brownellcece6e52008-09-07 23:41:57 -070045 /* OTG requires a Mini-AB connector */
46 .mode = MUSB_OTG,
David Brownell34f32c92009-02-20 13:45:17 -080047 .clock = "usb",
David Brownellcece6e52008-09-07 23:41:57 -070048 .config = &musb_config,
49};
50
51static struct resource usb_resources[] = {
52 {
53 /* physical address */
54 .start = DAVINCI_USB_OTG_BASE,
55 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
56 .flags = IORESOURCE_MEM,
57 },
58 {
59 .start = IRQ_USBINT,
60 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050061 .name = "mc"
David Brownellcece6e52008-09-07 23:41:57 -070062 },
Sergei Shtylyovefd91182009-07-16 19:58:53 +040063 {
64 /* placeholder for the dedicated CPPI IRQ */
65 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050066 .name = "dma"
Sergei Shtylyovefd91182009-07-16 19:58:53 +040067 },
David Brownellcece6e52008-09-07 23:41:57 -070068};
69
Yang Hongyang284901a2009-04-06 19:01:15 -070070static u64 usb_dmamask = DMA_BIT_MASK(32);
David Brownellcece6e52008-09-07 23:41:57 -070071
72static struct platform_device usb_dev = {
Felipe Balbi73b089b2010-12-02 09:16:55 +020073 .name = "musb-davinci",
David Brownellcece6e52008-09-07 23:41:57 -070074 .id = -1,
75 .dev = {
76 .platform_data = &usb_data,
77 .dma_mask = &usb_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -070078 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownellcece6e52008-09-07 23:41:57 -070079 },
80 .resource = usb_resources,
81 .num_resources = ARRAY_SIZE(usb_resources),
82};
83
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040084void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070085{
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040086 usb_data.power = mA > 510 ? 255 : mA / 2;
87 usb_data.potpgt = (potpgt_ms + 1) / 2;
Sergei Shtylyovefd91182009-07-16 19:58:53 +040088
89 if (cpu_is_davinci_dm646x()) {
90 /* Override the defaults as DM6467 uses different IRQs. */
91 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
92 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
93 } else /* other devices don't have dedicated CPPI IRQ */
94 usb_dev.num_resources = 2;
95
David Brownellcece6e52008-09-07 23:41:57 -070096 platform_device_register(&usb_dev);
97}
98
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +040099#ifdef CONFIG_ARCH_DAVINCI_DA8XX
100static struct resource da8xx_usb20_resources[] = {
101 {
102 .start = DA8XX_USB0_BASE,
103 .end = DA8XX_USB0_BASE + SZ_64K - 1,
104 .flags = IORESOURCE_MEM,
105 },
106 {
107 .start = IRQ_DA8XX_USB_INT,
108 .flags = IORESOURCE_IRQ,
Sergei Shtylyov5a166f42010-12-10 20:23:06 +0300109 .name = "mc",
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400110 },
111};
112
113int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
114{
115 usb_data.clock = "usb20";
116 usb_data.power = mA > 510 ? 255 : mA / 2;
117 usb_data.potpgt = (potpgt + 1) / 2;
118
119 usb_dev.resource = da8xx_usb20_resources;
120 usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources);
Felipe Balbi8ceae512010-12-02 09:19:35 +0200121 usb_dev.name = "musb-da8xx";
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400122
123 return platform_device_register(&usb_dev);
124}
125#endif /* CONFIG_DAVINCI_DA8XX */
126
David Brownellcece6e52008-09-07 23:41:57 -0700127#else
128
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +0400129void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -0700130{
131}
132
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400133#ifdef CONFIG_ARCH_DAVINCI_DA8XX
134int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
135{
136 return 0;
137}
138#endif
139
David Brownellcece6e52008-09-07 23:41:57 -0700140#endif /* CONFIG_USB_MUSB_HDRC */
141
Sergei Shtylyove5d3d252009-09-25 23:14:02 +0400142#ifdef CONFIG_ARCH_DAVINCI_DA8XX
143static struct resource da8xx_usb11_resources[] = {
144 [0] = {
145 .start = DA8XX_USB1_BASE,
146 .end = DA8XX_USB1_BASE + SZ_4K - 1,
147 .flags = IORESOURCE_MEM,
148 },
149 [1] = {
150 .start = IRQ_DA8XX_IRQN,
151 .end = IRQ_DA8XX_IRQN,
152 .flags = IORESOURCE_IRQ,
153 },
154};
155
156static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
157
158static struct platform_device da8xx_usb11_device = {
159 .name = "ohci",
160 .id = 0,
161 .dev = {
162 .dma_mask = &da8xx_usb11_dma_mask,
163 .coherent_dma_mask = DMA_BIT_MASK(32),
164 },
165 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
166 .resource = da8xx_usb11_resources,
167};
168
169int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
170{
171 da8xx_usb11_device.dev.platform_data = pdata;
172 return platform_device_register(&da8xx_usb11_device);
173}
174#endif /* CONFIG_DAVINCI_DA8XX */