diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 12:07:28 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 12:07:28 -0700 |
commit | 36f021b579d195cdc5fa6f3e2bab198b4bf70643 (patch) | |
tree | 96d3c97f5e5214d2aa7151c12a22a7eb345dbaa1 /drivers | |
parent | 215d06780d13fd7de629b02b61b7b7bf88ce5039 (diff) | |
parent | 1d72acf91abb327e25137ad2e371c1a788b34e45 (diff) |
Merge branch 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: (32 commits)
Use menuconfig objects - hwmon
hwmon/smsc47b397: Use dynamic sysfs callbacks
hwmon/smsc47b397: Convert to a platform driver
hwmon/w83781d: Deprecate W83627HF support
hwmon/w83781d: Use dynamic sysfs callbacks
hwmon/w83781d: Be less i2c_client-centric
hwmon/w83781d: Clean up conversion macros
hwmon/w83781d: No longer use i2c-isa
hwmon/ams: Do not print error on systems without apple motion sensor
hwmon/ams: Fix I2C read retry logic
hwmon: New AD7416, AD7417 and AD7418 driver
hwmon/coretemp: Add documentation
hwmon: New coretemp driver
i386: Use functions from library in msr driver
i386: Add safe variants of rdmsr_on_cpu and wrmsr_on_cpu
hwmon/lm75: Use dynamic sysfs callbacks
hwmon/lm78: Use dynamic sysfs callbacks
hwmon/lm78: Be less i2c_client-centric
hwmon/lm78: No longer use i2c-isa
hwmon: New max6650 driver
...
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/Kconfig | 146 | ||||
-rw-r--r-- | drivers/hwmon/Makefile | 3 | ||||
-rw-r--r-- | drivers/hwmon/ad7418.c | 373 | ||||
-rw-r--r-- | drivers/hwmon/ams/ams-core.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/ams/ams-i2c.c | 8 | ||||
-rw-r--r-- | drivers/hwmon/coretemp.c | 406 | ||||
-rw-r--r-- | drivers/hwmon/f71805f.c | 16 | ||||
-rw-r--r-- | drivers/hwmon/hwmon-vid.c | 6 | ||||
-rw-r--r-- | drivers/hwmon/lm75.c | 82 | ||||
-rw-r--r-- | drivers/hwmon/lm78.c | 662 | ||||
-rw-r--r-- | drivers/hwmon/lm87.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/max6650.c | 693 | ||||
-rw-r--r-- | drivers/hwmon/pc87427.c | 15 | ||||
-rw-r--r-- | drivers/hwmon/smsc47b397.c | 228 | ||||
-rw-r--r-- | drivers/hwmon/smsc47m1.c | 606 | ||||
-rw-r--r-- | drivers/hwmon/smsc47m192.c | 4 | ||||
-rw-r--r-- | drivers/hwmon/vt1211.c | 13 | ||||
-rw-r--r-- | drivers/hwmon/w83627hf.c | 670 | ||||
-rw-r--r-- | drivers/hwmon/w83781d.c | 1205 |
19 files changed, 3564 insertions, 1577 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 25b72a49170..3ba3a5221c4 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -2,9 +2,7 @@ # Hardware monitoring chip drivers configuration # -menu "Hardware Monitoring support" - -config HWMON +menuconfig HWMON tristate "Hardware Monitoring support" default y help @@ -23,13 +21,15 @@ config HWMON This support can also be built as a module. If so, the module will be called hwmon. +if HWMON + config HWMON_VID tristate default n config SENSORS_ABITUGURU tristate "Abit uGuru" - depends on HWMON && EXPERIMENTAL + depends on EXPERIMENTAL help If you say yes here you get support for the Abit uGuru chips sensor part. The voltage and frequency control parts of the Abit @@ -39,9 +39,19 @@ config SENSORS_ABITUGURU This driver can also be built as a module. If so, the module will be called abituguru. +config SENSORS_AD7418 + tristate "Analog Devices AD7416, AD7417 and AD7418" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the Analog Devices + AD7416, AD7417 and AD7418 temperature monitoring chips. + + This driver can also be built as a module. If so, the module + will be called ad7418. + config SENSORS_ADM1021 tristate "Analog Devices ADM1021 and compatibles" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for Analog Devices ADM1021 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, @@ -53,7 +63,7 @@ config SENSORS_ADM1021 config SENSORS_ADM1025 tristate "Analog Devices ADM1025 and compatibles" - depends on HWMON && I2C + depends on I2C select HWMON_VID help If you say yes here you get support for Analog Devices ADM1025 @@ -64,7 +74,7 @@ config SENSORS_ADM1025 config SENSORS_ADM1026 tristate "Analog Devices ADM1026 and compatibles" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for Analog Devices ADM1026 @@ -75,7 +85,7 @@ config SENSORS_ADM1026 config SENSORS_ADM1029 tristate "Analog Devices ADM1029" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL help If you say yes here you get support for Analog Devices ADM1029 sensor chip. @@ -86,7 +96,7 @@ config SENSORS_ADM1029 config SENSORS_ADM1031 tristate "Analog Devices ADM1031 and compatibles" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL help If you say yes here you get support for Analog Devices ADM1031 and ADM1030 sensor chips. @@ -96,7 +106,7 @@ config SENSORS_ADM1031 config SENSORS_ADM9240 tristate "Analog Devices ADM9240 and compatibles" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for Analog Devices ADM9240, @@ -107,7 +117,7 @@ config SENSORS_ADM9240 config SENSORS_K8TEMP tristate "AMD Athlon64/FX or Opteron temperature sensor" - depends on HWMON && X86 && PCI && EXPERIMENTAL + depends on X86 && PCI && EXPERIMENTAL help If you say yes here you get support for the temperature sensor(s) inside your CPU. Supported is whole AMD K8 @@ -119,7 +129,7 @@ config SENSORS_K8TEMP config SENSORS_AMS tristate "Apple Motion Sensor driver" - depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL + depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL help Support for the motion sensor included in PowerBooks. Includes implementations for PMU and I2C. @@ -144,7 +154,7 @@ config SENSORS_AMS_I2C config SENSORS_ASB100 tristate "Asus ASB100 Bach" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for the ASB100 Bach sensor @@ -155,7 +165,7 @@ config SENSORS_ASB100 config SENSORS_ATXP1 tristate "Attansic ATXP1 VID controller" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for the Attansic ATXP1 VID @@ -169,7 +179,7 @@ config SENSORS_ATXP1 config SENSORS_DS1621 tristate "Dallas Semiconductor DS1621 and DS1625" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for Dallas Semiconductor DS1621 and DS1625 sensor chips. @@ -179,7 +189,7 @@ config SENSORS_DS1621 config SENSORS_F71805F tristate "Fintek F71805F/FG and F71872F/FG" - depends on HWMON && EXPERIMENTAL + depends on EXPERIMENTAL help If you say yes here you get support for hardware monitoring features of the Fintek F71805F/FG and F71872F/FG Super-I/O @@ -190,7 +200,7 @@ config SENSORS_F71805F config SENSORS_FSCHER tristate "FSC Hermes" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for Fujitsu Siemens Computers Hermes sensor chips. @@ -200,7 +210,7 @@ config SENSORS_FSCHER config SENSORS_FSCPOS tristate "FSC Poseidon" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for Fujitsu Siemens Computers Poseidon sensor chips. @@ -210,7 +220,7 @@ config SENSORS_FSCPOS config SENSORS_GL518SM tristate "Genesys Logic GL518SM" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for Genesys Logic GL518SM sensor chips. @@ -220,7 +230,7 @@ config SENSORS_GL518SM config SENSORS_GL520SM tristate "Genesys Logic GL520SM" - depends on HWMON && I2C + depends on I2C select HWMON_VID help If you say yes here you get support for Genesys Logic GL520SM @@ -229,9 +239,17 @@ config SENSORS_GL520SM This driver can also be built as a module. If so, the module will be called gl520sm. +config SENSORS_CORETEMP + tristate "Intel Core (2) Duo/Solo temperature sensor" + depends on X86 && EXPERIMENTAL + help + If you say yes here you get support for the temperature + sensor inside your CPU. Supported all are all known variants + of Intel Core family. + config SENSORS_IT87 tristate "ITE IT87xx and compatibles" - depends on HWMON && I2C + depends on I2C select I2C_ISA select HWMON_VID help @@ -243,7 +261,7 @@ config SENSORS_IT87 config SENSORS_LM63 tristate "National Semiconductor LM63" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for the National Semiconductor LM63 remote diode digital temperature sensor with integrated fan @@ -255,7 +273,7 @@ config SENSORS_LM63 config SENSORS_LM70 tristate "National Semiconductor LM70" - depends on HWMON && SPI_MASTER && EXPERIMENTAL + depends on SPI_MASTER && EXPERIMENTAL help If you say yes here you get support for the National Semiconductor LM70 digital temperature sensor chip. @@ -265,7 +283,7 @@ config SENSORS_LM70 config SENSORS_LM75 tristate "National Semiconductor LM75 and compatibles" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for National Semiconductor LM75 sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in @@ -280,7 +298,7 @@ config SENSORS_LM75 config SENSORS_LM77 tristate "National Semiconductor LM77" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for National Semiconductor LM77 sensor chips. @@ -290,8 +308,7 @@ config SENSORS_LM77 config SENSORS_LM78 tristate "National Semiconductor LM78 and compatibles" - depends on HWMON && I2C - select I2C_ISA + depends on I2C select HWMON_VID help If you say yes here you get support for National Semiconductor LM78, @@ -302,7 +319,7 @@ config SENSORS_LM78 config SENSORS_LM80 tristate "National Semiconductor LM80" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL help If you say yes here you get support for National Semiconductor LM80 sensor chips. @@ -312,7 +329,7 @@ config SENSORS_LM80 config SENSORS_LM83 tristate "National Semiconductor LM83 and compatibles" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for National Semiconductor LM82 and LM83 sensor chips. @@ -322,7 +339,7 @@ config SENSORS_LM83 config SENSORS_LM85 tristate "National Semiconductor LM85 and compatibles" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for National Semiconductor LM85 @@ -333,7 +350,7 @@ config SENSORS_LM85 config SENSORS_LM87 tristate "National Semiconductor LM87" - depends on HWMON && I2C + depends on I2C select HWMON_VID help If you say yes here you get support for National Semiconductor LM87 @@ -344,7 +361,7 @@ config SENSORS_LM87 config SENSORS_LM90 tristate "National Semiconductor LM90 and compatibles" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for National Semiconductor LM90, LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and @@ -358,7 +375,7 @@ config SENSORS_LM90 config SENSORS_LM92 tristate "National Semiconductor LM92 and compatibles" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for National Semiconductor LM92 and Maxim MAX6635 sensor chips. @@ -368,16 +385,26 @@ config SENSORS_LM92 config SENSORS_MAX1619 tristate "Maxim MAX1619 sensor chip" - depends on HWMON && I2C + depends on I2C help If you say yes here you get support for MAX1619 sensor chip. This driver can also be built as a module. If so, the module will be called max1619. +config SENSORS_MAX6650 + tristate "Maxim MAX6650 sensor chip" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the MAX6650 / MAX6651 + sensor chips. + + This driver can also be built as a module. If so, the module + will be called max6650. + config SENSORS_PC87360 tristate "National Semiconductor PC87360 family" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select I2C_ISA select HWMON_VID help @@ -392,7 +419,7 @@ config SENSORS_PC87360 config SENSORS_PC87427 tristate "National Semiconductor PC87427" - depends on HWMON && EXPERIMENTAL + depends on EXPERIMENTAL help If you say yes here you get access to the hardware monitoring functions of the National Semiconductor PC87427 Super-I/O chip. @@ -405,7 +432,7 @@ config SENSORS_PC87427 config SENSORS_SIS5595 tristate "Silicon Integrated Systems Corp. SiS5595" - depends on HWMON && I2C && PCI && EXPERIMENTAL + depends on I2C && PCI && EXPERIMENTAL select I2C_ISA help If you say yes here you get support for the integrated sensors in @@ -416,28 +443,28 @@ config SENSORS_SIS5595 config SENSORS_SMSC47M1 tristate "SMSC LPC47M10x and compatibles" - depends on HWMON && I2C - select I2C_ISA help If you say yes here you get support for the integrated fan monitoring and control capabilities of the SMSC LPC47B27x, LPC47M10x, LPC47M112, LPC47M13x, LPC47M14x, LPC47M15x, - LPC47M192 and LPC47M997 chips. + LPC47M192, LPC47M292 and LPC47M997 chips. - The temperature and voltage sensor features of the LPC47M192 - and LPC47M997 are supported by another driver, select also - "SMSC LPC47M192 and compatibles" below for those. + The temperature and voltage sensor features of the LPC47M15x, + LPC47M192, LPC47M292 and LPC47M997 are supported by another + driver, select also "SMSC LPC47M192 and compatibles" below for + those. This driver can also be built as a module. If so, the module will be called smsc47m1. config SENSORS_SMSC47M192 tristate "SMSC LPC47M192 and compatibles" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for the temperature and - voltage sensors of the SMSC LPC47M192 and LPC47M997 chips. + voltage sensors of the SMSC LPC47M192, LPC47M15x, LPC47M292 + and LPC47M997 chips. The fan monitoring and control capabilities of these chips are supported by another driver, select @@ -449,8 +476,7 @@ config SENSORS_SMSC47M192 config SENSORS_SMSC47B397 tristate "SMSC LPC47B397-NC" - depends on HWMON && I2C && EXPERIMENTAL - select I2C_ISA + depends on EXPERIMENTAL help If you say yes here you get support for the SMSC LPC47B397-NC sensor chip. @@ -460,7 +486,7 @@ config SENSORS_SMSC47B397 config SENSORS_VIA686A tristate "VIA686A" - depends on HWMON && I2C && PCI + depends on I2C && PCI select I2C_ISA help If you say yes here you get support for the integrated sensors in @@ -471,7 +497,7 @@ config SENSORS_VIA686A config SENSORS_VT1211 tristate "VIA VT1211" - depends on HWMON && EXPERIMENTAL + depends on EXPERIMENTAL select HWMON_VID help If you say yes here then you get support for hardware monitoring @@ -482,7 +508,7 @@ config SENSORS_VT1211 config SENSORS_VT8231 tristate "VIA VT8231" - depends on HWMON && I2C && PCI && EXPERIMENTAL + depends on I2C && PCI && EXPERIMENTAL select HWMON_VID select I2C_ISA help @@ -494,8 +520,7 @@ config SENSORS_VT8231 config SENSORS_W83781D tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" - depends on HWMON && I2C - select I2C_ISA + depends on I2C select HWMON_VID help If you say yes here you get support for the Winbond W8378x series @@ -507,7 +532,7 @@ config SENSORS_W83781D config SENSORS_W83791D tristate "Winbond W83791D" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for the Winbond W83791D chip. @@ -517,7 +542,7 @@ config SENSORS_W83791D config SENSORS_W83792D tristate "Winbond W83792D" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL help If you say yes here you get support for the Winbond W83792D chip. @@ -526,7 +551,7 @@ config SENSORS_W83792D config SENSORS_W83793 tristate "Winbond W83793" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select HWMON_VID help If you say yes here you get support for the Winbond W83793 @@ -537,7 +562,7 @@ config SENSORS_W83793 config SENSORS_W83L785TS tristate "Winbond W83L785TS-S" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL help If you say yes here you get support for the Winbond W83L785TS-S sensor chip, which is used on the Asus A7N8X, among other @@ -548,8 +573,6 @@ config SENSORS_W83L785TS config SENSORS_W83627HF tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" - depends on HWMON && I2C - select I2C_ISA select HWMON_VID help If you say yes here you get support for the Winbond W836X7 series @@ -561,7 +584,7 @@ config SENSORS_W83627HF config SENSORS_W83627EHF tristate "Winbond W83627EHF" - depends on HWMON && I2C && EXPERIMENTAL + depends on I2C && EXPERIMENTAL select I2C_ISA help If you say yes here you get preliminary support for the hardware @@ -577,7 +600,7 @@ config SENSORS_W83627EHF config SENSORS_HDAPS tristate "IBM Hard Drive Active Protection System (hdaps)" - depends on HWMON && INPUT && X86 + depends on INPUT && X86 default n help This driver provides support for the IBM Hard Drive Active Protection @@ -620,7 +643,6 @@ config SENSORS_APPLESMC config HWMON_DEBUG_CHIP bool "Hardware Monitoring Chip debugging messages" - depends on HWMON default n help Say Y here if you want the I2C chip drivers to produce a bunch of @@ -628,4 +650,4 @@ config HWMON_DEBUG_CHIP a problem with I2C support and want to see more of what is going on. -endmenu +endif # HWMON diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 544f8d8dff4..cfaf338919d 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_SENSORS_W83781D) += w83781d.o obj-$(CONFIG_SENSORS_W83791D) += w83791d.o obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o +obj-$(CONFIG_SENSORS_AD7418) += ad7418.o obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o @@ -23,6 +24,7 @@ obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o +obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o obj-$(CONFIG_SENSORS_FSCHER) += fscher.o @@ -44,6 +46,7 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o obj-$(CONFIG_SENSORS_LM90) += lm90.o obj-$(CONFIG_SENSORS_LM92) += lm92.o obj-$(CONFIG_SENSORS_MAX1619) += max1619.o +obj-$(CONFIG_SENSORS_MAX6650) += max6650.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c new file mode 100644 index 00000000000..cc8b624a1e5 --- /dev/null +++ b/drivers/hwmon/ad7418.c @@ -0,0 +1,373 @@ +/* + * An hwmon driver for the Analog Devices AD7416/17/18 + * Copyright (C) 2006-07 Tower Technologies + * + * Author: Alessandro Zummo <a.zummo@towertech.it> + * + * Based on lm75.c + * Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, + * as published by the Free Software Foundation - version 2. + */ + +#include <linux/module.h> +#include <linux/jiffies.h> +#include <linux/i2c.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/err.h> +#include <linux/mutex.h> +#include <linux/delay.h> + +#include "lm75.h" + +#define DRV_VERSION "0.3" + +/* Addresses to scan */ +static unsigned short normal_i2c[] = { 0x28, I2C_CLIENT_END }; +/* Insmod parameters */ +I2C_CLIENT_INSMOD_3(ad7416, ad7417, ad7418); + +/* AD7418 registers */ +#define AD7418_REG_TEMP_IN 0x00 +#define AD7418_REG_CONF 0x01 +#define AD7418_REG_TEMP_HYST 0x02 +#define AD7418_REG_TEMP_OS 0x03 +#define AD7418_REG_ADC 0x04 +#define AD7418_REG_CONF2 0x05 + +#define AD7418_REG_ADC_CH(x) ((x) << 5) +#define AD7418_CH_TEMP AD7418_REG_ADC_CH(0) + +static const u8 AD7418_REG_TEMP[] = { AD7418_REG_TEMP_IN, + AD7418_REG_TEMP_HYST, + AD7418_REG_TEMP_OS }; + +struct ad7418_data { + struct i2c_client client; + struct class_device *class_dev; + struct attribute_group attrs; + enum chips type; + struct mutex lock; + int adc_max; /* number of ADC channels */ + char valid; + unsigned long last_updated; /* In jiffies */ + s16 temp[3]; /* Register values */ + u16 in[4]; +}; + +static int ad7418_attach_adapter(struct i2c_adapter *adapter); +static int ad7418_detect(struct i2c_adapter *adapter, int address, int kind); +static int ad7418_detach_client(struct i2c_client *client); + +static struct i2c_driver ad7418_driver = { + .driver = { + .name = "ad7418", + }, + .attach_adapter = ad7418_attach_adapter, + .detach_client = ad7418_detach_client, +}; + +/* All registers are word-sized, except for the configuration registers. + * AD7418 uses a high-byte first convention. Do NOT use those functions to + * access the configuration registers CONF and CONF2, as they are byte-sized. + */ +static inline int ad7418_read(struct i2c_client *client, u8 reg) +{ + return swab16(i2c_smbus_read_word_data(client, reg)); +} + +static inline int ad7418_write(struct i2c_client *client, u8 reg, u16 value) +{ + return i2c_smbus_write_word_data(client, reg, swab16(value)); +} + +static void ad7418_init_client(struct i2c_client *client) +{ + struct ad7418_data *data = i2c_get_clientdata(client); + + int reg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF); + if (reg < 0) { + dev_err(&client->dev, "cannot read configuration register\n"); + } else { + dev_info(&client->dev, "configuring for mode 1\n"); + i2c_smbus_write_byte_data(client, AD7418_REG_CONF, reg & 0xfe); + + if (data->type == ad7417 || data->type == ad7418) + i2c_smbus_write_byte_data(client, + AD7418_REG_CONF2, 0x00); + } +} + +static struct ad7418_data *ad7418_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct ad7418_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + u8 cfg; + int i, ch; + + /* read config register and clear channel bits */ + cfg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF); + cfg &= 0x1F; + + i2c_smbus_write_byte_data(client, AD7418_REG_CONF, + cfg | AD7418_CH_TEMP); + udelay(30); + + for (i = 0; i < 3; i++) { + data->temp[i] = ad7418_read(client, AD7418_REG_TEMP[i]); + } + + for (i = 0, ch = 4; i < data->adc_max; i++, ch--) { + i2c_smbus_write_byte_data(client, + AD7418_REG_CONF, + cfg | AD7418_REG_ADC_CH(ch)); + + udelay(15); + data->in[data->adc_max - 1 - i] = + ad7418_read(client, AD7418_REG_ADC); + } + + /* restore old configuration value */ + ad7418_write(client, AD7418_REG_CONF, cfg); + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->lock); + + return data; +} + +static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct ad7418_data *data = ad7418_update_device(dev); + return sprintf(buf, "%d\n", + LM75_TEMP_FROM_REG(data->temp[attr->index])); +} + +static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct ad7418_data *data = ad7418_update_device(dev); + + return sprintf(buf, "%d\n", + ((data->in[attr->index] >> 6) * 2500 + 512) / 1024); +} + +static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct ad7418_data *data = i2c_get_clientdata(client); + int temp = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->lock); + data->temp[attr->index] = LM75_TEMP_TO_REG(temp); + ad7418_write(client, AD7418_REG_TEMP[attr->index], data->temp[attr->index]); + mutex_unlock(&data->lock); + return count; +} + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); +static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, + show_temp, set_temp, 1); +static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, + show_temp, set_temp, 2); + +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 0); +static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 1); +static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 2); +static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 3); + +static int ad7418_attach_adapter(struct i2c_adapter *adapter) +{ + if (!(adapter->class & I2C_CLASS_HWMON)) + return 0; + return i2c_probe(adapter, &addr_data, ad7418_detect); +} + +static struct attribute *ad7416_attributes[] = { + &sensor_dev_attr_temp1_max.dev_attr.attr, + &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, + &sensor_dev_attr_temp1_input.dev_attr.attr, + NULL +}; + +static struct attribute *ad7417_attributes[] = { + &sensor_dev_attr_temp1_max.dev_attr.attr, + &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, + &sensor_dev_attr_temp1_input.dev_attr.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, + NULL +}; + +static struct attribute *ad7418_attributes[] = { + &sensor_dev_attr_temp1_max.dev_attr.attr, + &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_in1_input.dev_attr.attr, + NULL +}; + +static int ad7418_detect(struct i2c_adapter *adapter, int address, int kind) +{ + struct i2c_client *client; + struct ad7418_data *data; + int err = 0; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA)) + goto exit; + + if (!(data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL))) { + err = -ENOMEM; + goto exit; + } + + client = &data->client; + client->addr = address; + client->adapter = adapter; + client->driver = &ad7418_driver; + + i2c_set_clientdata(client, data); + + mutex_init(&data->lock); + + /* AD7418 has a curious behaviour on registers 6 and 7. They + * both always read 0xC071 and are not documented on the datasheet. + * We use them to detect the chip. + */ + if (kind <= 0) { + int reg, reg6, reg7; + + /* the AD7416 lies within this address range, but I have + * no means to check. + */ + if (address >= 0x48 && address <= 0x4f) { + /* XXX add tests for AD7416 here */ + /* data->type = ad7416; */ + } + /* here we might have AD7417 or AD7418 */ + else if (address >= 0x28 && address <= 0x2f) { + reg6 = i2c_smbus_read_word_data(client, 0x06); + reg7 = i2c_smbus_read_word_data(client, 0x07); + + if (address == 0x28 && reg6 == 0xC071 && reg7 == 0xC071) + data->type = ad7418; + + /* XXX add tests for AD7417 here */ + + + /* both AD7417 and AD7418 have bits 0-5 of + * the CONF2 register at 0 + */ + reg = i2c_smbus_read_byte_data(client, + AD7418_REG_CONF2); + if (reg & 0x3F) + data->type = any_chip; /* detection failed */ + } + } else { + dev_dbg(&adapter->dev, "detection forced\n"); + } + + if (kind > 0) + data->type = kind; + else if (kind < 0 && data->type == any_chip) { + err = -ENODEV; + goto exit_free; + } + + switch (data->type) { + case any_chip: + case ad7416: + data->adc_max = 0; + data->attrs.attrs = ad7416_attributes; + strlcpy(client->name, "ad7416", I2C_NAME_SIZE); + break; + + case ad7417: + data->adc_max = 4; + data->attrs.attrs = ad7417_attributes; + strlcpy(client->name, "ad7417", I2C_NAME_SIZE); + break; + + case ad7418: + data->adc_max = 1; + data->attrs.attrs = ad7418_attributes; + strlcpy(client->name, "ad7418", I2C_NAME_SIZE); + break; + } + + if ((err = i2c_attach_client(client))) + goto exit_free; + + dev_info(&client->dev, "%s chip found\n", client->name); + + /* Initialize the AD7418 chip */ + ad7418_init_client(client); + + /* Register sysfs hooks */ + if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) + goto exit_detach; + + data->class_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_remove; + } + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &data->attrs); +exit_detach: + i2c_detach_client(client); +exit_free: + kfree(data); +exit: + return err; +} + +static int ad7418_detach_client(struct i2c_client *client) +{ + struct ad7418_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->class_dev); + sysfs_remove_group(&client->dev.kobj, &data->attrs); + i2c_detach_client(client); + kfree(data); + return 0; +} + +static int __init ad7418_init(void) +{ + return i2c_add_driver(&ad7418_driver); +} + +static void __exit ad7418_exit(void) +{ + i2c_del_driver(&ad7418_driver); +} + +MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); +MODULE_DESCRIPTION("AD7416/17/18 driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + +module_init(ad7418_init); +module_exit(ad7418_exit); diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c index dbe6a32c064..6db97373972 100644 --- a/drivers/hwmon/ams/ams-core.c +++ b/drivers/hwmon/ams/ams-core.c @@ -219,9 +219,6 @@ int __init ams_init(void) /* Found PMU motion sensor */ return ams_pmu_init(np); #endif - - printk(KERN_ERR "ams: No motion sensor found |