ClockControl.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /** @file
  2. Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. Module Name:
  5. ClockControl.c
  6. Abstract:
  7. Sets platform/SKU specific clock routing information.
  8. --*/
  9. #include "PlatformDxe.h"
  10. #include <Protocol/CK505ClockPlatformInfo.h>
  11. //
  12. // Default clock routing informtion (All On)
  13. //
  14. EFI_CLOCK_PLATFORM_INFO mDefClockPolicy = {NULL, 0, NULL, 0, NULL, 0};
  15. //
  16. // Clock Settings
  17. //
  18. // Static clock table.
  19. // This should be used to define any clock settings that are static
  20. // (Always On or Always Off). Dynamic clocks should be set to enabled
  21. // in this table.
  22. //
  23. EFI_STATIC_SIGNALS mAtxStaticClocks[] = {
  24. {SrcClk8, Enabled, All},
  25. {SrcClk7, Enabled, All},
  26. {SrcClk6, Enabled, All},
  27. {SrcClk5, Enabled, All},
  28. {SrcClk4, Enabled, All},
  29. {SrcClk3, Enabled, All},
  30. {SrcClk2, Enabled, All},
  31. {SrcClk1, Enabled, All},
  32. {SrcClk0, Enabled, All},
  33. {Ref0, Enabled, All},
  34. {Dot96, Enabled, All},
  35. {Usb48, Enabled, All},
  36. {PciClkF5, Enabled, All},
  37. {PciClk0, Enabled, All},
  38. {PciClk2, Enabled, All},
  39. {PciClk3, Enabled, All},
  40. {PciClk4, Disabled, All},
  41. {Cr_B, EnabledWithSwitch, All},
  42. };
  43. //
  44. // ClockSxInfo Table
  45. // This is a list of clocks that need to be set to a known state when the
  46. // system enters S4 or S5.
  47. //
  48. EFI_STATIC_SIGNALS mAtxSxClocks[] = {
  49. {SaveClockConfiguration, Disabled, All}
  50. };
  51. //
  52. // ATX settings structure
  53. //
  54. EFI_CLOCK_PLATFORM_INFO mAtxClockSettings = {
  55. mAtxStaticClocks,
  56. sizeof(mAtxStaticClocks) / sizeof(mAtxStaticClocks[0]),
  57. mAtxSxClocks,
  58. sizeof(mAtxSxClocks) / sizeof(mAtxSxClocks[0])
  59. };
  60. VOID
  61. InitializeClockRouting(
  62. )
  63. {
  64. EFI_STATUS Status;
  65. UINTN BoardIdVarSize;
  66. EFI_BOARD_FEATURES BoardIdVar;
  67. EFI_CLOCK_PLATFORM_INFO *ClockPolicy;
  68. EFI_HANDLE Handle;
  69. ClockPolicy = &mDefClockPolicy;
  70. //
  71. // Do modifications based on board type
  72. //
  73. BoardIdVarSize = sizeof (EFI_BOARD_FEATURES);
  74. Status = gRT->GetVariable (
  75. BOARD_FEATURES_NAME,
  76. &gEfiBoardFeaturesGuid,
  77. NULL,
  78. &BoardIdVarSize,
  79. &BoardIdVar
  80. );
  81. if (!EFI_ERROR (Status)) {
  82. //
  83. // Isolate board type information
  84. //
  85. BoardIdVar = BoardIdVar & (B_BOARD_FEATURES_FORM_FACTOR_ATX |
  86. B_BOARD_FEATURES_FORM_FACTOR_BTX |
  87. B_BOARD_FEATURES_FORM_FACTOR_MICRO_ATX |
  88. B_BOARD_FEATURES_FORM_FACTOR_MICRO_BTX);
  89. if (BoardIdVar == B_BOARD_FEATURES_FORM_FACTOR_ATX ||
  90. BoardIdVar == B_BOARD_FEATURES_FORM_FACTOR_MICRO_ATX) {
  91. ClockPolicy = &mAtxClockSettings;
  92. }
  93. }
  94. Handle = NULL;
  95. Status = gBS->InstallProtocolInterface (
  96. &Handle,
  97. &gEfiCk505ClockPlatformInfoGuid,
  98. EFI_NATIVE_INTERFACE,
  99. ClockPolicy
  100. );
  101. ASSERT_EFI_ERROR(Status);
  102. }