diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2008-09-08 02:41:57 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@deeprootsystems.com> | 2008-09-17 03:31:42 -0400 |
commit | cece6e5af23815ae4cfa6d3dab1303f80b42feef (patch) | |
tree | bf548c083f0349fa26f0ad9452aed0445377ff86 /arch/arm | |
parent | d395e6ad98912b52a299999ab667de9a1f393c91 (diff) |
ARM: DaVinci: usb setup
Declare the musb_hdrc platform device for DaVinci.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-davinci/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/common.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-davinci/usb.c | 116 |
3 files changed, 120 insertions, 1 deletions
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index bddfbb717064..4dc458597f40 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | # Common objects | 6 | # Common objects |
7 | obj-y := time.o irq.o clock.o serial.o io.o id.o psc.o \ | 7 | obj-y := time.o irq.o clock.o serial.o io.o id.o psc.o \ |
8 | gpio.o mux.o devices.o | 8 | gpio.o mux.o devices.o usb.o |
9 | 9 | ||
10 | # Board specific | 10 | # Board specific |
11 | obj-$(CONFIG_MACH_DAVINCI_EVM) += board-evm.o | 11 | obj-$(CONFIG_MACH_DAVINCI_EVM) += board-evm.o |
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h index a97dfbb15e57..4b522e5c70ec 100644 --- a/arch/arm/mach-davinci/include/mach/common.h +++ b/arch/arm/mach-davinci/include/mach/common.h | |||
@@ -16,4 +16,7 @@ struct sys_timer; | |||
16 | 16 | ||
17 | extern struct sys_timer davinci_timer; | 17 | extern struct sys_timer davinci_timer; |
18 | 18 | ||
19 | /* parameters describe VBUS sourcing for host mode */ | ||
20 | extern void setup_usb(unsigned mA, unsigned potpgt_msec); | ||
21 | |||
19 | #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */ | 22 | #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */ |
diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c new file mode 100644 index 000000000000..fe182a85159c --- /dev/null +++ b/arch/arm/mach-davinci/usb.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
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) | ||
17 | static 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 | |||
28 | static 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 | |||
40 | static 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 | |||
52 | static 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 | |||
65 | static u64 usb_dmamask = DMA_32BIT_MASK; | ||
66 | |||
67 | static 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 | |||
81 | static struct otg_transceiver *xceiv; | ||
82 | |||
83 | struct otg_transceiver *otg_get_transceiver(void) | ||
84 | { | ||
85 | if (xceiv) | ||
86 | get_device(xceiv->dev); | ||
87 | return xceiv; | ||
88 | } | ||
89 | EXPORT_SYMBOL(otg_get_transceiver); | ||
90 | |||
91 | int otg_set_transceiver(struct otg_transceiver *x) | ||
92 | { | ||
93 | if (xceiv && x) | ||
94 | return -EBUSY; | ||
95 | xceiv = x; | ||
96 | return 0; | ||
97 | } | ||
98 | EXPORT_SYMBOL(otg_set_transceiver); | ||
99 | |||
100 | #endif | ||
101 | |||
102 | void __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 | |||
111 | void __init setup_usb(unsigned mA, unsigned potpgt_msec) | ||
112 | { | ||
113 | } | ||
114 | |||
115 | #endif /* CONFIG_USB_MUSB_HDRC */ | ||
116 | |||