omap3.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 <asm/omap_common.h>
  33. #include <twl4030.h>
  34. #include <twl6030.h>
  35. #include "omap3.h"
  36. static int platform_needs_initialization = 1;
  37. struct musb_config musb_cfg = {
  38. .regs = (struct musb_regs *)MENTOR_USB0_BASE,
  39. .timeout = OMAP3_USB_TIMEOUT,
  40. .musb_speed = 0,
  41. };
  42. /*
  43. * OMAP3 USB OTG registers.
  44. */
  45. struct omap3_otg_regs {
  46. u32 revision;
  47. u32 sysconfig;
  48. u32 sysstatus;
  49. u32 interfsel;
  50. u32 simenable;
  51. u32 forcestdby;
  52. };
  53. static struct omap3_otg_regs *otg;
  54. #define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
  55. #define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
  56. #define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
  57. #define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
  58. #define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
  59. #define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
  60. #define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
  61. #define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
  62. /* OMAP4430 has an internal PHY, use it */
  63. #ifdef CONFIG_OMAP4430
  64. #define OMAP3_OTG_INTERFSEL_OMAP 0x0000
  65. #else
  66. #define OMAP3_OTG_INTERFSEL_OMAP 0x0001
  67. #endif
  68. #define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
  69. #ifdef DEBUG_MUSB_OMAP3
  70. static void musb_db_otg_regs(void)
  71. {
  72. u32 l;
  73. l = readl(&otg->revision);
  74. serial_printf("OTG_REVISION 0x%x\n", l);
  75. l = readl(&otg->sysconfig);
  76. serial_printf("OTG_SYSCONFIG 0x%x\n", l);
  77. l = readl(&otg->sysstatus);
  78. serial_printf("OTG_SYSSTATUS 0x%x\n", l);
  79. l = readl(&otg->interfsel);
  80. serial_printf("OTG_INTERFSEL 0x%x\n", l);
  81. l = readl(&otg->forcestdby);
  82. serial_printf("OTG_FORCESTDBY 0x%x\n", l);
  83. }
  84. #endif
  85. int musb_platform_init(void)
  86. {
  87. int ret = -1;
  88. if (platform_needs_initialization) {
  89. u32 stdby;
  90. /*
  91. * OMAP3EVM uses ISP1504 phy and so
  92. * twl4030 related init is not required.
  93. */
  94. #ifdef CONFIG_TWL4030_USB
  95. if (twl4030_usb_ulpi_init()) {
  96. serial_printf("ERROR: %s Could not initialize PHY\n",
  97. __PRETTY_FUNCTION__);
  98. goto end;
  99. }
  100. #endif
  101. #ifdef CONFIG_TWL6030_POWER
  102. twl6030_usb_device_settings();
  103. #endif
  104. otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
  105. /* Set OTG to always be on */
  106. writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
  107. OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
  108. /* Set the interface */
  109. writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
  110. /* Clear force standby */
  111. stdby = readl(&otg->forcestdby);
  112. stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
  113. writel(stdby, &otg->forcestdby);
  114. #ifdef CONFIG_OMAP3_EVM
  115. musb_cfg.extvbus = omap3_evm_need_extvbus();
  116. #endif
  117. #ifdef CONFIG_OMAP4430
  118. u32 *usbotghs_control =
  119. (u32 *)((*ctrl)->control_usbotghs_ctrl);
  120. *usbotghs_control = 0x15;
  121. #endif
  122. platform_needs_initialization = 0;
  123. }
  124. ret = platform_needs_initialization;
  125. #ifdef CONFIG_TWL4030_USB
  126. end:
  127. #endif
  128. return ret;
  129. }
  130. void musb_platform_deinit(void)
  131. {
  132. /* noop */
  133. }