driver for the hardware monitoring chip in the Zyxel NSA320
Subsystems (3)
v4 cover driver for the hardware monitoring chip in the Zyxel NSA320
Documentation/devicetree/bindings/hwmon/nsa320-mcu.txt | 21 +++++ Documentation/hwmon/nsa320 | 53 +++++++++++ arch/arm/boot/dts/kirkwood-nsa320.dts | 13 ++- drivers/hwmon/Kconfig | 15 +++ drivers/hwmon/Makefile | 1 + drivers/hwmon/nsa320-hwmon.c | 216 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 317 insertions(+), 2 deletions(-)
Changes since v3
Use s32 as the return value from nsa320_hwmon_update
Changes since v2
Update patch 2/3 based on further review from Guenter Roeck, patches 1/3 and 3/3 are unchanged except for adding Rob's Ack to 1/3
Changes since v1
Update to reflect review comments from Guenter Roeck, mainly changing it to be nsa320, not nsa3xx but also making it return an errno on failure and various other tidy ups.
PATCH v4 1/3 hwmon: Define binding for the nsa320-hwmon driver
Define a binding for the hardware monitoring chip present in the Zyxel NSA-320 and some of the other Zyxel NAS devices.
---
Changes for v3, Add Robs Ack
--- .../devicetree/bindings/hwmon/nsa320-mcu.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/nsa320-mcu.txt
Documentation/devicetree/bindings/hwmon/nsa320-mcu.txt new file +21 -0
@@ -0,0 +1,21 @@ +Bindings for the fan / temperature monitor microcontroller used on +the Zyxel NSA 320 and several subsequent models. + +Required properties: +- compatible : "zyxel,nsa320-mcu" +- data-gpios : The GPIO pin connected to the data line on the MCU +- clk-gpios : The GPIO pin connected to the clock line on the MCU +- act-gpios : The GPIO pin connected to the active line on the MCU + +Example: + + hwmon { + compatible = "zyxel,nsa320-mcu"; + pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act>; + pinctrl-names = "default"; + + data-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; + clk-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + act-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; + }; +
Signature · 1 line
2.1.4
PATCH v4 2/3 hwmon: Create an NSA320 hardware monitoring driver
In reply to Adam BakerCreate a driver to support the hardware monitoring chip present in the Zyxel NSA320 and some of the other Zyxel NAS devices.
The driver reads fan speed and temperature from a suitably pre-programmed MCU on the device.
---
Changes since v3
- change return type of nsa320_hwmon_update to s32
- eliminate use of IS_ERR_VALUE()
- fix some remaining refernces to NSA3XX rather than NSA320
Changes since v2
Updated based on Guenter Roeck's review,
- return a single value that is result or error from the update function
- use separate show_value routimes for fan and temp
- Added Documentation/hwmon/nsa320-hwmon
--- Documentation/hwmon/nsa320 | 53 +++++++++++ drivers/hwmon/Kconfig | 15 +++ drivers/hwmon/Makefile | 1 + drivers/hwmon/nsa320-hwmon.c | 216 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 285 insertions(+) create mode 100644 Documentation/hwmon/nsa320 create mode 100644 drivers/hwmon/nsa320-hwmon.c
Documentation/hwmon/nsa320 new file +53 -0
@@ -0,0 +1,53 @@ +Kernel driver nsa320_hwmon +========================== + +Supported chips: + * Holtek HT46R065 microcontroller with onboard firmware that configures + it to act as a hardware monitor. + Prefix: 'nsa320' + Addresses scanned: none + Datasheet: Not available, driver was reverse engineered based upon the + Zyxel kernel source + +Author: + Adam Baker <[email protected]> + +Description +----------- + +This chip is known to be used in the Zyxel NSA320 and NSA325 NAS Units and +also in some variants of the NSA310 but the driver has only been tested +on the NSA320. In all of these devices it is connected to the same 3 GPIO +lines which are used to provide chip select, clock and data lines. The +interface behaves similarly to SPI but at much lower speeds than are normally +used for SPI. + +Following each chip select pulse the chip will generate a single 32 bit word +that contains 0x55 as a marker to indicate that data is being read correctly, +followed by an 8 bit fan speed in 100s of RPM and a 16 bit temperature in +tenths of a degree. + + +sysfs-Interface +--------------- + +temp1_input - temperature input +fan1_input - fan speed + +Notes +----- + +The access timings used in the driver are the same as used in the Zyxel +provided kernel. Testing has shown that if the delay between chip select and +the first clock pulse is reduced from 100 ms to just under 10ms then the chip +will not produce any output. If the duration of either phase of the clock +is reduced from 100 us to less than 15 us then data pulses are likely to be +read twice corrupting the output. The above analysis is based upon a sample +of one unit but suggests that the Zyxel provided delay values include a +reasonable tolerance. + +The driver incorporates a limit that it will not check for updated values +faster than once a second. This is because the hardware takes a relatively long +time to read the data from the device and when it does it reads both temp and +fan speed. As the most likely case for two accesses in quick succession is +to read both of these values avoiding a second read delay is desirable.
drivers/hwmon/Kconfig +15 -0
@@ -1186,6 +1186,21 @@ config SENSORS_NCT7904 This driver can also be built as a module. If so, the module will be called nct7904. +config SENSORS_NSA320 + tristate "ZyXEL NSA320 and compatible fan speed and temperature sensors" + depends on GPIOLIB && OF + depends on MACH_KIRKWOOD || COMPILE_TEST + help + If you say yes here you get support for hardware monitoring + for the ZyXEL NSA320 Media Server and other compatible devices + (probably the NSA325 and some NSA310 variants). + + The sensor data is taken from a Holtek HT46R065 microcontroller + connected to GPIO lines. + + This driver can also be built as a module. If so, the module + will be called nsa320-hwmon. + config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -124,6 +124,7 @@ obj-$(CONFIG_SENSORS_NCT6683) += nct6683.o obj-$(CONFIG_SENSORS_NCT6775) += nct6775.o obj-$(CONFIG_SENSORS_NCT7802) += nct7802.o obj-$(CONFIG_SENSORS_NCT7904) += nct7904.o +obj-$(CONFIG_SENSORS_NSA320) += nsa320-hwmon.o obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
drivers/hwmon/nsa320-hwmon.c new file +216 -0
216 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v4 3/3 ARM: mvebu: Add the hardware monitor to the NSA320 device tree
In reply to Adam BakerAdd an entry for the hardware monitoring MCU
---
This patch is unchanged from the version Gregory CLEMENT said he would apply once the hwmon maintainers accept 2/3
--- arch/arm/boot/dts/kirkwood-nsa320.dts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/arm/boot/dts/kirkwood-nsa320.dts +11 -2
@@ -193,10 +193,19 @@ }; }; + hwmon { + compatible = "zyxel,nsa320-mcu"; + pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act>; + pinctrl-names = "default"; + + data-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; + clk-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + act-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; + }; + /* The following pins are currently not assigned to a driver, some of them should be configured as inputs. - pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act - &pmx_htp &pmx_vid_b1 + pinctrl-0 = <&pmx_htp &pmx_vid_b1 &pmx_power_resume_data &pmx_power_resume_clk>; */ };
Signature · 1 line
2.1.4
PATCH v4 3/3 ARM: mvebu: Add the hardware monitor to the NSA320 device tree
Hi Adam,
Quoted 3 lines · Adam Baker
Add an entry for the hardware monitoring MCU
Signed-off-by Adam Baker <[email protected]>
Applied on mvebu/dt, I only changed the tropic to "ARM: dts: kirkwood:
Add the hardware monitor to the NSA320 device tree" as know requested by the arm-soc maintainer.
Thanks,
Gregory
Quoted 36 lines
---
This patch is unchanged from the version Gregory CLEMENT said he would apply once the hwmon maintainers accept 2/3--- arch/arm/boot/dts/kirkwood-nsa320.dts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)arch/arm/boot/dts/kirkwood-nsa320.dts +11
-2@@ -193,10 +193,19 @@ }; }; + hwmon { + compatible = "zyxel,nsa320-mcu"; + pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act>; + pinctrl-names = "default"; + + data-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; + clk-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + act-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; + }; + /* The following pins are currently not assigned to a driver, some of them should be configured as inputs. - pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act - &pmx_htp &pmx_vid_b1 + pinctrl-0 = <&pmx_htp &pmx_vid_b1 &pmx_power_resume_data &pmx_power_resume_clk>; */ };Signature · 1 line
2.1.4
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Guenter Roeck
maintainerv4 cover driver for the hardware monitoring chip in the Zyxel NSA320
In reply to Adam BakerQuoted 8 lines · Adam Baker
Documentation/devicetree/bindings/hwmon/nsa320-mcu.txt | 21 +++++ Documentation/hwmon/nsa320 | 53 +++++++++++ arch/arm/boot/dts/kirkwood-nsa320.dts | 13 ++- drivers/hwmon/Kconfig | 15 +++ drivers/hwmon/Makefile | 1 + drivers/hwmon/nsa320-hwmon.c | 216 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 317 insertions(+), 2 deletions(-)
Patch 1/3 and 2/3 applied to hwmon-next.
I assume that patch 3/3 will go through the arm tree.
Guenter
v4 cover driver for the hardware monitoring chip in the Zyxel NSA320
Hi Adam and Guenter,
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Adam Baker
Documentation/devicetree/bindings/hwmon/nsa320-mcu.txt | 21 +++++ Documentation/hwmon/nsa320 | 53 +++++++++++ arch/arm/boot/dts/kirkwood-nsa320.dts | 13 ++- drivers/hwmon/Kconfig | 15 +++ drivers/hwmon/Makefile | 1 + drivers/hwmon/nsa320-hwmon.c | 216 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 317 insertions(+), 2 deletions(-)
Quoted 3 lines
Patch 1/3 and 2/3 applied to hwmon-next.
I assume that patch 3/3 will go through the arm tree.
Yes but now that the rc7 was released is too late putting it to arm-soc for the 4.6 kernel.
Gregory
Quoted 2 lines
Guenter
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com