UsbOcUpdateDxe.c 4.9 KB

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