blob: fe182a85159cdc6e3ef8d6e549cd5760bb648fd9 [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>
15
16#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
17static struct musb_hdrc_eps_bits musb_eps[] = {
18 { "ep1_tx", 8, },
19 { "ep1_rx", 8, },
20 { "ep2_tx", 8, },
21 { "ep2_rx", 8, },
22 { "ep3_tx", 5, },
23 { "ep3_rx", 5, },
24 { "ep4_tx", 5, },
25 { "ep4_rx", 5, },
26};
27
28static struct musb_hdrc_config musb_config = {
29 .multipoint = true,
30 .dyn_fifo = true,
31 .soft_con = true,
32 .dma = true,
33
34 .num_eps = 5,
35 .dma_channels = 8,
36 .ram_bits = 10,
37 .eps_bits = musb_eps,
38};
39
40static struct musb_hdrc_platform_data usb_data = {
41#if defined(CONFIG_USB_MUSB_OTG)
42 /* OTG requires a Mini-AB connector */
43 .mode = MUSB_OTG,
44#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
45 .mode = MUSB_PERIPHERAL,
46#elif defined(CONFIG_USB_MUSB_HOST)
47 .mode = MUSB_HOST,
48#endif
49 .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,
62 },
63};
64
65static u64 usb_dmamask = DMA_32BIT_MASK;
66
67static struct platform_device usb_dev = {
68 .name = "musb_hdrc",
69 .id = -1,
70 .dev = {
71 .platform_data = &usb_data,
72 .dma_mask = &usb_dmamask,
73 .coherent_dma_mask = DMA_32BIT_MASK,
74 },
75 .resource = usb_resources,
76 .num_resources = ARRAY_SIZE(usb_resources),
77};
78
79#ifdef CONFIG_USB_MUSB_OTG
80
81static struct otg_transceiver *xceiv;
82
83struct otg_transceiver *otg_get_transceiver(void)
84{
85 if (xceiv)
86 get_device(xceiv->dev);
87 return xceiv;
88}
89EXPORT_SYMBOL(otg_get_transceiver);
90
91int otg_set_transceiver(struct otg_transceiver *x)
92{
93 if (xceiv && x)
94 return -EBUSY;
95 xceiv = x;
96 return 0;
97}
98EXPORT_SYMBOL(otg_set_transceiver);
99
100#endif
101
102void __init setup_usb(unsigned mA, unsigned potpgt_msec)
103{
104 usb_data.power = mA / 2;
105 usb_data.potpgt = potpgt_msec / 2;
106 platform_device_register(&usb_dev);
107}
108
109#else
110
111void __init setup_usb(unsigned mA, unsigned potpgt_msec)
112{
113}
114
115#endif /* CONFIG_USB_MUSB_HDRC */
116