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