2019-05-20 15:19:02 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* pc87360.c - Part of lm_sensors, Linux kernel modules
|
|
|
|
* for hardware monitoring
|
2014-01-30 03:40:08 +08:00
|
|
|
* Copyright (C) 2004, 2007 Jean Delvare <jdelvare@suse.de>
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Copied from smsc47m1.c:
|
|
|
|
* Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
|
|
|
|
*
|
|
|
|
* Supports the following chips:
|
|
|
|
*
|
|
|
|
* Chip #vin #fan #pwm #temp devid
|
|
|
|
* PC87360 - 2 2 - 0xE1
|
|
|
|
* PC87363 - 2 2 - 0xE8
|
|
|
|
* PC87364 - 3 3 - 0xE4
|
|
|
|
* PC87365 11 3 3 2 0xE5
|
|
|
|
* PC87366 11 3 3 3-4 0xE9
|
|
|
|
*
|
|
|
|
* This driver assumes that no more than one chip is present, and one of
|
|
|
|
* the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F).
|
|
|
|
*/
|
|
|
|
|
2011-01-13 04:55:11 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/jiffies.h>
|
2007-06-09 22:11:16 +08:00
|
|
|
#include <linux/platform_device.h>
|
2005-07-16 09:39:18 +08:00
|
|
|
#include <linux/hwmon.h>
|
2005-09-03 04:52:43 +08:00
|
|
|
#include <linux/hwmon-sysfs.h>
|
2005-08-01 03:52:01 +08:00
|
|
|
#include <linux/hwmon-vid.h>
|
2005-07-16 09:39:18 +08:00
|
|
|
#include <linux/err.h>
|
2006-01-19 06:19:26 +08:00
|
|
|
#include <linux/mutex.h>
|
2009-01-07 23:37:35 +08:00
|
|
|
#include <linux/acpi.h>
|
2009-09-15 23:18:13 +08:00
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static u8 devid;
|
2007-06-09 22:11:16 +08:00
|
|
|
static struct platform_device *pdev;
|
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Call the ISA chip drivers detection function directly instead of relying
on i2c_detect. The net effect is that address lists won't be handled
anymore, but they were mostly useless in the ISA case anyway (pc87360,
smsc47m1, smsc47b397 had already dropped them).
We don't need to handle multiple devices, all we may need is a way to
force a given address instead of the original one (some drivers already
do: sis5595, via686a, w83627hf), and, for drivers supporting multiple
chips, a way to force one given kind. All this may be added later on
demand, but I actually don't think there will be much demand.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-07-20 05:56:35 +08:00
|
|
|
static unsigned short extra_isa[3];
|
2005-04-17 06:20:36 +08:00
|
|
|
static u8 confreg[4];
|
|
|
|
|
|
|
|
static int init = 1;
|
|
|
|
module_param(init, int, 0);
|
|
|
|
MODULE_PARM_DESC(init,
|
2012-01-15 13:49:53 +08:00
|
|
|
"Chip initialization level:\n"
|
|
|
|
" 0: None\n"
|
|
|
|
"*1: Forcibly enable internal voltage and temperature channels, except in9\n"
|
|
|
|
" 2: Forcibly enable all voltage and temperature channels, except in9\n"
|
|
|
|
" 3: Forcibly enable all voltage and temperature channels, including in9");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-12-07 06:13:42 +08:00
|
|
|
static unsigned short force_id;
|
|
|
|
module_param(force_id, ushort, 0);
|
|
|
|
MODULE_PARM_DESC(force_id, "Override the detected device ID");
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Super-I/O registers and operations
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEV 0x07 /* Register: Logical device select */
|
|
|
|
#define DEVID 0x20 /* Register: Device ID */
|
|
|
|
#define ACT 0x30 /* Register: Device activation */
|
|
|
|
#define BASE 0x60 /* Register: Base address */
|
|
|
|
|
|
|
|
#define FSCM 0x09 /* Logical device: fans */
|
|
|
|
#define VLM 0x0d /* Logical device: voltages */
|
|
|
|
#define TMS 0x0e /* Logical device: temperatures */
|
2008-10-19 11:27:33 +08:00
|
|
|
#define LDNI_MAX 3
|
|
|
|
static const u8 logdev[LDNI_MAX] = { FSCM, VLM, TMS };
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define LD_FAN 0
|
|
|
|
#define LD_IN 1
|
|
|
|
#define LD_TEMP 2
|
|
|
|
|
|
|
|
static inline void superio_outb(int sioaddr, int reg, int val)
|
|
|
|
{
|
|
|
|
outb(reg, sioaddr);
|
2012-01-15 13:49:53 +08:00
|
|
|
outb(val, sioaddr + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int superio_inb(int sioaddr, int reg)
|
|
|
|
{
|
|
|
|
outb(reg, sioaddr);
|
2012-01-15 13:49:53 +08:00
|
|
|
return inb(sioaddr + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void superio_exit(int sioaddr)
|
|
|
|
{
|
|
|
|
outb(0x02, sioaddr);
|
2012-01-15 13:49:53 +08:00
|
|
|
outb(0x02, sioaddr + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Logical devices
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PC87360_EXTENT 0x10
|
|
|
|
#define PC87365_REG_BANK 0x09
|
|
|
|
#define NO_BANK 0xff
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fan registers and conversions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* nr has to be 0 or 1 (PC87360/87363) or 2 (PC87364/87365/87366) */
|
|
|
|
#define PC87360_REG_PRESCALE(nr) (0x00 + 2 * (nr))
|
|
|
|
#define PC87360_REG_PWM(nr) (0x01 + 2 * (nr))
|
|
|
|
#define PC87360_REG_FAN_MIN(nr) (0x06 + 3 * (nr))
|
|
|
|
#define PC87360_REG_FAN(nr) (0x07 + 3 * (nr))
|
|
|
|
#define PC87360_REG_FAN_STATUS(nr) (0x08 + 3 * (nr))
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
#define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : \
|
|
|
|
480000 / ((val) * (div)))
|
|
|
|
#define FAN_TO_REG(val, div) ((val) <= 100 ? 0 : \
|
|
|
|
480000 / ((val) * (div)))
|
|
|
|
#define FAN_DIV_FROM_REG(val) (1 << (((val) >> 5) & 0x03))
|
2005-04-17 06:20:36 +08:00
|
|
|
#define FAN_STATUS_FROM_REG(val) ((val) & 0x07)
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
#define FAN_CONFIG_MONITOR(val, nr) (((val) >> (2 + (nr) * 3)) & 1)
|
|
|
|
#define FAN_CONFIG_CONTROL(val, nr) (((val) >> (3 + (nr) * 3)) & 1)
|
|
|
|
#define FAN_CONFIG_INVERT(val, nr) (((val) >> (4 + (nr) * 3)) & 1)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
#define PWM_FROM_REG(val, inv) ((inv) ? 255 - (val) : (val))
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline u8 PWM_TO_REG(int val, int inv)
|
|
|
|
{
|
|
|
|
if (inv)
|
|
|
|
val = 255 - val;
|
|
|
|
if (val < 0)
|
|
|
|
return 0;
|
|
|
|
if (val > 255)
|
|
|
|
return 255;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Voltage registers and conversions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PC87365_REG_IN_CONVRATE 0x07
|
|
|
|
#define PC87365_REG_IN_CONFIG 0x08
|
|
|
|
#define PC87365_REG_IN 0x0B
|
|
|
|
#define PC87365_REG_IN_MIN 0x0D
|
|
|
|
#define PC87365_REG_IN_MAX 0x0C
|
|
|
|
#define PC87365_REG_IN_STATUS 0x0A
|
|
|
|
#define PC87365_REG_IN_ALARMS1 0x00
|
|
|
|
#define PC87365_REG_IN_ALARMS2 0x01
|
|
|
|
#define PC87365_REG_VID 0x06
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
#define IN_FROM_REG(val, ref) (((val) * (ref) + 128) / 256)
|
|
|
|
#define IN_TO_REG(val, ref) ((val) < 0 ? 0 : \
|
|
|
|
(val) * 256 >= (ref) * 255 ? 255 : \
|
|
|
|
((val) * 256 + (ref) / 2) / (ref))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Temperature registers and conversions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PC87365_REG_TEMP_CONFIG 0x08
|
|
|
|
#define PC87365_REG_TEMP 0x0B
|
|
|
|
#define PC87365_REG_TEMP_MIN 0x0D
|
|
|
|
#define PC87365_REG_TEMP_MAX 0x0C
|
|
|
|
#define PC87365_REG_TEMP_CRIT 0x0E
|
|
|
|
#define PC87365_REG_TEMP_STATUS 0x0A
|
|
|
|
#define PC87365_REG_TEMP_ALARMS 0x00
|
|
|
|
|
|
|
|
#define TEMP_FROM_REG(val) ((val) * 1000)
|
|
|
|
#define TEMP_TO_REG(val) ((val) < -55000 ? -55 : \
|
|
|
|
(val) > 127000 ? 127 : \
|
|
|
|
(val) < 0 ? ((val) - 500) / 1000 : \
|
|
|
|
((val) + 500) / 1000)
|
|
|
|
|
|
|
|
/*
|
2007-06-09 22:11:16 +08:00
|
|
|
* Device data
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct pc87360_data {
|
2007-06-09 22:11:16 +08:00
|
|
|
const char *name;
|
2007-08-21 04:46:20 +08:00
|
|
|
struct device *hwmon_dev;
|
2006-01-19 06:19:26 +08:00
|
|
|
struct mutex lock;
|
|
|
|
struct mutex update_lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
char valid; /* !=0 if following fields are valid */
|
|
|
|
unsigned long last_updated; /* In jiffies */
|
|
|
|
|
|
|
|
int address[3];
|
|
|
|
|
|
|
|
u8 fannr, innr, tempnr;
|
|
|
|
|
|
|
|
u8 fan[3]; /* Register value */
|
|
|
|
u8 fan_min[3]; /* Register value */
|
|
|
|
u8 fan_status[3]; /* Register value */
|
|
|
|
u8 pwm[3]; /* Register value */
|
|
|
|
u16 fan_conf; /* Configuration register values, combined */
|
|
|
|
|
|
|
|
u16 in_vref; /* 1 mV/bit */
|
|
|
|
u8 in[14]; /* Register value */
|
|
|
|
u8 in_min[14]; /* Register value */
|
|
|
|
u8 in_max[14]; /* Register value */
|
|
|
|
u8 in_crit[3]; /* Register value */
|
|
|
|
u8 in_status[14]; /* Register value */
|
|
|
|
u16 in_alarms; /* Register values, combined, masked */
|
|
|
|
u8 vid_conf; /* Configuration register value */
|
|
|
|
u8 vrm;
|
|
|
|
u8 vid; /* Register value */
|
|
|
|
|
|
|
|
s8 temp[3]; /* Register value */
|
|
|
|
s8 temp_min[3]; /* Register value */
|
|
|
|
s8 temp_max[3]; /* Register value */
|
|
|
|
s8 temp_crit[3]; /* Register value */
|
|
|
|
u8 temp_status[3]; /* Register value */
|
|
|
|
u8 temp_alarms; /* Register value, masked */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions declaration
|
|
|
|
*/
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
static int pc87360_probe(struct platform_device *pdev);
|
2012-11-20 02:25:51 +08:00
|
|
|
static int pc87360_remove(struct platform_device *pdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
|
|
|
|
u8 reg);
|
|
|
|
static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
|
|
|
|
u8 reg, u8 value);
|
2007-06-09 22:11:16 +08:00
|
|
|
static void pc87360_init_device(struct platform_device *pdev,
|
|
|
|
int use_thermistors);
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct pc87360_data *pc87360_update_device(struct device *dev);
|
|
|
|
|
|
|
|
/*
|
2007-06-09 22:11:16 +08:00
|
|
|
* Driver data
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
static struct platform_driver pc87360_driver = {
|
2005-11-27 03:37:41 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "pc87360",
|
|
|
|
},
|
2007-06-09 22:11:16 +08:00
|
|
|
.probe = pc87360_probe,
|
2012-11-20 02:21:20 +08:00
|
|
|
.remove = pc87360_remove,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sysfs stuff
|
|
|
|
*/
|
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t fan_input_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index],
|
|
|
|
FAN_DIV_FROM_REG(data->fan_status[attr->index])));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t fan_min_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index],
|
|
|
|
FAN_DIV_FROM_REG(data->fan_status[attr->index])));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t fan_div_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n",
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
FAN_DIV_FROM_REG(data->fan_status[attr->index]));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t fan_status_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n",
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
FAN_STATUS_FROM_REG(data->fan_status[attr->index]));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t fan_min_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long fan_min;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &fan_min);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 05:05:07 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
2012-01-15 13:49:53 +08:00
|
|
|
fan_min = FAN_TO_REG(fan_min,
|
|
|
|
FAN_DIV_FROM_REG(data->fan_status[attr->index]));
|
2005-09-03 05:05:07 +08:00
|
|
|
|
|
|
|
/* If it wouldn't fit, change clock divisor */
|
|
|
|
while (fan_min > 255
|
|
|
|
&& (data->fan_status[attr->index] & 0x60) != 0x60) {
|
|
|
|
fan_min >>= 1;
|
|
|
|
data->fan[attr->index] >>= 1;
|
|
|
|
data->fan_status[attr->index] += 0x20;
|
|
|
|
}
|
|
|
|
data->fan_min[attr->index] = fan_min > 255 ? 255 : fan_min;
|
2012-01-15 13:49:53 +08:00
|
|
|
pc87360_write_value(data, LD_FAN, NO_BANK,
|
|
|
|
PC87360_REG_FAN_MIN(attr->index),
|
2005-09-03 05:05:07 +08:00
|
|
|
data->fan_min[attr->index]);
|
|
|
|
|
|
|
|
/* Write new divider, preserve alarm bits */
|
2012-01-15 13:49:53 +08:00
|
|
|
pc87360_write_value(data, LD_FAN, NO_BANK,
|
|
|
|
PC87360_REG_FAN_STATUS(attr->index),
|
2005-09-03 05:05:07 +08:00
|
|
|
data->fan_status[attr->index] & 0xF9);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 05:05:07 +08:00
|
|
|
|
|
|
|
return count;
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
|
|
|
|
2006-01-10 06:24:41 +08:00
|
|
|
static struct sensor_device_attribute fan_input[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(fan1_input, fan_input, 0),
|
|
|
|
SENSOR_ATTR_RO(fan2_input, fan_input, 1),
|
|
|
|
SENSOR_ATTR_RO(fan3_input, fan_input, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute fan_status[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(fan1_status, fan_status, 0),
|
|
|
|
SENSOR_ATTR_RO(fan2_status, fan_status, 1),
|
|
|
|
SENSOR_ATTR_RO(fan3_status, fan_status, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute fan_div[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(fan1_div, fan_div, 0),
|
|
|
|
SENSOR_ATTR_RO(fan2_div, fan_div, 1),
|
|
|
|
SENSOR_ATTR_RO(fan3_div, fan_div, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute fan_min[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(fan1_min, fan_min, 0),
|
|
|
|
SENSOR_ATTR_RW(fan2_min, fan_min, 1),
|
|
|
|
SENSOR_ATTR_RW(fan3_min, fan_min, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-20 12:50:57 +08:00
|
|
|
#define FAN_UNIT_ATTRS(X) \
|
|
|
|
{ &fan_input[X].dev_attr.attr, \
|
2006-09-25 03:02:44 +08:00
|
|
|
&fan_status[X].dev_attr.attr, \
|
|
|
|
&fan_div[X].dev_attr.attr, \
|
2012-01-20 12:50:57 +08:00
|
|
|
&fan_min[X].dev_attr.attr, \
|
|
|
|
NULL \
|
|
|
|
}
|
2006-09-25 03:02:44 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr,
|
2012-01-15 13:49:53 +08:00
|
|
|
char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n",
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
PWM_FROM_REG(data->pwm[attr->index],
|
2005-09-03 04:52:43 +08:00
|
|
|
FAN_CONFIG_INVERT(data->fan_conf,
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
attr->index)));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->pwm[attr->index] = PWM_TO_REG(val,
|
|
|
|
FAN_CONFIG_INVERT(data->fan_conf, attr->index));
|
|
|
|
pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index),
|
|
|
|
data->pwm[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-01-10 06:24:41 +08:00
|
|
|
static struct sensor_device_attribute pwm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(pwm1, pwm, 0),
|
|
|
|
SENSOR_ATTR_RW(pwm2, pwm, 1),
|
|
|
|
SENSOR_ATTR_RW(pwm3, pwm, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-20 12:50:57 +08:00
|
|
|
static struct attribute *pc8736x_fan_attr[][5] = {
|
2006-09-25 03:02:44 +08:00
|
|
|
FAN_UNIT_ATTRS(0),
|
|
|
|
FAN_UNIT_ATTRS(1),
|
2012-01-20 12:50:57 +08:00
|
|
|
FAN_UNIT_ATTRS(2)
|
2006-09-25 03:02:44 +08:00
|
|
|
};
|
2012-01-20 12:50:57 +08:00
|
|
|
|
|
|
|
static const struct attribute_group pc8736x_fan_attr_group[] = {
|
|
|
|
{ .attrs = pc8736x_fan_attr[0], },
|
|
|
|
{ .attrs = pc8736x_fan_attr[1], },
|
|
|
|
{ .attrs = pc8736x_fan_attr[2], },
|
2006-09-25 03:02:44 +08:00
|
|
|
};
|
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_input_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index],
|
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_min_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index],
|
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_max_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index],
|
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_status_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", data->in_status[attr->index]);
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_min_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr, const char *buf,
|
|
|
|
size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
|
|
|
|
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN,
|
|
|
|
data->in_min[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_max_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr, const char *buf,
|
|
|
|
size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
data->in_max[attr->index] = IN_TO_REG(val,
|
|
|
|
data->in_vref);
|
|
|
|
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX,
|
|
|
|
data->in_max[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-01-10 06:24:41 +08:00
|
|
|
static struct sensor_device_attribute in_input[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(in0_input, in_input, 0),
|
|
|
|
SENSOR_ATTR_RO(in1_input, in_input, 1),
|
|
|
|
SENSOR_ATTR_RO(in2_input, in_input, 2),
|
|
|
|
SENSOR_ATTR_RO(in3_input, in_input, 3),
|
|
|
|
SENSOR_ATTR_RO(in4_input, in_input, 4),
|
|
|
|
SENSOR_ATTR_RO(in5_input, in_input, 5),
|
|
|
|
SENSOR_ATTR_RO(in6_input, in_input, 6),
|
|
|
|
SENSOR_ATTR_RO(in7_input, in_input, 7),
|
|
|
|
SENSOR_ATTR_RO(in8_input, in_input, 8),
|
|
|
|
SENSOR_ATTR_RO(in9_input, in_input, 9),
|
|
|
|
SENSOR_ATTR_RO(in10_input, in_input, 10),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute in_status[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(in0_status, in_status, 0),
|
|
|
|
SENSOR_ATTR_RO(in1_status, in_status, 1),
|
|
|
|
SENSOR_ATTR_RO(in2_status, in_status, 2),
|
|
|
|
SENSOR_ATTR_RO(in3_status, in_status, 3),
|
|
|
|
SENSOR_ATTR_RO(in4_status, in_status, 4),
|
|
|
|
SENSOR_ATTR_RO(in5_status, in_status, 5),
|
|
|
|
SENSOR_ATTR_RO(in6_status, in_status, 6),
|
|
|
|
SENSOR_ATTR_RO(in7_status, in_status, 7),
|
|
|
|
SENSOR_ATTR_RO(in8_status, in_status, 8),
|
|
|
|
SENSOR_ATTR_RO(in9_status, in_status, 9),
|
|
|
|
SENSOR_ATTR_RO(in10_status, in_status, 10),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute in_min[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(in0_min, in_min, 0),
|
|
|
|
SENSOR_ATTR_RW(in1_min, in_min, 1),
|
|
|
|
SENSOR_ATTR_RW(in2_min, in_min, 2),
|
|
|
|
SENSOR_ATTR_RW(in3_min, in_min, 3),
|
|
|
|
SENSOR_ATTR_RW(in4_min, in_min, 4),
|
|
|
|
SENSOR_ATTR_RW(in5_min, in_min, 5),
|
|
|
|
SENSOR_ATTR_RW(in6_min, in_min, 6),
|
|
|
|
SENSOR_ATTR_RW(in7_min, in_min, 7),
|
|
|
|
SENSOR_ATTR_RW(in8_min, in_min, 8),
|
|
|
|
SENSOR_ATTR_RW(in9_min, in_min, 9),
|
|
|
|
SENSOR_ATTR_RW(in10_min, in_min, 10),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute in_max[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(in0_max, in_max, 0),
|
|
|
|
SENSOR_ATTR_RW(in1_max, in_max, 1),
|
|
|
|
SENSOR_ATTR_RW(in2_max, in_max, 2),
|
|
|
|
SENSOR_ATTR_RW(in3_max, in_max, 3),
|
|
|
|
SENSOR_ATTR_RW(in4_max, in_max, 4),
|
|
|
|
SENSOR_ATTR_RW(in5_max, in_max, 5),
|
|
|
|
SENSOR_ATTR_RW(in6_max, in_max, 6),
|
|
|
|
SENSOR_ATTR_RW(in7_max, in_max, 7),
|
|
|
|
SENSOR_ATTR_RW(in8_max, in_max, 8),
|
|
|
|
SENSOR_ATTR_RW(in9_max, in_max, 9),
|
|
|
|
SENSOR_ATTR_RW(in10_max, in_max, 10),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
/* (temp & vin) channel status register alarm bits (pdf sec.11.5.12) */
|
|
|
|
#define CHAN_ALM_MIN 0x02 /* min limit crossed */
|
|
|
|
#define CHAN_ALM_MAX 0x04 /* max limit exceeded */
|
|
|
|
#define TEMP_ALM_CRIT 0x08 /* temp crit exceeded (temp only) */
|
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* show_in_min/max_alarm() reads data from the per-channel status
|
|
|
|
* register (sec 11.5.12), not the vin event status registers (sec
|
|
|
|
* 11.5.2) that (legacy) show_in_alarm() resds (via data->in_alarms)
|
|
|
|
*/
|
2008-10-19 11:27:32 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_min_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr, char *buf)
|
2008-10-19 11:27:32 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MIN));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t in_max_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr, char *buf)
|
2008-10-19 11:27:32 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MAX));
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sensor_device_attribute in_min_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(in0_min_alarm, in_min_alarm, 0),
|
|
|
|
SENSOR_ATTR_RO(in1_min_alarm, in_min_alarm, 1),
|
|
|
|
SENSOR_ATTR_RO(in2_min_alarm, in_min_alarm, 2),
|
|
|
|
SENSOR_ATTR_RO(in3_min_alarm, in_min_alarm, 3),
|
|
|
|
SENSOR_ATTR_RO(in4_min_alarm, in_min_alarm, 4),
|
|
|
|
SENSOR_ATTR_RO(in5_min_alarm, in_min_alarm, 5),
|
|
|
|
SENSOR_ATTR_RO(in6_min_alarm, in_min_alarm, 6),
|
|
|
|
SENSOR_ATTR_RO(in7_min_alarm, in_min_alarm, 7),
|
|
|
|
SENSOR_ATTR_RO(in8_min_alarm, in_min_alarm, 8),
|
|
|
|
SENSOR_ATTR_RO(in9_min_alarm, in_min_alarm, 9),
|
|
|
|
SENSOR_ATTR_RO(in10_min_alarm, in_min_alarm, 10),
|
2008-10-19 11:27:32 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute in_max_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(in0_max_alarm, in_max_alarm, 0),
|
|
|
|
SENSOR_ATTR_RO(in1_max_alarm, in_max_alarm, 1),
|
|
|
|
SENSOR_ATTR_RO(in2_max_alarm, in_max_alarm, 2),
|
|
|
|
SENSOR_ATTR_RO(in3_max_alarm, in_max_alarm, 3),
|
|
|
|
SENSOR_ATTR_RO(in4_max_alarm, in_max_alarm, 4),
|
|
|
|
SENSOR_ATTR_RO(in5_max_alarm, in_max_alarm, 5),
|
|
|
|
SENSOR_ATTR_RO(in6_max_alarm, in_max_alarm, 6),
|
|
|
|
SENSOR_ATTR_RO(in7_max_alarm, in_max_alarm, 7),
|
|
|
|
SENSOR_ATTR_RO(in8_max_alarm, in_max_alarm, 8),
|
|
|
|
SENSOR_ATTR_RO(in9_max_alarm, in_max_alarm, 9),
|
|
|
|
SENSOR_ATTR_RO(in10_max_alarm, in_max_alarm, 10),
|
2008-10-19 11:27:32 +08:00
|
|
|
};
|
|
|
|
|
2006-09-25 03:02:44 +08:00
|
|
|
#define VIN_UNIT_ATTRS(X) \
|
|
|
|
&in_input[X].dev_attr.attr, \
|
|
|
|
&in_status[X].dev_attr.attr, \
|
|
|
|
&in_min[X].dev_attr.attr, \
|
2008-10-19 11:27:32 +08:00
|
|
|
&in_max[X].dev_attr.attr, \
|
|
|
|
&in_min_alarm[X].dev_attr.attr, \
|
|
|
|
&in_max_alarm[X].dev_attr.attr
|
2006-09-25 03:02:44 +08:00
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static ssize_t cpu0_vid_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2006-09-25 03:01:56 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
|
|
|
|
}
|
2016-12-22 20:05:24 +08:00
|
|
|
static DEVICE_ATTR_RO(cpu0_vid);
|
2006-09-25 03:01:56 +08:00
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static ssize_t vrm_show(struct device *dev, struct device_attribute *attr,
|
2012-01-15 13:49:53 +08:00
|
|
|
char *buf)
|
2006-09-25 03:01:56 +08:00
|
|
|
{
|
2007-10-09 00:24:35 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2006-09-25 03:01:56 +08:00
|
|
|
return sprintf(buf, "%u\n", data->vrm);
|
|
|
|
}
|
2016-12-22 20:05:24 +08:00
|
|
|
static ssize_t vrm_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2006-09-25 03:01:56 +08:00
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
unsigned long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtoul(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2014-08-06 08:24:54 +08:00
|
|
|
if (val > 255)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
data->vrm = val;
|
2006-09-25 03:01:56 +08:00
|
|
|
return count;
|
|
|
|
}
|
2016-12-22 20:05:24 +08:00
|
|
|
static DEVICE_ATTR_RW(vrm);
|
2006-09-25 03:01:56 +08:00
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static ssize_t alarms_in_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *attr, char *buf)
|
2006-09-25 03:01:56 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", data->in_alarms);
|
|
|
|
}
|
2016-12-22 20:05:24 +08:00
|
|
|
static DEVICE_ATTR_RO(alarms_in);
|
2006-09-25 03:01:56 +08:00
|
|
|
|
2006-09-25 03:02:44 +08:00
|
|
|
static struct attribute *pc8736x_vin_attr_array[] = {
|
|
|
|
VIN_UNIT_ATTRS(0),
|
|
|
|
VIN_UNIT_ATTRS(1),
|
|
|
|
VIN_UNIT_ATTRS(2),
|
|
|
|
VIN_UNIT_ATTRS(3),
|
|
|
|
VIN_UNIT_ATTRS(4),
|
|
|
|
VIN_UNIT_ATTRS(5),
|
|
|
|
VIN_UNIT_ATTRS(6),
|
|
|
|
VIN_UNIT_ATTRS(7),
|
|
|
|
VIN_UNIT_ATTRS(8),
|
|
|
|
VIN_UNIT_ATTRS(9),
|
|
|
|
VIN_UNIT_ATTRS(10),
|
|
|
|
&dev_attr_cpu0_vid.attr,
|
|
|
|
&dev_attr_vrm.attr,
|
|
|
|
&dev_attr_alarms_in.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
static const struct attribute_group pc8736x_vin_group = {
|
|
|
|
.attrs = pc8736x_vin_attr_array,
|
|
|
|
};
|
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_input_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index],
|
2005-09-03 04:52:43 +08:00
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_min_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index],
|
2005-09-03 04:52:43 +08:00
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_max_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index],
|
2005-09-03 04:52:43 +08:00
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_crit_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-11],
|
2005-09-03 04:52:43 +08:00
|
|
|
data->in_vref));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_status_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%u\n", data->in_status[attr->index]);
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_min_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
|
|
|
|
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN,
|
|
|
|
data->in_min[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_max_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->in_max[attr->index] = IN_TO_REG(val, data->in_vref);
|
|
|
|
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX,
|
|
|
|
data->in_max[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_crit_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref);
|
|
|
|
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT,
|
|
|
|
data->in_crit[attr->index-11]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* the +11 term below reflects the fact that VLM units 11,12,13 are
|
|
|
|
* used in the chip to measure voltage across the thermistors
|
|
|
|
*/
|
2006-01-10 06:24:41 +08:00
|
|
|
static struct sensor_device_attribute therm_input[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp4_input, therm_input, 0 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp5_input, therm_input, 1 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp6_input, therm_input, 2 + 11),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute therm_status[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp4_status, therm_status, 0 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp5_status, therm_status, 1 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp6_status, therm_status, 2 + 11),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute therm_min[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(temp4_min, therm_min, 0 + 11),
|
|
|
|
SENSOR_ATTR_RW(temp5_min, therm_min, 1 + 11),
|
|
|
|
SENSOR_ATTR_RW(temp6_min, therm_min, 2 + 11),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute therm_max[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(temp4_max, therm_max, 0 + 11),
|
|
|
|
SENSOR_ATTR_RW(temp5_max, therm_max, 1 + 11),
|
|
|
|
SENSOR_ATTR_RW(temp6_max, therm_max, 2 + 11),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute therm_crit[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(temp4_crit, therm_crit, 0 + 11),
|
|
|
|
SENSOR_ATTR_RW(temp5_crit, therm_crit, 1 + 11),
|
|
|
|
SENSOR_ATTR_RW(temp6_crit, therm_crit, 2 + 11),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* show_therm_min/max_alarm() reads data from the per-channel voltage
|
|
|
|
* status register (sec 11.5.12)
|
|
|
|
*/
|
2008-10-19 11:27:35 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_min_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
char *buf)
|
2008-10-19 11:27:35 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MIN));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_max_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
char *buf)
|
2008-10-19 11:27:35 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MAX));
|
|
|
|
}
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t therm_crit_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
char *buf)
|
2008-10-19 11:27:35 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->in_status[nr] & TEMP_ALM_CRIT));
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sensor_device_attribute therm_min_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp4_min_alarm, therm_min_alarm, 0 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp5_min_alarm, therm_min_alarm, 1 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp6_min_alarm, therm_min_alarm, 2 + 11),
|
2008-10-19 11:27:35 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute therm_max_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp4_max_alarm, therm_max_alarm, 0 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp5_max_alarm, therm_max_alarm, 1 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp6_max_alarm, therm_max_alarm, 2 + 11),
|
2008-10-19 11:27:35 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute therm_crit_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp4_crit_alarm, therm_crit_alarm, 0 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp5_crit_alarm, therm_crit_alarm, 1 + 11),
|
|
|
|
SENSOR_ATTR_RO(temp6_crit_alarm, therm_crit_alarm, 2 + 11),
|
2008-10-19 11:27:35 +08:00
|
|
|
};
|
|
|
|
|
2006-09-25 03:02:44 +08:00
|
|
|
#define THERM_UNIT_ATTRS(X) \
|
|
|
|
&therm_input[X].dev_attr.attr, \
|
|
|
|
&therm_status[X].dev_attr.attr, \
|
|
|
|
&therm_min[X].dev_attr.attr, \
|
|
|
|
&therm_max[X].dev_attr.attr, \
|
2008-10-19 11:27:35 +08:00
|
|
|
&therm_crit[X].dev_attr.attr, \
|
|
|
|
&therm_min_alarm[X].dev_attr.attr, \
|
|
|
|
&therm_max_alarm[X].dev_attr.attr, \
|
|
|
|
&therm_crit_alarm[X].dev_attr.attr
|
2006-09-25 03:02:44 +08:00
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
static struct attribute *pc8736x_therm_attr_array[] = {
|
2006-09-25 03:02:44 +08:00
|
|
|
THERM_UNIT_ATTRS(0),
|
|
|
|
THERM_UNIT_ATTRS(1),
|
|
|
|
THERM_UNIT_ATTRS(2),
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
static const struct attribute_group pc8736x_therm_group = {
|
|
|
|
.attrs = pc8736x_therm_attr_array,
|
|
|
|
};
|
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_input_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_min_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index]));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_max_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index]));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_crit_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
return sprintf(buf, "%d\n",
|
|
|
|
TEMP_FROM_REG(data->temp_crit[attr->index]));
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_status_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
return sprintf(buf, "%d\n", data->temp_status[attr->index]);
|
2005-09-03 04:52:43 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_min_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->temp_min[attr->index] = TEMP_TO_REG(val);
|
|
|
|
pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN,
|
|
|
|
data->temp_min[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_max_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->temp_max[attr->index] = TEMP_TO_REG(val);
|
|
|
|
pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX,
|
|
|
|
data->temp_max[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_crit_store(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
const char *buf, size_t count)
|
2005-09-03 04:52:43 +08:00
|
|
|
{
|
|
|
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2012-01-15 13:49:53 +08:00
|
|
|
long val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = kstrtol(buf, 10, &val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-03 04:52:43 +08:00
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
[PATCH] hwmon: (2/3) pc87360 driver update
pc87360: number-skew to init
The temp, therm, fan, pwm callbacks all have an offset skew in the code
which accommodates attribute numbering conventions under
/sys/bus/i2c/devices/9191-6620/ (ie they start at 1)
This patch moves that skew into the declaration, and out of the
functions (except for therm, where we simplify from 2 skews to 1). The
declarative skew is clearer, less error-prone, and more efficient.
The use of 11+offset-4 below reflects the fact that the sysfs numbering
of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to
measure the thermistor voltages.
There's one remaining skew factor, in *_crit callbacks below, because
there are no critical thresholds for voltages 0-10, only for those
supporting the thermistors.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-03 04:57:52 +08:00
|
|
|
data->temp_crit[attr->index] = TEMP_TO_REG(val);
|
|
|
|
pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT,
|
|
|
|
data->temp_crit[attr->index]);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-09-03 04:52:43 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-01-10 06:24:41 +08:00
|
|
|
static struct sensor_device_attribute temp_input[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp1_input, temp_input, 0),
|
|
|
|
SENSOR_ATTR_RO(temp2_input, temp_input, 1),
|
|
|
|
SENSOR_ATTR_RO(temp3_input, temp_input, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute temp_status[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp1_status, temp_status, 0),
|
|
|
|
SENSOR_ATTR_RO(temp2_status, temp_status, 1),
|
|
|
|
SENSOR_ATTR_RO(temp3_status, temp_status, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute temp_min[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(temp1_min, temp_min, 0),
|
|
|
|
SENSOR_ATTR_RW(temp2_min, temp_min, 1),
|
|
|
|
SENSOR_ATTR_RW(temp3_min, temp_min, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute temp_max[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(temp1_max, temp_max, 0),
|
|
|
|
SENSOR_ATTR_RW(temp2_max, temp_max, 1),
|
|
|
|
SENSOR_ATTR_RW(temp3_max, temp_max, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
|
|
|
static struct sensor_device_attribute temp_crit[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RW(temp1_crit, temp_crit, 0),
|
|
|
|
SENSOR_ATTR_RW(temp2_crit, temp_crit, 1),
|
|
|
|
SENSOR_ATTR_RW(temp3_crit, temp_crit, 2),
|
2006-01-10 06:24:41 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static ssize_t alarms_temp_show(struct device *dev,
|
2012-01-15 13:49:53 +08:00
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
return sprintf(buf, "%u\n", data->temp_alarms);
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static DEVICE_ATTR_RO(alarms_temp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* show_temp_min/max_alarm() reads data from the per-channel status
|
|
|
|
* register (sec 12.3.7), not the temp event status registers (sec
|
|
|
|
* 12.3.2) that show_temp_alarm() reads (via data->temp_alarms)
|
|
|
|
*/
|
2008-10-19 11:27:32 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_min_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
char *buf)
|
2008-10-19 11:27:32 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MIN));
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_max_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
char *buf)
|
2008-10-19 11:27:32 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MAX));
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_crit_alarm_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr,
|
|
|
|
char *buf)
|
2008-10-19 11:27:32 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->temp_status[nr] & TEMP_ALM_CRIT));
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sensor_device_attribute temp_min_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp1_min_alarm, temp_min_alarm, 0),
|
|
|
|
SENSOR_ATTR_RO(temp2_min_alarm, temp_min_alarm, 1),
|
|
|
|
SENSOR_ATTR_RO(temp3_min_alarm, temp_min_alarm, 2),
|
2008-10-19 11:27:32 +08:00
|
|
|
};
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2008-10-19 11:27:32 +08:00
|
|
|
static struct sensor_device_attribute temp_max_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp1_max_alarm, temp_max_alarm, 0),
|
|
|
|
SENSOR_ATTR_RO(temp2_max_alarm, temp_max_alarm, 1),
|
|
|
|
SENSOR_ATTR_RO(temp3_max_alarm, temp_max_alarm, 2),
|
2008-10-19 11:27:32 +08:00
|
|
|
};
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2008-10-19 11:27:32 +08:00
|
|
|
static struct sensor_device_attribute temp_crit_alarm[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp1_crit_alarm, temp_crit_alarm, 0),
|
|
|
|
SENSOR_ATTR_RO(temp2_crit_alarm, temp_crit_alarm, 1),
|
|
|
|
SENSOR_ATTR_RO(temp3_crit_alarm, temp_crit_alarm, 2),
|
2008-10-19 11:27:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define TEMP_FAULT 0x40 /* open diode */
|
2018-12-11 06:02:18 +08:00
|
|
|
static ssize_t temp_fault_show(struct device *dev,
|
|
|
|
struct device_attribute *devattr, char *buf)
|
2008-10-19 11:27:32 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = pc87360_update_device(dev);
|
|
|
|
unsigned nr = to_sensor_dev_attr(devattr)->index;
|
|
|
|
|
|
|
|
return sprintf(buf, "%u\n", !!(data->temp_status[nr] & TEMP_FAULT));
|
|
|
|
}
|
|
|
|
static struct sensor_device_attribute temp_fault[] = {
|
2018-12-11 06:02:18 +08:00
|
|
|
SENSOR_ATTR_RO(temp1_fault, temp_fault, 0),
|
|
|
|
SENSOR_ATTR_RO(temp2_fault, temp_fault, 1),
|
|
|
|
SENSOR_ATTR_RO(temp3_fault, temp_fault, 2),
|
2008-10-19 11:27:32 +08:00
|
|
|
};
|
|
|
|
|
2012-01-20 12:50:57 +08:00
|
|
|
#define TEMP_UNIT_ATTRS(X) \
|
|
|
|
{ &temp_input[X].dev_attr.attr, \
|
|
|
|
&temp_status[X].dev_attr.attr, \
|
|
|
|
&temp_min[X].dev_attr.attr, \
|
|
|
|
&temp_max[X].dev_attr.attr, \
|
|
|
|
&temp_crit[X].dev_attr.attr, \
|
|
|
|
&temp_min_alarm[X].dev_attr.attr, \
|
|
|
|
&temp_max_alarm[X].dev_attr.attr, \
|
|
|
|
&temp_crit_alarm[X].dev_attr.attr, \
|
|
|
|
&temp_fault[X].dev_attr.attr, \
|
|
|
|
NULL \
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct attribute *pc8736x_temp_attr[][10] = {
|
2006-09-25 03:02:44 +08:00
|
|
|
TEMP_UNIT_ATTRS(0),
|
|
|
|
TEMP_UNIT_ATTRS(1),
|
2012-01-20 12:50:57 +08:00
|
|
|
TEMP_UNIT_ATTRS(2)
|
2006-09-25 03:02:44 +08:00
|
|
|
};
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2012-01-20 12:50:57 +08:00
|
|
|
static const struct attribute_group pc8736x_temp_attr_group[] = {
|
|
|
|
{ .attrs = pc8736x_temp_attr[0] },
|
|
|
|
{ .attrs = pc8736x_temp_attr[1] },
|
|
|
|
{ .attrs = pc8736x_temp_attr[2] }
|
2006-09-25 03:02:44 +08:00
|
|
|
};
|
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static ssize_t name_show(struct device *dev,
|
2008-10-19 11:27:32 +08:00
|
|
|
struct device_attribute *devattr, char *buf)
|
2007-06-09 22:11:16 +08:00
|
|
|
{
|
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
|
|
|
return sprintf(buf, "%s\n", data->name);
|
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
|
2016-12-22 20:05:24 +08:00
|
|
|
static DEVICE_ATTR_RO(name);
|
2007-06-09 22:11:16 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Device detection, registration and update
|
|
|
|
*/
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
static int __init pc87360_find(int sioaddr, u8 *devid,
|
|
|
|
unsigned short *addresses)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u16 val;
|
|
|
|
int i;
|
|
|
|
int nrdev; /* logical device count */
|
|
|
|
|
|
|
|
/* No superio_enter */
|
|
|
|
|
|
|
|
/* Identify device */
|
2007-12-07 06:13:42 +08:00
|
|
|
val = force_id ? force_id : superio_inb(sioaddr, DEVID);
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (val) {
|
|
|
|
case 0xE1: /* PC87360 */
|
|
|
|
case 0xE8: /* PC87363 */
|
|
|
|
case 0xE4: /* PC87364 */
|
|
|
|
nrdev = 1;
|
|
|
|
break;
|
|
|
|
case 0xE5: /* PC87365 */
|
|
|
|
case 0xE9: /* PC87366 */
|
|
|
|
nrdev = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
superio_exit(sioaddr);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
/* Remember the device id */
|
|
|
|
*devid = val;
|
|
|
|
|
|
|
|
for (i = 0; i < nrdev; i++) {
|
|
|
|
/* select logical device */
|
|
|
|
superio_outb(sioaddr, DEV, logdev[i]);
|
|
|
|
|
|
|
|
val = superio_inb(sioaddr, ACT);
|
|
|
|
if (!(val & 0x01)) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_info("Device 0x%02x not activated\n", logdev[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = (superio_inb(sioaddr, BASE) << 8)
|
|
|
|
| superio_inb(sioaddr, BASE + 1);
|
|
|
|
if (!val) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_info("Base address not set for device 0x%02x\n",
|
|
|
|
logdev[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Call the ISA chip drivers detection function directly instead of relying
on i2c_detect. The net effect is that address lists won't be handled
anymore, but they were mostly useless in the ISA case anyway (pc87360,
smsc47m1, smsc47b397 had already dropped them).
We don't need to handle multiple devices, all we may need is a way to
force a given address instead of the original one (some drivers already
do: sis5595, via686a, w83627hf), and, for drivers supporting multiple
chips, a way to force one given kind. All this may be added later on
demand, but I actually don't think there will be much demand.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-07-20 05:56:35 +08:00
|
|
|
addresses[i] = val;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
if (i == 0) { /* Fans */
|
2005-04-17 06:20:36 +08:00
|
|
|
confreg[0] = superio_inb(sioaddr, 0xF0);
|
|
|
|
confreg[1] = superio_inb(sioaddr, 0xF1);
|
|
|
|
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_debug("Fan %d: mon=%d ctrl=%d inv=%d\n", 1,
|
|
|
|
(confreg[0] >> 2) & 1, (confreg[0] >> 3) & 1,
|
|
|
|
(confreg[0] >> 4) & 1);
|
|
|
|
pr_debug("Fan %d: mon=%d ctrl=%d inv=%d\n", 2,
|
|
|
|
(confreg[0] >> 5) & 1, (confreg[0] >> 6) & 1,
|
|
|
|
(confreg[0] >> 7) & 1);
|
|
|
|
pr_debug("Fan %d: mon=%d ctrl=%d inv=%d\n", 3,
|
|
|
|
confreg[1] & 1, (confreg[1] >> 1) & 1,
|
|
|
|
(confreg[1] >> 2) & 1);
|
2012-01-15 13:49:53 +08:00
|
|
|
} else if (i == 1) { /* Voltages */
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Are we using thermistors? */
|
|
|
|
if (*devid == 0xE9) { /* PC87366 */
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* These registers are not logical-device
|
|
|
|
* specific, just that we won't need them if
|
|
|
|
* we don't use the VLM device
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
confreg[2] = superio_inb(sioaddr, 0x2B);
|
|
|
|
confreg[3] = superio_inb(sioaddr, 0x25);
|
|
|
|
|
|
|
|
if (confreg[2] & 0x40) {
|
2013-01-11 02:01:24 +08:00
|
|
|
pr_info("Using thermistors for temperature monitoring\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (confreg[3] & 0xE0) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_info("VID inputs routed (mode %u)\n",
|
|
|
|
confreg[3] >> 5);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
superio_exit(sioaddr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-20 12:50:57 +08:00
|
|
|
static void pc87360_remove_files(struct device *dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
device_remove_file(dev, &dev_attr_name);
|
|
|
|
device_remove_file(dev, &dev_attr_alarms_temp);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pc8736x_temp_attr_group); i++)
|
|
|
|
sysfs_remove_group(&dev->kobj, &pc8736x_temp_attr_group[i]);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pc8736x_fan_attr_group); i++) {
|
|
|
|
sysfs_remove_group(&pdev->dev.kobj, &pc8736x_fan_attr_group[i]);
|
|
|
|
device_remove_file(dev, &pwm[i].dev_attr);
|
|
|
|
}
|
|
|
|
sysfs_remove_group(&dev->kobj, &pc8736x_therm_group);
|
|
|
|
sysfs_remove_group(&dev->kobj, &pc8736x_vin_group);
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:22:35 +08:00
|
|
|
static int pc87360_probe(struct platform_device *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct pc87360_data *data;
|
|
|
|
int err = 0;
|
2014-04-05 00:01:34 +08:00
|
|
|
const char *name;
|
2005-04-17 06:20:36 +08:00
|
|
|
int use_thermistors = 0;
|
2007-06-09 22:11:16 +08:00
|
|
|
struct device *dev = &pdev->dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-06-03 02:20:19 +08:00
|
|
|
data = devm_kzalloc(dev, sizeof(struct pc87360_data), GFP_KERNEL);
|
2012-01-15 13:49:53 +08:00
|
|
|
if (!data)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
switch (devid) {
|
2014-04-05 00:01:34 +08:00
|
|
|
default:
|
|
|
|
name = "pc87360";
|
|
|
|
data->fannr = 2;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
case 0xe8:
|
|
|
|
name = "pc87363";
|
2014-04-05 00:01:34 +08:00
|
|
|
data->fannr = 2;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case 0xe4:
|
|
|
|
name = "pc87364";
|
|
|
|
data->fannr = 3;
|
|
|
|
break;
|
|
|
|
case 0xe5:
|
|
|
|
name = "pc87365";
|
|
|
|
data->fannr = extra_isa[0] ? 3 : 0;
|
|
|
|
data->innr = extra_isa[1] ? 11 : 0;
|
|
|
|
data->tempnr = extra_isa[2] ? 2 : 0;
|
|
|
|
break;
|
|
|
|
case 0xe9:
|
|
|
|
name = "pc87366";
|
|
|
|
data->fannr = extra_isa[0] ? 3 : 0;
|
|
|
|
data->innr = extra_isa[1] ? 14 : 0;
|
|
|
|
data->tempnr = extra_isa[2] ? 3 : 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
data->name = name;
|
|
|
|
mutex_init(&data->lock);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_init(&data->update_lock);
|
2007-06-09 22:11:16 +08:00
|
|
|
platform_set_drvdata(pdev, data);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-10-19 11:27:33 +08:00
|
|
|
for (i = 0; i < LDNI_MAX; i++) {
|
2012-01-15 13:49:53 +08:00
|
|
|
data->address[i] = extra_isa[i];
|
|
|
|
if (data->address[i]
|
2012-06-03 02:20:19 +08:00
|
|
|
&& !devm_request_region(dev, extra_isa[i], PC87360_EXTENT,
|
|
|
|
pc87360_driver.driver.name)) {
|
2013-01-11 02:01:24 +08:00
|
|
|
dev_err(dev,
|
|
|
|
"Region 0x%x-0x%x already in use!\n",
|
|
|
|
extra_isa[i], extra_isa[i]+PC87360_EXTENT-1);
|
2012-06-03 02:20:19 +08:00
|
|
|
return -EBUSY;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Retrieve the fans configuration from Super-I/O space */
|
|
|
|
if (data->fannr)
|
|
|
|
data->fan_conf = confreg[0] | (confreg[1] << 8);
|
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* Use the correct reference voltage
|
|
|
|
* Unless both the VLM and the TMS logical devices agree to
|
|
|
|
* use an external Vref, the internal one is used.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (data->innr) {
|
|
|
|
i = pc87360_read_value(data, LD_IN, NO_BANK,
|
|
|
|
PC87365_REG_IN_CONFIG);
|
|
|
|
if (data->tempnr) {
|
|
|
|
i &= pc87360_read_value(data, LD_TEMP, NO_BANK,
|
|
|
|
PC87365_REG_TEMP_CONFIG);
|
|
|
|
}
|
|
|
|
data->in_vref = (i&0x02) ? 3025 : 2966;
|
2007-06-09 22:11:16 +08:00
|
|
|
dev_dbg(dev, "Using %s reference voltage\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
(i&0x02) ? "external" : "internal");
|
|
|
|
|
|
|
|
data->vid_conf = confreg[3];
|
2006-12-13 01:18:28 +08:00
|
|
|
data->vrm = vid_which_vrm();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fan clock dividers may be needed before any data is read */
|
|
|
|
for (i = 0; i < data->fannr; i++) {
|
|
|
|
if (FAN_CONFIG_MONITOR(data->fan_conf, i))
|
|
|
|
data->fan_status[i] = pc87360_read_value(data,
|
|
|
|
LD_FAN, NO_BANK,
|
|
|
|
PC87360_REG_FAN_STATUS(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (init > 0) {
|
|
|
|
if (devid == 0xe9 && data->address[1]) /* PC87366 */
|
|
|
|
use_thermistors = confreg[2] & 0x40;
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
pc87360_init_device(pdev, use_thermistors);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-09-25 03:03:25 +08:00
|
|
|
/* Register all-or-nothing sysfs groups */
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
if (data->innr) {
|
|
|
|
err = sysfs_create_group(&dev->kobj, &pc8736x_vin_group);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2012-01-15 13:49:53 +08:00
|
|
|
}
|
2005-07-16 09:39:18 +08:00
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
if (data->innr == 14) {
|
|
|
|
err = sysfs_create_group(&dev->kobj, &pc8736x_therm_group);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2012-01-15 13:49:53 +08:00
|
|
|
}
|
2006-09-25 03:03:25 +08:00
|
|
|
|
|
|
|
/* create device attr-files for varying sysfs groups */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (data->tempnr) {
|
2006-01-10 06:24:41 +08:00
|
|
|
for (i = 0; i < data->tempnr; i++) {
|
2012-01-20 12:50:57 +08:00
|
|
|
err = sysfs_create_group(&dev->kobj,
|
|
|
|
&pc8736x_temp_attr_group[i]);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
err = device_create_file(dev, &dev_attr_alarms_temp);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-01-10 06:24:41 +08:00
|
|
|
for (i = 0; i < data->fannr; i++) {
|
2012-01-20 12:50:57 +08:00
|
|
|
if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
|
|
|
|
err = sysfs_create_group(&dev->kobj,
|
|
|
|
&pc8736x_fan_attr_group[i]);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2012-01-20 12:50:57 +08:00
|
|
|
}
|
2012-01-15 13:49:53 +08:00
|
|
|
if (FAN_CONFIG_CONTROL(data->fan_conf, i)) {
|
|
|
|
err = device_create_file(dev, &pwm[i].dev_attr);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2012-01-15 13:49:53 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-01-15 13:49:53 +08:00
|
|
|
err = device_create_file(dev, &dev_attr_name);
|
|
|
|
if (err)
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2007-06-09 22:11:16 +08:00
|
|
|
|
2007-08-21 04:46:20 +08:00
|
|
|
data->hwmon_dev = hwmon_device_register(dev);
|
|
|
|
if (IS_ERR(data->hwmon_dev)) {
|
|
|
|
err = PTR_ERR(data->hwmon_dev);
|
2012-06-03 02:20:19 +08:00
|
|
|
goto error;
|
2006-09-25 03:03:25 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
2012-06-03 02:20:19 +08:00
|
|
|
error:
|
2012-01-20 12:50:57 +08:00
|
|
|
pc87360_remove_files(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:25:51 +08:00
|
|
|
static int pc87360_remove(struct platform_device *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = platform_get_drvdata(pdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-08-21 04:46:20 +08:00
|
|
|
hwmon_device_unregister(data->hwmon_dev);
|
2012-01-20 12:50:57 +08:00
|
|
|
pc87360_remove_files(&pdev->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* ldi is the logical device index
|
|
|
|
* bank is for voltages and temperatures only
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
|
|
|
|
u8 reg)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&(data->lock));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (bank != NO_BANK)
|
|
|
|
outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
|
|
|
|
res = inb_p(data->address[ldi] + reg);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&(data->lock));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
|
|
|
|
u8 reg, u8 value)
|
|
|
|
{
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&(data->lock));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (bank != NO_BANK)
|
|
|
|
outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
|
|
|
|
outb_p(value, data->address[ldi] + reg);
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&(data->lock));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
/* (temp & vin) channel conversion status register flags (pdf sec.11.5.12) */
|
|
|
|
#define CHAN_CNVRTD 0x80 /* new data ready */
|
|
|
|
#define CHAN_ENA 0x01 /* enabled channel (temp or vin) */
|
|
|
|
#define CHAN_ALM_ENA 0x10 /* propagate to alarms-reg ?? (chk val!) */
|
|
|
|
#define CHAN_READY (CHAN_ENA|CHAN_CNVRTD) /* sample ready mask */
|
|
|
|
|
2008-10-19 11:27:32 +08:00
|
|
|
#define TEMP_OTS_OE 0x20 /* OTS Output Enable */
|
|
|
|
#define VIN_RW1C_MASK (CHAN_READY|CHAN_ALM_MAX|CHAN_ALM_MIN) /* 0x87 */
|
|
|
|
#define TEMP_RW1C_MASK (VIN_RW1C_MASK|TEMP_ALM_CRIT|TEMP_FAULT) /* 0xCF */
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
static void pc87360_init_device(struct platform_device *pdev,
|
|
|
|
int use_thermistors)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = platform_get_drvdata(pdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
int i, nr;
|
|
|
|
const u8 init_in[14] = { 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 1, 2, 2, 2 };
|
|
|
|
const u8 init_temp[3] = { 2, 2, 1 };
|
|
|
|
u8 reg;
|
|
|
|
|
|
|
|
if (init >= 2 && data->innr) {
|
|
|
|
reg = pc87360_read_value(data, LD_IN, NO_BANK,
|
|
|
|
PC87365_REG_IN_CONVRATE);
|
2013-01-11 02:01:24 +08:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"VLM conversion set to 1s period, 160us delay\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_IN, NO_BANK,
|
|
|
|
PC87365_REG_IN_CONVRATE,
|
|
|
|
(reg & 0xC0) | 0x11);
|
|
|
|
}
|
|
|
|
|
|
|
|
nr = data->innr < 11 ? data->innr : 11;
|
2006-01-10 06:24:41 +08:00
|
|
|
for (i = 0; i < nr; i++) {
|
2008-10-19 11:27:34 +08:00
|
|
|
reg = pc87360_read_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_IN_STATUS);
|
|
|
|
dev_dbg(&pdev->dev, "bios in%d status:0x%02x\n", i, reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (init >= init_in[i]) {
|
|
|
|
/* Forcibly enable voltage channel */
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (!(reg & CHAN_ENA)) {
|
2013-01-11 02:01:24 +08:00
|
|
|
dev_dbg(&pdev->dev, "Forcibly enabling in%d\n",
|
|
|
|
i);
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_IN_STATUS,
|
|
|
|
(reg & 0x68) | 0x87);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* We can't blindly trust the Super-I/O space configuration bit,
|
|
|
|
* most BIOS won't set it properly
|
|
|
|
*/
|
2008-10-19 11:27:34 +08:00
|
|
|
dev_dbg(&pdev->dev, "bios thermistors:%d\n", use_thermistors);
|
2006-01-10 06:24:41 +08:00
|
|
|
for (i = 11; i < data->innr; i++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
reg = pc87360_read_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_TEMP_STATUS);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
use_thermistors = use_thermistors || (reg & CHAN_ENA);
|
2008-10-19 11:27:34 +08:00
|
|
|
/* thermistors are temp[4-6], measured on vin[11-14] */
|
|
|
|
dev_dbg(&pdev->dev, "bios temp%d_status:0x%02x\n", i-7, reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-10-19 11:27:34 +08:00
|
|
|
dev_dbg(&pdev->dev, "using thermistors:%d\n", use_thermistors);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
i = use_thermistors ? 2 : 0;
|
2006-01-10 06:24:41 +08:00
|
|
|
for (; i < data->tempnr; i++) {
|
2008-10-19 11:27:34 +08:00
|
|
|
reg = pc87360_read_value(data, LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_STATUS);
|
2012-01-15 13:49:53 +08:00
|
|
|
dev_dbg(&pdev->dev, "bios temp%d_status:0x%02x\n", i + 1, reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (init >= init_temp[i]) {
|
|
|
|
/* Forcibly enable temperature channel */
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (!(reg & CHAN_ENA)) {
|
2012-01-15 13:49:53 +08:00
|
|
|
dev_dbg(&pdev->dev,
|
|
|
|
"Forcibly enabling temp%d\n", i + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_STATUS,
|
|
|
|
0xCF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_thermistors) {
|
2006-01-10 06:24:41 +08:00
|
|
|
for (i = 11; i < data->innr; i++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (init >= init_in[i]) {
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* The pin may already be used by thermal
|
|
|
|
* diodes
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
reg = pc87360_read_value(data, LD_TEMP,
|
2012-01-15 13:49:53 +08:00
|
|
|
(i - 11) / 2, PC87365_REG_TEMP_STATUS);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (reg & CHAN_ENA) {
|
2012-01-15 13:49:53 +08:00
|
|
|
dev_dbg(&pdev->dev,
|
|
|
|
"Skipping temp%d, pin already in use by temp%d\n",
|
|
|
|
i - 7, (i - 11) / 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Forcibly enable thermistor channel */
|
|
|
|
reg = pc87360_read_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_IN_STATUS);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (!(reg & CHAN_ENA)) {
|
2012-01-15 13:49:53 +08:00
|
|
|
dev_dbg(&pdev->dev,
|
|
|
|
"Forcibly enabling temp%d\n",
|
|
|
|
i - 7);
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_TEMP_STATUS,
|
|
|
|
(reg & 0x60) | 0x8F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->innr) {
|
|
|
|
reg = pc87360_read_value(data, LD_IN, NO_BANK,
|
|
|
|
PC87365_REG_IN_CONFIG);
|
2008-10-19 11:27:34 +08:00
|
|
|
dev_dbg(&pdev->dev, "bios vin-cfg:0x%02x\n", reg);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (reg & CHAN_ENA) {
|
2012-01-15 13:49:53 +08:00
|
|
|
dev_dbg(&pdev->dev,
|
|
|
|
"Forcibly enabling monitoring (VLM)\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_IN, NO_BANK,
|
|
|
|
PC87365_REG_IN_CONFIG,
|
|
|
|
reg & 0xFE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->tempnr) {
|
|
|
|
reg = pc87360_read_value(data, LD_TEMP, NO_BANK,
|
|
|
|
PC87365_REG_TEMP_CONFIG);
|
2008-10-19 11:27:34 +08:00
|
|
|
dev_dbg(&pdev->dev, "bios temp-cfg:0x%02x\n", reg);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (reg & CHAN_ENA) {
|
2012-01-15 13:49:53 +08:00
|
|
|
dev_dbg(&pdev->dev,
|
|
|
|
"Forcibly enabling monitoring (TMS)\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_TEMP, NO_BANK,
|
|
|
|
PC87365_REG_TEMP_CONFIG,
|
|
|
|
reg & 0xFE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (init >= 2) {
|
|
|
|
/* Chip config as documented by National Semi. */
|
|
|
|
pc87360_write_value(data, LD_TEMP, 0xF, 0xA, 0x08);
|
2012-01-20 03:02:22 +08:00
|
|
|
/*
|
|
|
|
* We voluntarily omit the bank here, in case the
|
|
|
|
* sequence itself matters. It shouldn't be a problem,
|
|
|
|
* since nobody else is supposed to access the
|
|
|
|
* device at that point.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
pc87360_write_value(data, LD_TEMP, NO_BANK, 0xB, 0x04);
|
|
|
|
pc87360_write_value(data, LD_TEMP, NO_BANK, 0xC, 0x35);
|
|
|
|
pc87360_write_value(data, LD_TEMP, NO_BANK, 0xD, 0x05);
|
|
|
|
pc87360_write_value(data, LD_TEMP, NO_BANK, 0xE, 0x05);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
static void pc87360_autodiv(struct device *dev, int nr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 old_min = data->fan_min[nr];
|
|
|
|
|
|
|
|
/* Increase clock divider if needed and possible */
|
|
|
|
if ((data->fan_status[nr] & 0x04) /* overflow flag */
|
|
|
|
|| (data->fan[nr] >= 224)) { /* next to overflow */
|
|
|
|
if ((data->fan_status[nr] & 0x60) != 0x60) {
|
|
|
|
data->fan_status[nr] += 0x20;
|
|
|
|
data->fan_min[nr] >>= 1;
|
|
|
|
data->fan[nr] >>= 1;
|
2013-01-11 02:01:24 +08:00
|
|
|
dev_dbg(dev,
|
|
|
|
"Increasing clock divider to %d for fan %d\n",
|
2012-01-15 13:49:53 +08:00
|
|
|
FAN_DIV_FROM_REG(data->fan_status[nr]), nr + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Decrease clock divider if possible */
|
|
|
|
while (!(data->fan_min[nr] & 0x80) /* min "nails" divider */
|
|
|
|
&& data->fan[nr] < 85 /* bad accuracy */
|
|
|
|
&& (data->fan_status[nr] & 0x60) != 0x00) {
|
|
|
|
data->fan_status[nr] -= 0x20;
|
|
|
|
data->fan_min[nr] <<= 1;
|
|
|
|
data->fan[nr] <<= 1;
|
2013-01-11 02:01:24 +08:00
|
|
|
dev_dbg(dev,
|
|
|
|
"Decreasing clock divider to %d for fan %d\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
FAN_DIV_FROM_REG(data->fan_status[nr]),
|
2012-01-15 13:49:53 +08:00
|
|
|
nr + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write new fan min if it changed */
|
|
|
|
if (old_min != data->fan_min[nr]) {
|
|
|
|
pc87360_write_value(data, LD_FAN, NO_BANK,
|
|
|
|
PC87360_REG_FAN_MIN(nr),
|
|
|
|
data->fan_min[nr]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pc87360_data *pc87360_update_device(struct device *dev)
|
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
struct pc87360_data *data = dev_get_drvdata(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 i;
|
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_lock(&data->update_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
|
2007-06-09 22:11:16 +08:00
|
|
|
dev_dbg(dev, "Data update\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Fans */
|
|
|
|
for (i = 0; i < data->fannr; i++) {
|
|
|
|
if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
|
|
|
|
data->fan_status[i] =
|
|
|
|
pc87360_read_value(data, LD_FAN,
|
|
|
|
NO_BANK, PC87360_REG_FAN_STATUS(i));
|
|
|
|
data->fan[i] = pc87360_read_value(data, LD_FAN,
|
|
|
|
NO_BANK, PC87360_REG_FAN(i));
|
|
|
|
data->fan_min[i] = pc87360_read_value(data,
|
|
|
|
LD_FAN, NO_BANK,
|
|
|
|
PC87360_REG_FAN_MIN(i));
|
|
|
|
/* Change clock divider if needed */
|
2007-06-09 22:11:16 +08:00
|
|
|
pc87360_autodiv(dev, i);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Clear bits and write new divider */
|
|
|
|
pc87360_write_value(data, LD_FAN, NO_BANK,
|
|
|
|
PC87360_REG_FAN_STATUS(i),
|
|
|
|
data->fan_status[i]);
|
|
|
|
}
|
|
|
|
if (FAN_CONFIG_CONTROL(data->fan_conf, i))
|
|
|
|
data->pwm[i] = pc87360_read_value(data, LD_FAN,
|
|
|
|
NO_BANK, PC87360_REG_PWM(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Voltages */
|
|
|
|
for (i = 0; i < data->innr; i++) {
|
|
|
|
data->in_status[i] = pc87360_read_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_IN_STATUS);
|
|
|
|
/* Clear bits */
|
|
|
|
pc87360_write_value(data, LD_IN, i,
|
|
|
|
PC87365_REG_IN_STATUS,
|
|
|
|
data->in_status[i]);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if ((data->in_status[i] & CHAN_READY) == CHAN_READY) {
|
2005-04-17 06:20:36 +08:00
|
|
|
data->in[i] = pc87360_read_value(data, LD_IN,
|
|
|
|
i, PC87365_REG_IN);
|
|
|
|
}
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (data->in_status[i] & CHAN_ENA) {
|
2005-04-17 06:20:36 +08:00
|
|
|
data->in_min[i] = pc87360_read_value(data,
|
|
|
|
LD_IN, i,
|
|
|
|
PC87365_REG_IN_MIN);
|
|
|
|
data->in_max[i] = pc87360_read_value(data,
|
|
|
|
LD_IN, i,
|
|
|
|
PC87365_REG_IN_MAX);
|
|
|
|
if (i >= 11)
|
|
|
|
data->in_crit[i-11] =
|
|
|
|
pc87360_read_value(data, LD_IN,
|
|
|
|
i, PC87365_REG_TEMP_CRIT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data->innr) {
|
|
|
|
data->in_alarms = pc87360_read_value(data, LD_IN,
|
|
|
|
NO_BANK, PC87365_REG_IN_ALARMS1)
|
|
|
|
| ((pc87360_read_value(data, LD_IN,
|
|
|
|
NO_BANK, PC87365_REG_IN_ALARMS2)
|
|
|
|
& 0x07) << 8);
|
|
|
|
data->vid = (data->vid_conf & 0xE0) ?
|
|
|
|
pc87360_read_value(data, LD_IN,
|
|
|
|
NO_BANK, PC87365_REG_VID) : 0x1F;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Temperatures */
|
|
|
|
for (i = 0; i < data->tempnr; i++) {
|
|
|
|
data->temp_status[i] = pc87360_read_value(data,
|
|
|
|
LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_STATUS);
|
|
|
|
/* Clear bits */
|
|
|
|
pc87360_write_value(data, LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_STATUS,
|
|
|
|
data->temp_status[i]);
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if ((data->temp_status[i] & CHAN_READY) == CHAN_READY) {
|
2005-04-17 06:20:36 +08:00
|
|
|
data->temp[i] = pc87360_read_value(data,
|
|
|
|
LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP);
|
|
|
|
}
|
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 11:27:30 +08:00
|
|
|
if (data->temp_status[i] & CHAN_ENA) {
|
2005-04-17 06:20:36 +08:00
|
|
|
data->temp_min[i] = pc87360_read_value(data,
|
|
|
|
LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_MIN);
|
|
|
|
data->temp_max[i] = pc87360_read_value(data,
|
|
|
|
LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_MAX);
|
|
|
|
data->temp_crit[i] = pc87360_read_value(data,
|
|
|
|
LD_TEMP, i,
|
|
|
|
PC87365_REG_TEMP_CRIT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data->tempnr) {
|
|
|
|
data->temp_alarms = pc87360_read_value(data, LD_TEMP,
|
|
|
|
NO_BANK, PC87365_REG_TEMP_ALARMS)
|
|
|
|
& 0x3F;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->last_updated = jiffies;
|
|
|
|
data->valid = 1;
|
|
|
|
}
|
|
|
|
|
2006-01-19 06:19:26 +08:00
|
|
|
mutex_unlock(&data->update_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
static int __init pc87360_device_add(unsigned short address)
|
|
|
|
{
|
2010-08-15 03:08:48 +08:00
|
|
|
struct resource res[3];
|
|
|
|
int err, i, res_count;
|
2007-06-09 22:11:16 +08:00
|
|
|
|
|
|
|
pdev = platform_device_alloc("pc87360", address);
|
|
|
|
if (!pdev) {
|
|
|
|
err = -ENOMEM;
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_err("Device allocation failed\n");
|
2007-06-09 22:11:16 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2010-08-15 03:08:48 +08:00
|
|
|
memset(res, 0, 3 * sizeof(struct resource));
|
|
|
|
res_count = 0;
|
2007-06-09 22:11:16 +08:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (!extra_isa[i])
|
|
|
|
continue;
|
2010-08-15 03:08:48 +08:00
|
|
|
res[res_count].start = extra_isa[i];
|
|
|
|
res[res_count].end = extra_isa[i] + PC87360_EXTENT - 1;
|
|
|
|
res[res_count].name = "pc87360",
|
|
|
|
res[res_count].flags = IORESOURCE_IO,
|
2009-01-07 23:37:35 +08:00
|
|
|
|
2010-08-15 03:08:48 +08:00
|
|
|
err = acpi_check_resource_conflict(&res[res_count]);
|
2009-01-07 23:37:35 +08:00
|
|
|
if (err)
|
|
|
|
goto exit_device_put;
|
|
|
|
|
2010-08-15 03:08:48 +08:00
|
|
|
res_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = platform_device_add_resources(pdev, res, res_count);
|
|
|
|
if (err) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_err("Device resources addition failed (%d)\n", err);
|
2010-08-15 03:08:48 +08:00
|
|
|
goto exit_device_put;
|
2007-06-09 22:11:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = platform_device_add(pdev);
|
|
|
|
if (err) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_err("Device addition failed (%d)\n", err);
|
2007-06-09 22:11:16 +08:00
|
|
|
goto exit_device_put;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
exit_device_put:
|
|
|
|
platform_device_put(pdev);
|
|
|
|
exit:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int __init pc87360_init(void)
|
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
int err, i;
|
|
|
|
unsigned short address = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (pc87360_find(0x2e, &devid, extra_isa)
|
|
|
|
&& pc87360_find(0x4e, &devid, extra_isa)) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_warn("PC8736x not detected, module not inserted\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Arbitrarily pick one of the addresses */
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (extra_isa[i] != 0x0000) {
|
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Call the ISA chip drivers detection function directly instead of relying
on i2c_detect. The net effect is that address lists won't be handled
anymore, but they were mostly useless in the ISA case anyway (pc87360,
smsc47m1, smsc47b397 had already dropped them).
We don't need to handle multiple devices, all we may need is a way to
force a given address instead of the original one (some drivers already
do: sis5595, via686a, w83627hf), and, for drivers supporting multiple
chips, a way to force one given kind. All this may be added later on
demand, but I actually don't think there will be much demand.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-07-20 05:56:35 +08:00
|
|
|
address = extra_isa[i];
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Call the ISA chip drivers detection function directly instead of relying
on i2c_detect. The net effect is that address lists won't be handled
anymore, but they were mostly useless in the ISA case anyway (pc87360,
smsc47m1, smsc47b397 had already dropped them).
We don't need to handle multiple devices, all we may need is a way to
force a given address instead of the original one (some drivers already
do: sis5595, via686a, w83627hf), and, for drivers supporting multiple
chips, a way to force one given kind. All this may be added later on
demand, but I actually don't think there will be much demand.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-07-20 05:56:35 +08:00
|
|
|
if (address == 0x0000) {
|
2011-01-13 04:55:11 +08:00
|
|
|
pr_warn("No active logical device, module not inserted\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
err = platform_driver_register(&pc87360_driver);
|
|
|
|
if (err)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
/* Sets global pdev as a side effect */
|
|
|
|
err = pc87360_device_add(address);
|
|
|
|
if (err)
|
|
|
|
goto exit_driver;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
exit_driver:
|
|
|
|
platform_driver_unregister(&pc87360_driver);
|
|
|
|
exit:
|
|
|
|
return err;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit pc87360_exit(void)
|
|
|
|
{
|
2007-06-09 22:11:16 +08:00
|
|
|
platform_device_unregister(pdev);
|
|
|
|
platform_driver_unregister(&pc87360_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-30 03:40:08 +08:00
|
|
|
MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>");
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_DESCRIPTION("PC8736x hardware monitor");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(pc87360_init);
|
|
|
|
module_exit(pc87360_exit);
|