thermal.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. /*
  2. * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. *
  25. * This driver fully implements the ACPI thermal policy as described in the
  26. * ACPI 2.0 Specification.
  27. *
  28. * TBD: 1. Implement passive cooling hysteresis.
  29. * 2. Enhance passive cooling (CPU) states/limit interface to support
  30. * concepts of 'multiple limiters', upper/lower limits, etc.
  31. *
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/module.h>
  35. #include <linux/dmi.h>
  36. #include <linux/init.h>
  37. #include <linux/slab.h>
  38. #include <linux/types.h>
  39. #include <linux/jiffies.h>
  40. #include <linux/kmod.h>
  41. #include <linux/reboot.h>
  42. #include <linux/device.h>
  43. #include <asm/uaccess.h>
  44. #include <linux/thermal.h>
  45. #include <acpi/acpi_bus.h>
  46. #include <acpi/acpi_drivers.h>
  47. #define PREFIX "ACPI: "
  48. #define ACPI_THERMAL_CLASS "thermal_zone"
  49. #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
  50. #define ACPI_THERMAL_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 int acpi_thermal_add(struct acpi_device *device);
  82. static int acpi_thermal_remove(struct acpi_device *device);
  83. static void acpi_thermal_notify(struct acpi_device *device, u32 event);
  84. static const struct acpi_device_id thermal_device_ids[] = {
  85. {ACPI_THERMAL_HID, 0},
  86. {"", 0},
  87. };
  88. MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
  89. #ifdef CONFIG_PM_SLEEP
  90. static int acpi_thermal_resume(struct device *dev);
  91. #endif
  92. static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume);
  93. static struct acpi_driver acpi_thermal_driver = {
  94. .name = "thermal",
  95. .class = ACPI_THERMAL_CLASS,
  96. .ids = thermal_device_ids,
  97. .ops = {
  98. .add = acpi_thermal_add,
  99. .remove = acpi_thermal_remove,
  100. .notify = acpi_thermal_notify,
  101. },
  102. .drv.pm = &acpi_thermal_pm,
  103. };
  104. struct acpi_thermal_state {
  105. u8 critical:1;
  106. u8 hot:1;
  107. u8 passive:1;
  108. u8 active:1;
  109. u8 reserved:4;
  110. int active_index;
  111. };
  112. struct acpi_thermal_state_flags {
  113. u8 valid:1;
  114. u8 enabled:1;
  115. u8 reserved:6;
  116. };
  117. struct acpi_thermal_critical {
  118. struct acpi_thermal_state_flags flags;
  119. unsigned long temperature;
  120. };
  121. struct acpi_thermal_hot {
  122. struct acpi_thermal_state_flags flags;
  123. unsigned long temperature;
  124. };
  125. struct acpi_thermal_passive {
  126. struct acpi_thermal_state_flags flags;
  127. unsigned long temperature;
  128. unsigned long tc1;
  129. unsigned long tc2;
  130. unsigned long tsp;
  131. struct acpi_handle_list devices;
  132. };
  133. struct acpi_thermal_active {
  134. struct acpi_thermal_state_flags flags;
  135. unsigned long temperature;
  136. struct acpi_handle_list devices;
  137. };
  138. struct acpi_thermal_trips {
  139. struct acpi_thermal_critical critical;
  140. struct acpi_thermal_hot hot;
  141. struct acpi_thermal_passive passive;
  142. struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
  143. };
  144. struct acpi_thermal_flags {
  145. u8 cooling_mode:1; /* _SCP */
  146. u8 devices:1; /* _TZD */
  147. u8 reserved:6;
  148. };
  149. struct acpi_thermal {
  150. struct acpi_device * device;
  151. acpi_bus_id name;
  152. unsigned long temperature;
  153. unsigned long last_temperature;
  154. unsigned long polling_frequency;
  155. volatile u8 zombie;
  156. struct acpi_thermal_flags flags;
  157. struct acpi_thermal_state state;
  158. struct acpi_thermal_trips trips;
  159. struct acpi_handle_list devices;
  160. struct thermal_zone_device *thermal_zone;
  161. int tz_enabled;
  162. int kelvin_offset;
  163. };
  164. /* --------------------------------------------------------------------------
  165. Thermal Zone Management
  166. -------------------------------------------------------------------------- */
  167. static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
  168. {
  169. acpi_status status = AE_OK;
  170. unsigned long long tmp;
  171. if (!tz)
  172. return -EINVAL;
  173. tz->last_temperature = tz->temperature;
  174. status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp);
  175. if (ACPI_FAILURE(status))
  176. return -ENODEV;
  177. tz->temperature = tmp;
  178. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
  179. tz->temperature));
  180. return 0;
  181. }
  182. static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
  183. {
  184. acpi_status status = AE_OK;
  185. unsigned long long tmp;
  186. if (!tz)
  187. return -EINVAL;
  188. status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp);
  189. if (ACPI_FAILURE(status))
  190. return -ENODEV;
  191. tz->polling_frequency = tmp;
  192. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
  193. tz->polling_frequency));
  194. return 0;
  195. }
  196. static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
  197. {
  198. acpi_status status = AE_OK;
  199. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  200. struct acpi_object_list arg_list = { 1, &arg0 };
  201. acpi_handle handle = NULL;
  202. if (!tz)
  203. return -EINVAL;
  204. status = acpi_get_handle(tz->device->handle, "_SCP", &handle);
  205. if (ACPI_FAILURE(status)) {
  206. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
  207. return -ENODEV;
  208. }
  209. arg0.integer.value = mode;
  210. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  211. if (ACPI_FAILURE(status))
  212. return -ENODEV;
  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. printk(KERN_WARNING FW_BUG "Invalid critical threshold "
  263. "(%llu)\n", 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. printk(KERN_WARNING PREFIX
  281. "Critical threshold %d C\n", 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.critical.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. printk(KERN_WARNING PREFIX
  351. "Invalid passive threshold\n");
  352. tz->trips.passive.flags.valid = 0;
  353. }
  354. else
  355. tz->trips.passive.flags.valid = 1;
  356. if (memcmp(&tz->trips.passive.devices, &devices,
  357. sizeof(struct acpi_handle_list))) {
  358. memcpy(&tz->trips.passive.devices, &devices,
  359. sizeof(struct acpi_handle_list));
  360. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
  361. }
  362. }
  363. if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) {
  364. if (valid != tz->trips.passive.flags.valid)
  365. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state");
  366. }
  367. /* Active (optional) */
  368. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  369. char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
  370. valid = tz->trips.active[i].flags.valid;
  371. if (act == -1)
  372. break; /* disable all active trip points */
  373. if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) &&
  374. tz->trips.active[i].flags.valid)) {
  375. status = acpi_evaluate_integer(tz->device->handle,
  376. name, NULL, &tmp);
  377. if (ACPI_FAILURE(status)) {
  378. tz->trips.active[i].flags.valid = 0;
  379. if (i == 0)
  380. break;
  381. if (act <= 0)
  382. break;
  383. if (i == 1)
  384. tz->trips.active[0].temperature =
  385. CELSIUS_TO_KELVIN(act);
  386. else
  387. /*
  388. * Don't allow override higher than
  389. * the next higher trip point
  390. */
  391. tz->trips.active[i - 1].temperature =
  392. (tz->trips.active[i - 2].temperature <
  393. CELSIUS_TO_KELVIN(act) ?
  394. tz->trips.active[i - 2].temperature :
  395. CELSIUS_TO_KELVIN(act));
  396. break;
  397. } else {
  398. tz->trips.active[i].temperature = tmp;
  399. tz->trips.active[i].flags.valid = 1;
  400. }
  401. }
  402. name[2] = 'L';
  403. if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) {
  404. memset(&devices, 0, sizeof(struct acpi_handle_list));
  405. status = acpi_evaluate_reference(tz->device->handle,
  406. name, NULL, &devices);
  407. if (ACPI_FAILURE(status)) {
  408. printk(KERN_WARNING PREFIX
  409. "Invalid active%d threshold\n", i);
  410. tz->trips.active[i].flags.valid = 0;
  411. }
  412. else
  413. tz->trips.active[i].flags.valid = 1;
  414. if (memcmp(&tz->trips.active[i].devices, &devices,
  415. sizeof(struct acpi_handle_list))) {
  416. memcpy(&tz->trips.active[i].devices, &devices,
  417. sizeof(struct acpi_handle_list));
  418. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
  419. }
  420. }
  421. if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES))
  422. if (valid != tz->trips.active[i].flags.valid)
  423. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state");
  424. if (!tz->trips.active[i].flags.valid)
  425. break;
  426. }
  427. if ((flag & ACPI_TRIPS_DEVICES)
  428. && acpi_has_method(tz->device->handle, "_TZD")) {
  429. memset(&devices, 0, sizeof(devices));
  430. status = acpi_evaluate_reference(tz->device->handle, "_TZD",
  431. NULL, &devices);
  432. if (ACPI_SUCCESS(status)
  433. && memcmp(&tz->devices, &devices, sizeof(devices))) {
  434. tz->devices = devices;
  435. ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
  436. }
  437. }
  438. return 0;
  439. }
  440. static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
  441. {
  442. int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
  443. if (ret)
  444. return ret;
  445. valid = tz->trips.critical.flags.valid |
  446. tz->trips.hot.flags.valid |
  447. tz->trips.passive.flags.valid;
  448. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
  449. valid |= tz->trips.active[i].flags.valid;
  450. if (!valid) {
  451. printk(KERN_WARNING FW_BUG "No valid trip found\n");
  452. return -ENODEV;
  453. }
  454. return 0;
  455. }
  456. static void acpi_thermal_check(void *data)
  457. {
  458. struct acpi_thermal *tz = data;
  459. if (!tz->tz_enabled) {
  460. pr_warn("thermal zone is disabled \n");
  461. return;
  462. }
  463. thermal_zone_device_update(tz->thermal_zone);
  464. }
  465. /* sys I/F for generic thermal sysfs support */
  466. #define KELVIN_TO_MILLICELSIUS(t, off) (((t) - (off)) * 100)
  467. static int thermal_get_temp(struct thermal_zone_device *thermal,
  468. unsigned long *temp)
  469. {
  470. struct acpi_thermal *tz = thermal->devdata;
  471. int result;
  472. if (!tz)
  473. return -EINVAL;
  474. result = acpi_thermal_get_temperature(tz);
  475. if (result)
  476. return result;
  477. *temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset);
  478. return 0;
  479. }
  480. static int thermal_get_mode(struct thermal_zone_device *thermal,
  481. enum thermal_device_mode *mode)
  482. {
  483. struct acpi_thermal *tz = thermal->devdata;
  484. if (!tz)
  485. return -EINVAL;
  486. *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED :
  487. THERMAL_DEVICE_DISABLED;
  488. return 0;
  489. }
  490. static int thermal_set_mode(struct thermal_zone_device *thermal,
  491. enum thermal_device_mode mode)
  492. {
  493. struct acpi_thermal *tz = thermal->devdata;
  494. int enable;
  495. if (!tz)
  496. return -EINVAL;
  497. /*
  498. * enable/disable thermal management from ACPI thermal driver
  499. */
  500. if (mode == THERMAL_DEVICE_ENABLED)
  501. enable = 1;
  502. else if (mode == THERMAL_DEVICE_DISABLED)
  503. enable = 0;
  504. else
  505. return -EINVAL;
  506. if (enable != tz->tz_enabled) {
  507. tz->tz_enabled = enable;
  508. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  509. "%s kernel ACPI thermal control\n",
  510. tz->tz_enabled ? "Enable" : "Disable"));
  511. acpi_thermal_check(tz);
  512. }
  513. return 0;
  514. }
  515. static int thermal_get_trip_type(struct thermal_zone_device *thermal,
  516. int trip, enum thermal_trip_type *type)
  517. {
  518. struct acpi_thermal *tz = thermal->devdata;
  519. int i;
  520. if (!tz || trip < 0)
  521. return -EINVAL;
  522. if (tz->trips.critical.flags.valid) {
  523. if (!trip) {
  524. *type = THERMAL_TRIP_CRITICAL;
  525. return 0;
  526. }
  527. trip--;
  528. }
  529. if (tz->trips.hot.flags.valid) {
  530. if (!trip) {
  531. *type = THERMAL_TRIP_HOT;
  532. return 0;
  533. }
  534. trip--;
  535. }
  536. if (tz->trips.passive.flags.valid) {
  537. if (!trip) {
  538. *type = THERMAL_TRIP_PASSIVE;
  539. return 0;
  540. }
  541. trip--;
  542. }
  543. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  544. tz->trips.active[i].flags.valid; i++) {
  545. if (!trip) {
  546. *type = THERMAL_TRIP_ACTIVE;
  547. return 0;
  548. }
  549. trip--;
  550. }
  551. return -EINVAL;
  552. }
  553. static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
  554. int trip, unsigned long *temp)
  555. {
  556. struct acpi_thermal *tz = thermal->devdata;
  557. int i;
  558. if (!tz || trip < 0)
  559. return -EINVAL;
  560. if (tz->trips.critical.flags.valid) {
  561. if (!trip) {
  562. *temp = KELVIN_TO_MILLICELSIUS(
  563. tz->trips.critical.temperature,
  564. tz->kelvin_offset);
  565. return 0;
  566. }
  567. trip--;
  568. }
  569. if (tz->trips.hot.flags.valid) {
  570. if (!trip) {
  571. *temp = KELVIN_TO_MILLICELSIUS(
  572. tz->trips.hot.temperature,
  573. tz->kelvin_offset);
  574. return 0;
  575. }
  576. trip--;
  577. }
  578. if (tz->trips.passive.flags.valid) {
  579. if (!trip) {
  580. *temp = KELVIN_TO_MILLICELSIUS(
  581. tz->trips.passive.temperature,
  582. tz->kelvin_offset);
  583. return 0;
  584. }
  585. trip--;
  586. }
  587. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  588. tz->trips.active[i].flags.valid; i++) {
  589. if (!trip) {
  590. *temp = KELVIN_TO_MILLICELSIUS(
  591. tz->trips.active[i].temperature,
  592. tz->kelvin_offset);
  593. return 0;
  594. }
  595. trip--;
  596. }
  597. return -EINVAL;
  598. }
  599. static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
  600. unsigned long *temperature) {
  601. struct acpi_thermal *tz = thermal->devdata;
  602. if (tz->trips.critical.flags.valid) {
  603. *temperature = KELVIN_TO_MILLICELSIUS(
  604. tz->trips.critical.temperature,
  605. tz->kelvin_offset);
  606. return 0;
  607. } else
  608. return -EINVAL;
  609. }
  610. static int thermal_get_trend(struct thermal_zone_device *thermal,
  611. int trip, enum thermal_trend *trend)
  612. {
  613. struct acpi_thermal *tz = thermal->devdata;
  614. enum thermal_trip_type type;
  615. int i;
  616. if (thermal_get_trip_type(thermal, trip, &type))
  617. return -EINVAL;
  618. if (type == THERMAL_TRIP_ACTIVE) {
  619. unsigned long trip_temp;
  620. unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature,
  621. tz->kelvin_offset);
  622. if (thermal_get_trip_temp(thermal, trip, &trip_temp))
  623. return -EINVAL;
  624. if (temp > trip_temp) {
  625. *trend = THERMAL_TREND_RAISING;
  626. return 0;
  627. } else {
  628. /* Fall back on default trend */
  629. return -EINVAL;
  630. }
  631. }
  632. /*
  633. * tz->temperature has already been updated by generic thermal layer,
  634. * before this callback being invoked
  635. */
  636. i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature))
  637. + (tz->trips.passive.tc2
  638. * (tz->temperature - tz->trips.passive.temperature));
  639. if (i > 0)
  640. *trend = THERMAL_TREND_RAISING;
  641. else if (i < 0)
  642. *trend = THERMAL_TREND_DROPPING;
  643. else
  644. *trend = THERMAL_TREND_STABLE;
  645. return 0;
  646. }
  647. static int thermal_notify(struct thermal_zone_device *thermal, int trip,
  648. enum thermal_trip_type trip_type)
  649. {
  650. u8 type = 0;
  651. struct acpi_thermal *tz = thermal->devdata;
  652. if (trip_type == THERMAL_TRIP_CRITICAL)
  653. type = ACPI_THERMAL_NOTIFY_CRITICAL;
  654. else if (trip_type == THERMAL_TRIP_HOT)
  655. type = ACPI_THERMAL_NOTIFY_HOT;
  656. else
  657. return 0;
  658. acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
  659. dev_name(&tz->device->dev), type, 1);
  660. if (trip_type == THERMAL_TRIP_CRITICAL && nocrt)
  661. return 1;
  662. return 0;
  663. }
  664. static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
  665. struct thermal_cooling_device *cdev,
  666. bool bind)
  667. {
  668. struct acpi_device *device = cdev->devdata;
  669. struct acpi_thermal *tz = thermal->devdata;
  670. struct acpi_device *dev;
  671. acpi_status status;
  672. acpi_handle handle;
  673. int i;
  674. int j;
  675. int trip = -1;
  676. int result = 0;
  677. if (tz->trips.critical.flags.valid)
  678. trip++;
  679. if (tz->trips.hot.flags.valid)
  680. trip++;
  681. if (tz->trips.passive.flags.valid) {
  682. trip++;
  683. for (i = 0; i < tz->trips.passive.devices.count;
  684. i++) {
  685. handle = tz->trips.passive.devices.handles[i];
  686. status = acpi_bus_get_device(handle, &dev);
  687. if (ACPI_FAILURE(status) || dev != device)
  688. continue;
  689. if (bind)
  690. result =
  691. thermal_zone_bind_cooling_device
  692. (thermal, trip, cdev,
  693. THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
  694. else
  695. result =
  696. thermal_zone_unbind_cooling_device
  697. (thermal, trip, cdev);
  698. if (result)
  699. goto failed;
  700. }
  701. }
  702. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  703. if (!tz->trips.active[i].flags.valid)
  704. break;
  705. trip++;
  706. for (j = 0;
  707. j < tz->trips.active[i].devices.count;
  708. j++) {
  709. handle = tz->trips.active[i].devices.handles[j];
  710. status = acpi_bus_get_device(handle, &dev);
  711. if (ACPI_FAILURE(status) || dev != device)
  712. continue;
  713. if (bind)
  714. result = thermal_zone_bind_cooling_device
  715. (thermal, trip, cdev,
  716. THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
  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. else
  734. result = thermal_zone_unbind_cooling_device
  735. (thermal, THERMAL_TRIPS_NONE,
  736. cdev);
  737. if (result)
  738. goto failed;
  739. }
  740. }
  741. failed:
  742. return result;
  743. }
  744. static int
  745. acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
  746. struct thermal_cooling_device *cdev)
  747. {
  748. return acpi_thermal_cooling_device_cb(thermal, cdev, true);
  749. }
  750. static int
  751. acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
  752. struct thermal_cooling_device *cdev)
  753. {
  754. return acpi_thermal_cooling_device_cb(thermal, cdev, false);
  755. }
  756. static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
  757. .bind = acpi_thermal_bind_cooling_device,
  758. .unbind = acpi_thermal_unbind_cooling_device,
  759. .get_temp = thermal_get_temp,
  760. .get_mode = thermal_get_mode,
  761. .set_mode = thermal_set_mode,
  762. .get_trip_type = thermal_get_trip_type,
  763. .get_trip_temp = thermal_get_trip_temp,
  764. .get_crit_temp = thermal_get_crit_temp,
  765. .get_trend = thermal_get_trend,
  766. .notify = thermal_notify,
  767. };
  768. static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
  769. {
  770. int trips = 0;
  771. int result;
  772. acpi_status status;
  773. int i;
  774. if (tz->trips.critical.flags.valid)
  775. trips++;
  776. if (tz->trips.hot.flags.valid)
  777. trips++;
  778. if (tz->trips.passive.flags.valid)
  779. trips++;
  780. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
  781. tz->trips.active[i].flags.valid; i++, trips++);
  782. if (tz->trips.passive.flags.valid)
  783. tz->thermal_zone =
  784. thermal_zone_device_register("acpitz", trips, 0, tz,
  785. &acpi_thermal_zone_ops, NULL,
  786. tz->trips.passive.tsp*100,
  787. tz->polling_frequency*100);
  788. else
  789. tz->thermal_zone =
  790. thermal_zone_device_register("acpitz", trips, 0, tz,
  791. &acpi_thermal_zone_ops, NULL,
  792. 0, tz->polling_frequency*100);
  793. if (IS_ERR(tz->thermal_zone))
  794. return -ENODEV;
  795. result = sysfs_create_link(&tz->device->dev.kobj,
  796. &tz->thermal_zone->device.kobj, "thermal_zone");
  797. if (result)
  798. return result;
  799. result = sysfs_create_link(&tz->thermal_zone->device.kobj,
  800. &tz->device->dev.kobj, "device");
  801. if (result)
  802. return result;
  803. status = acpi_attach_data(tz->device->handle,
  804. acpi_bus_private_data_handler,
  805. tz->thermal_zone);
  806. if (ACPI_FAILURE(status)) {
  807. printk(KERN_ERR PREFIX
  808. "Error attaching device data\n");
  809. return -ENODEV;
  810. }
  811. tz->tz_enabled = 1;
  812. dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
  813. tz->thermal_zone->id);
  814. return 0;
  815. }
  816. static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
  817. {
  818. sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
  819. sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
  820. thermal_zone_device_unregister(tz->thermal_zone);
  821. tz->thermal_zone = NULL;
  822. acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler);
  823. }
  824. /* --------------------------------------------------------------------------
  825. Driver Interface
  826. -------------------------------------------------------------------------- */
  827. static void acpi_thermal_notify(struct acpi_device *device, u32 event)
  828. {
  829. struct acpi_thermal *tz = acpi_driver_data(device);
  830. if (!tz)
  831. return;
  832. switch (event) {
  833. case ACPI_THERMAL_NOTIFY_TEMPERATURE:
  834. acpi_thermal_check(tz);
  835. break;
  836. case ACPI_THERMAL_NOTIFY_THRESHOLDS:
  837. acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
  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. case ACPI_THERMAL_NOTIFY_DEVICES:
  843. acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
  844. acpi_thermal_check(tz);
  845. acpi_bus_generate_netlink_event(device->pnp.device_class,
  846. dev_name(&device->dev), event, 0);
  847. break;
  848. default:
  849. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  850. "Unsupported event [0x%x]\n", event));
  851. break;
  852. }
  853. }
  854. /*
  855. * On some platforms, the AML code has dependency about
  856. * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx.
  857. * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after
  858. * /_CRT/_HOT/_PSV/_ACx, or else system will be power off.
  859. * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0
  860. * if _TMP has never been evaluated.
  861. *
  862. * As this dependency is totally transparent to OS, evaluate
  863. * all of them once, in the order of _CRT/_HOT/_PSV/_ACx,
  864. * _TMP, before they are actually used.
  865. */
  866. static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz)
  867. {
  868. acpi_handle handle = tz->device->handle;
  869. unsigned long long value;
  870. int i;
  871. acpi_evaluate_integer(handle, "_CRT", NULL, &value);
  872. acpi_evaluate_integer(handle, "_HOT", NULL, &value);
  873. acpi_evaluate_integer(handle, "_PSV", NULL, &value);
  874. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  875. char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
  876. acpi_status status;
  877. status = acpi_evaluate_integer(handle, name, NULL, &value);
  878. if (status == AE_NOT_FOUND)
  879. break;
  880. }
  881. acpi_evaluate_integer(handle, "_TMP", NULL, &value);
  882. }
  883. static int acpi_thermal_get_info(struct acpi_thermal *tz)
  884. {
  885. int result = 0;
  886. if (!tz)
  887. return -EINVAL;
  888. acpi_thermal_aml_dependency_fix(tz);
  889. /* Get trip points [_CRT, _PSV, etc.] (required) */
  890. result = acpi_thermal_get_trip_points(tz);
  891. if (result)
  892. return result;
  893. /* Get temperature [_TMP] (required) */
  894. result = acpi_thermal_get_temperature(tz);
  895. if (result)
  896. return result;
  897. /* Set the cooling mode [_SCP] to active cooling (default) */
  898. result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
  899. if (!result)
  900. tz->flags.cooling_mode = 1;
  901. /* Get default polling frequency [_TZP] (optional) */
  902. if (tzp)
  903. tz->polling_frequency = tzp;
  904. else
  905. acpi_thermal_get_polling_frequency(tz);
  906. return 0;
  907. }
  908. /*
  909. * The exact offset between Kelvin and degree Celsius is 273.15. However ACPI
  910. * handles temperature values with a single decimal place. As a consequence,
  911. * some implementations use an offset of 273.1 and others use an offset of
  912. * 273.2. Try to find out which one is being used, to present the most
  913. * accurate and visually appealing number.
  914. *
  915. * The heuristic below should work for all ACPI thermal zones which have a
  916. * critical trip point with a value being a multiple of 0.5 degree Celsius.
  917. */
  918. static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
  919. {
  920. if (tz->trips.critical.flags.valid &&
  921. (tz->trips.critical.temperature % 5) == 1)
  922. tz->kelvin_offset = 2731;
  923. else
  924. tz->kelvin_offset = 2732;
  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. printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
  948. acpi_device_name(device), acpi_device_bid(device),
  949. 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. tz = acpi_driver_data(device);
  962. acpi_thermal_unregister_thermal_zone(tz);
  963. kfree(tz);
  964. return 0;
  965. }
  966. #ifdef CONFIG_PM_SLEEP
  967. static int acpi_thermal_resume(struct device *dev)
  968. {
  969. struct acpi_thermal *tz;
  970. int i, j, power_state, result;
  971. if (!dev)
  972. return -EINVAL;
  973. tz = acpi_driver_data(to_acpi_device(dev));
  974. if (!tz)
  975. return -EINVAL;
  976. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  977. if (!(&tz->trips.active[i]))
  978. break;
  979. if (!tz->trips.active[i].flags.valid)
  980. break;
  981. tz->trips.active[i].flags.enabled = 1;
  982. for (j = 0; j < tz->trips.active[i].devices.count; j++) {
  983. result = acpi_bus_update_power(
  984. tz->trips.active[i].devices.handles[j],
  985. &power_state);
  986. if (result || (power_state != ACPI_STATE_D0)) {
  987. tz->trips.active[i].flags.enabled = 0;
  988. break;
  989. }
  990. }
  991. tz->state.active |= tz->trips.active[i].flags.enabled;
  992. }
  993. acpi_thermal_check(tz);
  994. return AE_OK;
  995. }
  996. #endif
  997. static int thermal_act(const struct dmi_system_id *d) {
  998. if (act == 0) {
  999. printk(KERN_NOTICE "ACPI: %s detected: "
  1000. "disabling all active thermal trip points\n", d->ident);
  1001. act = -1;
  1002. }
  1003. return 0;
  1004. }
  1005. static int thermal_nocrt(const struct dmi_system_id *d) {
  1006. printk(KERN_NOTICE "ACPI: %s detected: "
  1007. "disabling all critical thermal trip point actions.\n", d->ident);
  1008. nocrt = 1;
  1009. return 0;
  1010. }
  1011. static int thermal_tzp(const struct dmi_system_id *d) {
  1012. if (tzp == 0) {
  1013. printk(KERN_NOTICE "ACPI: %s detected: "
  1014. "enabling thermal zone polling\n", d->ident);
  1015. tzp = 300; /* 300 dS = 30 Seconds */
  1016. }
  1017. return 0;
  1018. }
  1019. static int thermal_psv(const struct dmi_system_id *d) {
  1020. if (psv == 0) {
  1021. printk(KERN_NOTICE "ACPI: %s detected: "
  1022. "disabling all passive thermal trip points\n", d->ident);
  1023. psv = -1;
  1024. }
  1025. return 0;
  1026. }
  1027. static struct dmi_system_id thermal_dmi_table[] __initdata = {
  1028. /*
  1029. * Award BIOS on this AOpen makes thermal control almost worthless.
  1030. * http://bugzilla.kernel.org/show_bug.cgi?id=8842
  1031. */
  1032. {
  1033. .callback = thermal_act,
  1034. .ident = "AOpen i915GMm-HFS",
  1035. .matches = {
  1036. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1037. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1038. },
  1039. },
  1040. {
  1041. .callback = thermal_psv,
  1042. .ident = "AOpen i915GMm-HFS",
  1043. .matches = {
  1044. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1045. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1046. },
  1047. },
  1048. {
  1049. .callback = thermal_tzp,
  1050. .ident = "AOpen i915GMm-HFS",
  1051. .matches = {
  1052. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  1053. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  1054. },
  1055. },
  1056. {
  1057. .callback = thermal_nocrt,
  1058. .ident = "Gigabyte GA-7ZX",
  1059. .matches = {
  1060. DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
  1061. DMI_MATCH(DMI_BOARD_NAME, "7ZX"),
  1062. },
  1063. },
  1064. {}
  1065. };
  1066. static int __init acpi_thermal_init(void)
  1067. {
  1068. int result = 0;
  1069. dmi_check_system(thermal_dmi_table);
  1070. if (off) {
  1071. printk(KERN_NOTICE "ACPI: thermal control disabled\n");
  1072. return -ENODEV;
  1073. }
  1074. result = acpi_bus_register_driver(&acpi_thermal_driver);
  1075. if (result < 0)
  1076. return -ENODEV;
  1077. return 0;
  1078. }
  1079. static void __exit acpi_thermal_exit(void)
  1080. {
  1081. acpi_bus_unregister_driver(&acpi_thermal_driver);
  1082. return;
  1083. }
  1084. module_init(acpi_thermal_init);
  1085. module_exit(acpi_thermal_exit);