From nobody Fri Jun 19 10:59:38 2026 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 6302DC433EF for ; Mon, 4 Apr 2022 13:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233174AbiDDNpB (ORCPT ); Mon, 4 Apr 2022 09:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357034AbiDDNo7 (ORCPT ); Mon, 4 Apr 2022 09:44:59 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D3224F1C; Mon, 4 Apr 2022 06:43:02 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id g22so11163373edz.2; Mon, 04 Apr 2022 06:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u0OSLQZj6r7Hg4QH+u+bSmvfVOK50W+ILu9L1bueJ4k=; b=OacaPTS9FUj3a6QF0pFR3OZnaEXWOy3ysmqDZn9Nqm/PSzpDMDk2Ruwegt1zAOrMnp XhGYkxRNWFE3/1ZxkDyX+CpwBGTEwSw3VBWZDgCijmOkF8IjAORzIray620mxtMGkjiP zcByLwfGkYe7hk7MOGe4u4gIVI9VOSVpaXHgZXYRCRkEsg2POZw8FQ/v+fm1ubcX83S7 sv1FNYW/hH6HY6HkfID6Ni2aEkh+g5Mcx/U5sWENAw3lAGuA4Dr5b31DukDg/1QPpJ9t Kb1EAhEKUehyYxsIAIWEPq6yLw6EoLVc9lo5FB9fe9zUCOZnFyAp0s1ay3XzWYVpOaBv kglQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u0OSLQZj6r7Hg4QH+u+bSmvfVOK50W+ILu9L1bueJ4k=; b=h29xlpa7gUEEgPDRVQSo+/tIbEvIdmzrD3WIZXbNKEKXRMW2TcuYET5hPkPfgXJB1g zQwPiwRkeomgWGVeHO6XUam3lUFraEbR1TasSktqMqDkvMoNqIjuEvyCVS83CMUoVjOg n9yWuvMQV5D3B+jqdJ1Ai4UwFSGZ6jHBMpIKFDfS99h2j7mhJAogyd8VrUDvF1tOYc4t GsmBQH4LRg94dsucpya5G1Yn+E3RpDFDR7uJlQ9SyKwUT+QBZnMHgcbGSAV8N4Y01V0D CCRz5kq2cgIF58wxYrpkCSo8AjNpFZMP8X3Xc2ixJ/l0oiqXWjUXVCBtoiMh2lh4Gjn/ XBZg== X-Gm-Message-State: AOAM532Ic/8DrwBhmGuKPF6kYtysUkBBJe4/GhnNyy+OwpkoDKPAcD5D LBcOAq00xYTniA3rJlwJZvY0VSLhIPg= X-Google-Smtp-Source: ABdhPJwgGbsdUP+u+WHvjtEc+QZw8GXcFPmE7gbhkyDM3xVyEHSRyp40EMgfcdgFJZbKdEHRglPmdA== X-Received: by 2002:a05:6402:5cd:b0:419:7753:acfb with SMTP id n13-20020a05640205cd00b004197753acfbmr68375edx.131.1649079780153; Mon, 04 Apr 2022 06:43:00 -0700 (PDT) Received: from fedora.. ([95.180.24.23]) by smtp.gmail.com with ESMTPSA id cr19-20020a170906d55300b006df6b316e29sm4392384ejc.208.2022.04.04.06.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 06:42:59 -0700 (PDT) From: Aleksa Savic To: linux-hwmon@vger.kernel.org Cc: savicaleksa83@gmail.com, Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] hwmon: (aquacomputer_d5next) Add support for Aquacomputer Octo Date: Mon, 4 Apr 2022 15:42:11 +0200 Message-Id: <20220404134212.9690-1-savicaleksa83@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Extend aquacomputer_d5next driver to expose hardware temperature sensors and fans of the Aquacomputer Octo fan controller, which communicates through a proprietary USB HID protocol. Four temperature sensors and eight PWM controllable fans are available. Additionally, serial number, firmware version and power-on count are exposed through debugfs. This driver has been tested on x86_64. Signed-off-by: Aleksa Savic --- Changes in v4: - Add comments above PWM conversion functions to note that they work in centi-percent Changes in v3: - Added break; statements where needed - aqc_set_ctrl_val() now only sets values with a length of 2 - Replace goto with return in aqc_send_ctrl_data() Changes in v2: - Fixed formatting - HID report values from device are now being converted sooner - aqc_pwm_to_percent() is now range checked - Put pointers to labels in aqc_data - Simplified checksum calculation call --- Documentation/hwmon/aquacomputer_d5next.rst | 4 + drivers/hwmon/Kconfig | 7 +- drivers/hwmon/aquacomputer_d5next.c | 433 +++++++++++++++++--- 3 files changed, 392 insertions(+), 52 deletions(-) diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hw= mon/aquacomputer_d5next.rst index 3373e27b707d..e69f718caf5b 100644 --- a/Documentation/hwmon/aquacomputer_d5next.rst +++ b/Documentation/hwmon/aquacomputer_d5next.rst @@ -7,6 +7,7 @@ Supported devices: =20 * Aquacomputer D5 Next watercooling pump * Aquacomputer Farbwerk 360 RGB controller +* Aquacomputer Octo fan controller =20 Author: Aleksa Savic =20 @@ -28,6 +29,9 @@ seems to require sending it a complete configuration. Tha= t includes addressable RGB LEDs, for which there is no standard sysfs interface. Thus, that task = is better suited for userspace tools. =20 +The Octo exposes four temperature sensors and eight PWM controllable fans,= along +with their speed (in RPM), power, voltage and current. + The Farbwerk 360 exposes four temperature sensors. Depending on the device, not all sysfs and debugfs entries will be available. =20 diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index db8bc55e5f50..5beadd8a0932 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -256,11 +256,12 @@ config SENSORS_AHT10 will be called aht10. =20 config SENSORS_AQUACOMPUTER_D5NEXT - tristate "Aquacomputer D5 Next watercooling pump" + tristate "Aquacomputer D5 Next, Octo and Farbwerk 360" depends on USB_HID help - If you say yes here you get support for the Aquacomputer D5 Next - watercooling pump sensors. + If you say yes here you get support for sensors and fans of + the Aquacomputer D5 Next watercooling pump, Octo fan + controller and Farbwerk 360 RGB controller, where available. =20 This driver can also be built as a module. If so, the module will be called aquacomputer_d5next. diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomput= er_d5next.c index 525809cf7c95..a464473bc981 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * hwmon driver for Aquacomputer devices (D5 Next, Farbwerk 360) + * hwmon driver for Aquacomputer devices (D5 Next, Farbwerk 360, Octo) * * Aquacomputer devices send HID reports (with ID 0x01) every second to re= port * sensor values. @@ -8,23 +8,27 @@ * Copyright 2021 Aleksa Savic */ =20 +#include #include #include #include #include #include +#include #include #include =20 #define USB_VENDOR_ID_AQUACOMPUTER 0x0c70 #define USB_PRODUCT_ID_D5NEXT 0xf00e #define USB_PRODUCT_ID_FARBWERK360 0xf010 +#define USB_PRODUCT_ID_OCTO 0xf011 =20 -enum kinds { d5next, farbwerk360 }; +enum kinds { d5next, farbwerk360, octo }; =20 static const char *const aqc_device_names[] =3D { [d5next] =3D "d5next", - [farbwerk360] =3D "farbwerk360" + [farbwerk360] =3D "farbwerk360", + [octo] =3D "octo" }; =20 #define DRIVER_NAME "aquacomputer_d5next" @@ -35,6 +39,18 @@ static const char *const aqc_device_names[] =3D { #define SERIAL_SECOND_PART 5 #define FIRMWARE_VERSION 13 =20 +#define CTRL_REPORT_ID 0x03 + +/* The HID report that the official software always sends + * after writing values, currently same for all devices + */ +#define SECONDARY_CTRL_REPORT_ID 0x02 +#define SECONDARY_CTRL_REPORT_SIZE 0x0B + +static u8 secondary_ctrl_report[] =3D { + 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC6 +}; + /* Register offsets for the D5 Next pump */ #define D5NEXT_POWER_CYCLES 24 =20 @@ -55,12 +71,38 @@ static const char *const aqc_device_names[] =3D { =20 /* Register offsets for the Farbwerk 360 RGB controller */ #define FARBWERK360_NUM_SENSORS 4 -#define FARBWERK360_SENSOR_START 0x32 +#define FARBWERK360_SENSOR_START 0x32 #define FARBWERK360_SENSOR_SIZE 0x02 #define FARBWERK360_SENSOR_DISCONNECTED 0x7FFF =20 +/* Register offsets for the Octo fan controller */ +#define OCTO_POWER_CYCLES 0x18 +#define OCTO_NUM_FANS 8 +#define OCTO_FAN_PERCENT_OFFSET 0x00 +#define OCTO_FAN_VOLTAGE_OFFSET 0x02 +#define OCTO_FAN_CURRENT_OFFSET 0x04 +#define OCTO_FAN_POWER_OFFSET 0x06 +#define OCTO_FAN_SPEED_OFFSET 0x08 + +static u8 octo_sensor_fan_offsets[] =3D { 0x7D, 0x8A, 0x97, 0xA4, 0xB1, 0x= BE, 0xCB, 0xD8 }; + +#define OCTO_NUM_SENSORS 4 +#define OCTO_SENSOR_START 0x3D +#define OCTO_SENSOR_SIZE 0x02 +#define OCTO_SENSOR_DISCONNECTED 0x7FFF + +#define OCTO_CTRL_REPORT_SIZE 0x65F +#define OCTO_CTRL_REPORT_CHECKSUM_OFFSET 0x65D +#define OCTO_CTRL_REPORT_CHECKSUM_START 0x01 +#define OCTO_CTRL_REPORT_CHECKSUM_LENGTH 0x65C + +/* Fan speed registers in Octo control report (from 0-100%) */ +static u16 octo_ctrl_fan_offsets[] =3D { 0x5B, 0xB0, 0x105, 0x15A, 0x1AF, = 0x204, 0x259, 0x2AE }; + /* Labels for D5 Next */ -#define L_D5NEXT_COOLANT_TEMP "Coolant temp" +static const char *const label_d5next_temp[] =3D { + "Coolant temp" +}; =20 static const char *const label_d5next_speeds[] =3D { "Pump speed", @@ -83,7 +125,7 @@ static const char *const label_d5next_current[] =3D { "Fan current" }; =20 -/* Labels for Farbwerk 360 temperature sensors */ +/* Labels for Farbwerk 360 and Octo temperature sensors */ static const char *const label_temp_sensors[] =3D { "Sensor 1", "Sensor 2", @@ -91,32 +133,182 @@ static const char *const label_temp_sensors[] =3D { "Sensor 4" }; =20 +/* Labels for Octo */ +static const char *const label_fan_speed[] =3D { + "Fan 1 speed", + "Fan 2 speed", + "Fan 3 speed", + "Fan 4 speed", + "Fan 5 speed", + "Fan 6 speed", + "Fan 7 speed", + "Fan 8 speed" +}; + +static const char *const label_fan_power[] =3D { + "Fan 1 power", + "Fan 2 power", + "Fan 3 power", + "Fan 4 power", + "Fan 5 power", + "Fan 6 power", + "Fan 7 power", + "Fan 8 power" +}; + +static const char *const label_fan_voltage[] =3D { + "Fan 1 voltage", + "Fan 2 voltage", + "Fan 3 voltage", + "Fan 4 voltage", + "Fan 5 voltage", + "Fan 6 voltage", + "Fan 7 voltage", + "Fan 8 voltage" +}; + +static const char *const label_fan_current[] =3D { + "Fan 1 current", + "Fan 2 current", + "Fan 3 current", + "Fan 4 current", + "Fan 5 current", + "Fan 6 current", + "Fan 7 current", + "Fan 8 current" +}; + struct aqc_data { struct hid_device *hdev; struct device *hwmon_dev; struct dentry *debugfs; + struct mutex mutex; /* Used for locking access when reading and writing P= WM values */ enum kinds kind; const char *name; =20 + int buffer_size; + u8 *buffer; + int checksum_start; + int checksum_length; + int checksum_offset; + /* General info, same across all devices */ u32 serial_number[2]; u16 firmware_version; =20 - /* D5 Next specific - how many times the device was powered on */ + /* How many times the device was powered on */ u32 power_cycles; =20 /* Sensor values */ s32 temp_input[4]; - u16 speed_input[2]; - u32 power_input[2]; - u16 voltage_input[3]; - u16 current_input[2]; + u16 speed_input[8]; + u32 power_input[8]; + u16 voltage_input[8]; + u16 current_input[8]; + + /* Label values */ + const char *const *temp_label; + const char *const *speed_label; + const char *const *power_label; + const char *const *voltage_label; + const char *const *current_label; =20 unsigned long updated; }; =20 -static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types ty= pe, u32 attr, - int channel) +/* Converts from centi-percent */ +static int aqc_percent_to_pwm(u16 val) +{ + return DIV_ROUND_CLOSEST(val * 255, 100 * 100); +} + +/* Converts to centi-percent */ +static int aqc_pwm_to_percent(long val) +{ + if (val < 0 || val > 255) + return -EINVAL; + + return DIV_ROUND_CLOSEST(val * 100 * 100, 255); +} + +/* Expects the mutex to be locked */ +static int aqc_get_ctrl_data(struct aqc_data *priv) +{ + int ret; + + memset(priv->buffer, 0x00, priv->buffer_size); + ret =3D hid_hw_raw_request(priv->hdev, CTRL_REPORT_ID, priv->buffer, priv= ->buffer_size, + HID_FEATURE_REPORT, HID_REQ_GET_REPORT); + if (ret < 0) + ret =3D -ENODATA; + + return ret; +} + +/* Expects the mutex to be locked */ +static int aqc_send_ctrl_data(struct aqc_data *priv) +{ + int ret; + u16 checksum; + + /* Init and xorout value for CRC-16/USB is 0xffff */ + checksum =3D crc16(0xffff, priv->buffer + priv->checksum_start, priv->che= cksum_length); + checksum ^=3D 0xffff; + + /* Place the new checksum at the end of the report */ + put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset); + + /* Send the patched up report back to the device */ + ret =3D hid_hw_raw_request(priv->hdev, CTRL_REPORT_ID, priv->buffer, priv= ->buffer_size, + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); + if (ret < 0) + return ret; + + /* The official software sends this report after every change, so do it h= ere as well */ + ret =3D hid_hw_raw_request(priv->hdev, SECONDARY_CTRL_REPORT_ID, secondar= y_ctrl_report, + SECONDARY_CTRL_REPORT_SIZE, HID_FEATURE_REPORT, + HID_REQ_SET_REPORT); + return ret; +} + +/* Refreshes the control buffer and returns value at offset */ +static int aqc_get_ctrl_val(struct aqc_data *priv, int offset) +{ + int ret; + + mutex_lock(&priv->mutex); + + ret =3D aqc_get_ctrl_data(priv); + if (ret < 0) + goto unlock_and_return; + + ret =3D get_unaligned_be16(priv->buffer + offset); + +unlock_and_return: + mutex_unlock(&priv->mutex); + return ret; +} + +static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val) +{ + int ret; + + mutex_lock(&priv->mutex); + + ret =3D aqc_get_ctrl_data(priv); + if (ret < 0) + goto unlock_and_return; + + put_unaligned_be16((u16)val, priv->buffer + offset); + + ret =3D aqc_send_ctrl_data(priv); + +unlock_and_return: + mutex_unlock(&priv->mutex); + return ret; +} + +static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types ty= pe, u32 attr, int channel) { const struct aqc_data *priv =3D data; =20 @@ -128,17 +320,47 @@ static umode_t aqc_is_visible(const void *data, enum = hwmon_sensor_types type, u3 return 0444; break; case farbwerk360: + case octo: return 0444; default: break; } break; + case hwmon_pwm: + switch (priv->kind) { + case octo: + switch (attr) { + case hwmon_pwm_input: + return 0644; + default: + break; + } + break; + default: + break; + } + break; case hwmon_fan: case hwmon_power: - case hwmon_in: case hwmon_curr: switch (priv->kind) { case d5next: + if (channel < 2) + return 0444; + break; + case octo: + return 0444; + default: + break; + } + break; + case hwmon_in: + switch (priv->kind) { + case d5next: + if (channel < 3) + return 0444; + break; + case octo: return 0444; default: break; @@ -154,6 +376,7 @@ static umode_t aqc_is_visible(const void *data, enum hw= mon_sensor_types type, u3 static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 = attr, int channel, long *val) { + int ret; struct aqc_data *priv =3D dev_get_drvdata(dev); =20 if (time_after(jiffies, priv->updated + STATUS_UPDATE_INTERVAL)) @@ -172,6 +395,19 @@ static int aqc_read(struct device *dev, enum hwmon_sen= sor_types type, u32 attr, case hwmon_power: *val =3D priv->power_input[channel]; break; + case hwmon_pwm: + switch (priv->kind) { + case octo: + ret =3D aqc_get_ctrl_val(priv, octo_ctrl_fan_offsets[channel]); + if (ret < 0) + return ret; + + *val =3D aqc_percent_to_pwm(ret); + break; + default: + break; + } + break; case hwmon_in: *val =3D priv->voltage_input[channel]; break; @@ -192,48 +428,51 @@ static int aqc_read_string(struct device *dev, enum h= wmon_sensor_types type, u32 =20 switch (type) { case hwmon_temp: - switch (priv->kind) { - case d5next: - *str =3D L_D5NEXT_COOLANT_TEMP; - break; - case farbwerk360: - *str =3D label_temp_sensors[channel]; - break; - default: - break; - } + *str =3D priv->temp_label[channel]; break; case hwmon_fan: - switch (priv->kind) { - case d5next: - *str =3D label_d5next_speeds[channel]; - break; - default: - break; - } + *str =3D priv->speed_label[channel]; break; case hwmon_power: - switch (priv->kind) { - case d5next: - *str =3D label_d5next_power[channel]; - break; - default: - break; - } + *str =3D priv->power_label[channel]; break; case hwmon_in: - switch (priv->kind) { - case d5next: - *str =3D label_d5next_voltages[channel]; - break; - default: - break; - } + *str =3D priv->voltage_label[channel]; break; case hwmon_curr: - switch (priv->kind) { - case d5next: - *str =3D label_d5next_current[channel]; + *str =3D priv->current_label[channel]; + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32= attr, int channel, + long val) +{ + int ret, pwm_value; + struct aqc_data *priv =3D dev_get_drvdata(dev); + + switch (type) { + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_input: + switch (priv->kind) { + case octo: + pwm_value =3D aqc_pwm_to_percent(val); + if (pwm_value < 0) + return pwm_value; + + ret =3D aqc_set_ctrl_val(priv, octo_ctrl_fan_offsets[channel], + pwm_value); + if (ret < 0) + return ret; + break; + default: + break; + } break; default: break; @@ -250,6 +489,7 @@ static const struct hwmon_ops aqc_hwmon_ops =3D { .is_visible =3D aqc_is_visible, .read =3D aqc_read, .read_string =3D aqc_read_string, + .write =3D aqc_write }; =20 static const struct hwmon_channel_info *aqc_info[] =3D { @@ -259,16 +499,48 @@ static const struct hwmon_channel_info *aqc_info[] = =3D { HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL), HWMON_CHANNEL_INFO(fan, + 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_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL), HWMON_CHANNEL_INFO(power, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, HWMON_P_INPUT | HWMON_P_LABEL, HWMON_P_INPUT | HWMON_P_LABEL), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT), HWMON_CHANNEL_INFO(in, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL), HWMON_CHANNEL_INFO(curr, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, HWMON_C_INPUT | HWMON_C_LABEL, HWMON_C_INPUT | HWMON_C_LABEL), NULL @@ -326,6 +598,35 @@ static int aqc_raw_event(struct hid_device *hdev, stru= ct hid_report *report, u8 priv->temp_input[i] =3D sensor_value * 10; } break; + case octo: + priv->power_cycles =3D get_unaligned_be32(data + OCTO_POWER_CYCLES); + + /* Fan speed and related readings */ + for (i =3D 0; i < OCTO_NUM_FANS; i++) { + priv->speed_input[i] =3D + get_unaligned_be16(data + octo_sensor_fan_offsets[i] + + OCTO_FAN_SPEED_OFFSET); + priv->power_input[i] =3D + get_unaligned_be16(data + octo_sensor_fan_offsets[i] + + OCTO_FAN_POWER_OFFSET) * 10000; + priv->voltage_input[i] =3D + get_unaligned_be16(data + octo_sensor_fan_offsets[i] + + OCTO_FAN_VOLTAGE_OFFSET) * 10; + priv->current_input[i] =3D + get_unaligned_be16(data + octo_sensor_fan_offsets[i] + + OCTO_FAN_CURRENT_OFFSET); + } + + /* Temperature sensor readings */ + for (i =3D 0; i < OCTO_NUM_SENSORS; i++) { + sensor_value =3D get_unaligned_be16(data + OCTO_SENSOR_START + + i * OCTO_SENSOR_SIZE); + if (sensor_value =3D=3D OCTO_SENSOR_DISCONNECTED) + priv->temp_input[i] =3D -ENODATA; + else + priv->temp_input[i] =3D sensor_value * 10; + } + break; default: break; } @@ -378,8 +679,14 @@ static void aqc_debugfs_init(struct aqc_data *priv) debugfs_create_file("serial_number", 0444, priv->debugfs, priv, &serial_n= umber_fops); debugfs_create_file("firmware_version", 0444, priv->debugfs, priv, &firmw= are_version_fops); =20 - if (priv->kind =3D=3D d5next) + switch (priv->kind) { + case d5next: + case octo: debugfs_create_file("power_cycles", 0444, priv->debugfs, priv, &power_cy= cles_fops); + break; + default: + break; + } } =20 #else @@ -419,9 +726,30 @@ static int aqc_probe(struct hid_device *hdev, const st= ruct hid_device_id *id) switch (hdev->product) { case USB_PRODUCT_ID_D5NEXT: priv->kind =3D d5next; + + priv->temp_label =3D label_d5next_temp; + priv->speed_label =3D label_d5next_speeds; + priv->power_label =3D label_d5next_power; + priv->voltage_label =3D label_d5next_voltages; + priv->current_label =3D label_d5next_current; break; case USB_PRODUCT_ID_FARBWERK360: priv->kind =3D farbwerk360; + + priv->temp_label =3D label_temp_sensors; + break; + case USB_PRODUCT_ID_OCTO: + priv->kind =3D octo; + priv->buffer_size =3D OCTO_CTRL_REPORT_SIZE; + priv->checksum_start =3D OCTO_CTRL_REPORT_CHECKSUM_START; + priv->checksum_length =3D OCTO_CTRL_REPORT_CHECKSUM_LENGTH; + priv->checksum_offset =3D OCTO_CTRL_REPORT_CHECKSUM_OFFSET; + + priv->temp_label =3D label_temp_sensors; + priv->speed_label =3D label_fan_speed; + priv->power_label =3D label_fan_power; + priv->voltage_label =3D label_fan_voltage; + priv->current_label =3D label_fan_current; break; default: break; @@ -429,6 +757,12 @@ static int aqc_probe(struct hid_device *hdev, const st= ruct hid_device_id *id) =20 priv->name =3D aqc_device_names[priv->kind]; =20 + priv->buffer =3D devm_kzalloc(&hdev->dev, priv->buffer_size, GFP_KERNEL); + if (!priv->buffer) + return -ENOMEM; + + mutex_init(&priv->mutex); + priv->hwmon_dev =3D hwmon_device_register_with_info(&hdev->dev, priv->nam= e, priv, &aqc_chip_info, NULL); =20 @@ -462,6 +796,7 @@ static void aqc_remove(struct hid_device *hdev) static const struct hid_device_id aqc_table[] =3D { { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_D5NEXT) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_FARBWERK360) = }, + { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_OCTO) }, { } }; =20 --=20 2.35.1