From nobody Mon Sep 28 14:47:48 2026 Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D10F378D94 for ; Thu, 20 Aug 2026 15:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.64.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238013; cv=none; b=nst/W7kQy2jv/SATAxhAPzYn1fHrTEcZbaojQ9HiBIS2n4zWAHg/eUxXpN0XfAyrgyHobXRmBAhzH6QdeXhj+N4buvK2qTuvlI9/PXunuAaLm/F/0ZQI+6JC6+uy02uUdEEdTKsim1DRPsXF7cHIWNWCaSEoGWvA7ob0XvVwYrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238013; c=relaxed/simple; bh=eOnk/u/GrSWEzyj0PXJycE8kCXganuI9Yeoa4tZRL/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dnhbNVA0sLLSbb8AhDMYsjGYaDDvktEWyVcNIuS60NCxUUMJHV7Rjk4MObLl7T1cnHiiGajkMkBGwn4Q3b8n0U2a+Uh0nkZORV2J9X2LBuw106kL4DR0BV1Di2B7jSvsXe9SZpddBxWiOt3hBRlcHQjTFWlhyYcR8NXs3XWpP80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass (2048-bit key) header.d=siemens.com header.i=alessandro.zini@siemens.com header.b=lEPecpFZ; arc=none smtp.client-ip=185.136.64.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=siemens.com header.i=alessandro.zini@siemens.com header.b="lEPecpFZ" Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 2026082015000090bdd3f17400020700 for ; Thu, 20 Aug 2026 17:00:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=alessandro.zini@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=dQKBkoYJT617xzrt/A2MoQz1lnW09udjgRt3UhSYhFA=; b=lEPecpFZh4K1omCGsdNkFfY0dk6AztHFoEuwjPuZD3j24ZfdjsdUJCoAtpq+ZzQkovgKXb 6QFrAvUMdGp6sOB//P5WSkjHYeE/rizgUuKoqRrr01YzSHDkKfkemAtxmECvdl8+mIjiM5l/ 3gMVyxvSVCGzYFNJOc8NvTHUMLLLpVqVgD2Ps0LFcvAc14OjjcSDsdbBnlR0okAM3kfViLHB Ct8y/sXINFYezsMxwKbGgo9kWuTTa/eEwaMSJMCmGnPDFFO2icR99CEgXcViJxkNTQk1r021 EIofnjU/cmZuqqtEoxhiTHSqgqoxuFt1lzxtuWCXwlztEBCKvgj4gkcw==; From: Alessandro Zini To: Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Alessandro Zini Subject: [PATCH 1/2] dt-bindings: trivial-devices: Add Sensirion STS4x series Date: Thu, 20 Aug 2026 16:59:45 +0200 Message-ID: <20260820145946.35468-2-alessandro.zini@siemens.com> In-Reply-To: <20260820145946.35468-1-alessandro.zini@siemens.com> References: <20260820145946.35468-1-alessandro.zini@siemens.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1327013:519-21489:flowmailer Content-Type: text/plain; charset="utf-8" Add "sensirion,sts40" as compatible for the Sensirion STS4x/STS4xA series of digital temperature sensors. Link: https://sensirion.com/resource/datasheet/sts4x Signed-off-by: Alessandro Zini Acked-by: Conor Dooley --- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Docum= entation/devicetree/bindings/trivial-devices.yaml index 435c4baab4365..48ded1b746723 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -423,6 +423,8 @@ properties: - sensirion,sht21 - sensirion,sht25 - sensirion,sht4x + # Sensirion temperature sensor with I2C interface + - sensirion,sts40 # Sensortek 3 axis accelerometer - sensortek,stk8312 # Sensortek 3 axis accelerometer --=20 2.55.0 From nobody Mon Sep 28 14:47:48 2026 Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF9FB37C90E for ; Thu, 20 Aug 2026 15:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.64.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238012; cv=none; b=mlp6ae199jOK/rgESH9YsXWX7soxOrVgsOA6riZGry8IYny+owBWMzM+UajIJA5l1zUw7d1O+v5Tr69uqChIRZl5/K84TFGLoOCQHU7zeNz1hSkTUmXWjtU4zoFckFsU6fyaoeOh+MO5kvAOT0tB+trM4u3O5NpzSbIQuITFiVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238012; c=relaxed/simple; bh=5vIYhEQdk4WuaWZX1t7/eUhpj4hJF1D1x4/NhXcICyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gjGBbVNG4270vNI94c+U0W/ZM0c3FUmOBlMByimmSCg88DO6V/QWZymCqGeaxLI5H7JSP8A7nov5ZE2xZl0xONbVwOjTwa7AmjerhDOjFwz+bIbA4dF6ou5QibWf5pW/WMebDOweGqbHRCoI9hIgs43Yll1LRRnYbpb28eCZ9O0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass (2048-bit key) header.d=siemens.com header.i=alessandro.zini@siemens.com header.b=IrSShM3i; arc=none smtp.client-ip=185.136.64.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=siemens.com header.i=alessandro.zini@siemens.com header.b="IrSShM3i" Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20260820150000eeb4bab94e000207a7 for ; Thu, 20 Aug 2026 17:00:01 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=alessandro.zini@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=nUUcTpLwNwAc6wleFo9//VPjl5RSye7e9Hj9sFJuo7Y=; b=IrSShM3ibd/Ut6Wt6uiJSvsTLtgKkZcriu39f7DFGeuJfH/Z/yj+p/C7MM7HvUctrUz3SC 3O3gSYiER0pmTnlBtCvQ/BO1zlbz8/fW5ibYyCxLyJ6nSr+HrKEEtG3YsjwM9IK5V7QueJc+ YyxNSkY/KQjXMVq84A3ur831cscylYwW0P1V/mmgrBvFSxLCHdarpdL0E3MkoevhnySR2MzF T4lPni/uAiqAlD44bhKusoKKMau6vQ3enIc1RG6ega83i8v4vFIBKG6J6K67iVZbYwm2eLvr Ow5Jn5Dfnk8DNy/Y5GyEOyZ7NaxBlXD0N8ssSvWGDCZ+RoPc4bk/csIQ==; From: Alessandro Zini To: Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Alessandro Zini Subject: [PATCH 2/2] hwmon: (sht4x): Add support for Sensirion STS4x temperature sensors Date: Thu, 20 Aug 2026 16:59:46 +0200 Message-ID: <20260820145946.35468-3-alessandro.zini@siemens.com> In-Reply-To: <20260820145946.35468-1-alessandro.zini@siemens.com> References: <20260820145946.35468-1-alessandro.zini@siemens.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1327013:519-21489:flowmailer Content-Type: text/plain; charset="utf-8" The Sensirion STS4x series is the temperature-only variant of the SHT4x family. It shares the same I2C command set, conversion formulas, CRC checksum, and timing with the SHT4x, but only returns temperature data (3 bytes: 2 data bytes + 1 CRC byte). Add support for the STS4x series by dynamically adjusting the read response length, suppressing humidity channel attributes when probed as STS4x, and omitting heater sysfs attributes. Link: https://sensirion.com/resource/datasheet/sts4x Signed-off-by: Alessandro Zini --- Documentation/hwmon/sht4x.rst | 17 +++++++++-- drivers/hwmon/sht4x.c | 56 +++++++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/Documentation/hwmon/sht4x.rst b/Documentation/hwmon/sht4x.rst index ba094ad0e2816..b9564632a1be2 100644 --- a/Documentation/hwmon/sht4x.rst +++ b/Documentation/hwmon/sht4x.rst @@ -15,6 +15,16 @@ Supported Chips: =20 English: https://www.sensirion.com/fileadmin/user_upload/customers/s= ensirion/Dokumente/2_Humidity_Sensors/Datasheets/Sensirion_Humidity_Sensors= _SHT4x_Datasheet.pdf =20 + * Sensirion STS4X + + Prefix: 'sts4x' + + Addresses scanned: None + + Datasheet: + + English: https://sensirion.com/resource/datasheet/sts4x + Author: Navin Sankar Velliangiri =20 =20 @@ -22,9 +32,10 @@ Description ----------- =20 This driver implements support for the Sensirion SHT4x chip, a humidity -and temperature sensor. Temperature is measured in degree celsius, relative -humidity is expressed as a percentage. In sysfs interface, all values are -scaled by 1000, i.e. the value for 31.5 degrees celsius is 31500. +and temperature sensor, and the Sensirion STS4x chip, a temperature sensor. +Temperature is measured in degree celsius, relative humidity is expressed = as a +percentage (on SHT4x only). In sysfs interface, all values are scaled by 1= 000, +i.e. the value for 31.5 degrees celsius is 31500. =20 Usage Notes ----------- diff --git a/drivers/hwmon/sht4x.c b/drivers/hwmon/sht4x.c index 9cace0e8acdab..d2b0d79bb7fe0 100644 --- a/drivers/hwmon/sht4x.c +++ b/drivers/hwmon/sht4x.c @@ -43,6 +43,7 @@ #define SHT4X_CRC8_LEN 1 #define SHT4X_WORD_LEN 2 #define SHT4X_RESPONSE_LENGTH 6 +#define STS4X_RESPONSE_LENGTH 3 #define SHT4X_CRC8_POLYNOMIAL 0x31 #define SHT4X_CRC8_INIT 0xff #define SHT4X_MIN_TEMPERATURE -45000 @@ -52,9 +53,15 @@ =20 DECLARE_CRC8_TABLE(sht4x_crc8_table); =20 +enum sht4x_chips { + sht4x, + sts4x, +}; + /** * struct sht4x_data - All the data required to operate an SHT4X chip * @client: the i2c client associated with the SHT4X + * @chip_id: the chip type (sht4x or sts4x) * @heating_complete: the time that the last heating finished * @data_pending: true if and only if there are measurements to retrieve a= fter heating * @heater_power: the power at which the heater will be started @@ -67,6 +74,7 @@ DECLARE_CRC8_TABLE(sht4x_crc8_table); */ struct sht4x_data { struct i2c_client *client; + enum sht4x_chips chip_id; unsigned long heating_complete; /* in jiffies */ bool data_pending; u32 heater_power; /* in milli-watts */ @@ -92,6 +100,8 @@ static int sht4x_read_values(struct sht4x_data *data) u8 crc; u8 cmd[SHT4X_CMD_LEN] =3D {SHT4X_CMD_MEASURE_HPM}; u8 raw_data[SHT4X_RESPONSE_LENGTH]; + size_t response_length =3D data->chip_id =3D=3D sts4x ? + STS4X_RESPONSE_LENGTH : SHT4X_RESPONSE_LENGTH; unsigned long curr_jiffies; =20 curr_jiffies =3D jiffies; @@ -115,15 +125,14 @@ static int sht4x_read_values(struct sht4x_data *data) usleep_range(SHT4X_MEAS_DELAY_HPM, SHT4X_MEAS_DELAY_HPM + SHT4X_DELAY_EX= TRA); } =20 - ret =3D i2c_master_recv(client, raw_data, SHT4X_RESPONSE_LENGTH); - if (ret !=3D SHT4X_RESPONSE_LENGTH) { + ret =3D i2c_master_recv(client, raw_data, response_length); + if (ret !=3D response_length) { if (ret >=3D 0) ret =3D -ENODATA; return ret; } =20 t_ticks =3D raw_data[0] << 8 | raw_data[1]; - rh_ticks =3D raw_data[3] << 8 | raw_data[4]; =20 crc =3D crc8(sht4x_crc8_table, &raw_data[0], SHT4X_WORD_LEN, CRC8_INIT_VA= LUE); if (crc !=3D raw_data[2]) { @@ -131,14 +140,19 @@ static int sht4x_read_values(struct sht4x_data *data) return -EIO; } =20 - crc =3D crc8(sht4x_crc8_table, &raw_data[3], SHT4X_WORD_LEN, CRC8_INIT_VA= LUE); - if (crc !=3D raw_data[5]) { - dev_err(&client->dev, "data integrity check failed\n"); - return -EIO; + data->temperature =3D ((21875 * (int32_t)t_ticks) >> 13) - 45000; + + if (data->chip_id !=3D sts4x) { + rh_ticks =3D raw_data[3] << 8 | raw_data[4]; + crc =3D crc8(sht4x_crc8_table, &raw_data[3], SHT4X_WORD_LEN, CRC8_INIT_V= ALUE); + if (crc !=3D raw_data[5]) { + dev_err(&client->dev, "data integrity check failed\n"); + return -EIO; + } + + data->humidity =3D ((15625 * (int32_t)rh_ticks) >> 13) - 6000; } =20 - data->temperature =3D ((21875 * (int32_t)t_ticks) >> 13) - 45000; - data->humidity =3D ((15625 * (int32_t)rh_ticks) >> 13) - 6000; data->last_updated =3D jiffies; data->valid =3D true; return 0; @@ -190,9 +204,14 @@ static umode_t sht4x_hwmon_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel) { + const struct sht4x_data *chip_data =3D data; + switch (type) { case hwmon_temp: + return 0444; case hwmon_humidity: + if (chip_data->chip_id =3D=3D sts4x) + return 0; return 0444; case hwmon_chip: return 0644; @@ -382,6 +401,7 @@ static const struct hwmon_chip_info sht4x_chip_info =3D= { =20 static int sht4x_probe(struct i2c_client *client) { + const struct attribute_group **groups =3D NULL; struct device *device =3D &client->dev; struct device *hwmon_dev; struct sht4x_data *data; @@ -400,11 +420,15 @@ static int sht4x_probe(struct i2c_client *client) if (!data) return -ENOMEM; =20 + data->chip_id =3D (uintptr_t)i2c_get_match_data(client); data->update_interval =3D SHT4X_MIN_POLL_INTERVAL; data->client =3D client; - data->heater_power =3D 200; - data->heater_time =3D 1000; - data->heating_complete =3D jiffies; + if (data->chip_id !=3D sts4x) { + data->heater_power =3D 200; + data->heater_time =3D 1000; + data->heating_complete =3D jiffies; + groups =3D sht4x_groups; + } =20 crc8_populate_msb(sht4x_crc8_table, SHT4X_CRC8_POLYNOMIAL); =20 @@ -418,19 +442,21 @@ static int sht4x_probe(struct i2c_client *client) client->name, data, &sht4x_chip_info, - sht4x_groups); + groups); =20 return PTR_ERR_OR_ZERO(hwmon_dev); } =20 static const struct i2c_device_id sht4x_id[] =3D { - { .name =3D "sht4x" }, + { .name =3D "sht4x", .driver_data =3D sht4x }, + { .name =3D "sts4x", .driver_data =3D sts4x }, { } }; MODULE_DEVICE_TABLE(i2c, sht4x_id); =20 static const struct of_device_id sht4x_of_match[] =3D { - { .compatible =3D "sensirion,sht4x" }, + { .compatible =3D "sensirion,sht4x", .data =3D (void *)sht4x }, + { .compatible =3D "sensirion,sts40", .data =3D (void *)sts4x }, { } }; MODULE_DEVICE_TABLE(of, sht4x_of_match); --=20 2.55.0