Commit e994d713a73716b54085a092b267099e40aa5513
Committed by
Zhang Rui
1 parent
ece238fe0a
Exists in
master
and in
16 other branches
ACPI/thermal : Remove zone disabled warning
Once thermal zone is disabled to move thermal control to user space, too many warnings printed in logs. Remove pr_warn from this path, instead warn when user mode issues request to disable thermal zone. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Acked-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Showing 1 changed file with 5 additions and 5 deletions Inline Diff
drivers/acpi/thermal.c
1 | /* | 1 | /* |
2 | * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $) | 2 | * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $) |
3 | * | 3 | * |
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | 4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | 5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
6 | * | 6 | * |
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 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 | 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 | 11 | * the Free Software Foundation; either version 2 of the License, or (at |
12 | * your option) any later version. | 12 | * your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, but | 14 | * This program is distributed in the hope that it will be useful, but |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | * General Public License for more details. | 17 | * General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License along | 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., | 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | 21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
22 | * | 22 | * |
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
24 | * | 24 | * |
25 | * This driver fully implements the ACPI thermal policy as described in the | 25 | * This driver fully implements the ACPI thermal policy as described in the |
26 | * ACPI 2.0 Specification. | 26 | * ACPI 2.0 Specification. |
27 | * | 27 | * |
28 | * TBD: 1. Implement passive cooling hysteresis. | 28 | * TBD: 1. Implement passive cooling hysteresis. |
29 | * 2. Enhance passive cooling (CPU) states/limit interface to support | 29 | * 2. Enhance passive cooling (CPU) states/limit interface to support |
30 | * concepts of 'multiple limiters', upper/lower limits, etc. | 30 | * concepts of 'multiple limiters', upper/lower limits, etc. |
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/dmi.h> | 36 | #include <linux/dmi.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
40 | #include <linux/jiffies.h> | 40 | #include <linux/jiffies.h> |
41 | #include <linux/kmod.h> | 41 | #include <linux/kmod.h> |
42 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
45 | #include <linux/thermal.h> | 45 | #include <linux/thermal.h> |
46 | #include <acpi/acpi_bus.h> | 46 | #include <acpi/acpi_bus.h> |
47 | #include <acpi/acpi_drivers.h> | 47 | #include <acpi/acpi_drivers.h> |
48 | 48 | ||
49 | #define PREFIX "ACPI: " | 49 | #define PREFIX "ACPI: " |
50 | 50 | ||
51 | #define ACPI_THERMAL_CLASS "thermal_zone" | 51 | #define ACPI_THERMAL_CLASS "thermal_zone" |
52 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" | 52 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" |
53 | #define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 | 53 | #define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 |
54 | #define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 | 54 | #define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 |
55 | #define ACPI_THERMAL_NOTIFY_DEVICES 0x82 | 55 | #define ACPI_THERMAL_NOTIFY_DEVICES 0x82 |
56 | #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 | 56 | #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 |
57 | #define ACPI_THERMAL_NOTIFY_HOT 0xF1 | 57 | #define ACPI_THERMAL_NOTIFY_HOT 0xF1 |
58 | #define ACPI_THERMAL_MODE_ACTIVE 0x00 | 58 | #define ACPI_THERMAL_MODE_ACTIVE 0x00 |
59 | 59 | ||
60 | #define ACPI_THERMAL_MAX_ACTIVE 10 | 60 | #define ACPI_THERMAL_MAX_ACTIVE 10 |
61 | #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65 | 61 | #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65 |
62 | 62 | ||
63 | #define _COMPONENT ACPI_THERMAL_COMPONENT | 63 | #define _COMPONENT ACPI_THERMAL_COMPONENT |
64 | ACPI_MODULE_NAME("thermal"); | 64 | ACPI_MODULE_NAME("thermal"); |
65 | 65 | ||
66 | MODULE_AUTHOR("Paul Diefenbaugh"); | 66 | MODULE_AUTHOR("Paul Diefenbaugh"); |
67 | MODULE_DESCRIPTION("ACPI Thermal Zone Driver"); | 67 | MODULE_DESCRIPTION("ACPI Thermal Zone Driver"); |
68 | MODULE_LICENSE("GPL"); | 68 | MODULE_LICENSE("GPL"); |
69 | 69 | ||
70 | static int act; | 70 | static int act; |
71 | module_param(act, int, 0644); | 71 | module_param(act, int, 0644); |
72 | MODULE_PARM_DESC(act, "Disable or override all lowest active trip points."); | 72 | MODULE_PARM_DESC(act, "Disable or override all lowest active trip points."); |
73 | 73 | ||
74 | static int crt; | 74 | static int crt; |
75 | module_param(crt, int, 0644); | 75 | module_param(crt, int, 0644); |
76 | MODULE_PARM_DESC(crt, "Disable or lower all critical trip points."); | 76 | MODULE_PARM_DESC(crt, "Disable or lower all critical trip points."); |
77 | 77 | ||
78 | static int tzp; | 78 | static int tzp; |
79 | module_param(tzp, int, 0444); | 79 | module_param(tzp, int, 0444); |
80 | MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds."); | 80 | MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds."); |
81 | 81 | ||
82 | static int nocrt; | 82 | static int nocrt; |
83 | module_param(nocrt, int, 0); | 83 | module_param(nocrt, int, 0); |
84 | MODULE_PARM_DESC(nocrt, "Set to take no action upon ACPI thermal zone critical trips points."); | 84 | MODULE_PARM_DESC(nocrt, "Set to take no action upon ACPI thermal zone critical trips points."); |
85 | 85 | ||
86 | static int off; | 86 | static int off; |
87 | module_param(off, int, 0); | 87 | module_param(off, int, 0); |
88 | MODULE_PARM_DESC(off, "Set to disable ACPI thermal support."); | 88 | MODULE_PARM_DESC(off, "Set to disable ACPI thermal support."); |
89 | 89 | ||
90 | static int psv; | 90 | static int psv; |
91 | module_param(psv, int, 0644); | 91 | module_param(psv, int, 0644); |
92 | MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); | 92 | MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); |
93 | 93 | ||
94 | static int acpi_thermal_add(struct acpi_device *device); | 94 | static int acpi_thermal_add(struct acpi_device *device); |
95 | static int acpi_thermal_remove(struct acpi_device *device); | 95 | static int acpi_thermal_remove(struct acpi_device *device); |
96 | static void acpi_thermal_notify(struct acpi_device *device, u32 event); | 96 | static void acpi_thermal_notify(struct acpi_device *device, u32 event); |
97 | 97 | ||
98 | static const struct acpi_device_id thermal_device_ids[] = { | 98 | static const struct acpi_device_id thermal_device_ids[] = { |
99 | {ACPI_THERMAL_HID, 0}, | 99 | {ACPI_THERMAL_HID, 0}, |
100 | {"", 0}, | 100 | {"", 0}, |
101 | }; | 101 | }; |
102 | MODULE_DEVICE_TABLE(acpi, thermal_device_ids); | 102 | MODULE_DEVICE_TABLE(acpi, thermal_device_ids); |
103 | 103 | ||
104 | #ifdef CONFIG_PM_SLEEP | 104 | #ifdef CONFIG_PM_SLEEP |
105 | static int acpi_thermal_resume(struct device *dev); | 105 | static int acpi_thermal_resume(struct device *dev); |
106 | #endif | 106 | #endif |
107 | static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume); | 107 | static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume); |
108 | 108 | ||
109 | static struct acpi_driver acpi_thermal_driver = { | 109 | static struct acpi_driver acpi_thermal_driver = { |
110 | .name = "thermal", | 110 | .name = "thermal", |
111 | .class = ACPI_THERMAL_CLASS, | 111 | .class = ACPI_THERMAL_CLASS, |
112 | .ids = thermal_device_ids, | 112 | .ids = thermal_device_ids, |
113 | .ops = { | 113 | .ops = { |
114 | .add = acpi_thermal_add, | 114 | .add = acpi_thermal_add, |
115 | .remove = acpi_thermal_remove, | 115 | .remove = acpi_thermal_remove, |
116 | .notify = acpi_thermal_notify, | 116 | .notify = acpi_thermal_notify, |
117 | }, | 117 | }, |
118 | .drv.pm = &acpi_thermal_pm, | 118 | .drv.pm = &acpi_thermal_pm, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | struct acpi_thermal_state { | 121 | struct acpi_thermal_state { |
122 | u8 critical:1; | 122 | u8 critical:1; |
123 | u8 hot:1; | 123 | u8 hot:1; |
124 | u8 passive:1; | 124 | u8 passive:1; |
125 | u8 active:1; | 125 | u8 active:1; |
126 | u8 reserved:4; | 126 | u8 reserved:4; |
127 | int active_index; | 127 | int active_index; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | struct acpi_thermal_state_flags { | 130 | struct acpi_thermal_state_flags { |
131 | u8 valid:1; | 131 | u8 valid:1; |
132 | u8 enabled:1; | 132 | u8 enabled:1; |
133 | u8 reserved:6; | 133 | u8 reserved:6; |
134 | }; | 134 | }; |
135 | 135 | ||
136 | struct acpi_thermal_critical { | 136 | struct acpi_thermal_critical { |
137 | struct acpi_thermal_state_flags flags; | 137 | struct acpi_thermal_state_flags flags; |
138 | unsigned long temperature; | 138 | unsigned long temperature; |
139 | }; | 139 | }; |
140 | 140 | ||
141 | struct acpi_thermal_hot { | 141 | struct acpi_thermal_hot { |
142 | struct acpi_thermal_state_flags flags; | 142 | struct acpi_thermal_state_flags flags; |
143 | unsigned long temperature; | 143 | unsigned long temperature; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | struct acpi_thermal_passive { | 146 | struct acpi_thermal_passive { |
147 | struct acpi_thermal_state_flags flags; | 147 | struct acpi_thermal_state_flags flags; |
148 | unsigned long temperature; | 148 | unsigned long temperature; |
149 | unsigned long tc1; | 149 | unsigned long tc1; |
150 | unsigned long tc2; | 150 | unsigned long tc2; |
151 | unsigned long tsp; | 151 | unsigned long tsp; |
152 | struct acpi_handle_list devices; | 152 | struct acpi_handle_list devices; |
153 | }; | 153 | }; |
154 | 154 | ||
155 | struct acpi_thermal_active { | 155 | struct acpi_thermal_active { |
156 | struct acpi_thermal_state_flags flags; | 156 | struct acpi_thermal_state_flags flags; |
157 | unsigned long temperature; | 157 | unsigned long temperature; |
158 | struct acpi_handle_list devices; | 158 | struct acpi_handle_list devices; |
159 | }; | 159 | }; |
160 | 160 | ||
161 | struct acpi_thermal_trips { | 161 | struct acpi_thermal_trips { |
162 | struct acpi_thermal_critical critical; | 162 | struct acpi_thermal_critical critical; |
163 | struct acpi_thermal_hot hot; | 163 | struct acpi_thermal_hot hot; |
164 | struct acpi_thermal_passive passive; | 164 | struct acpi_thermal_passive passive; |
165 | struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE]; | 165 | struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE]; |
166 | }; | 166 | }; |
167 | 167 | ||
168 | struct acpi_thermal_flags { | 168 | struct acpi_thermal_flags { |
169 | u8 cooling_mode:1; /* _SCP */ | 169 | u8 cooling_mode:1; /* _SCP */ |
170 | u8 devices:1; /* _TZD */ | 170 | u8 devices:1; /* _TZD */ |
171 | u8 reserved:6; | 171 | u8 reserved:6; |
172 | }; | 172 | }; |
173 | 173 | ||
174 | struct acpi_thermal { | 174 | struct acpi_thermal { |
175 | struct acpi_device * device; | 175 | struct acpi_device * device; |
176 | acpi_bus_id name; | 176 | acpi_bus_id name; |
177 | unsigned long temperature; | 177 | unsigned long temperature; |
178 | unsigned long last_temperature; | 178 | unsigned long last_temperature; |
179 | unsigned long polling_frequency; | 179 | unsigned long polling_frequency; |
180 | volatile u8 zombie; | 180 | volatile u8 zombie; |
181 | struct acpi_thermal_flags flags; | 181 | struct acpi_thermal_flags flags; |
182 | struct acpi_thermal_state state; | 182 | struct acpi_thermal_state state; |
183 | struct acpi_thermal_trips trips; | 183 | struct acpi_thermal_trips trips; |
184 | struct acpi_handle_list devices; | 184 | struct acpi_handle_list devices; |
185 | struct thermal_zone_device *thermal_zone; | 185 | struct thermal_zone_device *thermal_zone; |
186 | int tz_enabled; | 186 | int tz_enabled; |
187 | int kelvin_offset; | 187 | int kelvin_offset; |
188 | }; | 188 | }; |
189 | 189 | ||
190 | /* -------------------------------------------------------------------------- | 190 | /* -------------------------------------------------------------------------- |
191 | Thermal Zone Management | 191 | Thermal Zone Management |
192 | -------------------------------------------------------------------------- */ | 192 | -------------------------------------------------------------------------- */ |
193 | 193 | ||
194 | static int acpi_thermal_get_temperature(struct acpi_thermal *tz) | 194 | static int acpi_thermal_get_temperature(struct acpi_thermal *tz) |
195 | { | 195 | { |
196 | acpi_status status = AE_OK; | 196 | acpi_status status = AE_OK; |
197 | unsigned long long tmp; | 197 | unsigned long long tmp; |
198 | 198 | ||
199 | if (!tz) | 199 | if (!tz) |
200 | return -EINVAL; | 200 | return -EINVAL; |
201 | 201 | ||
202 | tz->last_temperature = tz->temperature; | 202 | tz->last_temperature = tz->temperature; |
203 | 203 | ||
204 | status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); | 204 | status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); |
205 | if (ACPI_FAILURE(status)) | 205 | if (ACPI_FAILURE(status)) |
206 | return -ENODEV; | 206 | return -ENODEV; |
207 | 207 | ||
208 | tz->temperature = tmp; | 208 | tz->temperature = tmp; |
209 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", | 209 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", |
210 | tz->temperature)); | 210 | tz->temperature)); |
211 | 211 | ||
212 | return 0; | 212 | return 0; |
213 | } | 213 | } |
214 | 214 | ||
215 | static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) | 215 | static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) |
216 | { | 216 | { |
217 | acpi_status status = AE_OK; | 217 | acpi_status status = AE_OK; |
218 | unsigned long long tmp; | 218 | unsigned long long tmp; |
219 | 219 | ||
220 | if (!tz) | 220 | if (!tz) |
221 | return -EINVAL; | 221 | return -EINVAL; |
222 | 222 | ||
223 | status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); | 223 | status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); |
224 | if (ACPI_FAILURE(status)) | 224 | if (ACPI_FAILURE(status)) |
225 | return -ENODEV; | 225 | return -ENODEV; |
226 | 226 | ||
227 | tz->polling_frequency = tmp; | 227 | tz->polling_frequency = tmp; |
228 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", | 228 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", |
229 | tz->polling_frequency)); | 229 | tz->polling_frequency)); |
230 | 230 | ||
231 | return 0; | 231 | return 0; |
232 | } | 232 | } |
233 | 233 | ||
234 | static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) | 234 | static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) |
235 | { | 235 | { |
236 | if (!tz) | 236 | if (!tz) |
237 | return -EINVAL; | 237 | return -EINVAL; |
238 | 238 | ||
239 | if (!acpi_has_method(tz->device->handle, "_SCP")) { | 239 | if (!acpi_has_method(tz->device->handle, "_SCP")) { |
240 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); | 240 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); |
241 | return -ENODEV; | 241 | return -ENODEV; |
242 | } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, | 242 | } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, |
243 | "_SCP", mode))) { | 243 | "_SCP", mode))) { |
244 | return -ENODEV; | 244 | return -ENODEV; |
245 | } | 245 | } |
246 | 246 | ||
247 | return 0; | 247 | return 0; |
248 | } | 248 | } |
249 | 249 | ||
250 | #define ACPI_TRIPS_CRITICAL 0x01 | 250 | #define ACPI_TRIPS_CRITICAL 0x01 |
251 | #define ACPI_TRIPS_HOT 0x02 | 251 | #define ACPI_TRIPS_HOT 0x02 |
252 | #define ACPI_TRIPS_PASSIVE 0x04 | 252 | #define ACPI_TRIPS_PASSIVE 0x04 |
253 | #define ACPI_TRIPS_ACTIVE 0x08 | 253 | #define ACPI_TRIPS_ACTIVE 0x08 |
254 | #define ACPI_TRIPS_DEVICES 0x10 | 254 | #define ACPI_TRIPS_DEVICES 0x10 |
255 | 255 | ||
256 | #define ACPI_TRIPS_REFRESH_THRESHOLDS (ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE) | 256 | #define ACPI_TRIPS_REFRESH_THRESHOLDS (ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE) |
257 | #define ACPI_TRIPS_REFRESH_DEVICES ACPI_TRIPS_DEVICES | 257 | #define ACPI_TRIPS_REFRESH_DEVICES ACPI_TRIPS_DEVICES |
258 | 258 | ||
259 | #define ACPI_TRIPS_INIT (ACPI_TRIPS_CRITICAL | ACPI_TRIPS_HOT | \ | 259 | #define ACPI_TRIPS_INIT (ACPI_TRIPS_CRITICAL | ACPI_TRIPS_HOT | \ |
260 | ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE | \ | 260 | ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE | \ |
261 | ACPI_TRIPS_DEVICES) | 261 | ACPI_TRIPS_DEVICES) |
262 | 262 | ||
263 | /* | 263 | /* |
264 | * This exception is thrown out in two cases: | 264 | * This exception is thrown out in two cases: |
265 | * 1.An invalid trip point becomes invalid or a valid trip point becomes invalid | 265 | * 1.An invalid trip point becomes invalid or a valid trip point becomes invalid |
266 | * when re-evaluating the AML code. | 266 | * when re-evaluating the AML code. |
267 | * 2.TODO: Devices listed in _PSL, _ALx, _TZD may change. | 267 | * 2.TODO: Devices listed in _PSL, _ALx, _TZD may change. |
268 | * We need to re-bind the cooling devices of a thermal zone when this occurs. | 268 | * We need to re-bind the cooling devices of a thermal zone when this occurs. |
269 | */ | 269 | */ |
270 | #define ACPI_THERMAL_TRIPS_EXCEPTION(flags, str) \ | 270 | #define ACPI_THERMAL_TRIPS_EXCEPTION(flags, str) \ |
271 | do { \ | 271 | do { \ |
272 | if (flags != ACPI_TRIPS_INIT) \ | 272 | if (flags != ACPI_TRIPS_INIT) \ |
273 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, \ | 273 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, \ |
274 | "ACPI thermal trip point %s changed\n" \ | 274 | "ACPI thermal trip point %s changed\n" \ |
275 | "Please send acpidump to linux-acpi@vger.kernel.org", str)); \ | 275 | "Please send acpidump to linux-acpi@vger.kernel.org", str)); \ |
276 | } while (0) | 276 | } while (0) |
277 | 277 | ||
278 | static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | 278 | static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) |
279 | { | 279 | { |
280 | acpi_status status = AE_OK; | 280 | acpi_status status = AE_OK; |
281 | unsigned long long tmp; | 281 | unsigned long long tmp; |
282 | struct acpi_handle_list devices; | 282 | struct acpi_handle_list devices; |
283 | int valid = 0; | 283 | int valid = 0; |
284 | int i; | 284 | int i; |
285 | 285 | ||
286 | /* Critical Shutdown */ | 286 | /* Critical Shutdown */ |
287 | if (flag & ACPI_TRIPS_CRITICAL) { | 287 | if (flag & ACPI_TRIPS_CRITICAL) { |
288 | status = acpi_evaluate_integer(tz->device->handle, | 288 | status = acpi_evaluate_integer(tz->device->handle, |
289 | "_CRT", NULL, &tmp); | 289 | "_CRT", NULL, &tmp); |
290 | tz->trips.critical.temperature = tmp; | 290 | tz->trips.critical.temperature = tmp; |
291 | /* | 291 | /* |
292 | * Treat freezing temperatures as invalid as well; some | 292 | * Treat freezing temperatures as invalid as well; some |
293 | * BIOSes return really low values and cause reboots at startup. | 293 | * BIOSes return really low values and cause reboots at startup. |
294 | * Below zero (Celsius) values clearly aren't right for sure.. | 294 | * Below zero (Celsius) values clearly aren't right for sure.. |
295 | * ... so lets discard those as invalid. | 295 | * ... so lets discard those as invalid. |
296 | */ | 296 | */ |
297 | if (ACPI_FAILURE(status)) { | 297 | if (ACPI_FAILURE(status)) { |
298 | tz->trips.critical.flags.valid = 0; | 298 | tz->trips.critical.flags.valid = 0; |
299 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 299 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
300 | "No critical threshold\n")); | 300 | "No critical threshold\n")); |
301 | } else if (tmp <= 2732) { | 301 | } else if (tmp <= 2732) { |
302 | printk(KERN_WARNING FW_BUG "Invalid critical threshold " | 302 | printk(KERN_WARNING FW_BUG "Invalid critical threshold " |
303 | "(%llu)\n", tmp); | 303 | "(%llu)\n", tmp); |
304 | tz->trips.critical.flags.valid = 0; | 304 | tz->trips.critical.flags.valid = 0; |
305 | } else { | 305 | } else { |
306 | tz->trips.critical.flags.valid = 1; | 306 | tz->trips.critical.flags.valid = 1; |
307 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 307 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
308 | "Found critical threshold [%lu]\n", | 308 | "Found critical threshold [%lu]\n", |
309 | tz->trips.critical.temperature)); | 309 | tz->trips.critical.temperature)); |
310 | } | 310 | } |
311 | if (tz->trips.critical.flags.valid == 1) { | 311 | if (tz->trips.critical.flags.valid == 1) { |
312 | if (crt == -1) { | 312 | if (crt == -1) { |
313 | tz->trips.critical.flags.valid = 0; | 313 | tz->trips.critical.flags.valid = 0; |
314 | } else if (crt > 0) { | 314 | } else if (crt > 0) { |
315 | unsigned long crt_k = CELSIUS_TO_KELVIN(crt); | 315 | unsigned long crt_k = CELSIUS_TO_KELVIN(crt); |
316 | /* | 316 | /* |
317 | * Allow override critical threshold | 317 | * Allow override critical threshold |
318 | */ | 318 | */ |
319 | if (crt_k > tz->trips.critical.temperature) | 319 | if (crt_k > tz->trips.critical.temperature) |
320 | printk(KERN_WARNING PREFIX | 320 | printk(KERN_WARNING PREFIX |
321 | "Critical threshold %d C\n", crt); | 321 | "Critical threshold %d C\n", crt); |
322 | tz->trips.critical.temperature = crt_k; | 322 | tz->trips.critical.temperature = crt_k; |
323 | } | 323 | } |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | /* Critical Sleep (optional) */ | 327 | /* Critical Sleep (optional) */ |
328 | if (flag & ACPI_TRIPS_HOT) { | 328 | if (flag & ACPI_TRIPS_HOT) { |
329 | status = acpi_evaluate_integer(tz->device->handle, | 329 | status = acpi_evaluate_integer(tz->device->handle, |
330 | "_HOT", NULL, &tmp); | 330 | "_HOT", NULL, &tmp); |
331 | if (ACPI_FAILURE(status)) { | 331 | if (ACPI_FAILURE(status)) { |
332 | tz->trips.hot.flags.valid = 0; | 332 | tz->trips.hot.flags.valid = 0; |
333 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 333 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
334 | "No hot threshold\n")); | 334 | "No hot threshold\n")); |
335 | } else { | 335 | } else { |
336 | tz->trips.hot.temperature = tmp; | 336 | tz->trips.hot.temperature = tmp; |
337 | tz->trips.hot.flags.valid = 1; | 337 | tz->trips.hot.flags.valid = 1; |
338 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 338 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
339 | "Found hot threshold [%lu]\n", | 339 | "Found hot threshold [%lu]\n", |
340 | tz->trips.critical.temperature)); | 340 | tz->trips.critical.temperature)); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | /* Passive (optional) */ | 344 | /* Passive (optional) */ |
345 | if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || | 345 | if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || |
346 | (flag == ACPI_TRIPS_INIT)) { | 346 | (flag == ACPI_TRIPS_INIT)) { |
347 | valid = tz->trips.passive.flags.valid; | 347 | valid = tz->trips.passive.flags.valid; |
348 | if (psv == -1) { | 348 | if (psv == -1) { |
349 | status = AE_SUPPORT; | 349 | status = AE_SUPPORT; |
350 | } else if (psv > 0) { | 350 | } else if (psv > 0) { |
351 | tmp = CELSIUS_TO_KELVIN(psv); | 351 | tmp = CELSIUS_TO_KELVIN(psv); |
352 | status = AE_OK; | 352 | status = AE_OK; |
353 | } else { | 353 | } else { |
354 | status = acpi_evaluate_integer(tz->device->handle, | 354 | status = acpi_evaluate_integer(tz->device->handle, |
355 | "_PSV", NULL, &tmp); | 355 | "_PSV", NULL, &tmp); |
356 | } | 356 | } |
357 | 357 | ||
358 | if (ACPI_FAILURE(status)) | 358 | if (ACPI_FAILURE(status)) |
359 | tz->trips.passive.flags.valid = 0; | 359 | tz->trips.passive.flags.valid = 0; |
360 | else { | 360 | else { |
361 | tz->trips.passive.temperature = tmp; | 361 | tz->trips.passive.temperature = tmp; |
362 | tz->trips.passive.flags.valid = 1; | 362 | tz->trips.passive.flags.valid = 1; |
363 | if (flag == ACPI_TRIPS_INIT) { | 363 | if (flag == ACPI_TRIPS_INIT) { |
364 | status = acpi_evaluate_integer( | 364 | status = acpi_evaluate_integer( |
365 | tz->device->handle, "_TC1", | 365 | tz->device->handle, "_TC1", |
366 | NULL, &tmp); | 366 | NULL, &tmp); |
367 | if (ACPI_FAILURE(status)) | 367 | if (ACPI_FAILURE(status)) |
368 | tz->trips.passive.flags.valid = 0; | 368 | tz->trips.passive.flags.valid = 0; |
369 | else | 369 | else |
370 | tz->trips.passive.tc1 = tmp; | 370 | tz->trips.passive.tc1 = tmp; |
371 | status = acpi_evaluate_integer( | 371 | status = acpi_evaluate_integer( |
372 | tz->device->handle, "_TC2", | 372 | tz->device->handle, "_TC2", |
373 | NULL, &tmp); | 373 | NULL, &tmp); |
374 | if (ACPI_FAILURE(status)) | 374 | if (ACPI_FAILURE(status)) |
375 | tz->trips.passive.flags.valid = 0; | 375 | tz->trips.passive.flags.valid = 0; |
376 | else | 376 | else |
377 | tz->trips.passive.tc2 = tmp; | 377 | tz->trips.passive.tc2 = tmp; |
378 | status = acpi_evaluate_integer( | 378 | status = acpi_evaluate_integer( |
379 | tz->device->handle, "_TSP", | 379 | tz->device->handle, "_TSP", |
380 | NULL, &tmp); | 380 | NULL, &tmp); |
381 | if (ACPI_FAILURE(status)) | 381 | if (ACPI_FAILURE(status)) |
382 | tz->trips.passive.flags.valid = 0; | 382 | tz->trips.passive.flags.valid = 0; |
383 | else | 383 | else |
384 | tz->trips.passive.tsp = tmp; | 384 | tz->trips.passive.tsp = tmp; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | } | 387 | } |
388 | if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { | 388 | if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { |
389 | memset(&devices, 0, sizeof(struct acpi_handle_list)); | 389 | memset(&devices, 0, sizeof(struct acpi_handle_list)); |
390 | status = acpi_evaluate_reference(tz->device->handle, "_PSL", | 390 | status = acpi_evaluate_reference(tz->device->handle, "_PSL", |
391 | NULL, &devices); | 391 | NULL, &devices); |
392 | if (ACPI_FAILURE(status)) { | 392 | if (ACPI_FAILURE(status)) { |
393 | printk(KERN_WARNING PREFIX | 393 | printk(KERN_WARNING PREFIX |
394 | "Invalid passive threshold\n"); | 394 | "Invalid passive threshold\n"); |
395 | tz->trips.passive.flags.valid = 0; | 395 | tz->trips.passive.flags.valid = 0; |
396 | } | 396 | } |
397 | else | 397 | else |
398 | tz->trips.passive.flags.valid = 1; | 398 | tz->trips.passive.flags.valid = 1; |
399 | 399 | ||
400 | if (memcmp(&tz->trips.passive.devices, &devices, | 400 | if (memcmp(&tz->trips.passive.devices, &devices, |
401 | sizeof(struct acpi_handle_list))) { | 401 | sizeof(struct acpi_handle_list))) { |
402 | memcpy(&tz->trips.passive.devices, &devices, | 402 | memcpy(&tz->trips.passive.devices, &devices, |
403 | sizeof(struct acpi_handle_list)); | 403 | sizeof(struct acpi_handle_list)); |
404 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); | 404 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) { | 407 | if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) { |
408 | if (valid != tz->trips.passive.flags.valid) | 408 | if (valid != tz->trips.passive.flags.valid) |
409 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state"); | 409 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state"); |
410 | } | 410 | } |
411 | 411 | ||
412 | /* Active (optional) */ | 412 | /* Active (optional) */ |
413 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { | 413 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
414 | char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; | 414 | char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; |
415 | valid = tz->trips.active[i].flags.valid; | 415 | valid = tz->trips.active[i].flags.valid; |
416 | 416 | ||
417 | if (act == -1) | 417 | if (act == -1) |
418 | break; /* disable all active trip points */ | 418 | break; /* disable all active trip points */ |
419 | 419 | ||
420 | if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) && | 420 | if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) && |
421 | tz->trips.active[i].flags.valid)) { | 421 | tz->trips.active[i].flags.valid)) { |
422 | status = acpi_evaluate_integer(tz->device->handle, | 422 | status = acpi_evaluate_integer(tz->device->handle, |
423 | name, NULL, &tmp); | 423 | name, NULL, &tmp); |
424 | if (ACPI_FAILURE(status)) { | 424 | if (ACPI_FAILURE(status)) { |
425 | tz->trips.active[i].flags.valid = 0; | 425 | tz->trips.active[i].flags.valid = 0; |
426 | if (i == 0) | 426 | if (i == 0) |
427 | break; | 427 | break; |
428 | if (act <= 0) | 428 | if (act <= 0) |
429 | break; | 429 | break; |
430 | if (i == 1) | 430 | if (i == 1) |
431 | tz->trips.active[0].temperature = | 431 | tz->trips.active[0].temperature = |
432 | CELSIUS_TO_KELVIN(act); | 432 | CELSIUS_TO_KELVIN(act); |
433 | else | 433 | else |
434 | /* | 434 | /* |
435 | * Don't allow override higher than | 435 | * Don't allow override higher than |
436 | * the next higher trip point | 436 | * the next higher trip point |
437 | */ | 437 | */ |
438 | tz->trips.active[i - 1].temperature = | 438 | tz->trips.active[i - 1].temperature = |
439 | (tz->trips.active[i - 2].temperature < | 439 | (tz->trips.active[i - 2].temperature < |
440 | CELSIUS_TO_KELVIN(act) ? | 440 | CELSIUS_TO_KELVIN(act) ? |
441 | tz->trips.active[i - 2].temperature : | 441 | tz->trips.active[i - 2].temperature : |
442 | CELSIUS_TO_KELVIN(act)); | 442 | CELSIUS_TO_KELVIN(act)); |
443 | break; | 443 | break; |
444 | } else { | 444 | } else { |
445 | tz->trips.active[i].temperature = tmp; | 445 | tz->trips.active[i].temperature = tmp; |
446 | tz->trips.active[i].flags.valid = 1; | 446 | tz->trips.active[i].flags.valid = 1; |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | name[2] = 'L'; | 450 | name[2] = 'L'; |
451 | if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { | 451 | if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { |
452 | memset(&devices, 0, sizeof(struct acpi_handle_list)); | 452 | memset(&devices, 0, sizeof(struct acpi_handle_list)); |
453 | status = acpi_evaluate_reference(tz->device->handle, | 453 | status = acpi_evaluate_reference(tz->device->handle, |
454 | name, NULL, &devices); | 454 | name, NULL, &devices); |
455 | if (ACPI_FAILURE(status)) { | 455 | if (ACPI_FAILURE(status)) { |
456 | printk(KERN_WARNING PREFIX | 456 | printk(KERN_WARNING PREFIX |
457 | "Invalid active%d threshold\n", i); | 457 | "Invalid active%d threshold\n", i); |
458 | tz->trips.active[i].flags.valid = 0; | 458 | tz->trips.active[i].flags.valid = 0; |
459 | } | 459 | } |
460 | else | 460 | else |
461 | tz->trips.active[i].flags.valid = 1; | 461 | tz->trips.active[i].flags.valid = 1; |
462 | 462 | ||
463 | if (memcmp(&tz->trips.active[i].devices, &devices, | 463 | if (memcmp(&tz->trips.active[i].devices, &devices, |
464 | sizeof(struct acpi_handle_list))) { | 464 | sizeof(struct acpi_handle_list))) { |
465 | memcpy(&tz->trips.active[i].devices, &devices, | 465 | memcpy(&tz->trips.active[i].devices, &devices, |
466 | sizeof(struct acpi_handle_list)); | 466 | sizeof(struct acpi_handle_list)); |
467 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); | 467 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES)) | 470 | if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES)) |
471 | if (valid != tz->trips.active[i].flags.valid) | 471 | if (valid != tz->trips.active[i].flags.valid) |
472 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state"); | 472 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state"); |
473 | 473 | ||
474 | if (!tz->trips.active[i].flags.valid) | 474 | if (!tz->trips.active[i].flags.valid) |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | 477 | ||
478 | if ((flag & ACPI_TRIPS_DEVICES) | 478 | if ((flag & ACPI_TRIPS_DEVICES) |
479 | && acpi_has_method(tz->device->handle, "_TZD")) { | 479 | && acpi_has_method(tz->device->handle, "_TZD")) { |
480 | memset(&devices, 0, sizeof(devices)); | 480 | memset(&devices, 0, sizeof(devices)); |
481 | status = acpi_evaluate_reference(tz->device->handle, "_TZD", | 481 | status = acpi_evaluate_reference(tz->device->handle, "_TZD", |
482 | NULL, &devices); | 482 | NULL, &devices); |
483 | if (ACPI_SUCCESS(status) | 483 | if (ACPI_SUCCESS(status) |
484 | && memcmp(&tz->devices, &devices, sizeof(devices))) { | 484 | && memcmp(&tz->devices, &devices, sizeof(devices))) { |
485 | tz->devices = devices; | 485 | tz->devices = devices; |
486 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); | 486 | ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | 489 | ||
490 | return 0; | 490 | return 0; |
491 | } | 491 | } |
492 | 492 | ||
493 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) | 493 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) |
494 | { | 494 | { |
495 | int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); | 495 | int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); |
496 | 496 | ||
497 | if (ret) | 497 | if (ret) |
498 | return ret; | 498 | return ret; |
499 | 499 | ||
500 | valid = tz->trips.critical.flags.valid | | 500 | valid = tz->trips.critical.flags.valid | |
501 | tz->trips.hot.flags.valid | | 501 | tz->trips.hot.flags.valid | |
502 | tz->trips.passive.flags.valid; | 502 | tz->trips.passive.flags.valid; |
503 | 503 | ||
504 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) | 504 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) |
505 | valid |= tz->trips.active[i].flags.valid; | 505 | valid |= tz->trips.active[i].flags.valid; |
506 | 506 | ||
507 | if (!valid) { | 507 | if (!valid) { |
508 | printk(KERN_WARNING FW_BUG "No valid trip found\n"); | 508 | printk(KERN_WARNING FW_BUG "No valid trip found\n"); |
509 | return -ENODEV; | 509 | return -ENODEV; |
510 | } | 510 | } |
511 | return 0; | 511 | return 0; |
512 | } | 512 | } |
513 | 513 | ||
514 | static void acpi_thermal_check(void *data) | 514 | static void acpi_thermal_check(void *data) |
515 | { | 515 | { |
516 | struct acpi_thermal *tz = data; | 516 | struct acpi_thermal *tz = data; |
517 | 517 | ||
518 | if (!tz->tz_enabled) { | 518 | if (!tz->tz_enabled) |
519 | pr_warn("thermal zone is disabled \n"); | ||
520 | return; | 519 | return; |
521 | } | 520 | |
522 | thermal_zone_device_update(tz->thermal_zone); | 521 | thermal_zone_device_update(tz->thermal_zone); |
523 | } | 522 | } |
524 | 523 | ||
525 | /* sys I/F for generic thermal sysfs support */ | 524 | /* sys I/F for generic thermal sysfs support */ |
526 | #define KELVIN_TO_MILLICELSIUS(t, off) (((t) - (off)) * 100) | 525 | #define KELVIN_TO_MILLICELSIUS(t, off) (((t) - (off)) * 100) |
527 | 526 | ||
528 | static int thermal_get_temp(struct thermal_zone_device *thermal, | 527 | static int thermal_get_temp(struct thermal_zone_device *thermal, |
529 | unsigned long *temp) | 528 | unsigned long *temp) |
530 | { | 529 | { |
531 | struct acpi_thermal *tz = thermal->devdata; | 530 | struct acpi_thermal *tz = thermal->devdata; |
532 | int result; | 531 | int result; |
533 | 532 | ||
534 | if (!tz) | 533 | if (!tz) |
535 | return -EINVAL; | 534 | return -EINVAL; |
536 | 535 | ||
537 | result = acpi_thermal_get_temperature(tz); | 536 | result = acpi_thermal_get_temperature(tz); |
538 | if (result) | 537 | if (result) |
539 | return result; | 538 | return result; |
540 | 539 | ||
541 | *temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset); | 540 | *temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset); |
542 | return 0; | 541 | return 0; |
543 | } | 542 | } |
544 | 543 | ||
545 | static int thermal_get_mode(struct thermal_zone_device *thermal, | 544 | static int thermal_get_mode(struct thermal_zone_device *thermal, |
546 | enum thermal_device_mode *mode) | 545 | enum thermal_device_mode *mode) |
547 | { | 546 | { |
548 | struct acpi_thermal *tz = thermal->devdata; | 547 | struct acpi_thermal *tz = thermal->devdata; |
549 | 548 | ||
550 | if (!tz) | 549 | if (!tz) |
551 | return -EINVAL; | 550 | return -EINVAL; |
552 | 551 | ||
553 | *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : | 552 | *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : |
554 | THERMAL_DEVICE_DISABLED; | 553 | THERMAL_DEVICE_DISABLED; |
555 | 554 | ||
556 | return 0; | 555 | return 0; |
557 | } | 556 | } |
558 | 557 | ||
559 | static int thermal_set_mode(struct thermal_zone_device *thermal, | 558 | static int thermal_set_mode(struct thermal_zone_device *thermal, |
560 | enum thermal_device_mode mode) | 559 | enum thermal_device_mode mode) |
561 | { | 560 | { |
562 | struct acpi_thermal *tz = thermal->devdata; | 561 | struct acpi_thermal *tz = thermal->devdata; |
563 | int enable; | 562 | int enable; |
564 | 563 | ||
565 | if (!tz) | 564 | if (!tz) |
566 | return -EINVAL; | 565 | return -EINVAL; |
567 | 566 | ||
568 | /* | 567 | /* |
569 | * enable/disable thermal management from ACPI thermal driver | 568 | * enable/disable thermal management from ACPI thermal driver |
570 | */ | 569 | */ |
571 | if (mode == THERMAL_DEVICE_ENABLED) | 570 | if (mode == THERMAL_DEVICE_ENABLED) |
572 | enable = 1; | 571 | enable = 1; |
573 | else if (mode == THERMAL_DEVICE_DISABLED) | 572 | else if (mode == THERMAL_DEVICE_DISABLED) { |
574 | enable = 0; | 573 | enable = 0; |
575 | else | 574 | pr_warn("thermal zone will be disabled\n"); |
575 | } else | ||
576 | return -EINVAL; | 576 | return -EINVAL; |
577 | 577 | ||
578 | if (enable != tz->tz_enabled) { | 578 | if (enable != tz->tz_enabled) { |
579 | tz->tz_enabled = enable; | 579 | tz->tz_enabled = enable; |
580 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 580 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
581 | "%s kernel ACPI thermal control\n", | 581 | "%s kernel ACPI thermal control\n", |
582 | tz->tz_enabled ? "Enable" : "Disable")); | 582 | tz->tz_enabled ? "Enable" : "Disable")); |
583 | acpi_thermal_check(tz); | 583 | acpi_thermal_check(tz); |
584 | } | 584 | } |
585 | return 0; | 585 | return 0; |
586 | } | 586 | } |
587 | 587 | ||
588 | static int thermal_get_trip_type(struct thermal_zone_device *thermal, | 588 | static int thermal_get_trip_type(struct thermal_zone_device *thermal, |
589 | int trip, enum thermal_trip_type *type) | 589 | int trip, enum thermal_trip_type *type) |
590 | { | 590 | { |
591 | struct acpi_thermal *tz = thermal->devdata; | 591 | struct acpi_thermal *tz = thermal->devdata; |
592 | int i; | 592 | int i; |
593 | 593 | ||
594 | if (!tz || trip < 0) | 594 | if (!tz || trip < 0) |
595 | return -EINVAL; | 595 | return -EINVAL; |
596 | 596 | ||
597 | if (tz->trips.critical.flags.valid) { | 597 | if (tz->trips.critical.flags.valid) { |
598 | if (!trip) { | 598 | if (!trip) { |
599 | *type = THERMAL_TRIP_CRITICAL; | 599 | *type = THERMAL_TRIP_CRITICAL; |
600 | return 0; | 600 | return 0; |
601 | } | 601 | } |
602 | trip--; | 602 | trip--; |
603 | } | 603 | } |
604 | 604 | ||
605 | if (tz->trips.hot.flags.valid) { | 605 | if (tz->trips.hot.flags.valid) { |
606 | if (!trip) { | 606 | if (!trip) { |
607 | *type = THERMAL_TRIP_HOT; | 607 | *type = THERMAL_TRIP_HOT; |
608 | return 0; | 608 | return 0; |
609 | } | 609 | } |
610 | trip--; | 610 | trip--; |
611 | } | 611 | } |
612 | 612 | ||
613 | if (tz->trips.passive.flags.valid) { | 613 | if (tz->trips.passive.flags.valid) { |
614 | if (!trip) { | 614 | if (!trip) { |
615 | *type = THERMAL_TRIP_PASSIVE; | 615 | *type = THERMAL_TRIP_PASSIVE; |
616 | return 0; | 616 | return 0; |
617 | } | 617 | } |
618 | trip--; | 618 | trip--; |
619 | } | 619 | } |
620 | 620 | ||
621 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && | 621 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && |
622 | tz->trips.active[i].flags.valid; i++) { | 622 | tz->trips.active[i].flags.valid; i++) { |
623 | if (!trip) { | 623 | if (!trip) { |
624 | *type = THERMAL_TRIP_ACTIVE; | 624 | *type = THERMAL_TRIP_ACTIVE; |
625 | return 0; | 625 | return 0; |
626 | } | 626 | } |
627 | trip--; | 627 | trip--; |
628 | } | 628 | } |
629 | 629 | ||
630 | return -EINVAL; | 630 | return -EINVAL; |
631 | } | 631 | } |
632 | 632 | ||
633 | static int thermal_get_trip_temp(struct thermal_zone_device *thermal, | 633 | static int thermal_get_trip_temp(struct thermal_zone_device *thermal, |
634 | int trip, unsigned long *temp) | 634 | int trip, unsigned long *temp) |
635 | { | 635 | { |
636 | struct acpi_thermal *tz = thermal->devdata; | 636 | struct acpi_thermal *tz = thermal->devdata; |
637 | int i; | 637 | int i; |
638 | 638 | ||
639 | if (!tz || trip < 0) | 639 | if (!tz || trip < 0) |
640 | return -EINVAL; | 640 | return -EINVAL; |
641 | 641 | ||
642 | if (tz->trips.critical.flags.valid) { | 642 | if (tz->trips.critical.flags.valid) { |
643 | if (!trip) { | 643 | if (!trip) { |
644 | *temp = KELVIN_TO_MILLICELSIUS( | 644 | *temp = KELVIN_TO_MILLICELSIUS( |
645 | tz->trips.critical.temperature, | 645 | tz->trips.critical.temperature, |
646 | tz->kelvin_offset); | 646 | tz->kelvin_offset); |
647 | return 0; | 647 | return 0; |
648 | } | 648 | } |
649 | trip--; | 649 | trip--; |
650 | } | 650 | } |
651 | 651 | ||
652 | if (tz->trips.hot.flags.valid) { | 652 | if (tz->trips.hot.flags.valid) { |
653 | if (!trip) { | 653 | if (!trip) { |
654 | *temp = KELVIN_TO_MILLICELSIUS( | 654 | *temp = KELVIN_TO_MILLICELSIUS( |
655 | tz->trips.hot.temperature, | 655 | tz->trips.hot.temperature, |
656 | tz->kelvin_offset); | 656 | tz->kelvin_offset); |
657 | return 0; | 657 | return 0; |
658 | } | 658 | } |
659 | trip--; | 659 | trip--; |
660 | } | 660 | } |
661 | 661 | ||
662 | if (tz->trips.passive.flags.valid) { | 662 | if (tz->trips.passive.flags.valid) { |
663 | if (!trip) { | 663 | if (!trip) { |
664 | *temp = KELVIN_TO_MILLICELSIUS( | 664 | *temp = KELVIN_TO_MILLICELSIUS( |
665 | tz->trips.passive.temperature, | 665 | tz->trips.passive.temperature, |
666 | tz->kelvin_offset); | 666 | tz->kelvin_offset); |
667 | return 0; | 667 | return 0; |
668 | } | 668 | } |
669 | trip--; | 669 | trip--; |
670 | } | 670 | } |
671 | 671 | ||
672 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && | 672 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && |
673 | tz->trips.active[i].flags.valid; i++) { | 673 | tz->trips.active[i].flags.valid; i++) { |
674 | if (!trip) { | 674 | if (!trip) { |
675 | *temp = KELVIN_TO_MILLICELSIUS( | 675 | *temp = KELVIN_TO_MILLICELSIUS( |
676 | tz->trips.active[i].temperature, | 676 | tz->trips.active[i].temperature, |
677 | tz->kelvin_offset); | 677 | tz->kelvin_offset); |
678 | return 0; | 678 | return 0; |
679 | } | 679 | } |
680 | trip--; | 680 | trip--; |
681 | } | 681 | } |
682 | 682 | ||
683 | return -EINVAL; | 683 | return -EINVAL; |
684 | } | 684 | } |
685 | 685 | ||
686 | static int thermal_get_crit_temp(struct thermal_zone_device *thermal, | 686 | static int thermal_get_crit_temp(struct thermal_zone_device *thermal, |
687 | unsigned long *temperature) { | 687 | unsigned long *temperature) { |
688 | struct acpi_thermal *tz = thermal->devdata; | 688 | struct acpi_thermal *tz = thermal->devdata; |
689 | 689 | ||
690 | if (tz->trips.critical.flags.valid) { | 690 | if (tz->trips.critical.flags.valid) { |
691 | *temperature = KELVIN_TO_MILLICELSIUS( | 691 | *temperature = KELVIN_TO_MILLICELSIUS( |
692 | tz->trips.critical.temperature, | 692 | tz->trips.critical.temperature, |
693 | tz->kelvin_offset); | 693 | tz->kelvin_offset); |
694 | return 0; | 694 | return 0; |
695 | } else | 695 | } else |
696 | return -EINVAL; | 696 | return -EINVAL; |
697 | } | 697 | } |
698 | 698 | ||
699 | static int thermal_get_trend(struct thermal_zone_device *thermal, | 699 | static int thermal_get_trend(struct thermal_zone_device *thermal, |
700 | int trip, enum thermal_trend *trend) | 700 | int trip, enum thermal_trend *trend) |
701 | { | 701 | { |
702 | struct acpi_thermal *tz = thermal->devdata; | 702 | struct acpi_thermal *tz = thermal->devdata; |
703 | enum thermal_trip_type type; | 703 | enum thermal_trip_type type; |
704 | int i; | 704 | int i; |
705 | 705 | ||
706 | if (thermal_get_trip_type(thermal, trip, &type)) | 706 | if (thermal_get_trip_type(thermal, trip, &type)) |
707 | return -EINVAL; | 707 | return -EINVAL; |
708 | 708 | ||
709 | if (type == THERMAL_TRIP_ACTIVE) { | 709 | if (type == THERMAL_TRIP_ACTIVE) { |
710 | unsigned long trip_temp; | 710 | unsigned long trip_temp; |
711 | unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature, | 711 | unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature, |
712 | tz->kelvin_offset); | 712 | tz->kelvin_offset); |
713 | if (thermal_get_trip_temp(thermal, trip, &trip_temp)) | 713 | if (thermal_get_trip_temp(thermal, trip, &trip_temp)) |
714 | return -EINVAL; | 714 | return -EINVAL; |
715 | 715 | ||
716 | if (temp > trip_temp) { | 716 | if (temp > trip_temp) { |
717 | *trend = THERMAL_TREND_RAISING; | 717 | *trend = THERMAL_TREND_RAISING; |
718 | return 0; | 718 | return 0; |
719 | } else { | 719 | } else { |
720 | /* Fall back on default trend */ | 720 | /* Fall back on default trend */ |
721 | return -EINVAL; | 721 | return -EINVAL; |
722 | } | 722 | } |
723 | } | 723 | } |
724 | 724 | ||
725 | /* | 725 | /* |
726 | * tz->temperature has already been updated by generic thermal layer, | 726 | * tz->temperature has already been updated by generic thermal layer, |
727 | * before this callback being invoked | 727 | * before this callback being invoked |
728 | */ | 728 | */ |
729 | i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) | 729 | i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) |
730 | + (tz->trips.passive.tc2 | 730 | + (tz->trips.passive.tc2 |
731 | * (tz->temperature - tz->trips.passive.temperature)); | 731 | * (tz->temperature - tz->trips.passive.temperature)); |
732 | 732 | ||
733 | if (i > 0) | 733 | if (i > 0) |
734 | *trend = THERMAL_TREND_RAISING; | 734 | *trend = THERMAL_TREND_RAISING; |
735 | else if (i < 0) | 735 | else if (i < 0) |
736 | *trend = THERMAL_TREND_DROPPING; | 736 | *trend = THERMAL_TREND_DROPPING; |
737 | else | 737 | else |
738 | *trend = THERMAL_TREND_STABLE; | 738 | *trend = THERMAL_TREND_STABLE; |
739 | return 0; | 739 | return 0; |
740 | } | 740 | } |
741 | 741 | ||
742 | 742 | ||
743 | static int thermal_notify(struct thermal_zone_device *thermal, int trip, | 743 | static int thermal_notify(struct thermal_zone_device *thermal, int trip, |
744 | enum thermal_trip_type trip_type) | 744 | enum thermal_trip_type trip_type) |
745 | { | 745 | { |
746 | u8 type = 0; | 746 | u8 type = 0; |
747 | struct acpi_thermal *tz = thermal->devdata; | 747 | struct acpi_thermal *tz = thermal->devdata; |
748 | 748 | ||
749 | if (trip_type == THERMAL_TRIP_CRITICAL) | 749 | if (trip_type == THERMAL_TRIP_CRITICAL) |
750 | type = ACPI_THERMAL_NOTIFY_CRITICAL; | 750 | type = ACPI_THERMAL_NOTIFY_CRITICAL; |
751 | else if (trip_type == THERMAL_TRIP_HOT) | 751 | else if (trip_type == THERMAL_TRIP_HOT) |
752 | type = ACPI_THERMAL_NOTIFY_HOT; | 752 | type = ACPI_THERMAL_NOTIFY_HOT; |
753 | else | 753 | else |
754 | return 0; | 754 | return 0; |
755 | 755 | ||
756 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | 756 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, |
757 | dev_name(&tz->device->dev), type, 1); | 757 | dev_name(&tz->device->dev), type, 1); |
758 | 758 | ||
759 | if (trip_type == THERMAL_TRIP_CRITICAL && nocrt) | 759 | if (trip_type == THERMAL_TRIP_CRITICAL && nocrt) |
760 | return 1; | 760 | return 1; |
761 | 761 | ||
762 | return 0; | 762 | return 0; |
763 | } | 763 | } |
764 | 764 | ||
765 | static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, | 765 | static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, |
766 | struct thermal_cooling_device *cdev, | 766 | struct thermal_cooling_device *cdev, |
767 | bool bind) | 767 | bool bind) |
768 | { | 768 | { |
769 | struct acpi_device *device = cdev->devdata; | 769 | struct acpi_device *device = cdev->devdata; |
770 | struct acpi_thermal *tz = thermal->devdata; | 770 | struct acpi_thermal *tz = thermal->devdata; |
771 | struct acpi_device *dev; | 771 | struct acpi_device *dev; |
772 | acpi_status status; | 772 | acpi_status status; |
773 | acpi_handle handle; | 773 | acpi_handle handle; |
774 | int i; | 774 | int i; |
775 | int j; | 775 | int j; |
776 | int trip = -1; | 776 | int trip = -1; |
777 | int result = 0; | 777 | int result = 0; |
778 | 778 | ||
779 | if (tz->trips.critical.flags.valid) | 779 | if (tz->trips.critical.flags.valid) |
780 | trip++; | 780 | trip++; |
781 | 781 | ||
782 | if (tz->trips.hot.flags.valid) | 782 | if (tz->trips.hot.flags.valid) |
783 | trip++; | 783 | trip++; |
784 | 784 | ||
785 | if (tz->trips.passive.flags.valid) { | 785 | if (tz->trips.passive.flags.valid) { |
786 | trip++; | 786 | trip++; |
787 | for (i = 0; i < tz->trips.passive.devices.count; | 787 | for (i = 0; i < tz->trips.passive.devices.count; |
788 | i++) { | 788 | i++) { |
789 | handle = tz->trips.passive.devices.handles[i]; | 789 | handle = tz->trips.passive.devices.handles[i]; |
790 | status = acpi_bus_get_device(handle, &dev); | 790 | status = acpi_bus_get_device(handle, &dev); |
791 | if (ACPI_FAILURE(status) || dev != device) | 791 | if (ACPI_FAILURE(status) || dev != device) |
792 | continue; | 792 | continue; |
793 | if (bind) | 793 | if (bind) |
794 | result = | 794 | result = |
795 | thermal_zone_bind_cooling_device | 795 | thermal_zone_bind_cooling_device |
796 | (thermal, trip, cdev, | 796 | (thermal, trip, cdev, |
797 | THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); | 797 | THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); |
798 | else | 798 | else |
799 | result = | 799 | result = |
800 | thermal_zone_unbind_cooling_device | 800 | thermal_zone_unbind_cooling_device |
801 | (thermal, trip, cdev); | 801 | (thermal, trip, cdev); |
802 | if (result) | 802 | if (result) |
803 | goto failed; | 803 | goto failed; |
804 | } | 804 | } |
805 | } | 805 | } |
806 | 806 | ||
807 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { | 807 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
808 | if (!tz->trips.active[i].flags.valid) | 808 | if (!tz->trips.active[i].flags.valid) |
809 | break; | 809 | break; |
810 | trip++; | 810 | trip++; |
811 | for (j = 0; | 811 | for (j = 0; |
812 | j < tz->trips.active[i].devices.count; | 812 | j < tz->trips.active[i].devices.count; |
813 | j++) { | 813 | j++) { |
814 | handle = tz->trips.active[i].devices.handles[j]; | 814 | handle = tz->trips.active[i].devices.handles[j]; |
815 | status = acpi_bus_get_device(handle, &dev); | 815 | status = acpi_bus_get_device(handle, &dev); |
816 | if (ACPI_FAILURE(status) || dev != device) | 816 | if (ACPI_FAILURE(status) || dev != device) |
817 | continue; | 817 | continue; |
818 | if (bind) | 818 | if (bind) |
819 | result = thermal_zone_bind_cooling_device | 819 | result = thermal_zone_bind_cooling_device |
820 | (thermal, trip, cdev, | 820 | (thermal, trip, cdev, |
821 | THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); | 821 | THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); |
822 | else | 822 | else |
823 | result = thermal_zone_unbind_cooling_device | 823 | result = thermal_zone_unbind_cooling_device |
824 | (thermal, trip, cdev); | 824 | (thermal, trip, cdev); |
825 | if (result) | 825 | if (result) |
826 | goto failed; | 826 | goto failed; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | for (i = 0; i < tz->devices.count; i++) { | 830 | for (i = 0; i < tz->devices.count; i++) { |
831 | handle = tz->devices.handles[i]; | 831 | handle = tz->devices.handles[i]; |
832 | status = acpi_bus_get_device(handle, &dev); | 832 | status = acpi_bus_get_device(handle, &dev); |
833 | if (ACPI_SUCCESS(status) && (dev == device)) { | 833 | if (ACPI_SUCCESS(status) && (dev == device)) { |
834 | if (bind) | 834 | if (bind) |
835 | result = thermal_zone_bind_cooling_device | 835 | result = thermal_zone_bind_cooling_device |
836 | (thermal, THERMAL_TRIPS_NONE, | 836 | (thermal, THERMAL_TRIPS_NONE, |
837 | cdev, THERMAL_NO_LIMIT, | 837 | cdev, THERMAL_NO_LIMIT, |
838 | THERMAL_NO_LIMIT); | 838 | THERMAL_NO_LIMIT); |
839 | else | 839 | else |
840 | result = thermal_zone_unbind_cooling_device | 840 | result = thermal_zone_unbind_cooling_device |
841 | (thermal, THERMAL_TRIPS_NONE, | 841 | (thermal, THERMAL_TRIPS_NONE, |
842 | cdev); | 842 | cdev); |
843 | if (result) | 843 | if (result) |
844 | goto failed; | 844 | goto failed; |
845 | } | 845 | } |
846 | } | 846 | } |
847 | 847 | ||
848 | failed: | 848 | failed: |
849 | return result; | 849 | return result; |
850 | } | 850 | } |
851 | 851 | ||
852 | static int | 852 | static int |
853 | acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, | 853 | acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, |
854 | struct thermal_cooling_device *cdev) | 854 | struct thermal_cooling_device *cdev) |
855 | { | 855 | { |
856 | return acpi_thermal_cooling_device_cb(thermal, cdev, true); | 856 | return acpi_thermal_cooling_device_cb(thermal, cdev, true); |
857 | } | 857 | } |
858 | 858 | ||
859 | static int | 859 | static int |
860 | acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, | 860 | acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, |
861 | struct thermal_cooling_device *cdev) | 861 | struct thermal_cooling_device *cdev) |
862 | { | 862 | { |
863 | return acpi_thermal_cooling_device_cb(thermal, cdev, false); | 863 | return acpi_thermal_cooling_device_cb(thermal, cdev, false); |
864 | } | 864 | } |
865 | 865 | ||
866 | static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { | 866 | static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { |
867 | .bind = acpi_thermal_bind_cooling_device, | 867 | .bind = acpi_thermal_bind_cooling_device, |
868 | .unbind = acpi_thermal_unbind_cooling_device, | 868 | .unbind = acpi_thermal_unbind_cooling_device, |
869 | .get_temp = thermal_get_temp, | 869 | .get_temp = thermal_get_temp, |
870 | .get_mode = thermal_get_mode, | 870 | .get_mode = thermal_get_mode, |
871 | .set_mode = thermal_set_mode, | 871 | .set_mode = thermal_set_mode, |
872 | .get_trip_type = thermal_get_trip_type, | 872 | .get_trip_type = thermal_get_trip_type, |
873 | .get_trip_temp = thermal_get_trip_temp, | 873 | .get_trip_temp = thermal_get_trip_temp, |
874 | .get_crit_temp = thermal_get_crit_temp, | 874 | .get_crit_temp = thermal_get_crit_temp, |
875 | .get_trend = thermal_get_trend, | 875 | .get_trend = thermal_get_trend, |
876 | .notify = thermal_notify, | 876 | .notify = thermal_notify, |
877 | }; | 877 | }; |
878 | 878 | ||
879 | static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) | 879 | static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) |
880 | { | 880 | { |
881 | int trips = 0; | 881 | int trips = 0; |
882 | int result; | 882 | int result; |
883 | acpi_status status; | 883 | acpi_status status; |
884 | int i; | 884 | int i; |
885 | 885 | ||
886 | if (tz->trips.critical.flags.valid) | 886 | if (tz->trips.critical.flags.valid) |
887 | trips++; | 887 | trips++; |
888 | 888 | ||
889 | if (tz->trips.hot.flags.valid) | 889 | if (tz->trips.hot.flags.valid) |
890 | trips++; | 890 | trips++; |
891 | 891 | ||
892 | if (tz->trips.passive.flags.valid) | 892 | if (tz->trips.passive.flags.valid) |
893 | trips++; | 893 | trips++; |
894 | 894 | ||
895 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && | 895 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && |
896 | tz->trips.active[i].flags.valid; i++, trips++); | 896 | tz->trips.active[i].flags.valid; i++, trips++); |
897 | 897 | ||
898 | if (tz->trips.passive.flags.valid) | 898 | if (tz->trips.passive.flags.valid) |
899 | tz->thermal_zone = | 899 | tz->thermal_zone = |
900 | thermal_zone_device_register("acpitz", trips, 0, tz, | 900 | thermal_zone_device_register("acpitz", trips, 0, tz, |
901 | &acpi_thermal_zone_ops, NULL, | 901 | &acpi_thermal_zone_ops, NULL, |
902 | tz->trips.passive.tsp*100, | 902 | tz->trips.passive.tsp*100, |
903 | tz->polling_frequency*100); | 903 | tz->polling_frequency*100); |
904 | else | 904 | else |
905 | tz->thermal_zone = | 905 | tz->thermal_zone = |
906 | thermal_zone_device_register("acpitz", trips, 0, tz, | 906 | thermal_zone_device_register("acpitz", trips, 0, tz, |
907 | &acpi_thermal_zone_ops, NULL, | 907 | &acpi_thermal_zone_ops, NULL, |
908 | 0, tz->polling_frequency*100); | 908 | 0, tz->polling_frequency*100); |
909 | if (IS_ERR(tz->thermal_zone)) | 909 | if (IS_ERR(tz->thermal_zone)) |
910 | return -ENODEV; | 910 | return -ENODEV; |
911 | 911 | ||
912 | result = sysfs_create_link(&tz->device->dev.kobj, | 912 | result = sysfs_create_link(&tz->device->dev.kobj, |
913 | &tz->thermal_zone->device.kobj, "thermal_zone"); | 913 | &tz->thermal_zone->device.kobj, "thermal_zone"); |
914 | if (result) | 914 | if (result) |
915 | return result; | 915 | return result; |
916 | 916 | ||
917 | result = sysfs_create_link(&tz->thermal_zone->device.kobj, | 917 | result = sysfs_create_link(&tz->thermal_zone->device.kobj, |
918 | &tz->device->dev.kobj, "device"); | 918 | &tz->device->dev.kobj, "device"); |
919 | if (result) | 919 | if (result) |
920 | return result; | 920 | return result; |
921 | 921 | ||
922 | status = acpi_attach_data(tz->device->handle, | 922 | status = acpi_attach_data(tz->device->handle, |
923 | acpi_bus_private_data_handler, | 923 | acpi_bus_private_data_handler, |
924 | tz->thermal_zone); | 924 | tz->thermal_zone); |
925 | if (ACPI_FAILURE(status)) { | 925 | if (ACPI_FAILURE(status)) { |
926 | printk(KERN_ERR PREFIX | 926 | printk(KERN_ERR PREFIX |
927 | "Error attaching device data\n"); | 927 | "Error attaching device data\n"); |
928 | return -ENODEV; | 928 | return -ENODEV; |
929 | } | 929 | } |
930 | 930 | ||
931 | tz->tz_enabled = 1; | 931 | tz->tz_enabled = 1; |
932 | 932 | ||
933 | dev_info(&tz->device->dev, "registered as thermal_zone%d\n", | 933 | dev_info(&tz->device->dev, "registered as thermal_zone%d\n", |
934 | tz->thermal_zone->id); | 934 | tz->thermal_zone->id); |
935 | return 0; | 935 | return 0; |
936 | } | 936 | } |
937 | 937 | ||
938 | static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) | 938 | static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) |
939 | { | 939 | { |
940 | sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); | 940 | sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); |
941 | sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); | 941 | sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); |
942 | thermal_zone_device_unregister(tz->thermal_zone); | 942 | thermal_zone_device_unregister(tz->thermal_zone); |
943 | tz->thermal_zone = NULL; | 943 | tz->thermal_zone = NULL; |
944 | acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler); | 944 | acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler); |
945 | } | 945 | } |
946 | 946 | ||
947 | 947 | ||
948 | /* -------------------------------------------------------------------------- | 948 | /* -------------------------------------------------------------------------- |
949 | Driver Interface | 949 | Driver Interface |
950 | -------------------------------------------------------------------------- */ | 950 | -------------------------------------------------------------------------- */ |
951 | 951 | ||
952 | static void acpi_thermal_notify(struct acpi_device *device, u32 event) | 952 | static void acpi_thermal_notify(struct acpi_device *device, u32 event) |
953 | { | 953 | { |
954 | struct acpi_thermal *tz = acpi_driver_data(device); | 954 | struct acpi_thermal *tz = acpi_driver_data(device); |
955 | 955 | ||
956 | 956 | ||
957 | if (!tz) | 957 | if (!tz) |
958 | return; | 958 | return; |
959 | 959 | ||
960 | switch (event) { | 960 | switch (event) { |
961 | case ACPI_THERMAL_NOTIFY_TEMPERATURE: | 961 | case ACPI_THERMAL_NOTIFY_TEMPERATURE: |
962 | acpi_thermal_check(tz); | 962 | acpi_thermal_check(tz); |
963 | break; | 963 | break; |
964 | case ACPI_THERMAL_NOTIFY_THRESHOLDS: | 964 | case ACPI_THERMAL_NOTIFY_THRESHOLDS: |
965 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); | 965 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); |
966 | acpi_thermal_check(tz); | 966 | acpi_thermal_check(tz); |
967 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 967 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
968 | dev_name(&device->dev), event, 0); | 968 | dev_name(&device->dev), event, 0); |
969 | break; | 969 | break; |
970 | case ACPI_THERMAL_NOTIFY_DEVICES: | 970 | case ACPI_THERMAL_NOTIFY_DEVICES: |
971 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); | 971 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); |
972 | acpi_thermal_check(tz); | 972 | acpi_thermal_check(tz); |
973 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 973 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
974 | dev_name(&device->dev), event, 0); | 974 | dev_name(&device->dev), event, 0); |
975 | break; | 975 | break; |
976 | default: | 976 | default: |
977 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 977 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
978 | "Unsupported event [0x%x]\n", event)); | 978 | "Unsupported event [0x%x]\n", event)); |
979 | break; | 979 | break; |
980 | } | 980 | } |
981 | } | 981 | } |
982 | 982 | ||
983 | /* | 983 | /* |
984 | * On some platforms, the AML code has dependency about | 984 | * On some platforms, the AML code has dependency about |
985 | * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx. | 985 | * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx. |
986 | * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after | 986 | * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after |
987 | * /_CRT/_HOT/_PSV/_ACx, or else system will be power off. | 987 | * /_CRT/_HOT/_PSV/_ACx, or else system will be power off. |
988 | * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0 | 988 | * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0 |
989 | * if _TMP has never been evaluated. | 989 | * if _TMP has never been evaluated. |
990 | * | 990 | * |
991 | * As this dependency is totally transparent to OS, evaluate | 991 | * As this dependency is totally transparent to OS, evaluate |
992 | * all of them once, in the order of _CRT/_HOT/_PSV/_ACx, | 992 | * all of them once, in the order of _CRT/_HOT/_PSV/_ACx, |
993 | * _TMP, before they are actually used. | 993 | * _TMP, before they are actually used. |
994 | */ | 994 | */ |
995 | static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) | 995 | static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) |
996 | { | 996 | { |
997 | acpi_handle handle = tz->device->handle; | 997 | acpi_handle handle = tz->device->handle; |
998 | unsigned long long value; | 998 | unsigned long long value; |
999 | int i; | 999 | int i; |
1000 | 1000 | ||
1001 | acpi_evaluate_integer(handle, "_CRT", NULL, &value); | 1001 | acpi_evaluate_integer(handle, "_CRT", NULL, &value); |
1002 | acpi_evaluate_integer(handle, "_HOT", NULL, &value); | 1002 | acpi_evaluate_integer(handle, "_HOT", NULL, &value); |
1003 | acpi_evaluate_integer(handle, "_PSV", NULL, &value); | 1003 | acpi_evaluate_integer(handle, "_PSV", NULL, &value); |
1004 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { | 1004 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
1005 | char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; | 1005 | char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; |
1006 | acpi_status status; | 1006 | acpi_status status; |
1007 | 1007 | ||
1008 | status = acpi_evaluate_integer(handle, name, NULL, &value); | 1008 | status = acpi_evaluate_integer(handle, name, NULL, &value); |
1009 | if (status == AE_NOT_FOUND) | 1009 | if (status == AE_NOT_FOUND) |
1010 | break; | 1010 | break; |
1011 | } | 1011 | } |
1012 | acpi_evaluate_integer(handle, "_TMP", NULL, &value); | 1012 | acpi_evaluate_integer(handle, "_TMP", NULL, &value); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | static int acpi_thermal_get_info(struct acpi_thermal *tz) | 1015 | static int acpi_thermal_get_info(struct acpi_thermal *tz) |
1016 | { | 1016 | { |
1017 | int result = 0; | 1017 | int result = 0; |
1018 | 1018 | ||
1019 | 1019 | ||
1020 | if (!tz) | 1020 | if (!tz) |
1021 | return -EINVAL; | 1021 | return -EINVAL; |
1022 | 1022 | ||
1023 | acpi_thermal_aml_dependency_fix(tz); | 1023 | acpi_thermal_aml_dependency_fix(tz); |
1024 | 1024 | ||
1025 | /* Get trip points [_CRT, _PSV, etc.] (required) */ | 1025 | /* Get trip points [_CRT, _PSV, etc.] (required) */ |
1026 | result = acpi_thermal_get_trip_points(tz); | 1026 | result = acpi_thermal_get_trip_points(tz); |
1027 | if (result) | 1027 | if (result) |
1028 | return result; | 1028 | return result; |
1029 | 1029 | ||
1030 | /* Get temperature [_TMP] (required) */ | 1030 | /* Get temperature [_TMP] (required) */ |
1031 | result = acpi_thermal_get_temperature(tz); | 1031 | result = acpi_thermal_get_temperature(tz); |
1032 | if (result) | 1032 | if (result) |
1033 | return result; | 1033 | return result; |
1034 | 1034 | ||
1035 | /* Set the cooling mode [_SCP] to active cooling (default) */ | 1035 | /* Set the cooling mode [_SCP] to active cooling (default) */ |
1036 | result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); | 1036 | result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); |
1037 | if (!result) | 1037 | if (!result) |
1038 | tz->flags.cooling_mode = 1; | 1038 | tz->flags.cooling_mode = 1; |
1039 | 1039 | ||
1040 | /* Get default polling frequency [_TZP] (optional) */ | 1040 | /* Get default polling frequency [_TZP] (optional) */ |
1041 | if (tzp) | 1041 | if (tzp) |
1042 | tz->polling_frequency = tzp; | 1042 | tz->polling_frequency = tzp; |
1043 | else | 1043 | else |
1044 | acpi_thermal_get_polling_frequency(tz); | 1044 | acpi_thermal_get_polling_frequency(tz); |
1045 | 1045 | ||
1046 | return 0; | 1046 | return 0; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | /* | 1049 | /* |
1050 | * The exact offset between Kelvin and degree Celsius is 273.15. However ACPI | 1050 | * The exact offset between Kelvin and degree Celsius is 273.15. However ACPI |
1051 | * handles temperature values with a single decimal place. As a consequence, | 1051 | * handles temperature values with a single decimal place. As a consequence, |
1052 | * some implementations use an offset of 273.1 and others use an offset of | 1052 | * some implementations use an offset of 273.1 and others use an offset of |
1053 | * 273.2. Try to find out which one is being used, to present the most | 1053 | * 273.2. Try to find out which one is being used, to present the most |
1054 | * accurate and visually appealing number. | 1054 | * accurate and visually appealing number. |
1055 | * | 1055 | * |
1056 | * The heuristic below should work for all ACPI thermal zones which have a | 1056 | * The heuristic below should work for all ACPI thermal zones which have a |
1057 | * critical trip point with a value being a multiple of 0.5 degree Celsius. | 1057 | * critical trip point with a value being a multiple of 0.5 degree Celsius. |
1058 | */ | 1058 | */ |
1059 | static void acpi_thermal_guess_offset(struct acpi_thermal *tz) | 1059 | static void acpi_thermal_guess_offset(struct acpi_thermal *tz) |
1060 | { | 1060 | { |
1061 | if (tz->trips.critical.flags.valid && | 1061 | if (tz->trips.critical.flags.valid && |
1062 | (tz->trips.critical.temperature % 5) == 1) | 1062 | (tz->trips.critical.temperature % 5) == 1) |
1063 | tz->kelvin_offset = 2731; | 1063 | tz->kelvin_offset = 2731; |
1064 | else | 1064 | else |
1065 | tz->kelvin_offset = 2732; | 1065 | tz->kelvin_offset = 2732; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | static int acpi_thermal_add(struct acpi_device *device) | 1068 | static int acpi_thermal_add(struct acpi_device *device) |
1069 | { | 1069 | { |
1070 | int result = 0; | 1070 | int result = 0; |
1071 | struct acpi_thermal *tz = NULL; | 1071 | struct acpi_thermal *tz = NULL; |
1072 | 1072 | ||
1073 | 1073 | ||
1074 | if (!device) | 1074 | if (!device) |
1075 | return -EINVAL; | 1075 | return -EINVAL; |
1076 | 1076 | ||
1077 | tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); | 1077 | tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); |
1078 | if (!tz) | 1078 | if (!tz) |
1079 | return -ENOMEM; | 1079 | return -ENOMEM; |
1080 | 1080 | ||
1081 | tz->device = device; | 1081 | tz->device = device; |
1082 | strcpy(tz->name, device->pnp.bus_id); | 1082 | strcpy(tz->name, device->pnp.bus_id); |
1083 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); | 1083 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); |
1084 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); | 1084 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); |
1085 | device->driver_data = tz; | 1085 | device->driver_data = tz; |
1086 | 1086 | ||
1087 | result = acpi_thermal_get_info(tz); | 1087 | result = acpi_thermal_get_info(tz); |
1088 | if (result) | 1088 | if (result) |
1089 | goto free_memory; | 1089 | goto free_memory; |
1090 | 1090 | ||
1091 | acpi_thermal_guess_offset(tz); | 1091 | acpi_thermal_guess_offset(tz); |
1092 | 1092 | ||
1093 | result = acpi_thermal_register_thermal_zone(tz); | 1093 | result = acpi_thermal_register_thermal_zone(tz); |
1094 | if (result) | 1094 | if (result) |
1095 | goto free_memory; | 1095 | goto free_memory; |
1096 | 1096 | ||
1097 | printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", | 1097 | printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", |
1098 | acpi_device_name(device), acpi_device_bid(device), | 1098 | acpi_device_name(device), acpi_device_bid(device), |
1099 | KELVIN_TO_CELSIUS(tz->temperature)); | 1099 | KELVIN_TO_CELSIUS(tz->temperature)); |
1100 | goto end; | 1100 | goto end; |
1101 | 1101 | ||
1102 | free_memory: | 1102 | free_memory: |
1103 | kfree(tz); | 1103 | kfree(tz); |
1104 | end: | 1104 | end: |
1105 | return result; | 1105 | return result; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | static int acpi_thermal_remove(struct acpi_device *device) | 1108 | static int acpi_thermal_remove(struct acpi_device *device) |
1109 | { | 1109 | { |
1110 | struct acpi_thermal *tz = NULL; | 1110 | struct acpi_thermal *tz = NULL; |
1111 | 1111 | ||
1112 | if (!device || !acpi_driver_data(device)) | 1112 | if (!device || !acpi_driver_data(device)) |
1113 | return -EINVAL; | 1113 | return -EINVAL; |
1114 | 1114 | ||
1115 | tz = acpi_driver_data(device); | 1115 | tz = acpi_driver_data(device); |
1116 | 1116 | ||
1117 | acpi_thermal_unregister_thermal_zone(tz); | 1117 | acpi_thermal_unregister_thermal_zone(tz); |
1118 | kfree(tz); | 1118 | kfree(tz); |
1119 | return 0; | 1119 | return 0; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | #ifdef CONFIG_PM_SLEEP | 1122 | #ifdef CONFIG_PM_SLEEP |
1123 | static int acpi_thermal_resume(struct device *dev) | 1123 | static int acpi_thermal_resume(struct device *dev) |
1124 | { | 1124 | { |
1125 | struct acpi_thermal *tz; | 1125 | struct acpi_thermal *tz; |
1126 | int i, j, power_state, result; | 1126 | int i, j, power_state, result; |
1127 | 1127 | ||
1128 | if (!dev) | 1128 | if (!dev) |
1129 | return -EINVAL; | 1129 | return -EINVAL; |
1130 | 1130 | ||
1131 | tz = acpi_driver_data(to_acpi_device(dev)); | 1131 | tz = acpi_driver_data(to_acpi_device(dev)); |
1132 | if (!tz) | 1132 | if (!tz) |
1133 | return -EINVAL; | 1133 | return -EINVAL; |
1134 | 1134 | ||
1135 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { | 1135 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
1136 | if (!(&tz->trips.active[i])) | 1136 | if (!(&tz->trips.active[i])) |
1137 | break; | 1137 | break; |
1138 | if (!tz->trips.active[i].flags.valid) | 1138 | if (!tz->trips.active[i].flags.valid) |
1139 | break; | 1139 | break; |
1140 | tz->trips.active[i].flags.enabled = 1; | 1140 | tz->trips.active[i].flags.enabled = 1; |
1141 | for (j = 0; j < tz->trips.active[i].devices.count; j++) { | 1141 | for (j = 0; j < tz->trips.active[i].devices.count; j++) { |
1142 | result = acpi_bus_update_power( | 1142 | result = acpi_bus_update_power( |
1143 | tz->trips.active[i].devices.handles[j], | 1143 | tz->trips.active[i].devices.handles[j], |
1144 | &power_state); | 1144 | &power_state); |
1145 | if (result || (power_state != ACPI_STATE_D0)) { | 1145 | if (result || (power_state != ACPI_STATE_D0)) { |
1146 | tz->trips.active[i].flags.enabled = 0; | 1146 | tz->trips.active[i].flags.enabled = 0; |
1147 | break; | 1147 | break; |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | tz->state.active |= tz->trips.active[i].flags.enabled; | 1150 | tz->state.active |= tz->trips.active[i].flags.enabled; |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | acpi_thermal_check(tz); | 1153 | acpi_thermal_check(tz); |
1154 | 1154 | ||
1155 | return AE_OK; | 1155 | return AE_OK; |
1156 | } | 1156 | } |
1157 | #endif | 1157 | #endif |
1158 | 1158 | ||
1159 | static int thermal_act(const struct dmi_system_id *d) { | 1159 | static int thermal_act(const struct dmi_system_id *d) { |
1160 | 1160 | ||
1161 | if (act == 0) { | 1161 | if (act == 0) { |
1162 | printk(KERN_NOTICE "ACPI: %s detected: " | 1162 | printk(KERN_NOTICE "ACPI: %s detected: " |
1163 | "disabling all active thermal trip points\n", d->ident); | 1163 | "disabling all active thermal trip points\n", d->ident); |
1164 | act = -1; | 1164 | act = -1; |
1165 | } | 1165 | } |
1166 | return 0; | 1166 | return 0; |
1167 | } | 1167 | } |
1168 | static int thermal_nocrt(const struct dmi_system_id *d) { | 1168 | static int thermal_nocrt(const struct dmi_system_id *d) { |
1169 | 1169 | ||
1170 | printk(KERN_NOTICE "ACPI: %s detected: " | 1170 | printk(KERN_NOTICE "ACPI: %s detected: " |
1171 | "disabling all critical thermal trip point actions.\n", d->ident); | 1171 | "disabling all critical thermal trip point actions.\n", d->ident); |
1172 | nocrt = 1; | 1172 | nocrt = 1; |
1173 | return 0; | 1173 | return 0; |
1174 | } | 1174 | } |
1175 | static int thermal_tzp(const struct dmi_system_id *d) { | 1175 | static int thermal_tzp(const struct dmi_system_id *d) { |
1176 | 1176 | ||
1177 | if (tzp == 0) { | 1177 | if (tzp == 0) { |
1178 | printk(KERN_NOTICE "ACPI: %s detected: " | 1178 | printk(KERN_NOTICE "ACPI: %s detected: " |
1179 | "enabling thermal zone polling\n", d->ident); | 1179 | "enabling thermal zone polling\n", d->ident); |
1180 | tzp = 300; /* 300 dS = 30 Seconds */ | 1180 | tzp = 300; /* 300 dS = 30 Seconds */ |
1181 | } | 1181 | } |
1182 | return 0; | 1182 | return 0; |
1183 | } | 1183 | } |
1184 | static int thermal_psv(const struct dmi_system_id *d) { | 1184 | static int thermal_psv(const struct dmi_system_id *d) { |
1185 | 1185 | ||
1186 | if (psv == 0) { | 1186 | if (psv == 0) { |
1187 | printk(KERN_NOTICE "ACPI: %s detected: " | 1187 | printk(KERN_NOTICE "ACPI: %s detected: " |
1188 | "disabling all passive thermal trip points\n", d->ident); | 1188 | "disabling all passive thermal trip points\n", d->ident); |
1189 | psv = -1; | 1189 | psv = -1; |
1190 | } | 1190 | } |
1191 | return 0; | 1191 | return 0; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | static struct dmi_system_id thermal_dmi_table[] __initdata = { | 1194 | static struct dmi_system_id thermal_dmi_table[] __initdata = { |
1195 | /* | 1195 | /* |
1196 | * Award BIOS on this AOpen makes thermal control almost worthless. | 1196 | * Award BIOS on this AOpen makes thermal control almost worthless. |
1197 | * http://bugzilla.kernel.org/show_bug.cgi?id=8842 | 1197 | * http://bugzilla.kernel.org/show_bug.cgi?id=8842 |
1198 | */ | 1198 | */ |
1199 | { | 1199 | { |
1200 | .callback = thermal_act, | 1200 | .callback = thermal_act, |
1201 | .ident = "AOpen i915GMm-HFS", | 1201 | .ident = "AOpen i915GMm-HFS", |
1202 | .matches = { | 1202 | .matches = { |
1203 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), | 1203 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), |
1204 | DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), | 1204 | DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), |
1205 | }, | 1205 | }, |
1206 | }, | 1206 | }, |
1207 | { | 1207 | { |
1208 | .callback = thermal_psv, | 1208 | .callback = thermal_psv, |
1209 | .ident = "AOpen i915GMm-HFS", | 1209 | .ident = "AOpen i915GMm-HFS", |
1210 | .matches = { | 1210 | .matches = { |
1211 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), | 1211 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), |
1212 | DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), | 1212 | DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), |
1213 | }, | 1213 | }, |
1214 | }, | 1214 | }, |
1215 | { | 1215 | { |
1216 | .callback = thermal_tzp, | 1216 | .callback = thermal_tzp, |
1217 | .ident = "AOpen i915GMm-HFS", | 1217 | .ident = "AOpen i915GMm-HFS", |
1218 | .matches = { | 1218 | .matches = { |
1219 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), | 1219 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), |
1220 | DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), | 1220 | DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), |
1221 | }, | 1221 | }, |
1222 | }, | 1222 | }, |
1223 | { | 1223 | { |
1224 | .callback = thermal_nocrt, | 1224 | .callback = thermal_nocrt, |
1225 | .ident = "Gigabyte GA-7ZX", | 1225 | .ident = "Gigabyte GA-7ZX", |
1226 | .matches = { | 1226 | .matches = { |
1227 | DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."), | 1227 | DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."), |
1228 | DMI_MATCH(DMI_BOARD_NAME, "7ZX"), | 1228 | DMI_MATCH(DMI_BOARD_NAME, "7ZX"), |
1229 | }, | 1229 | }, |
1230 | }, | 1230 | }, |
1231 | {} | 1231 | {} |
1232 | }; | 1232 | }; |
1233 | 1233 | ||
1234 | static int __init acpi_thermal_init(void) | 1234 | static int __init acpi_thermal_init(void) |
1235 | { | 1235 | { |
1236 | int result = 0; | 1236 | int result = 0; |
1237 | 1237 | ||
1238 | dmi_check_system(thermal_dmi_table); | 1238 | dmi_check_system(thermal_dmi_table); |
1239 | 1239 | ||
1240 | if (off) { | 1240 | if (off) { |
1241 | printk(KERN_NOTICE "ACPI: thermal control disabled\n"); | 1241 | printk(KERN_NOTICE "ACPI: thermal control disabled\n"); |
1242 | return -ENODEV; | 1242 | return -ENODEV; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | result = acpi_bus_register_driver(&acpi_thermal_driver); | 1245 | result = acpi_bus_register_driver(&acpi_thermal_driver); |
1246 | if (result < 0) | 1246 | if (result < 0) |
1247 | return -ENODEV; | 1247 | return -ENODEV; |
1248 | 1248 | ||
1249 | return 0; | 1249 | return 0; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | static void __exit acpi_thermal_exit(void) | 1252 | static void __exit acpi_thermal_exit(void) |
1253 | { | 1253 | { |
1254 | 1254 | ||
1255 | acpi_bus_unregister_driver(&acpi_thermal_driver); | 1255 | acpi_bus_unregister_driver(&acpi_thermal_driver); |
1256 | 1256 | ||
1257 | return; | 1257 | return; |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | module_init(acpi_thermal_init); | 1260 | module_init(acpi_thermal_init); |
1261 | module_exit(acpi_thermal_exit); | 1261 | module_exit(acpi_thermal_exit); |