thermal.c 32 KB

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