Drivers to support the MCU on QNAP NAS devices
Subsystems (9)
Heiko Stuebner
maintainerPATCH v3 7/7 arm64: dts: rockchip: set hdd led labels on qnap-ts433
In reply to Heiko StuebnerThe automatically generated names for the LEDs from color and function do not match nicely for the 4 hdds, so set them manually per the label property to also match the LEDs generated from the MCU.
--- arch/arm64/boot/dts/rockchip/rk3568-qnap-ts433.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568-qnap-ts433.dts +4 -0
@@ -50,6 +50,7 @@ led-0 { color = <LED_COLOR_ID_GREEN>; function = LED_FUNCTION_DISK; gpios = <&gpio1 RK_PD5 GPIO_ACTIVE_LOW>; + label = "hdd1:green:disk"; linux,default-trigger = "disk-activity"; pinctrl-names = "default"; pinctrl-0 = <&hdd1_led_pin>;
@@ -59,6 +60,7 @@ led-1 { color = <LED_COLOR_ID_GREEN>; function = LED_FUNCTION_DISK; gpios = <&gpio1 RK_PD6 GPIO_ACTIVE_LOW>; + label = "hdd2:green:disk"; linux,default-trigger = "disk-activity"; pinctrl-names = "default"; pinctrl-0 = <&hdd2_led_pin>;
@@ -68,6 +70,7 @@ led-2 { color = <LED_COLOR_ID_GREEN>; function = LED_FUNCTION_DISK; gpios = <&gpio1 RK_PD7 GPIO_ACTIVE_LOW>; + label = "hdd3:green:disk"; linux,default-trigger = "disk-activity"; pinctrl-names = "default"; pinctrl-0 = <&hdd3_led_pin>;
@@ -77,6 +80,7 @@ led-3 { color = <LED_COLOR_ID_GREEN>; function = LED_FUNCTION_DISK; gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "hdd4:green:disk"; linux,default-trigger = "disk-activity"; pinctrl-names = "default"; pinctrl-0 = <&hdd4_led_pin>;
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerPATCH v3 6/7 arm64: dts: rockchip: hook up the MCU on the QNAP TS433
In reply to Heiko StuebnerThe MCU is an important part of the device functionality. It provides functionality like fan-control, more leds, etc and even more important without it, the NAS-device cannot even fully turned off.
Hook up the serial device to its uart and hook into the thermal management to control the fan according to the cpu temperature.
While the MCU also provides a temperature sensor for the case, this one is just polled and does not provide functionality for handling trip points in hardware, so a lot of polling would be involved. As the cpu is only cooled passively in these devices, it's temperature rising will indicate the temperature level of the system just earlier.
--- .../boot/dts/rockchip/rk3568-qnap-ts433.dts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568-qnap-ts433.dts +54 -0
@@ -465,6 +465,54 @@ rgmii_phy0: ethernet-phy@0 { }; }; +/* + * The MCU can provide system temperature too, but only by polling and of + * course also cannot set trip points. So attach to the cpu thermal-zone + * instead to control the fan. + */ +&cpu_thermal { + trips { + case_fan0: case-fan0 { + hysteresis = <2000>; + temperature = <35000>; + type = "active"; + }; + + case_fan1: case-fan1 { + hysteresis = <2000>; + temperature = <45000>; + type = "active"; + }; + + case_fan2: case-fan2 { + hysteresis = <2000>; + temperature = <65000>; + type = "active"; + }; + }; + + cooling-maps { + /* + * Always provide some air movement, due to small case + * full of harddrives. + */ + map1 { + cooling-device = <&fan THERMAL_NO_LIMIT 1>; + trip = <&case_fan0>; + }; + + map2 { + cooling-device = <&fan 2 3>; + trip = <&case_fan1>; + }; + + map3 { + cooling-device = <&fan 4 THERMAL_NO_LIMIT>; + trip = <&case_fan2>; + }; + }; +}; + &pcie30phy { data-lanes = <1 2>; status = "okay";
@@ -563,6 +611,12 @@ &tsadc { */ &uart0 { status = "okay"; + + fan: mcu { + compatible = "qnap,ts433-mcu"; + #cooling-cells = <2>; + cooling-levels = <0 64 89 128 166 204 221 238>; + }; }; /*
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerv3 cover Drivers to support the MCU on QNAP NAS devices
This implements a set of drivers for the MCU used on QNAP NAS devices.
Of course no documentation for the serial protocol is available, so thankfully QNAP has a tool on their rescue-inird to talk to the MCU and I found interceptty [0] to listen to what goes over the serial connection.
In general it looks like there are two different generations in general, an "EC" device and now this "MCU" - referenced in the strings of the userspace handlers for those devices.
For the MCU "SPEC3" and "SPEC4" are listed which is configured in the model.conf of the device. When setting the value from SPEC4 to SPEC3 on my TS433, the supported commands change, but the command interface stays the same and especially the version command is the same.
The binding also does not expose any interals of the device that might change, so hopefully there shouldn't be big roadblocks to support different devices, apart from possibly adapting the commands.
changes in v3:
mfd
- use correct power-off priority: default
- constify the cmd-data array in command functions (Dmitry)
leds:
- don't point to temporary buffers for cdev->name (Florian Eckert)
hwmon:
- use clamp_val(), don't try to reimplement (Guenter)
- add Guenter's Ack
input:
address Dmitry's comments
- constify some cmd arrays
- add input-close callback to cancel beep worker
- drop initial input event report
changes in v2:
binding:
- rename to qnap,ts433-mcu.yaml (Krzysztof)
- drop "preserve formatting" indicator (Krzysztof)
- add Krzysztof's Review tag
mfd:
- fix checkpatch --strict CHECKs
- add a MAINTAINERS entry for all qnap-mcu-parts
hwmon:
address Guenter's review comments:
- fix checkpatch strict warnings
I've kept the devm_thermal_of_cooling_device_register alignment, because that line is so long that aligning to the "(" would make things way too long and unreadable
- add hwmon documentation
- spelling corrections
- report actual pwm value, not last-set one
- make some cmd arrays static
- drop pwm_enable as the pwm-mode is not controllable
- actually handle error returns from mcu commands
- fix calculation of fan-rpm (I read my notes wrong)
- fix temperature calculation to return millicelsius as expected
- only bail at obviously wrong pwm values, but clamp to min,max
- only register cooling-device if cooling-levels are available
[0] https://github.com/geoffmeyers/interceptty
Heiko Stuebner (7):
dt-bindings: mfd: add binding for qnap,ts433-mcu devices
mfd: add base driver for qnap-mcu devices
leds: add driver for LEDs from qnap-mcu devices
Input: add driver for the input part of qnap-mcu devices
hwmon: add driver for the hwmon parts of qnap-mcu devices
arm64: dts: rockchip: hook up the MCU on the QNAP TS433
arm64: dts: rockchip: set hdd led labels on qnap-ts433
.../bindings/mfd/qnap,ts433-mcu.yaml | 43 ++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/qnap-mcu-hwmon.rst | 27 ++ MAINTAINERS | 9 + .../boot/dts/rockchip/rk3568-qnap-ts433.dts | 58 +++ drivers/hwmon/Kconfig | 12 + drivers/hwmon/Makefile | 1 + drivers/hwmon/qnap-mcu-hwmon.c | 372 ++++++++++++++++++ drivers/input/misc/Kconfig | 12 + drivers/input/misc/Makefile | 1 + drivers/input/misc/qnap-mcu-input.c | 161 ++++++++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-qnap-mcu.c | 247 ++++++++++++ drivers/mfd/Kconfig | 10 + drivers/mfd/Makefile | 2 + drivers/mfd/qnap-mcu.c | 358 +++++++++++++++++ include/linux/mfd/qnap-mcu.h | 28 ++ 18 files changed, 1354 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml create mode 100644 Documentation/hwmon/qnap-mcu-hwmon.rst create mode 100644 drivers/hwmon/qnap-mcu-hwmon.c create mode 100644 drivers/input/misc/qnap-mcu-input.c create mode 100644 drivers/leds/leds-qnap-mcu.c create mode 100644 drivers/mfd/qnap-mcu.c create mode 100644 include/linux/mfd/qnap-mcu.h
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerPATCH v3 1/7 dt-bindings: mfd: add binding for qnap,ts433-mcu devices
These MCUs can be found in network attached storage devices made by QNAP. They are connected to a serial port of the host device and provide functionality like LEDs, power-control and temperature monitoring.
--- .../bindings/mfd/qnap,ts433-mcu.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +43 -0
@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/qnap,ts433-mcu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: QNAP NAS on-board Microcontroller + +maintainers: + - Heiko Stuebner <[email protected]> + +description: + QNAP embeds a microcontroller on their NAS devices adding system feature + as PWM Fan control, additional LEDs, power button status and more. + +properties: + compatible: + enum: + - qnap,ts433-mcu + + "#cooling-cells": + const: 2 + + cooling-levels: + description: PWM duty cycle values corresponding to thermal cooling states. + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + maximum: 255 + +required: + - compatible + +additionalProperties: false + +examples: + - | + uart { + mcu { + compatible = "qnap,ts433-mcu"; + #cooling-cells = <2>; + cooling-levels = <0 64 89 128 166 204 221 238>; + }; + };
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerPATCH v3 2/7 mfd: add base driver for qnap-mcu devices
In reply to Heiko StuebnerThese MCUs are used in network-attached-storage devices made by QNAP and provide additional functionality to the system.
This adds the base driver that implements the serial protocol via serdev and additionally hooks into the poweroff handlers to turn off the parts of the system not supplied by the general PMIC.
Turning off (at least the TSx33 devices using Rockchip SoCs) is twofold. Turning off the MCU does not turn off the SoC and turning off the SoC does not turn off the hard-drives. And if the MCU is not turned off, the system also won't start again until it is unplugged from power.
So on shutdown the MCU needs to be turned off before the general PMIC.
The protocol spoken by the MCU is sadly not documented, but was obtained by listening to the chatter on the serial port, as thankfully the "hal_app" program from QNAPs firmware allows triggering all/most MCU actions from the command line.
The implementation of how to talk to the serial device got some inspiration from the rave-sp servdev mfd.
--- MAINTAINERS | 6 + drivers/mfd/Kconfig | 10 + drivers/mfd/Makefile | 2 + drivers/mfd/qnap-mcu.c | 358 +++++++++++++++++++++++++++++++++++ include/linux/mfd/qnap-mcu.h | 28 +++ 5 files changed, 404 insertions(+) create mode 100644 drivers/mfd/qnap-mcu.c create mode 100644 include/linux/mfd/qnap-mcu.h
MAINTAINERS +6 -0
@@ -18651,6 +18651,12 @@ L: [email protected] S: Odd Fixes F: drivers/media/tuners/qm1d1c0042* +QNAP MCU DRIVER +M: Heiko Stuebner <[email protected]> +S: Maintained +F: drivers/mfd/qnap-mcu.c +F: include/linux/qnap-mcu.h + QNX4 FILESYSTEM M: Anders Larsen <[email protected]> S: Maintained
drivers/mfd/Kconfig +10 -0
@@ -2362,6 +2362,16 @@ config MFD_INTEL_M10_BMC_PMCI additional drivers must be enabled in order to use the functionality of the device. +config MFD_QNAP_MCU + tristate "QNAP MCU core driver" + depends on SERIAL_DEV_BUS + help + Select this to get support for the QNAP MCU device found in + several devices of QNAP network attached storages. + + It implements the base serial protocol to talk to the device + and provides functions for the other parts to hook into. + config MFD_RSMU_I2C tristate "Renesas Synchronization Management Unit with I2C" depends on I2C && OF
drivers/mfd/Makefile +2 -0
@@ -286,5 +286,7 @@ obj-$(CONFIG_MFD_INTEL_M10_BMC_PMCI) += intel-m10-bmc-pmci.o obj-$(CONFIG_MFD_ATC260X) += atc260x-core.o obj-$(CONFIG_MFD_ATC260X_I2C) += atc260x-i2c.o +obj-$(CONFIG_MFD_QNAP_MCU) += qnap-mcu.o + obj-$(CONFIG_MFD_RSMU_I2C) += rsmu_i2c.o rsmu_core.o obj-$(CONFIG_MFD_RSMU_SPI) += rsmu_spi.o rsmu_core.o
drivers/mfd/qnap-mcu.c new file +358 -0
358 lines not on this page · raw message
include/linux/mfd/qnap-mcu.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* +* Core definitions for QNAP MCU MFD driver. +* Copyright (C) 2024 Heiko Stuebner <[email protected]> +*/ + +#ifndef _LINUX_QNAP_MCU_H_ +#define _LINUX_QNAP_MCU_H_ + +struct qnap_mcu ; + +struct qnap_mcu_variant { +u32 baud_rate; +int num_drives; +int fan_pwm_min; +int fan_pwm_max; +bool usb_led; +}; + +int qnap_mcu_exec (struct qnap_mcu *mcu, +const u8 *cmd_data,size_t cmd_data_size, +u8 *reply_data,size_t reply_data_size); +int qnap_mcu_exec_with_ack (struct qnap_mcu *mcu, +const u8 *cmd_data,size_t cmd_data_size); +const struct qnap_mcu_variant *qnap_mcu_get_variant_data (struct qnap_mcu *mcu); + +#endif /* _LINUX_QNAP_MCU_H_ */
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerPATCH v3 3/7 leds: add driver for LEDs from qnap-mcu devices
In reply to Heiko StuebnerThis adds a driver that connects to the qnap-mcu mfd driver and provides access to the LEDs on it.
--- MAINTAINERS | 1 + drivers/leds/Kconfig | 11 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-qnap-mcu.c | 247 +++++++++++++++++++++++++++++++++++ 4 files changed, 260 insertions(+) create mode 100644 drivers/leds/leds-qnap-mcu.c
MAINTAINERS +1 -0
@@ -18654,6 +18654,7 @@ F: drivers/media/tuners/qm1d1c0042* QNAP MCU DRIVER M: Heiko Stuebner <[email protected]> S: Maintained +F: drivers/leds/leds-qnap-mcu.c F: drivers/mfd/qnap-mcu.c F: include/linux/qnap-mcu.h
drivers/leds/Kconfig +11 -0
@@ -580,6 +580,17 @@ config LEDS_PCA995X LED driver chips accessed via the I2C bus. Supported devices include PCA9955BTW, PCA9952TW and PCA9955TW. +config LEDS_QNAP_MCU + tristate "LED Support for QNAP MCU controllers" + depends on LEDS_CLASS + depends on MFD_QNAP_MCU + help + This option enables support for LEDs available on embedded + controllers used in QNAP NAS devices. + + This driver can also be built as a module. If so, the module + will be called qnap-mcu-leds. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -79,6 +79,7 @@ obj-$(CONFIG_LEDS_PCA995X) += leds-pca995x.o obj-$(CONFIG_LEDS_PM8058) += leds-pm8058.o obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o obj-$(CONFIG_LEDS_PWM) += leds-pwm.o +obj-$(CONFIG_LEDS_QNAP_MCU) += leds-qnap-mcu.o obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o obj-$(CONFIG_LEDS_SUN50I_A100) += leds-sun50i-a100.o
drivers/leds/leds-qnap-mcu.c new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerPATCH v3 4/7 Input: add driver for the input part of qnap-mcu devices
In reply to Heiko StuebnerThe MCU controls the power-button and beeper, so expose them as input device. There is of course no interrupt line, so the status of the power-button needs to be polled. To generate an event the power-button also needs to be held for 1-2 seconds, so the polling interval does not need to be overly fast.
--- MAINTAINERS | 1 + drivers/input/misc/Kconfig | 12 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/qnap-mcu-input.c | 161 ++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 drivers/input/misc/qnap-mcu-input.c
MAINTAINERS +1 -0
@@ -18654,6 +18654,7 @@ F: drivers/media/tuners/qm1d1c0042* QNAP MCU DRIVER M: Heiko Stuebner <[email protected]> S: Maintained +F: drivers/input/misc/qnap-mcu-input.c F: drivers/leds/leds-qnap-mcu.c F: drivers/mfd/qnap-mcu.c F: include/linux/qnap-mcu.h
drivers/input/misc/Kconfig +12 -0
@@ -917,6 +917,18 @@ config INPUT_HISI_POWERKEY To compile this driver as a module, choose M here: the module will be called hisi_powerkey. +config INPUT_QNAP_MCU + tristate "Input Support for QNAP MCU controllers" + depends on MFD_QNAP_MCU + help + This option enables support for input elements available on + embedded controllers used in QNAP NAS devices. + + This includes a polled power-button as well as a beeper. + + To compile this driver as a module, choose M here: the + module will be called qnap-mcu-input. + config INPUT_RAVE_SP_PWRBUTTON tristate "RAVE SP Power button Driver" depends on RAVE_SP_CORE
drivers/input/misc/Makefile +1 -0
@@ -68,6 +68,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY) += pmic8xxx-pwrkey.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_PWM_VIBRA) += pwm-vibra.o +obj-$(CONFIG_INPUT_QNAP_MCU) += qnap-mcu-input.o obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON) += rave-sp-pwrbutton.o obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o
drivers/input/misc/qnap-mcu-input.c new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.39.2
Heiko Stuebner
maintainerPATCH v3 5/7 hwmon: add driver for the hwmon parts of qnap-mcu devices
In reply to Heiko StuebnerThe MCU can be found on network-attached-storage devices made by QNAP and provides access to fan control including reading back its RPM as well as reading the temperature of the NAS case.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/qnap-mcu-hwmon.rst | 27 ++ MAINTAINERS | 1 + drivers/hwmon/Kconfig | 12 + drivers/hwmon/Makefile | 1 + drivers/hwmon/qnap-mcu-hwmon.c | 372 +++++++++++++++++++++++++ 6 files changed, 414 insertions(+) create mode 100644 Documentation/hwmon/qnap-mcu-hwmon.rst create mode 100644 drivers/hwmon/qnap-mcu-hwmon.c
Documentation/hwmon/index.rst +1 -0
@@ -199,6 +199,7 @@ Hardware Monitoring Kernel Drivers pxe1610 pwm-fan q54sj108a2 + qnap-mcu-hwmon raspberrypi-hwmon sbrmi sbtsi_temp
Documentation/hwmon/qnap-mcu-hwmon.rst new file +27 -0
@@ -0,0 +1,27 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver qnap-mcu-hwmon +============================ + +This driver enables the use of the hardware monitoring and fan control +of the MCU used on some QNAP network attached storage devices. + +Author: Heiko Stuebner <[email protected]> + +Description +----------- + +The driver implements a simple interface for driving the fan controlled by +setting its PWM output value and exposes the fan rpm and case-temperature +to user space through hwmon's sysfs interface. + +The fan rotation speed returned via the optional 'fan1_input' is calculated +inside the MCU device. + +The driver provides the following sensor accesses in sysfs: + +=============== ======= ======================================================= +fan1_input ro fan tachometer speed in RPM +pwm1 rw relative speed (0-255), 255=max. speed. +temp1_input ro Measured temperature in millicelsius +=============== ======= =======================================================
MAINTAINERS +1 -0
@@ -18654,6 +18654,7 @@ F: drivers/media/tuners/qm1d1c0042* QNAP MCU DRIVER M: Heiko Stuebner <[email protected]> S: Maintained +F: drivers/hwmon/qnap-mcu-hwmon.c F: drivers/input/misc/qnap-mcu-input.c F: drivers/leds/leds-qnap-mcu.c F: drivers/mfd/qnap-mcu.c
drivers/hwmon/Kconfig +12 -0
@@ -1793,6 +1793,18 @@ config SENSORS_PWM_FAN This driver can also be built as a module. If so, the module will be called pwm-fan. +config SENSORS_QNAP_MCU_HWMON + tristate "QNAP MCU hardware monitoring" + depends on MFD_QNAP_MCU + depends on THERMAL || THERMAL=n + help + Say yes here to enable support for fan and temperature sensor + connected to a QNAP MCU, as found in a number of QNAP network + attached storage devices. + + This driver can also be built as a module. If so, the module + will be called qnap-mcu-hwmon. + config SENSORS_RASPBERRYPI_HWMON tristate "Raspberry Pi voltage monitor" depends on RASPBERRYPI_FIRMWARE || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
drivers/hwmon/Makefile +1 -0
@@ -187,6 +187,7 @@ obj-$(CONFIG_SENSORS_POWERZ) += powerz.o obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o obj-$(CONFIG_SENSORS_PT5161L) += pt5161l.o obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o +obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) += qnap-mcu-hwmon.o obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o obj-$(CONFIG_SENSORS_SBTSI) += sbtsi_temp.o obj-$(CONFIG_SENSORS_SBRMI) += sbrmi.o
drivers/hwmon/qnap-mcu-hwmon.c new file +372 -0
372 lines not on this page · raw message
Signature · 1 line
2.39.2
kernel test robot
build botRe: [PATCH v3 2/7] mfd: add base driver for qnap-mcu devices
In reply to Heiko Stuebnerkernel test robot noticed the following build warnings:
Hi Heiko,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20240801]
[also build test WARNING on v6.11-rc1]
[cannot apply to groeck-staging/hwmon-next lee-leds/for-leds-next lee-mfd/for-mfd-next lee-mfd/for-mfd-fixes linus/master v6.11-rc1 v6.10 v6.10-rc7] [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/Heiko-Stuebner/dt-bindings-mfd-add-binding-for-qnap-ts433-mcu-devices/20240802-103948 base: next-20240801 patch link: https://lore.kernel.org/r/20240731212430.2677900-3-heiko%40sntech.de patch subject: [PATCH v3 2/7] mfd: add base driver for qnap-mcu devices config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20240803/[email protected]/config) compiler: sh4-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240803/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/platform_device.h:13,
from include/linux/mfd/core.h:13,
from drivers/mfd/qnap-mcu.c:12:
drivers/mfd/qnap-mcu.c: In function 'qnap_mcu_receive_buf':
>> drivers/mfd/qnap-mcu.c:108:31: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
108 | dev_warn(dev, "received %lu bytes, we were not waiting for\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:156:61: note: in expansion of macro 'dev_fmt'
156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/mfd/qnap-mcu.c:108:17: note: in expansion of macro 'dev_warn'
108 | dev_warn(dev, "received %lu bytes, we were not waiting for\n",
| ^~~~~~~~
drivers/mfd/qnap-mcu.c:108:43: note: format string is defined here
108 | dev_warn(dev, "received %lu bytes, we were not waiting for\n",
| ~~^
| |
| long unsigned int
| %uvim +108 drivers/mfd/qnap-mcu.c
96
97 static size_t qnap_mcu_receive_buf(struct serdev_device *serdev,
98 const u8 *buf, size_t size)
99 {
100 struct device *dev = &serdev->dev;
101 struct qnap_mcu *mcu = dev_get_drvdata(dev);
102 struct qnap_mcu_reply *reply = mcu->reply;
103 const u8 *src = buf;
104 const u8 *end = buf + size;
105
106 mutex_lock(&mcu->reply_lock);
107 if (!reply) {
> 108 dev_warn(dev, "received %lu bytes, we were not waiting for\n", 109 size);
110 mutex_unlock(&mcu->reply_lock);
111 return size;
112 }
113
114 while (src < end) {
115 reply->data[reply->received] = *src++;
116 reply->received++;
117
118 if (reply->received == reply->length) {
119 complete(&reply->done);
120 mutex_unlock(&mcu->reply_lock);
121
122 /*
123 * We report the consumed number of bytes. If there
124 * are still bytes remaining (though there shouldn't)
125 * the serdev layer will re-execute this handler with
126 * the remainder of the Rx bytes.
127 */
128 return src - buf;
129 }
130 }
131
132 /*
133 * The only way to get out of the above loop and end up here
134 * is through consuming all of the supplied data, so here we
135 * report that we processed it all.
136 */
137 mutex_unlock(&mcu->reply_lock);
138 return size;
139 }
140
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 4/7] Input: add driver for the input part of qnap-mcu devices
In reply to Heiko StuebnerQuoted 7 lines · Heiko Stuebner
The MCU controls the power-button and beeper, so expose them as input device. There is of course no interrupt line, so the status of the power-button needs to be polled. To generate an event the power-button also needs to be held for 1-2 seconds, so the polling interval does not need to be overly fast.
Signed-off-by Heiko Stuebner <[email protected]>
Feel free to merge with the rest of the patches.
Thanks.
Signature · 1 line
Dmitry
kernel test robot
build botRe: [PATCH v3 2/7] mfd: add base driver for qnap-mcu devices
In reply to Heiko Stuebnerkernel test robot noticed the following build warnings:
Hi Heiko,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20240801]
[also build test WARNING on v6.11-rc1]
[cannot apply to groeck-staging/hwmon-next lee-leds/for-leds-next lee-mfd/for-mfd-next lee-mfd/for-mfd-fixes linus/master v6.11-rc1 v6.10 v6.10-rc7] [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/Heiko-Stuebner/dt-bindings-mfd-add-binding-for-qnap-ts433-mcu-devices/20240802-103948 base: next-20240801 patch link: https://lore.kernel.org/r/20240731212430.2677900-3-heiko%40sntech.de patch subject: [PATCH v3 2/7] mfd: add base driver for qnap-mcu devices config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20240804/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 423aec6573df4424f90555468128e17073ddc69e) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/mfd/qnap-mcu.c:17:
In file included from include/linux/serdev.h:10:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/mfd/qnap-mcu.c:17:
In file included from include/linux/serdev.h:10:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/mfd/qnap-mcu.c:17:
In file included from include/linux/serdev.h:10:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
>> drivers/mfd/qnap-mcu.c:109:5: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
108 | dev_warn(dev, "received %lu bytes, we were not waiting for\n",
| ~~~
| %zu
109 | size);
| ^~~~
include/linux/dev_printk.h:156:70: note: expanded from macro 'dev_warn'
156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ~~~ ^~~~~~~~~~~7 warnings generated.
vim +109 drivers/mfd/qnap-mcu.c
96
97 static size_t qnap_mcu_receive_buf(struct serdev_device *serdev,
98 const u8 *buf, size_t size)
99 {
100 struct device *dev = &serdev->dev;
101 struct qnap_mcu *mcu = dev_get_drvdata(dev);
102 struct qnap_mcu_reply *reply = mcu->reply;
103 const u8 *src = buf;
104 const u8 *end = buf + size;
105
106 mutex_lock(&mcu->reply_lock);
107 if (!reply) {
108 dev_warn(dev, "received %lu bytes, we were not waiting for\n",
> 109 size); 110 mutex_unlock(&mcu->reply_lock);
111 return size;
112 }
113
114 while (src < end) {
115 reply->data[reply->received] = *src++;
116 reply->received++;
117
118 if (reply->received == reply->length) {
119 complete(&reply->done);
120 mutex_unlock(&mcu->reply_lock);
121
122 /*
123 * We report the consumed number of bytes. If there
124 * are still bytes remaining (though there shouldn't)
125 * the serdev layer will re-execute this handler with
126 * the remainder of the Rx bytes.
127 */
128 return src - buf;
129 }
130 }
131
132 /*
133 * The only way to get out of the above loop and end up here
134 * is through consuming all of the supplied data, so here we
135 * report that we processed it all.
136 */
137 mutex_unlock(&mcu->reply_lock);
138 return size;
139 }
140
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Rob Herring
maintainerRe: [PATCH v3 1/7] dt-bindings: mfd: add binding for qnap,ts433-mcu devices
In reply to Heiko StuebnerQuoted 21 lines · Heiko Stuebner
These MCUs can be found in network attached storage devices made by QNAP. They are connected to a serial port of the host device and provide functionality like LEDs, power-control and temperature monitoring.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>--- .../bindings/mfd/qnap,ts433-mcu.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yamlDocumentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +4
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/qnap,ts433-mcu.yaml#
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml line 14
Quoted 10 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +10
-0+$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: QNAP NAS on-board Microcontroller + +maintainers: + - Heiko Stuebner <[email protected]> + +description: + QNAP embeds a microcontroller on their NAS devices adding system feature + as PWM Fan control, additional LEDs, power button status and more.
Doesn't really look like the binding is complete.
Quoted 4 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +4
-0+ +properties: + compatible: + enum:
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +10
-0+ - qnap,ts433-mcu + + "#cooling-cells": + const: 2 + + cooling-levels: + description: PWM duty cycle values corresponding to thermal cooling states. + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + maximum: 255
These are fan properties and should be in a "fan" node referencing hwmon/fan-common.yaml.
Rob
Heiko Stübner
maintainerRe: [PATCH v3 1/7] dt-bindings: mfd: add binding for qnap,ts433-mcu devices
Hi Rob,
Am Montag, 5. August 2024, 21:17:23 CEST schrieb Rob Herring:
Quoted 26 lines · Heiko Stuebner
Quoted 25 lines
These MCUs can be found in network attached storage devices made by QNAP. They are connected to a serial port of the host device and provide functionality like LEDs, power-control and temperature monitoring.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>--- .../bindings/mfd/qnap,ts433-mcu.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yamlDocumentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +8
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/qnap,ts433-mcu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: QNAP NAS on-board Microcontroller +
Quoted 8 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml line 14
Quoted 6 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +6
-0+maintainers: + - Heiko Stuebner <[email protected]> + +description: + QNAP embeds a microcontroller on their NAS devices adding system feature + as PWM Fan control, additional LEDs, power button status and more.Doesn't really look like the binding is complete.
Hmm, apart from the fan subnode, anything else that is missing?
Input device does not need data from devicetree, as the existence of the button and buzzer is attached to the specific mcu-compatible.
Similar for the LEDs I guess, their number and color are a property of the MCU variant used. I guess one could do subnodes for the linux,default-trigger property?
Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +9
-0+ +properties: + compatible: + enum: + - qnap,ts433-mcu + + "#cooling-cells": + const: 2 +
Quoted 8 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml line 28
Quoted 5 lines
Documentation/devicetree/bindings/mfd/qnap,ts433-mcu.yaml new file +5
-0+ cooling-levels: + description: PWM duty cycle values corresponding to thermal cooling states. + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + maximum: 255These are fan properties and should be in a "fan" node referencing
hwmon/fan-common.yaml.
ok, I'll add a fan-0 subnode as some hwmon already does and move the cooling properties into it.
Heiko