jc42.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * jc42.c - driver for Jedec JC42.4 compliant temperature sensors
  3. *
  4. * Copyright (c) 2010 Ericsson AB.
  5. *
  6. * Derived from lm77.c by Andras BALI <drewie@freemail.hu>.
  7. *
  8. * JC42.4 compliant temperature sensors are typically used on memory modules.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. */
  24. #include <linux/bitops.h>
  25. #include <linux/module.h>
  26. #include <linux/init.h>
  27. #include <linux/slab.h>
  28. #include <linux/jiffies.h>
  29. #include <linux/i2c.h>
  30. #include <linux/hwmon.h>
  31. #include <linux/err.h>
  32. #include <linux/mutex.h>
  33. #include <linux/of.h>
  34. /* Addresses to scan */
  35. static const unsigned short normal_i2c[] = {
  36. 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, I2C_CLIENT_END };
  37. /* JC42 registers. All registers are 16 bit. */
  38. #define JC42_REG_CAP 0x00
  39. #define JC42_REG_CONFIG 0x01
  40. #define JC42_REG_TEMP_UPPER 0x02
  41. #define JC42_REG_TEMP_LOWER 0x03
  42. #define JC42_REG_TEMP_CRITICAL 0x04
  43. #define JC42_REG_TEMP 0x05
  44. #define JC42_REG_MANID 0x06
  45. #define JC42_REG_DEVICEID 0x07
  46. #define JC42_REG_SMBUS 0x22 /* NXP and Atmel, possibly others? */
  47. /* Status bits in temperature register */
  48. #define JC42_ALARM_CRIT_BIT 15
  49. #define JC42_ALARM_MAX_BIT 14
  50. #define JC42_ALARM_MIN_BIT 13
  51. /* Configuration register defines */
  52. #define JC42_CFG_CRIT_ONLY (1 << 2)
  53. #define JC42_CFG_TCRIT_LOCK (1 << 6)
  54. #define JC42_CFG_EVENT_LOCK (1 << 7)
  55. #define JC42_CFG_SHUTDOWN (1 << 8)
  56. #define JC42_CFG_HYST_SHIFT 9
  57. #define JC42_CFG_HYST_MASK (0x03 << 9)
  58. /* Capabilities */
  59. #define JC42_CAP_RANGE (1 << 2)
  60. /* Manufacturer IDs */
  61. #define ADT_MANID 0x11d4 /* Analog Devices */
  62. #define ATMEL_MANID 0x001f /* Atmel */
  63. #define ATMEL_MANID2 0x1114 /* Atmel */
  64. #define MAX_MANID 0x004d /* Maxim */
  65. #define IDT_MANID 0x00b3 /* IDT */
  66. #define MCP_MANID 0x0054 /* Microchip */
  67. #define NXP_MANID 0x1131 /* NXP Semiconductors */
  68. #define ONS_MANID 0x1b09 /* ON Semiconductor */
  69. #define STM_MANID 0x104a /* ST Microelectronics */
  70. /* SMBUS register */
  71. #define SMBUS_STMOUT BIT(7) /* SMBus time-out, active low */
  72. /* Supported chips */
  73. /* Analog Devices */
  74. #define ADT7408_DEVID 0x0801
  75. #define ADT7408_DEVID_MASK 0xffff
  76. /* Atmel */
  77. #define AT30TS00_DEVID 0x8201
  78. #define AT30TS00_DEVID_MASK 0xffff
  79. #define AT30TSE004_DEVID 0x2200
  80. #define AT30TSE004_DEVID_MASK 0xffff
  81. /* IDT */
  82. #define TSE2004_DEVID 0x2200
  83. #define TSE2004_DEVID_MASK 0xff00
  84. #define TS3000_DEVID 0x2900 /* Also matches TSE2002 */
  85. #define TS3000_DEVID_MASK 0xff00
  86. #define TS3001_DEVID 0x3000
  87. #define TS3001_DEVID_MASK 0xff00
  88. /* Maxim */
  89. #define MAX6604_DEVID 0x3e00
  90. #define MAX6604_DEVID_MASK 0xffff
  91. /* Microchip */
  92. #define MCP9804_DEVID 0x0200
  93. #define MCP9804_DEVID_MASK 0xfffc
  94. #define MCP9808_DEVID 0x0400
  95. #define MCP9808_DEVID_MASK 0xfffc
  96. #define MCP98242_DEVID 0x2000
  97. #define MCP98242_DEVID_MASK 0xfffc
  98. #define MCP98243_DEVID 0x2100
  99. #define MCP98243_DEVID_MASK 0xfffc
  100. #define MCP98244_DEVID 0x2200
  101. #define MCP98244_DEVID_MASK 0xfffc
  102. #define MCP9843_DEVID 0x0000 /* Also matches mcp9805 */
  103. #define MCP9843_DEVID_MASK 0xfffe
  104. /* NXP */
  105. #define SE97_DEVID 0xa200
  106. #define SE97_DEVID_MASK 0xfffc
  107. #define SE98_DEVID 0xa100
  108. #define SE98_DEVID_MASK 0xfffc
  109. /* ON Semiconductor */
  110. #define CAT6095_DEVID 0x0800 /* Also matches CAT34TS02 */
  111. #define CAT6095_DEVID_MASK 0xffe0
  112. /* ST Microelectronics */
  113. #define STTS424_DEVID 0x0101
  114. #define STTS424_DEVID_MASK 0xffff
  115. #define STTS424E_DEVID 0x0000
  116. #define STTS424E_DEVID_MASK 0xfffe
  117. #define STTS2002_DEVID 0x0300
  118. #define STTS2002_DEVID_MASK 0xffff
  119. #define STTS2004_DEVID 0x2201
  120. #define STTS2004_DEVID_MASK 0xffff
  121. #define STTS3000_DEVID 0x0200
  122. #define STTS3000_DEVID_MASK 0xffff
  123. static u16 jc42_hysteresis[] = { 0, 1500, 3000, 6000 };
  124. struct jc42_chips {
  125. u16 manid;
  126. u16 devid;
  127. u16 devid_mask;
  128. };
  129. static struct jc42_chips jc42_chips[] = {
  130. { ADT_MANID, ADT7408_DEVID, ADT7408_DEVID_MASK },
  131. { ATMEL_MANID, AT30TS00_DEVID, AT30TS00_DEVID_MASK },
  132. { ATMEL_MANID2, AT30TSE004_DEVID, AT30TSE004_DEVID_MASK },
  133. { IDT_MANID, TSE2004_DEVID, TSE2004_DEVID_MASK },
  134. { IDT_MANID, TS3000_DEVID, TS3000_DEVID_MASK },
  135. { IDT_MANID, TS3001_DEVID, TS3001_DEVID_MASK },
  136. { MAX_MANID, MAX6604_DEVID, MAX6604_DEVID_MASK },
  137. { MCP_MANID, MCP9804_DEVID, MCP9804_DEVID_MASK },
  138. { MCP_MANID, MCP9808_DEVID, MCP9808_DEVID_MASK },
  139. { MCP_MANID, MCP98242_DEVID, MCP98242_DEVID_MASK },
  140. { MCP_MANID, MCP98243_DEVID, MCP98243_DEVID_MASK },
  141. { MCP_MANID, MCP98244_DEVID, MCP98244_DEVID_MASK },
  142. { MCP_MANID, MCP9843_DEVID, MCP9843_DEVID_MASK },
  143. { NXP_MANID, SE97_DEVID, SE97_DEVID_MASK },
  144. { ONS_MANID, CAT6095_DEVID, CAT6095_DEVID_MASK },
  145. { NXP_MANID, SE98_DEVID, SE98_DEVID_MASK },
  146. { STM_MANID, STTS424_DEVID, STTS424_DEVID_MASK },
  147. { STM_MANID, STTS424E_DEVID, STTS424E_DEVID_MASK },
  148. { STM_MANID, STTS2002_DEVID, STTS2002_DEVID_MASK },
  149. { STM_MANID, STTS2004_DEVID, STTS2004_DEVID_MASK },
  150. { STM_MANID, STTS3000_DEVID, STTS3000_DEVID_MASK },
  151. };
  152. enum temp_index {
  153. t_input = 0,
  154. t_crit,
  155. t_min,
  156. t_max,
  157. t_num_temp
  158. };
  159. static const u8 temp_regs[t_num_temp] = {
  160. [t_input] = JC42_REG_TEMP,
  161. [t_crit] = JC42_REG_TEMP_CRITICAL,
  162. [t_min] = JC42_REG_TEMP_LOWER,
  163. [t_max] = JC42_REG_TEMP_UPPER,
  164. };
  165. /* Each client has this additional data */
  166. struct jc42_data {
  167. struct i2c_client *client;
  168. struct mutex update_lock; /* protect register access */
  169. bool extended; /* true if extended range supported */
  170. bool valid;
  171. unsigned long last_updated; /* In jiffies */
  172. u16 orig_config; /* original configuration */
  173. u16 config; /* current configuration */
  174. u16 temp[t_num_temp];/* Temperatures */
  175. };
  176. #define JC42_TEMP_MIN_EXTENDED (-40000)
  177. #define JC42_TEMP_MIN 0
  178. #define JC42_TEMP_MAX 125000
  179. static u16 jc42_temp_to_reg(long temp, bool extended)
  180. {
  181. int ntemp = clamp_val(temp,
  182. extended ? JC42_TEMP_MIN_EXTENDED :
  183. JC42_TEMP_MIN, JC42_TEMP_MAX);
  184. /* convert from 0.001 to 0.0625 resolution */
  185. return (ntemp * 2 / 125) & 0x1fff;
  186. }
  187. static int jc42_temp_from_reg(s16 reg)
  188. {
  189. reg = sign_extend32(reg, 12);
  190. /* convert from 0.0625 to 0.001 resolution */
  191. return reg * 125 / 2;
  192. }
  193. static struct jc42_data *jc42_update_device(struct device *dev)
  194. {
  195. struct jc42_data *data = dev_get_drvdata(dev);
  196. struct i2c_client *client = data->client;
  197. struct jc42_data *ret = data;
  198. int i, val;
  199. mutex_lock(&data->update_lock);
  200. if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
  201. for (i = 0; i < t_num_temp; i++) {
  202. val = i2c_smbus_read_word_swapped(client, temp_regs[i]);
  203. if (val < 0) {
  204. ret = ERR_PTR(val);
  205. goto abort;
  206. }
  207. data->temp[i] = val;
  208. }
  209. data->last_updated = jiffies;
  210. data->valid = true;
  211. }
  212. abort:
  213. mutex_unlock(&data->update_lock);
  214. return ret;
  215. }
  216. static int jc42_read(struct device *dev, enum hwmon_sensor_types type,
  217. u32 attr, int channel, long *val)
  218. {
  219. struct jc42_data *data = jc42_update_device(dev);
  220. int temp, hyst;
  221. if (IS_ERR(data))
  222. return PTR_ERR(data);
  223. switch (attr) {
  224. case hwmon_temp_input:
  225. *val = jc42_temp_from_reg(data->temp[t_input]);
  226. return 0;
  227. case hwmon_temp_min:
  228. *val = jc42_temp_from_reg(data->temp[t_min]);
  229. return 0;
  230. case hwmon_temp_max:
  231. *val = jc42_temp_from_reg(data->temp[t_max]);
  232. return 0;
  233. case hwmon_temp_crit:
  234. *val = jc42_temp_from_reg(data->temp[t_crit]);
  235. return 0;
  236. case hwmon_temp_max_hyst:
  237. temp = jc42_temp_from_reg(data->temp[t_max]);
  238. hyst = jc42_hysteresis[(data->config & JC42_CFG_HYST_MASK)
  239. >> JC42_CFG_HYST_SHIFT];
  240. *val = temp - hyst;
  241. return 0;
  242. case hwmon_temp_crit_hyst:
  243. temp = jc42_temp_from_reg(data->temp[t_crit]);
  244. hyst = jc42_hysteresis[(data->config & JC42_CFG_HYST_MASK)
  245. >> JC42_CFG_HYST_SHIFT];
  246. *val = temp - hyst;
  247. return 0;
  248. case hwmon_temp_min_alarm:
  249. *val = (data->temp[t_input] >> JC42_ALARM_MIN_BIT) & 1;
  250. return 0;
  251. case hwmon_temp_max_alarm:
  252. *val = (data->temp[t_input] >> JC42_ALARM_MAX_BIT) & 1;
  253. return 0;
  254. case hwmon_temp_crit_alarm:
  255. *val = (data->temp[t_input] >> JC42_ALARM_CRIT_BIT) & 1;
  256. return 0;
  257. default:
  258. return -EOPNOTSUPP;
  259. }
  260. }
  261. static int jc42_write(struct device *dev, enum hwmon_sensor_types type,
  262. u32 attr, int channel, long val)
  263. {
  264. struct jc42_data *data = dev_get_drvdata(dev);
  265. struct i2c_client *client = data->client;
  266. int diff, hyst;
  267. int ret;
  268. mutex_lock(&data->update_lock);
  269. switch (attr) {
  270. case hwmon_temp_min:
  271. data->temp[t_min] = jc42_temp_to_reg(val, data->extended);
  272. ret = i2c_smbus_write_word_swapped(client, temp_regs[t_min],
  273. data->temp[t_min]);
  274. break;
  275. case hwmon_temp_max:
  276. data->temp[t_max] = jc42_temp_to_reg(val, data->extended);
  277. ret = i2c_smbus_write_word_swapped(client, temp_regs[t_max],
  278. data->temp[t_max]);
  279. break;
  280. case hwmon_temp_crit:
  281. data->temp[t_crit] = jc42_temp_to_reg(val, data->extended);
  282. ret = i2c_smbus_write_word_swapped(client, temp_regs[t_crit],
  283. data->temp[t_crit]);
  284. break;
  285. case hwmon_temp_crit_hyst:
  286. /*
  287. * JC42.4 compliant chips only support four hysteresis values.
  288. * Pick best choice and go from there.
  289. */
  290. val = clamp_val(val, (data->extended ? JC42_TEMP_MIN_EXTENDED
  291. : JC42_TEMP_MIN) - 6000,
  292. JC42_TEMP_MAX);
  293. diff = jc42_temp_from_reg(data->temp[t_crit]) - val;
  294. hyst = 0;
  295. if (diff > 0) {
  296. if (diff < 2250)
  297. hyst = 1; /* 1.5 degrees C */
  298. else if (diff < 4500)
  299. hyst = 2; /* 3.0 degrees C */
  300. else
  301. hyst = 3; /* 6.0 degrees C */
  302. }
  303. data->config = (data->config & ~JC42_CFG_HYST_MASK) |
  304. (hyst << JC42_CFG_HYST_SHIFT);
  305. ret = i2c_smbus_write_word_swapped(data->client,
  306. JC42_REG_CONFIG,
  307. data->config);
  308. break;
  309. default:
  310. ret = -EOPNOTSUPP;
  311. break;
  312. }
  313. mutex_unlock(&data->update_lock);
  314. return ret;
  315. }
  316. static umode_t jc42_is_visible(const void *_data, enum hwmon_sensor_types type,
  317. u32 attr, int channel)
  318. {
  319. const struct jc42_data *data = _data;
  320. unsigned int config = data->config;
  321. umode_t mode = S_IRUGO;
  322. switch (attr) {
  323. case hwmon_temp_min:
  324. case hwmon_temp_max:
  325. if (!(config & JC42_CFG_EVENT_LOCK))
  326. mode |= S_IWUSR;
  327. break;
  328. case hwmon_temp_crit:
  329. if (!(config & JC42_CFG_TCRIT_LOCK))
  330. mode |= S_IWUSR;
  331. break;
  332. case hwmon_temp_crit_hyst:
  333. if (!(config & (JC42_CFG_EVENT_LOCK | JC42_CFG_TCRIT_LOCK)))
  334. mode |= S_IWUSR;
  335. break;
  336. case hwmon_temp_input:
  337. case hwmon_temp_max_hyst:
  338. case hwmon_temp_min_alarm:
  339. case hwmon_temp_max_alarm:
  340. case hwmon_temp_crit_alarm:
  341. break;
  342. default:
  343. mode = 0;
  344. break;
  345. }
  346. return mode;
  347. }
  348. /* Return 0 if detection is successful, -ENODEV otherwise */
  349. static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)
  350. {
  351. struct i2c_adapter *adapter = client->adapter;
  352. int i, config, cap, manid, devid;
  353. if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
  354. I2C_FUNC_SMBUS_WORD_DATA))
  355. return -ENODEV;
  356. cap = i2c_smbus_read_word_swapped(client, JC42_REG_CAP);
  357. config = i2c_smbus_read_word_swapped(client, JC42_REG_CONFIG);
  358. manid = i2c_smbus_read_word_swapped(client, JC42_REG_MANID);
  359. devid = i2c_smbus_read_word_swapped(client, JC42_REG_DEVICEID);
  360. if (cap < 0 || config < 0 || manid < 0 || devid < 0)
  361. return -ENODEV;
  362. if ((cap & 0xff00) || (config & 0xf800))
  363. return -ENODEV;
  364. for (i = 0; i < ARRAY_SIZE(jc42_chips); i++) {
  365. struct jc42_chips *chip = &jc42_chips[i];
  366. if (manid == chip->manid &&
  367. (devid & chip->devid_mask) == chip->devid) {
  368. strlcpy(info->type, "jc42", I2C_NAME_SIZE);
  369. return 0;
  370. }
  371. }
  372. return -ENODEV;
  373. }
  374. static const u32 jc42_temp_config[] = {
  375. HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_CRIT |
  376. HWMON_T_MAX_HYST | HWMON_T_CRIT_HYST |
  377. HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM,
  378. 0
  379. };
  380. static const struct hwmon_channel_info jc42_temp = {
  381. .type = hwmon_temp,
  382. .config = jc42_temp_config,
  383. };
  384. static const struct hwmon_channel_info *jc42_info[] = {
  385. &jc42_temp,
  386. NULL
  387. };
  388. static const struct hwmon_ops jc42_hwmon_ops = {
  389. .is_visible = jc42_is_visible,
  390. .read = jc42_read,
  391. .write = jc42_write,
  392. };
  393. static const struct hwmon_chip_info jc42_chip_info = {
  394. .ops = &jc42_hwmon_ops,
  395. .info = jc42_info,
  396. };
  397. static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id)
  398. {
  399. struct device *dev = &client->dev;
  400. struct device *hwmon_dev;
  401. struct jc42_data *data;
  402. int config, cap;
  403. data = devm_kzalloc(dev, sizeof(struct jc42_data), GFP_KERNEL);
  404. if (!data)
  405. return -ENOMEM;
  406. data->client = client;
  407. i2c_set_clientdata(client, data);
  408. mutex_init(&data->update_lock);
  409. cap = i2c_smbus_read_word_swapped(client, JC42_REG_CAP);
  410. if (cap < 0)
  411. return cap;
  412. data->extended = !!(cap & JC42_CAP_RANGE);
  413. if (device_property_read_bool(dev, "smbus-timeout-disable")) {
  414. int smbus;
  415. /*
  416. * Not all chips support this register, but from a
  417. * quick read of various datasheets no chip appears
  418. * incompatible with the below attempt to disable
  419. * the timeout. And the whole thing is opt-in...
  420. */
  421. smbus = i2c_smbus_read_word_swapped(client, JC42_REG_SMBUS);
  422. if (smbus < 0)
  423. return smbus;
  424. i2c_smbus_write_word_swapped(client, JC42_REG_SMBUS,
  425. smbus | SMBUS_STMOUT);
  426. }
  427. config = i2c_smbus_read_word_swapped(client, JC42_REG_CONFIG);
  428. if (config < 0)
  429. return config;
  430. data->orig_config = config;
  431. if (config & JC42_CFG_SHUTDOWN) {
  432. config &= ~JC42_CFG_SHUTDOWN;
  433. i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, config);
  434. }
  435. data->config = config;
  436. hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
  437. data, &jc42_chip_info,
  438. NULL);
  439. return PTR_ERR_OR_ZERO(hwmon_dev);
  440. }
  441. static int jc42_remove(struct i2c_client *client)
  442. {
  443. struct jc42_data *data = i2c_get_clientdata(client);
  444. /* Restore original configuration except hysteresis */
  445. if ((data->config & ~JC42_CFG_HYST_MASK) !=
  446. (data->orig_config & ~JC42_CFG_HYST_MASK)) {
  447. int config;
  448. config = (data->orig_config & ~JC42_CFG_HYST_MASK)
  449. | (data->config & JC42_CFG_HYST_MASK);
  450. i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, config);
  451. }
  452. return 0;
  453. }
  454. #ifdef CONFIG_PM
  455. static int jc42_suspend(struct device *dev)
  456. {
  457. struct jc42_data *data = dev_get_drvdata(dev);
  458. data->config |= JC42_CFG_SHUTDOWN;
  459. i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG,
  460. data->config);
  461. return 0;
  462. }
  463. static int jc42_resume(struct device *dev)
  464. {
  465. struct jc42_data *data = dev_get_drvdata(dev);
  466. data->config &= ~JC42_CFG_SHUTDOWN;
  467. i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG,
  468. data->config);
  469. return 0;
  470. }
  471. static const struct dev_pm_ops jc42_dev_pm_ops = {
  472. .suspend = jc42_suspend,
  473. .resume = jc42_resume,
  474. };
  475. #define JC42_DEV_PM_OPS (&jc42_dev_pm_ops)
  476. #else
  477. #define JC42_DEV_PM_OPS NULL
  478. #endif /* CONFIG_PM */
  479. static const struct i2c_device_id jc42_id[] = {
  480. { "jc42", 0 },
  481. { }
  482. };
  483. MODULE_DEVICE_TABLE(i2c, jc42_id);
  484. #ifdef CONFIG_OF
  485. static const struct of_device_id jc42_of_ids[] = {
  486. { .compatible = "jedec,jc-42.4-temp", },
  487. { }
  488. };
  489. MODULE_DEVICE_TABLE(of, jc42_of_ids);
  490. #endif
  491. static struct i2c_driver jc42_driver = {
  492. .class = I2C_CLASS_SPD | I2C_CLASS_HWMON,
  493. .driver = {
  494. .name = "jc42",
  495. .pm = JC42_DEV_PM_OPS,
  496. .of_match_table = of_match_ptr(jc42_of_ids),
  497. },
  498. .probe = jc42_probe,
  499. .remove = jc42_remove,
  500. .id_table = jc42_id,
  501. .detect = jc42_detect,
  502. .address_list = normal_i2c,
  503. };
  504. module_i2c_driver(jc42_driver);
  505. MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>");
  506. MODULE_DESCRIPTION("JC42 driver");
  507. MODULE_LICENSE("GPL");