Skip to contentSkip to conversation

hwmon: add Corsair Commander Pro driver

RFC Superseded Marius Zachmann 2 participants 2 messages Jun 17, 2020 – Jun 21, 2020

Subsystems (3)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Marius Zachmann

author maintainer
#0 lore raw

RFC v3 1/1 hwmon: add Corsair Commander Pro driver

This is v3 of a driver for the Corsair Commander Pro. It provides sysfs attributes for:
- Reading fan speed
- Reading temp sensors
- Reading voltage values
- Writing pwm and reading last written pwm
- Reading fan and temp connection status

I still need to add it to hid_ignore_list in hid-quirks.h, but for now I don't want to spam another mailing list.

---
Changes from v2
- add corsair-cpro to Documentation/hwmon/index.rst
- add SPDX license identifier to corsair-cpro.rst
- remove fanX_enable from Documentation and driver
- changed comment style
- clarified protocol in comments
- add get_temp_cnct for reading temperature sensor connection status
- added temp_cnct and temp_label in ccp_device
- added tempX_label, showing connection status
- renamed get_fan_mode_label to get_fan_cnct
- get_temp_cnct and get_fan_cnct only called in probe
- send_usb_cmd checks errors in the device response
- send_usb_cmd clears the buffer and sets the command
- inlined get_fan_rpm and get_voltage and removed functions
- more reverse christmas tree
- add device ids to hid_ignore_list in hid-quirks.h

Changes from v1:
- Style issues
- Changed to USB driver
- Clarify reading pwm
- Fixed attribute name number in Documentation
- MODULE_LICENSE now "GPL"
- Removed unneccesary hwmondev in ccp_device
- Moved buffer to ccp_device and mutex out of send_usb_cmd
- No more replacing or ignoring error codes
- Use DIV_ROUND_CLOSEST in set_pwm
- Changed fan_label when unknown to "fanX other"
- Only accept 0 or 1 for fan_enable
- Check for ERR_PTR in ccp_probe

---
 Documentation/hwmon/corsair-cpro.rst |  40 +++
 Documentation/hwmon/index.rst        |   1 +
 MAINTAINERS                          |   6 +
 drivers/hwmon/Kconfig                |  10 +
 drivers/hwmon/Makefile               |   1 +
 drivers/hwmon/corsair-cpro.c         | 497 +++++++++++++++++++++++++++
 6 files changed, 555 insertions(+)
 create mode 100644 Documentation/hwmon/corsair-cpro.rst
 create mode 100644 drivers/hwmon/corsair-cpro.c
Documentation/hwmon/corsair-cpro.rst new file +40 -0
new file mode 100644
index 000000000000..2383c6f72115
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Kernel driver corsair-cpro
+==========================
+
+Supported devices:
+
+  * Corsair Commander Pro
+  * Corsair Commander Pro (1000D)
+
+Author: Marius Zachmann
+
+Description
+-----------
+
+This driver implements the sysfs interface for the Corsair Commander Pro.
+The Corsair Commander Pro is a USB device with 6 fan connectors,
+4 temperature sensor connectors and 2 Corsair LED connectors.
+It can read the voltage levels on the SATA power connector.
+
+Usage Notes
+-----------
+
+Since it is a USB device, hotswapping is possible. The device is autodetected.
+
+Sysfs entries
+-------------
+
+======================= =====================================================================
+in0_input		Voltage on SATA 12v
+in1_input		Voltage on SATA 5v
+in2_input		Voltage on SATA 3.3v
+temp[1-4]_input		Temperature on connected temperature sensors
+temp[1-4] label		Shows "nc" after name, when not connected
+fan[1-6]_input		Connected fan rpm.
+fan[1-6]_label		Shows connection status of the fan as detected by the device.
+pwm[1-6]		Sets the fan speed. Values from 0-255.
+			When reading, it reports the last value if it was set by the driver.
+			Otherwise returns 0.
+======================= =====================================================================
Documentation/hwmon/index.rst +1 -0
index 55ff4b7c5349..750d3a975d82 100644
@@ -47,6 +47,7 @@ Hardware Monitoring Kernel Drivers
    bel-pfe
    bt1-pvt
    coretemp
+   corsair-cpro
    da9052
    da9055
    dell-smm-hwmon
MAINTAINERS +6 -0
index f08f290df174..169530c7eede 100644
@@ -4386,6 +4386,12 @@ S:	Maintained
 F:	Documentation/hwmon/coretemp.rst
 F:	drivers/hwmon/coretemp.c
 
+CORSAIR-CPRO HARDWARE MONITOR DRIVER
+M:	Marius Zachmann <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/hwmon/corsair-cpro.c
+
 COSA/SRP SYNC SERIAL DRIVER
 M:	Jan "Yenya" Kasprzak <[email protected]>
 S:	Maintained
drivers/hwmon/Kconfig +10 -0
index 288ae9f63588..8b046a5dfa40 100644
@@ -439,6 +439,16 @@ config SENSORS_BT1_PVT_ALARMS
 	  the data conversion will be periodically performed and the data will be
 	  saved in the internal driver cache.
 
+config SENSORS_CORSAIR_CPRO
+	tristate "Corsair Commander Pro controller"
+	depends on USB
+	help
+	  If you say yes here you get support for the Corsair Commander Pro
+	  controller.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called corsair-cpro.
+
 config SENSORS_DRIVETEMP
 	tristate "Hard disk drives with temperature sensors"
 	depends on SCSI && ATA
drivers/hwmon/Makefile +1 -0
index 3e32c21f5efe..18e1ef74ade7 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
 obj-$(CONFIG_SENSORS_AXI_FAN_CONTROL) += axi-fan-control.o
 obj-$(CONFIG_SENSORS_BT1_PVT)	+= bt1-pvt.o
 obj-$(CONFIG_SENSORS_CORETEMP)	+= coretemp.o
+obj-$(CONFIG_SENSORS_CORSAIR_CPRO) += corsair-cpro.o
 obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
 obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o
 obj-$(CONFIG_SENSORS_DELL_SMM)	+= dell-smm-hwmon.o
drivers/hwmon/corsair-cpro.c new file +497 -0

497 lines not on this page · raw message

Signature · 4 lines
2.27.0


-------------------------------------------------------------
#1 lore raw

[RFC PATCH] hwmon: ccp_disconnect() can be static

Signed-off-by: kernel test robot <[email protected]>
---
 corsair-cpro.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/corsair-cpro.c +1 -1
index c4852829f90f2..fc6449d16fa38 100644
@@ -474,7 +474,7 @@ static int ccp_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
-void ccp_disconnect(struct usb_interface *intf)
+static void ccp_disconnect(struct usb_interface *intf)
 {
 }