rtc-pcf8563.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * An I2C driver for the Philips PCF8563 RTC
  4. * Copyright 2005-06 Tower Technologies
  5. *
  6. * Author: Alessandro Zummo <[email protected]>
  7. * Maintainers: http://www.nslu2-linux.org/
  8. *
  9. * based on the other drivers in this same directory.
  10. *
  11. * https://www.nxp.com/docs/en/data-sheet/PCF8563.pdf
  12. */
  13. #include <linux/clk-provider.h>
  14. #include <linux/i2c.h>
  15. #include <linux/bcd.h>
  16. #include <linux/rtc.h>
  17. #include <linux/slab.h>
  18. #include <linux/module.h>
  19. #include <linux/of.h>
  20. #include <linux/err.h>
  21. #define PCF8563_REG_ST1 0x00 /* status */
  22. #define PCF8563_REG_ST2 0x01
  23. #define PCF8563_BIT_AIE BIT(1)
  24. #define PCF8563_BIT_AF BIT(3)
  25. #define PCF8563_BITS_ST2_N (7 << 5)
  26. #define PCF8563_REG_SC 0x02 /* datetime */
  27. #define PCF8563_REG_MN 0x03
  28. #define PCF8563_REG_HR 0x04
  29. #define PCF8563_REG_DM 0x05
  30. #define PCF8563_REG_DW 0x06
  31. #define PCF8563_REG_MO 0x07
  32. #define PCF8563_REG_YR 0x08
  33. #define PCF8563_REG_AMN 0x09 /* alarm */
  34. #define PCF8563_REG_CLKO 0x0D /* clock out */
  35. #define PCF8563_REG_CLKO_FE 0x80 /* clock out enabled */
  36. #define PCF8563_REG_CLKO_F_MASK 0x03 /* frequenc mask */
  37. #define PCF8563_REG_CLKO_F_32768HZ 0x00
  38. #define PCF8563_REG_CLKO_F_1024HZ 0x01
  39. #define PCF8563_REG_CLKO_F_32HZ 0x02
  40. #define PCF8563_REG_CLKO_F_1HZ 0x03
  41. #define PCF8563_REG_TMRC 0x0E /* timer control */
  42. #define PCF8563_TMRC_ENABLE BIT(7)
  43. #define PCF8563_TMRC_4096 0
  44. #define PCF8563_TMRC_64 1
  45. #define PCF8563_TMRC_1 2
  46. #define PCF8563_TMRC_1_60 3
  47. #define PCF8563_TMRC_MASK 3
  48. #define PCF8563_REG_TMR 0x0F /* timer */
  49. #define PCF8563_SC_LV 0x80 /* low voltage */
  50. #define PCF8563_MO_C 0x80 /* century */
  51. static struct i2c_driver pcf8563_driver;
  52. struct pcf8563 {
  53. struct rtc_device *rtc;
  54. /*
  55. * The meaning of MO_C bit varies by the chip type.
  56. * From PCF8563 datasheet: this bit is toggled when the years
  57. * register overflows from 99 to 00
  58. * 0 indicates the century is 20xx
  59. * 1 indicates the century is 19xx
  60. * From RTC8564 datasheet: this bit indicates change of
  61. * century. When the year digit data overflows from 99 to 00,
  62. * this bit is set. By presetting it to 0 while still in the
  63. * 20th century, it will be set in year 2000, ...
  64. * There seems no reliable way to know how the system use this
  65. * bit. So let's do it heuristically, assuming we are live in
  66. * 1970...2069.
  67. */
  68. int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
  69. struct i2c_client *client;
  70. #ifdef CONFIG_COMMON_CLK
  71. struct clk_hw clkout_hw;
  72. #endif
  73. };
  74. static int pcf8563_read_block_data(struct i2c_client *client, unsigned char reg,
  75. unsigned char length, unsigned char *buf)
  76. {
  77. struct i2c_msg msgs[] = {
  78. {/* setup read ptr */
  79. .addr = client->addr,
  80. .len = 1,
  81. .buf = &reg,
  82. },
  83. {
  84. .addr = client->addr,
  85. .flags = I2C_M_RD,
  86. .len = length,
  87. .buf = buf
  88. },
  89. };
  90. if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
  91. dev_err(&client->dev, "%s: read error\n", __func__);
  92. return -EIO;
  93. }
  94. return 0;
  95. }
  96. static int pcf8563_write_block_data(struct i2c_client *client,
  97. unsigned char reg, unsigned char length,
  98. unsigned char *buf)
  99. {
  100. int i, err;
  101. for (i = 0; i < length; i++) {
  102. unsigned char data[2] = { reg + i, buf[i] };
  103. err = i2c_master_send(client, data, sizeof(data));
  104. if (err != sizeof(data)) {
  105. dev_err(&client->dev,
  106. "%s: err=%d addr=%02x, data=%02x\n",
  107. __func__, err, data[0], data[1]);
  108. return -EIO;
  109. }
  110. }
  111. return 0;
  112. }
  113. static int pcf8563_set_alarm_mode(struct i2c_client *client, bool on)
  114. {
  115. unsigned char buf;
  116. int err;
  117. err = pcf8563_read_block_data(client, PCF8563_REG_ST2, 1, &buf);
  118. if (err < 0)
  119. return err;
  120. if (on)
  121. buf |= PCF8563_BIT_AIE;
  122. else
  123. buf &= ~PCF8563_BIT_AIE;
  124. buf &= ~(PCF8563_BIT_AF | PCF8563_BITS_ST2_N);
  125. err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf);
  126. if (err < 0) {
  127. dev_err(&client->dev, "%s: write error\n", __func__);
  128. return -EIO;
  129. }
  130. return 0;
  131. }
  132. static int pcf8563_get_alarm_mode(struct i2c_client *client, unsigned char *en,
  133. unsigned char *pen)
  134. {
  135. unsigned char buf;
  136. int err;
  137. err = pcf8563_read_block_data(client, PCF8563_REG_ST2, 1, &buf);
  138. if (err)
  139. return err;
  140. if (en)
  141. *en = !!(buf & PCF8563_BIT_AIE);
  142. if (pen)
  143. *pen = !!(buf & PCF8563_BIT_AF);
  144. return 0;
  145. }
  146. static irqreturn_t pcf8563_irq(int irq, void *dev_id)
  147. {
  148. struct pcf8563 *pcf8563 = i2c_get_clientdata(dev_id);
  149. int err;
  150. char pending;
  151. err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending);
  152. if (err)
  153. return IRQ_NONE;
  154. if (pending) {
  155. rtc_update_irq(pcf8563->rtc, 1, RTC_IRQF | RTC_AF);
  156. pcf8563_set_alarm_mode(pcf8563->client, 1);
  157. return IRQ_HANDLED;
  158. }
  159. return IRQ_NONE;
  160. }
  161. /*
  162. * In the routines that deal directly with the pcf8563 hardware, we use
  163. * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
  164. */
  165. static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
  166. {
  167. struct i2c_client *client = to_i2c_client(dev);
  168. struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
  169. unsigned char buf[9];
  170. int err;
  171. err = pcf8563_read_block_data(client, PCF8563_REG_ST1, 9, buf);
  172. if (err)
  173. return err;
  174. if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) {
  175. dev_err(&client->dev,
  176. "low voltage detected, date/time is not reliable.\n");
  177. return -EINVAL;
  178. }
  179. dev_dbg(&client->dev,
  180. "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, "
  181. "mday=%02x, wday=%02x, mon=%02x, year=%02x\n",
  182. __func__,
  183. buf[0], buf[1], buf[2], buf[3],
  184. buf[4], buf[5], buf[6], buf[7],
  185. buf[8]);
  186. tm->tm_sec = bcd2bin(buf[PCF8563_REG_SC] & 0x7F);
  187. tm->tm_min = bcd2bin(buf[PCF8563_REG_MN] & 0x7F);
  188. tm->tm_hour = bcd2bin(buf[PCF8563_REG_HR] & 0x3F); /* rtc hr 0-23 */
  189. tm->tm_mday = bcd2bin(buf[PCF8563_REG_DM] & 0x3F);
  190. tm->tm_wday = buf[PCF8563_REG_DW] & 0x07;
  191. tm->tm_mon = bcd2bin(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */
  192. tm->tm_year = bcd2bin(buf[PCF8563_REG_YR]) + 100;
  193. /* detect the polarity heuristically. see note above. */
  194. pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ?
  195. (tm->tm_year >= 100) : (tm->tm_year < 100);
  196. dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
  197. "mday=%d, mon=%d, year=%d, wday=%d\n",
  198. __func__,
  199. tm->tm_sec, tm->tm_min, tm->tm_hour,
  200. tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
  201. return 0;
  202. }
  203. static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
  204. {
  205. struct i2c_client *client = to_i2c_client(dev);
  206. struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
  207. unsigned char buf[9];
  208. dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "
  209. "mday=%d, mon=%d, year=%d, wday=%d\n",
  210. __func__,
  211. tm->tm_sec, tm->tm_min, tm->tm_hour,
  212. tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
  213. /* hours, minutes and seconds */
  214. buf[PCF8563_REG_SC] = bin2bcd(tm->tm_sec);
  215. buf[PCF8563_REG_MN] = bin2bcd(tm->tm_min);
  216. buf[PCF8563_REG_HR] = bin2bcd(tm->tm_hour);
  217. buf[PCF8563_REG_DM] = bin2bcd(tm->tm_mday);
  218. /* month, 1 - 12 */
  219. buf[PCF8563_REG_MO] = bin2bcd(tm->tm_mon + 1);
  220. /* year and century */
  221. buf[PCF8563_REG_YR] = bin2bcd(tm->tm_year - 100);
  222. if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100))
  223. buf[PCF8563_REG_MO] |= PCF8563_MO_C;
  224. buf[PCF8563_REG_DW] = tm->tm_wday & 0x07;
  225. return pcf8563_write_block_data(client, PCF8563_REG_SC,
  226. 9 - PCF8563_REG_SC, buf + PCF8563_REG_SC);
  227. }
  228. static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
  229. {
  230. struct i2c_client *client = to_i2c_client(dev);
  231. int ret;
  232. switch (cmd) {
  233. case RTC_VL_READ:
  234. ret = i2c_smbus_read_byte_data(client, PCF8563_REG_SC);
  235. if (ret < 0)
  236. return ret;
  237. return put_user(ret & PCF8563_SC_LV ? RTC_VL_DATA_INVALID : 0,
  238. (unsigned int __user *)arg);
  239. default:
  240. return -ENOIOCTLCMD;
  241. }
  242. }
  243. static int pcf8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *tm)
  244. {
  245. struct i2c_client *client = to_i2c_client(dev);
  246. unsigned char buf[4];
  247. int err;
  248. err = pcf8563_read_block_data(client, PCF8563_REG_AMN, 4, buf);
  249. if (err)
  250. return err;
  251. dev_dbg(&client->dev,
  252. "%s: raw data is min=%02x, hr=%02x, mday=%02x, wday=%02x\n",
  253. __func__, buf[0], buf[1], buf[2], buf[3]);
  254. tm->time.tm_sec = 0;
  255. tm->time.tm_min = bcd2bin(buf[0] & 0x7F);
  256. tm->time.tm_hour = bcd2bin(buf[1] & 0x3F);
  257. tm->time.tm_mday = bcd2bin(buf[2] & 0x3F);
  258. tm->time.tm_wday = bcd2bin(buf[3] & 0x7);
  259. err = pcf8563_get_alarm_mode(client, &tm->enabled, &tm->pending);
  260. if (err < 0)
  261. return err;
  262. dev_dbg(&client->dev, "%s: tm is mins=%d, hours=%d, mday=%d, wday=%d,"
  263. " enabled=%d, pending=%d\n", __func__, tm->time.tm_min,
  264. tm->time.tm_hour, tm->time.tm_mday, tm->time.tm_wday,
  265. tm->enabled, tm->pending);
  266. return 0;
  267. }
  268. static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm)
  269. {
  270. struct i2c_client *client = to_i2c_client(dev);
  271. unsigned char buf[4];
  272. int err;
  273. buf[0] = bin2bcd(tm->time.tm_min);
  274. buf[1] = bin2bcd(tm->time.tm_hour);
  275. buf[2] = bin2bcd(tm->time.tm_mday);
  276. buf[3] = tm->time.tm_wday & 0x07;
  277. err = pcf8563_write_block_data(client, PCF8563_REG_AMN, 4, buf);
  278. if (err)
  279. return err;
  280. return pcf8563_set_alarm_mode(client, !!tm->enabled);
  281. }
  282. static int pcf8563_irq_enable(struct device *dev, unsigned int enabled)
  283. {
  284. dev_dbg(dev, "%s: en=%d\n", __func__, enabled);
  285. return pcf8563_set_alarm_mode(to_i2c_client(dev), !!enabled);
  286. }
  287. #ifdef CONFIG_COMMON_CLK
  288. /*
  289. * Handling of the clkout
  290. */
  291. #define clkout_hw_to_pcf8563(_hw) container_of(_hw, struct pcf8563, clkout_hw)
  292. static const int clkout_rates[] = {
  293. 32768,
  294. 1024,
  295. 32,
  296. 1,
  297. };
  298. static unsigned long pcf8563_clkout_recalc_rate(struct clk_hw *hw,
  299. unsigned long parent_rate)
  300. {
  301. struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw);
  302. struct i2c_client *client = pcf8563->client;
  303. unsigned char buf;
  304. int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf);
  305. if (ret < 0)
  306. return 0;
  307. buf &= PCF8563_REG_CLKO_F_MASK;
  308. return clkout_rates[buf];
  309. }
  310. static long pcf8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
  311. unsigned long *prate)
  312. {
  313. int i;
  314. for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
  315. if (clkout_rates[i] <= rate)
  316. return clkout_rates[i];
  317. return 0;
  318. }
  319. static int pcf8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
  320. unsigned long parent_rate)
  321. {
  322. struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw);
  323. struct i2c_client *client = pcf8563->client;
  324. unsigned char buf;
  325. int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf);
  326. int i;
  327. if (ret < 0)
  328. return ret;
  329. for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
  330. if (clkout_rates[i] == rate) {
  331. buf &= ~PCF8563_REG_CLKO_F_MASK;
  332. buf |= i;
  333. ret = pcf8563_write_block_data(client,
  334. PCF8563_REG_CLKO, 1,
  335. &buf);
  336. return ret;
  337. }
  338. return -EINVAL;
  339. }
  340. static int pcf8563_clkout_control(struct clk_hw *hw, bool enable)
  341. {
  342. struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw);
  343. struct i2c_client *client = pcf8563->client;
  344. unsigned char buf;
  345. int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf);
  346. if (ret < 0)
  347. return ret;
  348. if (enable)
  349. buf |= PCF8563_REG_CLKO_FE;
  350. else
  351. buf &= ~PCF8563_REG_CLKO_FE;
  352. ret = pcf8563_write_block_data(client, PCF8563_REG_CLKO, 1, &buf);
  353. return ret;
  354. }
  355. static int pcf8563_clkout_prepare(struct clk_hw *hw)
  356. {
  357. return pcf8563_clkout_control(hw, 1);
  358. }
  359. static void pcf8563_clkout_unprepare(struct clk_hw *hw)
  360. {
  361. pcf8563_clkout_control(hw, 0);
  362. }
  363. static int pcf8563_clkout_is_prepared(struct clk_hw *hw)
  364. {
  365. struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw);
  366. struct i2c_client *client = pcf8563->client;
  367. unsigned char buf;
  368. int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf);
  369. if (ret < 0)
  370. return ret;
  371. return !!(buf & PCF8563_REG_CLKO_FE);
  372. }
  373. static const struct clk_ops pcf8563_clkout_ops = {
  374. .prepare = pcf8563_clkout_prepare,
  375. .unprepare = pcf8563_clkout_unprepare,
  376. .is_prepared = pcf8563_clkout_is_prepared,
  377. .recalc_rate = pcf8563_clkout_recalc_rate,
  378. .round_rate = pcf8563_clkout_round_rate,
  379. .set_rate = pcf8563_clkout_set_rate,
  380. };
  381. static struct clk *pcf8563_clkout_register_clk(struct pcf8563 *pcf8563)
  382. {
  383. struct i2c_client *client = pcf8563->client;
  384. struct device_node *node = client->dev.of_node;
  385. struct clk *clk;
  386. struct clk_init_data init;
  387. int ret;
  388. unsigned char buf;
  389. /* disable the clkout output */
  390. buf = 0;
  391. ret = pcf8563_write_block_data(client, PCF8563_REG_CLKO, 1, &buf);
  392. if (ret < 0)
  393. return ERR_PTR(ret);
  394. init.name = "pcf8563-clkout";
  395. init.ops = &pcf8563_clkout_ops;
  396. init.flags = 0;
  397. init.parent_names = NULL;
  398. init.num_parents = 0;
  399. pcf8563->clkout_hw.init = &init;
  400. /* optional override of the clockname */
  401. of_property_read_string(node, "clock-output-names", &init.name);
  402. /* register the clock */
  403. clk = devm_clk_register(&client->dev, &pcf8563->clkout_hw);
  404. if (!IS_ERR(clk))
  405. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  406. return clk;
  407. }
  408. #endif
  409. static const struct rtc_class_ops pcf8563_rtc_ops = {
  410. .ioctl = pcf8563_rtc_ioctl,
  411. .read_time = pcf8563_rtc_read_time,
  412. .set_time = pcf8563_rtc_set_time,
  413. .read_alarm = pcf8563_rtc_read_alarm,
  414. .set_alarm = pcf8563_rtc_set_alarm,
  415. .alarm_irq_enable = pcf8563_irq_enable,
  416. };
  417. static int pcf8563_probe(struct i2c_client *client)
  418. {
  419. struct pcf8563 *pcf8563;
  420. int err;
  421. unsigned char buf;
  422. dev_dbg(&client->dev, "%s\n", __func__);
  423. if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
  424. return -ENODEV;
  425. pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563),
  426. GFP_KERNEL);
  427. if (!pcf8563)
  428. return -ENOMEM;
  429. i2c_set_clientdata(client, pcf8563);
  430. pcf8563->client = client;
  431. device_set_wakeup_capable(&client->dev, 1);
  432. /* Set timer to lowest frequency to save power (ref Haoyu datasheet) */
  433. buf = PCF8563_TMRC_1_60;
  434. err = pcf8563_write_block_data(client, PCF8563_REG_TMRC, 1, &buf);
  435. if (err < 0) {
  436. dev_err(&client->dev, "%s: write error\n", __func__);
  437. return err;
  438. }
  439. /* Clear flags and disable interrupts */
  440. buf = 0;
  441. err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf);
  442. if (err < 0) {
  443. dev_err(&client->dev, "%s: write error\n", __func__);
  444. return err;
  445. }
  446. pcf8563->rtc = devm_rtc_allocate_device(&client->dev);
  447. if (IS_ERR(pcf8563->rtc))
  448. return PTR_ERR(pcf8563->rtc);
  449. pcf8563->rtc->ops = &pcf8563_rtc_ops;
  450. /* the pcf8563 alarm only supports a minute accuracy */
  451. set_bit(RTC_FEATURE_ALARM_RES_MINUTE, pcf8563->rtc->features);
  452. clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf8563->rtc->features);
  453. pcf8563->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
  454. pcf8563->rtc->range_max = RTC_TIMESTAMP_END_2099;
  455. pcf8563->rtc->set_start_time = true;
  456. if (client->irq > 0) {
  457. err = devm_request_threaded_irq(&client->dev, client->irq,
  458. NULL, pcf8563_irq,
  459. IRQF_SHARED | IRQF_ONESHOT | IRQF_TRIGGER_LOW,
  460. pcf8563_driver.driver.name, client);
  461. if (err) {
  462. dev_err(&client->dev, "unable to request IRQ %d\n",
  463. client->irq);
  464. return err;
  465. }
  466. }
  467. err = devm_rtc_register_device(pcf8563->rtc);
  468. if (err)
  469. return err;
  470. #ifdef CONFIG_COMMON_CLK
  471. /* register clk in common clk framework */
  472. pcf8563_clkout_register_clk(pcf8563);
  473. #endif
  474. return 0;
  475. }
  476. static const struct i2c_device_id pcf8563_id[] = {
  477. { "pcf8563", 0 },
  478. { "rtc8564", 0 },
  479. { "pca8565", 0 },
  480. { }
  481. };
  482. MODULE_DEVICE_TABLE(i2c, pcf8563_id);
  483. #ifdef CONFIG_OF
  484. static const struct of_device_id pcf8563_of_match[] = {
  485. { .compatible = "nxp,pcf8563" },
  486. { .compatible = "epson,rtc8564" },
  487. { .compatible = "microcrystal,rv8564" },
  488. { .compatible = "nxp,pca8565" },
  489. {}
  490. };
  491. MODULE_DEVICE_TABLE(of, pcf8563_of_match);
  492. #endif
  493. static struct i2c_driver pcf8563_driver = {
  494. .driver = {
  495. .name = "rtc-pcf8563",
  496. .of_match_table = of_match_ptr(pcf8563_of_match),
  497. },
  498. .probe_new = pcf8563_probe,
  499. .id_table = pcf8563_id,
  500. };
  501. module_i2c_driver(pcf8563_driver);
  502. MODULE_AUTHOR("Alessandro Zummo <[email protected]>");
  503. MODULE_DESCRIPTION("Philips PCF8563/Epson RTC8564 RTC driver");
  504. MODULE_LICENSE("GPL");