rtc-rv8803.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * RTC driver for the Micro Crystal RV8803
  3. *
  4. * Copyright (C) 2015 Micro Crystal SA
  5. *
  6. * Alexandre Belloni <alexandre.belloni@free-electrons.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 version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #include <linux/bcd.h>
  14. #include <linux/bitops.h>
  15. #include <linux/log2.h>
  16. #include <linux/i2c.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/kernel.h>
  19. #include <linux/module.h>
  20. #include <linux/rtc.h>
  21. #define RV8803_I2C_TRY_COUNT 4
  22. #define RV8803_SEC 0x00
  23. #define RV8803_MIN 0x01
  24. #define RV8803_HOUR 0x02
  25. #define RV8803_WEEK 0x03
  26. #define RV8803_DAY 0x04
  27. #define RV8803_MONTH 0x05
  28. #define RV8803_YEAR 0x06
  29. #define RV8803_RAM 0x07
  30. #define RV8803_ALARM_MIN 0x08
  31. #define RV8803_ALARM_HOUR 0x09
  32. #define RV8803_ALARM_WEEK_OR_DAY 0x0A
  33. #define RV8803_EXT 0x0D
  34. #define RV8803_FLAG 0x0E
  35. #define RV8803_CTRL 0x0F
  36. #define RV8803_EXT_WADA BIT(6)
  37. #define RV8803_FLAG_V1F BIT(0)
  38. #define RV8803_FLAG_V2F BIT(1)
  39. #define RV8803_FLAG_AF BIT(3)
  40. #define RV8803_FLAG_TF BIT(4)
  41. #define RV8803_FLAG_UF BIT(5)
  42. #define RV8803_CTRL_RESET BIT(0)
  43. #define RV8803_CTRL_EIE BIT(2)
  44. #define RV8803_CTRL_AIE BIT(3)
  45. #define RV8803_CTRL_TIE BIT(4)
  46. #define RV8803_CTRL_UIE BIT(5)
  47. #define RX8900_BACKUP_CTRL 0x18
  48. #define RX8900_FLAG_SWOFF BIT(2)
  49. #define RX8900_FLAG_VDETOFF BIT(3)
  50. enum rv8803_type {
  51. rv_8803,
  52. rx_8900
  53. };
  54. struct rv8803_data {
  55. struct i2c_client *client;
  56. struct rtc_device *rtc;
  57. struct mutex flags_lock;
  58. u8 ctrl;
  59. enum rv8803_type type;
  60. };
  61. static int rv8803_read_reg(const struct i2c_client *client, u8 reg)
  62. {
  63. int try = RV8803_I2C_TRY_COUNT;
  64. s32 ret;
  65. /*
  66. * There is a 61µs window during which the RTC does not acknowledge I2C
  67. * transfers. In that case, ensure that there are multiple attempts.
  68. */
  69. do
  70. ret = i2c_smbus_read_byte_data(client, reg);
  71. while ((ret == -ENXIO || ret == -EIO) && --try);
  72. if (ret < 0)
  73. dev_err(&client->dev, "Unable to read register 0x%02x\n", reg);
  74. return ret;
  75. }
  76. static int rv8803_read_regs(const struct i2c_client *client,
  77. u8 reg, u8 count, u8 *values)
  78. {
  79. int try = RV8803_I2C_TRY_COUNT;
  80. s32 ret;
  81. do
  82. ret = i2c_smbus_read_i2c_block_data(client, reg, count, values);
  83. while ((ret == -ENXIO || ret == -EIO) && --try);
  84. if (ret != count) {
  85. dev_err(&client->dev,
  86. "Unable to read registers 0x%02x..0x%02x\n",
  87. reg, reg + count - 1);
  88. return ret < 0 ? ret : -EIO;
  89. }
  90. return 0;
  91. }
  92. static int rv8803_write_reg(const struct i2c_client *client, u8 reg, u8 value)
  93. {
  94. int try = RV8803_I2C_TRY_COUNT;
  95. s32 ret;
  96. do
  97. ret = i2c_smbus_write_byte_data(client, reg, value);
  98. while ((ret == -ENXIO || ret == -EIO) && --try);
  99. if (ret)
  100. dev_err(&client->dev, "Unable to write register 0x%02x\n", reg);
  101. return ret;
  102. }
  103. static int rv8803_write_regs(const struct i2c_client *client,
  104. u8 reg, u8 count, const u8 *values)
  105. {
  106. int try = RV8803_I2C_TRY_COUNT;
  107. s32 ret;
  108. do
  109. ret = i2c_smbus_write_i2c_block_data(client, reg, count,
  110. values);
  111. while ((ret == -ENXIO || ret == -EIO) && --try);
  112. if (ret)
  113. dev_err(&client->dev,
  114. "Unable to write registers 0x%02x..0x%02x\n",
  115. reg, reg + count - 1);
  116. return ret;
  117. }
  118. static irqreturn_t rv8803_handle_irq(int irq, void *dev_id)
  119. {
  120. struct i2c_client *client = dev_id;
  121. struct rv8803_data *rv8803 = i2c_get_clientdata(client);
  122. unsigned long events = 0;
  123. int flags;
  124. mutex_lock(&rv8803->flags_lock);
  125. flags = rv8803_read_reg(client, RV8803_FLAG);
  126. if (flags <= 0) {
  127. mutex_unlock(&rv8803->flags_lock);
  128. return IRQ_NONE;
  129. }
  130. if (flags & RV8803_FLAG_V1F)
  131. dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n");
  132. if (flags & RV8803_FLAG_V2F)
  133. dev_warn(&client->dev, "Voltage low, data loss detected.\n");
  134. if (flags & RV8803_FLAG_TF) {
  135. flags &= ~RV8803_FLAG_TF;
  136. rv8803->ctrl &= ~RV8803_CTRL_TIE;
  137. events |= RTC_PF;
  138. }
  139. if (flags & RV8803_FLAG_AF) {
  140. flags &= ~RV8803_FLAG_AF;
  141. rv8803->ctrl &= ~RV8803_CTRL_AIE;
  142. events |= RTC_AF;
  143. }
  144. if (flags & RV8803_FLAG_UF) {
  145. flags &= ~RV8803_FLAG_UF;
  146. rv8803->ctrl &= ~RV8803_CTRL_UIE;
  147. events |= RTC_UF;
  148. }
  149. if (events) {
  150. rtc_update_irq(rv8803->rtc, 1, events);
  151. rv8803_write_reg(client, RV8803_FLAG, flags);
  152. rv8803_write_reg(rv8803->client, RV8803_CTRL, rv8803->ctrl);
  153. }
  154. mutex_unlock(&rv8803->flags_lock);
  155. return IRQ_HANDLED;
  156. }
  157. static int rv8803_get_time(struct device *dev, struct rtc_time *tm)
  158. {
  159. struct rv8803_data *rv8803 = dev_get_drvdata(dev);
  160. u8 date1[7];
  161. u8 date2[7];
  162. u8 *date = date1;
  163. int ret, flags;
  164. flags = rv8803_read_reg(rv8803->client, RV8803_FLAG);
  165. if (flags < 0)
  166. return flags;
  167. if (flags & RV8803_FLAG_V2F) {
  168. dev_warn(dev, "Voltage low, data is invalid.\n");
  169. return -EINVAL;
  170. }
  171. ret = rv8803_read_regs(rv8803->client, RV8803_SEC, 7, date);
  172. if (ret)
  173. return ret;
  174. if ((date1[RV8803_SEC] & 0x7f) == bin2bcd(59)) {
  175. ret = rv8803_read_regs(rv8803->client, RV8803_SEC, 7, date2);
  176. if (ret)
  177. return ret;
  178. if ((date2[RV8803_SEC] & 0x7f) != bin2bcd(59))
  179. date = date2;
  180. }
  181. tm->tm_sec = bcd2bin(date[RV8803_SEC] & 0x7f);
  182. tm->tm_min = bcd2bin(date[RV8803_MIN] & 0x7f);
  183. tm->tm_hour = bcd2bin(date[RV8803_HOUR] & 0x3f);
  184. tm->tm_wday = ilog2(date[RV8803_WEEK] & 0x7f);
  185. tm->tm_mday = bcd2bin(date[RV8803_DAY] & 0x3f);
  186. tm->tm_mon = bcd2bin(date[RV8803_MONTH] & 0x1f) - 1;
  187. tm->tm_year = bcd2bin(date[RV8803_YEAR]) + 100;
  188. return 0;
  189. }
  190. static int rv8803_set_time(struct device *dev, struct rtc_time *tm)
  191. {
  192. struct rv8803_data *rv8803 = dev_get_drvdata(dev);
  193. u8 date[7];
  194. int ctrl, flags, ret;
  195. if ((tm->tm_year < 100) || (tm->tm_year > 199))
  196. return -EINVAL;
  197. ctrl = rv8803_read_reg(rv8803->client, RV8803_CTRL);
  198. if (ctrl < 0)
  199. return ctrl;
  200. /* Stop the clock */
  201. ret = rv8803_write_reg(rv8803->client, RV8803_CTRL,
  202. ctrl | RV8803_CTRL_RESET);
  203. if (ret)
  204. return ret;
  205. date[RV8803_SEC] = bin2bcd(tm->tm_sec);
  206. date[RV8803_MIN] = bin2bcd(tm->tm_min);
  207. date[RV8803_HOUR] = bin2bcd(tm->tm_hour);
  208. date[RV8803_WEEK] = 1 << (tm->tm_wday);
  209. date[RV8803_DAY] = bin2bcd(tm->tm_mday);
  210. date[RV8803_MONTH] = bin2bcd(tm->tm_mon + 1);
  211. date[RV8803_YEAR] = bin2bcd(tm->tm_year - 100);
  212. ret = rv8803_write_regs(rv8803->client, RV8803_SEC, 7, date);
  213. if (ret)
  214. return ret;
  215. /* Restart the clock */
  216. ret = rv8803_write_reg(rv8803->client, RV8803_CTRL,
  217. ctrl & ~RV8803_CTRL_RESET);
  218. if (ret)
  219. return ret;
  220. mutex_lock(&rv8803->flags_lock);
  221. flags = rv8803_read_reg(rv8803->client, RV8803_FLAG);
  222. if (flags < 0) {
  223. mutex_unlock(&rv8803->flags_lock);
  224. return flags;
  225. }
  226. ret = rv8803_write_reg(rv8803->client, RV8803_FLAG,
  227. flags & ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F));
  228. mutex_unlock(&rv8803->flags_lock);
  229. return ret;
  230. }
  231. static int rv8803_get_alarm(struct device *dev, struct rtc_wkalrm *alrm)
  232. {
  233. struct rv8803_data *rv8803 = dev_get_drvdata(dev);
  234. struct i2c_client *client = rv8803->client;
  235. u8 alarmvals[3];
  236. int flags, ret;
  237. ret = rv8803_read_regs(client, RV8803_ALARM_MIN, 3, alarmvals);
  238. if (ret)
  239. return ret;
  240. flags = rv8803_read_reg(client, RV8803_FLAG);
  241. if (flags < 0)
  242. return flags;
  243. alrm->time.tm_sec = 0;
  244. alrm->time.tm_min = bcd2bin(alarmvals[0] & 0x7f);
  245. alrm->time.tm_hour = bcd2bin(alarmvals[1] & 0x3f);
  246. alrm->time.tm_mday = bcd2bin(alarmvals[2] & 0x3f);
  247. alrm->enabled = !!(rv8803->ctrl & RV8803_CTRL_AIE);
  248. alrm->pending = (flags & RV8803_FLAG_AF) && alrm->enabled;
  249. return 0;
  250. }
  251. static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
  252. {
  253. struct i2c_client *client = to_i2c_client(dev);
  254. struct rv8803_data *rv8803 = dev_get_drvdata(dev);
  255. u8 alarmvals[3];
  256. u8 ctrl[2];
  257. int ret, err;
  258. /* The alarm has no seconds, round up to nearest minute */
  259. if (alrm->time.tm_sec) {
  260. time64_t alarm_time = rtc_tm_to_time64(&alrm->time);
  261. alarm_time += 60 - alrm->time.tm_sec;
  262. rtc_time64_to_tm(alarm_time, &alrm->time);
  263. }
  264. mutex_lock(&rv8803->flags_lock);
  265. ret = rv8803_read_regs(client, RV8803_FLAG, 2, ctrl);
  266. if (ret) {
  267. mutex_unlock(&rv8803->flags_lock);
  268. return ret;
  269. }
  270. alarmvals[0] = bin2bcd(alrm->time.tm_min);
  271. alarmvals[1] = bin2bcd(alrm->time.tm_hour);
  272. alarmvals[2] = bin2bcd(alrm->time.tm_mday);
  273. if (rv8803->ctrl & (RV8803_CTRL_AIE | RV8803_CTRL_UIE)) {
  274. rv8803->ctrl &= ~(RV8803_CTRL_AIE | RV8803_CTRL_UIE);
  275. err = rv8803_write_reg(rv8803->client, RV8803_CTRL,
  276. rv8803->ctrl);
  277. if (err) {
  278. mutex_unlock(&rv8803->flags_lock);
  279. return err;
  280. }
  281. }
  282. ctrl[1] &= ~RV8803_FLAG_AF;
  283. err = rv8803_write_reg(rv8803->client, RV8803_FLAG, ctrl[1]);
  284. mutex_unlock(&rv8803->flags_lock);
  285. if (err)
  286. return err;
  287. err = rv8803_write_regs(rv8803->client, RV8803_ALARM_MIN, 3, alarmvals);
  288. if (err)
  289. return err;
  290. if (alrm->enabled) {
  291. if (rv8803->rtc->uie_rtctimer.enabled)
  292. rv8803->ctrl |= RV8803_CTRL_UIE;
  293. if (rv8803->rtc->aie_timer.enabled)
  294. rv8803->ctrl |= RV8803_CTRL_AIE;
  295. err = rv8803_write_reg(rv8803->client, RV8803_CTRL,
  296. rv8803->ctrl);
  297. if (err)
  298. return err;
  299. }
  300. return 0;
  301. }
  302. static int rv8803_alarm_irq_enable(struct device *dev, unsigned int enabled)
  303. {
  304. struct i2c_client *client = to_i2c_client(dev);
  305. struct rv8803_data *rv8803 = dev_get_drvdata(dev);
  306. int ctrl, flags, err;
  307. ctrl = rv8803->ctrl;
  308. if (enabled) {
  309. if (rv8803->rtc->uie_rtctimer.enabled)
  310. ctrl |= RV8803_CTRL_UIE;
  311. if (rv8803->rtc->aie_timer.enabled)
  312. ctrl |= RV8803_CTRL_AIE;
  313. } else {
  314. if (!rv8803->rtc->uie_rtctimer.enabled)
  315. ctrl &= ~RV8803_CTRL_UIE;
  316. if (!rv8803->rtc->aie_timer.enabled)
  317. ctrl &= ~RV8803_CTRL_AIE;
  318. }
  319. mutex_lock(&rv8803->flags_lock);
  320. flags = rv8803_read_reg(client, RV8803_FLAG);
  321. if (flags < 0) {
  322. mutex_unlock(&rv8803->flags_lock);
  323. return flags;
  324. }
  325. flags &= ~(RV8803_FLAG_AF | RV8803_FLAG_UF);
  326. err = rv8803_write_reg(client, RV8803_FLAG, flags);
  327. mutex_unlock(&rv8803->flags_lock);
  328. if (err)
  329. return err;
  330. if (ctrl != rv8803->ctrl) {
  331. rv8803->ctrl = ctrl;
  332. err = rv8803_write_reg(client, RV8803_CTRL, rv8803->ctrl);
  333. if (err)
  334. return err;
  335. }
  336. return 0;
  337. }
  338. static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
  339. {
  340. struct i2c_client *client = to_i2c_client(dev);
  341. struct rv8803_data *rv8803 = dev_get_drvdata(dev);
  342. int flags, ret = 0;
  343. switch (cmd) {
  344. case RTC_VL_READ:
  345. flags = rv8803_read_reg(client, RV8803_FLAG);
  346. if (flags < 0)
  347. return flags;
  348. if (flags & RV8803_FLAG_V1F)
  349. dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n");
  350. if (flags & RV8803_FLAG_V2F)
  351. dev_warn(&client->dev, "Voltage low, data loss detected.\n");
  352. flags &= RV8803_FLAG_V1F | RV8803_FLAG_V2F;
  353. if (copy_to_user((void __user *)arg, &flags, sizeof(int)))
  354. return -EFAULT;
  355. return 0;
  356. case RTC_VL_CLR:
  357. mutex_lock(&rv8803->flags_lock);
  358. flags = rv8803_read_reg(client, RV8803_FLAG);
  359. if (flags < 0) {
  360. mutex_unlock(&rv8803->flags_lock);
  361. return flags;
  362. }
  363. flags &= ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F);
  364. ret = rv8803_write_reg(client, RV8803_FLAG, flags);
  365. mutex_unlock(&rv8803->flags_lock);
  366. if (ret)
  367. return ret;
  368. return 0;
  369. default:
  370. return -ENOIOCTLCMD;
  371. }
  372. }
  373. static ssize_t rv8803_nvram_write(struct file *filp, struct kobject *kobj,
  374. struct bin_attribute *attr,
  375. char *buf, loff_t off, size_t count)
  376. {
  377. struct device *dev = kobj_to_dev(kobj);
  378. struct i2c_client *client = to_i2c_client(dev);
  379. int ret;
  380. ret = rv8803_write_reg(client, RV8803_RAM, buf[0]);
  381. if (ret)
  382. return ret;
  383. return 1;
  384. }
  385. static ssize_t rv8803_nvram_read(struct file *filp, struct kobject *kobj,
  386. struct bin_attribute *attr,
  387. char *buf, loff_t off, size_t count)
  388. {
  389. struct device *dev = kobj_to_dev(kobj);
  390. struct i2c_client *client = to_i2c_client(dev);
  391. int ret;
  392. ret = rv8803_read_reg(client, RV8803_RAM);
  393. if (ret < 0)
  394. return ret;
  395. buf[0] = ret;
  396. return 1;
  397. }
  398. static struct bin_attribute rv8803_nvram_attr = {
  399. .attr = {
  400. .name = "nvram",
  401. .mode = S_IRUGO | S_IWUSR,
  402. },
  403. .size = 1,
  404. .read = rv8803_nvram_read,
  405. .write = rv8803_nvram_write,
  406. };
  407. static struct rtc_class_ops rv8803_rtc_ops = {
  408. .read_time = rv8803_get_time,
  409. .set_time = rv8803_set_time,
  410. .ioctl = rv8803_ioctl,
  411. };
  412. static int rx8900_trickle_charger_init(struct rv8803_data *rv8803)
  413. {
  414. struct i2c_client *client = rv8803->client;
  415. struct device_node *node = client->dev.of_node;
  416. int err;
  417. u8 flags;
  418. if (!node)
  419. return 0;
  420. if (rv8803->type != rx_8900)
  421. return 0;
  422. err = i2c_smbus_read_byte_data(rv8803->client, RX8900_BACKUP_CTRL);
  423. if (err < 0)
  424. return err;
  425. flags = ~(RX8900_FLAG_VDETOFF | RX8900_FLAG_SWOFF) & (u8)err;
  426. if (of_property_read_bool(node, "epson,vdet-disable"))
  427. flags |= RX8900_FLAG_VDETOFF;
  428. if (of_property_read_bool(node, "trickle-diode-disable"))
  429. flags |= RX8900_FLAG_SWOFF;
  430. return i2c_smbus_write_byte_data(rv8803->client, RX8900_BACKUP_CTRL,
  431. flags);
  432. }
  433. static int rv8803_probe(struct i2c_client *client,
  434. const struct i2c_device_id *id)
  435. {
  436. struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
  437. struct rv8803_data *rv8803;
  438. int err, flags;
  439. if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
  440. I2C_FUNC_SMBUS_I2C_BLOCK)) {
  441. dev_err(&adapter->dev, "doesn't support I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK\n");
  442. return -EIO;
  443. }
  444. rv8803 = devm_kzalloc(&client->dev, sizeof(struct rv8803_data),
  445. GFP_KERNEL);
  446. if (!rv8803)
  447. return -ENOMEM;
  448. mutex_init(&rv8803->flags_lock);
  449. rv8803->client = client;
  450. rv8803->type = id->driver_data;
  451. i2c_set_clientdata(client, rv8803);
  452. flags = rv8803_read_reg(client, RV8803_FLAG);
  453. if (flags < 0)
  454. return flags;
  455. if (flags & RV8803_FLAG_V1F)
  456. dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n");
  457. if (flags & RV8803_FLAG_V2F)
  458. dev_warn(&client->dev, "Voltage low, data loss detected.\n");
  459. if (flags & RV8803_FLAG_AF)
  460. dev_warn(&client->dev, "An alarm maybe have been missed.\n");
  461. if (client->irq > 0) {
  462. err = devm_request_threaded_irq(&client->dev, client->irq,
  463. NULL, rv8803_handle_irq,
  464. IRQF_TRIGGER_LOW | IRQF_ONESHOT,
  465. "rv8803", client);
  466. if (err) {
  467. dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n");
  468. client->irq = 0;
  469. } else {
  470. rv8803_rtc_ops.read_alarm = rv8803_get_alarm;
  471. rv8803_rtc_ops.set_alarm = rv8803_set_alarm;
  472. rv8803_rtc_ops.alarm_irq_enable = rv8803_alarm_irq_enable;
  473. }
  474. }
  475. rv8803->rtc = devm_rtc_device_register(&client->dev, client->name,
  476. &rv8803_rtc_ops, THIS_MODULE);
  477. if (IS_ERR(rv8803->rtc)) {
  478. dev_err(&client->dev, "unable to register the class device\n");
  479. return PTR_ERR(rv8803->rtc);
  480. }
  481. err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA);
  482. if (err)
  483. return err;
  484. err = rx8900_trickle_charger_init(rv8803);
  485. if (err) {
  486. dev_err(&client->dev, "failed to init charger\n");
  487. return err;
  488. }
  489. err = device_create_bin_file(&client->dev, &rv8803_nvram_attr);
  490. if (err)
  491. return err;
  492. rv8803->rtc->max_user_freq = 1;
  493. return 0;
  494. }
  495. static int rv8803_remove(struct i2c_client *client)
  496. {
  497. device_remove_bin_file(&client->dev, &rv8803_nvram_attr);
  498. return 0;
  499. }
  500. static const struct i2c_device_id rv8803_id[] = {
  501. { "rv8803", rv_8803 },
  502. { "rx8900", rx_8900 },
  503. { }
  504. };
  505. MODULE_DEVICE_TABLE(i2c, rv8803_id);
  506. static struct i2c_driver rv8803_driver = {
  507. .driver = {
  508. .name = "rtc-rv8803",
  509. },
  510. .probe = rv8803_probe,
  511. .remove = rv8803_remove,
  512. .id_table = rv8803_id,
  513. };
  514. module_i2c_driver(rv8803_driver);
  515. MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@free-electrons.com>");
  516. MODULE_DESCRIPTION("Micro Crystal RV8803 RTC driver");
  517. MODULE_LICENSE("GPL v2");