4 #include <linux/init.h>
5 #include <linux/platform_device.h>
6 #include <linux/dma-mapping.h>
8 #include <linux/usb/musb.h>
10 #include <mach/common.h>
11 #include <mach/irqs.h>
12 #include <mach/cputype.h>
15 #define DAVINCI_USB_OTG_BASE 0x01c64000
17 #define DA8XX_USB0_BASE 0x01e00000
18 #define DA8XX_USB1_BASE 0x01e25000
20 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
21 static struct musb_hdrc_eps_bits musb_eps
[] = {
32 static struct musb_hdrc_config musb_config
= {
44 static struct musb_hdrc_platform_data usb_data
= {
45 #if defined(CONFIG_USB_MUSB_OTG)
46 /* OTG requires a Mini-AB connector */
48 #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
49 .mode
= MUSB_PERIPHERAL
,
50 #elif defined(CONFIG_USB_MUSB_HOST)
54 .config
= &musb_config
,
57 static struct resource usb_resources
[] = {
59 /* physical address */
60 .start
= DAVINCI_USB_OTG_BASE
,
61 .end
= DAVINCI_USB_OTG_BASE
+ 0x5ff,
62 .flags
= IORESOURCE_MEM
,
66 .flags
= IORESOURCE_IRQ
,
70 /* placeholder for the dedicated CPPI IRQ */
71 .flags
= IORESOURCE_IRQ
,
76 static u64 usb_dmamask
= DMA_BIT_MASK(32);
78 static struct platform_device usb_dev
= {
79 .name
= "musb-davinci",
82 .platform_data
= &usb_data
,
83 .dma_mask
= &usb_dmamask
,
84 .coherent_dma_mask
= DMA_BIT_MASK(32),
86 .resource
= usb_resources
,
87 .num_resources
= ARRAY_SIZE(usb_resources
),
90 void __init
davinci_setup_usb(unsigned mA
, unsigned potpgt_ms
)
92 usb_data
.power
= mA
> 510 ? 255 : mA
/ 2;
93 usb_data
.potpgt
= (potpgt_ms
+ 1) / 2;
95 if (cpu_is_davinci_dm646x()) {
96 /* Override the defaults as DM6467 uses different IRQs. */
97 usb_dev
.resource
[1].start
= IRQ_DM646X_USBINT
;
98 usb_dev
.resource
[2].start
= IRQ_DM646X_USBDMAINT
;
99 } else /* other devices don't have dedicated CPPI IRQ */
100 usb_dev
.num_resources
= 2;
102 platform_device_register(&usb_dev
);
105 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
106 static struct resource da8xx_usb20_resources
[] = {
108 .start
= DA8XX_USB0_BASE
,
109 .end
= DA8XX_USB0_BASE
+ SZ_64K
- 1,
110 .flags
= IORESOURCE_MEM
,
113 .start
= IRQ_DA8XX_USB_INT
,
114 .flags
= IORESOURCE_IRQ
,
119 int __init
da8xx_register_usb20(unsigned mA
, unsigned potpgt
)
121 usb_data
.clock
= "usb20";
122 usb_data
.power
= mA
> 510 ? 255 : mA
/ 2;
123 usb_data
.potpgt
= (potpgt
+ 1) / 2;
125 usb_dev
.resource
= da8xx_usb20_resources
;
126 usb_dev
.num_resources
= ARRAY_SIZE(da8xx_usb20_resources
);
127 usb_dev
.name
= "musb-da8xx";
129 return platform_device_register(&usb_dev
);
131 #endif /* CONFIG_DAVINCI_DA8XX */
135 void __init
davinci_setup_usb(unsigned mA
, unsigned potpgt_ms
)
139 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
140 int __init
da8xx_register_usb20(unsigned mA
, unsigned potpgt
)
146 #endif /* CONFIG_USB_MUSB_HDRC */
148 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
149 static struct resource da8xx_usb11_resources
[] = {
151 .start
= DA8XX_USB1_BASE
,
152 .end
= DA8XX_USB1_BASE
+ SZ_4K
- 1,
153 .flags
= IORESOURCE_MEM
,
156 .start
= IRQ_DA8XX_IRQN
,
157 .end
= IRQ_DA8XX_IRQN
,
158 .flags
= IORESOURCE_IRQ
,
162 static u64 da8xx_usb11_dma_mask
= DMA_BIT_MASK(32);
164 static struct platform_device da8xx_usb11_device
= {
168 .dma_mask
= &da8xx_usb11_dma_mask
,
169 .coherent_dma_mask
= DMA_BIT_MASK(32),
171 .num_resources
= ARRAY_SIZE(da8xx_usb11_resources
),
172 .resource
= da8xx_usb11_resources
,
175 int __init
da8xx_register_usb11(struct da8xx_ohci_root_hub
*pdata
)
177 da8xx_usb11_device
.dev
.platform_data
= pdata
;
178 return platform_device_register(&da8xx_usb11_device
);
180 #endif /* CONFIG_DAVINCI_DA8XX */