blob: 69680784448a20a259f96ef059e2c4c375b0ea17 [file] [log] [blame]
David Brownellcece6e52008-09-07 23:41:57 -07001/*
2 * USB
3 */
4#include <linux/kernel.h>
5#include <linux/module.h>
6#include <linux/init.h>
7#include <linux/platform_device.h>
8#include <linux/dma-mapping.h>
9
10#include <linux/usb/musb.h>
11#include <linux/usb/otg.h>
12
13#include <mach/common.h>
14#include <mach/hardware.h>
David Brownelld0e58ae2009-01-18 17:29:10 +010015#include <mach/irqs.h>
David Brownellcece6e52008-09-07 23:41:57 -070016
17#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
18static struct musb_hdrc_eps_bits musb_eps[] = {
19 { "ep1_tx", 8, },
20 { "ep1_rx", 8, },
21 { "ep2_tx", 8, },
22 { "ep2_rx", 8, },
23 { "ep3_tx", 5, },
24 { "ep3_rx", 5, },
25 { "ep4_tx", 5, },
26 { "ep4_rx", 5, },
27};
28
29static struct musb_hdrc_config musb_config = {
30 .multipoint = true,
31 .dyn_fifo = true,
32 .soft_con = true,
33 .dma = true,
34
35 .num_eps = 5,
36 .dma_channels = 8,
37 .ram_bits = 10,
38 .eps_bits = musb_eps,
39};
40
41static struct musb_hdrc_platform_data usb_data = {
42#if defined(CONFIG_USB_MUSB_OTG)
43 /* OTG requires a Mini-AB connector */
44 .mode = MUSB_OTG,
45#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
46 .mode = MUSB_PERIPHERAL,
47#elif defined(CONFIG_USB_MUSB_HOST)
48 .mode = MUSB_HOST,
49#endif
David Brownell34f32c92009-02-20 13:45:17 -080050 .clock = "usb",
David Brownellcece6e52008-09-07 23:41:57 -070051 .config = &musb_config,
52};
53
54static struct resource usb_resources[] = {
55 {
56 /* physical address */
57 .start = DAVINCI_USB_OTG_BASE,
58 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
59 .flags = IORESOURCE_MEM,
60 },
61 {
62 .start = IRQ_USBINT,
63 .flags = IORESOURCE_IRQ,
64 },
65};
66
67static u64 usb_dmamask = DMA_32BIT_MASK;
68
69static struct platform_device usb_dev = {
70 .name = "musb_hdrc",
71 .id = -1,
72 .dev = {
73 .platform_data = &usb_data,
74 .dma_mask = &usb_dmamask,
75 .coherent_dma_mask = DMA_32BIT_MASK,
76 },
77 .resource = usb_resources,
78 .num_resources = ARRAY_SIZE(usb_resources),
79};
80
David Brownellcece6e52008-09-07 23:41:57 -070081void __init setup_usb(unsigned mA, unsigned potpgt_msec)
82{
83 usb_data.power = mA / 2;
84 usb_data.potpgt = potpgt_msec / 2;
85 platform_device_register(&usb_dev);
86}
87
88#else
89
90void __init setup_usb(unsigned mA, unsigned potpgt_msec)
91{
92}
93
94#endif /* CONFIG_USB_MUSB_HDRC */
95