thermal.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  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 <linux/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. struct mutex thermal_check_lock;
  166. refcount_t thermal_check_count;
  167. };
  168. /* --------------------------------------------------------------------------
  169. Thermal Zone Management
  170. -------------------------------------------------------------------------- */
  171. static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
  172. {
  173. acpi_status status = AE_OK;
  174. unsigned long long tmp;
  175. if (!tz)
  176. return -EINVAL;
  177. tz->last_temperature = tz->temperature;
  178. status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp);
  179. if (ACPI_FAILURE(status))
  180. return -ENODEV;
  181. tz->temperature = tmp;
  182. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
  183. tz->temperature));
  184. return 0;
  185. }
  186. static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
  187. {
  188. acpi_status status = AE_OK;
  189. unsigned long long tmp;
  190. if (!tz)
  191. return -EINVAL;
  192. status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp);
  193. if (ACPI_FAILURE(status))
  194. return -ENODEV;
  195. tz->polling_frequency = tmp;
  196. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
  197. tz->polling_frequency));
  198. return 0;
  199. }
  200. static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
  201. {
  202. if (!tz)
  203. return -EINVAL;
  204. if (!acpi_has_method(tz->device->handle, "_SCP")) {
  205. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
  206. return -ENODEV;
  207. } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle,
  208. "_SCP", mode))) {
  209. return -ENODEV;
  210. }
  211. return 0;
  212. }
  213. #define ACPI_TRIPS_CRITICAL 0x01
  214. #define ACPI_TRIPS_HOT 0x02
  215. #define ACPI_TRIPS_PASSIVE 0x04
  216. #define ACPI_TRIPS_ACTIVE 0x08
  217. #define ACPI_TRIPS_DEVICES 0x10
  218. #define ACPI_TRIPS_REFRESH_THRESHOLDS (ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE)
  219. #define ACPI_TRIPS_REFRESH_DEVICES ACPI_TRIPS_DEVICES
  220. #define ACPI_TRIPS_INIT (ACPI_TRIPS_CRITICAL | ACPI_TRIPS_HOT | \
  221. ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE | \
  222. ACPI_TRIPS_DEVICES)
  223. /*
  224. * This exception is thrown out in two cases:
  225. * 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
  226. * when re-evaluating the AML code.
  227. * 2.TODO: Devices listed in _PSL, _ALx, _TZD may change.
  228. * We need to re-bind the cooling devices of a thermal zone when this occurs.
  229. */
  230. #define ACPI_THERMAL_TRIPS_EXCEPTION(flags, str) \
  231. do { \
  232. if (flags != ACPI_TRIPS_INIT) \
  233. ACPI_EXCEPTION((AE_INFO, AE_ERROR, \
  234. "ACPI thermal trip point %s changed\n" \
  235. "Please send acpidump to linux-acpi@vger.kernel.org", str)); \
  236. } while (0)
  237. static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
  238. {
  239. acpi_status status = AE_OK;
  240. unsigned long long tmp;
  241. struct acpi_handle_list devices;
  242. int valid = 0;
  243. int i;
  244. /* Critical Shutdown */
  245. if (flag & ACPI_TRIPS_CRITICAL) {
  246. status = acpi_evaluate_integer(tz->device->handle,
  247. "_CRT", NULL, &tmp);
  248. tz->trips.critical.temperature = tmp;
  249. /*
  250. * Treat freezing temperatures as invalid as well; some
  251. * BIOSes return really low values and cause reboots at startup.
  252. * Below zero (Celsius) values clearly aren't right for sure..
  253. * ... so lets discard those as invalid.
  254. */
  255. if (ACPI_FAILURE(status)) {
  256. tz->trips.critical.flags.valid = 0;
  257. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  258. "No critical threshold\n"));
  259. } else if (tmp <= 2732) {
  260. pr_warn(FW_BUG "Invalid critical threshold (%llu)\n",
  261. tmp);
  262. tz->trips.critical.flags.valid = 0;
  263. } else {
  264. tz->trips.critical.flags.valid = 1;
  265. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  266. "Found critical threshold [%lu]\n",
  267. tz->trips.critical.temperature));
  268. }
  269. if (tz->trips.critical.flags.valid == 1) {
  270. if (crt == -1) {
  271. tz->trips.critical.flags.valid = 0;
  272. } else if (crt > 0) {
  273. unsigned long crt_k = CELSIUS_TO_DECI_KELVIN(crt);
  274. /*
  275. * Allow override critical threshold
  276. */
  277. if (crt_k > tz->trips.critical.temperature)
  278. pr_warn(PREFIX "Critical threshold %d C\n",
  279. crt);
  280. tz->trips.critical.temperature = crt_k;
  281. }
  282. }
  283. }
  284. /* Critical Sleep (optional) */
  285. if (flag & ACPI_TRIPS_HOT) {
  286. status = acpi_evaluate_integer(tz->device->handle,
  287. "_HOT", NULL, &tmp);
  288. if (ACPI_FAILURE(status)) {
  289. tz->trips.hot.flags.valid = 0;
  290. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  291. "No hot threshold\n"));
  292. } else {
  293. tz->trips.hot.temperature = tmp;
  294. tz->trips.hot.flags.valid = 1;
  295. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  296. "Found hot threshold [%lu]\n",
  297. tz->trips.hot.temperature));
  298. }
  299. }
  300. /* Passive (optional) */
  301. if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) ||
  302. (flag == ACPI_TRIPS_INIT)) {
  303. valid = tz->trips.passive.flags.valid;
  304. if (psv == -1) {
  305. status = AE_SUPPORT;
  306. } else if (psv > 0) {
  307. tmp = CELSIUS_TO_DECI_KELVIN(psv);
  308. status = AE_OK;
  309. } else {
  310. status = acpi_evaluate_integer(tz->device->handle,
  311. "_PSV", NULL, &tmp);
  312. }
  313. if (ACPI_FAILURE(status))
  314. tz->trips.passive.flags.valid = 0;
  315. else {
  316. tz->trips.passive.temperature = tmp;
  317. tz->trips.passive.flags.valid = 1;
  318. if (flag == ACPI_TRIPS_INIT) {
  319. status = acpi_evaluate_integer(
  320. tz->device->handle, "_TC1",
  321. NULL, &tmp);
  322. if (ACPI_FAILURE(status))
  323. tz->trips.passive.flags.valid = 0;
  324. else
  325. tz->trips.passive.tc1 = tmp;
  326. status = acpi_evaluate_integer(
  327. tz->device->handle, "_TC2",
  328. NULL, &tmp);
  329. if (ACPI_FAILURE(status))
  330. tz->trips.passive.flags.valid = 0;
  331. else
  332. tz->trips.passive.tc2 = tmp;
  333. status = acpi_evaluate_integer(
  334. tz->device->handle, "_TSP",
  335. NULL, &tmp);
  336. if (ACPI_FAILURE(status))
  337. tz->trips.passive.flags.valid = 0;
  338. else
  339. tz->trips.passive.tsp = tmp;
  340. }
  341. }
  342. }
  343. if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) {
  344. memset(&devices, 0, sizeof(struct acpi_handle_list));
  345. status = acpi_evaluate_reference(tz->device->handle, "_PSL",
  346. NULL, &devices);
  347. if (ACPI_FAILURE(status)) {
  348. pr_warn(PREFIX "Invalid passive threshold\n");
  349. tz->trips.passive.flags.valid = 0;
  350. }
  351. else
  352. tz->trips.passive.flags.valid = 1;
  353. if (memcmp(&tz->trips.passive.devices, &devices,
  354. sizeof(struct acpi_handle_list))) {
  355. memcpy(&tz->trips.passive.devices, &devices,
  356. sizeof(struct acpi_handle_list));
  357. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
  358. }
  359. }
  360. if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) {
  361. if (valid != tz->trips.passive.flags.valid)
  362. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state");
  363. }
  364. /* Active (optional) */
  365. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  366. char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
  367. valid = tz->trips.active[i].flags.valid;
  368. if (act == -1)
  369. break; /* disable all active trip points */
  370. if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) &&
  371. tz->trips.active[i].flags.valid)) {
  372. status = acpi_evaluate_integer(tz->device->handle,
  373. name, NULL, &tmp);
  374. if (ACPI_FAILURE(status)) {
  375. tz->trips.active[i].flags.valid = 0;
  376. if (i == 0)
  377. break;
  378. if (act <= 0)
  379. break;
  380. if (i == 1)
  381. tz->trips.active[0].temperature =
  382. CELSIUS_TO_DECI_KELVIN(act);
  383. else
  384. /*
  385. * Don't allow override higher than
  386. * the next higher trip point
  387. */
  388. tz->trips.active[i - 1].temperature =
  389. (tz->trips.active[i - 2].temperature <
  390. CELSIUS_TO_DECI_KELVIN(act) ?
  391. tz->trips.active[i - 2].temperature :
  392. CELSIUS_TO_DECI_KELVIN(act));
  393. break;
  394. } else {
  395. tz->trips.active[i].temperature = tmp;
  396. tz->trips.active[i].flags.valid = 1;
  397. }
  398. }
  399. name[2] = 'L';
  400. if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) {
  401. memset(&devices, 0, sizeof(struct acpi_handle_list));
  402. status = acpi_evaluate_reference(tz->device->handle,
  403. name, NULL, &devices);
  404. if (ACPI_FAILURE(status)) {
  405. pr_warn(PREFIX "Invalid active%d threshold\n",
  406. i);
  407. tz->trips.active[i].flags.valid = 0;
  408. }
  409. else
  410. tz->trips.active[i].flags.valid = 1;
  411. if (memcmp(&tz->trips.active[i].devices, &devices,
  412. sizeof(struct acpi_handle_list))) {
  413. memcpy(&tz->trips.active[i].devices, &devices,
  414. sizeof(struct acpi_handle_list));
  415. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
  416. }
  417. }
  418. if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES))
  419. if (valid != tz->trips.active[i].flags.valid)
  420. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state");
  421. if (!tz->trips.active[i].flags.valid)
  422. break;
  423. }
  424. if ((flag & ACPI_TRIPS_DEVICES)
  425. && acpi_has_method(tz->device->handle, "_TZD")) {
  426. memset(&devices, 0, sizeof(devices));
  427. status = acpi_evaluate_reference(tz->device->handle, "_TZD",
  428. NULL, &devices);
  429. if (ACPI_SUCCESS(status)
  430. && memcmp(&tz->devices, &devices, sizeof(devices))) {
  431. tz->devices = devices;
  432. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
  433. }
  434. }
  435. return 0;
  436. }
  437. static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
  438. {
  439. int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
  440. if (ret)
  441. return ret;
  442. valid = tz->trips.critical.flags.valid |
  443. tz->trips.hot.flags.valid |
  444. tz->trips.passive.flags.valid;
  445. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
  446. valid |= tz->trips.active[i].flags.valid;
  447. if (!valid) {
  448. pr_warn(FW_BUG "No valid trip found\n");
  449. return -ENODEV;
  450. }
  451. return 0;
  452. }
  453. /* sys I/F for generic thermal sysfs support */
  454. static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
  455. {
  456. struct acpi_thermal *tz = thermal->devdata;
  457. int result;
  458. if (!tz)
  459. return -EINVAL;
  460. result = acpi_thermal_get_temperature(tz);
  461. if (result)
  462. return result;
  463. *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(tz->temperature,
  464. tz->kelvin_offset);
  465. return 0;
  466. }
  467. static int thermal_get_mode(struct thermal_zone_device *thermal,
  468. enum thermal_device_mode *mode)
  469. {
  470. struct acpi_thermal *tz = thermal->devdata;
  471. if (!tz)
  472. return -EINVAL;
  473. *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED :
  474. THERMAL_DEVICE_DISABLED;
  475. return 0;
  476. }
  477. static void acpi_thermal_check_fn(struct work_struct *work);
  478. static int thermal_set_mode(struct thermal_zone_device *thermal,
  479. enum thermal_device_mode mode)
  480. {
  481. struct acpi_thermal *tz = thermal->devdata;
  482. int enable;
  483. if (!tz)
  484. return -EINVAL;
  485. /*
  486. * enable/disable thermal management from ACPI thermal driver
  487. */
  488. if (mode == THERMAL_DEVICE_ENABLED)
  489. enable = 1;
  490. else if (mode == THERMAL_DEVICE_DISABLED) {
  491. enable = 0;
  492. pr_warn("thermal zone will be disabled\n");
  493. } else
  494. return -EINVAL;
  495. if (enable != tz->tz_enabled) {
  496. tz->tz_enabled = enable;
  497. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  498. "%s kernel ACPI thermal control\n",
  499. tz->tz_enabled ? "Enable" : "Disable"));
  500. acpi_thermal_check_fn(&tz->thermal_check_work);
  501. }
  502. return 0;
  503. }
  504. static int thermal_get_trip_type(struct thermal_zone_device *thermal,
  505. int trip, enum thermal_trip_type *type)
  506. {
  507. struct acpi_thermal *tz = thermal->devdata;
  508. int i;
  509. if (!tz || trip < 0)
  510. return -EINVAL;
  511. if (tz->trips.critical.flags.valid) {
  512. if (!trip) {
  513. *type = THERMAL_TRIP_CRITICAL;
  514. return 0;
  515. }
  516. trip--;
  517. }
  518. if (tz->trips.hot.flags.valid) {
  519. if (!trip) {
  520. *type = THERMAL_TRIP_HOT;
  521. return 0;
  522. }
  523. trip--;
  524. }
  525. if (tz->trips.passive.flags.valid) {
  526. if (!trip) {
  527. *type = THERMAL_TRIP_PASSIVE;
  528. return 0;
  529. }
  530. trip--;
  531. }
  532. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  533. tz->trips.active[i].flags.valid; i++) {
  534. if (!trip) {
  535. *type = THERMAL_TRIP_ACTIVE;
  536. return 0;
  537. }
  538. trip--;
  539. }
  540. return -EINVAL;
  541. }
  542. static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
  543. int trip, int *temp)
  544. {
  545. struct acpi_thermal *tz = thermal->devdata;
  546. int i;
  547. if (!tz || trip < 0)
  548. return -EINVAL;
  549. if (tz->trips.critical.flags.valid) {
  550. if (!trip) {
  551. *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
  552. tz->trips.critical.temperature,
  553. tz->kelvin_offset);
  554. return 0;
  555. }
  556. trip--;
  557. }
  558. if (tz->trips.hot.flags.valid) {
  559. if (!trip) {
  560. *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
  561. tz->trips.hot.temperature,
  562. tz->kelvin_offset);
  563. return 0;
  564. }
  565. trip--;
  566. }
  567. if (tz->trips.passive.flags.valid) {
  568. if (!trip) {
  569. *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
  570. tz->trips.passive.temperature,
  571. tz->kelvin_offset);
  572. return 0;
  573. }
  574. trip--;
  575. }
  576. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  577. tz->trips.active[i].flags.valid; i++) {
  578. if (!trip) {
  579. *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
  580. tz->trips.active[i].temperature,
  581. tz->kelvin_offset);
  582. return 0;
  583. }
  584. trip--;
  585. }
  586. return -EINVAL;
  587. }
  588. static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
  589. int *temperature)
  590. {
  591. struct acpi_thermal *tz = thermal->devdata;
  592. if (tz->trips.critical.flags.valid) {
  593. *temperature = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
  594. tz->trips.critical.temperature,
  595. tz->kelvin_offset);
  596. return 0;
  597. } else
  598. return -EINVAL;
  599. }
  600. static int thermal_get_trend(struct thermal_zone_device *thermal,
  601. int trip, enum thermal_trend *trend)
  602. {
  603. struct acpi_thermal *tz = thermal->devdata;
  604. enum thermal_trip_type type;
  605. int i;
  606. if (thermal_get_trip_type(thermal, trip, &type))
  607. return -EINVAL;
  608. if (type == THERMAL_TRIP_ACTIVE) {
  609. int trip_temp;
  610. int temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
  611. tz->temperature, tz->kelvin_offset);
  612. if (thermal_get_trip_temp(thermal, trip, &trip_temp))
  613. return -EINVAL;
  614. if (temp > trip_temp) {
  615. *trend = THERMAL_TREND_RAISING;
  616. return 0;
  617. } else {
  618. /* Fall back on default trend */
  619. return -EINVAL;
  620. }
  621. }
  622. /*
  623. * tz->temperature has already been updated by generic thermal layer,
  624. * before this callback being invoked
  625. */
  626. i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature))
  627. + (tz->trips.passive.tc2
  628. * (tz->temperature - tz->trips.passive.temperature));
  629. if (i > 0)
  630. *trend = THERMAL_TREND_RAISING;
  631. else if (i < 0)
  632. *trend = THERMAL_TREND_DROPPING;
  633. else
  634. *trend = THERMAL_TREND_STABLE;
  635. return 0;
  636. }
  637. static int thermal_notify(struct thermal_zone_device *thermal, int trip,
  638. enum thermal_trip_type trip_type)
  639. {
  640. u8 type = 0;
  641. struct acpi_thermal *tz = thermal->devdata;
  642. if (trip_type == THERMAL_TRIP_CRITICAL)
  643. type = ACPI_THERMAL_NOTIFY_CRITICAL;
  644. else if (trip_type == THERMAL_TRIP_HOT)
  645. type = ACPI_THERMAL_NOTIFY_HOT;
  646. else
  647. return 0;
  648. acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
  649. dev_name(&tz->device->dev), type, 1);
  650. if (trip_type == THERMAL_TRIP_CRITICAL && nocrt)
  651. return 1;
  652. return 0;
  653. }
  654. static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
  655. struct thermal_cooling_device *cdev,
  656. bool bind)
  657. {
  658. struct acpi_device *device = cdev->devdata;
  659. struct acpi_thermal *tz = thermal->devdata;
  660. struct acpi_device *dev;
  661. acpi_status status;
  662. acpi_handle handle;
  663. int i;
  664. int j;
  665. int trip = -1;
  666. int result = 0;
  667. if (tz->trips.critical.flags.valid)
  668. trip++;
  669. if (tz->trips.hot.flags.valid)
  670. trip++;
  671. if (tz->trips.passive.flags.valid) {
  672. trip++;
  673. for (i = 0; i < tz->trips.passive.devices.count;
  674. i++) {
  675. handle = tz->trips.passive.devices.handles[i];
  676. status = acpi_bus_get_device(handle, &dev);
  677. if (ACPI_FAILURE(status) || dev != device)
  678. continue;
  679. if (bind)
  680. result =
  681. thermal_zone_bind_cooling_device
  682. (thermal, trip, cdev,
  683. THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
  684. THERMAL_WEIGHT_DEFAULT);
  685. else
  686. result =
  687. thermal_zone_unbind_cooling_device
  688. (thermal, trip, cdev);
  689. if (result)
  690. goto failed;
  691. }
  692. }
  693. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  694. if (!tz->trips.active[i].flags.valid)
  695. break;
  696. trip++;
  697. for (j = 0;
  698. j < tz->trips.active[i].devices.count;
  699. j++) {
  700. handle = tz->trips.active[i].devices.handles[j];
  701. status = acpi_bus_get_device(handle, &dev);
  702. if (ACPI_FAILURE(status) || dev != device)
  703. continue;
  704. if (bind)
  705. result = thermal_zone_bind_cooling_device
  706. (thermal, trip, cdev,
  707. THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
  708. THERMAL_WEIGHT_DEFAULT);
  709. else
  710. result = thermal_zone_unbind_cooling_device
  711. (thermal, trip, cdev);
  712. if (result)
  713. goto failed;
  714. }
  715. }
  716. for (i = 0; i < tz->devices.count; i++) {
  717. handle = tz->devices.handles[i];
  718. status = acpi_bus_get_device(handle, &dev);
  719. if (ACPI_SUCCESS(status) && (dev == device)) {
  720. if (bind)
  721. result = thermal_zone_bind_cooling_device
  722. (thermal, THERMAL_TRIPS_NONE,
  723. cdev, THERMAL_NO_LIMIT,
  724. THERMAL_NO_LIMIT,
  725. THERMAL_WEIGHT_DEFAULT);
  726. else
  727. result = thermal_zone_unbind_cooling_device
  728. (thermal, THERMAL_TRIPS_NONE,
  729. cdev);
  730. if (result)
  731. goto failed;
  732. }
  733. }
  734. failed:
  735. return result;
  736. }
  737. static int
  738. acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
  739. struct thermal_cooling_device *cdev)
  740. {
  741. return acpi_thermal_cooling_device_cb(thermal, cdev, true);
  742. }
  743. static int
  744. acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
  745. struct thermal_cooling_device *cdev)
  746. {
  747. return acpi_thermal_cooling_device_cb(thermal, cdev, false);
  748. }
  749. static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
  750. .bind = acpi_thermal_bind_cooling_device,
  751. .unbind = acpi_thermal_unbind_cooling_device,
  752. .get_temp = thermal_get_temp,
  753. .get_mode = thermal_get_mode,
  754. .set_mode = thermal_set_mode,
  755. .get_trip_type = thermal_get_trip_type,
  756. .get_trip_temp = thermal_get_trip_temp,
  757. .get_crit_temp = thermal_get_crit_temp,
  758. .get_trend = thermal_get_trend,
  759. .notify = thermal_notify,
  760. };
  761. static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
  762. {
  763. int trips = 0;
  764. int result;
  765. acpi_status status;
  766. int i;
  767. if (tz->trips.critical.flags.valid)
  768. trips++;
  769. if (tz->trips.hot.flags.valid)
  770. trips++;
  771. if (tz->trips.passive.flags.valid)
  772. trips++;
  773. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  774. tz->trips.active[i].flags.valid; i++, trips++);
  775. if (tz->trips.passive.flags.valid)
  776. tz->thermal_zone =
  777. thermal_zone_device_register("acpitz", trips, 0, tz,
  778. &acpi_thermal_zone_ops, NULL,
  779. tz->trips.passive.tsp*100,
  780. tz->polling_frequency*100);
  781. else
  782. tz->thermal_zone =
  783. thermal_zone_device_register("acpitz", trips, 0, tz,
  784. &acpi_thermal_zone_ops, NULL,
  785. 0, tz->polling_frequency*100);
  786. if (IS_ERR(tz->thermal_zone))
  787. return -ENODEV;
  788. result = sysfs_create_link(&tz->device->dev.kobj,
  789. &tz->thermal_zone->device.kobj, "thermal_zone");
  790. if (result)
  791. return result;
  792. result = sysfs_create_link(&tz->thermal_zone->device.kobj,
  793. &tz->device->dev.kobj, "device");
  794. if (result)
  795. return result;
  796. status = acpi_bus_attach_private_data(tz->device->handle,
  797. tz->thermal_zone);
  798. if (ACPI_FAILURE(status))
  799. return -ENODEV;
  800. tz->tz_enabled = 1;
  801. dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
  802. tz->thermal_zone->id);
  803. return 0;
  804. }
  805. static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
  806. {
  807. sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
  808. sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
  809. thermal_zone_device_unregister(tz->thermal_zone);
  810. tz->thermal_zone = NULL;
  811. acpi_bus_detach_private_data(tz->device->handle);
  812. }
  813. /* --------------------------------------------------------------------------
  814. Driver Interface
  815. -------------------------------------------------------------------------- */
  816. static void acpi_queue_thermal_check(struct acpi_thermal *tz)
  817. {
  818. if (!work_pending(&tz->thermal_check_work))
  819. queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
  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_queue_thermal_check(tz);
  829. break;
  830. case ACPI_THERMAL_NOTIFY_THRESHOLDS:
  831. acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
  832. acpi_queue_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_queue_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. if (!tz->tz_enabled)
  925. return;
  926. /*
  927. * In general, it is not sufficient to check the pending bit, because
  928. * subsequent instances of this function may be queued after one of them
  929. * has started running (e.g. if _TMP sleeps). Avoid bailing out if just
  930. * one of them is running, though, because it may have done the actual
  931. * check some time ago, so allow at least one of them to block on the
  932. * mutex while another one is running the update.
  933. */
  934. if (!refcount_dec_not_one(&tz->thermal_check_count))
  935. return;
  936. mutex_lock(&tz->thermal_check_lock);
  937. thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED);
  938. refcount_inc(&tz->thermal_check_count);
  939. mutex_unlock(&tz->thermal_check_lock);
  940. }
  941. static int acpi_thermal_add(struct acpi_device *device)
  942. {
  943. int result = 0;
  944. struct acpi_thermal *tz = NULL;
  945. if (!device)
  946. return -EINVAL;
  947. tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
  948. if (!tz)
  949. return -ENOMEM;
  950. tz->device = device;
  951. strcpy(tz->name, device->pnp.bus_id);
  952. strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
  953. strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
  954. device->driver_data = tz;
  955. result = acpi_thermal_get_info(tz);
  956. if (result)
  957. goto free_memory;
  958. acpi_thermal_guess_offset(tz);
  959. result = acpi_thermal_register_thermal_zone(tz);
  960. if (result)
  961. goto free_memory;
  962. refcount_set(&tz->thermal_check_count, 3);
  963. mutex_init(&tz->thermal_check_lock);
  964. INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn);
  965. pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device),
  966. acpi_device_bid(device), DECI_KELVIN_TO_CELSIUS(tz->temperature));
  967. goto end;
  968. free_memory:
  969. kfree(tz);
  970. end:
  971. return result;
  972. }
  973. static int acpi_thermal_remove(struct acpi_device *device)
  974. {
  975. struct acpi_thermal *tz = NULL;
  976. if (!device || !acpi_driver_data(device))
  977. return -EINVAL;
  978. flush_workqueue(acpi_thermal_pm_queue);
  979. tz = acpi_driver_data(device);
  980. acpi_thermal_unregister_thermal_zone(tz);
  981. kfree(tz);
  982. return 0;
  983. }
  984. #ifdef CONFIG_PM_SLEEP
  985. static int acpi_thermal_suspend(struct device *dev)
  986. {
  987. /* Make sure the previously queued thermal check work has been done */
  988. flush_workqueue(acpi_thermal_pm_queue);
  989. return 0;
  990. }
  991. static int acpi_thermal_resume(struct device *dev)
  992. {
  993. struct acpi_thermal *tz;
  994. int i, j, power_state, result;
  995. if (!dev)
  996. return -EINVAL;
  997. tz = acpi_driver_data(to_acpi_device(dev));
  998. if (!tz)
  999. return -EINVAL;
  1000. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  1001. if (!(&tz->trips.active[i]))
  1002. break;
  1003. if (!tz->trips.active[i].flags.valid)
  1004. break;
  1005. tz->trips.active[i].flags.enabled = 1;
  1006. for (j = 0; j < tz->trips.active[i].devices.count; j++) {
  1007. result = acpi_bus_update_power(
  1008. tz->trips.active[i].devices.handles[j],
  1009. &power_state);
  1010. if (result || (power_state != ACPI_STATE_D0)) {
  1011. tz->trips.active[i].flags.enabled = 0;
  1012. break;
  1013. }
  1014. }
  1015. tz->state.active |= tz->trips.active[i].flags.enabled;
  1016. }
  1017. acpi_queue_thermal_check(tz);
  1018. return AE_OK;
  1019. }
  1020. #endif
  1021. static int thermal_act(const struct dmi_system_id *d) {
  1022. if (act == 0) {
  1023. pr_notice(PREFIX "%s detected: "
  1024. "disabling all active thermal trip points\n", d->ident);
  1025. act = -1;
  1026. }
  1027. return 0;
  1028. }
  1029. static int thermal_nocrt(const struct dmi_system_id *d) {
  1030. pr_notice(PREFIX "%s detected: "
  1031. "disabling all critical thermal trip point actions.\n", d->ident);
  1032. nocrt = 1;
  1033. return 0;
  1034. }
  1035. static int thermal_tzp(const struct dmi_system_id *d) {
  1036. if (tzp == 0) {
  1037. pr_notice(PREFIX "%s detected: "
  1038. "enabling thermal zone polling\n", d->ident);
  1039. tzp = 300; /* 300 dS = 30 Seconds */
  1040. }
  1041. return 0;
  1042. }
  1043. static int thermal_psv(const struct dmi_system_id *d) {
  1044. if (psv == 0) {
  1045. pr_notice(PREFIX "%s detected: "
  1046. "disabling all passive thermal trip points\n", d->ident);
  1047. psv = -1;
  1048. }
  1049. return 0;
  1050. }
  1051. static const struct dmi_system_id thermal_dmi_table[] __initconst = {
  1052. /*
  1053. * Award BIOS on this AOpen makes thermal control almost worthless.
  1054. * http://bugzilla.kernel.org/show_bug.cgi?id=8842
  1055. */
  1056. {
  1057. .callback = thermal_act,
  1058. .ident = "AOpen i915GMm-HFS",
  1059. .matches = {
  1060. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1061. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1062. },
  1063. },
  1064. {
  1065. .callback = thermal_psv,
  1066. .ident = "AOpen i915GMm-HFS",
  1067. .matches = {
  1068. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1069. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1070. },
  1071. },
  1072. {
  1073. .callback = thermal_tzp,
  1074. .ident = "AOpen i915GMm-HFS",
  1075. .matches = {
  1076. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1077. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1078. },
  1079. },
  1080. {
  1081. .callback = thermal_nocrt,
  1082. .ident = "Gigabyte GA-7ZX",
  1083. .matches = {
  1084. DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
  1085. DMI_MATCH(DMI_BOARD_NAME, "7ZX"),
  1086. },
  1087. },
  1088. {}
  1089. };
  1090. static int __init acpi_thermal_init(void)
  1091. {
  1092. int result = 0;
  1093. dmi_check_system(thermal_dmi_table);
  1094. if (off) {
  1095. pr_notice(PREFIX "thermal control disabled\n");
  1096. return -ENODEV;
  1097. }
  1098. acpi_thermal_pm_queue = alloc_workqueue("acpi_thermal_pm",
  1099. WQ_HIGHPRI | WQ_MEM_RECLAIM, 0);
  1100. if (!acpi_thermal_pm_queue)
  1101. return -ENODEV;
  1102. result = acpi_bus_register_driver(&acpi_thermal_driver);
  1103. if (result < 0) {
  1104. destroy_workqueue(acpi_thermal_pm_queue);
  1105. return -ENODEV;
  1106. }
  1107. return 0;
  1108. }
  1109. static void __exit acpi_thermal_exit(void)
  1110. {
  1111. acpi_bus_unregister_driver(&acpi_thermal_driver);
  1112. destroy_workqueue(acpi_thermal_pm_queue);
  1113. return;
  1114. }
  1115. module_init(acpi_thermal_init);
  1116. module_exit(acpi_thermal_exit);