Skip to content

Instantly share code, notes, and snippets.

@divi255
Created May 18, 2022 02:11
Show Gist options
  • Save divi255/e8b7e6e9c8e001608c36e51f38d7d6f9 to your computer and use it in GitHub Desktop.
Save divi255/e8b7e6e9c8e001608c36e51f38d7d6f9 to your computer and use it in GitHub Desktop.
Thinkpad 2nd fan patch hack for Linux Kernel 5.13. Forces 2nd fan detection and control. Use at your own risk! (confirmed to work on P15 Gen2)
--- drivers/platform/x86/thinkpad_acpi.c.bak 2021-06-28 00:21:11.000000000 +0200
+++ drivers/platform/x86/thinkpad_acpi.c 2022-05-18 04:07:06.814390699 +0200
@@ -8883,31 +8883,22 @@
quirks = tpacpi_check_quirks(fan_quirk_table,
ARRAY_SIZE(fan_quirk_table));
- if (gfan_handle) {
- /* 570, 600e/x, 770e, 770x */
- fan_status_access_mode = TPACPI_FAN_RD_ACPI_GFAN;
- } else {
- /* all other ThinkPads: note that even old-style
- * ThinkPad ECs supports the fan control register */
- if (likely(acpi_ec_read(fan_status_offset,
- &fan_control_initial_status))) {
- fan_status_access_mode = TPACPI_FAN_RD_TPEC;
- if (quirks & TPACPI_FAN_Q1)
- fan_quirk1_setup();
- if (quirks & TPACPI_FAN_2FAN) {
- tp_features.second_fan = 1;
- pr_info("secondary fan support enabled\n");
- }
- if (quirks & TPACPI_FAN_2CTL) {
- tp_features.second_fan = 1;
- tp_features.second_fan_ctl = 1;
- pr_info("secondary fan control enabled\n");
- }
- } else {
- pr_err("ThinkPad ACPI EC access misbehaving, fan status and control unavailable\n");
- return 1;
- }
- }
+ /*
+ * Force 2nd fan control hack
+ *
+ * Do not apply for 570, 600e/x, 770e, 770x
+ */
+ if (likely(acpi_ec_read(fan_status_offset,
+ &fan_control_initial_status))) {
+ fan_status_access_mode = TPACPI_FAN_RD_TPEC;
+ fan_quirk1_setup();
+ tp_features.second_fan = 1;
+ tp_features.second_fan_ctl = 1;
+ pr_info("secondary fan control enabled\n");
+ } else {
+ pr_err("ThinkPad ACPI EC access misbehaving, fan status and control unavailable\n");
+ return 1;
+ }
if (sfan_handle) {
/* 570, 770x-JL */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment