Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2001, 2002, 2003 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * Keith Outwater, keith_outwater@mvis.com` |
| 6 | * Steven Scholz, steven.scholz@imc-berlin.de |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * Date & Time support (no alarms) for Dallas Semiconductor (now Maxim) |
Markus Niebel | 412921d | 2014-07-21 11:06:16 +0200 | [diff] [blame] | 11 | * DS1307 and DS1338/9 Real Time Clock (RTC). |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 12 | * |
| 13 | * based on ds1337.c |
| 14 | */ |
| 15 | |
| 16 | #include <common.h> |
| 17 | #include <command.h> |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 18 | #include <dm.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 19 | #include <log.h> |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 20 | #include <rtc.h> |
| 21 | #include <i2c.h> |
| 22 | |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 23 | enum ds_type { |
| 24 | ds_1307, |
| 25 | ds_1337, |
Chris Packham | f65774e | 2021-03-03 14:09:44 +1300 | [diff] [blame] | 26 | ds_1339, |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 27 | ds_1340, |
Heiko Schocher | 8dd6803 | 2019-05-27 08:13:41 +0200 | [diff] [blame] | 28 | m41t11, |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 29 | mcp794xx, |
| 30 | }; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 31 | |
| 32 | /* |
| 33 | * RTC register addresses |
| 34 | */ |
| 35 | #define RTC_SEC_REG_ADDR 0x00 |
| 36 | #define RTC_MIN_REG_ADDR 0x01 |
| 37 | #define RTC_HR_REG_ADDR 0x02 |
| 38 | #define RTC_DAY_REG_ADDR 0x03 |
| 39 | #define RTC_DATE_REG_ADDR 0x04 |
| 40 | #define RTC_MON_REG_ADDR 0x05 |
| 41 | #define RTC_YR_REG_ADDR 0x06 |
| 42 | #define RTC_CTL_REG_ADDR 0x07 |
| 43 | |
| 44 | #define RTC_SEC_BIT_CH 0x80 /* Clock Halt (in Register 0) */ |
| 45 | |
| 46 | #define RTC_CTL_BIT_RS0 0x01 /* Rate select 0 */ |
| 47 | #define RTC_CTL_BIT_RS1 0x02 /* Rate select 1 */ |
| 48 | #define RTC_CTL_BIT_SQWE 0x10 /* Square Wave Enable */ |
| 49 | #define RTC_CTL_BIT_OUT 0x80 /* Output Control */ |
| 50 | |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 51 | /* MCP7941X-specific bits */ |
| 52 | #define MCP7941X_BIT_ST 0x80 |
| 53 | #define MCP7941X_BIT_VBATEN 0x08 |
| 54 | |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 55 | #ifndef CONFIG_DM_RTC |
| 56 | |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 57 | /*---------------------------------------------------------------------*/ |
| 58 | #undef DEBUG_RTC |
| 59 | |
| 60 | #ifdef DEBUG_RTC |
| 61 | #define DEBUGR(fmt, args...) printf(fmt, ##args) |
| 62 | #else |
| 63 | #define DEBUGR(fmt, args...) |
| 64 | #endif |
| 65 | /*---------------------------------------------------------------------*/ |
| 66 | |
| 67 | #ifndef CONFIG_SYS_I2C_RTC_ADDR |
| 68 | # define CONFIG_SYS_I2C_RTC_ADDR 0x68 |
| 69 | #endif |
| 70 | |
| 71 | #if defined(CONFIG_RTC_DS1307) && (CONFIG_SYS_I2C_SPEED > 100000) |
| 72 | # error The DS1307 is specified only up to 100kHz! |
| 73 | #endif |
| 74 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 75 | static uchar rtc_read (uchar reg); |
| 76 | static void rtc_write (uchar reg, uchar val); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * Get the current time from the RTC |
| 80 | */ |
Yuri Tikhonov | b73a19e | 2008-03-20 17:56:04 +0300 | [diff] [blame] | 81 | int rtc_get (struct rtc_time *tmp) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 82 | { |
Yuri Tikhonov | b73a19e | 2008-03-20 17:56:04 +0300 | [diff] [blame] | 83 | int rel = 0; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 84 | uchar sec, min, hour, mday, wday, mon, year; |
| 85 | |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 86 | #ifdef CONFIG_RTC_MCP79411 |
| 87 | read_rtc: |
| 88 | #endif |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 89 | sec = rtc_read (RTC_SEC_REG_ADDR); |
| 90 | min = rtc_read (RTC_MIN_REG_ADDR); |
| 91 | hour = rtc_read (RTC_HR_REG_ADDR); |
| 92 | wday = rtc_read (RTC_DAY_REG_ADDR); |
| 93 | mday = rtc_read (RTC_DATE_REG_ADDR); |
| 94 | mon = rtc_read (RTC_MON_REG_ADDR); |
| 95 | year = rtc_read (RTC_YR_REG_ADDR); |
| 96 | |
| 97 | DEBUGR ("Get RTC year: %02x mon: %02x mday: %02x wday: %02x " |
| 98 | "hr: %02x min: %02x sec: %02x\n", |
| 99 | year, mon, mday, wday, hour, min, sec); |
| 100 | |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 101 | #ifdef CONFIG_RTC_DS1307 |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 102 | if (sec & RTC_SEC_BIT_CH) { |
| 103 | printf ("### Warning: RTC oscillator has stopped\n"); |
| 104 | /* clear the CH flag */ |
| 105 | rtc_write (RTC_SEC_REG_ADDR, |
| 106 | rtc_read (RTC_SEC_REG_ADDR) & ~RTC_SEC_BIT_CH); |
Yuri Tikhonov | b73a19e | 2008-03-20 17:56:04 +0300 | [diff] [blame] | 107 | rel = -1; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 108 | } |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 109 | #endif |
| 110 | |
| 111 | #ifdef CONFIG_RTC_MCP79411 |
| 112 | /* make sure that the backup battery is enabled */ |
| 113 | if (!(wday & MCP7941X_BIT_VBATEN)) { |
| 114 | rtc_write(RTC_DAY_REG_ADDR, |
| 115 | wday | MCP7941X_BIT_VBATEN); |
| 116 | } |
| 117 | |
| 118 | /* clock halted? turn it on, so clock can tick. */ |
| 119 | if (!(sec & MCP7941X_BIT_ST)) { |
| 120 | rtc_write(RTC_SEC_REG_ADDR, MCP7941X_BIT_ST); |
| 121 | printf("Started RTC\n"); |
| 122 | goto read_rtc; |
| 123 | } |
| 124 | #endif |
| 125 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 126 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 127 | tmp->tm_sec = bcd2bin (sec & 0x7F); |
| 128 | tmp->tm_min = bcd2bin (min & 0x7F); |
| 129 | tmp->tm_hour = bcd2bin (hour & 0x3F); |
| 130 | tmp->tm_mday = bcd2bin (mday & 0x3F); |
| 131 | tmp->tm_mon = bcd2bin (mon & 0x1F); |
| 132 | tmp->tm_year = bcd2bin (year) + ( bcd2bin (year) >= 70 ? 1900 : 2000); |
| 133 | tmp->tm_wday = bcd2bin ((wday - 1) & 0x07); |
| 134 | tmp->tm_yday = 0; |
| 135 | tmp->tm_isdst= 0; |
| 136 | |
| 137 | DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", |
| 138 | tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, |
| 139 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
Yuri Tikhonov | b73a19e | 2008-03-20 17:56:04 +0300 | [diff] [blame] | 140 | |
| 141 | return rel; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | |
| 145 | /* |
| 146 | * Set the RTC |
| 147 | */ |
Jean-Christophe PLAGNIOL-VILLARD | d1e2319 | 2008-09-01 23:06:23 +0200 | [diff] [blame] | 148 | int rtc_set (struct rtc_time *tmp) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 149 | { |
| 150 | DEBUGR ("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", |
| 151 | tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, |
| 152 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 153 | |
| 154 | if (tmp->tm_year < 1970 || tmp->tm_year > 2069) |
| 155 | printf("WARNING: year should be between 1970 and 2069!\n"); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 156 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 157 | rtc_write (RTC_YR_REG_ADDR, bin2bcd (tmp->tm_year % 100)); |
| 158 | rtc_write (RTC_MON_REG_ADDR, bin2bcd (tmp->tm_mon)); |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 159 | #ifdef CONFIG_RTC_MCP79411 |
| 160 | rtc_write (RTC_DAY_REG_ADDR, |
| 161 | bin2bcd (tmp->tm_wday + 1) | MCP7941X_BIT_VBATEN); |
| 162 | #else |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 163 | rtc_write (RTC_DAY_REG_ADDR, bin2bcd (tmp->tm_wday + 1)); |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 164 | #endif |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 165 | rtc_write (RTC_DATE_REG_ADDR, bin2bcd (tmp->tm_mday)); |
| 166 | rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour)); |
| 167 | rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min)); |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 168 | #ifdef CONFIG_RTC_MCP79411 |
| 169 | rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec) | MCP7941X_BIT_ST); |
| 170 | #else |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 171 | rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec)); |
Andy Fleming | c79e1c1 | 2015-10-21 18:59:06 -0500 | [diff] [blame] | 172 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | d1e2319 | 2008-09-01 23:06:23 +0200 | [diff] [blame] | 173 | |
| 174 | return 0; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | |
| 178 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 179 | * Reset the RTC. We setting the date back to 1970-01-01. |
| 180 | * We also enable the oscillator output on the SQW/OUT pin and program |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 181 | * it for 32,768 Hz output. Note that according to the datasheet, turning |
| 182 | * on the square wave output increases the current drain on the backup |
| 183 | * battery to something between 480nA and 800nA. |
| 184 | */ |
| 185 | void rtc_reset (void) |
| 186 | { |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 187 | rtc_write (RTC_SEC_REG_ADDR, 0x00); /* clearing Clock Halt */ |
| 188 | rtc_write (RTC_CTL_REG_ADDR, RTC_CTL_BIT_SQWE | RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS0); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | |
| 192 | /* |
| 193 | * Helper functions |
| 194 | */ |
| 195 | |
| 196 | static |
| 197 | uchar rtc_read (uchar reg) |
| 198 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 199 | return (i2c_reg_read (CONFIG_SYS_I2C_RTC_ADDR, reg)); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | |
| 203 | static void rtc_write (uchar reg, uchar val) |
| 204 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 205 | i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 206 | } |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 207 | |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 208 | #endif /* !CONFIG_DM_RTC */ |
| 209 | |
| 210 | #ifdef CONFIG_DM_RTC |
| 211 | static int ds1307_rtc_set(struct udevice *dev, const struct rtc_time *tm) |
| 212 | { |
| 213 | int ret; |
| 214 | uchar buf[7]; |
| 215 | enum ds_type type = dev_get_driver_data(dev); |
| 216 | |
| 217 | debug("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", |
| 218 | tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday, |
| 219 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 220 | |
| 221 | if (tm->tm_year < 1970 || tm->tm_year > 2069) |
| 222 | printf("WARNING: year should be between 1970 and 2069!\n"); |
| 223 | |
| 224 | buf[RTC_YR_REG_ADDR] = bin2bcd(tm->tm_year % 100); |
| 225 | buf[RTC_MON_REG_ADDR] = bin2bcd(tm->tm_mon); |
| 226 | buf[RTC_DAY_REG_ADDR] = bin2bcd(tm->tm_wday + 1); |
| 227 | buf[RTC_DATE_REG_ADDR] = bin2bcd(tm->tm_mday); |
| 228 | buf[RTC_HR_REG_ADDR] = bin2bcd(tm->tm_hour); |
| 229 | buf[RTC_MIN_REG_ADDR] = bin2bcd(tm->tm_min); |
| 230 | buf[RTC_SEC_REG_ADDR] = bin2bcd(tm->tm_sec); |
| 231 | |
| 232 | if (type == mcp794xx) { |
| 233 | buf[RTC_DAY_REG_ADDR] |= MCP7941X_BIT_VBATEN; |
| 234 | buf[RTC_SEC_REG_ADDR] |= MCP7941X_BIT_ST; |
| 235 | } |
| 236 | |
| 237 | ret = dm_i2c_write(dev, 0, buf, sizeof(buf)); |
| 238 | if (ret < 0) |
| 239 | return ret; |
| 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | static int ds1307_rtc_get(struct udevice *dev, struct rtc_time *tm) |
| 245 | { |
| 246 | int ret; |
| 247 | uchar buf[7]; |
| 248 | enum ds_type type = dev_get_driver_data(dev); |
| 249 | |
| 250 | read_rtc: |
| 251 | ret = dm_i2c_read(dev, 0, buf, sizeof(buf)); |
| 252 | if (ret < 0) |
| 253 | return ret; |
| 254 | |
| 255 | if (type == ds_1307) { |
| 256 | if (buf[RTC_SEC_REG_ADDR] & RTC_SEC_BIT_CH) { |
| 257 | printf("### Warning: RTC oscillator has stopped\n"); |
| 258 | /* clear the CH flag */ |
| 259 | buf[RTC_SEC_REG_ADDR] &= ~RTC_SEC_BIT_CH; |
| 260 | dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, |
| 261 | buf[RTC_SEC_REG_ADDR]); |
| 262 | return -1; |
| 263 | } |
| 264 | } |
| 265 | |
Heiko Schocher | 8dd6803 | 2019-05-27 08:13:41 +0200 | [diff] [blame] | 266 | if (type == m41t11) { |
| 267 | /* clock halted? turn it on, so clock can tick. */ |
| 268 | if (buf[RTC_SEC_REG_ADDR] & RTC_SEC_BIT_CH) { |
| 269 | buf[RTC_SEC_REG_ADDR] &= ~RTC_SEC_BIT_CH; |
| 270 | dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, |
| 271 | MCP7941X_BIT_ST); |
| 272 | dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, |
| 273 | buf[RTC_SEC_REG_ADDR]); |
| 274 | goto read_rtc; |
| 275 | } |
| 276 | } |
| 277 | |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 278 | if (type == mcp794xx) { |
| 279 | /* make sure that the backup battery is enabled */ |
| 280 | if (!(buf[RTC_DAY_REG_ADDR] & MCP7941X_BIT_VBATEN)) { |
| 281 | dm_i2c_reg_write(dev, RTC_DAY_REG_ADDR, |
| 282 | buf[RTC_DAY_REG_ADDR] | |
| 283 | MCP7941X_BIT_VBATEN); |
| 284 | } |
| 285 | |
| 286 | /* clock halted? turn it on, so clock can tick. */ |
| 287 | if (!(buf[RTC_SEC_REG_ADDR] & MCP7941X_BIT_ST)) { |
| 288 | dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, |
| 289 | MCP7941X_BIT_ST); |
| 290 | printf("Started RTC\n"); |
| 291 | goto read_rtc; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | tm->tm_sec = bcd2bin(buf[RTC_SEC_REG_ADDR] & 0x7F); |
| 296 | tm->tm_min = bcd2bin(buf[RTC_MIN_REG_ADDR] & 0x7F); |
| 297 | tm->tm_hour = bcd2bin(buf[RTC_HR_REG_ADDR] & 0x3F); |
| 298 | tm->tm_mday = bcd2bin(buf[RTC_DATE_REG_ADDR] & 0x3F); |
| 299 | tm->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F); |
| 300 | tm->tm_year = bcd2bin(buf[RTC_YR_REG_ADDR]) + |
| 301 | (bcd2bin(buf[RTC_YR_REG_ADDR]) >= 70 ? |
| 302 | 1900 : 2000); |
| 303 | tm->tm_wday = bcd2bin((buf[RTC_DAY_REG_ADDR] - 1) & 0x07); |
| 304 | tm->tm_yday = 0; |
| 305 | tm->tm_isdst = 0; |
| 306 | |
| 307 | debug("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", |
| 308 | tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday, |
| 309 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 310 | |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | static int ds1307_rtc_reset(struct udevice *dev) |
| 315 | { |
| 316 | int ret; |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 317 | |
| 318 | /* clear Clock Halt */ |
| 319 | ret = dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, 0x00); |
| 320 | if (ret < 0) |
| 321 | return ret; |
| 322 | ret = dm_i2c_reg_write(dev, RTC_CTL_REG_ADDR, |
| 323 | RTC_CTL_BIT_SQWE | RTC_CTL_BIT_RS1 | |
| 324 | RTC_CTL_BIT_RS0); |
| 325 | if (ret < 0) |
| 326 | return ret; |
| 327 | |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | static int ds1307_probe(struct udevice *dev) |
| 332 | { |
| 333 | i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS | |
| 334 | DM_I2C_CHIP_WR_ADDRESS); |
| 335 | |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | static const struct rtc_ops ds1307_rtc_ops = { |
| 340 | .get = ds1307_rtc_get, |
| 341 | .set = ds1307_rtc_set, |
| 342 | .reset = ds1307_rtc_reset, |
| 343 | }; |
| 344 | |
| 345 | static const struct udevice_id ds1307_rtc_ids[] = { |
| 346 | { .compatible = "dallas,ds1307", .data = ds_1307 }, |
| 347 | { .compatible = "dallas,ds1337", .data = ds_1337 }, |
Chris Packham | f65774e | 2021-03-03 14:09:44 +1300 | [diff] [blame] | 348 | { .compatible = "dallas,ds1339", .data = ds_1339 }, |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 349 | { .compatible = "dallas,ds1340", .data = ds_1340 }, |
| 350 | { .compatible = "microchip,mcp7941x", .data = mcp794xx }, |
Heiko Schocher | 8dd6803 | 2019-05-27 08:13:41 +0200 | [diff] [blame] | 351 | { .compatible = "st,m41t11", .data = m41t11 }, |
Chris Packham | d425d60 | 2017-04-29 15:20:29 +1200 | [diff] [blame] | 352 | { } |
| 353 | }; |
| 354 | |
| 355 | U_BOOT_DRIVER(rtc_ds1307) = { |
| 356 | .name = "rtc-ds1307", |
| 357 | .id = UCLASS_RTC, |
| 358 | .probe = ds1307_probe, |
| 359 | .of_match = ds1307_rtc_ids, |
| 360 | .ops = &ds1307_rtc_ops, |
| 361 | }; |
| 362 | #endif /* CONFIG_DM_RTC */ |