ltc4245.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*
  2. * Driver for Linear Technology LTC4245 I2C Multiple Supply Hot Swap Controller
  3. *
  4. * Copyright (C) 2008 Ira W. Snyder <iws@ovro.caltech.edu>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This driver is based on the ds1621 and ina209 drivers.
  11. *
  12. * Datasheet:
  13. * http://www.linear.com/pc/downloadDocument.do?navId=H0,C1,C1003,C1006,C1140,P19392,D13517
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/init.h>
  18. #include <linux/err.h>
  19. #include <linux/slab.h>
  20. #include <linux/i2c.h>
  21. #include <linux/hwmon.h>
  22. #include <linux/hwmon-sysfs.h>
  23. #include <linux/i2c/ltc4245.h>
  24. /* Here are names of the chip's registers (a.k.a. commands) */
  25. enum ltc4245_cmd {
  26. LTC4245_STATUS = 0x00, /* readonly */
  27. LTC4245_ALERT = 0x01,
  28. LTC4245_CONTROL = 0x02,
  29. LTC4245_ON = 0x03,
  30. LTC4245_FAULT1 = 0x04,
  31. LTC4245_FAULT2 = 0x05,
  32. LTC4245_GPIO = 0x06,
  33. LTC4245_ADCADR = 0x07,
  34. LTC4245_12VIN = 0x10,
  35. LTC4245_12VSENSE = 0x11,
  36. LTC4245_12VOUT = 0x12,
  37. LTC4245_5VIN = 0x13,
  38. LTC4245_5VSENSE = 0x14,
  39. LTC4245_5VOUT = 0x15,
  40. LTC4245_3VIN = 0x16,
  41. LTC4245_3VSENSE = 0x17,
  42. LTC4245_3VOUT = 0x18,
  43. LTC4245_VEEIN = 0x19,
  44. LTC4245_VEESENSE = 0x1a,
  45. LTC4245_VEEOUT = 0x1b,
  46. LTC4245_GPIOADC = 0x1c,
  47. };
  48. struct ltc4245_data {
  49. struct device *hwmon_dev;
  50. struct mutex update_lock;
  51. bool valid;
  52. unsigned long last_updated; /* in jiffies */
  53. /* Control registers */
  54. u8 cregs[0x08];
  55. /* Voltage registers */
  56. u8 vregs[0x0d];
  57. /* GPIO ADC registers */
  58. bool use_extra_gpios;
  59. int gpios[3];
  60. };
  61. /*
  62. * Update the readings from the GPIO pins. If the driver has been configured to
  63. * sample all GPIO's as analog voltages, a round-robin sampling method is used.
  64. * Otherwise, only the configured GPIO pin is sampled.
  65. *
  66. * LOCKING: must hold data->update_lock
  67. */
  68. static void ltc4245_update_gpios(struct device *dev)
  69. {
  70. struct i2c_client *client = to_i2c_client(dev);
  71. struct ltc4245_data *data = i2c_get_clientdata(client);
  72. u8 gpio_curr, gpio_next, gpio_reg;
  73. int i;
  74. /* no extra gpio support, we're basically done */
  75. if (!data->use_extra_gpios) {
  76. data->gpios[0] = data->vregs[LTC4245_GPIOADC - 0x10];
  77. return;
  78. }
  79. /*
  80. * If the last reading was too long ago, then we mark all old GPIO
  81. * readings as stale by setting them to -EAGAIN
  82. */
  83. if (time_after(jiffies, data->last_updated + 5 * HZ)) {
  84. dev_dbg(&client->dev, "Marking GPIOs invalid\n");
  85. for (i = 0; i < ARRAY_SIZE(data->gpios); i++)
  86. data->gpios[i] = -EAGAIN;
  87. }
  88. /*
  89. * Get the current GPIO pin
  90. *
  91. * The datasheet calls these GPIO[1-3], but we'll calculate the zero
  92. * based array index instead, and call them GPIO[0-2]. This is much
  93. * easier to think about.
  94. */
  95. gpio_curr = (data->cregs[LTC4245_GPIO] & 0xc0) >> 6;
  96. if (gpio_curr > 0)
  97. gpio_curr -= 1;
  98. /* Read the GPIO voltage from the GPIOADC register */
  99. data->gpios[gpio_curr] = data->vregs[LTC4245_GPIOADC - 0x10];
  100. /* Find the next GPIO pin to read */
  101. gpio_next = (gpio_curr + 1) % ARRAY_SIZE(data->gpios);
  102. /*
  103. * Calculate the correct setting for the GPIO register so it will
  104. * sample the next GPIO pin
  105. */
  106. gpio_reg = (data->cregs[LTC4245_GPIO] & 0x3f) | ((gpio_next + 1) << 6);
  107. /* Update the GPIO register */
  108. i2c_smbus_write_byte_data(client, LTC4245_GPIO, gpio_reg);
  109. /* Update saved data */
  110. data->cregs[LTC4245_GPIO] = gpio_reg;
  111. }
  112. static struct ltc4245_data *ltc4245_update_device(struct device *dev)
  113. {
  114. struct i2c_client *client = to_i2c_client(dev);
  115. struct ltc4245_data *data = i2c_get_clientdata(client);
  116. s32 val;
  117. int i;
  118. mutex_lock(&data->update_lock);
  119. if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
  120. dev_dbg(&client->dev, "Starting ltc4245 update\n");
  121. /* Read control registers -- 0x00 to 0x07 */
  122. for (i = 0; i < ARRAY_SIZE(data->cregs); i++) {
  123. val = i2c_smbus_read_byte_data(client, i);
  124. if (unlikely(val < 0))
  125. data->cregs[i] = 0;
  126. else
  127. data->cregs[i] = val;
  128. }
  129. /* Read voltage registers -- 0x10 to 0x1c */
  130. for (i = 0; i < ARRAY_SIZE(data->vregs); i++) {
  131. val = i2c_smbus_read_byte_data(client, i+0x10);
  132. if (unlikely(val < 0))
  133. data->vregs[i] = 0;
  134. else
  135. data->vregs[i] = val;
  136. }
  137. /* Update GPIO readings */
  138. ltc4245_update_gpios(dev);
  139. data->last_updated = jiffies;
  140. data->valid = 1;
  141. }
  142. mutex_unlock(&data->update_lock);
  143. return data;
  144. }
  145. /* Return the voltage from the given register in millivolts */
  146. static int ltc4245_get_voltage(struct device *dev, u8 reg)
  147. {
  148. struct ltc4245_data *data = ltc4245_update_device(dev);
  149. const u8 regval = data->vregs[reg - 0x10];
  150. u32 voltage = 0;
  151. switch (reg) {
  152. case LTC4245_12VIN:
  153. case LTC4245_12VOUT:
  154. voltage = regval * 55;
  155. break;
  156. case LTC4245_5VIN:
  157. case LTC4245_5VOUT:
  158. voltage = regval * 22;
  159. break;
  160. case LTC4245_3VIN:
  161. case LTC4245_3VOUT:
  162. voltage = regval * 15;
  163. break;
  164. case LTC4245_VEEIN:
  165. case LTC4245_VEEOUT:
  166. voltage = regval * -55;
  167. break;
  168. case LTC4245_GPIOADC:
  169. voltage = regval * 10;
  170. break;
  171. default:
  172. /* If we get here, the developer messed up */
  173. WARN_ON_ONCE(1);
  174. break;
  175. }
  176. return voltage;
  177. }
  178. /* Return the current in the given sense register in milliAmperes */
  179. static unsigned int ltc4245_get_current(struct device *dev, u8 reg)
  180. {
  181. struct ltc4245_data *data = ltc4245_update_device(dev);
  182. const u8 regval = data->vregs[reg - 0x10];
  183. unsigned int voltage;
  184. unsigned int curr;
  185. /* The strange looking conversions that follow are fixed-point
  186. * math, since we cannot do floating point in the kernel.
  187. *
  188. * Step 1: convert sense register to microVolts
  189. * Step 2: convert voltage to milliAmperes
  190. *
  191. * If you play around with the V=IR equation, you come up with
  192. * the following: X uV / Y mOhm == Z mA
  193. *
  194. * With the resistors that are fractions of a milliOhm, we multiply
  195. * the voltage and resistance by 10, to shift the decimal point.
  196. * Now we can use the normal division operator again.
  197. */
  198. switch (reg) {
  199. case LTC4245_12VSENSE:
  200. voltage = regval * 250; /* voltage in uV */
  201. curr = voltage / 50; /* sense resistor 50 mOhm */
  202. break;
  203. case LTC4245_5VSENSE:
  204. voltage = regval * 125; /* voltage in uV */
  205. curr = (voltage * 10) / 35; /* sense resistor 3.5 mOhm */
  206. break;
  207. case LTC4245_3VSENSE:
  208. voltage = regval * 125; /* voltage in uV */
  209. curr = (voltage * 10) / 25; /* sense resistor 2.5 mOhm */
  210. break;
  211. case LTC4245_VEESENSE:
  212. voltage = regval * 250; /* voltage in uV */
  213. curr = voltage / 100; /* sense resistor 100 mOhm */
  214. break;
  215. default:
  216. /* If we get here, the developer messed up */
  217. WARN_ON_ONCE(1);
  218. curr = 0;
  219. break;
  220. }
  221. return curr;
  222. }
  223. static ssize_t ltc4245_show_voltage(struct device *dev,
  224. struct device_attribute *da,
  225. char *buf)
  226. {
  227. struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
  228. const int voltage = ltc4245_get_voltage(dev, attr->index);
  229. return snprintf(buf, PAGE_SIZE, "%d\n", voltage);
  230. }
  231. static ssize_t ltc4245_show_current(struct device *dev,
  232. struct device_attribute *da,
  233. char *buf)
  234. {
  235. struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
  236. const unsigned int curr = ltc4245_get_current(dev, attr->index);
  237. return snprintf(buf, PAGE_SIZE, "%u\n", curr);
  238. }
  239. static ssize_t ltc4245_show_power(struct device *dev,
  240. struct device_attribute *da,
  241. char *buf)
  242. {
  243. struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
  244. const unsigned int curr = ltc4245_get_current(dev, attr->index);
  245. const int output_voltage = ltc4245_get_voltage(dev, attr->index+1);
  246. /* current in mA * voltage in mV == power in uW */
  247. const unsigned int power = abs(output_voltage * curr);
  248. return snprintf(buf, PAGE_SIZE, "%u\n", power);
  249. }
  250. static ssize_t ltc4245_show_alarm(struct device *dev,
  251. struct device_attribute *da,
  252. char *buf)
  253. {
  254. struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da);
  255. struct ltc4245_data *data = ltc4245_update_device(dev);
  256. const u8 reg = data->cregs[attr->index];
  257. const u32 mask = attr->nr;
  258. return snprintf(buf, PAGE_SIZE, "%u\n", (reg & mask) ? 1 : 0);
  259. }
  260. static ssize_t ltc4245_show_gpio(struct device *dev,
  261. struct device_attribute *da,
  262. char *buf)
  263. {
  264. struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
  265. struct ltc4245_data *data = ltc4245_update_device(dev);
  266. int val = data->gpios[attr->index];
  267. /* handle stale GPIO's */
  268. if (val < 0)
  269. return val;
  270. /* Convert to millivolts and print */
  271. return snprintf(buf, PAGE_SIZE, "%u\n", val * 10);
  272. }
  273. /* These macros are used below in constructing device attribute objects
  274. * for use with sysfs_create_group() to make a sysfs device file
  275. * for each register.
  276. */
  277. #define LTC4245_VOLTAGE(name, ltc4245_cmd_idx) \
  278. static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
  279. ltc4245_show_voltage, NULL, ltc4245_cmd_idx)
  280. #define LTC4245_CURRENT(name, ltc4245_cmd_idx) \
  281. static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
  282. ltc4245_show_current, NULL, ltc4245_cmd_idx)
  283. #define LTC4245_POWER(name, ltc4245_cmd_idx) \
  284. static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
  285. ltc4245_show_power, NULL, ltc4245_cmd_idx)
  286. #define LTC4245_ALARM(name, mask, reg) \
  287. static SENSOR_DEVICE_ATTR_2(name, S_IRUGO, \
  288. ltc4245_show_alarm, NULL, (mask), reg)
  289. #define LTC4245_GPIO_VOLTAGE(name, gpio_num) \
  290. static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
  291. ltc4245_show_gpio, NULL, gpio_num)
  292. /* Construct a sensor_device_attribute structure for each register */
  293. /* Input voltages */
  294. LTC4245_VOLTAGE(in1_input, LTC4245_12VIN);
  295. LTC4245_VOLTAGE(in2_input, LTC4245_5VIN);
  296. LTC4245_VOLTAGE(in3_input, LTC4245_3VIN);
  297. LTC4245_VOLTAGE(in4_input, LTC4245_VEEIN);
  298. /* Input undervoltage alarms */
  299. LTC4245_ALARM(in1_min_alarm, (1 << 0), LTC4245_FAULT1);
  300. LTC4245_ALARM(in2_min_alarm, (1 << 1), LTC4245_FAULT1);
  301. LTC4245_ALARM(in3_min_alarm, (1 << 2), LTC4245_FAULT1);
  302. LTC4245_ALARM(in4_min_alarm, (1 << 3), LTC4245_FAULT1);
  303. /* Currents (via sense resistor) */
  304. LTC4245_CURRENT(curr1_input, LTC4245_12VSENSE);
  305. LTC4245_CURRENT(curr2_input, LTC4245_5VSENSE);
  306. LTC4245_CURRENT(curr3_input, LTC4245_3VSENSE);
  307. LTC4245_CURRENT(curr4_input, LTC4245_VEESENSE);
  308. /* Overcurrent alarms */
  309. LTC4245_ALARM(curr1_max_alarm, (1 << 4), LTC4245_FAULT1);
  310. LTC4245_ALARM(curr2_max_alarm, (1 << 5), LTC4245_FAULT1);
  311. LTC4245_ALARM(curr3_max_alarm, (1 << 6), LTC4245_FAULT1);
  312. LTC4245_ALARM(curr4_max_alarm, (1 << 7), LTC4245_FAULT1);
  313. /* Output voltages */
  314. LTC4245_VOLTAGE(in5_input, LTC4245_12VOUT);
  315. LTC4245_VOLTAGE(in6_input, LTC4245_5VOUT);
  316. LTC4245_VOLTAGE(in7_input, LTC4245_3VOUT);
  317. LTC4245_VOLTAGE(in8_input, LTC4245_VEEOUT);
  318. /* Power Bad alarms */
  319. LTC4245_ALARM(in5_min_alarm, (1 << 0), LTC4245_FAULT2);
  320. LTC4245_ALARM(in6_min_alarm, (1 << 1), LTC4245_FAULT2);
  321. LTC4245_ALARM(in7_min_alarm, (1 << 2), LTC4245_FAULT2);
  322. LTC4245_ALARM(in8_min_alarm, (1 << 3), LTC4245_FAULT2);
  323. /* GPIO voltages */
  324. LTC4245_GPIO_VOLTAGE(in9_input, 0);
  325. LTC4245_GPIO_VOLTAGE(in10_input, 1);
  326. LTC4245_GPIO_VOLTAGE(in11_input, 2);
  327. /* Power Consumption (virtual) */
  328. LTC4245_POWER(power1_input, LTC4245_12VSENSE);
  329. LTC4245_POWER(power2_input, LTC4245_5VSENSE);
  330. LTC4245_POWER(power3_input, LTC4245_3VSENSE);
  331. LTC4245_POWER(power4_input, LTC4245_VEESENSE);
  332. /* Finally, construct an array of pointers to members of the above objects,
  333. * as required for sysfs_create_group()
  334. */
  335. static struct attribute *ltc4245_std_attributes[] = {
  336. &sensor_dev_attr_in1_input.dev_attr.attr,
  337. &sensor_dev_attr_in2_input.dev_attr.attr,
  338. &sensor_dev_attr_in3_input.dev_attr.attr,
  339. &sensor_dev_attr_in4_input.dev_attr.attr,
  340. &sensor_dev_attr_in1_min_alarm.dev_attr.attr,
  341. &sensor_dev_attr_in2_min_alarm.dev_attr.attr,
  342. &sensor_dev_attr_in3_min_alarm.dev_attr.attr,
  343. &sensor_dev_attr_in4_min_alarm.dev_attr.attr,
  344. &sensor_dev_attr_curr1_input.dev_attr.attr,
  345. &sensor_dev_attr_curr2_input.dev_attr.attr,
  346. &sensor_dev_attr_curr3_input.dev_attr.attr,
  347. &sensor_dev_attr_curr4_input.dev_attr.attr,
  348. &sensor_dev_attr_curr1_max_alarm.dev_attr.attr,
  349. &sensor_dev_attr_curr2_max_alarm.dev_attr.attr,
  350. &sensor_dev_attr_curr3_max_alarm.dev_attr.attr,
  351. &sensor_dev_attr_curr4_max_alarm.dev_attr.attr,
  352. &sensor_dev_attr_in5_input.dev_attr.attr,
  353. &sensor_dev_attr_in6_input.dev_attr.attr,
  354. &sensor_dev_attr_in7_input.dev_attr.attr,
  355. &sensor_dev_attr_in8_input.dev_attr.attr,
  356. &sensor_dev_attr_in5_min_alarm.dev_attr.attr,
  357. &sensor_dev_attr_in6_min_alarm.dev_attr.attr,
  358. &sensor_dev_attr_in7_min_alarm.dev_attr.attr,
  359. &sensor_dev_attr_in8_min_alarm.dev_attr.attr,
  360. &sensor_dev_attr_in9_input.dev_attr.attr,
  361. &sensor_dev_attr_power1_input.dev_attr.attr,
  362. &sensor_dev_attr_power2_input.dev_attr.attr,
  363. &sensor_dev_attr_power3_input.dev_attr.attr,
  364. &sensor_dev_attr_power4_input.dev_attr.attr,
  365. NULL,
  366. };
  367. static struct attribute *ltc4245_gpio_attributes[] = {
  368. &sensor_dev_attr_in10_input.dev_attr.attr,
  369. &sensor_dev_attr_in11_input.dev_attr.attr,
  370. NULL,
  371. };
  372. static const struct attribute_group ltc4245_std_group = {
  373. .attrs = ltc4245_std_attributes,
  374. };
  375. static const struct attribute_group ltc4245_gpio_group = {
  376. .attrs = ltc4245_gpio_attributes,
  377. };
  378. static int ltc4245_sysfs_create_groups(struct i2c_client *client)
  379. {
  380. struct ltc4245_data *data = i2c_get_clientdata(client);
  381. struct device *dev = &client->dev;
  382. int ret;
  383. /* register the standard sysfs attributes */
  384. ret = sysfs_create_group(&dev->kobj, &ltc4245_std_group);
  385. if (ret) {
  386. dev_err(dev, "unable to register standard attributes\n");
  387. return ret;
  388. }
  389. /* if we're using the extra gpio support, register it's attributes */
  390. if (data->use_extra_gpios) {
  391. ret = sysfs_create_group(&dev->kobj, &ltc4245_gpio_group);
  392. if (ret) {
  393. dev_err(dev, "unable to register gpio attributes\n");
  394. sysfs_remove_group(&dev->kobj, &ltc4245_std_group);
  395. return ret;
  396. }
  397. }
  398. return 0;
  399. }
  400. static void ltc4245_sysfs_remove_groups(struct i2c_client *client)
  401. {
  402. struct ltc4245_data *data = i2c_get_clientdata(client);
  403. struct device *dev = &client->dev;
  404. if (data->use_extra_gpios)
  405. sysfs_remove_group(&dev->kobj, &ltc4245_gpio_group);
  406. sysfs_remove_group(&dev->kobj, &ltc4245_std_group);
  407. }
  408. static bool ltc4245_use_extra_gpios(struct i2c_client *client)
  409. {
  410. struct ltc4245_platform_data *pdata = dev_get_platdata(&client->dev);
  411. #ifdef CONFIG_OF
  412. struct device_node *np = client->dev.of_node;
  413. #endif
  414. /* prefer platform data */
  415. if (pdata)
  416. return pdata->use_extra_gpios;
  417. #ifdef CONFIG_OF
  418. /* fallback on OF */
  419. if (of_find_property(np, "ltc4245,use-extra-gpios", NULL))
  420. return true;
  421. #endif
  422. return false;
  423. }
  424. static int ltc4245_probe(struct i2c_client *client,
  425. const struct i2c_device_id *id)
  426. {
  427. struct i2c_adapter *adapter = client->adapter;
  428. struct ltc4245_data *data;
  429. int ret;
  430. if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
  431. return -ENODEV;
  432. data = kzalloc(sizeof(*data), GFP_KERNEL);
  433. if (!data) {
  434. ret = -ENOMEM;
  435. goto out_kzalloc;
  436. }
  437. i2c_set_clientdata(client, data);
  438. mutex_init(&data->update_lock);
  439. data->use_extra_gpios = ltc4245_use_extra_gpios(client);
  440. /* Initialize the LTC4245 chip */
  441. i2c_smbus_write_byte_data(client, LTC4245_FAULT1, 0x00);
  442. i2c_smbus_write_byte_data(client, LTC4245_FAULT2, 0x00);
  443. /* Register sysfs hooks */
  444. ret = ltc4245_sysfs_create_groups(client);
  445. if (ret)
  446. goto out_sysfs_create_groups;
  447. data->hwmon_dev = hwmon_device_register(&client->dev);
  448. if (IS_ERR(data->hwmon_dev)) {
  449. ret = PTR_ERR(data->hwmon_dev);
  450. goto out_hwmon_device_register;
  451. }
  452. return 0;
  453. out_hwmon_device_register:
  454. ltc4245_sysfs_remove_groups(client);
  455. out_sysfs_create_groups:
  456. kfree(data);
  457. out_kzalloc:
  458. return ret;
  459. }
  460. static int ltc4245_remove(struct i2c_client *client)
  461. {
  462. struct ltc4245_data *data = i2c_get_clientdata(client);
  463. hwmon_device_unregister(data->hwmon_dev);
  464. ltc4245_sysfs_remove_groups(client);
  465. kfree(data);
  466. return 0;
  467. }
  468. static const struct i2c_device_id ltc4245_id[] = {
  469. { "ltc4245", 0 },
  470. { }
  471. };
  472. MODULE_DEVICE_TABLE(i2c, ltc4245_id);
  473. /* This is the driver that will be inserted */
  474. static struct i2c_driver ltc4245_driver = {
  475. .driver = {
  476. .name = "ltc4245",
  477. },
  478. .probe = ltc4245_probe,
  479. .remove = ltc4245_remove,
  480. .id_table = ltc4245_id,
  481. };
  482. static int __init ltc4245_init(void)
  483. {
  484. return i2c_add_driver(&ltc4245_driver);
  485. }
  486. static void __exit ltc4245_exit(void)
  487. {
  488. i2c_del_driver(&ltc4245_driver);
  489. }
  490. MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>");
  491. MODULE_DESCRIPTION("LTC4245 driver");
  492. MODULE_LICENSE("GPL");
  493. module_init(ltc4245_init);
  494. module_exit(ltc4245_exit);