From patchwork Sun Dec 18 11:31:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Anderweit X-Patchwork-Id: 13076029 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 4105BC10F1E for ; Sun, 18 Dec 2022 11:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbiLRLcG (ORCPT ); Sun, 18 Dec 2022 06:32:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbiLRLcF (ORCPT ); Sun, 18 Dec 2022 06:32:05 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CDE463CA; Sun, 18 Dec 2022 03:32:03 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id m5-20020a7bca45000000b003d2fbab35c6so4619079wml.4; Sun, 18 Dec 2022 03:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R0WKs2spplBX1OT7AnO6JAVTucdqtfLOI5UI2kX7UwE=; b=n+10qFGybORa4kQxYKG4STcwIMzcgSNUs6KbrEw/l3CHAKIVdqSflULT5InhFIenJe 5JDN0aTef3TmUYokjEadD4fmMjz0XvfdKzaUQg2RTkfnh/kxGB+rieHAQATi7yt3GwbC 2WlNb6O9zTmyH1B5pOZ/YjhR+GNcXQYkTpwQj5nMSuOsj2XAVV63e5YFJH8McBK0GLvR IJCdkB1ufAegaEhk81HCgfVpNGs0hyGBFzERaBx/OvkT0fPOcVh0Nd80rtVNPVyrmZF5 nmrPHhFdhFq+8GNTDeveIs9mx+yEP/b8cvArmwd40aFhrOf+ZQUg/veR1QJkV7PieUXP L5qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R0WKs2spplBX1OT7AnO6JAVTucdqtfLOI5UI2kX7UwE=; b=W+h/4TlsbJfZJdtDbJj+A24Y+C3OGBfvDS0mjvpFYtxXpB/yts8csNFdkAWT6F++8P gRsVljt9SMvFSLe1kX91og/Auna5k55Ky9/Eu22FS08p+UqnqrB6JEjMYWO7KvzNBAHG MyoBCXZkEx1mfz9StsgvyASkfetipmvt3ILxtAMuBMLLwqMy9f4S34nVMAhIPklORkfn 17pMmGT8M9PJNrXeakvOk4MGU+b91gnkSoP9GcnlN96ich+wEfidYqfvCfUlBC3GmVyW cRIdpuQgaNR1XlqP/PXU239FOkxGosJze4fmcw2Dp99SU/wWYoZX9eL9s9bNPADu3Iqh hO7g== X-Gm-Message-State: ANoB5plEC5aKGclUXMRdAOAv0tqshbPjsa5AN11aidUJ/IszR83ZaU6D gANmXTSj3x8r5cJ3/bgJMXZcd0LTkKeZIg== X-Google-Smtp-Source: AA0mqf4GeZbaUYl8nZJugrKURgZQZlUYLytwz1Xlq+W9MN8fPFHqv0eB6gu3SdFKr4o0EiY5QFpwmA== X-Received: by 2002:a1c:f20e:0:b0:3cf:b690:6a9d with SMTP id s14-20020a1cf20e000000b003cfb6906a9dmr29690178wmc.30.1671363121554; Sun, 18 Dec 2022 03:32:01 -0800 (PST) Received: from localhost.localdomain ([2001:9e8:20fa:a700:21e9:9128:9ea2:3911]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b003d069fc7372sm9440751wms.1.2022.12.18.03.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 03:32:01 -0800 (PST) From: Leonard Anderweit To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leonard Anderweit Subject: [PATCH 1/6] hwmon: (aquacomputer_d5next) Rename AQC_TEMP_SENSOR_SIZE to AQC_SENSOR_SIZE Date: Sun, 18 Dec 2022 12:31:26 +0100 Message-Id: <20221218113131.3752-2-leonard.anderweit@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221218113131.3752-1-leonard.anderweit@gmail.com> References: <20221218113131.3752-1-leonard.anderweit@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Rename AQC_TEMP_SENSOR_SIZE to AQC_SENSOR_SIZE to use with other sensor types. Signed-off-by: Leonard Anderweit --- drivers/hwmon/aquacomputer_d5next.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 9cc10080160b..8fd9f7fd7ec4 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -60,7 +60,7 @@ static u8 secondary_ctrl_report[] = { }; /* Sensor sizes and offsets for all Aquacomputer devices */ -#define AQC_TEMP_SENSOR_SIZE 0x02 +#define AQC_SENSOR_SIZE 0x02 #define AQC_TEMP_SENSOR_DISCONNECTED 0x7FFF #define AQC_FAN_PERCENT_OFFSET 0x00 #define AQC_FAN_VOLTAGE_OFFSET 0x02 @@ -557,7 +557,7 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, case hwmon_temp_offset: ret = aqc_get_ctrl_val(priv, priv->temp_ctrl_offset + - channel * AQC_TEMP_SENSOR_SIZE, val); + channel * AQC_SENSOR_SIZE, val); if (ret < 0) return ret; @@ -651,7 +651,7 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, val = clamp_val(val, -15000, 15000) / 10; ret = aqc_set_ctrl_val(priv, priv->temp_ctrl_offset + - channel * AQC_TEMP_SENSOR_SIZE, val); + channel * AQC_SENSOR_SIZE, val); if (ret < 0) return ret; break; @@ -797,7 +797,7 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 for (i = 0; i < priv->num_temp_sensors; i++) { sensor_value = get_unaligned_be16(data + priv->temp_sensor_start_offset + - i * AQC_TEMP_SENSOR_SIZE); + i * AQC_SENSOR_SIZE); if (sensor_value == AQC_TEMP_SENSOR_DISCONNECTED) priv->temp_input[i] = -ENODATA; else @@ -808,7 +808,7 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 for (j = 0; j < priv->num_virtual_temp_sensors; j++) { sensor_value = get_unaligned_be16(data + priv->virtual_temp_sensor_start_offset + - j * AQC_TEMP_SENSOR_SIZE); + j * AQC_SENSOR_SIZE); if (sensor_value == AQC_TEMP_SENSOR_DISCONNECTED) priv->temp_input[i] = -ENODATA; else From patchwork Sun Dec 18 11:31:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Anderweit X-Patchwork-Id: 13076030 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 B53DDC3DA7B for ; Sun, 18 Dec 2022 11:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiLRLcH (ORCPT ); Sun, 18 Dec 2022 06:32:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230436AbiLRLcF (ORCPT ); Sun, 18 Dec 2022 06:32:05 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D57276422; Sun, 18 Dec 2022 03:32:03 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id f13-20020a1cc90d000000b003d08c4cf679so4611205wmb.5; Sun, 18 Dec 2022 03:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z/yBxHd+8YC4wBMSoujgnt9WFjjMoc4F6zebxkDT7rA=; b=e04n22PUh9HTJJnTrs3svu9UYml5c26/3n6xroQlixSoamCKRgIp4h/08m+dJTzaM7 Diubcz3Ult7xs5F7ToSQ8XfhF+D876dT9db+PM8glyJyk2T0V9uwcQ935G6aVkBXsOIl mHWxZOJ4HvbhUhifA6B4uPQAEWTsM/AbOsi09olqveGQoWS7alDpflC7vu4tkDJEHFlX OlL/ThMtEtjBSfDbfTq5zwmozMxndep/P/KvFGNSGKKmUaAa0ZeaNcqtWwM+nhi3YRVM 8xdEu4f7OyMmcaWxaT23R94G0doSZZ7kCIa2bhP+xqu253+nrhd8Of5ZnkxrwHIO5Ov/ sUPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z/yBxHd+8YC4wBMSoujgnt9WFjjMoc4F6zebxkDT7rA=; b=UqJga+WWdK0ORsMDSlsAO24tiAypfenoMPJJbdk7hDZCj3AaauKOK+xePPG3RSEOeV OIZx50xRqDX9PxaY3yXTi9T7shOHkJJ0sS7itLj+pp8QEM6t7/3JtSEkuJRd6E0J1lSP 3Gt/ZKsDk2rHHHP5XOQ7hzjGuXQyem4f9SoN8DOym/SrnODMWwEjcAQZoTkj0NQz2/TI mqDKRrcb6i8pGGowja1lEMq4a71guBKILTy3pu8ybUFApguWB5/HoMDKhJoxA+hzA6Qr prpese2URtJ72Lin/lUqXCmBSr9nUfHcdQqAT4+DqIyhfFmSeR2eBdDMxKO0PuQdqwLI jHRg== X-Gm-Message-State: ANoB5pmgcUKY7DZAuuJFL+Gfa9G+jYc5g4gVsWu3b80l7ENPe8JTXaaZ DU0gMcMcAIpCwVZLACO9sYDOjCJ0aX77BQ== X-Google-Smtp-Source: AA0mqf6LPjNEoILNeV0EDRCaCsgDAkh35iA4P8Y7ncxG98gkhQk0BW+hTz4F6CajMU9UQTZETaL3kw== X-Received: by 2002:a05:600c:1d2a:b0:3d2:2faf:e54b with SMTP id l42-20020a05600c1d2a00b003d22fafe54bmr16328656wms.6.1671363122396; Sun, 18 Dec 2022 03:32:02 -0800 (PST) Received: from localhost.localdomain ([2001:9e8:20fa:a700:21e9:9128:9ea2:3911]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b003d069fc7372sm9440751wms.1.2022.12.18.03.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 03:32:02 -0800 (PST) From: Leonard Anderweit To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leonard Anderweit Subject: [PATCH 2/6] hwmon: (aquacomputer_d5next) Restructure flow sensor reading Date: Sun, 18 Dec 2022 12:31:27 +0100 Message-Id: <20221218113131.3752-3-leonard.anderweit@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221218113131.3752-1-leonard.anderweit@gmail.com> References: <20221218113131.3752-1-leonard.anderweit@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Read flow sensors the same way for all devices instead of in special cases. Implemented by Aleksa Savic [1]. [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/commit/1c10912c5fdc8287d88378bcf1ef14d596f29462 Originally-from: Aleksa Savic Signed-off-by: Leonard Anderweit --- drivers/hwmon/aquacomputer_d5next.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 8fd9f7fd7ec4..388bf1e33e0d 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -125,6 +125,7 @@ static u16 octo_ctrl_fan_offsets[] = { 0x5B, 0xB0, 0x105, 0x15A, 0x1AF, 0x204, 0 #define QUADRO_NUM_FANS 4 #define QUADRO_NUM_SENSORS 4 #define QUADRO_NUM_VIRTUAL_SENSORS 16 +#define QUADRO_NUM_FLOW_SENSORS 1 #define QUADRO_CTRL_REPORT_SIZE 0x3c1 /* Sensor report offsets for the Quadro */ @@ -141,6 +142,7 @@ static u16 quadro_ctrl_fan_offsets[] = { 0x37, 0x8c, 0xe1, 0x136 }; /* Fan speed /* Specs of High Flow Next flow sensor */ #define HIGHFLOWNEXT_NUM_SENSORS 2 +#define HIGHFLOWNEXT_NUM_FLOW_SENSORS 1 /* Sensor report offsets for the High Flow Next */ #define HIGHFLOWNEXT_SENSOR_START 85 @@ -303,7 +305,8 @@ struct aqc_data { int virtual_temp_sensor_start_offset; u16 temp_ctrl_offset; u16 power_cycle_count_offset; - u8 flow_sensor_offset; + int num_flow_sensors; + u8 flow_sensors_start_offset; u8 flow_pulses_ctrl_offset; /* General info, same across all devices */ @@ -475,8 +478,8 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3 return 0444; break; case quadro: - /* Special case to support flow sensor */ - if (channel < priv->num_fans + 1) + /* Special case to support flow sensors */ + if (channel < priv->num_fans + priv->num_flow_sensors) return 0444; break; default: @@ -830,6 +833,13 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 get_unaligned_be16(data + priv->fan_sensor_offsets[i] + AQC_FAN_CURRENT_OFFSET); } + /* Flow sensor readings */ + for (j = 0; j < priv->num_flow_sensors; j++) { + priv->speed_input[i] = get_unaligned_be16(data + priv->flow_sensors_start_offset + + j * AQC_SENSOR_SIZE); + i++; + } + if (priv->power_cycle_count_offset != 0) priv->power_cycles = get_unaligned_be32(data + priv->power_cycle_count_offset); @@ -839,9 +849,6 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 priv->voltage_input[2] = get_unaligned_be16(data + D5NEXT_5V_VOLTAGE) * 10; priv->voltage_input[3] = get_unaligned_be16(data + D5NEXT_12V_VOLTAGE) * 10; break; - case quadro: - priv->speed_input[4] = get_unaligned_be16(data + priv->flow_sensor_offset); - break; case highflownext: /* If external temp sensor is not connected, its power reading is also N/A */ if (priv->temp_input[1] == -ENODATA) @@ -854,7 +861,6 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 priv->voltage_input[1] = get_unaligned_be16(data + HIGHFLOWNEXT_5V_VOLTAGE_USB) * 10; - priv->speed_input[0] = get_unaligned_be16(data + HIGHFLOWNEXT_FLOW); priv->speed_input[1] = get_unaligned_be16(data + HIGHFLOWNEXT_WATER_QUALITY); priv->speed_input[2] = get_unaligned_be16(data + HIGHFLOWNEXT_CONDUCTIVITY); break; @@ -1034,11 +1040,13 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->temp_sensor_start_offset = QUADRO_SENSOR_START; priv->num_virtual_temp_sensors = QUADRO_NUM_VIRTUAL_SENSORS; priv->virtual_temp_sensor_start_offset = QUADRO_VIRTUAL_SENSORS_START; + priv->num_flow_sensors = QUADRO_NUM_FLOW_SENSORS; + priv->flow_sensors_start_offset = QUADRO_FLOW_SENSOR_OFFSET; + priv->temp_ctrl_offset = QUADRO_TEMP_CTRL_OFFSET; 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; @@ -1056,6 +1064,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->num_temp_sensors = HIGHFLOWNEXT_NUM_SENSORS; priv->temp_sensor_start_offset = HIGHFLOWNEXT_SENSOR_START; + priv->num_flow_sensors = HIGHFLOWNEXT_NUM_FLOW_SENSORS; + priv->flow_sensors_start_offset = HIGHFLOWNEXT_FLOW; priv->power_cycle_count_offset = QUADRO_POWER_CYCLES; From patchwork Sun Dec 18 11:31:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Anderweit X-Patchwork-Id: 13076031 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 5BC6BC3DA78 for ; Sun, 18 Dec 2022 11:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230467AbiLRLcI (ORCPT ); Sun, 18 Dec 2022 06:32:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbiLRLcF (ORCPT ); Sun, 18 Dec 2022 06:32:05 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA64D6567; Sun, 18 Dec 2022 03:32:04 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id ay40so4695332wmb.2; Sun, 18 Dec 2022 03:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vSetaWLPY2RzczT8dviu9hjeHMLZpPIw6Q1N0t2ZCKw=; b=Cyb93Jfpn/cMaA8CYCQBPt9rsFG9AEWjzj/F8ZsdNxUTs7KrhOq6x0u91KVY2DghTh 4nb8dBHbyIkyWRHchu7MOtIclaYwHtbZZvrNs7uj1aXCJeXwqNMluJ1di2iRiH7KrW7X DrjJ23d4jmYJA6dKp+FTxoz7ayxr/KKdDHObJdYMf6Sh7/rh4v5En8OYS7+X1uEjehag XWA5eAAyGlj09ZQl5RjWPrFhzD4MAtq4uG2EBMLg7Rbvi4COpaJuT2PotbCLxjgZsir9 7DqGLcYUFSGQ35G9YCNYCh5j+tll0XinvrAbklTVIT/59oOQ9XaPwe1TBY7eNcQlv4VY fIlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vSetaWLPY2RzczT8dviu9hjeHMLZpPIw6Q1N0t2ZCKw=; b=QV4mbSoGWX3hPdZMNJYUCcboFJoBXaTF0ZSusC67/ElgDL/hiM7DEwi11rc7wF59Ze GROP46ERtlqYtt9h7RYI4Fni5hFiPdUePT1tYTbX89CvSYEDU1y21jkRAsJTrpMJLEpE y/xDMUArmaeWl+xv7rjFdQiwLOAkxeBuuOrH3DweLmCo3mqY/hRMqFA7BtCovud2091n SFzJxbz7bxLvWTq7Bq21mk3AA5N69UGLWsvPhb8bPPOIW1oJN2SGdgwAxuinKyZkBvvX onn5otnwmNOVAxntXMpM5nU3otBy0Dt/jAvdvo90zS/BsqeABmW12K0Ar3Ek0rDYyzDA Ahxg== X-Gm-Message-State: ANoB5pmKrXZNpBzTWrE/0TmHDSGHVV/6uzGiuyw9O/F8Dupc/tsXol2U HPLvM461cr3tvaTd+CcZXaPN/vGcYmXn8Vs+ X-Google-Smtp-Source: AA0mqf6srxtsltfnM3JV+Jqhe1JY4SS4cC1aPGdFTwViDIzKBg4EMrI3ip8OhvTDz9tWaSXlX/Bnqw== X-Received: by 2002:a05:600c:3d06:b0:3c6:e60f:3f55 with SMTP id bh6-20020a05600c3d0600b003c6e60f3f55mr30077687wmb.12.1671363123289; Sun, 18 Dec 2022 03:32:03 -0800 (PST) Received: from localhost.localdomain ([2001:9e8:20fa:a700:21e9:9128:9ea2:3911]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b003d069fc7372sm9440751wms.1.2022.12.18.03.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 03:32:02 -0800 (PST) From: Leonard Anderweit To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leonard Anderweit Subject: [PATCH 3/6] hwmon: (aquacomputer_d5next) Add structure for fan layout Date: Sun, 18 Dec 2022 12:31:28 +0100 Message-Id: <20221218113131.3752-4-leonard.anderweit@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221218113131.3752-1-leonard.anderweit@gmail.com> References: <20221218113131.3752-1-leonard.anderweit@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Introduce structure for per device fan sensor offsets. This allows reading fan sensors in aqc_raw_event() from devices which use a different sensor layout in their status HID report. Currently only one version is implemented as all supported devices use the same structure. Signed-off-by: Leonard Anderweit --- drivers/hwmon/aquacomputer_d5next.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 388bf1e33e0d..1ea866fcd3ec 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -282,6 +282,21 @@ static const char *const label_highflownext_voltage[] = { "+5V USB voltage" }; +struct aqc_fan_structure_offsets { + u8 voltage; + u8 curr; + u8 power; + u8 speed; +}; + +/* Fan structure offsets for all devices except Aquaero */ +static struct aqc_fan_structure_offsets aqc_general_fan_structure = { + .voltage = AQC_FAN_VOLTAGE_OFFSET, + .curr = AQC_FAN_CURRENT_OFFSET, + .power = AQC_FAN_POWER_OFFSET, + .speed = AQC_FAN_SPEED_OFFSET +}; + struct aqc_data { struct hid_device *hdev; struct device *hwmon_dev; @@ -308,6 +323,7 @@ struct aqc_data { int num_flow_sensors; u8 flow_sensors_start_offset; u8 flow_pulses_ctrl_offset; + struct aqc_fan_structure_offsets *fan_structure; /* General info, same across all devices */ u32 serial_number[2]; @@ -822,15 +838,17 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 /* Fan speed and related readings */ for (i = 0; i < priv->num_fans; i++) { priv->speed_input[i] = - get_unaligned_be16(data + priv->fan_sensor_offsets[i] + AQC_FAN_SPEED_OFFSET); + get_unaligned_be16(data + priv->fan_sensor_offsets[i] + + priv->fan_structure->speed); priv->power_input[i] = get_unaligned_be16(data + priv->fan_sensor_offsets[i] + - AQC_FAN_POWER_OFFSET) * 10000; + priv->fan_structure->power) * 10000; priv->voltage_input[i] = get_unaligned_be16(data + priv->fan_sensor_offsets[i] + - AQC_FAN_VOLTAGE_OFFSET) * 10; + priv->fan_structure->voltage) * 10; priv->current_input[i] = - get_unaligned_be16(data + priv->fan_sensor_offsets[i] + AQC_FAN_CURRENT_OFFSET); + get_unaligned_be16(data + priv->fan_sensor_offsets[i] + + priv->fan_structure->curr); } /* Flow sensor readings */ @@ -1078,6 +1096,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) break; } + priv->fan_structure = &aqc_general_fan_structure; + if (priv->buffer_size != 0) { priv->checksum_start = 0x01; priv->checksum_length = priv->buffer_size - 3; From patchwork Sun Dec 18 11:31:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Anderweit X-Patchwork-Id: 13076032 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 1876DC4167B for ; Sun, 18 Dec 2022 11:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbiLRLcJ (ORCPT ); Sun, 18 Dec 2022 06:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbiLRLcG (ORCPT ); Sun, 18 Dec 2022 06:32:06 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 968EC5FCD; Sun, 18 Dec 2022 03:32:05 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso6979734wme.5; Sun, 18 Dec 2022 03:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yLjJfom/Djky4gJzOObWXZRGBYjZpEjW1f7nmI91XpI=; b=RYFhvq3UuA1RlSEtXy76MNft8qV3J3SYjxceU6+W/2yaQ5XjS35UK6Xx4nkY+6Q3nH AVtfbyCcrFcUDa9qUdEKAN06yySkNyEoPefRksOH6iT+M178KlbjroWFWXlHToExXOL5 1RWB5hKHNVVVv4muz6KDbn423Lis+18ixeMkzZT2FdjXwPBF4877bdBZ1PViRsnVqucH WSLZfx2smHC+rCVs4XGDZ+DwU5t4kg+Tnp5+RPnYFBBrPU0cb9Ib+42FsSyfoMLS687u 6NQPqAMNfKrQnj4xjfLLUY2MGaQyBTyw0hIDQd2Bm58fAo52E0ZX32kHmyA1pTz+F/CI DIew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yLjJfom/Djky4gJzOObWXZRGBYjZpEjW1f7nmI91XpI=; b=Z36attyEOynvCy6FCw1Lz27t9iNn46inblryVGZJq22ZUWmPttrweRh5cBHdvN9McM X8b+v+ocYvJuvzKlk0IILLe4+y3hN3r6CvlPz1Djn5FAsXnrBxxHXcImY+GgblsCzKrW 1duQ7UNPP9TYMj8fzWLR3P2Nuov0szuiHIwVBh6NZ4Q/R6mWT0L6SEgh+QGWiw+KUkHn wPrJGSGjraXQvsYLc2/OqiU5q860hhMs7xP+BTz9rEmYqp/d1qOZbbqqN67BcfG9OWZO tZbhRofix1I/JD72YQCIyJ66H6EwEG99prKhiDbXRdJmDvv2DYlmp2p7DE6XLlc3mNyM 4hzQ== X-Gm-Message-State: ANoB5pm5jSv95UjRK8iMSK+V2TlxkgMJu8NqVYtkQ2ns86pVxZpcEuXZ FwPIY+jO7TF9osaTzeRXrlFxFVTtFBME7EoB X-Google-Smtp-Source: AA0mqf5J2dKxLGdrSUWQsEJ4+4N8P2+k9DxXVA1Q0iGylxqEwxcHn0DgJtE4fznDovotRigng/hIFw== X-Received: by 2002:a05:600c:3511:b0:3cf:7b8b:6521 with SMTP id h17-20020a05600c351100b003cf7b8b6521mr30384391wmq.32.1671363124085; Sun, 18 Dec 2022 03:32:04 -0800 (PST) Received: from localhost.localdomain ([2001:9e8:20fa:a700:21e9:9128:9ea2:3911]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b003d069fc7372sm9440751wms.1.2022.12.18.03.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 03:32:03 -0800 (PST) From: Leonard Anderweit To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leonard Anderweit Subject: [PATCH 4/6] hwmon: (aquacomputer_d5next) Device dependent serial number and firmware offsets Date: Sun, 18 Dec 2022 12:31:29 +0100 Message-Id: <20221218113131.3752-5-leonard.anderweit@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221218113131.3752-1-leonard.anderweit@gmail.com> References: <20221218113131.3752-1-leonard.anderweit@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add device dependent serial number and firmware offsets to support devices with different offsets. All currently supported devices share the same offsets. Implemented by Aleksa Savic [1]. [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/31/commits/14c3acf78b17397edb5dd356e6f5943a9996a1f9 Originally-from: Aleksa Savic Signed-off-by: Leonard Anderweit --- drivers/hwmon/aquacomputer_d5next.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 1ea866fcd3ec..cc53231067f4 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -43,9 +43,7 @@ static const char *const aqc_device_names[] = { #define STATUS_REPORT_ID 0x01 #define STATUS_UPDATE_INTERVAL (2 * HZ) /* In seconds */ -#define SERIAL_FIRST_PART 3 -#define SERIAL_SECOND_PART 5 -#define FIRMWARE_VERSION 13 +#define SERIAL_PART_OFFSET 2 #define CTRL_REPORT_ID 0x03 @@ -59,7 +57,10 @@ static u8 secondary_ctrl_report[] = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC6 }; -/* Sensor sizes and offsets for all Aquacomputer devices */ +/* Info, sensor sizes and offsets for all Aquacomputer devices */ +#define AQC_SERIAL_START 0x3 +#define AQC_FIRMWARE_VERSION 0xD + #define AQC_SENSOR_SIZE 0x02 #define AQC_TEMP_SENSOR_DISCONNECTED 0x7FFF #define AQC_FAN_PERCENT_OFFSET 0x00 @@ -326,7 +327,9 @@ struct aqc_data { struct aqc_fan_structure_offsets *fan_structure; /* General info, same across all devices */ + u8 serial_number_start_offset; u32 serial_number[2]; + u8 firmware_version_offset; u16 firmware_version; /* How many times the device was powered on, if available */ @@ -808,9 +811,10 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 priv = hid_get_drvdata(hdev); /* Info provided with every report */ - priv->serial_number[0] = get_unaligned_be16(data + SERIAL_FIRST_PART); - priv->serial_number[1] = get_unaligned_be16(data + SERIAL_SECOND_PART); - priv->firmware_version = get_unaligned_be16(data + FIRMWARE_VERSION); + priv->serial_number[0] = get_unaligned_be16(data + priv->serial_number_start_offset); + priv->serial_number[1] = get_unaligned_be16(data + priv->serial_number_start_offset + + SERIAL_PART_OFFSET); + priv->firmware_version = get_unaligned_be16(data + priv->firmware_version_offset); /* Physical temperature sensor readings */ for (i = 0; i < priv->num_temp_sensors; i++) { @@ -1096,6 +1100,9 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) break; } + priv->serial_number_start_offset = AQC_SERIAL_START; + priv->firmware_version_offset = AQC_FIRMWARE_VERSION; + priv->fan_structure = &aqc_general_fan_structure; if (priv->buffer_size != 0) { From patchwork Sun Dec 18 11:31:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Anderweit X-Patchwork-Id: 13076033 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 5872AC4708E for ; Sun, 18 Dec 2022 11:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbiLRLcJ (ORCPT ); Sun, 18 Dec 2022 06:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbiLRLcH (ORCPT ); Sun, 18 Dec 2022 06:32:07 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D9A263CA; Sun, 18 Dec 2022 03:32:06 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id bi26-20020a05600c3d9a00b003d3404a89faso3358947wmb.1; Sun, 18 Dec 2022 03:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3pbmmyFC1PRzbhY0ju1h8WYqW4QNOGc54qUO49wYIb0=; b=jCDsQlfkx0e63LiHu050H2soe6xVvWqRctC6450L4tfFQikkSRK5GMLlBQ1kITmjf1 6xdwrjmqQpjNbQbbYiHOjqktEY/9qQqZB0PPMXDVIY23COsts0zV6PKAwXDjL/+ggtA4 FTk71gKMMxR1uosPNOPKfU7mPSJYHUN/50I0OaoSsd5U1CBOI7rVm6GvrGIfeiKCYwaN XntuBXFwZWYzM4BohgzZv/EQEud8wut9Z45O7jBL5LOhYwKA3eEU7GhxfkXFxjMaruNa qd8VgBH6wqZAKSEoYWngNCdIr94JOXYNt3U83nuhubaUklO5CWBfoqQI2fbYnmcd0TYQ eSgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3pbmmyFC1PRzbhY0ju1h8WYqW4QNOGc54qUO49wYIb0=; b=KMNAWN1kREm4OIslYfugIo6+6r66R+f1yuLXQ892JtkJItI3WpT9T0vcA2HUWz8jJj X54F9DZdcn+TSbCCgd/NlGxdA9ndq/9KZyHRGpumtav9mOcywQewHtkSnIOXrAkIPHh5 bvaG/n8qpA53Brm5Et/F8NGAG6KJxbvIvuugdfQWtlnM3sIcrHMK1VJa4FIHaLXJfRQ5 a9/LqlXDxdgKwhxnDssYGtwB/b7NwyeJdHMJSXugwB3os/31m6t88WDXK2G2BFaQAbr3 PlxgnM2TPZOVDLQMbfQU+R5g7mXzLuCd+w/6tK3uA6Faw85Ha49mttZ7x7GlJvNAnkWu ll1g== X-Gm-Message-State: ANoB5pnHiAtS9Q+iplBipa0Z5eLpumcOzdsT7+hsjmNPzQ0+FYFRtR+g 05c+qu5xxPe6QubNNdKZF/SAYlugQ1Q85M/B X-Google-Smtp-Source: AA0mqf4f/BdGEhFCMc0GEwgRmfVZ9HxBGiOItzgkUMtnEpcF/cnCDU9ihr1zAMcYETc9K0HD8l8HGQ== X-Received: by 2002:a7b:c358:0:b0:3d1:f882:43eb with SMTP id l24-20020a7bc358000000b003d1f88243ebmr29548154wmj.10.1671363124970; Sun, 18 Dec 2022 03:32:04 -0800 (PST) Received: from localhost.localdomain ([2001:9e8:20fa:a700:21e9:9128:9ea2:3911]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b003d069fc7372sm9440751wms.1.2022.12.18.03.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 03:32:04 -0800 (PST) From: Leonard Anderweit To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leonard Anderweit Subject: [PATCH 5/6] hwmon: (aquacomputer_d5next) Make fan sensor offsets u16 Date: Sun, 18 Dec 2022 12:31:30 +0100 Message-Id: <20221218113131.3752-6-leonard.anderweit@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221218113131.3752-1-leonard.anderweit@gmail.com> References: <20221218113131.3752-1-leonard.anderweit@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Make fan sensor offsets u16 as u8 is insufficient for upcoming devices. Signed-off-by: Leonard Anderweit --- drivers/hwmon/aquacomputer_d5next.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index cc53231067f4..d28d7079917a 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -83,7 +83,7 @@ static u8 secondary_ctrl_report[] = { #define D5NEXT_5V_VOLTAGE 0x39 #define D5NEXT_12V_VOLTAGE 0x37 #define D5NEXT_VIRTUAL_SENSORS_START 0x3f -static u8 d5next_sensor_fan_offsets[] = { D5NEXT_PUMP_OFFSET, D5NEXT_FAN_OFFSET }; +static u16 d5next_sensor_fan_offsets[] = { D5NEXT_PUMP_OFFSET, D5NEXT_FAN_OFFSET }; /* Control report offsets for the D5 Next pump */ #define D5NEXT_TEMP_CTRL_OFFSET 0x2D /* Temperature sensor offsets location */ @@ -115,7 +115,7 @@ static u16 d5next_ctrl_fan_offsets[] = { 0x97, 0x42 }; /* Pump and fan speed (fr #define OCTO_POWER_CYCLES 0x18 #define OCTO_SENSOR_START 0x3D #define OCTO_VIRTUAL_SENSORS_START 0x45 -static u8 octo_sensor_fan_offsets[] = { 0x7D, 0x8A, 0x97, 0xA4, 0xB1, 0xBE, 0xCB, 0xD8 }; +static u16 octo_sensor_fan_offsets[] = { 0x7D, 0x8A, 0x97, 0xA4, 0xB1, 0xBE, 0xCB, 0xD8 }; /* Control report offsets for the Octo */ #define OCTO_TEMP_CTRL_OFFSET 0xA @@ -134,7 +134,7 @@ static u16 octo_ctrl_fan_offsets[] = { 0x5B, 0xB0, 0x105, 0x15A, 0x1AF, 0x204, 0 #define QUADRO_SENSOR_START 0x34 #define QUADRO_VIRTUAL_SENSORS_START 0x3c #define QUADRO_FLOW_SENSOR_OFFSET 0x6e -static u8 quadro_sensor_fan_offsets[] = { 0x70, 0x7D, 0x8A, 0x97 }; +static u16 quadro_sensor_fan_offsets[] = { 0x70, 0x7D, 0x8A, 0x97 }; /* Control report offsets for the Quadro */ #define QUADRO_TEMP_CTRL_OFFSET 0xA @@ -313,7 +313,7 @@ struct aqc_data { int checksum_offset; int num_fans; - u8 *fan_sensor_offsets; + u16 *fan_sensor_offsets; u16 *fan_ctrl_offsets; int num_temp_sensors; int temp_sensor_start_offset; From patchwork Sun Dec 18 11:31:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Anderweit X-Patchwork-Id: 13076034 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 A9336C10F1E for ; Sun, 18 Dec 2022 11:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbiLRLcQ (ORCPT ); Sun, 18 Dec 2022 06:32:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbiLRLcI (ORCPT ); Sun, 18 Dec 2022 06:32:08 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615026422; Sun, 18 Dec 2022 03:32:07 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so4629538wms.2; Sun, 18 Dec 2022 03:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NGUMh8qUOo0nRY5Ge+o8HiihlH9WbEdrIODpngTYT8o=; b=bTZm+6W7pLy9IxX3hontjakYQQNYFg2pZ7HjDXZW+2obJb/tD/ltKYh/EsXA21ztBY io59ywVfMTDeW0ML4oyoYqnEOGPNlfyg4PtJHot/wzAMcHG21w/P4bUHPPNVeDyGhj1h AsuDij7BQv173ReC4Hd1u+eo+y4WCxn6xdfyOoeb3A3phbuK2tBChyDgorjflFHOa/Me L5ZjPm2KDT8Ngk0T5IEetsUBPPmKS3nFbukt645wDMEGrJMNwZDAygi6FyEGX/c4FyOy sl5sjy7OLrbVP52y6kMKTIGt/wIkdbtv+rs5qZdnKJzvkJY0P86AhYLRLM29gArLHLKn wb3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NGUMh8qUOo0nRY5Ge+o8HiihlH9WbEdrIODpngTYT8o=; b=g94iODeKhyOdLn8Dbvu0Hcn2yUlBp+Qa5cKyUEG3hgyD0b5f8rvOvyEz4HXPyNGKF0 1mu64S8ZMehmc06M3+5h+SXdSs/1aq1Vjc8g/suWSsuTbhrR0hIILwJoU6rZ7HJkA1SQ l2C7xRpsT9EkyDmehPXOby4G5uJUvGexXqdnkP4pWzX1yiOBa4eUT35mEArge4yLCN5T etVYEL9D2Zyg8ee09HOds2VtwDaCcLGe9qE3In8o0JyCG1iQZnKDe6YAnRAkg2MWYqOz E0oGc8/VxBA123pTkxR9zxJEs2VhiuDiqfrrwhrZ5aPqU27ZlGa7fJCBj0iW7v534qvv V6rQ== X-Gm-Message-State: ANoB5pnfR3yvRAWC0myULveb3NGtwEgywHYRCemvKI3vERZe3Jk9N6P/ dLIOyHDJHqydXK525Pc5uAKJt7/EAJMdvwXS X-Google-Smtp-Source: AA0mqf5zQncc9fQm9tNY5rxyqdfw64V7uzyXXXw2q5JHkTwdcb1gJOSSezGuHyGTWNUUf109HkzOkw== X-Received: by 2002:a05:600c:3b23:b0:3d1:ebdf:d586 with SMTP id m35-20020a05600c3b2300b003d1ebdfd586mr29959461wms.29.1671363125886; Sun, 18 Dec 2022 03:32:05 -0800 (PST) Received: from localhost.localdomain ([2001:9e8:20fa:a700:21e9:9128:9ea2:3911]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b003d069fc7372sm9440751wms.1.2022.12.18.03.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 03:32:05 -0800 (PST) From: Leonard Anderweit To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic , Jack Doan , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leonard Anderweit Subject: [PATCH 6/6] hwmon: (aquacomputer_d5next) Support sensors for Aquacomputer Aquaero Date: Sun, 18 Dec 2022 12:31:31 +0100 Message-Id: <20221218113131.3752-7-leonard.anderweit@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221218113131.3752-1-leonard.anderweit@gmail.com> References: <20221218113131.3752-1-leonard.anderweit@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add support for reading sensors of the Aquacomputer Aquaero 5/6 fan controllers. These fan controllers supports 4 fans, 8 physical temperature sensors, 8 virtual temperature sensors and 2 flow sensors. Temperature and flow sensor reading implemented by Aleksa Savic [1] [2] [3]. [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/31 [2] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/51 [3] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/55 Originally-from: Aleksa Savic Signed-off-by: Leonard Anderweit --- Documentation/hwmon/aquacomputer_d5next.rst | 5 + drivers/hwmon/aquacomputer_d5next.c | 108 ++++++++++++++++++-- 2 files changed, 104 insertions(+), 9 deletions(-) diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hwmon/aquacomputer_d5next.rst index 637bdbc8fcad..b94ff08080bf 100644 --- a/Documentation/hwmon/aquacomputer_d5next.rst +++ b/Documentation/hwmon/aquacomputer_d5next.rst @@ -5,6 +5,7 @@ Kernel driver aquacomputer-d5next Supported devices: +* Aquacomputer Aquaero 5/6 fan controllers * Aquacomputer D5 Next watercooling pump * Aquacomputer Farbwerk RGB controller * Aquacomputer Farbwerk 360 RGB controller @@ -20,6 +21,10 @@ Description This driver exposes hardware sensors of listed Aquacomputer devices, which communicate through proprietary USB HID protocols. +The Aquaero devices expose eight temperature sensors, eight virtual temperature +sensors and two flow senors. The fans expose their speed (in RPM), power, +voltage and current. + For the D5 Next pump, available sensors are pump and fan speed, power, voltage and current, as well as coolant temperature and eight virtual temp sensors. Also available through debugfs are the serial number, firmware version and power-on diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index d28d7079917a..0fd00cfb86c8 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * hwmon driver for Aquacomputer devices (D5 Next, Farbwerk, Farbwerk 360, Octo, - * Quadro, High Flow Next) + * Quadro, High Flow Next, Aquaero) * * Aquacomputer devices send HID reports (with ID 0x01) every second to report * sensor values. @@ -21,6 +21,7 @@ #include #define USB_VENDOR_ID_AQUACOMPUTER 0x0c70 +#define USB_PRODUCT_ID_AQUAERO 0xf001 #define USB_PRODUCT_ID_FARBWERK 0xf00a #define USB_PRODUCT_ID_QUADRO 0xf00d #define USB_PRODUCT_ID_D5NEXT 0xf00e @@ -28,7 +29,7 @@ #define USB_PRODUCT_ID_OCTO 0xf011 #define USB_PRODUCT_ID_HIGHFLOWNEXT 0xf012 -enum kinds { d5next, farbwerk, farbwerk360, octo, quadro, highflownext }; +enum kinds { d5next, farbwerk, farbwerk360, octo, quadro, highflownext, aquaero }; static const char *const aqc_device_names[] = { [d5next] = "d5next", @@ -36,7 +37,8 @@ static const char *const aqc_device_names[] = { [farbwerk360] = "farbwerk360", [octo] = "octo", [quadro] = "quadro", - [highflownext] = "highflownext" + [highflownext] = "highflownext", + [aquaero] = "aquaero" }; #define DRIVER_NAME "aquacomputer_d5next" @@ -57,7 +59,7 @@ static u8 secondary_ctrl_report[] = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC6 }; -/* Info, sensor sizes and offsets for all Aquacomputer devices */ +/* Info, sensor sizes and offsets for most Aquacomputer devices */ #define AQC_SERIAL_START 0x3 #define AQC_FIRMWARE_VERSION 0xD @@ -69,6 +71,24 @@ static u8 secondary_ctrl_report[] = { #define AQC_FAN_POWER_OFFSET 0x06 #define AQC_FAN_SPEED_OFFSET 0x08 +/* Specs of the Aquaero fan controllers */ +#define AQUAERO_SERIAL_START 0x07 +#define AQUAERO_FIRMWARE_VERSION 0x0B +#define AQUAERO_NUM_FANS 4 +#define AQUAERO_NUM_SENSORS 8 +#define AQUAERO_NUM_VIRTUAL_SENSORS 8 +#define AQUAERO_NUM_FLOW_SENSORS 2 + +/* Sensor report offsets for Aquaero fan controllers */ +#define AQUAERO_SENSOR_START 0x65 +#define AQUAERO_VIRTUAL_SENSOR_START 0x85 +#define AQUAERO_FLOW_SENSORS_START 0xF9 +#define AQUAERO_FAN_VOLTAGE_OFFSET 0x04 +#define AQUAERO_FAN_CURRENT_OFFSET 0x06 +#define AQUAERO_FAN_POWER_OFFSET 0x08 +#define AQUAERO_FAN_SPEED_OFFSET 0x00 +static u16 aquaero_sensor_fan_offsets[] = { 0x167, 0x173, 0x17f, 0x18B }; + /* Specs of the D5 Next pump */ #define D5NEXT_NUM_FANS 2 #define D5NEXT_NUM_SENSORS 1 @@ -181,12 +201,16 @@ static const char *const label_d5next_current[] = { "Fan current" }; -/* Labels for Farbwerk, Farbwerk 360 and Octo and Quadro temperature sensors */ +/* Labels for Aquaero, Farbwerk, Farbwerk 360 and Octo and Quadro temperature sensors */ static const char *const label_temp_sensors[] = { "Sensor 1", "Sensor 2", "Sensor 3", - "Sensor 4" + "Sensor 4", + "Sensor 5", + "Sensor 6", + "Sensor 7", + "Sensor 8" }; static const char *const label_virtual_temp_sensors[] = { @@ -262,6 +286,16 @@ static const char *const label_quadro_speeds[] = { "Flow speed [dL/h]" }; +/* Labels for Aquaero fan speeds */ +static const char *const label_aquaero_speeds[] = { + "Fan 1 speed", + "Fan 2 speed", + "Fan 3 speed", + "Fan 4 speed", + "Flow sensor 1 [dL/h]", + "Flow sensor 2 [dL/h]" +}; + /* Labels for High Flow Next */ static const char *const label_highflownext_temp_sensors[] = { "Coolant temp", @@ -290,6 +324,14 @@ struct aqc_fan_structure_offsets { u8 speed; }; +/* Fan structure offsets for Aquaero */ +static struct aqc_fan_structure_offsets aqc_aquaero_fan_structure = { + .voltage = AQUAERO_FAN_VOLTAGE_OFFSET, + .curr = AQUAERO_FAN_CURRENT_OFFSET, + .power = AQUAERO_FAN_POWER_OFFSET, + .speed = AQUAERO_FAN_SPEED_OFFSET +}; + /* Fan structure offsets for all devices except Aquaero */ static struct aqc_fan_structure_offsets aqc_general_fan_structure = { .voltage = AQC_FAN_VOLTAGE_OFFSET, @@ -496,6 +538,7 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3 if (channel < 3) return 0444; break; + case aquaero: case quadro: /* Special case to support flow sensors */ if (channel < priv->num_fans + priv->num_flow_sensors) @@ -977,6 +1020,42 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) goto fail_and_stop; switch (hdev->product) { + case USB_PRODUCT_ID_AQUAERO: + /* + * Aquaero presents itself as three HID devices under the same product ID: + * "aquaero keyboard/mouse", "aquaero System Control" and "aquaero Device", + * which is the one we want to communicate with. Unlike most other Aquacomputer + * devices, Aquaero does not return meaningful data when explicitly requested + * using GET_FEATURE_REPORT. + * + * The difference between "aquaero Device" and the other two is in the collections + * they present. The two other devices have the type of the second element in + * their respective collections set to 1, while the real device has it set to 0. + */ + if (hdev->collection[1].type != 0) { + ret = -ENODEV; + goto fail_and_close; + } + + priv->kind = aquaero; + + priv->num_fans = AQUAERO_NUM_FANS; + priv->fan_sensor_offsets = aquaero_sensor_fan_offsets; + + priv->num_temp_sensors = AQUAERO_NUM_SENSORS; + priv->temp_sensor_start_offset = AQUAERO_SENSOR_START; + priv->num_virtual_temp_sensors = AQUAERO_NUM_VIRTUAL_SENSORS; + priv->virtual_temp_sensor_start_offset = AQUAERO_VIRTUAL_SENSOR_START; + priv->num_flow_sensors = AQUAERO_NUM_FLOW_SENSORS; + priv->flow_sensors_start_offset = AQUAERO_FLOW_SENSORS_START; + + priv->temp_label = label_temp_sensors; + priv->virtual_temp_label = label_virtual_temp_sensors; + priv->speed_label = label_aquaero_speeds; + priv->power_label = label_fan_power; + priv->voltage_label = label_fan_voltage; + priv->current_label = label_fan_current; + break; case USB_PRODUCT_ID_D5NEXT: priv->kind = d5next; @@ -1100,10 +1179,20 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) break; } - priv->serial_number_start_offset = AQC_SERIAL_START; - priv->firmware_version_offset = AQC_FIRMWARE_VERSION; + switch (priv->kind) { + case aquaero: + priv->serial_number_start_offset = AQUAERO_SERIAL_START; + priv->firmware_version_offset = AQUAERO_FIRMWARE_VERSION; + + priv->fan_structure = &aqc_aquaero_fan_structure; + break; + default: + priv->serial_number_start_offset = AQC_SERIAL_START; + priv->firmware_version_offset = AQC_FIRMWARE_VERSION; - priv->fan_structure = &aqc_general_fan_structure; + priv->fan_structure = &aqc_general_fan_structure; + break; + } if (priv->buffer_size != 0) { priv->checksum_start = 0x01; @@ -1152,6 +1241,7 @@ static void aqc_remove(struct hid_device *hdev) } static const struct hid_device_id aqc_table[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUAERO) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_D5NEXT) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_FARBWERK) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_FARBWERK360) },