[x86] applesmc: Update to Linux 3.6, including fixes for new MacBook models
svn path=/dists/trunk/linux/; revision=19301
This commit is contained in:
parent
e4853bde02
commit
a0123a711d
|
@ -9,6 +9,7 @@ linux (3.5-1~experimental.1) UNRELEASED; urgency=low
|
||||||
* debian/copyright: Convert to machine-readable format (fka DEP-5)
|
* debian/copyright: Convert to machine-readable format (fka DEP-5)
|
||||||
* debian/copyright: Add copyright notice for newly-added Unicode data
|
* debian/copyright: Add copyright notice for newly-added Unicode data
|
||||||
* [x86] seccomp: Enable SECCOMP_FILTER
|
* [x86] seccomp: Enable SECCOMP_FILTER
|
||||||
|
* [x86] applesmc: Update to Linux 3.6, including fixes for new MacBook models
|
||||||
|
|
||||||
-- Ben Hutchings <ben@decadent.org.uk> Mon, 02 Jul 2012 15:09:43 +0100
|
-- Ben Hutchings <ben@decadent.org.uk> Mon, 02 Jul 2012 15:09:43 +0100
|
||||||
|
|
||||||
|
|
77
debian/patches/bugfix/all/hwmon-applesmc-Allow-negative-temperature-values.patch
vendored
Normal file
77
debian/patches/bugfix/all/hwmon-applesmc-Allow-negative-temperature-values.patch
vendored
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
From: Henrik Rydberg <rydberg@euromail.se>
|
||||||
|
Date: Mon, 16 Jul 2012 09:18:10 +0200
|
||||||
|
Subject: [3/5] hwmon: (applesmc) Allow negative temperature values
|
||||||
|
|
||||||
|
commit b6e5122f09272cb30c2e1fc1d80a40bfa6e87757 upstream.
|
||||||
|
|
||||||
|
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>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 19 ++++++++-----------
|
||||||
|
1 file changed, 8 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index f41585e..75f87f1 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -80,6 +80,8 @@
|
||||||
|
#define FANS_MANUAL "FS! " /* r-w ui16 */
|
||||||
|
#define FAN_ID_FMT "F%dID" /* r-o char[16] */
|
||||||
|
|
||||||
|
+#define TEMP_SENSOR_TYPE "sp78"
|
||||||
|
+
|
||||||
|
/* List of keys used to read/write fan speeds */
|
||||||
|
static const char *const fan_speed_fmt[] = {
|
||||||
|
"F%dAc", /* actual speed */
|
||||||
|
@@ -720,27 +722,22 @@ static ssize_t applesmc_show_temperature(struct device *dev,
|
||||||
|
int index = smcreg.temp_begin + to_index(devattr);
|
||||||
|
const struct applesmc_entry *entry;
|
||||||
|
int ret;
|
||||||
|
- u8 buffer[2];
|
||||||
|
- unsigned int temp;
|
||||||
|
+ s16 value;
|
||||||
|
+ int temp;
|
||||||
|
|
||||||
|
entry = applesmc_get_entry_by_index(index);
|
||||||
|
if (IS_ERR(entry))
|
||||||
|
return PTR_ERR(entry);
|
||||||
|
- if (entry->len > 2)
|
||||||
|
+ if (strcmp(entry->type, TEMP_SENSOR_TYPE))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
- ret = applesmc_read_entry(entry, buffer, entry->len);
|
||||||
|
+ ret = applesmc_read_s16(entry->key, &value);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (entry->len == 2) {
|
||||||
|
- temp = buffer[0] * 1000;
|
||||||
|
- temp += (buffer[1] >> 6) * 250;
|
||||||
|
- } else {
|
||||||
|
- temp = buffer[0] * 4000;
|
||||||
|
- }
|
||||||
|
+ temp = 250 * (value >> 6);
|
||||||
|
|
||||||
|
- return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp);
|
||||||
|
+ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t applesmc_show_fan_speed(struct device *dev,
|
171
debian/patches/bugfix/all/hwmon-applesmc-Decode-and-act-on-read-write-status-c.patch
vendored
Normal file
171
debian/patches/bugfix/all/hwmon-applesmc-Decode-and-act-on-read-write-status-c.patch
vendored
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
From: Henrik Rydberg <rydberg@euromail.se>
|
||||||
|
Date: Fri, 27 Jul 2012 20:12:46 +0200
|
||||||
|
Subject: [5/5] hwmon: (applesmc) Decode and act on read/write status codes
|
||||||
|
|
||||||
|
commit 829917cd7246204d6c5f066c40b66d2b62d0930d upstream.
|
||||||
|
|
||||||
|
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>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 70 ++++++++++++++++++++++++++++++----------------
|
||||||
|
1 file changed, 46 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 4d937a1..2827088 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -55,9 +55,9 @@
|
||||||
|
|
||||||
|
/* wait up to 32 ms for a status change. */
|
||||||
|
#define APPLESMC_MIN_WAIT 0x0010
|
||||||
|
+#define APPLESMC_RETRY_WAIT 0x0100
|
||||||
|
#define APPLESMC_MAX_WAIT 0x8000
|
||||||
|
|
||||||
|
-#define APPLESMC_STATUS_MASK 0x0f
|
||||||
|
#define APPLESMC_READ_CMD 0x10
|
||||||
|
#define APPLESMC_WRITE_CMD 0x11
|
||||||
|
#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12
|
||||||
|
@@ -162,51 +162,68 @@ static unsigned int key_at_index;
|
||||||
|
static struct workqueue_struct *applesmc_led_wq;
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * __wait_status - Wait up to 32ms for the status port to get a certain value
|
||||||
|
- * (masked with 0x0f), returning zero if the value is obtained. Callers must
|
||||||
|
+ * wait_read - Wait for a byte to appear on SMC port. Callers must
|
||||||
|
* hold applesmc_lock.
|
||||||
|
*/
|
||||||
|
-static int __wait_status(u8 val)
|
||||||
|
+static int wait_read(void)
|
||||||
|
{
|
||||||
|
+ u8 status;
|
||||||
|
int us;
|
||||||
|
-
|
||||||
|
- val = val & APPLESMC_STATUS_MASK;
|
||||||
|
-
|
||||||
|
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
|
||||||
|
udelay(us);
|
||||||
|
- if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val)
|
||||||
|
+ status = inb(APPLESMC_CMD_PORT);
|
||||||
|
+ /* read: wait for smc to settle */
|
||||||
|
+ if (status & 0x01)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ pr_warn("wait_read() fail: 0x%02x\n", status);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * special treatment of command port - on newer macbooks, it seems necessary
|
||||||
|
- * to resend the command byte before polling the status again. Callers must
|
||||||
|
- * hold applesmc_lock.
|
||||||
|
+ * send_byte - Write to SMC port, retrying when necessary. Callers
|
||||||
|
+ * must hold applesmc_lock.
|
||||||
|
*/
|
||||||
|
-static int send_command(u8 cmd)
|
||||||
|
+static int send_byte(u8 cmd, u16 port)
|
||||||
|
{
|
||||||
|
+ u8 status;
|
||||||
|
int us;
|
||||||
|
+
|
||||||
|
+ outb(cmd, port);
|
||||||
|
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
|
||||||
|
- outb(cmd, APPLESMC_CMD_PORT);
|
||||||
|
udelay(us);
|
||||||
|
- if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c)
|
||||||
|
+ status = inb(APPLESMC_CMD_PORT);
|
||||||
|
+ /* write: wait for smc to settle */
|
||||||
|
+ if (status & 0x02)
|
||||||
|
+ continue;
|
||||||
|
+ /* ready: cmd accepted, return */
|
||||||
|
+ if (status & 0x04)
|
||||||
|
return 0;
|
||||||
|
+ /* timeout: give up */
|
||||||
|
+ if (us << 1 == APPLESMC_MAX_WAIT)
|
||||||
|
+ break;
|
||||||
|
+ /* busy: long wait and resend */
|
||||||
|
+ udelay(APPLESMC_RETRY_WAIT);
|
||||||
|
+ outb(cmd, port);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ pr_warn("send_byte(0x%02x, 0x%04x) fail: 0x%02x\n", cmd, port, status);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int send_command(u8 cmd)
|
||||||
|
+{
|
||||||
|
+ return send_byte(cmd, APPLESMC_CMD_PORT);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int send_argument(const char *key)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- for (i = 0; i < 4; i++) {
|
||||||
|
- outb(key[i], APPLESMC_DATA_PORT);
|
||||||
|
- if (__wait_status(0x04))
|
||||||
|
+ for (i = 0; i < 4; i++)
|
||||||
|
+ if (send_byte(key[i], APPLESMC_DATA_PORT))
|
||||||
|
return -EIO;
|
||||||
|
- }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -219,11 +236,14 @@ static int read_smc(u8 cmd, const char *key, u8 *buffer, u8 len)
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- outb(len, APPLESMC_DATA_PORT);
|
||||||
|
+ if (send_byte(len, APPLESMC_DATA_PORT)) {
|
||||||
|
+ pr_warn("%.4s: read len fail\n", key);
|
||||||
|
+ return -EIO;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
- if (__wait_status(0x05)) {
|
||||||
|
- pr_warn("%.4s: read data fail\n", key);
|
||||||
|
+ if (wait_read()) {
|
||||||
|
+ pr_warn("%.4s: read data[%d] fail\n", key, i);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
buffer[i] = inb(APPLESMC_DATA_PORT);
|
||||||
|
@@ -241,14 +261,16 @@ static int write_smc(u8 cmd, const char *key, const u8 *buffer, u8 len)
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- outb(len, APPLESMC_DATA_PORT);
|
||||||
|
+ if (send_byte(len, APPLESMC_DATA_PORT)) {
|
||||||
|
+ pr_warn("%.4s: write len fail\n", key);
|
||||||
|
+ return -EIO;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
- if (__wait_status(0x04)) {
|
||||||
|
+ if (send_byte(buffer[i], APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%s: write data fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
- outb(buffer[i], APPLESMC_DATA_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
171
debian/patches/bugfix/all/hwmon-applesmc-Ignore-some-temperature-registers.patch
vendored
Normal file
171
debian/patches/bugfix/all/hwmon-applesmc-Ignore-some-temperature-registers.patch
vendored
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
From: Henrik Rydberg <rydberg@euromail.se>
|
||||||
|
Date: Mon, 16 Jul 2012 09:18:11 +0200
|
||||||
|
Subject: [4/5] hwmon: (applesmc) Ignore some temperature registers
|
||||||
|
|
||||||
|
commit e30bca12573fbf54e2470723aadc047549d147ce upstream.
|
||||||
|
|
||||||
|
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>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 75 +++++++++++++++++++++++++++++-----------------
|
||||||
|
1 file changed, 47 insertions(+), 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 75f87f1..4d937a1 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -133,11 +133,13 @@ static struct applesmc_registers {
|
||||||
|
unsigned int temp_count; /* number of temperature registers */
|
||||||
|
unsigned int temp_begin; /* temperature lower index bound */
|
||||||
|
unsigned int temp_end; /* temperature upper index bound */
|
||||||
|
+ unsigned int index_count; /* size of temperature index array */
|
||||||
|
int num_light_sensors; /* number of light sensors */
|
||||||
|
bool has_accelerometer; /* has motion sensor */
|
||||||
|
bool has_key_backlight; /* has keyboard backlight */
|
||||||
|
bool init_complete; /* true when fully initialized */
|
||||||
|
struct applesmc_entry *cache; /* cached key entries */
|
||||||
|
+ const char **index; /* temperature key index */
|
||||||
|
} smcreg = {
|
||||||
|
.mutex = __MUTEX_INITIALIZER(smcreg.mutex),
|
||||||
|
};
|
||||||
|
@@ -469,6 +471,30 @@ static void applesmc_device_init(void)
|
||||||
|
pr_warn("failed to init the device\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int applesmc_init_index(struct applesmc_registers *s)
|
||||||
|
+{
|
||||||
|
+ const struct applesmc_entry *entry;
|
||||||
|
+ unsigned int i;
|
||||||
|
+
|
||||||
|
+ if (s->index)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ s->index = kcalloc(s->temp_count, sizeof(s->index[0]), GFP_KERNEL);
|
||||||
|
+ if (!s->index)
|
||||||
|
+ return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ for (i = s->temp_begin; i < s->temp_end; i++) {
|
||||||
|
+ entry = applesmc_get_entry_by_index(i);
|
||||||
|
+ if (IS_ERR(entry))
|
||||||
|
+ continue;
|
||||||
|
+ if (strcmp(entry->type, TEMP_SENSOR_TYPE))
|
||||||
|
+ continue;
|
||||||
|
+ s->index[s->index_count++] = entry->key;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* applesmc_init_smcreg_try - Try to initialize register cache. Idempotent.
|
||||||
|
*/
|
||||||
|
@@ -504,6 +530,10 @@ static int applesmc_init_smcreg_try(void)
|
||||||
|
return ret;
|
||||||
|
s->temp_count = s->temp_end - s->temp_begin;
|
||||||
|
|
||||||
|
+ ret = applesmc_init_index(s);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = applesmc_has_key(LIGHT_SENSOR_LEFT_KEY, &left_light_sensor);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
@@ -520,8 +550,8 @@ static int applesmc_init_smcreg_try(void)
|
||||||
|
s->num_light_sensors = left_light_sensor + right_light_sensor;
|
||||||
|
s->init_complete = true;
|
||||||
|
|
||||||
|
- pr_info("key=%d fan=%d temp=%d acc=%d lux=%d kbd=%d\n",
|
||||||
|
- s->key_count, s->fan_count, s->temp_count,
|
||||||
|
+ pr_info("key=%d fan=%d temp=%d index=%d acc=%d lux=%d kbd=%d\n",
|
||||||
|
+ s->key_count, s->fan_count, s->temp_count, s->index_count,
|
||||||
|
s->has_accelerometer,
|
||||||
|
s->num_light_sensors,
|
||||||
|
s->has_key_backlight);
|
||||||
|
@@ -529,6 +559,15 @@ static int applesmc_init_smcreg_try(void)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void applesmc_destroy_smcreg(void)
|
||||||
|
+{
|
||||||
|
+ kfree(smcreg.index);
|
||||||
|
+ smcreg.index = NULL;
|
||||||
|
+ kfree(smcreg.cache);
|
||||||
|
+ smcreg.cache = NULL;
|
||||||
|
+ smcreg.init_complete = false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* applesmc_init_smcreg - Initialize register cache.
|
||||||
|
*
|
||||||
|
@@ -549,19 +588,11 @@ static int applesmc_init_smcreg(void)
|
||||||
|
msleep(INIT_WAIT_MSECS);
|
||||||
|
}
|
||||||
|
|
||||||
|
- kfree(smcreg.cache);
|
||||||
|
- smcreg.cache = NULL;
|
||||||
|
+ applesmc_destroy_smcreg();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void applesmc_destroy_smcreg(void)
|
||||||
|
-{
|
||||||
|
- kfree(smcreg.cache);
|
||||||
|
- smcreg.cache = NULL;
|
||||||
|
- smcreg.init_complete = false;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
/* Device model stuff */
|
||||||
|
static int applesmc_probe(struct platform_device *dev)
|
||||||
|
{
|
||||||
|
@@ -705,33 +736,21 @@ out:
|
||||||
|
static ssize_t applesmc_show_sensor_label(struct device *dev,
|
||||||
|
struct device_attribute *devattr, char *sysfsbuf)
|
||||||
|
{
|
||||||
|
- int index = smcreg.temp_begin + to_index(devattr);
|
||||||
|
- const struct applesmc_entry *entry;
|
||||||
|
+ const char *key = smcreg.index[to_index(devattr)];
|
||||||
|
|
||||||
|
- entry = applesmc_get_entry_by_index(index);
|
||||||
|
- if (IS_ERR(entry))
|
||||||
|
- return PTR_ERR(entry);
|
||||||
|
-
|
||||||
|
- return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", entry->key);
|
||||||
|
+ return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Displays degree Celsius * 1000 */
|
||||||
|
static ssize_t applesmc_show_temperature(struct device *dev,
|
||||||
|
struct device_attribute *devattr, char *sysfsbuf)
|
||||||
|
{
|
||||||
|
- int index = smcreg.temp_begin + to_index(devattr);
|
||||||
|
- const struct applesmc_entry *entry;
|
||||||
|
+ const char *key = smcreg.index[to_index(devattr)];
|
||||||
|
int ret;
|
||||||
|
s16 value;
|
||||||
|
int temp;
|
||||||
|
|
||||||
|
- entry = applesmc_get_entry_by_index(index);
|
||||||
|
- if (IS_ERR(entry))
|
||||||
|
- return PTR_ERR(entry);
|
||||||
|
- if (strcmp(entry->type, TEMP_SENSOR_TYPE))
|
||||||
|
- return -EINVAL;
|
||||||
|
-
|
||||||
|
- ret = applesmc_read_s16(entry->key, &value);
|
||||||
|
+ ret = applesmc_read_s16(key, &value);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
@@ -1247,7 +1266,7 @@ static int __init applesmc_init(void)
|
||||||
|
if (ret)
|
||||||
|
goto out_info;
|
||||||
|
|
||||||
|
- ret = applesmc_create_nodes(temp_group, smcreg.temp_count);
|
||||||
|
+ ret = applesmc_create_nodes(temp_group, smcreg.index_count);
|
||||||
|
if (ret)
|
||||||
|
goto out_fans;
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
From: Henrik Rydberg <rydberg@euromail.se>
|
||||||
|
Date: Mon, 9 Jul 2012 12:10:26 +0200
|
||||||
|
Subject: [2/5] hwmon: (applesmc) Shorten minimum wait time
|
||||||
|
|
||||||
|
commit a332bf9a65ab34b01226ed177f6937af843c8465 upstream.
|
||||||
|
|
||||||
|
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>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 0162f55..f41585e 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -54,7 +54,7 @@
|
||||||
|
#define APPLESMC_MAX_DATA_LENGTH 32
|
||||||
|
|
||||||
|
/* wait up to 32 ms for a status change. */
|
||||||
|
-#define APPLESMC_MIN_WAIT 0x0040
|
||||||
|
+#define APPLESMC_MIN_WAIT 0x0010
|
||||||
|
#define APPLESMC_MAX_WAIT 0x8000
|
||||||
|
|
||||||
|
#define APPLESMC_STATUS_MASK 0x0f
|
|
@ -0,0 +1,106 @@
|
||||||
|
From: Henrik Rydberg <rydberg@euromail.se>
|
||||||
|
Date: Wed, 20 Jun 2012 18:00:06 +0200
|
||||||
|
Subject: [1/5] hwmon: (applesmc) Skip sensor mapping
|
||||||
|
|
||||||
|
commit edf48f3a73b027a99c92edab2b07d78fe77523cc upstream.
|
||||||
|
|
||||||
|
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>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 41 +++++++++++++----------------------------
|
||||||
|
1 file changed, 13 insertions(+), 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 2cde9ec..0162f55 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -96,10 +96,6 @@ static const char *const fan_speed_fmt[] = {
|
||||||
|
#define APPLESMC_INPUT_FUZZ 4 /* input event threshold */
|
||||||
|
#define APPLESMC_INPUT_FLAT 4
|
||||||
|
|
||||||
|
-#define SENSOR_X 0
|
||||||
|
-#define SENSOR_Y 1
|
||||||
|
-#define SENSOR_Z 2
|
||||||
|
-
|
||||||
|
#define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff)
|
||||||
|
#define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16)
|
||||||
|
|
||||||
|
@@ -432,30 +428,19 @@ static int applesmc_has_key(const char *key, bool *value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z).
|
||||||
|
+ * applesmc_read_s16 - Read 16-bit signed big endian register
|
||||||
|
*/
|
||||||
|
-static int applesmc_read_motion_sensor(int index, s16 *value)
|
||||||
|
+static int applesmc_read_s16(const char *key, s16 *value)
|
||||||
|
{
|
||||||
|
u8 buffer[2];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- switch (index) {
|
||||||
|
- case SENSOR_X:
|
||||||
|
- ret = applesmc_read_key(MOTION_SENSOR_X_KEY, buffer, 2);
|
||||||
|
- break;
|
||||||
|
- case SENSOR_Y:
|
||||||
|
- ret = applesmc_read_key(MOTION_SENSOR_Y_KEY, buffer, 2);
|
||||||
|
- break;
|
||||||
|
- case SENSOR_Z:
|
||||||
|
- ret = applesmc_read_key(MOTION_SENSOR_Z_KEY, buffer, 2);
|
||||||
|
- break;
|
||||||
|
- default:
|
||||||
|
- ret = -EINVAL;
|
||||||
|
- }
|
||||||
|
+ ret = applesmc_read_key(key, buffer, 2);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
|
||||||
|
*value = ((s16)buffer[0] << 8) | buffer[1];
|
||||||
|
-
|
||||||
|
- return ret;
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -624,8 +609,8 @@ static struct platform_driver applesmc_driver = {
|
||||||
|
*/
|
||||||
|
static void applesmc_calibrate(void)
|
||||||
|
{
|
||||||
|
- applesmc_read_motion_sensor(SENSOR_X, &rest_x);
|
||||||
|
- applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
|
||||||
|
+ applesmc_read_s16(MOTION_SENSOR_X_KEY, &rest_x);
|
||||||
|
+ applesmc_read_s16(MOTION_SENSOR_Y_KEY, &rest_y);
|
||||||
|
rest_x = -rest_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -634,9 +619,9 @@ static void applesmc_idev_poll(struct input_polled_dev *dev)
|
||||||
|
struct input_dev *idev = dev->input;
|
||||||
|
s16 x, y;
|
||||||
|
|
||||||
|
- if (applesmc_read_motion_sensor(SENSOR_X, &x))
|
||||||
|
+ if (applesmc_read_s16(MOTION_SENSOR_X_KEY, &x))
|
||||||
|
return;
|
||||||
|
- if (applesmc_read_motion_sensor(SENSOR_Y, &y))
|
||||||
|
+ if (applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y))
|
||||||
|
return;
|
||||||
|
|
||||||
|
x = -x;
|
||||||
|
@@ -659,13 +644,13 @@ static ssize_t applesmc_position_show(struct device *dev,
|
||||||
|
int ret;
|
||||||
|
s16 x, y, z;
|
||||||
|
|
||||||
|
- ret = applesmc_read_motion_sensor(SENSOR_X, &x);
|
||||||
|
+ ret = applesmc_read_s16(MOTION_SENSOR_X_KEY, &x);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
- ret = applesmc_read_motion_sensor(SENSOR_Y, &y);
|
||||||
|
+ ret = applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
- ret = applesmc_read_motion_sensor(SENSOR_Z, &z);
|
||||||
|
+ ret = applesmc_read_s16(MOTION_SENSOR_Z_KEY, &z);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
|
@ -55,3 +55,8 @@ features/all/cpu-devices/Partially-revert-cpufreq-Add-support-for-x86-cpuinfo.pa
|
||||||
bugfix/all/udf-Improve-table-length-check-to-avoid-possible-underflow.patch
|
bugfix/all/udf-Improve-table-length-check-to-avoid-possible-underflow.patch
|
||||||
bugfix/all/net-e100-ucode-is-optional-in-some-cases.patch
|
bugfix/all/net-e100-ucode-is-optional-in-some-cases.patch
|
||||||
bugfix/x86/drm-i915-prefer-wide-slow-to-fast-narrow-in-DP-confi.patch
|
bugfix/x86/drm-i915-prefer-wide-slow-to-fast-narrow-in-DP-confi.patch
|
||||||
|
bugfix/all/hwmon-applesmc-Skip-sensor-mapping.patch
|
||||||
|
bugfix/all/hwmon-applesmc-Shorten-minimum-wait-time.patch
|
||||||
|
bugfix/all/hwmon-applesmc-Allow-negative-temperature-values.patch
|
||||||
|
bugfix/all/hwmon-applesmc-Ignore-some-temperature-registers.patch
|
||||||
|
bugfix/all/hwmon-applesmc-Decode-and-act-on-read-write-status-c.patch
|
||||||
|
|
Loading…
Reference in New Issue