2022-09-05 14:35:53

by Aleksa Savic

[permalink] [raw]
Subject: [PATCH] hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow Next

Extend aquacomputer_d5next driver to expose various hardware
sensors of the Aquacomputer High Flow Next flow sensor, which
communicates through a proprietary USB HID protocol.

The High Flow Next exposes +5V voltages, water quality, conductivity
and flow readings. A temperature sensor can be connected to it, in
which case it provides its reading and an estimation of the
dissipated/absorbed power in the liquid cooling loop.

Additionally, serial number and firmware version are exposed through
debugfs.

Registry offsets were discovered and tested by users on Github [1] [2].

[1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/issues/8
[2] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/34

Signed-off-by: Aleksa Savic <[email protected]>
---
Documentation/hwmon/aquacomputer_d5next.rst | 4 +
drivers/hwmon/Kconfig | 6 +-
drivers/hwmon/aquacomputer_d5next.c | 88 ++++++++++++++++++++-
3 files changed, 93 insertions(+), 5 deletions(-)

diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hwmon/aquacomputer_d5next.rst
index b63a78d47624..3d044b1a9aed 100644
--- a/Documentation/hwmon/aquacomputer_d5next.rst
+++ b/Documentation/hwmon/aquacomputer_d5next.rst
@@ -43,6 +43,10 @@ voltage and current.
The Farbwerk and Farbwerk 360 expose four temperature sensors. Additionally,
sixteen virtual temperature sensors of the Farbwerk 360 are exposed.

+The High Flow Next exposes +5V voltages, water quality, conductivity and flow readings.
+A temperature sensor can be connected to it, in which case it provides its reading
+and an estimation of the dissipated/absorbed power in the liquid cooling loop.
+
Depending on the device, not all sysfs and debugfs entries will be available.
Writing to virtual temperature sensors is not currently supported.

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index d32f1705915c..f604f599a341 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -257,14 +257,14 @@ config SENSORS_AHT10
will be called aht10.

config SENSORS_AQUACOMPUTER_D5NEXT
- tristate "Aquacomputer D5 Next, Octo, Quadro, Farbwerk, and Farbwerk 360"
+ tristate "Aquacomputer D5 Next, Octo, Quadro, Farbwerk, Farbwerk 360, High Flow Next"
depends on USB_HID
select CRC16
help
If you say yes here you get support for sensors and fans of
the Aquacomputer D5 Next watercooling pump, Octo and Quadro fan
- controllers, Farbwerk and Farbwerk 360 RGB controllers, where
- available.
+ controllers, Farbwerk and Farbwerk 360 RGB controllers, High Flow
+ Next sensor, where available.

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/aquacomputer_d5next.c
index b2b0c4fdfa84..a715142a3d0c 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)
+ * Quadro, High Flow Next)
*
* Aquacomputer devices send HID reports (with ID 0x01) every second to report
* sensor values.
@@ -34,7 +34,8 @@ static const char *const aqc_device_names[] = {
[farbwerk] = "farbwerk",
[farbwerk360] = "farbwerk360",
[octo] = "octo",
- [quadro] = "quadro"
+ [quadro] = "quadro",
+ [highflownext] = "highflownext"
};

#define DRIVER_NAME "aquacomputer_d5next"
@@ -120,6 +121,16 @@ static u8 quadro_sensor_fan_offsets[] = { 0x70, 0x7D, 0x8A, 0x97 };
/* Fan speed registers in Quadro control report (from 0-100%) */
static u16 quadro_ctrl_fan_offsets[] = { 0x36, 0x8b, 0xe0, 0x135 };

+/* Register offsets for the High Flow Next */
+#define HIGHFLOWNEXT_NUM_SENSORS 2
+#define HIGHFLOWNEXT_SENSOR_START 85
+#define HIGHFLOWNEXT_FLOW 81
+#define HIGHFLOWNEXT_WATER_QUALITY 89
+#define HIGHFLOWNEXT_POWER 91
+#define HIGHFLOWNEXT_CONDUCTIVITY 95
+#define HIGHFLOWNEXT_5V_VOLTAGE 97
+#define HIGHFLOWNEXT_5V_VOLTAGE_USB 99
+
/* Labels for D5 Next */
static const char *const label_d5next_temp[] = {
"Coolant temp"
@@ -228,6 +239,27 @@ static const char *const label_quadro_speeds[] = {
"Flow speed [dL/h]"
};

+/* Labels for High Flow Next */
+static const char *const label_highflownext_temp_sensors[] = {
+ "Coolant temp",
+ "External sensor"
+};
+
+static const char *const label_highflownext_fan_speed[] = {
+ "Flow [dL/h]",
+ "Water quality [%]",
+ "Conductivity [nS/cm]",
+};
+
+static const char *const label_highflownext_power[] = {
+ "Dissipated power",
+};
+
+static const char *const label_highflownext_voltage[] = {
+ "+5V voltage",
+ "+5V USB voltage"
+};
+
struct aqc_data {
struct hid_device *hdev;
struct device *hwmon_dev;
@@ -390,6 +422,11 @@ 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)
@@ -402,6 +439,18 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3
}
break;
case hwmon_power:
+ switch (priv->kind) {
+ case highflownext:
+ /* Special case to support one power sensor */
+ if (channel == 0)
+ return 0444;
+ break;
+ default:
+ if (channel < priv->num_fans)
+ return 0444;
+ break;
+ }
+ break;
case hwmon_curr:
if (channel < priv->num_fans)
return 0444;
@@ -413,6 +462,11 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3
if (channel < priv->num_fans + 2)
return 0444;
break;
+ case highflownext:
+ /* Special case to support two voltage sensors */
+ if (channel < 2)
+ return 0444;
+ break;
default:
if (channel < priv->num_fans)
return 0444;
@@ -679,6 +733,22 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8
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)
+ priv->power_input[0] = -ENODATA;
+ else
+ priv->power_input[0] =
+ get_unaligned_be16(data + HIGHFLOWNEXT_POWER) * 1000000;
+
+ priv->voltage_input[0] = get_unaligned_be16(data + HIGHFLOWNEXT_5V_VOLTAGE) * 10;
+ 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;
default:
break;
}
@@ -851,6 +921,19 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
priv->voltage_label = label_fan_voltage;
priv->current_label = label_fan_current;
break;
+ case USB_PRODUCT_ID_HIGHFLOWNEXT:
+ priv->kind = highflownext;
+
+ priv->num_fans = 0;
+ priv->num_temp_sensors = HIGHFLOWNEXT_NUM_SENSORS;
+ priv->temp_sensor_start_offset = HIGHFLOWNEXT_SENSOR_START;
+ priv->power_cycle_count_offset = QUADRO_POWER_CYCLES;
+
+ priv->temp_label = label_highflownext_temp_sensors;
+ priv->speed_label = label_highflownext_fan_speed;
+ priv->power_label = label_highflownext_power;
+ priv->voltage_label = label_highflownext_voltage;
+ break;
default:
break;
}
@@ -907,6 +990,7 @@ static const struct hid_device_id aqc_table[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_FARBWERK360) },
{ HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_OCTO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_QUADRO) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOWNEXT) },
{ }
};

--
2.37.2


2022-09-05 20:37:21

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow Next

Hi Aleksa,

I love your patch! Yet something to improve:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on next-20220901]
[cannot apply to linus/master v6.0-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Aleksa-Savic/hwmon-aquacomputer_d5next-Add-support-for-Aquacomputer-High-Flow-Next/20220905-222744
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: arc-randconfig-r043-20220905 (https://download.01.org/0day-ci/archive/20220906/[email protected]/config)
compiler: arceb-elf-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0a43ba8acd8bcd54afd03ea6149d54fc99fe284c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Aleksa-Savic/hwmon-aquacomputer_d5next-Add-support-for-Aquacomputer-High-Flow-Next/20220905-222744
git checkout 0a43ba8acd8bcd54afd03ea6149d54fc99fe284c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash drivers/hwmon/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/hwmon/aquacomputer_d5next.c:38:10: error: 'highflownext' undeclared here (not in a function)
38 | [highflownext] = "highflownext"
| ^~~~~~~~~~~~
>> drivers/hwmon/aquacomputer_d5next.c:38:10: error: array index in initializer not of integer type
drivers/hwmon/aquacomputer_d5next.c:38:10: note: (near initialization for 'aqc_device_names')
drivers/hwmon/aquacomputer_d5next.c: In function 'aqc_probe':
>> drivers/hwmon/aquacomputer_d5next.c:924:14: error: 'USB_PRODUCT_ID_HIGHFLOWNEXT' undeclared (first use in this function); did you mean 'USB_PRODUCT_ID_D5NEXT'?
924 | case USB_PRODUCT_ID_HIGHFLOWNEXT:
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| USB_PRODUCT_ID_D5NEXT
drivers/hwmon/aquacomputer_d5next.c:924:14: note: each undeclared identifier is reported only once for each function it appears in
In file included from drivers/hwmon/aquacomputer_d5next.c:15:
drivers/hwmon/aquacomputer_d5next.c: At top level:
>> drivers/hwmon/aquacomputer_d5next.c:993:54: error: 'USB_PRODUCT_ID_HIGHFLOWNEXT' undeclared here (not in a function); did you mean 'USB_PRODUCT_ID_D5NEXT'?
993 | { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOWNEXT) },
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/hid.h:713:54: note: in definition of macro 'HID_USB_DEVICE'
713 | .bus = BUS_USB, .vendor = (ven), .product = (prod)
| ^~~~


vim +/highflownext +38 drivers/hwmon/aquacomputer_d5next.c

31
32 static const char *const aqc_device_names[] = {
33 [d5next] = "d5next",
34 [farbwerk] = "farbwerk",
35 [farbwerk360] = "farbwerk360",
36 [octo] = "octo",
37 [quadro] = "quadro",
> 38 [highflownext] = "highflownext"
39 };
40

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-09-05 21:06:55

by Aleksa Savic

[permalink] [raw]
Subject: Re: [PATCH] hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow Next

Woops, looks like I sent a botched patch. Sorry for the noise,
will send a v2.

Thanks,
Aleksa

2022-09-05 23:58:29

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow Next

Hi Aleksa,

I love your patch! Yet something to improve:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on next-20220901]
[cannot apply to linus/master v6.0-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Aleksa-Savic/hwmon-aquacomputer_d5next-Add-support-for-Aquacomputer-High-Flow-Next/20220905-222744
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: riscv-buildonly-randconfig-r005-20220905
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project c55b41d5199d2394dd6cdb8f52180d8b81d809d4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/0a43ba8acd8bcd54afd03ea6149d54fc99fe284c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Aleksa-Savic/hwmon-aquacomputer_d5next-Add-support-for-Aquacomputer-High-Flow-Next/20220905-222744
git checkout 0a43ba8acd8bcd54afd03ea6149d54fc99fe284c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/hwmon/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/hwmon/aquacomputer_d5next.c:38:3: error: use of undeclared identifier 'highflownext'
[highflownext] = "highflownext"
^
drivers/hwmon/aquacomputer_d5next.c:425:8: error: use of undeclared identifier 'highflownext'
case highflownext:
^
drivers/hwmon/aquacomputer_d5next.c:443:8: error: use of undeclared identifier 'highflownext'
case highflownext:
^
drivers/hwmon/aquacomputer_d5next.c:465:8: error: use of undeclared identifier 'highflownext'
case highflownext:
^
drivers/hwmon/aquacomputer_d5next.c:736:7: error: use of undeclared identifier 'highflownext'
case highflownext:
^
>> drivers/hwmon/aquacomputer_d5next.c:924:7: error: use of undeclared identifier 'USB_PRODUCT_ID_HIGHFLOWNEXT'
case USB_PRODUCT_ID_HIGHFLOWNEXT:
^
drivers/hwmon/aquacomputer_d5next.c:925:16: error: use of undeclared identifier 'highflownext'
priv->kind = highflownext;
^
drivers/hwmon/aquacomputer_d5next.c:993:47: error: use of undeclared identifier 'USB_PRODUCT_ID_HIGHFLOWNEXT'
{ HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOWNEXT) },
^
8 errors generated.


vim +/highflownext +38 drivers/hwmon/aquacomputer_d5next.c

31
32 static const char *const aqc_device_names[] = {
33 [d5next] = "d5next",
34 [farbwerk] = "farbwerk",
35 [farbwerk360] = "farbwerk360",
36 [octo] = "octo",
37 [quadro] = "quadro",
> 38 [highflownext] = "highflownext"
39 };
40

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (3.63 kB)
config (175.16 kB)
Download all attachments

2022-09-06 11:37:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow Next

Hi Aleksa,

I love your patch! Yet something to improve:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on next-20220901]
[cannot apply to linus/master v6.0-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Aleksa-Savic/hwmon-aquacomputer_d5next-Add-support-for-Aquacomputer-High-Flow-Next/20220905-222744
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: i386-randconfig-a002 (https://download.01.org/0day-ci/archive/20220906/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0a43ba8acd8bcd54afd03ea6149d54fc99fe284c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Aleksa-Savic/hwmon-aquacomputer_d5next-Add-support-for-Aquacomputer-High-Flow-Next/20220905-222744
git checkout 0a43ba8acd8bcd54afd03ea6149d54fc99fe284c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash arch/x86/kvm/ drivers/hwmon/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/hwmon/aquacomputer_d5next.c:38:3: error: use of undeclared identifier 'highflownext'
[highflownext] = "highflownext"
^
drivers/hwmon/aquacomputer_d5next.c:425:8: error: use of undeclared identifier 'highflownext'
case highflownext:
^
drivers/hwmon/aquacomputer_d5next.c:443:8: error: use of undeclared identifier 'highflownext'
case highflownext:
^
drivers/hwmon/aquacomputer_d5next.c:465:8: error: use of undeclared identifier 'highflownext'
case highflownext:
^
drivers/hwmon/aquacomputer_d5next.c:736:7: error: use of undeclared identifier 'highflownext'
case highflownext:
^
>> drivers/hwmon/aquacomputer_d5next.c:924:7: error: use of undeclared identifier 'USB_PRODUCT_ID_HIGHFLOWNEXT'
case USB_PRODUCT_ID_HIGHFLOWNEXT:
^
drivers/hwmon/aquacomputer_d5next.c:925:16: error: use of undeclared identifier 'highflownext'
priv->kind = highflownext;
^
drivers/hwmon/aquacomputer_d5next.c:993:47: error: use of undeclared identifier 'USB_PRODUCT_ID_HIGHFLOWNEXT'
{ HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOWNEXT) },
^
>> drivers/hwmon/aquacomputer_d5next.c:997:1: error: definition of variable with array type needs an explicit size or an initializer
MODULE_DEVICE_TABLE(hid, aqc_table);
^
include/linux/module.h:244:21: note: expanded from macro 'MODULE_DEVICE_TABLE'
extern typeof(name) __mod_##type##__##name##_device_table \
^
<scratch space>:196:1: note: expanded from here
__mod_hid__aqc_table_device_table
^
9 errors generated.


vim +/highflownext +38 drivers/hwmon/aquacomputer_d5next.c

31
32 static const char *const aqc_device_names[] = {
33 [d5next] = "d5next",
34 [farbwerk] = "farbwerk",
35 [farbwerk360] = "farbwerk360",
36 [octo] = "octo",
37 [quadro] = "quadro",
> 38 [highflownext] = "highflownext"
39 };
40

--
0-DAY CI Kernel Test Service
https://01.org/lkp