Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * An I2C driver for the Epson RX8581 RTC |
| 3 | * |
Martyn Welch | 9756c4d | 2010-04-14 09:24:16 +0100 | [diff] [blame] | 4 | * Author: Martyn Welch <martyn.welch@ge.com> |
| 5 | * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc. |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * Based on: rtc-pcf8563.c (An I2C driver for the Philips PCF8563 RTC) |
| 12 | * Copyright 2005-06 Tower Technologies |
| 13 | */ |
| 14 | |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/i2c.h> |
| 17 | #include <linux/bcd.h> |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 18 | #include <linux/of.h> |
| 19 | #include <linux/of_device.h> |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 20 | #include <linux/regmap.h> |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 21 | #include <linux/rtc.h> |
| 22 | #include <linux/log2.h> |
| 23 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 24 | #define RX8581_REG_SC 0x00 /* Second in BCD */ |
| 25 | #define RX8581_REG_MN 0x01 /* Minute in BCD */ |
| 26 | #define RX8581_REG_HR 0x02 /* Hour in BCD */ |
| 27 | #define RX8581_REG_DW 0x03 /* Day of Week */ |
| 28 | #define RX8581_REG_DM 0x04 /* Day of Month in BCD */ |
| 29 | #define RX8581_REG_MO 0x05 /* Month in BCD */ |
| 30 | #define RX8581_REG_YR 0x06 /* Year in BCD */ |
| 31 | #define RX8581_REG_RAM 0x07 /* RAM */ |
| 32 | #define RX8581_REG_AMN 0x08 /* Alarm Min in BCD*/ |
| 33 | #define RX8581_REG_AHR 0x09 /* Alarm Hour in BCD */ |
| 34 | #define RX8581_REG_ADM 0x0A |
| 35 | #define RX8581_REG_ADW 0x0A |
| 36 | #define RX8581_REG_TMR0 0x0B |
| 37 | #define RX8581_REG_TMR1 0x0C |
| 38 | #define RX8581_REG_EXT 0x0D /* Extension Register */ |
| 39 | #define RX8581_REG_FLAG 0x0E /* Flag Register */ |
| 40 | #define RX8581_REG_CTRL 0x0F /* Control Register */ |
| 41 | |
| 42 | |
| 43 | /* Flag Register bit definitions */ |
| 44 | #define RX8581_FLAG_UF 0x20 /* Update */ |
| 45 | #define RX8581_FLAG_TF 0x10 /* Timer */ |
| 46 | #define RX8581_FLAG_AF 0x08 /* Alarm */ |
| 47 | #define RX8581_FLAG_VLF 0x02 /* Voltage Low */ |
| 48 | |
| 49 | /* Control Register bit definitions */ |
| 50 | #define RX8581_CTRL_UIE 0x20 /* Update Interrupt Enable */ |
| 51 | #define RX8581_CTRL_TIE 0x10 /* Timer Interrupt Enable */ |
| 52 | #define RX8581_CTRL_AIE 0x08 /* Alarm Interrupt Enable */ |
| 53 | #define RX8581_CTRL_STOP 0x02 /* STOP bit */ |
| 54 | #define RX8581_CTRL_RESET 0x01 /* RESET bit */ |
| 55 | |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 56 | #define RX8571_USER_RAM 0x10 |
| 57 | #define RX8571_NVRAM_SIZE 0x10 |
| 58 | |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 59 | struct rx8581 { |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 60 | struct regmap *regmap; |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 61 | struct rtc_device *rtc; |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 64 | struct rx85x1_config { |
| 65 | struct regmap_config regmap; |
| 66 | unsigned int num_nvram; |
| 67 | }; |
| 68 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 69 | /* |
| 70 | * In the routines that deal directly with the rx8581 hardware, we use |
| 71 | * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch. |
| 72 | */ |
Alexandre Belloni | 2d2b300 | 2018-05-17 22:33:28 +0200 | [diff] [blame] | 73 | static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm) |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 74 | { |
Alexandre Belloni | 2d2b300 | 2018-05-17 22:33:28 +0200 | [diff] [blame] | 75 | struct i2c_client *client = to_i2c_client(dev); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 76 | unsigned char date[7]; |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 77 | unsigned int data; |
| 78 | int err; |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 79 | struct rx8581 *rx8581 = i2c_get_clientdata(client); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 80 | |
| 81 | /* First we ensure that the "update flag" is not set, we read the |
| 82 | * time and date then re-read the "update flag". If the update flag |
| 83 | * has been set, we know that the time has changed during the read so |
| 84 | * we repeat the whole process again. |
| 85 | */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 86 | err = regmap_read(rx8581->regmap, RX8581_REG_FLAG, &data); |
| 87 | if (err < 0) |
| 88 | return err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 89 | |
Alexandre Belloni | 6e6111f | 2018-05-17 22:33:30 +0200 | [diff] [blame] | 90 | if (data & RX8581_FLAG_VLF) { |
| 91 | dev_warn(dev, |
| 92 | "low voltage detected, date/time is not reliable.\n"); |
| 93 | return -EINVAL; |
| 94 | } |
| 95 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 96 | do { |
| 97 | /* If update flag set, clear it */ |
| 98 | if (data & RX8581_FLAG_UF) { |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 99 | err = regmap_write(rx8581->regmap, RX8581_REG_FLAG, |
| 100 | data & ~RX8581_FLAG_UF); |
| 101 | if (err < 0) |
| 102 | return err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /* Now read time and date */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 106 | err = regmap_bulk_read(rx8581->regmap, RX8581_REG_SC, date, |
| 107 | sizeof(date)); |
| 108 | if (err < 0) |
| 109 | return err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 110 | |
| 111 | /* Check flag register */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 112 | err = regmap_read(rx8581->regmap, RX8581_REG_FLAG, &data); |
| 113 | if (err < 0) |
| 114 | return err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 115 | } while (data & RX8581_FLAG_UF); |
| 116 | |
Alexandre Belloni | ed87c6d | 2018-05-17 22:33:29 +0200 | [diff] [blame] | 117 | dev_dbg(dev, "%s: raw data is sec=%02x, min=%02x, hr=%02x, " |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 118 | "wday=%02x, mday=%02x, mon=%02x, year=%02x\n", |
| 119 | __func__, |
| 120 | date[0], date[1], date[2], date[3], date[4], date[5], date[6]); |
| 121 | |
| 122 | tm->tm_sec = bcd2bin(date[RX8581_REG_SC] & 0x7F); |
| 123 | tm->tm_min = bcd2bin(date[RX8581_REG_MN] & 0x7F); |
| 124 | tm->tm_hour = bcd2bin(date[RX8581_REG_HR] & 0x3F); /* rtc hr 0-23 */ |
| 125 | tm->tm_wday = ilog2(date[RX8581_REG_DW] & 0x7F); |
| 126 | tm->tm_mday = bcd2bin(date[RX8581_REG_DM] & 0x3F); |
| 127 | tm->tm_mon = bcd2bin(date[RX8581_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ |
Alexandre Belloni | c6e3c29 | 2018-05-17 22:33:27 +0200 | [diff] [blame] | 128 | tm->tm_year = bcd2bin(date[RX8581_REG_YR]) + 100; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 129 | |
Alexandre Belloni | ed87c6d | 2018-05-17 22:33:29 +0200 | [diff] [blame] | 130 | dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 131 | "mday=%d, mon=%d, year=%d, wday=%d\n", |
| 132 | __func__, |
| 133 | tm->tm_sec, tm->tm_min, tm->tm_hour, |
| 134 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); |
| 135 | |
Alexandre Belloni | 24f421b | 2018-02-21 00:25:18 +0100 | [diff] [blame] | 136 | return 0; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 137 | } |
| 138 | |
Alexandre Belloni | 2d2b300 | 2018-05-17 22:33:28 +0200 | [diff] [blame] | 139 | static int rx8581_rtc_set_time(struct device *dev, struct rtc_time *tm) |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 140 | { |
Alexandre Belloni | 2d2b300 | 2018-05-17 22:33:28 +0200 | [diff] [blame] | 141 | struct i2c_client *client = to_i2c_client(dev); |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 142 | int err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 143 | unsigned char buf[7]; |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 144 | struct rx8581 *rx8581 = i2c_get_clientdata(client); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 145 | |
Alexandre Belloni | ed87c6d | 2018-05-17 22:33:29 +0200 | [diff] [blame] | 146 | dev_dbg(dev, "%s: secs=%d, mins=%d, hours=%d, " |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 147 | "mday=%d, mon=%d, year=%d, wday=%d\n", |
| 148 | __func__, |
| 149 | tm->tm_sec, tm->tm_min, tm->tm_hour, |
| 150 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); |
| 151 | |
| 152 | /* hours, minutes and seconds */ |
| 153 | buf[RX8581_REG_SC] = bin2bcd(tm->tm_sec); |
| 154 | buf[RX8581_REG_MN] = bin2bcd(tm->tm_min); |
| 155 | buf[RX8581_REG_HR] = bin2bcd(tm->tm_hour); |
| 156 | |
| 157 | buf[RX8581_REG_DM] = bin2bcd(tm->tm_mday); |
| 158 | |
| 159 | /* month, 1 - 12 */ |
| 160 | buf[RX8581_REG_MO] = bin2bcd(tm->tm_mon + 1); |
| 161 | |
| 162 | /* year and century */ |
Alexandre Belloni | c6e3c29 | 2018-05-17 22:33:27 +0200 | [diff] [blame] | 163 | buf[RX8581_REG_YR] = bin2bcd(tm->tm_year - 100); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 164 | buf[RX8581_REG_DW] = (0x1 << tm->tm_wday); |
| 165 | |
| 166 | /* Stop the clock */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 167 | err = regmap_update_bits(rx8581->regmap, RX8581_REG_CTRL, |
| 168 | RX8581_CTRL_STOP, RX8581_CTRL_STOP); |
| 169 | if (err < 0) |
| 170 | return err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 171 | |
| 172 | /* write register's data */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 173 | err = regmap_bulk_write(rx8581->regmap, RX8581_REG_SC, |
| 174 | buf, sizeof(buf)); |
| 175 | if (err < 0) |
| 176 | return err; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 177 | |
Rudolf Marek | 2884fce | 2010-07-27 13:18:02 -0700 | [diff] [blame] | 178 | /* get VLF and clear it */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 179 | err = regmap_update_bits(rx8581->regmap, RX8581_REG_FLAG, |
| 180 | RX8581_FLAG_VLF, 0); |
| 181 | if (err < 0) |
| 182 | return err; |
Rudolf Marek | 2884fce | 2010-07-27 13:18:02 -0700 | [diff] [blame] | 183 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 184 | /* Restart the clock */ |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 185 | return regmap_update_bits(rx8581->regmap, RX8581_REG_CTRL, |
| 186 | RX8581_CTRL_STOP, 0); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 187 | } |
| 188 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 189 | static const struct rtc_class_ops rx8581_rtc_ops = { |
| 190 | .read_time = rx8581_rtc_read_time, |
| 191 | .set_time = rx8581_rtc_set_time, |
| 192 | }; |
| 193 | |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 194 | static int rx8571_nvram_read(void *priv, unsigned int offset, void *val, |
| 195 | size_t bytes) |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 196 | { |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 197 | struct rx8581 *rx8581 = priv; |
| 198 | |
| 199 | return regmap_bulk_read(rx8581->regmap, RX8571_USER_RAM + offset, |
| 200 | val, bytes); |
| 201 | } |
| 202 | |
| 203 | static int rx8571_nvram_write(void *priv, unsigned int offset, void *val, |
| 204 | size_t bytes) |
| 205 | { |
| 206 | struct rx8581 *rx8581 = priv; |
| 207 | |
| 208 | return regmap_bulk_write(rx8581->regmap, RX8571_USER_RAM + offset, |
| 209 | val, bytes); |
| 210 | } |
| 211 | |
| 212 | static int rx85x1_nvram_read(void *priv, unsigned int offset, void *val, |
| 213 | size_t bytes) |
| 214 | { |
| 215 | struct rx8581 *rx8581 = priv; |
| 216 | unsigned int tmp_val; |
| 217 | int ret; |
| 218 | |
| 219 | ret = regmap_read(rx8581->regmap, RX8581_REG_RAM, &tmp_val); |
| 220 | (*(unsigned char *)val) = (unsigned char) tmp_val; |
| 221 | |
| 222 | return ret; |
| 223 | } |
| 224 | |
| 225 | static int rx85x1_nvram_write(void *priv, unsigned int offset, void *val, |
| 226 | size_t bytes) |
| 227 | { |
| 228 | struct rx8581 *rx8581 = priv; |
| 229 | unsigned char tmp_val; |
| 230 | |
| 231 | tmp_val = *((unsigned char *)val); |
| 232 | return regmap_write(rx8581->regmap, RX8581_REG_RAM, |
| 233 | (unsigned int)tmp_val); |
| 234 | } |
| 235 | |
| 236 | static const struct rx85x1_config rx8581_config = { |
| 237 | .regmap = { |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 238 | .reg_bits = 8, |
| 239 | .val_bits = 8, |
| 240 | .max_register = 0xf, |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 241 | }, |
| 242 | .num_nvram = 1 |
| 243 | }; |
| 244 | |
| 245 | static const struct rx85x1_config rx8571_config = { |
| 246 | .regmap = { |
| 247 | .reg_bits = 8, |
| 248 | .val_bits = 8, |
| 249 | .max_register = 0x1f, |
| 250 | }, |
| 251 | .num_nvram = 2 |
| 252 | }; |
| 253 | |
| 254 | static int rx8581_probe(struct i2c_client *client, |
| 255 | const struct i2c_device_id *id) |
| 256 | { |
| 257 | struct rx8581 *rx8581; |
| 258 | const struct rx85x1_config *config = &rx8581_config; |
| 259 | const void *data = of_device_get_match_data(&client->dev); |
| 260 | static struct nvmem_config nvmem_cfg[] = { |
| 261 | { |
| 262 | .name = "rx85x1-", |
| 263 | .word_size = 1, |
| 264 | .stride = 1, |
| 265 | .size = 1, |
| 266 | .reg_read = rx85x1_nvram_read, |
| 267 | .reg_write = rx85x1_nvram_write, |
| 268 | }, { |
| 269 | .name = "rx8571-", |
| 270 | .word_size = 1, |
| 271 | .stride = 1, |
| 272 | .size = RX8571_NVRAM_SIZE, |
| 273 | .reg_read = rx8571_nvram_read, |
| 274 | .reg_write = rx8571_nvram_write, |
| 275 | }, |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 276 | }; |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 277 | int ret, i; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 278 | |
| 279 | dev_dbg(&client->dev, "%s\n", __func__); |
| 280 | |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 281 | if (data) |
| 282 | config = data; |
| 283 | |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 284 | rx8581 = devm_kzalloc(&client->dev, sizeof(struct rx8581), GFP_KERNEL); |
| 285 | if (!rx8581) |
| 286 | return -ENOMEM; |
| 287 | |
| 288 | i2c_set_clientdata(client, rx8581); |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 289 | |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 290 | rx8581->regmap = devm_regmap_init_i2c(client, &config->regmap); |
Alexandre Belloni | 94389b2 | 2018-05-17 22:33:31 +0200 | [diff] [blame] | 291 | if (IS_ERR(rx8581->regmap)) |
| 292 | return PTR_ERR(rx8581->regmap); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 293 | |
Alexandre Belloni | b815716 | 2018-05-17 22:33:25 +0200 | [diff] [blame] | 294 | rx8581->rtc = devm_rtc_allocate_device(&client->dev); |
| 295 | if (IS_ERR(rx8581->rtc)) |
Andreas Werner | d643a49 | 2014-01-23 15:55:20 -0800 | [diff] [blame] | 296 | return PTR_ERR(rx8581->rtc); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 297 | |
Alexandre Belloni | b815716 | 2018-05-17 22:33:25 +0200 | [diff] [blame] | 298 | rx8581->rtc->ops = &rx8581_rtc_ops; |
Alexandre Belloni | 86c54ef | 2018-05-17 22:33:26 +0200 | [diff] [blame] | 299 | rx8581->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; |
| 300 | rx8581->rtc->range_max = RTC_TIMESTAMP_END_2099; |
Alexandre Belloni | c6e3c29 | 2018-05-17 22:33:27 +0200 | [diff] [blame] | 301 | rx8581->rtc->start_secs = 0; |
| 302 | rx8581->rtc->set_start_time = true; |
Alexandre Belloni | b815716 | 2018-05-17 22:33:25 +0200 | [diff] [blame] | 303 | |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 304 | ret = rtc_register_device(rx8581->rtc); |
| 305 | |
| 306 | for (i = 0; i < config->num_nvram; i++) { |
| 307 | nvmem_cfg[i].priv = rx8581; |
| 308 | rtc_nvmem_register(rx8581->rtc, &nvmem_cfg[i]); |
| 309 | } |
| 310 | |
| 311 | return ret; |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 312 | } |
| 313 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 314 | static const struct i2c_device_id rx8581_id[] = { |
| 315 | { "rx8581", 0 }, |
| 316 | { } |
| 317 | }; |
| 318 | MODULE_DEVICE_TABLE(i2c, rx8581_id); |
| 319 | |
Javier Martinez Canillas | ffbecfb | 2017-03-03 11:29:22 -0300 | [diff] [blame] | 320 | static const struct of_device_id rx8581_of_match[] = { |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 321 | { .compatible = "epson,rx8571", .data = &rx8571_config }, |
| 322 | { .compatible = "epson,rx8581", .data = &rx8581_config }, |
| 323 | { /* sentinel */ } |
Javier Martinez Canillas | ffbecfb | 2017-03-03 11:29:22 -0300 | [diff] [blame] | 324 | }; |
| 325 | MODULE_DEVICE_TABLE(of, rx8581_of_match); |
| 326 | |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 327 | static struct i2c_driver rx8581_driver = { |
| 328 | .driver = { |
| 329 | .name = "rtc-rx8581", |
Javier Martinez Canillas | ffbecfb | 2017-03-03 11:29:22 -0300 | [diff] [blame] | 330 | .of_match_table = of_match_ptr(rx8581_of_match), |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 331 | }, |
| 332 | .probe = rx8581_probe, |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 333 | .id_table = rx8581_id, |
| 334 | }; |
| 335 | |
Axel Lin | 0abc920 | 2012-03-23 15:02:31 -0700 | [diff] [blame] | 336 | module_i2c_driver(rx8581_driver); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 337 | |
Martyn Welch | 9756c4d | 2010-04-14 09:24:16 +0100 | [diff] [blame] | 338 | MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>"); |
Biju Das | 51f896f | 2019-02-21 09:40:45 +0000 | [diff] [blame] | 339 | MODULE_DESCRIPTION("Epson RX-8571/RX-8581 RTC driver"); |
Martyn Welch | a7fa985 | 2008-11-12 13:27:06 -0800 | [diff] [blame] | 340 | MODULE_LICENSE("GPL"); |