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/03gAlSCdeiHEqFLPRcfeTlGaNzQ4e5jWP6BaKa1QmDlEwP3HMr6iJybyq2QeBAxPuHK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CzfbP1Gs4N+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];