thermal.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  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 = create_workqueue("acpi_thermal_pm");
  1081. if (!acpi_thermal_pm_queue)
  1082. return -ENODEV;
  1083. result = acpi_bus_register_driver(&acpi_thermal_driver);
  1084. if (result < 0) {
  1085. destroy_workqueue(acpi_thermal_pm_queue);
  1086. return -ENODEV;
  1087. }
  1088. return 0;
  1089. }
  1090. static void __exit acpi_thermal_exit(void)
  1091. {
  1092. acpi_bus_unregister_driver(&acpi_thermal_driver);
  1093. destroy_workqueue(acpi_thermal_pm_queue);
  1094. return;
  1095. }
  1096. module_init(acpi_thermal_init);
  1097. module_exit(acpi_thermal_exit);