ark_musb.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #include <common.h>
  2. #include "musb_core.h"
  3. #include "ark_musb.h"
  4. #include <asm/gpio.h>
  5. /* MUSB platform configuration */
  6. struct musb_config musb_cfg = {
  7. #if 0
  8. #if CONFIG_USB_DEV_PART == 0
  9. .regs = (struct musb_regs *)MUSB_ARK_USB_BASE,
  10. #elif CONFIG_USB_DEV_PART == 1
  11. .regs = (struct musb_regs *)MUSB_ARK_USB1_BASE,
  12. #endif
  13. #endif
  14. .regs = (struct musb_regs *)MUSB_ARK_USB_BASE,
  15. .timeout = 400000,//0x3FFFFFF,
  16. .musb_speed = 0,
  17. };
  18. #if 0
  19. static void set_usb_power(unsigned int Enable)
  20. {
  21. unsigned int reg;
  22. //GPIO126
  23. reg = (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x1f0));
  24. reg &= ~(0x1<<(126-117));
  25. (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x1f0)) = reg;
  26. //Set GPIO OutPut
  27. (*(unsigned int *)(MUSB_ARK_GPIO_BASE+0x60)) &= ~(1<<(126-96));
  28. //Set GPIO Data
  29. if(Enable)
  30. {
  31. (*(unsigned int *)(MUSB_ARK_GPIO_BASE+0x64)) |= (1<<(126-96));
  32. }
  33. else
  34. {
  35. (*(unsigned int *)(MUSB_ARK_GPIO_BASE+0x64)) &= ~(1<<(126-96));
  36. }
  37. }
  38. #endif
  39. static void reset_usb_phy(int index)
  40. {
  41. unsigned int reg;
  42. //set_usb_power(0);
  43. //mdelay(20);
  44. //set_usb_power(1);
  45. if(index == 0) {
  46. reg = (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x74));
  47. reg &= ~(0x3<<5);
  48. (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x74)) = reg;
  49. udelay(20);
  50. reg |= (0x3<<5);
  51. (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x74)) = reg;
  52. }else if(index == 1) {
  53. reg = (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x78));
  54. reg &= ~(0x3<<6);
  55. (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x78)) = reg;
  56. udelay(20);
  57. reg |= (0x3<<6);
  58. (*(unsigned int *)(MUSB_ARK_SYS_BASE+0x78)) = reg;
  59. }
  60. }
  61. /*
  62. * CPU and board-specific MUSB initializations. Aliased function
  63. * signals caller to move on.
  64. */
  65. static void musb_ark_init(void)
  66. {
  67. char *ch = CONFIG_USB_DEV_PART;
  68. int index = 0;
  69. index = ch ? (*ch - '0') : 0;
  70. if(index == 1)
  71. musb_cfg.regs = (struct musb_regs *)MUSB_ARK_USB1_BASE;
  72. if(CONFIG_USB_GPIO_SW >= 0)
  73. gpio_direction_output(CONFIG_USB_GPIO_SW, 0);
  74. if(CONFIG_USB_GPIO_PWR >= 0)
  75. gpio_direction_output(CONFIG_USB_GPIO_PWR, 1);
  76. if(CONFIG_USB_GPIO_ID >= 0)
  77. gpio_direction_output(CONFIG_USB_GPIO_ID, 0);
  78. udelay(20000);
  79. reset_usb_phy(index);
  80. }
  81. void board_musb_init(void) __attribute__((weak, alias("musb_ark_init")));
  82. int musb_platform_init(void)
  83. {
  84. /* board specific initialization */
  85. board_musb_init();
  86. return 0;
  87. }
  88. /*
  89. * This function performs platform specific deinitialization for usb.
  90. */
  91. void musb_platform_deinit(void)
  92. {
  93. }