diff options
author | Bob Liu <lliubbo@gmail.com> | 2010-10-24 12:10:14 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2010-11-05 08:10:57 -0400 |
commit | 1e393c6eece048052d4131ec4dad3b98e35a98e2 (patch) | |
tree | 4025b0bea317aee755a4f858b4fbed83030df48b /drivers/usb/musb | |
parent | 32d5dc9520f0c6f60f691dd478741c774e292406 (diff) |
USB: musb: blackfin: pm: make it work
Split the USB MMR init steps out into a helper func that both the platform
init and the resume code may call.
Then while suspending, the gpio_vrsel will change from high to low which
will generate a wakeup event and resume the system immediately, so we need
to manually drive it low before we sleep.
Signed-off-by: Bob Liu <lliubbo@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r-- | drivers/usb/musb/blackfin.c | 72 | ||||
-rw-r--r-- | drivers/usb/musb/musb_core.h | 2 |
2 files changed, 50 insertions, 24 deletions
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 611a9d274363..32cc6d927760 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -323,30 +323,8 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | |||
323 | return -EIO; | 323 | return -EIO; |
324 | } | 324 | } |
325 | 325 | ||
326 | int __init musb_platform_init(struct musb *musb, void *board_data) | 326 | static void musb_platform_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,6 +358,33 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
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 | int __init musb_platform_init(struct musb *musb, void *board_data) | ||
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 | musb_platform_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_set_vbus; |
@@ -394,6 +399,27 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
394 | return 0; | 399 | return 0; |
395 | } | 400 | } |
396 | 401 | ||
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 | musb_platform_reg_init(musb); | ||
420 | } | ||
421 | #endif | ||
422 | |||
397 | int musb_platform_exit(struct musb *musb) | 423 | int musb_platform_exit(struct musb *musb) |
398 | { | 424 | { |
399 | gpio_free(musb->config->gpio_vrsel); | 425 | gpio_free(musb->config->gpio_vrsel); |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 69797e5b46a7..febaabcc2b35 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -487,7 +487,7 @@ struct musb_context_registers { | |||
487 | }; | 487 | }; |
488 | 488 | ||
489 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ | 489 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ |
490 | defined(CONFIG_ARCH_OMAP4) | 490 | defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) |
491 | extern void musb_platform_save_context(struct musb *musb, | 491 | extern void musb_platform_save_context(struct musb *musb, |
492 | struct musb_context_registers *musb_context); | 492 | struct musb_context_registers *musb_context); |
493 | extern void musb_platform_restore_context(struct musb *musb, | 493 | extern void musb_platform_restore_context(struct musb *musb, |