From nobody Mon Sep 28 13:18:32 2026 Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.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 5C30946AF0D for ; Fri, 21 Aug 2026 09:19:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.65.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787303989; cv=none; b=EoMWUiGceBUWVNkGgOUobR9nLWaGgTlx1/TJK+g0VjZNjfeUJXGP4eeFOYNHZrmA9hp6FJFLjbZfiVZO7gRq77F1onow3DXc1C8maJD7EvfBBtHCXowpOe5DBQuT73I6jKzvQ4UpfgXhxNKmY14HEAinj4NwxsTDURQ5X7ir9H8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787303989; c=relaxed/simple; bh=fASmTc1+4WUosnBJCv26scoFHh3RrNoMkn9ReuKY3XQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gCOPBlsNEmCTTGLaUeyNkRXH8NMIOcceZu43Rm8Qz0/aM/PMSWZHI52jAaqMBqJ9TAwm3pbiSnuLyW6nsEXUjtOt28DMCm6Y+mUXAzWAP6Ltjp9uh4ohEoeY+uodMIoeEGo3MLdHsfQdtEMqIyrxmGQyQjXsDqgBVN/kZ9PhFxo= 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=dZSKNHOd; arc=none smtp.client-ip=185.136.65.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="dZSKNHOd" Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 2026082109193573e1b3ad68000207be for ; Fri, 21 Aug 2026 11:19:35 +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=oVcMN0/piicBYC5HyeyMbJvD9tp2n1UeCOioN+Ar/fc=; b=dZSKNHOdUzSAulQdoFO1TKdqZ0JBaaMT2wZOywQ3mvqJgYHiDrKwXcbPRXL7RyArL9dh/S l2qTeVk/zmd9dDAXy9yC9kxvs6o7ukZlw0m1aIZHSTaA3iafWF4eQRWO0T3wxLaOoIu9tspL XNjWPXKOz3tCDJ1zOjFh7xsfSErU2y+DaVbV+mEdjOFkbaRzDnSzDWzJMLzEuhVsN0LiLpIr 92SJn2w18um1kvOhzJ3xUNBvjDuauqMx8Z/T6kKrxZMSKcmqVSBj3sVnv1wnoq4I2Q2FmQUN 5KGjFm57SdfddkISonyzofH3jQVR6QArdcIElxYquk3Qz5JJndWeMG2A==; 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 , Conor Dooley Subject: [PATCH v2 1/2] dt-bindings: trivial-devices: Add Sensirion STS4x series Date: Fri, 21 Aug 2026 11:19:23 +0200 Message-ID: <20260821091924.18975-2-alessandro.zini@siemens.com> In-Reply-To: <20260821091924.18975-1-alessandro.zini@siemens.com> References: <20260821091924.18975-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 Acked-by: Conor Dooley Signed-off-by: Alessandro Zini --- 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 13:18:32 2026 Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net [185.136.65.227]) (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 5AF0445DF4F for ; Fri, 21 Aug 2026 09:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.65.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787303989; cv=none; b=rwVXRY86mR41X6L/7ZTMr1JotWIAWKFXESC92q1z2WL5GZHzBRXj9quG3SZD9KD9Tu7dYI/XPAN5icQ/Gm4eJVVWyxYACk1YJE6LaP/UU0XWD0SH2/5R/6Xo0BHt28HTOnSNt1R5RfSXrD7lTNWU919JhW+dfC4WKxTWsZPtffc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787303989; c=relaxed/simple; bh=G/ZgrRWzaMfJE/ZIBZ/3JR7E2wBCujSE8gIQdvcFa98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OwHqfWXbwu1NQcq82hbnX/ynyDdRd/HppUZ5svnpojw9CS9D5K0GeER8JVWlUkMhwRtRzkhdQEsgGNJfTUUBfB/EVsyoKpWoTt2T/omG2THG5ZyiOSfJ8ZFQf6SDmKTcG7BYABMTqLwG9ItbpiXDRDjruz0h7K+zSKHMVPf2fFg= 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=bjbGkq54; arc=none smtp.client-ip=185.136.65.227 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="bjbGkq54" Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 202608210919352c2bb506c400020779 for ; Fri, 21 Aug 2026 11:19:35 +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=KTcHGzrqBpn9wM6QDuJ440qBt5kqvP8kTR8wiOFYPa8=; b=bjbGkq54mGzO6hoOmzHCF6au6F3X2nG1ccMNyNdsJ4r2PfJGa037TCpbKqaww1p5BnMl62 VKVBwhGSj5n+lNIuUdWvGleXLmh/dEl9qRKCXt5+dCEuoGXniX8zmrVF8Q5Du+GXtSCNmUDD hgc1cFXi1y6JSUlnppeBD7upQl4q1axPn5yLeFtUV9fRj1L9yTHwisEaivJ+OlVHUGNmqM8a +WL1a9cs4clQr8qS7oQNjQDVWjdCGkLDvIfTTTWAOX+kpNm4+JV37Z9mH4JrXk5qSW0kgQHe lNO8ECY4sbQcaMMC9P2y1Mhv2EbwsJRJCtAbMukPYBpltpHYdT81N+RQ==; 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 v2 2/2] hwmon: (sht4x): Add support for Sensirion STS4x temperature sensors Date: Fri, 21 Aug 2026 11:19:24 +0200 Message-ID: <20260821091924.18975-3-alessandro.zini@siemens.com> In-Reply-To: <20260821091924.18975-1-alessandro.zini@siemens.com> References: <20260821091924.18975-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 --- Changes in v2: - Unconditionally initialize data->heating_complete in probe to avoid an msleep delay on boot with INITIAL_JIFFIES. - Bypass heater delay checks in sht4x_read_values() when chip is sts4x. Documentation/hwmon/sht4x.rst | 17 ++++++++-- drivers/hwmon/sht4x.c | 62 +++++++++++++++++++++++++---------- 2 files changed, 59 insertions(+), 20 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..daca24cfbcd52 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,11 +100,15 @@ 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; - if (time_before(curr_jiffies, data->heating_complete)) - msleep(jiffies_to_msecs(data->heating_complete - curr_jiffies)); + if (data->chip_id !=3D sts4x) { + curr_jiffies =3D jiffies; + if (time_before(curr_jiffies, data->heating_complete)) + msleep(jiffies_to_msecs(data->heating_complete - curr_jiffies)); + } =20 if (data->data_pending && time_before(jiffies, data->heating_complete + data->update_interval))= { @@ -115,15 +127,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 +142,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 +206,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 +403,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 +422,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; + groups =3D sht4x_groups; + } =20 crc8_populate_msb(sht4x_crc8_table, SHT4X_CRC8_POLYNOMIAL); =20 @@ -418,19 +444,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