History log of /drivers/hwmon/applesmc.c
Revision Date Author Comments
25f2bd7f5add608c1d1405938f39c96927b275ca 02-Oct-2013 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Always read until end of data

The crash reported and investigated in commit 5f4513 turned out to be
caused by a change to the read interface on newer (2012) SMCs.

Tests by Chris show that simply reading the data valid line is enough
for the problem to go away. Additional tests show that the newer SMCs
no longer wait for the number of requested bytes, but start sending
data right away. Apparently the number of bytes to read is no longer
specified as before, but instead found out by reading until end of
data. Failure to read until end of data confuses the state machine,
which eventually causes the crash.

As a remedy, assuming bit0 is the read valid line, make sure there is
nothing more to read before leaving the read function.

Tested to resolve the original problem, and runtested on MBA3,1,
MBP4,1, MBP8,2, MBP10,1, MBP10,2. The patch seems to have no effect on
machines before 2012.

Tested-by: Chris Murphy <chris@cmurf.com>
Cc: stable@vger.kernel.org
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
5f4513864304672e6ea9eac60583eeac32e679f2 26-Sep-2013 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Check key count before proceeding

After reports from Chris and Josh Boyer of a rare crash in applesmc,
Guenter pointed at the initialization problem fixed below. The patch
has not been verified to fix the crash, but should be applied
regardless.

Reported-by: <jwboyer@fedoraproject.org>
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
692fe501da4b851cbb60edc672679ad1b41e1602 10-Jan-2013 Guenter Roeck <linux@roeck-us.net> hwmon: checkpatch cleanup: Replace printk with pr_debug or dev_dbg as appropriate

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Alistair John Strachan <alistair@devzero.co.uk>
Cc: Henrik Rydberg <rydberg@euromail.se>
Acked-by: Alistair John Strachan <alistair@devzero.co.uk>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
fa845740cbc565d8f52c32973bb598743eb0d995 10-Oct-2012 Jean Delvare <khali@linux-fr.org> hwmon: Add missing inclusions of <linux/err.h>

These drivers use IS_ERR so they should include <linux/err.h>.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Luca Tettamanti <kronos.it@gmail.com>
Cc: Henrik Rydberg <rydberg@euromail.se>
521cf6489269f5b223c24857d99c779e91f42d3e 17-Sep-2012 Parag Warudkar <parag.lkml@gmail.com> hwmon: (applesmc) Bump max wait

A heavy-load test on a MacBookPro6,1 is still showing a substantial
amount of read errors. Increasing the maximum wait time to 128 ms
resolves the issue.

Signed-off-by: Parag Warudkar <parag.lkml@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
829917cd7246204d6c5f066c40b66d2b62d0930d 27-Jul-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Decode and act on read/write status codes

The behavior of the SMC has changed several times over the years,
causing read failures in the driver. It seems the problem can be
explained by a shift in SMC speed combined with improper action on
status codes.

We should first wait for the SMC to settle, which was the most
frequent response on the old slow machines. Then, if the SMC is busy,
we need to try again later by resending the command. This was the most
likely response until 2012. Now, with a shorter wait time, we are
again most likely to poll while the SMC is settling, and as a result
we see high failure rates on many old and new models.

With the distinction between busy and failure, we can also wait longer
before retrying, without sacrificing speed. This seems to bring
failures down to virtually zero on all models.

Tested on: MBA1,1 MBA3,1 MBA5,1 MBA5,2 MBP9,2

Tested-by: Adam Somerville <adamsomerville@gmail.com>
Tested-by: Hubert Eichner <hubert.georg.eichner@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
e30bca12573fbf54e2470723aadc047549d147ce 16-Jul-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Ignore some temperature registers

Not all sensors in the T range are useful temperatures. This patch
creates a subset of sensors to be exported to userland, excluding the
unknown types.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
b6e5122f09272cb30c2e1fc1d80a40bfa6e87757 16-Jul-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Allow negative temperature values

There are many userland reports of sensors with unreasonably small and
large temperatures. There seem to be several reasons for this:

Firstly, the major sensor type (sp78) is actually a signed number.
This explains why some sensors show very small or large values - they
are in fact all small, but of different sign.

Secondly, the other sensor type (1-hex) is not properly understood; it
may be that it is not a temperature after all.

Thirdly, some sensors are differential in nature, showing changes over
time rather than absolute numbers. This explains why those values are
small and of varying sign.

This patch interprets the sp78 type as signed short, but keeps the
original scaling. For other types, -EINVAL is returned, since the
nature of those sensors is unknown.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
a332bf9a65ab34b01226ed177f6937af843c8465 09-Jul-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Shorten minimum wait time

The 2012 series of MacBooks have a faster SMC, and the current driver
timings do not work at all. Tests show that decreasing the minimum
wait time, from 64 us to 16 us, works well. Since this is still larger
than the original minimum of 10 us used before 2008, there is nothing
inherently problematic with changing it. The fail frequency on older
machines seems to increase slightly, but not enough to be noticeable.

Tested on MBA11, MBA31, MBA5,2, MBP9,2.

The patch was originally written by adamski99 (ubuntuforums.org) and
later tested by janhouse (bbs.archlinux.org).

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
edf48f3a73b027a99c92edab2b07d78fe77523cc 20-Jun-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Skip sensor mapping

The special motion sensor mapping is unnecessary; remove it.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
aa8521ec2889d5d1f2f0ed00c3295b8229135f98 20-Jun-2012 Jesper Juhl <jj@chaosbits.net> hwmon: (applesmc) correct email address for Jesper Juhl

I've not had a gmail address for years. This commit updates the
address to my actual working one.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
ac852edb47b15900886ba2564eeeb13b3b526e3e 07-Jun-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Limit key length in warning messages

Key lookups may call read_smc() with a fixed-length key string,
and if the lookup fails, trailing stack content may appear in the
kernel log. Fixed with this patch.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
0fc86eca1b338d06ec500b34ef7def79c32b602b 26-Jan-2012 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Silence uninitialized warnings

Some error paths do not set a result, leading to the (false)
assumption that the value may be used uninitialized. Set results for
those paths as well.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
85ebfd3ef9a52abe6426cc5e96604f2dd0e9b375 19-Jan-2012 Guenter Roeck <linux@roeck-us.net> hwmon: (applesmc) Fix multi-line comments

Cc: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
179c4fdb565dd2157e5dfe89318b74868e3b523d 04-Jan-2012 Frans Meulenbroeks <fransmeulenbroeks@gmail.com> hwmon: replaced strict_str* with kstr*

replaced strict_strtol with kstrtol and
replaced strict_strtuol with kstrtuol

This satisfies checkpatch -f
Compile tested only: no warnings or errors given

Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
9d1f8a40ddab65a5cedb69b369ee4c0c6e4acf6b 22-Jan-2011 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Properly initialize lockdep attributes

The switch to dynamically allocated sysfs attributes left the
internal lockdep members uninitialized, causing a formal bug.
This patch adds sysfs_attr_init() to the node creation function,
remedying the problem.

Reported-and-tested-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
2bfe814826b7266a489895f731a777f8cbe37963 10-Nov-2010 Guenter Roeck <guenter.roeck@ericsson.com> hwmon: (applesmc) Fix checkpatch errors and fix value range checks

This patch fixes all checkpatch errors and most of the checkpatch warnings.
It also fixes the range check in applesmc_store_fan_speed().

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
41e71f97174ba08fcca7f31bf448de92abc8862e 09-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Update copyright information

With the preceding patches, git blame assigns about half of
the file to the present author. Add a line to the copyright
to reflect this.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
0b8ad5a57b75322e4b671ef420b5fe90e5154912 09-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Silence driver

Make the driver report a single line on success.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
0b0b5dff8967a4468f05174d0d74e1ed6e369776 09-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Simplify feature sysfs handling

Given the dynamic node construction method, the setup of the
accelerometer, light sensor and keyboard backlight sysfs nodes
can be simplified. This patch does not contain any logic changes.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
3eba2bf7c5fb7863412554cd73646cb80ac293ff 09-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Dynamic creation of fan files

With the dynamic temperature group in place, the setup of fans
can be simplified. This patch sets up the fans dynamically, removing
a hundred lines of code.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
40ef06f1120bcc0a2ad483b5cd42f58c4df78a5b 10-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Extract all features generically

With temperature keys being determined automatically, the dmi match
data is only used to assign features that can easily be detected from
the smc. This patch removes the dmi match data altogether, and reduces
the match table to the main machine models.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
dcdea2614ab9b7864a3ae620419d04e0cc4a65cc 09-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Handle new temperature format

The recent Macbooks have temperature registers of a new type.
This patch adds the logic to handle them.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
9792dadfce22ae1518c88577ac743a3077a85084 10-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Dynamic creation of temperature files

The current driver creates temperature files based on a list
of temperature keys given per device. Apart from slow adaption
to new machine models, the number of sensors also depends on
the number of processors. This patch looks up the temperature
keys dynamically, thereby supporting all models.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
5874583d5662de5550b0ed1c54a9dea70bcdcba4 10-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Introduce a register lookup table

One main problem with the current driver is the inability to quickly
search for supported keys, resulting in detailed feature maps per
machine model which are cumbersome to maintain.

This patch adds a register lookup table, which enables binary search
for supported keys. The lookup also reduces the io frequency, so the
original mutex is replaced by locks around the actual io.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
[guenter.roeck@ericsson.com: Added value range check to key_at_index_store()]
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
1ee7c71bd1aa9758f14e1be92310215a5bd0abe7 09-Nov-2010 Joe Perches <joe@perches.com> hwmon: (applesmc) Use pr_fmt and pr_<level>

Added #define pr_fmt KBUILD_MODNAME ": " fmt
Converted printks to pr_<level>
Coalesced any long formats
Removed prefixes from formats

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
2344cd0c2e9ea8f3037be11fb997ddbeda0237ca 09-Nov-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Relax the severity of device init failure

The device init is used to reset the accelerometer. Failure to reset
is not severe enough to stop loading the module or to resume from
hibernation. This patch relaxes failure to a warning and drops
output in case of success.

Cc: stable@kernel.org
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
132af03233b493101a53010383b5abb5b9ff1e51 09-Nov-2010 Edgar Hucek <gimli@dark-green.com> hwmon: (applesmc) Add MacBookAir3,1(3,2) support

This patch add support for the MacBookAir3,1 and MacBookAir3,2 to the
applesmc driver.

[rydberg@euromail.se: minor cleanup]
Cc: stable@kernel.org
Signed-off-by: Edgar Hucek <gimli@dark-green.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
fa5575cff92eb43f467b9b00468d70d073e8b3d2 27-May-2010 Alex Murray <murray.alex@gmail.com> hwmon: (applesmc) Add temperature sensor labels to sysfs interface

The Apple SMC uses a systematic labeling scheme for the hardware
temperature sensors. This scheme is currently hidden from
userland. Since the sensor set, and consequently the numbering,
differs between models, an extensive database of configurations is
required for an application such as fan control. This patch adds the
SMC labels to the hwmon sysfs interface, allowing applications to use
the sensors more intelligibly.

[rydberg@euromail.se: fixed error handling]
Signed-off-by: Alex Murray <murray.alex@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
405eaa1c1d045cdd872802fc515f638573984880 27-May-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Add generic support for MacBook Pro 7

This patch adds generic support for the MacBook Pro 7 family
based on the 7,1 model.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
872bad55e2d3fcc13e1e8770a3b200f0c6ca5126 27-May-2010 Bernhard Froemel <froemel@vmars.tuwien.ac.at> hwmon: (applesmc) Add generic support for MacBook Pro 6

This patch adds generic support for the MacBook Pro 6 family
based on the 6,2 model.

[rydberg@euromail.se: patch cleanup]
Signed-off-by: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
4e4a99d32721800c061191027f18f780dcbd9e0b 27-May-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Add support for MacBook Pro 5,3 and 5,4

The MacBookPro 5,3 model has two fans, whereas the 5,4 model has
only one. This patch adds explicit support for the 5,3 and 5,4 models.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
0559a538899d48e7d730affb9df2abb13a7d9008 11-May-2010 Henrik Rydberg <rydberg@euromail.se> hwmon: (applesmc) Correct sysfs fan error handling

The current code will not remove the sysfs files for fan numbers three
and up. Also, upon exit, fans one and two are removed regardless of
their existence. This patch cleans up the sysfs error handling for
the fans.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
e1741712e85cec8004c7eeeea81186618f78eff1 14-Apr-2010 Justin P. Mattock <justinmattock@gmail.com> hwmon: (applesmc) Add iMac9,1 and MacBookPro2,2 support

Add the iMac9,1 and the MacBookPro2,2 temperature sensors to hwmon
driver applesmc to fix kernel bug #14429:
https://bugzilla.kernel.org/show_bug.cgi?id=14429

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
Acked-by: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
471452104b8520337ae2fb48c4e61cd4896e025d 15-Dec-2009 Alexey Dobriyan <adobriyan@gmail.com> const: constify remaining dev_pm_ops

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
a976f150a6953da5ccbd40fa6dba3bd7d56f9f67 22-Sep-2009 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: restore accelerometer and keyboard backlight on resume

On resume from suspend, the driver currently resets the logical state as
if it was brought up from halt. This patch uses the
dev_pm_ops.resume/restore methods to synchronize the hardware with the
memorized logical state, in effect bringing back the accelerometer and
backlight to the state prior to suspend. Works for both suspend to ram
and hibernation. The patch has zero effect on the running state.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
6055fae8aceee41471edfd1876e5617d16e028fe 15-Sep-2009 H Hartley Sweeten <hartleys@visionengravers.com> hwmon: Include <linux/io.h> instead of <asm/io.h>

Drivers should be including <linux/io.h> instead of <asm/io.h>.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Alistair John Strachan <alistair@devzero.co.uk>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Juerg Haefliger <juergh@gmail.com>
Cc: Frank Seidel <frank@f-seidel.de>
Acked-by: Jim Cromie <jim.cromie@gmail.com>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Roger Lucas <vt8231@hiddenengine.co.uk>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
fb9f88e1dc76f9feb39d39c40a5d61aad6df4388 29-Jan-2009 Bharath Ramesh <bramesh@vt.edu> hwmon: applesmc: add support for MacPro 3 temperature sensors

MacPro 3 have more temperature sensors than the previous MacPro's also the
sensor THTG has been removed. This patch add supports for the newer
temperature sensors in the MacPro3.

Signed-off-by: Bharath Ramesh <bramesh@vt.edu>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
c3d6362b8717759de7f2086f9665a4d96cacbc51 15-Jan-2009 Alex Murray <murray.alex@gmail.com> hwmon: applesmc: fix light sensor readings on newer MacBooks

The light sensors ALV0 and ALV1 on newer MacBooks (early 2008 and later)
changed to report 10 bytes instead the earlier 6, and the sensor encoding
subsequently changed. As a result, the reported light sensors readings
are much too low.

Via experiments leading up to this patch, it seems only the ALV0 is
reporting data, and the most useful value therein is a 10-bit big-endian
value at offset 6. This suggests that a new protocol was added as a
backward-compatible replacement on top of the old one.

This patch makes applesmc report the improved light sensor reading for the
new machines, on a scale in conformance with earlier ones.

Signed-off-by: Alex Murray <murray.alex@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
85e0e5ad1ef8cebd010bbd7047418a47ca9c5ead 06-Jan-2009 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: Add support for MacBook Air 2

Add temperature sensor support for MacBook Air 2.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
dc924efb52ba9e4dffec5b15ae2242b894198139 01-Dec-2008 Henrik Rydberg <rydberg@bitmath.org> hwmon: applesmc: make applesmc load automatically on startup

make use of the new dmi device loading support to automatically load the
applesmc driver based on the dmi_match table.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
45a3a36b6333b9ddfb0c57602d959a8d05bc47e4 20-Nov-2008 Henrik Rydberg <rydberg@euromail.se> drivers/hwmon/applesmc.c: add generic MacPro support

In order to analyze the SMC of the newer MacPros, applesmc needs to
recognize the machine. This patch adds the missing generic dmi_match
entry for MacPro models.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9ca791bbd464d7968db1530b433cc397a4c348c1 20-Nov-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: Add support for iMac 6

Add temperature sensor support for iMac 6.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Tested-by: Caleb Hyde <caleb.hyde@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
468cc0320ed083e26364d9febde2679d981ed6a6 12-Nov-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: add support for Macbook 4

This patch adds accelerometer and temperature sensor support for Macbook 4.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
eefc488f96cdde6e152b45675b50bf380b95d99f 06-Nov-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: add support for iMac 8

Add temperature sensor support for iMac 8.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Tested-by: Klaus Doblmann <klaus.doblmann@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
a66603257bf88bbe2c9fd6a97ee5dc24de15d196 06-Nov-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: add support for Macbook Pro 5

Add accelerometer, backlight and temperature sensor support for the new
unibody Macbook Pro 5.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
181209a1d91756bfd83b1d6ce2008cea3ca225b6 06-Nov-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: add support for Macbook 5

Add accelerometer, backlight and temperature sensor support for the new
unibody Macbook 5.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Tested-by: David M. Lary <dmlary@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
6e3530fa241ae759313496f67295c9252691ed04 06-Nov-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: add support for iMac 5

Add temperature sensor support for iMac 5.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Tested-by: Ricky Campbell <johnrcampbell@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8c9398d1e9766e3659e277acb2e8ca1c17684139 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: lighter wait mechanism, drastic improvement

The read fail ratio is sensitive to the delay between the first byte
written and the first byte read; apparently the sensors cannot be rushed.
Increasing the minimum wait time, without changing the total wait time,
improves the fail ratio from a 8% chance that any of the sensors fails in
one read, down to 0.4%, on a Macbook Air. On a Macbook Pro 3,1, the
effect is even more apparent. By reducing the number of status polls, the
ratio is further improved to below 0.1%. Finally, increasing the total
wait time brings the fail ratio down to virtually zero.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Tested-by: Bob McElrath <bob@mcelrath.org>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
07e8dbd3ebbdedc71335049dd4b0d542cb038d7d 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: Add support for Macbook Pro 3

Add temperature sensor support for Macbook Pro 3.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
d7549905f157f217b888edb0f2055f5090eaf1d8 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: Add support for Macbook Pro 4

Adds temperature sensor support for the Macbook Pro 4.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7b5e3cb28f52f42d8cf2b36771be580f33bbc7ae 19-Oct-2008 Andrew Morton <akpm@linux-foundation.org> drivers/hwmon/applesmc.c: remove unneeded casts

dmi_system_id.driver_data is already void*.

Cc: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
f5274c972bac2d14c092a9c634e03f51785c7b76 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: add support for Macbook Air

This patch adds accelerometer, backlight and temperature sensor support
for the Macbook Air.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8bd1a12a51871f0c870612d8220b1485d6aefc73 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: allow for variable ALV0 and ALV1 package length

On some recent Macbooks, the package length for the light sensors ALV0 and
ALV1 has changed from 6 to 10. This patch allows for a variable package
length encompassing both variants.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
02fcbd144d684167aa67b1d3ad68f18d265f2d08 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: prolong status wait

The time to wait for a status change while reading or writing to the SMC
ports is a balance between read reliability and system performance. The
current setting yields rougly three errors in a thousand when
simultaneously reading three different temperature values on a Macbook
Air. This patch increases the setting to a value yielding roughly one
error in ten thousand, with no noticable system performance degradation.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
84d2d7f2ee98dc9bd799790c89b5eb8280af2d37 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: fix the 'wait status failed: c != 8' problem

On many Macbooks since mid 2007, the Pro, C2D and Air models, applesmc
fails to read some or all SMC ports. This problem has various effects,
such as flooded logfiles, malfunctioning temperature sensors,
accelerometers failing to initialize, and difficulties getting backlight
functionality to work properly.

The root of the problem seems to be the command protocol. The current
code sends out a command byte, then repeatedly polls for an ack before
continuing to send or recieve data. From experiments leading to this
patch, it seems the command protocol never quite worked or changed so that
one now sends a command byte, waits a little bit, polls for an ack, and if
it fails, repeats the whole thing by sending the command byte again.

This patch implements a send_command function according to the new
interpretation of the protocol, and should work also for earlier models.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
05224091af06177c0ce7c1fae1f498455b47a6be 19-Oct-2008 Henrik Rydberg <rydberg@euromail.se> hwmon: applesmc: specified number of bytes to read should match actual

At one single place in the code, the specified number of bytes to read and
the actual number of bytes read differ by one. This one-liner patch fixes
that inconsistency.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
f91a79fe86a0becdf2506c189cdde154e82c787c 15-Aug-2008 Guilherme M. Schroeder <guilherme.m.schroeder@gmail.com> applesmc: add support for Macbook

Add support for Macbook v3 (sensors and accelerometer).

Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9f86f28df14e06b12908d6475ee2462f0555bf34 15-Aug-2008 Roberto De Ioris <roberto@unbit.it> applesmc: support for Intel iMac

This adds support for fans and temperature sensors on intel iMac.

Tested on iMac 24" 2.8ghz (iMac8,1), it supports the following sensors:

cpu A
ambient
gpu
gpu diode
gpu heatsink
hd bay 1
memory controller
optical drive
power

Signed-off-by: Roberto De Ioris <roberto@unbit.it>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
cd19ba1391f93bc3741d298667c074d2d3fcc9fd 05-Feb-2008 Riki Oktarianto <rkoktarianto@gmail.com> hwmon: (applesmc) sensors set for MacBook2

On my mid-2007 MacBook2, reading Ts0P sensor always failed with this message:
applesmc: wait status failed: 5 != 50.

So I assume that there's no such Ts0p sensor in this model (please confirm,
anyone). If there's the case, then we need a new set of sensors defined for
MacBook2.

Signed-off-by: Riki Oktarianto <rkoktarianto@gmail.com>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
6c152beefbf90579d21afc4f7e075b1f801f9a75 31-Oct-2007 Richard Purdie <rpurdie@rpsys.net> leds: Standardise LED naming scheme

As discussed on LKML some notion of 'function' is needed in
LED naming. This patch adds this to the documentation and
standardises existing LED drivers.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
8de577095d65e8a51135793bf48c7be6c6c5bc77 16-Oct-2007 René Rebe <rene@exactcode.de> hwmon: (applesmc) Add support for Mac Pro 2 x Quad-Core

At least the 2x Quad-Core Apple Mac Pro appears to have some over-heat
protection which suddenly powers off the whole box under load. This adds
support for the fans and temerature sensors in the Mac Pro - later some
"windwarm" a-like code should probably monitor the values. For now
manually tweaking the fans prevents the sudden shutdown for me.

cd /sys/devices/platform/applesmc.768
for x in fan{1,2,3,4}; do
echo 1 > ${x}_manual
echo 1285 > ${x}_output
done

Two sensors are 0, while four are 129 °C, those might be removed again,
later.

Signed-off-by: René Rebe <rene@exactcode.de>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
7b19ada2ed3c1eccb9fe94d74b05e1428224663d 19-Oct-2007 Jiri Slaby <jirislaby@gmail.com> get rid of input BIT* duplicate defines

get rid of input BIT* duplicate defines

use newly global defined macros for input layer. Also remove includes of
input.h from non-input sources only for BIT macro definiton. Define the
macro temporarily in local manner, all those local definitons will be
removed further in this patchset (to not break bisecting).
BIT macro will be globally defined (1<<x)

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: <dtor@mail.ru>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Cc: <lenb@kernel.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Cc: <perex@suse.cz>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: <vernux@us.ibm.com>
Cc: <malattia@linux.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1beeffe43311f64df8dd0ab08ff6b1858c58363f 20-Aug-2007 Tony Jones <tonyj@suse.de> hwmon: Convert from class_device to device

Convert from class_device to device for hwmon_device_register/unregister

Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
1855256c497ecfefc730df6032243f26855ce52c 03-Oct-2007 Jeff Garzik <jeff@garzik.org> drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const,
since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should,
whenever possible, be marked const to ensure we never ever write to
that data area.

3) const-ify DMI API, to enable marking tables const where possible
in low-level drivers.

And if we're really lucky, this might enable some additional
optimizations on the part of the compiler.

The bulk of the changes are #2 and #3, which are interrelated. #1 could
have been a separate patch, but it was so small compared to the others,
it was easier to roll it into this changeset.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
d5cf2b99dac2e3ff17c7a80fcc71e538b38a3c75 26-Sep-2007 Dmitry Torokhov <dmitry.torokhov@gmail.com> HWMON: applesmc - convert to use input-polldev

Switch to using input-polldev skeleton instead of implementing polling loop by
itself. This also fixes problem with trylock on a mutex in atomic context.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1bed24b9785f7f5255c120f194e98343b998f6ce 09-Jul-2007 Martin Szulecki <mactel@sukimashita.com> hwmon: (applesmc) add temperature sensors set for Macbook

Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
Acked-by: Jean Delvare <khali@linux-fr.org>
Cc: Martin Szulecki <mactel@sukimashita.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
6996abf0962bb86b6285987a4698f6d275ff531f 27-May-2007 Nicolas Boichat <nicolas@boichat.ch> hwmon/applesmc: Handle name file creation error and deletion

The previous patch was incomplete.

Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
fa74419bb7b51af4bbb66116d14cc92f0b5aff25 23-May-2007 Nicolas Boichat <nicolas@boichat.ch> applesmc - sensors patch missing from 2.6.22-rc2

Add name file needed by lm_sensors user-space applications in applesmc
sysfs tree.

Cc: Soeren Sonnenburg <kernel@nn7.de>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
c5ddb547e899993be56dc7d0bf72bfd7a8d4ae1e 10-May-2007 Dmitry Torokhov <dtor@insightbb.com> drivers/hwmon: switch to using input_dev->dev.parent

In preparation for struct class_device -> struct device input core
conversion, switch to using input_dev->dev.parent when specifying device
position in sysfs tree.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
da4e8ca376a1b3dca470eba14dcec321a6a27b8b 09-May-2007 Jean Delvare <khali@linux-fr.org> applesmc: Use standard sysfs names for labels

We have a standard suffix to associate a designation string to a sensor:
_label. Use it instead of _position so that libsensors will catch it.
(This isn't implemented yet, but should be soon.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ddfbf2afd538b38139267f71a185eb9434465440 09-May-2007 Jean Delvare <khali@linux-fr.org> applesmc: Use the address as platform device ID

Let the applesmc device export its address to userspace. libsensors needs
this to recognize the device and give it a unique ID.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Nicolas Boichat <nicolas@boichat.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
6f2fad748ccced5b9313efce2a2c7ae4c04ef564 08-May-2007 Nicolas Boichat <nicolas@boichat.ch> Apple SMC driver (hardware monitoring and control)

This driver provides support for the Apple System Management Controller, which
provides an accelerometer (Apple Sudden Motion Sensor), light sensors,
temperature sensors, keyboard backlight control and fan control. Only
Intel-based Apple's computers are supported (MacBook Pro, MacBook, MacMini).

[bunk@stusta.de: make drivers/hwmon/applesmc.c:backlight_work stati]
[khali@linux-fr.org: fix temperature attribute file names]
Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>