rtc-rv8803.c 15 KB

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