Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: thinkpad_acpi: Add dual fan probe

Instead of having quirks for systems that have a second fan it would
be nice to detect this setup.
Unfortunately, confirmed by the Lenovo FW team, there is no way to
retrieve this information from the EC or BIOS. Recommendation was to
attempt to read the fan and if successful then assume a 2nd fan is
present.

The fans are also supposed to spin up on boot for some time, so in
theory we could check for a speed > 0. In testing this seems to hold
true but as I couldn't test on all platforms I've avoided implementing
this. It also breaks for the corner case where you load the module
once the fans are idle.

Tested on P1G4, P1G3, X1C9 and T14 (no fans) and it works correctly.
For the platforms with dual fans where it was confirmed to work I have
removed the quirks. Potentially this could be done for all platforms
but I've left untested platforms in for now. On these platforms the
fans will be enabled and then detected - so no impact.

Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20220222185137.4325-1-markpearson@lenovo.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Mark Pearson and committed by
Hans de Goede
bf779aaf 402576d9

+12 -3
+12 -3
drivers/platform/x86/thinkpad_acpi.c
··· 8698 8698 TPACPI_Q_LNV3('N', '2', 'N', TPACPI_FAN_2CTL), /* P53 / P73 */ 8699 8699 TPACPI_Q_LNV3('N', '2', 'E', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (1st gen) */ 8700 8700 TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (2nd gen) */ 8701 - TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (3nd gen) */ 8702 - TPACPI_Q_LNV3('N', '4', '0', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (4nd gen) */ 8703 8701 TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL), /* P15 (1st gen) / P15v (1st gen) */ 8704 - TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL), /* X1 Carbon (9th gen) */ 8705 8702 TPACPI_Q_LNV3('N', '3', '7', TPACPI_FAN_2CTL), /* T15g (2nd gen) */ 8706 8703 TPACPI_Q_LNV3('N', '1', 'O', TPACPI_FAN_NOFAN), /* X1 Tablet (2nd gen) */ 8707 8704 }; ··· 8742 8745 * ThinkPad ECs supports the fan control register */ 8743 8746 if (likely(acpi_ec_read(fan_status_offset, 8744 8747 &fan_control_initial_status))) { 8748 + int res; 8749 + unsigned int speed; 8750 + 8745 8751 fan_status_access_mode = TPACPI_FAN_RD_TPEC; 8746 8752 if (quirks & TPACPI_FAN_Q1) 8747 8753 fan_quirk1_setup(); ··· 8757 8757 tp_features.second_fan_ctl = 1; 8758 8758 pr_info("secondary fan control enabled\n"); 8759 8759 } 8760 + /* Try and probe the 2nd fan */ 8761 + res = fan2_get_speed(&speed); 8762 + if (res >= 0) { 8763 + /* It responded - so let's assume it's there */ 8764 + tp_features.second_fan = 1; 8765 + tp_features.second_fan_ctl = 1; 8766 + pr_info("secondary fan control detected & enabled\n"); 8767 + } 8768 + 8760 8769 } else { 8761 8770 pr_err("ThinkPad ACPI EC access misbehaving, fan status and control unavailable\n"); 8762 8771 return -ENODEV;