omap3.c 3.2 KB

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