Xhci.asl 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /** @file
  2. *
  3. * Copyright (c) 2019 Linaro, Limited. All rights reserved.
  4. * Copyright (c) 2019 Andrei Warkentin <andrey.warkentin@gmail.com>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause-Patent
  7. *
  8. **/
  9. #include <IndustryStandard/Bcm2711.h>
  10. #include "AcpiTables.h"
  11. /*
  12. * The following can be used to remove parenthesis from
  13. * defined macros that the compiler complains about.
  14. */
  15. #define ISOLATE_ARGS(...) __VA_ARGS__
  16. #define REMOVE_PARENTHESES(x) ISOLATE_ARGS x
  17. #define SANITIZED_PCIE_CPU_MMIO_WINDOW REMOVE_PARENTHESES(PCIE_CPU_MMIO_WINDOW)
  18. #define SANITIZED_PCIE_REG_BASE REMOVE_PARENTHESES(PCIE_REG_BASE)
  19. /*
  20. * According to UEFI boot log for the VLI device on Pi 4.
  21. */
  22. #define XHCI_REG_LENGTH 0x1000
  23. DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI4XHCI", 2)
  24. {
  25. Scope (\_SB_)
  26. {
  27. Device (SCB0) {
  28. Name (_HID, "ACPI0004")
  29. Name (_UID, 0x0)
  30. Name (_CCA, 0x0)
  31. Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings
  32. /*
  33. * Container devices with _DMA must have _CRS, meaning SCB0
  34. * to provide all resources that XHC0 consumes (except
  35. * interrupts).
  36. */
  37. Name (RBUF, ResourceTemplate () {
  38. QWordMemory (ResourceProducer,
  39. ,
  40. MinFixed,
  41. MaxFixed,
  42. NonCacheable,
  43. ReadWrite,
  44. 0x0,
  45. SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN
  46. SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX
  47. 0x0,
  48. 0x1, // LEN
  49. ,
  50. ,
  51. MMIO
  52. )
  53. })
  54. CreateQwordField (RBUF, MMIO._MAX, MMBE)
  55. CreateQwordField (RBUF, MMIO._LEN, MMLE)
  56. Add (MMBE, XHCI_REG_LENGTH - 1, MMBE)
  57. Add (MMLE, XHCI_REG_LENGTH - 1, MMLE)
  58. Return (RBUF)
  59. }
  60. Name (_DMA, ResourceTemplate() {
  61. /*
  62. * XHC0 is limited to DMA to first 3GB. Note this
  63. * only applies to PCIe, not GENET or other devices
  64. * next to the A72.
  65. */
  66. QWordMemory (ResourceProducer,
  67. ,
  68. MinFixed,
  69. MaxFixed,
  70. NonCacheable,
  71. ReadWrite,
  72. 0x0,
  73. 0x0, // MIN
  74. 0xbfffffff, // MAX
  75. 0x0, // TRA
  76. 0xc0000000, // LEN
  77. ,
  78. ,
  79. )
  80. })
  81. Device (XHC0)
  82. {
  83. Name (_HID, "PNP0D10") // _HID: Hardware ID
  84. Name (_UID, 0x0) // _UID: Unique ID
  85. Name (_CCA, 0x0) // _CCA: Cache Coherency Attribute
  86. Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings
  87. Name (RBUF, ResourceTemplate () {
  88. QWordMemory (ResourceConsumer,
  89. ,
  90. MinFixed,
  91. MaxFixed,
  92. NonCacheable,
  93. ReadWrite,
  94. 0x0,
  95. SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN
  96. SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX
  97. 0x0,
  98. 0x1, // LEN
  99. ,
  100. ,
  101. MMIO
  102. )
  103. Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) {
  104. 175
  105. }
  106. })
  107. CreateQwordField (RBUF, MMIO._MAX, MMBE)
  108. CreateQwordField (RBUF, MMIO._LEN, MMLE)
  109. Add (MMBE, XHCI_REG_LENGTH - 1, MMBE)
  110. Add (MMLE, XHCI_REG_LENGTH - 1, MMLE)
  111. Return (RBUF)
  112. }
  113. Method (_INI, 0, Serialized) {
  114. OperationRegion (PCFG, SystemMemory, SANITIZED_PCIE_REG_BASE + PCIE_EXT_CFG_DATA, 0x1000)
  115. Field (PCFG, AnyAcc, NoLock, Preserve) {
  116. VNID, 16, // Vendor ID
  117. DVID, 16, // Device ID
  118. CMND, 16, // Command register
  119. STAT, 16, // Status register
  120. }
  121. // Set command register to:
  122. // 1) decode MMIO (set bit 1)
  123. // 2) enable DMA (set bit 2)
  124. // 3) enable interrupts (clear bit 10)
  125. Debug = "xHCI enable"
  126. Store (0x6, CMND)
  127. }
  128. /*
  129. * Microsoft's USB Device-Specific Methods. See:
  130. * https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/usb-device-specific-method---dsm-
  131. */
  132. Name (DSMU, ToUUID ("ce2ee385-00e6-48cb-9f05-2edb927c4899"))
  133. Method (_DSM, 4, Serialized) {
  134. If (LEqual (Arg0, DSMU)) { // USB capabilities UUID
  135. Switch (ToInteger (Arg2)) {
  136. Case (0) { // Function 0: List of supported functions
  137. Return (Buffer () { 0x41 }) // 0x41 - Functions 0 and 6 supported
  138. }
  139. Case (6) { // Function 6: RegisterAccessType
  140. Return (Buffer () { 0x01 }) // 0x01 - Must use 32bit register access
  141. }
  142. Default { } // Unsupported
  143. }
  144. }
  145. return (Buffer () { 0x00 }) // Return 0x00 for anything unsupported
  146. }
  147. } // end XHC0
  148. } //end SCB0
  149. } //end scope sb
  150. } //end definition block