1
0

usb.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. usb.c
  5. Abstract:
  6. This module fires up the RK32xx Veyron's High Speed USB controller.
  7. Author:
  8. Chris Stevens 10-Aug-2015
  9. Environment:
  10. Firmware
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include <uefifw.h>
  16. #include "veyronfw.h"
  17. //
  18. // --------------------------------------------------------------------- Macros
  19. //
  20. //
  21. // These macros read from and write to the GPIO registers.
  22. //
  23. #define RK32_READ_GPIO(_GpioBase, _Register) \
  24. EfiReadRegister32((VOID *)(_GpioBase) + (_Register))
  25. #define RK32_WRITE_GPIO(_GpioBase, _Register, _Value) \
  26. EfiWriteRegister32((VOID *)(_GpioBase) + (_Register), (_Value))
  27. //
  28. // ---------------------------------------------------------------- Definitions
  29. //
  30. //
  31. // Define the GPIO 0 bit values.
  32. //
  33. #define RK32_GPIO0_USB_HOST1_POWER_ENABLE (1 << 3)
  34. #define RK32_GPIO0_USB_OTG_POWER_ENABLE (1 << 4)
  35. //
  36. // Define the GPIO 7 bit values.
  37. //
  38. #define RK32_GPIO7_USB_5V (1 << 5)
  39. //
  40. // ----------------------------------------------- Internal Function Prototypes
  41. //
  42. //
  43. // ------------------------------------------------------ Data Type Definitions
  44. //
  45. //
  46. // -------------------------------------------------------------------- Globals
  47. //
  48. //
  49. // ------------------------------------------------------------------ Functions
  50. //
  51. VOID
  52. EfipVeyronUsbInitialize (
  53. VOID
  54. )
  55. /*++
  56. Routine Description:
  57. This routine performs any board-specific high speed USB initialization.
  58. Arguments:
  59. None.
  60. Return Value:
  61. None.
  62. --*/
  63. {
  64. UINT32 Value;
  65. //
  66. // Enable USB Host 1 power.
  67. //
  68. Value = RK32_READ_GPIO(RK32_GPIO0_BASE, Rk32GpioPortADirection);
  69. Value |= RK32_GPIO0_USB_HOST1_POWER_ENABLE;
  70. RK32_WRITE_GPIO(RK32_GPIO0_BASE, Rk32GpioPortADirection, Value);
  71. Value = RK32_READ_GPIO(RK32_GPIO0_BASE, Rk32GpioPortAData);
  72. Value |= RK32_GPIO0_USB_HOST1_POWER_ENABLE;
  73. RK32_WRITE_GPIO(RK32_GPIO0_BASE, Rk32GpioPortAData, Value);
  74. //
  75. // Enable USB OTG power.
  76. //
  77. Value = RK32_READ_GPIO(RK32_GPIO0_BASE, Rk32GpioPortADirection);
  78. Value |= RK32_GPIO0_USB_OTG_POWER_ENABLE;
  79. RK32_WRITE_GPIO(RK32_GPIO0_BASE, Rk32GpioPortADirection, Value);
  80. Value = RK32_READ_GPIO(RK32_GPIO0_BASE, Rk32GpioPortAData);
  81. Value |= RK32_GPIO0_USB_OTG_POWER_ENABLE;
  82. RK32_WRITE_GPIO(RK32_GPIO0_BASE, Rk32GpioPortAData, Value);
  83. //
  84. // Set USB to 5V.
  85. //
  86. Value = RK32_READ_GPIO(RK32_GPIO7_BASE, Rk32GpioPortADirection);
  87. Value |= RK32_GPIO7_USB_5V;
  88. RK32_WRITE_GPIO(RK32_GPIO7_BASE, Rk32GpioPortADirection, Value);
  89. Value = RK32_READ_GPIO(RK32_GPIO7_BASE, Rk32GpioPortAData);
  90. Value |= RK32_GPIO7_USB_5V;
  91. RK32_WRITE_GPIO(RK32_GPIO7_BASE, Rk32GpioPortAData, Value);
  92. return;
  93. }