1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * RTC driver for the Micro Crystal RV8803 4 * 5 * Copyright (C) 2015 Micro Crystal SA 6 * Alexandre Belloni <alexandre.belloni@bootlin.com> 7 * 8 */ 9 10 #include <linux/bcd.h> 11 #include <linux/bitops.h> 12 #include <linux/bitfield.h> 13 #include <linux/log2.h> 14 #include <linux/i2c.h> 15 #include <linux/interrupt.h> 16 #include <linux/kernel.h> 17 #include <linux/module.h> 18 #include <linux/of_device.h> 19 #include <linux/rtc.h> 20 21 #define RV8803_I2C_TRY_COUNT 4 22 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_OSC_OFFSET 0x2C 38 39 #define RV8803_EXT_WADA BIT(6) 40 41 #define RV8803_FLAG_V1F BIT(0) 42 #define RV8803_FLAG_V2F BIT(1) 43 #define RV8803_FLAG_AF BIT(3) 44 #define RV8803_FLAG_TF BIT(4) 45 #define RV8803_FLAG_UF BIT(5) 46 47 #define RV8803_CTRL_RESET BIT(0) 48 49 #define RV8803_CTRL_EIE BIT(2) 50 #define RV8803_CTRL_AIE BIT(3) 51 #define RV8803_CTRL_TIE BIT(4) 52 #define RV8803_CTRL_UIE BIT(5) 53 54 #define RX8803_CTRL_CSEL GENMASK(7, 6) 55 56 #define RX8900_BACKUP_CTRL 0x18 57 #define RX8900_FLAG_SWOFF BIT(2) 58 #define RX8900_FLAG_VDETOFF BIT(3) 59 60 enum rv8803_type { 61 rv_8803, 62 rx_8803, 63 rx_8804, 64 rx_8900 65 }; 66 67 struct rv8803_data { 68 struct i2c_client *client; 69 struct rtc_device *rtc; 70 struct mutex flags_lock; 71 u8 ctrl; 72 u8 backup; 73 enum rv8803_type type; 74 }; 75 76 static int rv8803_read_reg(const struct i2c_client *client, u8 reg) 77 { 78 int try = RV8803_I2C_TRY_COUNT; 79 s32 ret; 80 81 /* 82 * There is a 61µs window during which the RTC does not acknowledge I2C 83 * transfers. In that case, ensure that there are multiple attempts. 84 */ 85 do 86 ret = i2c_smbus_read_byte_data(client, reg); 87 while ((ret == -ENXIO || ret == -EIO) && --try); 88 if (ret < 0) 89 dev_err(&client->dev, "Unable to read register 0x%02x\n", reg); 90 91 return ret; 92 } 93 94 static int rv8803_read_regs(const struct i2c_client *client, 95 u8 reg, u8 count, u8 *values) 96 { 97 int try = RV8803_I2C_TRY_COUNT; 98 s32 ret; 99 100 do 101 ret = i2c_smbus_read_i2c_block_data(client, reg, count, values); 102 while ((ret == -ENXIO || ret == -EIO) && --try); 103 if (ret != count) { 104 dev_err(&client->dev, 105 "Unable to read registers 0x%02x..0x%02x\n", 106 reg, reg + count - 1); 107 return ret < 0 ? ret : -EIO; 108 } 109 110 return 0; 111 } 112 113 static int rv8803_write_reg(const struct i2c_client *client, u8 reg, u8 value) 114 { 115 int try = RV8803_I2C_TRY_COUNT; 116 s32 ret; 117 118 do 119 ret = i2c_smbus_write_byte_data(client, reg, value); 120 while ((ret == -ENXIO || ret == -EIO) && --try); 121 if (ret) 122 dev_err(&client->dev, "Unable to write register 0x%02x\n", reg); 123 124 return ret; 125 } 126 127 static int rv8803_write_regs(const struct i2c_client *client, 128 u8 reg, u8 count, const u8 *values) 129 { 130 int try = RV8803_I2C_TRY_COUNT; 131 s32 ret; 132 133 do 134 ret = i2c_smbus_write_i2c_block_data(client, reg, count, 135 values); 136 while ((ret == -ENXIO || ret == -EIO) && --try); 137 if (ret) 138 dev_err(&client->dev, 139 "Unable to write registers 0x%02x..0x%02x\n", 140 reg, reg + count - 1); 141 142 return ret; 143 } 144 145 static int rv8803_regs_init(struct rv8803_data *rv8803) 146 { 147 int ret; 148 149 ret = rv8803_write_reg(rv8803->client, RV8803_OSC_OFFSET, 0x00); 150 if (ret) 151 return ret; 152 153 ret = rv8803_write_reg(rv8803->client, RV8803_CTRL, 154 FIELD_PREP(RX8803_CTRL_CSEL, 1)); /* 2s */ 155 if (ret) 156 return ret; 157 158 ret = rv8803_write_regs(rv8803->client, RV8803_ALARM_MIN, 3, 159 (u8[]){ 0, 0, 0 }); 160 if (ret) 161 return ret; 162 163 return rv8803_write_reg(rv8803->client, RV8803_RAM, 0x00); 164 } 165 166 static int rv8803_regs_configure(struct rv8803_data *rv8803); 167 168 static int rv8803_regs_reset(struct rv8803_data *rv8803) 169 { 170 /* 171 * The RV-8803 resets all registers to POR defaults after voltage-loss, 172 * the Epson RTCs don't, so we manually reset the remainder here. 173 */ 174 if (rv8803->type == rx_8803 || rv8803->type == rx_8900) { 175 int ret = rv8803_regs_init(rv8803); 176 if (ret) 177 return ret; 178 } 179 180 return rv8803_regs_configure(rv8803); 181 } 182 183 static irqreturn_t rv8803_handle_irq(int irq, void *dev_id) 184 { 185 struct i2c_client *client = dev_id; 186 struct rv8803_data *rv8803 = i2c_get_clientdata(client); 187 unsigned long events = 0; 188 int flags; 189 190 mutex_lock(&rv8803->flags_lock); 191 192 flags = rv8803_read_reg(client, RV8803_FLAG); 193 if (flags <= 0) { 194 mutex_unlock(&rv8803->flags_lock); 195 return IRQ_NONE; 196 } 197 198 if (flags & RV8803_FLAG_V1F) 199 dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n"); 200 201 if (flags & RV8803_FLAG_V2F) 202 dev_warn(&client->dev, "Voltage low, data loss detected.\n"); 203 204 if (flags & RV8803_FLAG_TF) { 205 flags &= ~RV8803_FLAG_TF; 206 rv8803->ctrl &= ~RV8803_CTRL_TIE; 207 events |= RTC_PF; 208 } 209 210 if (flags & RV8803_FLAG_AF) { 211 flags &= ~RV8803_FLAG_AF; 212 rv8803->ctrl &= ~RV8803_CTRL_AIE; 213 events |= RTC_AF; 214 } 215 216 if (flags & RV8803_FLAG_UF) { 217 flags &= ~RV8803_FLAG_UF; 218 rv8803->ctrl &= ~RV8803_CTRL_UIE; 219 events |= RTC_UF; 220 } 221 222 if (events) { 223 rtc_update_irq(rv8803->rtc, 1, events); 224 rv8803_write_reg(client, RV8803_FLAG, flags); 225 rv8803_write_reg(rv8803->client, RV8803_CTRL, rv8803->ctrl); 226 } 227 228 mutex_unlock(&rv8803->flags_lock); 229 230 return IRQ_HANDLED; 231 } 232 233 static int rv8803_get_time(struct device *dev, struct rtc_time *tm) 234 { 235 struct rv8803_data *rv8803 = dev_get_drvdata(dev); 236 u8 date1[7]; 237 u8 date2[7]; 238 u8 *date = date1; 239 int ret, flags; 240 241 flags = rv8803_read_reg(rv8803->client, RV8803_FLAG); 242 if (flags < 0) 243 return flags; 244 245 if (flags & RV8803_FLAG_V2F) { 246 dev_warn(dev, "Voltage low, data is invalid.\n"); 247 return -EINVAL; 248 } 249 250 ret = rv8803_read_regs(rv8803->client, RV8803_SEC, 7, date); 251 if (ret) 252 return ret; 253 254 if ((date1[RV8803_SEC] & 0x7f) == bin2bcd(59)) { 255 ret = rv8803_read_regs(rv8803->client, RV8803_SEC, 7, date2); 256 if (ret) 257 return ret; 258 259 if ((date2[RV8803_SEC] & 0x7f) != bin2bcd(59)) 260 date = date2; 261 } 262 263 tm->tm_sec = bcd2bin(date[RV8803_SEC] & 0x7f); 264 tm->tm_min = bcd2bin(date[RV8803_MIN] & 0x7f); 265 tm->tm_hour = bcd2bin(date[RV8803_HOUR] & 0x3f); 266 tm->tm_wday = ilog2(date[RV8803_WEEK] & 0x7f); 267 tm->tm_mday = bcd2bin(date[RV8803_DAY] & 0x3f); 268 tm->tm_mon = bcd2bin(date[RV8803_MONTH] & 0x1f) - 1; 269 tm->tm_year = bcd2bin(date[RV8803_YEAR]) + 100; 270 271 return 0; 272 } 273 274 static int rv8803_set_time(struct device *dev, struct rtc_time *tm) 275 { 276 struct rv8803_data *rv8803 = dev_get_drvdata(dev); 277 u8 date[7]; 278 int ctrl, flags, ret; 279 280 ctrl = rv8803_read_reg(rv8803->client, RV8803_CTRL); 281 if (ctrl < 0) 282 return ctrl; 283 284 /* Stop the clock */ 285 ret = rv8803_write_reg(rv8803->client, RV8803_CTRL, 286 ctrl | RV8803_CTRL_RESET); 287 if (ret) 288 return ret; 289 290 date[RV8803_SEC] = bin2bcd(tm->tm_sec); 291 date[RV8803_MIN] = bin2bcd(tm->tm_min); 292 date[RV8803_HOUR] = bin2bcd(tm->tm_hour); 293 date[RV8803_WEEK] = 1 << (tm->tm_wday); 294 date[RV8803_DAY] = bin2bcd(tm->tm_mday); 295 date[RV8803_MONTH] = bin2bcd(tm->tm_mon + 1); 296 date[RV8803_YEAR] = bin2bcd(tm->tm_year - 100); 297 298 ret = rv8803_write_regs(rv8803->client, RV8803_SEC, 7, date); 299 if (ret) 300 return ret; 301 302 /* Restart the clock */ 303 ret = rv8803_write_reg(rv8803->client, RV8803_CTRL, 304 ctrl & ~RV8803_CTRL_RESET); 305 if (ret) 306 return ret; 307 308 mutex_lock(&rv8803->flags_lock); 309 310 flags = rv8803_read_reg(rv8803->client, RV8803_FLAG); 311 if (flags < 0) { 312 mutex_unlock(&rv8803->flags_lock); 313 return flags; 314 } 315 316 if (flags & RV8803_FLAG_V2F) { 317 ret = rv8803_regs_reset(rv8803); 318 if (ret) { 319 mutex_unlock(&rv8803->flags_lock); 320 return ret; 321 } 322 } 323 324 ret = rv8803_write_reg(rv8803->client, RV8803_FLAG, 325 flags & ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F)); 326 327 mutex_unlock(&rv8803->flags_lock); 328 329 return ret; 330 } 331 332 static int rv8803_get_alarm(struct device *dev, struct rtc_wkalrm *alrm) 333 { 334 struct rv8803_data *rv8803 = dev_get_drvdata(dev); 335 struct i2c_client *client = rv8803->client; 336 u8 alarmvals[3]; 337 int flags, ret; 338 339 ret = rv8803_read_regs(client, RV8803_ALARM_MIN, 3, alarmvals); 340 if (ret) 341 return ret; 342 343 flags = rv8803_read_reg(client, RV8803_FLAG); 344 if (flags < 0) 345 return flags; 346 347 alrm->time.tm_sec = 0; 348 alrm->time.tm_min = bcd2bin(alarmvals[0] & 0x7f); 349 alrm->time.tm_hour = bcd2bin(alarmvals[1] & 0x3f); 350 alrm->time.tm_mday = bcd2bin(alarmvals[2] & 0x3f); 351 352 alrm->enabled = !!(rv8803->ctrl & RV8803_CTRL_AIE); 353 alrm->pending = (flags & RV8803_FLAG_AF) && alrm->enabled; 354 355 return 0; 356 } 357 358 static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 359 { 360 struct i2c_client *client = to_i2c_client(dev); 361 struct rv8803_data *rv8803 = dev_get_drvdata(dev); 362 u8 alarmvals[3]; 363 u8 ctrl[2]; 364 int ret, err; 365 366 /* The alarm has no seconds, round up to nearest minute */ 367 if (alrm->time.tm_sec) { 368 time64_t alarm_time = rtc_tm_to_time64(&alrm->time); 369 370 alarm_time += 60 - alrm->time.tm_sec; 371 rtc_time64_to_tm(alarm_time, &alrm->time); 372 } 373 374 mutex_lock(&rv8803->flags_lock); 375 376 ret = rv8803_read_regs(client, RV8803_FLAG, 2, ctrl); 377 if (ret) { 378 mutex_unlock(&rv8803->flags_lock); 379 return ret; 380 } 381 382 alarmvals[0] = bin2bcd(alrm->time.tm_min); 383 alarmvals[1] = bin2bcd(alrm->time.tm_hour); 384 alarmvals[2] = bin2bcd(alrm->time.tm_mday); 385 386 if (rv8803->ctrl & (RV8803_CTRL_AIE | RV8803_CTRL_UIE)) { 387 rv8803->ctrl &= ~(RV8803_CTRL_AIE | RV8803_CTRL_UIE); 388 err = rv8803_write_reg(rv8803->client, RV8803_CTRL, 389 rv8803->ctrl); 390 if (err) { 391 mutex_unlock(&rv8803->flags_lock); 392 return err; 393 } 394 } 395 396 ctrl[0] &= ~RV8803_FLAG_AF; 397 err = rv8803_write_reg(rv8803->client, RV8803_FLAG, ctrl[0]); 398 mutex_unlock(&rv8803->flags_lock); 399 if (err) 400 return err; 401 402 err = rv8803_write_regs(rv8803->client, RV8803_ALARM_MIN, 3, alarmvals); 403 if (err) 404 return err; 405 406 if (alrm->enabled) { 407 if (rv8803->rtc->uie_rtctimer.enabled) 408 rv8803->ctrl |= RV8803_CTRL_UIE; 409 if (rv8803->rtc->aie_timer.enabled) 410 rv8803->ctrl |= RV8803_CTRL_AIE; 411 412 err = rv8803_write_reg(rv8803->client, RV8803_CTRL, 413 rv8803->ctrl); 414 if (err) 415 return err; 416 } 417 418 return 0; 419 } 420 421 static int rv8803_alarm_irq_enable(struct device *dev, unsigned int enabled) 422 { 423 struct i2c_client *client = to_i2c_client(dev); 424 struct rv8803_data *rv8803 = dev_get_drvdata(dev); 425 int ctrl, flags, err; 426 427 ctrl = rv8803->ctrl; 428 429 if (enabled) { 430 if (rv8803->rtc->uie_rtctimer.enabled) 431 ctrl |= RV8803_CTRL_UIE; 432 if (rv8803->rtc->aie_timer.enabled) 433 ctrl |= RV8803_CTRL_AIE; 434 } else { 435 if (!rv8803->rtc->uie_rtctimer.enabled) 436 ctrl &= ~RV8803_CTRL_UIE; 437 if (!rv8803->rtc->aie_timer.enabled) 438 ctrl &= ~RV8803_CTRL_AIE; 439 } 440 441 mutex_lock(&rv8803->flags_lock); 442 flags = rv8803_read_reg(client, RV8803_FLAG); 443 if (flags < 0) { 444 mutex_unlock(&rv8803->flags_lock); 445 return flags; 446 } 447 flags &= ~(RV8803_FLAG_AF | RV8803_FLAG_UF); 448 err = rv8803_write_reg(client, RV8803_FLAG, flags); 449 mutex_unlock(&rv8803->flags_lock); 450 if (err) 451 return err; 452 453 if (ctrl != rv8803->ctrl) { 454 rv8803->ctrl = ctrl; 455 err = rv8803_write_reg(client, RV8803_CTRL, rv8803->ctrl); 456 if (err) 457 return err; 458 } 459 460 return 0; 461 } 462 463 static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 464 { 465 struct i2c_client *client = to_i2c_client(dev); 466 struct rv8803_data *rv8803 = dev_get_drvdata(dev); 467 unsigned int vl = 0; 468 int flags, ret = 0; 469 470 switch (cmd) { 471 case RTC_VL_READ: 472 flags = rv8803_read_reg(client, RV8803_FLAG); 473 if (flags < 0) 474 return flags; 475 476 if (flags & RV8803_FLAG_V1F) { 477 dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n"); 478 vl = RTC_VL_ACCURACY_LOW; 479 } 480 481 if (flags & RV8803_FLAG_V2F) 482 vl |= RTC_VL_DATA_INVALID; 483 484 return put_user(vl, (unsigned int __user *)arg); 485 486 case RTC_VL_CLR: 487 mutex_lock(&rv8803->flags_lock); 488 flags = rv8803_read_reg(client, RV8803_FLAG); 489 if (flags < 0) { 490 mutex_unlock(&rv8803->flags_lock); 491 return flags; 492 } 493 494 flags &= ~RV8803_FLAG_V1F; 495 ret = rv8803_write_reg(client, RV8803_FLAG, flags); 496 mutex_unlock(&rv8803->flags_lock); 497 if (ret) 498 return ret; 499 500 return 0; 501 502 default: 503 return -ENOIOCTLCMD; 504 } 505 } 506 507 static int rv8803_nvram_write(void *priv, unsigned int offset, void *val, 508 size_t bytes) 509 { 510 return rv8803_write_reg(priv, RV8803_RAM, *(u8 *)val); 511 } 512 513 static int rv8803_nvram_read(void *priv, unsigned int offset, 514 void *val, size_t bytes) 515 { 516 int ret; 517 518 ret = rv8803_read_reg(priv, RV8803_RAM); 519 if (ret < 0) 520 return ret; 521 522 *(u8 *)val = ret; 523 524 return 0; 525 } 526 527 static const struct rtc_class_ops rv8803_rtc_ops = { 528 .read_time = rv8803_get_time, 529 .set_time = rv8803_set_time, 530 .ioctl = rv8803_ioctl, 531 .read_alarm = rv8803_get_alarm, 532 .set_alarm = rv8803_set_alarm, 533 .alarm_irq_enable = rv8803_alarm_irq_enable, 534 }; 535 536 static int rx8900_trickle_charger_init(struct rv8803_data *rv8803) 537 { 538 struct i2c_client *client = rv8803->client; 539 struct device_node *node = client->dev.of_node; 540 int err; 541 u8 flags; 542 543 if (!node) 544 return 0; 545 546 if (rv8803->type != rx_8900) 547 return 0; 548 549 err = i2c_smbus_read_byte_data(rv8803->client, RX8900_BACKUP_CTRL); 550 if (err < 0) 551 return err; 552 553 flags = (u8)err; 554 flags &= ~(RX8900_FLAG_VDETOFF | RX8900_FLAG_SWOFF); 555 flags |= rv8803->backup; 556 557 return i2c_smbus_write_byte_data(rv8803->client, RX8900_BACKUP_CTRL, 558 flags); 559 } 560 561 /* configure registers with values different than the Power-On reset defaults */ 562 static int rv8803_regs_configure(struct rv8803_data *rv8803) 563 { 564 int err; 565 566 err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA); 567 if (err) 568 return err; 569 570 err = rx8900_trickle_charger_init(rv8803); 571 if (err) { 572 dev_err(&rv8803->client->dev, "failed to init charger\n"); 573 return err; 574 } 575 576 return 0; 577 } 578 579 static int rv8803_probe(struct i2c_client *client, 580 const struct i2c_device_id *id) 581 { 582 struct i2c_adapter *adapter = client->adapter; 583 struct rv8803_data *rv8803; 584 int err, flags; 585 struct nvmem_config nvmem_cfg = { 586 .name = "rv8803_nvram", 587 .word_size = 1, 588 .stride = 1, 589 .size = 1, 590 .reg_read = rv8803_nvram_read, 591 .reg_write = rv8803_nvram_write, 592 .priv = client, 593 }; 594 595 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 596 I2C_FUNC_SMBUS_I2C_BLOCK)) { 597 dev_err(&adapter->dev, "doesn't support I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK\n"); 598 return -EIO; 599 } 600 601 rv8803 = devm_kzalloc(&client->dev, sizeof(struct rv8803_data), 602 GFP_KERNEL); 603 if (!rv8803) 604 return -ENOMEM; 605 606 mutex_init(&rv8803->flags_lock); 607 rv8803->client = client; 608 if (client->dev.of_node) 609 rv8803->type = (enum rv8803_type) 610 of_device_get_match_data(&client->dev); 611 else 612 rv8803->type = id->driver_data; 613 i2c_set_clientdata(client, rv8803); 614 615 flags = rv8803_read_reg(client, RV8803_FLAG); 616 if (flags < 0) 617 return flags; 618 619 if (flags & RV8803_FLAG_V1F) 620 dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n"); 621 622 if (flags & RV8803_FLAG_V2F) 623 dev_warn(&client->dev, "Voltage low, data loss detected.\n"); 624 625 if (flags & RV8803_FLAG_AF) 626 dev_warn(&client->dev, "An alarm maybe have been missed.\n"); 627 628 rv8803->rtc = devm_rtc_allocate_device(&client->dev); 629 if (IS_ERR(rv8803->rtc)) 630 return PTR_ERR(rv8803->rtc); 631 632 if (client->irq > 0) { 633 err = devm_request_threaded_irq(&client->dev, client->irq, 634 NULL, rv8803_handle_irq, 635 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 636 "rv8803", client); 637 if (err) { 638 dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n"); 639 client->irq = 0; 640 } 641 } 642 if (!client->irq) 643 clear_bit(RTC_FEATURE_ALARM, rv8803->rtc->features); 644 645 if (of_property_read_bool(client->dev.of_node, "epson,vdet-disable")) 646 rv8803->backup |= RX8900_FLAG_VDETOFF; 647 648 if (of_property_read_bool(client->dev.of_node, "trickle-diode-disable")) 649 rv8803->backup |= RX8900_FLAG_SWOFF; 650 651 err = rv8803_regs_configure(rv8803); 652 if (err) 653 return err; 654 655 rv8803->rtc->ops = &rv8803_rtc_ops; 656 rv8803->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; 657 rv8803->rtc->range_max = RTC_TIMESTAMP_END_2099; 658 err = devm_rtc_register_device(rv8803->rtc); 659 if (err) 660 return err; 661 662 devm_rtc_nvmem_register(rv8803->rtc, &nvmem_cfg); 663 664 rv8803->rtc->max_user_freq = 1; 665 666 return 0; 667 } 668 669 static const struct i2c_device_id rv8803_id[] = { 670 { "rv8803", rv_8803 }, 671 { "rv8804", rx_8804 }, 672 { "rx8803", rx_8803 }, 673 { "rx8900", rx_8900 }, 674 { } 675 }; 676 MODULE_DEVICE_TABLE(i2c, rv8803_id); 677 678 static const __maybe_unused struct of_device_id rv8803_of_match[] = { 679 { 680 .compatible = "microcrystal,rv8803", 681 .data = (void *)rv_8803 682 }, 683 { 684 .compatible = "epson,rx8803", 685 .data = (void *)rx_8803 686 }, 687 { 688 .compatible = "epson,rx8804", 689 .data = (void *)rx_8804 690 }, 691 { 692 .compatible = "epson,rx8900", 693 .data = (void *)rx_8900 694 }, 695 { } 696 }; 697 MODULE_DEVICE_TABLE(of, rv8803_of_match); 698 699 static struct i2c_driver rv8803_driver = { 700 .driver = { 701 .name = "rtc-rv8803", 702 .of_match_table = of_match_ptr(rv8803_of_match), 703 }, 704 .probe = rv8803_probe, 705 .id_table = rv8803_id, 706 }; 707 module_i2c_driver(rv8803_driver); 708 709 MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@bootlin.com>"); 710 MODULE_DESCRIPTION("Micro Crystal RV8803 RTC driver"); 711 MODULE_LICENSE("GPL v2"); 712