diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-08-29 17:25:47 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-09-01 04:57:47 -0400 |
commit | f648d40b99ba7363bf4a1bbca5cc93904725dceb (patch) | |
tree | 321f4f2ed2e5fc3517cfa7b82a43198eef0e6a73 /drivers/rtc | |
parent | c7d5f6dbd9f9a68374f3d24c63a99691d792fd29 (diff) |
rtc: pcf8563: let the core handle range offsetting
Set the RTC range properly and use the core windowing and offsetting to
(unfortunately) map back to a 1970-2069 range.
Link: https://lore.kernel.org/r/20190829212547.19185-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 45462ec460a3..24baa4767b11 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -229,9 +229,7 @@ static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
229 | tm->tm_mday = bcd2bin(buf[PCF8563_REG_DM] & 0x3F); | 229 | tm->tm_mday = bcd2bin(buf[PCF8563_REG_DM] & 0x3F); |
230 | tm->tm_wday = buf[PCF8563_REG_DW] & 0x07; | 230 | tm->tm_wday = buf[PCF8563_REG_DW] & 0x07; |
231 | tm->tm_mon = bcd2bin(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ | 231 | tm->tm_mon = bcd2bin(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ |
232 | tm->tm_year = bcd2bin(buf[PCF8563_REG_YR]); | 232 | tm->tm_year = bcd2bin(buf[PCF8563_REG_YR]) + 100; |
233 | if (tm->tm_year < 70) | ||
234 | tm->tm_year += 100; /* assume we are in 1970...2069 */ | ||
235 | /* detect the polarity heuristically. see note above. */ | 233 | /* detect the polarity heuristically. see note above. */ |
236 | pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ? | 234 | pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ? |
237 | (tm->tm_year >= 100) : (tm->tm_year < 100); | 235 | (tm->tm_year >= 100) : (tm->tm_year < 100); |
@@ -268,7 +266,7 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
268 | buf[PCF8563_REG_MO] = bin2bcd(tm->tm_mon + 1); | 266 | buf[PCF8563_REG_MO] = bin2bcd(tm->tm_mon + 1); |
269 | 267 | ||
270 | /* year and century */ | 268 | /* year and century */ |
271 | buf[PCF8563_REG_YR] = bin2bcd(tm->tm_year % 100); | 269 | buf[PCF8563_REG_YR] = bin2bcd(tm->tm_year - 100); |
272 | if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100)) | 270 | if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100)) |
273 | buf[PCF8563_REG_MO] |= PCF8563_MO_C; | 271 | buf[PCF8563_REG_MO] |= PCF8563_MO_C; |
274 | 272 | ||
@@ -590,6 +588,9 @@ static int pcf8563_probe(struct i2c_client *client, | |||
590 | pcf8563->rtc->ops = &pcf8563_rtc_ops; | 588 | pcf8563->rtc->ops = &pcf8563_rtc_ops; |
591 | /* the pcf8563 alarm only supports a minute accuracy */ | 589 | /* the pcf8563 alarm only supports a minute accuracy */ |
592 | pcf8563->rtc->uie_unsupported = 1; | 590 | pcf8563->rtc->uie_unsupported = 1; |
591 | pcf8563->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; | ||
592 | pcf8563->rtc->range_max = RTC_TIMESTAMP_END_2099; | ||
593 | pcf8563->rtc->set_start_time = true; | ||
593 | 594 | ||
594 | if (client->irq > 0) { | 595 | if (client->irq > 0) { |
595 | err = devm_request_threaded_irq(&client->dev, client->irq, | 596 | err = devm_request_threaded_irq(&client->dev, client->irq, |