UsbOcUpdateDxe.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /** @file
  2. @copyright
  3. Copyright 2018 - 2021 Intel Corporation. <BR>
  4. Copyright (c) 2021, American Megatrends International LLC. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include "UsbOcUpdateDxe.h"
  8. #include <Library/UbaUsbOcUpdateLib.h>
  9. #include <PchLimits.h>
  10. #include <ConfigBlock/UsbConfig.h>
  11. #include <ConfigBlock/Usb2PhyConfig.h>
  12. USB_OVERCURRENT_PIN TypeJunctionCityUsb20OverCurrentMappings[PCH_MAX_USB2_PORTS] = {
  13. UsbOverCurrentPinSkip, //Port00: BMC
  14. UsbOverCurrentPinSkip, //Port01: BMC
  15. UsbOverCurrentPin0, //Port02: Rear Panel
  16. UsbOverCurrentPin1, //Port03: Rear Panel
  17. UsbOverCurrentPin1, //Port04: Rear Panel
  18. UsbOverCurrentPinSkip, //Port05: NC
  19. UsbOverCurrentPinSkip, //Port06: NC
  20. UsbOverCurrentPin4, //Port07: Type A internal
  21. UsbOverCurrentPinSkip, //Port08: NC
  22. UsbOverCurrentPinSkip, //Port09: NC
  23. UsbOverCurrentPin6, //Port10: Front Panel
  24. UsbOverCurrentPinSkip, //Port11: NC
  25. UsbOverCurrentPin6, //Port12: Front Panel
  26. UsbOverCurrentPinSkip, //Port13: NC
  27. UsbOverCurrentPinSkip,
  28. UsbOverCurrentPinSkip
  29. };
  30. USB_OVERCURRENT_PIN TypeJunctionCityUsb30OverCurrentMappings[PCH_MAX_USB3_PORTS] = {
  31. UsbOverCurrentPin6, //Port01: Front Panel
  32. UsbOverCurrentPin6, //Port02: Front Panel
  33. UsbOverCurrentPin0, //Port03: Rear Panel
  34. UsbOverCurrentPin1, //Port04: Rear Panel
  35. UsbOverCurrentPin1, //Port05: Rear Panel
  36. UsbOverCurrentPinSkip, //Port06: NC
  37. UsbOverCurrentPinSkip,
  38. UsbOverCurrentPinSkip,
  39. UsbOverCurrentPinSkip,
  40. UsbOverCurrentPinSkip
  41. };
  42. USB2_PHY_PARAMETERS TypeJunctionCityUsb20AfeParams[PCH_H_XHCI_MAX_USB2_PHYSICAL_PORTS] = {
  43. {3, 0, 3, 1}, // PP0
  44. {5, 0, 3, 1}, // PP1
  45. {3, 0, 3, 1}, // PP2
  46. {0, 5, 1, 1}, // PP3
  47. {3, 0, 3, 1}, // PP4
  48. {3, 0, 3, 1}, // PP5
  49. {3, 0, 3, 1}, // PP6
  50. {3, 0, 3, 1}, // PP7
  51. {2, 2, 1, 0}, // PP8
  52. {6, 0, 2, 1}, // PP9
  53. {2, 2, 1, 0}, // PP10
  54. {6, 0, 2, 1}, // PP11
  55. {0, 5, 1, 1}, // PP12
  56. {7, 0, 2, 1}, // PP13
  57. };
  58. EFI_STATUS
  59. TypeJunctionCityPlatformUsbOcUpdateCallback (
  60. IN OUT USB_OVERCURRENT_PIN **Usb20OverCurrentMappings,
  61. IN OUT USB_OVERCURRENT_PIN **Usb30OverCurrentMappings,
  62. IN OUT USB2_PHY_PARAMETERS **Usb20AfeParams
  63. )
  64. {
  65. *Usb20OverCurrentMappings = &TypeJunctionCityUsb20OverCurrentMappings[0];
  66. *Usb30OverCurrentMappings = &TypeJunctionCityUsb30OverCurrentMappings[0];
  67. *Usb20AfeParams = TypeJunctionCityUsb20AfeParams;
  68. return EFI_SUCCESS;
  69. }
  70. PLATFORM_USBOC_UPDATE_TABLE TypeJunctionCityUsbOcUpdate =
  71. {
  72. PLATFORM_USBOC_UPDATE_SIGNATURE,
  73. PLATFORM_USBOC_UPDATE_VERSION,
  74. TypeJunctionCityPlatformUsbOcUpdateCallback
  75. };
  76. /**
  77. The Driver Entry Point.
  78. The function is the driver Entry point.
  79. @param ImageHandle A handle for the image that is initializing this driver
  80. @param SystemTable A pointer to the EFI system table
  81. @retval EFI_SUCCESS: Driver initialized successfully
  82. @retval EFI_LOAD_ERROR: Failed to Initialize or has been loaded
  83. @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
  84. **/
  85. EFI_STATUS
  86. EFIAPI
  87. UsbOcUpdateEntry (
  88. IN EFI_HANDLE ImageHandle,
  89. IN EFI_SYSTEM_TABLE *SystemTable
  90. )
  91. {
  92. EFI_STATUS Status;
  93. UBA_CONFIG_DATABASE_PROTOCOL *UbaConfigProtocol = NULL;
  94. DEBUG((DEBUG_INFO, "UBA:UsbOcUpdate-TypeJunctionCity\n"));
  95. Status = gBS->LocateProtocol (
  96. &gUbaConfigDatabaseProtocolGuid,
  97. NULL,
  98. &UbaConfigProtocol
  99. );
  100. if (EFI_ERROR(Status)) {
  101. return Status;
  102. }
  103. Status = UbaConfigProtocol->AddData (
  104. UbaConfigProtocol,
  105. &gDxePlatformUbaOcConfigDataGuid,
  106. &TypeJunctionCityUsbOcUpdate,
  107. sizeof(TypeJunctionCityUsbOcUpdate)
  108. );
  109. return Status;
  110. }