therm_adt746x.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Device driver for the i2c thermostat found on the iBook G4, Albook G4
  4. *
  5. * Copyright (C) 2003, 2004 Colin Leroy, Rasmus Rohde, Benjamin Herrenschmidt
  6. *
  7. * Documentation from 115254175ADT7467_pra.pdf and 3686221171167ADT7460_b.pdf
  8. * https://www.onsemi.com/PowerSolutions/product.do?id=ADT7467
  9. * https://www.onsemi.com/PowerSolutions/product.do?id=ADT7460
  10. *
  11. */
  12. #include <linux/types.h>
  13. #include <linux/module.h>
  14. #include <linux/errno.h>
  15. #include <linux/kernel.h>
  16. #include <linux/delay.h>
  17. #include <linux/sched.h>
  18. #include <linux/i2c.h>
  19. #include <linux/slab.h>
  20. #include <linux/init.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/wait.h>
  23. #include <linux/suspend.h>
  24. #include <linux/kthread.h>
  25. #include <linux/moduleparam.h>
  26. #include <linux/freezer.h>
  27. #include <linux/of_platform.h>
  28. #include <asm/prom.h>
  29. #include <asm/machdep.h>
  30. #include <asm/io.h>
  31. #include <asm/sections.h>
  32. #undef DEBUG
  33. #define CONFIG_REG 0x40
  34. #define MANUAL_MASK 0xe0
  35. #define AUTO_MASK 0x20
  36. #define INVERT_MASK 0x10
  37. static u8 TEMP_REG[3] = {0x26, 0x25, 0x27}; /* local, sensor1, sensor2 */
  38. static u8 LIMIT_REG[3] = {0x6b, 0x6a, 0x6c}; /* local, sensor1, sensor2 */
  39. static u8 MANUAL_MODE[2] = {0x5c, 0x5d};
  40. static u8 REM_CONTROL[2] = {0x00, 0x40};
  41. static u8 FAN_SPEED[2] = {0x28, 0x2a};
  42. static u8 FAN_SPD_SET[2] = {0x30, 0x31};
  43. static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */
  44. static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */
  45. static const char *sensor_location[3] = { "?", "?", "?" };
  46. static int limit_adjust;
  47. static int fan_speed = -1;
  48. static bool verbose;
  49. MODULE_AUTHOR("Colin Leroy <colin@colino.net>");
  50. MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and "
  51. "Powerbook G4 Alu");
  52. MODULE_LICENSE("GPL");
  53. module_param(limit_adjust, int, 0644);
  54. MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50 sensor1, 70 sensor2) "
  55. "by N degrees.");
  56. module_param(fan_speed, int, 0644);
  57. MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) "
  58. "(default 64)");
  59. module_param(verbose, bool, 0);
  60. MODULE_PARM_DESC(verbose,"Verbose log operations "
  61. "(default 0)");
  62. struct thermostat {
  63. struct i2c_client *clt;
  64. u8 temps[3];
  65. u8 cached_temp[3];
  66. u8 initial_limits[3];
  67. u8 limits[3];
  68. int last_speed[2];
  69. int last_var[2];
  70. int pwm_inv[2];
  71. struct task_struct *thread;
  72. struct platform_device *pdev;
  73. enum {
  74. ADT7460,
  75. ADT7467
  76. } type;
  77. };
  78. static void write_both_fan_speed(struct thermostat *th, int speed);
  79. static void write_fan_speed(struct thermostat *th, int speed, int fan);
  80. static int
  81. write_reg(struct thermostat* th, int reg, u8 data)
  82. {
  83. u8 tmp[2];
  84. int rc;
  85. tmp[0] = reg;
  86. tmp[1] = data;
  87. rc = i2c_master_send(th->clt, (const char *)tmp, 2);
  88. if (rc < 0)
  89. return rc;
  90. if (rc != 2)
  91. return -ENODEV;
  92. return 0;
  93. }
  94. static int
  95. read_reg(struct thermostat* th, int reg)
  96. {
  97. u8 reg_addr, data;
  98. int rc;
  99. reg_addr = (u8)reg;
  100. rc = i2c_master_send(th->clt, &reg_addr, 1);
  101. if (rc < 0)
  102. return rc;
  103. if (rc != 1)
  104. return -ENODEV;
  105. rc = i2c_master_recv(th->clt, (char *)&data, 1);
  106. if (rc < 0)
  107. return rc;
  108. return data;
  109. }
  110. static int read_fan_speed(struct thermostat *th, u8 addr)
  111. {
  112. u8 tmp[2];
  113. u16 res;
  114. /* should start with low byte */
  115. tmp[1] = read_reg(th, addr);
  116. tmp[0] = read_reg(th, addr + 1);
  117. res = tmp[1] + (tmp[0] << 8);
  118. /* "a value of 0xffff means that the fan has stopped" */
  119. return (res == 0xffff ? 0 : (90000*60)/res);
  120. }
  121. static void write_both_fan_speed(struct thermostat *th, int speed)
  122. {
  123. write_fan_speed(th, speed, 0);
  124. if (th->type == ADT7460)
  125. write_fan_speed(th, speed, 1);
  126. }
  127. static void write_fan_speed(struct thermostat *th, int speed, int fan)
  128. {
  129. u8 manual;
  130. if (speed > 0xff)
  131. speed = 0xff;
  132. else if (speed < -1)
  133. speed = 0;
  134. if (th->type == ADT7467 && fan == 1)
  135. return;
  136. if (th->last_speed[fan] != speed) {
  137. if (verbose) {
  138. if (speed == -1)
  139. printk(KERN_DEBUG "adt746x: Setting speed to automatic "
  140. "for %s fan.\n", sensor_location[fan+1]);
  141. else
  142. printk(KERN_DEBUG "adt746x: Setting speed to %d "
  143. "for %s fan.\n", speed, sensor_location[fan+1]);
  144. }
  145. } else
  146. return;
  147. if (speed >= 0) {
  148. manual = read_reg(th, MANUAL_MODE[fan]);
  149. manual &= ~INVERT_MASK;
  150. write_reg(th, MANUAL_MODE[fan],
  151. manual | MANUAL_MASK | th->pwm_inv[fan]);
  152. write_reg(th, FAN_SPD_SET[fan], speed);
  153. } else {
  154. /* back to automatic */
  155. if(th->type == ADT7460) {
  156. manual = read_reg(th,
  157. MANUAL_MODE[fan]) & (~MANUAL_MASK);
  158. manual &= ~INVERT_MASK;
  159. manual |= th->pwm_inv[fan];
  160. write_reg(th,
  161. MANUAL_MODE[fan], manual|REM_CONTROL[fan]);
  162. } else {
  163. manual = read_reg(th, MANUAL_MODE[fan]);
  164. manual &= ~INVERT_MASK;
  165. manual |= th->pwm_inv[fan];
  166. write_reg(th, MANUAL_MODE[fan], manual&(~AUTO_MASK));
  167. }
  168. }
  169. th->last_speed[fan] = speed;
  170. }
  171. static void read_sensors(struct thermostat *th)
  172. {
  173. int i = 0;
  174. for (i = 0; i < 3; i++)
  175. th->temps[i] = read_reg(th, TEMP_REG[i]);
  176. }
  177. #ifdef DEBUG
  178. static void display_stats(struct thermostat *th)
  179. {
  180. if (th->temps[0] != th->cached_temp[0]
  181. || th->temps[1] != th->cached_temp[1]
  182. || th->temps[2] != th->cached_temp[2]) {
  183. printk(KERN_INFO "adt746x: Temperature infos:"
  184. " thermostats: %d,%d,%d;"
  185. " limits: %d,%d,%d;"
  186. " fan speed: %d RPM\n",
  187. th->temps[0], th->temps[1], th->temps[2],
  188. th->limits[0], th->limits[1], th->limits[2],
  189. read_fan_speed(th, FAN_SPEED[0]));
  190. }
  191. th->cached_temp[0] = th->temps[0];
  192. th->cached_temp[1] = th->temps[1];
  193. th->cached_temp[2] = th->temps[2];
  194. }
  195. #endif
  196. static void update_fans_speed (struct thermostat *th)
  197. {
  198. int lastvar = 0; /* last variation, for iBook */
  199. int i = 0;
  200. /* we don't care about local sensor, so we start at sensor 1 */
  201. for (i = 1; i < 3; i++) {
  202. bool started = false;
  203. int fan_number = (th->type == ADT7460 && i == 2);
  204. int var = th->temps[i] - th->limits[i];
  205. if (var > -1) {
  206. int step = (255 - fan_speed) / 7;
  207. int new_speed = 0;
  208. /* hysteresis : change fan speed only if variation is
  209. * more than two degrees */
  210. if (abs(var - th->last_var[fan_number]) < 2)
  211. continue;
  212. started = true;
  213. new_speed = fan_speed + ((var-1)*step);
  214. if (new_speed < fan_speed)
  215. new_speed = fan_speed;
  216. if (new_speed > 255)
  217. new_speed = 255;
  218. if (verbose)
  219. printk(KERN_DEBUG "adt746x: Setting fans speed to %d "
  220. "(limit exceeded by %d on %s)\n",
  221. new_speed, var,
  222. sensor_location[fan_number+1]);
  223. write_both_fan_speed(th, new_speed);
  224. th->last_var[fan_number] = var;
  225. } else if (var < -2) {
  226. /* don't stop fan if sensor2 is cold and sensor1 is not
  227. * so cold (lastvar >= -1) */
  228. if (i == 2 && lastvar < -1) {
  229. if (th->last_speed[fan_number] != 0)
  230. if (verbose)
  231. printk(KERN_DEBUG "adt746x: Stopping "
  232. "fans.\n");
  233. write_both_fan_speed(th, 0);
  234. }
  235. }
  236. lastvar = var;
  237. if (started)
  238. return; /* we don't want to re-stop the fan
  239. * if sensor1 is heating and sensor2 is not */
  240. }
  241. }
  242. static int monitor_task(void *arg)
  243. {
  244. struct thermostat* th = arg;
  245. set_freezable();
  246. while(!kthread_should_stop()) {
  247. try_to_freeze();
  248. msleep_interruptible(2000);
  249. #ifndef DEBUG
  250. if (fan_speed != -1)
  251. read_sensors(th);
  252. #else
  253. read_sensors(th);
  254. #endif
  255. if (fan_speed != -1)
  256. update_fans_speed(th);
  257. #ifdef DEBUG
  258. display_stats(th);
  259. #endif
  260. }
  261. return 0;
  262. }
  263. static void set_limit(struct thermostat *th, int i)
  264. {
  265. /* Set sensor1 limit higher to avoid powerdowns */
  266. th->limits[i] = default_limits_chip[i] + limit_adjust;
  267. write_reg(th, LIMIT_REG[i], th->limits[i]);
  268. /* set our limits to normal */
  269. th->limits[i] = default_limits_local[i] + limit_adjust;
  270. }
  271. #define BUILD_SHOW_FUNC_INT(name, data) \
  272. static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
  273. { \
  274. struct thermostat *th = dev_get_drvdata(dev); \
  275. return sprintf(buf, "%d\n", data); \
  276. }
  277. #define BUILD_SHOW_FUNC_INT_LITE(name, data) \
  278. static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
  279. { \
  280. return sprintf(buf, "%d\n", data); \
  281. }
  282. #define BUILD_SHOW_FUNC_STR(name, data) \
  283. static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
  284. { \
  285. return sprintf(buf, "%s\n", data); \
  286. }
  287. #define BUILD_SHOW_FUNC_FAN(name, data) \
  288. static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
  289. { \
  290. struct thermostat *th = dev_get_drvdata(dev); \
  291. return sprintf(buf, "%d (%d rpm)\n", \
  292. th->last_speed[data], \
  293. read_fan_speed(th, FAN_SPEED[data]) \
  294. ); \
  295. }
  296. #define BUILD_STORE_FUNC_DEG(name, data) \
  297. static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
  298. { \
  299. struct thermostat *th = dev_get_drvdata(dev); \
  300. int val; \
  301. int i; \
  302. val = simple_strtol(buf, NULL, 10); \
  303. printk(KERN_INFO "Adjusting limits by %d degrees\n", val); \
  304. limit_adjust = val; \
  305. for (i=0; i < 3; i++) \
  306. set_limit(th, i); \
  307. return n; \
  308. }
  309. #define BUILD_STORE_FUNC_INT(name, data) \
  310. static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
  311. { \
  312. int val; \
  313. val = simple_strtol(buf, NULL, 10); \
  314. if (val < 0 || val > 255) \
  315. return -EINVAL; \
  316. printk(KERN_INFO "Setting specified fan speed to %d\n", val); \
  317. data = val; \
  318. return n; \
  319. }
  320. BUILD_SHOW_FUNC_INT(sensor1_temperature, (read_reg(th, TEMP_REG[1])))
  321. BUILD_SHOW_FUNC_INT(sensor2_temperature, (read_reg(th, TEMP_REG[2])))
  322. BUILD_SHOW_FUNC_INT(sensor1_limit, th->limits[1])
  323. BUILD_SHOW_FUNC_INT(sensor2_limit, th->limits[2])
  324. BUILD_SHOW_FUNC_STR(sensor1_location, sensor_location[1])
  325. BUILD_SHOW_FUNC_STR(sensor2_location, sensor_location[2])
  326. BUILD_SHOW_FUNC_INT_LITE(specified_fan_speed, fan_speed)
  327. BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed)
  328. BUILD_SHOW_FUNC_FAN(sensor1_fan_speed, 0)
  329. BUILD_SHOW_FUNC_FAN(sensor2_fan_speed, 1)
  330. BUILD_SHOW_FUNC_INT_LITE(limit_adjust, limit_adjust)
  331. BUILD_STORE_FUNC_DEG(limit_adjust, th)
  332. static DEVICE_ATTR(sensor1_temperature, S_IRUGO,
  333. show_sensor1_temperature,NULL);
  334. static DEVICE_ATTR(sensor2_temperature, S_IRUGO,
  335. show_sensor2_temperature,NULL);
  336. static DEVICE_ATTR(sensor1_limit, S_IRUGO,
  337. show_sensor1_limit, NULL);
  338. static DEVICE_ATTR(sensor2_limit, S_IRUGO,
  339. show_sensor2_limit, NULL);
  340. static DEVICE_ATTR(sensor1_location, S_IRUGO,
  341. show_sensor1_location, NULL);
  342. static DEVICE_ATTR(sensor2_location, S_IRUGO,
  343. show_sensor2_location, NULL);
  344. static DEVICE_ATTR(specified_fan_speed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
  345. show_specified_fan_speed,store_specified_fan_speed);
  346. static DEVICE_ATTR(sensor1_fan_speed, S_IRUGO,
  347. show_sensor1_fan_speed, NULL);
  348. static DEVICE_ATTR(sensor2_fan_speed, S_IRUGO,
  349. show_sensor2_fan_speed, NULL);
  350. static DEVICE_ATTR(limit_adjust, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
  351. show_limit_adjust, store_limit_adjust);
  352. static void thermostat_create_files(struct thermostat *th)
  353. {
  354. struct device_node *np = th->clt->dev.of_node;
  355. struct device *dev;
  356. int err;
  357. /* To maintain ABI compatibility with userspace, create
  358. * the old style platform driver and attach the attributes
  359. * to it here
  360. */
  361. th->pdev = of_platform_device_create(np, "temperatures", NULL);
  362. if (!th->pdev)
  363. return;
  364. dev = &th->pdev->dev;
  365. dev_set_drvdata(dev, th);
  366. err = device_create_file(dev, &dev_attr_sensor1_temperature);
  367. err |= device_create_file(dev, &dev_attr_sensor2_temperature);
  368. err |= device_create_file(dev, &dev_attr_sensor1_limit);
  369. err |= device_create_file(dev, &dev_attr_sensor2_limit);
  370. err |= device_create_file(dev, &dev_attr_sensor1_location);
  371. err |= device_create_file(dev, &dev_attr_sensor2_location);
  372. err |= device_create_file(dev, &dev_attr_limit_adjust);
  373. err |= device_create_file(dev, &dev_attr_specified_fan_speed);
  374. err |= device_create_file(dev, &dev_attr_sensor1_fan_speed);
  375. if(th->type == ADT7460)
  376. err |= device_create_file(dev, &dev_attr_sensor2_fan_speed);
  377. if (err)
  378. printk(KERN_WARNING
  379. "Failed to create temperature attribute file(s).\n");
  380. }
  381. static void thermostat_remove_files(struct thermostat *th)
  382. {
  383. struct device *dev;
  384. if (!th->pdev)
  385. return;
  386. dev = &th->pdev->dev;
  387. device_remove_file(dev, &dev_attr_sensor1_temperature);
  388. device_remove_file(dev, &dev_attr_sensor2_temperature);
  389. device_remove_file(dev, &dev_attr_sensor1_limit);
  390. device_remove_file(dev, &dev_attr_sensor2_limit);
  391. device_remove_file(dev, &dev_attr_sensor1_location);
  392. device_remove_file(dev, &dev_attr_sensor2_location);
  393. device_remove_file(dev, &dev_attr_limit_adjust);
  394. device_remove_file(dev, &dev_attr_specified_fan_speed);
  395. device_remove_file(dev, &dev_attr_sensor1_fan_speed);
  396. if (th->type == ADT7460)
  397. device_remove_file(dev, &dev_attr_sensor2_fan_speed);
  398. of_device_unregister(th->pdev);
  399. }
  400. static int probe_thermostat(struct i2c_client *client,
  401. const struct i2c_device_id *id)
  402. {
  403. struct device_node *np = client->dev.of_node;
  404. struct thermostat* th;
  405. const __be32 *prop;
  406. int i, rc, vers, offset = 0;
  407. if (!np)
  408. return -ENXIO;
  409. prop = of_get_property(np, "hwsensor-params-version", NULL);
  410. if (!prop)
  411. return -ENXIO;
  412. vers = be32_to_cpup(prop);
  413. printk(KERN_INFO "adt746x: version %d (%ssupported)\n",
  414. vers, vers == 1 ? "" : "un");
  415. if (vers != 1)
  416. return -ENXIO;
  417. if (of_get_property(np, "hwsensor-location", NULL)) {
  418. for (i = 0; i < 3; i++) {
  419. sensor_location[i] = of_get_property(np,
  420. "hwsensor-location", NULL) + offset;
  421. if (sensor_location[i] == NULL)
  422. sensor_location[i] = "";
  423. printk(KERN_INFO "sensor %d: %s\n", i, sensor_location[i]);
  424. offset += strlen(sensor_location[i]) + 1;
  425. }
  426. }
  427. th = kzalloc(sizeof(struct thermostat), GFP_KERNEL);
  428. if (!th)
  429. return -ENOMEM;
  430. i2c_set_clientdata(client, th);
  431. th->clt = client;
  432. th->type = id->driver_data;
  433. rc = read_reg(th, CONFIG_REG);
  434. if (rc < 0) {
  435. dev_err(&client->dev, "Thermostat failed to read config!\n");
  436. kfree(th);
  437. return -ENODEV;
  438. }
  439. /* force manual control to start the fan quieter */
  440. if (fan_speed == -1)
  441. fan_speed = 64;
  442. if (th->type == ADT7460) {
  443. printk(KERN_INFO "adt746x: ADT7460 initializing\n");
  444. /* The 7460 needs to be started explicitly */
  445. write_reg(th, CONFIG_REG, 1);
  446. } else
  447. printk(KERN_INFO "adt746x: ADT7467 initializing\n");
  448. for (i = 0; i < 3; i++) {
  449. th->initial_limits[i] = read_reg(th, LIMIT_REG[i]);
  450. set_limit(th, i);
  451. }
  452. printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
  453. " to %d, %d, %d\n",
  454. th->initial_limits[0], th->initial_limits[1],
  455. th->initial_limits[2], th->limits[0], th->limits[1],
  456. th->limits[2]);
  457. /* record invert bit status because fw can corrupt it after suspend */
  458. th->pwm_inv[0] = read_reg(th, MANUAL_MODE[0]) & INVERT_MASK;
  459. th->pwm_inv[1] = read_reg(th, MANUAL_MODE[1]) & INVERT_MASK;
  460. /* be sure to really write fan speed the first time */
  461. th->last_speed[0] = -2;
  462. th->last_speed[1] = -2;
  463. th->last_var[0] = -80;
  464. th->last_var[1] = -80;
  465. if (fan_speed != -1) {
  466. /* manual mode, stop fans */
  467. write_both_fan_speed(th, 0);
  468. } else {
  469. /* automatic mode */
  470. write_both_fan_speed(th, -1);
  471. }
  472. th->thread = kthread_run(monitor_task, th, "kfand");
  473. if (th->thread == ERR_PTR(-ENOMEM)) {
  474. printk(KERN_INFO "adt746x: Kthread creation failed\n");
  475. th->thread = NULL;
  476. return -ENOMEM;
  477. }
  478. thermostat_create_files(th);
  479. return 0;
  480. }
  481. static int remove_thermostat(struct i2c_client *client)
  482. {
  483. struct thermostat *th = i2c_get_clientdata(client);
  484. int i;
  485. thermostat_remove_files(th);
  486. if (th->thread != NULL)
  487. kthread_stop(th->thread);
  488. printk(KERN_INFO "adt746x: Putting max temperatures back from "
  489. "%d, %d, %d to %d, %d, %d\n",
  490. th->limits[0], th->limits[1], th->limits[2],
  491. th->initial_limits[0], th->initial_limits[1],
  492. th->initial_limits[2]);
  493. for (i = 0; i < 3; i++)
  494. write_reg(th, LIMIT_REG[i], th->initial_limits[i]);
  495. write_both_fan_speed(th, -1);
  496. kfree(th);
  497. return 0;
  498. }
  499. static const struct i2c_device_id therm_adt746x_id[] = {
  500. { "MAC,adt7460", ADT7460 },
  501. { "MAC,adt7467", ADT7467 },
  502. { }
  503. };
  504. MODULE_DEVICE_TABLE(i2c, therm_adt746x_id);
  505. static struct i2c_driver thermostat_driver = {
  506. .driver = {
  507. .name = "therm_adt746x",
  508. },
  509. .probe = probe_thermostat,
  510. .remove = remove_thermostat,
  511. .id_table = therm_adt746x_id,
  512. };
  513. static int __init thermostat_init(void)
  514. {
  515. #ifndef CONFIG_I2C_POWERMAC
  516. request_module("i2c-powermac");
  517. #endif
  518. return i2c_add_driver(&thermostat_driver);
  519. }
  520. static void __exit thermostat_exit(void)
  521. {
  522. i2c_del_driver(&thermostat_driver);
  523. }
  524. module_init(thermostat_init);
  525. module_exit(thermostat_exit);