thermal.c 31 KB

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