提交 dff6d1c5 编写于 作者: L Linus Torvalds

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
  ...
...@@ -449,12 +449,6 @@ Who: Alok N Kataria <akataria@vmware.com> ...@@ -449,12 +449,6 @@ Who: Alok N Kataria <akataria@vmware.com>
---------------------------- ----------------------------
What: adt7473 hardware monitoring driver
When: February 2010
Why: Obsoleted by the adt7475 driver.
Who: Jean Delvare <khali@linux-fr.org>
---------------------------
What: Support for lcd_switch and display_get in asus-laptop driver What: Support for lcd_switch and display_get in asus-laptop driver
When: March 2010 When: March 2010
Why: These two features use non-standard interfaces. There are the Why: These two features use non-standard interfaces. There are the
......
Kernel driver adt7411
=====================
Supported chips:
* Analog Devices ADT7411
Prefix: 'adt7411'
Addresses scanned: 0x48, 0x4a, 0x4b
Datasheet: Publicly available at the Analog Devices website
Author: Wolfram Sang (based on adt7470 by Darrick J. Wong)
Description
-----------
This driver implements support for the Analog Devices ADT7411 chip. There may
be other chips that implement this interface.
The ADT7411 can use an I2C/SMBus compatible 2-wire interface or an
SPI-compatible 4-wire interface. It provides a 10-bit analog to digital
converter which measures 1 temperature, vdd and 8 input voltages. It has an
internal temperature sensor, but an external one can also be connected (one
loses 2 inputs then). There are high- and low-limit registers for all inputs.
Check the datasheet for details.
sysfs-Interface
---------------
in0_input - vdd voltage input
in[1-8]_input - analog 1-8 input
temp1_input - temperature input
Besides standard interfaces, this driver adds (0 = off, 1 = on):
adc_ref_vdd - Use vdd as reference instead of 2.25 V
fast_sampling - Sample at 22.5 kHz instead of 1.4 kHz, but drop filters
no_average - Turn off averaging over 16 samples
Notes
-----
SPI, external temperature sensor and limit registers are not supported yet.
Kernel driver adt7473
======================
Supported chips:
* Analog Devices ADT7473
Prefix: 'adt7473'
Addresses scanned: I2C 0x2C, 0x2D, 0x2E
Datasheet: Publicly available at the Analog Devices website
Author: Darrick J. Wong
This driver is depreacted, please use the adt7475 driver instead.
Description
-----------
This driver implements support for the Analog Devices ADT7473 chip family.
The ADT7473 uses the 2-wire interface compatible with the SMBUS 2.0
specification. Using an analog to digital converter it measures three (3)
temperatures and two (2) voltages. It has four (4) 16-bit counters for
measuring fan speed. There are three (3) PWM outputs that can be used
to control fan speed.
A sophisticated control system for the PWM outputs is designed into the
ADT7473 that allows fan speed to be adjusted automatically based on any of the
three temperature sensors. Each PWM output is individually adjustable and
programmable. Once configured, the ADT7473 will adjust the PWM outputs in
response to the measured temperatures without further host intervention.
This feature can also be disabled for manual control of the PWM's.
Each of the measured inputs (voltage, temperature, fan speed) has
corresponding high/low limit values. The ADT7473 will signal an ALARM if
any measured value exceeds either limit.
The ADT7473 samples all inputs continuously. The driver will not read
the registers more often than once every other second. Further,
configuration data is only read once per minute.
Special Features
----------------
The ADT7473 have a 10-bit ADC and can therefore measure temperatures
with 0.25 degC resolution. Temperature readings can be configured either
for twos complement format or "Offset 64" format, wherein 63 is subtracted
from the raw value to get the temperature value.
The Analog Devices datasheet is very detailed and describes a procedure for
determining an optimal configuration for the automatic PWM control.
Configuration Notes
-------------------
Besides standard interfaces driver adds the following:
* PWM Control
* pwm#_auto_point1_pwm and temp#_auto_point1_temp and
* pwm#_auto_point2_pwm and temp#_auto_point2_temp -
point1: Set the pwm speed at a lower temperature bound.
point2: Set the pwm speed at a higher temperature bound.
The ADT7473 will scale the pwm between the lower and higher pwm speed when
the temperature is between the two temperature boundaries. PWM values range
from 0 (off) to 255 (full speed). Fan speed will be set to maximum when the
temperature sensor associated with the PWM control exceeds temp#_max.
Notes
-----
The NVIDIA binary driver presents an ADT7473 chip via an on-card i2c bus.
Unfortunately, they fail to set the i2c adapter class, so this driver may
fail to find the chip until the nvidia driver is patched.
Kernel driver asc7621
==================
Supported chips:
Andigilog aSC7621 and aSC7621a
Prefix: 'asc7621'
Addresses scanned: I2C 0x2c, 0x2d, 0x2e
Datasheet: http://www.fairview5.com/linux/asc7621/asc7621.pdf
Author:
George Joseph
Description provided by Dave Pivin @ Andigilog:
Andigilog has both the PECI and pre-PECI versions of the Heceta-6, as
Intel calls them. Heceta-6e has high frequency PWM and Heceta-6p has
added PECI and a 4th thermal zone. The Andigilog aSC7611 is the
Heceta-6e part and aSC7621 is the Heceta-6p part. They are both in
volume production, shipping to Intel and their subs.
We have enhanced both parts relative to the governing Intel
specification. First enhancement is temperature reading resolution. We
have used registers below 20h for vendor-specific functions in addition
to those in the Intel-specified vendor range.
Our conversion process produces a result that is reported as two bytes.
The fan speed control uses this finer value to produce a "step-less" fan
PWM output. These two bytes are "read-locked" to guarantee that once a
high or low byte is read, the other byte is locked-in until after the
next read of any register. So to get an atomic reading, read high or low
byte, then the very next read should be the opposite byte. Our data
sheet says 10-bits of resolution, although you may find the lower bits
are active, they are not necessarily reliable or useful externally. We
chose not to mask them.
We employ significant filtering that is user tunable as described in the
data sheet. Our temperature reports and fan PWM outputs are very smooth
when compared to the competition, in addition to the higher resolution
temperature reports. The smoother PWM output does not require user
intervention.
We offer GPIO features on the former VID pins. These are open-drain
outputs or inputs and may be used as general purpose I/O or as alarm
outputs that are based on temperature limits. These are in 19h and 1Ah.
We offer flexible mapping of temperature readings to thermal zones. Any
temperature may be mapped to any zone, which has a default assignment
that follows Intel's specs.
Since there is a fan to zone assignment that allows for the "hotter" of
a set of zones to control the PWM of an individual fan, but there is no
indication to the user, we have added an indicator that shows which zone
is currently controlling the PWM for a given fan. This is in register
00h.
Both remote diode temperature readings may be given an offset value such
that the reported reading as well as the temperature used to determine
PWM may be offset for system calibration purposes.
PECI Extended configuration allows for having more than two domains per
PECI address and also provides an enabling function for each PECI
address. One could use our flexible zone assignment to have a zone
assigned to up to 4 PECI addresses. This is not possible in the default
Intel configuration. This would be useful in multi-CPU systems with
individual fans on each that would benefit from individual fan control.
This is in register 0Eh.
The tachometer measurement system is flexible and able to adapt to many
fan types. We can also support pulse-stretched PWM so that 3-wire fans
may be used. These characteristics are in registers 04h to 07h.
Finally, we have added a tach disable function that turns off the tach
measurement system for individual tachs in order to save power. That is
in register 75h.
--
aSC7621 Product Description
The aSC7621 has a two wire digital interface compatible with SMBus 2.0.
Using a 10-bit ADC, the aSC7621 measures the temperature of two remote diode
connected transistors as well as its own die. Support for Platform
Environmental Control Interface (PECI) is included.
Using temperature information from these four zones, an automatic fan speed
control algorithm is employed to minimize acoustic impact while achieving
recommended CPU temperature under varying operational loads.
To set fan speed, the aSC7621 has three independent pulse width modulation
(PWM) outputs that are controlled by one, or a combination of three,
temperature zones. Both high- and low-frequency PWM ranges are supported.
The aSC7621 also includes a digital filter that can be invoked to smooth
temperature readings for better control of fan speed and minimum acoustic
impact.
The aSC7621 has tachometer inputs to measure fan speed on up to four fans.
Limit and status registers for all measured values are included to alert
the system host that any measurements are outside of programmed limits
via status registers.
System voltages of VCCP, 2.5V, 3.3V, 5.0V, and 12V motherboard power are
monitored efficiently with internal scaling resistors.
Features
- Supports PECI interface and monitors internal and remote thermal diodes
- 2-wire, SMBus 2.0 compliant, serial interface
- 10-bit ADC
- Monitors VCCP, 2.5V, 3.3V, 5.0V, and 12V motherboard/processor supplies
- Programmable autonomous fan control based on temperature readings
- Noise filtering of temperature reading for fan speed control
- 0.25C digital temperature sensor resolution
- 3 PWM fan speed control outputs for 2-, 3- or 4-wire fans and up to 4 fan
tachometer inputs
- Enhanced measured temperature to Temperature Zone assignment.
- Provides high and low PWM frequency ranges
- 3 GPIO pins for custom use
- 24-Lead QSOP package
Configuration Notes
===================
Except where noted below, the sysfs entries created by this driver follow
the standards defined in "sysfs-interface".
temp1_source
0 (default) peci_legacy = 0, Remote 1 Temperature
peci_legacy = 1, PECI Processor Temperature 0
1 Remote 1 Temperature
2 Remote 2 Temperature
3 Internal Temperature
4 PECI Processor Temperature 0
5 PECI Processor Temperature 1
6 PECI Processor Temperature 2
7 PECI Processor Temperature 3
temp2_source
0 (default) Internal Temperature
1 Remote 1 Temperature
2 Remote 2 Temperature
3 Internal Temperature
4 PECI Processor Temperature 0
5 PECI Processor Temperature 1
6 PECI Processor Temperature 2
7 PECI Processor Temperature 3
temp3_source
0 (default) Remote 2 Temperature
1 Remote 1 Temperature
2 Remote 2 Temperature
3 Internal Temperature
4 PECI Processor Temperature 0
5 PECI Processor Temperature 1
6 PECI Processor Temperature 2
7 PECI Processor Temperature 3
temp4_source
0 (default) peci_legacy = 0, PECI Processor Temperature 0
peci_legacy = 1, Remote 1 Temperature
1 Remote 1 Temperature
2 Remote 2 Temperature
3 Internal Temperature
4 PECI Processor Temperature 0
5 PECI Processor Temperature 1
6 PECI Processor Temperature 2
7 PECI Processor Temperature 3
temp[1-4]_smoothing_enable
temp[1-4]_smoothing_time
Smooths spikes in temp readings caused by noise.
Valid values in milliseconds are:
35000
17600
11800
7000
4400
3000
1600
800
temp[1-4]_crit
When the corresponding zone temperature reaches this value,
ALL pwm outputs will got to 100%.
temp[5-8]_input
temp[5-8]_enable
The aSC7621 can also read temperatures provided by the processor
via the PECI bus. Usually these are "core" temps and are relative
to the point where the automatic thermal control circuit starts
throttling. This means that these are usually negative numbers.
pwm[1-3]_enable
0 Fan off.
1 Fan on manual control.
2 Fan on automatic control and will run at the minimum pwm
if the temperature for the zone is below the minimum.
3 Fan on automatic control but will be off if the temperature
for the zone is below the minimum.
4-254 Ignored.
255 Fan on full.
pwm[1-3]_auto_channels
Bitmap as described in sysctl-interface with the following
exceptions...
Only the following combination of zones (and their corresponding masks)
are valid:
1
2
3
2,3
1,2,3
4
1,2,3,4
Special values:
0 Disabled.
16 Fan on manual control.
31 Fan on full.
pwm[1-3]_invert
When set, inverts the meaning of pwm[1-3].
i.e. when pwm = 0, the fan will be on full and
when pwm = 255 the fan will be off.
pwm[1-3]_freq
PWM frequency in Hz
Valid values in Hz are:
10
15
23
30 (default)
38
47
62
94
23000
24000
25000
26000
27000
28000
29000
30000
Setting any other value will be ignored.
peci_enable
Enables or disables PECI
peci_avg
Input filter average time.
0 0 Sec. (no Smoothing) (default)
1 0.25 Sec.
2 0.5 Sec.
3 1.0 Sec.
4 2.0 Sec.
5 4.0 Sec.
6 8.0 Sec.
7 0.0 Sec.
peci_legacy
0 Standard Mode (default)
Remote Diode 1 reading is associated with
Temperature Zone 1, PECI is associated with
Zone 4
1 Legacy Mode
PECI is associated with Temperature Zone 1,
Remote Diode 1 is associated with Zone 4
peci_diode
Diode filter
0 0.25 Sec.
1 1.1 Sec.
2 2.4 Sec. (default)
3 3.4 Sec.
4 5.0 Sec.
5 6.8 Sec.
6 10.2 Sec.
7 16.4 Sec.
peci_4domain
Four domain enable
0 1 or 2 Domains for enabled processors (default)
1 3 or 4 Domains for enabled processors
peci_domain
Domain
0 Processor contains a single domain (0) (default)
1 Processor contains two domains (0,1)
...@@ -5,31 +5,23 @@ Supported chips: ...@@ -5,31 +5,23 @@ Supported chips:
* IT8705F * IT8705F
Prefix: 'it87' Prefix: 'it87'
Addresses scanned: from Super I/O config space (8 I/O ports) Addresses scanned: from Super I/O config space (8 I/O ports)
Datasheet: Publicly available at the ITE website Datasheet: Once publicly available at the ITE website, but no longer
http://www.ite.com.tw/product_info/file/pc/IT8705F_V.0.4.1.pdf
* IT8712F * IT8712F
Prefix: 'it8712' Prefix: 'it8712'
Addresses scanned: from Super I/O config space (8 I/O ports) Addresses scanned: from Super I/O config space (8 I/O ports)
Datasheet: Publicly available at the ITE website Datasheet: Once publicly available at the ITE website, but no longer
http://www.ite.com.tw/product_info/file/pc/IT8712F_V0.9.1.pdf
http://www.ite.com.tw/product_info/file/pc/Errata%20V0.1%20for%20IT8712F%20V0.9.1.pdf
http://www.ite.com.tw/product_info/file/pc/IT8712F_V0.9.3.pdf
* IT8716F/IT8726F * IT8716F/IT8726F
Prefix: 'it8716' Prefix: 'it8716'
Addresses scanned: from Super I/O config space (8 I/O ports) Addresses scanned: from Super I/O config space (8 I/O ports)
Datasheet: Publicly available at the ITE website Datasheet: Once publicly available at the ITE website, but no longer
http://www.ite.com.tw/product_info/file/pc/IT8716F_V0.3.ZIP
http://www.ite.com.tw/product_info/file/pc/IT8726F_V0.3.pdf
* IT8718F * IT8718F
Prefix: 'it8718' Prefix: 'it8718'
Addresses scanned: from Super I/O config space (8 I/O ports) Addresses scanned: from Super I/O config space (8 I/O ports)
Datasheet: Publicly available at the ITE website Datasheet: Once publicly available at the ITE website, but no longer
http://www.ite.com.tw/product_info/file/pc/IT8718F_V0.2.zip
http://www.ite.com.tw/product_info/file/pc/IT8718F_V0%203_(for%20C%20version).zip
* IT8720F * IT8720F
Prefix: 'it8720' Prefix: 'it8720'
Addresses scanned: from Super I/O config space (8 I/O ports) Addresses scanned: from Super I/O config space (8 I/O ports)
Datasheet: Not yet publicly available. Datasheet: Not publicly available
* SiS950 [clone of IT8705F] * SiS950 [clone of IT8705F]
Prefix: 'it87' Prefix: 'it87'
Addresses scanned: from Super I/O config space (8 I/O ports) Addresses scanned: from Super I/O config space (8 I/O ports)
...@@ -136,6 +128,10 @@ registers are read whenever any data is read (unless it is less than 1.5 ...@@ -136,6 +128,10 @@ registers are read whenever any data is read (unless it is less than 1.5
seconds since the last update). This means that you can easily miss seconds since the last update). This means that you can easily miss
once-only alarms. once-only alarms.
Out-of-limit readings can also result in beeping, if the chip is properly
wired and configured. Beeping can be enabled or disabled per sensor type
(temperatures, voltages and fans.)
The IT87xx only updates its values each 1.5 seconds; reading it more often The IT87xx only updates its values each 1.5 seconds; reading it more often
will do no harm, but will return 'old' values. will do no harm, but will return 'old' values.
...@@ -150,11 +146,38 @@ Fan speed control ...@@ -150,11 +146,38 @@ Fan speed control
----------------- -----------------
The fan speed control features are limited to manual PWM mode. Automatic The fan speed control features are limited to manual PWM mode. Automatic
"Smart Guardian" mode control handling is not implemented. However "Smart Guardian" mode control handling is only implemented for older chips
if you want to go for "manual mode" just write 1 to pwmN_enable. (see below.) However if you want to go for "manual mode" just write 1 to
pwmN_enable.
If you are only able to control the fan speed with very small PWM values, If you are only able to control the fan speed with very small PWM values,
try lowering the PWM base frequency (pwm1_freq). Depending on the fan, try lowering the PWM base frequency (pwm1_freq). Depending on the fan,
it may give you a somewhat greater control range. The same frequency is it may give you a somewhat greater control range. The same frequency is
used to drive all fan outputs, which is why pwm2_freq and pwm3_freq are used to drive all fan outputs, which is why pwm2_freq and pwm3_freq are
read-only. read-only.
Automatic fan speed control (old interface)
-------------------------------------------
The driver supports the old interface to automatic fan speed control
which is implemented by IT8705F chips up to revision F and IT8712F
chips up to revision G.
This interface implements 4 temperature vs. PWM output trip points.
The PWM output of trip point 4 is always the maximum value (fan running
at full speed) while the PWM output of the other 3 trip points can be
freely chosen. The temperature of all 4 trip points can be freely chosen.
Additionally, trip point 1 has an hysteresis temperature attached, to
prevent fast switching between fan on and off.
The chip automatically computes the PWM output value based on the input
temperature, based on this simple rule: if the temperature value is
between trip point N and trip point N+1 then the PWM output value is
the one of trip point N. The automatic control mode is less flexible
than the manual control mode, but it reacts faster, is more robust and
doesn't use CPU cycles.
Trip points must be set properly before switching to automatic fan speed
control mode. The driver will perform basic integrity checks before
actually switching to automatic control mode.
...@@ -84,6 +84,10 @@ Supported chips: ...@@ -84,6 +84,10 @@ Supported chips:
Addresses scanned: I2C 0x4c Addresses scanned: I2C 0x4c
Datasheet: Publicly available at the Maxim website Datasheet: Publicly available at the Maxim website
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500
* Winbond/Nuvoton W83L771AWG/ASG
Prefix: 'w83l771'
Addresses scanned: I2C 0x4c
Datasheet: Not publicly available, can be requested from Nuvoton
Author: Jean Delvare <khali@linux-fr.org> Author: Jean Delvare <khali@linux-fr.org>
...@@ -147,6 +151,12 @@ MAX6680 and MAX6681: ...@@ -147,6 +151,12 @@ MAX6680 and MAX6681:
* Selectable address * Selectable address
* Remote sensor type selection * Remote sensor type selection
W83L771AWG/ASG
* The AWG and ASG variants only differ in package format.
* Filter and alert configuration register at 0xBF
* Diode ideality factor configuration (remote sensor) at 0xE3
* Moving average (depending on conversion rate)
All temperature values are given in degrees Celsius. Resolution All temperature values are given in degrees Celsius. Resolution
is 1.0 degree for the local temperature, 0.125 degree for the remote is 1.0 degree for the local temperature, 0.125 degree for the remote
temperature, except for the MAX6657, MAX6658 and MAX6659 which have a temperature, except for the MAX6657, MAX6658 and MAX6659 which have a
...@@ -163,6 +173,18 @@ The lm90 driver will not update its values more frequently than every ...@@ -163,6 +173,18 @@ The lm90 driver will not update its values more frequently than every
other second; reading them more often will do no harm, but will return other second; reading them more often will do no harm, but will return
'old' values. 'old' values.
SMBus Alert Support
-------------------
This driver has basic support for SMBus alert. When an alert is received,
the status register is read and the faulty temperature channel is logged.
The Analog Devices chips (ADM1032 and ADT7461) do not implement the SMBus
alert protocol properly so additional care is needed: the ALERT output is
disabled when an alert is received, and is re-enabled only when the alarm
is gone. Otherwise the chip would block alerts from other chips in the bus
as long as the alarm is active.
PEC Support PEC Support
----------- -----------
......
...@@ -968,6 +968,13 @@ W: http://www.arm.linux.org.uk/ ...@@ -968,6 +968,13 @@ W: http://www.arm.linux.org.uk/
S: Maintained S: Maintained
F: arch/arm/vfp/ F: arch/arm/vfp/
ASC7621 HARDWARE MONITOR DRIVER
M: George Joseph <george.joseph@fairview5.com>
L: lm-sensors@lm-sensors.org
S: Maintained
F: Documentation/hwmon/asc7621
F: drivers/hwmon/asc7621.c
ASUS ACPI EXTRAS DRIVER ASUS ACPI EXTRAS DRIVER
M: Corentin Chary <corentincj@iksaif.net> M: Corentin Chary <corentincj@iksaif.net>
M: Karol Kozimor <sziwan@users.sourceforge.net> M: Karol Kozimor <sziwan@users.sourceforge.net>
...@@ -3048,6 +3055,13 @@ W: http://www.melware.de ...@@ -3048,6 +3055,13 @@ W: http://www.melware.de
S: Maintained S: Maintained
F: drivers/isdn/hardware/eicon/ F: drivers/isdn/hardware/eicon/
IT87 HARDWARE MONITORING DRIVER
M: Jean Delvare <khali@linux-fr.org>
L: lm-sensors@lm-sensors.org
S: Maintained
F: Documentation/hwmon/it87
F: drivers/hwmon/it87.c
IVTV VIDEO4LINUX DRIVER IVTV VIDEO4LINUX DRIVER
M: Andy Walls <awalls@radix.net> M: Andy Walls <awalls@radix.net>
L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers) L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers)
......
...@@ -170,6 +170,16 @@ config SENSORS_ADM9240 ...@@ -170,6 +170,16 @@ config SENSORS_ADM9240
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called adm9240. 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 config SENSORS_ADT7462
tristate "Analog Devices ADT7462" tristate "Analog Devices ADT7462"
depends on I2C && EXPERIMENTAL depends on I2C && EXPERIMENTAL
...@@ -190,20 +200,6 @@ config SENSORS_ADT7470 ...@@ -190,20 +200,6 @@ config SENSORS_ADT7470
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called adt7470. 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 config SENSORS_ADT7475
tristate "Analog Devices ADT7473, ADT7475, ADT7476 and ADT7490" tristate "Analog Devices ADT7473, ADT7475, ADT7476 and ADT7490"
depends on I2C && EXPERIMENTAL depends on I2C && EXPERIMENTAL
...@@ -216,6 +212,19 @@ config SENSORS_ADT7475 ...@@ -216,6 +212,19 @@ config SENSORS_ADT7475
This driver can also be build as a module. If so, the module This driver can also be build as a module. If so, the module
will be called adt7475. 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 config SENSORS_K8TEMP
tristate "AMD Athlon64/FX or Opteron temperature sensor" tristate "AMD Athlon64/FX or Opteron temperature sensor"
depends on X86 && PCI && EXPERIMENTAL depends on X86 && PCI && EXPERIMENTAL
...@@ -563,9 +572,10 @@ config SENSORS_LM90 ...@@ -563,9 +572,10 @@ config SENSORS_LM90
depends on I2C depends on I2C
help help
If you say yes here you get support for National Semiconductor LM90, 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, 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 This driver can also be built as a module. If so, the module
will be called lm90. will be called lm90.
...@@ -909,7 +919,8 @@ config SENSORS_W83793 ...@@ -909,7 +919,8 @@ config SENSORS_W83793
select HWMON_VID select HWMON_VID
help help
If you say yes here you get support for the Winbond W83793 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 This driver can also be built as a module. If so, the module
will be called w83793. will be called w83793.
......
...@@ -29,12 +29,13 @@ obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o ...@@ -29,12 +29,13 @@ obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o
obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o
obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o
obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o
obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o
obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o
obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o
obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_AMS) += ams/
obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o
obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o
obj-$(CONFIG_SENSORS_DME1737) += dme1737.o obj-$(CONFIG_SENSORS_DME1737) += dme1737.o
......
/*
* 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");
此差异已折叠。
此差异已折叠。
...@@ -267,7 +267,7 @@ struct fschmd_data { ...@@ -267,7 +267,7 @@ struct fschmd_data {
struct list_head list; /* member of the watchdog_data_list */ struct list_head list; /* member of the watchdog_data_list */
struct kref kref; struct kref kref;
struct miscdevice watchdog_miscdev; struct miscdevice watchdog_miscdev;
int kind; enum chips kind;
unsigned long watchdog_is_open; unsigned long watchdog_is_open;
char watchdog_expect_close; char watchdog_expect_close;
char watchdog_name[10]; /* must be unique to avoid sysfs conflict */ char watchdog_name[10]; /* must be unique to avoid sysfs conflict */
...@@ -325,8 +325,7 @@ static ssize_t show_in_value(struct device *dev, ...@@ -325,8 +325,7 @@ static ssize_t show_in_value(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct fschmd_data *data = fschmd_update_device(dev); 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 || data->kind >= fschrc)
if (data->kind == (fscher - 1) || data->kind >= (fschrc - 1))
return sprintf(buf, "%d\n", (data->volt[index] * dmi_vref * return sprintf(buf, "%d\n", (data->volt[index] * dmi_vref *
dmi_mult[index]) / 255 + dmi_offset[index]); dmi_mult[index]) / 255 + dmi_offset[index]);
else else
...@@ -492,7 +491,7 @@ static ssize_t show_pwm_auto_point1_pwm(struct device *dev, ...@@ -492,7 +491,7 @@ static ssize_t show_pwm_auto_point1_pwm(struct device *dev,
int val = data->fan_min[index]; int val = data->fan_min[index];
/* 0 = allow turning off (except on the syl), 1-255 = 50-100% */ /* 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; val = val / 2 + 128;
return sprintf(buf, "%d\n", val); return sprintf(buf, "%d\n", val);
...@@ -506,7 +505,7 @@ static ssize_t store_pwm_auto_point1_pwm(struct device *dev, ...@@ -506,7 +505,7 @@ static ssize_t store_pwm_auto_point1_pwm(struct device *dev,
unsigned long v = simple_strtoul(buf, NULL, 10); unsigned long v = simple_strtoul(buf, NULL, 10);
/* reg: 0 = allow turning off (except on the syl), 1-255 = 50-100% */ /* 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 = SENSORS_LIMIT(v, 128, 255);
v = (v - 128) * 2 + 1; v = (v - 128) * 2 + 1;
} }
...@@ -1037,7 +1036,7 @@ static int fschmd_detect(struct i2c_client *client, ...@@ -1037,7 +1036,7 @@ static int fschmd_detect(struct i2c_client *client,
else else
return -ENODEV; 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; return 0;
} }
...@@ -1065,6 +1064,7 @@ static int fschmd_probe(struct i2c_client *client, ...@@ -1065,6 +1064,7 @@ static int fschmd_probe(struct i2c_client *client,
(where the client is found through a data ptr instead of the (where the client is found through a data ptr instead of the
otherway around) */ otherway around) */
data->client = client; data->client = client;
data->kind = kind;
if (kind == fscpos) { if (kind == fscpos) {
/* The Poseidon has hardwired temp limits, fill these /* The Poseidon has hardwired temp limits, fill these
...@@ -1085,9 +1085,6 @@ static int fschmd_probe(struct i2c_client *client, ...@@ -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 */ /* Read in some never changing registers */
data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION); data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION);
data->global_control = i2c_smbus_read_byte_data(client, data->global_control = i2c_smbus_read_byte_data(client,
......
...@@ -68,7 +68,7 @@ struct g760a_data { ...@@ -68,7 +68,7 @@ struct g760a_data {
#define PWM_FROM_CNT(cnt) (0xff-(cnt)) #define PWM_FROM_CNT(cnt) (0xff-(cnt))
#define PWM_TO_CNT(pwm) (0xff-(pwm)) #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))); return ((val == 0x00) ? 0 : ((clk*30)/(val*div)));
} }
......
此差异已折叠。
此差异已折叠。
...@@ -134,7 +134,7 @@ struct tmp401_data { ...@@ -134,7 +134,7 @@ struct tmp401_data {
struct mutex update_lock; struct mutex update_lock;
char valid; /* zero until following fields are valid */ char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */ unsigned long last_updated; /* in jiffies */
int kind; enum chips kind;
/* register values */ /* register values */
u8 status; u8 status;
...@@ -524,7 +524,7 @@ static int tmp401_detect(struct i2c_client *client, ...@@ -524,7 +524,7 @@ static int tmp401_detect(struct i2c_client *client,
if (reg > 15) if (reg > 15)
return -ENODEV; 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; return 0;
} }
...@@ -572,8 +572,7 @@ static int tmp401_probe(struct i2c_client *client, ...@@ -572,8 +572,7 @@ static int tmp401_probe(struct i2c_client *client,
goto exit_remove; goto exit_remove;
} }
dev_info(&client->dev, "Detected TI %s chip\n", dev_info(&client->dev, "Detected TI %s chip\n", names[data->kind]);
names[data->kind - 1]);
return 0; return 0;
......
...@@ -61,9 +61,9 @@ static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 }; ...@@ -61,9 +61,9 @@ static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 };
#define TMP423_DEVICE_ID 0x23 #define TMP423_DEVICE_ID 0x23
static const struct i2c_device_id tmp421_id[] = { static const struct i2c_device_id tmp421_id[] = {
{ "tmp421", tmp421 }, { "tmp421", 2 },
{ "tmp422", tmp422 }, { "tmp422", 3 },
{ "tmp423", tmp423 }, { "tmp423", 4 },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, tmp421_id); MODULE_DEVICE_TABLE(i2c, tmp421_id);
...@@ -73,21 +73,23 @@ struct tmp421_data { ...@@ -73,21 +73,23 @@ struct tmp421_data {
struct mutex update_lock; struct mutex update_lock;
char valid; char valid;
unsigned long last_updated; unsigned long last_updated;
int kind; int channels;
u8 config; u8 config;
s16 temp[4]; s16 temp[4];
}; };
static int temp_from_s16(s16 reg) static int temp_from_s16(s16 reg)
{ {
int temp = reg; /* Mask out status bits */
int temp = reg & ~0xf;
return (temp * 1000 + 128) / 256; return (temp * 1000 + 128) / 256;
} }
static int temp_from_u16(u16 reg) static int temp_from_u16(u16 reg)
{ {
int temp = reg; /* Mask out status bits */
int temp = reg & ~0xf;
/* Add offset for extended temperature range. */ /* Add offset for extended temperature range. */
temp -= 64 * 256; temp -= 64 * 256;
...@@ -107,7 +109,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev) ...@@ -107,7 +109,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev)
data->config = i2c_smbus_read_byte_data(client, data->config = i2c_smbus_read_byte_data(client,
TMP421_CONFIG_REG_1); 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, data->temp[i] = i2c_smbus_read_byte_data(client,
TMP421_TEMP_MSB[i]) << 8; TMP421_TEMP_MSB[i]) << 8;
data->temp[i] |= i2c_smbus_read_byte_data(client, 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, ...@@ -166,7 +168,7 @@ static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a,
devattr = container_of(a, struct device_attribute, attr); devattr = container_of(a, struct device_attribute, attr);
index = to_sensor_dev_attr(devattr)->index; index = to_sensor_dev_attr(devattr)->index;
if (data->kind > index) if (index < data->channels)
return a->mode; return a->mode;
return 0; return 0;
...@@ -252,9 +254,9 @@ static int tmp421_detect(struct i2c_client *client, ...@@ -252,9 +254,9 @@ static int tmp421_detect(struct i2c_client *client,
return -ENODEV; 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", dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
names[kind - 1], client->addr); names[kind], client->addr);
return 0; return 0;
} }
...@@ -271,7 +273,7 @@ static int tmp421_probe(struct i2c_client *client, ...@@ -271,7 +273,7 @@ static int tmp421_probe(struct i2c_client *client,
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
data->kind = id->driver_data; data->channels = id->driver_data;
err = tmp421_init_client(client); err = tmp421_init_client(client);
if (err) if (err)
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册