| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2007-2009 ST-Ericsson AB |
|---|
| 3 | | - * License terms: GNU General Public License (GPL) version 2 |
|---|
| 4 | 4 | * RTC clock driver for the AB3100 Analog Baseband Chip |
|---|
| 5 | 5 | * Author: Linus Walleij <linus.walleij@stericsson.com> |
|---|
| 6 | 6 | */ |
|---|
| .. | .. |
|---|
| 43 | 43 | /* |
|---|
| 44 | 44 | * RTC clock functions and device struct declaration |
|---|
| 45 | 45 | */ |
|---|
| 46 | | -static int ab3100_rtc_set_mmss(struct device *dev, time64_t secs) |
|---|
| 46 | +static int ab3100_rtc_set_time(struct device *dev, struct rtc_time *tm) |
|---|
| 47 | 47 | { |
|---|
| 48 | 48 | u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2, |
|---|
| 49 | 49 | AB3100_TI3, AB3100_TI4, AB3100_TI5}; |
|---|
| 50 | 50 | unsigned char buf[6]; |
|---|
| 51 | | - u64 hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2; |
|---|
| 51 | + u64 hw_counter = rtc_tm_to_time64(tm) * AB3100_RTC_CLOCK_RATE * 2; |
|---|
| 52 | 52 | int err = 0; |
|---|
| 53 | 53 | int i; |
|---|
| 54 | 54 | |
|---|
| .. | .. |
|---|
| 192 | 192 | |
|---|
| 193 | 193 | static const struct rtc_class_ops ab3100_rtc_ops = { |
|---|
| 194 | 194 | .read_time = ab3100_rtc_read_time, |
|---|
| 195 | | - .set_mmss64 = ab3100_rtc_set_mmss, |
|---|
| 195 | + .set_time = ab3100_rtc_set_time, |
|---|
| 196 | 196 | .read_alarm = ab3100_rtc_read_alarm, |
|---|
| 197 | 197 | .set_alarm = ab3100_rtc_set_alarm, |
|---|
| 198 | 198 | .alarm_irq_enable = ab3100_rtc_irq_enable, |
|---|
| .. | .. |
|---|
| 228 | 228 | /* Ignore any error on this write */ |
|---|
| 229 | 229 | } |
|---|
| 230 | 230 | |
|---|
| 231 | | - rtc = devm_rtc_device_register(&pdev->dev, "ab3100-rtc", |
|---|
| 232 | | - &ab3100_rtc_ops, THIS_MODULE); |
|---|
| 233 | | - if (IS_ERR(rtc)) { |
|---|
| 234 | | - err = PTR_ERR(rtc); |
|---|
| 235 | | - return err; |
|---|
| 236 | | - } |
|---|
| 231 | + rtc = devm_rtc_allocate_device(&pdev->dev); |
|---|
| 232 | + if (IS_ERR(rtc)) |
|---|
| 233 | + return PTR_ERR(rtc); |
|---|
| 234 | + |
|---|
| 235 | + rtc->ops = &ab3100_rtc_ops; |
|---|
| 236 | + /* 48bit counter at (AB3100_RTC_CLOCK_RATE * 2) */ |
|---|
| 237 | + rtc->range_max = U32_MAX; |
|---|
| 238 | + |
|---|
| 237 | 239 | platform_set_drvdata(pdev, rtc); |
|---|
| 238 | 240 | |
|---|
| 239 | | - return 0; |
|---|
| 241 | + return rtc_register_device(rtc); |
|---|
| 240 | 242 | } |
|---|
| 241 | 243 | |
|---|
| 242 | 244 | static struct platform_driver ab3100_rtc_driver = { |
|---|