blob: 2b4c648f99b69a26cc5d946c1ed580d2c2e34585 [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>
Sekhar Nori215a0842013-04-10 14:57:15 +053013#include <mach/da8xx.h>
Arnd Bergmannec2a0832012-08-24 15:11:34 +020014#include <linux/platform_data/usb-davinci.h>
David Brownellcece6e52008-09-07 23:41:57 -070015
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040016#define DAVINCI_USB_OTG_BASE 0x01c64000
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +040017
18#define DA8XX_USB0_BASE 0x01e00000
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040019#define DA8XX_USB1_BASE 0x01e25000
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050020
David Brownellcece6e52008-09-07 23:41:57 -070021#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
22static struct musb_hdrc_eps_bits musb_eps[] = {
23 { "ep1_tx", 8, },
24 { "ep1_rx", 8, },
25 { "ep2_tx", 8, },
26 { "ep2_rx", 8, },
27 { "ep3_tx", 5, },
28 { "ep3_rx", 5, },
29 { "ep4_tx", 5, },
30 { "ep4_rx", 5, },
31};
32
33static struct musb_hdrc_config musb_config = {
34 .multipoint = true,
35 .dyn_fifo = true,
36 .soft_con = true,
37 .dma = true,
38
39 .num_eps = 5,
40 .dma_channels = 8,
41 .ram_bits = 10,
42 .eps_bits = musb_eps,
43};
44
45static struct musb_hdrc_platform_data usb_data = {
David Brownellcece6e52008-09-07 23:41:57 -070046 /* OTG requires a Mini-AB connector */
47 .mode = MUSB_OTG,
David Brownell34f32c92009-02-20 13:45:17 -080048 .clock = "usb",
David Brownellcece6e52008-09-07 23:41:57 -070049 .config = &musb_config,
50};
51
52static struct resource usb_resources[] = {
53 {
54 /* physical address */
55 .start = DAVINCI_USB_OTG_BASE,
56 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
57 .flags = IORESOURCE_MEM,
58 },
59 {
60 .start = IRQ_USBINT,
61 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050062 .name = "mc"
David Brownellcece6e52008-09-07 23:41:57 -070063 },
Sergei Shtylyovefd91182009-07-16 19:58:53 +040064 {
65 /* placeholder for the dedicated CPPI IRQ */
66 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050067 .name = "dma"
Sergei Shtylyovefd91182009-07-16 19:58:53 +040068 },
David Brownellcece6e52008-09-07 23:41:57 -070069};
70
Yang Hongyang284901a2009-04-06 19:01:15 -070071static u64 usb_dmamask = DMA_BIT_MASK(32);
David Brownellcece6e52008-09-07 23:41:57 -070072
73static struct platform_device usb_dev = {
Felipe Balbi73b089b2010-12-02 09:16:55 +020074 .name = "musb-davinci",
David Brownellcece6e52008-09-07 23:41:57 -070075 .id = -1,
76 .dev = {
77 .platform_data = &usb_data,
78 .dma_mask = &usb_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -070079 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownellcece6e52008-09-07 23:41:57 -070080 },
81 .resource = usb_resources,
82 .num_resources = ARRAY_SIZE(usb_resources),
83};
84
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040085void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070086{
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040087 usb_data.power = mA > 510 ? 255 : mA / 2;
88 usb_data.potpgt = (potpgt_ms + 1) / 2;
Sergei Shtylyovefd91182009-07-16 19:58:53 +040089
90 if (cpu_is_davinci_dm646x()) {
91 /* Override the defaults as DM6467 uses different IRQs. */
92 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
93 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
94 } else /* other devices don't have dedicated CPPI IRQ */
95 usb_dev.num_resources = 2;
96
David Brownellcece6e52008-09-07 23:41:57 -070097 platform_device_register(&usb_dev);
98}
99
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400100#ifdef CONFIG_ARCH_DAVINCI_DA8XX
101static struct resource da8xx_usb20_resources[] = {
102 {
103 .start = DA8XX_USB0_BASE,
104 .end = DA8XX_USB0_BASE + SZ_64K - 1,
105 .flags = IORESOURCE_MEM,
106 },
107 {
108 .start = IRQ_DA8XX_USB_INT,
109 .flags = IORESOURCE_IRQ,
Sergei Shtylyov5a166f42010-12-10 20:23:06 +0300110 .name = "mc",
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400111 },
112};
113
114int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
115{
116 usb_data.clock = "usb20";
117 usb_data.power = mA > 510 ? 255 : mA / 2;
118 usb_data.potpgt = (potpgt + 1) / 2;
119
120 usb_dev.resource = da8xx_usb20_resources;
121 usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources);
Felipe Balbi8ceae512010-12-02 09:19:35 +0200122 usb_dev.name = "musb-da8xx";
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400123
124 return platform_device_register(&usb_dev);
125}
126#endif /* CONFIG_DAVINCI_DA8XX */
127
David Brownellcece6e52008-09-07 23:41:57 -0700128#else
129
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +0400130void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -0700131{
132}
133
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +0400134#ifdef CONFIG_ARCH_DAVINCI_DA8XX
135int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
136{
137 return 0;
138}
139#endif
140
David Brownellcece6e52008-09-07 23:41:57 -0700141#endif /* CONFIG_USB_MUSB_HDRC */
142
Sergei Shtylyove5d3d252009-09-25 23:14:02 +0400143#ifdef CONFIG_ARCH_DAVINCI_DA8XX
144static struct resource da8xx_usb11_resources[] = {
145 [0] = {
146 .start = DA8XX_USB1_BASE,
147 .end = DA8XX_USB1_BASE + SZ_4K - 1,
148 .flags = IORESOURCE_MEM,
149 },
150 [1] = {
151 .start = IRQ_DA8XX_IRQN,
152 .end = IRQ_DA8XX_IRQN,
153 .flags = IORESOURCE_IRQ,
154 },
155};
156
157static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
158
159static struct platform_device da8xx_usb11_device = {
160 .name = "ohci",
161 .id = 0,
162 .dev = {
163 .dma_mask = &da8xx_usb11_dma_mask,
164 .coherent_dma_mask = DMA_BIT_MASK(32),
165 },
166 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
167 .resource = da8xx_usb11_resources,
168};
169
170int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
171{
172 da8xx_usb11_device.dev.platform_data = pdata;
173 return platform_device_register(&da8xx_usb11_device);
174}
175#endif /* CONFIG_DAVINCI_DA8XX */