Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $) |
| 3 | * |
| 4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
| 5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
| 6 | * |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or (at |
| 12 | * your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 22 | * |
| 23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 24 | * |
| 25 | * This driver fully implements the ACPI thermal policy as described in the |
| 26 | * ACPI 2.0 Specification. |
| 27 | * |
| 28 | * TBD: 1. Implement passive cooling hysteresis. |
| 29 | * 2. Enhance passive cooling (CPU) states/limit interface to support |
| 30 | * concepts of 'multiple limiters', upper/lower limits, etc. |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <linux/kernel.h> |
| 35 | #include <linux/module.h> |
| 36 | #include <linux/init.h> |
| 37 | #include <linux/types.h> |
| 38 | #include <linux/proc_fs.h> |
| 39 | #include <linux/sched.h> |
| 40 | #include <linux/kmod.h> |
| 41 | #include <linux/seq_file.h> |
| 42 | #include <asm/uaccess.h> |
| 43 | |
| 44 | #include <acpi/acpi_bus.h> |
| 45 | #include <acpi/acpi_drivers.h> |
| 46 | |
| 47 | #define ACPI_THERMAL_COMPONENT 0x04000000 |
| 48 | #define ACPI_THERMAL_CLASS "thermal_zone" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" |
| 50 | #define ACPI_THERMAL_FILE_STATE "state" |
| 51 | #define ACPI_THERMAL_FILE_TEMPERATURE "temperature" |
| 52 | #define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points" |
| 53 | #define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode" |
| 54 | #define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency" |
| 55 | #define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 |
| 56 | #define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 |
| 57 | #define ACPI_THERMAL_NOTIFY_DEVICES 0x82 |
| 58 | #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 |
| 59 | #define ACPI_THERMAL_NOTIFY_HOT 0xF1 |
| 60 | #define ACPI_THERMAL_MODE_ACTIVE 0x00 |
| 61 | #define ACPI_THERMAL_MODE_PASSIVE 0x01 |
| 62 | #define ACPI_THERMAL_MODE_CRITICAL 0xff |
| 63 | #define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" |
| 64 | |
| 65 | #define ACPI_THERMAL_MAX_ACTIVE 10 |
| 66 | #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65 |
| 67 | |
| 68 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10) |
| 69 | #define CELSIUS_TO_KELVIN(t) ((t+273)*10) |
| 70 | |
| 71 | #define _COMPONENT ACPI_THERMAL_COMPONENT |
Len Brown | f52fd66 | 2007-02-12 22:42:12 -0500 | [diff] [blame] | 72 | ACPI_MODULE_NAME("thermal"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 74 | MODULE_AUTHOR("Paul Diefenbaugh"); |
Len Brown | 7cda93e | 2007-02-12 23:50:02 -0500 | [diff] [blame^] | 75 | MODULE_DESCRIPTION("ACPI Thermal Zone Driver"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | MODULE_LICENSE("GPL"); |
| 77 | |
| 78 | static int tzp; |
| 79 | module_param(tzp, int, 0); |
| 80 | MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n"); |
| 81 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | static int acpi_thermal_add(struct acpi_device *device); |
| 83 | static int acpi_thermal_remove(struct acpi_device *device, int type); |
Patrick Mochel | 5d9464a | 2006-12-07 20:56:27 +0800 | [diff] [blame] | 84 | static int acpi_thermal_resume(struct acpi_device *device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); |
| 86 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); |
| 87 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | static ssize_t acpi_thermal_write_trip_points(struct file *, |
| 89 | const char __user *, size_t, |
| 90 | loff_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | static ssize_t acpi_thermal_write_cooling_mode(struct file *, |
| 93 | const char __user *, size_t, |
| 94 | loff_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 96 | static ssize_t acpi_thermal_write_polling(struct file *, const char __user *, |
| 97 | size_t, loff_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
| 99 | static struct acpi_driver acpi_thermal_driver = { |
Len Brown | c2b6705 | 2007-02-12 23:33:40 -0500 | [diff] [blame] | 100 | .name = "thermal", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 101 | .class = ACPI_THERMAL_CLASS, |
| 102 | .ids = ACPI_THERMAL_HID, |
| 103 | .ops = { |
| 104 | .add = acpi_thermal_add, |
| 105 | .remove = acpi_thermal_remove, |
Konstantin Karasyov | 74ce1468 | 2006-05-08 08:32:00 -0400 | [diff] [blame] | 106 | .resume = acpi_thermal_resume, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 107 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | struct acpi_thermal_state { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 111 | u8 critical:1; |
| 112 | u8 hot:1; |
| 113 | u8 passive:1; |
| 114 | u8 active:1; |
| 115 | u8 reserved:4; |
| 116 | int active_index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | struct acpi_thermal_state_flags { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 120 | u8 valid:1; |
| 121 | u8 enabled:1; |
| 122 | u8 reserved:6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | struct acpi_thermal_critical { |
| 126 | struct acpi_thermal_state_flags flags; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 127 | unsigned long temperature; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | struct acpi_thermal_hot { |
| 131 | struct acpi_thermal_state_flags flags; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 132 | unsigned long temperature; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | struct acpi_thermal_passive { |
| 136 | struct acpi_thermal_state_flags flags; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | unsigned long temperature; |
| 138 | unsigned long tc1; |
| 139 | unsigned long tc2; |
| 140 | unsigned long tsp; |
| 141 | struct acpi_handle_list devices; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | struct acpi_thermal_active { |
| 145 | struct acpi_thermal_state_flags flags; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 146 | unsigned long temperature; |
| 147 | struct acpi_handle_list devices; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | struct acpi_thermal_trips { |
| 151 | struct acpi_thermal_critical critical; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | struct acpi_thermal_hot hot; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | struct acpi_thermal_passive passive; |
| 154 | struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE]; |
| 155 | }; |
| 156 | |
| 157 | struct acpi_thermal_flags { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | u8 cooling_mode:1; /* _SCP */ |
| 159 | u8 devices:1; /* _TZD */ |
| 160 | u8 reserved:6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | struct acpi_thermal { |
Patrick Mochel | 8348e1b | 2006-05-19 16:54:40 -0400 | [diff] [blame] | 164 | struct acpi_device * device; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | acpi_bus_id name; |
| 166 | unsigned long temperature; |
| 167 | unsigned long last_temperature; |
| 168 | unsigned long polling_frequency; |
| 169 | u8 cooling_mode; |
| 170 | volatile u8 zombie; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | struct acpi_thermal_flags flags; |
| 172 | struct acpi_thermal_state state; |
| 173 | struct acpi_thermal_trips trips; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 174 | struct acpi_handle_list devices; |
| 175 | struct timer_list timer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 178 | static const struct file_operations acpi_thermal_state_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 179 | .open = acpi_thermal_state_open_fs, |
| 180 | .read = seq_read, |
| 181 | .llseek = seq_lseek, |
| 182 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 185 | static const struct file_operations acpi_thermal_temp_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 186 | .open = acpi_thermal_temp_open_fs, |
| 187 | .read = seq_read, |
| 188 | .llseek = seq_lseek, |
| 189 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | }; |
| 191 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 192 | static const struct file_operations acpi_thermal_trip_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | .open = acpi_thermal_trip_open_fs, |
| 194 | .read = seq_read, |
| 195 | .write = acpi_thermal_write_trip_points, |
| 196 | .llseek = seq_lseek, |
| 197 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | }; |
| 199 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 200 | static const struct file_operations acpi_thermal_cooling_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 201 | .open = acpi_thermal_cooling_open_fs, |
| 202 | .read = seq_read, |
| 203 | .write = acpi_thermal_write_cooling_mode, |
| 204 | .llseek = seq_lseek, |
| 205 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | }; |
| 207 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 208 | static const struct file_operations acpi_thermal_polling_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 209 | .open = acpi_thermal_polling_open_fs, |
| 210 | .read = seq_read, |
| 211 | .write = acpi_thermal_write_polling, |
| 212 | .llseek = seq_lseek, |
| 213 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | }; |
| 215 | |
| 216 | /* -------------------------------------------------------------------------- |
| 217 | Thermal Zone Management |
| 218 | -------------------------------------------------------------------------- */ |
| 219 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 220 | static int acpi_thermal_get_temperature(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 222 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 226 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | tz->last_temperature = tz->temperature; |
| 229 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 230 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 231 | acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tz->temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | if (ACPI_FAILURE(status)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 233 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", |
| 236 | tz->temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 238 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 241 | static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
| 246 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 247 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 249 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 250 | acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 251 | &tz->polling_frequency); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | if (ACPI_FAILURE(status)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 253 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", |
| 256 | tz->polling_frequency)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 258 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 261 | static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
| 264 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 265 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | |
| 267 | tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ |
| 268 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 269 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 270 | "Polling frequency set to %lu seconds\n", |
| 271 | tz->polling_frequency)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 273 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 276 | static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 278 | acpi_status status = AE_OK; |
| 279 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
| 280 | struct acpi_object_list arg_list = { 1, &arg0 }; |
| 281 | acpi_handle handle = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
| 284 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 285 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 287 | status = acpi_get_handle(tz->device->handle, "_SCP", &handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | if (ACPI_FAILURE(status)) { |
| 289 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 290 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | arg0.integer.value = mode; |
| 294 | |
| 295 | status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); |
| 296 | if (ACPI_FAILURE(status)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 297 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | |
| 299 | tz->cooling_mode = mode; |
| 300 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 301 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", |
| 302 | mode ? "passive" : "active")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 304 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 309 | acpi_status status = AE_OK; |
| 310 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
| 313 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 314 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | /* Critical Shutdown (required) */ |
| 317 | |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 318 | status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 319 | &tz->trips.critical.temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | if (ACPI_FAILURE(status)) { |
| 321 | tz->trips.critical.flags.valid = 0; |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 322 | ACPI_EXCEPTION((AE_INFO, status, "No critical threshold")); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 323 | return -ENODEV; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 324 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | tz->trips.critical.flags.valid = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 326 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 327 | "Found critical threshold [%lu]\n", |
| 328 | tz->trips.critical.temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | /* Critical Sleep (optional) */ |
| 332 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 334 | acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 335 | &tz->trips.hot.temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | if (ACPI_FAILURE(status)) { |
| 337 | tz->trips.hot.flags.valid = 0; |
| 338 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 339 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | tz->trips.hot.flags.valid = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 341 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", |
| 342 | tz->trips.hot.temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /* Passive: Processors (optional) */ |
| 346 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 347 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 348 | acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 349 | &tz->trips.passive.temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | if (ACPI_FAILURE(status)) { |
| 351 | tz->trips.passive.flags.valid = 0; |
| 352 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | tz->trips.passive.flags.valid = 1; |
| 355 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 356 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 357 | acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 358 | &tz->trips.passive.tc1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | if (ACPI_FAILURE(status)) |
| 360 | tz->trips.passive.flags.valid = 0; |
| 361 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 362 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 363 | acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 364 | &tz->trips.passive.tc2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | if (ACPI_FAILURE(status)) |
| 366 | tz->trips.passive.flags.valid = 0; |
| 367 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 369 | acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 370 | &tz->trips.passive.tsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | if (ACPI_FAILURE(status)) |
| 372 | tz->trips.passive.flags.valid = 0; |
| 373 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 374 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 375 | acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 376 | &tz->trips.passive.devices); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | if (ACPI_FAILURE(status)) |
| 378 | tz->trips.passive.flags.valid = 0; |
| 379 | |
| 380 | if (!tz->trips.passive.flags.valid) |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 381 | printk(KERN_WARNING PREFIX "Invalid passive threshold\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | else |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 383 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 384 | "Found passive threshold [%lu]\n", |
| 385 | tz->trips.passive.temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /* Active: Fans, etc. (optional) */ |
| 389 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 392 | char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 394 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 395 | acpi_evaluate_integer(tz->device->handle, name, NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 396 | &tz->trips.active[i].temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | if (ACPI_FAILURE(status)) |
| 398 | break; |
| 399 | |
| 400 | name[2] = 'L'; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 401 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 402 | acpi_evaluate_reference(tz->device->handle, name, NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 403 | &tz->trips.active[i].devices); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | if (ACPI_SUCCESS(status)) { |
| 405 | tz->trips.active[i].flags.valid = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 406 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 407 | "Found active threshold [%d]:[%lu]\n", |
| 408 | i, tz->trips.active[i].temperature)); |
| 409 | } else |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 410 | ACPI_EXCEPTION((AE_INFO, status, |
| 411 | "Invalid active threshold [%d]", i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 414 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | static int acpi_thermal_get_devices(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 419 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
| 422 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 423 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | status = |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 426 | acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &tz->devices); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | if (ACPI_FAILURE(status)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 428 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 430 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | } |
| 432 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | static int acpi_thermal_call_usermode(char *path) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 435 | char *argv[2] = { NULL, NULL }; |
| 436 | char *envp[3] = { NULL, NULL, NULL }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
| 439 | if (!path) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 440 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
| 442 | argv[0] = path; |
| 443 | |
| 444 | /* minimal command environment */ |
| 445 | envp[0] = "HOME=/"; |
| 446 | envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | call_usermodehelper(argv[0], argv, envp, 0); |
| 449 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 450 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | } |
| 452 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 453 | static int acpi_thermal_critical(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | if (!tz || !tz->trips.critical.flags.valid) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 456 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
| 458 | if (tz->temperature >= tz->trips.critical.temperature) { |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 459 | printk(KERN_WARNING PREFIX "Critical trip point\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | tz->trips.critical.flags.enabled = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 461 | } else if (tz->trips.critical.flags.enabled) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | tz->trips.critical.flags.enabled = 0; |
| 463 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 464 | printk(KERN_EMERG |
| 465 | "Critical temperature reached (%ld C), shutting down.\n", |
| 466 | KELVIN_TO_CELSIUS(tz->temperature)); |
Patrick Mochel | 8348e1b | 2006-05-19 16:54:40 -0400 | [diff] [blame] | 467 | acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 468 | tz->trips.critical.flags.enabled); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
| 470 | acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); |
| 471 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 472 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 475 | static int acpi_thermal_hot(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | if (!tz || !tz->trips.hot.flags.valid) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 478 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | |
| 480 | if (tz->temperature >= tz->trips.hot.temperature) { |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 481 | printk(KERN_WARNING PREFIX "Hot trip point\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | tz->trips.hot.flags.enabled = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 483 | } else if (tz->trips.hot.flags.enabled) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | tz->trips.hot.flags.enabled = 0; |
| 485 | |
Patrick Mochel | 8348e1b | 2006-05-19 16:54:40 -0400 | [diff] [blame] | 486 | acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 487 | tz->trips.hot.flags.enabled); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
| 489 | /* TBD: Call user-mode "sleep(S4)" function */ |
| 490 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 491 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 494 | static void acpi_thermal_passive(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | { |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 496 | int result = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | struct acpi_thermal_passive *passive = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 498 | int trend = 0; |
| 499 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
| 502 | if (!tz || !tz->trips.passive.flags.valid) |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 503 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
| 505 | passive = &(tz->trips.passive); |
| 506 | |
| 507 | /* |
| 508 | * Above Trip? |
| 509 | * ----------- |
| 510 | * Calculate the thermal trend (using the passive cooling equation) |
| 511 | * and modify the performance limit for all passive cooling devices |
| 512 | * accordingly. Note that we assume symmetry. |
| 513 | */ |
| 514 | if (tz->temperature >= passive->temperature) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 515 | trend = |
| 516 | (passive->tc1 * (tz->temperature - tz->last_temperature)) + |
| 517 | (passive->tc2 * (tz->temperature - passive->temperature)); |
| 518 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 519 | "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", |
| 520 | trend, passive->tc1, tz->temperature, |
| 521 | tz->last_temperature, passive->tc2, |
| 522 | tz->temperature, passive->temperature)); |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 523 | passive->flags.enabled = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | /* Heating up? */ |
| 525 | if (trend > 0) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 526 | for (i = 0; i < passive->devices.count; i++) |
| 527 | acpi_processor_set_thermal_limit(passive-> |
| 528 | devices. |
| 529 | handles[i], |
| 530 | ACPI_PROCESSOR_LIMIT_INCREMENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | /* Cooling off? */ |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 532 | else if (trend < 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 533 | for (i = 0; i < passive->devices.count; i++) |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 534 | /* |
| 535 | * assume that we are on highest |
| 536 | * freq/lowest thrott and can leave |
| 537 | * passive mode, even in error case |
| 538 | */ |
| 539 | if (!acpi_processor_set_thermal_limit |
| 540 | (passive->devices.handles[i], |
| 541 | ACPI_PROCESSOR_LIMIT_DECREMENT)) |
| 542 | result = 0; |
| 543 | /* |
| 544 | * Leave cooling mode, even if the temp might |
| 545 | * higher than trip point This is because some |
| 546 | * machines might have long thermal polling |
| 547 | * frequencies (tsp) defined. We will fall back |
| 548 | * into passive mode in next cycle (probably quicker) |
| 549 | */ |
| 550 | if (result) { |
| 551 | passive->flags.enabled = 0; |
| 552 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 553 | "Disabling passive cooling, still above threshold," |
| 554 | " but we are cooling down\n")); |
| 555 | } |
| 556 | } |
| 557 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /* |
| 561 | * Below Trip? |
| 562 | * ----------- |
| 563 | * Implement passive cooling hysteresis to slowly increase performance |
| 564 | * and avoid thrashing around the passive trip point. Note that we |
| 565 | * assume symmetry. |
| 566 | */ |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 567 | if (!passive->flags.enabled) |
| 568 | return; |
| 569 | for (i = 0; i < passive->devices.count; i++) |
| 570 | if (!acpi_processor_set_thermal_limit |
| 571 | (passive->devices.handles[i], |
| 572 | ACPI_PROCESSOR_LIMIT_DECREMENT)) |
| 573 | result = 0; |
| 574 | if (result) { |
| 575 | passive->flags.enabled = 0; |
| 576 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 577 | "Disabling passive cooling (zone is cool)\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 581 | static void acpi_thermal_active(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 583 | int result = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | struct acpi_thermal_active *active = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 585 | int i = 0; |
| 586 | int j = 0; |
| 587 | unsigned long maxtemp = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | |
| 590 | if (!tz) |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 591 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 593 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | active = &(tz->trips.active[i]); |
| 595 | if (!active || !active->flags.valid) |
| 596 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | if (tz->temperature >= active->temperature) { |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 598 | /* |
| 599 | * Above Threshold? |
| 600 | * ---------------- |
| 601 | * If not already enabled, turn ON all cooling devices |
| 602 | * associated with this active threshold. |
| 603 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | if (active->temperature > maxtemp) |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 605 | tz->state.active_index = i; |
| 606 | maxtemp = active->temperature; |
| 607 | if (active->flags.enabled) |
| 608 | continue; |
| 609 | for (j = 0; j < active->devices.count; j++) { |
| 610 | result = |
| 611 | acpi_bus_set_power(active->devices. |
| 612 | handles[j], |
| 613 | ACPI_STATE_D0); |
| 614 | if (result) { |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 615 | printk(KERN_WARNING PREFIX |
| 616 | "Unable to turn cooling device [%p] 'on'\n", |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 617 | active->devices. |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 618 | handles[j]); |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 619 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | } |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 621 | active->flags.enabled = 1; |
| 622 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 623 | "Cooling device [%p] now 'on'\n", |
| 624 | active->devices.handles[j])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | } |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 626 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | } |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 628 | if (!active->flags.enabled) |
| 629 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | /* |
| 631 | * Below Threshold? |
| 632 | * ---------------- |
| 633 | * Turn OFF all cooling devices associated with this |
| 634 | * threshold. |
| 635 | */ |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 636 | for (j = 0; j < active->devices.count; j++) { |
| 637 | result = acpi_bus_set_power(active->devices.handles[j], |
| 638 | ACPI_STATE_D3); |
| 639 | if (result) { |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 640 | printk(KERN_WARNING PREFIX |
| 641 | "Unable to turn cooling device [%p] 'off'\n", |
| 642 | active->devices.handles[j]); |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 643 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | } |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 645 | active->flags.enabled = 0; |
| 646 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 647 | "Cooling device [%p] now 'off'\n", |
| 648 | active->devices.handles[j])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | } |
| 650 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | } |
| 652 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 653 | static void acpi_thermal_check(void *context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 655 | static void acpi_thermal_run(unsigned long data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | { |
| 657 | struct acpi_thermal *tz = (struct acpi_thermal *)data; |
| 658 | if (!tz->zombie) |
Alexey Starikovskiy | b8d3519 | 2006-05-05 03:23:00 -0400 | [diff] [blame] | 659 | acpi_os_execute(OSL_GPE_HANDLER, acpi_thermal_check, (void *)data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 662 | static void acpi_thermal_check(void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 664 | int result = 0; |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 665 | struct acpi_thermal *tz = data; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 666 | unsigned long sleep_time = 0; |
| 667 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | struct acpi_thermal_state state; |
| 669 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | |
| 671 | if (!tz) { |
Len Brown | 6468463 | 2006-06-26 23:41:38 -0400 | [diff] [blame] | 672 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 673 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | state = tz->state; |
| 677 | |
| 678 | result = acpi_thermal_get_temperature(tz); |
| 679 | if (result) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 680 | return; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 681 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | memset(&tz->state, 0, sizeof(tz->state)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 683 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | /* |
| 685 | * Check Trip Points |
| 686 | * ----------------- |
| 687 | * Compare the current temperature to the trip point values to see |
| 688 | * if we've entered one of the thermal policy states. Note that |
| 689 | * this function determines when a state is entered, but the |
| 690 | * individual policy decides when it is exited (e.g. hysteresis). |
| 691 | */ |
| 692 | if (tz->trips.critical.flags.valid) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 693 | state.critical |= |
| 694 | (tz->temperature >= tz->trips.critical.temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | if (tz->trips.hot.flags.valid) |
| 696 | state.hot |= (tz->temperature >= tz->trips.hot.temperature); |
| 697 | if (tz->trips.passive.flags.valid) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 698 | state.passive |= |
| 699 | (tz->temperature >= tz->trips.passive.temperature); |
| 700 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | if (tz->trips.active[i].flags.valid) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 702 | state.active |= |
| 703 | (tz->temperature >= |
| 704 | tz->trips.active[i].temperature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
| 706 | /* |
| 707 | * Invoke Policy |
| 708 | * ------------- |
| 709 | * Separated from the above check to allow individual policy to |
| 710 | * determine when to exit a given state. |
| 711 | */ |
| 712 | if (state.critical) |
| 713 | acpi_thermal_critical(tz); |
| 714 | if (state.hot) |
| 715 | acpi_thermal_hot(tz); |
| 716 | if (state.passive) |
| 717 | acpi_thermal_passive(tz); |
| 718 | if (state.active) |
| 719 | acpi_thermal_active(tz); |
| 720 | |
| 721 | /* |
| 722 | * Calculate State |
| 723 | * --------------- |
| 724 | * Again, separated from the above two to allow independent policy |
| 725 | * decisions. |
| 726 | */ |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 727 | tz->state.critical = tz->trips.critical.flags.enabled; |
| 728 | tz->state.hot = tz->trips.hot.flags.enabled; |
| 729 | tz->state.passive = tz->trips.passive.flags.enabled; |
| 730 | tz->state.active = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 731 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) |
Thomas Renninger | 1cbf4c5 | 2004-09-16 11:07:00 -0400 | [diff] [blame] | 732 | tz->state.active |= tz->trips.active[i].flags.enabled; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | |
| 734 | /* |
| 735 | * Calculate Sleep Time |
| 736 | * -------------------- |
| 737 | * If we're in the passive state, use _TSP's value. Otherwise |
| 738 | * use the default polling frequency (e.g. _TZP). If no polling |
| 739 | * frequency is specified then we'll wait forever (at least until |
| 740 | * a thermal event occurs). Note that _TSP and _TZD values are |
| 741 | * given in 1/10th seconds (we must covert to milliseconds). |
| 742 | */ |
| 743 | if (tz->state.passive) |
| 744 | sleep_time = tz->trips.passive.tsp * 100; |
| 745 | else if (tz->polling_frequency > 0) |
| 746 | sleep_time = tz->polling_frequency * 100; |
| 747 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 748 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", |
| 749 | tz->name, tz->temperature, sleep_time)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | |
| 751 | /* |
| 752 | * Schedule Next Poll |
| 753 | * ------------------ |
| 754 | */ |
| 755 | if (!sleep_time) { |
| 756 | if (timer_pending(&(tz->timer))) |
| 757 | del_timer(&(tz->timer)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 758 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | if (timer_pending(&(tz->timer))) |
| 760 | mod_timer(&(tz->timer), (HZ * sleep_time) / 1000); |
| 761 | else { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 762 | tz->timer.data = (unsigned long)tz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | tz->timer.function = acpi_thermal_run; |
| 764 | tz->timer.expires = jiffies + (HZ * sleep_time) / 1000; |
| 765 | add_timer(&(tz->timer)); |
| 766 | } |
| 767 | } |
| 768 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 769 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | } |
| 771 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | /* -------------------------------------------------------------------------- |
| 773 | FS Interface (/proc) |
| 774 | -------------------------------------------------------------------------- */ |
| 775 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 776 | static struct proc_dir_entry *acpi_thermal_dir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | |
| 778 | static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) |
| 779 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 780 | struct acpi_thermal *tz = seq->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | |
| 783 | if (!tz) |
| 784 | goto end; |
| 785 | |
| 786 | seq_puts(seq, "state: "); |
| 787 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 788 | if (!tz->state.critical && !tz->state.hot && !tz->state.passive |
| 789 | && !tz->state.active) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | seq_puts(seq, "ok\n"); |
| 791 | else { |
| 792 | if (tz->state.critical) |
| 793 | seq_puts(seq, "critical "); |
| 794 | if (tz->state.hot) |
| 795 | seq_puts(seq, "hot "); |
| 796 | if (tz->state.passive) |
| 797 | seq_puts(seq, "passive "); |
| 798 | if (tz->state.active) |
| 799 | seq_printf(seq, "active[%d]", tz->state.active_index); |
| 800 | seq_puts(seq, "\n"); |
| 801 | } |
| 802 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 803 | end: |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 804 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) |
| 808 | { |
| 809 | return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data); |
| 810 | } |
| 811 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) |
| 813 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 814 | int result = 0; |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 815 | struct acpi_thermal *tz = seq->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
| 818 | if (!tz) |
| 819 | goto end; |
| 820 | |
| 821 | result = acpi_thermal_get_temperature(tz); |
| 822 | if (result) |
| 823 | goto end; |
| 824 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 825 | seq_printf(seq, "temperature: %ld C\n", |
| 826 | KELVIN_TO_CELSIUS(tz->temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 828 | end: |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 829 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) |
| 833 | { |
| 834 | return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data); |
| 835 | } |
| 836 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) |
| 838 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 839 | struct acpi_thermal *tz = seq->private; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 840 | int i = 0; |
| 841 | int j = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
| 844 | if (!tz) |
| 845 | goto end; |
| 846 | |
| 847 | if (tz->trips.critical.flags.valid) |
| 848 | seq_printf(seq, "critical (S5): %ld C\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 849 | KELVIN_TO_CELSIUS(tz->trips.critical.temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | |
| 851 | if (tz->trips.hot.flags.valid) |
| 852 | seq_printf(seq, "hot (S4): %ld C\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 853 | KELVIN_TO_CELSIUS(tz->trips.hot.temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | |
| 855 | if (tz->trips.passive.flags.valid) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 856 | seq_printf(seq, |
| 857 | "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=", |
| 858 | KELVIN_TO_CELSIUS(tz->trips.passive.temperature), |
| 859 | tz->trips.passive.tc1, tz->trips.passive.tc2, |
| 860 | tz->trips.passive.tsp); |
| 861 | for (j = 0; j < tz->trips.passive.devices.count; j++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 863 | seq_printf(seq, "0x%p ", |
| 864 | tz->trips.passive.devices.handles[j]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | } |
| 866 | seq_puts(seq, "\n"); |
| 867 | } |
| 868 | |
| 869 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
| 870 | if (!(tz->trips.active[i].flags.valid)) |
| 871 | break; |
| 872 | seq_printf(seq, "active[%d]: %ld C: devices=", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 873 | i, |
| 874 | KELVIN_TO_CELSIUS(tz->trips.active[i].temperature)); |
| 875 | for (j = 0; j < tz->trips.active[i].devices.count; j++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | seq_printf(seq, "0x%p ", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 877 | tz->trips.active[i].devices.handles[j]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | seq_puts(seq, "\n"); |
| 879 | } |
| 880 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 881 | end: |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 882 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) |
| 886 | { |
| 887 | return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data); |
| 888 | } |
| 889 | |
| 890 | static ssize_t |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 891 | acpi_thermal_write_trip_points(struct file *file, |
| 892 | const char __user * buffer, |
| 893 | size_t count, loff_t * ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 895 | struct seq_file *m = file->private_data; |
| 896 | struct acpi_thermal *tz = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 898 | char *limit_string; |
| 899 | int num, critical, hot, passive; |
| 900 | int *active; |
| 901 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | |
Burman Yan | 36bcbec | 2006-12-19 12:56:11 -0800 | [diff] [blame] | 904 | limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 905 | if (!limit_string) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 906 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 908 | active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); |
Dave Jones | fdc136c | 2006-03-08 22:12:00 -0500 | [diff] [blame] | 909 | if (!active) { |
| 910 | kfree(limit_string); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 911 | return -ENOMEM; |
Dave Jones | fdc136c | 2006-03-08 22:12:00 -0500 | [diff] [blame] | 912 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | |
| 914 | if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | count = -EINVAL; |
| 916 | goto end; |
| 917 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 918 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | if (copy_from_user(limit_string, buffer, count)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | count = -EFAULT; |
| 921 | goto end; |
| 922 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 923 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | limit_string[count] = '\0'; |
| 925 | |
| 926 | num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 927 | &critical, &hot, &passive, |
| 928 | &active[0], &active[1], &active[2], &active[3], &active[4], |
| 929 | &active[5], &active[6], &active[7], &active[8], |
| 930 | &active[9]); |
| 931 | if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | count = -EINVAL; |
| 933 | goto end; |
| 934 | } |
| 935 | |
| 936 | tz->trips.critical.temperature = CELSIUS_TO_KELVIN(critical); |
| 937 | tz->trips.hot.temperature = CELSIUS_TO_KELVIN(hot); |
| 938 | tz->trips.passive.temperature = CELSIUS_TO_KELVIN(passive); |
| 939 | for (i = 0; i < num - 3; i++) { |
| 940 | if (!(tz->trips.active[i].flags.valid)) |
| 941 | break; |
| 942 | tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]); |
| 943 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 944 | |
| 945 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | kfree(active); |
| 947 | kfree(limit_string); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 948 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) |
| 952 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 953 | struct acpi_thermal *tz = seq->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
| 956 | if (!tz) |
| 957 | goto end; |
| 958 | |
| 959 | if (!tz->flags.cooling_mode) { |
| 960 | seq_puts(seq, "<setting not supported>\n"); |
| 961 | } |
| 962 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 963 | if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | seq_printf(seq, "cooling mode: critical\n"); |
| 965 | else |
| 966 | seq_printf(seq, "cooling mode: %s\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 967 | tz->cooling_mode ? "passive" : "active"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 969 | end: |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 970 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) |
| 974 | { |
| 975 | return single_open(file, acpi_thermal_cooling_seq_show, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 976 | PDE(inode)->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | static ssize_t |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 980 | acpi_thermal_write_cooling_mode(struct file *file, |
| 981 | const char __user * buffer, |
| 982 | size_t count, loff_t * ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 984 | struct seq_file *m = file->private_data; |
| 985 | struct acpi_thermal *tz = m->private; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 986 | int result = 0; |
| 987 | char mode_string[12] = { '\0' }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | |
| 990 | if (!tz || (count > sizeof(mode_string) - 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 991 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | |
| 993 | if (!tz->flags.cooling_mode) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 994 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | |
| 996 | if (copy_from_user(mode_string, buffer, count)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 997 | return -EFAULT; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 998 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | mode_string[count] = '\0'; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1000 | |
| 1001 | result = acpi_thermal_set_cooling_mode(tz, |
| 1002 | simple_strtoul(mode_string, NULL, |
| 1003 | 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | if (result) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1005 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | |
| 1007 | acpi_thermal_check(tz); |
| 1008 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1009 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | } |
| 1011 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) |
| 1013 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1014 | struct acpi_thermal *tz = seq->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | |
| 1017 | if (!tz) |
| 1018 | goto end; |
| 1019 | |
| 1020 | if (!tz->polling_frequency) { |
| 1021 | seq_puts(seq, "<polling disabled>\n"); |
| 1022 | goto end; |
| 1023 | } |
| 1024 | |
| 1025 | seq_printf(seq, "polling frequency: %lu seconds\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1026 | (tz->polling_frequency / 10)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1028 | end: |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1029 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) |
| 1033 | { |
| 1034 | return single_open(file, acpi_thermal_polling_seq_show, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1035 | PDE(inode)->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | static ssize_t |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1039 | acpi_thermal_write_polling(struct file *file, |
| 1040 | const char __user * buffer, |
| 1041 | size_t count, loff_t * ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1043 | struct seq_file *m = file->private_data; |
| 1044 | struct acpi_thermal *tz = m->private; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1045 | int result = 0; |
| 1046 | char polling_string[12] = { '\0' }; |
| 1047 | int seconds = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | |
| 1050 | if (!tz || (count > sizeof(polling_string) - 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1051 | return -EINVAL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1052 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | if (copy_from_user(polling_string, buffer, count)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1054 | return -EFAULT; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1055 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | polling_string[count] = '\0'; |
| 1057 | |
| 1058 | seconds = simple_strtoul(polling_string, NULL, 0); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1059 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | result = acpi_thermal_set_polling(tz, seconds); |
| 1061 | if (result) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1062 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | |
| 1064 | acpi_thermal_check(tz); |
| 1065 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1066 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | } |
| 1068 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1069 | static int acpi_thermal_add_fs(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1071 | struct proc_dir_entry *entry = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
| 1074 | if (!acpi_device_dir(device)) { |
| 1075 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1076 | acpi_thermal_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | if (!acpi_device_dir(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1078 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | acpi_device_dir(device)->owner = THIS_MODULE; |
| 1080 | } |
| 1081 | |
| 1082 | /* 'state' [R] */ |
| 1083 | entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1084 | S_IRUGO, acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1086 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | else { |
| 1088 | entry->proc_fops = &acpi_thermal_state_fops; |
| 1089 | entry->data = acpi_driver_data(device); |
| 1090 | entry->owner = THIS_MODULE; |
| 1091 | } |
| 1092 | |
| 1093 | /* 'temperature' [R] */ |
| 1094 | entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1095 | S_IRUGO, acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1097 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | else { |
| 1099 | entry->proc_fops = &acpi_thermal_temp_fops; |
| 1100 | entry->data = acpi_driver_data(device); |
| 1101 | entry->owner = THIS_MODULE; |
| 1102 | } |
| 1103 | |
| 1104 | /* 'trip_points' [R/W] */ |
| 1105 | entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1106 | S_IFREG | S_IRUGO | S_IWUSR, |
| 1107 | acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1109 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | else { |
| 1111 | entry->proc_fops = &acpi_thermal_trip_fops; |
| 1112 | entry->data = acpi_driver_data(device); |
| 1113 | entry->owner = THIS_MODULE; |
| 1114 | } |
| 1115 | |
| 1116 | /* 'cooling_mode' [R/W] */ |
| 1117 | entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1118 | S_IFREG | S_IRUGO | S_IWUSR, |
| 1119 | acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1121 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | else { |
| 1123 | entry->proc_fops = &acpi_thermal_cooling_fops; |
| 1124 | entry->data = acpi_driver_data(device); |
| 1125 | entry->owner = THIS_MODULE; |
| 1126 | } |
| 1127 | |
| 1128 | /* 'polling_frequency' [R/W] */ |
| 1129 | entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1130 | S_IFREG | S_IRUGO | S_IWUSR, |
| 1131 | acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1133 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | else { |
| 1135 | entry->proc_fops = &acpi_thermal_polling_fops; |
| 1136 | entry->data = acpi_driver_data(device); |
| 1137 | entry->owner = THIS_MODULE; |
| 1138 | } |
| 1139 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1140 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1143 | static int acpi_thermal_remove_fs(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | |
| 1146 | if (acpi_device_dir(device)) { |
| 1147 | remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, |
| 1148 | acpi_device_dir(device)); |
| 1149 | remove_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, |
| 1150 | acpi_device_dir(device)); |
| 1151 | remove_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, |
| 1152 | acpi_device_dir(device)); |
| 1153 | remove_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, |
| 1154 | acpi_device_dir(device)); |
| 1155 | remove_proc_entry(ACPI_THERMAL_FILE_STATE, |
| 1156 | acpi_device_dir(device)); |
| 1157 | remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir); |
| 1158 | acpi_device_dir(device) = NULL; |
| 1159 | } |
| 1160 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1161 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | } |
| 1163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | /* -------------------------------------------------------------------------- |
| 1165 | Driver Interface |
| 1166 | -------------------------------------------------------------------------- */ |
| 1167 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1168 | static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1170 | struct acpi_thermal *tz = data; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1171 | struct acpi_device *device = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | |
| 1174 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1175 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | |
Patrick Mochel | 8348e1b | 2006-05-19 16:54:40 -0400 | [diff] [blame] | 1177 | device = tz->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | |
| 1179 | switch (event) { |
| 1180 | case ACPI_THERMAL_NOTIFY_TEMPERATURE: |
| 1181 | acpi_thermal_check(tz); |
| 1182 | break; |
| 1183 | case ACPI_THERMAL_NOTIFY_THRESHOLDS: |
| 1184 | acpi_thermal_get_trip_points(tz); |
| 1185 | acpi_thermal_check(tz); |
| 1186 | acpi_bus_generate_event(device, event, 0); |
| 1187 | break; |
| 1188 | case ACPI_THERMAL_NOTIFY_DEVICES: |
| 1189 | if (tz->flags.devices) |
| 1190 | acpi_thermal_get_devices(tz); |
| 1191 | acpi_bus_generate_event(device, event, 0); |
| 1192 | break; |
| 1193 | default: |
| 1194 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1195 | "Unsupported event [0x%x]\n", event)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | break; |
| 1197 | } |
| 1198 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1199 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1202 | static int acpi_thermal_get_info(struct acpi_thermal *tz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1204 | int result = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | |
| 1207 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1208 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | |
| 1210 | /* Get temperature [_TMP] (required) */ |
| 1211 | result = acpi_thermal_get_temperature(tz); |
| 1212 | if (result) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1213 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | |
| 1215 | /* Get trip points [_CRT, _PSV, etc.] (required) */ |
| 1216 | result = acpi_thermal_get_trip_points(tz); |
| 1217 | if (result) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1218 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | |
| 1220 | /* Set the cooling mode [_SCP] to active cooling (default) */ |
| 1221 | result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1222 | if (!result) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | tz->flags.cooling_mode = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1224 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | /* Oh,we have not _SCP method. |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1226 | Generally show cooling_mode by _ACx, _PSV,spec 12.2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | tz->flags.cooling_mode = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1228 | if (tz->trips.active[0].flags.valid |
| 1229 | && tz->trips.passive.flags.valid) { |
| 1230 | if (tz->trips.passive.temperature > |
| 1231 | tz->trips.active[0].temperature) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1233 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1234 | tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1235 | } else if (!tz->trips.active[0].flags.valid |
| 1236 | && tz->trips.passive.flags.valid) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1238 | } else if (tz->trips.active[0].flags.valid |
| 1239 | && !tz->trips.passive.flags.valid) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; |
| 1241 | } else { |
| 1242 | /* _ACx and _PSV are optional, but _CRT is required */ |
| 1243 | tz->cooling_mode = ACPI_THERMAL_MODE_CRITICAL; |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | /* Get default polling frequency [_TZP] (optional) */ |
| 1248 | if (tzp) |
| 1249 | tz->polling_frequency = tzp; |
| 1250 | else |
| 1251 | acpi_thermal_get_polling_frequency(tz); |
| 1252 | |
| 1253 | /* Get devices in this thermal zone [_TZD] (optional) */ |
| 1254 | result = acpi_thermal_get_devices(tz); |
| 1255 | if (!result) |
| 1256 | tz->flags.devices = 1; |
| 1257 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1258 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1261 | static int acpi_thermal_add(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1263 | int result = 0; |
| 1264 | acpi_status status = AE_OK; |
| 1265 | struct acpi_thermal *tz = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
| 1268 | if (!device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1269 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | |
Burman Yan | 36bcbec | 2006-12-19 12:56:11 -0800 | [diff] [blame] | 1271 | tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | if (!tz) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1273 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | |
Patrick Mochel | 8348e1b | 2006-05-19 16:54:40 -0400 | [diff] [blame] | 1275 | tz->device = device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | strcpy(tz->name, device->pnp.bus_id); |
| 1277 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); |
| 1278 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); |
| 1279 | acpi_driver_data(device) = tz; |
| 1280 | |
| 1281 | result = acpi_thermal_get_info(tz); |
| 1282 | if (result) |
| 1283 | goto end; |
| 1284 | |
| 1285 | result = acpi_thermal_add_fs(device); |
| 1286 | if (result) |
Vasily Averin | 09047e7 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 1287 | goto end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | |
| 1289 | init_timer(&tz->timer); |
| 1290 | |
| 1291 | acpi_thermal_check(tz); |
| 1292 | |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 1293 | status = acpi_install_notify_handler(device->handle, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1294 | ACPI_DEVICE_NOTIFY, |
| 1295 | acpi_thermal_notify, tz); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1296 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | result = -ENODEV; |
| 1298 | goto end; |
| 1299 | } |
| 1300 | |
| 1301 | printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1302 | acpi_device_name(device), acpi_device_bid(device), |
| 1303 | KELVIN_TO_CELSIUS(tz->temperature)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1304 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1305 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | if (result) { |
| 1307 | acpi_thermal_remove_fs(device); |
| 1308 | kfree(tz); |
| 1309 | } |
| 1310 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1311 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | } |
| 1313 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1314 | static int acpi_thermal_remove(struct acpi_device *device, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1316 | acpi_status status = AE_OK; |
| 1317 | struct acpi_thermal *tz = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | |
| 1320 | if (!device || !acpi_driver_data(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1321 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1323 | tz = acpi_driver_data(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | |
| 1325 | /* avoid timer adding new defer task */ |
| 1326 | tz->zombie = 1; |
| 1327 | /* wait for running timer (on other CPUs) finish */ |
| 1328 | del_timer_sync(&(tz->timer)); |
| 1329 | /* synchronize deferred task */ |
| 1330 | acpi_os_wait_events_complete(NULL); |
| 1331 | /* deferred task may reinsert timer */ |
| 1332 | del_timer_sync(&(tz->timer)); |
| 1333 | |
Patrick Mochel | 38ba7c9 | 2006-05-19 16:54:48 -0400 | [diff] [blame] | 1334 | status = acpi_remove_notify_handler(device->handle, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1335 | ACPI_DEVICE_NOTIFY, |
| 1336 | acpi_thermal_notify); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | |
| 1338 | /* Terminate policy */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1339 | if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | tz->trips.passive.flags.enabled = 0; |
| 1341 | acpi_thermal_passive(tz); |
| 1342 | } |
| 1343 | if (tz->trips.active[0].flags.valid |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1344 | && tz->trips.active[0].flags.enabled) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | tz->trips.active[0].flags.enabled = 0; |
| 1346 | acpi_thermal_active(tz); |
| 1347 | } |
| 1348 | |
| 1349 | acpi_thermal_remove_fs(device); |
| 1350 | |
| 1351 | kfree(tz); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1352 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | } |
| 1354 | |
Patrick Mochel | 5d9464a | 2006-12-07 20:56:27 +0800 | [diff] [blame] | 1355 | static int acpi_thermal_resume(struct acpi_device *device) |
Konstantin Karasyov | 74ce1468 | 2006-05-08 08:32:00 -0400 | [diff] [blame] | 1356 | { |
| 1357 | struct acpi_thermal *tz = NULL; |
Konstantin Karasyov | bed936f | 2006-07-10 04:44:26 -0700 | [diff] [blame] | 1358 | int i; |
Konstantin Karasyov | 74ce1468 | 2006-05-08 08:32:00 -0400 | [diff] [blame] | 1359 | |
| 1360 | if (!device || !acpi_driver_data(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1361 | return -EINVAL; |
Konstantin Karasyov | 74ce1468 | 2006-05-08 08:32:00 -0400 | [diff] [blame] | 1362 | |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1363 | tz = acpi_driver_data(device); |
Konstantin Karasyov | 74ce1468 | 2006-05-08 08:32:00 -0400 | [diff] [blame] | 1364 | |
Konstantin Karasyov | bed936f | 2006-07-10 04:44:26 -0700 | [diff] [blame] | 1365 | acpi_thermal_get_temperature(tz); |
| 1366 | |
| 1367 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
| 1368 | if (tz->trips.active[i].flags.valid) { |
| 1369 | tz->temperature = tz->trips.active[i].temperature; |
| 1370 | tz->trips.active[i].flags.enabled = 0; |
| 1371 | |
| 1372 | acpi_thermal_active(tz); |
| 1373 | |
| 1374 | tz->state.active |= tz->trips.active[i].flags.enabled; |
| 1375 | tz->state.active_index = i; |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | acpi_thermal_check(tz); |
Konstantin Karasyov | 74ce1468 | 2006-05-08 08:32:00 -0400 | [diff] [blame] | 1380 | |
| 1381 | return AE_OK; |
| 1382 | } |
| 1383 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1384 | static int __init acpi_thermal_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1386 | int result = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | |
| 1389 | acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); |
| 1390 | if (!acpi_thermal_dir) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1391 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | acpi_thermal_dir->owner = THIS_MODULE; |
| 1393 | |
| 1394 | result = acpi_bus_register_driver(&acpi_thermal_driver); |
| 1395 | if (result < 0) { |
| 1396 | remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1397 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1398 | } |
| 1399 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1400 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | } |
| 1402 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1403 | static void __exit acpi_thermal_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | |
| 1406 | acpi_bus_unregister_driver(&acpi_thermal_driver); |
| 1407 | |
| 1408 | remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); |
| 1409 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1410 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | } |
| 1412 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | module_init(acpi_thermal_init); |
| 1414 | module_exit(acpi_thermal_exit); |