0006-sb-intel-lynxpoint-Add-native-thermal-init.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. From 92be49d8422b4bc1c89bb49535f4dc6a01d47295 Mon Sep 17 00:00:00 2001
  2. From: Angel Pons <th3fanbus@gmail.com>
  3. Date: Fri, 6 May 2022 23:22:11 +0200
  4. Subject: [PATCH 06/26] sb/intel/lynxpoint: Add native thermal init
  5. Implement native thermal initialisation for Lynx Point. This is only
  6. needed when MRC.bin is not used.
  7. Change-Id: I4a67a3092d0c2e56bfdacb513a899ef838193cbd
  8. Signed-off-by: Angel Pons <th3fanbus@gmail.com>
  9. ---
  10. .../haswell/native_raminit/raminit_native.c | 1 +
  11. src/southbridge/intel/lynxpoint/Makefile.inc | 2 +-
  12. src/southbridge/intel/lynxpoint/pch.h | 1 +
  13. src/southbridge/intel/lynxpoint/thermal.c | 64 +++++++++++++++++++
  14. 4 files changed, 67 insertions(+), 1 deletion(-)
  15. create mode 100644 src/southbridge/intel/lynxpoint/thermal.c
  16. diff --git a/src/northbridge/intel/haswell/native_raminit/raminit_native.c b/src/northbridge/intel/haswell/native_raminit/raminit_native.c
  17. index ef61d4ee09..dd1f1ec14e 100644
  18. --- a/src/northbridge/intel/haswell/native_raminit/raminit_native.c
  19. +++ b/src/northbridge/intel/haswell/native_raminit/raminit_native.c
  20. @@ -16,6 +16,7 @@ static bool early_init_native(int s3resume)
  21. /** TODO: CPU replacement check must be skipped in warm boots and S3 resumes **/
  22. const bool cpu_replaced = !s3resume && intel_early_me_cpu_replacement_check();
  23. + early_thermal_init();
  24. early_usb_init();
  25. if (!CONFIG(INTEL_LYNXPOINT_LP))
  26. diff --git a/src/southbridge/intel/lynxpoint/Makefile.inc b/src/southbridge/intel/lynxpoint/Makefile.inc
  27. index 0e1f2fe4eb..a9a9b153d6 100644
  28. --- a/src/southbridge/intel/lynxpoint/Makefile.inc
  29. +++ b/src/southbridge/intel/lynxpoint/Makefile.inc
  30. @@ -37,7 +37,7 @@ bootblock-y += early_pch.c
  31. romstage-y += early_usb.c early_me.c me_status.c early_pch.c
  32. romstage-y += pmutil.c
  33. -romstage-$(CONFIG_USE_NATIVE_RAMINIT) += early_pch_native.c early_usb_native.c iobp.c
  34. +romstage-$(CONFIG_USE_NATIVE_RAMINIT) += early_pch_native.c early_usb_native.c iobp.c thermal.c
  35. ifeq ($(CONFIG_INTEL_LYNXPOINT_LP),y)
  36. romstage-y += lp_gpio.c
  37. diff --git a/src/southbridge/intel/lynxpoint/pch.h b/src/southbridge/intel/lynxpoint/pch.h
  38. index ad983d86cf..38a9349220 100644
  39. --- a/src/southbridge/intel/lynxpoint/pch.h
  40. +++ b/src/southbridge/intel/lynxpoint/pch.h
  41. @@ -116,6 +116,7 @@ enum pch_platform_type {
  42. void pch_dmi_setup_physical_layer(void);
  43. void pch_dmi_tc_vc_mapping(u32 vc0, u32 vc1, u32 vcp, u32 vcm);
  44. void early_usb_init(void);
  45. +void early_thermal_init(void);
  46. void usb_ehci_sleep_prepare(pci_devfn_t dev, u8 slp_typ);
  47. void usb_ehci_disable(pci_devfn_t dev);
  48. diff --git a/src/southbridge/intel/lynxpoint/thermal.c b/src/southbridge/intel/lynxpoint/thermal.c
  49. new file mode 100644
  50. index 0000000000..e71969ea0c
  51. --- /dev/null
  52. +++ b/src/southbridge/intel/lynxpoint/thermal.c
  53. @@ -0,0 +1,64 @@
  54. +/* SPDX-License-Identifier: GPL-2.0-or-later */
  55. +
  56. +#include <device/mmio.h>
  57. +#include <device/pci_ops.h>
  58. +#include <southbridge/intel/lynxpoint/pch.h>
  59. +#include <types.h>
  60. +
  61. +#define TBARB_TEMP 0x40000000
  62. +
  63. +#define THERMAL_DEV PCI_DEV(0, 0x1f, 6)
  64. +
  65. +/* Early thermal init, it may need to be done prior to giving ME its memory */
  66. +void early_thermal_init(void)
  67. +{
  68. + /* Program address for temporary BAR */
  69. + pci_write_config32(THERMAL_DEV, 0x40, TBARB_TEMP);
  70. + pci_write_config32(THERMAL_DEV, 0x44, 0);
  71. +
  72. + /* Activate temporary BAR */
  73. + pci_or_config32(THERMAL_DEV, 0x40, 1);
  74. +
  75. + /*
  76. + * BWG section 17.3.1 says:
  77. + *
  78. + * ### Initializing Lynx Point Thermal Sensors ###
  79. + *
  80. + * The System BIOS must perform the following steps to initialize the Lynx
  81. + * Point thermal subsystem device, D31:F6. The System BIOS is required to
  82. + * repeat this process on a resume from Sx. BIOS may enable any or all of
  83. + * the registers below based on OEM's platform configuration. Intel does
  84. + * not recommend a value on some of the registers, since each platform has
  85. + * different temperature trip points and one may enable a trip to cause an
  86. + * SMI while another platform would cause an interrupt instead.
  87. + *
  88. + * The recommended flow for enabling thermal sensor is by setting up various
  89. + * temperature trip points first, followed by enabling the desired trip
  90. + * alert method and then enable the actual sensors from TSEL registers.
  91. + * If this flow is not followed, software will need to take special care
  92. + * to handle false events during setting up those registers.
  93. + */
  94. +
  95. + /* Step 1: Program CTT */
  96. + write16p(TBARB_TEMP + 0x10, 0x0154);
  97. +
  98. + /* Step 2: Clear trip status from TSS and TAS */
  99. + write8p(TBARB_TEMP + 0x06, 0xff);
  100. + write8p(TBARB_TEMP + 0x80, 0xff);
  101. +
  102. + /* Step 3: Program TSGPEN and TSPIEN to zero */
  103. + write8p(TBARB_TEMP + 0x84, 0x00);
  104. + write8p(TBARB_TEMP + 0x82, 0x00);
  105. +
  106. + /*
  107. + * Step 4: If thermal reporting to an EC over SMBus is supported,
  108. + * then write 0x01 to TSREL, else leave at default.
  109. + */
  110. + write8p(TBARB_TEMP + 0x0a, 0x01);
  111. +
  112. + /* Disable temporary BAR */
  113. + pci_and_config32(THERMAL_DEV, 0x40, ~1);
  114. +
  115. + /* Clear temporary BAR address */
  116. + pci_write_config32(THERMAL_DEV, 0x40, 0);
  117. +}
  118. --
  119. 2.39.2