therm_adt746x.c 16 KB

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