blob: 0e7e89c1f3313f728b8a8bd788e6690c939ef13e [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
Lad, Prabhakara0a56db2013-04-01 12:43:44 +053017#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
David Brownellcece6e52008-09-07 23:41:57 -070018static struct musb_hdrc_config musb_config = {
19 .multipoint = true,
David Brownellcece6e52008-09-07 23:41:57 -070020
21 .num_eps = 5,
David Brownellcece6e52008-09-07 23:41:57 -070022 .ram_bits = 10,
David Brownellcece6e52008-09-07 23:41:57 -070023};
24
25static struct musb_hdrc_platform_data usb_data = {
David Brownellcece6e52008-09-07 23:41:57 -070026 /* OTG requires a Mini-AB connector */
27 .mode = MUSB_OTG,
David Brownell34f32c92009-02-20 13:45:17 -080028 .clock = "usb",
David Brownellcece6e52008-09-07 23:41:57 -070029 .config = &musb_config,
30};
31
32static struct resource usb_resources[] = {
33 {
34 /* physical address */
35 .start = DAVINCI_USB_OTG_BASE,
36 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
37 .flags = IORESOURCE_MEM,
38 },
39 {
40 .start = IRQ_USBINT,
41 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050042 .name = "mc"
David Brownellcece6e52008-09-07 23:41:57 -070043 },
Sergei Shtylyovefd91182009-07-16 19:58:53 +040044 {
45 /* placeholder for the dedicated CPPI IRQ */
46 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050047 .name = "dma"
Sergei Shtylyovefd91182009-07-16 19:58:53 +040048 },
David Brownellcece6e52008-09-07 23:41:57 -070049};
50
Yang Hongyang284901a2009-04-06 19:01:15 -070051static u64 usb_dmamask = DMA_BIT_MASK(32);
David Brownellcece6e52008-09-07 23:41:57 -070052
53static struct platform_device usb_dev = {
Felipe Balbi73b089b2010-12-02 09:16:55 +020054 .name = "musb-davinci",
David Brownellcece6e52008-09-07 23:41:57 -070055 .id = -1,
56 .dev = {
57 .platform_data = &usb_data,
58 .dma_mask = &usb_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -070059 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownellcece6e52008-09-07 23:41:57 -070060 },
61 .resource = usb_resources,
62 .num_resources = ARRAY_SIZE(usb_resources),
63};
64
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040065void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070066{
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040067 usb_data.power = mA > 510 ? 255 : mA / 2;
68 usb_data.potpgt = (potpgt_ms + 1) / 2;
Sergei Shtylyovefd91182009-07-16 19:58:53 +040069
70 if (cpu_is_davinci_dm646x()) {
71 /* Override the defaults as DM6467 uses different IRQs. */
72 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
73 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
74 } else /* other devices don't have dedicated CPPI IRQ */
75 usb_dev.num_resources = 2;
76
David Brownellcece6e52008-09-07 23:41:57 -070077 platform_device_register(&usb_dev);
78}
79
80#else
81
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040082void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070083{
84}
85
86#endif /* CONFIG_USB_MUSB_HDRC */