i5k_amb.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. * A hwmon driver for the Intel 5000 series chipset FB-DIMM AMB
  3. * temperature sensors
  4. * Copyright (C) 2007 IBM
  5. *
  6. * Author: Darrick J. Wong <djwong@us.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/module.h>
  23. #include <linux/jiffies.h>
  24. #include <linux/hwmon.h>
  25. #include <linux/hwmon-sysfs.h>
  26. #include <linux/err.h>
  27. #include <linux/mutex.h>
  28. #include <linux/delay.h>
  29. #include <linux/log2.h>
  30. #include <linux/pci.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/slab.h>
  33. #define DRVNAME "i5k_amb"
  34. #define I5K_REG_AMB_BASE_ADDR 0x48
  35. #define I5K_REG_AMB_LEN_ADDR 0x50
  36. #define I5K_REG_CHAN0_PRESENCE_ADDR 0x64
  37. #define I5K_REG_CHAN1_PRESENCE_ADDR 0x66
  38. #define AMB_REG_TEMP_MIN_ADDR 0x80
  39. #define AMB_REG_TEMP_MID_ADDR 0x81
  40. #define AMB_REG_TEMP_MAX_ADDR 0x82
  41. #define AMB_REG_TEMP_STATUS_ADDR 0x84
  42. #define AMB_REG_TEMP_ADDR 0x85
  43. #define AMB_CONFIG_SIZE 2048
  44. #define AMB_FUNC_3_OFFSET 768
  45. static unsigned long amb_reg_temp_status(unsigned int amb)
  46. {
  47. return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_STATUS_ADDR +
  48. AMB_CONFIG_SIZE * amb;
  49. }
  50. static unsigned long amb_reg_temp_min(unsigned int amb)
  51. {
  52. return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MIN_ADDR +
  53. AMB_CONFIG_SIZE * amb;
  54. }
  55. static unsigned long amb_reg_temp_mid(unsigned int amb)
  56. {
  57. return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MID_ADDR +
  58. AMB_CONFIG_SIZE * amb;
  59. }
  60. static unsigned long amb_reg_temp_max(unsigned int amb)
  61. {
  62. return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MAX_ADDR +
  63. AMB_CONFIG_SIZE * amb;
  64. }
  65. static unsigned long amb_reg_temp(unsigned int amb)
  66. {
  67. return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_ADDR +
  68. AMB_CONFIG_SIZE * amb;
  69. }
  70. #define MAX_MEM_CHANNELS 4
  71. #define MAX_AMBS_PER_CHANNEL 16
  72. #define MAX_AMBS (MAX_MEM_CHANNELS * \
  73. MAX_AMBS_PER_CHANNEL)
  74. #define CHANNEL_SHIFT 4
  75. #define DIMM_MASK 0xF
  76. /*
  77. * Ugly hack: For some reason the highest bit is set if there
  78. * are _any_ DIMMs in the channel. Attempting to read from
  79. * this "high-order" AMB results in a memory bus error, so
  80. * for now we'll just ignore that top bit, even though that
  81. * might prevent us from seeing the 16th DIMM in the channel.
  82. */
  83. #define REAL_MAX_AMBS_PER_CHANNEL 15
  84. #define KNOBS_PER_AMB 6
  85. static unsigned long amb_num_from_reg(unsigned int byte_num, unsigned int bit)
  86. {
  87. return byte_num * MAX_AMBS_PER_CHANNEL + bit;
  88. }
  89. #define AMB_SYSFS_NAME_LEN 16
  90. struct i5k_device_attribute {
  91. struct sensor_device_attribute s_attr;
  92. char name[AMB_SYSFS_NAME_LEN];
  93. };
  94. struct i5k_amb_data {
  95. struct device *hwmon_dev;
  96. unsigned long amb_base;
  97. unsigned long amb_len;
  98. u16 amb_present[MAX_MEM_CHANNELS];
  99. void __iomem *amb_mmio;
  100. struct i5k_device_attribute *attrs;
  101. unsigned int num_attrs;
  102. unsigned long chipset_id;
  103. };
  104. static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
  105. char *buf)
  106. {
  107. return sprintf(buf, "%s\n", DRVNAME);
  108. }
  109. static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
  110. static struct platform_device *amb_pdev;
  111. static u8 amb_read_byte(struct i5k_amb_data *data, unsigned long offset)
  112. {
  113. return ioread8(data->amb_mmio + offset);
  114. }
  115. static void amb_write_byte(struct i5k_amb_data *data, unsigned long offset,
  116. u8 val)
  117. {
  118. iowrite8(val, data->amb_mmio + offset);
  119. }
  120. static ssize_t show_amb_alarm(struct device *dev,
  121. struct device_attribute *devattr,
  122. char *buf)
  123. {
  124. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  125. struct i5k_amb_data *data = dev_get_drvdata(dev);
  126. if (!(amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x20) &&
  127. (amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x8))
  128. return sprintf(buf, "1\n");
  129. else
  130. return sprintf(buf, "0\n");
  131. }
  132. static ssize_t store_amb_min(struct device *dev,
  133. struct device_attribute *devattr,
  134. const char *buf,
  135. size_t count)
  136. {
  137. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  138. struct i5k_amb_data *data = dev_get_drvdata(dev);
  139. unsigned long temp = simple_strtoul(buf, NULL, 10) / 500;
  140. if (temp > 255)
  141. temp = 255;
  142. amb_write_byte(data, amb_reg_temp_min(attr->index), temp);
  143. return count;
  144. }
  145. static ssize_t store_amb_mid(struct device *dev,
  146. struct device_attribute *devattr,
  147. const char *buf,
  148. size_t count)
  149. {
  150. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  151. struct i5k_amb_data *data = dev_get_drvdata(dev);
  152. unsigned long temp = simple_strtoul(buf, NULL, 10) / 500;
  153. if (temp > 255)
  154. temp = 255;
  155. amb_write_byte(data, amb_reg_temp_mid(attr->index), temp);
  156. return count;
  157. }
  158. static ssize_t store_amb_max(struct device *dev,
  159. struct device_attribute *devattr,
  160. const char *buf,
  161. size_t count)
  162. {
  163. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  164. struct i5k_amb_data *data = dev_get_drvdata(dev);
  165. unsigned long temp = simple_strtoul(buf, NULL, 10) / 500;
  166. if (temp > 255)
  167. temp = 255;
  168. amb_write_byte(data, amb_reg_temp_max(attr->index), temp);
  169. return count;
  170. }
  171. static ssize_t show_amb_min(struct device *dev,
  172. struct device_attribute *devattr,
  173. char *buf)
  174. {
  175. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  176. struct i5k_amb_data *data = dev_get_drvdata(dev);
  177. return sprintf(buf, "%d\n",
  178. 500 * amb_read_byte(data, amb_reg_temp_min(attr->index)));
  179. }
  180. static ssize_t show_amb_mid(struct device *dev,
  181. struct device_attribute *devattr,
  182. char *buf)
  183. {
  184. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  185. struct i5k_amb_data *data = dev_get_drvdata(dev);
  186. return sprintf(buf, "%d\n",
  187. 500 * amb_read_byte(data, amb_reg_temp_mid(attr->index)));
  188. }
  189. static ssize_t show_amb_max(struct device *dev,
  190. struct device_attribute *devattr,
  191. char *buf)
  192. {
  193. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  194. struct i5k_amb_data *data = dev_get_drvdata(dev);
  195. return sprintf(buf, "%d\n",
  196. 500 * amb_read_byte(data, amb_reg_temp_max(attr->index)));
  197. }
  198. static ssize_t show_amb_temp(struct device *dev,
  199. struct device_attribute *devattr,
  200. char *buf)
  201. {
  202. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  203. struct i5k_amb_data *data = dev_get_drvdata(dev);
  204. return sprintf(buf, "%d\n",
  205. 500 * amb_read_byte(data, amb_reg_temp(attr->index)));
  206. }
  207. static ssize_t show_label(struct device *dev,
  208. struct device_attribute *devattr,
  209. char *buf)
  210. {
  211. struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  212. return sprintf(buf, "Ch. %d DIMM %d\n", attr->index >> CHANNEL_SHIFT,
  213. attr->index & DIMM_MASK);
  214. }
  215. static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
  216. {
  217. int i, j, k, d = 0;
  218. u16 c;
  219. int res = 0;
  220. int num_ambs = 0;
  221. struct i5k_amb_data *data = platform_get_drvdata(pdev);
  222. /* Count the number of AMBs found */
  223. /* ignore the high-order bit, see "Ugly hack" comment above */
  224. for (i = 0; i < MAX_MEM_CHANNELS; i++)
  225. num_ambs += hweight16(data->amb_present[i] & 0x7fff);
  226. /* Set up sysfs stuff */
  227. data->attrs = kzalloc(sizeof(*data->attrs) * num_ambs * KNOBS_PER_AMB,
  228. GFP_KERNEL);
  229. if (!data->attrs)
  230. return -ENOMEM;
  231. data->num_attrs = 0;
  232. for (i = 0; i < MAX_MEM_CHANNELS; i++) {
  233. c = data->amb_present[i];
  234. for (j = 0; j < REAL_MAX_AMBS_PER_CHANNEL; j++, c >>= 1) {
  235. struct i5k_device_attribute *iattr;
  236. k = amb_num_from_reg(i, j);
  237. if (!(c & 0x1))
  238. continue;
  239. d++;
  240. /* sysfs label */
  241. iattr = data->attrs + data->num_attrs;
  242. snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
  243. "temp%d_label", d);
  244. iattr->s_attr.dev_attr.attr.name = iattr->name;
  245. iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
  246. iattr->s_attr.dev_attr.show = show_label;
  247. iattr->s_attr.index = k;
  248. sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
  249. res = device_create_file(&pdev->dev,
  250. &iattr->s_attr.dev_attr);
  251. if (res)
  252. goto exit_remove;
  253. data->num_attrs++;
  254. /* Temperature sysfs knob */
  255. iattr = data->attrs + data->num_attrs;
  256. snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
  257. "temp%d_input", d);
  258. iattr->s_attr.dev_attr.attr.name = iattr->name;
  259. iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
  260. iattr->s_attr.dev_attr.show = show_amb_temp;
  261. iattr->s_attr.index = k;
  262. sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
  263. res = device_create_file(&pdev->dev,
  264. &iattr->s_attr.dev_attr);
  265. if (res)
  266. goto exit_remove;
  267. data->num_attrs++;
  268. /* Temperature min sysfs knob */
  269. iattr = data->attrs + data->num_attrs;
  270. snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
  271. "temp%d_min", d);
  272. iattr->s_attr.dev_attr.attr.name = iattr->name;
  273. iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
  274. iattr->s_attr.dev_attr.show = show_amb_min;
  275. iattr->s_attr.dev_attr.store = store_amb_min;
  276. iattr->s_attr.index = k;
  277. sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
  278. res = device_create_file(&pdev->dev,
  279. &iattr->s_attr.dev_attr);
  280. if (res)
  281. goto exit_remove;
  282. data->num_attrs++;
  283. /* Temperature mid sysfs knob */
  284. iattr = data->attrs + data->num_attrs;
  285. snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
  286. "temp%d_mid", d);
  287. iattr->s_attr.dev_attr.attr.name = iattr->name;
  288. iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
  289. iattr->s_attr.dev_attr.show = show_amb_mid;
  290. iattr->s_attr.dev_attr.store = store_amb_mid;
  291. iattr->s_attr.index = k;
  292. sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
  293. res = device_create_file(&pdev->dev,
  294. &iattr->s_attr.dev_attr);
  295. if (res)
  296. goto exit_remove;
  297. data->num_attrs++;
  298. /* Temperature max sysfs knob */
  299. iattr = data->attrs + data->num_attrs;
  300. snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
  301. "temp%d_max", d);
  302. iattr->s_attr.dev_attr.attr.name = iattr->name;
  303. iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
  304. iattr->s_attr.dev_attr.show = show_amb_max;
  305. iattr->s_attr.dev_attr.store = store_amb_max;
  306. iattr->s_attr.index = k;
  307. sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
  308. res = device_create_file(&pdev->dev,
  309. &iattr->s_attr.dev_attr);
  310. if (res)
  311. goto exit_remove;
  312. data->num_attrs++;
  313. /* Temperature alarm sysfs knob */
  314. iattr = data->attrs + data->num_attrs;
  315. snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
  316. "temp%d_alarm", d);
  317. iattr->s_attr.dev_attr.attr.name = iattr->name;
  318. iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
  319. iattr->s_attr.dev_attr.show = show_amb_alarm;
  320. iattr->s_attr.index = k;
  321. sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
  322. res = device_create_file(&pdev->dev,
  323. &iattr->s_attr.dev_attr);
  324. if (res)
  325. goto exit_remove;
  326. data->num_attrs++;
  327. }
  328. }
  329. res = device_create_file(&pdev->dev, &dev_attr_name);
  330. if (res)
  331. goto exit_remove;
  332. data->hwmon_dev = hwmon_device_register(&pdev->dev);
  333. if (IS_ERR(data->hwmon_dev)) {
  334. res = PTR_ERR(data->hwmon_dev);
  335. goto exit_remove;
  336. }
  337. return res;
  338. exit_remove:
  339. device_remove_file(&pdev->dev, &dev_attr_name);
  340. for (i = 0; i < data->num_attrs; i++)
  341. device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr);
  342. kfree(data->attrs);
  343. return res;
  344. }
  345. static int __devinit i5k_amb_add(void)
  346. {
  347. int res = -ENODEV;
  348. /* only ever going to be one of these */
  349. amb_pdev = platform_device_alloc(DRVNAME, 0);
  350. if (!amb_pdev)
  351. return -ENOMEM;
  352. res = platform_device_add(amb_pdev);
  353. if (res)
  354. goto err;
  355. return 0;
  356. err:
  357. platform_device_put(amb_pdev);
  358. return res;
  359. }
  360. static int __devinit i5k_find_amb_registers(struct i5k_amb_data *data,
  361. unsigned long devid)
  362. {
  363. struct pci_dev *pcidev;
  364. u32 val32;
  365. int res = -ENODEV;
  366. /* Find AMB register memory space */
  367. pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
  368. devid,
  369. NULL);
  370. if (!pcidev)
  371. return -ENODEV;
  372. if (pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32))
  373. goto out;
  374. data->amb_base = val32;
  375. if (pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32))
  376. goto out;
  377. data->amb_len = val32;
  378. /* Is it big enough? */
  379. if (data->amb_len < AMB_CONFIG_SIZE * MAX_AMBS) {
  380. dev_err(&pcidev->dev, "AMB region too small!\n");
  381. goto out;
  382. }
  383. data->chipset_id = devid;
  384. res = 0;
  385. out:
  386. pci_dev_put(pcidev);
  387. return res;
  388. }
  389. static int __devinit i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
  390. {
  391. struct pci_dev *pcidev;
  392. u16 val16;
  393. int res = -ENODEV;
  394. /* Copy the DIMM presence map for these two channels */
  395. pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, NULL);
  396. if (!pcidev)
  397. return -ENODEV;
  398. if (pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16))
  399. goto out;
  400. amb_present[0] = val16;
  401. if (pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16))
  402. goto out;
  403. amb_present[1] = val16;
  404. res = 0;
  405. out:
  406. pci_dev_put(pcidev);
  407. return res;
  408. }
  409. static unsigned long i5k_channel_pci_id(struct i5k_amb_data *data,
  410. unsigned long channel)
  411. {
  412. switch (data->chipset_id) {
  413. case PCI_DEVICE_ID_INTEL_5000_ERR:
  414. return PCI_DEVICE_ID_INTEL_5000_FBD0 + channel;
  415. case PCI_DEVICE_ID_INTEL_5400_ERR:
  416. return PCI_DEVICE_ID_INTEL_5400_FBD0 + channel;
  417. default:
  418. BUG();
  419. }
  420. }
  421. static unsigned long chipset_ids[] = {
  422. PCI_DEVICE_ID_INTEL_5000_ERR,
  423. PCI_DEVICE_ID_INTEL_5400_ERR,
  424. 0
  425. };
  426. #ifdef MODULE
  427. static struct pci_device_id i5k_amb_ids[] __devinitdata = {
  428. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
  429. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
  430. { 0, }
  431. };
  432. MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
  433. #endif
  434. static int __devinit i5k_amb_probe(struct platform_device *pdev)
  435. {
  436. struct i5k_amb_data *data;
  437. struct resource *reso;
  438. int i;
  439. int res = -ENODEV;
  440. data = kzalloc(sizeof(*data), GFP_KERNEL);
  441. if (!data)
  442. return -ENOMEM;
  443. /* Figure out where the AMB registers live */
  444. i = 0;
  445. do {
  446. res = i5k_find_amb_registers(data, chipset_ids[i]);
  447. i++;
  448. } while (res && chipset_ids[i]);
  449. if (res)
  450. goto err;
  451. /* Copy the DIMM presence map for the first two channels */
  452. res = i5k_channel_probe(&data->amb_present[0],
  453. i5k_channel_pci_id(data, 0));
  454. if (res)
  455. goto err;
  456. /* Copy the DIMM presence map for the optional second two channels */
  457. i5k_channel_probe(&data->amb_present[2],
  458. i5k_channel_pci_id(data, 1));
  459. /* Set up resource regions */
  460. reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);
  461. if (!reso) {
  462. res = -EBUSY;
  463. goto err;
  464. }
  465. data->amb_mmio = ioremap_nocache(data->amb_base, data->amb_len);
  466. if (!data->amb_mmio) {
  467. res = -EBUSY;
  468. goto err_map_failed;
  469. }
  470. platform_set_drvdata(pdev, data);
  471. res = i5k_amb_hwmon_init(pdev);
  472. if (res)
  473. goto err_init_failed;
  474. return res;
  475. err_init_failed:
  476. iounmap(data->amb_mmio);
  477. platform_set_drvdata(pdev, NULL);
  478. err_map_failed:
  479. release_mem_region(data->amb_base, data->amb_len);
  480. err:
  481. kfree(data);
  482. return res;
  483. }
  484. static int __devexit i5k_amb_remove(struct platform_device *pdev)
  485. {
  486. int i;
  487. struct i5k_amb_data *data = platform_get_drvdata(pdev);
  488. hwmon_device_unregister(data->hwmon_dev);
  489. device_remove_file(&pdev->dev, &dev_attr_name);
  490. for (i = 0; i < data->num_attrs; i++)
  491. device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr);
  492. kfree(data->attrs);
  493. iounmap(data->amb_mmio);
  494. release_mem_region(data->amb_base, data->amb_len);
  495. platform_set_drvdata(pdev, NULL);
  496. kfree(data);
  497. return 0;
  498. }
  499. static struct platform_driver i5k_amb_driver = {
  500. .driver = {
  501. .owner = THIS_MODULE,
  502. .name = DRVNAME,
  503. },
  504. .probe = i5k_amb_probe,
  505. .remove = __devexit_p(i5k_amb_remove),
  506. };
  507. static int __init i5k_amb_init(void)
  508. {
  509. int res;
  510. res = platform_driver_register(&i5k_amb_driver);
  511. if (res)
  512. return res;
  513. res = i5k_amb_add();
  514. if (res)
  515. platform_driver_unregister(&i5k_amb_driver);
  516. return res;
  517. }
  518. static void __exit i5k_amb_exit(void)
  519. {
  520. platform_device_unregister(amb_pdev);
  521. platform_driver_unregister(&i5k_amb_driver);
  522. }
  523. MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
  524. MODULE_DESCRIPTION("Intel 5000 chipset FB-DIMM AMB temperature sensor");
  525. MODULE_LICENSE("GPL");
  526. module_init(i5k_amb_init);
  527. module_exit(i5k_amb_exit);