max34440.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  2. * Hardware monitoring driver for Maxim MAX34440/MAX34441
  3. *
  4. * Copyright (c) 2011 Ericsson AB.
  5. * Copyright (c) 2012 Guenter Roeck
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/bitops.h>
  22. #include <linux/kernel.h>
  23. #include <linux/module.h>
  24. #include <linux/init.h>
  25. #include <linux/err.h>
  26. #include <linux/i2c.h>
  27. #include "pmbus.h"
  28. enum chips { max34440, max34441, max34446, max34460, max34461 };
  29. #define MAX34440_MFR_VOUT_PEAK 0xd4
  30. #define MAX34440_MFR_IOUT_PEAK 0xd5
  31. #define MAX34440_MFR_TEMPERATURE_PEAK 0xd6
  32. #define MAX34440_MFR_VOUT_MIN 0xd7
  33. #define MAX34446_MFR_POUT_PEAK 0xe0
  34. #define MAX34446_MFR_POUT_AVG 0xe1
  35. #define MAX34446_MFR_IOUT_AVG 0xe2
  36. #define MAX34446_MFR_TEMPERATURE_AVG 0xe3
  37. #define MAX34440_STATUS_OC_WARN BIT(0)
  38. #define MAX34440_STATUS_OC_FAULT BIT(1)
  39. #define MAX34440_STATUS_OT_FAULT BIT(5)
  40. #define MAX34440_STATUS_OT_WARN BIT(6)
  41. struct max34440_data {
  42. int id;
  43. struct pmbus_driver_info info;
  44. };
  45. #define to_max34440_data(x) container_of(x, struct max34440_data, info)
  46. static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
  47. {
  48. int ret;
  49. const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
  50. const struct max34440_data *data = to_max34440_data(info);
  51. switch (reg) {
  52. case PMBUS_VIRT_READ_VOUT_MIN:
  53. ret = pmbus_read_word_data(client, page,
  54. MAX34440_MFR_VOUT_MIN);
  55. break;
  56. case PMBUS_VIRT_READ_VOUT_MAX:
  57. ret = pmbus_read_word_data(client, page,
  58. MAX34440_MFR_VOUT_PEAK);
  59. break;
  60. case PMBUS_VIRT_READ_IOUT_AVG:
  61. if (data->id != max34446)
  62. return -ENXIO;
  63. ret = pmbus_read_word_data(client, page,
  64. MAX34446_MFR_IOUT_AVG);
  65. break;
  66. case PMBUS_VIRT_READ_IOUT_MAX:
  67. ret = pmbus_read_word_data(client, page,
  68. MAX34440_MFR_IOUT_PEAK);
  69. break;
  70. case PMBUS_VIRT_READ_POUT_AVG:
  71. if (data->id != max34446)
  72. return -ENXIO;
  73. ret = pmbus_read_word_data(client, page,
  74. MAX34446_MFR_POUT_AVG);
  75. break;
  76. case PMBUS_VIRT_READ_POUT_MAX:
  77. if (data->id != max34446)
  78. return -ENXIO;
  79. ret = pmbus_read_word_data(client, page,
  80. MAX34446_MFR_POUT_PEAK);
  81. break;
  82. case PMBUS_VIRT_READ_TEMP_AVG:
  83. if (data->id != max34446 && data->id != max34460 &&
  84. data->id != max34461)
  85. return -ENXIO;
  86. ret = pmbus_read_word_data(client, page,
  87. MAX34446_MFR_TEMPERATURE_AVG);
  88. break;
  89. case PMBUS_VIRT_READ_TEMP_MAX:
  90. ret = pmbus_read_word_data(client, page,
  91. MAX34440_MFR_TEMPERATURE_PEAK);
  92. break;
  93. case PMBUS_VIRT_RESET_POUT_HISTORY:
  94. if (data->id != max34446)
  95. return -ENXIO;
  96. ret = 0;
  97. break;
  98. case PMBUS_VIRT_RESET_VOUT_HISTORY:
  99. case PMBUS_VIRT_RESET_IOUT_HISTORY:
  100. case PMBUS_VIRT_RESET_TEMP_HISTORY:
  101. ret = 0;
  102. break;
  103. default:
  104. ret = -ENODATA;
  105. break;
  106. }
  107. return ret;
  108. }
  109. static int max34440_write_word_data(struct i2c_client *client, int page,
  110. int reg, u16 word)
  111. {
  112. const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
  113. const struct max34440_data *data = to_max34440_data(info);
  114. int ret;
  115. switch (reg) {
  116. case PMBUS_VIRT_RESET_POUT_HISTORY:
  117. ret = pmbus_write_word_data(client, page,
  118. MAX34446_MFR_POUT_PEAK, 0);
  119. if (ret)
  120. break;
  121. ret = pmbus_write_word_data(client, page,
  122. MAX34446_MFR_POUT_AVG, 0);
  123. break;
  124. case PMBUS_VIRT_RESET_VOUT_HISTORY:
  125. ret = pmbus_write_word_data(client, page,
  126. MAX34440_MFR_VOUT_MIN, 0x7fff);
  127. if (ret)
  128. break;
  129. ret = pmbus_write_word_data(client, page,
  130. MAX34440_MFR_VOUT_PEAK, 0);
  131. break;
  132. case PMBUS_VIRT_RESET_IOUT_HISTORY:
  133. ret = pmbus_write_word_data(client, page,
  134. MAX34440_MFR_IOUT_PEAK, 0);
  135. if (!ret && data->id == max34446)
  136. ret = pmbus_write_word_data(client, page,
  137. MAX34446_MFR_IOUT_AVG, 0);
  138. break;
  139. case PMBUS_VIRT_RESET_TEMP_HISTORY:
  140. ret = pmbus_write_word_data(client, page,
  141. MAX34440_MFR_TEMPERATURE_PEAK,
  142. 0x8000);
  143. if (!ret && data->id == max34446)
  144. ret = pmbus_write_word_data(client, page,
  145. MAX34446_MFR_TEMPERATURE_AVG, 0);
  146. break;
  147. default:
  148. ret = -ENODATA;
  149. break;
  150. }
  151. return ret;
  152. }
  153. static int max34440_read_byte_data(struct i2c_client *client, int page, int reg)
  154. {
  155. int ret = 0;
  156. int mfg_status;
  157. if (page >= 0) {
  158. ret = pmbus_set_page(client, page);
  159. if (ret < 0)
  160. return ret;
  161. }
  162. switch (reg) {
  163. case PMBUS_STATUS_IOUT:
  164. mfg_status = pmbus_read_word_data(client, 0,
  165. PMBUS_STATUS_MFR_SPECIFIC);
  166. if (mfg_status < 0)
  167. return mfg_status;
  168. if (mfg_status & MAX34440_STATUS_OC_WARN)
  169. ret |= PB_IOUT_OC_WARNING;
  170. if (mfg_status & MAX34440_STATUS_OC_FAULT)
  171. ret |= PB_IOUT_OC_FAULT;
  172. break;
  173. case PMBUS_STATUS_TEMPERATURE:
  174. mfg_status = pmbus_read_word_data(client, 0,
  175. PMBUS_STATUS_MFR_SPECIFIC);
  176. if (mfg_status < 0)
  177. return mfg_status;
  178. if (mfg_status & MAX34440_STATUS_OT_WARN)
  179. ret |= PB_TEMP_OT_WARNING;
  180. if (mfg_status & MAX34440_STATUS_OT_FAULT)
  181. ret |= PB_TEMP_OT_FAULT;
  182. break;
  183. default:
  184. ret = -ENODATA;
  185. break;
  186. }
  187. return ret;
  188. }
  189. static struct pmbus_driver_info max34440_info[] = {
  190. [max34440] = {
  191. .pages = 14,
  192. .format[PSC_VOLTAGE_IN] = direct,
  193. .format[PSC_VOLTAGE_OUT] = direct,
  194. .format[PSC_TEMPERATURE] = direct,
  195. .format[PSC_CURRENT_OUT] = direct,
  196. .m[PSC_VOLTAGE_IN] = 1,
  197. .b[PSC_VOLTAGE_IN] = 0,
  198. .R[PSC_VOLTAGE_IN] = 3, /* R = 0 in datasheet reflects mV */
  199. .m[PSC_VOLTAGE_OUT] = 1,
  200. .b[PSC_VOLTAGE_OUT] = 0,
  201. .R[PSC_VOLTAGE_OUT] = 3, /* R = 0 in datasheet reflects mV */
  202. .m[PSC_CURRENT_OUT] = 1,
  203. .b[PSC_CURRENT_OUT] = 0,
  204. .R[PSC_CURRENT_OUT] = 3, /* R = 0 in datasheet reflects mA */
  205. .m[PSC_TEMPERATURE] = 1,
  206. .b[PSC_TEMPERATURE] = 0,
  207. .R[PSC_TEMPERATURE] = 2,
  208. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  209. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  210. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  211. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  212. .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  213. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  214. .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  215. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  216. .func[4] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  217. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  218. .func[5] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  219. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  220. .func[6] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  221. .func[7] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  222. .func[8] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  223. .func[9] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  224. .func[10] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  225. .func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  226. .func[12] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  227. .func[13] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  228. .read_byte_data = max34440_read_byte_data,
  229. .read_word_data = max34440_read_word_data,
  230. .write_word_data = max34440_write_word_data,
  231. },
  232. [max34441] = {
  233. .pages = 12,
  234. .format[PSC_VOLTAGE_IN] = direct,
  235. .format[PSC_VOLTAGE_OUT] = direct,
  236. .format[PSC_TEMPERATURE] = direct,
  237. .format[PSC_CURRENT_OUT] = direct,
  238. .format[PSC_FAN] = direct,
  239. .m[PSC_VOLTAGE_IN] = 1,
  240. .b[PSC_VOLTAGE_IN] = 0,
  241. .R[PSC_VOLTAGE_IN] = 3,
  242. .m[PSC_VOLTAGE_OUT] = 1,
  243. .b[PSC_VOLTAGE_OUT] = 0,
  244. .R[PSC_VOLTAGE_OUT] = 3,
  245. .m[PSC_CURRENT_OUT] = 1,
  246. .b[PSC_CURRENT_OUT] = 0,
  247. .R[PSC_CURRENT_OUT] = 3,
  248. .m[PSC_TEMPERATURE] = 1,
  249. .b[PSC_TEMPERATURE] = 0,
  250. .R[PSC_TEMPERATURE] = 2,
  251. .m[PSC_FAN] = 1,
  252. .b[PSC_FAN] = 0,
  253. .R[PSC_FAN] = 0,
  254. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  255. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  256. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  257. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  258. .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  259. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  260. .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  261. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  262. .func[4] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  263. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  264. .func[5] = PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12,
  265. .func[6] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  266. .func[7] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  267. .func[8] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  268. .func[9] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  269. .func[10] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  270. .func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  271. .read_byte_data = max34440_read_byte_data,
  272. .read_word_data = max34440_read_word_data,
  273. .write_word_data = max34440_write_word_data,
  274. },
  275. [max34446] = {
  276. .pages = 7,
  277. .format[PSC_VOLTAGE_IN] = direct,
  278. .format[PSC_VOLTAGE_OUT] = direct,
  279. .format[PSC_TEMPERATURE] = direct,
  280. .format[PSC_CURRENT_OUT] = direct,
  281. .format[PSC_POWER] = direct,
  282. .m[PSC_VOLTAGE_IN] = 1,
  283. .b[PSC_VOLTAGE_IN] = 0,
  284. .R[PSC_VOLTAGE_IN] = 3,
  285. .m[PSC_VOLTAGE_OUT] = 1,
  286. .b[PSC_VOLTAGE_OUT] = 0,
  287. .R[PSC_VOLTAGE_OUT] = 3,
  288. .m[PSC_CURRENT_OUT] = 1,
  289. .b[PSC_CURRENT_OUT] = 0,
  290. .R[PSC_CURRENT_OUT] = 3,
  291. .m[PSC_POWER] = 1,
  292. .b[PSC_POWER] = 0,
  293. .R[PSC_POWER] = 3,
  294. .m[PSC_TEMPERATURE] = 1,
  295. .b[PSC_TEMPERATURE] = 0,
  296. .R[PSC_TEMPERATURE] = 2,
  297. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  298. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
  299. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  300. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  301. .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  302. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
  303. .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  304. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  305. .func[4] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  306. .func[5] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  307. .func[6] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  308. .read_byte_data = max34440_read_byte_data,
  309. .read_word_data = max34440_read_word_data,
  310. .write_word_data = max34440_write_word_data,
  311. },
  312. [max34460] = {
  313. .pages = 18,
  314. .format[PSC_VOLTAGE_OUT] = direct,
  315. .format[PSC_TEMPERATURE] = direct,
  316. .m[PSC_VOLTAGE_OUT] = 1,
  317. .b[PSC_VOLTAGE_OUT] = 0,
  318. .R[PSC_VOLTAGE_OUT] = 3,
  319. .m[PSC_TEMPERATURE] = 1,
  320. .b[PSC_TEMPERATURE] = 0,
  321. .R[PSC_TEMPERATURE] = 2,
  322. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  323. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  324. .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  325. .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  326. .func[4] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  327. .func[5] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  328. .func[6] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  329. .func[7] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  330. .func[8] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  331. .func[9] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  332. .func[10] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  333. .func[11] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  334. .func[13] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  335. .func[14] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  336. .func[15] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  337. .func[16] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  338. .func[17] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  339. .read_byte_data = max34440_read_byte_data,
  340. .read_word_data = max34440_read_word_data,
  341. .write_word_data = max34440_write_word_data,
  342. },
  343. [max34461] = {
  344. .pages = 23,
  345. .format[PSC_VOLTAGE_OUT] = direct,
  346. .format[PSC_TEMPERATURE] = direct,
  347. .m[PSC_VOLTAGE_OUT] = 1,
  348. .b[PSC_VOLTAGE_OUT] = 0,
  349. .R[PSC_VOLTAGE_OUT] = 3,
  350. .m[PSC_TEMPERATURE] = 1,
  351. .b[PSC_TEMPERATURE] = 0,
  352. .R[PSC_TEMPERATURE] = 2,
  353. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  354. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  355. .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  356. .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  357. .func[4] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  358. .func[5] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  359. .func[6] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  360. .func[7] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  361. .func[8] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  362. .func[9] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  363. .func[10] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  364. .func[11] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  365. .func[12] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  366. .func[13] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  367. .func[14] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  368. .func[15] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  369. /* page 16 is reserved */
  370. .func[17] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  371. .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  372. .func[19] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  373. .func[20] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  374. .func[21] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
  375. .read_byte_data = max34440_read_byte_data,
  376. .read_word_data = max34440_read_word_data,
  377. .write_word_data = max34440_write_word_data,
  378. },
  379. };
  380. static int max34440_probe(struct i2c_client *client,
  381. const struct i2c_device_id *id)
  382. {
  383. struct max34440_data *data;
  384. data = devm_kzalloc(&client->dev, sizeof(struct max34440_data),
  385. GFP_KERNEL);
  386. if (!data)
  387. return -ENOMEM;
  388. data->id = id->driver_data;
  389. data->info = max34440_info[id->driver_data];
  390. return pmbus_do_probe(client, id, &data->info);
  391. }
  392. static const struct i2c_device_id max34440_id[] = {
  393. {"max34440", max34440},
  394. {"max34441", max34441},
  395. {"max34446", max34446},
  396. {"max34460", max34460},
  397. {"max34461", max34461},
  398. {}
  399. };
  400. MODULE_DEVICE_TABLE(i2c, max34440_id);
  401. /* This is the driver that will be inserted */
  402. static struct i2c_driver max34440_driver = {
  403. .driver = {
  404. .name = "max34440",
  405. },
  406. .probe = max34440_probe,
  407. .remove = pmbus_do_remove,
  408. .id_table = max34440_id,
  409. };
  410. module_i2c_driver(max34440_driver);
  411. MODULE_AUTHOR("Guenter Roeck");
  412. MODULE_DESCRIPTION("PMBus driver for Maxim MAX34440/MAX34441");
  413. MODULE_LICENSE("GPL");