Skip to content

Commit 1be765b

Browse files
vishnuocvjwrdegoede
authored andcommitted
platform/x86: thinkpad_acpi: Fix for ThinkPad's with ECFW showing incorrect fan speed
Fix for Thinkpad's with ECFW showing incorrect fan speed. Some models use decimal instead of hexadecimal for the speed stored in the EC registers. For example the rpm register will have 0x4200 instead of 0x1068, here the actual RPM is "4200" in decimal. Add a quirk to handle this. Signed-off-by: Vishnu Sankar <[email protected]> Suggested-by: Mark Pearson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 36e66be commit 1be765b

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7936,6 +7936,7 @@ static u8 fan_control_resume_level;
79367936
static int fan_watchdog_maxinterval;
79377937

79387938
static bool fan_with_ns_addr;
7939+
static bool ecfw_with_fan_dec_rpm;
79397940

79407941
static struct mutex fan_mutex;
79417942

@@ -8682,7 +8683,11 @@ static ssize_t fan_fan1_input_show(struct device *dev,
86828683
if (res < 0)
86838684
return res;
86848685

8685-
return sysfs_emit(buf, "%u\n", speed);
8686+
/* Check for fan speeds displayed in hexadecimal */
8687+
if (!ecfw_with_fan_dec_rpm)
8688+
return sysfs_emit(buf, "%u\n", speed);
8689+
else
8690+
return sysfs_emit(buf, "%x\n", speed);
86868691
}
86878692

86888693
static DEVICE_ATTR(fan1_input, S_IRUGO, fan_fan1_input_show, NULL);
@@ -8699,7 +8704,11 @@ static ssize_t fan_fan2_input_show(struct device *dev,
86998704
if (res < 0)
87008705
return res;
87018706

8702-
return sysfs_emit(buf, "%u\n", speed);
8707+
/* Check for fan speeds displayed in hexadecimal */
8708+
if (!ecfw_with_fan_dec_rpm)
8709+
return sysfs_emit(buf, "%u\n", speed);
8710+
else
8711+
return sysfs_emit(buf, "%x\n", speed);
87038712
}
87048713

87058714
static DEVICE_ATTR(fan2_input, S_IRUGO, fan_fan2_input_show, NULL);
@@ -8775,6 +8784,7 @@ static const struct attribute_group fan_driver_attr_group = {
87758784
#define TPACPI_FAN_2CTL 0x0004 /* selects fan2 control */
87768785
#define TPACPI_FAN_NOFAN 0x0008 /* no fan available */
87778786
#define TPACPI_FAN_NS 0x0010 /* For EC with non-Standard register addresses */
8787+
#define TPACPI_FAN_DECRPM 0x0020 /* For ECFW's with RPM in register as decimal */
87788788

87798789
static const struct tpacpi_quirk fan_quirk_table[] __initconst = {
87808790
TPACPI_QEC_IBM('1', 'Y', TPACPI_FAN_Q1),
@@ -8803,6 +8813,7 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = {
88038813
TPACPI_Q_LNV3('R', '1', 'D', TPACPI_FAN_NS), /* 11e Gen5 GL-R */
88048814
TPACPI_Q_LNV3('R', '0', 'V', TPACPI_FAN_NS), /* 11e Gen5 KL-Y */
88058815
TPACPI_Q_LNV3('N', '1', 'O', TPACPI_FAN_NOFAN), /* X1 Tablet (2nd gen) */
8816+
TPACPI_Q_LNV3('R', '0', 'Q', TPACPI_FAN_DECRPM),/* L480 */
88068817
};
88078818

88088819
static int __init fan_init(struct ibm_init_struct *iibm)
@@ -8847,6 +8858,13 @@ static int __init fan_init(struct ibm_init_struct *iibm)
88478858
tp_features.fan_ctrl_status_undef = 1;
88488859
}
88498860

8861+
/* Check for the EC/BIOS with RPM reported in decimal*/
8862+
if (quirks & TPACPI_FAN_DECRPM) {
8863+
pr_info("ECFW with fan RPM as decimal in EC register\n");
8864+
ecfw_with_fan_dec_rpm = 1;
8865+
tp_features.fan_ctrl_status_undef = 1;
8866+
}
8867+
88508868
if (gfan_handle) {
88518869
/* 570, 600e/x, 770e, 770x */
88528870
fan_status_access_mode = TPACPI_FAN_RD_ACPI_GFAN;
@@ -9067,7 +9085,11 @@ static int fan_read(struct seq_file *m)
90679085
if (rc < 0)
90689086
return rc;
90699087

9070-
seq_printf(m, "speed:\t\t%d\n", speed);
9088+
/* Check for fan speeds displayed in hexadecimal */
9089+
if (!ecfw_with_fan_dec_rpm)
9090+
seq_printf(m, "speed:\t\t%d\n", speed);
9091+
else
9092+
seq_printf(m, "speed:\t\t%x\n", speed);
90719093

90729094
if (fan_status_access_mode == TPACPI_FAN_RD_TPEC_NS) {
90739095
/*

0 commit comments

Comments
 (0)