Source
static ssize_t label_show(struct device *dev, struct device_attribute *attr,
// SPDX-License-Identifier: GPL-2.0-only
/*
* drivers/hwmon/nsa320-hwmon.c
*
* ZyXEL NSA320 Media Servers
* hardware monitoring
*
* Copyright (C) 2016 Adam Baker <linux@baker-net.org.uk>
* based on a board file driver
* Copyright (C) 2012 Peter Schildmann <linux@schildmann.info>
*/
/* Tests for error return values rely upon this value being < 0x80 */
/*
* The Zyxel hwmon MCU is a Holtek HT46R065 that is factory programmed
* to perform temperature and fan speed monitoring. It is read by taking
* the active pin low. The 32 bit output word is then clocked onto the
* data line. The MSB of the data word is a magic nuber to indicate it
* has been read correctly, the next byte is the fan speed (in hundreds
* of RPM) and the last two bytes are the temperature (in tenths of a
* degree)
*/
struct nsa320_hwmon {
struct mutex update_lock; /* lock GPIO operations */
unsigned long last_updated; /* jiffies */
unsigned long mcu_data;
struct gpio_desc *act;
struct gpio_desc *clk;
struct gpio_desc *data;
};
enum nsa320_inputs {
NSA320_TEMP = 0,
NSA320_FAN = 1,
};
static const char * const nsa320_input_names[] = {
[NSA320_TEMP] = "System Temperature",
[NSA320_FAN] = "Chassis Fan",
};
/*
* Although this protocol looks similar to SPI the long delay
* between the active (aka chip select) signal and the shorter
* delay between clock pulses are needed for reliable operation.
* The delays provided are taken from the manufacturer kernel,