1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/init.h>
6 #include <linux/platform_device.h>
7 #include <linux/dma-mapping.h>
9 #include <linux/usb/musb.h>
11 #include <mach/common.h>
12 #include <mach/irqs.h>
13 #include <mach/cputype.h>
14 #include <linux/platform_data/usb-davinci.h>
16 #define DAVINCI_USB_OTG_BASE 0x01c64000
18 #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
19 static struct musb_hdrc_config musb_config = {
26 static struct musb_hdrc_platform_data usb_data = {
27 /* OTG requires a Mini-AB connector */
30 .config = &musb_config,
33 static struct resource usb_resources[] = {
35 /* physical address */
36 .start = DAVINCI_USB_OTG_BASE,
37 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
38 .flags = IORESOURCE_MEM,
42 .flags = IORESOURCE_IRQ,
46 /* placeholder for the dedicated CPPI IRQ */
47 .flags = IORESOURCE_IRQ,
52 static u64 usb_dmamask = DMA_BIT_MASK(32);
54 static struct platform_device usb_dev = {
55 .name = "musb-davinci",
58 .platform_data = &usb_data,
59 .dma_mask = &usb_dmamask,
60 .coherent_dma_mask = DMA_BIT_MASK(32),
62 .resource = usb_resources,
63 .num_resources = ARRAY_SIZE(usb_resources),
66 void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
68 usb_data.power = mA > 510 ? 255 : mA / 2;
69 usb_data.potpgt = (potpgt_ms + 1) / 2;
71 if (cpu_is_davinci_dm646x()) {
72 /* Override the defaults as DM6467 uses different IRQs. */
73 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
74 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
75 } else /* other devices don't have dedicated CPPI IRQ */
76 usb_dev.num_resources = 2;
78 platform_device_register(&usb_dev);
83 void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
87 #endif /* CONFIG_USB_MUSB_HDRC */