omap3.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Copyright (c) 2009 Wind River Systems, Inc.
  3. * Tom Rix <Tom.Rix@windriver.com>
  4. *
  5. * This is file is based on
  6. * repository git.gitorious.org/u-boot-omap3/mainline.git,
  7. * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c
  8. *
  9. * This is the unique part of its copyright :
  10. *
  11. * ------------------------------------------------------------------------
  12. *
  13. * Copyright (c) 2009 Texas Instruments
  14. *
  15. * ------------------------------------------------------------------------
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. */
  32. #include <twl4030.h>
  33. #include <twl6030.h>
  34. #include "omap3.h"
  35. static int platform_needs_initialization = 1;
  36. struct musb_config musb_cfg = {
  37. .regs = (struct musb_regs *)MENTOR_USB0_BASE,
  38. .timeout = OMAP3_USB_TIMEOUT,
  39. .musb_speed = 0,
  40. };
  41. /*
  42. * OMAP3 USB OTG registers.
  43. */
  44. struct omap3_otg_regs {
  45. u32 revision;
  46. u32 sysconfig;
  47. u32 sysstatus;
  48. u32 interfsel;
  49. u32 simenable;
  50. u32 forcestdby;
  51. };
  52. static struct omap3_otg_regs *otg;
  53. #define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
  54. #define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
  55. #define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
  56. #define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
  57. #define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
  58. #define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
  59. #define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
  60. #define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
  61. /* OMAP4430 has an internal PHY, use it */
  62. #ifdef CONFIG_OMAP4430
  63. #define OMAP3_OTG_INTERFSEL_OMAP 0x0000
  64. #else
  65. #define OMAP3_OTG_INTERFSEL_OMAP 0x0001
  66. #endif
  67. #define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
  68. #ifdef DEBUG_MUSB_OMAP3
  69. static void musb_db_otg_regs(void)
  70. {
  71. u32 l;
  72. l = readl(&otg->revision);
  73. serial_printf("OTG_REVISION 0x%x\n", l);
  74. l = readl(&otg->sysconfig);
  75. serial_printf("OTG_SYSCONFIG 0x%x\n", l);
  76. l = readl(&otg->sysstatus);
  77. serial_printf("OTG_SYSSTATUS 0x%x\n", l);
  78. l = readl(&otg->interfsel);
  79. serial_printf("OTG_INTERFSEL 0x%x\n", l);
  80. l = readl(&otg->forcestdby);
  81. serial_printf("OTG_FORCESTDBY 0x%x\n", l);
  82. }
  83. #endif
  84. int musb_platform_init(void)
  85. {
  86. int ret = -1;
  87. if (platform_needs_initialization) {
  88. u32 stdby;
  89. /*
  90. * OMAP3EVM uses ISP1504 phy and so
  91. * twl4030 related init is not required.
  92. */
  93. #ifdef CONFIG_TWL4030_USB
  94. if (twl4030_usb_ulpi_init()) {
  95. serial_printf("ERROR: %s Could not initialize PHY\n",
  96. __PRETTY_FUNCTION__);
  97. goto end;
  98. }
  99. #endif
  100. #ifdef CONFIG_TWL6030_POWER
  101. twl6030_usb_device_settings();
  102. #endif
  103. otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
  104. /* Set OTG to always be on */
  105. writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
  106. OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
  107. /* Set the interface */
  108. writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
  109. /* Clear force standby */
  110. stdby = readl(&otg->forcestdby);
  111. stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
  112. writel(stdby, &otg->forcestdby);
  113. #ifdef CONFIG_OMAP3_EVM
  114. musb_cfg.extvbus = omap3_evm_need_extvbus();
  115. #endif
  116. #ifdef CONFIG_OMAP4430
  117. u32 *usbotghs_control = (u32 *)(CTRL_BASE + 0x33C);
  118. *usbotghs_control = 0x15;
  119. #endif
  120. platform_needs_initialization = 0;
  121. }
  122. ret = platform_needs_initialization;
  123. #ifdef CONFIG_TWL4030_USB
  124. end:
  125. #endif
  126. return ret;
  127. }
  128. void musb_platform_deinit(void)
  129. {
  130. /* noop */
  131. }