thermal.c 32 KB

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