* [RFC PATCH v2 1/3] hwmon: (asus-ec-sensors) propagate EC read and selector errors
2026-11-28 19:12 [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card John den Heijer
@ 2026-11-28 19:12 ` John den Heijer
2026-11-28 19:17 ` sashiko-bot
2026-11-28 19:12 ` [RFC PATCH v2 2/3] hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM John den Heijer
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: John den Heijer @ 2026-11-28 19:12 UTC (permalink / raw)
To: linux-hwmon; +Cc: eugene.shalygin, linux
On an EC or selector failure, asus_ec_block_read() can continue with a
partial buffer. A successful final bank restore then reports success,
so update_ec_sensors() publishes stale bytes.
Propagate the first error. Attempt selector restoration in its bank,
then restore the original bank. A failed restore also rejects the
update. This changes the failure path for all supported boards.
Signed-off-by: John den Heijer <jdenheijer74@gmail.com>
---
drivers/hwmon/asus-ec-sensors.c | 39 ++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index d0c01b825..6e06256a5 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -1309,7 +1309,7 @@ static int asus_ec_bank_switch(u8 bank, u8 *old)
static int asus_ec_block_read(const struct device *dev,
struct ec_sensors_data *ec)
{
- int ireg, ibank, status;
+ int ireg, ibank, status, restore_status;
u8 bank, reg_bank, prev_bank, select, prev_select;
bool select_saved;
@@ -1330,7 +1330,8 @@ static int asus_ec_block_read(const struct device *dev,
for (ibank = 0; ibank < ec->nr_banks; ibank++) {
if (bank != ec->banks[ibank]) {
bank = ec->banks[ibank];
- if (asus_ec_bank_switch(bank, NULL)) {
+ status = asus_ec_bank_switch(bank, NULL);
+ if (status) {
dev_warn(dev, "EC bank switch to %d failed",
bank);
break;
@@ -1345,24 +1346,36 @@ static int asus_ec_block_read(const struct device *dev,
select = register_select(ec->registers[ireg]);
if (select) {
if (!select_saved) {
- if (ec_read(ASUS_EC_SELECT_REGISTER,
- &prev_select))
- continue;
+ status = ec_read(ASUS_EC_SELECT_REGISTER,
+ &prev_select);
+ if (status)
+ goto restore_select;
select_saved = true;
}
- if (ec_write(ASUS_EC_SELECT_REGISTER, select))
- continue;
+ status = ec_write(ASUS_EC_SELECT_REGISTER, select);
+ if (status)
+ goto restore_select;
}
- ec_read(register_index(ec->registers[ireg]),
- ec->read_buffer + ireg);
+ status = ec_read(register_index(ec->registers[ireg]),
+ ec->read_buffer + ireg);
+ if (status)
+ goto restore_select;
}
+restore_select:
/* restore the selector while still in its bank */
- if (select_saved &&
- ec_write(ASUS_EC_SELECT_REGISTER, prev_select))
- dev_warn(dev, "EC selector restore failed");
+ if (select_saved) {
+ restore_status = ec_write(ASUS_EC_SELECT_REGISTER,
+ prev_select);
+ if (!status)
+ status = restore_status;
+ }
+ if (status)
+ break;
}
- status = asus_ec_bank_switch(prev_bank, NULL);
+ restore_status = asus_ec_bank_switch(prev_bank, NULL);
+ if (!status)
+ status = restore_status;
return status;
}
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [RFC PATCH v2 2/3] hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM
2026-11-28 19:12 [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card John den Heijer
2026-11-28 19:12 ` [RFC PATCH v2 1/3] hwmon: (asus-ec-sensors) propagate EC read and selector errors John den Heijer
@ 2026-11-28 19:12 ` John den Heijer
2026-11-28 19:19 ` sashiko-bot
2026-11-28 19:12 ` [RFC PATCH v2 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors John den Heijer
2026-11-28 19:19 ` [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card sashiko-bot
3 siblings, 1 reply; 7+ messages in thread
From: John den Heijer @ 2026-11-28 19:12 UTC (permalink / raw)
To: linux-hwmon; +Cc: eugene.shalygin, linux
BIOS 2004 reads the three optional extension fan tachometers by writing
selector 0x0a, 0x0b or 0x0c to EC bank-0 register 0x43 and reading the
high and low RPM bytes from 0x57/0x58.
Before the first read, or after a lost latch, the BIOS getter sets bit 7
of 0xd4 and bits 0-2 of 0x89. Reuse the upstream MAXIMUS IX EXTREME
selector path, but add this initialization only for the exact non-WiFi
MAXIMUS XI HERO DMI name. Keep the optional-card support default-off:
a reliable live card-presence detector has not been established.
Signed-off-by: John den Heijer <jdenheijer74@gmail.com>
---
drivers/hwmon/asus-ec-sensors.c | 76 ++++++++++++++++++++++++++++++---
1 file changed, 71 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index 6e06256a5..45beba10f 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -37,6 +37,7 @@
#include <linux/unaligned.h>
static char *mutex_path_override;
+static bool enable_ext_fan;
/* Writing to this EC register switches EC bank */
#define ASUS_EC_BANK_REGISTER 0xff
@@ -45,6 +46,9 @@ static char *mutex_path_override;
* group of registers reports (e.g. one of the fans of the fan extension card).
*/
#define ASUS_EC_SELECT_REGISTER 0x43
+#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5
+#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4
+#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89
#define SENSOR_LABEL_LEN 16
/*
@@ -414,6 +418,12 @@ static const struct ec_sensor_info sensors_family_intel_300[] = {
[ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),
[ec_sensor_fan_water_flow] =
EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xbc),
+ [ec_sensor_fan_ext_1] =
+ EC_SENSOR_SELECT("EXT_FAN1", hwmon_fan, 2, 0x00, 0x57, 0x0a),
+ [ec_sensor_fan_ext_2] =
+ EC_SENSOR_SELECT("EXT_FAN2", hwmon_fan, 2, 0x00, 0x57, 0x0b),
+ [ec_sensor_fan_ext_3] =
+ EC_SENSOR_SELECT("EXT_FAN3", hwmon_fan, 2, 0x00, 0x57, 0x0c),
[ec_sensor_temp_water_in] =
EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00),
[ec_sensor_temp_water_out] =
@@ -484,6 +494,7 @@ static const struct ec_sensor_info sensors_family_intel_700[] = {
struct ec_board_info {
unsigned long sensors;
+ bool ext_fan_capable;
/*
* Defines which mutex to use for guarding access to the state and the
* hardware. Can be either a full path to an AML mutex or the
@@ -593,6 +604,16 @@ static const struct ec_board_info board_info_maximus_xi_hero = {
.family = family_intel_300_series,
};
+static const struct ec_board_info board_info_maximus_xi_hero_ext = {
+ .sensors = SENSOR_SET_TEMP_CHIPSET_CPU_MB |
+ SENSOR_TEMP_T_SENSOR |
+ SENSOR_TEMP_VRM | SENSOR_SET_TEMP_WATER |
+ SENSOR_FAN_CPU_OPT | SENSOR_FAN_WATER_FLOW,
+ .ext_fan_capable = true,
+ .mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX,
+ .family = family_intel_300_series,
+};
+
static const struct ec_board_info board_info_maximus_z690_formula = {
.sensors = SENSOR_TEMP_T_SENSOR | SENSOR_TEMP_VRM |
SENSOR_SET_TEMP_WATER | SENSOR_FAN_WATER_FLOW,
@@ -1004,7 +1025,7 @@ static const struct dmi_system_id dmi_table[] = {
DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR X870E HERO",
&board_info_crosshair_x870e_hero),
DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS XI HERO",
- &board_info_maximus_xi_hero),
+ &board_info_maximus_xi_hero_ext),
DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS XI HERO (WI-FI)",
&board_info_maximus_xi_hero),
DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS X HERO",
@@ -1135,6 +1156,9 @@ static bool unlock_global_acpi_lock(struct lock_data *data)
struct ec_sensors_data {
const struct ec_board_info *board_info;
const struct ec_sensor_info *sensors_info;
+ unsigned long sensor_mask;
+ bool ext_fan_enabled;
+ bool ext_fan_initialized;
struct ec_sensor *sensors;
/*
* EC registers to read from: (select << 16) + (bank << 8) + index,
@@ -1224,8 +1248,8 @@ static void setup_sensor_data(struct ec_sensors_data *ec)
ec->nr_banks = 0;
ec->nr_registers = 0;
- for_each_set_bit(i, &ec->board_info->sensors,
- BITS_PER_TYPE(ec->board_info->sensors)) {
+ for_each_set_bit(i, &ec->sensor_mask,
+ BITS_PER_TYPE(ec->sensor_mask)) {
s->info_index = i;
s->cached_value = 0;
ec->nr_registers +=
@@ -1306,6 +1330,30 @@ static int asus_ec_bank_switch(u8 bank, u8 *old)
return ec_write(ASUS_EC_BANK_REGISTER, bank);
}
+static int asus_ec_prepare_ext_fans(struct ec_sensors_data *ec)
+{
+ u8 enabled, channels;
+ int status;
+
+ status = ec_read(ASUS_EC_EXT_FAN_ENABLE_REGISTER, &enabled);
+ if (status)
+ return status;
+ if (ec->ext_fan_initialized && (enabled & BIT(7)))
+ return 0;
+
+ status = ec_write(ASUS_EC_EXT_FAN_ENABLE_REGISTER, enabled | BIT(7));
+ if (status)
+ return status;
+ status = ec_read(ASUS_EC_EXT_FAN_CHANNEL_REGISTER, &channels);
+ if (status)
+ return status;
+ status = ec_write(ASUS_EC_EXT_FAN_CHANNEL_REGISTER,
+ channels | GENMASK(2, 0));
+ if (!status)
+ ec->ext_fan_initialized = true;
+ return status;
+}
+
static int asus_ec_block_read(const struct device *dev,
struct ec_sensors_data *ec)
{
@@ -1325,6 +1373,11 @@ static int asus_ec_block_read(const struct device *dev,
dev_warn(dev,
"Concurrent access to the ACPI EC detected.\nRace condition possible.");
}
+ if (ec->ext_fan_enabled) {
+ status = asus_ec_prepare_ext_fans(ec);
+ if (status)
+ goto restore_bank;
+ }
/* read registers minimizing bank switches. */
for (ibank = 0; ibank < ec->nr_banks; ibank++) {
@@ -1373,6 +1426,7 @@ restore_select:
break;
}
+restore_bank:
restore_status = asus_ec_bank_switch(prev_bank, NULL);
if (!status)
status = restore_status;
@@ -1503,8 +1557,11 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
return ret;
sensor_info = get_sensor_info(state, sidx);
+ ec_sensor = get_ec_sensor_type(state, sidx);
+ if (state->ext_fan_enabled && ec_sensor >= ec_sensor_fan_ext_1 &&
+ ec_sensor <= ec_sensor_fan_ext_3 && value < ASUS_EC_EXT_FAN_RPM_MIN)
+ value = 0;
if (sensor_info->type == hwmon_temp) {
- ec_sensor = get_ec_sensor_type(state, sidx);
if ((environment_temp_sensors & BIT(ec_sensor)) &&
is_blank_temperature_value(value))
return -ENODATA;
@@ -1601,6 +1658,12 @@ static int asus_ec_probe(struct platform_device *pdev)
ec_data->next_update = INITIAL_JIFFIES;
dev_set_drvdata(dev, ec_data);
ec_data->board_info = pboard_info;
+ ec_data->sensor_mask = pboard_info->sensors;
+ ec_data->ext_fan_enabled = pboard_info->ext_fan_capable &&
+ enable_ext_fan;
+ if (ec_data->ext_fan_enabled)
+ ec_data->sensor_mask |= SENSOR_FAN_EXT_1 |
+ SENSOR_FAN_EXT_2 | SENSOR_FAN_EXT_3;
switch (ec_data->board_info->family) {
case family_amd_400_series:
@@ -1645,7 +1708,7 @@ static int asus_ec_probe(struct platform_device *pdev)
return -EINVAL;
}
- ec_data->nr_sensors = hweight_long(ec_data->board_info->sensors);
+ ec_data->nr_sensors = hweight_long(ec_data->sensor_mask);
ec_data->sensors = devm_kzalloc_objs(dev, struct ec_sensor,
ec_data->nr_sensors);
if (!ec_data->sensors)
@@ -1745,6 +1808,9 @@ module_exit(asus_ec_exit);
module_param_named(mutex_path, mutex_path_override, charp, 0);
MODULE_PARM_DESC(mutex_path,
"Override ACPI mutex path used to guard access to hardware");
+module_param(enable_ext_fan, bool, 0);
+MODULE_PARM_DESC(enable_ext_fan,
+ "Enable Fan Extension Card sensors on ROG MAXIMUS XI HERO");
MODULE_AUTHOR("Eugene Shalygin <eugene.shalygin@gmail.com>");
MODULE_DESCRIPTION(
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [RFC PATCH v2 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
2026-11-28 19:12 [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card John den Heijer
2026-11-28 19:12 ` [RFC PATCH v2 1/3] hwmon: (asus-ec-sensors) propagate EC read and selector errors John den Heijer
2026-11-28 19:12 ` [RFC PATCH v2 2/3] hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM John den Heijer
@ 2026-11-28 19:12 ` John den Heijer
2026-11-28 19:19 ` [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card sashiko-bot
3 siblings, 0 replies; 7+ messages in thread
From: John den Heijer @ 2026-11-28 19:12 UTC (permalink / raw)
To: linux-hwmon; +Cc: eugene.shalygin, linux
BIOS 2004 maps the three optional Fan Extension Card thermistors to EC
bank-0 registers 0x60, 0x61 and 0x62. Its getter writes 0x68=0x07
immediately before each read.
Reproduce that sequence only for the opted-in non-WiFi XI HERO and
return -ENODATA for firmware-invalid values. The bit-level meaning of
0x68 is not established.
Signed-off-by: John den Heijer <jdenheijer74@gmail.com>
---
drivers/hwmon/asus-ec-sensors.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index 45beba10f..09bfccf58 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -49,6 +49,8 @@ static bool enable_ext_fan;
#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5
#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4
#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89
+#define ASUS_EC_EXT_TEMP_PREPARE_REGISTER 0x68
+#define ASUS_EC_EXT_TEMP_PREPARE_VALUE 0x07
#define SENSOR_LABEL_LEN 16
/*
@@ -413,6 +415,13 @@ static const struct ec_sensor_info sensors_family_intel_300[] = {
[ec_sensor_temp_t_sensor] =
EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d),
[ec_sensor_temp_vrm] = EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e),
+ /* BIOS 2004 properties 0x06030032, 0x06030034, 0x06030036 */
+ [ec_sensor_temp_sensor_extra_1] =
+ EC_SENSOR("EXT_Sensor1", hwmon_temp, 1, 0x00, 0x60),
+ [ec_sensor_temp_sensor_extra_2] =
+ EC_SENSOR("EXT_Sensor2", hwmon_temp, 1, 0x00, 0x61),
+ [ec_sensor_temp_sensor_extra_3] =
+ EC_SENSOR("EXT_Sensor3", hwmon_temp, 1, 0x00, 0x62),
[ec_sensor_fan_cpu_opt] =
EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0),
[ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),
@@ -1409,6 +1418,15 @@ static int asus_ec_block_read(const struct device *dev,
if (status)
goto restore_select;
}
+ /* BIOS 2004 performs this write before each EXT probe read. */
+ if (ec->ext_fan_enabled && !bank &&
+ register_index(ec->registers[ireg]) >= 0x60 &&
+ register_index(ec->registers[ireg]) <= 0x62) {
+ status = ec_write(ASUS_EC_EXT_TEMP_PREPARE_REGISTER,
+ ASUS_EC_EXT_TEMP_PREPARE_VALUE);
+ if (status)
+ goto restore_select;
+ }
status = ec_read(register_index(ec->registers[ireg]),
ec->read_buffer + ireg);
if (status)
@@ -1562,6 +1580,10 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
ec_sensor <= ec_sensor_fan_ext_3 && value < ASUS_EC_EXT_FAN_RPM_MIN)
value = 0;
if (sensor_info->type == hwmon_temp) {
+ if (state->ext_fan_enabled &&
+ ec_sensor >= ec_sensor_temp_sensor_extra_1 &&
+ ec_sensor <= ec_sensor_temp_sensor_extra_3 && value < -50)
+ return -ENODATA;
if ((environment_temp_sensors & BIT(ec_sensor)) &&
is_blank_temperature_value(value))
return -ENODATA;
@@ -1663,7 +1685,10 @@ static int asus_ec_probe(struct platform_device *pdev)
enable_ext_fan;
if (ec_data->ext_fan_enabled)
ec_data->sensor_mask |= SENSOR_FAN_EXT_1 |
- SENSOR_FAN_EXT_2 | SENSOR_FAN_EXT_3;
+ SENSOR_FAN_EXT_2 | SENSOR_FAN_EXT_3 |
+ SENSOR_TEMP_SENSOR_EXTRA_1 |
+ SENSOR_TEMP_SENSOR_EXTRA_2 |
+ SENSOR_TEMP_SENSOR_EXTRA_3;
switch (ec_data->board_info->family) {
case family_amd_400_series:
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] 7+ messages in thread