| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Real Time Clock driver for Freescale MC13XXX PMIC |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * (C) 2009 Sascha Hauer, Pengutronix |
|---|
| 5 | 6 | * (C) 2009 Uwe Kleine-Koenig, Pengutronix |
|---|
| 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 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | #include <linux/mfd/mc13xxx.h> |
|---|
| .. | .. |
|---|
| 89 | 86 | return 0; |
|---|
| 90 | 87 | } |
|---|
| 91 | 88 | |
|---|
| 92 | | -static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs) |
|---|
| 89 | +static int mc13xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) |
|---|
| 93 | 90 | { |
|---|
| 94 | 91 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
|---|
| 95 | 92 | unsigned int seconds, days; |
|---|
| 96 | 93 | unsigned int alarmseconds; |
|---|
| 97 | 94 | int ret; |
|---|
| 98 | 95 | |
|---|
| 99 | | - days = div_s64_rem(secs, SEC_PER_DAY, &seconds); |
|---|
| 96 | + days = div_s64_rem(rtc_tm_to_time64(tm), SEC_PER_DAY, &seconds); |
|---|
| 100 | 97 | |
|---|
| 101 | 98 | mc13xxx_lock(priv->mc13xxx); |
|---|
| 102 | 99 | |
|---|
| .. | .. |
|---|
| 158 | 155 | static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
|---|
| 159 | 156 | { |
|---|
| 160 | 157 | struct mc13xxx_rtc *priv = dev_get_drvdata(dev); |
|---|
| 161 | | - unsigned seconds, days; |
|---|
| 158 | + unsigned int seconds, days; |
|---|
| 162 | 159 | time64_t s1970; |
|---|
| 163 | 160 | int enabled, pending; |
|---|
| 164 | 161 | int ret; |
|---|
| .. | .. |
|---|
| 253 | 250 | |
|---|
| 254 | 251 | static const struct rtc_class_ops mc13xxx_rtc_ops = { |
|---|
| 255 | 252 | .read_time = mc13xxx_rtc_read_time, |
|---|
| 256 | | - .set_mmss64 = mc13xxx_rtc_set_mmss, |
|---|
| 253 | + .set_time = mc13xxx_rtc_set_time, |
|---|
| 257 | 254 | .read_alarm = mc13xxx_rtc_read_alarm, |
|---|
| 258 | 255 | .set_alarm = mc13xxx_rtc_set_alarm, |
|---|
| 259 | 256 | .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, |
|---|
| .. | .. |
|---|
| 285 | 282 | priv->mc13xxx = mc13xxx; |
|---|
| 286 | 283 | priv->valid = 1; |
|---|
| 287 | 284 | |
|---|
| 285 | + priv->rtc = devm_rtc_allocate_device(&pdev->dev); |
|---|
| 286 | + if (IS_ERR(priv->rtc)) |
|---|
| 287 | + return PTR_ERR(priv->rtc); |
|---|
| 288 | 288 | platform_set_drvdata(pdev, priv); |
|---|
| 289 | + |
|---|
| 290 | + priv->rtc->ops = &mc13xxx_rtc_ops; |
|---|
| 291 | + /* 15bit days + hours, minutes, seconds */ |
|---|
| 292 | + priv->rtc->range_max = (timeu64_t)(1 << 15) * SEC_PER_DAY - 1; |
|---|
| 289 | 293 | |
|---|
| 290 | 294 | mc13xxx_lock(mc13xxx); |
|---|
| 291 | 295 | |
|---|
| .. | .. |
|---|
| 303 | 307 | |
|---|
| 304 | 308 | mc13xxx_unlock(mc13xxx); |
|---|
| 305 | 309 | |
|---|
| 306 | | - priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
|---|
| 307 | | - &mc13xxx_rtc_ops, THIS_MODULE); |
|---|
| 310 | + ret = rtc_register_device(priv->rtc); |
|---|
| 311 | + if (ret) { |
|---|
| 312 | + mc13xxx_lock(mc13xxx); |
|---|
| 313 | + goto err_irq_request; |
|---|
| 314 | + } |
|---|
| 308 | 315 | |
|---|
| 309 | 316 | return 0; |
|---|
| 310 | 317 | |
|---|