From patchwork Wed Jun 14 06:24:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13279562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4D02EB64D8 for ; Wed, 14 Jun 2023 06:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243074AbjFNGZr (ORCPT ); Wed, 14 Jun 2023 02:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243152AbjFNGZo (ORCPT ); Wed, 14 Jun 2023 02:25:44 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2054.outbound.protection.outlook.com [40.92.90.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC85C1FCC; Tue, 13 Jun 2023 23:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lzGniITmJDD0RFo0kKw0Tl3ia0lprwla3wXf2A+hZVQpiTGOsN4Z62wMxiXoXLlSYVH1US1vq4HlcKKYGjguut3XH6vyfQfV/W64k0cjkRDliOL6H9OseYEWuegjpQ7q247ndb2/u/eHJJDTs9Wt6MXH6vXQKkgiCmLLj5HDkjpT50+XniEdfBKd9Tyl6MlRVvGkzBwXTwJ2gCPRtG5i7lC58rrSwBV58KT1bVlHwaAOPVcGsArXP7w0TdWZNedFhC7U9hkQr1fdLqpNSvrW8dtmot/vHb3DUnPNAN7vB41iuI1zzbER9WbjRaGZSGxFYCRPwBqMIwZFfXD8uaStNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T3IzD7v21WE0xQQCUNxip81zyG5AIiqCxmyW+1F1OVE=; b=jkLR1WCTKJp7G6DYnKpq7IksmLGBGD3a4/epvaMWzclvQmAM1O0+X86rcLLSKLvP0l1nOyvDPRvKCo0dBxWCfBiXFrRkfmGJkklMSU+sWupaoKMvX7iS0NvxxG8JqNOHmWHMSHPjdEWKbNcHbsxZ3L95ql7OWQL0psmcizbfyl+wSGBZydFqMK+D4bCO1QHohH63Xzz3mgFgJYazcGwAGBDIPkvkqwDjHr9j5LB/4pZx7YkSEaK7qIb2DhHvm0ouFBNHHa56D2F3V93dSDQHXwaZGB4mLUOvYb5jrstO44tcsVJfZ5ligg9UsPYgnctcnFaPjiHNqGmaMsDD/gBbEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T3IzD7v21WE0xQQCUNxip81zyG5AIiqCxmyW+1F1OVE=; b=bNmVp6tXYVa33B3O409eOIeM+r6TbMRrB1NVrLgvcRK3KqD5dj04335FOpLwQnZmamO4kFq6IcoCmlaAQGi5uxde/aENeEMsBYlUXD3FCGfSX50l6pRGuFMc3NBTYC8k74L7bHHZQos0k+z21MmNpF4UIVnVwQQ5QwAOHbk6g17ScixCmnlnMLXlFjAvhT7HBOXXYrESd1I1TtGjR1i79MhhsxpEvC7AXPodpZ/hzigG9PtRZ0Tqt7FIgbatTGkPiN2DRlnSTd8LzCLSxKARl3qQ5ezkq8cNPu/jTNl7FbR7IJrsVEtqp54dX2Ooft1VnRae7oE90t/mvcOSSsNxbQ== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by DB8PR10MB3706.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:13c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Wed, 14 Jun 2023 06:25:37 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%6]) with mapi id 15.20.6455.030; Wed, 14 Jun 2023 06:25:37 +0000 From: JuenKit Yip To: linux@roeck-us.net, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH 1/3] hwmon: (sht3x)remove sht3x_platform_data Date: Wed, 14 Jun 2023 14:24:54 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [MhnJGz78fSlRJzCaRQMIb9kTGs/XYyXC] X-ClientProxiedBy: TYCP286CA0025.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:263::16) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230614062458.888114-1-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|DB8PR10MB3706:EE_ X-MS-Office365-Filtering-Correlation-Id: d3c43a96-fed6-49ba-45f8-08db6ca02aae X-MS-Exchange-SLBlob-MailProps: WaIXnCbdHrOQku+SANv8F+rkkwqOSg82+Nv+s7faFNGAbPvNzLuFT9St7k75w4orUIfh2bzDK8q0oDaRNJRUzSMlhlmLTYMe0HPtDqBrRwi9dT62fDb1FU0Fg2ImX7Ujd8CUSHPMQjWo5nqKBa83Rjq8dUT9a9DDz1QqnrK6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xXxtzLO/rcBWk2YmmUBimfXfWv7ZnRZCDfzOJl9LYsyhMCfb69+ZKj6DEgkqsHIqzhzptxGok65ElGhw4nrWTwHsB31CFMDjBOx9QZORLsgq9giQTDja2voBFfBWD7UT1S4ywlE5GgCG35Qq/T1AegwO4Ql6T07hhIDyL5TSssyBcVE+rKeSuHor98sWzz4aotqUQRVWtYPIXh+NCFKnp+vBImXEb2s+VexfnhRIew8gNijCVYKHAOvuQUbFNuoTXNBtUE+Mx1W09tSeNk/5pppEUX5ysQTqlfpm3Or52+5Biv0PzC23YpM/kr6Lz04v3xO351t7aUnuNA5NJJ0WM8CBZR6Xaew1MgMUvXzTbxZsfokAfhmUeV127jSOba8gJNq1qC4QCLDvuo5qS4byRzP7sU/pTlM2BMuXPkbToXCsAvcYSPsX4O9QMk29T8g= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: d3c43a96-fed6-49ba-45f8-08db6ca02aae X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 06:25:37.4433 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR10MB3706 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Since no in-tree driver supports it, the sht3x_platform_data was removed. - "blocking_io" property and its related code have been removed, and Single-Shot mode should be blocking in default. - "high-precision" property has been replaced to "repeatability" for matching datasheet. Signed-off-by: JuenKit Yip --- Documentation/hwmon/sht3x.rst | 12 +++++------ drivers/hwmon/sht3x.c | 32 ++++++++++++----------------- include/linux/platform_data/sht3x.h | 15 -------------- 3 files changed, 18 insertions(+), 41 deletions(-) delete mode 100644 include/linux/platform_data/sht3x.h diff --git a/Documentation/hwmon/sht3x.rst b/Documentation/hwmon/sht3x.rst index 95a850d5b..2c87c8f58 100644 --- a/Documentation/hwmon/sht3x.rst +++ b/Documentation/hwmon/sht3x.rst @@ -28,28 +28,26 @@ The device communicates with the I2C protocol. Sensors can have the I2C addresses 0x44 or 0x45, depending on the wiring. See Documentation/i2c/instantiating-devices.rst for methods to instantiate the device. -There are two options configurable by means of sht3x_platform_data: +This driver supports block and non-block mode: -1. blocking (pull the I2C clock line down while performing the measurement) or + blocking (pull the I2C clock line down while performing the measurement) or non-blocking mode. Blocking mode will guarantee the fastest result but the I2C bus will be busy during that time. By default, non-blocking mode is used. Make sure clock-stretching works properly on your device if you want to use blocking mode. -2. high or low accuracy. High accuracy is used by default and using it is - strongly recommended. The sht3x sensor supports a single shot mode as well as 5 periodic measure modes, which can be controlled with the update_interval sysfs interface. The allowed update_interval in milliseconds are as follows: - ===== ======= ==================== - 0 single shot mode + ===== ======= ========================== + 0 single shot mode(blocking) 2000 0.5 Hz periodic measurement 1000 1 Hz periodic measurement 500 2 Hz periodic measurement 250 4 Hz periodic measurement 100 10 Hz periodic measurement - ===== ======= ==================== + ===== ======= ========================== In the periodic measure mode, the sensor automatically triggers a measurement with the configured update interval on the chip. When a temperature or humidity diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index 8305e44d9..5bc0001b1 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -20,13 +20,12 @@ #include #include #include -#include -/* commands (high precision mode) */ +/* commands (high repeatability mode) */ static const unsigned char sht3x_cmd_measure_blocking_hpm[] = { 0x2c, 0x06 }; static const unsigned char sht3x_cmd_measure_nonblocking_hpm[] = { 0x24, 0x00 }; -/* commands (low power mode) */ +/* commands (low repeatability mode) */ static const unsigned char sht3x_cmd_measure_blocking_lpm[] = { 0x2c, 0x10 }; static const unsigned char sht3x_cmd_measure_nonblocking_lpm[] = { 0x24, 0x16 }; @@ -69,9 +68,14 @@ enum sht3x_limits { limit_min_hyst, }; +enum sht3x_repeatability { + low_repeatability, + high_repeatability, +}; + DECLARE_CRC8_TABLE(sht3x_crc8_table); -/* periodic measure commands (high precision mode) */ +/* periodic measure commands (high repeatability mode) */ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { /* 0.5 measurements per second */ {0x20, 0x32}, @@ -85,7 +89,7 @@ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { {0x27, 0x37}, }; -/* periodic measure commands (low power mode) */ +/* periodic measure commands (low repeatability mode) */ static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] = { /* 0.5 measurements per second */ {0x20, 0x2f}, @@ -132,12 +136,11 @@ struct sht3x_data { struct mutex data_lock; /* lock for updating driver data */ u8 mode; + enum sht3x_repeatability repeatability; const unsigned char *command; u32 wait_time; /* in us*/ unsigned long last_update; /* last update in periodic mode*/ - struct sht3x_platform_data setup; - /* * cached values for temperature and humidity and limits * the limits arrays have the following order: @@ -441,13 +444,8 @@ static void sht3x_select_command(struct sht3x_data *data) if (data->mode > 0) { data->command = sht3x_cmd_measure_periodic_mode; data->wait_time = 0; - } else if (data->setup.blocking_io) { - data->command = data->setup.high_precision ? - sht3x_cmd_measure_blocking_hpm : - sht3x_cmd_measure_blocking_lpm; - data->wait_time = 0; } else { - if (data->setup.high_precision) { + if (data->repeatability == high_repeatability) { data->command = sht3x_cmd_measure_nonblocking_hpm; data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_HPM; } else { @@ -595,7 +593,7 @@ static ssize_t update_interval_store(struct device *dev, } if (mode > 0) { - if (data->setup.high_precision) + if (data->repeatability == high_repeatability) command = periodic_measure_commands_hpm[mode - 1]; else command = periodic_measure_commands_lpm[mode - 1]; @@ -690,16 +688,12 @@ static int sht3x_probe(struct i2c_client *client) if (!data) return -ENOMEM; - data->setup.blocking_io = false; - data->setup.high_precision = true; + data->repeatability = high_repeatability; data->mode = 0; data->last_update = jiffies - msecs_to_jiffies(3000); data->client = client; crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL); - if (client->dev.platform_data) - data->setup = *(struct sht3x_platform_data *)dev->platform_data; - sht3x_select_command(data); mutex_init(&data->i2c_lock); diff --git a/include/linux/platform_data/sht3x.h b/include/linux/platform_data/sht3x.h deleted file mode 100644 index 14680d2a9..000000000 --- a/include/linux/platform_data/sht3x.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2016 Sensirion AG, Switzerland - * Author: David Frey - * Author: Pascal Sachs - */ - -#ifndef __SHT3X_H_ -#define __SHT3X_H_ - -struct sht3x_platform_data { - bool blocking_io; - bool high_precision; -}; -#endif /* __SHT3X_H_ */ From patchwork Wed Jun 14 06:27:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13279563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2B15EB64D8 for ; Wed, 14 Jun 2023 06:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242281AbjFNG1y (ORCPT ); Wed, 14 Jun 2023 02:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242549AbjFNG1w (ORCPT ); Wed, 14 Jun 2023 02:27:52 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2063.outbound.protection.outlook.com [40.92.90.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 547461702; Tue, 13 Jun 2023 23:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mQR2x2EJnWujb7L8ZNbc1GY4SO/7DSvEJs10lGT5ncCbeS6keE9A3TM9fwt0vy+nooImiofOlvuiC9YLk8vJvfXPar3XqjkNxmxYa74kruk5BvQkJyO6Uh5OJFbvsNxoydI5IyV1zFdmTMgy3osEmqhjottv2gEfEgHto54sMvQT0X7EIUa9T52s2wngseiTzV+pdqSiFT9BB5U7c/CMZgb5NG0vAs6xH9aNl5BC4ntHFRpbNByTtcZ4RtF3gAxBtH4XQTi2gbLpejRFJx8dPnpOYURtweHctm2nCB16NkQ/PMmeUAiXPnI6PpE8ENG8wzd3US8YvKVMPQ0FLR+aXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2oOuiYIgBbrGBq2ClEQzloAW/IZrZ+uV4T5YD2V35So=; b=a5byp3H/sbLVGVjjQ8n5nsgoKwoPvA8tzt2wq/sa3mj+v8qYPSpOuh69tj0bl1eBqZ2jaF4ml9ecMbu7D4lXnMezUHmXgecrgLLfbRu4AGW6y6syBEVK2qCdlTeL9mwz1b1CIh8dVA5Qb0BX2D7aqsB4z4xCHtMUvtR5a74KmCoFYOhFpGVVodWIG/DfpEW24NKln97bYRhsD49WhvWjWlLXAApUTpCI47bhMVEBUnF0X9EcUuykvU3a7b82tpHQ+ZdBaOnravVWfqmmjCiAG7sddDFgowkL4MmaUi9K7deWS0mHQktVuIO5B6Xh2hcnoWkL1pILQ15Bj75Lpzh44g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2oOuiYIgBbrGBq2ClEQzloAW/IZrZ+uV4T5YD2V35So=; b=jTI5GzPftmxjzYvy9xuCbYxkfWSM4WsFka9fNu8VHDZeNGmf5TT5FdXXU9mMOme9hSICZk2Bq6gtWz/8y+A/W+jCCvkjx3bhSW783yR2Vp8a+Hp0JB9x8x7myp3jmpG6h0MuEhAIPKNJuzIhDMDQgNXQbMsypQRot0S8Yem5ZGNKx+/6APZfboXw9w250QL59NBCuGoSkrPMAeeHk7jIPJjxk2hveIv/0N0GFnTzgyfUwKXfZiiTI1LgNhJKTvLXBTIkzbzKZZEoTUBLszt47YfUHHt4ybpZfE7gxUEdWAzjtfqK6J+eiMspYn8t4fCCSAkHwzj3EtJKjPRzvjhXag== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by GV2PR10MB6981.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:de::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.46; Wed, 14 Jun 2023 06:27:49 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%6]) with mapi id 15.20.6455.030; Wed, 14 Jun 2023 06:27:49 +0000 From: JuenKit Yip To: linux@roeck-us.net, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH 2/3] hwmon: (sht3x) add medium repeatability support Date: Wed, 14 Jun 2023 14:27:23 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [T1qJXBObZldXK0pSSwLd58JnLDV85iep] X-ClientProxiedBy: TYWP286CA0013.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::9) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230614062723.888171-1-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|GV2PR10MB6981:EE_ X-MS-Office365-Filtering-Correlation-Id: aaeacb4a-c051-4e16-ef7b-08db6ca07904 X-MS-Exchange-SLBlob-MailProps: EgT5Wr3QDKzwu8YPsqYDy7f7AA4ui0PNriGzB6Pm435daW4chHiPdy5Hpqg7lL0VqiX2x4RnTEZpS4kT1/6Pan/YbJ6XuJ0F77dx4l2D/03gAlSCdeiHEqFLPRcfeTlGaNzQ4e5jWP6BaKa1QmDlEwP3HMr6iJybyq2QeBAxPuHKRDwLbeYVj926JyNpeAdmu/SNbOzYWXkppXJH6MbofqyD/Aj8eRMd9IrNz2YBywii3LSC+wl0b17eP20CwPw7ETzpqMrT4oE/04HLw+F4xLjEM1wlYS0vmJEarI7JdVtD/Hl0LMvHkXqv8UlUzcvEv1Vas1Km7on9ABAM/s5Fh/NTT1owdHPTUDoUOxM3rCeD4cTEf2jTqPMMnt8SYpvjO+QYqHiHgrtECvwn+SDod0g92zRMa/RwezquI9jZ3uvvjmikAyMMCfM4Kx1DWA9dhHZJZ4tjRtGRgOG3/Xu3vMMYMUvsIGDlre3DWPAZx4OMpMHLiV7Pt9b14r7sMxc/ZP4AmLApsB3To+XDdU9XZ+jRYiVkugfSdeMbwg75seacf02ZpzK2Fl+O02XM0g8b+OW7LZD6G7l6qmxbTJO4u7UYX9oO/xVXXHcVZ016IK0mBP0LvHWPTV7rUnh0iQEAu5uj9wJ0o4gm/OipKogFGf2BwX8mitXOCYF/D/vee8MoSVyEPdgSKpfjakfPFyQ2aRRM8FLOzUCqFvE4do3o3iz8YVr1eg+0FxClVG9zm34= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D587KTrSf2RTXN6OVD/RWdTzzja2okmXDYRXPpfWAzOGO8wC2xR7A6EA+C9ZONonBsGIYduWkGcv9r+h8YuU9BJiU/qg82nhOgqy3GhkUJ0tB4KAAdeGysBYfUlMzIxDnvEIkNgATVfr0rJCsQ35/j+EkHmhHjVIqMFtnvh7jv+kzC1w8t5CvzCaPuvY6CPT/V5EavIWd3m937h5pPGlazgHO9UdmdHTFjq0GWgFTVqAHyPgQlROZLEbNUX+NUktOv/Y9YeMqVHuHcnGMqY/GLIWpz2jAdIa1f5AUXKYRU3R72fq4xvJeZBGOHqIzbjup76tZk66Cyk4o+Y4gyjh75yn8SaDLLMSNSqxjUoEOCLUOQefma4jOFie9OWENqjdPOPJiv09Hk7RdasBinziJfGyF6p/8uTXdy92vNKHzytMtZdnqXza5Za1MFNPgs4gx/7eTaRIWWMSzU4cCGWBZGygwWowk079xsxitstaE/4o9xqI9RdoUx0t39RdqLEAvoa469NixUdKmtIdKYFGD+z+4nxzqL3O3wGdcJMU0KmsWJLE3M70pFL7bc+rv2jO6avyLpJIQ+v48CHfuWDZExvJ1H7I1XL6BvWsvzBrDuHbXZT+d4iFA+++IMMdybtI X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dTueGx782A9LK4l5mfT3h1UIaT9D1L5+r1RfBPW9D+3Jg3lzBzT0kXazlo0KNxiT+pCPxmHJM2vsRpL1fvRC2gKJ+itpGr8nhSi2F+2VSU28K98wJwjwJfHtKnrwk2OcouMclPMvX+DrBMZy8+hVUE1zsnqx7W4Odt3gbcyjhRWviBFH778pJaJWJrQDXdilEpTf7TkUxJqcLMdiHEAfX+6mS5GbcDRHbF6jVv8/1soaqMzC9noMu9OOouzdbTC7C7Q04B7FpiLYtIOvB04rQdyO2DirAGALgzf/WWuM5AEl2WRGsGWd72f/MWaKPyjDHy/qvofmQoR7ArXOBu1o1qg89IPIhGOChcIQHgb0nX1cL4QvGFP+xu6IeHxLRSR1P0TPRy/92NHjLBFMWg2wwytiCZhbIl3YJ8Ct5dOUhBfhjS5zCTfW3q5ldDwUSjR0AEYHzqwYmSokuzFPhHXMuTnnIc3KBnI4qjAI7fFlOydGyAkugsr3jdsdE66b9UrFRx9YFt6sn+hTZQAaVKAy7MPVFl2ZODil7FpFa7l5svuDR8WDJsJOZpziiE4gxBpjyuGR7q649tc8oI1E0mfJZCSkJmrdnhC4pquKhUxUeHL/D4W356OGD5uVwgldwur4/mfq8c//o0xAvR9ir2YCAh8R70VQgsXSL08e7H1ajE0t1Cn7g35F8JxODxC3tMlc8yZlnPE1zDeXqw/JAmjfYuBsMgUYpAGmOwlGRTsra2rNb6Z7Mv0RWK0kD6kEje2NxKW25BpS5y0yd+XNNi5wWRXHBsnzez9rlw1etT6Nu8D1iZ9Ps2/LXrOxTfBxt3oINLbv+OgbmCzfbP1Gs4N+myr4YAA6BE0RktjaUG9mEmM5CuQBGn3ZZZAf7RcC912LaTMoe7Sh8O+WoOT04mWLs7DIcn7F/wXxoOQeQNr7ZjaKlFiK6qd3q6yg9ni6FGbhZy5jwsCjxLqFrmjBhipd4FoZSVmUPyodIfOV0XNFhyrB7dxWRlEByNbe2bVR6meJTmYkjXg5B7XOrHyUNQqVh1w31n81fyoTB76Z1uI2MD0oYvEyxbtosiV80xrrz9LsKS8gL6Dsm6jbdFQe06kd1cafpEmJRNtXb86zyZYre6LRT0vtO4bHusLxdElRvtobiZYeQtB8yIjugDZvrWBl11Z7B8vGUCg3nrBAV/YailIefyD4V/33e1RPt3nD14or/+2/DPNGUdCk0Wq5O6cxf1qPdSR82TWwP9F4hPjnC9E= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: aaeacb4a-c051-4e16-ef7b-08db6ca07904 X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 06:27:48.9803 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR10MB6981 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org add medium repeatability support for matching datasheet Signed-off-by: JuenKit Yip --- drivers/hwmon/sht3x.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index 5bc0001b1..eb968b9d3 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -25,6 +25,10 @@ static const unsigned char sht3x_cmd_measure_blocking_hpm[] = { 0x2c, 0x06 }; static const unsigned char sht3x_cmd_measure_nonblocking_hpm[] = { 0x24, 0x00 }; +/* commands (medium repeatability mode) */ +static const unsigned char sht3x_cmd_measure_blocking_mpm[] = { 0x2c, 0x0d }; +static const unsigned char sht3x_cmd_measure_nonblocking_mpm[] = { 0x24, 0x0b }; + /* commands (low repeatability mode) */ static const unsigned char sht3x_cmd_measure_blocking_lpm[] = { 0x2c, 0x10 }; static const unsigned char sht3x_cmd_measure_nonblocking_lpm[] = { 0x24, 0x16 }; @@ -43,6 +47,7 @@ static const unsigned char sht3x_cmd_clear_status_reg[] = { 0x30, 0x41 }; /* delays for non-blocking i2c commands, both in us */ #define SHT3X_NONBLOCKING_WAIT_TIME_HPM 15000 +#define SHT3X_NONBLOCKING_WAIT_TIME_MPM 6000 #define SHT3X_NONBLOCKING_WAIT_TIME_LPM 4000 #define SHT3X_WORD_LEN 2 @@ -69,8 +74,9 @@ enum sht3x_limits { }; enum sht3x_repeatability { - low_repeatability, - high_repeatability, + low_repeatability = 0, + medium_repeatability = 1, + high_repeatability = 2, }; DECLARE_CRC8_TABLE(sht3x_crc8_table); @@ -89,6 +95,20 @@ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { {0x27, 0x37}, }; +/* periodic measure commands (medium repeatability) */ +static const char periodic_measure_commands_mpm[][SHT3X_CMD_LENGTH] = { + /* 0.5 measurements per second */ + {0x20, 0x24}, + /* 1 measurements per second */ + {0x21, 0x26}, + /* 2 measurements per second */ + {0x22, 0x20}, + /* 4 measurements per second */ + {0x23, 0x22}, + /* 10 measurements per second */ + {0x27, 0x21}, +}; + /* periodic measure commands (low repeatability mode) */ static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] = { /* 0.5 measurements per second */ @@ -448,6 +468,9 @@ static void sht3x_select_command(struct sht3x_data *data) if (data->repeatability == high_repeatability) { data->command = sht3x_cmd_measure_nonblocking_hpm; data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_HPM; + } else if (data->repeatability == medium_repeatability) { + data->command = sht3x_cmd_measure_nonblocking_mpm; + data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_MPM; } else { data->command = sht3x_cmd_measure_nonblocking_lpm; data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_LPM; @@ -595,6 +618,8 @@ static ssize_t update_interval_store(struct device *dev, if (mode > 0) { if (data->repeatability == high_repeatability) command = periodic_measure_commands_hpm[mode - 1]; + else if (data->repeatability == medium_repeatability) + command = periodic_measure_commands_mpm[mode - 1]; else command = periodic_measure_commands_lpm[mode - 1]; From patchwork Wed Jun 14 06:28:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13279564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36FADEB64D8 for ; Wed, 14 Jun 2023 06:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242947AbjFNGaB (ORCPT ); Wed, 14 Jun 2023 02:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243179AbjFNG33 (ORCPT ); Wed, 14 Jun 2023 02:29:29 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2097.outbound.protection.outlook.com [40.92.59.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64DD02102; Tue, 13 Jun 2023 23:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mGrhvYFsUAJQM0PHPCBy3c9uwl7KoZhnjvnW03q++r2Gj9YhufJRkgj0C97+6OsNl6oXXRIFJjYo65Z1q2hUlycthykFiDOtel060RJcn76gSRa/31RnDADc0CBcfHSRFKB/zIkzBznGKaOijtTuMK22FEEauYqgnxmY5qqvxayvZq+OAx10pV6VBQvZ/SIvwnPEAuCx3z/RwtG3pgrtlvwLHzCUAyPRX/MSPUtHGhJAyNLKQhNu6wMKDEcU/yd7gJs1D7YoUdHe71N75j1BG0N2e2MgFf4fOr6ICC4CJXyhYGCgI3QnpEf4ncGYHpAbTU5wkzDq1RgkfdpwIFvHmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T4ztIYSyuNhSxWFttmUJQdXlXz3wECbts3tnhkCTfT4=; b=M3SHuAcoTGvap5+Z+fbCj5Gn+aiX5NeK0PNdK47gTqY+Y9PDlrfNp5eisdUeYfye2ODbMoy/gf0g8pxgsXAsd5sdQ+dWIObyPUQLBty8rPE89pRa1l2pbbURJozU/Bvz5Q/RFcLKLz5kqTtWv1WTzA7CSDWVI5Gt/JUBZ7lK0+pgVM19oGIZR+LNQjCqduoabACjbVF5OJqWRb2xZN9F/BDaGE83+VCwE6soDV31x4hqg3m2JysmWLt6648+BbF0SjhsqG8cOvdKvtheXwR72LaJfwIgyVBqOX7PhjUqX1Y9xZB6Zao8HNVfcMCuOYMe/rZC3IbTa3sd6Ybw1pPJiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T4ztIYSyuNhSxWFttmUJQdXlXz3wECbts3tnhkCTfT4=; b=bXlZ2MqurA5H3BwrE96tnoY5OsvzTNxoZoaTmFY21PMTEGzTzIDLMKiA5R1Kl0BA07M1116nou2pIb1YisI5SQz/4JwmRLhVa4k8PTTfxwFQNHIcsYYv2TWjpPqrWRFbSHFKlaCdFD5r20yDp99ltzmX+NwXV9WqjRZrFyhpyRKjCUmc+EvmiVF7St/6+pm3IsOJiXmkX/JT1tQCv1u7Rsocd/4eC9nQsMaGNH65DAK1lZc2Q0oNNwCcH+G9XocikpkoGdY+RHf2AvaDxSJdcgmiMvP7ts44A7Yld/NFB4JM/kR34jJKQQagZyrwQ+QYExyWYTIppFiVoNTa3+46gg== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by AS1PR10MB5601.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:478::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.36; Wed, 14 Jun 2023 06:29:18 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%6]) with mapi id 15.20.6455.030; Wed, 14 Jun 2023 06:29:18 +0000 From: JuenKit Yip To: linux@roeck-us.net, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH 3/3] hwmon: (sht3x)add new non-stardard sysfs interface Date: Wed, 14 Jun 2023 14:28:43 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [34bP/Isi1jIGgTIKxsGpxRwWq5jDMX7O] X-ClientProxiedBy: TYCP286CA0021.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:263::11) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230614062843.888225-1-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|AS1PR10MB5601:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ea40210-c86b-4529-8d03-08db6ca0ae7c X-MS-Exchange-SLBlob-MailProps: 5fu/r660v9PvfFeBhIdXTOajjuRTH3Fbkt9oQBP2HWLQSHV22AkrgfAHkhLa77SuidZ+rcKFzpXiL4iRTFmoJ+5StkLwF2TRDIkon1tGEuyfOTRL4Mco74VW/VYYUXt/hbh9n7TMjCBGCPhd+/G518RH8+uTIoeLppXnvyh21h0/Uzm+2lngWhGvZicDEJ6etZ6kJGgQHjuehKA9FI+N8vHwWSP+TemM6OVYYMUwzW7UoTdSU4LAt9cf7k+gcg92IlDpZn6JE30tO3Lgu/DclVre3IpxR9l9PaFpvZSiNBhRAD5VljWn7TRctm/1aIorfxO+TnwJt2vb3L0vGqAy4N+U857+VQQ4PZ07SrcPlV3pzcLwy5Cnd6Aca0HE5uKdPd+oDS8lrGiMEisPmMIi+f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zCVJ794VQBTYLfPqmftkU1i59Z/duTWNGyMc86Pb1a2tejOZy74vmAXHsMptdWlX7+DSG3jMP8d6ueMEr8jw3aQ2c49UgP82EdI5rcTD/YKu7WCTo4/0C+LovHwuXowisQI+rJ7WtEGYVlUM2Y92G3hnAIzbw8XAf2trkWt0EY/uCT86kDD+B/w6f+3vp9RFSetvoAAo8GlF9mb6M= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 6ea40210-c86b-4529-8d03-08db6ca0ae7c X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 06:29:18.3443 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR10MB5601 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org add "repeatability" interface to sysfs, it could be read or written to control the sensor. Signed-off-by: JuenKit Yip --- Documentation/hwmon/sht3x.rst | 7 +++++++ drivers/hwmon/sht3x.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Documentation/hwmon/sht3x.rst b/Documentation/hwmon/sht3x.rst index 2c87c8f58..3dc4b9c14 100644 --- a/Documentation/hwmon/sht3x.rst +++ b/Documentation/hwmon/sht3x.rst @@ -83,4 +83,11 @@ heater_enable: heater enable, heating element removes excess humidity from update_interval: update interval, 0 for single shot, interval in msec for periodic measurement. If the interval is not supported by the sensor, the next faster interval is chosen +repeatability: write or read repeatability, the higher repeatability means + the longer measurement duration, the lower noise level and + the larger energy consumption: + + - 0: low repeatability + - 1: medium repeatability + - 2: high repeatability =================== ============================================================ diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index eb968b9d3..209090a48 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -642,6 +642,33 @@ static ssize_t update_interval_store(struct device *dev, return count; } +static ssize_t repeatability_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct sht3x_data *data = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", data->repeatability); +} + +static ssize_t repeatability_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t count) +{ + u8 val; + struct sht3x_data *data = dev_get_drvdata(dev); + + val = kstrtou8(buf, 0, &val); + if (val) + return val; + + val = clamp_val(val, low_repeatability, high_repeatability); + data->repeatability = val; + + return count; +} + static SENSOR_DEVICE_ATTR_RO(temp1_input, temp1_input, 0); static SENSOR_DEVICE_ATTR_RO(humidity1_input, humidity1_input, 0); static SENSOR_DEVICE_ATTR_RW(temp1_max, temp1_limit, limit_max); @@ -658,6 +685,7 @@ static SENSOR_DEVICE_ATTR_RO(temp1_alarm, temp1_alarm, 0); static SENSOR_DEVICE_ATTR_RO(humidity1_alarm, humidity1_alarm, 0); static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0); static SENSOR_DEVICE_ATTR_RW(update_interval, update_interval, 0); +static SENSOR_DEVICE_ATTR_RW(repeatability, repeatability, 0); static struct attribute *sht3x_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, @@ -674,6 +702,7 @@ static struct attribute *sht3x_attrs[] = { &sensor_dev_attr_humidity1_alarm.dev_attr.attr, &sensor_dev_attr_heater_enable.dev_attr.attr, &sensor_dev_attr_update_interval.dev_attr.attr, + &sensor_dev_attr_repeatability.dev_attr.attr, NULL };