thermal.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  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);
  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", 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. if (!tz->tz_enabled) {
  466. pr_warn("thermal zone is disabled \n");
  467. return;
  468. }
  469. thermal_zone_device_update(tz->thermal_zone);
  470. }
  471. /* sys I/F for generic thermal sysfs support */
  472. #define KELVIN_TO_MILLICELSIUS(t, off) (((t) - (off)) * 100)
  473. static int thermal_get_temp(struct thermal_zone_device *thermal,
  474. unsigned long *temp)
  475. {
  476. struct acpi_thermal *tz = thermal->devdata;
  477. int result;
  478. if (!tz)
  479. return -EINVAL;
  480. result = acpi_thermal_get_temperature(tz);
  481. if (result)
  482. return result;
  483. *temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset);
  484. return 0;
  485. }
  486. static int thermal_get_mode(struct thermal_zone_device *thermal,
  487. enum thermal_device_mode *mode)
  488. {
  489. struct acpi_thermal *tz = thermal->devdata;
  490. if (!tz)
  491. return -EINVAL;
  492. *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED :
  493. THERMAL_DEVICE_DISABLED;
  494. return 0;
  495. }
  496. static int thermal_set_mode(struct thermal_zone_device *thermal,
  497. enum thermal_device_mode mode)
  498. {
  499. struct acpi_thermal *tz = thermal->devdata;
  500. int enable;
  501. if (!tz)
  502. return -EINVAL;
  503. /*
  504. * enable/disable thermal management from ACPI thermal driver
  505. */
  506. if (mode == THERMAL_DEVICE_ENABLED)
  507. enable = 1;
  508. else if (mode == THERMAL_DEVICE_DISABLED)
  509. enable = 0;
  510. else
  511. return -EINVAL;
  512. if (enable != tz->tz_enabled) {
  513. tz->tz_enabled = enable;
  514. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  515. "%s kernel ACPI thermal control\n",
  516. tz->tz_enabled ? "Enable" : "Disable"));
  517. acpi_thermal_check(tz);
  518. }
  519. return 0;
  520. }
  521. static int thermal_get_trip_type(struct thermal_zone_device *thermal,
  522. int trip, enum thermal_trip_type *type)
  523. {
  524. struct acpi_thermal *tz = thermal->devdata;
  525. int i;
  526. if (!tz || trip < 0)
  527. return -EINVAL;
  528. if (tz->trips.critical.flags.valid) {
  529. if (!trip) {
  530. *type = THERMAL_TRIP_CRITICAL;
  531. return 0;
  532. }
  533. trip--;
  534. }
  535. if (tz->trips.hot.flags.valid) {
  536. if (!trip) {
  537. *type = THERMAL_TRIP_HOT;
  538. return 0;
  539. }
  540. trip--;
  541. }
  542. if (tz->trips.passive.flags.valid) {
  543. if (!trip) {
  544. *type = THERMAL_TRIP_PASSIVE;
  545. return 0;
  546. }
  547. trip--;
  548. }
  549. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  550. tz->trips.active[i].flags.valid; i++) {
  551. if (!trip) {
  552. *type = THERMAL_TRIP_ACTIVE;
  553. return 0;
  554. }
  555. trip--;
  556. }
  557. return -EINVAL;
  558. }
  559. static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
  560. int trip, unsigned long *temp)
  561. {
  562. struct acpi_thermal *tz = thermal->devdata;
  563. int i;
  564. if (!tz || trip < 0)
  565. return -EINVAL;
  566. if (tz->trips.critical.flags.valid) {
  567. if (!trip) {
  568. *temp = KELVIN_TO_MILLICELSIUS(
  569. tz->trips.critical.temperature,
  570. tz->kelvin_offset);
  571. return 0;
  572. }
  573. trip--;
  574. }
  575. if (tz->trips.hot.flags.valid) {
  576. if (!trip) {
  577. *temp = KELVIN_TO_MILLICELSIUS(
  578. tz->trips.hot.temperature,
  579. tz->kelvin_offset);
  580. return 0;
  581. }
  582. trip--;
  583. }
  584. if (tz->trips.passive.flags.valid) {
  585. if (!trip) {
  586. *temp = KELVIN_TO_MILLICELSIUS(
  587. tz->trips.passive.temperature,
  588. tz->kelvin_offset);
  589. return 0;
  590. }
  591. trip--;
  592. }
  593. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  594. tz->trips.active[i].flags.valid; i++) {
  595. if (!trip) {
  596. *temp = KELVIN_TO_MILLICELSIUS(
  597. tz->trips.active[i].temperature,
  598. tz->kelvin_offset);
  599. return 0;
  600. }
  601. trip--;
  602. }
  603. return -EINVAL;
  604. }
  605. static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
  606. unsigned long *temperature) {
  607. struct acpi_thermal *tz = thermal->devdata;
  608. if (tz->trips.critical.flags.valid) {
  609. *temperature = KELVIN_TO_MILLICELSIUS(
  610. tz->trips.critical.temperature,
  611. tz->kelvin_offset);
  612. return 0;
  613. } else
  614. return -EINVAL;
  615. }
  616. static int thermal_get_trend(struct thermal_zone_device *thermal,
  617. int trip, enum thermal_trend *trend)
  618. {
  619. struct acpi_thermal *tz = thermal->devdata;
  620. enum thermal_trip_type type;
  621. int i;
  622. if (thermal_get_trip_type(thermal, trip, &type))
  623. return -EINVAL;
  624. if (type == THERMAL_TRIP_ACTIVE) {
  625. /* aggressive active cooling */
  626. *trend = THERMAL_TREND_RAISING;
  627. return 0;
  628. }
  629. /*
  630. * tz->temperature has already been updated by generic thermal layer,
  631. * before this callback being invoked
  632. */
  633. i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature))
  634. + (tz->trips.passive.tc2
  635. * (tz->temperature - tz->trips.passive.temperature));
  636. if (i > 0)
  637. *trend = THERMAL_TREND_RAISING;
  638. else if (i < 0)
  639. *trend = THERMAL_TREND_DROPPING;
  640. else
  641. *trend = THERMAL_TREND_STABLE;
  642. return 0;
  643. }
  644. static int thermal_notify(struct thermal_zone_device *thermal, int trip,
  645. enum thermal_trip_type trip_type)
  646. {
  647. u8 type = 0;
  648. struct acpi_thermal *tz = thermal->devdata;
  649. if (trip_type == THERMAL_TRIP_CRITICAL)
  650. type = ACPI_THERMAL_NOTIFY_CRITICAL;
  651. else if (trip_type == THERMAL_TRIP_HOT)
  652. type = ACPI_THERMAL_NOTIFY_HOT;
  653. else
  654. return 0;
  655. acpi_bus_generate_proc_event(tz->device, type, 1);
  656. acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
  657. dev_name(&tz->device->dev), type, 1);
  658. if (trip_type == THERMAL_TRIP_CRITICAL && nocrt)
  659. return 1;
  660. return 0;
  661. }
  662. static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
  663. struct thermal_cooling_device *cdev,
  664. bool bind)
  665. {
  666. struct acpi_device *device = cdev->devdata;
  667. struct acpi_thermal *tz = thermal->devdata;
  668. struct acpi_device *dev;
  669. acpi_status status;
  670. acpi_handle handle;
  671. int i;
  672. int j;
  673. int trip = -1;
  674. int result = 0;
  675. if (tz->trips.critical.flags.valid)
  676. trip++;
  677. if (tz->trips.hot.flags.valid)
  678. trip++;
  679. if (tz->trips.passive.flags.valid) {
  680. trip++;
  681. for (i = 0; i < tz->trips.passive.devices.count;
  682. i++) {
  683. handle = tz->trips.passive.devices.handles[i];
  684. status = acpi_bus_get_device(handle, &dev);
  685. if (ACPI_FAILURE(status) || dev != device)
  686. continue;
  687. if (bind)
  688. result =
  689. thermal_zone_bind_cooling_device
  690. (thermal, trip, cdev,
  691. THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
  692. else
  693. result =
  694. thermal_zone_unbind_cooling_device
  695. (thermal, trip, cdev);
  696. if (result)
  697. goto failed;
  698. }
  699. }
  700. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  701. if (!tz->trips.active[i].flags.valid)
  702. break;
  703. trip++;
  704. for (j = 0;
  705. j < tz->trips.active[i].devices.count;
  706. j++) {
  707. handle = tz->trips.active[i].devices.handles[j];
  708. status = acpi_bus_get_device(handle, &dev);
  709. if (ACPI_FAILURE(status) || dev != device)
  710. continue;
  711. if (bind)
  712. result = thermal_zone_bind_cooling_device
  713. (thermal, trip, cdev,
  714. THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
  715. else
  716. result = thermal_zone_unbind_cooling_device
  717. (thermal, trip, cdev);
  718. if (result)
  719. goto failed;
  720. }
  721. }
  722. for (i = 0; i < tz->devices.count; i++) {
  723. handle = tz->devices.handles[i];
  724. status = acpi_bus_get_device(handle, &dev);
  725. if (ACPI_SUCCESS(status) && (dev == device)) {
  726. if (bind)
  727. result = thermal_zone_bind_cooling_device
  728. (thermal, -1, cdev,
  729. THERMAL_NO_LIMIT,
  730. THERMAL_NO_LIMIT);
  731. else
  732. result = thermal_zone_unbind_cooling_device
  733. (thermal, -1, cdev);
  734. if (result)
  735. goto failed;
  736. }
  737. }
  738. failed:
  739. return result;
  740. }
  741. static int
  742. acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
  743. struct thermal_cooling_device *cdev)
  744. {
  745. return acpi_thermal_cooling_device_cb(thermal, cdev, true);
  746. }
  747. static int
  748. acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
  749. struct thermal_cooling_device *cdev)
  750. {
  751. return acpi_thermal_cooling_device_cb(thermal, cdev, false);
  752. }
  753. static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
  754. .bind = acpi_thermal_bind_cooling_device,
  755. .unbind = acpi_thermal_unbind_cooling_device,
  756. .get_temp = thermal_get_temp,
  757. .get_mode = thermal_get_mode,
  758. .set_mode = thermal_set_mode,
  759. .get_trip_type = thermal_get_trip_type,
  760. .get_trip_temp = thermal_get_trip_temp,
  761. .get_crit_temp = thermal_get_crit_temp,
  762. .get_trend = thermal_get_trend,
  763. .notify = thermal_notify,
  764. };
  765. static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
  766. {
  767. int trips = 0;
  768. int result;
  769. acpi_status status;
  770. int i;
  771. if (tz->trips.critical.flags.valid)
  772. trips++;
  773. if (tz->trips.hot.flags.valid)
  774. trips++;
  775. if (tz->trips.passive.flags.valid)
  776. trips++;
  777. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  778. tz->trips.active[i].flags.valid; i++, trips++);
  779. if (tz->trips.passive.flags.valid)
  780. tz->thermal_zone =
  781. thermal_zone_device_register("acpitz", trips, 0, tz,
  782. &acpi_thermal_zone_ops, NULL,
  783. tz->trips.passive.tsp*100,
  784. tz->polling_frequency*100);
  785. else
  786. tz->thermal_zone =
  787. thermal_zone_device_register("acpitz", trips, 0, tz,
  788. &acpi_thermal_zone_ops, NULL,
  789. 0, tz->polling_frequency*100);
  790. if (IS_ERR(tz->thermal_zone))
  791. return -ENODEV;
  792. result = sysfs_create_link(&tz->device->dev.kobj,
  793. &tz->thermal_zone->device.kobj, "thermal_zone");
  794. if (result)
  795. return result;
  796. result = sysfs_create_link(&tz->thermal_zone->device.kobj,
  797. &tz->device->dev.kobj, "device");
  798. if (result)
  799. return result;
  800. status = acpi_attach_data(tz->device->handle,
  801. acpi_bus_private_data_handler,
  802. tz->thermal_zone);
  803. if (ACPI_FAILURE(status)) {
  804. printk(KERN_ERR PREFIX
  805. "Error attaching device data\n");
  806. return -ENODEV;
  807. }
  808. tz->tz_enabled = 1;
  809. dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
  810. tz->thermal_zone->id);
  811. return 0;
  812. }
  813. static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
  814. {
  815. sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
  816. sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
  817. thermal_zone_device_unregister(tz->thermal_zone);
  818. tz->thermal_zone = NULL;
  819. acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler);
  820. }
  821. /* --------------------------------------------------------------------------
  822. Driver Interface
  823. -------------------------------------------------------------------------- */
  824. static void acpi_thermal_notify(struct acpi_device *device, u32 event)
  825. {
  826. struct acpi_thermal *tz = acpi_driver_data(device);
  827. if (!tz)
  828. return;
  829. switch (event) {
  830. case ACPI_THERMAL_NOTIFY_TEMPERATURE:
  831. acpi_thermal_check(tz);
  832. break;
  833. case ACPI_THERMAL_NOTIFY_THRESHOLDS:
  834. acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
  835. acpi_thermal_check(tz);
  836. acpi_bus_generate_proc_event(device, event, 0);
  837. acpi_bus_generate_netlink_event(device->pnp.device_class,
  838. dev_name(&device->dev), event, 0);
  839. break;
  840. case ACPI_THERMAL_NOTIFY_DEVICES:
  841. acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
  842. acpi_thermal_check(tz);
  843. acpi_bus_generate_proc_event(device, event, 0);
  844. acpi_bus_generate_netlink_event(device->pnp.device_class,
  845. dev_name(&device->dev), event, 0);
  846. break;
  847. default:
  848. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  849. "Unsupported event [0x%x]\n", event));
  850. break;
  851. }
  852. }
  853. /*
  854. * On some platforms, the AML code has dependency about
  855. * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx.
  856. * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after
  857. * /_CRT/_HOT/_PSV/_ACx, or else system will be power off.
  858. * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0
  859. * if _TMP has never been evaluated.
  860. *
  861. * As this dependency is totally transparent to OS, evaluate
  862. * all of them once, in the order of _CRT/_HOT/_PSV/_ACx,
  863. * _TMP, before they are actually used.
  864. */
  865. static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz)
  866. {
  867. acpi_handle handle = tz->device->handle;
  868. unsigned long long value;
  869. int i;
  870. acpi_evaluate_integer(handle, "_CRT", NULL, &value);
  871. acpi_evaluate_integer(handle, "_HOT", NULL, &value);
  872. acpi_evaluate_integer(handle, "_PSV", NULL, &value);
  873. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  874. char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
  875. acpi_status status;
  876. status = acpi_evaluate_integer(handle, name, NULL, &value);
  877. if (status == AE_NOT_FOUND)
  878. break;
  879. }
  880. acpi_evaluate_integer(handle, "_TMP", NULL, &value);
  881. }
  882. static int acpi_thermal_get_info(struct acpi_thermal *tz)
  883. {
  884. int result = 0;
  885. if (!tz)
  886. return -EINVAL;
  887. acpi_thermal_aml_dependency_fix(tz);
  888. /* Get trip points [_CRT, _PSV, etc.] (required) */
  889. result = acpi_thermal_get_trip_points(tz);
  890. if (result)
  891. return result;
  892. /* Get temperature [_TMP] (required) */
  893. result = acpi_thermal_get_temperature(tz);
  894. if (result)
  895. return result;
  896. /* Set the cooling mode [_SCP] to active cooling (default) */
  897. result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
  898. if (!result)
  899. tz->flags.cooling_mode = 1;
  900. /* Get default polling frequency [_TZP] (optional) */
  901. if (tzp)
  902. tz->polling_frequency = tzp;
  903. else
  904. acpi_thermal_get_polling_frequency(tz);
  905. return 0;
  906. }
  907. /*
  908. * The exact offset between Kelvin and degree Celsius is 273.15. However ACPI
  909. * handles temperature values with a single decimal place. As a consequence,
  910. * some implementations use an offset of 273.1 and others use an offset of
  911. * 273.2. Try to find out which one is being used, to present the most
  912. * accurate and visually appealing number.
  913. *
  914. * The heuristic below should work for all ACPI thermal zones which have a
  915. * critical trip point with a value being a multiple of 0.5 degree Celsius.
  916. */
  917. static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
  918. {
  919. if (tz->trips.critical.flags.valid &&
  920. (tz->trips.critical.temperature % 5) == 1)
  921. tz->kelvin_offset = 2731;
  922. else
  923. tz->kelvin_offset = 2732;
  924. }
  925. static int acpi_thermal_add(struct acpi_device *device)
  926. {
  927. int result = 0;
  928. struct acpi_thermal *tz = NULL;
  929. if (!device)
  930. return -EINVAL;
  931. tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
  932. if (!tz)
  933. return -ENOMEM;
  934. tz->device = device;
  935. strcpy(tz->name, device->pnp.bus_id);
  936. strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
  937. strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
  938. device->driver_data = tz;
  939. mutex_init(&tz->lock);
  940. result = acpi_thermal_get_info(tz);
  941. if (result)
  942. goto free_memory;
  943. acpi_thermal_guess_offset(tz);
  944. result = acpi_thermal_register_thermal_zone(tz);
  945. if (result)
  946. goto free_memory;
  947. printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
  948. acpi_device_name(device), acpi_device_bid(device),
  949. KELVIN_TO_CELSIUS(tz->temperature));
  950. goto end;
  951. free_memory:
  952. kfree(tz);
  953. end:
  954. return result;
  955. }
  956. static int acpi_thermal_remove(struct acpi_device *device)
  957. {
  958. struct acpi_thermal *tz = NULL;
  959. if (!device || !acpi_driver_data(device))
  960. return -EINVAL;
  961. tz = acpi_driver_data(device);
  962. acpi_thermal_unregister_thermal_zone(tz);
  963. mutex_destroy(&tz->lock);
  964. kfree(tz);
  965. return 0;
  966. }
  967. #ifdef CONFIG_PM_SLEEP
  968. static int acpi_thermal_resume(struct device *dev)
  969. {
  970. struct acpi_thermal *tz;
  971. int i, j, power_state, result;
  972. if (!dev)
  973. return -EINVAL;
  974. tz = acpi_driver_data(to_acpi_device(dev));
  975. if (!tz)
  976. return -EINVAL;
  977. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  978. if (!(&tz->trips.active[i]))
  979. break;
  980. if (!tz->trips.active[i].flags.valid)
  981. break;
  982. tz->trips.active[i].flags.enabled = 1;
  983. for (j = 0; j < tz->trips.active[i].devices.count; j++) {
  984. result = acpi_bus_update_power(
  985. tz->trips.active[i].devices.handles[j],
  986. &power_state);
  987. if (result || (power_state != ACPI_STATE_D0)) {
  988. tz->trips.active[i].flags.enabled = 0;
  989. break;
  990. }
  991. }
  992. tz->state.active |= tz->trips.active[i].flags.enabled;
  993. }
  994. acpi_thermal_check(tz);
  995. return AE_OK;
  996. }
  997. #endif
  998. static int thermal_act(const struct dmi_system_id *d) {
  999. if (act == 0) {
  1000. printk(KERN_NOTICE "ACPI: %s detected: "
  1001. "disabling all active thermal trip points\n", d->ident);
  1002. act = -1;
  1003. }
  1004. return 0;
  1005. }
  1006. static int thermal_nocrt(const struct dmi_system_id *d) {
  1007. printk(KERN_NOTICE "ACPI: %s detected: "
  1008. "disabling all critical thermal trip point actions.\n", d->ident);
  1009. nocrt = 1;
  1010. return 0;
  1011. }
  1012. static int thermal_tzp(const struct dmi_system_id *d) {
  1013. if (tzp == 0) {
  1014. printk(KERN_NOTICE "ACPI: %s detected: "
  1015. "enabling thermal zone polling\n", d->ident);
  1016. tzp = 300; /* 300 dS = 30 Seconds */
  1017. }
  1018. return 0;
  1019. }
  1020. static int thermal_psv(const struct dmi_system_id *d) {
  1021. if (psv == 0) {
  1022. printk(KERN_NOTICE "ACPI: %s detected: "
  1023. "disabling all passive thermal trip points\n", d->ident);
  1024. psv = -1;
  1025. }
  1026. return 0;
  1027. }
  1028. static struct dmi_system_id thermal_dmi_table[] __initdata = {
  1029. /*
  1030. * Award BIOS on this AOpen makes thermal control almost worthless.
  1031. * http://bugzilla.kernel.org/show_bug.cgi?id=8842
  1032. */
  1033. {
  1034. .callback = thermal_act,
  1035. .ident = "AOpen i915GMm-HFS",
  1036. .matches = {
  1037. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1038. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1039. },
  1040. },
  1041. {
  1042. .callback = thermal_psv,
  1043. .ident = "AOpen i915GMm-HFS",
  1044. .matches = {
  1045. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1046. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1047. },
  1048. },
  1049. {
  1050. .callback = thermal_tzp,
  1051. .ident = "AOpen i915GMm-HFS",
  1052. .matches = {
  1053. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1054. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1055. },
  1056. },
  1057. {
  1058. .callback = thermal_nocrt,
  1059. .ident = "Gigabyte GA-7ZX",
  1060. .matches = {
  1061. DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
  1062. DMI_MATCH(DMI_BOARD_NAME, "7ZX"),
  1063. },
  1064. },
  1065. {}
  1066. };
  1067. static int __init acpi_thermal_init(void)
  1068. {
  1069. int result = 0;
  1070. dmi_check_system(thermal_dmi_table);
  1071. if (off) {
  1072. printk(KERN_NOTICE "ACPI: thermal control disabled\n");
  1073. return -ENODEV;
  1074. }
  1075. result = acpi_bus_register_driver(&acpi_thermal_driver);
  1076. if (result < 0)
  1077. return -ENODEV;
  1078. return 0;
  1079. }
  1080. static void __exit acpi_thermal_exit(void)
  1081. {
  1082. acpi_bus_unregister_driver(&acpi_thermal_driver);
  1083. return;
  1084. }
  1085. module_init(acpi_thermal_init);
  1086. module_exit(acpi_thermal_exit);