Skip to content

Commit

Permalink
Merge tag 'hwmon-for-linus-v4.9' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:

 - New hwmon registration API, including ports of several drivers to the
   new API

 - New hwmon driver for APM X-Gene SoC

 - Added support for UCD90160, DPS-460, DPS-800, and SGD009 PMBUs chips

 - Various cleanups, minor improvements, and fixes in several drivers

* tag 'hwmon-for-linus-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (54 commits)
  hwmon: (nct6775) Add support for multiple virtual temperature sources
  hwmon: (adt7470) No need for additional synchronization on kthread_stop()
  hwmon: (lm95241) Update module description to include LM95231
  hwmon: (lm95245) Select REGMAP_I2C
  hwmon: (ibmpowernv) Fix label for cores numbers not threads
  hwmon: (adt7470) Allow faster removal
  hwmon: (adt7470) Add write support to alarm_mask
  hwmon: (xgene) access mailbox as RAM
  hwmon: (lm95245) Use new hwmon registration API
  hwmon: (lm95241) Convert to use new hwmon registration API
  hwmon: (jc42) Convert to use new hwmon registration API
  hwmon: (max31790) Convert to use new hwmon registration API
  hwmon: (nct7904) Convert to use new hwmon registration API
  hwmon: (ltc4245) Convert to use new hwmon registration API
  hwmon: (tmp421) Convert to use new hwmon registration API
  hwmon: (tmp102) Convert to use new hwmon registration API
  hwmon: (lm90) Convert to use new hwmon registration API
  hwmon: (lm75) Convert to use new hwmon registration API
  hwmon: (xgene) Fix crash when alarm occurs before driver probe
  hwmon: (iio_hwmon) defer probe when no channel is found
  ...
  • Loading branch information
Linus Torvalds committed Oct 4, 2016
2 parents f80fa18 + 7ce4190 commit 77b0a4a
Show file tree
Hide file tree
Showing 36 changed files with 4,620 additions and 2,156 deletions.
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/hwmon/ltc4151.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
LTC4151 High Voltage I2C Current and Voltage Monitor

Required properties:
- compatible: Must be "lltc,ltc4151"
- reg: I2C address

Optional properties:
- shunt-resistor-micro-ohms
Shunt resistor value in micro-Ohms
Defaults to <1000> if unset.

Example:

ltc4151@6e {
compatible = "lltc,ltc4151";
reg = <0x6e>;
shunt-resistor-micro-ohms = <1500>;
};
28 changes: 28 additions & 0 deletions Documentation/devicetree/bindings/hwmon/max6650.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Bindings for MAX6651 and MAX6650 I2C fan controllers

Reference:
[1] https://datasheets.maximintegrated.com/en/ds/MAX6650-MAX6651.pdf

Required properties:
- compatible : One of "maxim,max6650" or "maxim,max6651"
- reg : I2C address, one of 0x1b, 0x1f, 0x4b, 0x48.

Optional properties, default is to retain the chip's current setting:
- maxim,fan-microvolt : The supply voltage of the fan, either 5000000 uV or
12000000 uV.
- maxim,fan-prescale : Pre-scaling value, as per datasheet [1]. Lower values
allow more fine-grained control of slower fans.
Valid: 1, 2, 4, 8, 16.
- maxim,fan-target-rpm: Initial requested fan rotation speed. If specified, the
driver selects closed-loop mode and the requested speed.
This ensures the fan is already running before userspace
takes over.

Example:
fan-max6650: max6650@1b {
reg = <0x1b>;
compatible = "maxim,max6650";
maxim,fan-microvolt = <12000000>;
maxim,fan-prescale = <4>;
maxim,fan-target-rpm = <1200>;
};
17 changes: 17 additions & 0 deletions Documentation/hwmon/adt7470
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ from 0 (off) to 255 (full speed). Fan speed will be set to maximum when the
temperature sensor associated with the PWM control exceeds
pwm#_auto_point2_temp.

The driver also allows control of the PWM frequency:

* pwm1_freq

The PWM frequency is rounded to the nearest one of:

* 11.0 Hz
* 14.7 Hz
* 22.1 Hz
* 29.4 Hz
* 35.3 Hz
* 44.1 Hz
* 58.8 Hz
* 88.2 Hz
* 1.4 kHz
* 22.5 kHz

Notes
-----

Expand Down
231 changes: 229 additions & 2 deletions Documentation/hwmon/hwmon-kernel-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ devm_hwmon_device_register_with_groups(struct device *dev,
const char *name, void *drvdata,
const struct attribute_group **groups);

struct device *
hwmon_device_register_with_info(struct device *dev,
const char *name, void *drvdata,
const struct hwmon_chip_info *info,
const struct attribute_group **groups);

struct device *
devm_hwmon_device_register_with_info(struct device *dev,
const char *name,
void *drvdata,
const struct hwmon_chip_info *info,
const struct attribute_group **groups);

void hwmon_device_unregister(struct device *dev);
void devm_hwmon_device_unregister(struct device *dev);

Expand All @@ -60,15 +73,229 @@ devm_hwmon_device_register_with_groups is similar to
hwmon_device_register_with_groups. However, it is device managed, meaning the
hwmon device does not have to be removed explicitly by the removal function.

hwmon_device_register_with_info is the most comprehensive and preferred means
to register a hardware monitoring device. It creates the standard sysfs
attributes in the hardware monitoring core, letting the driver focus on reading
from and writing to the chip instead of having to bother with sysfs attributes.
Its parameters are described in more detail below.

devm_hwmon_device_register_with_info is similar to
hwmon_device_register_with_info. However, it is device managed, meaning the
hwmon device does not have to be removed explicitly by the removal function.

hwmon_device_unregister deregisters a registered hardware monitoring device.
The parameter of this function is the pointer to the registered hardware
monitoring device structure. This function must be called from the driver
remove function if the hardware monitoring device was registered with
hwmon_device_register or with hwmon_device_register_with_groups.
hwmon_device_register, hwmon_device_register_with_groups, or
hwmon_device_register_with_info.

devm_hwmon_device_unregister does not normally have to be called. It is only
needed for error handling, and only needed if the driver probe fails after
the call to devm_hwmon_device_register_with_groups.
the call to devm_hwmon_device_register_with_groups and if the automatic
(device managed) removal would be too late.

Using devm_hwmon_device_register_with_info()
--------------------------------------------

hwmon_device_register_with_info() registers a hardware monitoring device.
The parameters to this function are

struct device *dev Pointer to parent device
const char *name Device name
void *drvdata Driver private data
const struct hwmon_chip_info *info
Pointer to chip description.
const struct attribute_group **groups
Null-terminated list of additional sysfs attribute
groups.

This function returns a pointer to the created hardware monitoring device
on success and a negative error code for failure.

The hwmon_chip_info structure looks as follows.

struct hwmon_chip_info {
const struct hwmon_ops *ops;
const struct hwmon_channel_info **info;
};

It contains the following fields:

* ops: Pointer to device operations.
* info: NULL-terminated list of device channel descriptors.

The list of hwmon operations is defined as:

struct hwmon_ops {
umode_t (*is_visible)(const void *, enum hwmon_sensor_types type,
u32 attr, int);
int (*read)(struct device *, enum hwmon_sensor_types type,
u32 attr, int, long *);
int (*write)(struct device *, enum hwmon_sensor_types type,
u32 attr, int, long);
};

It defines the following operations.

* is_visible: Pointer to a function to return the file mode for each supported
attribute. This function is mandatory.

* read: Pointer to a function for reading a value from the chip. This function
is optional, but must be provided if any readable attributes exist.

* write: Pointer to a function for writing a value to the chip. This function is
optional, but must be provided if any writeable attributes exist.

Each sensor channel is described with struct hwmon_channel_info, which is
defined as follows.

struct hwmon_channel_info {
enum hwmon_sensor_types type;
u32 *config;
};

It contains following fields:

* type: The hardware monitoring sensor type.
Supported sensor types are
* hwmon_chip A virtual sensor type, used to describe attributes
which apply to the entire chip.
* hwmon_temp Temperature sensor
* hwmon_in Voltage sensor
* hwmon_curr Current sensor
* hwmon_power Power sensor
* hwmon_energy Energy sensor
* hwmon_humidity Humidity sensor
* hwmon_fan Fan speed sensor
* hwmon_pwm PWM control

* config: Pointer to a 0-terminated list of configuration values for each
sensor of the given type. Each value is a combination of bit values
describing the attributes supposed by a single sensor.

As an example, here is the complete description file for a LM75 compatible
sensor chip. The chip has a single temperature sensor. The driver wants to
register with the thermal subsystem (HWMON_C_REGISTER_TZ), and it supports
the update_interval attribute (HWMON_C_UPDATE_INTERVAL). The chip supports
reading the temperature (HWMON_T_INPUT), it has a maximum temperature
register (HWMON_T_MAX) as well as a maximum temperature hysteresis register
(HWMON_T_MAX_HYST).

static const u32 lm75_chip_config[] = {
HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL,
0
};

static const struct hwmon_channel_info lm75_chip = {
.type = hwmon_chip,
.config = lm75_chip_config,
};

static const u32 lm75_temp_config[] = {
HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST,
0
};

static const struct hwmon_channel_info lm75_temp = {
.type = hwmon_temp,
.config = lm75_temp_config,
};

static const struct hwmon_channel_info *lm75_info[] = {
&lm75_chip,
&lm75_temp,
NULL
};

static const struct hwmon_ops lm75_hwmon_ops = {
.is_visible = lm75_is_visible,
.read = lm75_read,
.write = lm75_write,
};

static const struct hwmon_chip_info lm75_chip_info = {
.ops = &lm75_hwmon_ops,
.info = lm75_info,
};

A complete list of bit values indicating individual attribute support
is defined in include/linux/hwmon.h. Definition prefixes are as follows.

HWMON_C_xxxx Chip attributes, for use with hwmon_chip.
HWMON_T_xxxx Temperature attributes, for use with hwmon_temp.
HWMON_I_xxxx Voltage attributes, for use with hwmon_in.
HWMON_C_xxxx Current attributes, for use with hwmon_curr.
Notice the prefix overlap with chip attributes.
HWMON_P_xxxx Power attributes, for use with hwmon_power.
HWMON_E_xxxx Energy attributes, for use with hwmon_energy.
HWMON_H_xxxx Humidity attributes, for use with hwmon_humidity.
HWMON_F_xxxx Fan speed attributes, for use with hwmon_fan.
HWMON_PWM_xxxx PWM control attributes, for use with hwmon_pwm.

Driver callback functions
-------------------------

Each driver provides is_visible, read, and write functions. Parameters
and return values for those functions are as follows.

umode_t is_visible_func(const void *data, enum hwmon_sensor_types type,
u32 attr, int channel)

Parameters:
data: Pointer to device private data structure.
type: The sensor type.
attr: Attribute identifier associated with a specific attribute.
For example, the attribute value for HWMON_T_INPUT would be
hwmon_temp_input. For complete mappings of bit fields to
attribute values please see include/linux/hwmon.h.
channel:The sensor channel number.

Return value:
The file mode for this attribute. Typically, this will be 0 (the
attribute will not be created), S_IRUGO, or 'S_IRUGO | S_IWUSR'.

int read_func(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)

Parameters:
dev: Pointer to the hardware monitoring device.
type: The sensor type.
attr: Attribute identifier associated with a specific attribute.
For example, the attribute value for HWMON_T_INPUT would be
hwmon_temp_input. For complete mappings please see
include/linux/hwmon.h.
channel:The sensor channel number.
val: Pointer to attribute value.

Return value:
0 on success, a negative error number otherwise.

int write_func(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long val)

Parameters:
dev: Pointer to the hardware monitoring device.
type: The sensor type.
attr: Attribute identifier associated with a specific attribute.
For example, the attribute value for HWMON_T_INPUT would be
hwmon_temp_input. For complete mappings please see
include/linux/hwmon.h.
channel:The sensor channel number.
val: The value to write to the chip.

Return value:
0 on success, a negative error number otherwise.


Driver-provided sysfs attributes
--------------------------------

If the hardware monitoring device is registered with
hwmon_device_register_with_info or devm_hwmon_device_register_with_info,
it is most likely not necessary to provide sysfs attributes. Only non-standard
sysfs attributes need to be provided when one of those registration functions
is used.

The header file linux/hwmon-sysfs.h provides a number of useful macros to
declare and use hardware monitoring sysfs attributes.
Expand Down
1 change: 1 addition & 0 deletions Documentation/hwmon/max6650
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fan3_input ro "
fan4_input ro "
fan1_target rw desired fan speed in RPM (closed loop mode only)
pwm1_enable rw regulator mode, 0=full on, 1=open loop, 2=closed loop
3=off
pwm1 rw relative speed (0-255), 255=max. speed.
Used in open loop mode only.
fan1_div rw sets the speed range the inputs can handle. Legal
Expand Down
12 changes: 10 additions & 2 deletions Documentation/hwmon/ucd9000
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ Kernel driver ucd9000
=====================

Supported chips:
* TI UCD90120, UCD90124, UCD9090, and UCD90910
Prefixes: 'ucd90120', 'ucd90124', 'ucd9090', 'ucd90910'
* TI UCD90120, UCD90124, UCD90160, UCD9090, and UCD90910
Prefixes: 'ucd90120', 'ucd90124', 'ucd90160', 'ucd9090', 'ucd90910'
Addresses scanned: -
Datasheets:
http://focus.ti.com/lit/ds/symlink/ucd90120.pdf
http://focus.ti.com/lit/ds/symlink/ucd90124.pdf
http://focus.ti.com/lit/ds/symlink/ucd90160.pdf
http://focus.ti.com/lit/ds/symlink/ucd9090.pdf
http://focus.ti.com/lit/ds/symlink/ucd90910.pdf

Expand All @@ -32,6 +33,13 @@ interrupts, cascading, or other system functions. Twelve of these pins offer PWM
functionality. Using these pins, the UCD90124 offers support for fan control,
margining, and general-purpose PWM functions.

The UCD90160 is a 16-rail PMBus/I2C addressable power-supply sequencer and
monitor. The device integrates a 12-bit ADC for monitoring up to 16 power-supply
voltage inputs. Twenty-six GPIO pins can be used for power supply enables,
power-on reset signals, external interrupts, cascading, or other system
functions. Twelve of these pins offer PWM functionality. Using these pins, the
UCD90160 offers support for margining, and general-purpose PWM functions.

The UCD9090 is a 10-rail PMBus/I2C addressable power-supply sequencer and
monitor. The device integrates a 12-bit ADC for monitoring up to 10 power-supply
voltage inputs. Twenty-three GPIO pins can be used for power supply enables,
Expand Down
30 changes: 30 additions & 0 deletions Documentation/hwmon/xgene-hwmon
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Kernel driver xgene-hwmon
========================

Supported chips:
* APM X-Gene SoC

Description
-----------

This driver adds hardware temperature and power reading support for
APM X-Gene SoC using the mailbox communication interface.
For device tree, it is the standard DT mailbox.
For ACPI, it is the PCC mailbox.

The following sensors are supported

* Temperature
- SoC on-die temperature in milli-degree C
- Alarm when high/over temperature occurs
* Power
- CPU power in uW
- IO power in uW

sysfs-Interface
---------------

temp0_input - SoC on-die temperature (milli-degree C)
temp0_critical_alarm - An 1 would indicates on-die temperature exceeded threshold
power0_input - CPU power in (uW)
power1_input - IO power in (uW)
Loading

0 comments on commit 77b0a4a

Please sign in to comment.