thermal.c 32 KB

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