omap3.c 3.4 KB

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