thermal.c 32 KB

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