|
From: <nbo...@us...> - 2007-03-14 18:16:43
|
Revision: 86
http://svn.sourceforge.net/mactel-linux/?rev=86&view=rev
Author: nboichat
Date: 2007-03-14 11:16:40 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Add sigmatel_audio patch again, 2.6.21 doesn't work with my Macbook Pro.
Number the patches so they get applied in the right order.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/unapply
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0002-appleir.patch
trunk/kernel/mactel-patches-2.6.21/0003-usb-storage-zerowait.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
trunk/kernel/mactel-patches-2.6.21/0005-appletouch.patch
trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/appleir.patch
trunk/kernel/mactel-patches-2.6.21/applesmc.patch
trunk/kernel/mactel-patches-2.6.21/appletouch.patch
trunk/kernel/mactel-patches-2.6.21/coretemp.patch
trunk/kernel/mactel-patches-2.6.21/usb-storage-zerowait.patch
Added: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-03-14 18:16:40 UTC (rev 86)
@@ -0,0 +1,1029 @@
+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).
+
+From: Nicolas Boichat <ni...@bo...>
+
+
+---
+
+ drivers/hwmon/Kconfig | 24 +
+ drivers/hwmon/Makefile | 1
+ drivers/hwmon/applesmc.c | 964 ++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 989 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
+index c3d4856..798b91d 100644
+--- a/drivers/hwmon/Kconfig
++++ b/drivers/hwmon/Kconfig
+@@ -593,6 +593,30 @@ config SENSORS_HDAPS
+ Say Y here if you have an applicable laptop and want to experience
+ the awesome power of hdaps.
+
++config SENSORS_APPLESMC
++ tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
++ depends on HWMON && INPUT && X86
++ select NEW_LEDS
++ select LEDS_CLASS
++ default n
++ help
++ 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).
++
++ Data from the different sensors, keyboard backlight control and fan
++ control are accessible via sysfs.
++
++ This driver also provides an absolute input class device, allowing
++ the laptop to act as a pinball machine-esque joystick.
++
++ Say Y here if you have an applicable laptop and want to experience
++ the awesome power of applesmc.
++
+ config HWMON_DEBUG_CHIP
+ bool "Hardware Monitoring Chip debugging messages"
+ depends on HWMON
+diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
+index 4165c27..544f8d8 100644
+--- a/drivers/hwmon/Makefile
++++ b/drivers/hwmon/Makefile
+@@ -20,6 +20,7 @@ obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
+ obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o
+ obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
+ obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
++obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
+ obj-$(CONFIG_SENSORS_AMS) += ams/
+ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
+ obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+new file mode 100644
+index 0000000..3bdd1a8
+--- /dev/null
++++ b/drivers/hwmon/applesmc.c
+@@ -0,0 +1,964 @@
++/*
++ * drivers/hwmon/applesmc.c - driver for Apple's SMC (accelerometer, temperature
++ * sensors, fan control, keyboard backlight control) used in Intel-based Apple
++ * computers.
++ *
++ * Copyright (C) 2007 Nicolas Boichat <ni...@bo...>
++ *
++ * Based on hdaps.c driver:
++ * Copyright (C) 2005 Robert Love <rm...@no...>
++ * Copyright (C) 2005 Jesper Juhl <jes...@gm...>
++ *
++ * Fan control based on smcFanControl:
++ * Copyright (C) 2006 Hendrik Holtmann <hol...@ma...>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License v2 as published by the
++ * Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * You should have received a copy of the GNU General Public License along with
++ * this program; if not, write to the Free Software Foundation, Inc.,
++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
++ */
++
++#include <linux/delay.h>
++#include <linux/platform_device.h>
++#include <linux/input.h>
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/timer.h>
++#include <linux/dmi.h>
++#include <asm/io.h>
++#include <linux/leds.h>
++
++/* data port used by apple SMC */
++#define APPLESMC_DATA_PORT 0x300
++/* command/status port used by apple SMC */
++#define APPLESMC_CMD_PORT 0x304
++
++#define APPLESMC_NR_PORTS 5 /* 0x300-0x304 */
++
++#define APPLESMC_STATUS_MASK 0x0f
++#define APPLESMC_READ_CMD 0x10
++#define APPLESMC_WRITE_CMD 0x11
++
++#define LIGHT_SENSOR_LEFT_KEY "ALV0" //r-o length 6
++#define LIGHT_SENSOR_RIGHT_KEY "ALV1" //r-o length 6
++#define BACKLIGHT_KEY "LKSB" //w-o
++
++#define CLAMSHELL_KEY "MSLD" //r-o length 1 (unused)
++
++#define MOTION_SENSOR_X_KEY "MO_X" //r-o length 2
++#define MOTION_SENSOR_Y_KEY "MO_Y" //r-o length 2
++#define MOTION_SENSOR_Z_KEY "MO_Z" //r-o length 2
++#define MOTION_SENSOR_KEY "MOCN" //r/w length 2
++
++#define FANS_COUNT "FNum" //r-o length 1
++#define FANS_MANUAL "FS! " //r-w length 2
++#define FAN_ACTUAL_SPEED "F0Ac" //r-o length 2
++#define FAN_MIN_SPEED "F0Mn" //r-o length 2
++#define FAN_MAX_SPEED "F0Mx" //r-o length 2
++#define FAN_SAFE_SPEED "F0Sf" //r-o length 2
++#define FAN_TARGET_SPEED "F0Tg" //r-w length 2
++
++/* Temperature sensors keys. First set for Macbook(Pro), second for Macmini */
++static const char* temperature_sensors_sets[][8] = {
++ { "TB0T", "TC0D", "TC0P", "Th0H", "Ts0P", "Th1H", "Ts1P", NULL },
++ { "TC0D", "TC0P", NULL }
++};
++
++#define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */
++#define INIT_WAIT_MSECS 50 /* ... in 50ms increments */
++
++#define APPLESMC_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */
++#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
++
++/* Structure to be passed to DMI_MATCH function */
++struct dmi_match_data {
++/* Indicates whether this computer has an accelerometer. */
++ int accelerometer;
++/* Indicates whether this computer has light sensors and keyboard backlight. */
++ int light;
++/* Indicates which temperature sensors set to use. */
++ int temperature_set;
++};
++
++static int debug = 0;
++static struct platform_device *pdev;
++static s16 rest_x;
++static s16 rest_y;
++static struct timer_list applesmc_timer;
++static struct input_dev *applesmc_idev;
++
++/* Indicates whether this computer has an accelerometer. */
++static unsigned int applesmc_accelerometer = 0;
++
++/* Indicates whether this computer has light sensors and keyboard backlight. */
++static unsigned int applesmc_light = 0;
++
++/* Indicates which temperature sensors set to use. */
++static unsigned int applesmc_temperature_set = 0;
++
++static DECLARE_MUTEX(applesmc_sem);
++
++/*
++ * __wait_status - Wait up to 100ms for the status port to get a certain value
++ * (masked with 0x0f), returning zero if the value is obtained. Callers must
++ * hold applesmc_sem.
++ */
++static int __wait_status(u8 val)
++{
++ unsigned int i;
++
++ val = val & APPLESMC_STATUS_MASK;
++
++ for (i = 0; i < 10000; i++) {
++ if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val)
++ return 0;
++ udelay(10);
++ }
++
++ printk(KERN_WARNING "applesmc: wait status failed: %x != %x\n",
++ val, inb(APPLESMC_CMD_PORT));
++
++ return -EIO;
++}
++
++/*
++ * applesmc_read_key - reads len bytes from a given key, and put them in buffer.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_sem.
++ */
++static int applesmc_read_key(const char* key, u8* buffer, u8 len)
++{
++ int ret = -EIO;
++ int i;
++
++ outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c))
++ goto out;
++
++ for (i = 0; i < 4; i++) {
++ outb(key[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04))
++ goto out;
++ }
++ if (debug) printk(KERN_DEBUG "<%s", key);
++
++ outb(len, APPLESMC_DATA_PORT);
++ if (debug) printk(KERN_DEBUG ">%x", len);
++
++ for (i = 0; i < len; i++) {
++ if (__wait_status(0x05))
++ goto out;
++ buffer[i] = inb(APPLESMC_DATA_PORT);
++ if (debug) printk(KERN_DEBUG "<%x", buffer[i]);
++ }
++ if (debug) printk(KERN_DEBUG "\n");
++ ret = 0;
++
++out:
++ return ret;
++}
++
++/*
++ * applesmc_write_key - writes len bytes from buffer to a given key.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_sem.
++ */
++static int applesmc_write_key(const char* key, u8* buffer, u8 len)
++{
++ int ret = -EIO;
++ int i;
++
++ outb(APPLESMC_WRITE_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c))
++ goto out;
++
++ for (i = 0; i < 4; i++) {
++ outb(key[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04))
++ goto out;
++ }
++
++ outb(len, APPLESMC_DATA_PORT);
++
++ for (i = 0; i < len; i++) {
++ if (__wait_status(0x04))
++ goto out;
++ outb(buffer[i], APPLESMC_DATA_PORT);
++ }
++
++ ret = 0;
++out:
++ return ret;
++}
++
++/*
++ * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). Callers must
++ * hold applesmc_sem.
++ */
++static int applesmc_read_motion_sensor(int index, 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;
++ }
++
++ *value = ((s16)buffer[0] << 8) | buffer[1];
++
++ return ret;
++}
++
++/*
++ * applesmc_device_init - initialize the accelerometer. Returns zero on success
++ * and negative error code on failure. Can sleep.
++ */
++static int applesmc_device_init(void)
++{
++ int total, ret = -ENXIO;
++ u8 buffer[2];
++
++ if (!applesmc_accelerometer) return 0;
++
++ down(&applesmc_sem);
++
++ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++ if (debug) printk(KERN_DEBUG "applesmc try %d\n", total);
++ if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
++ (buffer[0] != 0x00 || buffer[1] != 0x00)) {
++ if (total == INIT_TIMEOUT_MSECS) {
++ printk(KERN_DEBUG "applesmc: device has"
++ " already been initialized"
++ " (0x%02x, 0x%02x).\n",
++ buffer[0], buffer[1]);
++ }
++ else {
++ printk(KERN_DEBUG "applesmc: device"
++ " successfully initialized"
++ " (0x%02x, 0x%02x).\n",
++ buffer[0], buffer[1]);
++ }
++ ret = 0;
++ goto out;
++ }
++ buffer[0] = 0xe0;
++ buffer[1] = 0x00;
++ applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
++ msleep(INIT_WAIT_MSECS);
++ }
++
++ printk(KERN_WARNING "applesmc: failed to init the device\n");
++
++out:
++ up(&applesmc_sem);
++ return ret;
++}
++
++/*
++ * applesmc_get_fan_count - get the number of fans. Callers must NOT hold
++ * applesmc_sem.
++ */
++static int applesmc_get_fan_count(void)
++{
++ int ret;
++ u8 buffer[1];
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_key(FANS_COUNT, buffer, 1);
++
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return buffer[0];
++}
++
++/* Device model stuff */
++static int applesmc_probe(struct platform_device *dev)
++{
++ int ret;
++
++ ret = applesmc_device_init();
++ if (ret)
++ return ret;
++
++ printk(KERN_INFO "applesmc: device successfully initialized.\n");
++ return 0;
++}
++
++static int applesmc_resume(struct platform_device *dev)
++{
++ return applesmc_device_init();
++}
++
++static struct platform_driver applesmc_driver = {
++ .probe = applesmc_probe,
++ .resume = applesmc_resume,
++ .driver = {
++ .name = "applesmc",
++ .owner = THIS_MODULE,
++ },
++};
++
++/*
++ * applesmc_calibrate - Set our "resting" values. Callers must
++ * hold applesmc_sem.
++ */
++static void applesmc_calibrate(void)
++{
++ applesmc_read_motion_sensor(SENSOR_X, &rest_x);
++ applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
++}
++
++static void applesmc_mousedev_poll(unsigned long unused)
++{
++ s16 x, y;
++
++ /* Cannot sleep. Try nonblockingly. If we fail, try again later. */
++ if (down_trylock(&applesmc_sem)) {
++ mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
++ return;
++ }
++
++ if (applesmc_read_motion_sensor(SENSOR_X, &x))
++ goto out;
++ if (applesmc_read_motion_sensor(SENSOR_Y, &y))
++ goto out;
++
++
++ input_report_abs(applesmc_idev, ABS_X, x - rest_x);
++ input_report_abs(applesmc_idev, ABS_Y, y - rest_y);
++ input_sync(applesmc_idev);
++
++out:
++ mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
++
++ up(&applesmc_sem);
++}
++
++/* Sysfs Files */
++
++static ssize_t applesmc_position_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ int ret;
++ s16 x, y, z;
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_motion_sensor(SENSOR_X, &x);
++ if (ret)
++ goto out;
++ ret = applesmc_read_motion_sensor(SENSOR_Y, &y);
++ if (ret)
++ goto out;
++ ret = applesmc_read_motion_sensor(SENSOR_Z, &z);
++ if (ret)
++ goto out;
++
++out:
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return sprintf(buf, "(%d,%d,%d)\n", x, y, z);
++}
++
++static ssize_t applesmc_light_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ int ret;
++ u8 left = 0, right = 0;
++ u8 buffer[6];
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, 6);
++ left = buffer[2];
++ if (ret)
++ goto out;
++ ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, 6);
++ right = buffer[2];
++
++out:
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return sprintf(buf, "(%d,%d)\n", left, right);
++}
++
++/* Displays °C * 100 */
++static ssize_t applesmc_show_temperature(struct device *dev, char *buf,
++ const char *key)
++{
++ int ret;
++ u8 buffer[2];
++ unsigned int temp;
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_key(key, buffer, 2);
++ temp = buffer[0]*100;
++ temp += (buffer[1] >> 6) * 25;
++
++ up(&applesmc_sem);
++
++ if (ret)
++ return ret;
++ else
++ return sprintf(buf, "%u\n", temp);
++}
++
++static ssize_t applesmc_show_fan_speed(struct device *dev, char *buf,
++ const char* key, int offset)
++{
++ int ret;
++ unsigned int speed = 0;
++ char newkey[5];
++ u8 buffer[2];
++
++ newkey[0] = key[0];
++ newkey[1] = '0' + offset;
++ newkey[2] = key[2];
++ newkey[3] = key[3];
++ newkey[4] = 0;
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_key(newkey, buffer, 2);
++ speed = ((buffer[0] << 8 | buffer[1]) >> 2);
++
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return sprintf(buf, "%u\n", speed);
++}
++
++static ssize_t applesmc_store_fan_speed(struct device *dev, const char *buf,
++ size_t count, const char* key, int offset)
++{
++ int ret;
++ u32 speed;
++ char newkey[5];
++ u8 buffer[2];
++
++ speed = simple_strtoul(buf, NULL, 10);
++
++ if (speed > 0x4000) /* Bigger than a 14-bit value */
++ return -EINVAL;
++
++ newkey[0] = key[0];
++ newkey[1] = '0' + offset;
++ newkey[2] = key[2];
++ newkey[3] = key[3];
++ newkey[4] = 0;
++
++ down(&applesmc_sem);
++
++ buffer[0] = (speed >> 6) & 0xff;
++ buffer[1] = (speed << 2) & 0xff;
++ ret = applesmc_write_key(newkey, buffer, 2);
++
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return count;
++}
++
++static ssize_t applesmc_show_fan_manual(struct device *dev, char *buf,
++ int offset)
++{
++ int ret;
++ u16 manual = 0;
++ u8 buffer[2];
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
++ manual = ((buffer[0] << 8 | buffer[1]) >> offset) & 0x01;
++
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return sprintf(buf, "%d\n", manual);
++}
++
++static ssize_t applesmc_store_fan_manual(struct device *dev, const char *buf,
++ size_t count, int offset)
++{
++ int ret;
++ u8 buffer[2];
++ u32 input;
++ u16 val;
++
++ input = simple_strtoul(buf, NULL, 10);
++
++ down(&applesmc_sem);
++
++ ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
++ val = (buffer[0] << 8 | buffer[1]);
++ if (ret)
++ goto out;
++
++ if (input)
++ val = val | (0x01 << offset);
++ else
++ val = val & ~(0x01 << offset);
++
++ buffer[0] = (val >> 8) & 0xFF;
++ buffer[1] = val & 0xFF;
++
++ ret = applesmc_write_key(FANS_MANUAL, buffer, 2);
++
++out:
++ up(&applesmc_sem);
++ if (ret)
++ return ret;
++ else
++ return count;
++}
++
++static ssize_t applesmc_calibrate_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ return sprintf(buf, "(%d,%d)\n", rest_x, rest_y);
++}
++
++static ssize_t applesmc_calibrate_store(struct device *dev,
++ struct device_attribute *attr, const char *buf, size_t count)
++{
++ down(&applesmc_sem);
++ applesmc_calibrate();
++ up(&applesmc_sem);
++
++ return count;
++}
++
++static void applesmc_backlight_set(struct led_classdev *led_cdev,
++ enum led_brightness value)
++{
++ u8 buffer[2];
++
++ down(&applesmc_sem);
++ buffer[0] = value;
++ buffer[1] = 0x00;
++ applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
++ up(&applesmc_sem);
++}
++
++static struct led_classdev applesmc_backlight = {
++ .name = "smc:kbd_backlight",
++ .default_trigger = "nand-disk",
++ .brightness_set = applesmc_backlight_set,
++};
++
++static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
++static DEVICE_ATTR(calibrate, 0644,
++ applesmc_calibrate_show, applesmc_calibrate_store);
++
++static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL);
++
++/*
++ * Macro defining helper functions and DEVICE_ATTR for a fan sysfs entries.
++ * - show actual speed
++ * - show/store minimum speed
++ * - show maximum speed
++ * - show safe speed
++ * - show/store target speed
++ * - show/store manual mode
++ */
++#define sysfs_fan_speeds_offset(offset) \
++static ssize_t show_fan_actual_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_fan_speed(dev, buf, FAN_ACTUAL_SPEED, offset); \
++} \
++static DEVICE_ATTR(fan##offset##_actual_speed, S_IRUGO, \
++ show_fan_actual_speed_##offset, NULL); \
++\
++static ssize_t show_fan_minimum_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_fan_speed(dev, buf, FAN_MIN_SPEED, offset); \
++} \
++static ssize_t store_fan_minimum_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, const char *buf, size_t count) \
++{ \
++ return applesmc_store_fan_speed(dev, buf, count, FAN_MIN_SPEED, offset); \
++} \
++static DEVICE_ATTR(fan##offset##_minimum_speed, S_IRUGO | S_IWUSR, \
++ show_fan_minimum_speed_##offset, store_fan_minimum_speed_##offset); \
++\
++static ssize_t show_fan_maximum_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_fan_speed(dev, buf, FAN_MAX_SPEED, offset); \
++} \
++static DEVICE_ATTR(fan##offset##_maximum_speed, S_IRUGO, \
++ show_fan_maximum_speed_##offset, NULL); \
++\
++static ssize_t show_fan_safe_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_fan_speed(dev, buf, FAN_SAFE_SPEED, offset); \
++} \
++static DEVICE_ATTR(fan##offset##_safe_speed, S_IRUGO, \
++ show_fan_safe_speed_##offset, NULL); \
++\
++static ssize_t show_fan_target_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_fan_speed(dev, buf, FAN_TARGET_SPEED, offset); \
++} \
++static ssize_t store_fan_target_speed_##offset (struct device *dev, \
++ struct device_attribute *attr, const char *buf, size_t count) \
++{ \
++ return applesmc_store_fan_speed(dev, buf, count, FAN_TARGET_SPEED, offset); \
++} \
++static DEVICE_ATTR(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \
++ show_fan_target_speed_##offset, store_fan_target_speed_##offset); \
++static ssize_t show_fan_manual_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_fan_manual(dev, buf, offset); \
++} \
++static ssize_t store_fan_manual_##offset (struct device *dev, \
++ struct device_attribute *attr, const char *buf, size_t count) \
++{ \
++ return applesmc_store_fan_manual(dev, buf, count, offset); \
++} \
++static DEVICE_ATTR(fan##offset##_manual, S_IRUGO | S_IWUSR, \
++ show_fan_manual_##offset, store_fan_manual_##offset);
++
++/*
++ * Create the needed functions for each fan using the macro defined above
++ * (2 fans are supported)
++ */
++sysfs_fan_speeds_offset(0);
++sysfs_fan_speeds_offset(1);
++
++/* Macro creating the sysfs entries for a fan */
++#define device_create_file_fan(ret, client, offset) \
++do { \
++ret = sysfs_create_file(client, &dev_attr_fan##offset##_actual_speed.attr); \
++if (ret) break; \
++ret = sysfs_create_file(client, &dev_attr_fan##offset##_minimum_speed.attr); \
++if (ret) break; \
++ret = sysfs_create_file(client, &dev_attr_fan##offset##_maximum_speed.attr); \
++if (ret) break; \
++ret = sysfs_create_file(client, &dev_attr_fan##offset##_safe_speed.attr); \
++if (ret) break; \
++ret = sysfs_create_file(client, &dev_attr_fan##offset##_target_speed.attr); \
++if (ret) break; \
++ret = sysfs_create_file(client, &dev_attr_fan##offset##_manual.attr); \
++} while (0)
++
++/*
++ * Macro defining the helper function and DEVICE_ATTR for a temperature sensor
++ * sysfs entry.
++ */
++#define sysfs_temperature_offset(offset) \
++static ssize_t show_temperature_##offset (struct device *dev, \
++ struct device_attribute *attr, char *buf) \
++{ \
++ return applesmc_show_temperature(dev, buf, \
++ temperature_sensors_sets[applesmc_temperature_set][offset]); \
++} \
++static DEVICE_ATTR(temperature_##offset, S_IRUGO, \
++ show_temperature_##offset, NULL);
++
++/*
++ * Create the needed functions for each temperature sensors using the macro
++ * defined above (7 temperature sensors are supported)
++ */
++sysfs_temperature_offset(0);
++sysfs_temperature_offset(1);
++sysfs_temperature_offset(2);
++sysfs_temperature_offset(3);
++sysfs_temperature_offset(4);
++sysfs_temperature_offset(5);
++sysfs_temperature_offset(6);
++
++/* Macro creating the sysfs entry for a temperature sensor */
++#define device_create_files_temperature(ret, client, offset) \
++{ \
++ ret = sysfs_create_file(client, &dev_attr_temperature_##offset.attr); \
++} while (0)
++
++/* Module stuff */
++
++/*
++ * applesmc_dmi_match - found a match. return one, short-circuiting the hunt.
++ */
++static int applesmc_dmi_match(struct dmi_system_id *id)
++{
++ int i = 0;
++ struct dmi_match_data* dmi_data =
++ (struct dmi_match_data*)id->driver_data;
++ printk(KERN_INFO "applesmc: %s detected:\n", id->ident);
++ applesmc_accelerometer = dmi_data->accelerometer;
++ printk(KERN_INFO "applesmc: - Model %s accelerometer\n",
++ applesmc_accelerometer ? "with" : "without");
++ applesmc_light = dmi_data->light;
++ printk(KERN_INFO "applesmc: - Model %s light sensors and backlight\n",
++ applesmc_light ? "with" : "without");
++
++ applesmc_temperature_set = dmi_data->temperature_set;
++ while (temperature_sensors_sets[applesmc_temperature_set][i] != NULL)
++ i++;
++ printk(KERN_INFO "applesmc: - Model with %d temperature sensors\n", i);
++ return 1;
++}
++
++/* Create accelerometer ressources */
++static int applesmc_create_accelerometer(void) {
++ int ret;
++
++ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_position.attr);
++ if (ret)
++ goto out;
++
++ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_calibrate.attr);
++ if (ret)
++ goto out;
++
++ applesmc_idev = input_allocate_device();
++ if (!applesmc_idev) {
++ ret = -ENOMEM;
++ goto out;
++ }
++
++ /* initial calibrate for the input device */
++ applesmc_calibrate();
++
++ /* initialize the input class */
++ applesmc_idev->name = "applesmc";
++ applesmc_idev->cdev.dev = &pdev->dev;
++ applesmc_idev->evbit[0] = BIT(EV_ABS);
++ input_set_abs_params(applesmc_idev, ABS_X,
++ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
++ input_set_abs_params(applesmc_idev, ABS_Y,
++ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
++
++ input_register_device(applesmc_idev);
++
++ /* start up our timer for the input device */
++ init_timer(&applesmc_timer);
++ applesmc_timer.function = applesmc_mousedev_poll;
++ applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
++ add_timer(&applesmc_timer);
++
++ return 0;
++
++out:
++ printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
++ return ret;
++}
++
++/* Release all ressources used by the accelerometer */
++static void applesmc_release_accelerometer(void) {
++ del_timer_sync(&applesmc_timer);
++ input_unregister_device(applesmc_idev);
++}
++
++static int __init applesmc_init(void)
++{
++ int ret;
++ int count;
++
++ struct dmi_match_data applesmc_dmi_data[] = {
++ /* MacBook Pro: accelerometer, backlight and temperature set 0 */
++ { .accelerometer = 1, .light = 1, .temperature_set = 0 },
++ /* MacBook: accelerometer and temperature set 0 */
++ { .accelerometer = 1, .light = 0, .temperature_set = 0 },
++ /* MacBook: temperature set 1 */
++ { .accelerometer = 0, .light = 0, .temperature_set = 1 }
++ };
++
++ /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
++ * So we need to put "Apple MacBook Pro" before "Apple MacBook". */
++ struct dmi_system_id applesmc_whitelist[] = {
++ { applesmc_dmi_match, "Apple MacBook Pro", {
++ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++ DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") },
++ (void*)&applesmc_dmi_data[0]},
++ { applesmc_dmi_match, "Apple MacBook", {
++ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++ DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") },
++ (void*)&applesmc_dmi_data[1]},
++ { applesmc_dmi_match, "Apple Macmini", {
++ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++ DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") },
++ (void*)&applesmc_dmi_data[2]},
++ { .ident = NULL }
++ };
++
++ if (!dmi_check_system(applesmc_whitelist)) {
++ printk(KERN_WARNING "applesmc: supported laptop not found!\n");
++ ret = -ENODEV;
++ goto out;
++ }
++
++ if (!request_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS,
++ "applesmc")) {
++ ret = -ENXIO;
++ goto out;
++ }
++
++ ret = platform_driver_register(&applesmc_driver);
++ if (ret)
++ goto out_region;
++
++ pdev = platform_device_register_simple("applesmc", -1, NULL, 0);
++ if (IS_ERR(pdev)) {
++ ret = PTR_ERR(pdev);
++ goto out_driver;
++ }
++
++ /* create fan files */
++ count = applesmc_get_fan_count();
++ if (count < 0) {
++ printk(KERN_ERR "applesmc: Cannot get the number of fans.\n");
++ }
++ else {
++ printk(KERN_INFO "applesmc: %d fans found.\n", count);
++
++ switch (count) {
++ default:
++ printk(KERN_WARNING "applesmc: More than 2 fans found,"
++ " but at most 2 fans are supported"
++ " by the driver.\n");
++ case 2:
++ device_create_file_fan(ret, &pdev->dev.kobj, 1);
++ if (ret)
++ goto out_device;
++ case 1:
++ device_create_file_fan(ret, &pdev->dev.kobj, 0);
++ if (ret)
++ goto out_device;
++ case 0:
++ ;
++ }
++ }
++
++ count = 0;
++ while (temperature_sensors_sets[applesmc_temperature_set][count]
++ != NULL)
++ count++;
++
++ switch (count) {
++ default:
++ case 7:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 6);
++ if (ret)
++ goto out_device;
++ case 6:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 5);
++ if (ret)
++ goto out_device;
++ case 5:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 4);
++ if (ret)
++ goto out_device;
++ case 4:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 3);
++ if (ret)
++ goto out_device;
++ case 3:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 2);
++ if (ret)
++ goto out_device;
++ case 2:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 1);
++ if (ret)
++ goto out_device;
++ case 1:
++ device_create_files_temperature(ret, &pdev->dev.kobj, 0);
++ if (ret)
++ goto out_device;
++ case 0:
++ ;
++ }
++
++ if (applesmc_accelerometer) {
++ ret = applesmc_create_accelerometer();
++ if (ret)
++ goto out_device;
++ }
++
++ if (applesmc_light) {
++ /* Add light sensor file */
++ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_light.attr);
++ if (ret)
++ goto out_accelerometer;
++
++ /* register as a led device */
++ ret = led_classdev_register(&pdev->dev, &applesmc_backlight);
++ if (ret < 0)
++ goto out_accelerometer;
++ }
++
++ printk(KERN_INFO "applesmc: driver successfully loaded.\n");
++ return 0;
++
++out_accelerometer:
++ if (applesmc_accelerometer)
++ applesmc_release_accelerometer();
++out_device:
++ platform_device_unregister(pdev);
++out_driver:
++ platform_driver_unregister(&applesmc_driver);
++out_region:
++ release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
++out:
++ printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
++ return ret;
++}
++
++static void __exit applesmc_exit(void)
++{
++ if (applesmc_light)
++ led_classdev_unregister(&applesmc_backlight);
++ if (applesmc_accelerometer)
++ applesmc_release_accelerometer();
++ platform_device_unregister(pdev);
+...
[truncated message content] |
|
From: <nbo...@us...> - 2007-03-15 06:18:38
|
Revision: 87
http://svn.sourceforge.net/mactel-linux/?rev=87&view=rev
Author: nboichat
Date: 2007-03-14 23:18:32 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Remove usb-storage-zerowait.
Update sigmatel-audio (modifications asked by upstream maintainer)
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/0003-usb-storage-zerowait.patch
Deleted: trunk/kernel/mactel-patches-2.6.21/0003-usb-storage-zerowait.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0003-usb-storage-zerowait.patch 2007-03-14 18:16:40 UTC (rev 86)
+++ trunk/kernel/mactel-patches-2.6.21/0003-usb-storage-zerowait.patch 2007-03-15 06:18:32 UTC (rev 87)
@@ -1,23 +0,0 @@
-Zero-wait on usb-storage.
-
-From: ? <?>
-
-
----
-
- drivers/usb/storage/usb.c | 2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
-index 8e898e3..6e33e13 100644
---- a/drivers/usb/storage/usb.c
-+++ b/drivers/usb/storage/usb.c
-@@ -107,7 +107,7 @@ MODULE_AUTHOR("Matthew Dharm <mdh...@on...>");
- MODULE_DESCRIPTION("USB Mass Storage driver for Linux");
- MODULE_LICENSE("GPL");
-
--static unsigned int delay_use = 5;
-+static unsigned int delay_use = 0;
- module_param(delay_use, uint, S_IRUGO | S_IWUSR);
- MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
-
Modified: trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch 2007-03-14 18:16:40 UTC (rev 86)
+++ trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch 2007-03-15 06:18:32 UTC (rev 87)
@@ -5,11 +5,26 @@
---
- sound/pci/hda/patch_sigmatel.c | 21 +++++++++++++++++----
- 1 files changed, 17 insertions(+), 4 deletions(-)
+ Documentation/sound/alsa/ALSA-Configuration.txt | 3 ++-
+ sound/pci/hda/patch_sigmatel.c | 25 +++++++++++++++++------
+ 2 files changed, 21 insertions(+), 7 deletions(-)
+diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
+index db398a6..438f3fe 100644
+--- a/Documentation/sound/alsa/ALSA-Configuration.txt
++++ b/Documentation/sound/alsa/ALSA-Configuration.txt
+@@ -906,7 +906,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
+ 5stack D945 5stack + SPDIF
+ macmini Intel Mac Mini
+ macbook Intel Mac Book
+- macbook-pro Intel Mac Book Pro
++ macbook-pro-v1 Intel Mac Book Pro 1st generation
++ macbook-pro Intel Mac Book Pro 2nd generation
+
+ STAC9202/9250/9251
+ ref Reference board, base config
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 4c7b039..5ee9a82 100644
+index 4c7b039..2d78a9f 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -60,7 +60,8 @@ enum {
@@ -22,26 +37,28 @@
STAC_922X_MODELS
};
-@@ -529,6 +530,12 @@ static unsigned int macbook_pin_configs[10] = {
+@@ -529,7 +530,13 @@ static unsigned int macbook_pin_configs[10] = {
0x400000fc, 0x400000fb,
};
+-static unsigned int macbook_pro_pin_configs[10] = {
+static unsigned int macbook_pro_v1_pin_configs[10] = {
-+ 0x0321E230, 0x03A1E020, 0x9017E110, 0x01014010,
-+ 0x01a19021, 0x0381E021, 0x1345E240, 0x13C5E22E,
-+ 0x02a19320, 0x400000FB,
++ 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
++ 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
++ 0x02a19320, 0x400000fb
+};
+
- static unsigned int macbook_pro_pin_configs[10] = {
++static unsigned int macbook_pro_v2_pin_configs[10] = {
0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
+ 0x400000fc, 0x400000fb,
@@ -541,7 +548,8 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
[STAC_D945GTP5] = d945gtp5_pin_configs,
[STAC_MACMINI] = d945gtp5_pin_configs,
[STAC_MACBOOK] = macbook_pin_configs,
- [STAC_MACBOOK_PRO] = macbook_pro_pin_configs,
+ [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
-+ [STAC_MACBOOK_PRO_V2] = macbook_pro_pin_configs,
++ [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
};
static const char *stac922x_models[STAC_922X_MODELS] = {
@@ -51,7 +68,7 @@
[STAC_MACBOOK] = "macbook",
- [STAC_MACBOOK_PRO] = "macbook-pro",
+ [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
-+ [STAC_MACBOOK_PRO_V2] = "macbook-pro-v2",
++ [STAC_MACBOOK_PRO_V2] = "macbook-pro",
};
static struct snd_pci_quirk stac922x_cfg_tbl[] = {
@@ -61,11 +78,12 @@
*/
+ printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
switch (codec->subsystem_id) {
+- case 0x106b1e00:
+- spec->board_config = STAC_MACBOOK_PRO;
+ case 0x106b0200: /* MacBook Pro first generation */
+ spec->board_config = STAC_MACBOOK_PRO_V1;
+ break;
- case 0x106b1e00:
-- spec->board_config = STAC_MACBOOK_PRO;
++ case 0x106b1e00: /* MacBook Pro second generation */
+ spec->board_config = STAC_MACBOOK_PRO_V2;
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Tino K. <tin...@ti...> - 2007-03-20 08:08:05
|
On Wed, Mar 14, 2007 at 23:18:32 -0700, nbo...@us... wrote: > Revision: 87 > http://svn.sourceforge.net/mactel-linux/?rev=87&view=rev > Author: nboichat > Date: 2007-03-14 23:18:32 -0700 (Wed, 14 Mar 2007) > > Log Message: > ----------- > Remove usb-storage-zerowait. > Update sigmatel-audio (modifications asked by upstream maintainer) Hi, I gave the new sigmatel patches a quick test with 2.6.21-rc4 on my mini and the internal speaker, digital out and line in were ok. Regards, Tino |
|
From: <nbo...@us...> - 2007-03-18 22:58:57
|
Revision: 88
http://svn.sourceforge.net/mactel-linux/?rev=88&view=rev
Author: nboichat
Date: 2007-03-17 11:41:11 -0700 (Sat, 17 Mar 2007)
Log Message:
-----------
Fix sound on Macbook and Macmini.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-03-15 06:18:32 UTC (rev 87)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-03-17 18:41:11 UTC (rev 88)
@@ -11,10 +11,10 @@
3 files changed, 989 insertions(+), 0 deletions(-)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
-index c3d4856..798b91d 100644
+index 6d105a1..25b72a4 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
-@@ -593,6 +593,30 @@ config SENSORS_HDAPS
+@@ -594,6 +594,30 @@ config SENSORS_HDAPS
Say Y here if you have an applicable laptop and want to experience
the awesome power of hdaps.
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-03-15 06:18:32 UTC (rev 87)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-03-17 18:41:11 UTC (rev 88)
@@ -5,14 +5,58 @@
---
- arch/i386/kernel/msr.c | 31 ++--
- drivers/hwmon/Kconfig | 9 +
- drivers/hwmon/Makefile | 1
- drivers/hwmon/coretemp.c | 400 ++++++++++++++++++++++++++++++++++++++++++++++
- include/asm-i386/msr.h | 3
- include/asm-x86_64/msr.h | 3
- 6 files changed, 433 insertions(+), 14 deletions(-)
+ Documentation/hwmon/coretemp | 37 ++++
+ arch/i386/kernel/msr.c | 31 ++-
+ drivers/hwmon/Kconfig | 9 +
+ drivers/hwmon/Makefile | 1
+ drivers/hwmon/coretemp.c | 400 ++++++++++++++++++++++++++++++++++++++++++
+ include/asm-i386/msr.h | 3
+ include/asm-x86_64/msr.h | 3
+ 7 files changed, 470 insertions(+), 14 deletions(-)
+diff --git a/Documentation/hwmon/coretemp b/Documentation/hwmon/coretemp
+new file mode 100644
+index 0000000..ba02dee
+--- /dev/null
++++ b/Documentation/hwmon/coretemp
+@@ -0,0 +1,37 @@
++Kernel driver coretemp
++======================
++
++Supported chips:
++ * All Intel Core family
++ Prefix: 'coretemp'
++ Addresses scanned: CPUID (family 0x6, models 0xe, 0xf)
++ Datasheet: Intel 64 and IA-32 Architectures Software Developer's Manual
++ Volume 3A: System Programming Guide
++
++Author: Rudolf Marek
++Contact: Rudolf Marek <r....@as...>
++
++Description
++-----------
++
++This driver permits reading temperature sensor embedded inside Intel Core CPU.
++Temperature is measured in degrees Celsius and measurement resolution is
++1 degree C. Valid temperatures are from 0 to TjMax degrees C, because
++the actual temperature is in fact a delta from TjMax.
++
++Temperature known as TjMax is the maximum junction temperature of processor.
++Intel defines this temperature as 85C or 100C. At this temperature, protection
++mechanism will perform actions to forcibly cool down the processor. Alarm
++may be raised, if the temperature grows enough (more than TjMax) to trigger
++the Out-Of-Spec bit. Following table summarizes the exported sysfs files:
++
++temp1_input - Core temperature (in milidegrees of Celsius).
++temp1_crit - Maximum junction temperature (in milidegrees of Celsius).
++temp1_crit_alarm - Set when Out-of-spec bit is set, never clears.
++ Correct CPU operation is no longer guaranteed.
++temp1_label - Contains string with the "Core X", where X is processor
++ number.
++
++The TjMax temperature is set to 85C if undocumented model specific register
++(UMSR) 0xee has bit 30 set. If not the TjMax is 100C as documented in processor
++datasheet. Intel will not disclose this information to individuals.
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index bcaa6e9..c9a8f88 100644
--- a/arch/i386/kernel/msr.c
@@ -122,7 +166,7 @@
static int msr_device_create(int i)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
-index 798b91d..5278f1d 100644
+index 25b72a4..873e463 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -167,6 +167,15 @@ config SENSORS_ATXP1
Added: trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-03-17 18:41:11 UTC (rev 88)
@@ -0,0 +1,38 @@
+Fix audio on Macmini and Macbook.
+
+From: Takashi Iwai <ti...@su...>
+
+
+---
+
+ sound/pci/hda/patch_sigmatel.c | 10 ++--------
+ 1 files changed, 2 insertions(+), 8 deletions(-)
+
+diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
+index 2d78a9f..9ff5cf2 100644
+--- a/sound/pci/hda/patch_sigmatel.c
++++ b/sound/pci/hda/patch_sigmatel.c
+@@ -524,12 +524,6 @@ static unsigned int d945gtp5_pin_configs[10] = {
+ 0x02a19320, 0x40000100,
+ };
+
+-static unsigned int macbook_pin_configs[10] = {
+- 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110,
+- 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e,
+- 0x400000fc, 0x400000fb,
+-};
+-
+ static unsigned int macbook_pro_v1_pin_configs[10] = {
+ 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
+ 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
+@@ -546,8 +540,8 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
+ [STAC_D945_REF] = ref922x_pin_configs,
+ [STAC_D945GTP3] = d945gtp3_pin_configs,
+ [STAC_D945GTP5] = d945gtp5_pin_configs,
+- [STAC_MACMINI] = d945gtp5_pin_configs,
+- [STAC_MACBOOK] = macbook_pin_configs,
++ [STAC_MACMINI] = macbook_pro_v1_pin_configs,
++ [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
+ [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
+ [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
+ };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-09 10:36:27
|
Revision: 101
http://svn.sourceforge.net/mactel-linux/?rev=101&view=rev
Author: nboichat
Date: 2007-04-09 03:36:08 -0700 (Mon, 09 Apr 2007)
Log Message:
-----------
Update patches to 2.6.21-rc6 (offsets).
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-07 12:59:40 UTC (rev 100)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-09 10:36:08 UTC (rev 101)
@@ -12,10 +12,10 @@
4 files changed, 948 insertions(+), 0 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
-index 8c8090e..57a2d44 100644
+index 829407f..3e19a09 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
-@@ -367,6 +367,12 @@ L: lin...@vg...
+@@ -382,6 +382,12 @@ L: lin...@vg...
W: http://www.canb.auug.org.au/~sfr/
S: Supported
Modified: trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch 2007-04-07 12:59:40 UTC (rev 100)
+++ trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch 2007-04-09 10:36:08 UTC (rev 101)
@@ -130,7 +130,7 @@
+EXPORT_SYMBOL(rdmsr_safe_on_cpu);
+EXPORT_SYMBOL(wrmsr_safe_on_cpu);
diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
-index ec3b680..5ed97c8 100644
+index 2ad3f30..e6a2a34 100644
--- a/include/asm-i386/msr.h
+++ b/include/asm-i386/msr.h
@@ -4,7 +4,7 @@
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-07 12:59:40 UTC (rev 100)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-09 10:36:08 UTC (rev 101)
@@ -55,10 +55,10 @@
+register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
+(sometimes) documented in processor datasheet.
diff --git a/MAINTAINERS b/MAINTAINERS
-index 57a2d44..28b4fbf 100644
+index 3e19a09..b12f11a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
-@@ -958,6 +958,12 @@ M: mh...@wi...
+@@ -973,6 +973,12 @@ M: mh...@wi...
W: http://www.wittsend.com/computone.html
S: Maintained
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-10 09:50:18
|
Revision: 106
http://svn.sourceforge.net/mactel-linux/?rev=106&view=rev
Author: nboichat
Date: 2007-04-10 02:50:11 -0700 (Tue, 10 Apr 2007)
Log Message:
-----------
Fix audio on Macbook 1st generation.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-04-10 09:49:42 UTC (rev 105)
+++ trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-04-10 09:50:11 UTC (rev 106)
@@ -5,11 +5,11 @@
---
- sound/pci/hda/patch_sigmatel.c | 18 +++++++++---------
- 1 files changed, 9 insertions(+), 9 deletions(-)
+ sound/pci/hda/patch_sigmatel.c | 19 ++++++++++---------
+ 1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index c94291b..4c5fee3 100644
+index c94291b..07bfc6e 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -524,16 +524,16 @@ static unsigned int d945gtp5_pin_configs[10] = {
@@ -47,3 +47,11 @@
[STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
[STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
};
+@@ -1905,6 +1905,7 @@ static int patch_stac922x(struct hda_codec *codec)
+ */
+ printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
+ switch (codec->subsystem_id) {
++ case 0x106b0a00: /* MacBook first generation */
+ case 0x106b0200: /* MacBook Pro first generation */
+ spec->board_config = STAC_MACBOOK_PRO_V1;
+ break;
Modified: trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-10 09:49:42 UTC (rev 105)
+++ trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-10 09:50:11 UTC (rev 106)
@@ -9,14 +9,14 @@
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 4c5fee3..13cb0c5 100644
+index 07bfc6e..4f064c3 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1905,6 +1905,7 @@ static int patch_stac922x(struct hda_codec *codec)
*/
printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
switch (codec->subsystem_id) {
-+ case 0x100:
++ case 0x100: /* Invalid subsystem ID */
+ case 0x106b0a00: /* MacBook first generation */
case 0x106b0200: /* MacBook Pro first generation */
spec->board_config = STAC_MACBOOK_PRO_V1;
- break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-11 09:36:14
|
Revision: 112
http://svn.sourceforge.net/mactel-linux/?rev=112&view=rev
Author: nboichat
Date: 2007-04-11 02:36:05 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
Fix missing ;.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-04-11 07:48:53 UTC (rev 111)
+++ trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-04-11 09:36:05 UTC (rev 112)
@@ -9,10 +9,10 @@
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index c94291b..af46702 100644
+index c94291b..b1df711 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -524,16 +524,22 @@ static unsigned int d945gtp5_pin_configs[10] = {
+@@ -524,18 +524,24 @@ static unsigned int d945gtp5_pin_configs[10] = {
0x02a19320, 0x40000100,
};
@@ -31,15 +31,17 @@
0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
0x02a19320, 0x400000fb
-+}
-+
+ };
+
+static unsigned int macbook_pro_v1_pin_configs[10] = {
+ 0x0321e230, 0x02a7e020, 0x9017e110, 0x01014010,
+ 0x400000fd, 0x0381e021, 0x1345e240, 0x13c5e22e,
+ 0x400000fc, 0x400000fb
- };
-
++};
++
static unsigned int macbook_pro_v2_pin_configs[10] = {
+ 0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
+ 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
@@ -546,7 +552,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
[STAC_D945_REF] = ref922x_pin_configs,
[STAC_D945GTP3] = d945gtp3_pin_configs,
Modified: trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-11 07:48:53 UTC (rev 111)
+++ trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-11 09:36:05 UTC (rev 112)
@@ -9,7 +9,7 @@
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index af46702..89a7e19 100644
+index b1df711..4fa6049 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1914,6 +1914,7 @@ static int patch_stac922x(struct hda_codec *codec)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-12 16:36:47
|
Revision: 113
http://svn.sourceforge.net/mactel-linux/?rev=113&view=rev
Author: nboichat
Date: 2007-04-12 09:36:44 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
Update patch descriptions.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
trunk/kernel/mactel-patches-2.6.21/0008-msr.patch
trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-11 09:36:05 UTC (rev 112)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-12 16:36:44 UTC (rev 113)
@@ -1,4 +1,4 @@
-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).
+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). - SENT UPSTREAM - in mm tree
From: Nicolas Boichat <ni...@bo...>
Modified: trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch 2007-04-11 09:36:05 UTC (rev 112)
+++ trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch 2007-04-12 16:36:44 UTC (rev 113)
@@ -1,4 +1,4 @@
-This patch adds support for _safe (exception handled) variants of rdmsr_on_cpu and wrmsr_on_cpu. This is needed for the new coretemp driver, which might step into non-existing MSR (poorly documented).
+This patch adds support for _safe (exception handled) variants of rdmsr_on_cpu and wrmsr_on_cpu. This is needed for the new coretemp driver, which might step into non-existing MSR (poorly documented). -- FROM UPSTREAM - in mm
From: Rudolf Marek <r....@as...>
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-11 09:36:05 UTC (rev 112)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-12 16:36:44 UTC (rev 113)
@@ -1,4 +1,4 @@
-Intel Core CPU temperature monitor driver.
+Intel Core CPU temperature monitor driver. -- FROM UPSTREAM - in mm
From: lm-sensors mailing list <?>
Modified: trunk/kernel/mactel-patches-2.6.21/0008-msr.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0008-msr.patch 2007-04-11 09:36:05 UTC (rev 112)
+++ trunk/kernel/mactel-patches-2.6.21/0008-msr.patch 2007-04-12 16:36:44 UTC (rev 113)
@@ -1,4 +1,4 @@
-Use functions provided by arch/*/lib/msr-on-cpu.c in arch/i386/kernel/msr.c.
+Use functions provided by arch/*/lib/msr-on-cpu.c in arch/i386/kernel/msr.c. -- FROM UPSTREAM - in mm
From: Nicolas Boichat <ni...@bo...>
Modified: trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch 2007-04-11 09:36:05 UTC (rev 112)
+++ trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch 2007-04-12 16:36:44 UTC (rev 113)
@@ -1,4 +1,4 @@
-- Invert y axis on input device. - Only activate the input device polling timer when the device is open. - Others fixes as asked by Dmitry Torokhov.
+- Invert y axis on input device. - Only activate the input device polling timer when the device is open. - Others fixes as asked by Dmitry Torokhov. - SENT UPSTREAM - in mm tree
From: Nicolas Boichat <ni...@bo...>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-12 16:38:08
|
Revision: 114
http://svn.sourceforge.net/mactel-linux/?rev=114&view=rev
Author: nboichat
Date: 2007-04-12 09:38:05 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
Fix applesmc patch, and break it in parts (standard and enum will be sent first to -mm, int needs more testing on different hardware).
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/0011-applesmc_standard.patch
trunk/kernel/mactel-patches-2.6.21/0012-applesmc_enum.patch
trunk/kernel/mactel-patches-2.6.21/0013-applesmc_int.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch
Deleted: trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch 2007-04-12 16:36:44 UTC (rev 113)
+++ trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch 2007-04-12 16:38:05 UTC (rev 114)
@@ -1,799 +0,0 @@
-New features for applesmc: 1. Add support for keys enumeration. 2. IRQ support for the accelerometer. 3. Add more temperature sensors on the Macbook Pro. 4. Add fan description reading.
-
-From: Nicolas Boichat <ni...@bo...>
-
-
----
-
- drivers/hwmon/applesmc.c | 601 +++++++++++++++++++++++++++++++++++++++++-----
- 1 files changed, 535 insertions(+), 66 deletions(-)
-
-diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index f7b59fc..f320f7b 100644
---- a/drivers/hwmon/applesmc.c
-+++ b/drivers/hwmon/applesmc.c
-@@ -37,40 +37,69 @@
- #include <linux/hwmon-sysfs.h>
- #include <asm/io.h>
- #include <linux/leds.h>
-+#include <linux/interrupt.h>
-
--/* data port used by apple SMC */
--#define APPLESMC_DATA_PORT 0x300
--/* command/status port used by apple SMC */
--#define APPLESMC_CMD_PORT 0x304
-+/* data port used by Apple SMC */
-+#define APPLESMC_DATA_PORT 0x300
-+/* command/status port used by Apple SMC */
-+#define APPLESMC_CMD_PORT 0x304
-+/* status port used by Apple SMC to get which interrupt type just happened */
-+#define APPLESMC_INT_PORT 0x31f
-
--#define APPLESMC_NR_PORTS 5 /* 0x300-0x304 */
-+#define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
-
--#define APPLESMC_STATUS_MASK 0x0f
--#define APPLESMC_READ_CMD 0x10
--#define APPLESMC_WRITE_CMD 0x11
-+#define APPLESMC_MAX_DATA_LENGTH 32
-+
-+/* Defined in ACPI DSDT table, should we read it from there? */
-+#define APPLESMC_IRQ 6
-+
-+#define APPLESMC_STATUS_MASK 0x0f
-+#define APPLESMC_READ_CMD 0x10
-+#define APPLESMC_WRITE_CMD 0x11
-+#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12
-+#define APPLESMC_GET_KEY_INFO_CMD 0x13
-+
-+#define KEY_COUNT_KEY "#KEY" /* r-o ui32 */
-+
-+#define INTERRUPT_OK_KEY "NTOK" /* w-o ui8 */
-
- #define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o length 6 */
- #define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o length 6 */
--#define BACKLIGHT_KEY "LKSB" /* w-o */
-+#define BACKLIGHT_KEY "LKSB" /* w-o length 2 */
-
--#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */
-+#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */
-
--#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */
--#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */
--#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */
--#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */
-+#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */
-+#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */
-+#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
-+#define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
-
--#define FANS_COUNT "FNum" /* r-o length 1 */
--#define FANS_MANUAL "FS! " /* r-w length 2 */
--#define FAN_ACTUAL_SPEED "F0Ac" /* r-o length 2 */
--#define FAN_MIN_SPEED "F0Mn" /* r-o length 2 */
--#define FAN_MAX_SPEED "F0Mx" /* r-o length 2 */
--#define FAN_SAFE_SPEED "F0Sf" /* r-o length 2 */
--#define FAN_TARGET_SPEED "F0Tg" /* r-w length 2 */
-+/*
-+ * Interrupt controls.
-+ * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than
-+ * MOLT (free fall), or bigger than MOHT (high acceleration) for longer than the
-+ * value of MOLD (or MOHD), SMC will trigger an interrupt.
-+ */
-+#define MOTION_LOW_NORM "MOLT" /* r/w sp78 (2 bytes) */
-+#define MOTION_HIGH_NORM "MOHT" /* r/w sp78 (2 bytes) */
-+#define MOTION_LOW_NORM_INTERVAL "MOLD" /* r/w ui8 */
-+#define MOTION_HIGH_NORM_INTERVAL "MOHD" /* r/w ui8 */
-+
-+#define MSDW_KEY "MSDW" /* r/w flag (1 byte) */
-+
-+#define FANS_COUNT "FNum" /* r-o ui8 */
-+#define FANS_MANUAL "FS! " /* r-w ui16 */
-+#define FAN_ACTUAL_SPEED "F0Ac" /* r-o fpe2 */
-+#define FAN_MIN_SPEED "F0Mn" /* r-o fpe2 */
-+#define FAN_MAX_SPEED "F0Mx" /* r-o fpe2 */
-+#define FAN_SAFE_SPEED "F0Sf" /* r-o fpe2 */
-+#define FAN_TARGET_SPEED "F0Tg" /* r-w fpe2 */
-+#define FAN_ID "F0ID" /* r-o char[16] */
-
- /* Temperature sensors keys. First set for Macbook(Pro), second for Macmini */
--static const char* temperature_sensors_sets[][8] = {
-- { "TB0T", "TC0D", "TC0P", "Th0H", "Ts0P", "Th1H", "Ts1P", NULL },
-+static const char* temperature_sensors_sets[][13] = {
-+ { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
-+ "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
- { "TC0D", "TC0P", NULL }
- };
-
-@@ -122,6 +151,9 @@ static unsigned int applesmc_temperature_set;
-
- static struct mutex applesmc_lock;
-
-+/* Last index written to key_at_index sysfs file. */
-+static unsigned int key_at_index;
-+
- /*
- * __wait_status - Wait up to 100ms for the status port to get a certain value
- * (masked with 0x0f), returning zero if the value is obtained. Callers must
-@@ -152,17 +184,22 @@ static int __wait_status(u8 val)
- */
- static int applesmc_read_key(const char* key, u8* buffer, u8 len)
- {
-- int ret = -EIO;
- int i;
-
-+ if (len > APPLESMC_MAX_DATA_LENGTH) {
-+ printk(KERN_ERR "applesmc_read_key: cannot read more than "
-+ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
-+ return -EINVAL;
-+ }
-+
- outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
- if (__wait_status(0x0c))
-- goto out;
-+ return -EIO;
-
- for (i = 0; i < 4; i++) {
- outb(key[i], APPLESMC_DATA_PORT);
- if (__wait_status(0x04))
-- goto out;
-+ return -EIO;
- }
- if (debug)
- printk(KERN_DEBUG "<%s", key);
-@@ -173,7 +210,7 @@ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
-
- for (i = 0; i < len; i++) {
- if (__wait_status(0x05))
-- goto out;
-+ return -EIO;
- buffer[i] = inb(APPLESMC_DATA_PORT);
- if (debug)
- printk(KERN_DEBUG "<%x", buffer[i]);
-@@ -181,10 +218,7 @@ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
- if (debug)
- printk(KERN_DEBUG "\n");
-
-- ret = 0;
--
--out:
-- return ret;
-+ return 0;
- }
-
- /*
-@@ -194,30 +228,100 @@ out:
- */
- static int applesmc_write_key(const char* key, u8* buffer, u8 len)
- {
-- int ret = -EIO;
- int i;
-
-+ if (len > APPLESMC_MAX_DATA_LENGTH) {
-+ printk(KERN_ERR "applesmc_write_key: cannot write more than "
-+ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
-+ return -EINVAL;
-+ }
-+
- outb(APPLESMC_WRITE_CMD, APPLESMC_CMD_PORT);
- if (__wait_status(0x0c))
-- goto out;
-+ return -EIO;
-
- for (i = 0; i < 4; i++) {
- outb(key[i], APPLESMC_DATA_PORT);
- if (__wait_status(0x04))
-- goto out;
-+ return -EIO;
- }
-
- outb(len, APPLESMC_DATA_PORT);
-
- for (i = 0; i < len; i++) {
- if (__wait_status(0x04))
-- goto out;
-+ return -EIO;
- outb(buffer[i], APPLESMC_DATA_PORT);
- }
-
-- ret = 0;
--out:
-- return ret;
-+ return 0;
-+}
-+
-+/*
-+ * applesmc_get_key_at_index - get key at index, and put the result in key.
-+ * Returns zero on success or a negative error on failure. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_get_key_at_index(int index, char* key)
-+{
-+ int i;
-+ u8 readkey[4];
-+ readkey[0] = index >> 24;
-+ readkey[1] = index >> 16;
-+ readkey[2] = index >> 8;
-+ readkey[3] = index;
-+
-+ outb(APPLESMC_GET_KEY_BY_INDEX_CMD, APPLESMC_CMD_PORT);
-+ if (__wait_status(0x0c))
-+ return -EIO;
-+
-+ for (i = 0; i < 4; i++) {
-+ outb(readkey[i], APPLESMC_DATA_PORT);
-+ if (__wait_status(0x04))
-+ return -EIO;
-+ }
-+
-+ outb(4, APPLESMC_DATA_PORT);
-+
-+ for (i = 0; i < 4; i++) {
-+ if (__wait_status(0x05))
-+ return -EIO;
-+ key[i] = inb(APPLESMC_DATA_PORT);
-+ }
-+ key[4] = 0;
-+
-+ return 0;
-+}
-+
-+/*
-+ * applesmc_get_key_info - get key info, and put the result in info (char[6]).
-+ * Returns zero on success or a negative error on failure. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_get_key_info(char* key, char* info)
-+{
-+ int i;
-+
-+ outb(APPLESMC_GET_KEY_INFO_CMD, APPLESMC_CMD_PORT);
-+ if (__wait_status(0x0c))
-+ return -EIO;
-+
-+ for (i = 0; i < 4; i++) {
-+ outb(key[i], APPLESMC_DATA_PORT);
-+ if (__wait_status(0x04))
-+ return -EIO;
-+ }
-+
-+ outb(5, APPLESMC_DATA_PORT);
-+
-+ for (i = 0; i < 6; i++) {
-+ if (__wait_status(0x05))
-+ return -EIO;
-+ info[i] = inb(APPLESMC_DATA_PORT);
-+ }
-+ info[5] = 0;
-+
-+ return 0;
- }
-
- /*
-@@ -249,12 +353,79 @@ static int applesmc_read_motion_sensor(int index, s16* value)
- }
-
- /*
-+ * applesmc_init_check_key_value - checks if a given key contains the bytes in
-+ * buffer, if not, writes these bytes.
-+ * In case of failure retry every INIT_WAIT_MSECS msec, and timeout if it
-+ * waited more than INIT_TIMEOUT_MSECS in total.
-+ * Returns zero on success or a negative error on failure. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_init_check_key_value(const char* key, u8* buffer, u8 len)
-+{
-+ int total, ret, i, compare;
-+ u8 rdbuffer[APPLESMC_MAX_DATA_LENGTH];
-+
-+ if (len > APPLESMC_MAX_DATA_LENGTH) {
-+ printk(KERN_ERR "applesmc_init_check_key_value: cannot "
-+ "read/write more than %d bytes",
-+ APPLESMC_MAX_DATA_LENGTH);
-+ return -EINVAL;
-+ }
-+
-+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-+ if (!(ret = applesmc_read_key(key, rdbuffer, len))) {
-+ compare = 1;
-+ for (i = 0; i < len; i++) {
-+ if (rdbuffer[i] != buffer[i]) {
-+ compare = 0;
-+ break;
-+ }
-+ }
-+
-+ if (compare) {
-+ return 0;
-+ }
-+ }
-+ ret = applesmc_write_key(key, buffer, len);
-+ msleep(INIT_WAIT_MSECS);
-+ }
-+
-+ if (ret)
-+ return ret;
-+ else
-+ return -EIO;
-+}
-+
-+irqreturn_t applesmc_irq_handler(int irq, void *dev_id)
-+{
-+ u8 int_type = inb(APPLESMC_INT_PORT);
-+
-+ switch (int_type) {
-+ case 0x60:
-+ printk("applesmc: received a free fall interrupt\n");
-+ break;
-+ case 0x6f:
-+ printk("applesmc: received a high acceleration interrupt\n");
-+ break;
-+ case 0x80:
-+ printk("applesmc: received a shock interrupt\n");
-+ break;
-+ default:
-+ printk("applesmc: received an unknown interrupt %x\n", int_type);
-+ }
-+
-+ return IRQ_NONE;
-+}
-+
-+/*
- * applesmc_device_init - initialize the accelerometer. Returns zero on success
- * and negative error code on failure. Can sleep.
- */
- static int applesmc_device_init(void)
- {
-- int total, ret = -ENXIO;
-+ int total;
-+ int ret = -ENXIO;
-+ int ret1, ret2;
- u8 buffer[2];
-
- if (!applesmc_accelerometer)
-@@ -262,32 +433,76 @@ static int applesmc_device_init(void)
-
- mutex_lock(&applesmc_lock);
-
-+ /* Accept interrupts */
-+ buffer[0] = 0x01;
- for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-- if (debug)
-- printk(KERN_DEBUG "applesmc try %d\n", total);
-- if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
-- (buffer[0] != 0x00 || buffer[1] != 0x00)) {
-- if (total == INIT_TIMEOUT_MSECS) {
-- printk(KERN_DEBUG "applesmc: device has"
-- " already been initialized"
-- " (0x%02x, 0x%02x).\n",
-- buffer[0], buffer[1]);
-- } else {
-- printk(KERN_DEBUG "applesmc: device"
-- " successfully initialized"
-- " (0x%02x, 0x%02x).\n",
-- buffer[0], buffer[1]);
-- }
-- ret = 0;
-- goto out;
-- }
-- buffer[0] = 0xe0;
-- buffer[1] = 0x00;
-- applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
-+ ret1 = applesmc_write_key(INTERRUPT_OK_KEY, buffer, 1);
-+ msleep(INIT_WAIT_MSECS);
-+
-+ if (!ret1)
-+ break;
-+ }
-+ if (ret1)
-+ printk(KERN_WARNING "applesmc: Cannot set NTOK key, "
-+ "will not receive interrupts.\n");
-+
-+ /* Setup interrupt controls. */
-+ buffer[0] = 20; /* 20 msecs */
-+ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM_INTERVAL, buffer, 1);
-+
-+ buffer[0] = 20; /* 20 msecs */
-+ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM_INTERVAL, buffer, 1);
-+
-+ if (ret1 || ret2) {
-+ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
-+ "parameter 1, might not receive some interrupts.");
-+ }
-+
-+ buffer[0] = 0x00;
-+ buffer[1] = 0x60;
-+ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM, buffer, 2);
-+
-+ buffer[0] = 0x01;
-+ buffer[1] = 0xc0;
-+ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM, buffer, 2);
-+
-+ if (ret1 || ret2) {
-+ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
-+ "min/max norm parameters, "
-+ "might not receive some interrupts.");
-+ }
-+
-+ /* Mysterious key. */
-+ buffer[0] = 0x01;
-+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-+ ret1 = applesmc_write_key(MSDW_KEY, buffer, 1);
- msleep(INIT_WAIT_MSECS);
-+
-+ if (!ret1)
-+ break;
-+ }
-+ if (ret1)
-+ printk(KERN_WARNING "applesmc: Cannot set MSDW key\n");
-+
-+ /* Initialize the device. */
-+ buffer[0] = 0xe0;
-+ buffer[1] = 0xf8;
-+ if (applesmc_init_check_key_value(MOTION_SENSOR_KEY, buffer, 2)) {
-+ printk(KERN_WARNING "applesmc: failed to init "
-+ "the accelerometer\n");
-+ goto out;
-+ }
-+
-+ ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED,
-+ "applesmc_irq_handler", NULL);
-+
-+ if (ret1) {
-+ printk(KERN_WARNING "applesmc: cannot setup irq handler\n");
- }
-
-- printk(KERN_WARNING "applesmc: failed to init the device\n");
-+ printk(KERN_DEBUG "applesmc: accelerometer "
-+ "successfully initialized.\n");
-+ ret = 0;
-
- out:
- mutex_unlock(&applesmc_lock);
-@@ -332,9 +547,16 @@ static int applesmc_resume(struct platform_device *dev)
- return applesmc_device_init();
- }
-
-+static int applesmc_remove(struct platform_device *dev)
-+{
-+ free_irq(6, NULL);
-+ return 0;
-+}
-+
- static struct platform_driver applesmc_driver = {
- .probe = applesmc_probe,
- .resume = applesmc_resume,
-+ .remove = applesmc_remove,
- .driver = {
- .name = "applesmc",
- .owner = THIS_MODULE,
-@@ -587,6 +809,33 @@ out:
- return count;
- }
-
-+static ssize_t applesmc_show_fan_id(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ int ret;
-+ char newkey[5];
-+ u8 buffer[17];
-+ struct sensor_device_attribute_2 *sensor_attr =
-+ to_sensor_dev_attr_2(attr);
-+
-+ newkey[0] = FAN_ID[0];
-+ newkey[1] = '0' + sensor_attr->index;
-+ newkey[2] = FAN_ID[2];
-+ newkey[3] = FAN_ID[3];
-+ newkey[4] = 0;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(newkey, buffer, 16);
-+ buffer[16] = 0;
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "%s\n", buffer+4);
-+}
-+
- static ssize_t applesmc_calibrate_show(struct device *dev,
- struct device_attribute *attr, char *sysfsbuf)
- {
-@@ -603,6 +852,26 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
- return count;
- }
-
-+static ssize_t applesmc_key_count_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ int ret;
-+ u8 buffer[4];
-+ u32 count;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(KEY_COUNT_KEY, buffer, 4);
-+ count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) +
-+ ((u32)buffer[2]<<8) + buffer[3];
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "%d\n", count);
-+}
-+
- static void applesmc_backlight_set(struct led_classdev *led_cdev,
- enum led_brightness value)
- {
-@@ -615,6 +884,165 @@ static void applesmc_backlight_set(struct led_classdev *led_cdev,
- mutex_unlock(&applesmc_lock);
- }
-
-+static ssize_t applesmc_key_at_index_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ char key[5];
-+ char info[6];
-+ u8 buffer[APPLESMC_MAX_DATA_LENGTH];
-+ char outbuffer[256];
-+ int ret, ret2;
-+ int i;
-+
-+ outbuffer[0] = 0;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_get_key_at_index(key_at_index, key);
-+
-+ if (!ret && key[0]) {
-+ applesmc_get_key_info(key, info);
-+
-+ ret2 = applesmc_read_key(key, buffer, info[0]);
-+ if (!ret2) {
-+ for (i = 0; i < info[0]; i++) {
-+ sprintf(outbuffer+(i*2), "%02x", buffer[i]);
-+ }
-+ outbuffer[info[0]*2] = 0;
-+ }
-+ }
-+
-+ mutex_unlock(&applesmc_lock);
-+
-+ if (!ret && key[0])
-+ return sprintf(sysfsbuf, "%d: %s [%d:%s] - %s\n", key_at_index, key, info[0], info+1, outbuffer);
-+ else
-+ return sprintf(sysfsbuf, "%d=invalid\n", key_at_index);
-+}
-+
-+static ssize_t applesmc_key_at_index_store(struct device *dev,
-+ struct device_attribute *attr, const char *sysfsbuf, size_t count)
-+{
-+ mutex_lock(&applesmc_lock);
-+
-+ key_at_index = simple_strtoul(sysfsbuf, NULL, 10);
-+
-+ mutex_unlock(&applesmc_lock);
-+
-+ return count;
-+}
-+
-+static ssize_t applesmc_param_show(char* key, int length, char *sysfsbuf)
-+{
-+ int ret;
-+ unsigned int value = 0;
-+ u8 buffer[2];
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(key, buffer, length);
-+ if (length == 2) {
-+ value = ((unsigned int)buffer[0] << 8) | buffer[1];
-+ }
-+ else if (length == 1) {
-+ value = buffer[0];
-+ }
-+ else {
-+ printk("Invalid length for applesmc_param_show");
-+ ret = -EINVAL;
-+ }
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "%u\n", value);
-+}
-+
-+static ssize_t applesmc_param_store(char* key, int length,
-+ const char *sysfsbuf, size_t count)
-+{
-+ int ret;
-+ u32 value;
-+ u8 buffer[2];
-+
-+ value = simple_strtoul(sysfsbuf, NULL, 10);
-+
-+ if (length == 2) {
-+ if (value > 0xffff)
-+ return -EINVAL;
-+
-+ buffer[0] = (value >> 8) & 0xff;
-+ buffer[1] = value & 0xff;
-+ } else if (length == 1) {
-+ if (value > 0xff)
-+ return -EINVAL;
-+
-+ buffer[0] = value & 0xff;
-+ } else {
-+ printk("Invalid length for applesmc_param_store");
-+ return -EINVAL;
-+ }
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_write_key(key, buffer, length);
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return count;
-+}
-+
-+static ssize_t applesmc_low_norm_trigger_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ return applesmc_param_show(MOTION_LOW_NORM_INTERVAL, 1, sysfsbuf);
-+}
-+
-+static ssize_t applesmc_high_norm_trigger_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ return applesmc_param_show(MOTION_HIGH_NORM_INTERVAL, 1, sysfsbuf);
-+}
-+
-+static ssize_t applesmc_low_norm_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ return applesmc_param_show(MOTION_LOW_NORM, 2, sysfsbuf);
-+}
-+
-+static ssize_t applesmc_high_norm_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ return applesmc_param_show(MOTION_HIGH_NORM, 2, sysfsbuf);
-+}
-+
-+static ssize_t applesmc_low_norm_trigger_store(struct device *dev,
-+ struct device_attribute *attr, const char *sysfsbuf, size_t count)
-+{
-+ return applesmc_param_store(MOTION_LOW_NORM_INTERVAL, 1, sysfsbuf, count);
-+}
-+
-+static ssize_t applesmc_high_norm_trigger_store(struct device *dev,
-+ struct device_attribute *attr, const char *sysfsbuf, size_t count)
-+{
-+ return applesmc_param_store(MOTION_HIGH_NORM_INTERVAL, 1, sysfsbuf, count);
-+}
-+
-+static ssize_t applesmc_low_norm_store(struct device *dev,
-+ struct device_attribute *attr, const char *sysfsbuf, size_t count)
-+{
-+ return applesmc_param_store(MOTION_LOW_NORM, 2, sysfsbuf, count);
-+}
-+
-+static ssize_t applesmc_high_norm_store(struct device *dev,
-+ struct device_attribute *attr, const char *sysfsbuf, size_t count)
-+{
-+ return applesmc_param_store(MOTION_HIGH_NORM, 2, sysfsbuf, count);
-+}
-+
- static struct led_classdev applesmc_backlight = {
- .name = "smc:kbd_backlight",
- .default_trigger = "nand-disk",
-@@ -624,9 +1052,29 @@ static struct led_classdev applesmc_backlight = {
- static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
- static DEVICE_ATTR(calibrate, 0644,
- applesmc_calibrate_show, applesmc_calibrate_store);
-+static DEVICE_ATTR(low_norm_trigger_interval, 0644, applesmc_low_norm_trigger_show, applesmc_low_norm_trigger_store);
-+static DEVICE_ATTR(high_norm_trigger_interval, 0644, applesmc_high_norm_trigger_show, applesmc_high_norm_trigger_store);
-+static DEVICE_ATTR(low_norm_trigger, 0644, applesmc_low_norm_show, applesmc_low_norm_store);
-+static DEVICE_ATTR(high_norm_trigger, 0644, applesmc_high_norm_show, applesmc_high_norm_store);
-
- static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL);
-
-+static DEVICE_ATTR(key_count, 0444, applesmc_key_count_show, NULL);
-+static DEVICE_ATTR(key_at_index, 0600, applesmc_key_at_index_show, applesmc_key_at_index_store);
-+
-+static struct attribute *accelerometer_attributes[] = {
-+ &dev_attr_position.attr,
-+ &dev_attr_calibrate.attr,
-+ &dev_attr_low_norm_trigger.attr,
-+ &dev_attr_high_norm_trigger.attr,
-+ &dev_attr_low_norm_trigger_interval.attr,
-+ &dev_attr_high_norm_trigger_interval.attr,
-+ NULL
-+};
-+
-+static const struct attribute_group accelerometer_attributes_group =
-+ { .attrs = accelerometer_attributes };
-+
- /*
- * Macro defining SENSOR_DEVICE_ATTR for a fan sysfs entries.
- * - show actual speed
-@@ -655,6 +1103,9 @@ static SENSOR_DEVICE_ATTR_2(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \
- static SENSOR_DEVICE_ATTR(fan##offset##_manual, S_IRUGO | S_IWUSR, \
- applesmc_show_fan_manual, applesmc_store_fan_manual, offset); \
- \
-+static SENSOR_DEVICE_ATTR(fan##offset##_id, S_IRUGO, \
-+ applesmc_show_fan_id, NULL, offset); \
-+\
- static struct attribute *fan##offset##_attributes[] = { \
- &sensor_dev_attr_fan##offset##_actual_speed.dev_attr.attr, \
- &sensor_dev_attr_fan##offset##_minimum_speed.dev_attr.attr, \
-@@ -662,6 +1113,7 @@ static struct attribute *fan##offset##_attributes[] = { \
- &sensor_dev_attr_fan##offset##_safe_speed.dev_attr.attr, \
- &sensor_dev_attr_fan##offset##_target_speed.dev_attr.attr, \
- &sensor_dev_attr_fan##offset##_manual.dev_attr.attr, \
-+ &sensor_dev_attr_fan##offset##_id.dev_attr.attr, \
- NULL \
- };
-
-@@ -694,6 +1146,16 @@ static SENSOR_DEVICE_ATTR(temperature_5, S_IRUGO,
- applesmc_show_temperature, NULL, 5);
- static SENSOR_DEVICE_ATTR(temperature_6, S_IRUGO,
- applesmc_show_temperature, NULL, 6);
-+static SENSOR_DEVICE_ATTR(temperature_7, S_IRUGO,
-+ applesmc_show_temperature, NULL, 7);
-+static SENSOR_DEVICE_ATTR(temperature_8, S_IRUGO,
-+ applesmc_show_temperature, NULL, 8);
-+static SENSOR_DEVICE_ATTR(temperature_9, S_IRUGO,
-+ applesmc_show_temperature, NULL, 9);
-+static SENSOR_DEVICE_ATTR(temperature_10, S_IRUGO,
-+ applesmc_show_temperature, NULL, 10);
-+static SENSOR_DEVICE_ATTR(temperature_11, S_IRUGO,
-+ applesmc_show_temperature, NULL, 11);
-
- static struct attribute *temperature_attributes[] = {
- &sensor_dev_attr_temperature_0.dev_attr.attr,
-@@ -703,6 +1165,11 @@ static struct attribute *temperature_attributes[] = {
- &sensor_dev_attr_temperature_4.dev_attr.attr,
- &sensor_dev_attr_temperature_5.dev_attr.attr,
- &sensor_dev_attr_temperature_6.dev_attr.attr,
-+ &sensor_dev_attr_temperature_7.dev_attr.attr,
-+ &sensor_dev_attr_temperature_8.dev_attr.attr,
-+ &sensor_dev_attr_temperature_9.dev_attr.attr,
-+ &sensor_dev_attr_temperature_10.dev_attr.attr,
-+ &sensor_dev_attr_temperature_11.dev_attr.attr,
- };
-
- /* Module stuff */
-@@ -734,11 +1201,8 @@ static int applesmc_create_accelerometer(void)
- {
- int ret;
-
-- ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_position.attr);
-- if (ret)
-- goto out;
--
-- ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_calibrate.attr);
-+ ret = sysfs_create_group(&pdev->dev.kobj,
-+ &accelerometer_attributes_group);
- if (ret)
- goto out;
-
-@@ -900,6 +1364,11 @@ static int __init applesmc_init(void)
- goto out_accelerometer;
- }
-
-+ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_key_count.attr);
-+ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_key_at_index.attr);
-+ if (ret)
-+ goto out_accelerometer;
-+
- printk(KERN_INFO "applesmc: driver successfully loaded.\n");
- return 0;
-
Added: trunk/kernel/mactel-patches-2.6.21/0011-applesmc_standard.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0011-applesmc_standard.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0011-applesmc_standard.patch 2007-04-12 16:38:05 UTC (rev 114)
@@ -0,0 +1,556 @@
+- Standardize applesmc to use sysfs filenames recommended by
+
+From: Nicolas Boichat <ni...@bo...>
+
+Documentation/hwmon/sysfs-interface.
+- Use snprintf instead of sprintf in sysfs show handlers.
+- Remove the sysfs files properly in case of initialisation problem, and when
+ the driver is unloaded.
+- Add various sanity checks and improvements of SMC key comments.
+- Add support for reading fan physical position (e.g. "Left Side")
+---
+
+ drivers/hwmon/applesmc.c | 280 ++++++++++++++++++++++++++++++++--------------
+ 1 files changed, 192 insertions(+), 88 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index f7b59fc..531bc9a 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -37,40 +37,48 @@
+ #include <linux/hwmon-sysfs.h>
+ #include <asm/io.h>
+ #include <linux/leds.h>
++#include <linux/hwmon.h>
+
+-/* data port used by apple SMC */
++/* data port used by Apple SMC */
+ #define APPLESMC_DATA_PORT 0x300
+-/* command/status port used by apple SMC */
++/* command/status port used by Apple SMC */
+ #define APPLESMC_CMD_PORT 0x304
+
+-#define APPLESMC_NR_PORTS 5 /* 0x300-0x304 */
++#define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
++
++#define APPLESMC_MAX_DATA_LENGTH 32
+
+ #define APPLESMC_STATUS_MASK 0x0f
+ #define APPLESMC_READ_CMD 0x10
+ #define APPLESMC_WRITE_CMD 0x11
+
+-#define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o length 6 */
+-#define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o length 6 */
+-#define BACKLIGHT_KEY "LKSB" /* w-o */
++#define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */
++#define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */
++#define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */
+
+-#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */
++#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */
+
+-#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */
+-#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */
+-#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */
+-#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */
++#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */
++#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */
++#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
++#define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
+
+-#define FANS_COUNT "FNum" /* r-o length 1 */
+-#define FANS_MANUAL "FS! " /* r-w length 2 */
+-#define FAN_ACTUAL_SPEED "F0Ac" /* r-o length 2 */
+-#define FAN_MIN_SPEED "F0Mn" /* r-o length 2 */
+-#define FAN_MAX_SPEED "F0Mx" /* r-o length 2 */
+-#define FAN_SAFE_SPEED "F0Sf" /* r-o length 2 */
+-#define FAN_TARGET_SPEED "F0Tg" /* r-w length 2 */
++#define FANS_COUNT "FNum" /* r-o ui8 */
++#define FANS_MANUAL "FS! " /* r-w ui16 */
++#define FAN_ACTUAL_SPEED "F0Ac" /* r-o fpe2 (2 bytes) */
++#define FAN_MIN_SPEED "F0Mn" /* r-o fpe2 (2 bytes) */
++#define FAN_MAX_SPEED "F0Mx" /* r-o fpe2 (2 bytes) */
++#define FAN_SAFE_SPEED "F0Sf" /* r-o fpe2 (2 bytes) */
++#define FAN_TARGET_SPEED "F0Tg" /* r-w fpe2 (2 bytes) */
++#define FAN_POSITION "F0ID" /* r-o char[16] */
+
+-/* Temperature sensors keys. First set for Macbook(Pro), second for Macmini */
+-static const char* temperature_sensors_sets[][8] = {
+- { "TB0T", "TC0D", "TC0P", "Th0H", "Ts0P", "Th1H", "Ts1P", NULL },
++/*
++ * Temperature sensors keys (sp78 - 2 bytes).
++ * First set for Macbook(Pro), second for Macmini.
++ */
++static const char* temperature_sensors_sets[][13] = {
++ { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
++ "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
+ { "TC0D", "TC0P", NULL }
+ };
+
+@@ -110,6 +118,7 @@ static s16 rest_x;
+ static s16 rest_y;
+ static struct timer_list applesmc_timer;
+ static struct input_dev *applesmc_idev;
++static struct class_device *hwmon_class_dev;
+
+ /* Indicates whether this computer has an accelerometer. */
+ static unsigned int applesmc_accelerometer;
+@@ -152,17 +161,22 @@ static int __wait_status(u8 val)
+ */
+ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
+ {
+- int ret = -EIO;
+ int i;
+
++ if (len > APPLESMC_MAX_DATA_LENGTH) {
++ printk(KERN_ERR "applesmc_read_key: cannot read more than "
++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
++ return -EINVAL;
++ }
++
+ outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
+ if (__wait_status(0x0c))
+- goto out;
++ return -EIO;
+
+ for (i = 0; i < 4; i++) {
+ outb(key[i], APPLESMC_DATA_PORT);
+ if (__wait_status(0x04))
+- goto out;
++ return -EIO;
+ }
+ if (debug)
+ printk(KERN_DEBUG "<%s", key);
+@@ -173,7 +187,7 @@ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
+
+ for (i = 0; i < len; i++) {
+ if (__wait_status(0x05))
+- goto out;
++ return -EIO;
+ buffer[i] = inb(APPLESMC_DATA_PORT);
+ if (debug)
+ printk(KERN_DEBUG "<%x", buffer[i]);
+@@ -181,10 +195,7 @@ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
+ if (debug)
+ printk(KERN_DEBUG "\n");
+
+- ret = 0;
+-
+-out:
+- return ret;
++ return 0;
+ }
+
+ /*
+@@ -194,30 +205,33 @@ out:
+ */
+ static int applesmc_write_key(const char* key, u8* buffer, u8 len)
+ {
+- int ret = -EIO;
+ int i;
+
++ if (len > APPLESMC_MAX_DATA_LENGTH) {
++ printk(KERN_ERR "applesmc_write_key: cannot write more than "
++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
++ return -EINVAL;
++ }
++
+ outb(APPLESMC_WRITE_CMD, ...
[truncated message content] |
|
From: <nbo...@us...> - 2007-04-16 03:16:56
|
Revision: 117
http://svn.sourceforge.net/mactel-linux/?rev=117&view=rev
Author: nboichat
Date: 2007-04-15 20:16:51 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
Fix crash when led triggers are activated on the keyboard backlight.
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/0013-applesmc_fix_sleep_in_led_brightness_set.patch
trunk/kernel/mactel-patches-2.6.21/0014-applesmc_int.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/0013-applesmc_int.patch
Added: trunk/kernel/mactel-patches-2.6.21/0013-applesmc_fix_sleep_in_led_brightness_set.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0013-applesmc_fix_sleep_in_led_brightness_set.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0013-applesmc_fix_sleep_in_led_brightness_set.patch 2007-04-16 03:16:51 UTC (rev 117)
@@ -0,0 +1,158 @@
+Cannot sleep in led->brightness_set handler, as it might be called from a softirq, so we use a workqueue to change the brightness (as recommended by Richard Purdie)
+
+From: Nicolas Boichat <ni...@bo...>
+
+
+---
+
+ drivers/hwmon/applesmc.c | 61 +++++++++++++++++++++++++++++++++++++---------
+ 1 files changed, 49 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index 4ec38ef..ea0a004 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -38,6 +38,7 @@
+ #include <asm/io.h>
+ #include <linux/leds.h>
+ #include <linux/hwmon.h>
++#include <linux/workqueue.h>
+
+ /* data port used by Apple SMC */
+ #define APPLESMC_DATA_PORT 0x300
+@@ -116,7 +117,7 @@ struct dmi_match_data {
+ int temperature_set;
+ };
+
+-static int debug = 0;
++static const int debug = 0;
+ static struct platform_device *pdev;
+ static s16 rest_x;
+ static s16 rest_y;
+@@ -141,8 +142,10 @@ static struct mutex applesmc_lock;
+ */
+ static unsigned int key_at_index;
+
++static struct workqueue_struct *applesmc_led_wq;
++
+ /*
+- * __wait_status - Wait up to 100ms for the status port to get a certain value
++ * __wait_status - Wait up to 2ms for the status port to get a certain value
+ * (masked with 0x0f), returning zero if the value is obtained. Callers must
+ * hold applesmc_lock.
+ */
+@@ -152,9 +155,14 @@ static int __wait_status(u8 val)
+
+ val = val & APPLESMC_STATUS_MASK;
+
+- for (i = 0; i < 10000; i++) {
+- if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val)
++ for (i = 0; i < 200; i++) {
++ if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) {
++ if (debug)
++ printk(KERN_DEBUG
++ "Waited %d us for status %x\n",
++ i*10, val);
+ return 0;
++ }
+ udelay(10);
+ }
+
+@@ -721,17 +729,33 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
+ return count;
+ }
+
+-static void applesmc_backlight_set(struct led_classdev *led_cdev,
+- enum led_brightness value)
++/* Store the next backlight value to be written by the work */
++static unsigned int backlight_value;
++
++static void applesmc_backlight_set(struct work_struct *work)
+ {
+ u8 buffer[2];
+
+ mutex_lock(&applesmc_lock);
+- buffer[0] = value;
++ buffer[0] = backlight_value;
+ buffer[1] = 0x00;
+ applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
+ mutex_unlock(&applesmc_lock);
+ }
++DECLARE_WORK(backlight_work, &applesmc_backlight_set);
++
++static void applesmc_brightness_set(struct led_classdev *led_cdev,
++ enum led_brightness value)
++{
++ int ret;
++
++ backlight_value = value;
++ ret = queue_work(applesmc_led_wq, &backlight_work);
++
++ if (debug && (!ret)) {
++ printk(KERN_DEBUG "applesmc: work was already on the queue.\n");
++ }
++}
+
+ static ssize_t applesmc_key_count_show(struct device *dev,
+ struct device_attribute *attr, char *sysfsbuf)
+@@ -887,7 +911,7 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
+ static struct led_classdev applesmc_backlight = {
+ .name = "smc:kbd_backlight",
+ .default_trigger = "nand-disk",
+- .brightness_set = applesmc_backlight_set,
++ .brightness_set = applesmc_brightness_set,
+ };
+
+ static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
+@@ -1234,25 +1258,35 @@ static int __init applesmc_init(void)
+ if (ret)
+ goto out_accelerometer;
+
++ /* Create the workqueue */
++ applesmc_led_wq = create_singlethread_workqueue("applesmc-led");
++ if (!applesmc_led_wq) {
++ ret = -ENOMEM;
++ goto out_light_sysfs;
++ }
++
+ /* register as a led device */
+ ret = led_classdev_register(&pdev->dev, &applesmc_backlight);
+ if (ret < 0)
+- goto out_light_sysfs;
++ goto out_light_wq;
+ }
+
+ hwmon_class_dev = hwmon_device_register(&pdev->dev);
+ if (IS_ERR(hwmon_class_dev)) {
+ ret = PTR_ERR(hwmon_class_dev);
+- goto out_light;
++ goto out_light_ledclass;
+ }
+
+ printk(KERN_INFO "applesmc: driver successfully loaded.\n");
+
+ return 0;
+
+-out_light:
++out_light_ledclass:
+ if (applesmc_light)
+ led_classdev_unregister(&applesmc_backlight);
++out_light_wq:
++ if (applesmc_light)
++ destroy_workqueue(applesmc_led_wq);
+ out_light_sysfs:
+ if (applesmc_light)
+ sysfs_remove_file(&pdev->dev.kobj, &dev_attr_light.attr);
+@@ -1280,8 +1314,11 @@ out:
+ static void __exit applesmc_exit(void)
+ {
+ hwmon_device_unregister(hwmon_class_dev);
+- if (applesmc_light)
++ if (applesmc_light) {
+ led_classdev_unregister(&applesmc_backlight);
++ destroy_workqueue(applesmc_led_wq);
++ sysfs_remove_file(&pdev->dev.kobj, &dev_attr_light.attr);
++ }
+ if (applesmc_accelerometer)
+ applesmc_release_accelerometer();
+ sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group);
Deleted: trunk/kernel/mactel-patches-2.6.21/0013-applesmc_int.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0013-applesmc_int.patch 2007-04-16 03:11:46 UTC (rev 116)
+++ trunk/kernel/mactel-patches-2.6.21/0013-applesmc_int.patch 2007-04-16 03:16:51 UTC (rev 117)
@@ -1,410 +0,0 @@
-Interrupt support for the accelerometer.
-
-From: Nicolas Boichat <ni...@bo...>
-
-
----
-
- drivers/hwmon/applesmc.c | 316 +++++++++++++++++++++++++++++++++++++++++++---
- 1 files changed, 293 insertions(+), 23 deletions(-)
-
-diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index 4ec38ef..6ad1c2d 100644
---- a/drivers/hwmon/applesmc.c
-+++ b/drivers/hwmon/applesmc.c
-@@ -38,14 +38,20 @@
- #include <asm/io.h>
- #include <linux/leds.h>
- #include <linux/hwmon.h>
-+#include <linux/interrupt.h>
-
- /* data port used by Apple SMC */
- #define APPLESMC_DATA_PORT 0x300
- /* command/status port used by Apple SMC */
- #define APPLESMC_CMD_PORT 0x304
-+/* status port used by Apple SMC to get which interrupt type just happened */
-+#define APPLESMC_INT_PORT 0x31f
-
- #define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
-
-+/* Defined in ACPI DSDT table, should we read it from there? */
-+#define APPLESMC_IRQ 6
-+
- #define APPLESMC_MAX_DATA_LENGTH 32
-
- #define APPLESMC_STATUS_MASK 0x0f
-@@ -56,6 +62,8 @@
-
- #define KEY_COUNT_KEY "#KEY" /* r-o ui32 */
-
-+#define INTERRUPT_OK_KEY "NTOK" /* w-o ui8 */
-+
- #define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */
- #define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */
- #define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */
-@@ -67,6 +75,19 @@
- #define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
- #define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
-
-+/*
-+ * Interrupt controls.
-+ * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than
-+ * MOLT (free fall), or bigger than MOHT (high acceleration) for longer than the
-+ * value of MOLD (or MOHD), SMC will trigger an interrupt.
-+ */
-+#define MOTION_LOW_NORM "MOLT" /* r/w sp78 (2 bytes) */
-+#define MOTION_HIGH_NORM "MOHT" /* r/w sp78 (2 bytes) */
-+#define MOTION_LOW_NORM_INTERVAL "MOLD" /* r/w ui8 */
-+#define MOTION_HIGH_NORM_INTERVAL "MOHD" /* r/w ui8 */
-+
-+#define MSDW_KEY "MSDW" /* r/w flag (1 byte) */
-+
- #define FANS_COUNT "FNum" /* r-o ui8 */
- #define FANS_MANUAL "FS! " /* r-w ui16 */
- #define FAN_ACTUAL_SPEED "F0Ac" /* r-o fpe2 (2 bytes) */
-@@ -340,12 +361,79 @@ static int applesmc_read_motion_sensor(int index, s16* value)
- }
-
- /*
-+ * applesmc_init_check_key_value - checks if a given key contains the bytes in
-+ * buffer, if not, writes these bytes.
-+ * In case of failure retry every INIT_WAIT_MSECS msec, and timeout if it
-+ * waited more than INIT_TIMEOUT_MSECS in total.
-+ * Returns zero on success or a negative error on failure. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_init_check_key_value(const char* key, u8* buffer, u8 len)
-+{
-+ int total, ret, i, compare;
-+ u8 rdbuffer[APPLESMC_MAX_DATA_LENGTH];
-+
-+ if (len > APPLESMC_MAX_DATA_LENGTH) {
-+ printk(KERN_ERR "applesmc_init_check_key_value: cannot "
-+ "read/write more than %d bytes",
-+ APPLESMC_MAX_DATA_LENGTH);
-+ return -EINVAL;
-+ }
-+
-+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-+ if (!(ret = applesmc_read_key(key, rdbuffer, len))) {
-+ compare = 1;
-+ for (i = 0; i < len; i++) {
-+ if (rdbuffer[i] != buffer[i]) {
-+ compare = 0;
-+ break;
-+ }
-+ }
-+
-+ if (compare) {
-+ return 0;
-+ }
-+ }
-+ ret = applesmc_write_key(key, buffer, len);
-+ msleep(INIT_WAIT_MSECS);
-+ }
-+
-+ if (ret)
-+ return ret;
-+ else
-+ return -EIO;
-+}
-+
-+irqreturn_t applesmc_irq_handler(int irq, void *dev_id)
-+{
-+ u8 int_type = inb(APPLESMC_INT_PORT);
-+
-+ switch (int_type) {
-+ case 0x60:
-+ printk("applesmc: received a free fall interrupt\n");
-+ break;
-+ case 0x6f:
-+ printk("applesmc: received a high acceleration interrupt\n");
-+ break;
-+ case 0x80:
-+ printk("applesmc: received a shock interrupt\n");
-+ break;
-+ default:
-+ printk("applesmc: received an unknown interrupt %x\n", int_type);
-+ }
-+
-+ return IRQ_NONE;
-+}
-+
-+/*
- * applesmc_device_init - initialize the accelerometer. Returns zero on success
- * and negative error code on failure. Can sleep.
- */
- static int applesmc_device_init(void)
- {
-- int total, ret = -ENXIO;
-+ int total;
-+ int ret = -ENXIO;
-+ int ret1, ret2;
- u8 buffer[2];
-
- if (!applesmc_accelerometer)
-@@ -353,32 +441,79 @@ static int applesmc_device_init(void)
-
- mutex_lock(&applesmc_lock);
-
-+ /* Accept interrupts */
-+ buffer[0] = 0x01;
- for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-- if (debug)
-- printk(KERN_DEBUG "applesmc try %d\n", total);
-- if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
-- (buffer[0] != 0x00 || buffer[1] != 0x00)) {
-- if (total == INIT_TIMEOUT_MSECS) {
-- printk(KERN_DEBUG "applesmc: device has"
-- " already been initialized"
-- " (0x%02x, 0x%02x).\n",
-- buffer[0], buffer[1]);
-- } else {
-- printk(KERN_DEBUG "applesmc: device"
-- " successfully initialized"
-- " (0x%02x, 0x%02x).\n",
-- buffer[0], buffer[1]);
-- }
-- ret = 0;
-- goto out;
-- }
-- buffer[0] = 0xe0;
-- buffer[1] = 0x00;
-- applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
-+ ret1 = applesmc_write_key(INTERRUPT_OK_KEY, buffer, 1);
-+ msleep(INIT_WAIT_MSECS);
-+
-+ if (!ret1)
-+ break;
-+ }
-+ if (ret1)
-+ printk(KERN_WARNING "applesmc: Cannot set NTOK key, "
-+ "will not receive interrupts.\n");
-+
-+ /* Setup interrupt controls. */
-+ buffer[0] = 20; /* 20 msecs */
-+ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM_INTERVAL,
-+ buffer, 1);
-+
-+ buffer[0] = 20; /* 20 msecs */
-+ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM_INTERVAL,
-+ buffer, 1);
-+
-+ if (ret1 || ret2) {
-+ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
-+ "interrupt interval, might not receive "
-+ "some interrupts.");
-+ }
-+
-+ buffer[0] = 0x00;
-+ buffer[1] = 0x60;
-+ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM, buffer, 2);
-+
-+ buffer[0] = 0x01;
-+ buffer[1] = 0xc0;
-+ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM, buffer, 2);
-+
-+ if (ret1 || ret2) {
-+ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
-+ "min/max norm parameters, "
-+ "might not receive some interrupts.");
-+ }
-+
-+ /* Mysterious key. */
-+ buffer[0] = 0x01;
-+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-+ ret1 = applesmc_write_key(MSDW_KEY, buffer, 1);
- msleep(INIT_WAIT_MSECS);
-+
-+ if (!ret1)
-+ break;
-+ }
-+ if (ret1)
-+ printk(KERN_WARNING "applesmc: Cannot set MSDW key\n");
-+
-+ /* Initialize the device. */
-+ buffer[0] = 0xe0;
-+ buffer[1] = 0xf8;
-+ if (applesmc_init_check_key_value(MOTION_SENSOR_KEY, buffer, 2)) {
-+ printk(KERN_WARNING "applesmc: failed to init "
-+ "the accelerometer\n");
-+ goto out;
- }
-
-- printk(KERN_WARNING "applesmc: failed to init the device\n");
-+ ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED,
-+ "applesmc_irq_handler", NULL);
-+
-+ if (ret1) {
-+ printk(KERN_WARNING "applesmc: cannot setup irq handler\n");
-+ }
-+
-+ printk(KERN_DEBUG "applesmc: accelerometer "
-+ "successfully initialized.\n");
-+ ret = 0;
-
- out:
- mutex_unlock(&applesmc_lock);
-@@ -423,9 +558,16 @@ static int applesmc_resume(struct platform_device *dev)
- return applesmc_device_init();
- }
-
-+static int applesmc_remove(struct platform_device *dev)
-+{
-+ free_irq(6, NULL);
-+ return 0;
-+}
-+
- static struct platform_driver applesmc_driver = {
- .probe = applesmc_probe,
- .resume = applesmc_resume,
-+ .remove = applesmc_remove,
- .driver = {
- .name = "applesmc",
- .owner = THIS_MODULE,
-@@ -884,6 +1026,122 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
- return count;
- }
-
-+static ssize_t applesmc_accelerometer_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ int ret;
-+ unsigned int value = 0;
-+ u8 buffer[2];
-+ char* key;
-+ int length;
-+ struct sensor_device_attribute_2 *sensor_attr =
-+ to_sensor_dev_attr_2(attr);
-+
-+ switch(sensor_attr->index) {
-+ case 0:
-+ key = MOTION_LOW_NORM_INTERVAL;
-+ length = 1;
-+ break;
-+ case 1:
-+ key = MOTION_HIGH_NORM_INTERVAL;
-+ length = 1;
-+ break;
-+ case 2:
-+ key = MOTION_LOW_NORM;
-+ length = 2;
-+ break;
-+ case 3:
-+ key = MOTION_HIGH_NORM;
-+ length = 2;
-+ break;
-+ default:
-+ printk("Invalid index for applesmc_accelerometer_show");
-+ return -EINVAL;
-+ }
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(key, buffer, length);
-+ if (length == 2)
-+ value = ((unsigned int)buffer[0] << 8) | buffer[1];
-+ else if (length == 1)
-+ value = buffer[0];
-+ else {
-+ printk("Invalid length for applesmc_param_show");
-+ ret = -EINVAL;
-+ }
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", value);
-+}
-+
-+static ssize_t applesmc_accelerometer_store(struct device *dev,
-+ struct device_attribute *attr,
-+ const char *sysfsbuf, size_t count)
-+{
-+ int ret;
-+ u32 value;
-+ u8 buffer[2];
-+ char* key;
-+ int length;
-+ struct sensor_device_attribute_2 *sensor_attr =
-+ to_sensor_dev_attr_2(attr);
-+
-+ switch(sensor_attr->index) {
-+ case 0:
-+ key = MOTION_LOW_NORM_INTERVAL;
-+ length = 1;
-+ break;
-+ case 1:
-+ key = MOTION_HIGH_NORM_INTERVAL;
-+ length = 1;
-+ break;
-+ case 2:
-+ key = MOTION_LOW_NORM;
-+ length = 2;
-+ break;
-+ case 3:
-+ key = MOTION_HIGH_NORM;
-+ length = 2;
-+ break;
-+ default:
-+ printk("Invalid index for applesmc_accelerometer_show");
-+ return -EINVAL;
-+ }
-+
-+ value = simple_strtoul(sysfsbuf, NULL, 10);
-+
-+ if (length == 2) {
-+ if (value > 0xffff)
-+ return -EINVAL;
-+
-+ buffer[0] = (value >> 8) & 0xff;
-+ buffer[1] = value & 0xff;
-+ } else if (length == 1) {
-+ if (value > 0xff)
-+ return -EINVAL;
-+
-+ buffer[0] = value & 0xff;
-+ } else {
-+ printk("Invalid length for applesmc_param_store");
-+ return -EINVAL;
-+ }
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_write_key(key, buffer, length);
-+
-+ mutex_unlock(&applesmc_lock);
-+
-+ if (ret)
-+ return ret;
-+ else
-+ return count;
-+}
-+
- static struct led_classdev applesmc_backlight = {
- .name = "smc:kbd_backlight",
- .default_trigger = "nand-disk",
-@@ -893,10 +1151,22 @@ static struct led_classdev applesmc_backlight = {
- static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
- static DEVICE_ATTR(calibrate, 0644,
- applesmc_calibrate_show, applesmc_calibrate_store);
-+static SENSOR_DEVICE_ATTR(low_norm_trigger_interval, 0644,
-+ applesmc_accelerometer_show, applesmc_accelerometer_store, 0);
-+static SENSOR_DEVICE_ATTR(high_norm_trigger_interval, 0644,
-+ applesmc_accelerometer_show, applesmc_accelerometer_store, 1);
-+static SENSOR_DEVICE_ATTR(low_norm_trigger, 0644,
-+ applesmc_accelerometer_show, applesmc_accelerometer_store, 2);
-+static SENSOR_DEVICE_ATTR(high_norm_trigger, 0644,
-+ applesmc_accelerometer_show, applesmc_accelerometer_store, 3);
-
- static struct attribute *accelerometer_attributes[] = {
- &dev_attr_position.attr,
- &dev_attr_calibrate.attr,
-+ &sensor_dev_attr_low_norm_trigger.dev_attr.attr,
-+ &sensor_dev_attr_high_norm_trigger.dev_attr.attr,
-+ &sensor_dev_attr_low_norm_trigger_interval.dev_attr.attr,
-+ &sensor_dev_attr_high_norm_trigger_interval.dev_attr.attr,
- NULL
- };
-
Added: trunk/kernel/mactel-patches-2.6.21/0014-applesmc_int.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0014-applesmc_int.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0014-applesmc_int.patch 2007-04-16 03:16:51 UTC (rev 117)
@@ -0,0 +1,410 @@
+Interrupt support for the accelerometer.
+
+From: Nicolas Boichat <ni...@bo...>
+
+
+---
+
+ drivers/hwmon/applesmc.c | 316 +++++++++++++++++++++++++++++++++++++++++++---
+ 1 files changed, 293 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index ea0a004..bf1b6e6 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -39,14 +39,20 @@
+ #include <linux/leds.h>
+ #include <linux/hwmon.h>
+ #include <linux/workqueue.h>
++#include <linux/interrupt.h>
+
+ /* data port used by Apple SMC */
+ #define APPLESMC_DATA_PORT 0x300
+ /* command/status port used by Apple SMC */
+ #define APPLESMC_CMD_PORT 0x304
++/* status port used by Apple SMC to get which interrupt type just happened */
++#define APPLESMC_INT_PORT 0x31f
+
+ #define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
+
++/* Defined in ACPI DSDT table, should we read it from there? */
++#define APPLESMC_IRQ 6
++
+ #define APPLESMC_MAX_DATA_LENGTH 32
+
+ #define APPLESMC_STATUS_MASK 0x0f
+@@ -57,6 +63,8 @@
+
+ #define KEY_COUNT_KEY "#KEY" /* r-o ui32 */
+
++#define INTERRUPT_OK_KEY "NTOK" /* w-o ui8 */
++
+ #define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */
+ #define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */
+ #define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */
+@@ -68,6 +76,19 @@
+ #define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
+ #define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
+
++/*
++ * Interrupt controls.
++ * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than
++ * MOLT (free fall), or bigger than MOHT (high acceleration) for longer than the
++ * value of MOLD (or MOHD), SMC will trigger an interrupt.
++ */
++#define MOTION_LOW_NORM "MOLT" /* r/w sp78 (2 bytes) */
++#define MOTION_HIGH_NORM "MOHT" /* r/w sp78 (2 bytes) */
++#define MOTION_LOW_NORM_INTERVAL "MOLD" /* r/w ui8 */
++#define MOTION_HIGH_NORM_INTERVAL "MOHD" /* r/w ui8 */
++
++#define MSDW_KEY "MSDW" /* r/w flag (1 byte) */
++
+ #define FANS_COUNT "FNum" /* r-o ui8 */
+ #define FANS_MANUAL "FS! " /* r-w ui16 */
+ #define FAN_ACTUAL_SPEED "F0Ac" /* r-o fpe2 (2 bytes) */
+@@ -348,12 +369,79 @@ static int applesmc_read_motion_sensor(int index, s16* value)
+ }
+
+ /*
++ * applesmc_init_check_key_value - checks if a given key contains the bytes in
++ * buffer, if not, writes these bytes.
++ * In case of failure retry every INIT_WAIT_MSECS msec, and timeout if it
++ * waited more than INIT_TIMEOUT_MSECS in total.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_init_check_key_value(const char* key, u8* buffer, u8 len)
++{
++ int total, ret, i, compare;
++ u8 rdbuffer[APPLESMC_MAX_DATA_LENGTH];
++
++ if (len > APPLESMC_MAX_DATA_LENGTH) {
++ printk(KERN_ERR "applesmc_init_check_key_value: cannot "
++ "read/write more than %d bytes",
++ APPLESMC_MAX_DATA_LENGTH);
++ return -EINVAL;
++ }
++
++ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++ if (!(ret = applesmc_read_key(key, rdbuffer, len))) {
++ compare = 1;
++ for (i = 0; i < len; i++) {
++ if (rdbuffer[i] != buffer[i]) {
++ compare = 0;
++ break;
++ }
++ }
++
++ if (compare) {
++ return 0;
++ }
++ }
++ ret = applesmc_write_key(key, buffer, len);
++ msleep(INIT_WAIT_MSECS);
++ }
++
++ if (ret)
++ return ret;
++ else
++ return -EIO;
++}
++
++irqreturn_t applesmc_irq_handler(int irq, void *dev_id)
++{
++ u8 int_type = inb(APPLESMC_INT_PORT);
++
++ switch (int_type) {
++ case 0x60:
++ printk("applesmc: received a free fall interrupt\n");
++ break;
++ case 0x6f:
++ printk("applesmc: received a high acceleration interrupt\n");
++ break;
++ case 0x80:
++ printk("applesmc: received a shock interrupt\n");
++ break;
++ default:
++ printk("applesmc: received an unknown interrupt %x\n", int_type);
++ }
++
++ return IRQ_NONE;
++}
++
++/*
+ * applesmc_device_init - initialize the accelerometer. Returns zero on success
+ * and negative error code on failure. Can sleep.
+ */
+ static int applesmc_device_init(void)
+ {
+- int total, ret = -ENXIO;
++ int total;
++ int ret = -ENXIO;
++ int ret1, ret2;
+ u8 buffer[2];
+
+ if (!applesmc_accelerometer)
+@@ -361,32 +449,79 @@ static int applesmc_device_init(void)
+
+ mutex_lock(&applesmc_lock);
+
++ /* Accept interrupts */
++ buffer[0] = 0x01;
+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
+- if (debug)
+- printk(KERN_DEBUG "applesmc try %d\n", total);
+- if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
+- (buffer[0] != 0x00 || buffer[1] != 0x00)) {
+- if (total == INIT_TIMEOUT_MSECS) {
+- printk(KERN_DEBUG "applesmc: device has"
+- " already been initialized"
+- " (0x%02x, 0x%02x).\n",
+- buffer[0], buffer[1]);
+- } else {
+- printk(KERN_DEBUG "applesmc: device"
+- " successfully initialized"
+- " (0x%02x, 0x%02x).\n",
+- buffer[0], buffer[1]);
+- }
+- ret = 0;
+- goto out;
+- }
+- buffer[0] = 0xe0;
+- buffer[1] = 0x00;
+- applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
++ ret1 = applesmc_write_key(INTERRUPT_OK_KEY, buffer, 1);
++ msleep(INIT_WAIT_MSECS);
++
++ if (!ret1)
++ break;
++ }
++ if (ret1)
++ printk(KERN_WARNING "applesmc: Cannot set NTOK key, "
++ "will not receive interrupts.\n");
++
++ /* Setup interrupt controls. */
++ buffer[0] = 20; /* 20 msecs */
++ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM_INTERVAL,
++ buffer, 1);
++
++ buffer[0] = 20; /* 20 msecs */
++ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM_INTERVAL,
++ buffer, 1);
++
++ if (ret1 || ret2) {
++ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
++ "interrupt interval, might not receive "
++ "some interrupts.");
++ }
++
++ buffer[0] = 0x00;
++ buffer[1] = 0x60;
++ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM, buffer, 2);
++
++ buffer[0] = 0x01;
++ buffer[1] = 0xc0;
++ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM, buffer, 2);
++
++ if (ret1 || ret2) {
++ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
++ "min/max norm parameters, "
++ "might not receive some interrupts.");
++ }
++
++ /* Mysterious key. */
++ buffer[0] = 0x01;
++ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++ ret1 = applesmc_write_key(MSDW_KEY, buffer, 1);
+ msleep(INIT_WAIT_MSECS);
++
++ if (!ret1)
++ break;
++ }
++ if (ret1)
++ printk(KERN_WARNING "applesmc: Cannot set MSDW key\n");
++
++ /* Initialize the device. */
++ buffer[0] = 0xe0;
++ buffer[1] = 0xf8;
++ if (applesmc_init_check_key_value(MOTION_SENSOR_KEY, buffer, 2)) {
++ printk(KERN_WARNING "applesmc: failed to init "
++ "the accelerometer\n");
++ goto out;
+ }
+
+- printk(KERN_WARNING "applesmc: failed to init the device\n");
++ ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED,
++ "applesmc_irq_handler", NULL);
++
++ if (ret1) {
++ printk(KERN_WARNING "applesmc: cannot setup irq handler\n");
++ }
++
++ printk(KERN_DEBUG "applesmc: accelerometer "
++ "successfully initialized.\n");
++ ret = 0;
+
+ out:
+ mutex_unlock(&applesmc_lock);
+@@ -431,9 +566,16 @@ static int applesmc_resume(struct platform_device *dev)
+ return applesmc_device_init();
+ }
+
++static int applesmc_remove(struct platform_device *dev)
++{
++ free_irq(6, NULL);
++ return 0;
++}
++
+ static struct platform_driver applesmc_driver = {
+ .probe = applesmc_probe,
+ .resume = applesmc_resume,
++ .remove = applesmc_remove,
+ .driver = {
+ .name = "applesmc",
+ .owner = THIS_MODULE,
+@@ -908,6 +1050,122 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
+ return count;
+ }
+
++static ssize_t applesmc_accelerometer_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ int ret;
++ unsigned int value = 0;
++ u8 buffer[2];
++ char* key;
++ int length;
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ switch(sensor_attr->index) {
++ case 0:
++ key = MOTION_LOW_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 1:
++ key = MOTION_HIGH_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 2:
++ key = MOTION_LOW_NORM;
++ length = 2;
++ break;
++ case 3:
++ key = MOTION_HIGH_NORM;
++ length = 2;
++ break;
++ default:
++ printk("Invalid index for applesmc_accelerometer_show");
++ return -EINVAL;
++ }
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(key, buffer, length);
++ if (length == 2)
++ value = ((unsigned int)buffer[0] << 8) | buffer[1];
++ else if (length == 1)
++ value = buffer[0];
++ else {
++ printk("Invalid length for applesmc_param_show");
++ ret = -EINVAL;
++ }
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", value);
++}
++
++static ssize_t applesmc_accelerometer_store(struct device *dev,
++ struct device_attribute *attr,
++ const char *sysfsbuf, size_t count)
++{
++ int ret;
++ u32 value;
++ u8 buffer[2];
++ char* key;
++ int length;
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ switch(sensor_attr->index) {
++ case 0:
++ key = MOTION_LOW_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 1:
++ key = MOTION_HIGH_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 2:
++ key = MOTION_LOW_NORM;
++ length = 2;
++ break;
++ case 3:
++ key = MOTION_HIGH_NORM;
++ length = 2;
++ break;
++ default:
++ printk("Invalid index for applesmc_accelerometer_show");
++ return -EINVAL;
++ }
++
++ value = simple_strtoul(sysfsbuf, NULL, 10);
++
++ if (length == 2) {
++ if (value > 0xffff)
++ return -EINVAL;
++
++ buffer[0] = (value >> 8) & 0xff;
++ buffer[1] = value & 0xff;
++ } else if (length == 1) {
++ if (value > 0xff)
++ return -EINVAL;
++
++ buffer[0] = value & 0xff;
++ } else {
++ printk("Invalid length for applesmc_param_store");
++ return -EINVAL;
++ }
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_write_key(key, buffer, length);
++
++ mutex_unlock(&applesmc_lock);
++
++ if (ret)
++ return ret;
++ else
++ return count;
++}
++
+ static struct led_classdev applesmc_backlight = {
+ .name = "smc:kbd_backlight",
+ .default_trigger = "nand-disk",
+@@ -917,10 +1175,22 @@ static struct led_classdev applesmc_backlight = {
+ static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
+ static DEVICE_ATTR(calibrate, 0644,
+ applesmc_calibrate_show, applesmc_calibrate_store);
++static SENSOR_DEVICE_ATTR(low_norm_trigger_interval, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 0);
++static SENSOR_DEVICE_ATTR(high_norm_trigger_interval, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 1);
++static SENSOR_DEVICE_ATTR(low_norm_trigger, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 2);
++static SENSOR_DEVICE_ATTR(high_norm_trigger, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 3);
+
+ static struct attribute *accelerometer_attributes[] = {
+ &dev_attr_position.attr,
+ &dev_attr_calibrate.attr,
++ &sensor_dev_attr_low_norm_trigger.dev_attr.attr,
++ &sensor_dev_attr_high_norm_trigger.dev_attr.attr,
++ &sensor_dev_attr_low_norm_trigger_interval.dev_attr.attr,
++ &sensor_dev_attr_high_norm_trigger_interval.dev_attr.attr,
+ NULL
+ };
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-16 03:17:46
|
Revision: 118
http://svn.sourceforge.net/mactel-linux/?rev=118&view=rev
Author: nboichat
Date: 2007-04-15 20:17:44 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
Update to latest git.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-16 03:16:51 UTC (rev 117)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-16 03:17:44 UTC (rev 118)
@@ -12,7 +12,7 @@
4 files changed, 948 insertions(+), 0 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
-index 829407f..3e19a09 100644
+index ef84419..a4aab8c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -382,6 +382,12 @@ L: lin...@vg...
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-16 03:16:51 UTC (rev 117)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-16 03:17:44 UTC (rev 118)
@@ -55,7 +55,7 @@
+register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
+(sometimes) documented in processor datasheet.
diff --git a/MAINTAINERS b/MAINTAINERS
-index 3e19a09..b12f11a 100644
+index a4aab8c..41e617a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -973,6 +973,12 @@ M: mh...@wi...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-05-03 09:24:45
|
Revision: 121
http://svn.sourceforge.net/mactel-linux/?rev=121&view=rev
Author: nboichat
Date: 2007-05-03 02:24:38 -0700 (Thu, 03 May 2007)
Log Message:
-----------
Update patchset to 2.6.21.1.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-19 07:24:07 UTC (rev 120)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-05-03 09:24:38 UTC (rev 121)
@@ -12,7 +12,7 @@
4 files changed, 948 insertions(+), 0 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
-index ef84419..a4aab8c 100644
+index 277877a..4b83092 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -382,6 +382,12 @@ L: lin...@vg...
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-19 07:24:07 UTC (rev 120)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-05-03 09:24:38 UTC (rev 121)
@@ -55,7 +55,7 @@
+register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
+(sometimes) documented in processor datasheet.
diff --git a/MAINTAINERS b/MAINTAINERS
-index a4aab8c..41e617a 100644
+index 4b83092..3624a10 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -973,6 +973,12 @@ M: mh...@wi...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-03-21 10:58:15
|
Revision: 91
http://svn.sourceforge.net/mactel-linux/?rev=91&view=rev
Author: nboichat
Date: 2007-03-21 03:58:05 -0700 (Wed, 21 Mar 2007)
Log Message:
-----------
New coretemp patches (0008 is not essential).
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
trunk/kernel/mactel-patches-2.6.21/0008-msr.patch
Added: trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch 2007-03-21 10:58:05 UTC (rev 91)
@@ -0,0 +1,204 @@
+This patch adds support for _safe (exception handled) variants of rdmsr_on_cpu and wrmsr_on_cpu. This is needed for the new coretemp driver, which might step into non-existing MSR (poorly documented).
+
+From: Rudolf Marek <r....@as...>
+
+
+---
+
+ arch/i386/lib/msr-on-cpu.c | 71 ++++++++++++++++++++++++++++++++++++++++----
+ include/asm-i386/msr.h | 12 +++++++
+ include/asm-x86_64/msr.h | 11 +++++++
+ 3 files changed, 87 insertions(+), 7 deletions(-)
+
+diff --git a/arch/i386/lib/msr-on-cpu.c b/arch/i386/lib/msr-on-cpu.c
+index 1c46bda..bd9920b 100644
+--- a/arch/i386/lib/msr-on-cpu.c
++++ b/arch/i386/lib/msr-on-cpu.c
+@@ -6,6 +6,7 @@
+ struct msr_info {
+ u32 msr_no;
+ u32 l, h;
++ int err;
+ };
+
+ static void __rdmsr_on_cpu(void *info)
+@@ -15,20 +16,38 @@ static void __rdmsr_on_cpu(void *info)
+ rdmsr(rv->msr_no, rv->l, rv->h);
+ }
+
+-void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
++static void __rdmsr_safe_on_cpu(void *info)
+ {
++ struct msr_info *rv = info;
++
++ rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h);
++}
++
++static int _rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h, int safe)
++{
++ int err = 0;
+ preempt_disable();
+ if (smp_processor_id() == cpu)
+- rdmsr(msr_no, *l, *h);
++ if (safe)
++ err = rdmsr_safe(msr_no, l, h);
++ else
++ rdmsr(msr_no, *l, *h);
+ else {
+ struct msr_info rv;
+
+ rv.msr_no = msr_no;
+- smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 0, 1);
++ if (safe) {
++ smp_call_function_single(cpu, __rdmsr_safe_on_cpu,
++ &rv, 0, 1);
++ err = rv.err;
++ } else {
++ smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 0, 1);
++ }
+ *l = rv.l;
+ *h = rv.h;
+ }
+ preempt_enable();
++ return err;
+ }
+
+ static void __wrmsr_on_cpu(void *info)
+@@ -38,21 +57,61 @@ static void __wrmsr_on_cpu(void *info)
+ wrmsr(rv->msr_no, rv->l, rv->h);
+ }
+
+-void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
++static void __wrmsr_safe_on_cpu(void *info)
+ {
++ struct msr_info *rv = info;
++
++ rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h);
++}
++
++static int _wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h, int safe)
++{
++ int err = 0;
+ preempt_disable();
+ if (smp_processor_id() == cpu)
+- wrmsr(msr_no, l, h);
++ if (safe)
++ err = wrmsr_safe(msr_no, l, h);
++ else
++ wrmsr(msr_no, l, h);
+ else {
+ struct msr_info rv;
+
+ rv.msr_no = msr_no;
+ rv.l = l;
+ rv.h = h;
+- smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 0, 1);
++ if (safe) {
++ smp_call_function_single(cpu, __wrmsr_safe_on_cpu,
++ &rv, 0, 1);
++ err = rv.err;
++ } else {
++ smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 0, 1);
++ }
+ }
+ preempt_enable();
++ return err;
++}
++
++void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
++{
++ _wrmsr_on_cpu(cpu, msr_no, l, h, 0);
++}
++
++void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
++{
++ _rdmsr_on_cpu(cpu, msr_no, l, h, 0);
++}
++
++int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
++{
++ return _wrmsr_on_cpu(cpu, msr_no, l, h, 1);
++}
++
++int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
++{
++ return _rdmsr_on_cpu(cpu, msr_no, l, h, 1);
+ }
+
+ EXPORT_SYMBOL(rdmsr_on_cpu);
+ EXPORT_SYMBOL(wrmsr_on_cpu);
++EXPORT_SYMBOL(rdmsr_safe_on_cpu);
++EXPORT_SYMBOL(wrmsr_safe_on_cpu);
+diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
+index ec3b680..5ed97c8 100644
+--- a/include/asm-i386/msr.h
++++ b/include/asm-i386/msr.h
+@@ -4,7 +4,7 @@
+ #ifdef CONFIG_PARAVIRT
+ #include <asm/paravirt.h>
+ #else
+-
++#include <linux/errno.h>
+ /*
+ * Access to machine-specific registers (available on 586 and better only)
+ * Note: the rd* operations modify the parameters directly (without using
+@@ -86,6 +86,8 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
+ #ifdef CONFIG_SMP
+ void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
+ void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
++int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
++int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
+ #else /* CONFIG_SMP */
+ static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+ {
+@@ -95,6 +97,14 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+ {
+ wrmsr(msr_no, l, h);
+ }
++static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
++{
++ return rdmsr_safe(msr_no, l, h);
++}
++static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
++{
++ return wrmsr_safe(msr_no, l, h);
++}
+ #endif /* CONFIG_SMP */
+
+ /* symbolic names for some interesting MSRs */
+diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
+index 902f9a5..0327f66 100644
+--- a/include/asm-x86_64/msr.h
++++ b/include/asm-x86_64/msr.h
+@@ -2,6 +2,7 @@
+ #define X86_64_MSR_H 1
+
+ #ifndef __ASSEMBLY__
++#include <linux/errno.h>
+ /*
+ * Access to machine-specific registers (available on 586 and better only)
+ * Note: the rd* operations modify the parameters directly (without using
+@@ -163,6 +164,8 @@ static inline unsigned int cpuid_edx(unsigned int op)
+ #ifdef CONFIG_SMP
+ void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
+ void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
++int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
++int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
+ #else /* CONFIG_SMP */
+ static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+ {
+@@ -172,6 +175,14 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+ {
+ wrmsr(msr_no, l, h);
+ }
++static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
++{
++ return rdmsr_safe(msr_no, l, h);
++}
++static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
++{
++ return wrmsr_safe(msr_no, l, h);
++}
+ #endif /* CONFIG_SMP */
+
+ #endif
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-03-21 10:57:16 UTC (rev 90)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-03-21 10:58:05 UTC (rev 91)
@@ -5,33 +5,30 @@
---
- Documentation/hwmon/coretemp | 37 ++++
- arch/i386/kernel/msr.c | 31 ++-
- drivers/hwmon/Kconfig | 9 +
+ Documentation/hwmon/coretemp | 36 ++++
+ MAINTAINERS | 6 +
+ drivers/hwmon/Kconfig | 8 +
drivers/hwmon/Makefile | 1
- drivers/hwmon/coretemp.c | 400 ++++++++++++++++++++++++++++++++++++++++++
- include/asm-i386/msr.h | 3
- include/asm-x86_64/msr.h | 3
- 7 files changed, 470 insertions(+), 14 deletions(-)
+ drivers/hwmon/coretemp.c | 406 ++++++++++++++++++++++++++++++++++++++++++
+ 5 files changed, 457 insertions(+), 0 deletions(-)
diff --git a/Documentation/hwmon/coretemp b/Documentation/hwmon/coretemp
new file mode 100644
-index 0000000..ba02dee
+index 0000000..870cda9
--- /dev/null
+++ b/Documentation/hwmon/coretemp
-@@ -0,0 +1,37 @@
+@@ -0,0 +1,36 @@
+Kernel driver coretemp
+======================
+
+Supported chips:
+ * All Intel Core family
+ Prefix: 'coretemp'
-+ Addresses scanned: CPUID (family 0x6, models 0xe, 0xf)
++ CPUID: family 0x6, models 0xe, 0xf
+ Datasheet: Intel 64 and IA-32 Architectures Software Developer's Manual
+ Volume 3A: System Programming Guide
+
+Author: Rudolf Marek
-+Contact: Rudolf Marek <r....@as...>
+
+Description
+-----------
@@ -39,7 +36,7 @@
+This driver permits reading temperature sensor embedded inside Intel Core CPU.
+Temperature is measured in degrees Celsius and measurement resolution is
+1 degree C. Valid temperatures are from 0 to TjMax degrees C, because
-+the actual temperature is in fact a delta from TjMax.
++the actual value of temperature register is in fact a delta from TjMax.
+
+Temperature known as TjMax is the maximum junction temperature of processor.
+Intel defines this temperature as 85C or 100C. At this temperature, protection
@@ -47,136 +44,44 @@
+may be raised, if the temperature grows enough (more than TjMax) to trigger
+the Out-Of-Spec bit. Following table summarizes the exported sysfs files:
+
-+temp1_input - Core temperature (in milidegrees of Celsius).
-+temp1_crit - Maximum junction temperature (in milidegrees of Celsius).
++temp1_input - Core temperature (in millidegrees Celsius).
++temp1_crit - Maximum junction temperature (in millidegrees Celsius).
+temp1_crit_alarm - Set when Out-of-spec bit is set, never clears.
+ Correct CPU operation is no longer guaranteed.
-+temp1_label - Contains string with the "Core X", where X is processor
++temp1_label - Contains string "Core X", where X is processor
+ number.
+
-+The TjMax temperature is set to 85C if undocumented model specific register
-+(UMSR) 0xee has bit 30 set. If not the TjMax is 100C as documented in processor
-+datasheet. Intel will not disclose this information to individuals.
-diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
-index bcaa6e9..c9a8f88 100644
---- a/arch/i386/kernel/msr.c
-+++ b/arch/i386/kernel/msr.c
-@@ -87,7 +87,7 @@ static void msr_smp_rdmsr(void *cmd_block)
- cmd->err = rdmsr_eio(cmd->reg, &cmd->data[0], &cmd->data[1]);
- }
++The TjMax temperature is set to 85 degrees C if undocumented model specific
++register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
++(sometimes) documented in processor datasheet.
+diff --git a/MAINTAINERS b/MAINTAINERS
+index cbfdc3e..f74beef 100644
+--- a/MAINTAINERS
++++ b/MAINTAINERS
+@@ -958,6 +958,12 @@ M: mh...@wi...
+ W: http://www.wittsend.com/computone.html
+ S: Maintained
--static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
-+int msr_write(int cpu, u32 reg, u32 eax, u32 edx)
- {
- struct msr_command cmd;
- int ret;
-@@ -107,7 +107,7 @@ static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
- return ret;
- }
-
--static inline int do_rdmsr(int cpu, u32 reg, u32 * eax, u32 * edx)
-+int msr_read(int cpu, u32 reg, u32 * eax, u32 * edx)
- {
- struct msr_command cmd;
- int ret;
-@@ -131,19 +131,22 @@ static inline int do_rdmsr(int cpu, u32 reg, u32 * eax, u32 * edx)
-
- #else /* ! CONFIG_SMP */
-
--static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
-+int msr_write(int cpu, u32 reg, u32 eax, u32 edx)
- {
- return wrmsr_eio(reg, eax, edx);
- }
-
--static inline int do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx)
-+int msr_read(int cpu, u32 reg, u32 *eax, u32 *edx)
- {
- return rdmsr_eio(reg, eax, edx);
- }
-
- #endif /* ! CONFIG_SMP */
-
--static loff_t msr_seek(struct file *file, loff_t offset, int orig)
-+EXPORT_SYMBOL_GPL(msr_write);
-+EXPORT_SYMBOL_GPL(msr_read);
++CORETEMP HARDWARE MONITORING DRIVER
++P: Rudolf Marek
++M: r....@as...
++L: lm-...@lm...
++S: Maintained
+
-+static loff_t msr_fseek(struct file *file, loff_t offset, int orig)
- {
- loff_t ret = -EINVAL;
-
-@@ -161,7 +164,7 @@ static loff_t msr_seek(struct file *file, loff_t offset, int orig)
- return ret;
- }
-
--static ssize_t msr_read(struct file *file, char __user * buf,
-+static ssize_t msr_fread(struct file *file, char __user * buf,
- size_t count, loff_t * ppos)
- {
- u32 __user *tmp = (u32 __user *) buf;
-@@ -174,7 +177,7 @@ static ssize_t msr_read(struct file *file, char __user * buf,
- return -EINVAL; /* Invalid chunk size */
-
- for (; count; count -= 8) {
-- err = do_rdmsr(cpu, reg, &data[0], &data[1]);
-+ err = msr_read(cpu, reg, &data[0], &data[1]);
- if (err)
- return err;
- if (copy_to_user(tmp, &data, 8))
-@@ -185,7 +188,7 @@ static ssize_t msr_read(struct file *file, char __user * buf,
- return ((char __user *)tmp) - buf;
- }
-
--static ssize_t msr_write(struct file *file, const char __user *buf,
-+static ssize_t msr_fwrite(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
- {
- const u32 __user *tmp = (const u32 __user *)buf;
-@@ -200,7 +203,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
- for (; count; count -= 8) {
- if (copy_from_user(&data, tmp, 8))
- return -EFAULT;
-- err = do_wrmsr(cpu, reg, data[0], data[1]);
-+ err = msr_write(cpu, reg, data[0], data[1]);
- if (err)
- return err;
- tmp += 2;
-@@ -209,7 +212,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
- return ((char __user *)tmp) - buf;
- }
-
--static int msr_open(struct inode *inode, struct file *file)
-+static int msr_fopen(struct inode *inode, struct file *file)
- {
- unsigned int cpu = iminor(file->f_path.dentry->d_inode);
- struct cpuinfo_x86 *c = &(cpu_data)[cpu];
-@@ -227,10 +230,10 @@ static int msr_open(struct inode *inode, struct file *file)
- */
- static const struct file_operations msr_fops = {
- .owner = THIS_MODULE,
-- .llseek = msr_seek,
-- .read = msr_read,
-- .write = msr_write,
-- .open = msr_open,
-+ .llseek = msr_fseek,
-+ .read = msr_fread,
-+ .write = msr_fwrite,
-+ .open = msr_fopen,
- };
-
- static int msr_device_create(int i)
+ COSA/SRP SYNC SERIAL DRIVER
+ P: Jan "Yenya" Kasprzak
+ M: ka...@fi...
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
-index 25b72a4..873e463 100644
+index 25b72a4..1d19717 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
-@@ -167,6 +167,15 @@ config SENSORS_ATXP1
+@@ -167,6 +167,14 @@ config SENSORS_ATXP1
This driver can also be built as a module. If so, the module
will be called atxp1.
+config SENSORS_CORETEMP
+ tristate "Intel Core (2) Duo/Solo temperature sensor"
+ depends on HWMON && X86 && EXPERIMENTAL
-+ select X86_MSR
+ help
+ If you say yes here you get support for the temperature
+ sensor inside your CPU. Supported all are all known variants
@@ -199,21 +104,20 @@
obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
new file mode 100644
-index 0000000..f139b41
+index 0000000..a6d19c8
--- /dev/null
+++ b/drivers/hwmon/coretemp.c
-@@ -0,0 +1,400 @@
+@@ -0,0 +1,406 @@
+/*
+ * coretemp.c - Linux kernel module for hardware monitoring
+ *
-+ * Copyright (C) 2006 Rudolf Marek <r....@as...>
++ * Copyright (C) 2007 Rudolf Marek <r....@as...>
+ *
+ * Inspired from many hwmon drivers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version.
++ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -238,10 +142,11 @@
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/platform_device.h>
-+#include <asm/msr.h>
+#include <linux/cpu.h>
++#include <asm/msr.h>
++#include <asm/processor.h>
+
-+#define DRVNAME "coretemp"
++#define DRVNAME "coretemp"
+
+typedef enum { SHOW_TEMP, SHOW_TJMAX, SHOW_LABEL, SHOW_NAME } SHOW;
+
@@ -260,8 +165,7 @@
+ unsigned long last_updated; /* in jiffies */
+ int temp;
+ int tjmax;
-+ /* registers values */
-+ u32 therm_status;
++ u8 alarm;
+};
+
+static struct coretemp_data *coretemp_update_device(struct device *dev);
@@ -270,7 +174,6 @@
+ * Sysfs stuff
+ */
+
-+
+static ssize_t show_name(struct device *dev, struct device_attribute
+ *devattr, char *buf)
+{
@@ -290,7 +193,7 @@
+{
+ struct coretemp_data *data = coretemp_update_device(dev);
+ /* read the Out-of-spec log, never clear */
-+ return sprintf(buf, "%d\n", (data->therm_status >> 5) & 1);
++ return sprintf(buf, "%d\n", data->alarm);
+}
+
+static ssize_t show_temp(struct device *dev,
@@ -298,9 +201,14 @@
+{
+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct coretemp_data *data = coretemp_update_device(dev);
-+ return sprintf(buf, "%d\n",
-+ attr->index ==
-+ SHOW_TEMP ? data->temp : data->tjmax);
++ int err;
++
++ if (attr->index == SHOW_TEMP)
++ err = data->valid ? sprintf(buf, "%d\n", data->temp) : -EAGAIN;
++ else
++ err = sprintf(buf, "%d\n", data->tjmax);
++
++ return err;
+}
+
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL,
@@ -334,14 +242,15 @@
+ u32 eax, edx;
+
+ data->valid = 0;
-+ msr_read(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);
-+ data->therm_status = eax;
-+
++ rdmsr_on_cpu(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);
++ data->alarm = (eax >> 5) & 1;
+ /* update only if data has been valid */
+ if (eax & 0x80000000) {
-+ data->temp = data->tjmax - (((data->therm_status >> 16)
++ data->temp = data->tjmax - (((eax >> 16)
+ & 0x7f) * 1000);
+ data->valid = 1;
++ } else {
++ dev_dbg(dev, "Temperature data invalid (0x%x)\n", eax);
+ }
+ data->last_updated = jiffies;
+ }
@@ -366,33 +275,34 @@
+ data->id = pdev->id;
+ data->name = "coretemp";
+ mutex_init(&data->update_lock);
-+ /* Tjmax default is 100C */
++ /* Tjmax default is 100 degrees C */
+ data->tjmax = 100000;
+
-+ /* Some processors have Tjmax 85 following magic should detect it */
-+ /* family is always 0x6 */
++ /* test if we can access the THERM_STATUS MSR */
++ err = rdmsr_safe_on_cpu(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);
++ if (err) {
++ dev_err(&pdev->dev,
++ "Unable to access THERM_STATUS MSR, giving up\n");
++ goto exit_free;
++ }
+
-+ if (((c->x86_model == 0xf) && (c->x86_mask > 3 )) ||
-+ (c->x86_model == 0xe)) {
++ /* Some processors have Tjmax 85 following magic should detect it
++ Intel won't disclose the information without signed NDA, but
++ individuals cannot sign it. Catch(ed) 22.
++ */
+
-+ err = msr_read(data->id, 0xee, &eax, &edx);
++ if (((c->x86_model == 0xf) && (c->x86_mask > 3)) ||
++ (c->x86_model == 0xe)) {
++ err = rdmsr_safe_on_cpu(data->id, 0xee, &eax, &edx);
+ if (err) {
+ dev_warn(&pdev->dev,
-+ "Unable to access MSR 0xEE, Tjmax left at %d\n",
-+ data->tjmax);
++ "Unable to access MSR 0xEE, Tjmax left at %d"
++ "C\n", data->tjmax/1000);
+ } else if (eax & 0x40000000) {
+ data->tjmax = 85000;
+ }
+ }
+
-+ /* test if we can access the THERM_STATUS MSR */
-+ err = msr_read(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);
-+
-+ if (err) {
-+ dev_err(&pdev->dev,
-+ "Unable to access THERM_STATUS MSR, giving up\n");
-+ goto exit_free;
-+ }
+ platform_set_drvdata(pdev, data);
+
+ if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
@@ -429,9 +339,9 @@
+
+static struct platform_driver coretemp_driver = {
+ .driver = {
-+ .owner = THIS_MODULE,
-+ .name = DRVNAME,
-+ },
++ .owner = THIS_MODULE,
++ .name = DRVNAME,
++ },
+ .probe = coretemp_probe,
+ .remove = __devexit_p(coretemp_remove),
+};
@@ -445,7 +355,7 @@
+static LIST_HEAD(pdev_list);
+static DEFINE_MUTEX(pdev_list_mutex);
+
-+static int __cpuinit coretemp_devices_add(unsigned int cpu)
++static int __cpuinit coretemp_device_add(unsigned int cpu)
+{
+ int err;
+ struct platform_device *pdev;
@@ -456,18 +366,15 @@
+ err = -ENOMEM;
+ printk(KERN_ERR DRVNAME ": Device allocation failed\n");
+ goto exit;
-+
+ }
+
+ pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
-+
+ if (!pdev_entry) {
+ err = -ENOMEM;
+ goto exit_device_put;
+ }
+
+ err = platform_device_add(pdev);
-+
+ if (err) {
+ printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
+ err);
@@ -491,7 +398,7 @@
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
-+void coretemp_devices_remove(unsigned int cpu)
++void coretemp_device_remove(unsigned int cpu)
+{
+ struct pdev_entry *p, *n;
+ mutex_lock(&pdev_list_mutex);
@@ -512,10 +419,10 @@
+
+ switch (action) {
+ case CPU_ONLINE:
-+ coretemp_devices_add(cpu);
++ coretemp_device_add(cpu);
+ break;
+ case CPU_DEAD:
-+ coretemp_devices_remove(cpu);
++ coretemp_device_remove(cpu);
+ break;
+ }
+ return NOTIFY_OK;
@@ -531,7 +438,11 @@
+ int i, err = -ENODEV;
+ struct pdev_entry *p, *n;
+
-+ if (current_cpu_data.x86_vendor != X86_VENDOR_INTEL)
++ printk(KERN_NOTICE DRVNAME ": This driver uses undocumented features"
++ " of Core CPU. Temperature might be wrong!\n");
++
++ /* quick check if we run Intel */
++ if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL)
+ goto exit;
+
+ err = platform_driver_register(&coretemp_driver);
@@ -548,14 +459,14 @@
+ /* supported CPU not found, but report the unknown
+ family 6 CPU */
+ if ((c->x86 == 0x6) && (c->x86_model > 0xf))
-+ printk(KERN_WARNING DRVNAME ": Unknown CPU, please"
-+ " report to the lm-...@lm...\n");
++ printk(KERN_WARNING DRVNAME ": Unknown CPU"
++ "model %x\n", c->x86_model);
+ continue;
+ }
+
-+ err = coretemp_devices_add(i);
++ err = coretemp_device_add(i);
+ if (err)
-+ goto exit_driver;
++ goto exit_devices_unreg;
+ }
+ if (list_empty(&pdev_list)) {
+ err = -ENODEV;
@@ -567,7 +478,7 @@
+#endif
+ return 0;
+
-+exit_driver:
++exit_devices_unreg:
+ mutex_lock(&pdev_list_mutex);
+ list_for_each_entry_safe(p, n, &pdev_list, list) {
+ platform_device_unregister(p->pdev);
@@ -603,31 +514,3 @@
+
+module_init(coretemp_init)
+module_exit(coretemp_exit)
-diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
-index ec3b680..ff73a99 100644
---- a/include/asm-i386/msr.h
-+++ b/include/asm-i386/msr.h
-@@ -97,6 +97,9 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
- }
- #endif /* CONFIG_SMP */
-
-+int msr_write(int cpu, u32 reg, u32 eax, u32 edx);
-+int msr_read(int cpu, u32 reg, u32 *eax, u32 *edx);
-+
- /* symbolic names for some interesting MSRs */
- /* Intel defined MSRs. */
- #define MSR_IA32_P5_MC_ADDR 0
-diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
-index 902f9a5..90662f4 100644
---- a/include/asm-x86_64/msr.h
-+++ b/include/asm-x86_64/msr.h
-@@ -160,6 +160,9 @@ static inline unsigned int cpuid_edx(unsigned int op)
- #define MSR_IA32_UCODE_WRITE 0x79
- #define MSR_IA32_UCODE_REV 0x8b
-
-+int msr_write(int cpu, u32 reg, u32 eax, u32 edx);
-+int msr_read(int cpu, u32 reg, u32 *eax, u32 *edx);
-+
- #ifdef CONFIG_SMP
- void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
- void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
Added: trunk/kernel/mactel-patches-2.6.21/0008-msr.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0008-msr.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0008-msr.patch 2007-03-21 10:58:05 UTC (rev 91)
@@ -0,0 +1,143 @@
+Use functions provided by arch/*/lib/msr-on-cpu.c in arch/i386/kernel/msr.c.
+
+From: Nicolas Boichat <ni...@bo...>
+
+
+---
+
+ arch/i386/kernel/msr.c | 106 ++----------------------------------------------
+ 1 files changed, 4 insertions(+), 102 deletions(-)
+
+diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
+index bcaa6e9..8cd0a91 100644
+--- a/arch/i386/kernel/msr.c
++++ b/arch/i386/kernel/msr.c
+@@ -45,104 +45,6 @@
+
+ static struct class *msr_class;
+
+-static inline int wrmsr_eio(u32 reg, u32 eax, u32 edx)
+-{
+- int err;
+-
+- err = wrmsr_safe(reg, eax, edx);
+- if (err)
+- err = -EIO;
+- return err;
+-}
+-
+-static inline int rdmsr_eio(u32 reg, u32 *eax, u32 *edx)
+-{
+- int err;
+-
+- err = rdmsr_safe(reg, eax, edx);
+- if (err)
+- err = -EIO;
+- return err;
+-}
+-
+-#ifdef CONFIG_SMP
+-
+-struct msr_command {
+- int err;
+- u32 reg;
+- u32 data[2];
+-};
+-
+-static void msr_smp_wrmsr(void *cmd_block)
+-{
+- struct msr_command *cmd = (struct msr_command *)cmd_block;
+-
+- cmd->err = wrmsr_eio(cmd->reg, cmd->data[0], cmd->data[1]);
+-}
+-
+-static void msr_smp_rdmsr(void *cmd_block)
+-{
+- struct msr_command *cmd = (struct msr_command *)cmd_block;
+-
+- cmd->err = rdmsr_eio(cmd->reg, &cmd->data[0], &cmd->data[1]);
+-}
+-
+-static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
+-{
+- struct msr_command cmd;
+- int ret;
+-
+- preempt_disable();
+- if (cpu == smp_processor_id()) {
+- ret = wrmsr_eio(reg, eax, edx);
+- } else {
+- cmd.reg = reg;
+- cmd.data[0] = eax;
+- cmd.data[1] = edx;
+-
+- smp_call_function_single(cpu, msr_smp_wrmsr, &cmd, 1, 1);
+- ret = cmd.err;
+- }
+- preempt_enable();
+- return ret;
+-}
+-
+-static inline int do_rdmsr(int cpu, u32 reg, u32 * eax, u32 * edx)
+-{
+- struct msr_command cmd;
+- int ret;
+-
+- preempt_disable();
+- if (cpu == smp_processor_id()) {
+- ret = rdmsr_eio(reg, eax, edx);
+- } else {
+- cmd.reg = reg;
+-
+- smp_call_function_single(cpu, msr_smp_rdmsr, &cmd, 1, 1);
+-
+- *eax = cmd.data[0];
+- *edx = cmd.data[1];
+-
+- ret = cmd.err;
+- }
+- preempt_enable();
+- return ret;
+-}
+-
+-#else /* ! CONFIG_SMP */
+-
+-static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
+-{
+- return wrmsr_eio(reg, eax, edx);
+-}
+-
+-static inline int do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx)
+-{
+- return rdmsr_eio(reg, eax, edx);
+-}
+-
+-#endif /* ! CONFIG_SMP */
+-
+ static loff_t msr_seek(struct file *file, loff_t offset, int orig)
+ {
+ loff_t ret = -EINVAL;
+@@ -174,9 +76,9 @@ static ssize_t msr_read(struct file *file, char __user * buf,
+ return -EINVAL; /* Invalid chunk size */
+
+ for (; count; count -= 8) {
+- err = do_rdmsr(cpu, reg, &data[0], &data[1]);
++ err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
+ if (err)
+- return err;
++ return -EIO;
+ if (copy_to_user(tmp, &data, 8))
+ return -EFAULT;
+ tmp += 2;
+@@ -200,9 +102,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
+ for (; count; count -= 8) {
+ if (copy_from_user(&data, tmp, 8))
+ return -EFAULT;
+- err = do_wrmsr(cpu, reg, data[0], data[1]);
++ err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]);
+ if (err)
+- return err;
++ return -EIO;
+ tmp += 2;
+ }
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-03-21 11:01:54
|
Revision: 92
http://svn.sourceforge.net/mactel-linux/?rev=92&view=rev
Author: nboichat
Date: 2007-03-21 04:01:40 -0700 (Wed, 21 Mar 2007)
Log Message:
-----------
Remove useless controls on Macbook Pro and Macmini. Needs testing on Macmini. Will probably not work on Macbook.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch 2007-03-21 10:58:05 UTC (rev 91)
+++ trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch 2007-03-21 11:01:40 UTC (rev 92)
@@ -1,5 +1,7 @@
Fix audio on Macbook Pro.
+Need to be dropped when 2.6.21-rc5 is released (in 2.6.21-rc4-git*)
+
From: Nicolas Boichat <ni...@bo...>
Modified: trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-03-21 10:58:05 UTC (rev 91)
+++ trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-03-21 11:01:40 UTC (rev 92)
@@ -5,14 +5,14 @@
---
- sound/pci/hda/patch_sigmatel.c | 10 ++--------
- 1 files changed, 2 insertions(+), 8 deletions(-)
+ sound/pci/hda/patch_sigmatel.c | 18 +++++++++---------
+ 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 2d78a9f..9ff5cf2 100644
+index c94291b..4c5fee3 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -524,12 +524,6 @@ static unsigned int d945gtp5_pin_configs[10] = {
+@@ -524,16 +524,16 @@ static unsigned int d945gtp5_pin_configs[10] = {
0x02a19320, 0x40000100,
};
@@ -20,18 +20,29 @@
- 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110,
- 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e,
- 0x400000fc, 0x400000fb,
--};
--
++static unsigned int macmini_pin_configs[10] = {
++ 0x0321e230, 0x400000fd, 0x9017e110, 0x01014010,
++ 0x400000fd, 0x0381e021, 0x1345e240, 0x13c5e22e,
++ 0x400000fc, 0x400000fb
+ };
+
static unsigned int macbook_pro_v1_pin_configs[10] = {
- 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
- 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
-@@ -546,8 +540,8 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
+- 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
+- 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
+- 0x02a19320, 0x400000fb
++ 0x0321e230, 0x02a7e020, 0x9017e110, 0x01014010,
++ 0x400000fd, 0x0381e021, 0x1345e240, 0x13c5e22e,
++ 0x400000fc, 0x400000fb
+ };
+
+ static unsigned int macbook_pro_v2_pin_configs[10] = {
+@@ -546,8 +546,8 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
[STAC_D945_REF] = ref922x_pin_configs,
[STAC_D945GTP3] = d945gtp3_pin_configs,
[STAC_D945GTP5] = d945gtp5_pin_configs,
- [STAC_MACMINI] = d945gtp5_pin_configs,
- [STAC_MACBOOK] = macbook_pin_configs,
-+ [STAC_MACMINI] = macbook_pro_v1_pin_configs,
++ [STAC_MACMINI] = macmini_pin_configs,
+ [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
[STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
[STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-03 04:33:10
|
Revision: 96
http://svn.sourceforge.net/mactel-linux/?rev=96&view=rev
Author: nboichat
Date: 2007-04-02 21:33:05 -0700 (Mon, 02 Apr 2007)
Log Message:
-----------
Update apply script to allow a patch to depend on another one.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/apply
trunk/kernel/mactel-patches-2.6.21/unapply
Modified: trunk/kernel/mactel-patches-2.6.21/apply
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/apply 2007-04-03 04:32:38 UTC (rev 95)
+++ trunk/kernel/mactel-patches-2.6.21/apply 2007-04-03 04:33:05 UTC (rev 96)
@@ -7,21 +7,26 @@
WORK=$PWD
+APPLIED=""
+
cd $1
for i in `ls $WORK/*.patch`
do
patch -p1 --dry-run < $i > /dev/null
if [ "$?" != "0" ]; then
- echo "$i would not apply cleanly"
+ echo -n "$i" | sed -e "s/.*\/\(.*\)$/\1/"
+ echo " would not apply cleanly"
+ for j in $APPLIED
+ do
+ echo "$j" | sed -e "s/.*\/\(.*\)$/Reversing \1.../"
+ patch -s -R -p1 < $j
+ done
exit
fi
-done
-
-for i in `ls $WORK/*.patch`
-do
echo "$i" | sed -e "s/.*\/\(.*\)$/Applying \1.../"
- patch -p1 < $i
+ patch -s -p1 < $i
+ APPLIED="$i $APPLIED"
done
grep "^EXTRAVERSION *=.*-mactel$" Makefile > /dev/null
Modified: trunk/kernel/mactel-patches-2.6.21/unapply
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/unapply 2007-04-03 04:32:38 UTC (rev 95)
+++ trunk/kernel/mactel-patches-2.6.21/unapply 2007-04-03 04:33:05 UTC (rev 96)
@@ -1,27 +1,32 @@
#!/bin/sh
if [ "$1" == "" ]; then
- echo "usage ./apply kerneldir"
+ echo "usage ./unapply kerneldir"
exit 0
fi
WORK=$PWD
+REVERSED=""
+
cd $1
for i in `ls -r $WORK/*.patch`
do
patch -R -p1 --dry-run < $i > /dev/null
if [ "$?" != "0" ]; then
- echo "$i would not unapply cleanly"
+ echo -n "$i" | sed -e "s/.*\/\(.*\)$/\1/"
+ echo " would not reverse cleanly"
+ for j in $REVERSED
+ do
+ echo "$j" | sed -e "s/.*\/\(.*\)$/Applying \1.../"
+ patch -s -p1 < $j
+ done
exit
fi
-done
-
-for i in `ls -r $WORK/*.patch`
-do
echo "$i" | sed -e "s/.*\/\(.*\)$/Reversing \1.../"
- patch -R -p1 < $i
+ patch -s -R -p1 < $i
+ REVERSED="$i $REVERSED"
done
echo "changing version in Makefile"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-03 04:34:47
|
Revision: 97
http://svn.sourceforge.net/mactel-linux/?rev=97&view=rev
Author: nboichat
Date: 2007-04-02 21:34:45 -0700 (Mon, 02 Apr 2007)
Log Message:
-----------
Update 2.6.21 patchset.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-03 04:33:05 UTC (rev 96)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-04-03 04:34:45 UTC (rev 97)
@@ -12,7 +12,7 @@
4 files changed, 948 insertions(+), 0 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
-index 81bcc22..cbfdc3e 100644
+index 8c8090e..57a2d44 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -367,6 +367,12 @@ L: lin...@vg...
Modified: trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-03 04:33:05 UTC (rev 96)
+++ trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch 2007-04-03 04:34:45 UTC (rev 97)
@@ -55,7 +55,7 @@
+register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
+(sometimes) documented in processor datasheet.
diff --git a/MAINTAINERS b/MAINTAINERS
-index cbfdc3e..f74beef 100644
+index 57a2d44..28b4fbf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -958,6 +958,12 @@ M: mh...@wi...
Deleted: trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch 2007-04-03 04:33:05 UTC (rev 96)
+++ trunk/kernel/mactel-patches-2.6.21/0006-sigmatel_audio.patch 2007-04-03 04:34:45 UTC (rev 97)
@@ -1,92 +0,0 @@
-Fix audio on Macbook Pro.
-
-Need to be dropped when 2.6.21-rc5 is released (in 2.6.21-rc4-git*)
-
-From: Nicolas Boichat <ni...@bo...>
-
-
----
-
- Documentation/sound/alsa/ALSA-Configuration.txt | 3 ++-
- sound/pci/hda/patch_sigmatel.c | 25 +++++++++++++++++------
- 2 files changed, 21 insertions(+), 7 deletions(-)
-
-diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
-index db398a6..438f3fe 100644
---- a/Documentation/sound/alsa/ALSA-Configuration.txt
-+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
-@@ -906,7 +906,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
- 5stack D945 5stack + SPDIF
- macmini Intel Mac Mini
- macbook Intel Mac Book
-- macbook-pro Intel Mac Book Pro
-+ macbook-pro-v1 Intel Mac Book Pro 1st generation
-+ macbook-pro Intel Mac Book Pro 2nd generation
-
- STAC9202/9250/9251
- ref Reference board, base config
-diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 4c7b039..2d78a9f 100644
---- a/sound/pci/hda/patch_sigmatel.c
-+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -60,7 +60,8 @@ enum {
- STAC_D945GTP5,
- STAC_MACMINI,
- STAC_MACBOOK,
-- STAC_MACBOOK_PRO,
-+ STAC_MACBOOK_PRO_V1,
-+ STAC_MACBOOK_PRO_V2,
- STAC_922X_MODELS
- };
-
-@@ -529,7 +530,13 @@ static unsigned int macbook_pin_configs[10] = {
- 0x400000fc, 0x400000fb,
- };
-
--static unsigned int macbook_pro_pin_configs[10] = {
-+static unsigned int macbook_pro_v1_pin_configs[10] = {
-+ 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
-+ 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
-+ 0x02a19320, 0x400000fb
-+};
-+
-+static unsigned int macbook_pro_v2_pin_configs[10] = {
- 0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
- 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
- 0x400000fc, 0x400000fb,
-@@ -541,7 +548,8 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
- [STAC_D945GTP5] = d945gtp5_pin_configs,
- [STAC_MACMINI] = d945gtp5_pin_configs,
- [STAC_MACBOOK] = macbook_pin_configs,
-- [STAC_MACBOOK_PRO] = macbook_pro_pin_configs,
-+ [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
-+ [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
- };
-
- static const char *stac922x_models[STAC_922X_MODELS] = {
-@@ -550,7 +558,8 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
- [STAC_D945GTP3] = "3stack",
- [STAC_MACMINI] = "macmini",
- [STAC_MACBOOK] = "macbook",
-- [STAC_MACBOOK_PRO] = "macbook-pro",
-+ [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
-+ [STAC_MACBOOK_PRO_V2] = "macbook-pro",
- };
-
- static struct snd_pci_quirk stac922x_cfg_tbl[] = {
-@@ -1889,9 +1898,13 @@ static int patch_stac922x(struct hda_codec *codec)
- /* Intel Macs have all same PCI SSID, so we need to check
- * codec SSID to distinguish the exact models
- */
-+ printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
- switch (codec->subsystem_id) {
-- case 0x106b1e00:
-- spec->board_config = STAC_MACBOOK_PRO;
-+ case 0x106b0200: /* MacBook Pro first generation */
-+ spec->board_config = STAC_MACBOOK_PRO_V1;
-+ break;
-+ case 0x106b1e00: /* MacBook Pro second generation */
-+ spec->board_config = STAC_MACBOOK_PRO_V2;
- break;
- }
- }
Added: trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-03 04:34:45 UTC (rev 97)
@@ -0,0 +1,22 @@
+Display all controls when the subsystem id is wrong (0x100).
+
+From: Nicolas Boichat <ni...@bo...>
+
+
+---
+
+ sound/pci/hda/patch_sigmatel.c | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
+index 4c5fee3..13cb0c5 100644
+--- a/sound/pci/hda/patch_sigmatel.c
++++ b/sound/pci/hda/patch_sigmatel.c
+@@ -1905,6 +1905,7 @@ static int patch_stac922x(struct hda_codec *codec)
+ */
+ printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
+ switch (codec->subsystem_id) {
++ case 0x100:
+ case 0x106b0200: /* MacBook Pro first generation */
+ spec->board_config = STAC_MACBOOK_PRO_V1;
+ break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Nicolas B. <ni...@bo...> - 2007-04-04 01:48:22
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kai Weber wrote: > * nbo...@us... <nbo...@us...>: > > Hi Nicolas, do you consider the comment from Dmitry Torokhov? > http://lkml.org/lkml/2007/3/22/193 > > I think, he is right on this. > > "Please consider implemention open and close methods for the input > device and start/stop timer from there - there is no point of checking > hardware state if noone is listening to events." Yeah yeah I agree, he's right... Thank you for pointing me out this message, for some reason I never received it. Will fix that. > In this blog post the author thinks, that a interrupt is used in > AppleSMC for sensor monitoring > (http://blog.technologeek.org/2006/12/27/44). Have you infos about that? Interesting post, unfortunately he does not provide anything proving what he's stating in his article. (not saying he never contacted me to give me more details about his findings) For example, for me, this sentence: "It is highly probable that the OS X driver is taking over the fan control to keep the machine both cool and quiet." contradicts basic principles of physics, I don't understand how you can run the fans more slowly, and have a lower temperature... Anyway, it's very highly likely there are some interrupts in the SMC, which are not handled by the Linux driver. These are probably used for the accelerometer device, to be able to park the head of the hard drive quickly in case of shock of free fall (the old PowerBook AMS supports these interrupts, and I don't see why Apple would have removed this important feature). Best regards, Nicolas -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGEwO401ajQnpJXgERAlLCAJ44neMKd4TvtOYYkwOpbxr2Dp/O9ACfaZbV NPH0UEpfMD03N2NtvmyLRyw= =DY9z -----END PGP SIGNATURE----- |
|
From: mike d. <fl...@po...> - 2007-04-05 15:01:36
|
Nicolas Boichat a dit: > > In this blog post the author thinks, that a interrupt is used in > > AppleSMC for sensor monitoring > > (http://blog.technologeek.org/2006/12/27/44). Have you infos about > > that? > > Interesting post, unfortunately he does not provide anything proving > what he's stating in his article. (not saying he never contacted me to > give me more details about his findings) > > For example, for me, this sentence: "It is highly probable that the OS > X driver is taking over the fan control to keep the machine both cool > and quiet." contradicts basic principles of physics, I don't > understand how you can run the fans more slowly, and have a lower > temperature... > > Anyway, it's very highly likely there are some interrupts in the SMC, > which are not handled by the Linux driver. These are probably used for > the accelerometer device, to be able to park the head of the hard > drive quickly in case of shock of free fall (the old PowerBook AMS > supports these interrupts, and I don't see why Apple would have > removed this important feature). Does it seem possible to find out about those persistent mysteries through reverse-engineering? If so, has anyone started yet? -- mike dentifrice <fl...@po...> |
|
From: <nbo...@us...> - 2007-04-09 16:57:56
|
Revision: 103
http://svn.sourceforge.net/mactel-linux/?rev=103&view=rev
Author: nboichat
Date: 2007-04-09 09:57:54 -0700 (Mon, 09 Apr 2007)
Log Message:
-----------
Update AppleSMC:
- Various input dev fixes.
- Allow setting accelerometer interrupt parameters.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch
trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch 2007-04-09 10:54:35 UTC (rev 102)
+++ trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch 2007-04-09 16:57:54 UTC (rev 103)
@@ -1,26 +1,42 @@
-Fix y axis on applesmc input device.
+- Invert y axis on input device. - Only activate the input device polling timer when the device is open. - Others fixes as asked by Dmitry Torokhov.
From: Nicolas Boichat <ni...@bo...>
---
- drivers/hwmon/applesmc.c | 2 ++
- 1 files changed, 2 insertions(+), 0 deletions(-)
+ drivers/hwmon/applesmc.c | 29 +++++++++++++++++++++++++----
+ 1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index 4060667..581ed3e 100644
+index 4060667..f7b59fc 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
-@@ -349,6 +349,7 @@ static void applesmc_calibrate(void)
+@@ -349,9 +349,22 @@ static void applesmc_calibrate(void)
{
applesmc_read_motion_sensor(SENSOR_X, &rest_x);
applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
+ rest_x = -rest_x;
}
- static void applesmc_mousedev_poll(unsigned long unused)
-@@ -366,6 +367,7 @@ static void applesmc_mousedev_poll(unsigned long unused)
+-static void applesmc_mousedev_poll(unsigned long unused)
++static int applesmc_idev_open(struct input_dev *dev)
++{
++ add_timer(&applesmc_timer);
++
++ return 0;
++}
++
++static void applesmc_idev_close(struct input_dev *dev)
++{
++ del_timer_sync(&applesmc_timer);
++}
++
++static void applesmc_idev_poll(unsigned long unused)
+ {
+ s16 x, y;
+
+@@ -366,6 +379,7 @@ static void applesmc_mousedev_poll(unsigned long unused)
if (applesmc_read_motion_sensor(SENSOR_Y, &y))
goto out;
@@ -28,3 +44,37 @@
input_report_abs(applesmc_idev, ABS_X, x - rest_x);
input_report_abs(applesmc_idev, ABS_Y, y - rest_y);
input_sync(applesmc_idev);
+@@ -739,23 +753,30 @@ static int applesmc_create_accelerometer(void)
+
+ /* initialize the input class */
+ applesmc_idev->name = "applesmc";
++ applesmc_idev->id.bustype = BUS_HOST;
+ applesmc_idev->cdev.dev = &pdev->dev;
+ applesmc_idev->evbit[0] = BIT(EV_ABS);
++ applesmc_idev->open = applesmc_idev_open;
++ applesmc_idev->close = applesmc_idev_close;
+ input_set_abs_params(applesmc_idev, ABS_X,
+ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
+ input_set_abs_params(applesmc_idev, ABS_Y,
+ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
+
+- input_register_device(applesmc_idev);
++ ret = input_register_device(applesmc_idev);
++ if (ret)
++ goto out_idev;
+
+ /* start up our timer for the input device */
+ init_timer(&applesmc_timer);
+- applesmc_timer.function = applesmc_mousedev_poll;
++ applesmc_timer.function = applesmc_idev_poll;
+ applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
+- add_timer(&applesmc_timer);
+
+ return 0;
+
++out_idev:
++ input_free_device(applesmc_idev);
++
+ out:
+ printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
+ return ret;
Modified: trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch 2007-04-09 10:54:35 UTC (rev 102)
+++ trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch 2007-04-09 16:57:54 UTC (rev 103)
@@ -5,11 +5,11 @@
---
- drivers/hwmon/applesmc.c | 471 ++++++++++++++++++++++++++++++++++++++++------
- 1 files changed, 410 insertions(+), 61 deletions(-)
+ drivers/hwmon/applesmc.c | 606 +++++++++++++++++++++++++++++++++++++++++-----
+ 1 files changed, 540 insertions(+), 66 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index 581ed3e..c68391d 100644
+index f7b59fc..7c368a3 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -37,40 +37,71 @@
@@ -56,22 +56,18 @@
+#define BACKLIGHT_KEY "LKSB" /* w-o length 2 */
+
+#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */
-+
+
+-#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */
+#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */
+#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */
+#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
+#define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
-
--#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */
++
+/* Interrupt controls. */
+/* Don't know what these parameters control. */
+#define MOTION_SENSOR_PARAM_1L "MOLD" /* r/w ui8 */
+#define MOTION_SENSOR_PARAM_1H "MOHD" /* r/w ui8 */
-
--#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */
--#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */
--#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */
--#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */
++
+/*
+ * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than
+ * MOLT (free fall), or bigger than MOHT (high acceleration), SMC will trigger
@@ -79,7 +75,11 @@
+ */
+#define MOTION_MIN_NORM "MOLT" /* r/w sp78 (2 bytes) */
+#define MOTION_MAX_NORM "MOHT" /* r/w sp78 (2 bytes) */
-+
+
+-#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */
+-#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */
+-#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */
+-#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */
+#define MSDW_KEY "MSDW" /* r/w flag (1 byte) */
-#define FANS_COUNT "FNum" /* r-o length 1 */
@@ -126,7 +126,7 @@
+ if (len > APPLESMC_MAX_DATA_LENGTH) {
+ printk(KERN_ERR "applesmc_read_key: cannot read more than "
-+ APPLESMC_MAX_DATA_LENGTH " bytes");
++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
+ return -EINVAL;
+ }
+
@@ -173,7 +173,7 @@
+ if (len > APPLESMC_MAX_DATA_LENGTH) {
+ printk(KERN_ERR "applesmc_write_key: cannot write more than "
-+ APPLESMC_MAX_DATA_LENGTH " bytes");
++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
+ return -EINVAL;
+ }
+
@@ -290,8 +290,8 @@
+
+ if (len > APPLESMC_MAX_DATA_LENGTH) {
+ printk(KERN_ERR "applesmc_init_check_key_value: cannot "
-+ "read/write more than "
-+ APPLESMC_MAX_DATA_LENGTH " bytes");
++ "read/write more than %d bytes",
++ APPLESMC_MAX_DATA_LENGTH);
+ return -EINVAL;
+ }
+
@@ -436,16 +436,16 @@
+ printk(KERN_WARNING "applesmc: failed to init "
+ "the accelerometer\n");
+ goto out;
- }
-
-- printk(KERN_WARNING "applesmc: failed to init the device\n");
++ }
++
+ ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED,
+ "applesmc_irq_handler", NULL);
+
+ if (ret1) {
+ printk(KERN_WARNING "applesmc: cannot setup irq handler\n");
-+ }
-+
+ }
+
+- printk(KERN_WARNING "applesmc: failed to init the device\n");
+ printk(KERN_DEBUG "applesmc: accelerometer "
+ "successfully initialized.\n");
+ ret = 0;
@@ -469,7 +469,7 @@
.driver = {
.name = "applesmc",
.owner = THIS_MODULE,
-@@ -575,6 +799,33 @@ out:
+@@ -587,6 +811,33 @@ out:
return count;
}
@@ -503,7 +503,7 @@
static ssize_t applesmc_calibrate_show(struct device *dev,
struct device_attribute *attr, char *sysfsbuf)
{
-@@ -591,6 +842,77 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
+@@ -603,6 +854,26 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
return count;
}
@@ -527,6 +527,13 @@
+ return sprintf(sysfsbuf, "%d\n", count);
+}
+
+ static void applesmc_backlight_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+ {
+@@ -615,6 +886,168 @@ static void applesmc_backlight_set(struct led_classdev *led_cdev,
+ mutex_unlock(&applesmc_lock);
+ }
+
+static ssize_t applesmc_key_at_index_show(struct device *dev,
+ struct device_attribute *attr, char *sysfsbuf)
+{
@@ -578,20 +585,151 @@
+ return count;
+}
+
- static void applesmc_backlight_set(struct led_classdev *led_cdev,
- enum led_brightness value)
- {
-@@ -615,6 +937,9 @@ static DEVICE_ATTR(calibrate, 0644,
++static ssize_t applesmc_param_show(char* key, int length, char *sysfsbuf)
++{
++ int ret;
++ unsigned int value = 0;
++ u8 buffer[2];
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(key, buffer, length);
++ if (length == 2) {
++ value = ((unsigned int)buffer[0] << 8) | buffer[1];
++ }
++ else if (length == 1) {
++ value = buffer[0];
++ }
++ else {
++ printk("Invalid length for applesmc_param_show");
++ ret = -EINVAL;
++ }
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return sprintf(sysfsbuf, "%u\n", value);
++}
++
++static ssize_t applesmc_param_store(char* key, int length,
++ const char *sysfsbuf, size_t count)
++{
++ int ret;
++ u32 value;
++ u8 buffer[2];
++
++ value = simple_strtoul(sysfsbuf, NULL, 10);
++
++ if (length == 2) {
++ if (value > 0xffff)
++ return -EINVAL;
++
++ buffer[0] = (value >> 8) & 0xff;
++ buffer[1] = value & 0xff;
++ } else if (length == 1) {
++ if (value > 0xff)
++ return -EINVAL;
++
++ buffer[0] = value & 0xff;
++ } else {
++ printk("Invalid length for applesmc_param_store");
++ return -EINVAL;
++ }
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_write_key(key, buffer, 2);
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return count;
++}
++
++static ssize_t applesmc_param_1_min_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ return applesmc_param_show(MOTION_SENSOR_PARAM_1L, 1, sysfsbuf);
++}
++
++static ssize_t applesmc_param_1_max_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ return applesmc_param_show(MOTION_SENSOR_PARAM_1H, 1, sysfsbuf);
++}
++
++static ssize_t applesmc_norm_min_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ return applesmc_param_show(MOTION_MIN_NORM, 2, sysfsbuf);
++}
++
++static ssize_t applesmc_norm_max_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ return applesmc_param_show(MOTION_MAX_NORM, 2, sysfsbuf);
++}
++
++static ssize_t applesmc_param_1_min_store(struct device *dev,
++ struct device_attribute *attr, const char *sysfsbuf, size_t count)
++{
++ return applesmc_param_store(MOTION_SENSOR_PARAM_1L, 1, sysfsbuf, count);
++}
++
++static ssize_t applesmc_param_1_max_store(struct device *dev,
++ struct device_attribute *attr, const char *sysfsbuf, size_t count)
++{
++ return applesmc_param_store(MOTION_SENSOR_PARAM_1H, 1, sysfsbuf, count);
++}
++
++static ssize_t applesmc_norm_min_store(struct device *dev,
++ struct device_attribute *attr, const char *sysfsbuf, size_t count)
++{
++ return applesmc_param_store(MOTION_MIN_NORM, 2, sysfsbuf, count);
++}
++
++static ssize_t applesmc_norm_max_store(struct device *dev,
++ struct device_attribute *attr, const char *sysfsbuf, size_t count)
++{
++ return applesmc_param_store(MOTION_MAX_NORM, 2, sysfsbuf, count);
++}
++
+ static struct led_classdev applesmc_backlight = {
+ .name = "smc:kbd_backlight",
+ .default_trigger = "nand-disk",
+@@ -624,9 +1057,29 @@ static struct led_classdev applesmc_backlight = {
+ static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
+ static DEVICE_ATTR(calibrate, 0644,
+ applesmc_calibrate_show, applesmc_calibrate_store);
++static DEVICE_ATTR(param_1_min, 0644, applesmc_param_1_min_show, applesmc_param_1_min_store);
++static DEVICE_ATTR(param_1_max, 0644, applesmc_param_1_max_show, applesmc_param_1_max_store);
++static DEVICE_ATTR(norm_min, 0644, applesmc_norm_min_show, applesmc_norm_min_store);
++static DEVICE_ATTR(norm_max, 0644, applesmc_norm_max_show, applesmc_norm_max_store);
static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL);
+static DEVICE_ATTR(key_count, 0444, applesmc_key_count_show, NULL);
+static DEVICE_ATTR(key_at_index, 0600, applesmc_key_at_index_show, applesmc_key_at_index_store);
+
++static struct attribute *accelerometer_attributes[] = {
++ &dev_attr_position.attr,
++ &dev_attr_calibrate.attr,
++ &dev_attr_param_1_min.attr,
++ &dev_attr_param_1_max.attr,
++ &dev_attr_norm_min.attr,
++ &dev_attr_norm_max.attr,
++ NULL
++};
++
++static const struct attribute_group accelerometer_attributes_group =
++ { .attrs = accelerometer_attributes };
++
/*
* Macro defining SENSOR_DEVICE_ATTR for a fan sysfs entries.
* - show actual speed
-@@ -643,6 +968,9 @@ static SENSOR_DEVICE_ATTR_2(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \
+@@ -655,6 +1108,9 @@ static SENSOR_DEVICE_ATTR_2(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \
static SENSOR_DEVICE_ATTR(fan##offset##_manual, S_IRUGO | S_IWUSR, \
applesmc_show_fan_manual, applesmc_store_fan_manual, offset); \
\
@@ -601,7 +739,7 @@
static struct attribute *fan##offset##_attributes[] = { \
&sensor_dev_attr_fan##offset##_actual_speed.dev_attr.attr, \
&sensor_dev_attr_fan##offset##_minimum_speed.dev_attr.attr, \
-@@ -650,6 +978,7 @@ static struct attribute *fan##offset##_attributes[] = { \
+@@ -662,6 +1118,7 @@ static struct attribute *fan##offset##_attributes[] = { \
&sensor_dev_attr_fan##offset##_safe_speed.dev_attr.attr, \
&sensor_dev_attr_fan##offset##_target_speed.dev_attr.attr, \
&sensor_dev_attr_fan##offset##_manual.dev_attr.attr, \
@@ -609,7 +747,7 @@
NULL \
};
-@@ -682,6 +1011,16 @@ static SENSOR_DEVICE_ATTR(temperature_5, S_IRUGO,
+@@ -694,6 +1151,16 @@ static SENSOR_DEVICE_ATTR(temperature_5, S_IRUGO,
applesmc_show_temperature, NULL, 5);
static SENSOR_DEVICE_ATTR(temperature_6, S_IRUGO,
applesmc_show_temperature, NULL, 6);
@@ -626,7 +764,7 @@
static struct attribute *temperature_attributes[] = {
&sensor_dev_attr_temperature_0.dev_attr.attr,
-@@ -691,6 +1030,11 @@ static struct attribute *temperature_attributes[] = {
+@@ -703,6 +1170,11 @@ static struct attribute *temperature_attributes[] = {
&sensor_dev_attr_temperature_4.dev_attr.attr,
&sensor_dev_attr_temperature_5.dev_attr.attr,
&sensor_dev_attr_temperature_6.dev_attr.attr,
@@ -638,7 +776,21 @@
};
/* Module stuff */
-@@ -881,6 +1225,11 @@ static int __init applesmc_init(void)
+@@ -734,11 +1206,8 @@ static int applesmc_create_accelerometer(void)
+ {
+ int ret;
+
+- ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_position.attr);
+- if (ret)
+- goto out;
+-
+- ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_calibrate.attr);
++ ret = sysfs_create_group(&pdev->dev.kobj,
++ &accelerometer_attributes_group);
+ if (ret)
+ goto out;
+
+@@ -900,6 +1369,11 @@ static int __init applesmc_init(void)
goto out_accelerometer;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-04-11 07:48:54
|
Revision: 111
http://svn.sourceforge.net/mactel-linux/?rev=111&view=rev
Author: nboichat
Date: 2007-04-11 00:48:53 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
Hopefully fix audio on Macbook... (reverted to old pins)
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
Modified: trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-04-10 22:48:54 UTC (rev 110)
+++ trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch 2007-04-11 07:48:53 UTC (rev 111)
@@ -5,14 +5,14 @@
---
- sound/pci/hda/patch_sigmatel.c | 19 ++++++++++---------
- 1 files changed, 10 insertions(+), 9 deletions(-)
+ sound/pci/hda/patch_sigmatel.c | 21 +++++++++++++++------
+ 1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index c94291b..07bfc6e 100644
+index c94291b..af46702 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -524,16 +524,16 @@ static unsigned int d945gtp5_pin_configs[10] = {
+@@ -524,16 +524,22 @@ static unsigned int d945gtp5_pin_configs[10] = {
0x02a19320, 0x40000100,
};
@@ -26,32 +26,36 @@
+ 0x400000fc, 0x400000fb
};
- static unsigned int macbook_pro_v1_pin_configs[10] = {
-- 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
-- 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
-- 0x02a19320, 0x400000fb
+-static unsigned int macbook_pro_v1_pin_configs[10] = {
++static unsigned int macbook_pin_configs[10] = {
+ 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
+ 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
+ 0x02a19320, 0x400000fb
++}
++
++static unsigned int macbook_pro_v1_pin_configs[10] = {
+ 0x0321e230, 0x02a7e020, 0x9017e110, 0x01014010,
+ 0x400000fd, 0x0381e021, 0x1345e240, 0x13c5e22e,
+ 0x400000fc, 0x400000fb
};
static unsigned int macbook_pro_v2_pin_configs[10] = {
-@@ -546,8 +546,8 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
+@@ -546,7 +552,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
[STAC_D945_REF] = ref922x_pin_configs,
[STAC_D945GTP3] = d945gtp3_pin_configs,
[STAC_D945GTP5] = d945gtp5_pin_configs,
- [STAC_MACMINI] = d945gtp5_pin_configs,
-- [STAC_MACBOOK] = macbook_pin_configs,
+ [STAC_MACMINI] = macmini_pin_configs,
-+ [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
+ [STAC_MACBOOK] = macbook_pin_configs,
[STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
[STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
- };
-@@ -1905,6 +1905,7 @@ static int patch_stac922x(struct hda_codec *codec)
+@@ -1905,6 +1911,9 @@ static int patch_stac922x(struct hda_codec *codec)
*/
printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
switch (codec->subsystem_id) {
+ case 0x106b0a00: /* MacBook first generation */
++ spec->board_config = STAC_MACBOOK;
++ break;
case 0x106b0200: /* MacBook Pro first generation */
spec->board_config = STAC_MACBOOK_PRO_V1;
break;
Modified: trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-10 22:48:54 UTC (rev 110)
+++ trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch 2007-04-11 07:48:53 UTC (rev 111)
@@ -9,14 +9,14 @@
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 07bfc6e..4f064c3 100644
+index af46702..89a7e19 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -1905,6 +1905,7 @@ static int patch_stac922x(struct hda_codec *codec)
- */
- printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
- switch (codec->subsystem_id) {
+@@ -1914,6 +1914,7 @@ static int patch_stac922x(struct hda_codec *codec)
+ case 0x106b0a00: /* MacBook first generation */
+ spec->board_config = STAC_MACBOOK;
+ break;
+ case 0x100: /* Invalid subsystem ID */
- case 0x106b0a00: /* MacBook first generation */
case 0x106b0200: /* MacBook Pro first generation */
spec->board_config = STAC_MACBOOK_PRO_V1;
+ break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-05-04 03:16:42
|
Revision: 122
http://svn.sourceforge.net/mactel-linux/?rev=122&view=rev
Author: nboichat
Date: 2007-05-03 20:16:41 -0700 (Thu, 03 May 2007)
Log Message:
-----------
Use "series" file provided by stgit to apply and unapply the patches.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/apply
trunk/kernel/mactel-patches-2.6.21/unapply
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/appleir.patch
trunk/kernel/mactel-patches-2.6.21/applesmc.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_enum.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_fix_sleep_in_led_brightness_set.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_int.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_joydev.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_standard.patch
trunk/kernel/mactel-patches-2.6.21/appletouch.patch
trunk/kernel/mactel-patches-2.6.21/coretemp.patch
trunk/kernel/mactel-patches-2.6.21/msr-on-cpu.patch
trunk/kernel/mactel-patches-2.6.21/msr.patch
trunk/kernel/mactel-patches-2.6.21/series
trunk/kernel/mactel-patches-2.6.21/sigmatel_audio2.patch
trunk/kernel/mactel-patches-2.6.21/sigmatel_audio3.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
trunk/kernel/mactel-patches-2.6.21/0002-appleir.patch
trunk/kernel/mactel-patches-2.6.21/0003-msr-on-cpu.patch
trunk/kernel/mactel-patches-2.6.21/0004-coretemp.patch
trunk/kernel/mactel-patches-2.6.21/0005-appletouch.patch
trunk/kernel/mactel-patches-2.6.21/0007-sigmatel_audio2.patch
trunk/kernel/mactel-patches-2.6.21/0008-msr.patch
trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch
trunk/kernel/mactel-patches-2.6.21/0010-sigmatel_audio3.patch
trunk/kernel/mactel-patches-2.6.21/0011-applesmc_standard.patch
trunk/kernel/mactel-patches-2.6.21/0012-applesmc_enum.patch
trunk/kernel/mactel-patches-2.6.21/0013-applesmc_fix_sleep_in_led_brightness_set.patch
trunk/kernel/mactel-patches-2.6.21/0014-applesmc_int.patch
Deleted: trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-05-03 09:24:38 UTC (rev 121)
+++ trunk/kernel/mactel-patches-2.6.21/0001-applesmc.patch 2007-05-04 03:16:41 UTC (rev 122)
@@ -1,1000 +0,0 @@
-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). - SENT UPSTREAM - in mm tree
-
-From: Nicolas Boichat <ni...@bo...>
-
-
----
-
- MAINTAINERS | 6
- drivers/hwmon/Kconfig | 24 +
- drivers/hwmon/Makefile | 1
- drivers/hwmon/applesmc.c | 917 ++++++++++++++++++++++++++++++++++++++++++++++
- 4 files changed, 948 insertions(+), 0 deletions(-)
-
-diff --git a/MAINTAINERS b/MAINTAINERS
-index 277877a..4b83092 100644
---- a/MAINTAINERS
-+++ b/MAINTAINERS
-@@ -382,6 +382,12 @@ L: lin...@vg...
- W: http://www.canb.auug.org.au/~sfr/
- S: Supported
-
-+APPLE SMC DRIVER
-+P: Nicolas Boichat
-+M: ni...@bo...
-+L: mac...@li...
-+S: Maintained
-+
- APPLETALK NETWORK LAYER
- P: Arnaldo Carvalho de Melo
- M: ac...@co...
-diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
-index 6d105a1..25b72a4 100644
---- a/drivers/hwmon/Kconfig
-+++ b/drivers/hwmon/Kconfig
-@@ -594,6 +594,30 @@ config SENSORS_HDAPS
- Say Y here if you have an applicable laptop and want to experience
- the awesome power of hdaps.
-
-+config SENSORS_APPLESMC
-+ tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
-+ depends on HWMON && INPUT && X86
-+ select NEW_LEDS
-+ select LEDS_CLASS
-+ default n
-+ help
-+ 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).
-+
-+ Data from the different sensors, keyboard backlight control and fan
-+ control are accessible via sysfs.
-+
-+ This driver also provides an absolute input class device, allowing
-+ the laptop to act as a pinball machine-esque joystick.
-+
-+ Say Y here if you have an applicable laptop and want to experience
-+ the awesome power of applesmc.
-+
- config HWMON_DEBUG_CHIP
- bool "Hardware Monitoring Chip debugging messages"
- depends on HWMON
-diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
-index 4165c27..544f8d8 100644
---- a/drivers/hwmon/Makefile
-+++ b/drivers/hwmon/Makefile
-@@ -20,6 +20,7 @@ obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
- obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o
- obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
- obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
-+obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
- obj-$(CONFIG_SENSORS_AMS) += ams/
- obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
- obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
-diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-new file mode 100644
-index 0000000..4060667
---- /dev/null
-+++ b/drivers/hwmon/applesmc.c
-@@ -0,0 +1,917 @@
-+/*
-+ * drivers/hwmon/applesmc.c - driver for Apple's SMC (accelerometer, temperature
-+ * sensors, fan control, keyboard backlight control) used in Intel-based Apple
-+ * computers.
-+ *
-+ * Copyright (C) 2007 Nicolas Boichat <ni...@bo...>
-+ *
-+ * Based on hdaps.c driver:
-+ * Copyright (C) 2005 Robert Love <rm...@no...>
-+ * Copyright (C) 2005 Jesper Juhl <jes...@gm...>
-+ *
-+ * Fan control based on smcFanControl:
-+ * Copyright (C) 2006 Hendrik Holtmann <hol...@ma...>
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License v2 as published by the
-+ * Free Software Foundation.
-+ *
-+ * This program is distributed in the hope that it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-+ * more details.
-+ *
-+ * You should have received a copy of the GNU General Public License along with
-+ * this program; if not, write to the Free Software Foundation, Inc.,
-+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-+ */
-+
-+#include <linux/delay.h>
-+#include <linux/platform_device.h>
-+#include <linux/input.h>
-+#include <linux/kernel.h>
-+#include <linux/module.h>
-+#include <linux/timer.h>
-+#include <linux/dmi.h>
-+#include <linux/mutex.h>
-+#include <linux/hwmon-sysfs.h>
-+#include <asm/io.h>
-+#include <linux/leds.h>
-+
-+/* data port used by apple SMC */
-+#define APPLESMC_DATA_PORT 0x300
-+/* command/status port used by apple SMC */
-+#define APPLESMC_CMD_PORT 0x304
-+
-+#define APPLESMC_NR_PORTS 5 /* 0x300-0x304 */
-+
-+#define APPLESMC_STATUS_MASK 0x0f
-+#define APPLESMC_READ_CMD 0x10
-+#define APPLESMC_WRITE_CMD 0x11
-+
-+#define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o length 6 */
-+#define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o length 6 */
-+#define BACKLIGHT_KEY "LKSB" /* w-o */
-+
-+#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */
-+
-+#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */
-+#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */
-+#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */
-+#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */
-+
-+#define FANS_COUNT "FNum" /* r-o length 1 */
-+#define FANS_MANUAL "FS! " /* r-w length 2 */
-+#define FAN_ACTUAL_SPEED "F0Ac" /* r-o length 2 */
-+#define FAN_MIN_SPEED "F0Mn" /* r-o length 2 */
-+#define FAN_MAX_SPEED "F0Mx" /* r-o length 2 */
-+#define FAN_SAFE_SPEED "F0Sf" /* r-o length 2 */
-+#define FAN_TARGET_SPEED "F0Tg" /* r-w length 2 */
-+
-+/* Temperature sensors keys. First set for Macbook(Pro), second for Macmini */
-+static const char* temperature_sensors_sets[][8] = {
-+ { "TB0T", "TC0D", "TC0P", "Th0H", "Ts0P", "Th1H", "Ts1P", NULL },
-+ { "TC0D", "TC0P", NULL }
-+};
-+
-+/* List of keys used to read/write fan speeds */
-+static const char* fan_speed_keys[] = {
-+ FAN_ACTUAL_SPEED,
-+ FAN_MIN_SPEED,
-+ FAN_MAX_SPEED,
-+ FAN_SAFE_SPEED,
-+ FAN_TARGET_SPEED
-+};
-+
-+#define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */
-+#define INIT_WAIT_MSECS 50 /* ... in 50ms increments */
-+
-+#define APPLESMC_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */
-+#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
-+
-+/* Structure to be passed to DMI_MATCH function */
-+struct dmi_match_data {
-+/* Indicates whether this computer has an accelerometer. */
-+ int accelerometer;
-+/* Indicates whether this computer has light sensors and keyboard backlight. */
-+ int light;
-+/* Indicates which temperature sensors set to use. */
-+ int temperature_set;
-+};
-+
-+static int debug = 0;
-+static struct platform_device *pdev;
-+static s16 rest_x;
-+static s16 rest_y;
-+static struct timer_list applesmc_timer;
-+static struct input_dev *applesmc_idev;
-+
-+/* Indicates whether this computer has an accelerometer. */
-+static unsigned int applesmc_accelerometer;
-+
-+/* Indicates whether this computer has light sensors and keyboard backlight. */
-+static unsigned int applesmc_light;
-+
-+/* Indicates which temperature sensors set to use. */
-+static unsigned int applesmc_temperature_set;
-+
-+static struct mutex applesmc_lock;
-+
-+/*
-+ * __wait_status - Wait up to 100ms for the status port to get a certain value
-+ * (masked with 0x0f), returning zero if the value is obtained. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int __wait_status(u8 val)
-+{
-+ unsigned int i;
-+
-+ val = val & APPLESMC_STATUS_MASK;
-+
-+ for (i = 0; i < 10000; i++) {
-+ if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val)
-+ return 0;
-+ udelay(10);
-+ }
-+
-+ printk(KERN_WARNING "applesmc: wait status failed: %x != %x\n",
-+ val, inb(APPLESMC_CMD_PORT));
-+
-+ return -EIO;
-+}
-+
-+/*
-+ * applesmc_read_key - reads len bytes from a given key, and put them in buffer.
-+ * Returns zero on success or a negative error on failure. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_read_key(const char* key, u8* buffer, u8 len)
-+{
-+ int ret = -EIO;
-+ int i;
-+
-+ outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
-+ if (__wait_status(0x0c))
-+ goto out;
-+
-+ for (i = 0; i < 4; i++) {
-+ outb(key[i], APPLESMC_DATA_PORT);
-+ if (__wait_status(0x04))
-+ goto out;
-+ }
-+ if (debug)
-+ printk(KERN_DEBUG "<%s", key);
-+
-+ outb(len, APPLESMC_DATA_PORT);
-+ if (debug)
-+ printk(KERN_DEBUG ">%x", len);
-+
-+ for (i = 0; i < len; i++) {
-+ if (__wait_status(0x05))
-+ goto out;
-+ buffer[i] = inb(APPLESMC_DATA_PORT);
-+ if (debug)
-+ printk(KERN_DEBUG "<%x", buffer[i]);
-+ }
-+ if (debug)
-+ printk(KERN_DEBUG "\n");
-+
-+ ret = 0;
-+
-+out:
-+ return ret;
-+}
-+
-+/*
-+ * applesmc_write_key - writes len bytes from buffer to a given key.
-+ * Returns zero on success or a negative error on failure. Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_write_key(const char* key, u8* buffer, u8 len)
-+{
-+ int ret = -EIO;
-+ int i;
-+
-+ outb(APPLESMC_WRITE_CMD, APPLESMC_CMD_PORT);
-+ if (__wait_status(0x0c))
-+ goto out;
-+
-+ for (i = 0; i < 4; i++) {
-+ outb(key[i], APPLESMC_DATA_PORT);
-+ if (__wait_status(0x04))
-+ goto out;
-+ }
-+
-+ outb(len, APPLESMC_DATA_PORT);
-+
-+ for (i = 0; i < len; i++) {
-+ if (__wait_status(0x04))
-+ goto out;
-+ outb(buffer[i], APPLESMC_DATA_PORT);
-+ }
-+
-+ ret = 0;
-+out:
-+ return ret;
-+}
-+
-+/*
-+ * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). Callers must
-+ * hold applesmc_lock.
-+ */
-+static int applesmc_read_motion_sensor(int index, 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;
-+ }
-+
-+ *value = ((s16)buffer[0] << 8) | buffer[1];
-+
-+ return ret;
-+}
-+
-+/*
-+ * applesmc_device_init - initialize the accelerometer. Returns zero on success
-+ * and negative error code on failure. Can sleep.
-+ */
-+static int applesmc_device_init(void)
-+{
-+ int total, ret = -ENXIO;
-+ u8 buffer[2];
-+
-+ if (!applesmc_accelerometer)
-+ return 0;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
-+ if (debug)
-+ printk(KERN_DEBUG "applesmc try %d\n", total);
-+ if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
-+ (buffer[0] != 0x00 || buffer[1] != 0x00)) {
-+ if (total == INIT_TIMEOUT_MSECS) {
-+ printk(KERN_DEBUG "applesmc: device has"
-+ " already been initialized"
-+ " (0x%02x, 0x%02x).\n",
-+ buffer[0], buffer[1]);
-+ } else {
-+ printk(KERN_DEBUG "applesmc: device"
-+ " successfully initialized"
-+ " (0x%02x, 0x%02x).\n",
-+ buffer[0], buffer[1]);
-+ }
-+ ret = 0;
-+ goto out;
-+ }
-+ buffer[0] = 0xe0;
-+ buffer[1] = 0x00;
-+ applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
-+ msleep(INIT_WAIT_MSECS);
-+ }
-+
-+ printk(KERN_WARNING "applesmc: failed to init the device\n");
-+
-+out:
-+ mutex_unlock(&applesmc_lock);
-+ return ret;
-+}
-+
-+/*
-+ * applesmc_get_fan_count - get the number of fans. Callers must NOT hold
-+ * applesmc_lock.
-+ */
-+static int applesmc_get_fan_count(void)
-+{
-+ int ret;
-+ u8 buffer[1];
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(FANS_COUNT, buffer, 1);
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return buffer[0];
-+}
-+
-+/* Device model stuff */
-+static int applesmc_probe(struct platform_device *dev)
-+{
-+ int ret;
-+
-+ ret = applesmc_device_init();
-+ if (ret)
-+ return ret;
-+
-+ printk(KERN_INFO "applesmc: device successfully initialized.\n");
-+ return 0;
-+}
-+
-+static int applesmc_resume(struct platform_device *dev)
-+{
-+ return applesmc_device_init();
-+}
-+
-+static struct platform_driver applesmc_driver = {
-+ .probe = applesmc_probe,
-+ .resume = applesmc_resume,
-+ .driver = {
-+ .name = "applesmc",
-+ .owner = THIS_MODULE,
-+ },
-+};
-+
-+/*
-+ * applesmc_calibrate - Set our "resting" values. Callers must
-+ * hold applesmc_lock.
-+ */
-+static void applesmc_calibrate(void)
-+{
-+ applesmc_read_motion_sensor(SENSOR_X, &rest_x);
-+ applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
-+}
-+
-+static void applesmc_mousedev_poll(unsigned long unused)
-+{
-+ s16 x, y;
-+
-+ /* Cannot sleep. Try nonblockingly. If we fail, try again later. */
-+ if (!mutex_trylock(&applesmc_lock)) {
-+ mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
-+ return;
-+ }
-+
-+ if (applesmc_read_motion_sensor(SENSOR_X, &x))
-+ goto out;
-+ if (applesmc_read_motion_sensor(SENSOR_Y, &y))
-+ goto out;
-+
-+ input_report_abs(applesmc_idev, ABS_X, x - rest_x);
-+ input_report_abs(applesmc_idev, ABS_Y, y - rest_y);
-+ input_sync(applesmc_idev);
-+
-+out:
-+ mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
-+
-+ mutex_unlock(&applesmc_lock);
-+}
-+
-+/* Sysfs Files */
-+
-+static ssize_t applesmc_position_show(struct device *dev,
-+ struct device_attribute *attr, char *buf)
-+{
-+ int ret;
-+ s16 x, y, z;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_motion_sensor(SENSOR_X, &x);
-+ if (ret)
-+ goto out;
-+ ret = applesmc_read_motion_sensor(SENSOR_Y, &y);
-+ if (ret)
-+ goto out;
-+ ret = applesmc_read_motion_sensor(SENSOR_Z, &z);
-+ if (ret)
-+ goto out;
-+
-+out:
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(buf, "(%d,%d,%d)\n", x, y, z);
-+}
-+
-+static ssize_t applesmc_light_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ int ret;
-+ u8 left = 0, right = 0;
-+ u8 buffer[6];
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, 6);
-+ left = buffer[2];
-+ if (ret)
-+ goto out;
-+ ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, 6);
-+ right = buffer[2];
-+
-+out:
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "(%d,%d)\n", left, right);
-+}
-+
-+/* Displays degree Celsius * 100 */
-+static ssize_t applesmc_show_temperature(struct device *dev,
-+ struct device_attribute *devattr, char *sysfsbuf)
-+{
-+ int ret;
-+ u8 buffer[2];
-+ unsigned int temp;
-+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-+ const char* key =
-+ temperature_sensors_sets[applesmc_temperature_set][attr->index];
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(key, buffer, 2);
-+ temp = buffer[0]*100;
-+ temp += (buffer[1] >> 6) * 25;
-+
-+ mutex_unlock(&applesmc_lock);
-+
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "%u\n", temp);
-+}
-+
-+static ssize_t applesmc_show_fan_speed(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ int ret;
-+ unsigned int speed = 0;
-+ char newkey[5];
-+ u8 buffer[2];
-+ struct sensor_device_attribute_2 *sensor_attr =
-+ to_sensor_dev_attr_2(attr);
-+
-+ newkey[0] = fan_speed_keys[sensor_attr->nr][0];
-+ newkey[1] = '0' + sensor_attr->index;
-+ newkey[2] = fan_speed_keys[sensor_attr->nr][2];
-+ newkey[3] = fan_speed_keys[sensor_attr->nr][3];
-+ newkey[4] = 0;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(newkey, buffer, 2);
-+ speed = ((buffer[0] << 8 | buffer[1]) >> 2);
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "%u\n", speed);
-+}
-+
-+static ssize_t applesmc_store_fan_speed(struct device *dev,
-+ struct device_attribute *attr,
-+ const char *sysfsbuf, size_t count)
-+{
-+ int ret;
-+ u32 speed;
-+ char newkey[5];
-+ u8 buffer[2];
-+ struct sensor_device_attribute_2 *sensor_attr =
-+ to_sensor_dev_attr_2(attr);
-+
-+ speed = simple_strtoul(sysfsbuf, NULL, 10);
-+
-+ if (speed > 0x4000) /* Bigger than a 14-bit value */
-+ return -EINVAL;
-+
-+ newkey[0] = fan_speed_keys[sensor_attr->nr][0];
-+ newkey[1] = '0' + sensor_attr->index;
-+ newkey[2] = fan_speed_keys[sensor_attr->nr][2];
-+ newkey[3] = fan_speed_keys[sensor_attr->nr][3];
-+ newkey[4] = 0;
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ buffer[0] = (speed >> 6) & 0xff;
-+ buffer[1] = (speed << 2) & 0xff;
-+ ret = applesmc_write_key(newkey, buffer, 2);
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return count;
-+}
-+
-+static ssize_t applesmc_show_fan_manual(struct device *dev,
-+ struct device_attribute *devattr, char *sysfsbuf)
-+{
-+ int ret;
-+ u16 manual = 0;
-+ u8 buffer[2];
-+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
-+ manual = ((buffer[0] << 8 | buffer[1]) >> attr->index) & 0x01;
-+
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return sprintf(sysfsbuf, "%d\n", manual);
-+}
-+
-+static ssize_t applesmc_store_fan_manual(struct device *dev,
-+ struct device_attribute *devattr,
-+ const char *sysfsbuf, size_t count)
-+{
-+ int ret;
-+ u8 buffer[2];
-+ u32 input;
-+ u16 val;
-+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-+
-+ input = simple_strtoul(sysfsbuf, NULL, 10);
-+
-+ mutex_lock(&applesmc_lock);
-+
-+ ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
-+ val = (buffer[0] << 8 | buffer[1]);
-+ if (ret)
-+ goto out;
-+
-+ if (input)
-+ val = val | (0x01 << attr->index);
-+ else
-+ val = val & ~(0x01 << attr->index);
-+
-+ buffer[0] = (val >> 8) & 0xFF;
-+ buffer[1] = val & 0xFF;
-+
-+ ret = applesmc_write_key(FANS_MANUAL, buffer, 2);
-+
-+out:
-+ mutex_unlock(&applesmc_lock);
-+ if (ret)
-+ return ret;
-+ else
-+ return count;
-+}
-+
-+static ssize_t applesmc_calibrate_show(struct device *dev,
-+ struct device_attribute *attr, char *sysfsbuf)
-+{
-+ return sprintf(sysfsbuf, "(%d,%d)\n", rest_x, rest_y);
-+}
-+
-+static ssize_t applesmc_calibrate_store(struct device *dev,
-+ struct device_attribute *attr, const char *sysfsbuf, size_t count)
-+{
-+ mutex_lock(&applesmc_lock);
-+ applesmc_calibrate();
-+ mutex_unlock(&applesmc_lock);
-+
-+ return count;
-+}
-+
-+static void applesmc_backlight_set(struct led_classdev *led_cdev,
-+ enum led_brightness value)
-+{
-+ u8 buffer[2];
-+
-+ mutex_lock(&applesmc_lock);
-+ buffer[0] = value;
-+ buffer[1] = 0x00;
-+ applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
-+ mutex_unlock(&applesmc_lock);
-+}
-+
-+static struct led_classdev applesmc_backlight = {
-+ .name = "smc:kbd_backlight",
-+ .default_trigger = "nand-disk",
-+ .brightness_set = applesmc_backlight_set,
-+};
-+
-+static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
-+static DEVICE_ATTR(calibrate, 0644,
-+ applesmc_calibrate_show, applesmc_calibrate_store);
-+
-+static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL);
-+
-+/*
-+ * Macro defining SENSOR_DEVICE_ATTR for a fan sysfs entries.
-+ * - show actual speed
-+ * - show/store minimum speed
-+ * - show maximum speed
-+ * - show safe speed
-+ * - show/store target speed
-+ * - show/store manual mode
-+ */
-+#define sysfs_fan_speeds_offset(offset) \
-+static SENSOR_DEVICE_ATTR_2(fan##offset##_actual_speed, S_IRUGO, \
-+ applesmc_show_fan_speed, NULL, 0, offset); \
-+\
-+static SENSOR_DEVICE_ATTR_2(fan##offset##_minimum_speed, S_IRUGO | S_IWUSR, \
-+ applesmc_show_fan_speed, applesmc_store_fan_speed, 1, offset); \
-+\
-+static SENSOR_DEVICE_ATTR_2(fan##offset##_maximum_speed, S_IRUGO, \
-+ applesmc_show_fan_speed, NULL, 2, offset); \
-+\
-+static SENSOR_DEVICE_ATTR_2(fan##offset##_safe_speed, S_IRUGO, \
-+ applesmc_show_fan_speed, NULL, 3, offset); \
-+\
-+static SENSOR_DEVICE_ATTR_2(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \
-+ applesmc_show_fan_speed, applesmc_store_fan_speed, 4, offset); \
-+\
-+static SENSOR_DEVICE_ATTR(fan##offset##_manual, S_IRUGO | S_IWUSR, \
-+ applesmc_show_fan_manual, applesmc_store_fan_manual, offset); \
-+\
-+static struct attribute *fan##offset##_attributes[] = { \
-+ &sensor_dev_attr_fan##offset##_actual_speed.dev_attr.attr, \
-+ &sensor_dev_attr_fan##offset##_minimum_speed.dev_attr.attr, \
-+ &sensor_dev_attr_fan##offset##_maximum_speed.dev_attr.attr, \
-+ &sensor_dev_attr_fan##offset##_safe_speed.dev_attr.attr, \
-+ &sensor_dev_attr_fan##offset##_target_speed.dev_attr.attr, \
-+ &sensor_dev_attr_fan##offset##_manual.dev_attr.attr, \
-+ NULL \
-+};
-+
-+/*
-+ * Create the needed functions for each fan using the macro defined above
-+ * (2 fans are supported)
-+ */
-+sysfs_fan_speeds_offset(0);
-+sysfs_fan_speeds_offset(1);
-+
-+static const struct attribute_group fan_attribute_groups[] = {
-+ { .attrs = fan0_attributes },
-+ { .attrs = fan1_attributes }
-+};
-+
-+/*
-+ * Temperature sensors sysfs entries.
-+ */
-+static SENSOR_DEVICE_ATTR(temperature_0, S_IRUGO,
-+ applesmc_show_temperature, NULL, 0);
-+static SENSOR_DEVICE_ATTR(temperature_1, S_IRUGO,
-+ applesmc_show_temperature, NULL, 1);
-+static SENSOR_DEVICE_ATTR(temperature_2, S_IRUGO,
-+ applesmc_show_temperature, NULL, 2);
-+static SENSOR_DEVICE_ATTR(temperature_3, S_IRUGO,
-+ applesmc_show_temperature, NULL, 3);
-+static SENSOR_DEVICE_ATTR(temperature_4, S_IRUGO,
-+ applesmc_show_temperature, NULL, 4);
-+static SENSOR_DEVICE_ATTR(temperature_5, S_IRUGO,
-+ applesmc_show_temperature, NULL, 5);
-+static SENSOR_DEVICE_ATTR(temperature_6, S_IRUGO,
-+ applesmc_show_temperature, NULL, 6);
-+
-+static struct attribute *temperature_attributes[] = {
-+ &sensor_dev_attr_temperature_0.dev_attr.attr,
-+ &sensor_dev_attr_temperature_1.dev_attr.attr,
-+ &sensor_dev_attr_temperature_2.dev_attr.attr,
-+ &sensor_dev_attr_temperature_3.dev_attr.attr,
-+ &sensor_dev_attr_temperature_4.dev_attr.attr,
-+ &sensor_dev_attr_temperature_5.dev_attr.attr,
-+ &sensor_dev_attr_temperature_6.dev_attr.attr,
-+};
-+
-+/* Module stuff */
-+
-+/*
-+ * applesmc_dmi_match - found a match. return one, short-circuiting the hunt.
-+ */
-+static int applesmc_dmi_match(struct dmi_system_id *id)
-+{
-+ int i = 0;
-+ struct dmi_match_data* dmi_data = id->driver_data;
-+ printk(KERN_INFO "applesmc: %s detected:\n", id->ident);
-+ applesmc_accelerometer = dmi_data->accelerometer;
-+ printk(KERN_INFO "applesmc: - Model %s accelerometer\n",
-+ applesmc_accelerometer ? "with" : "without");
-+ applesmc_light = dmi_data->light;
-+ printk(KERN_INFO "applesmc: - Model %s light sensors and backlight\n",
-+ applesmc_light ? "with" : "without");
-+
-+ applesmc_temperature_set = dmi_data->temperature_set;
-+ while (temperature_sensors_sets[applesmc_temperature_set][i] != NULL)
-+ i++;
-+ printk(KERN_INFO "applesmc: - Model with %d temperature sensors\n", i);
-+ return 1;
-+}
-+
-+/* Create accelerometer ressources */
-+static int applesmc_create_accelerometer(void)
-+{
-+ int ret;
-+
-+ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_position.attr);
-+ if (ret)
-+ goto out;
-+
-+ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_calibrate.attr);
-+ if (ret)
-+ goto out;
-+
-+ applesmc_idev = input_allocate_device();
-+ if (!applesmc_idev) {
-+ ret = -ENOMEM;
-+ goto out;
-+ }
-+
-+ /* initial calibrate for the input device */
-+ applesmc_calibrate();
-+
-+ /* initialize the input class */
-+ applesmc_idev->name = "applesmc";
-+ applesmc_idev->cdev.dev = &pdev->dev;
-+ applesmc_idev->evbit[0] = BIT(EV_ABS);
-+ input_set_abs_params(applesmc_idev, ABS_X,
-+ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
-+ input_set_abs_params(applesmc_idev, ABS_Y,
-+ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
-+
-+ input_register_device(applesmc_idev);
-+
-+ /* start up our timer for the input device */
-+ init_timer(&applesmc_timer);
-+ applesmc_timer.function = applesmc_mousedev_poll;
-+ applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
-+ add_timer(&applesmc_timer);
-+
-+ return 0;
-+
-+out:
-+ printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
-+ return ret;
-+}
-+
-+/* Release all ressources used by the accelerometer */
-+static void applesmc_release_accelerometer(void)
-+{
-+ del_timer_sync(&applesmc_timer);
-+ input_unregister_device(applesmc_idev);
-+}
-+
-+static __initdata struct dmi_match_data applesmc_dmi_data[] = {
-+/* MacBook Pro: accelerometer, backlight and temperature set 0 */
-+ { .accelerometer = 1, .light = 1, .temperature_set = 0 },
-+/* MacBook: accelerometer and temperature set 0 */
-+ { .accelerometer = 1, .light = 0, .temperature_set = 0 },
-+/* MacBook: temperature set 1 */
-+ { .accelerometer = 0, .light = 0, .temperature_set = 1 }
-+};
-+
-+/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
-+ * So we need to put "Apple MacBook Pro" before "Apple MacBook". */
-+static __initdata struct dmi_system_id applesmc_whitelist[] = {
-+ { applesmc_dmi_match, "Apple MacBook Pro", {
-+ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
-+ DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") },
-+ (void*)&applesmc_dmi_data[0]},
-+ { applesmc_dmi_match, "Apple MacBook", {
-+ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
-+ DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") },
-+ (void*)&applesmc_dmi_data[1]},
-+ { applesmc_dmi_match, "Apple Macmini", {
-+ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
-+ DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") },
-+ (void*)&applesmc_dmi_data[2]},
-+ { .ident = NULL }
-+};
-+
-+static int __init applesmc_init(void)
-+{
-+ int ret;
-+ int count;
-+ int i;
-+
-+ mutex_init(&applesmc_lock);
-+
-+ if (!dmi_check_system(applesmc_whitelist)) {
-+ printk(KERN_WARNING "applesmc: supported laptop not found!\n");
-+ ret = -ENODEV;
-+ goto out;
-+ }
-+
-+ if (!request_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS,
-+ "applesmc")) {
-+ ret = -ENXIO;
-+ goto out;
-+ }
-+
-+ ret = platform_driver_register(&applesmc_driver);
-+ if (ret)
-+ goto out_region;
-+
-+ pdev = platform_device_register_simple("applesmc", -1, NULL, 0);
-+ if (IS_ERR(pdev)) {
-+ ret = PTR_ERR(pdev);
-+ goto out_driver;
-+ }
-+
-+ /* create fan files */
-+ count = applesmc_get_fan_count();
-+ if (count < 0) {
-+ printk(KERN_ERR "applesmc: Cannot get the number of fans.\n");
-+ } else {
-+ printk(KERN_INFO "applesmc: %d fans found.\n", count);
-+
-+ switch (count) {
-+ default:
-+ printk(KERN_WARNING "applesmc: More than 2 fans found,"
-+ " but at most 2 fans are supported"
-+ " by the driver.\n");
-+ case 2:
-+ ret = sysfs_create_group(&pdev->dev.kobj,
-+ &fan_attribute_groups[1]);
-+ if (ret)
-+ goto out_device;
-+ case 1:
-+ ret = sysfs_create_group(&pdev->dev.kobj,
-+ &fan_attribute_groups[0]);
-+ if (ret)
-+ goto out_device;
-+ case 0:
-+ ;
-+ }
-+ }
-+
-+ for (i = 0;
-+ temperature_sensors_sets[applesmc_temperature_set][i] != NULL;
-+ i++) {
-+ ret = sysfs_create_file(&pdev->dev.kobj,
-+ temperature_attributes[i]);
-+ if (ret)
-+ goto out_device;
-+ }
-+
-+ if (applesmc_accelerometer) {
-+ ret = applesmc_create_accelerometer();
-+ if (ret)
-+ goto out_device;
-+ }
-+
-+ if (applesmc_light) {
-+ /* Add light sensor file */
-+ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_light.attr);
-+ if (ret)
-+ goto out_accelerometer;
-+
-+ /* register as a led device */
-+ ret = led_classdev_register(&pdev->dev, &applesmc_backlight);
-+ if (ret < 0)
-+ goto out_accelerometer;
-+ }
-+
-+ printk(KERN_INFO "applesmc: driver successfully loaded.\n");
-+ return 0;
-+
-+out_accelerometer:
-+ if (applesmc_accelerometer)
-+ applesmc_release_accelerometer();
-+out_device:
-+ platform_device_unregister(pdev);
-+out_driver:
-+ platform_driver_unregister(&applesmc_driver);
-+out_region:
-+ release_region(APPLESMC_DATA_PORT, APPLESMC_...
[truncated message content] |
|
From: <nbo...@us...> - 2007-05-04 03:42:06
|
Revision: 123
http://svn.sourceforge.net/mactel-linux/?rev=123&view=rev
Author: nboichat
Date: 2007-05-03 20:42:01 -0700 (Thu, 03 May 2007)
Log Message:
-----------
Add 2 minor patches (one to fix applesmc filenames, the other to fix the comment for the kernel option about fn keys)
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/applesmc_int.patch
trunk/kernel/mactel-patches-2.6.21/series
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch
trunk/kernel/mactel-patches-2.6.21/fix_usb_hidinput_powerbook_comment.patch
Added: trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch 2007-05-04 03:42:01 UTC (rev 123)
@@ -0,0 +1,89 @@
+Subject: Apple SMC driver: fix temperature attribute file names.
+
+From: Jean Delvare <kh...@li...>
+
+These attribute names don't follow the standard, there's an extra "_"
+which shouldn't be there.
+
+Signed-off-by: Jean Delvare <kh...@li...>
+Cc: Nicolas Boichat <ni...@bo...>
+Cc: Dmitry Torokhov <dt...@ma...>
+Signed-off-by: Andrew Morton <ak...@li...>
+---
+
+ drivers/hwmon/applesmc.c | 48 +++++++++++++++++++++++-----------------------
+ 1 files changed, 24 insertions(+), 24 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index ea0a004..4e8da39 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -1011,44 +1011,44 @@ static const struct attribute_group fan_attribute_groups[] = {
+ /*
+ * Temperature sensors sysfs entries.
+ */
+-static SENSOR_DEVICE_ATTR(temp_1_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 0);
+-static SENSOR_DEVICE_ATTR(temp_2_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 1);
+-static SENSOR_DEVICE_ATTR(temp_3_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 2);
+-static SENSOR_DEVICE_ATTR(temp_4_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 3);
+-static SENSOR_DEVICE_ATTR(temp_5_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 4);
+-static SENSOR_DEVICE_ATTR(temp_6_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 5);
+-static SENSOR_DEVICE_ATTR(temp_7_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 6);
+-static SENSOR_DEVICE_ATTR(temp_8_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 7);
+-static SENSOR_DEVICE_ATTR(temp_9_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 8);
+-static SENSOR_DEVICE_ATTR(temp_10_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 9);
+-static SENSOR_DEVICE_ATTR(temp_11_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp11_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 10);
+-static SENSOR_DEVICE_ATTR(temp_12_input, S_IRUGO,
++static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO,
+ applesmc_show_temperature, NULL, 11);
+
+ static struct attribute *temperature_attributes[] = {
+- &sensor_dev_attr_temp_1_input.dev_attr.attr,
+- &sensor_dev_attr_temp_2_input.dev_attr.attr,
+- &sensor_dev_attr_temp_3_input.dev_attr.attr,
+- &sensor_dev_attr_temp_4_input.dev_attr.attr,
+- &sensor_dev_attr_temp_5_input.dev_attr.attr,
+- &sensor_dev_attr_temp_6_input.dev_attr.attr,
+- &sensor_dev_attr_temp_7_input.dev_attr.attr,
+- &sensor_dev_attr_temp_8_input.dev_attr.attr,
+- &sensor_dev_attr_temp_9_input.dev_attr.attr,
+- &sensor_dev_attr_temp_10_input.dev_attr.attr,
+- &sensor_dev_attr_temp_11_input.dev_attr.attr,
+- &sensor_dev_attr_temp_12_input.dev_attr.attr,
++ &sensor_dev_attr_temp1_input.dev_attr.attr,
++ &sensor_dev_attr_temp2_input.dev_attr.attr,
++ &sensor_dev_attr_temp3_input.dev_attr.attr,
++ &sensor_dev_attr_temp4_input.dev_attr.attr,
++ &sensor_dev_attr_temp5_input.dev_attr.attr,
++ &sensor_dev_attr_temp6_input.dev_attr.attr,
++ &sensor_dev_attr_temp7_input.dev_attr.attr,
++ &sensor_dev_attr_temp8_input.dev_attr.attr,
++ &sensor_dev_attr_temp9_input.dev_attr.attr,
++ &sensor_dev_attr_temp10_input.dev_attr.attr,
++ &sensor_dev_attr_temp11_input.dev_attr.attr,
++ &sensor_dev_attr_temp12_input.dev_attr.attr,
+ NULL
+ };
+
Modified: trunk/kernel/mactel-patches-2.6.21/applesmc_int.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/applesmc_int.patch 2007-05-04 03:16:41 UTC (rev 122)
+++ trunk/kernel/mactel-patches-2.6.21/applesmc_int.patch 2007-05-04 03:42:01 UTC (rev 123)
@@ -9,7 +9,7 @@
1 files changed, 293 insertions(+), 23 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index ea0a004..087d101 100644
+index 4e8da39..e9a3a11 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -39,14 +39,20 @@
Added: trunk/kernel/mactel-patches-2.6.21/fix_usb_hidinput_powerbook_comment.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/fix_usb_hidinput_powerbook_comment.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/fix_usb_hidinput_powerbook_comment.patch 2007-05-04 03:42:01 UTC (rev 123)
@@ -0,0 +1,29 @@
+Fix USB_HIDINPUT_POWERBOOK comment in Kconfig.
+
+From: Nicolas Boichat <ni...@bo...>
+
+
+---
+
+ drivers/usb/input/Kconfig | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
+index f88c132..422e26f 100644
+--- a/drivers/usb/input/Kconfig
++++ b/drivers/usb/input/Kconfig
+@@ -28,12 +28,12 @@ comment "Input core support is needed for USB HID input layer or HIDBP support"
+ depends on USB_HID && INPUT=n
+
+ config USB_HIDINPUT_POWERBOOK
+- bool "Enable support for iBook/PowerBook special keys"
++ bool "Enable support for Macintosh special keys"
+ default n
+ depends on USB_HID
+ help
+ Say Y here if you want support for the special keys (Fn, Numlock) on
+- Apple iBooks and PowerBooks.
++ Apple computers (iBooks, PowerBooks, Macbooks).
+
+ If unsure, say N.
+
Modified: trunk/kernel/mactel-patches-2.6.21/series
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/series 2007-05-04 03:16:41 UTC (rev 122)
+++ trunk/kernel/mactel-patches-2.6.21/series 2007-05-04 03:42:01 UTC (rev 123)
@@ -11,4 +11,6 @@
applesmc_standard.patch
applesmc_enum.patch
applesmc_fix_sleep_in_led_brightness_set.patch
+applesmc-fix-names.patch
applesmc_int.patch
+fix_usb_hidinput_powerbook_comment.patch
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-05-06 17:54:26
|
Revision: 124
http://svn.sourceforge.net/mactel-linux/?rev=124&view=rev
Author: nboichat
Date: 2007-05-06 10:54:23 -0700 (Sun, 06 May 2007)
Log Message:
-----------
Merge applesmc patches in one single patch (was done by akpm in the mm tree), add name in the sysfs tree, which should provide lm_sensors support (but lm_sensors crashes).
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_int.patch
trunk/kernel/mactel-patches-2.6.21/series
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/applesmc-mm.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_add_name.patch
Removed Paths:
-------------
trunk/kernel/mactel-patches-2.6.21/applesmc.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_enum.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_fix_sleep_in_led_brightness_set.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_joydev.patch
trunk/kernel/mactel-patches-2.6.21/applesmc_standard.patch
Modified: trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch 2007-05-04 03:42:01 UTC (rev 123)
+++ trunk/kernel/mactel-patches-2.6.21/applesmc-fix-names.patch 2007-05-06 17:54:23 UTC (rev 124)
@@ -15,10 +15,10 @@
1 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index ea0a004..4e8da39 100644
+index 1dc693b..b5d13e7 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
-@@ -1011,44 +1011,44 @@ static const struct attribute_group fan_attribute_groups[] = {
+@@ -1010,44 +1010,44 @@ static const struct attribute_group fan_attribute_groups[] = {
/*
* Temperature sensors sysfs entries.
*/
Added: trunk/kernel/mactel-patches-2.6.21/applesmc-mm.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/applesmc-mm.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/applesmc-mm.patch 2007-05-06 17:54:23 UTC (rev 124)
@@ -0,0 +1,1428 @@
+From: Nicolas Boichat <ni...@bo...>
+
+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).
+
+Signed-off-by: Nicolas Boichat <ni...@bo...>
+Cc: Jean Delvare <kh...@li...>
+Cc: Dmitry Torokhov <dt...@ma...>
+Signed-off-by: Andrew Morton <ak...@li...>
+---
+
+ MAINTAINERS | 6
+ drivers/hwmon/Kconfig | 24 +
+ drivers/hwmon/Makefile | 1
+ drivers/hwmon/applesmc.c | 1339 ++++++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 1370 insertions(+), 0 deletions(-)
+
+diff --git a/MAINTAINERS b/MAINTAINERS
+index 277877a..4b83092 100644
+--- a/MAINTAINERS
++++ b/MAINTAINERS
+@@ -382,6 +382,12 @@ L: lin...@vg...
+ W: http://www.canb.auug.org.au/~sfr/
+ S: Supported
+
++APPLE SMC DRIVER
++P: Nicolas Boichat
++M: ni...@bo...
++L: mac...@li...
++S: Maintained
++
+ APPLETALK NETWORK LAYER
+ P: Arnaldo Carvalho de Melo
+ M: ac...@co...
+diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
+index 6d105a1..25b72a4 100644
+--- a/drivers/hwmon/Kconfig
++++ b/drivers/hwmon/Kconfig
+@@ -594,6 +594,30 @@ config SENSORS_HDAPS
+ Say Y here if you have an applicable laptop and want to experience
+ the awesome power of hdaps.
+
++config SENSORS_APPLESMC
++ tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
++ depends on HWMON && INPUT && X86
++ select NEW_LEDS
++ select LEDS_CLASS
++ default n
++ help
++ 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).
++
++ Data from the different sensors, keyboard backlight control and fan
++ control are accessible via sysfs.
++
++ This driver also provides an absolute input class device, allowing
++ the laptop to act as a pinball machine-esque joystick.
++
++ Say Y here if you have an applicable laptop and want to experience
++ the awesome power of applesmc.
++
+ config HWMON_DEBUG_CHIP
+ bool "Hardware Monitoring Chip debugging messages"
+ depends on HWMON
+diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
+index 4165c27..544f8d8 100644
+--- a/drivers/hwmon/Makefile
++++ b/drivers/hwmon/Makefile
+@@ -20,6 +20,7 @@ obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
+ obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o
+ obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
+ obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
++obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
+ obj-$(CONFIG_SENSORS_AMS) += ams/
+ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
+ obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+new file mode 100644
+index 0000000..1dc693b
+--- /dev/null
++++ b/drivers/hwmon/applesmc.c
+@@ -0,0 +1,1339 @@
++/*
++ * drivers/hwmon/applesmc.c - driver for Apple's SMC (accelerometer, temperature
++ * sensors, fan control, keyboard backlight control) used in Intel-based Apple
++ * computers.
++ *
++ * Copyright (C) 2007 Nicolas Boichat <ni...@bo...>
++ *
++ * Based on hdaps.c driver:
++ * Copyright (C) 2005 Robert Love <rm...@no...>
++ * Copyright (C) 2005 Jesper Juhl <jes...@gm...>
++ *
++ * Fan control based on smcFanControl:
++ * Copyright (C) 2006 Hendrik Holtmann <hol...@ma...>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License v2 as published by the
++ * Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * You should have received a copy of the GNU General Public License along with
++ * this program; if not, write to the Free Software Foundation, Inc.,
++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
++ */
++
++#include <linux/delay.h>
++#include <linux/platform_device.h>
++#include <linux/input.h>
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/timer.h>
++#include <linux/dmi.h>
++#include <linux/mutex.h>
++#include <linux/hwmon-sysfs.h>
++#include <asm/io.h>
++#include <linux/leds.h>
++#include <linux/hwmon.h>
++#include <linux/workqueue.h>
++
++/* data port used by Apple SMC */
++#define APPLESMC_DATA_PORT 0x300
++/* command/status port used by Apple SMC */
++#define APPLESMC_CMD_PORT 0x304
++
++#define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
++
++#define APPLESMC_MAX_DATA_LENGTH 32
++
++#define APPLESMC_STATUS_MASK 0x0f
++#define APPLESMC_READ_CMD 0x10
++#define APPLESMC_WRITE_CMD 0x11
++#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12
++#define APPLESMC_GET_KEY_TYPE_CMD 0x13
++
++#define KEY_COUNT_KEY "#KEY" /* r-o ui32 */
++
++#define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */
++#define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */
++#define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */
++
++#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */
++
++#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */
++#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */
++#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
++#define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
++
++#define FANS_COUNT "FNum" /* r-o ui8 */
++#define FANS_MANUAL "FS! " /* r-w ui16 */
++#define FAN_ACTUAL_SPEED "F0Ac" /* r-o fpe2 (2 bytes) */
++#define FAN_MIN_SPEED "F0Mn" /* r-o fpe2 (2 bytes) */
++#define FAN_MAX_SPEED "F0Mx" /* r-o fpe2 (2 bytes) */
++#define FAN_SAFE_SPEED "F0Sf" /* r-o fpe2 (2 bytes) */
++#define FAN_TARGET_SPEED "F0Tg" /* r-w fpe2 (2 bytes) */
++#define FAN_POSITION "F0ID" /* r-o char[16] */
++
++/*
++ * Temperature sensors keys (sp78 - 2 bytes).
++ * First set for Macbook(Pro), second for Macmini.
++ */
++static const char* temperature_sensors_sets[][13] = {
++ { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
++ "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
++ { "TC0D", "TC0P", NULL }
++};
++
++/* List of keys used to read/write fan speeds */
++static const char* fan_speed_keys[] = {
++ FAN_ACTUAL_SPEED,
++ FAN_MIN_SPEED,
++ FAN_MAX_SPEED,
++ FAN_SAFE_SPEED,
++ FAN_TARGET_SPEED
++};
++
++#define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */
++#define INIT_WAIT_MSECS 50 /* ... in 50ms increments */
++
++#define APPLESMC_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */
++#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
++
++/* Structure to be passed to DMI_MATCH function */
++struct dmi_match_data {
++/* Indicates whether this computer has an accelerometer. */
++ int accelerometer;
++/* Indicates whether this computer has light sensors and keyboard backlight. */
++ int light;
++/* Indicates which temperature sensors set to use. */
++ int temperature_set;
++};
++
++static const int debug;
++static struct platform_device *pdev;
++static s16 rest_x;
++static s16 rest_y;
++static struct timer_list applesmc_timer;
++static struct input_dev *applesmc_idev;
++static struct class_device *hwmon_class_dev;
++
++/* Indicates whether this computer has an accelerometer. */
++static unsigned int applesmc_accelerometer;
++
++/* Indicates whether this computer has light sensors and keyboard backlight. */
++static unsigned int applesmc_light;
++
++/* Indicates which temperature sensors set to use. */
++static unsigned int applesmc_temperature_set;
++
++static struct mutex applesmc_lock;
++
++/*
++ * Last index written to key_at_index sysfs file, and value to use for all other
++ * key_at_index_* sysfs files.
++ */
++static unsigned int key_at_index;
++
++static struct workqueue_struct *applesmc_led_wq;
++
++/*
++ * __wait_status - Wait up to 2ms for the status port to get a certain value
++ * (masked with 0x0f), returning zero if the value is obtained. Callers must
++ * hold applesmc_lock.
++ */
++static int __wait_status(u8 val)
++{
++ unsigned int i;
++
++ val = val & APPLESMC_STATUS_MASK;
++
++ for (i = 0; i < 200; i++) {
++ if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) {
++ if (debug)
++ printk(KERN_DEBUG
++ "Waited %d us for status %x\n",
++ i*10, val);
++ return 0;
++ }
++ udelay(10);
++ }
++
++ printk(KERN_WARNING "applesmc: wait status failed: %x != %x\n",
++ val, inb(APPLESMC_CMD_PORT));
++
++ return -EIO;
++}
++
++/*
++ * applesmc_read_key - reads len bytes from a given key, and put them in buffer.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_read_key(const char* key, u8* buffer, u8 len)
++{
++ int i;
++
++ if (len > APPLESMC_MAX_DATA_LENGTH) {
++ printk(KERN_ERR "applesmc_read_key: cannot read more than "
++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
++ return -EINVAL;
++ }
++
++ outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c))
++ return -EIO;
++
++ for (i = 0; i < 4; i++) {
++ outb(key[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04))
++ return -EIO;
++ }
++ if (debug)
++ printk(KERN_DEBUG "<%s", key);
++
++ outb(len, APPLESMC_DATA_PORT);
++ if (debug)
++ printk(KERN_DEBUG ">%x", len);
++
++ for (i = 0; i < len; i++) {
++ if (__wait_status(0x05))
++ return -EIO;
++ buffer[i] = inb(APPLESMC_DATA_PORT);
++ if (debug)
++ printk(KERN_DEBUG "<%x", buffer[i]);
++ }
++ if (debug)
++ printk(KERN_DEBUG "\n");
++
++ return 0;
++}
++
++/*
++ * applesmc_write_key - writes len bytes from buffer to a given key.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_write_key(const char* key, u8* buffer, u8 len)
++{
++ int i;
++
++ if (len > APPLESMC_MAX_DATA_LENGTH) {
++ printk(KERN_ERR "applesmc_write_key: cannot write more than "
++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH);
++ return -EINVAL;
++ }
++
++ outb(APPLESMC_WRITE_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c))
++ return -EIO;
++
++ for (i = 0; i < 4; i++) {
++ outb(key[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04))
++ return -EIO;
++ }
++
++ outb(len, APPLESMC_DATA_PORT);
++
++ for (i = 0; i < len; i++) {
++ if (__wait_status(0x04))
++ return -EIO;
++ outb(buffer[i], APPLESMC_DATA_PORT);
++ }
++
++ return 0;
++}
++
++/*
++ * applesmc_get_key_at_index - get key at index, and put the result in key
++ * (char[6]). Returns zero on success or a negative error on failure. Callers
++ * must hold applesmc_lock.
++ */
++static int applesmc_get_key_at_index(int index, char* key)
++{
++ int i;
++ u8 readkey[4];
++ readkey[0] = index >> 24;
++ readkey[1] = index >> 16;
++ readkey[2] = index >> 8;
++ readkey[3] = index;
++
++ outb(APPLESMC_GET_KEY_BY_INDEX_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c))
++ return -EIO;
++
++ for (i = 0; i < 4; i++) {
++ outb(readkey[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04))
++ return -EIO;
++ }
++
++ outb(4, APPLESMC_DATA_PORT);
++
++ for (i = 0; i < 4; i++) {
++ if (__wait_status(0x05))
++ return -EIO;
++ key[i] = inb(APPLESMC_DATA_PORT);
++ }
++ key[4] = 0;
++
++ return 0;
++}
++
++/*
++ * applesmc_get_key_type - get key type, and put the result in type (char[6]).
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_get_key_type(char* key, char* type)
++{
++ int i;
++
++ outb(APPLESMC_GET_KEY_TYPE_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c))
++ return -EIO;
++
++ for (i = 0; i < 4; i++) {
++ outb(key[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04))
++ return -EIO;
++ }
++
++ outb(5, APPLESMC_DATA_PORT);
++
++ for (i = 0; i < 6; i++) {
++ if (__wait_status(0x05))
++ return -EIO;
++ type[i] = inb(APPLESMC_DATA_PORT);
++ }
++ type[5] = 0;
++
++ return 0;
++}
++
++/*
++ * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_read_motion_sensor(int index, 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;
++ }
++
++ *value = ((s16)buffer[0] << 8) | buffer[1];
++
++ return ret;
++}
++
++/*
++ * applesmc_device_init - initialize the accelerometer. Returns zero on success
++ * and negative error code on failure. Can sleep.
++ */
++static int applesmc_device_init(void)
++{
++ int total, ret = -ENXIO;
++ u8 buffer[2];
++
++ if (!applesmc_accelerometer)
++ return 0;
++
++ mutex_lock(&applesmc_lock);
++
++ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++ if (debug)
++ printk(KERN_DEBUG "applesmc try %d\n", total);
++ if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
++ (buffer[0] != 0x00 || buffer[1] != 0x00)) {
++ if (total == INIT_TIMEOUT_MSECS) {
++ printk(KERN_DEBUG "applesmc: device has"
++ " already been initialized"
++ " (0x%02x, 0x%02x).\n",
++ buffer[0], buffer[1]);
++ } else {
++ printk(KERN_DEBUG "applesmc: device"
++ " successfully initialized"
++ " (0x%02x, 0x%02x).\n",
++ buffer[0], buffer[1]);
++ }
++ ret = 0;
++ goto out;
++ }
++ buffer[0] = 0xe0;
++ buffer[1] = 0x00;
++ applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
++ msleep(INIT_WAIT_MSECS);
++ }
++
++ printk(KERN_WARNING "applesmc: failed to init the device\n");
++
++out:
++ mutex_unlock(&applesmc_lock);
++ return ret;
++}
++
++/*
++ * applesmc_get_fan_count - get the number of fans. Callers must NOT hold
++ * applesmc_lock.
++ */
++static int applesmc_get_fan_count(void)
++{
++ int ret;
++ u8 buffer[1];
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(FANS_COUNT, buffer, 1);
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return buffer[0];
++}
++
++/* Device model stuff */
++static int applesmc_probe(struct platform_device *dev)
++{
++ int ret;
++
++ ret = applesmc_device_init();
++ if (ret)
++ return ret;
++
++ printk(KERN_INFO "applesmc: device successfully initialized.\n");
++ return 0;
++}
++
++static int applesmc_resume(struct platform_device *dev)
++{
++ return applesmc_device_init();
++}
++
++static struct platform_driver applesmc_driver = {
++ .probe = applesmc_probe,
++ .resume = applesmc_resume,
++ .driver = {
++ .name = "applesmc",
++ .owner = THIS_MODULE,
++ },
++};
++
++/*
++ * applesmc_calibrate - Set our "resting" values. Callers must
++ * hold applesmc_lock.
++ */
++static void applesmc_calibrate(void)
++{
++ applesmc_read_motion_sensor(SENSOR_X, &rest_x);
++ applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
++ rest_x = -rest_x;
++}
++
++static int applesmc_idev_open(struct input_dev *dev)
++{
++ add_timer(&applesmc_timer);
++
++ return 0;
++}
++
++static void applesmc_idev_close(struct input_dev *dev)
++{
++ del_timer_sync(&applesmc_timer);
++}
++
++static void applesmc_idev_poll(unsigned long unused)
++{
++ s16 x, y;
++
++ /* Cannot sleep. Try nonblockingly. If we fail, try again later. */
++ if (!mutex_trylock(&applesmc_lock)) {
++ mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
++ return;
++ }
++
++ if (applesmc_read_motion_sensor(SENSOR_X, &x))
++ goto out;
++ if (applesmc_read_motion_sensor(SENSOR_Y, &y))
++ goto out;
++
++ x = -x;
++ input_report_abs(applesmc_idev, ABS_X, x - rest_x);
++ input_report_abs(applesmc_idev, ABS_Y, y - rest_y);
++ input_sync(applesmc_idev);
++
++out:
++ mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
++
++ mutex_unlock(&applesmc_lock);
++}
++
++/* Sysfs Files */
++
++static ssize_t applesmc_position_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ int ret;
++ s16 x, y, z;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_motion_sensor(SENSOR_X, &x);
++ if (ret)
++ goto out;
++ ret = applesmc_read_motion_sensor(SENSOR_Y, &y);
++ if (ret)
++ goto out;
++ ret = applesmc_read_motion_sensor(SENSOR_Z, &z);
++ if (ret)
++ goto out;
++
++out:
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(buf, PAGE_SIZE, "(%d,%d,%d)\n", x, y, z);
++}
++
++static ssize_t applesmc_light_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ int ret;
++ u8 left = 0, right = 0;
++ u8 buffer[6];
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, 6);
++ left = buffer[2];
++ if (ret)
++ goto out;
++ ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, 6);
++ right = buffer[2];
++
++out:
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "(%d,%d)\n", left, right);
++}
++
++/* Displays degree Celsius * 1000 */
++static ssize_t applesmc_show_temperature(struct device *dev,
++ struct device_attribute *devattr, char *sysfsbuf)
++{
++ int ret;
++ u8 buffer[2];
++ unsigned int temp;
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
++ const char* key =
++ temperature_sensors_sets[applesmc_temperature_set][attr->index];
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(key, buffer, 2);
++ temp = buffer[0]*1000;
++ temp += (buffer[1] >> 6) * 250;
++
++ mutex_unlock(&applesmc_lock);
++
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp);
++}
++
++static ssize_t applesmc_show_fan_speed(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ int ret;
++ unsigned int speed = 0;
++ char newkey[5];
++ u8 buffer[2];
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ newkey[0] = fan_speed_keys[sensor_attr->nr][0];
++ newkey[1] = '0' + sensor_attr->index;
++ newkey[2] = fan_speed_keys[sensor_attr->nr][2];
++ newkey[3] = fan_speed_keys[sensor_attr->nr][3];
++ newkey[4] = 0;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(newkey, buffer, 2);
++ speed = ((buffer[0] << 8 | buffer[1]) >> 2);
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed);
++}
++
++static ssize_t applesmc_store_fan_speed(struct device *dev,
++ struct device_attribute *attr,
++ const char *sysfsbuf, size_t count)
++{
++ int ret;
++ u32 speed;
++ char newkey[5];
++ u8 buffer[2];
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ speed = simple_strtoul(sysfsbuf, NULL, 10);
++
++ if (speed > 0x4000) /* Bigger than a 14-bit value */
++ return -EINVAL;
++
++ newkey[0] = fan_speed_keys[sensor_attr->nr][0];
++ newkey[1] = '0' + sensor_attr->index;
++ newkey[2] = fan_speed_keys[sensor_attr->nr][2];
++ newkey[3] = fan_speed_keys[sensor_attr->nr][3];
++ newkey[4] = 0;
++
++ mutex_lock(&applesmc_lock);
++
++ buffer[0] = (speed >> 6) & 0xff;
++ buffer[1] = (speed << 2) & 0xff;
++ ret = applesmc_write_key(newkey, buffer, 2);
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return count;
++}
++
++static ssize_t applesmc_show_fan_manual(struct device *dev,
++ struct device_attribute *devattr, char *sysfsbuf)
++{
++ int ret;
++ u16 manual = 0;
++ u8 buffer[2];
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
++ manual = ((buffer[0] << 8 | buffer[1]) >> attr->index) & 0x01;
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual);
++}
++
++static ssize_t applesmc_store_fan_manual(struct device *dev,
++ struct device_attribute *devattr,
++ const char *sysfsbuf, size_t count)
++{
++ int ret;
++ u8 buffer[2];
++ u32 input;
++ u16 val;
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
++
++ input = simple_strtoul(sysfsbuf, NULL, 10);
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
++ val = (buffer[0] << 8 | buffer[1]);
++ if (ret)
++ goto out;
++
++ if (input)
++ val = val | (0x01 << attr->index);
++ else
++ val = val & ~(0x01 << attr->index);
++
++ buffer[0] = (val >> 8) & 0xFF;
++ buffer[1] = val & 0xFF;
++
++ ret = applesmc_write_key(FANS_MANUAL, buffer, 2);
++
++out:
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return count;
++}
++
++static ssize_t applesmc_show_fan_position(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ int ret;
++ char newkey[5];
++ u8 buffer[17];
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ newkey[0] = FAN_POSITION[0];
++ newkey[1] = '0' + sensor_attr->index;
++ newkey[2] = FAN_POSITION[2];
++ newkey[3] = FAN_POSITION[3];
++ newkey[4] = 0;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(newkey, buffer, 16);
++ buffer[16] = 0;
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", buffer+4);
++}
++
++static ssize_t applesmc_calibrate_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ return snprintf(sysfsbuf, PAGE_SIZE, "(%d,%d)\n", rest_x, rest_y);
++}
++
++static ssize_t applesmc_calibrate_store(struct device *dev,
++ struct device_attribute *attr, const char *sysfsbuf, size_t count)
++{
++ mutex_lock(&applesmc_lock);
++ applesmc_calibrate();
++ mutex_unlock(&applesmc_lock);
++
++ return count;
++}
++
++/* Store the next backlight value to be written by the work */
++static unsigned int backlight_value;
++
++static void applesmc_backlight_set(struct work_struct *work)
++{
++ u8 buffer[2];
++
++ mutex_lock(&applesmc_lock);
++ buffer[0] = backlight_value;
++ buffer[1] = 0x00;
++ applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
++ mutex_unlock(&applesmc_lock);
++}
++DECLARE_WORK(backlight_work, &applesmc_backlight_set);
++
++static void applesmc_brightness_set(struct led_classdev *led_cdev,
++ enum led_brightness value)
++{
++ int ret;
++
++ backlight_value = value;
++ ret = queue_work(applesmc_led_wq, &backlight_work);
++
++ if (debug && (!ret))
++ printk(KERN_DEBUG "applesmc: work was already on the queue.\n");
++}
++
++static ssize_t applesmc_key_count_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ int ret;
++ u8 buffer[4];
++ u32 count;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(KEY_COUNT_KEY, buffer, 4);
++ count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) +
++ ((u32)buffer[2]<<8) + buffer[3];
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count);
++}
++
++static ssize_t applesmc_key_at_index_read_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ char key[5];
++ char info[6];
++ int ret;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_get_key_at_index(key_at_index, key);
++
++ if (ret || !key[0]) {
++ mutex_unlock(&applesmc_lock);
++
++ return -EINVAL;
++ }
++
++ ret = applesmc_get_key_type(key, info);
++
++ if (ret) {
++ mutex_unlock(&applesmc_lock);
++
++ return ret;
++ }
++
++ /*
++ * info[0] maximum value (APPLESMC_MAX_DATA_LENGTH) is much lower than
++ * PAGE_SIZE, so we don't need any checks before writing to sysfsbuf.
++ */
++ ret = applesmc_read_key(key, sysfsbuf, info[0]);
++
++ mutex_unlock(&applesmc_lock);
++
++ if (!ret) {
++ return info[0];
++ }
++ else {
++ return ret;
++ }
++}
++
++static ssize_t applesmc_key_at_index_data_length_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ char key[5];
++ char info[6];
++ int ret;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_get_key_at_index(key_at_index, key);
++
++ if (ret || !key[0]) {
++ mutex_unlock(&applesmc_lock);
++
++ return -EINVAL;
++ }
++
++ ret = applesmc_get_key_type(key, info);
++
++ mutex_unlock(&applesmc_lock);
++
++ if (!ret)
++ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", info[0]);
++ else
++ return ret;
++}
++
++static ssize_t applesmc_key_at_index_type_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ char key[5];
++ char info[6];
++ int ret;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_get_key_at_index(key_at_index, key);
++
++ if (ret || !key[0]) {
++ mutex_unlock(&applesmc_lock);
++
++ return -EINVAL;
++ }
++
++ ret = applesmc_get_key_type(key, info);
++
++ mutex_unlock(&applesmc_lock);
++
++ if (!ret)
++ return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", info+1);
++ else
++ return ret;
++}
++
++static ssize_t applesmc_key_at_index_name_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ char key[5];
++ int ret;
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_get_key_at_index(key_at_index, key);
++
++ mutex_unlock(&applesmc_lock);
++
++ if (!ret && key[0])
++ return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", key);
++ else
++ return -EINVAL;
++}
++
++static ssize_t applesmc_key_at_index_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", key_at_index);
++}
++
++static ssize_t applesmc_key_at_index_store(struct device *dev,
++ struct device_attribute *attr, const char *sysfsbuf, size_t count)
++{
++ mutex_lock(&applesmc_lock);
++
++ key_at_index = simple_strtoul(sysfsbuf, NULL, 10);
++
++ mutex_unlock(&applesmc_lock);
++
++ return count;
++}
++
++static struct led_classdev applesmc_backlight = {
++ .name = "smc:kbd_backlight",
++ .default_trigger = "nand-disk",
++ .brightness_set = applesmc_brightness_set,
++};
++
++static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
++static DEVICE_ATTR(calibrate, 0644,
++ applesmc_calibrate_show, applesmc_calibrate_store);
++
++static struct attribute *accelerometer_attributes[] = {
++ &dev_attr_position.attr,
++ &dev_attr_calibrate.attr,
++ NULL
++};
++
++static const struct attribute_group accelerometer_attributes_group =
++ { .attrs = accelerometer_attributes };
++
++static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL);
++
++static DEVICE_ATTR(key_count, 0444, applesmc_key_count_show, NULL);
++static DEVICE_ATTR(key_at_index, 0644,
++ applesmc_key_at_index_show, applesmc_key_at_index_store);
++static DEVICE_ATTR(key_at_index_name, 0444,
++ applesmc_key_at_index_name_show, NULL);
++static DEVICE_ATTR(key_at_index_type, 0444,
++ applesmc_key_at_index_type_show, NULL);
++static DEVICE_ATTR(key_at_index_data_length, 0444,
++ applesmc_key_at_index_data_length_show, NULL);
++static DEVICE_ATTR(key_at_index_data, 0444,
++ applesmc_key_at_index_read_show, NULL);
++
++static struct attribute *key_enumeration_attributes[] = {
++ &dev_attr_key_count.attr,
++ &dev_attr_key_at_index.attr,
++ &dev_attr_key_at_index_name.attr,
++ &dev_attr_key_at_index_type.attr,
++ &dev_attr_key_at_index_data_length.attr,
++ &dev_attr_key_at_index_data.attr,
++ NULL
++};
++
++static const struct attribute_group key_enumeration_group =
++ { .attrs = key_enumeration_attributes };
++
++/*
++ * Macro defining SENSOR_DEVICE_ATTR for a fan sysfs entries.
++ * - show actual speed
++ * - show/store minimum speed
++ * - show maximum speed
++ * - show safe speed
++ * - show/store target speed
++ * - show/store manual mode
++ */
++#define sysfs_fan_speeds_offset(offset) \
++static SENSOR_DEVICE_ATTR_2(fan##offset##_input, S_IRUGO, \
++ applesmc_show_fan_speed, NULL...
[truncated message content] |
|
From: <nbo...@us...> - 2007-05-27 11:21:33
|
Revision: 126
http://svn.sourceforge.net/mactel-linux/?rev=126&view=rev
Author: nboichat
Date: 2007-05-27 04:21:30 -0700 (Sun, 27 May 2007)
Log Message:
-----------
Port patch series to 2.6.21.3 (no major differences)
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/series
trunk/kernel/mactel-patches-2.6.21/sigmatel_audio2.patch
trunk/kernel/mactel-patches-2.6.21/sigmatel_audio3.patch
Modified: trunk/kernel/mactel-patches-2.6.21/series
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/series 2007-05-26 22:33:14 UTC (rev 125)
+++ trunk/kernel/mactel-patches-2.6.21/series 2007-05-27 11:21:30 UTC (rev 126)
@@ -1,4 +1,4 @@
-# This series applies on GIT commit 8d8b10482fffcb72b15515231bb942e2ad6395c9
+# This series applies on GIT commit dcf1697d4b4b9b94363b5fb0d97f7949602922ab
applesmc-mm.patch
applesmc-fix-names.patch
applesmc_int.patch
Modified: trunk/kernel/mactel-patches-2.6.21/sigmatel_audio2.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/sigmatel_audio2.patch 2007-05-26 22:33:14 UTC (rev 125)
+++ trunk/kernel/mactel-patches-2.6.21/sigmatel_audio2.patch 2007-05-27 11:21:30 UTC (rev 126)
@@ -9,7 +9,7 @@
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index c94291b..b1df711 100644
+index a6f8992..14e6fb0 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -524,18 +524,24 @@ static unsigned int d945gtp5_pin_configs[10] = {
@@ -51,7 +51,7 @@
[STAC_MACBOOK] = macbook_pin_configs,
[STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
[STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
-@@ -1905,6 +1911,9 @@ static int patch_stac922x(struct hda_codec *codec)
+@@ -1906,6 +1912,9 @@ static int patch_stac922x(struct hda_codec *codec)
*/
printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
switch (codec->subsystem_id) {
Modified: trunk/kernel/mactel-patches-2.6.21/sigmatel_audio3.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/sigmatel_audio3.patch 2007-05-26 22:33:14 UTC (rev 125)
+++ trunk/kernel/mactel-patches-2.6.21/sigmatel_audio3.patch 2007-05-27 11:21:30 UTC (rev 126)
@@ -9,10 +9,10 @@
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index b1df711..4fa6049 100644
+index 14e6fb0..28397aa 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -1914,6 +1914,7 @@ static int patch_stac922x(struct hda_codec *codec)
+@@ -1915,6 +1915,7 @@ static int patch_stac922x(struct hda_codec *codec)
case 0x106b0a00: /* MacBook first generation */
spec->board_config = STAC_MACBOOK;
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nbo...@us...> - 2007-06-19 17:59:56
|
Revision: 131
http://svn.sourceforge.net/mactel-linux/?rev=131&view=rev
Author: nboichat
Date: 2007-06-19 10:59:55 -0700 (Tue, 19 Jun 2007)
Log Message:
-----------
Add applesmc-export-address.patch to 2.6.21 patch line.
Modified Paths:
--------------
trunk/kernel/mactel-patches-2.6.21/series
Added Paths:
-----------
trunk/kernel/mactel-patches-2.6.21/applesmc-export-address.patch
Added: trunk/kernel/mactel-patches-2.6.21/applesmc-export-address.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/applesmc-export-address.patch (rev 0)
+++ trunk/kernel/mactel-patches-2.6.21/applesmc-export-address.patch 2007-06-19 17:59:55 UTC (rev 131)
@@ -0,0 +1,24 @@
+Let the applesmc device export its address to userspace. libsensors needs this to recognize the device and give it a unique ID.
+
+From: Jean Delvare <kh...@li...>
+
+
+---
+
+ drivers/hwmon/applesmc.c | 3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index 5fec762..b36b8a0 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -1468,7 +1468,8 @@ static int __init applesmc_init(void)
+ if (ret)
+ goto out_region;
+
+- pdev = platform_device_register_simple("applesmc", -1, NULL, 0);
++ pdev = platform_device_register_simple("applesmc", APPLESMC_DATA_PORT,
++ NULL, 0);
+ if (IS_ERR(pdev)) {
+ ret = PTR_ERR(pdev);
+ goto out_driver;
Modified: trunk/kernel/mactel-patches-2.6.21/series
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/series 2007-06-19 13:42:37 UTC (rev 130)
+++ trunk/kernel/mactel-patches-2.6.21/series 2007-06-19 17:59:55 UTC (rev 131)
@@ -11,3 +11,4 @@
msr.patch
sigmatel_audio3.patch
fix_usb_hidinput_powerbook_comment.patch
+applesmc-export-address.patch
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|