#include <linux/spinlock.h>
#include <linux/smp_lock.h>
#include <linux/wait.h>
+#include <linux/suspend.h>
+#include <linux/kthread.h>
+#include <linux/moduleparam.h>
+
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/io.h>
#define MANUAL_MASK 0xe0
#define AUTO_MASK 0x20
-static u8 TEMP_REG[3] = {0x26, 0x25, 0x27}; /* local, cpu, gpu */
-static u8 LIMIT_REG[3] = {0x6b, 0x6a, 0x6c}; /* local, cpu, gpu */
+static u8 TEMP_REG[3] = {0x26, 0x25, 0x27}; /* local, sensor1, sensor2 */
+static u8 LIMIT_REG[3] = {0x6b, 0x6a, 0x6c}; /* local, sensor1, sensor2 */
static u8 MANUAL_MODE[2] = {0x5c, 0x5d};
static u8 REM_CONTROL[2] = {0x00, 0x40};
static u8 FAN_SPEED[2] = {0x28, 0x2a};
static u8 FAN_SPD_SET[2] = {0x30, 0x31};
-static u8 default_limits_local[3] = {70, 50, 70}; /* local, cpu, gpu */
-static u8 default_limits_chip[3] = {80, 65, 80}; /* local, cpu, gpu */
+static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */
+static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */
+static char *sensor_location[3] = {NULL, NULL, NULL};
static int limit_adjust = 0;
static int fan_speed = -1;
+static int verbose = 0;
MODULE_AUTHOR("Colin Leroy <colin@colino.net>");
-MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and Powerbook G4 Alu");
+MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and "
+ "Powerbook G4 Alu");
MODULE_LICENSE("GPL");
-MODULE_PARM(limit_adjust,"i");
-MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50°C cpu, 70°C gpu) by N °C.");
-MODULE_PARM(fan_speed,"i");
-MODULE_PARM_DESC(fan_speed,"Specify fan speed (0-255) when lim < temp < lim+8 (default 128)");
+module_param(limit_adjust, int, 0644);
+MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50 sensor1, 70 sensor2) "
+ "by N degrees.");
+
+module_param(fan_speed, int, 0644);
+MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) "
+ "(default 64)");
+
+module_param(verbose, bool, 0);
+MODULE_PARM_DESC(verbose,"Verbose log operations "
+ "(default 0)");
struct thermostat {
struct i2c_client clt;
+ u8 temps[3];
u8 cached_temp[3];
u8 initial_limits[3];
u8 limits[3];
int last_speed[2];
- int overriding[2];
+ int last_var[2];
};
static enum {ADT7460, ADT7467} therm_type;
static int therm_bus, therm_address;
static struct of_device * of_dev;
static struct thermostat* thermostat;
-static pid_t monitor_thread_id;
-static int monitor_running;
-static struct completion monitor_task_compl;
+static struct task_struct *thread_therm = NULL;
+
+static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
+ int busno);
-static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno);
static void write_both_fan_speed(struct thermostat *th, int speed);
static void write_fan_speed(struct thermostat *th, int speed, int fan);
th = thermostat;
- if (monitor_running) {
- monitor_running = 0;
- wait_for_completion(&monitor_task_compl);
+ if (thread_therm != NULL) {
+ kthread_stop(thread_therm);
}
-
- printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d,"
- " to %d, %d, %d, (°C)\n",
+
+ printk(KERN_INFO "adt746x: Putting max temperatures back from "
+ "%d, %d, %d to %d, %d, %d\n",
th->limits[0], th->limits[1], th->limits[2],
- th->initial_limits[0], th->initial_limits[1], th->initial_limits[2]);
-
+ th->initial_limits[0], th->initial_limits[1],
+ th->initial_limits[2]);
+
for (i = 0; i < 3; i++)
write_reg(th, LIMIT_REG[i], th->initial_limits[i]);
}
static struct i2c_driver thermostat_driver = {
- .name ="Apple Thermostat ADT746x",
- .id =0xDEAD7467,
- .flags =I2C_DF_NOTIFY,
- .attach_adapter =&attach_thermostat,
- .detach_adapter =&detach_thermostat,
+ .driver = {
+ .name = "therm_adt746x",
+ },
+ .attach_adapter = attach_thermostat,
+ .detach_adapter = detach_thermostat,
};
static int read_fan_speed(struct thermostat *th, u8 addr)
tmp[0] = read_reg(th, addr + 1);
res = tmp[1] + (tmp[0] << 8);
- return (90000*60)/res;
+ /* "a value of 0xffff means that the fan has stopped" */
+ return (res == 0xffff ? 0 : (90000*60)/res);
}
static void write_both_fan_speed(struct thermostat *th, int speed)
return;
if (th->last_speed[fan] != speed) {
- if (speed == -1)
- printk(KERN_INFO "adt746x: Setting speed to: automatic for %s fan.\n",
- fan?"GPU":"CPU");
- else
- printk(KERN_INFO "adt746x: Setting speed to: %d for %s fan.\n",
- speed, fan?"GPU":"CPU");
+ if (verbose) {
+ if (speed == -1)
+ printk(KERN_DEBUG "adt746x: Setting speed to automatic "
+ "for %s fan.\n", sensor_location[fan+1]);
+ else
+ printk(KERN_DEBUG "adt746x: Setting speed to %d "
+ "for %s fan.\n", speed, sensor_location[fan+1]);
+ }
} else
return;
} else {
/* back to automatic */
if(therm_type == ADT7460) {
- manual = read_reg(th, MANUAL_MODE[fan]) & (~MANUAL_MASK);
- write_reg(th, MANUAL_MODE[fan], manual|REM_CONTROL[fan]);
+ manual = read_reg(th,
+ MANUAL_MODE[fan]) & (~MANUAL_MASK);
+
+ write_reg(th,
+ MANUAL_MODE[fan], manual|REM_CONTROL[fan]);
} else {
manual = read_reg(th, MANUAL_MODE[fan]);
write_reg(th, MANUAL_MODE[fan], manual&(~AUTO_MASK));
th->last_speed[fan] = speed;
}
-static int monitor_task(void *arg)
+static void read_sensors(struct thermostat *th)
{
- struct thermostat* th = arg;
- u8 temps[3];
- u8 lims[3];
- int i;
+ int i = 0;
+
+ for (i = 0; i < 3; i++)
+ th->temps[i] = read_reg(th, TEMP_REG[i]);
+}
+
#ifdef DEBUG
- int mfan_speed;
-#endif
-
- lock_kernel();
- daemonize("kfand");
- unlock_kernel();
- strcpy(current->comm, "thermostat");
- monitor_running = 1;
-
- while(monitor_running)
- {
- msleep(2000);
-
- /* Check status */
- /* local : chip */
- /* remote 1: CPU ?*/
- /* remote 2: GPU ?*/
-#ifndef DEBUG
- if (fan_speed != -1) {
+static void display_stats(struct thermostat *th)
+{
+ if (th->temps[0] != th->cached_temp[0]
+ || th->temps[1] != th->cached_temp[1]
+ || th->temps[2] != th->cached_temp[2]) {
+ printk(KERN_INFO "adt746x: Temperature infos:"
+ " thermostats: %d,%d,%d;"
+ " limits: %d,%d,%d;"
+ " fan speed: %d RPM\n",
+ th->temps[0], th->temps[1], th->temps[2],
+ th->limits[0], th->limits[1], th->limits[2],
+ read_fan_speed(th, FAN_SPEED[0]));
+ }
+ th->cached_temp[0] = th->temps[0];
+ th->cached_temp[1] = th->temps[1];
+ th->cached_temp[2] = th->temps[2];
+}
#endif
- for (i = 0; i < 3; i++) {
- temps[i] = read_reg(th, TEMP_REG[i]);
- lims[i] = th->limits[i];
+
+static void update_fans_speed (struct thermostat *th)
+{
+ int lastvar = 0; /* last variation, for iBook */
+ int i = 0;
+
+ /* we don't care about local sensor, so we start at sensor 1 */
+ for (i = 1; i < 3; i++) {
+ int started = 0;
+ int fan_number = (therm_type == ADT7460 && i == 2);
+ int var = th->temps[i] - th->limits[i];
+
+ if (var > -1) {
+ int step = (255 - fan_speed) / 7;
+ int new_speed = 0;
+
+ /* hysteresis : change fan speed only if variation is
+ * more than two degrees */
+ if (abs(var - th->last_var[fan_number]) < 2)
+ continue;
+
+ started = 1;
+ new_speed = fan_speed + ((var-1)*step);
+
+ if (new_speed < fan_speed)
+ new_speed = fan_speed;
+ if (new_speed > 255)
+ new_speed = 255;
+
+ if (verbose)
+ printk(KERN_DEBUG "adt746x: Setting fans speed to %d "
+ "(limit exceeded by %d on %s) \n",
+ new_speed, var,
+ sensor_location[fan_number+1]);
+ write_both_fan_speed(th, new_speed);
+ th->last_var[fan_number] = var;
+ } else if (var < -2) {
+ /* don't stop fan if sensor2 is cold and sensor1 is not
+ * so cold (lastvar >= -1) */
+ if (i == 2 && lastvar < -1) {
+ if (th->last_speed[fan_number] != 0)
+ if (verbose)
+ printk(KERN_DEBUG "adt746x: Stopping "
+ "fans.\n");
+ write_both_fan_speed(th, 0);
}
-#ifndef DEBUG
}
+
+ lastvar = var;
+
+ if (started)
+ return; /* we don't want to re-stop the fan
+ * if sensor1 is heating and sensor2 is not */
+ }
+}
+
+static int monitor_task(void *arg)
+{
+ struct thermostat* th = arg;
+
+ while(!kthread_should_stop()) {
+ try_to_freeze();
+ msleep_interruptible(2000);
+
+#ifndef DEBUG
+ if (fan_speed != -1)
+ read_sensors(th);
+#else
+ read_sensors(th);
#endif
- if (fan_speed != -1) {
- int lastvar = 0; /* for iBook */
- for (i = 1; i < 3; i++) { /* we don't care about local sensor */
- int started = 0;
- int fan_number = (therm_type == ADT7460 && i == 2);
- int var = temps[i] - lims[i];
- if (var > 8) {
- if (th->overriding[fan_number] == 0)
- printk(KERN_INFO "adt746x: Limit exceeded by %d°C, overriding specified fan speed for %s.\n",
- var, fan_number?"GPU":"CPU");
- th->overriding[fan_number] = 1;
- write_fan_speed(th, 255, fan_number);
- started = 1;
- } else if ((!th->overriding[fan_number] || var < 6) && var > 0) {
- if (th->overriding[fan_number] == 1)
- printk(KERN_INFO "adt746x: Limit exceeded by %d°C, setting speed to specified for %s.\n",
- var, fan_number?"GPU":"CPU");
- th->overriding[fan_number] = 0;
- write_fan_speed(th, fan_speed, fan_number);
- started = 1;
- } else if (var < -1) {
- /* don't stop iBook fan if GPU is cold and CPU is not
- * so cold (lastvar >= -1) */
- if (therm_type == ADT7460 || lastvar < -1 || i == 1) {
- if (th->last_speed[fan_number] != 0)
- printk(KERN_INFO "adt746x: Stopping %s fan.\n",
- fan_number?"GPU":"CPU");
- write_fan_speed(th, 0, fan_number);
- }
- }
-
- lastvar = var;
-
- if (started && therm_type == ADT7467)
- break; /* we don't want to re-stop the fan
- * if CPU is heating and GPU is not */
- }
- }
+
+ if (fan_speed != -1)
+ update_fans_speed(th);
+
#ifdef DEBUG
- mfan_speed = read_fan_speed(th, FAN_SPEED[0]);
- /* only one fan in the iBook G4 */
-
- if (temps[0] != th->cached_temp[0]
- || temps[1] != th->cached_temp[1]
- || temps[2] != th->cached_temp[2]) {
- printk(KERN_INFO "adt746x: Temperature infos:"
- " thermostats: %d,%d,%d °C;"
- " limits: %d,%d,%d °C;"
- " fan speed: %d RPM\n",
- temps[0], temps[1], temps[2],
- lims[0], lims[1], lims[2],
- mfan_speed);
- }
- th->cached_temp[0] = temps[0];
- th->cached_temp[1] = temps[1];
- th->cached_temp[2] = temps[2];
-#endif
+ display_stats(th);
+#endif
+
}
- complete_and_exit(&monitor_task_compl, 0);
return 0;
}
-static void
-set_limit(struct thermostat *th, int i)
+static void set_limit(struct thermostat *th, int i)
{
- /* Set CPU limit higher to avoid powerdowns */
+ /* Set sensor1 limit higher to avoid powerdowns */
th->limits[i] = default_limits_chip[i] + limit_adjust;
write_reg(th, LIMIT_REG[i], th->limits[i]);
/* set our limits to normal */
th->limits[i] = default_limits_local[i] + limit_adjust;
}
-
-static int
-attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
+
+static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
+ int busno)
{
struct thermostat* th;
int rc;
if (thermostat)
return 0;
- th = (struct thermostat *)kmalloc(sizeof(struct thermostat), GFP_KERNEL);
+
+ th = (struct thermostat *)
+ kmalloc(sizeof(struct thermostat), GFP_KERNEL);
+
if (!th)
return -ENOMEM;
+
memset(th, 0, sizeof(*th));
th->clt.addr = addr;
th->clt.adapter = adapter;
th->clt.driver = &thermostat_driver;
- th->clt.id = 0xDEAD7467;
strcpy(th->clt.name, "thermostat");
rc = read_reg(th, 0);
if (rc < 0) {
- printk(KERN_ERR "adt746x: Thermostat failed to read config from bus %d !\n",
- busno);
+ printk(KERN_ERR "adt746x: Thermostat failed to read config "
+ "from bus %d !\n",
+ busno);
kfree(th);
return -ENODEV;
}
+
/* force manual control to start the fan quieter */
-
if (fan_speed == -1)
- fan_speed=128;
+ fan_speed = 64;
if(therm_type == ADT7460) {
printk(KERN_INFO "adt746x: ADT7460 initializing\n");
th->initial_limits[i] = read_reg(th, LIMIT_REG[i]);
set_limit(th, i);
}
-
+
printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
- " to %d, %d, %d (°C)\n",
- th->initial_limits[0], th->initial_limits[1], th->initial_limits[2],
- th->limits[0], th->limits[1], th->limits[2]);
+ " to %d, %d, %d\n",
+ th->initial_limits[0], th->initial_limits[1],
+ th->initial_limits[2], th->limits[0], th->limits[1],
+ th->limits[2]);
thermostat = th;
if (i2c_attach_client(&th->clt)) {
- printk("adt746x: Thermostat failed to attach client !\n");
+ printk(KERN_INFO "adt746x: Thermostat failed to attach "
+ "client !\n");
thermostat = NULL;
kfree(th);
return -ENODEV;
/* be sure to really write fan speed the first time */
th->last_speed[0] = -2;
th->last_speed[1] = -2;
-
+ th->last_var[0] = -80;
+ th->last_var[1] = -80;
+
if (fan_speed != -1) {
+ /* manual mode, stop fans */
write_both_fan_speed(th, 0);
} else {
+ /* automatic mode */
write_both_fan_speed(th, -1);
}
- init_completion(&monitor_task_compl);
-
- monitor_thread_id = kernel_thread(monitor_task, th,
- SIGCHLD | CLONE_KERNEL);
+ thread_therm = kthread_run(monitor_task, th, "kfand");
+
+ if (thread_therm == ERR_PTR(-ENOMEM)) {
+ printk(KERN_INFO "adt746x: Kthread creation failed\n");
+ thread_therm = NULL;
+ return -ENOMEM;
+ }
return 0;
}
* pass around to the attribute functions, so we don't really have
* choice but implement a bunch of them...
*
+ * FIXME, it does now...
*/
-#define BUILD_SHOW_FUNC_DEG(name, data) \
-static ssize_t show_##name(struct device *dev, char *buf) \
-{ \
- return sprintf(buf, "%d°C\n", data); \
-}
#define BUILD_SHOW_FUNC_INT(name, data) \
-static ssize_t show_##name(struct device *dev, char *buf) \
+static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
return sprintf(buf, "%d\n", data); \
}
+#define BUILD_SHOW_FUNC_STR(name, data) \
+static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
+{ \
+ return sprintf(buf, "%s\n", data); \
+}
+
+#define BUILD_SHOW_FUNC_FAN(name, data) \
+static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
+{ \
+ return sprintf(buf, "%d (%d rpm)\n", \
+ thermostat->last_speed[data], \
+ read_fan_speed(thermostat, FAN_SPEED[data]) \
+ ); \
+}
+
#define BUILD_STORE_FUNC_DEG(name, data) \
-static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
+static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
{ \
int val; \
int i; \
val = simple_strtol(buf, NULL, 10); \
- printk(KERN_INFO "Adjusting limits by %d°C\n", val); \
+ printk(KERN_INFO "Adjusting limits by %d degrees\n", val); \
limit_adjust = val; \
for (i=0; i < 3; i++) \
set_limit(thermostat, i); \
}
#define BUILD_STORE_FUNC_INT(name, data) \
-static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
+static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
{ \
u32 val; \
val = simple_strtoul(buf, NULL, 10); \
if (val < 0 || val > 255) \
return -EINVAL; \
- printk(KERN_INFO "Setting fan speed to %d\n", val); \
+ printk(KERN_INFO "Setting specified fan speed to %d\n", val); \
data = val; \
return n; \
}
-BUILD_SHOW_FUNC_DEG(cpu_temperature, (read_reg(thermostat, TEMP_REG[1])))
-BUILD_SHOW_FUNC_DEG(gpu_temperature, (read_reg(thermostat, TEMP_REG[2])))
-BUILD_SHOW_FUNC_DEG(cpu_limit, thermostat->limits[1])
-BUILD_SHOW_FUNC_DEG(gpu_limit, thermostat->limits[2])
+BUILD_SHOW_FUNC_INT(sensor1_temperature, (read_reg(thermostat, TEMP_REG[1])))
+BUILD_SHOW_FUNC_INT(sensor2_temperature, (read_reg(thermostat, TEMP_REG[2])))
+BUILD_SHOW_FUNC_INT(sensor1_limit, thermostat->limits[1])
+BUILD_SHOW_FUNC_INT(sensor2_limit, thermostat->limits[2])
+BUILD_SHOW_FUNC_STR(sensor1_location, sensor_location[1])
+BUILD_SHOW_FUNC_STR(sensor2_location, sensor_location[2])
BUILD_SHOW_FUNC_INT(specified_fan_speed, fan_speed)
-BUILD_SHOW_FUNC_INT(cpu_fan_speed, (read_fan_speed(thermostat, FAN_SPEED[0])))
-BUILD_SHOW_FUNC_INT(gpu_fan_speed, (read_fan_speed(thermostat, FAN_SPEED[1])))
+BUILD_SHOW_FUNC_FAN(sensor1_fan_speed, 0)
+BUILD_SHOW_FUNC_FAN(sensor2_fan_speed, 1)
BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed)
BUILD_SHOW_FUNC_INT(limit_adjust, limit_adjust)
BUILD_STORE_FUNC_DEG(limit_adjust, thermostat)
-static DEVICE_ATTR(cpu_temperature, S_IRUGO,
- show_cpu_temperature,NULL);
-static DEVICE_ATTR(gpu_temperature, S_IRUGO,
- show_gpu_temperature,NULL);
-static DEVICE_ATTR(cpu_limit, S_IRUGO,
- show_cpu_limit, NULL);
-static DEVICE_ATTR(gpu_limit, S_IRUGO,
- show_gpu_limit, NULL);
+static DEVICE_ATTR(sensor1_temperature, S_IRUGO,
+ show_sensor1_temperature,NULL);
+static DEVICE_ATTR(sensor2_temperature, S_IRUGO,
+ show_sensor2_temperature,NULL);
+static DEVICE_ATTR(sensor1_limit, S_IRUGO,
+ show_sensor1_limit, NULL);
+static DEVICE_ATTR(sensor2_limit, S_IRUGO,
+ show_sensor2_limit, NULL);
+static DEVICE_ATTR(sensor1_location, S_IRUGO,
+ show_sensor1_location, NULL);
+static DEVICE_ATTR(sensor2_location, S_IRUGO,
+ show_sensor2_location, NULL);
static DEVICE_ATTR(specified_fan_speed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
show_specified_fan_speed,store_specified_fan_speed);
-static DEVICE_ATTR(cpu_fan_speed, S_IRUGO,
- show_cpu_fan_speed, NULL);
-static DEVICE_ATTR(gpu_fan_speed, S_IRUGO,
- show_gpu_fan_speed, NULL);
+static DEVICE_ATTR(sensor1_fan_speed, S_IRUGO,
+ show_sensor1_fan_speed, NULL);
+static DEVICE_ATTR(sensor2_fan_speed, S_IRUGO,
+ show_sensor2_fan_speed, NULL);
static DEVICE_ATTR(limit_adjust, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
show_limit_adjust, store_limit_adjust);
{
struct device_node* np;
u32 *prop;
+ int i = 0, offset = 0;
np = of_find_node_by_name(NULL, "fan");
if (!np)
else
return -ENODEV;
+ prop = (u32 *)get_property(np, "hwsensor-params-version", NULL);
+ printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
+ (*prop == 1)?"":"un");
+ if (*prop != 1)
+ return -ENODEV;
+
prop = (u32 *)get_property(np, "reg", NULL);
if (!prop)
return -ENODEV;
- therm_bus = ((*prop) >> 8) & 0x0f;
+
+ /* look for bus either by path or using "reg" */
+ if (strstr(np->full_name, "/i2c-bus@") != NULL) {
+ const char *tmp_bus = (strstr(np->full_name, "/i2c-bus@") + 9);
+ therm_bus = tmp_bus[0]-'0';
+ } else {
+ therm_bus = ((*prop) >> 8) & 0x0f;
+ }
+
therm_address = ((*prop) & 0xff) >> 1;
- printk(KERN_INFO "adt746x: Thermostat bus: %d, address: 0x%02x, limit_adjust: %d, fan_speed: %d\n",
- therm_bus, therm_address, limit_adjust, fan_speed);
+ printk(KERN_INFO "adt746x: Thermostat bus: %d, address: 0x%02x, "
+ "limit_adjust: %d, fan_speed: %d\n",
+ therm_bus, therm_address, limit_adjust, fan_speed);
+
+ if (get_property(np, "hwsensor-location", NULL)) {
+ for (i = 0; i < 3; i++) {
+ sensor_location[i] = get_property(np,
+ "hwsensor-location", NULL) + offset;
+
+ if (sensor_location[i] == NULL)
+ sensor_location[i] = "";
+
+ printk(KERN_INFO "sensor %d: %s\n", i, sensor_location[i]);
+ offset += strlen(sensor_location[i]) + 1;
+ }
+ } else {
+ sensor_location[0] = "?";
+ sensor_location[1] = "?";
+ sensor_location[2] = "?";
+ }
- of_dev = of_platform_device_create(np, "temperatures");
+ of_dev = of_platform_device_create(np, "temperatures", NULL);
if (of_dev == NULL) {
printk(KERN_ERR "Can't register temperatures device !\n");
return -ENODEV;
}
- device_create_file(&of_dev->dev, &dev_attr_cpu_temperature);
- device_create_file(&of_dev->dev, &dev_attr_gpu_temperature);
- device_create_file(&of_dev->dev, &dev_attr_cpu_limit);
- device_create_file(&of_dev->dev, &dev_attr_gpu_limit);
+ device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature);
+ device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature);
+ device_create_file(&of_dev->dev, &dev_attr_sensor1_limit);
+ device_create_file(&of_dev->dev, &dev_attr_sensor2_limit);
+ device_create_file(&of_dev->dev, &dev_attr_sensor1_location);
+ device_create_file(&of_dev->dev, &dev_attr_sensor2_location);
device_create_file(&of_dev->dev, &dev_attr_limit_adjust);
device_create_file(&of_dev->dev, &dev_attr_specified_fan_speed);
- device_create_file(&of_dev->dev, &dev_attr_cpu_fan_speed);
+ device_create_file(&of_dev->dev, &dev_attr_sensor1_fan_speed);
if(therm_type == ADT7460)
- device_create_file(&of_dev->dev, &dev_attr_gpu_fan_speed);
+ device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed);
-#ifndef CONFIG_I2C_KEYWEST
- request_module("i2c-keywest");
+#ifndef CONFIG_I2C_POWERMAC
+ request_module("i2c-powermac");
#endif
return i2c_add_driver(&thermostat_driver);
thermostat_exit(void)
{
if (of_dev) {
- device_remove_file(&of_dev->dev, &dev_attr_cpu_temperature);
- device_remove_file(&of_dev->dev, &dev_attr_gpu_temperature);
- device_remove_file(&of_dev->dev, &dev_attr_cpu_limit);
- device_remove_file(&of_dev->dev, &dev_attr_gpu_limit);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor1_temperature);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor2_temperature);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor1_limit);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor2_limit);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor1_location);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor2_location);
device_remove_file(&of_dev->dev, &dev_attr_limit_adjust);
device_remove_file(&of_dev->dev, &dev_attr_specified_fan_speed);
- device_remove_file(&of_dev->dev, &dev_attr_cpu_fan_speed);
+ device_remove_file(&of_dev->dev, &dev_attr_sensor1_fan_speed);
+
if(therm_type == ADT7460)
- device_remove_file(&of_dev->dev, &dev_attr_gpu_fan_speed);
+ device_remove_file(&of_dev->dev,
+ &dev_attr_sensor2_fan_speed);
+
of_device_unregister(of_dev);
}
i2c_del_driver(&thermostat_driver);