* [PATCH v2 0/2] hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver
@ 2026-11-19 16:02 Benedikt Niedermayr
2026-11-19 16:02 ` [PATCH v2 1/2] " Benedikt Niedermayr
2026-11-19 16:02 ` [PATCH v2 2/2] docs: hwmon: introduce simatic-ipc-ec-sensors Benedikt Niedermayr
0 siblings, 2 replies; 5+ messages in thread
From: Benedikt Niedermayr @ 2026-11-19 16:02 UTC (permalink / raw)
To: linux; +Cc: linux-hwmon
Hi,
this patch adds a hardware monitoring driver for the embedded controller on
Siemens SIMATIC IPC BX-54A systems.
The driver loads directly via ACPI "_HID" which is reserved for Siemens.
See commit for more information.
I'm not the original author of this driver but I reviewed it as carefully as
possible and I would step in as maintainer for it.
This patch does not enable the hardware platform on which this controller is
present.
Instead I just routed the enablement through the i2c tree, which is currently
in review [1].git l
I wasn't expecting the review to take that long, so it's maybe better to route
the platform enablements through this tree instead... I dont know...
changes since v1:
- fix typo (drviers -> drivers) in a comment
- improve fan speed decoding (my own AI finding -> considers little-endian)
- Sashiko review:
- add documentation leaning a bit towards asus_ec_sensors.rst
- sanitize chip_name in simatic_ipc_ec_fan_probe()
- temp channel config: Move to a static approach.
Use a static array sized for the maximum number of channels that fit into
the 256 byte EC address space.
Also reject configurations (from the firmware) that exceed this limit.
IMHO this was only a theoretical issue since there is only a single EC.
- fix uninitialized reads on ec_read()
- validate pwm_enable
- clamp before cast in simatic_ipc_ec_temp_write()
- fix pointer-sign mismatch passing s8 to ec_read()
- fix wrong assignment to temp*_min_alarm and temp*_max_alarm
[1] https://patchwork.ozlabs.org/project/linux-i2c/patch/20261116142351.1228943-4-benedikt.niedermayr@siemens.com/
Best regards,
Benedikt
Benedikt Niedermayr (2):
hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver
docs: hwmon: introduce simatic-ipc-ec-sensors
Documentation/hwmon/index.rst | 1 +
.../hwmon/simatic-ipc-ec-sensors.rst | 64 ++
MAINTAINERS | 7 +
drivers/hwmon/Kconfig | 11 +
drivers/hwmon/Makefile | 1 +
drivers/hwmon/simatic-ipc-ec-sensors.c | 577 ++++++++++++++++++
6 files changed, 661 insertions(+)
create mode 100644 Documentation/hwmon/simatic-ipc-ec-sensors.rst
create mode 100644 drivers/hwmon/simatic-ipc-ec-sensors.c
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver
2026-11-19 16:02 [PATCH v2 0/2] hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver Benedikt Niedermayr
@ 2026-11-19 16:02 ` Benedikt Niedermayr
2026-11-19 16:18 ` sashiko-bot
2026-11-19 16:02 ` [PATCH v2 2/2] docs: hwmon: introduce simatic-ipc-ec-sensors Benedikt Niedermayr
1 sibling, 1 reply; 5+ messages in thread
From: Benedikt Niedermayr @ 2026-11-19 16:02 UTC (permalink / raw)
To: linux; +Cc: linux-hwmon
Add a hardware monitoring driver for the embedded controller on
Siemens SIMATIC IPC BX-54A systems.
The driver binds to ACPI devices with HID prefix "110A" which is
currently a registered PCI ID for Siemens [1].
Looking at Dell, HP, Lenovo and ASUS this seems to be a common pattern
where vendors define custom ACPI tables for platform-specific features
that are not covered by standard ACPI tables (used by the ACPI EC
driver at drivers/acpi/ec.c).
[1] https://admin.pci-ids.ucw.cz/read/PC/110a
Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
MAINTAINERS | 6 +
drivers/hwmon/Kconfig | 11 +
drivers/hwmon/Makefile | 1 +
drivers/hwmon/simatic-ipc-ec-sensors.c | 577 +++++++++++++++++++++++++
4 files changed, 595 insertions(+)
create mode 100644 drivers/hwmon/simatic-ipc-ec-sensors.c
diff --git a/MAINTAINERS b/MAINTAINERS
index e70b2621ddb8..d54fc6b8c60e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25908,6 +25908,12 @@ F: drivers/media/mmc/siano/
F: drivers/media/usb/siano/
F: drivers/media/usb/siano/
+SIEMENS IPC EC SENSORS DRIVER
+M: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
+L: linux-hwmon@vger.kernel.org
+S: Maintained
+F: drivers/hwmon/simatic-ipc-ec-sensors.c
+
SIEMENS IPC LED DRIVERS
M: Bao Cheng Su <baocheng.su@siemens.com>
M: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 576ddbfec7ab..6a319c963cd3 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -2931,6 +2931,17 @@ config SENSORS_HP_WMI
This driver can also be built as a module. If so, the module
will be called hp_wmi_sensors.
+config SENSORS_SIMATIC_IPC_EC
+ tristate "Siemens SIMATIC IPC EC Sensors"
+ depends on X86
+ depends on ACPI_EC
+ help
+ If you say yes here you get support for the Embedded Controller (EC)
+ sensors and fan control on Siemens SIMATIC IPCs (e.g. BX54-A).
+
+ This driver can also be built as a module. If so, the module
+ will be called simatic-ipc-ec-sensors.
+
endif # ACPI
endif # HWMON
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 3ee099699f6f..e3faffbde6e3 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_ASUS_EC) += asus-ec-sensors.o
obj-$(CONFIG_SENSORS_ASUS_WMI) += asus_wmi_sensors.o
obj-$(CONFIG_SENSORS_HONOR_FMI) += honor-fmi.o
obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o
+obj-$(CONFIG_SENSORS_SIMATIC_IPC_EC) += simatic-ipc-ec-sensors.o
# Native drivers
# asb100, then w83781d go first, as they can override other drivers' addresses.
diff --git a/drivers/hwmon/simatic-ipc-ec-sensors.c b/drivers/hwmon/simatic-ipc-ec-sensors.c
new file mode 100644
index 000000000000..05a48faaa1b0
--- /dev/null
+++ b/drivers/hwmon/simatic-ipc-ec-sensors.c
@@ -0,0 +1,577 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Driver for sensors and fan control on Siemens SIMATIC IPC embedded controllers.
+ *
+ * Due to historical reasons the ACPI description for the ec doesn't
+ * follow the standard ACPI descriptions for fans and hwmon sensors (using
+ * the generic drivers/acpi/ec.c driver).
+ *
+ * This driver binds to Siemens SIMATIC IPC embedded controller sensor devices.
+ *
+ * Copyright (c) Siemens AG, 2025-2026
+ *
+ * Authors:
+ * Gao Nian <nian.gao@siemens.com>
+ * Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
+ */
+#include <linux/acpi.h>
+#include <linux/ctype.h>
+#include <linux/err.h>
+#include <linux/hwmon.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/unaligned.h>
+
+/*
+ * The ACPI ID domain "110A" belongs to Siemens
+ * https://admin.pci-ids.ucw.cz/read/PC/110a
+ */
+#define SIEMENS_FAN_HID "110A5002"
+#define SIEMENS_HWMON_HID "110A5004"
+
+/*
+ * All temperature sensors are located in an ACPI device with SIEMENS_HWMON_HID.
+ */
+#define TEMP_REG_CTR_STATUS 0 /* u8 */
+#define TEMP_REG_VALUE 1 /* char */
+#define TEMP_REG_ALARM_LOWLIMIT 2 /* char */
+#define TEMP_REG_ALARM_HIGHLIMIT 3 /* char */
+#define TEMP_REG_CRITICAL 4 /* char */
+
+#define SIZE_OF_TEMP_REG 5
+
+/* Each channel uses SIZE_OF_TEMP_REG bytes of the 256 byte EC address space */
+#define TEMP_MAX_CHANNELS (256 / SIZE_OF_TEMP_REG)
+
+#define CRITICAL_SUPPORT BIT(5)
+#define ALARM_SUPPORT BIT(4)
+
+/*
+ * Each fan device is a separate ACPI device with the same SIEMENS_FAN_HID.
+ */
+#define FAN_REG_CTR_STATUS 0 /* u8 */
+#define FAN_REG_SPEED 1 /* u16 */
+#define FAN_REG_MODE 3 /* u8 */
+#define FAN_REG_DUTY_LEVEL 4 /* u8 */
+
+/*
+ * CONTROL MODE:
+ * 0: Full speed
+ * 1: Manual fan speed control enabled
+ * 2: Automatic fan speed control enabled
+ */
+#define CONTROL_MODE_MASK (BIT(1) | BIT(0))
+#define CONTROL_MODE_GET(mode) ((mode) & CONTROL_MODE_MASK)
+
+struct simatic_ipc_ec_temp {
+ u8 base;
+ u8 count;
+};
+
+struct simatic_ipc_ec_fan {
+ u8 base;
+ const char *label;
+};
+
+struct simatic_ipc_ec_sensor {
+ struct simatic_ipc_ec_temp *temp; /* Optional */
+ struct simatic_ipc_ec_fan *fan; /* Optional */
+};
+
+static inline u8 temp_reg(u8 base, u8 ch, u8 offset)
+{
+ return base + ch * SIZE_OF_TEMP_REG + offset;
+}
+
+static inline u8 fan_reg(u8 base, u8 offset)
+{
+ return base + offset;
+}
+
+static umode_t simatic_ipc_ec_temp_is_visible(const struct simatic_ipc_ec_temp *temp,
+ u32 attr, int channel)
+{
+ switch (attr) {
+ case hwmon_temp_input:
+ return 0444;
+ case hwmon_temp_max:
+ case hwmon_temp_min:
+ case hwmon_temp_crit:
+ return 0644;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int simatic_ipc_ec_temp_read(const struct simatic_ipc_ec_temp *temp, u32 attr,
+ int channel, long *val)
+{
+ u8 value;
+ int ret;
+ u8 reg;
+
+ switch (attr) {
+ case hwmon_temp_input:
+ reg = temp_reg(temp->base, channel, TEMP_REG_VALUE);
+ break;
+ case hwmon_temp_max:
+ reg = temp_reg(temp->base, channel, TEMP_REG_ALARM_HIGHLIMIT);
+ break;
+ case hwmon_temp_min:
+ reg = temp_reg(temp->base, channel, TEMP_REG_ALARM_LOWLIMIT);
+ break;
+ case hwmon_temp_crit:
+ reg = temp_reg(temp->base, channel, TEMP_REG_CRITICAL);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ ret = ec_read(reg, &value);
+ if (ret < 0)
+ return ret;
+
+ /* Signed degree Celsius to millidegree Celsius */
+ *val = (s8)value * 1000;
+
+ return 0;
+}
+
+static int simatic_ipc_ec_temp_write(const struct simatic_ipc_ec_temp *temp, u32 attr,
+ int channel, long val)
+{
+ s8 value;
+ u8 reg;
+
+ switch (attr) {
+ case hwmon_temp_max:
+ reg = temp_reg(temp->base, channel, TEMP_REG_ALARM_HIGHLIMIT);
+ break;
+ case hwmon_temp_min:
+ reg = temp_reg(temp->base, channel, TEMP_REG_ALARM_LOWLIMIT);
+ break;
+ case hwmon_temp_crit:
+ reg = temp_reg(temp->base, channel, TEMP_REG_CRITICAL);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ /* Millidegree Celsius to signed degree Celsius */
+ val = clamp_val(val, S8_MIN * 1000L, S8_MAX * 1000L);
+ value = DIV_ROUND_CLOSEST(val, 1000);
+
+ return ec_write(reg, (u8)value);
+}
+
+static umode_t simatic_ipc_ec_fan_is_visible(const struct simatic_ipc_ec_fan *fan,
+ enum hwmon_sensor_types type, u32 attr,
+ int channel)
+{
+ switch (type) {
+ case hwmon_fan:
+ switch (attr) {
+ case hwmon_fan_input:
+ case hwmon_fan_label:
+ return 0444;
+ default:
+ break;
+ }
+ break;
+ case hwmon_pwm:
+ switch (attr) {
+ case hwmon_pwm_input:
+ case hwmon_pwm_enable:
+ return 0644;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int simatic_ipc_ec_read_block(u8 addr, u8 *buf, u8 n)
+{
+ int ret;
+ u8 i;
+
+ for (i = 0; i < n; i++) {
+ ret = ec_read(addr + i, &buf[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int simatic_ipc_ec_fan_read(struct simatic_ipc_ec_fan *fan, enum hwmon_sensor_types type,
+ u32 attr, int channel, long *val)
+{
+ u8 buf[2];
+ u8 value;
+ int ret;
+
+ switch (type) {
+ case hwmon_fan:
+ switch (attr) {
+ case hwmon_fan_input:
+ ret = simatic_ipc_ec_read_block(fan_reg(fan->base, FAN_REG_SPEED),
+ buf, sizeof(buf));
+ if (ret < 0)
+ return ret;
+ *val = get_unaligned_le16(buf);
+ return 0;
+ default:
+ break;
+ }
+ break;
+ case hwmon_pwm:
+ switch (attr) {
+ case hwmon_pwm_input:
+ ret = ec_read(fan_reg(fan->base, FAN_REG_DUTY_LEVEL), &value);
+ if (ret < 0)
+ return ret;
+ *val = value;
+ return 0;
+ case hwmon_pwm_enable:
+ ret = ec_read(fan_reg(fan->base, FAN_REG_MODE), &value);
+ if (ret < 0)
+ return ret;
+ *val = CONTROL_MODE_GET(value);
+ return 0;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static int simatic_ipc_ec_fan_read_string(struct simatic_ipc_ec_fan *fan, u32 attr,
+ const char **str)
+{
+ switch (attr) {
+ case hwmon_fan_label:
+ *str = fan->label;
+ return 0;
+ default:
+ break;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static int simatic_ipc_ec_fan_set_control_mode(struct simatic_ipc_ec_fan *fan, u8 ctrl_mode)
+{
+ int ret;
+ u8 mode;
+
+ ret = ec_read(fan_reg(fan->base, FAN_REG_MODE), &mode);
+ if (ret < 0)
+ return ret;
+
+ mode &= ~CONTROL_MODE_MASK;
+ mode |= ctrl_mode;
+
+ ret = ec_write(fan_reg(fan->base, FAN_REG_MODE), mode);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int simatic_ipc_ec_fan_write(struct simatic_ipc_ec_fan *fan, u32 attr, int channel,
+ long val)
+{
+ switch (attr) {
+ case hwmon_pwm_input:
+ if (val < 0 || val > 0xFF)
+ return -EINVAL;
+ return ec_write(fan_reg(fan->base, FAN_REG_DUTY_LEVEL), (u8)val);
+ case hwmon_pwm_enable:
+ /* 0: full speed, 1: manual control, 2: auto-control */
+ if (val < 0 || val > 2)
+ return -EINVAL;
+ return simatic_ipc_ec_fan_set_control_mode(fan, val);
+ default:
+ break;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static umode_t simatic_ipc_ec_is_visible(const void *drvdata, enum hwmon_sensor_types type,
+ u32 attr, int channel)
+{
+ const struct simatic_ipc_ec_sensor *data = drvdata;
+ umode_t ret = 0;
+
+ switch (type) {
+ case hwmon_temp:
+ if (data->temp)
+ ret = simatic_ipc_ec_temp_is_visible(data->temp, attr, channel);
+ break;
+ case hwmon_fan:
+ case hwmon_pwm:
+ if (data->fan)
+ ret = simatic_ipc_ec_fan_is_visible(data->fan, type, attr, channel);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+static int simatic_ipc_ec_read(struct device *dev, enum hwmon_sensor_types type,
+ u32 attr, int channel, long *val)
+{
+ struct simatic_ipc_ec_sensor *data = dev_get_drvdata(dev);
+
+ switch (type) {
+ case hwmon_temp:
+ return simatic_ipc_ec_temp_read(data->temp, attr, channel, val);
+ case hwmon_fan:
+ case hwmon_pwm:
+ return simatic_ipc_ec_fan_read(data->fan, type, attr, channel, val);
+ default:
+ break;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static int simatic_ipc_ec_read_string(struct device *dev, enum hwmon_sensor_types type,
+ u32 attr, int channel, const char **str)
+{
+ struct simatic_ipc_ec_sensor *data = dev_get_drvdata(dev);
+
+ switch (type) {
+ case hwmon_fan:
+ case hwmon_pwm:
+ return simatic_ipc_ec_fan_read_string(data->fan, attr, str);
+ default:
+ break;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static int simatic_ipc_ec_write(struct device *dev, enum hwmon_sensor_types type,
+ u32 attr, int channel, long val)
+{
+ struct simatic_ipc_ec_sensor *data = dev_get_drvdata(dev);
+
+ switch (type) {
+ case hwmon_temp:
+ return simatic_ipc_ec_temp_write(data->temp, attr, channel, val);
+ case hwmon_fan:
+ case hwmon_pwm:
+ return simatic_ipc_ec_fan_write(data->fan, attr, channel, val);
+ default:
+ break;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static const struct hwmon_ops simatic_ipc_ec_ops = {
+ .is_visible = simatic_ipc_ec_is_visible,
+ .read = simatic_ipc_ec_read,
+ .read_string = simatic_ipc_ec_read_string,
+ .write = simatic_ipc_ec_write,
+};
+
+/*
+ * The number of temperature sensor's channels comes from ACPI as it may be different for
+ * different projects. One extra zeroed entry terminates the array.
+ */
+static u32 simatic_ipc_ec_temp_config[TEMP_MAX_CHANNELS + 1];
+
+static struct hwmon_channel_info simatic_ipc_ec_temp_ch_info = {
+ .type = hwmon_temp,
+ .config = simatic_ipc_ec_temp_config,
+};
+
+static const struct hwmon_channel_info * const simatic_ipc_ec_hwmon_ch_info[] = {
+ &simatic_ipc_ec_temp_ch_info,
+ NULL
+};
+
+static const struct hwmon_channel_info * const simatic_ipc_ec_fan_ch_info[] = {
+ HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL),
+ HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT | HWMON_PWM_ENABLE),
+ NULL
+};
+
+static const struct hwmon_chip_info simatic_ipc_ec_hwmon_info = {
+ .ops = &simatic_ipc_ec_ops,
+ .info = simatic_ipc_ec_hwmon_ch_info,
+};
+
+static const struct hwmon_chip_info simatic_ipc_ec_fan_info = {
+ .ops = &simatic_ipc_ec_ops,
+ .info = simatic_ipc_ec_fan_ch_info,
+};
+
+static int simatic_ipc_ec_hwmon_probe(struct device *dev, struct simatic_ipc_ec_sensor *data)
+{
+ struct simatic_ipc_ec_temp *temp;
+ struct device *hwmon_dev;
+ u8 temp_count;
+ u8 temp_base;
+ u8 value;
+ int ret;
+ u8 ch;
+
+ ret = device_property_read_u8(dev, "TempRegOffset", &temp_base);
+ if (ret < 0)
+ return ret;
+
+ ret = device_property_read_u8(dev, "TempCount", &temp_count);
+ if (ret < 0)
+ return ret;
+
+ if (temp_base + temp_count * SIZE_OF_TEMP_REG > 256)
+ return -EINVAL;
+
+ temp = devm_kzalloc(dev, sizeof(*temp), GFP_KERNEL);
+ if (!temp)
+ return -ENOMEM;
+
+ /* Clear flags left over from a previous probe */
+ memset(simatic_ipc_ec_temp_config, 0, sizeof(simatic_ipc_ec_temp_config));
+
+ temp->base = temp_base;
+ temp->count = temp_count;
+
+ data->temp = temp;
+
+ /* Dynamically create temperature sensor channels */
+ for (ch = 0; ch < temp_count; ch++) {
+ ret = ec_read(temp_reg(temp_base, ch, TEMP_REG_CTR_STATUS), &value);
+ if (ret < 0)
+ return ret;
+
+ simatic_ipc_ec_temp_config[ch] |= HWMON_T_INPUT;
+
+ if (value & ALARM_SUPPORT)
+ simatic_ipc_ec_temp_config[ch] |= HWMON_T_MIN | HWMON_T_MAX;
+
+ if (value & CRITICAL_SUPPORT)
+ simatic_ipc_ec_temp_config[ch] |= HWMON_T_CRIT;
+ }
+
+ hwmon_dev = devm_hwmon_device_register_with_info(dev, "simatic_ipc_ec_hwmon",
+ data, &simatic_ipc_ec_hwmon_info,
+ NULL);
+
+ return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static int simatic_ipc_ec_fan_probe(struct device *dev, struct simatic_ipc_ec_sensor *data)
+{
+ struct device *hwmon_dev;
+ struct simatic_ipc_ec_fan *fan;
+ const char *label, *fan_name = NULL;
+ char *chip_name, *p;
+ u8 fan_base;
+ int ret;
+
+ ret = device_property_read_u8(dev, "RegOffset", &fan_base);
+ if (ret < 0)
+ return ret;
+
+ ret = device_property_read_string(dev, "Label", &label);
+ if (ret < 0)
+ return ret;
+
+ device_property_read_string(dev, "FanName", &fan_name);
+
+ fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL);
+ if (!fan)
+ return -ENOMEM;
+
+ fan->base = fan_base;
+ fan->label = fan_name ? fan_name : label;
+
+ chip_name = devm_kasprintf(dev, GFP_KERNEL, "simatic_ipc_ec_%s", fan->label);
+ if (!chip_name)
+ return -ENOMEM;
+
+ chip_name = devm_hwmon_sanitize_name(dev, chip_name);
+ if (IS_ERR(chip_name))
+ return PTR_ERR(chip_name);
+
+ for (p = chip_name; *p; p++)
+ *p = tolower(*p);
+
+ data->fan = fan;
+
+ hwmon_dev = devm_hwmon_device_register_with_info(dev, chip_name, data,
+ &simatic_ipc_ec_fan_info,
+ NULL);
+
+ return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static int simatic_ipc_ec_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct simatic_ipc_ec_sensor *data;
+ const char *hid;
+ int ret;
+
+ /* The same HID sensor device may not be on the EC. */
+ ret = device_property_match_string(dev, "ChipType", "ec");
+ if (ret < 0)
+ return -ENODEV;
+
+ hid = acpi_device_hid(to_acpi_device_node(dev->fwnode));
+
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ if (!strcmp(hid, SIEMENS_HWMON_HID))
+ ret = simatic_ipc_ec_hwmon_probe(dev, data);
+ else if (!strcmp(hid, SIEMENS_FAN_HID))
+ ret = simatic_ipc_ec_fan_probe(dev, data);
+ else
+ ret = -EINVAL;
+
+ return ret;
+}
+
+static const struct acpi_device_id simatic_ipc_ec_sensors_ids[] = {
+ {SIEMENS_HWMON_HID},
+ {SIEMENS_FAN_HID},
+ {}
+};
+
+MODULE_DEVICE_TABLE(acpi, simatic_ipc_ec_sensors_ids);
+
+static struct platform_driver simatic_ipc_ec_sensors_driver = {
+ .probe = simatic_ipc_ec_probe,
+ .driver = {
+ .name = KBUILD_MODNAME,
+ .acpi_match_table = simatic_ipc_ec_sensors_ids
+ },
+};
+
+module_platform_driver(simatic_ipc_ec_sensors_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Gao Nian <nian.gao@siemens.com>");
+MODULE_DESCRIPTION("Siemens SIMATIC IPC embedded controller sensors driver");
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] docs: hwmon: introduce simatic-ipc-ec-sensors
2026-11-19 16:02 [PATCH v2 0/2] hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver Benedikt Niedermayr
2026-11-19 16:02 ` [PATCH v2 1/2] " Benedikt Niedermayr
@ 2026-11-19 16:02 ` Benedikt Niedermayr
2026-11-19 16:07 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Benedikt Niedermayr @ 2026-11-19 16:02 UTC (permalink / raw)
To: linux; +Cc: linux-hwmon
Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
Documentation/hwmon/index.rst | 1 +
.../hwmon/simatic-ipc-ec-sensors.rst | 64 +++++++++++++++++++
MAINTAINERS | 1 +
3 files changed, 66 insertions(+)
create mode 100644 Documentation/hwmon/simatic-ipc-ec-sensors.rst
diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 2167e04ef573..2ecc46d906f7 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -255,6 +255,7 @@ Hardware Monitoring Kernel Drivers
sht3x
sht4x
shtc1
+ simatic-ipc-ec-sensors
sis5595
sl28cpld
stef48h28
diff --git a/Documentation/hwmon/simatic-ipc-ec-sensors.rst b/Documentation/hwmon/simatic-ipc-ec-sensors.rst
new file mode 100644
index 000000000000..4a6c005f29a6
--- /dev/null
+++ b/Documentation/hwmon/simatic-ipc-ec-sensors.rst
@@ -0,0 +1,64 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+Kernel driver simatic-ipc-ec-sensors
+====================================
+
+Supported systems:
+
+ * Siemens SIMATIC IPC BX-54A
+
+ Prefix: 'simatic_ipc_ec_hwmon', 'simatic_ipc_ec_<fan name>'
+
+ Addresses: embedded controller (EC) address space, described by ACPI
+
+Authors:
+
+ - Gao Nian <nian.gao@siemens.com>
+ - Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
+
+Description
+-----------
+
+This driver exposes the temperature sensors and fans managed by the embedded
+controller (EC) of Siemens SIMATIC IPCs.
+
+The firmware describes these sensors with vendor specific ACPI devices instead
+of following the standard ACPI EC model, so they are not covered by the
+generic ACPI drivers.
+
+Only the temperature limits supported by the EC are exposed.
+
+A separate hwmon device is registered for each fan.
+
+Sysfs attributes
+----------------
+
+Temperature device (``simatic_ipc_ec_hwmon``):
+
+======================= ==== ==================================================
+Name Perm Description
+======================= ==== ==================================================
+``temp[1-*]_input`` RO Temperature in millidegree Celsius.
+``temp[1-*]_min`` RW Low temperature limit in millidegree Celsius.
+``temp[1-*]_max`` RW High temperature limit in millidegree Celsius.
+``temp[1-*]_crit`` RW Critical temperature limit in millidegree Celsius.
+======================= ==== ==================================================
+
+Temperature values and limits are stored by the EC as signed degree Celsius,
+so written values are rounded to whole degrees and clamped to the range
+-128000 to 127000.
+
+Fan device (``simatic_ipc_ec_<fan name>``):
+
+======================= ==== ==================================================
+Name Perm Description
+======================= ==== ==================================================
+fan1_input RO Fan speed in RPM.
+fan1_label RO Fan name as provided by the firmware.
+pwm1 RW Fan duty level (0-255).
+pwm1_enable RW Fan control mode:
+
+ - 0: full speed
+ - 1: manual control via ``pwm1``
+ - 2: automatic control by the EC
+======================= ==== ==================================================
diff --git a/MAINTAINERS b/MAINTAINERS
index d54fc6b8c60e..5ed0dd24dc7b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25912,6 +25912,7 @@ SIEMENS IPC EC SENSORS DRIVER
M: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
L: linux-hwmon@vger.kernel.org
S: Maintained
+F: Documentation/hwmon/simatic-ipc-ec-sensors.rst
F: drivers/hwmon/simatic-ipc-ec-sensors.c
SIEMENS IPC LED DRIVERS
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] docs: hwmon: introduce simatic-ipc-ec-sensors
2026-11-19 16:02 ` [PATCH v2 2/2] docs: hwmon: introduce simatic-ipc-ec-sensors Benedikt Niedermayr
@ 2026-11-19 16:07 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-19 16:07 UTC (permalink / raw)
To: Benedikt Niedermayr; +Cc: linux-hwmon
> Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119160210.1257890-1-benedikt.niedermayr@siemens.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver
2026-11-19 16:02 ` [PATCH v2 1/2] " Benedikt Niedermayr
@ 2026-11-19 16:18 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-19 16:18 UTC (permalink / raw)
To: Benedikt Niedermayr; +Cc: linux-hwmon
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] hwmon: shared mutable temp config array in
simatic_ipc_ec_hwmon_probe()
--
commit d1d68eaeccfb28c478d4c0f38bfdd8c663f3ba61
Author: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver
This commit adds a hardware monitoring driver for temperature sensors and
fan control on the embedded controller of Siemens SIMATIC IPC BX-54A
systems.
> diff --git a/drivers/hwmon/simatic-ipc-ec-sensors.c b/drivers/hwmon/simatic-ipc-ec-sensors.c
> new file mode 100644
> index 0000000000000..05a48faaa1b0d
> --- /dev/null
> +++ b/drivers/hwmon/simatic-ipc-ec-sensors.c
[ ... ]
> +/*
> + * The number of temperature sensor's channels comes from ACPI as it may be different for
> + * different projects. One extra zeroed entry terminates the array.
> + */
> +static u32 simatic_ipc_ec_temp_config[TEMP_MAX_CHANNELS + 1];
> +
> +static struct hwmon_channel_info simatic_ipc_ec_temp_ch_info = {
> + .type = hwmon_temp,
> + .config = simatic_ipc_ec_temp_config,
> +};
> +
> +static const struct hwmon_channel_info * const simatic_ipc_ec_hwmon_ch_info[] = {
> + &simatic_ipc_ec_temp_ch_info,
> + NULL
> +};
> +
> +static const struct hwmon_channel_info * const simatic_ipc_ec_fan_ch_info[] = {
> + HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL),
> + HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT | HWMON_PWM_ENABLE),
> + NULL
> +};
> +
> +static const struct hwmon_chip_info simatic_ipc_ec_hwmon_info = {
> + .ops = &simatic_ipc_ec_ops,
> + .info = simatic_ipc_ec_hwmon_ch_info,
> +};
> +
> +static const struct hwmon_chip_info simatic_ipc_ec_fan_info = {
> + .ops = &simatic_ipc_ec_ops,
> + .info = simatic_ipc_ec_fan_ch_info,
> +};
> +
> +static int simatic_ipc_ec_hwmon_probe(struct device *dev, struct simatic_ipc_ec_sensor *data)
> +{
> + struct simatic_ipc_ec_temp *temp;
> + struct device *hwmon_dev;
> + u8 temp_count;
> + u8 temp_base;
> + u8 value;
> + int ret;
> + u8 ch;
> +
> + ret = device_property_read_u8(dev, "TempRegOffset", &temp_base);
> + if (ret < 0)
> + return ret;
> +
> + ret = device_property_read_u8(dev, "TempCount", &temp_count);
> + if (ret < 0)
> + return ret;
> +
> + if (temp_base + temp_count * SIZE_OF_TEMP_REG > 256)
> + return -EINVAL;
> +
> + temp = devm_kzalloc(dev, sizeof(*temp), GFP_KERNEL);
> + if (!temp)
> + return -ENOMEM;
> +
> + /* Clear flags left over from a previous probe */
> + memset(simatic_ipc_ec_temp_config, 0, sizeof(simatic_ipc_ec_temp_config));
> +
> + temp->base = temp_base;
> + temp->count = temp_count;
> +
> + data->temp = temp;
> +
> + /* Dynamically create temperature sensor channels */
> + for (ch = 0; ch < temp_count; ch++) {
> + ret = ec_read(temp_reg(temp_base, ch, TEMP_REG_CTR_STATUS), &value);
> + if (ret < 0)
> + return ret;
> +
> + simatic_ipc_ec_temp_config[ch] |= HWMON_T_INPUT;
> +
> + if (value & ALARM_SUPPORT)
> + simatic_ipc_ec_temp_config[ch] |= HWMON_T_MIN | HWMON_T_MAX;
> +
> + if (value & CRITICAL_SUPPORT)
> + simatic_ipc_ec_temp_config[ch] |= HWMON_T_CRIT;
> + }
> +
> + hwmon_dev = devm_hwmon_device_register_with_info(dev, "simatic_ipc_ec_hwmon",
> + data, &simatic_ipc_ec_hwmon_info,
> + NULL);
[Severity: Medium]
Can mutating the file-scope simatic_ipc_ec_temp_config[] array in
simatic_ipc_ec_hwmon_probe() corrupt an existing device's configuration or
overflow the attribute array during concurrent probes?
Because hwdev->chip retains a pointer to simatic_ipc_ec_hwmon_info and its
config array for the lifetime of the hwmon device, probing a second
110A5004 instance zeroes and overwrites the channel config backing an
already-registered device. Also, if two probes run concurrently while
ec_read() sleeps, mutating simatic_ipc_ec_temp_config[] between the
sizing pass (hwmon_num_channel_attrs()) and the population pass
(hwmon_genattrs()) in __hwmon_create_attrs() can write past the end of
the allocated attrs array:
CPU0 CPU1
simatic_ipc_ec_hwmon_probe()
populate simatic_ipc_ec_temp_config
...
__hwmon_create_attrs()
nattrs = hwmon_num_channel_attrs()
attrs = kzalloc_objs(..., nattrs + 1)
simatic_ipc_ec_hwmon_probe()
memset(simatic_ipc_ec_temp_config, 0, ...)
for (ch = 0; ch < temp_count; ch++)
ec_read()
simatic_ipc_ec_temp_config[ch] |= ...
hwmon_genattrs()
attrs[aindex++] = ... <-- heap buffer overflow
Could the channel config be allocated per device, or could a const static
config table be paired with dynamic visibility checks in
simatic_ipc_ec_temp_is_visible()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119160210.1257890-1-benedikt.niedermayr@siemens.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-19 16:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 16:02 [PATCH v2 0/2] hwmon: simatic-ipc-ec-sensors: add BX-54A EC driver Benedikt Niedermayr
2026-11-19 16:02 ` [PATCH v2 1/2] " Benedikt Niedermayr
2026-11-19 16:18 ` sashiko-bot
2026-11-19 16:02 ` [PATCH v2 2/2] docs: hwmon: introduce simatic-ipc-ec-sensors Benedikt Niedermayr
2026-11-19 16:07 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox