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:
commit
dff6d1c5ef
|
@ -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
|
||||
When: March 2010
|
||||
Why: These two features use non-standard interfaces. There are the
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
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.
|
|
@ -1,74 +0,0 @@
|
|||
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.
|
|
@ -0,0 +1,296 @@
|
|||
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:
|
|||
* IT8705F
|
||||
Prefix: 'it87'
|
||||
Addresses scanned: from Super I/O config space (8 I/O ports)
|
||||
Datasheet: Publicly available at the ITE website
|
||||
http://www.ite.com.tw/product_info/file/pc/IT8705F_V.0.4.1.pdf
|
||||
Datasheet: Once publicly available at the ITE website, but no longer
|
||||
* IT8712F
|
||||
Prefix: 'it8712'
|
||||
Addresses scanned: from Super I/O config space (8 I/O ports)
|
||||
Datasheet: Publicly available at the ITE website
|
||||
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
|
||||
Datasheet: Once publicly available at the ITE website, but no longer
|
||||
* IT8716F/IT8726F
|
||||
Prefix: 'it8716'
|
||||
Addresses scanned: from Super I/O config space (8 I/O ports)
|
||||
Datasheet: Publicly available at the ITE website
|
||||
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
|
||||
Datasheet: Once publicly available at the ITE website, but no longer
|
||||
* IT8718F
|
||||
Prefix: 'it8718'
|
||||
Addresses scanned: from Super I/O config space (8 I/O ports)
|
||||
Datasheet: Publicly available at the ITE website
|
||||
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
|
||||
Datasheet: Once publicly available at the ITE website, but no longer
|
||||
* IT8720F
|
||||
Prefix: 'it8720'
|
||||
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]
|
||||
Prefix: 'it87'
|
||||
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
|
|||
seconds since the last update). This means that you can easily miss
|
||||
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
|
||||
will do no harm, but will return 'old' values.
|
||||
|
||||
|
@ -150,11 +146,38 @@ Fan speed control
|
|||
-----------------
|
||||
|
||||
The fan speed control features are limited to manual PWM mode. Automatic
|
||||
"Smart Guardian" mode control handling is not implemented. However
|
||||
if you want to go for "manual mode" just write 1 to pwmN_enable.
|
||||
"Smart Guardian" mode control handling is only implemented for older chips
|
||||
(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,
|
||||
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
|
||||
used to drive all fan outputs, which is why pwm2_freq and pwm3_freq are
|
||||
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:
|
|||
Addresses scanned: I2C 0x4c
|
||||
Datasheet: Publicly available at the Maxim website
|
||||
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>
|
||||
|
@ -147,6 +151,12 @@ MAX6680 and MAX6681:
|
|||
* Selectable address
|
||||
* 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
|
||||
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
|
||||
|
@ -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
|
||||
'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
|
||||
-----------
|
||||
|
||||
|
|
14
MAINTAINERS
14
MAINTAINERS
|
@ -968,6 +968,13 @@ W: http://www.arm.linux.org.uk/
|
|||
S: Maintained
|
||||
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
|
||||
M: Corentin Chary <corentincj@iksaif.net>
|
||||
M: Karol Kozimor <sziwan@users.sourceforge.net>
|
||||
|
@ -3048,6 +3055,13 @@ W: http://www.melware.de
|
|||
S: Maintained
|
||||
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
|
||||
M: Andy Walls <awalls@radix.net>
|
||||
L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers)
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
Copyright (C) 2006 Winbond Electronics Corp.
|
||||
Yuan Mu
|
||||
Rudolf Marek <r.marek@assembler.cz>
|
||||
Copyright (C) 2009-2010 Sven Anders <anders@anduras.de>, ANDURAS AG.
|
||||
Watchdog driver part
|
||||
(Based partially on fschmd driver,
|
||||
Copyright 2007-2008 by Hans de Goede)
|
||||
|
||||
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
|
||||
|
@ -35,6 +39,16 @@
|
|||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/watchdog.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/reboot.h>
|
||||
|
||||
/* Default values */
|
||||
#define WATCHDOG_TIMEOUT 2 /* 2 minute default timeout */
|
||||
|
||||
/* Addresses to scan */
|
||||
static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
|
@ -51,6 +65,18 @@ static int reset;
|
|||
module_param(reset, bool, 0);
|
||||
MODULE_PARM_DESC(reset, "Set to 1 to reset chip, not recommended");
|
||||
|
||||
static int timeout = WATCHDOG_TIMEOUT; /* default timeout in minutes */
|
||||
module_param(timeout, int, 0);
|
||||
MODULE_PARM_DESC(timeout,
|
||||
"Watchdog timeout in minutes. 2<= timeout <=255 (default="
|
||||
__MODULE_STRING(WATCHDOG_TIMEOUT) ")");
|
||||
|
||||
static int nowayout = WATCHDOG_NOWAYOUT;
|
||||
module_param(nowayout, int, 0);
|
||||
MODULE_PARM_DESC(nowayout,
|
||||
"Watchdog cannot be stopped once started (default="
|
||||
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
||||
|
||||
/*
|
||||
Address 0x00, 0x0d, 0x0e, 0x0f in all three banks are reserved
|
||||
as ID, Bank Select registers
|
||||
|
@ -72,6 +98,11 @@ MODULE_PARM_DESC(reset, "Set to 1 to reset chip, not recommended");
|
|||
#define W83793_REG_VID_LATCHB 0x08
|
||||
#define W83793_REG_VID_CTRL 0x59
|
||||
|
||||
#define W83793_REG_WDT_LOCK 0x01
|
||||
#define W83793_REG_WDT_ENABLE 0x02
|
||||
#define W83793_REG_WDT_STATUS 0x03
|
||||
#define W83793_REG_WDT_TIMEOUT 0x04
|
||||
|
||||
static u16 W83793_REG_TEMP_MODE[2] = { 0x5e, 0x5f };
|
||||
|
||||
#define TEMP_READ 0
|
||||
|
@ -223,8 +254,37 @@ struct w83793_data {
|
|||
u8 tolerance[3]; /* Temp tolerance(Smart Fan I/II) */
|
||||
u8 sf2_pwm[6][7]; /* Smart FanII: Fan duty cycle */
|
||||
u8 sf2_temp[6][7]; /* Smart FanII: Temp level point */
|
||||
|
||||
/* watchdog */
|
||||
struct i2c_client *client;
|
||||
struct mutex watchdog_lock;
|
||||
struct list_head list; /* member of the watchdog_data_list */
|
||||
struct kref kref;
|
||||
struct miscdevice watchdog_miscdev;
|
||||
unsigned long watchdog_is_open;
|
||||
char watchdog_expect_close;
|
||||
char watchdog_name[10]; /* must be unique to avoid sysfs conflict */
|
||||
unsigned int watchdog_caused_reboot;
|
||||
int watchdog_timeout; /* watchdog timeout in minutes */
|
||||
};
|
||||
|
||||
/* Somewhat ugly :( global data pointer list with all devices, so that
|
||||
we can find our device data as when using misc_register. There is no
|
||||
other method to get to one's device data from the open file-op and
|
||||
for usage in the reboot notifier callback. */
|
||||
static LIST_HEAD(watchdog_data_list);
|
||||
|
||||
/* Note this lock not only protect list access, but also data.kref access */
|
||||
static DEFINE_MUTEX(watchdog_data_mutex);
|
||||
|
||||
/* Release our data struct when we're detached from the i2c client *and* all
|
||||
references to our watchdog device are released */
|
||||
static void w83793_release_resources(struct kref *ref)
|
||||
{
|
||||
struct w83793_data *data = container_of(ref, struct w83793_data, kref);
|
||||
kfree(data);
|
||||
}
|
||||
|
||||
static u8 w83793_read_value(struct i2c_client *client, u16 reg);
|
||||
static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value);
|
||||
static int w83793_probe(struct i2c_client *client,
|
||||
|
@ -1063,14 +1123,349 @@ static void w83793_init_client(struct i2c_client *client)
|
|||
/* Start monitoring */
|
||||
w83793_write_value(client, W83793_REG_CONFIG,
|
||||
w83793_read_value(client, W83793_REG_CONFIG) | 0x01);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Watchdog routines
|
||||
*/
|
||||
|
||||
static int watchdog_set_timeout(struct w83793_data *data, int timeout)
|
||||
{
|
||||
int ret, mtimeout;
|
||||
|
||||
mtimeout = DIV_ROUND_UP(timeout, 60);
|
||||
|
||||
if (mtimeout > 255)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&data->watchdog_lock);
|
||||
if (!data->client) {
|
||||
ret = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
data->watchdog_timeout = mtimeout;
|
||||
|
||||
/* Set Timeout value (in Minutes) */
|
||||
w83793_write_value(data->client, W83793_REG_WDT_TIMEOUT,
|
||||
data->watchdog_timeout);
|
||||
|
||||
ret = mtimeout * 60;
|
||||
|
||||
leave:
|
||||
mutex_unlock(&data->watchdog_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int watchdog_get_timeout(struct w83793_data *data)
|
||||
{
|
||||
int timeout;
|
||||
|
||||
mutex_lock(&data->watchdog_lock);
|
||||
timeout = data->watchdog_timeout * 60;
|
||||
mutex_unlock(&data->watchdog_lock);
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
static int watchdog_trigger(struct w83793_data *data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&data->watchdog_lock);
|
||||
if (!data->client) {
|
||||
ret = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* Set Timeout value (in Minutes) */
|
||||
w83793_write_value(data->client, W83793_REG_WDT_TIMEOUT,
|
||||
data->watchdog_timeout);
|
||||
|
||||
leave:
|
||||
mutex_unlock(&data->watchdog_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int watchdog_enable(struct w83793_data *data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&data->watchdog_lock);
|
||||
if (!data->client) {
|
||||
ret = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* Set initial timeout */
|
||||
w83793_write_value(data->client, W83793_REG_WDT_TIMEOUT,
|
||||
data->watchdog_timeout);
|
||||
|
||||
/* Enable Soft Watchdog */
|
||||
w83793_write_value(data->client, W83793_REG_WDT_LOCK, 0x55);
|
||||
|
||||
leave:
|
||||
mutex_unlock(&data->watchdog_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int watchdog_disable(struct w83793_data *data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&data->watchdog_lock);
|
||||
if (!data->client) {
|
||||
ret = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* Disable Soft Watchdog */
|
||||
w83793_write_value(data->client, W83793_REG_WDT_LOCK, 0xAA);
|
||||
|
||||
leave:
|
||||
mutex_unlock(&data->watchdog_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int watchdog_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
struct w83793_data *pos, *data = NULL;
|
||||
int watchdog_is_open;
|
||||
|
||||
/* We get called from drivers/char/misc.c with misc_mtx hold, and we
|
||||
call misc_register() from w83793_probe() with watchdog_data_mutex
|
||||
hold, as misc_register() takes the misc_mtx lock, this is a possible
|
||||
deadlock, so we use mutex_trylock here. */
|
||||
if (!mutex_trylock(&watchdog_data_mutex))
|
||||
return -ERESTARTSYS;
|
||||
list_for_each_entry(pos, &watchdog_data_list, list) {
|
||||
if (pos->watchdog_miscdev.minor == iminor(inode)) {
|
||||
data = pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check, if device is already open */
|
||||
watchdog_is_open = test_and_set_bit(0, &data->watchdog_is_open);
|
||||
|
||||
/* Increase data reference counter (if not already done).
|
||||
Note we can never not have found data, so we don't check for this */
|
||||
if (!watchdog_is_open)
|
||||
kref_get(&data->kref);
|
||||
|
||||
mutex_unlock(&watchdog_data_mutex);
|
||||
|
||||
/* Check, if device is already open and possibly issue error */
|
||||
if (watchdog_is_open)
|
||||
return -EBUSY;
|
||||
|
||||
/* Enable Soft Watchdog */
|
||||
watchdog_enable(data);
|
||||
|
||||
/* Store pointer to data into filp's private data */
|
||||
filp->private_data = data;
|
||||
|
||||
return nonseekable_open(inode, filp);
|
||||
}
|
||||
|
||||
static int watchdog_close(struct inode *inode, struct file *filp)
|
||||
{
|
||||
struct w83793_data *data = filp->private_data;
|
||||
|
||||
if (data->watchdog_expect_close) {
|
||||
watchdog_disable(data);
|
||||
data->watchdog_expect_close = 0;
|
||||
} else {
|
||||
watchdog_trigger(data);
|
||||
dev_crit(&data->client->dev,
|
||||
"unexpected close, not stopping watchdog!\n");
|
||||
}
|
||||
|
||||
clear_bit(0, &data->watchdog_is_open);
|
||||
|
||||
/* Decrease data reference counter */
|
||||
mutex_lock(&watchdog_data_mutex);
|
||||
kref_put(&data->kref, w83793_release_resources);
|
||||
mutex_unlock(&watchdog_data_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t watchdog_write(struct file *filp, const char __user *buf,
|
||||
size_t count, loff_t *offset)
|
||||
{
|
||||
size_t ret;
|
||||
struct w83793_data *data = filp->private_data;
|
||||
|
||||
if (count) {
|
||||
if (!nowayout) {
|
||||
size_t i;
|
||||
|
||||
/* Clear it in case it was set with a previous write */
|
||||
data->watchdog_expect_close = 0;
|
||||
|
||||
for (i = 0; i != count; i++) {
|
||||
char c;
|
||||
if (get_user(c, buf + i))
|
||||
return -EFAULT;
|
||||
if (c == 'V')
|
||||
data->watchdog_expect_close = 1;
|
||||
}
|
||||
}
|
||||
ret = watchdog_trigger(data);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static int watchdog_ioctl(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
static struct watchdog_info ident = {
|
||||
.options = WDIOF_KEEPALIVEPING |
|
||||
WDIOF_SETTIMEOUT |
|
||||
WDIOF_CARDRESET,
|
||||
.identity = "w83793 watchdog"
|
||||
};
|
||||
|
||||
int val, ret = 0;
|
||||
struct w83793_data *data = filp->private_data;
|
||||
|
||||
switch (cmd) {
|
||||
case WDIOC_GETSUPPORT:
|
||||
if (!nowayout)
|
||||
ident.options |= WDIOF_MAGICCLOSE;
|
||||
if (copy_to_user((void __user *)arg, &ident, sizeof(ident)))
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
|
||||
case WDIOC_GETSTATUS:
|
||||
val = data->watchdog_caused_reboot ? WDIOF_CARDRESET : 0;
|
||||
ret = put_user(val, (int __user *)arg);
|
||||
break;
|
||||
|
||||
case WDIOC_GETBOOTSTATUS:
|
||||
ret = put_user(0, (int __user *)arg);
|
||||
break;
|
||||
|
||||
case WDIOC_KEEPALIVE:
|
||||
ret = watchdog_trigger(data);
|
||||
break;
|
||||
|
||||
case WDIOC_GETTIMEOUT:
|
||||
val = watchdog_get_timeout(data);
|
||||
ret = put_user(val, (int __user *)arg);
|
||||
break;
|
||||
|
||||
case WDIOC_SETTIMEOUT:
|
||||
if (get_user(val, (int __user *)arg)) {
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
ret = watchdog_set_timeout(data, val);
|
||||
if (ret > 0)
|
||||
ret = put_user(ret, (int __user *)arg);
|
||||
break;
|
||||
|
||||
case WDIOC_SETOPTIONS:
|
||||
if (get_user(val, (int __user *)arg)) {
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (val & WDIOS_DISABLECARD)
|
||||
ret = watchdog_disable(data);
|
||||
else if (val & WDIOS_ENABLECARD)
|
||||
ret = watchdog_enable(data);
|
||||
else
|
||||
ret = -EINVAL;
|
||||
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct file_operations watchdog_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.llseek = no_llseek,
|
||||
.open = watchdog_open,
|
||||
.release = watchdog_close,
|
||||
.write = watchdog_write,
|
||||
.ioctl = watchdog_ioctl,
|
||||
};
|
||||
|
||||
/*
|
||||
* Notifier for system down
|
||||
*/
|
||||
|
||||
static int watchdog_notify_sys(struct notifier_block *this, unsigned long code,
|
||||
void *unused)
|
||||
{
|
||||
struct w83793_data *data = NULL;
|
||||
|
||||
if (code == SYS_DOWN || code == SYS_HALT) {
|
||||
|
||||
/* Disable each registered watchdog */
|
||||
mutex_lock(&watchdog_data_mutex);
|
||||
list_for_each_entry(data, &watchdog_data_list, list) {
|
||||
if (data->watchdog_miscdev.minor)
|
||||
watchdog_disable(data);
|
||||
}
|
||||
mutex_unlock(&watchdog_data_mutex);
|
||||
}
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* The WDT needs to learn about soft shutdowns in order to
|
||||
* turn the timebomb registers off.
|
||||
*/
|
||||
|
||||
static struct notifier_block watchdog_notifier = {
|
||||
.notifier_call = watchdog_notify_sys,
|
||||
};
|
||||
|
||||
/*
|
||||
* Init / remove routines
|
||||
*/
|
||||
|
||||
static int w83793_remove(struct i2c_client *client)
|
||||
{
|
||||
struct w83793_data *data = i2c_get_clientdata(client);
|
||||
struct device *dev = &client->dev;
|
||||
int i;
|
||||
int i, tmp;
|
||||
|
||||
/* Unregister the watchdog (if registered) */
|
||||
if (data->watchdog_miscdev.minor) {
|
||||
misc_deregister(&data->watchdog_miscdev);
|
||||
|
||||
if (data->watchdog_is_open) {
|
||||
dev_warn(&client->dev,
|
||||
"i2c client detached with watchdog open! "
|
||||
"Stopping watchdog.\n");
|
||||
watchdog_disable(data);
|
||||
}
|
||||
|
||||
mutex_lock(&watchdog_data_mutex);
|
||||
list_del(&data->list);
|
||||
mutex_unlock(&watchdog_data_mutex);
|
||||
|
||||
/* Tell the watchdog code the client is gone */
|
||||
mutex_lock(&data->watchdog_lock);
|
||||
data->client = NULL;
|
||||
mutex_unlock(&data->watchdog_lock);
|
||||
}
|
||||
|
||||
/* Reset Configuration Register to Disable Watch Dog Registers */
|
||||
tmp = w83793_read_value(client, W83793_REG_CONFIG);
|
||||
w83793_write_value(client, W83793_REG_CONFIG, tmp & ~0x04);
|
||||
|
||||
unregister_reboot_notifier(&watchdog_notifier);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
|
||||
|
@ -1099,7 +1494,10 @@ static int w83793_remove(struct i2c_client *client)
|
|||
if (data->lm75[1] != NULL)
|
||||
i2c_unregister_device(data->lm75[1]);
|
||||
|
||||
kfree(data);
|
||||
/* Decrease data reference counter */
|
||||
mutex_lock(&watchdog_data_mutex);
|
||||
kref_put(&data->kref, w83793_release_resources);
|
||||
mutex_unlock(&watchdog_data_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1203,6 +1601,7 @@ static int w83793_probe(struct i2c_client *client,
|
|||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
const int watchdog_minors[] = { WATCHDOG_MINOR, 212, 213, 214, 215 };
|
||||
struct w83793_data *data;
|
||||
int i, tmp, val, err;
|
||||
int files_fan = ARRAY_SIZE(w83793_left_fan) / 7;
|
||||
|
@ -1218,6 +1617,14 @@ static int w83793_probe(struct i2c_client *client,
|
|||
i2c_set_clientdata(client, data);
|
||||
data->bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL);
|
||||
mutex_init(&data->update_lock);
|
||||
mutex_init(&data->watchdog_lock);
|
||||
INIT_LIST_HEAD(&data->list);
|
||||
kref_init(&data->kref);
|
||||
|
||||
/* Store client pointer in our data struct for watchdog usage
|
||||
(where the client is found through a data ptr instead of the
|
||||
otherway around) */
|
||||
data->client = client;
|
||||
|
||||
err = w83793_detect_subclients(client);
|
||||
if (err)
|
||||
|
@ -1380,8 +1787,77 @@ static int w83793_probe(struct i2c_client *client,
|
|||
goto exit_remove;
|
||||
}
|
||||
|
||||
/* Watchdog initialization */
|
||||
|
||||
/* Register boot notifier */
|
||||
err = register_reboot_notifier(&watchdog_notifier);
|
||||
if (err != 0) {
|
||||
dev_err(&client->dev,
|
||||
"cannot register reboot notifier (err=%d)\n", err);
|
||||
goto exit_devunreg;
|
||||
}
|
||||
|
||||
/* Enable Watchdog registers.
|
||||
Set Configuration Register to Enable Watch Dog Registers
|
||||
(Bit 2) = XXXX, X1XX. */
|
||||
tmp = w83793_read_value(client, W83793_REG_CONFIG);
|
||||
w83793_write_value(client, W83793_REG_CONFIG, tmp | 0x04);
|
||||
|
||||
/* Set the default watchdog timeout */
|
||||
data->watchdog_timeout = timeout;
|
||||
|
||||
/* Check, if last reboot was caused by watchdog */
|
||||
data->watchdog_caused_reboot =
|
||||
w83793_read_value(data->client, W83793_REG_WDT_STATUS) & 0x01;
|
||||
|
||||
/* Disable Soft Watchdog during initialiation */
|
||||
watchdog_disable(data);
|
||||
|
||||
/* We take the data_mutex lock early so that watchdog_open() cannot
|
||||
run when misc_register() has completed, but we've not yet added
|
||||
our data to the watchdog_data_list (and set the default timeout) */
|
||||
mutex_lock(&watchdog_data_mutex);
|
||||
for (i = 0; i < ARRAY_SIZE(watchdog_minors); i++) {
|
||||
/* Register our watchdog part */
|
||||
snprintf(data->watchdog_name, sizeof(data->watchdog_name),
|
||||
"watchdog%c", (i == 0) ? '\0' : ('0' + i));
|
||||
data->watchdog_miscdev.name = data->watchdog_name;
|
||||
data->watchdog_miscdev.fops = &watchdog_fops;
|
||||
data->watchdog_miscdev.minor = watchdog_minors[i];
|
||||
|
||||
err = misc_register(&data->watchdog_miscdev);
|
||||
if (err == -EBUSY)
|
||||
continue;
|
||||
if (err) {
|
||||
data->watchdog_miscdev.minor = 0;
|
||||
dev_err(&client->dev,
|
||||
"Registering watchdog chardev: %d\n", err);
|
||||
break;
|
||||
}
|
||||
|
||||
list_add(&data->list, &watchdog_data_list);
|
||||
|
||||
dev_info(&client->dev,
|
||||
"Registered watchdog chardev major 10, minor: %d\n",
|
||||
watchdog_minors[i]);
|
||||
break;
|
||||
}
|
||||
if (i == ARRAY_SIZE(watchdog_minors)) {
|
||||
data->watchdog_miscdev.minor = 0;
|
||||
dev_warn(&client->dev, "Couldn't register watchdog chardev "
|
||||
"(due to no free minor)\n");
|
||||
}
|
||||
|
||||
mutex_unlock(&watchdog_data_mutex);
|
||||
|
||||
return 0;
|
||||
|
||||
/* Unregister hwmon device */
|
||||
|
||||
exit_devunreg:
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
|
||||
/* Unregister sysfs hooks */
|
||||
|
||||
exit_remove:
|
||||
|
@ -1628,7 +2104,7 @@ static void __exit sensors_w83793_exit(void)
|
|||
i2c_del_driver(&w83793_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Yuan Mu");
|
||||
MODULE_AUTHOR("Yuan Mu, Sven Anders");
|
||||
MODULE_DESCRIPTION("w83793 driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
|
|
Loading…
Reference in New Issue