diff options
author | Felipe Balbi <balbi@ti.com> | 2010-12-01 06:22:05 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2010-12-07 02:19:39 -0500 |
commit | 743411b3f3e96e8ac4cae73551a0a95392fed1ea (patch) | |
tree | 485f2f1f92768df7b1cc2d44cf3b8d4cc3cdaf3b | |
parent | 3ca8abb84522f4b773678726db6ebd6fc277bc96 (diff) |
usb: musb: make all glue layer export struct musb_platform_ops
preparing to a big refactor on musb code. We need
to be able to compile in all glue layers (or at
least all ARM-based ones) together and have a
working binary.
While preparing for that, we move every glue
layer to export only one symbol, which is
a struct musb_platform_ops, and make all
other functions static.
Later patches will come to allow for compiling
all glue layers together and have a working
binary.
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/musb/am35x.c | 37 | ||||
-rw-r--r-- | drivers/usb/musb/blackfin.c | 106 | ||||
-rw-r--r-- | drivers/usb/musb/da8xx.c | 37 | ||||
-rw-r--r-- | drivers/usb/musb/davinci.c | 40 | ||||
-rw-r--r-- | drivers/usb/musb/musb_core.c | 8 | ||||
-rw-r--r-- | drivers/usb/musb/musb_core.h | 174 | ||||
-rw-r--r-- | drivers/usb/musb/musb_virthub.c | 2 | ||||
-rw-r--r-- | drivers/usb/musb/omap2430.c | 46 | ||||
-rw-r--r-- | drivers/usb/musb/tusb6010.c | 62 |
9 files changed, 335 insertions, 177 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index b0aabf3a606f..be17610d7fc2 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -122,9 +122,9 @@ static inline void phy_off(void) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * musb_platform_enable - enable interrupts | 125 | * am35x_musb_enable - enable interrupts |
126 | */ | 126 | */ |
127 | void musb_platform_enable(struct musb *musb) | 127 | static void am35x_musb_enable(struct musb *musb) |
128 | { | 128 | { |
129 | void __iomem *reg_base = musb->ctrl_base; | 129 | void __iomem *reg_base = musb->ctrl_base; |
130 | u32 epmask; | 130 | u32 epmask; |
@@ -143,9 +143,9 @@ void musb_platform_enable(struct musb *musb) | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /* | 145 | /* |
146 | * musb_platform_disable - disable HDRC and flush interrupts | 146 | * am35x_musb_disable - disable HDRC and flush interrupts |
147 | */ | 147 | */ |
148 | void musb_platform_disable(struct musb *musb) | 148 | static void am35x_musb_disable(struct musb *musb) |
149 | { | 149 | { |
150 | void __iomem *reg_base = musb->ctrl_base; | 150 | void __iomem *reg_base = musb->ctrl_base; |
151 | 151 | ||
@@ -162,7 +162,7 @@ void musb_platform_disable(struct musb *musb) | |||
162 | #define portstate(stmt) | 162 | #define portstate(stmt) |
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | static void am35x_set_vbus(struct musb *musb, int is_on) | 165 | static void am35x_musb_set_vbus(struct musb *musb, int is_on) |
166 | { | 166 | { |
167 | WARN_ON(is_on && is_peripheral_active(musb)); | 167 | WARN_ON(is_on && is_peripheral_active(musb)); |
168 | } | 168 | } |
@@ -221,7 +221,7 @@ static void otg_timer(unsigned long _musb) | |||
221 | spin_unlock_irqrestore(&musb->lock, flags); | 221 | spin_unlock_irqrestore(&musb->lock, flags); |
222 | } | 222 | } |
223 | 223 | ||
224 | void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | 224 | static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout) |
225 | { | 225 | { |
226 | static unsigned long last_timer; | 226 | static unsigned long last_timer; |
227 | 227 | ||
@@ -251,7 +251,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | |||
251 | mod_timer(&otg_workaround, timeout); | 251 | mod_timer(&otg_workaround, timeout); |
252 | } | 252 | } |
253 | 253 | ||
254 | static irqreturn_t am35x_interrupt(int irq, void *hci) | 254 | static irqreturn_t am35x_musb_interrupt(int irq, void *hci) |
255 | { | 255 | { |
256 | struct musb *musb = hci; | 256 | struct musb *musb = hci; |
257 | void __iomem *reg_base = musb->ctrl_base; | 257 | void __iomem *reg_base = musb->ctrl_base; |
@@ -362,7 +362,7 @@ eoi: | |||
362 | return ret; | 362 | return ret; |
363 | } | 363 | } |
364 | 364 | ||
365 | int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | 365 | static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) |
366 | { | 366 | { |
367 | u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); | 367 | u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); |
368 | 368 | ||
@@ -391,7 +391,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | |||
391 | return 0; | 391 | return 0; |
392 | } | 392 | } |
393 | 393 | ||
394 | int __init musb_platform_init(struct musb *musb, void *board_data) | 394 | static int am35x_musb_init(struct musb *musb) |
395 | { | 395 | { |
396 | void __iomem *reg_base = musb->ctrl_base; | 396 | void __iomem *reg_base = musb->ctrl_base; |
397 | u32 rev, lvl_intr, sw_reset; | 397 | u32 rev, lvl_intr, sw_reset; |
@@ -427,7 +427,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
427 | if (is_host_enabled(musb)) | 427 | if (is_host_enabled(musb)) |
428 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); | 428 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); |
429 | 429 | ||
430 | musb->board_set_vbus = am35x_set_vbus; | 430 | musb->board_set_vbus = am35x_musb_set_vbus; |
431 | 431 | ||
432 | /* Global reset */ | 432 | /* Global reset */ |
433 | sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); | 433 | sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); |
@@ -446,7 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
446 | 446 | ||
447 | msleep(5); | 447 | msleep(5); |
448 | 448 | ||
449 | musb->isr = am35x_interrupt; | 449 | musb->isr = am35x_musb_interrupt; |
450 | 450 | ||
451 | /* clear level interrupt */ | 451 | /* clear level interrupt */ |
452 | lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); | 452 | lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); |
@@ -461,7 +461,7 @@ exit0: | |||
461 | return status; | 461 | return status; |
462 | } | 462 | } |
463 | 463 | ||
464 | int musb_platform_exit(struct musb *musb) | 464 | static int am35x_musb_exit(struct musb *musb) |
465 | { | 465 | { |
466 | if (is_host_enabled(musb)) | 466 | if (is_host_enabled(musb)) |
467 | del_timer_sync(&otg_workaround); | 467 | del_timer_sync(&otg_workaround); |
@@ -522,3 +522,16 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | |||
522 | memcpy(dst, &val, len); | 522 | memcpy(dst, &val, len); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | |||
526 | const struct musb_platform_ops musb_ops = { | ||
527 | .init = am35x_musb_init, | ||
528 | .exit = am35x_musb_exit, | ||
529 | |||
530 | .enable = am35x_musb_enable, | ||
531 | .disable = am35x_musb_disable, | ||
532 | |||
533 | .set_mode = am35x_musb_set_mode, | ||
534 | .try_idle = am35x_musb_try_idle, | ||
535 | |||
536 | .set_vbus = am35x_musb_set_vbus, | ||
537 | }; | ||
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index e8cbcc59c419..9874501d6429 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -277,7 +277,7 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
277 | DBG(4, "state is %s\n", otg_state_string(musb)); | 277 | DBG(4, "state is %s\n", otg_state_string(musb)); |
278 | } | 278 | } |
279 | 279 | ||
280 | void musb_platform_enable(struct musb *musb) | 280 | static void bfin_musb_enable(struct musb *musb) |
281 | { | 281 | { |
282 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) { | 282 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) { |
283 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | 283 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); |
@@ -285,11 +285,11 @@ void musb_platform_enable(struct musb *musb) | |||
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | void musb_platform_disable(struct musb *musb) | 288 | static void bfin_musb_disable(struct musb *musb) |
289 | { | 289 | { |
290 | } | 290 | } |
291 | 291 | ||
292 | static void bfin_set_vbus(struct musb *musb, int is_on) | 292 | static void bfin_musb_set_vbus(struct musb *musb, int is_on) |
293 | { | 293 | { |
294 | int value = musb->config->gpio_vrsel_active; | 294 | int value = musb->config->gpio_vrsel_active; |
295 | if (!is_on) | 295 | if (!is_on) |
@@ -302,51 +302,29 @@ static void bfin_set_vbus(struct musb *musb, int is_on) | |||
302 | musb_readb(musb->mregs, MUSB_DEVCTL)); | 302 | musb_readb(musb->mregs, MUSB_DEVCTL)); |
303 | } | 303 | } |
304 | 304 | ||
305 | static int bfin_set_power(struct otg_transceiver *x, unsigned mA) | 305 | static int bfin_musb_set_power(struct otg_transceiver *x, unsigned mA) |
306 | { | 306 | { |
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | 309 | ||
310 | void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | 310 | static void bfin_musb_try_idle(struct musb *musb, unsigned long timeout) |
311 | { | 311 | { |
312 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) | 312 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) |
313 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | 313 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); |
314 | } | 314 | } |
315 | 315 | ||
316 | int musb_platform_get_vbus_status(struct musb *musb) | 316 | static int bfin_musb_get_vbus_status(struct musb *musb) |
317 | { | 317 | { |
318 | return 0; | 318 | return 0; |
319 | } | 319 | } |
320 | 320 | ||
321 | int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | 321 | static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode) |
322 | { | 322 | { |
323 | return -EIO; | 323 | return -EIO; |
324 | } | 324 | } |
325 | 325 | ||
326 | int __init musb_platform_init(struct musb *musb) | 326 | static void bfin_musb_reg_init(struct musb *musb) |
327 | { | 327 | { |
328 | |||
329 | /* | ||
330 | * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE | ||
331 | * and OTG HOST modes, while rev 1.1 and greater require PE7 to | ||
332 | * be low for DEVICE mode and high for HOST mode. We set it high | ||
333 | * here because we are in host mode | ||
334 | */ | ||
335 | |||
336 | if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { | ||
337 | printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d \n", | ||
338 | musb->config->gpio_vrsel); | ||
339 | return -ENODEV; | ||
340 | } | ||
341 | gpio_direction_output(musb->config->gpio_vrsel, 0); | ||
342 | |||
343 | usb_nop_xceiv_register(); | ||
344 | musb->xceiv = otg_get_transceiver(); | ||
345 | if (!musb->xceiv) { | ||
346 | gpio_free(musb->config->gpio_vrsel); | ||
347 | return -ENODEV; | ||
348 | } | ||
349 | |||
350 | if (ANOMALY_05000346) { | 328 | if (ANOMALY_05000346) { |
351 | bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); | 329 | bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); |
352 | SSYNC(); | 330 | SSYNC(); |
@@ -380,21 +358,69 @@ int __init musb_platform_init(struct musb *musb) | |||
380 | EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | | 358 | EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | |
381 | EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); | 359 | EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); |
382 | SSYNC(); | 360 | SSYNC(); |
361 | } | ||
362 | |||
363 | static int bfin_musb_init(struct musb *musb) | ||
364 | { | ||
365 | |||
366 | /* | ||
367 | * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE | ||
368 | * and OTG HOST modes, while rev 1.1 and greater require PE7 to | ||
369 | * be low for DEVICE mode and high for HOST mode. We set it high | ||
370 | * here because we are in host mode | ||
371 | */ | ||
372 | |||
373 | if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { | ||
374 | printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n", | ||
375 | musb->config->gpio_vrsel); | ||
376 | return -ENODEV; | ||
377 | } | ||
378 | gpio_direction_output(musb->config->gpio_vrsel, 0); | ||
379 | |||
380 | usb_nop_xceiv_register(); | ||
381 | musb->xceiv = otg_get_transceiver(); | ||
382 | if (!musb->xceiv) { | ||
383 | gpio_free(musb->config->gpio_vrsel); | ||
384 | return -ENODEV; | ||
385 | } | ||
386 | |||
387 | bfin_musb_reg_init(musb); | ||
383 | 388 | ||
384 | if (is_host_enabled(musb)) { | 389 | if (is_host_enabled(musb)) { |
385 | musb->board_set_vbus = bfin_set_vbus; | 390 | musb->board_set_vbus = bfin_musb_set_vbus; |
386 | setup_timer(&musb_conn_timer, | 391 | setup_timer(&musb_conn_timer, |
387 | musb_conn_timer_handler, (unsigned long) musb); | 392 | musb_conn_timer_handler, (unsigned long) musb); |
388 | } | 393 | } |
389 | if (is_peripheral_enabled(musb)) | 394 | if (is_peripheral_enabled(musb)) |
390 | musb->xceiv->set_power = bfin_set_power; | 395 | musb->xceiv->set_power = bfin_musb_set_power; |
391 | 396 | ||
392 | musb->isr = blackfin_interrupt; | 397 | musb->isr = blackfin_interrupt; |
393 | 398 | ||
394 | return 0; | 399 | return 0; |
395 | } | 400 | } |
396 | 401 | ||
397 | int musb_platform_exit(struct musb *musb) | 402 | #ifdef CONFIG_PM |
403 | void musb_platform_save_context(struct musb *musb, | ||
404 | struct musb_context_registers *musb_context) | ||
405 | { | ||
406 | if (is_host_active(musb)) | ||
407 | /* | ||
408 | * During hibernate gpio_vrsel will change from high to low | ||
409 | * low which will generate wakeup event resume the system | ||
410 | * immediately. Set it to 0 before hibernate to avoid this | ||
411 | * wakeup event. | ||
412 | */ | ||
413 | gpio_set_value(musb->config->gpio_vrsel, 0); | ||
414 | } | ||
415 | |||
416 | void musb_platform_restore_context(struct musb *musb, | ||
417 | struct musb_context_registers *musb_context) | ||
418 | { | ||
419 | bfin_musb_reg_init(musb); | ||
420 | } | ||
421 | #endif | ||
422 | |||
423 | static int bfin_musb_exit(struct musb *musb) | ||
398 | { | 424 | { |
399 | gpio_free(musb->config->gpio_vrsel); | 425 | gpio_free(musb->config->gpio_vrsel); |
400 | 426 | ||
@@ -402,3 +428,17 @@ int musb_platform_exit(struct musb *musb) | |||
402 | usb_nop_xceiv_unregister(); | 428 | usb_nop_xceiv_unregister(); |
403 | return 0; | 429 | return 0; |
404 | } | 430 | } |
431 | |||
432 | const struct musb_platform_ops musb_ops = { | ||
433 | .init = bfin_musb_init, | ||
434 | .exit = bfin_musb_exit, | ||
435 | |||
436 | .enable = bfin_musb_enable, | ||
437 | .disable = bfin_musb_disable, | ||
438 | |||
439 | .set_mode = bfin_musb_set_mode, | ||
440 | .try_idle = bfin_musb_try_idle, | ||
441 | |||
442 | .vbus_status = bfin_musb_vbus_status, | ||
443 | .set_vbus = bfin_musb_set_vbus, | ||
444 | }; | ||
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 84427bebbf62..6161fc50d049 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -131,9 +131,9 @@ static inline void phy_off(void) | |||
131 | */ | 131 | */ |
132 | 132 | ||
133 | /** | 133 | /** |
134 | * musb_platform_enable - enable interrupts | 134 | * da8xx_musb_enable - enable interrupts |
135 | */ | 135 | */ |
136 | void musb_platform_enable(struct musb *musb) | 136 | static void da8xx_musb_enable(struct musb *musb) |
137 | { | 137 | { |
138 | void __iomem *reg_base = musb->ctrl_base; | 138 | void __iomem *reg_base = musb->ctrl_base; |
139 | u32 mask; | 139 | u32 mask; |
@@ -151,9 +151,9 @@ void musb_platform_enable(struct musb *musb) | |||
151 | } | 151 | } |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * musb_platform_disable - disable HDRC and flush interrupts | 154 | * da8xx_musb_disable - disable HDRC and flush interrupts |
155 | */ | 155 | */ |
156 | void musb_platform_disable(struct musb *musb) | 156 | static void da8xx_musb_disable(struct musb *musb) |
157 | { | 157 | { |
158 | void __iomem *reg_base = musb->ctrl_base; | 158 | void __iomem *reg_base = musb->ctrl_base; |
159 | 159 | ||
@@ -170,7 +170,7 @@ void musb_platform_disable(struct musb *musb) | |||
170 | #define portstate(stmt) | 170 | #define portstate(stmt) |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | static void da8xx_set_vbus(struct musb *musb, int is_on) | 173 | static void da8xx_musb_set_vbus(struct musb *musb, int is_on) |
174 | { | 174 | { |
175 | WARN_ON(is_on && is_peripheral_active(musb)); | 175 | WARN_ON(is_on && is_peripheral_active(musb)); |
176 | } | 176 | } |
@@ -252,7 +252,7 @@ static void otg_timer(unsigned long _musb) | |||
252 | spin_unlock_irqrestore(&musb->lock, flags); | 252 | spin_unlock_irqrestore(&musb->lock, flags); |
253 | } | 253 | } |
254 | 254 | ||
255 | void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | 255 | static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) |
256 | { | 256 | { |
257 | static unsigned long last_timer; | 257 | static unsigned long last_timer; |
258 | 258 | ||
@@ -282,7 +282,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | |||
282 | mod_timer(&otg_workaround, timeout); | 282 | mod_timer(&otg_workaround, timeout); |
283 | } | 283 | } |
284 | 284 | ||
285 | static irqreturn_t da8xx_interrupt(int irq, void *hci) | 285 | static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) |
286 | { | 286 | { |
287 | struct musb *musb = hci; | 287 | struct musb *musb = hci; |
288 | void __iomem *reg_base = musb->ctrl_base; | 288 | void __iomem *reg_base = musb->ctrl_base; |
@@ -380,7 +380,7 @@ static irqreturn_t da8xx_interrupt(int irq, void *hci) | |||
380 | return ret; | 380 | return ret; |
381 | } | 381 | } |
382 | 382 | ||
383 | int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | 383 | static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) |
384 | { | 384 | { |
385 | u32 cfgchip2 = __raw_readl(CFGCHIP2); | 385 | u32 cfgchip2 = __raw_readl(CFGCHIP2); |
386 | 386 | ||
@@ -409,7 +409,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | |||
409 | return 0; | 409 | return 0; |
410 | } | 410 | } |
411 | 411 | ||
412 | int __init musb_platform_init(struct musb *musb, void *board_data) | 412 | static int da8xx_musb_init(struct musb *musb) |
413 | { | 413 | { |
414 | void __iomem *reg_base = musb->ctrl_base; | 414 | void __iomem *reg_base = musb->ctrl_base; |
415 | u32 rev; | 415 | u32 rev; |
@@ -431,7 +431,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
431 | if (is_host_enabled(musb)) | 431 | if (is_host_enabled(musb)) |
432 | setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); | 432 | setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); |
433 | 433 | ||
434 | musb->board_set_vbus = da8xx_set_vbus; | 434 | musb->board_set_vbus = da8xx_musb_set_vbus; |
435 | 435 | ||
436 | /* Reset the controller */ | 436 | /* Reset the controller */ |
437 | musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); | 437 | musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); |
@@ -446,14 +446,14 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
446 | rev, __raw_readl(CFGCHIP2), | 446 | rev, __raw_readl(CFGCHIP2), |
447 | musb_readb(reg_base, DA8XX_USB_CTRL_REG)); | 447 | musb_readb(reg_base, DA8XX_USB_CTRL_REG)); |
448 | 448 | ||
449 | musb->isr = da8xx_interrupt; | 449 | musb->isr = da8xx_musb_interrupt; |
450 | return 0; | 450 | return 0; |
451 | fail: | 451 | fail: |
452 | clk_disable(musb->clock); | 452 | clk_disable(musb->clock); |
453 | return -ENODEV; | 453 | return -ENODEV; |
454 | } | 454 | } |
455 | 455 | ||
456 | int musb_platform_exit(struct musb *musb) | 456 | static int da8xx_musb_exit(struct musb *musb) |
457 | { | 457 | { |
458 | if (is_host_enabled(musb)) | 458 | if (is_host_enabled(musb)) |
459 | del_timer_sync(&otg_workaround); | 459 | del_timer_sync(&otg_workaround); |
@@ -467,3 +467,16 @@ int musb_platform_exit(struct musb *musb) | |||
467 | 467 | ||
468 | return 0; | 468 | return 0; |
469 | } | 469 | } |
470 | |||
471 | const struct musb_platform_ops musb_ops = { | ||
472 | .init = da8xx_musb_init, | ||
473 | .exit = da8xx_musb_exit, | ||
474 | |||
475 | .enable = da8xx_musb_enable, | ||
476 | .disable = da8xx_musb_disable, | ||
477 | |||
478 | .set_mode = da8xx_musb_set_mode, | ||
479 | .try_idle = da8xx_musb_try_idle, | ||
480 | |||
481 | .set_vbus = da8xx_musb_set_vbus, | ||
482 | }; | ||
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 051e2bf1897a..e283b5af8de0 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -83,7 +83,7 @@ static inline void phy_off(void) | |||
83 | 83 | ||
84 | static int dma_off = 1; | 84 | static int dma_off = 1; |
85 | 85 | ||
86 | void musb_platform_enable(struct musb *musb) | 86 | static void davinci_musb_enable(struct musb *musb) |
87 | { | 87 | { |
88 | u32 tmp, old, val; | 88 | u32 tmp, old, val; |
89 | 89 | ||
@@ -116,7 +116,7 @@ void musb_platform_enable(struct musb *musb) | |||
116 | /* | 116 | /* |
117 | * Disable the HDRC and flush interrupts | 117 | * Disable the HDRC and flush interrupts |
118 | */ | 118 | */ |
119 | void musb_platform_disable(struct musb *musb) | 119 | static void davinci_musb_disable(struct musb *musb) |
120 | { | 120 | { |
121 | /* because we don't set CTRLR.UINT, "important" to: | 121 | /* because we don't set CTRLR.UINT, "important" to: |
122 | * - not read/write INTRUSB/INTRUSBE | 122 | * - not read/write INTRUSB/INTRUSBE |
@@ -167,7 +167,7 @@ static void evm_deferred_drvvbus(struct work_struct *ignored) | |||
167 | 167 | ||
168 | #endif /* EVM */ | 168 | #endif /* EVM */ |
169 | 169 | ||
170 | static void davinci_source_power(struct musb *musb, int is_on, int immediate) | 170 | static void davinci_musb_source_power(struct musb *musb, int is_on, int immediate) |
171 | { | 171 | { |
172 | #ifdef CONFIG_MACH_DAVINCI_EVM | 172 | #ifdef CONFIG_MACH_DAVINCI_EVM |
173 | if (is_on) | 173 | if (is_on) |
@@ -190,10 +190,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) | |||
190 | #endif | 190 | #endif |
191 | } | 191 | } |
192 | 192 | ||
193 | static void davinci_set_vbus(struct musb *musb, int is_on) | 193 | static void davinci_musb_set_vbus(struct musb *musb, int is_on) |
194 | { | 194 | { |
195 | WARN_ON(is_on && is_peripheral_active(musb)); | 195 | WARN_ON(is_on && is_peripheral_active(musb)); |
196 | davinci_source_power(musb, is_on, 0); | 196 | davinci_musb_source_power(musb, is_on, 0); |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
@@ -259,7 +259,7 @@ static void otg_timer(unsigned long _musb) | |||
259 | spin_unlock_irqrestore(&musb->lock, flags); | 259 | spin_unlock_irqrestore(&musb->lock, flags); |
260 | } | 260 | } |
261 | 261 | ||
262 | static irqreturn_t davinci_interrupt(int irq, void *__hci) | 262 | static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) |
263 | { | 263 | { |
264 | unsigned long flags; | 264 | unsigned long flags; |
265 | irqreturn_t retval = IRQ_NONE; | 265 | irqreturn_t retval = IRQ_NONE; |
@@ -345,7 +345,7 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci) | |||
345 | /* NOTE: this must complete poweron within 100 msec | 345 | /* NOTE: this must complete poweron within 100 msec |
346 | * (OTG_TIME_A_WAIT_VRISE) but we don't check for that. | 346 | * (OTG_TIME_A_WAIT_VRISE) but we don't check for that. |
347 | */ | 347 | */ |
348 | davinci_source_power(musb, drvvbus, 0); | 348 | davinci_musb_source_power(musb, drvvbus, 0); |
349 | DBG(2, "VBUS %s (%s)%s, devctl %02x\n", | 349 | DBG(2, "VBUS %s (%s)%s, devctl %02x\n", |
350 | drvvbus ? "on" : "off", | 350 | drvvbus ? "on" : "off", |
351 | otg_state_string(musb), | 351 | otg_state_string(musb), |
@@ -370,13 +370,13 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci) | |||
370 | return retval; | 370 | return retval; |
371 | } | 371 | } |
372 | 372 | ||
373 | int musb_platform_set_mode(struct musb *musb, u8 mode) | 373 | static int davinci_musb_set_mode(struct musb *musb, u8 mode) |
374 | { | 374 | { |
375 | /* EVM can't do this (right?) */ | 375 | /* EVM can't do this (right?) */ |
376 | return -EIO; | 376 | return -EIO; |
377 | } | 377 | } |
378 | 378 | ||
379 | int __init musb_platform_init(struct musb *musb) | 379 | static int davinci_musb_init(struct musb *musb) |
380 | { | 380 | { |
381 | void __iomem *tibase = musb->ctrl_base; | 381 | void __iomem *tibase = musb->ctrl_base; |
382 | u32 revision; | 382 | u32 revision; |
@@ -398,8 +398,8 @@ int __init musb_platform_init(struct musb *musb) | |||
398 | if (is_host_enabled(musb)) | 398 | if (is_host_enabled(musb)) |
399 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); | 399 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); |
400 | 400 | ||
401 | musb->board_set_vbus = davinci_set_vbus; | 401 | musb->board_set_vbus = davinci_musb_set_vbus; |
402 | davinci_source_power(musb, 0, 1); | 402 | davinci_musb_source_power(musb, 0, 1); |
403 | 403 | ||
404 | /* dm355 EVM swaps D+/D- for signal integrity, and | 404 | /* dm355 EVM swaps D+/D- for signal integrity, and |
405 | * is clocked from the main 24 MHz crystal. | 405 | * is clocked from the main 24 MHz crystal. |
@@ -440,7 +440,7 @@ int __init musb_platform_init(struct musb *musb) | |||
440 | revision, __raw_readl(USB_PHY_CTRL), | 440 | revision, __raw_readl(USB_PHY_CTRL), |
441 | musb_readb(tibase, DAVINCI_USB_CTRL_REG)); | 441 | musb_readb(tibase, DAVINCI_USB_CTRL_REG)); |
442 | 442 | ||
443 | musb->isr = davinci_interrupt; | 443 | musb->isr = davinci_musb_interrupt; |
444 | return 0; | 444 | return 0; |
445 | 445 | ||
446 | fail: | 446 | fail: |
@@ -451,7 +451,7 @@ fail: | |||
451 | return -ENODEV; | 451 | return -ENODEV; |
452 | } | 452 | } |
453 | 453 | ||
454 | int musb_platform_exit(struct musb *musb) | 454 | static int davinci_musb_exit(struct musb *musb) |
455 | { | 455 | { |
456 | if (is_host_enabled(musb)) | 456 | if (is_host_enabled(musb)) |
457 | del_timer_sync(&otg_workaround); | 457 | del_timer_sync(&otg_workaround); |
@@ -465,7 +465,7 @@ int musb_platform_exit(struct musb *musb) | |||
465 | __raw_writel(deepsleep, DM355_DEEPSLEEP); | 465 | __raw_writel(deepsleep, DM355_DEEPSLEEP); |
466 | } | 466 | } |
467 | 467 | ||
468 | davinci_source_power(musb, 0 /*off*/, 1); | 468 | davinci_musb_source_power(musb, 0 /*off*/, 1); |
469 | 469 | ||
470 | /* delay, to avoid problems with module reload */ | 470 | /* delay, to avoid problems with module reload */ |
471 | if (is_host_enabled(musb) && musb->xceiv->default_a) { | 471 | if (is_host_enabled(musb) && musb->xceiv->default_a) { |
@@ -502,3 +502,15 @@ int musb_platform_exit(struct musb *musb) | |||
502 | 502 | ||
503 | return 0; | 503 | return 0; |
504 | } | 504 | } |
505 | |||
506 | const struct musb_platform_ops musb_ops = { | ||
507 | .init = davinci_musb_init, | ||
508 | .exit = davinci_musb_exit, | ||
509 | |||
510 | .enable = davinci_musb_enable, | ||
511 | .disable = davinci_musb_disable, | ||
512 | |||
513 | .set_mode = davinci_musb_set_mode, | ||
514 | |||
515 | .set_vbus = davinci_musb_set_vbus, | ||
516 | }; | ||
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index a5ceddfe57d6..516c68c6fa50 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -390,7 +390,7 @@ void musb_otg_timer_func(unsigned long data) | |||
390 | case OTG_STATE_A_SUSPEND: | 390 | case OTG_STATE_A_SUSPEND: |
391 | case OTG_STATE_A_WAIT_BCON: | 391 | case OTG_STATE_A_WAIT_BCON: |
392 | DBG(1, "HNP: %s timeout\n", otg_state_string(musb)); | 392 | DBG(1, "HNP: %s timeout\n", otg_state_string(musb)); |
393 | musb_set_vbus(musb, 0); | 393 | musb_platform_set_vbus(musb, 0); |
394 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 394 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
395 | break; | 395 | break; |
396 | default: | 396 | default: |
@@ -570,7 +570,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
570 | musb->ep0_stage = MUSB_EP0_START; | 570 | musb->ep0_stage = MUSB_EP0_START; |
571 | musb->xceiv->state = OTG_STATE_A_IDLE; | 571 | musb->xceiv->state = OTG_STATE_A_IDLE; |
572 | MUSB_HST_MODE(musb); | 572 | MUSB_HST_MODE(musb); |
573 | musb_set_vbus(musb, 1); | 573 | musb_platform_set_vbus(musb, 1); |
574 | 574 | ||
575 | handled = IRQ_HANDLED; | 575 | handled = IRQ_HANDLED; |
576 | } | 576 | } |
@@ -641,7 +641,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
641 | 641 | ||
642 | /* go through A_WAIT_VFALL then start a new session */ | 642 | /* go through A_WAIT_VFALL then start a new session */ |
643 | if (!ignore) | 643 | if (!ignore) |
644 | musb_set_vbus(musb, 0); | 644 | musb_platform_set_vbus(musb, 0); |
645 | handled = IRQ_HANDLED; | 645 | handled = IRQ_HANDLED; |
646 | } | 646 | } |
647 | 647 | ||
@@ -1898,6 +1898,8 @@ allocate_instance(struct device *dev, | |||
1898 | } | 1898 | } |
1899 | 1899 | ||
1900 | musb->controller = dev; | 1900 | musb->controller = dev; |
1901 | musb->ops = &musb_ops; | ||
1902 | |||
1901 | return musb; | 1903 | return musb; |
1902 | } | 1904 | } |
1903 | 1905 | ||
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 59928a235dc5..68fc76f5e316 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -281,6 +281,8 @@ struct musb_platform_ops { | |||
281 | void (*set_vbus)(struct musb *musb, int on); | 281 | void (*set_vbus)(struct musb *musb, int on); |
282 | }; | 282 | }; |
283 | 283 | ||
284 | extern const struct musb_platform_ops musb_ops; | ||
285 | |||
284 | /* | 286 | /* |
285 | * struct musb_hw_ep - endpoint hardware (bidirectional) | 287 | * struct musb_hw_ep - endpoint hardware (bidirectional) |
286 | * | 288 | * |
@@ -359,6 +361,9 @@ struct musb { | |||
359 | spinlock_t lock; | 361 | spinlock_t lock; |
360 | struct clk *clock; | 362 | struct clk *clock; |
361 | struct clk *phy_clock; | 363 | struct clk *phy_clock; |
364 | |||
365 | const struct musb_platform_ops *ops; | ||
366 | |||
362 | irqreturn_t (*isr)(int, void *); | 367 | irqreturn_t (*isr)(int, void *); |
363 | struct work_struct irq_work; | 368 | struct work_struct irq_work; |
364 | u16 hwvers; | 369 | u16 hwvers; |
@@ -486,52 +491,6 @@ struct musb { | |||
486 | #endif | 491 | #endif |
487 | }; | 492 | }; |
488 | 493 | ||
489 | #ifdef CONFIG_PM | ||
490 | struct musb_csr_regs { | ||
491 | /* FIFO registers */ | ||
492 | u16 txmaxp, txcsr, rxmaxp, rxcsr; | ||
493 | u16 rxfifoadd, txfifoadd; | ||
494 | u8 txtype, txinterval, rxtype, rxinterval; | ||
495 | u8 rxfifosz, txfifosz; | ||
496 | u8 txfunaddr, txhubaddr, txhubport; | ||
497 | u8 rxfunaddr, rxhubaddr, rxhubport; | ||
498 | }; | ||
499 | |||
500 | struct musb_context_registers { | ||
501 | |||
502 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ | ||
503 | defined(CONFIG_ARCH_OMAP4) | ||
504 | u32 otg_sysconfig, otg_forcestandby; | ||
505 | #endif | ||
506 | u8 power; | ||
507 | u16 intrtxe, intrrxe; | ||
508 | u8 intrusbe; | ||
509 | u16 frame; | ||
510 | u8 index, testmode; | ||
511 | |||
512 | u8 devctl, busctl, misc; | ||
513 | |||
514 | struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; | ||
515 | }; | ||
516 | |||
517 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ | ||
518 | defined(CONFIG_ARCH_OMAP4) | ||
519 | extern void musb_platform_save_context(struct musb *musb, | ||
520 | struct musb_context_registers *musb_context); | ||
521 | extern void musb_platform_restore_context(struct musb *musb, | ||
522 | struct musb_context_registers *musb_context); | ||
523 | #else | ||
524 | #define musb_platform_save_context(m, x) do {} while (0) | ||
525 | #define musb_platform_restore_context(m, x) do {} while (0) | ||
526 | #endif | ||
527 | |||
528 | #endif | ||
529 | |||
530 | static inline void musb_set_vbus(struct musb *musb, int is_on) | ||
531 | { | ||
532 | musb->board_set_vbus(musb, is_on); | ||
533 | } | ||
534 | |||
535 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | 494 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC |
536 | static inline struct musb *gadget_to_musb(struct usb_gadget *g) | 495 | static inline struct musb *gadget_to_musb(struct usb_gadget *g) |
537 | { | 496 | { |
@@ -620,29 +579,120 @@ extern void musb_load_testpacket(struct musb *); | |||
620 | 579 | ||
621 | extern irqreturn_t musb_interrupt(struct musb *); | 580 | extern irqreturn_t musb_interrupt(struct musb *); |
622 | 581 | ||
623 | extern void musb_platform_enable(struct musb *musb); | ||
624 | extern void musb_platform_disable(struct musb *musb); | ||
625 | |||
626 | extern void musb_hnp_stop(struct musb *musb); | 582 | extern void musb_hnp_stop(struct musb *musb); |
627 | 583 | ||
628 | extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode); | 584 | #ifdef CONFIG_PM |
585 | struct musb_csr_regs { | ||
586 | /* FIFO registers */ | ||
587 | u16 txmaxp, txcsr, rxmaxp, rxcsr; | ||
588 | u16 rxfifoadd, txfifoadd; | ||
589 | u8 txtype, txinterval, rxtype, rxinterval; | ||
590 | u8 rxfifosz, txfifosz; | ||
591 | u8 txfunaddr, txhubaddr, txhubport; | ||
592 | u8 rxfunaddr, rxhubaddr, rxhubport; | ||
593 | }; | ||
629 | 594 | ||
630 | #if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \ | 595 | struct musb_context_registers { |
631 | defined(CONFIG_ARCH_DAVINCI_DA8XX) || \ | 596 | |
632 | defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ | 597 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ |
633 | defined(CONFIG_ARCH_OMAP4) | 598 | defined(CONFIG_ARCH_OMAP4) |
634 | extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); | 599 | u32 otg_sysconfig, otg_forcestandby; |
635 | #else | ||
636 | #define musb_platform_try_idle(x, y) do {} while (0) | ||
637 | #endif | 600 | #endif |
601 | u8 power; | ||
602 | u16 intrtxe, intrrxe; | ||
603 | u8 intrusbe; | ||
604 | u16 frame; | ||
605 | u8 index, testmode; | ||
638 | 606 | ||
639 | #if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) | 607 | u8 devctl, busctl, misc; |
640 | extern int musb_platform_get_vbus_status(struct musb *musb); | 608 | |
609 | struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; | ||
610 | }; | ||
611 | |||
612 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ | ||
613 | defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) | ||
614 | extern void musb_platform_save_context(struct musb *musb, | ||
615 | struct musb_context_registers *musb_context); | ||
616 | extern void musb_platform_restore_context(struct musb *musb, | ||
617 | struct musb_context_registers *musb_context); | ||
641 | #else | 618 | #else |
642 | #define musb_platform_get_vbus_status(x) 0 | 619 | #define musb_platform_save_context(m, x) do {} while (0) |
620 | #define musb_platform_restore_context(m, x) do {} while (0) | ||
643 | #endif | 621 | #endif |
644 | 622 | ||
645 | extern int __init musb_platform_init(struct musb *musb); | 623 | #endif |
646 | extern int musb_platform_exit(struct musb *musb); | 624 | |
625 | static inline void musb_platform_set_vbus(struct musb *musb, int is_on) | ||
626 | { | ||
627 | if (musb->ops->set_vbus) | ||
628 | musb->ops->set_vbus(musb, is_on); | ||
629 | } | ||
630 | |||
631 | static inline void musb_platform_enable(struct musb *musb) | ||
632 | { | ||
633 | if (musb->ops->enable) | ||
634 | musb->ops->enable(musb); | ||
635 | } | ||
636 | |||
637 | static inline void musb_platform_disable(struct musb *musb) | ||
638 | { | ||
639 | if (musb->ops->disable) | ||
640 | musb->ops->disable(musb); | ||
641 | } | ||
642 | |||
643 | static inline int musb_platform_set_mode(struct musb *musb, u8 mode) | ||
644 | { | ||
645 | if (!musb->ops->set_mode) | ||
646 | return 0; | ||
647 | |||
648 | return musb->ops->set_mode(musb, mode); | ||
649 | } | ||
650 | |||
651 | static inline void musb_platform_try_idle(struct musb *musb, | ||
652 | unsigned long timeout) | ||
653 | { | ||
654 | if (musb->ops->try_idle) | ||
655 | musb->ops->try_idle(musb, timeout); | ||
656 | } | ||
657 | |||
658 | static inline int musb_platform_get_vbus_status(struct musb *musb) | ||
659 | { | ||
660 | if (!musb->ops->vbus_status) | ||
661 | return 0; | ||
662 | |||
663 | return musb->ops->vbus_status(musb); | ||
664 | } | ||
665 | |||
666 | static inline int musb_platform_init(struct musb *musb) | ||
667 | { | ||
668 | if (!musb->ops->init) | ||
669 | return -EINVAL; | ||
670 | |||
671 | return musb->ops->init(musb); | ||
672 | } | ||
673 | |||
674 | static inline int musb_platform_exit(struct musb *musb) | ||
675 | { | ||
676 | if (!musb->ops->exit) | ||
677 | return -EINVAL; | ||
678 | |||
679 | return musb->ops->exit(musb); | ||
680 | } | ||
681 | |||
682 | static inline int musb_platform_suspend(struct musb *musb) | ||
683 | { | ||
684 | if (!musb->ops->suspend) | ||
685 | return 0; | ||
686 | |||
687 | return musb->ops->suspend(musb); | ||
688 | } | ||
689 | |||
690 | static inline int musb_platform_resume(struct musb *musb) | ||
691 | { | ||
692 | if (!musb->ops->resume) | ||
693 | return 0; | ||
694 | |||
695 | return musb->ops->resume(musb); | ||
696 | } | ||
647 | 697 | ||
648 | #endif /* __MUSB_CORE_H__ */ | 698 | #endif /* __MUSB_CORE_H__ */ |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 43233c397b6e..b46d1877e28e 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -276,7 +276,7 @@ int musb_hub_control( | |||
276 | break; | 276 | break; |
277 | case USB_PORT_FEAT_POWER: | 277 | case USB_PORT_FEAT_POWER: |
278 | if (!(is_otg_enabled(musb) && hcd->self.is_b_host)) | 278 | if (!(is_otg_enabled(musb) && hcd->self.is_b_host)) |
279 | musb_set_vbus(musb, 0); | 279 | musb_platform_set_vbus(musb, 0); |
280 | break; | 280 | break; |
281 | case USB_PORT_FEAT_C_CONNECTION: | 281 | case USB_PORT_FEAT_C_CONNECTION: |
282 | case USB_PORT_FEAT_C_ENABLE: | 282 | case USB_PORT_FEAT_C_ENABLE: |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 27dabcf0a868..5f0d0f105989 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "musb_core.h" | 35 | #include "musb_core.h" |
36 | #include "omap2430.h" | 36 | #include "omap2430.h" |
37 | 37 | ||
38 | |||
39 | static struct timer_list musb_idle_timer; | 38 | static struct timer_list musb_idle_timer; |
40 | 39 | ||
41 | static void musb_do_idle(unsigned long _musb) | 40 | static void musb_do_idle(unsigned long _musb) |
@@ -98,7 +97,7 @@ static void musb_do_idle(unsigned long _musb) | |||
98 | } | 97 | } |
99 | 98 | ||
100 | 99 | ||
101 | void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | 100 | static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) |
102 | { | 101 | { |
103 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); | 102 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); |
104 | static unsigned long last_timer; | 103 | static unsigned long last_timer; |
@@ -131,13 +130,15 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | |||
131 | mod_timer(&musb_idle_timer, timeout); | 130 | mod_timer(&musb_idle_timer, timeout); |
132 | } | 131 | } |
133 | 132 | ||
134 | void musb_platform_enable(struct musb *musb) | 133 | static void omap2430_musb_enable(struct musb *musb) |
135 | { | 134 | { |
136 | } | 135 | } |
137 | void musb_platform_disable(struct musb *musb) | 136 | |
137 | static void omap2430_musb_disable(struct musb *musb) | ||
138 | { | 138 | { |
139 | } | 139 | } |
140 | static void omap_set_vbus(struct musb *musb, int is_on) | 140 | |
141 | static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | ||
141 | { | 142 | { |
142 | u8 devctl; | 143 | u8 devctl; |
143 | /* HDRC controls CPEN, but beware current surges during device | 144 | /* HDRC controls CPEN, but beware current surges during device |
@@ -175,9 +176,9 @@ static void omap_set_vbus(struct musb *musb, int is_on) | |||
175 | musb_readb(musb->mregs, MUSB_DEVCTL)); | 176 | musb_readb(musb->mregs, MUSB_DEVCTL)); |
176 | } | 177 | } |
177 | 178 | ||
178 | static int musb_platform_resume(struct musb *musb); | 179 | static int omap2430_musb_resume(struct musb *musb); |
179 | 180 | ||
180 | int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | 181 | static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode) |
181 | { | 182 | { |
182 | u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 183 | u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
183 | 184 | ||
@@ -187,7 +188,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | |||
187 | return 0; | 188 | return 0; |
188 | } | 189 | } |
189 | 190 | ||
190 | int __init musb_platform_init(struct musb *musb) | 191 | static int omap2430_musb_init(struct musb *musb) |
191 | { | 192 | { |
192 | u32 l; | 193 | u32 l; |
193 | struct device *dev = musb->controller; | 194 | struct device *dev = musb->controller; |
@@ -204,7 +205,7 @@ int __init musb_platform_init(struct musb *musb) | |||
204 | return -ENODEV; | 205 | return -ENODEV; |
205 | } | 206 | } |
206 | 207 | ||
207 | musb_platform_resume(musb); | 208 | omap2430_musb_resume(musb); |
208 | 209 | ||
209 | l = musb_readl(musb->mregs, OTG_SYSCONFIG); | 210 | l = musb_readl(musb->mregs, OTG_SYSCONFIG); |
210 | l &= ~ENABLEWAKEUP; /* disable wakeup */ | 211 | l &= ~ENABLEWAKEUP; /* disable wakeup */ |
@@ -242,7 +243,7 @@ int __init musb_platform_init(struct musb *musb) | |||
242 | musb_readl(musb->mregs, OTG_SIMENABLE)); | 243 | musb_readl(musb->mregs, OTG_SIMENABLE)); |
243 | 244 | ||
244 | if (is_host_enabled(musb)) | 245 | if (is_host_enabled(musb)) |
245 | musb->board_set_vbus = omap_set_vbus; | 246 | musb->board_set_vbus = omap2430_musb_set_vbus; |
246 | 247 | ||
247 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); | 248 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); |
248 | 249 | ||
@@ -265,7 +266,7 @@ void musb_platform_restore_context(struct musb *musb, | |||
265 | } | 266 | } |
266 | #endif | 267 | #endif |
267 | 268 | ||
268 | static int musb_platform_suspend(struct musb *musb) | 269 | static int omap2430_musb_suspend(struct musb *musb) |
269 | { | 270 | { |
270 | u32 l; | 271 | u32 l; |
271 | 272 | ||
@@ -291,7 +292,7 @@ static int musb_platform_suspend(struct musb *musb) | |||
291 | return 0; | 292 | return 0; |
292 | } | 293 | } |
293 | 294 | ||
294 | static int musb_platform_resume(struct musb *musb) | 295 | static int omap2430_musb_resume(struct musb *musb) |
295 | { | 296 | { |
296 | u32 l; | 297 | u32 l; |
297 | 298 | ||
@@ -316,12 +317,27 @@ static int musb_platform_resume(struct musb *musb) | |||
316 | return 0; | 317 | return 0; |
317 | } | 318 | } |
318 | 319 | ||
319 | 320 | static int omap2430_musb_exit(struct musb *musb) | |
320 | int musb_platform_exit(struct musb *musb) | ||
321 | { | 321 | { |
322 | 322 | ||
323 | musb_platform_suspend(musb); | 323 | omap2430_musb_suspend(musb); |
324 | 324 | ||
325 | otg_put_transceiver(musb->xceiv); | 325 | otg_put_transceiver(musb->xceiv); |
326 | return 0; | 326 | return 0; |
327 | } | 327 | } |
328 | |||
329 | const struct musb_platform_ops musb_ops = { | ||
330 | .init = omap2430_musb_init, | ||
331 | .exit = omap2430_musb_exit, | ||
332 | |||
333 | .suspend = omap2430_musb_suspend, | ||
334 | .resume = omap2430_musb_resume, | ||
335 | |||
336 | .enable = omap2430_musb_enable, | ||
337 | .disable = omap2430_musb_disable, | ||
338 | |||
339 | .set_mode = omap2430_musb_set_mode, | ||
340 | .try_idle = omap2430_musb_try_idle, | ||
341 | |||
342 | .set_vbus = omap2430_musb_set_vbus, | ||
343 | }; | ||
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 41b04b906ce1..60abd52b2c51 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include "musb_core.h" | 25 | #include "musb_core.h" |
26 | 26 | ||
27 | static void tusb_source_power(struct musb *musb, int is_on); | 27 | static void tusb_musb_set_vbus(struct musb *musb, int is_on); |
28 | 28 | ||
29 | #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) | 29 | #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) |
30 | #define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) | 30 | #define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) |
@@ -50,7 +50,7 @@ u8 tusb_get_revision(struct musb *musb) | |||
50 | return rev; | 50 | return rev; |
51 | } | 51 | } |
52 | 52 | ||
53 | static int __init tusb_print_revision(struct musb *musb) | 53 | static int tusb_print_revision(struct musb *musb) |
54 | { | 54 | { |
55 | void __iomem *tbase = musb->ctrl_base; | 55 | void __iomem *tbase = musb->ctrl_base; |
56 | u8 rev; | 56 | u8 rev; |
@@ -348,7 +348,7 @@ static void tusb_set_clock_source(struct musb *musb, unsigned mode) | |||
348 | * USB link is not suspended ... and tells us the relevant wakeup | 348 | * USB link is not suspended ... and tells us the relevant wakeup |
349 | * events. SW_EN for voltage is handled separately. | 349 | * events. SW_EN for voltage is handled separately. |
350 | */ | 350 | */ |
351 | void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) | 351 | static void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) |
352 | { | 352 | { |
353 | void __iomem *tbase = musb->ctrl_base; | 353 | void __iomem *tbase = musb->ctrl_base; |
354 | u32 reg; | 354 | u32 reg; |
@@ -385,7 +385,7 @@ void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) | |||
385 | /* | 385 | /* |
386 | * Updates cable VBUS status. Caller must take care of locking. | 386 | * Updates cable VBUS status. Caller must take care of locking. |
387 | */ | 387 | */ |
388 | int musb_platform_get_vbus_status(struct musb *musb) | 388 | static int tusb_musb_vbus_status(struct musb *musb) |
389 | { | 389 | { |
390 | void __iomem *tbase = musb->ctrl_base; | 390 | void __iomem *tbase = musb->ctrl_base; |
391 | u32 otg_stat, prcm_mngmt; | 391 | u32 otg_stat, prcm_mngmt; |
@@ -431,7 +431,7 @@ static void musb_do_idle(unsigned long _musb) | |||
431 | } | 431 | } |
432 | /* FALLTHROUGH */ | 432 | /* FALLTHROUGH */ |
433 | case OTG_STATE_A_IDLE: | 433 | case OTG_STATE_A_IDLE: |
434 | tusb_source_power(musb, 0); | 434 | tusb_musb_set_vbus(musb, 0); |
435 | default: | 435 | default: |
436 | break; | 436 | break; |
437 | } | 437 | } |
@@ -475,7 +475,7 @@ done: | |||
475 | * we don't want to treat that full speed J as a wakeup event. | 475 | * we don't want to treat that full speed J as a wakeup event. |
476 | * ... peripherals must draw only suspend current after 10 msec. | 476 | * ... peripherals must draw only suspend current after 10 msec. |
477 | */ | 477 | */ |
478 | void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | 478 | static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout) |
479 | { | 479 | { |
480 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); | 480 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); |
481 | static unsigned long last_timer; | 481 | static unsigned long last_timer; |
@@ -515,7 +515,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | |||
515 | | TUSB_DEV_OTG_TIMER_ENABLE) \ | 515 | | TUSB_DEV_OTG_TIMER_ENABLE) \ |
516 | : 0) | 516 | : 0) |
517 | 517 | ||
518 | static void tusb_source_power(struct musb *musb, int is_on) | 518 | static void tusb_musb_set_vbus(struct musb *musb, int is_on) |
519 | { | 519 | { |
520 | void __iomem *tbase = musb->ctrl_base; | 520 | void __iomem *tbase = musb->ctrl_base; |
521 | u32 conf, prcm, timer; | 521 | u32 conf, prcm, timer; |
@@ -599,7 +599,7 @@ static void tusb_source_power(struct musb *musb, int is_on) | |||
599 | * and peripheral modes in non-OTG configurations by reconfiguring hardware | 599 | * and peripheral modes in non-OTG configurations by reconfiguring hardware |
600 | * and then setting musb->board_mode. For now, only support OTG mode. | 600 | * and then setting musb->board_mode. For now, only support OTG mode. |
601 | */ | 601 | */ |
602 | int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | 602 | static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) |
603 | { | 603 | { |
604 | void __iomem *tbase = musb->ctrl_base; | 604 | void __iomem *tbase = musb->ctrl_base; |
605 | u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; | 605 | u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; |
@@ -677,7 +677,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
677 | default_a = is_host_enabled(musb); | 677 | default_a = is_host_enabled(musb); |
678 | DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); | 678 | DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); |
679 | musb->xceiv->default_a = default_a; | 679 | musb->xceiv->default_a = default_a; |
680 | tusb_source_power(musb, default_a); | 680 | tusb_musb_set_vbus(musb, default_a); |
681 | 681 | ||
682 | /* Don't allow idling immediately */ | 682 | /* Don't allow idling immediately */ |
683 | if (default_a) | 683 | if (default_a) |
@@ -722,7 +722,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
722 | switch (musb->xceiv->state) { | 722 | switch (musb->xceiv->state) { |
723 | case OTG_STATE_A_IDLE: | 723 | case OTG_STATE_A_IDLE: |
724 | DBG(2, "Got SRP, turning on VBUS\n"); | 724 | DBG(2, "Got SRP, turning on VBUS\n"); |
725 | musb_set_vbus(musb, 1); | 725 | musb_platform_set_vbus(musb, 1); |
726 | 726 | ||
727 | /* CONNECT can wake if a_wait_bcon is set */ | 727 | /* CONNECT can wake if a_wait_bcon is set */ |
728 | if (musb->a_wait_bcon != 0) | 728 | if (musb->a_wait_bcon != 0) |
@@ -748,11 +748,11 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
748 | */ | 748 | */ |
749 | if (musb->vbuserr_retry) { | 749 | if (musb->vbuserr_retry) { |
750 | musb->vbuserr_retry--; | 750 | musb->vbuserr_retry--; |
751 | tusb_source_power(musb, 1); | 751 | tusb_musb_set_vbus(musb, 1); |
752 | } else { | 752 | } else { |
753 | musb->vbuserr_retry | 753 | musb->vbuserr_retry |
754 | = VBUSERR_RETRY_COUNT; | 754 | = VBUSERR_RETRY_COUNT; |
755 | tusb_source_power(musb, 0); | 755 | tusb_musb_set_vbus(musb, 0); |
756 | } | 756 | } |
757 | break; | 757 | break; |
758 | default: | 758 | default: |
@@ -786,7 +786,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
786 | } else { | 786 | } else { |
787 | /* REVISIT report overcurrent to hub? */ | 787 | /* REVISIT report overcurrent to hub? */ |
788 | ERR("vbus too slow, devctl %02x\n", devctl); | 788 | ERR("vbus too slow, devctl %02x\n", devctl); |
789 | tusb_source_power(musb, 0); | 789 | tusb_musb_set_vbus(musb, 0); |
790 | } | 790 | } |
791 | break; | 791 | break; |
792 | case OTG_STATE_A_WAIT_BCON: | 792 | case OTG_STATE_A_WAIT_BCON: |
@@ -807,7 +807,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
807 | return idle_timeout; | 807 | return idle_timeout; |
808 | } | 808 | } |
809 | 809 | ||
810 | static irqreturn_t tusb_interrupt(int irq, void *__hci) | 810 | static irqreturn_t tusb_musb_interrupt(int irq, void *__hci) |
811 | { | 811 | { |
812 | struct musb *musb = __hci; | 812 | struct musb *musb = __hci; |
813 | void __iomem *tbase = musb->ctrl_base; | 813 | void __iomem *tbase = musb->ctrl_base; |
@@ -911,7 +911,7 @@ static irqreturn_t tusb_interrupt(int irq, void *__hci) | |||
911 | musb_writel(tbase, TUSB_INT_SRC_CLEAR, | 911 | musb_writel(tbase, TUSB_INT_SRC_CLEAR, |
912 | int_src & ~TUSB_INT_MASK_RESERVED_BITS); | 912 | int_src & ~TUSB_INT_MASK_RESERVED_BITS); |
913 | 913 | ||
914 | musb_platform_try_idle(musb, idle_timeout); | 914 | tusb_musb_try_idle(musb, idle_timeout); |
915 | 915 | ||
916 | musb_writel(tbase, TUSB_INT_MASK, int_mask); | 916 | musb_writel(tbase, TUSB_INT_MASK, int_mask); |
917 | spin_unlock_irqrestore(&musb->lock, flags); | 917 | spin_unlock_irqrestore(&musb->lock, flags); |
@@ -926,7 +926,7 @@ static int dma_off; | |||
926 | * REVISIT: | 926 | * REVISIT: |
927 | * - Check what is unnecessary in MGC_HdrcStart() | 927 | * - Check what is unnecessary in MGC_HdrcStart() |
928 | */ | 928 | */ |
929 | void musb_platform_enable(struct musb *musb) | 929 | static void tusb_musb_enable(struct musb *musb) |
930 | { | 930 | { |
931 | void __iomem *tbase = musb->ctrl_base; | 931 | void __iomem *tbase = musb->ctrl_base; |
932 | 932 | ||
@@ -970,7 +970,7 @@ void musb_platform_enable(struct musb *musb) | |||
970 | /* | 970 | /* |
971 | * Disables TUSB6010. Caller must take care of locking. | 971 | * Disables TUSB6010. Caller must take care of locking. |
972 | */ | 972 | */ |
973 | void musb_platform_disable(struct musb *musb) | 973 | static void tusb_musb_disable(struct musb *musb) |
974 | { | 974 | { |
975 | void __iomem *tbase = musb->ctrl_base; | 975 | void __iomem *tbase = musb->ctrl_base; |
976 | 976 | ||
@@ -995,7 +995,7 @@ void musb_platform_disable(struct musb *musb) | |||
995 | * Sets up TUSB6010 CPU interface specific signals and registers | 995 | * Sets up TUSB6010 CPU interface specific signals and registers |
996 | * Note: Settings optimized for OMAP24xx | 996 | * Note: Settings optimized for OMAP24xx |
997 | */ | 997 | */ |
998 | static void __init tusb_setup_cpu_interface(struct musb *musb) | 998 | static void tusb_setup_cpu_interface(struct musb *musb) |
999 | { | 999 | { |
1000 | void __iomem *tbase = musb->ctrl_base; | 1000 | void __iomem *tbase = musb->ctrl_base; |
1001 | 1001 | ||
@@ -1022,7 +1022,7 @@ static void __init tusb_setup_cpu_interface(struct musb *musb) | |||
1022 | musb_writel(tbase, TUSB_WAIT_COUNT, 1); | 1022 | musb_writel(tbase, TUSB_WAIT_COUNT, 1); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | static int __init tusb_start(struct musb *musb) | 1025 | static int tusb_musb_start(struct musb *musb) |
1026 | { | 1026 | { |
1027 | void __iomem *tbase = musb->ctrl_base; | 1027 | void __iomem *tbase = musb->ctrl_base; |
1028 | int ret = 0; | 1028 | int ret = 0; |
@@ -1091,7 +1091,7 @@ err: | |||
1091 | return -ENODEV; | 1091 | return -ENODEV; |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | int __init musb_platform_init(struct musb *musb) | 1094 | static int tusb_musb_init(struct musb *musb) |
1095 | { | 1095 | { |
1096 | struct platform_device *pdev; | 1096 | struct platform_device *pdev; |
1097 | struct resource *mem; | 1097 | struct resource *mem; |
@@ -1131,16 +1131,14 @@ int __init musb_platform_init(struct musb *musb) | |||
1131 | */ | 1131 | */ |
1132 | musb->mregs += TUSB_BASE_OFFSET; | 1132 | musb->mregs += TUSB_BASE_OFFSET; |
1133 | 1133 | ||
1134 | ret = tusb_start(musb); | 1134 | ret = tusb_musb_start(musb); |
1135 | if (ret) { | 1135 | if (ret) { |
1136 | printk(KERN_ERR "Could not start tusb6010 (%d)\n", | 1136 | printk(KERN_ERR "Could not start tusb6010 (%d)\n", |
1137 | ret); | 1137 | ret); |
1138 | goto done; | 1138 | goto done; |
1139 | } | 1139 | } |
1140 | musb->isr = tusb_interrupt; | 1140 | musb->isr = tusb_musb_interrupt; |
1141 | 1141 | ||
1142 | if (is_host_enabled(musb)) | ||
1143 | musb->board_set_vbus = tusb_source_power; | ||
1144 | if (is_peripheral_enabled(musb)) { | 1142 | if (is_peripheral_enabled(musb)) { |
1145 | musb->xceiv->set_power = tusb_draw_power; | 1143 | musb->xceiv->set_power = tusb_draw_power; |
1146 | the_musb = musb; | 1144 | the_musb = musb; |
@@ -1159,7 +1157,7 @@ done: | |||
1159 | return ret; | 1157 | return ret; |
1160 | } | 1158 | } |
1161 | 1159 | ||
1162 | int musb_platform_exit(struct musb *musb) | 1160 | static int tusb_musb_exit(struct musb *musb) |
1163 | { | 1161 | { |
1164 | del_timer_sync(&musb_idle_timer); | 1162 | del_timer_sync(&musb_idle_timer); |
1165 | the_musb = NULL; | 1163 | the_musb = NULL; |
@@ -1173,3 +1171,17 @@ int musb_platform_exit(struct musb *musb) | |||
1173 | usb_nop_xceiv_unregister(); | 1171 | usb_nop_xceiv_unregister(); |
1174 | return 0; | 1172 | return 0; |
1175 | } | 1173 | } |
1174 | |||
1175 | const struct musb_platform_ops musb_ops = { | ||
1176 | .init = tusb_musb_init, | ||
1177 | .exit = tusb_musb_exit, | ||
1178 | |||
1179 | .enable = tusb_musb_enable, | ||
1180 | .disable = tusb_musb_disable, | ||
1181 | |||
1182 | .set_mode = tusb_musb_set_mode, | ||
1183 | .try_idle = tusb_musb_try_idle, | ||
1184 | |||
1185 | .vbus_status = tusb_musb_vbus_status, | ||
1186 | .set_vbus = tusb_musb_set_vbus, | ||
1187 | }; | ||