omap3.c 3.2 KB

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