You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: (23 commits) hwmon: Remove the deprecated adt7473 driver hwmon: Fix off-by-one kind values hwmon: (tmp421) Fix temperature conversions hwmon: (tmp421) Restore missing inputs hwmon: Driver for Andigilog aSC7621 family monitoring chips hwmon: (adt7411) Improve locking hwmon: Add driver for ADT7411 voltage and temperature sensor hwmon: (w83793) Add watchdog functionality hwmon: (g760a) Make rpm_from_cnt static hwmon: (it87) Validate auto pwm settings hwmon: (it87) Add support for old automatic fan speed control hwmon: (it87) Drop dead web links in documentation hwmon: (it87) Add an entry in MAINTAINERS hwmon: (it87) Use strict_strtol instead of simple_strtol hwmon: (it87) Fix many checkpatch errors and warnings hwmon: (it87) Add support for beep on alarm hwmon: (it87) Create vid attributes by group hwmon: (it87) Refactor attributes creation and removal hwmon: (it87) Expose the PWM/temperature mappings hwmon: (it87) Display fan outputs in automatic mode as such ...
This commit is contained in:
+28
-17
@@ -170,6 +170,16 @@ config SENSORS_ADM9240
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called adm9240.
|
||||
|
||||
config SENSORS_ADT7411
|
||||
tristate "Analog Devices ADT7411"
|
||||
depends on I2C && EXPERIMENTAL
|
||||
help
|
||||
If you say yes here you get support for the Analog Devices
|
||||
ADT7411 voltage and temperature monitoring chip.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called adt7411.
|
||||
|
||||
config SENSORS_ADT7462
|
||||
tristate "Analog Devices ADT7462"
|
||||
depends on I2C && EXPERIMENTAL
|
||||
@@ -190,20 +200,6 @@ config SENSORS_ADT7470
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called adt7470.
|
||||
|
||||
config SENSORS_ADT7473
|
||||
tristate "Analog Devices ADT7473 (DEPRECATED)"
|
||||
depends on I2C && EXPERIMENTAL
|
||||
select SENSORS_ADT7475
|
||||
help
|
||||
If you say yes here you get support for the Analog Devices
|
||||
ADT7473 temperature monitoring chips.
|
||||
|
||||
This driver is deprecated, you should use the adt7475 driver
|
||||
instead.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called adt7473.
|
||||
|
||||
config SENSORS_ADT7475
|
||||
tristate "Analog Devices ADT7473, ADT7475, ADT7476 and ADT7490"
|
||||
depends on I2C && EXPERIMENTAL
|
||||
@@ -216,6 +212,19 @@ config SENSORS_ADT7475
|
||||
This driver can also be build as a module. If so, the module
|
||||
will be called adt7475.
|
||||
|
||||
config SENSORS_ASC7621
|
||||
tristate "Andigilog aSC7621"
|
||||
depends on HWMON && I2C
|
||||
help
|
||||
If you say yes here you get support for the aSC7621
|
||||
family of SMBus sensors chip found on most Intel X48, X38, 975,
|
||||
965 and 945 desktop boards. Currently supported chips:
|
||||
aSC7621
|
||||
aSC7621a
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called asc7621.
|
||||
|
||||
config SENSORS_K8TEMP
|
||||
tristate "AMD Athlon64/FX or Opteron temperature sensor"
|
||||
depends on X86 && PCI && EXPERIMENTAL
|
||||
@@ -563,9 +572,10 @@ config SENSORS_LM90
|
||||
depends on I2C
|
||||
help
|
||||
If you say yes here you get support for National Semiconductor LM90,
|
||||
LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, and Maxim
|
||||
LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim
|
||||
MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659,
|
||||
MAX6680, MAX6681 and MAX6692 sensor chips.
|
||||
MAX6680, MAX6681 and MAX6692, and Winbond/Nuvoton W83L771AWG/ASG
|
||||
sensor chips.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called lm90.
|
||||
@@ -909,7 +919,8 @@ config SENSORS_W83793
|
||||
select HWMON_VID
|
||||
help
|
||||
If you say yes here you get support for the Winbond W83793
|
||||
hardware monitoring chip.
|
||||
hardware monitoring chip, including support for the integrated
|
||||
watchdog.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called w83793.
|
||||
|
||||
@@ -29,12 +29,13 @@ obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o
|
||||
obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
|
||||
obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
|
||||
obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o
|
||||
obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o
|
||||
obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o
|
||||
obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o
|
||||
obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o
|
||||
obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o
|
||||
obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
|
||||
obj-$(CONFIG_SENSORS_AMS) += ams/
|
||||
obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o
|
||||
obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
|
||||
obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o
|
||||
obj-$(CONFIG_SENSORS_DME1737) += dme1737.o
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* Driver for the ADT7411 (I2C/SPI 8 channel 10 bit ADC & temperature-sensor)
|
||||
*
|
||||
* Copyright (C) 2008, 2010 Pengutronix
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* TODO: SPI, support for external temperature sensor
|
||||
* use power-down mode for suspend?, interrupt handling?
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
|
||||
#define ADT7411_REG_INT_TEMP_VDD_LSB 0x03
|
||||
#define ADT7411_REG_EXT_TEMP_AIN14_LSB 0x04
|
||||
#define ADT7411_REG_VDD_MSB 0x06
|
||||
#define ADT7411_REG_INT_TEMP_MSB 0x07
|
||||
#define ADT7411_REG_EXT_TEMP_AIN1_MSB 0x08
|
||||
|
||||
#define ADT7411_REG_CFG1 0x18
|
||||
#define ADT7411_CFG1_START_MONITOR (1 << 0)
|
||||
|
||||
#define ADT7411_REG_CFG2 0x19
|
||||
#define ADT7411_CFG2_DISABLE_AVG (1 << 5)
|
||||
|
||||
#define ADT7411_REG_CFG3 0x1a
|
||||
#define ADT7411_CFG3_ADC_CLK_225 (1 << 0)
|
||||
#define ADT7411_CFG3_REF_VDD (1 << 4)
|
||||
|
||||
#define ADT7411_REG_DEVICE_ID 0x4d
|
||||
#define ADT7411_REG_MANUFACTURER_ID 0x4e
|
||||
|
||||
#define ADT7411_DEVICE_ID 0x2
|
||||
#define ADT7411_MANUFACTURER_ID 0x41
|
||||
|
||||
static const unsigned short normal_i2c[] = { 0x48, 0x4a, 0x4b, I2C_CLIENT_END };
|
||||
|
||||
struct adt7411_data {
|
||||
struct mutex device_lock; /* for "atomic" device accesses */
|
||||
struct mutex update_lock;
|
||||
unsigned long next_update;
|
||||
int vref_cached;
|
||||
struct device *hwmon_dev;
|
||||
};
|
||||
|
||||
/*
|
||||
* When reading a register containing (up to 4) lsb, all associated
|
||||
* msb-registers get locked by the hardware. After _one_ of those msb is read,
|
||||
* _all_ are unlocked. In order to use this locking correctly, reading lsb/msb
|
||||
* is protected here with a mutex, too.
|
||||
*/
|
||||
static int adt7411_read_10_bit(struct i2c_client *client, u8 lsb_reg,
|
||||
u8 msb_reg, u8 lsb_shift)
|
||||
{
|
||||
struct adt7411_data *data = i2c_get_clientdata(client);
|
||||
int val, tmp;
|
||||
|
||||
mutex_lock(&data->device_lock);
|
||||
|
||||
val = i2c_smbus_read_byte_data(client, lsb_reg);
|
||||
if (val < 0)
|
||||
goto exit_unlock;
|
||||
|
||||
tmp = (val >> lsb_shift) & 3;
|
||||
val = i2c_smbus_read_byte_data(client, msb_reg);
|
||||
|
||||
if (val >= 0)
|
||||
val = (val << 2) | tmp;
|
||||
|
||||
exit_unlock:
|
||||
mutex_unlock(&data->device_lock);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static int adt7411_modify_bit(struct i2c_client *client, u8 reg, u8 bit,
|
||||
bool flag)
|
||||
{
|
||||
struct adt7411_data *data = i2c_get_clientdata(client);
|
||||
int ret, val;
|
||||
|
||||
mutex_lock(&data->device_lock);
|
||||
|
||||
ret = i2c_smbus_read_byte_data(client, reg);
|
||||
if (ret < 0)
|
||||
goto exit_unlock;
|
||||
|
||||
if (flag)
|
||||
val = ret | bit;
|
||||
else
|
||||
val = ret & ~bit;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client, reg, val);
|
||||
|
||||
exit_unlock:
|
||||
mutex_unlock(&data->device_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t adt7411_show_vdd(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
int ret = adt7411_read_10_bit(client, ADT7411_REG_INT_TEMP_VDD_LSB,
|
||||
ADT7411_REG_VDD_MSB, 2);
|
||||
|
||||
return ret < 0 ? ret : sprintf(buf, "%u\n", ret * 7000 / 1024);
|
||||
}
|
||||
|
||||
static ssize_t adt7411_show_temp(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
int val = adt7411_read_10_bit(client, ADT7411_REG_INT_TEMP_VDD_LSB,
|
||||
ADT7411_REG_INT_TEMP_MSB, 0);
|
||||
|
||||
if (val < 0)
|
||||
return val;
|
||||
|
||||
val = val & 0x200 ? val - 0x400 : val; /* 10 bit signed */
|
||||
|
||||
return sprintf(buf, "%d\n", val * 250);
|
||||
}
|
||||
|
||||
static ssize_t adt7411_show_input(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int nr = to_sensor_dev_attr(attr)->index;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct adt7411_data *data = i2c_get_clientdata(client);
|
||||
int val;
|
||||
u8 lsb_reg, lsb_shift;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
if (time_after_eq(jiffies, data->next_update)) {
|
||||
val = i2c_smbus_read_byte_data(client, ADT7411_REG_CFG3);
|
||||
if (val < 0)
|
||||
goto exit_unlock;
|
||||
|
||||
if (val & ADT7411_CFG3_REF_VDD) {
|
||||
val = adt7411_read_10_bit(client,
|
||||
ADT7411_REG_INT_TEMP_VDD_LSB,
|
||||
ADT7411_REG_VDD_MSB, 2);
|
||||
if (val < 0)
|
||||
goto exit_unlock;
|
||||
|
||||
data->vref_cached = val * 7000 / 1024;
|
||||
} else {
|
||||
data->vref_cached = 2250;
|
||||
}
|
||||
|
||||
data->next_update = jiffies + HZ;
|
||||
}
|
||||
|
||||
lsb_reg = ADT7411_REG_EXT_TEMP_AIN14_LSB + (nr >> 2);
|
||||
lsb_shift = 2 * (nr & 0x03);
|
||||
val = adt7411_read_10_bit(client, lsb_reg,
|
||||
ADT7411_REG_EXT_TEMP_AIN1_MSB + nr, lsb_shift);
|
||||
if (val < 0)
|
||||
goto exit_unlock;
|
||||
|
||||
val = sprintf(buf, "%u\n", val * data->vref_cached / 1024);
|
||||
exit_unlock:
|
||||
mutex_unlock(&data->update_lock);
|
||||
return val;
|
||||
}
|
||||
|
||||
static ssize_t adt7411_show_bit(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
int ret = i2c_smbus_read_byte_data(client, attr2->index);
|
||||
|
||||
return ret < 0 ? ret : sprintf(buf, "%u\n", !!(ret & attr2->nr));
|
||||
}
|
||||
|
||||
static ssize_t adt7411_set_bit(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
struct sensor_device_attribute_2 *s_attr2 = to_sensor_dev_attr_2(attr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct adt7411_data *data = i2c_get_clientdata(client);
|
||||
int ret;
|
||||
unsigned long flag;
|
||||
|
||||
ret = strict_strtoul(buf, 0, &flag);
|
||||
if (ret || flag > 1)
|
||||
return -EINVAL;
|
||||
|
||||
ret = adt7411_modify_bit(client, s_attr2->index, s_attr2->nr, flag);
|
||||
|
||||
/* force update */
|
||||
mutex_lock(&data->update_lock);
|
||||
data->next_update = jiffies;
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return ret < 0 ? ret : count;
|
||||
}
|
||||
|
||||
#define ADT7411_BIT_ATTR(__name, __reg, __bit) \
|
||||
SENSOR_DEVICE_ATTR_2(__name, S_IRUGO | S_IWUSR, adt7411_show_bit, \
|
||||
adt7411_set_bit, __bit, __reg)
|
||||
|
||||
static DEVICE_ATTR(temp1_input, S_IRUGO, adt7411_show_temp, NULL);
|
||||
static DEVICE_ATTR(in0_input, S_IRUGO, adt7411_show_vdd, NULL);
|
||||
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, adt7411_show_input, NULL, 0);
|
||||
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, adt7411_show_input, NULL, 1);
|
||||
static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, adt7411_show_input, NULL, 2);
|
||||
static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, adt7411_show_input, NULL, 3);
|
||||
static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, adt7411_show_input, NULL, 4);
|
||||
static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, adt7411_show_input, NULL, 5);
|
||||
static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, adt7411_show_input, NULL, 6);
|
||||
static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, adt7411_show_input, NULL, 7);
|
||||
static ADT7411_BIT_ATTR(no_average, ADT7411_REG_CFG2, ADT7411_CFG2_DISABLE_AVG);
|
||||
static ADT7411_BIT_ATTR(fast_sampling, ADT7411_REG_CFG3, ADT7411_CFG3_ADC_CLK_225);
|
||||
static ADT7411_BIT_ATTR(adc_ref_vdd, ADT7411_REG_CFG3, ADT7411_CFG3_REF_VDD);
|
||||
|
||||
static struct attribute *adt7411_attrs[] = {
|
||||
&dev_attr_temp1_input.attr,
|
||||
&dev_attr_in0_input.attr,
|
||||
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in4_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in5_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in6_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in7_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in8_input.dev_attr.attr,
|
||||
&sensor_dev_attr_no_average.dev_attr.attr,
|
||||
&sensor_dev_attr_fast_sampling.dev_attr.attr,
|
||||
&sensor_dev_attr_adc_ref_vdd.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group adt7411_attr_grp = {
|
||||
.attrs = adt7411_attrs,
|
||||
};
|
||||
|
||||
static int adt7411_detect(struct i2c_client *client,
|
||||
struct i2c_board_info *info)
|
||||
{
|
||||
int val;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return -ENODEV;
|
||||
|
||||
val = i2c_smbus_read_byte_data(client, ADT7411_REG_MANUFACTURER_ID);
|
||||
if (val < 0 || val != ADT7411_MANUFACTURER_ID) {
|
||||
dev_dbg(&client->dev, "Wrong manufacturer ID. Got %d, "
|
||||
"expected %d\n", val, ADT7411_MANUFACTURER_ID);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
val = i2c_smbus_read_byte_data(client, ADT7411_REG_DEVICE_ID);
|
||||
if (val < 0 || val != ADT7411_DEVICE_ID) {
|
||||
dev_dbg(&client->dev, "Wrong device ID. Got %d, "
|
||||
"expected %d\n", val, ADT7411_DEVICE_ID);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
strlcpy(info->type, "adt7411", I2C_NAME_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit adt7411_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct adt7411_data *data;
|
||||
int ret;
|
||||
|
||||
data = kzalloc(sizeof(*data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->device_lock);
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
ret = adt7411_modify_bit(client, ADT7411_REG_CFG1,
|
||||
ADT7411_CFG1_START_MONITOR, 1);
|
||||
if (ret < 0)
|
||||
goto exit_free;
|
||||
|
||||
/* force update on first occasion */
|
||||
data->next_update = jiffies;
|
||||
|
||||
ret = sysfs_create_group(&client->dev.kobj, &adt7411_attr_grp);
|
||||
if (ret)
|
||||
goto exit_free;
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
ret = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "successfully registered\n");
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
|
||||
exit_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __devexit adt7411_remove(struct i2c_client *client)
|
||||
{
|
||||
struct adt7411_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id adt7411_id[] = {
|
||||
{ "adt7411", 0 },
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct i2c_driver adt7411_driver = {
|
||||
.driver = {
|
||||
.name = "adt7411",
|
||||
},
|
||||
.probe = adt7411_probe,
|
||||
.remove = __devexit_p(adt7411_remove),
|
||||
.id_table = adt7411_id,
|
||||
.detect = adt7411_detect,
|
||||
.address_list = normal_i2c,
|
||||
.class = I2C_CLASS_HWMON,
|
||||
};
|
||||
|
||||
static int __init sensors_adt7411_init(void)
|
||||
{
|
||||
return i2c_add_driver(&adt7411_driver);
|
||||
}
|
||||
module_init(sensors_adt7411_init)
|
||||
|
||||
static void __exit sensors_adt7411_exit(void)
|
||||
{
|
||||
i2c_del_driver(&adt7411_driver);
|
||||
}
|
||||
module_exit(sensors_adt7411_exit)
|
||||
|
||||
MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de> and "
|
||||
"Wolfram Sang <w.sang@pengutronix.de>");
|
||||
MODULE_DESCRIPTION("ADT7411 driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -267,7 +267,7 @@ struct fschmd_data {
|
||||
struct list_head list; /* member of the watchdog_data_list */
|
||||
struct kref kref;
|
||||
struct miscdevice watchdog_miscdev;
|
||||
int kind;
|
||||
enum chips kind;
|
||||
unsigned long watchdog_is_open;
|
||||
char watchdog_expect_close;
|
||||
char watchdog_name[10]; /* must be unique to avoid sysfs conflict */
|
||||
@@ -325,8 +325,7 @@ static ssize_t show_in_value(struct device *dev,
|
||||
int index = to_sensor_dev_attr(devattr)->index;
|
||||
struct fschmd_data *data = fschmd_update_device(dev);
|
||||
|
||||
/* fscher / fschrc - 1 as data->kind is an array index, not a chips */
|
||||
if (data->kind == (fscher - 1) || data->kind >= (fschrc - 1))
|
||||
if (data->kind == fscher || data->kind >= fschrc)
|
||||
return sprintf(buf, "%d\n", (data->volt[index] * dmi_vref *
|
||||
dmi_mult[index]) / 255 + dmi_offset[index]);
|
||||
else
|
||||
@@ -492,7 +491,7 @@ static ssize_t show_pwm_auto_point1_pwm(struct device *dev,
|
||||
int val = data->fan_min[index];
|
||||
|
||||
/* 0 = allow turning off (except on the syl), 1-255 = 50-100% */
|
||||
if (val || data->kind == fscsyl - 1)
|
||||
if (val || data->kind == fscsyl)
|
||||
val = val / 2 + 128;
|
||||
|
||||
return sprintf(buf, "%d\n", val);
|
||||
@@ -506,7 +505,7 @@ static ssize_t store_pwm_auto_point1_pwm(struct device *dev,
|
||||
unsigned long v = simple_strtoul(buf, NULL, 10);
|
||||
|
||||
/* reg: 0 = allow turning off (except on the syl), 1-255 = 50-100% */
|
||||
if (v || data->kind == fscsyl - 1) {
|
||||
if (v || data->kind == fscsyl) {
|
||||
v = SENSORS_LIMIT(v, 128, 255);
|
||||
v = (v - 128) * 2 + 1;
|
||||
}
|
||||
@@ -1037,7 +1036,7 @@ static int fschmd_detect(struct i2c_client *client,
|
||||
else
|
||||
return -ENODEV;
|
||||
|
||||
strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE);
|
||||
strlcpy(info->type, fschmd_id[kind].name, I2C_NAME_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1065,6 +1064,7 @@ static int fschmd_probe(struct i2c_client *client,
|
||||
(where the client is found through a data ptr instead of the
|
||||
otherway around) */
|
||||
data->client = client;
|
||||
data->kind = kind;
|
||||
|
||||
if (kind == fscpos) {
|
||||
/* The Poseidon has hardwired temp limits, fill these
|
||||
@@ -1085,9 +1085,6 @@ static int fschmd_probe(struct i2c_client *client,
|
||||
}
|
||||
}
|
||||
|
||||
/* i2c kind goes from 1-6, we want from 0-5 to address arrays */
|
||||
data->kind = kind - 1;
|
||||
|
||||
/* Read in some never changing registers */
|
||||
data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION);
|
||||
data->global_control = i2c_smbus_read_byte_data(client,
|
||||
|
||||
@@ -68,7 +68,7 @@ struct g760a_data {
|
||||
#define PWM_FROM_CNT(cnt) (0xff-(cnt))
|
||||
#define PWM_TO_CNT(pwm) (0xff-(pwm))
|
||||
|
||||
unsigned int rpm_from_cnt(u8 val, u32 clk, u16 div)
|
||||
static inline unsigned int rpm_from_cnt(u8 val, u32 clk, u16 div)
|
||||
{
|
||||
return ((val == 0x00) ? 0 : ((clk*30)/(val*div)));
|
||||
}
|
||||
|
||||
+686
-253
File diff suppressed because it is too large
Load Diff
+84
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* lm90.c - Part of lm_sensors, Linux kernel modules for hardware
|
||||
* monitoring
|
||||
* Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org>
|
||||
* Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
|
||||
*
|
||||
* Based on the lm83 driver. The LM90 is a sensor chip made by National
|
||||
* Semiconductor. It reports up to two temperatures (its own plus up to
|
||||
@@ -93,7 +93,8 @@
|
||||
static const unsigned short normal_i2c[] = {
|
||||
0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
|
||||
|
||||
enum chips { lm90, adm1032, lm99, lm86, max6657, adt7461, max6680, max6646 };
|
||||
enum chips { lm90, adm1032, lm99, lm86, max6657, adt7461, max6680, max6646,
|
||||
w83l771 };
|
||||
|
||||
/*
|
||||
* The LM90 registers
|
||||
@@ -151,6 +152,7 @@ static int lm90_detect(struct i2c_client *client, struct i2c_board_info *info);
|
||||
static int lm90_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id);
|
||||
static void lm90_init_client(struct i2c_client *client);
|
||||
static void lm90_alert(struct i2c_client *client, unsigned int flag);
|
||||
static int lm90_remove(struct i2c_client *client);
|
||||
static struct lm90_data *lm90_update_device(struct device *dev);
|
||||
|
||||
@@ -173,6 +175,7 @@ static const struct i2c_device_id lm90_id[] = {
|
||||
{ "max6659", max6657 },
|
||||
{ "max6680", max6680 },
|
||||
{ "max6681", max6680 },
|
||||
{ "w83l771", w83l771 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, lm90_id);
|
||||
@@ -184,6 +187,7 @@ static struct i2c_driver lm90_driver = {
|
||||
},
|
||||
.probe = lm90_probe,
|
||||
.remove = lm90_remove,
|
||||
.alert = lm90_alert,
|
||||
.id_table = lm90_id,
|
||||
.detect = lm90_detect,
|
||||
.address_list = normal_i2c,
|
||||
@@ -201,6 +205,9 @@ struct lm90_data {
|
||||
int kind;
|
||||
int flags;
|
||||
|
||||
u8 config_orig; /* Original configuration register value */
|
||||
u8 alert_alarms; /* Which alarm bits trigger ALERT# */
|
||||
|
||||
/* registers values */
|
||||
s8 temp8[4]; /* 0: local low limit
|
||||
1: local high limit
|
||||
@@ -758,6 +765,14 @@ static int lm90_detect(struct i2c_client *new_client,
|
||||
&& reg_convrate <= 0x07) {
|
||||
name = "max6646";
|
||||
}
|
||||
} else
|
||||
if (address == 0x4C
|
||||
&& man_id == 0x5C) { /* Winbond/Nuvoton */
|
||||
if ((chip_id & 0xFE) == 0x10 /* W83L771AWG/ASG */
|
||||
&& (reg_config1 & 0x2A) == 0x00
|
||||
&& reg_convrate <= 0x08) {
|
||||
name = "w83l771";
|
||||
}
|
||||
}
|
||||
|
||||
if (!name) { /* identification failed */
|
||||
@@ -794,6 +809,19 @@ static int lm90_probe(struct i2c_client *new_client,
|
||||
new_client->flags &= ~I2C_CLIENT_PEC;
|
||||
}
|
||||
|
||||
/* Different devices have different alarm bits triggering the
|
||||
* ALERT# output */
|
||||
switch (data->kind) {
|
||||
case lm90:
|
||||
case lm99:
|
||||
case lm86:
|
||||
data->alert_alarms = 0x7b;
|
||||
break;
|
||||
default:
|
||||
data->alert_alarms = 0x7c;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Initialize the LM90 chip */
|
||||
lm90_init_client(new_client);
|
||||
|
||||
@@ -830,7 +858,7 @@ exit:
|
||||
|
||||
static void lm90_init_client(struct i2c_client *client)
|
||||
{
|
||||
u8 config, config_orig;
|
||||
u8 config;
|
||||
struct lm90_data *data = i2c_get_clientdata(client);
|
||||
|
||||
/*
|
||||
@@ -842,7 +870,7 @@ static void lm90_init_client(struct i2c_client *client)
|
||||
dev_warn(&client->dev, "Initialization failed!\n");
|
||||
return;
|
||||
}
|
||||
config_orig = config;
|
||||
data->config_orig = config;
|
||||
|
||||
/* Check Temperature Range Select */
|
||||
if (data->kind == adt7461) {
|
||||
@@ -860,7 +888,7 @@ static void lm90_init_client(struct i2c_client *client)
|
||||
}
|
||||
|
||||
config &= 0xBF; /* run */
|
||||
if (config != config_orig) /* Only write if changed */
|
||||
if (config != data->config_orig) /* Only write if changed */
|
||||
i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
|
||||
}
|
||||
|
||||
@@ -875,10 +903,46 @@ static int lm90_remove(struct i2c_client *client)
|
||||
device_remove_file(&client->dev,
|
||||
&sensor_dev_attr_temp2_offset.dev_attr);
|
||||
|
||||
/* Restore initial configuration */
|
||||
i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
|
||||
data->config_orig);
|
||||
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lm90_alert(struct i2c_client *client, unsigned int flag)
|
||||
{
|
||||
struct lm90_data *data = i2c_get_clientdata(client);
|
||||
u8 config, alarms;
|
||||
|
||||
lm90_read_reg(client, LM90_REG_R_STATUS, &alarms);
|
||||
if ((alarms & 0x7f) == 0) {
|
||||
dev_info(&client->dev, "Everything OK\n");
|
||||
} else {
|
||||
if (alarms & 0x61)
|
||||
dev_warn(&client->dev,
|
||||
"temp%d out of range, please check!\n", 1);
|
||||
if (alarms & 0x1a)
|
||||
dev_warn(&client->dev,
|
||||
"temp%d out of range, please check!\n", 2);
|
||||
if (alarms & 0x04)
|
||||
dev_warn(&client->dev,
|
||||
"temp%d diode open, please check!\n", 2);
|
||||
|
||||
/* Disable ALERT# output, because these chips don't implement
|
||||
SMBus alert correctly; they should only hold the alert line
|
||||
low briefly. */
|
||||
if ((data->kind == adm1032 || data->kind == adt7461)
|
||||
&& (alarms & data->alert_alarms)) {
|
||||
dev_dbg(&client->dev, "Disabling ALERT#\n");
|
||||
lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
|
||||
i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
|
||||
config | 0x80);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
|
||||
{
|
||||
int err;
|
||||
@@ -966,6 +1030,21 @@ static struct lm90_data *lm90_update_device(struct device *dev)
|
||||
}
|
||||
lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms);
|
||||
|
||||
/* Re-enable ALERT# output if it was originally enabled and
|
||||
* relevant alarms are all clear */
|
||||
if ((data->config_orig & 0x80) == 0
|
||||
&& (data->alarms & data->alert_alarms) == 0) {
|
||||
u8 config;
|
||||
|
||||
lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
|
||||
if (config & 0x80) {
|
||||
dev_dbg(&client->dev, "Re-enabling ALERT#\n");
|
||||
i2c_smbus_write_byte_data(client,
|
||||
LM90_REG_W_CONFIG1,
|
||||
config & ~0x80);
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ struct tmp401_data {
|
||||
struct mutex update_lock;
|
||||
char valid; /* zero until following fields are valid */
|
||||
unsigned long last_updated; /* in jiffies */
|
||||
int kind;
|
||||
enum chips kind;
|
||||
|
||||
/* register values */
|
||||
u8 status;
|
||||
@@ -524,7 +524,7 @@ static int tmp401_detect(struct i2c_client *client,
|
||||
if (reg > 15)
|
||||
return -ENODEV;
|
||||
|
||||
strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE);
|
||||
strlcpy(info->type, tmp401_id[kind].name, I2C_NAME_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -572,8 +572,7 @@ static int tmp401_probe(struct i2c_client *client,
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "Detected TI %s chip\n",
|
||||
names[data->kind - 1]);
|
||||
dev_info(&client->dev, "Detected TI %s chip\n", names[data->kind]);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
+13
-11
@@ -61,9 +61,9 @@ static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 };
|
||||
#define TMP423_DEVICE_ID 0x23
|
||||
|
||||
static const struct i2c_device_id tmp421_id[] = {
|
||||
{ "tmp421", tmp421 },
|
||||
{ "tmp422", tmp422 },
|
||||
{ "tmp423", tmp423 },
|
||||
{ "tmp421", 2 },
|
||||
{ "tmp422", 3 },
|
||||
{ "tmp423", 4 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, tmp421_id);
|
||||
@@ -73,21 +73,23 @@ struct tmp421_data {
|
||||
struct mutex update_lock;
|
||||
char valid;
|
||||
unsigned long last_updated;
|
||||
int kind;
|
||||
int channels;
|
||||
u8 config;
|
||||
s16 temp[4];
|
||||
};
|
||||
|
||||
static int temp_from_s16(s16 reg)
|
||||
{
|
||||
int temp = reg;
|
||||
/* Mask out status bits */
|
||||
int temp = reg & ~0xf;
|
||||
|
||||
return (temp * 1000 + 128) / 256;
|
||||
}
|
||||
|
||||
static int temp_from_u16(u16 reg)
|
||||
{
|
||||
int temp = reg;
|
||||
/* Mask out status bits */
|
||||
int temp = reg & ~0xf;
|
||||
|
||||
/* Add offset for extended temperature range. */
|
||||
temp -= 64 * 256;
|
||||
@@ -107,7 +109,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev)
|
||||
data->config = i2c_smbus_read_byte_data(client,
|
||||
TMP421_CONFIG_REG_1);
|
||||
|
||||
for (i = 0; i <= data->kind; i++) {
|
||||
for (i = 0; i < data->channels; i++) {
|
||||
data->temp[i] = i2c_smbus_read_byte_data(client,
|
||||
TMP421_TEMP_MSB[i]) << 8;
|
||||
data->temp[i] |= i2c_smbus_read_byte_data(client,
|
||||
@@ -166,7 +168,7 @@ static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a,
|
||||
devattr = container_of(a, struct device_attribute, attr);
|
||||
index = to_sensor_dev_attr(devattr)->index;
|
||||
|
||||
if (data->kind > index)
|
||||
if (index < data->channels)
|
||||
return a->mode;
|
||||
|
||||
return 0;
|
||||
@@ -252,9 +254,9 @@ static int tmp421_detect(struct i2c_client *client,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE);
|
||||
strlcpy(info->type, tmp421_id[kind].name, I2C_NAME_SIZE);
|
||||
dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
|
||||
names[kind - 1], client->addr);
|
||||
names[kind], client->addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -271,7 +273,7 @@ static int tmp421_probe(struct i2c_client *client,
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
data->kind = id->driver_data;
|
||||
data->channels = id->driver_data;
|
||||
|
||||
err = tmp421_init_client(client);
|
||||
if (err)
|
||||
|
||||
+480
-4
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user