Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 1 | /* |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 2 | * Micro Crystal RV-3029 rtc class driver |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 3 | * |
| 4 | * Author: Gregory Hermant <gregory.hermant@calao-systems.com> |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 5 | * Michael Buesch <m@bues.ch> |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 6 | * |
| 7 | * based on previously existing rtc class drivers |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/i2c.h> |
| 17 | #include <linux/bcd.h> |
| 18 | #include <linux/rtc.h> |
Michael Büsch | a7f6e28 | 2016-03-04 22:40:55 +0100 | [diff] [blame] | 19 | #include <linux/delay.h> |
| 20 | #include <linux/of.h> |
| 21 | |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 22 | |
| 23 | /* Register map */ |
| 24 | /* control section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 25 | #define RV3029_ONOFF_CTRL 0x00 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 26 | #define RV3029_ONOFF_CTRL_WE BIT(0) |
| 27 | #define RV3029_ONOFF_CTRL_TE BIT(1) |
| 28 | #define RV3029_ONOFF_CTRL_TAR BIT(2) |
| 29 | #define RV3029_ONOFF_CTRL_EERE BIT(3) |
| 30 | #define RV3029_ONOFF_CTRL_SRON BIT(4) |
| 31 | #define RV3029_ONOFF_CTRL_TD0 BIT(5) |
| 32 | #define RV3029_ONOFF_CTRL_TD1 BIT(6) |
| 33 | #define RV3029_ONOFF_CTRL_CLKINT BIT(7) |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 34 | #define RV3029_IRQ_CTRL 0x01 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 35 | #define RV3029_IRQ_CTRL_AIE BIT(0) |
| 36 | #define RV3029_IRQ_CTRL_TIE BIT(1) |
| 37 | #define RV3029_IRQ_CTRL_V1IE BIT(2) |
| 38 | #define RV3029_IRQ_CTRL_V2IE BIT(3) |
| 39 | #define RV3029_IRQ_CTRL_SRIE BIT(4) |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 40 | #define RV3029_IRQ_FLAGS 0x02 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 41 | #define RV3029_IRQ_FLAGS_AF BIT(0) |
| 42 | #define RV3029_IRQ_FLAGS_TF BIT(1) |
| 43 | #define RV3029_IRQ_FLAGS_V1IF BIT(2) |
| 44 | #define RV3029_IRQ_FLAGS_V2IF BIT(3) |
| 45 | #define RV3029_IRQ_FLAGS_SRF BIT(4) |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 46 | #define RV3029_STATUS 0x03 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 47 | #define RV3029_STATUS_VLOW1 BIT(2) |
| 48 | #define RV3029_STATUS_VLOW2 BIT(3) |
| 49 | #define RV3029_STATUS_SR BIT(4) |
| 50 | #define RV3029_STATUS_PON BIT(5) |
| 51 | #define RV3029_STATUS_EEBUSY BIT(7) |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 52 | #define RV3029_RST_CTRL 0x04 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 53 | #define RV3029_RST_CTRL_SYSR BIT(4) |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 54 | #define RV3029_CONTROL_SECTION_LEN 0x05 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 55 | |
| 56 | /* watch section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 57 | #define RV3029_W_SEC 0x08 |
| 58 | #define RV3029_W_MINUTES 0x09 |
| 59 | #define RV3029_W_HOURS 0x0A |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 60 | #define RV3029_REG_HR_12_24 BIT(6) /* 24h/12h mode */ |
| 61 | #define RV3029_REG_HR_PM BIT(5) /* PM/AM bit in 12h mode */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 62 | #define RV3029_W_DATE 0x0B |
| 63 | #define RV3029_W_DAYS 0x0C |
| 64 | #define RV3029_W_MONTHS 0x0D |
| 65 | #define RV3029_W_YEARS 0x0E |
| 66 | #define RV3029_WATCH_SECTION_LEN 0x07 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 67 | |
| 68 | /* alarm section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 69 | #define RV3029_A_SC 0x10 |
| 70 | #define RV3029_A_MN 0x11 |
| 71 | #define RV3029_A_HR 0x12 |
| 72 | #define RV3029_A_DT 0x13 |
| 73 | #define RV3029_A_DW 0x14 |
| 74 | #define RV3029_A_MO 0x15 |
| 75 | #define RV3029_A_YR 0x16 |
| 76 | #define RV3029_ALARM_SECTION_LEN 0x07 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 77 | |
| 78 | /* timer section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 79 | #define RV3029_TIMER_LOW 0x18 |
| 80 | #define RV3029_TIMER_HIGH 0x19 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 81 | |
| 82 | /* temperature section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 83 | #define RV3029_TEMP_PAGE 0x20 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 84 | |
| 85 | /* eeprom data section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 86 | #define RV3029_E2P_EEDATA1 0x28 |
| 87 | #define RV3029_E2P_EEDATA2 0x29 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 88 | #define RV3029_E2PDATA_SECTION_LEN 0x02 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 89 | |
| 90 | /* eeprom control section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 91 | #define RV3029_CONTROL_E2P_EECTRL 0x30 |
Michael Büsch | 7697de3 | 2016-03-04 22:39:49 +0100 | [diff] [blame] | 92 | #define RV3029_EECTRL_THP BIT(0) /* temp scan interval */ |
| 93 | #define RV3029_EECTRL_THE BIT(1) /* thermometer enable */ |
| 94 | #define RV3029_EECTRL_FD0 BIT(2) /* CLKOUT */ |
| 95 | #define RV3029_EECTRL_FD1 BIT(3) /* CLKOUT */ |
| 96 | #define RV3029_TRICKLE_1K BIT(4) /* 1.5K resistance */ |
| 97 | #define RV3029_TRICKLE_5K BIT(5) /* 5K resistance */ |
| 98 | #define RV3029_TRICKLE_20K BIT(6) /* 20K resistance */ |
| 99 | #define RV3029_TRICKLE_80K BIT(7) /* 80K resistance */ |
| 100 | #define RV3029_TRICKLE_MASK (RV3029_TRICKLE_1K |\ |
| 101 | RV3029_TRICKLE_5K |\ |
| 102 | RV3029_TRICKLE_20K |\ |
| 103 | RV3029_TRICKLE_80K) |
| 104 | #define RV3029_TRICKLE_SHIFT 4 |
| 105 | #define RV3029_CONTROL_E2P_XOFFS 0x31 /* XTAL offset */ |
| 106 | #define RV3029_CONTROL_E2P_XOFFS_SIGN BIT(7) /* Sign: 1->pos, 0->neg */ |
| 107 | #define RV3029_CONTROL_E2P_QCOEF 0x32 /* XTAL temp drift coef */ |
| 108 | #define RV3029_CONTROL_E2P_TURNOVER 0x33 /* XTAL turnover temp (in *C) */ |
| 109 | #define RV3029_CONTROL_E2P_TOV_MASK 0x3F /* XTAL turnover temp mask */ |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 110 | |
| 111 | /* user ram section */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 112 | #define RV3029_USR1_RAM_PAGE 0x38 |
| 113 | #define RV3029_USR1_SECTION_LEN 0x04 |
| 114 | #define RV3029_USR2_RAM_PAGE 0x3C |
| 115 | #define RV3029_USR2_SECTION_LEN 0x04 |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 116 | |
| 117 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 118 | rv3029_i2c_read_regs(struct i2c_client *client, u8 reg, u8 *buf, |
| 119 | unsigned len) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 120 | { |
| 121 | int ret; |
| 122 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 123 | if ((reg > RV3029_USR1_RAM_PAGE + 7) || |
| 124 | (reg + len > RV3029_USR1_RAM_PAGE + 8)) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 125 | return -EINVAL; |
| 126 | |
| 127 | ret = i2c_smbus_read_i2c_block_data(client, reg, len, buf); |
| 128 | if (ret < 0) |
| 129 | return ret; |
| 130 | if (ret < len) |
| 131 | return -EIO; |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 136 | rv3029_i2c_write_regs(struct i2c_client *client, u8 reg, u8 const buf[], |
| 137 | unsigned len) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 138 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 139 | if ((reg > RV3029_USR1_RAM_PAGE + 7) || |
| 140 | (reg + len > RV3029_USR1_RAM_PAGE + 8)) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 141 | return -EINVAL; |
| 142 | |
| 143 | return i2c_smbus_write_i2c_block_data(client, reg, len, buf); |
| 144 | } |
| 145 | |
| 146 | static int |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 147 | rv3029_i2c_update_bits(struct i2c_client *client, u8 reg, u8 mask, u8 set) |
| 148 | { |
| 149 | u8 buf; |
| 150 | int ret; |
| 151 | |
| 152 | ret = rv3029_i2c_read_regs(client, reg, &buf, 1); |
| 153 | if (ret < 0) |
| 154 | return ret; |
| 155 | buf &= ~mask; |
| 156 | buf |= set & mask; |
| 157 | ret = rv3029_i2c_write_regs(client, reg, &buf, 1); |
| 158 | if (ret < 0) |
| 159 | return ret; |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 165 | rv3029_i2c_get_sr(struct i2c_client *client, u8 *buf) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 166 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 167 | int ret = rv3029_i2c_read_regs(client, RV3029_STATUS, buf, 1); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 168 | |
| 169 | if (ret < 0) |
| 170 | return -EIO; |
| 171 | dev_dbg(&client->dev, "status = 0x%.2x (%d)\n", buf[0], buf[0]); |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 176 | rv3029_i2c_set_sr(struct i2c_client *client, u8 val) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 177 | { |
| 178 | u8 buf[1]; |
| 179 | int sr; |
| 180 | |
| 181 | buf[0] = val; |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 182 | sr = rv3029_i2c_write_regs(client, RV3029_STATUS, buf, 1); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 183 | dev_dbg(&client->dev, "status = 0x%.2x (%d)\n", buf[0], buf[0]); |
| 184 | if (sr < 0) |
| 185 | return -EIO; |
| 186 | return 0; |
| 187 | } |
| 188 | |
Michael Büsch | a7f6e28 | 2016-03-04 22:40:55 +0100 | [diff] [blame] | 189 | static int rv3029_eeprom_busywait(struct i2c_client *client) |
| 190 | { |
| 191 | int i, ret; |
| 192 | u8 sr; |
| 193 | |
| 194 | for (i = 100; i > 0; i--) { |
| 195 | ret = rv3029_i2c_get_sr(client, &sr); |
| 196 | if (ret < 0) |
| 197 | break; |
| 198 | if (!(sr & RV3029_STATUS_EEBUSY)) |
| 199 | break; |
| 200 | usleep_range(1000, 10000); |
| 201 | } |
| 202 | if (i <= 0) { |
| 203 | dev_err(&client->dev, "EEPROM busy wait timeout.\n"); |
| 204 | return -ETIMEDOUT; |
| 205 | } |
| 206 | |
| 207 | return ret; |
| 208 | } |
| 209 | |
| 210 | static int rv3029_eeprom_exit(struct i2c_client *client) |
| 211 | { |
| 212 | /* Re-enable eeprom refresh */ |
| 213 | return rv3029_i2c_update_bits(client, RV3029_ONOFF_CTRL, |
| 214 | RV3029_ONOFF_CTRL_EERE, |
| 215 | RV3029_ONOFF_CTRL_EERE); |
| 216 | } |
| 217 | |
| 218 | static int rv3029_eeprom_enter(struct i2c_client *client) |
| 219 | { |
| 220 | int ret; |
| 221 | u8 sr; |
| 222 | |
| 223 | /* Check whether we are in the allowed voltage range. */ |
| 224 | ret = rv3029_i2c_get_sr(client, &sr); |
| 225 | if (ret < 0) |
| 226 | return ret; |
| 227 | if (sr & (RV3029_STATUS_VLOW1 | RV3029_STATUS_VLOW2)) { |
| 228 | /* We clear the bits and retry once just in case |
| 229 | * we had a brown out in early startup. |
| 230 | */ |
| 231 | sr &= ~RV3029_STATUS_VLOW1; |
| 232 | sr &= ~RV3029_STATUS_VLOW2; |
| 233 | ret = rv3029_i2c_set_sr(client, sr); |
| 234 | if (ret < 0) |
| 235 | return ret; |
| 236 | usleep_range(1000, 10000); |
| 237 | ret = rv3029_i2c_get_sr(client, &sr); |
| 238 | if (ret < 0) |
| 239 | return ret; |
| 240 | if (sr & (RV3029_STATUS_VLOW1 | RV3029_STATUS_VLOW2)) { |
| 241 | dev_err(&client->dev, |
| 242 | "Supply voltage is too low to safely access the EEPROM.\n"); |
| 243 | return -ENODEV; |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | /* Disable eeprom refresh. */ |
| 248 | ret = rv3029_i2c_update_bits(client, RV3029_ONOFF_CTRL, |
| 249 | RV3029_ONOFF_CTRL_EERE, 0); |
| 250 | if (ret < 0) |
| 251 | return ret; |
| 252 | |
| 253 | /* Wait for any previous eeprom accesses to finish. */ |
| 254 | ret = rv3029_eeprom_busywait(client); |
| 255 | if (ret < 0) |
| 256 | rv3029_eeprom_exit(client); |
| 257 | |
| 258 | return ret; |
| 259 | } |
| 260 | |
| 261 | static int rv3029_eeprom_read(struct i2c_client *client, u8 reg, |
| 262 | u8 buf[], size_t len) |
| 263 | { |
| 264 | int ret, err; |
| 265 | |
| 266 | err = rv3029_eeprom_enter(client); |
| 267 | if (err < 0) |
| 268 | return err; |
| 269 | |
| 270 | ret = rv3029_i2c_read_regs(client, reg, buf, len); |
| 271 | |
| 272 | err = rv3029_eeprom_exit(client); |
| 273 | if (err < 0) |
| 274 | return err; |
| 275 | |
| 276 | return ret; |
| 277 | } |
| 278 | |
| 279 | static int rv3029_eeprom_write(struct i2c_client *client, u8 reg, |
| 280 | u8 const buf[], size_t len) |
| 281 | { |
| 282 | int ret, err; |
| 283 | size_t i; |
| 284 | u8 tmp; |
| 285 | |
| 286 | err = rv3029_eeprom_enter(client); |
| 287 | if (err < 0) |
| 288 | return err; |
| 289 | |
| 290 | for (i = 0; i < len; i++, reg++) { |
| 291 | ret = rv3029_i2c_read_regs(client, reg, &tmp, 1); |
| 292 | if (ret < 0) |
| 293 | break; |
| 294 | if (tmp != buf[i]) { |
| 295 | ret = rv3029_i2c_write_regs(client, reg, &buf[i], 1); |
| 296 | if (ret < 0) |
| 297 | break; |
| 298 | } |
| 299 | ret = rv3029_eeprom_busywait(client); |
| 300 | if (ret < 0) |
| 301 | break; |
| 302 | } |
| 303 | |
| 304 | err = rv3029_eeprom_exit(client); |
| 305 | if (err < 0) |
| 306 | return err; |
| 307 | |
| 308 | return ret; |
| 309 | } |
| 310 | |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 311 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 312 | rv3029_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 313 | { |
| 314 | u8 buf[1]; |
| 315 | int ret; |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 316 | u8 regs[RV3029_WATCH_SECTION_LEN] = { 0, }; |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 317 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 318 | ret = rv3029_i2c_get_sr(client, buf); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 319 | if (ret < 0) { |
| 320 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); |
| 321 | return -EIO; |
| 322 | } |
| 323 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 324 | ret = rv3029_i2c_read_regs(client, RV3029_W_SEC, regs, |
| 325 | RV3029_WATCH_SECTION_LEN); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 326 | if (ret < 0) { |
| 327 | dev_err(&client->dev, "%s: reading RTC section failed\n", |
| 328 | __func__); |
| 329 | return ret; |
| 330 | } |
| 331 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 332 | tm->tm_sec = bcd2bin(regs[RV3029_W_SEC-RV3029_W_SEC]); |
| 333 | tm->tm_min = bcd2bin(regs[RV3029_W_MINUTES-RV3029_W_SEC]); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 334 | |
| 335 | /* HR field has a more complex interpretation */ |
| 336 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 337 | const u8 _hr = regs[RV3029_W_HOURS-RV3029_W_SEC]; |
| 338 | |
| 339 | if (_hr & RV3029_REG_HR_12_24) { |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 340 | /* 12h format */ |
| 341 | tm->tm_hour = bcd2bin(_hr & 0x1f); |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 342 | if (_hr & RV3029_REG_HR_PM) /* PM flag set */ |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 343 | tm->tm_hour += 12; |
| 344 | } else /* 24h format */ |
| 345 | tm->tm_hour = bcd2bin(_hr & 0x3f); |
| 346 | } |
| 347 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 348 | tm->tm_mday = bcd2bin(regs[RV3029_W_DATE-RV3029_W_SEC]); |
| 349 | tm->tm_mon = bcd2bin(regs[RV3029_W_MONTHS-RV3029_W_SEC]) - 1; |
| 350 | tm->tm_year = bcd2bin(regs[RV3029_W_YEARS-RV3029_W_SEC]) + 100; |
| 351 | tm->tm_wday = bcd2bin(regs[RV3029_W_DAYS-RV3029_W_SEC]) - 1; |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 352 | |
| 353 | return 0; |
| 354 | } |
| 355 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 356 | static int rv3029_rtc_read_time(struct device *dev, struct rtc_time *tm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 357 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 358 | return rv3029_i2c_read_time(to_i2c_client(dev), tm); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 362 | rv3029_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 363 | { |
| 364 | struct rtc_time *const tm = &alarm->time; |
| 365 | int ret; |
| 366 | u8 regs[8]; |
| 367 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 368 | ret = rv3029_i2c_get_sr(client, regs); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 369 | if (ret < 0) { |
| 370 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); |
| 371 | return -EIO; |
| 372 | } |
| 373 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 374 | ret = rv3029_i2c_read_regs(client, RV3029_A_SC, regs, |
| 375 | RV3029_ALARM_SECTION_LEN); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 376 | |
| 377 | if (ret < 0) { |
| 378 | dev_err(&client->dev, "%s: reading alarm section failed\n", |
| 379 | __func__); |
| 380 | return ret; |
| 381 | } |
| 382 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 383 | tm->tm_sec = bcd2bin(regs[RV3029_A_SC-RV3029_A_SC] & 0x7f); |
| 384 | tm->tm_min = bcd2bin(regs[RV3029_A_MN-RV3029_A_SC] & 0x7f); |
| 385 | tm->tm_hour = bcd2bin(regs[RV3029_A_HR-RV3029_A_SC] & 0x3f); |
| 386 | tm->tm_mday = bcd2bin(regs[RV3029_A_DT-RV3029_A_SC] & 0x3f); |
| 387 | tm->tm_mon = bcd2bin(regs[RV3029_A_MO-RV3029_A_SC] & 0x1f) - 1; |
| 388 | tm->tm_year = bcd2bin(regs[RV3029_A_YR-RV3029_A_SC] & 0x7f) + 100; |
| 389 | tm->tm_wday = bcd2bin(regs[RV3029_A_DW-RV3029_A_SC] & 0x07) - 1; |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 390 | |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 395 | rv3029_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 396 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 397 | return rv3029_i2c_read_alarm(to_i2c_client(dev), alarm); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 398 | } |
| 399 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 400 | static int rv3029_rtc_i2c_alarm_set_irq(struct i2c_client *client, |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 401 | int enable) |
| 402 | { |
| 403 | int ret; |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 404 | |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 405 | /* enable/disable AIE irq */ |
| 406 | ret = rv3029_i2c_update_bits(client, RV3029_IRQ_CTRL, |
| 407 | RV3029_IRQ_CTRL_AIE, |
| 408 | (enable ? RV3029_IRQ_CTRL_AIE : 0)); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 409 | if (ret < 0) { |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 410 | dev_err(&client->dev, "can't update INT reg\n"); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 411 | return ret; |
| 412 | } |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 417 | static int rv3029_rtc_i2c_set_alarm(struct i2c_client *client, |
| 418 | struct rtc_wkalrm *alarm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 419 | { |
| 420 | struct rtc_time *const tm = &alarm->time; |
| 421 | int ret; |
| 422 | u8 regs[8]; |
| 423 | |
| 424 | /* |
| 425 | * The clock has an 8 bit wide bcd-coded register (they never learn) |
| 426 | * for the year. tm_year is an offset from 1900 and we are interested |
| 427 | * in the 2000-2099 range, so any value less than 100 is invalid. |
| 428 | */ |
| 429 | if (tm->tm_year < 100) |
| 430 | return -EINVAL; |
| 431 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 432 | ret = rv3029_i2c_get_sr(client, regs); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 433 | if (ret < 0) { |
| 434 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); |
| 435 | return -EIO; |
| 436 | } |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 437 | regs[RV3029_A_SC-RV3029_A_SC] = bin2bcd(tm->tm_sec & 0x7f); |
| 438 | regs[RV3029_A_MN-RV3029_A_SC] = bin2bcd(tm->tm_min & 0x7f); |
| 439 | regs[RV3029_A_HR-RV3029_A_SC] = bin2bcd(tm->tm_hour & 0x3f); |
| 440 | regs[RV3029_A_DT-RV3029_A_SC] = bin2bcd(tm->tm_mday & 0x3f); |
| 441 | regs[RV3029_A_MO-RV3029_A_SC] = bin2bcd((tm->tm_mon & 0x1f) - 1); |
| 442 | regs[RV3029_A_DW-RV3029_A_SC] = bin2bcd((tm->tm_wday & 7) - 1); |
| 443 | regs[RV3029_A_YR-RV3029_A_SC] = bin2bcd((tm->tm_year & 0x7f) - 100); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 444 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 445 | ret = rv3029_i2c_write_regs(client, RV3029_A_SC, regs, |
| 446 | RV3029_ALARM_SECTION_LEN); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 447 | if (ret < 0) |
| 448 | return ret; |
| 449 | |
| 450 | if (alarm->enabled) { |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 451 | /* clear AF flag */ |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 452 | ret = rv3029_i2c_update_bits(client, RV3029_IRQ_FLAGS, |
| 453 | RV3029_IRQ_FLAGS_AF, 0); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 454 | if (ret < 0) { |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 455 | dev_err(&client->dev, "can't clear alarm flag\n"); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 456 | return ret; |
| 457 | } |
| 458 | /* enable AIE irq */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 459 | ret = rv3029_rtc_i2c_alarm_set_irq(client, 1); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 460 | if (ret) |
| 461 | return ret; |
| 462 | |
| 463 | dev_dbg(&client->dev, "alarm IRQ armed\n"); |
| 464 | } else { |
| 465 | /* disable AIE irq */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 466 | ret = rv3029_rtc_i2c_alarm_set_irq(client, 0); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 467 | if (ret) |
| 468 | return ret; |
| 469 | |
| 470 | dev_dbg(&client->dev, "alarm IRQ disabled\n"); |
| 471 | } |
| 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 476 | static int rv3029_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 477 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 478 | return rv3029_rtc_i2c_set_alarm(to_i2c_client(dev), alarm); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | static int |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 482 | rv3029_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 483 | { |
| 484 | u8 regs[8]; |
| 485 | int ret; |
| 486 | |
| 487 | /* |
| 488 | * The clock has an 8 bit wide bcd-coded register (they never learn) |
| 489 | * for the year. tm_year is an offset from 1900 and we are interested |
| 490 | * in the 2000-2099 range, so any value less than 100 is invalid. |
| 491 | */ |
| 492 | if (tm->tm_year < 100) |
| 493 | return -EINVAL; |
| 494 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 495 | regs[RV3029_W_SEC-RV3029_W_SEC] = bin2bcd(tm->tm_sec); |
| 496 | regs[RV3029_W_MINUTES-RV3029_W_SEC] = bin2bcd(tm->tm_min); |
| 497 | regs[RV3029_W_HOURS-RV3029_W_SEC] = bin2bcd(tm->tm_hour); |
| 498 | regs[RV3029_W_DATE-RV3029_W_SEC] = bin2bcd(tm->tm_mday); |
| 499 | regs[RV3029_W_MONTHS-RV3029_W_SEC] = bin2bcd(tm->tm_mon+1); |
| 500 | regs[RV3029_W_DAYS-RV3029_W_SEC] = bin2bcd((tm->tm_wday & 7)+1); |
| 501 | regs[RV3029_W_YEARS-RV3029_W_SEC] = bin2bcd(tm->tm_year - 100); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 502 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 503 | ret = rv3029_i2c_write_regs(client, RV3029_W_SEC, regs, |
| 504 | RV3029_WATCH_SECTION_LEN); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 505 | if (ret < 0) |
| 506 | return ret; |
| 507 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 508 | ret = rv3029_i2c_get_sr(client, regs); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 509 | if (ret < 0) { |
| 510 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); |
| 511 | return ret; |
| 512 | } |
| 513 | /* clear PON bit */ |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 514 | ret = rv3029_i2c_set_sr(client, (regs[0] & ~RV3029_STATUS_PON)); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 515 | if (ret < 0) { |
| 516 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); |
| 517 | return ret; |
| 518 | } |
| 519 | |
| 520 | return 0; |
| 521 | } |
| 522 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 523 | static int rv3029_rtc_set_time(struct device *dev, struct rtc_time *tm) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 524 | { |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 525 | return rv3029_i2c_set_time(to_i2c_client(dev), tm); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Michael Büsch | e27e216 | 2016-03-04 22:41:19 +0100 | [diff] [blame^] | 528 | static const struct rv3029_trickle_tab_elem { |
| 529 | u32 r; /* resistance in ohms */ |
| 530 | u8 conf; /* trickle config bits */ |
| 531 | } rv3029_trickle_tab[] = { |
| 532 | { |
| 533 | .r = 1076, |
| 534 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_5K | |
| 535 | RV3029_TRICKLE_20K | RV3029_TRICKLE_80K, |
| 536 | }, { |
| 537 | .r = 1091, |
| 538 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_5K | |
| 539 | RV3029_TRICKLE_20K, |
| 540 | }, { |
| 541 | .r = 1137, |
| 542 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_5K | |
| 543 | RV3029_TRICKLE_80K, |
| 544 | }, { |
| 545 | .r = 1154, |
| 546 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_5K, |
| 547 | }, { |
| 548 | .r = 1371, |
| 549 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_20K | |
| 550 | RV3029_TRICKLE_80K, |
| 551 | }, { |
| 552 | .r = 1395, |
| 553 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_20K, |
| 554 | }, { |
| 555 | .r = 1472, |
| 556 | .conf = RV3029_TRICKLE_1K | RV3029_TRICKLE_80K, |
| 557 | }, { |
| 558 | .r = 1500, |
| 559 | .conf = RV3029_TRICKLE_1K, |
| 560 | }, { |
| 561 | .r = 3810, |
| 562 | .conf = RV3029_TRICKLE_5K | RV3029_TRICKLE_20K | |
| 563 | RV3029_TRICKLE_80K, |
| 564 | }, { |
| 565 | .r = 4000, |
| 566 | .conf = RV3029_TRICKLE_5K | RV3029_TRICKLE_20K, |
| 567 | }, { |
| 568 | .r = 4706, |
| 569 | .conf = RV3029_TRICKLE_5K | RV3029_TRICKLE_80K, |
| 570 | }, { |
| 571 | .r = 5000, |
| 572 | .conf = RV3029_TRICKLE_5K, |
| 573 | }, { |
| 574 | .r = 16000, |
| 575 | .conf = RV3029_TRICKLE_20K | RV3029_TRICKLE_80K, |
| 576 | }, { |
| 577 | .r = 20000, |
| 578 | .conf = RV3029_TRICKLE_20K, |
| 579 | }, { |
| 580 | .r = 80000, |
| 581 | .conf = RV3029_TRICKLE_80K, |
| 582 | }, |
| 583 | }; |
| 584 | |
| 585 | static void rv3029_trickle_config(struct i2c_client *client) |
| 586 | { |
| 587 | struct device_node *of_node = client->dev.of_node; |
| 588 | const struct rv3029_trickle_tab_elem *elem; |
| 589 | int i, err; |
| 590 | u32 ohms; |
| 591 | u8 eectrl; |
| 592 | |
| 593 | if (!of_node) |
| 594 | return; |
| 595 | |
| 596 | /* Configure the trickle charger. */ |
| 597 | err = rv3029_eeprom_read(client, RV3029_CONTROL_E2P_EECTRL, |
| 598 | &eectrl, 1); |
| 599 | if (err < 0) { |
| 600 | dev_err(&client->dev, |
| 601 | "Failed to read trickle charger config\n"); |
| 602 | return; |
| 603 | } |
| 604 | err = of_property_read_u32(of_node, "trickle-resistor-ohms", &ohms); |
| 605 | if (err) { |
| 606 | /* Disable trickle charger. */ |
| 607 | eectrl &= ~RV3029_TRICKLE_MASK; |
| 608 | } else { |
| 609 | /* Enable trickle charger. */ |
| 610 | for (i = 0; i < ARRAY_SIZE(rv3029_trickle_tab); i++) { |
| 611 | elem = &rv3029_trickle_tab[i]; |
| 612 | if (elem->r >= ohms) |
| 613 | break; |
| 614 | } |
| 615 | eectrl &= ~RV3029_TRICKLE_MASK; |
| 616 | eectrl |= elem->conf; |
| 617 | dev_info(&client->dev, |
| 618 | "Trickle charger enabled at %d ohms resistance.\n", |
| 619 | elem->r); |
| 620 | } |
| 621 | err = rv3029_eeprom_write(client, RV3029_CONTROL_E2P_EECTRL, |
| 622 | &eectrl, 1); |
| 623 | if (err < 0) { |
| 624 | dev_err(&client->dev, |
| 625 | "Failed to write trickle charger config\n"); |
| 626 | } |
| 627 | } |
| 628 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 629 | static const struct rtc_class_ops rv3029_rtc_ops = { |
| 630 | .read_time = rv3029_rtc_read_time, |
| 631 | .set_time = rv3029_rtc_set_time, |
| 632 | .read_alarm = rv3029_rtc_read_alarm, |
| 633 | .set_alarm = rv3029_rtc_set_alarm, |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 634 | }; |
| 635 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 636 | static struct i2c_device_id rv3029_id[] = { |
Michael Büsch | baba623 | 2016-03-04 22:39:17 +0100 | [diff] [blame] | 637 | { "rv3029", 0 }, |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 638 | { "rv3029c2", 0 }, |
| 639 | { } |
| 640 | }; |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 641 | MODULE_DEVICE_TABLE(i2c, rv3029_id); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 642 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 643 | static int rv3029_probe(struct i2c_client *client, |
| 644 | const struct i2c_device_id *id) |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 645 | { |
| 646 | struct rtc_device *rtc; |
| 647 | int rc = 0; |
| 648 | u8 buf[1]; |
| 649 | |
| 650 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_EMUL)) |
| 651 | return -ENODEV; |
| 652 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 653 | rc = rv3029_i2c_get_sr(client, buf); |
Gregory Hermant | 67ab244 | 2014-04-03 14:50:17 -0700 | [diff] [blame] | 654 | if (rc < 0) { |
| 655 | dev_err(&client->dev, "reading status failed\n"); |
| 656 | return rc; |
| 657 | } |
| 658 | |
Michael Büsch | e27e216 | 2016-03-04 22:41:19 +0100 | [diff] [blame^] | 659 | rv3029_trickle_config(client); |
| 660 | |
Jingoo Han | 3d7068c | 2013-04-29 16:19:48 -0700 | [diff] [blame] | 661 | rtc = devm_rtc_device_register(&client->dev, client->name, |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 662 | &rv3029_rtc_ops, THIS_MODULE); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 663 | |
| 664 | if (IS_ERR(rtc)) |
| 665 | return PTR_ERR(rtc); |
| 666 | |
| 667 | i2c_set_clientdata(client, rtc); |
| 668 | |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 669 | return 0; |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 670 | } |
| 671 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 672 | static struct i2c_driver rv3029_driver = { |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 673 | .driver = { |
| 674 | .name = "rtc-rv3029c2", |
| 675 | }, |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 676 | .probe = rv3029_probe, |
| 677 | .id_table = rv3029_id, |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 678 | }; |
| 679 | |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 680 | module_i2c_driver(rv3029_driver); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 681 | |
| 682 | MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>"); |
Michael Büsch | 2dca3d9 | 2016-03-04 22:40:30 +0100 | [diff] [blame] | 683 | MODULE_AUTHOR("Michael Buesch <m@bues.ch>"); |
Michael Büsch | aba39d2 | 2016-03-04 22:38:45 +0100 | [diff] [blame] | 684 | MODULE_DESCRIPTION("Micro Crystal RV3029 RTC driver"); |
Heiko Schocher | 5236523 | 2011-05-26 16:25:05 -0700 | [diff] [blame] | 685 | MODULE_LICENSE("GPL"); |