2 * Intersil ISL1208 rtc class driver
4 * Copyright 2005,2006 Hebert Valerio Riedel <hvr@gnu.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
13 #include <linux/bcd.h>
14 #include <linux/i2c.h>
15 #include <linux/module.h>
16 #include <linux/of_irq.h>
17 #include <linux/rtc.h>
21 #define ISL1208_REG_SC 0x00
22 #define ISL1208_REG_MN 0x01
23 #define ISL1208_REG_HR 0x02
24 #define ISL1208_REG_HR_MIL (1<<7) /* 24h/12h mode */
25 #define ISL1208_REG_HR_PM (1<<5) /* PM/AM bit in 12h mode */
26 #define ISL1208_REG_DT 0x03
27 #define ISL1208_REG_MO 0x04
28 #define ISL1208_REG_YR 0x05
29 #define ISL1208_REG_DW 0x06
30 #define ISL1208_RTC_SECTION_LEN 7
32 /* control/status section */
33 #define ISL1208_REG_SR 0x07
34 #define ISL1208_REG_SR_ARST (1<<7) /* auto reset */
35 #define ISL1208_REG_SR_XTOSCB (1<<6) /* crystal oscillator */
36 #define ISL1208_REG_SR_WRTC (1<<4) /* write rtc */
37 #define ISL1208_REG_SR_EVT (1<<3) /* event */
38 #define ISL1208_REG_SR_ALM (1<<2) /* alarm */
39 #define ISL1208_REG_SR_BAT (1<<1) /* battery */
40 #define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */
41 #define ISL1208_REG_INT 0x08
42 #define ISL1208_REG_INT_ALME (1<<6) /* alarm enable */
43 #define ISL1208_REG_INT_IM (1<<7) /* interrupt/alarm mode */
44 #define ISL1219_REG_EV 0x09
45 #define ISL1219_REG_EV_EVEN (1<<4) /* event detection enable */
46 #define ISL1219_REG_EV_EVIENB (1<<7) /* event in pull-up disable */
47 #define ISL1208_REG_ATR 0x0a
48 #define ISL1208_REG_DTR 0x0b
51 #define ISL1208_REG_SCA 0x0c
52 #define ISL1208_REG_MNA 0x0d
53 #define ISL1208_REG_HRA 0x0e
54 #define ISL1208_REG_DTA 0x0f
55 #define ISL1208_REG_MOA 0x10
56 #define ISL1208_REG_DWA 0x11
57 #define ISL1208_ALARM_SECTION_LEN 6
60 #define ISL1208_REG_USR1 0x12
61 #define ISL1208_REG_USR2 0x13
62 #define ISL1208_USR_SECTION_LEN 2
65 #define ISL1219_REG_SCT 0x14
66 #define ISL1219_REG_MNT 0x15
67 #define ISL1219_REG_HRT 0x16
68 #define ISL1219_REG_DTT 0x17
69 #define ISL1219_REG_MOT 0x18
70 #define ISL1219_REG_YRT 0x19
71 #define ISL1219_EVT_SECTION_LEN 6
73 static struct i2c_driver isl1208_driver;
75 /* ISL1208 various variants */
84 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
87 u8 reg_addr[1] = { reg };
88 struct i2c_msg msgs[2] = {
91 .len = sizeof(reg_addr),
103 WARN_ON(reg > ISL1219_REG_YRT);
104 WARN_ON(reg + len > ISL1219_REG_YRT + 1);
106 ret = i2c_transfer(client->adapter, msgs, 2);
114 isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[],
117 u8 i2c_buf[ISL1208_REG_USR2 + 2];
118 struct i2c_msg msgs[1] = {
120 .addr = client->addr,
127 WARN_ON(reg > ISL1219_REG_YRT);
128 WARN_ON(reg + len > ISL1219_REG_YRT + 1);
131 memcpy(&i2c_buf[1], &buf[0], len);
133 ret = i2c_transfer(client->adapter, msgs, 1);
139 /* simple check to see whether we have a isl1208 */
141 isl1208_i2c_validate_client(struct i2c_client *client)
143 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
144 u8 zero_mask[ISL1208_RTC_SECTION_LEN] = {
145 0x80, 0x80, 0x40, 0xc0, 0xe0, 0x00, 0xf8
150 ret = isl1208_i2c_read_regs(client, 0, regs, ISL1208_RTC_SECTION_LEN);
154 for (i = 0; i < ISL1208_RTC_SECTION_LEN; ++i) {
155 if (regs[i] & zero_mask[i]) /* check if bits are cleared */
163 isl1208_i2c_get_sr(struct i2c_client *client)
165 return i2c_smbus_read_byte_data(client, ISL1208_REG_SR);
169 isl1208_i2c_get_atr(struct i2c_client *client)
171 int atr = i2c_smbus_read_byte_data(client, ISL1208_REG_ATR);
175 /* The 6bit value in the ATR register controls the load
176 * capacitance C_load * in steps of 0.25pF
178 * bit (1<<5) of the ATR register is inverted
180 * C_load(ATR=0x20) = 4.50pF
181 * C_load(ATR=0x00) = 12.50pF
182 * C_load(ATR=0x1f) = 20.25pF
186 atr &= 0x3f; /* mask out lsb */
187 atr ^= 1 << 5; /* invert 6th bit */
188 atr += 2 * 9; /* add offset of 4.5pF; unit[atr] = 0.25pF */
194 isl1208_i2c_get_dtr(struct i2c_client *client)
196 int dtr = i2c_smbus_read_byte_data(client, ISL1208_REG_DTR);
200 /* dtr encodes adjustments of {-60,-40,-20,0,20,40,60} ppm */
201 dtr = ((dtr & 0x3) * 20) * (dtr & (1 << 2) ? -1 : 1);
207 isl1208_i2c_get_usr(struct i2c_client *client)
209 u8 buf[ISL1208_USR_SECTION_LEN] = { 0, };
212 ret = isl1208_i2c_read_regs(client, ISL1208_REG_USR1, buf,
213 ISL1208_USR_SECTION_LEN);
217 return (buf[1] << 8) | buf[0];
221 isl1208_i2c_set_usr(struct i2c_client *client, u16 usr)
223 u8 buf[ISL1208_USR_SECTION_LEN];
226 buf[1] = (usr >> 8) & 0xff;
228 return isl1208_i2c_set_regs(client, ISL1208_REG_USR1, buf,
229 ISL1208_USR_SECTION_LEN);
233 isl1208_rtc_toggle_alarm(struct i2c_client *client, int enable)
235 int icr = i2c_smbus_read_byte_data(client, ISL1208_REG_INT);
238 dev_err(&client->dev, "%s: reading INT failed\n", __func__);
243 icr |= ISL1208_REG_INT_ALME | ISL1208_REG_INT_IM;
245 icr &= ~(ISL1208_REG_INT_ALME | ISL1208_REG_INT_IM);
247 icr = i2c_smbus_write_byte_data(client, ISL1208_REG_INT, icr);
249 dev_err(&client->dev, "%s: writing INT failed\n", __func__);
257 isl1208_rtc_proc(struct device *dev, struct seq_file *seq)
259 struct i2c_client *const client = to_i2c_client(dev);
260 int sr, dtr, atr, usr;
262 sr = isl1208_i2c_get_sr(client);
264 dev_err(&client->dev, "%s: reading SR failed\n", __func__);
268 seq_printf(seq, "status_reg\t:%s%s%s%s%s%s (0x%.2x)\n",
269 (sr & ISL1208_REG_SR_RTCF) ? " RTCF" : "",
270 (sr & ISL1208_REG_SR_BAT) ? " BAT" : "",
271 (sr & ISL1208_REG_SR_ALM) ? " ALM" : "",
272 (sr & ISL1208_REG_SR_WRTC) ? " WRTC" : "",
273 (sr & ISL1208_REG_SR_XTOSCB) ? " XTOSCB" : "",
274 (sr & ISL1208_REG_SR_ARST) ? " ARST" : "", sr);
276 seq_printf(seq, "batt_status\t: %s\n",
277 (sr & ISL1208_REG_SR_RTCF) ? "bad" : "okay");
279 dtr = isl1208_i2c_get_dtr(client);
281 seq_printf(seq, "digital_trim\t: %d ppm\n", dtr);
283 atr = isl1208_i2c_get_atr(client);
285 seq_printf(seq, "analog_trim\t: %d.%.2d pF\n",
286 atr >> 2, (atr & 0x3) * 25);
288 usr = isl1208_i2c_get_usr(client);
290 seq_printf(seq, "user_data\t: 0x%.4x\n", usr);
296 isl1208_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
299 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
301 sr = isl1208_i2c_get_sr(client);
303 dev_err(&client->dev, "%s: reading SR failed\n", __func__);
307 sr = isl1208_i2c_read_regs(client, 0, regs, ISL1208_RTC_SECTION_LEN);
309 dev_err(&client->dev, "%s: reading RTC section failed\n",
314 tm->tm_sec = bcd2bin(regs[ISL1208_REG_SC]);
315 tm->tm_min = bcd2bin(regs[ISL1208_REG_MN]);
317 /* HR field has a more complex interpretation */
319 const u8 _hr = regs[ISL1208_REG_HR];
320 if (_hr & ISL1208_REG_HR_MIL) /* 24h format */
321 tm->tm_hour = bcd2bin(_hr & 0x3f);
324 tm->tm_hour = bcd2bin(_hr & 0x1f);
325 if (_hr & ISL1208_REG_HR_PM) /* PM flag set */
330 tm->tm_mday = bcd2bin(regs[ISL1208_REG_DT]);
331 tm->tm_mon = bcd2bin(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */
332 tm->tm_year = bcd2bin(regs[ISL1208_REG_YR]) + 100;
333 tm->tm_wday = bcd2bin(regs[ISL1208_REG_DW]);
339 isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
341 struct rtc_time *const tm = &alarm->time;
342 u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, };
343 int icr, yr, sr = isl1208_i2c_get_sr(client);
346 dev_err(&client->dev, "%s: reading SR failed\n", __func__);
350 sr = isl1208_i2c_read_regs(client, ISL1208_REG_SCA, regs,
351 ISL1208_ALARM_SECTION_LEN);
353 dev_err(&client->dev, "%s: reading alarm section failed\n",
358 /* MSB of each alarm register is an enable bit */
359 tm->tm_sec = bcd2bin(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f);
360 tm->tm_min = bcd2bin(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f);
361 tm->tm_hour = bcd2bin(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f);
362 tm->tm_mday = bcd2bin(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f);
364 bcd2bin(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1;
365 tm->tm_wday = bcd2bin(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03);
367 /* The alarm doesn't store the year so get it from the rtc section */
368 yr = i2c_smbus_read_byte_data(client, ISL1208_REG_YR);
370 dev_err(&client->dev, "%s: reading RTC YR failed\n", __func__);
373 tm->tm_year = bcd2bin(yr) + 100;
375 icr = i2c_smbus_read_byte_data(client, ISL1208_REG_INT);
377 dev_err(&client->dev, "%s: reading INT failed\n", __func__);
380 alarm->enabled = !!(icr & ISL1208_REG_INT_ALME);
386 isl1208_i2c_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
388 struct rtc_time *alarm_tm = &alarm->time;
389 u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, };
390 const int offs = ISL1208_REG_SCA;
391 struct rtc_time rtc_tm;
394 err = isl1208_i2c_read_time(client, &rtc_tm);
398 /* If the alarm time is before the current time disable the alarm */
399 if (!alarm->enabled || rtc_tm_sub(alarm_tm, &rtc_tm) <= 0)
404 /* Program the alarm and enable it for each setting */
405 regs[ISL1208_REG_SCA - offs] = bin2bcd(alarm_tm->tm_sec) | enable;
406 regs[ISL1208_REG_MNA - offs] = bin2bcd(alarm_tm->tm_min) | enable;
407 regs[ISL1208_REG_HRA - offs] = bin2bcd(alarm_tm->tm_hour) |
408 ISL1208_REG_HR_MIL | enable;
410 regs[ISL1208_REG_DTA - offs] = bin2bcd(alarm_tm->tm_mday) | enable;
411 regs[ISL1208_REG_MOA - offs] = bin2bcd(alarm_tm->tm_mon + 1) | enable;
412 regs[ISL1208_REG_DWA - offs] = bin2bcd(alarm_tm->tm_wday & 7) | enable;
414 /* write ALARM registers */
415 err = isl1208_i2c_set_regs(client, offs, regs,
416 ISL1208_ALARM_SECTION_LEN);
418 dev_err(&client->dev, "%s: writing ALARM section failed\n",
423 err = isl1208_rtc_toggle_alarm(client, enable);
431 isl1208_rtc_read_time(struct device *dev, struct rtc_time *tm)
433 return isl1208_i2c_read_time(to_i2c_client(dev), tm);
437 isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
440 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
442 /* The clock has an 8 bit wide bcd-coded register (they never learn)
443 * for the year. tm_year is an offset from 1900 and we are interested
444 * in the 2000-2099 range, so any value less than 100 is invalid.
446 if (tm->tm_year < 100)
449 regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec);
450 regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min);
451 regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL;
453 regs[ISL1208_REG_DT] = bin2bcd(tm->tm_mday);
454 regs[ISL1208_REG_MO] = bin2bcd(tm->tm_mon + 1);
455 regs[ISL1208_REG_YR] = bin2bcd(tm->tm_year - 100);
457 regs[ISL1208_REG_DW] = bin2bcd(tm->tm_wday & 7);
459 sr = isl1208_i2c_get_sr(client);
461 dev_err(&client->dev, "%s: reading SR failed\n", __func__);
466 sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
467 sr | ISL1208_REG_SR_WRTC);
469 dev_err(&client->dev, "%s: writing SR failed\n", __func__);
473 /* write RTC registers */
474 sr = isl1208_i2c_set_regs(client, 0, regs, ISL1208_RTC_SECTION_LEN);
476 dev_err(&client->dev, "%s: writing RTC section failed\n",
481 /* clear WRTC again */
482 sr = isl1208_i2c_get_sr(client);
484 dev_err(&client->dev, "%s: reading SR failed\n", __func__);
487 sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
488 sr & ~ISL1208_REG_SR_WRTC);
490 dev_err(&client->dev, "%s: writing SR failed\n", __func__);
499 isl1208_rtc_set_time(struct device *dev, struct rtc_time *tm)
501 return isl1208_i2c_set_time(to_i2c_client(dev), tm);
505 isl1208_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
507 return isl1208_i2c_read_alarm(to_i2c_client(dev), alarm);
511 isl1208_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
513 return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
516 static ssize_t timestamp0_store(struct device *dev,
517 struct device_attribute *attr,
518 const char *buf, size_t count)
520 struct i2c_client *client = to_i2c_client(dev->parent);
523 sr = isl1208_i2c_get_sr(client);
525 dev_err(dev, "%s: reading SR failed\n", __func__);
529 sr &= ~ISL1208_REG_SR_EVT;
531 sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
533 dev_err(dev, "%s: writing SR failed\n",
539 static ssize_t timestamp0_show(struct device *dev,
540 struct device_attribute *attr, char *buf)
542 struct i2c_client *client = to_i2c_client(dev->parent);
543 u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
547 sr = isl1208_i2c_get_sr(client);
549 dev_err(dev, "%s: reading SR failed\n", __func__);
553 if (!(sr & ISL1208_REG_SR_EVT))
556 sr = isl1208_i2c_read_regs(client, ISL1219_REG_SCT, regs,
557 ISL1219_EVT_SECTION_LEN);
559 dev_err(dev, "%s: reading event section failed\n",
564 /* MSB of each alarm register is an enable bit */
565 tm.tm_sec = bcd2bin(regs[ISL1219_REG_SCT - ISL1219_REG_SCT] & 0x7f);
566 tm.tm_min = bcd2bin(regs[ISL1219_REG_MNT - ISL1219_REG_SCT] & 0x7f);
567 tm.tm_hour = bcd2bin(regs[ISL1219_REG_HRT - ISL1219_REG_SCT] & 0x3f);
568 tm.tm_mday = bcd2bin(regs[ISL1219_REG_DTT - ISL1219_REG_SCT] & 0x3f);
570 bcd2bin(regs[ISL1219_REG_MOT - ISL1219_REG_SCT] & 0x1f) - 1;
571 tm.tm_year = bcd2bin(regs[ISL1219_REG_YRT - ISL1219_REG_SCT]) + 100;
573 sr = rtc_valid_tm(&tm);
577 return sprintf(buf, "%llu\n",
578 (unsigned long long)rtc_tm_to_time64(&tm));
581 static DEVICE_ATTR_RW(timestamp0);
584 isl1208_rtc_interrupt(int irq, void *data)
586 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
587 struct i2c_client *client = data;
588 struct rtc_device *rtc = i2c_get_clientdata(client);
589 int handled = 0, sr, err;
592 * I2C reads get NAK'ed if we read straight away after an interrupt?
593 * Using a mdelay/msleep didn't seem to help either, so we work around
594 * this by continually trying to read the register for a short time.
597 sr = isl1208_i2c_get_sr(client);
601 if (time_after(jiffies, timeout)) {
602 dev_err(&client->dev, "%s: reading SR failed\n",
608 if (sr & ISL1208_REG_SR_ALM) {
609 dev_dbg(&client->dev, "alarm!\n");
611 rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
613 /* Clear the alarm */
614 sr &= ~ISL1208_REG_SR_ALM;
615 sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
617 dev_err(&client->dev, "%s: writing SR failed\n",
622 /* Disable the alarm */
623 err = isl1208_rtc_toggle_alarm(client, 0);
628 if (sr & ISL1208_REG_SR_EVT) {
629 sysfs_notify(&rtc->dev.kobj, NULL,
630 dev_attr_timestamp0.attr.name);
631 dev_warn(&client->dev, "event detected");
635 return handled ? IRQ_HANDLED : IRQ_NONE;
638 static const struct rtc_class_ops isl1208_rtc_ops = {
639 .proc = isl1208_rtc_proc,
640 .read_time = isl1208_rtc_read_time,
641 .set_time = isl1208_rtc_set_time,
642 .read_alarm = isl1208_rtc_read_alarm,
643 .set_alarm = isl1208_rtc_set_alarm,
646 /* sysfs interface */
649 isl1208_sysfs_show_atrim(struct device *dev,
650 struct device_attribute *attr, char *buf)
652 int atr = isl1208_i2c_get_atr(to_i2c_client(dev->parent));
656 return sprintf(buf, "%d.%.2d pF\n", atr >> 2, (atr & 0x3) * 25);
659 static DEVICE_ATTR(atrim, S_IRUGO, isl1208_sysfs_show_atrim, NULL);
662 isl1208_sysfs_show_dtrim(struct device *dev,
663 struct device_attribute *attr, char *buf)
665 int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev->parent));
669 return sprintf(buf, "%d ppm\n", dtr);
672 static DEVICE_ATTR(dtrim, S_IRUGO, isl1208_sysfs_show_dtrim, NULL);
675 isl1208_sysfs_show_usr(struct device *dev,
676 struct device_attribute *attr, char *buf)
678 int usr = isl1208_i2c_get_usr(to_i2c_client(dev->parent));
682 return sprintf(buf, "0x%.4x\n", usr);
686 isl1208_sysfs_store_usr(struct device *dev,
687 struct device_attribute *attr,
688 const char *buf, size_t count)
692 if (buf[0] == '0' && (buf[1] == 'x' || buf[1] == 'X')) {
693 if (sscanf(buf, "%x", &usr) != 1)
696 if (sscanf(buf, "%d", &usr) != 1)
700 if (usr < 0 || usr > 0xffff)
703 if (isl1208_i2c_set_usr(to_i2c_client(dev->parent), usr))
709 static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr,
710 isl1208_sysfs_store_usr);
712 static struct attribute *isl1208_rtc_attrs[] = {
713 &dev_attr_atrim.attr,
714 &dev_attr_dtrim.attr,
719 static const struct attribute_group isl1208_rtc_sysfs_files = {
720 .attrs = isl1208_rtc_attrs,
723 static struct attribute *isl1219_rtc_attrs[] = {
724 &dev_attr_timestamp0.attr,
728 static const struct attribute_group isl1219_rtc_sysfs_files = {
729 .attrs = isl1219_rtc_attrs,
732 static int isl1208_setup_irq(struct i2c_client *client, int irq)
734 int rc = devm_request_threaded_irq(&client->dev, irq, NULL,
735 isl1208_rtc_interrupt,
736 IRQF_SHARED | IRQF_ONESHOT,
737 isl1208_driver.driver.name,
740 device_init_wakeup(&client->dev, 1);
741 enable_irq_wake(irq);
743 dev_err(&client->dev,
744 "Unable to request irq %d, no alarm support\n",
751 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
754 struct rtc_device *rtc;
757 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
760 if (isl1208_i2c_validate_client(client) < 0)
763 rtc = devm_rtc_allocate_device(&client->dev);
767 rtc->ops = &isl1208_rtc_ops;
769 i2c_set_clientdata(client, rtc);
771 rc = isl1208_i2c_get_sr(client);
773 dev_err(&client->dev, "reading status failed\n");
777 if (rc & ISL1208_REG_SR_RTCF)
778 dev_warn(&client->dev, "rtc power failure detected, "
779 "please set clock.\n");
781 if (id->driver_data == TYPE_ISL1219) {
782 struct device_node *np = client->dev.of_node;
785 rc = i2c_smbus_read_byte_data(client, ISL1219_REG_EV);
787 dev_err(&client->dev, "failed to read EV reg\n");
790 rc |= ISL1219_REG_EV_EVEN;
791 if (!of_property_read_u32(np, "isil,ev-evienb", &evienb)) {
793 rc |= ISL1219_REG_EV_EVIENB;
795 rc &= ~ISL1219_REG_EV_EVIENB;
797 rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
799 dev_err(&client->dev, "could not enable tamper detection\n");
802 rc = rtc_add_group(rtc, &isl1219_rtc_sysfs_files);
805 evdet_irq = of_irq_get_byname(np, "evdet");
808 rc = rtc_add_group(rtc, &isl1208_rtc_sysfs_files);
813 rc = isl1208_setup_irq(client, client->irq);
817 if (evdet_irq > 0 && evdet_irq != client->irq)
818 rc = isl1208_setup_irq(client, evdet_irq);
822 return rtc_register_device(rtc);
825 static const struct i2c_device_id isl1208_id[] = {
826 { "isl1208", TYPE_ISL1208 },
827 { "isl1218", TYPE_ISL1218 },
828 { "isl1219", TYPE_ISL1219 },
831 MODULE_DEVICE_TABLE(i2c, isl1208_id);
833 static const struct of_device_id isl1208_of_match[] = {
834 { .compatible = "isil,isl1208" },
835 { .compatible = "isil,isl1218" },
836 { .compatible = "isil,isl1219" },
839 MODULE_DEVICE_TABLE(of, isl1208_of_match);
841 static struct i2c_driver isl1208_driver = {
843 .name = "rtc-isl1208",
844 .of_match_table = of_match_ptr(isl1208_of_match),
846 .probe = isl1208_probe,
847 .id_table = isl1208_id,
850 module_i2c_driver(isl1208_driver);
852 MODULE_AUTHOR("Herbert Valerio Riedel <hvr@gnu.org>");
853 MODULE_DESCRIPTION("Intersil ISL1208 RTC driver");
854 MODULE_LICENSE("GPL");