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