thermal.c 32 KB

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