board_usb.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include "sdk.h"
  31. #include "usb/usb.h"
  32. ////////////////////////////////////////////////////////////////////////////////
  33. // Code
  34. ////////////////////////////////////////////////////////////////////////////////
  35. /*!
  36. * This function enables Vbus for the given USB port\n
  37. * The procedure to enable Vbus depends on both the Chip and board hardware\n
  38. *
  39. * @param port USB module to initialize
  40. */
  41. void usbEnableVbus(usb_module_t * port)
  42. {
  43. switch (port->controllerID) {
  44. case OTG:
  45. case OTG1:
  46. #ifdef BOARD_SABRE_AI
  47. board_ioexpander_iomux_config();
  48. // Vbus control is on I2C port expander C1 for the ARD board.
  49. max7310_set_gpio_output(2, 1, 1);
  50. #endif
  51. #if defined(BOARD_EVB) || defined(BOARD_SMART_DEVICE)
  52. gpio_set_gpio(GPIO_PORT3, 22);
  53. gpio_set_direction(GPIO_PORT3, 22, GPIO_GDIR_OUTPUT);
  54. gpio_set_level(GPIO_PORT3, 22, GPIO_HIGH_LEVEL);
  55. #endif
  56. break;
  57. case Host1:
  58. case OTG2:
  59. #ifdef BOARD_SABRE_AI
  60. board_ioexpander_iomux_config();
  61. // Vbus control is on I2C port expander B7 for the ARD board.
  62. max7310_set_gpio_output(1, 7, 1);
  63. #endif
  64. #ifdef BOARD_EVB
  65. gpio_set_gpio(GPIO_PORT3, 31);
  66. gpio_set_direction(GPIO_PORT3, 31, GPIO_GDIR_OUTPUT);
  67. gpio_set_level(GPIO_PORT3, 31, GPIO_HIGH_LEVEL);
  68. #endif
  69. #ifdef BOARD_SMART_DEVICE
  70. gpio_set_gpio(GPIO_PORT3, 30);
  71. gpio_set_direction(GPIO_PORT3, 30, GPIO_GDIR_OUTPUT);
  72. gpio_set_level(GPIO_PORT3, 30, GPIO_HIGH_LEVEL);
  73. #endif
  74. break;
  75. case Host2:
  76. #ifdef BOARD_EVB
  77. #endif
  78. break;
  79. case Host3:
  80. // Nothing to be done here.
  81. break;
  82. default:
  83. // no such controller
  84. break;
  85. }
  86. }
  87. /*!
  88. * This function disables Vbus for the given USB port\n
  89. * The procedure to enable Vbus depends on both the Chip and board hardware\n
  90. * This implementation is for the MX6q Sabre-AI board\n
  91. *
  92. * @param port USB module to initialize
  93. */
  94. void usbDisableVbus(usb_module_t * port)
  95. {
  96. switch (port->controllerID) {
  97. case OTG:
  98. #ifdef BOARD_SABRE_AI
  99. board_ioexpander_iomux_config();
  100. max7310_set_gpio_output(2, 1, 0);
  101. #endif
  102. #if defined(BOARD_EVB) || defined(BOARD_SMART_DEVICE)
  103. gpio_set_level(GPIO_PORT3, 22, GPIO_LOW_LEVEL);
  104. #endif
  105. break;
  106. case Host1:
  107. #ifdef BOARD_SABRE_AI
  108. board_ioexpander_iomux_config();
  109. max7310_set_gpio_output(1, 7, 0);
  110. #endif
  111. #ifdef BOARD_EVB
  112. gpio_set_level(GPIO_PORT3, 31, GPIO_LOW_LEVEL);
  113. #endif
  114. #ifdef BOARD_SMART_DEVICE
  115. gpio_set_level(GPIO_PORT3, 30, GPIO_LOW_LEVEL);
  116. #endif
  117. case Host2:
  118. #ifdef BOARD_EVB
  119. #endif
  120. break;
  121. case Host3:
  122. // Nothing to be done here.
  123. break;
  124. default:
  125. // no such controller
  126. break;
  127. }
  128. }
  129. /*!
  130. * USB HUB reset function
  131. */
  132. void reset_usb_hub(void)
  133. {
  134. }
  135. ////////////////////////////////////////////////////////////////////////////////
  136. // EOF
  137. ////////////////////////////////////////////////////////////////////////////////