From patchwork Fri Nov 25 21:55:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksa Savic X-Patchwork-Id: 26146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4315028wrr; Fri, 25 Nov 2022 14:06:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6t9TeUS5hu7uo4NOo+a23uON0s6AMM/PI0+N59p0+hsjZgAoBq/0bXgC1B3gdWFXw/dfZx X-Received: by 2002:aa7:d999:0:b0:461:7f5a:e04e with SMTP id u25-20020aa7d999000000b004617f5ae04emr1581566eds.389.1669414009723; Fri, 25 Nov 2022 14:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669414009; cv=none; d=google.com; s=arc-20160816; b=kR4K0pQ75ExXnGsY9hd/6sTSsPPBAcEs6HJg6AszJeDfg3kr9TXEMdp16gTxwTuDe+ 10tVN7p5Izt5XUuudZ9EvpOq5rZIOsPUwEIgJmzIfB5QC3q8wVaim7xCA/A3ZpxL4jTd g/6p4tDenH0R3IS+d+HUuW16hQeaj3nPTth1GeWOU0MicRbAQz2FlAcQQQ3u4sxO71IG gVz3+t4Mx5N41mnen/xJA+uJOeXDhUOT2PXj7RReaKkbQAtyYub5F1aCwmf81axTn2TA ihy9t2KDP0OKg0W/debDF9KN8DHFvHDHX5RQ8I4WifX8teTcr1P3X4JDK/5NJN4zvlLY Cq6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=D3EDYbGccBK89yykxes9BQKaCfAxUWSmOZVPyYSYNP4=; b=ANKnXJkn7pfT3sVscbFEtZvsOBTIvQYg2LhzRVOnyODO1elgpJFqttmR3X2LocKXFR Ms7dbnV+m+Jk+gX4jP3/mkOu4YI4ov0EuTCzVT5BcNMh9gNGhWuyfzYfTtKTJXgWnqjt 1UUo92YYMHg6JCGLb3WoO0v7wBAV2Tyh8swFnVlqB2JyANWDLSaDksAgfHKKR9MliCaU Fm9pnmkEN1X+GL/yAxygkHY6imH5VPvQ+NIzTTcRgGjHPgT+896wk5uCQH7ppNs9S9AE urdHlPdhegRhz+5FcalXFKEEAumy7qgI4Qszg8ZJLpiQLPzlQIOUCyzoiJDM/MMYsIT6 3bHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HW0RUCPU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a05640240d000b00461c41bd7b6si5368095edb.209.2022.11.25.14.06.25; Fri, 25 Nov 2022 14:06:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HW0RUCPU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbiKYVzp (ORCPT + 99 others); Fri, 25 Nov 2022 16:55:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiKYVzm (ORCPT ); Fri, 25 Nov 2022 16:55:42 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62F8455CAC; Fri, 25 Nov 2022 13:55:41 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id l11so7987748edb.4; Fri, 25 Nov 2022 13:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=D3EDYbGccBK89yykxes9BQKaCfAxUWSmOZVPyYSYNP4=; b=HW0RUCPUMjBLDO1TxAyw2BM+t22jEI0sTP6233lB+dAXLsWzsZYFkXRYkpOrQXnWEP dyQgnwg8KFMCMlQQIPTk1hOYObv3To/VzmjzT7wv2cfQjtYf8r27A++EDccRDn1Y90Sv 8XFBcC18B6F/GlKYFzBr34ODmhTIKZRwUt1eNcl07WwRjG7mDOULGTz6pFuzSIgXHikx og6NNgCfzlPbmGrpNcvwbfNFMBZHngQh5LTzaflitNv8wFH5xPrMF0LHXuOACoBaItZA gP0vnA3+rMbT8VDL9UZzSxJEjDY6wo63azhqXJLVxeAFNurOBdKIpqyWDZ7BcyFDa2cw SexQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D3EDYbGccBK89yykxes9BQKaCfAxUWSmOZVPyYSYNP4=; b=qYNMOi5bwr7F/Ely6ITIFGzihZgYjCui0/4ghK3AIvjI7/O4+iEOKWS9SgQfJ8zqsk AZQsupbpkwZBSEGuhJ5C93IqX819kjY56mBUlx1LBhOjghFZSyPD4jM42KM/VNtb7e4K auiok2HYEsuSaD0RxvL8rpULV5/oobTATw9IQ0ySc7To5BJfvFmp+JTLuz7QIWfY60eQ CogTfPRCVNnyTnovCPZOXnNPmtBNl57hPEmbcSyOHA9tB0rVmbJVYpX/GmF1WV/9WFdY taU8eJ1HZ710HukyF5fPPR+nnmVHxwrKk7f2jz1Z5nea56Kgqyvifv4k1lLzRMNJhN5a qS2Q== X-Gm-Message-State: ANoB5pmU/hJHT4jNiU+8afqTlAX+Isp/FFTu6N5xdH8wGr++RHm1YzcF DfT6VIZ+oLS5K9JFpc+RwVZlHjjVd7E4SA== X-Received: by 2002:a05:6402:1aca:b0:469:701b:588d with SMTP id ba10-20020a0564021aca00b00469701b588dmr19471780edb.384.1669413339594; Fri, 25 Nov 2022 13:55:39 -0800 (PST) Received: from fedora.. ([87.116.166.89]) by smtp.gmail.com with ESMTPSA id l17-20020a1709063d3100b0077b2b0563f4sm2009764ejf.173.2022.11.25.13.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 13:55:39 -0800 (PST) From: Aleksa Savic To: linux-hwmon@vger.kernel.org Cc: leonard.anderweit@gmail.com, Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (aquacomputer_d5next) Add support for Quadro flow sensor pulses Date: Fri, 25 Nov 2022 22:55:15 +0100 Message-Id: <20221125215515.31380-1-savicaleksa83@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750507464355336376?= X-GMAIL-MSGID: =?utf-8?q?1750507464355336376?= Add support for reading and writing flow sensor pulses value on the Aquacomputer Quadro. Implemented by Leonard Anderweit [1]. [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/45 Originally-from: Leonard Anderweit Signed-off-by: Aleksa Savic --- Documentation/hwmon/aquacomputer_d5next.rst | 3 +- drivers/hwmon/aquacomputer_d5next.c | 68 ++++++++++++++++----- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hwmon/aquacomputer_d5next.rst index 15226346434d..637bdbc8fcad 100644 --- a/Documentation/hwmon/aquacomputer_d5next.rst +++ b/Documentation/hwmon/aquacomputer_d5next.rst @@ -39,7 +39,7 @@ current. The Quadro exposes four physical and sixteen virtual temperature sensors, a flow sensor and four PWM controllable fans, along with their speed (in RPM), power, -voltage and current. +voltage and current. Flow sensor pulses are also available. The Farbwerk and Farbwerk 360 expose four temperature sensors. Additionally, sixteen virtual temperature sensors of the Farbwerk 360 are exposed. @@ -64,6 +64,7 @@ Sysfs entries temp[1-20]_input Physical/virtual temperature sensors (in millidegrees Celsius) temp[1-4]_offset Temperature sensor correction offset (in millidegrees Celsius) fan[1-8]_input Pump/fan speed (in RPM) / Flow speed (in dL/h) +fan5_pulses Quadro flow sensor pulses power[1-8]_input Pump/fan power (in micro Watts) in[0-7]_input Pump/fan voltage (in milli Volts) curr[1-8]_input Pump/fan current (in milli Amperes) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 49d3f9876fe8..77a3ac33d4ac 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -136,6 +136,7 @@ static u8 quadro_sensor_fan_offsets[] = { 0x70, 0x7D, 0x8A, 0x97 }; /* Control report offsets for the Quadro */ #define QUADRO_TEMP_CTRL_OFFSET 0xA +#define QUADRO_FLOW_PULSES_CTRL_OFFSET 0x6 static u16 quadro_ctrl_fan_offsets[] = { 0x37, 0x8c, 0xe1, 0x136 }; /* Fan speed offsets (0-100%) */ /* Specs of High Flow Next flow sensor */ @@ -303,6 +304,7 @@ struct aqc_data { u16 temp_ctrl_offset; u16 power_cycle_count_offset; u8 flow_sensor_offset; + u8 flow_pulses_ctrl_offset; /* General info, same across all devices */ u32 serial_number[2]; @@ -461,20 +463,32 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3 } break; case hwmon_fan: - switch (priv->kind) { - case highflownext: - /* Special case to support flow sensor, water quality and conductivity */ - if (channel < 3) - return 0444; - break; - case quadro: - /* Special case to support flow sensor */ - if (channel < priv->num_fans + 1) - return 0444; + switch (attr) { + case hwmon_fan_input: + case hwmon_fan_label: + switch (priv->kind) { + case highflownext: + /* Special case to support flow sensor, water quality + * and conductivity + */ + if (channel < 3) + return 0444; + break; + case quadro: + /* Special case to support flow sensor */ + if (channel < priv->num_fans + 1) + return 0444; + break; + default: + if (channel < priv->num_fans) + return 0444; + break; + } break; - default: - if (channel < priv->num_fans) - return 0444; + case hwmon_fan_pulses: + /* Special case for Quadro flow sensor */ + if (priv->kind == quadro && channel == priv->num_fans) + return 0644; break; } break; @@ -552,7 +566,18 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, } break; case hwmon_fan: - *val = priv->speed_input[channel]; + switch (attr) { + case hwmon_fan_input: + *val = priv->speed_input[channel]; + break; + case hwmon_fan_pulses: + ret = aqc_get_ctrl_val(priv, priv->flow_pulses_ctrl_offset, val); + if (ret < 0) + return ret; + break; + default: + break; + } break; case hwmon_power: *val = priv->power_input[channel]; @@ -632,6 +657,18 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, return -EOPNOTSUPP; } break; + case hwmon_fan: + switch (attr) { + case hwmon_fan_pulses: + val = clamp_val(val, 10, 1000); + ret = aqc_set_ctrl_val(priv, priv->flow_pulses_ctrl_offset, val); + if (ret < 0) + return ret; + break; + default: + break; + } + break; case hwmon_pwm: switch (attr) { case hwmon_pwm_input: @@ -691,7 +728,7 @@ static const struct hwmon_channel_info *aqc_info[] = { HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL, - HWMON_F_INPUT | HWMON_F_LABEL, + HWMON_F_INPUT | HWMON_F_LABEL | HWMON_F_PULSES, HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL), @@ -1000,6 +1037,7 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->buffer_size = QUADRO_CTRL_REPORT_SIZE; priv->flow_sensor_offset = QUADRO_FLOW_SENSOR_OFFSET; + priv->flow_pulses_ctrl_offset = QUADRO_FLOW_PULSES_CTRL_OFFSET; priv->power_cycle_count_offset = QUADRO_POWER_CYCLES; priv->temp_label = label_temp_sensors;