aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/usb-musb.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/usb-musb.c')
-rw-r--r--arch/arm/mach-omap2/usb-musb.c138
1 files changed, 102 insertions, 36 deletions
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 33a5cde1c227..c7ed540d868d 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -28,23 +28,12 @@
28 28
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <mach/irqs.h> 30#include <mach/irqs.h>
31#include <mach/am35xx.h>
31#include <plat/usb.h> 32#include <plat/usb.h>
33#include <plat/omap_device.h>
34#include "mux.h"
32 35
33#ifdef CONFIG_USB_MUSB_SOC 36#if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined (CONFIG_USB_MUSB_AM35X)
34
35static struct resource musb_resources[] = {
36 [0] = { /* start and end set dynamically */
37 .flags = IORESOURCE_MEM,
38 },
39 [1] = { /* general IRQ */
40 .start = INT_243X_HS_USB_MC,
41 .flags = IORESOURCE_IRQ,
42 },
43 [2] = { /* DMA IRQ */
44 .start = INT_243X_HS_USB_DMA,
45 .flags = IORESOURCE_IRQ,
46 },
47};
48 37
49static struct musb_hdrc_config musb_config = { 38static struct musb_hdrc_config musb_config = {
50 .multipoint = 1, 39 .multipoint = 1,
@@ -73,30 +62,72 @@ static struct musb_hdrc_platform_data musb_plat = {
73 62
74static u64 musb_dmamask = DMA_BIT_MASK(32); 63static u64 musb_dmamask = DMA_BIT_MASK(32);
75 64
76static struct platform_device musb_device = { 65static struct omap_device_pm_latency omap_musb_latency[] = {
77 .name = "musb_hdrc", 66 {
78 .id = -1, 67 .deactivate_func = omap_device_idle_hwmods,
79 .dev = { 68 .activate_func = omap_device_enable_hwmods,
80 .dma_mask = &musb_dmamask, 69 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
81 .coherent_dma_mask = DMA_BIT_MASK(32),
82 .platform_data = &musb_plat,
83 }, 70 },
84 .num_resources = ARRAY_SIZE(musb_resources),
85 .resource = musb_resources,
86}; 71};
87 72
88void __init usb_musb_init(struct omap_musb_board_data *board_data) 73static void usb_musb_mux_init(struct omap_musb_board_data *board_data)
89{ 74{
90 if (cpu_is_omap243x()) { 75 switch (board_data->interface_type) {
91 musb_resources[0].start = OMAP243X_HS_BASE; 76 case MUSB_INTERFACE_UTMI:
92 } else if (cpu_is_omap34xx()) { 77 omap_mux_init_signal("usba0_otg_dp", OMAP_PIN_INPUT);
93 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE; 78 omap_mux_init_signal("usba0_otg_dm", OMAP_PIN_INPUT);
94 } else if (cpu_is_omap44xx()) { 79 break;
95 musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE; 80 case MUSB_INTERFACE_ULPI:
96 musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N; 81 omap_mux_init_signal("usba0_ulpiphy_clk",
97 musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N; 82 OMAP_PIN_INPUT_PULLDOWN);
83 omap_mux_init_signal("usba0_ulpiphy_stp",
84 OMAP_PIN_INPUT_PULLDOWN);
85 omap_mux_init_signal("usba0_ulpiphy_dir",
86 OMAP_PIN_INPUT_PULLDOWN);
87 omap_mux_init_signal("usba0_ulpiphy_nxt",
88 OMAP_PIN_INPUT_PULLDOWN);
89 omap_mux_init_signal("usba0_ulpiphy_dat0",
90 OMAP_PIN_INPUT_PULLDOWN);
91 omap_mux_init_signal("usba0_ulpiphy_dat1",
92 OMAP_PIN_INPUT_PULLDOWN);
93 omap_mux_init_signal("usba0_ulpiphy_dat2",
94 OMAP_PIN_INPUT_PULLDOWN);
95 omap_mux_init_signal("usba0_ulpiphy_dat3",
96 OMAP_PIN_INPUT_PULLDOWN);
97 omap_mux_init_signal("usba0_ulpiphy_dat4",
98 OMAP_PIN_INPUT_PULLDOWN);
99 omap_mux_init_signal("usba0_ulpiphy_dat5",
100 OMAP_PIN_INPUT_PULLDOWN);
101 omap_mux_init_signal("usba0_ulpiphy_dat6",
102 OMAP_PIN_INPUT_PULLDOWN);
103 omap_mux_init_signal("usba0_ulpiphy_dat7",
104 OMAP_PIN_INPUT_PULLDOWN);
105 break;
106 default:
107 break;
98 } 108 }
99 musb_resources[0].end = musb_resources[0].start + SZ_4K - 1; 109}
110
111static struct omap_musb_board_data musb_default_board_data = {
112 .interface_type = MUSB_INTERFACE_ULPI,
113 .mode = MUSB_OTG,
114 .power = 100,
115};
116
117void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
118{
119 struct omap_hwmod *oh;
120 struct omap_device *od;
121 struct platform_device *pdev;
122 struct device *dev;
123 int bus_id = -1;
124 const char *oh_name, *name;
125 struct omap_musb_board_data *board_data;
126
127 if (musb_board_data)
128 board_data = musb_board_data;
129 else
130 board_data = &musb_default_board_data;
100 131
101 /* 132 /*
102 * REVISIT: This line can be removed once all the platforms using 133 * REVISIT: This line can be removed once all the platforms using
@@ -108,12 +139,47 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
108 musb_plat.mode = board_data->mode; 139 musb_plat.mode = board_data->mode;
109 musb_plat.extvbus = board_data->extvbus; 140 musb_plat.extvbus = board_data->extvbus;
110 141
111 if (platform_device_register(&musb_device) < 0) 142 if (cpu_is_omap44xx())
112 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n"); 143 omap4430_phy_init(dev);
144
145 if (cpu_is_omap3517() || cpu_is_omap3505()) {
146 oh_name = "am35x_otg_hs";
147 name = "musb-am35x";
148 } else {
149 oh_name = "usb_otg_hs";
150 name = "musb-omap2430";
151 }
152
153 oh = omap_hwmod_lookup(oh_name);
154 if (!oh) {
155 pr_err("Could not look up %s\n", oh_name);
156 return;
157 }
158
159 od = omap_device_build(name, bus_id, oh, &musb_plat,
160 sizeof(musb_plat), omap_musb_latency,
161 ARRAY_SIZE(omap_musb_latency), false);
162 if (IS_ERR(od)) {
163 pr_err("Could not build omap_device for %s %s\n",
164 name, oh_name);
165 return;
166 }
167
168 pdev = &od->pdev;
169 dev = &pdev->dev;
170 get_device(dev);
171 dev->dma_mask = &musb_dmamask;
172 dev->coherent_dma_mask = musb_dmamask;
173 put_device(dev);
174
175 if (cpu_is_omap44xx())
176 omap4430_phy_init(dev);
113} 177}
114 178
115#else 179#else
116void __init usb_musb_init(struct omap_musb_board_data *board_data) 180void __init usb_musb_init(struct omap_musb_board_data *board_data)
117{ 181{
182 if (cpu_is_omap44xx())
183 omap4430_phy_init(NULL);
118} 184}
119#endif /* CONFIG_USB_MUSB_SOC */ 185#endif /* CONFIG_USB_MUSB_SOC */