Commit 8e4ff713 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rtc-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "A huge series from me this cycle. I went through many drivers to set
  the date and time range supported by the RTC which helps solving HW
  limitation when the time comes (as early as next year for some). This
  time, I focused on drivers using .set_mms and .set_mmss64, allowing me
  to remove those callbacks. About a third of the patches got reviews, I
  actually own the RTCs and I tested another third and the remaining one
  are unlikely to cause any issues.

  Other than that, a single new driver and the usual fixes here and there.

  Summary:

  Subsystem:

   - set_mmss and set_mmss64 rtc_ops removal

   - Fix timestamp value for RTC_TIMESTAMP_BEGIN_1900

   - Use SPDX identifier for the core

   - validate upper bound of tm->tm_year

  New driver:

   - Aspeed BMC SoC RTC

  Drivers:

   - abx80x: use rtc_add_group

   - ds3232: nvram support

   - pcf85063: add alarm, nvram, offset correction and microcrystal
     rv8263 support

   - x1205: add of_match_table

   - Use set_time instead of set_mms/set_mmss64 for: ab3100, coh901331,
     digicolor, ds1672, ds2404, ep93xx, imxdi, jz4740, lpc32xx, mc13xxx,
     mxc, pcap, stmp3xxx, test, wm831x, xgene.

   - Set RTC range for: ab3100, at91sam9, coh901331, da9063, digicolor,
     dm355evm, ds1672, ds2404, ep39xx, goldfish, imxdi, jz4740, lpc32xx,
     mc13xxx, mv, mxc, omap, pcap, pcf85063, pcf85363, ps3, sh,
     stmp3xxx, sun4v, tegra, wm831x, xgene.

   - Switch to rtc_time64_to_tm/rtc_tm_to_time64 for the driver that
     properly set the RTC range.

   - Use dev_get_drvdata instead of multiple indirections"

* tag 'rtc-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (177 commits)
  rtc: snvs: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
  rtc: imxdi: remove unused variable
  rtc: drop set_mms and set_mmss64
  rtc: pcap: convert to SPDX identifier
  rtc: pcap: use .set_time
  rtc: pcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
  rtc: pcap: set range
  rtc: digicolor: convert to SPDX identifier
  rtc: digicolor: use .set_time
  rtc: digicolor: set range
  rtc: digicolor: fix possible race condition
  rtc: jz4740: convert to SPDX identifier
  rtc: jz4740: rework invalid time detection
  rtc: jz4740: use dev_pm_set_wake_irq() to simplify code
  rtc: jz4740: use .set_time
  rtc: jz4740: remove useless check
  rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64
  rtc: jz4740: set range
  rtc: 88pm860x: prevent use-after-free on device remove
  rtc: Use dev_get_drvdata()
  ...
parents 45182e4e dacb6a40
* NXP PCF85063 Real Time Clock * NXP PCF85063 Real Time Clock
Required properties: Required properties:
- compatible: Should contain "nxp,pcf85063". - compatible: Should one of contain:
"nxp,pcf85063",
"nxp,pcf85063a",
"nxp,pcf85063tp",
"microcrystal,rv8263"
- reg: I2C address for chip. - reg: I2C address for chip.
Optional property: Optional property:
......
ASPEED BMC RTC
==============
Required properties:
- compatible: should be one of the following
* aspeed,ast2400-rtc for the ast2400
* aspeed,ast2500-rtc for the ast2500
* aspeed,ast2600-rtc for the ast2600
- reg: physical base address of the controller and length of memory mapped
region
- interrupts: The interrupt number
Example:
rtc@1e781000 {
compatible = "aspeed,ast2400-rtc";
reg = <0x1e781000 0x18>;
interrupts = <22>;
status = "disabled";
};
...@@ -69,3 +69,4 @@ ricoh,rv5c386 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC ...@@ -69,3 +69,4 @@ ricoh,rv5c386 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
ricoh,rv5c387a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC ricoh,rv5c387a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
sii,s35390a 2-wire CMOS real-time clock sii,s35390a 2-wire CMOS real-time clock
whwave,sd3078 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC whwave,sd3078 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
xircom,x1205 Xircom X1205 I2C RTC
...@@ -439,6 +439,7 @@ config RTC_DRV_PCF8523 ...@@ -439,6 +439,7 @@ config RTC_DRV_PCF8523
config RTC_DRV_PCF85063 config RTC_DRV_PCF85063
tristate "NXP PCF85063" tristate "NXP PCF85063"
select REGMAP_I2C
help help
If you say yes here you get support for the PCF85063 RTC chip If you say yes here you get support for the PCF85063 RTC chip
...@@ -447,7 +448,6 @@ config RTC_DRV_PCF85063 ...@@ -447,7 +448,6 @@ config RTC_DRV_PCF85063
config RTC_DRV_PCF85363 config RTC_DRV_PCF85363
tristate "NXP PCF85363" tristate "NXP PCF85363"
depends on I2C
select REGMAP_I2C select REGMAP_I2C
help help
If you say yes here you get support for the PCF85363 RTC chip. If you say yes here you get support for the PCF85363 RTC chip.
...@@ -602,7 +602,6 @@ config RTC_DRV_FM3130 ...@@ -602,7 +602,6 @@ config RTC_DRV_FM3130
config RTC_DRV_RX8010 config RTC_DRV_RX8010
tristate "Epson RX8010SJ" tristate "Epson RX8010SJ"
depends on I2C
help help
If you say yes here you get support for the Epson RX8010SJ RTC If you say yes here you get support for the Epson RX8010SJ RTC
chip. chip.
...@@ -1432,7 +1431,7 @@ config RTC_DRV_AT91RM9200 ...@@ -1432,7 +1431,7 @@ config RTC_DRV_AT91RM9200
config RTC_DRV_AT91SAM9 config RTC_DRV_AT91SAM9
tristate "AT91SAM9 RTT as RTC" tristate "AT91SAM9 RTT as RTC"
depends on ARCH_AT91 || COMPILE_TEST depends on ARCH_AT91 || COMPILE_TEST
depends on HAS_IOMEM depends on OF && HAS_IOMEM
select MFD_SYSCON select MFD_SYSCON
help help
Some AT91SAM9 SoCs provide an RTT (Real Time Timer) block which Some AT91SAM9 SoCs provide an RTT (Real Time Timer) block which
...@@ -1841,6 +1840,17 @@ config RTC_DRV_RTD119X ...@@ -1841,6 +1840,17 @@ config RTC_DRV_RTD119X
If you say yes here, you get support for the RTD1295 SoC If you say yes here, you get support for the RTD1295 SoC
Real Time Clock. Real Time Clock.
config RTC_DRV_ASPEED
tristate "ASPEED RTC"
depends on OF
depends on ARCH_ASPEED || COMPILE_TEST
help
If you say yes here you get support for the ASPEED BMC SoC real time
clocks.
This driver can also be built as a module, if so, the module
will be called "rtc-aspeed".
comment "HID Sensor RTC drivers" comment "HID Sensor RTC drivers"
config RTC_DRV_HID_SENSOR_TIME config RTC_DRV_HID_SENSOR_TIME
...@@ -1857,7 +1867,8 @@ config RTC_DRV_HID_SENSOR_TIME ...@@ -1857,7 +1867,8 @@ config RTC_DRV_HID_SENSOR_TIME
config RTC_DRV_GOLDFISH config RTC_DRV_GOLDFISH
tristate "Goldfish Real Time Clock" tristate "Goldfish Real Time Clock"
depends on MIPS && (GOLDFISH || COMPILE_TEST) depends on OF && HAS_IOMEM
depends on GOLDFISH || COMPILE_TEST
help help
Say yes to enable RTC driver for the Goldfish based virtual platform. Say yes to enable RTC driver for the Goldfish based virtual platform.
......
...@@ -34,6 +34,7 @@ obj-$(CONFIG_RTC_DRV_AC100) += rtc-ac100.o ...@@ -34,6 +34,7 @@ obj-$(CONFIG_RTC_DRV_AC100) += rtc-ac100.o
obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o
obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o
obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o
obj-$(CONFIG_RTC_DRV_ASPEED) += rtc-aspeed.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* RTC subsystem, base class * RTC subsystem, base class
* *
...@@ -5,11 +6,7 @@ ...@@ -5,11 +6,7 @@
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
* *
* class skeleton from drivers/hwmon/hwmon.c * class skeleton from drivers/hwmon/hwmon.c
* */
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
...@@ -23,13 +20,13 @@ ...@@ -23,13 +20,13 @@
#include "rtc-core.h" #include "rtc-core.h"
static DEFINE_IDA(rtc_ida); static DEFINE_IDA(rtc_ida);
struct class *rtc_class; struct class *rtc_class;
static void rtc_device_release(struct device *dev) static void rtc_device_release(struct device *dev)
{ {
struct rtc_device *rtc = to_rtc_device(dev); struct rtc_device *rtc = to_rtc_device(dev);
ida_simple_remove(&rtc_ida, rtc->id); ida_simple_remove(&rtc_ida, rtc->id);
kfree(rtc); kfree(rtc);
} }
...@@ -47,7 +44,6 @@ int rtc_hctosys_ret = -ENODEV; ...@@ -47,7 +44,6 @@ int rtc_hctosys_ret = -ENODEV;
static struct timespec64 old_rtc, old_system, old_delta; static struct timespec64 old_rtc, old_system, old_delta;
static int rtc_suspend(struct device *dev) static int rtc_suspend(struct device *dev)
{ {
struct rtc_device *rtc = to_rtc_device(dev); struct rtc_device *rtc = to_rtc_device(dev);
...@@ -71,7 +67,6 @@ static int rtc_suspend(struct device *dev) ...@@ -71,7 +67,6 @@ static int rtc_suspend(struct device *dev)
ktime_get_real_ts64(&old_system); ktime_get_real_ts64(&old_system);
old_rtc.tv_sec = rtc_tm_to_time64(&tm); old_rtc.tv_sec = rtc_tm_to_time64(&tm);
/* /*
* To avoid drift caused by repeated suspend/resumes, * To avoid drift caused by repeated suspend/resumes,
* which each can add ~1 second drift error, * which each can add ~1 second drift error,
...@@ -83,7 +78,7 @@ static int rtc_suspend(struct device *dev) ...@@ -83,7 +78,7 @@ static int rtc_suspend(struct device *dev)
if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) {
/* /*
* if delta_delta is too large, assume time correction * if delta_delta is too large, assume time correction
* has occured and set old_delta to the current delta. * has occurred and set old_delta to the current delta.
*/ */
old_delta = delta; old_delta = delta;
} else { } else {
...@@ -136,7 +131,7 @@ static int rtc_resume(struct device *dev) ...@@ -136,7 +131,7 @@ static int rtc_resume(struct device *dev)
* to keep things accurate. * to keep things accurate.
*/ */
sleep_time = timespec64_sub(sleep_time, sleep_time = timespec64_sub(sleep_time,
timespec64_sub(new_system, old_system)); timespec64_sub(new_system, old_system));
if (sleep_time.tv_sec >= 0) if (sleep_time.tv_sec >= 0)
timekeeping_inject_sleeptime64(&sleep_time); timekeeping_inject_sleeptime64(&sleep_time);
...@@ -397,9 +392,9 @@ EXPORT_SYMBOL_GPL(__rtc_register_device); ...@@ -397,9 +392,9 @@ EXPORT_SYMBOL_GPL(__rtc_register_device);
* rtc_register_device instead * rtc_register_device instead
*/ */
struct rtc_device *devm_rtc_device_register(struct device *dev, struct rtc_device *devm_rtc_device_register(struct device *dev,
const char *name, const char *name,
const struct rtc_class_ops *ops, const struct rtc_class_ops *ops,
struct module *owner) struct module *owner)
{ {
struct rtc_device *rtc; struct rtc_device *rtc;
int err; int err;
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* RTC subsystem, dev interface * RTC subsystem, dev interface
* *
...@@ -5,11 +6,7 @@ ...@@ -5,11 +6,7 @@
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
* *
* based on arch/arm/common/rtctime.c * based on arch/arm/common/rtctime.c
* */
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
...@@ -60,7 +57,7 @@ static void rtc_uie_task(struct work_struct *work) ...@@ -60,7 +57,7 @@ static void rtc_uie_task(struct work_struct *work)
} else if (rtc->oldsecs != tm.tm_sec) { } else if (rtc->oldsecs != tm.tm_sec) {
num = (tm.tm_sec + 60 - rtc->oldsecs) % 60; num = (tm.tm_sec + 60 - rtc->oldsecs) % 60;
rtc->oldsecs = tm.tm_sec; rtc->oldsecs = tm.tm_sec;
rtc->uie_timer.expires = jiffies + HZ - (HZ/10); rtc->uie_timer.expires = jiffies + HZ - (HZ / 10);
rtc->uie_timer_active = 1; rtc->uie_timer_active = 1;
rtc->uie_task_active = 0; rtc->uie_task_active = 0;
add_timer(&rtc->uie_timer); add_timer(&rtc->uie_timer);
...@@ -71,6 +68,7 @@ static void rtc_uie_task(struct work_struct *work) ...@@ -71,6 +68,7 @@ static void rtc_uie_task(struct work_struct *work)
if (num) if (num)
rtc_handle_legacy_irq(rtc, num, RTC_UF); rtc_handle_legacy_irq(rtc, num, RTC_UF);
} }
static void rtc_uie_timer(struct timer_list *t) static void rtc_uie_timer(struct timer_list *t)
{ {
struct rtc_device *rtc = from_timer(rtc, t, uie_timer); struct rtc_device *rtc = from_timer(rtc, t, uie_timer);
...@@ -202,14 +200,14 @@ static __poll_t rtc_dev_poll(struct file *file, poll_table *wait) ...@@ -202,14 +200,14 @@ static __poll_t rtc_dev_poll(struct file *file, poll_table *wait)
} }
static long rtc_dev_ioctl(struct file *file, static long rtc_dev_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int err = 0; int err = 0;
struct rtc_device *rtc = file->private_data; struct rtc_device *rtc = file->private_data;
const struct rtc_class_ops *ops = rtc->ops; const struct rtc_class_ops *ops = rtc->ops;
struct rtc_time tm; struct rtc_time tm;
struct rtc_wkalrm alarm; struct rtc_wkalrm alarm;
void __user *uarg = (void __user *) arg; void __user *uarg = (void __user *)arg;
err = mutex_lock_interruptible(&rtc->ops_lock); err = mutex_lock_interruptible(&rtc->ops_lock);
if (err) if (err)
...@@ -233,7 +231,7 @@ static long rtc_dev_ioctl(struct file *file, ...@@ -233,7 +231,7 @@ static long rtc_dev_ioctl(struct file *file,
case RTC_PIE_ON: case RTC_PIE_ON:
if (rtc->irq_freq > rtc->max_user_freq && if (rtc->irq_freq > rtc->max_user_freq &&
!capable(CAP_SYS_RESOURCE)) !capable(CAP_SYS_RESOURCE))
err = -EACCES; err = -EACCES;
break; break;
} }
...@@ -390,8 +388,9 @@ static long rtc_dev_ioctl(struct file *file, ...@@ -390,8 +388,9 @@ static long rtc_dev_ioctl(struct file *file,
err = ops->ioctl(rtc->dev.parent, cmd, arg); err = ops->ioctl(rtc->dev.parent, cmd, arg);
if (err == -ENOIOCTLCMD) if (err == -ENOIOCTLCMD)
err = -ENOTTY; err = -ENOTTY;
} else } else {
err = -ENOTTY; err = -ENOTTY;
}
break; break;
} }
...@@ -403,6 +402,7 @@ static long rtc_dev_ioctl(struct file *file, ...@@ -403,6 +402,7 @@ static long rtc_dev_ioctl(struct file *file,
static int rtc_dev_fasync(int fd, struct file *file, int on) static int rtc_dev_fasync(int fd, struct file *file, int on)
{ {
struct rtc_device *rtc = file->private_data; struct rtc_device *rtc = file->private_data;
return fasync_helper(fd, file, on, &rtc->async_queue); return fasync_helper(fd, file, on, &rtc->async_queue);
} }
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* RTC subsystem, initialize system time on startup * RTC subsystem, initialize system time on startup
* *
* Copyright (C) 2005 Tower Technologies * Copyright (C) 2005 Tower Technologies
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
* */
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
...@@ -33,7 +30,7 @@ static int __init rtc_hctosys(void) ...@@ -33,7 +30,7 @@ static int __init rtc_hctosys(void)
}; };
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
if (rtc == NULL) { if (!rtc) {
pr_info("unable to open rtc device (%s)\n", pr_info("unable to open rtc device (%s)\n",
CONFIG_RTC_HCTOSYS_DEVICE); CONFIG_RTC_HCTOSYS_DEVICE);
goto err_open; goto err_open;
...@@ -44,7 +41,6 @@ static int __init rtc_hctosys(void) ...@@ -44,7 +41,6 @@ static int __init rtc_hctosys(void)
dev_err(rtc->dev.parent, dev_err(rtc->dev.parent,
"hctosys: unable to read the hardware clock\n"); "hctosys: unable to read the hardware clock\n");
goto err_read; goto err_read;
} }
tv64.tv_sec = rtc_tm_to_time64(&tm); tv64.tv_sec = rtc_tm_to_time64(&tm);
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* rtc and date/time utility functions * rtc and date/time utility functions
* *
...@@ -5,11 +6,7 @@ ...@@ -5,11 +6,7 @@
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
* *
* based on arch/arm/common/rtctime.c and other bits * based on arch/arm/common/rtctime.c and other bits
* */
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/export.h> #include <linux/export.h>
#include <linux/rtc.h> #include <linux/rtc.h>
...@@ -25,7 +22,7 @@ static const unsigned short rtc_ydays[2][13] = { ...@@ -25,7 +22,7 @@ static const unsigned short rtc_ydays[2][13] = {
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
}; };
#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400) #define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
/* /*
* The number of days in the month. * The number of days in the month.
...@@ -41,11 +38,10 @@ EXPORT_SYMBOL(rtc_month_days); ...@@ -41,11 +38,10 @@ EXPORT_SYMBOL(rtc_month_days);
*/ */
int rtc_year_days(unsigned int day, unsigned int month, unsigned int year) int rtc_year_days(unsigned int day, unsigned int month, unsigned int year)
{ {
return rtc_ydays[is_leap_year(year)][month] + day-1; return rtc_ydays[is_leap_year(year)][month] + day - 1;
} }
EXPORT_SYMBOL(rtc_year_days); EXPORT_SYMBOL(rtc_year_days);
/* /*
* rtc_time64_to_tm - Converts time64_t to rtc_time. * rtc_time64_to_tm - Converts time64_t to rtc_time.
* Convert seconds since 01-01-1970 00:00:00 to Gregorian date. * Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
...@@ -97,13 +93,15 @@ EXPORT_SYMBOL(rtc_time64_to_tm); ...@@ -97,13 +93,15 @@ EXPORT_SYMBOL(rtc_time64_to_tm);
*/ */
int rtc_valid_tm(struct rtc_time *tm) int rtc_valid_tm(struct rtc_time *tm)
{ {
if (tm->tm_year < 70 if (tm->tm_year < 70 ||
|| ((unsigned)tm->tm_mon) >= 12 tm->tm_year > (INT_MAX - 1900) ||
|| tm->tm_mday < 1 ((unsigned int)tm->tm_mon) >= 12 ||
|| tm->tm_mday > rtc_month_days(tm->tm_mon, ((unsigned)tm->tm_year + 1900)) tm->tm_mday < 1 ||
|| ((unsigned)tm->tm_hour) >= 24 tm->tm_mday > rtc_month_days(tm->tm_mon,
|| ((unsigned)tm->tm_min) >= 60 ((unsigned int)tm->tm_year + 1900)) ||
|| ((unsigned)tm->tm_sec) >= 60) ((unsigned int)tm->tm_hour) >= 24 ||
((unsigned int)tm->tm_min) >= 60 ||
((unsigned int)tm->tm_sec) >= 60)
return -EINVAL; return -EINVAL;
return 0; return 0;
...@@ -116,7 +114,7 @@ EXPORT_SYMBOL(rtc_valid_tm); ...@@ -116,7 +114,7 @@ EXPORT_SYMBOL(rtc_valid_tm);
*/ */
time64_t rtc_tm_to_time64(struct rtc_time *tm) time64_t rtc_tm_to_time64(struct rtc_time *tm)
{ {
return mktime64(((unsigned)tm->tm_year + 1900), tm->tm_mon + 1, return mktime64(((unsigned int)tm->tm_year + 1900), tm->tm_mon + 1,
tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
} }
EXPORT_SYMBOL(rtc_tm_to_time64); EXPORT_SYMBOL(rtc_tm_to_time64);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* RTC subsystem, nvmem interface * RTC subsystem, nvmem interface
* *
* Copyright (C) 2017 Alexandre Belloni * Copyright (C) 2017 Alexandre Belloni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/err.h> #include <linux/err.h>
...@@ -46,7 +43,7 @@ static int rtc_nvram_register(struct rtc_device *rtc, ...@@ -46,7 +43,7 @@ static int rtc_nvram_register(struct rtc_device *rtc,
{ {
int err; int err;
rtc->nvram = kzalloc(sizeof(struct bin_attribute), GFP_KERNEL); rtc->nvram = kzalloc(sizeof(*rtc->nvram), GFP_KERNEL);
if (!rtc->nvram) if (!rtc->nvram)
return -ENOMEM; return -ENOMEM;
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* RTC subsystem, proc interface * RTC subsystem, proc interface
* *
...@@ -5,11 +6,7 @@ ...@@ -5,11 +6,7 @@
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
* *
* based on arch/arm/common/rtctime.c * based on arch/arm/common/rtctime.c
* */
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h> #include <linux/module.h>
#include <linux/rtc.h> #include <linux/rtc.h>
...@@ -60,17 +57,17 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) ...@@ -60,17 +57,17 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time); seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time);
seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time); seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time);
seq_printf(seq, "alarm_IRQ\t: %s\n", seq_printf(seq, "alarm_IRQ\t: %s\n",
alrm.enabled ? "yes" : "no"); alrm.enabled ? "yes" : "no");
seq_printf(seq, "alrm_pending\t: %s\n", seq_printf(seq, "alrm_pending\t: %s\n",
alrm.pending ? "yes" : "no"); alrm.pending ? "yes" : "no");
seq_printf(seq, "update IRQ enabled\t: %s\n", seq_printf(seq, "update IRQ enabled\t: %s\n",
(rtc->uie_rtctimer.enabled) ? "yes" : "no"); (rtc->uie_rtctimer.enabled) ? "yes" : "no");
seq_printf(seq, "periodic IRQ enabled\t: %s\n", seq_printf(seq, "periodic IRQ enabled\t: %s\n",
(rtc->pie_enabled) ? "yes" : "no"); (rtc->pie_enabled) ? "yes" : "no");
seq_printf(seq, "periodic IRQ frequency\t: %d\n", seq_printf(seq, "periodic IRQ frequency\t: %d\n",
rtc->irq_freq); rtc->irq_freq);
seq_printf(seq, "max user IRQ frequency\t: %d\n", seq_printf(seq, "max user IRQ frequency\t: %d\n",
rtc->max_user_freq); rtc->max_user_freq);
} }
seq_printf(seq, "24hr\t\t: yes\n"); seq_printf(seq, "24hr\t\t: yes\n");
...@@ -85,7 +82,7 @@ void rtc_proc_add_device(struct rtc_device *rtc) ...@@ -85,7 +82,7 @@ void rtc_proc_add_device(struct rtc_device *rtc)
{ {
if (is_rtc_hctosys(rtc)) if (is_rtc_hctosys(rtc))
proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show, proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
rtc); rtc);
} }
void rtc_proc_del_device(struct rtc_device *rtc) void rtc_proc_del_device(struct rtc_device *rtc)
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Real Time Clock driver for Marvell 88PM80x PMIC * Real Time Clock driver for Marvell 88PM80x PMIC
* *
* Copyright (c) 2012 Marvell International Ltd. * Copyright (c) 2012 Marvell International Ltd.
* Wenzeng Chen<wzch@marvell.com> * Wenzeng Chen<wzch@marvell.com>
* Qiao Zhou <zhouqiao@marvell.com> * Qiao Zhou <zhouqiao@marvell.com>
*
* This file is subject to the terms and conditions of the GNU General
* Public License. See the file "COPYING" in the main directory of this
* archive for more details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -421,7 +421,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev) ...@@ -421,7 +421,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev)
struct pm860x_rtc_info *info = platform_get_drvdata(pdev); struct pm860x_rtc_info *info = platform_get_drvdata(pdev);
#ifdef VRTC_CALIBRATION #ifdef VRTC_CALIBRATION
flush_scheduled_work(); cancel_delayed_work_sync(&info->calib_work);
/* disable measurement */ /* disable measurement */
pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0); pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0);
#endif /* VRTC_CALIBRATION */ #endif /* VRTC_CALIBRATION */
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2007-2009 ST-Ericsson AB * Copyright (C) 2007-2009 ST-Ericsson AB
* License terms: GNU General Public License (GPL) version 2
* RTC clock driver for the AB3100 Analog Baseband Chip * RTC clock driver for the AB3100 Analog Baseband Chip
* Author: Linus Walleij <linus.walleij@stericsson.com> * Author: Linus Walleij <linus.walleij@stericsson.com>
*/ */
...@@ -43,12 +43,12 @@ ...@@ -43,12 +43,12 @@
/* /*
* RTC clock functions and device struct declaration * RTC clock functions and device struct declaration
*/ */
static int ab3100_rtc_set_mmss(struct device *dev, time64_t secs) static int ab3100_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2, u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2,
AB3100_TI3, AB3100_TI4, AB3100_TI5}; AB3100_TI3, AB3100_TI4, AB3100_TI5};
unsigned char buf[6]; unsigned char buf[6];
u64 hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2; u64 hw_counter = rtc_tm_to_time64(tm) * AB3100_RTC_CLOCK_RATE * 2;
int err = 0; int err = 0;
int i; int i;
...@@ -192,7 +192,7 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled) ...@@ -192,7 +192,7 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
static const struct rtc_class_ops ab3100_rtc_ops = { static const struct rtc_class_ops ab3100_rtc_ops = {
.read_time = ab3100_rtc_read_time, .read_time = ab3100_rtc_read_time,
.set_mmss64 = ab3100_rtc_set_mmss, .set_time = ab3100_rtc_set_time,
.read_alarm = ab3100_rtc_read_alarm, .read_alarm = ab3100_rtc_read_alarm,
.set_alarm = ab3100_rtc_set_alarm, .set_alarm = ab3100_rtc_set_alarm,
.alarm_irq_enable = ab3100_rtc_irq_enable, .alarm_irq_enable = ab3100_rtc_irq_enable,
...@@ -228,15 +228,17 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev) ...@@ -228,15 +228,17 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev)
/* Ignore any error on this write */ /* Ignore any error on this write */
} }
rtc = devm_rtc_device_register(&pdev->dev, "ab3100-rtc", rtc = devm_rtc_allocate_device(&pdev->dev);
&ab3100_rtc_ops, THIS_MODULE); if (IS_ERR(rtc))
if (IS_ERR(rtc)) { return PTR_ERR(rtc);
err = PTR_ERR(rtc);
return err; rtc->ops = &ab3100_rtc_ops;
} /* 48bit counter at (AB3100_RTC_CLOCK_RATE * 2) */
rtc->range_max = U32_MAX;
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
return 0; return rtc_register_device(rtc);
} }
static struct platform_driver ab3100_rtc_driver = { static struct platform_driver ab3100_rtc_driver = {
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* A driver for the I2C members of the Abracon AB x8xx RTC family, * A driver for the I2C members of the Abracon AB x8xx RTC family,
* and compatible: AB 1805 and AB 0805 * and compatible: AB 1805 and AB 0805
...@@ -7,10 +8,6 @@ ...@@ -7,10 +8,6 @@
* Author: Philippe De Muyter <phdm@macqel.be> * Author: Philippe De Muyter <phdm@macqel.be>
* Author: Alexandre Belloni <alexandre.belloni@bootlin.com> * Author: Alexandre Belloni <alexandre.belloni@bootlin.com>
* *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
#include <linux/bcd.h> #include <linux/bcd.h>
...@@ -404,7 +401,7 @@ static ssize_t autocalibration_store(struct device *dev, ...@@ -404,7 +401,7 @@ static ssize_t autocalibration_store(struct device *dev,
return -EINVAL; return -EINVAL;
} }
retval = abx80x_rtc_set_autocalibration(dev, autocalibration); retval = abx80x_rtc_set_autocalibration(dev->parent, autocalibration);
return retval ? retval : count; return retval ? retval : count;
} }
...@@ -414,7 +411,7 @@ static ssize_t autocalibration_show(struct device *dev, ...@@ -414,7 +411,7 @@ static ssize_t autocalibration_show(struct device *dev,
{ {
int autocalibration = 0; int autocalibration = 0;
autocalibration = abx80x_rtc_get_autocalibration(dev); autocalibration = abx80x_rtc_get_autocalibration(dev->parent);
if (autocalibration < 0) { if (autocalibration < 0) {
dev_err(dev, "Failed to read RTC autocalibration\n"); dev_err(dev, "Failed to read RTC autocalibration\n");
sprintf(buf, "0\n"); sprintf(buf, "0\n");
...@@ -430,7 +427,7 @@ static ssize_t oscillator_store(struct device *dev, ...@@ -430,7 +427,7 @@ static ssize_t oscillator_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev->parent);
int retval, flags, rc_mode = 0; int retval, flags, rc_mode = 0;
if (strncmp(buf, "rc", 2) == 0) { if (strncmp(buf, "rc", 2) == 0) {
...@@ -472,7 +469,7 @@ static ssize_t oscillator_show(struct device *dev, ...@@ -472,7 +469,7 @@ static ssize_t oscillator_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int rc_mode = 0; int rc_mode = 0;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev->parent);
rc_mode = abx80x_is_rc_mode(client); rc_mode = abx80x_is_rc_mode(client);
...@@ -592,13 +589,6 @@ static int abx80x_dt_trickle_cfg(struct device_node *np) ...@@ -592,13 +589,6 @@ static int abx80x_dt_trickle_cfg(struct device_node *np)
return (trickle_cfg | i); return (trickle_cfg | i);
} }
static void rtc_calib_remove_sysfs_group(void *_dev)
{
struct device *dev = _dev;
sysfs_remove_group(&dev->kobj, &rtc_calib_attr_group);
}
#ifdef CONFIG_WATCHDOG #ifdef CONFIG_WATCHDOG
static inline u8 timeout_bits(unsigned int timeout) static inline u8 timeout_bits(unsigned int timeout)
...@@ -851,32 +841,14 @@ static int abx80x_probe(struct i2c_client *client, ...@@ -851,32 +841,14 @@ static int abx80x_probe(struct i2c_client *client,
} }
} }
/* Export sysfs entries */ err = rtc_add_group(priv->rtc, &rtc_calib_attr_group);
err = sysfs_create_group(&(&client->dev)->kobj, &rtc_calib_attr_group);
if (err) { if (err) {
dev_err(&client->dev, "Failed to create sysfs group: %d\n", dev_err(&client->dev, "Failed to create sysfs group: %d\n",
err); err);
return err; return err;
} }
err = devm_add_action_or_reset(&client->dev, return rtc_register_device(priv->rtc);
rtc_calib_remove_sysfs_group,
&client->dev);
if (err) {
dev_err(&client->dev,
"Failed to add sysfs cleanup action: %d\n",
err);
return err;
}
err = rtc_register_device(priv->rtc);
return err;
}
static int abx80x_remove(struct i2c_client *client)
{
return 0;
} }
static const struct i2c_device_id abx80x_id[] = { static const struct i2c_device_id abx80x_id[] = {
...@@ -899,7 +871,6 @@ static struct i2c_driver abx80x_driver = { ...@@ -899,7 +871,6 @@ static struct i2c_driver abx80x_driver = {
.name = "rtc-abx80x", .name = "rtc-abx80x",
}, },
.probe = abx80x_probe, .probe = abx80x_probe,
.remove = abx80x_remove,
.id_table = abx80x_id, .id_table = abx80x_id,
}; };
......
// SPDX-License-Identifier: GPL-2.0+
// Copyright 2015 IBM Corp.
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <linux/io.h>
struct aspeed_rtc {
struct rtc_device *rtc_dev;
void __iomem *base;
};
#define RTC_TIME 0x00
#define RTC_YEAR 0x04
#define RTC_CTRL 0x10
#define RTC_UNLOCK BIT(1)
#define RTC_ENABLE BIT(0)
static int aspeed_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct aspeed_rtc *rtc = dev_get_drvdata(dev);
unsigned int cent, year;
u32 reg1, reg2;
if (!(readl(rtc->base + RTC_CTRL) & RTC_ENABLE)) {
dev_dbg(dev, "%s failing as rtc disabled\n", __func__);
return -EINVAL;
}
do {
reg2 = readl(rtc->base + RTC_YEAR);
reg1 = readl(rtc->base + RTC_TIME);
} while (reg2 != readl(rtc->base + RTC_YEAR));
tm->tm_mday = (reg1 >> 24) & 0x1f;
tm->tm_hour = (reg1 >> 16) & 0x1f;
tm->tm_min = (reg1 >> 8) & 0x3f;
tm->tm_sec = (reg1 >> 0) & 0x3f;
cent = (reg2 >> 16) & 0x1f;
year = (reg2 >> 8) & 0x7f;
tm->tm_mon = ((reg2 >> 0) & 0x0f) - 1;
tm->tm_year = year + (cent * 100) - 1900;
dev_dbg(dev, "%s %ptR", __func__, tm);
return 0;
}
static int aspeed_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct aspeed_rtc *rtc = dev_get_drvdata(dev);
u32 reg1, reg2, ctrl;
int year, cent;
cent = (tm->tm_year + 1900) / 100;
year = tm->tm_year % 100;
reg1 = (tm->tm_mday << 24) | (tm->tm_hour << 16) | (tm->tm_min << 8) |
tm->tm_sec;
reg2 = ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) |
((tm->tm_mon + 1) & 0xf);
ctrl = readl(rtc->base + RTC_CTRL);
writel(ctrl | RTC_UNLOCK, rtc->base + RTC_CTRL);
writel(reg1, rtc->base + RTC_TIME);
writel(reg2, rtc->base + RTC_YEAR);
/* Re-lock and ensure enable is set now that a time is programmed */
writel(ctrl | RTC_ENABLE, rtc->base + RTC_CTRL);
return 0;
}
static const struct rtc_class_ops aspeed_rtc_ops = {
.read_time = aspeed_rtc_read_time,
.set_time = aspeed_rtc_set_time,
};
static int aspeed_rtc_probe(struct platform_device *pdev)
{
struct aspeed_rtc *rtc;
struct resource *res;
int ret;
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
rtc->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(rtc->base))
return PTR_ERR(rtc->base);
rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
platform_set_drvdata(pdev, rtc);
rtc->rtc_dev->ops = &aspeed_rtc_ops;
rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_1900;
rtc->rtc_dev->range_max = 38814989399LL; /* 3199-12-31 23:59:59 */
ret = rtc_register_device(rtc->rtc_dev);
if (ret)
return ret;
return 0;
}
static const struct of_device_id aspeed_rtc_match[] = {
{ .compatible = "aspeed,ast2400-rtc", },
{ .compatible = "aspeed,ast2500-rtc", },
{ .compatible = "aspeed,ast2600-rtc", },
{}
};
MODULE_DEVICE_TABLE(of, aspeed_rtc_match);
static struct platform_driver aspeed_rtc_driver = {
.driver = {
.name = "aspeed-rtc",
.of_match_table = of_match_ptr(aspeed_rtc_match),
},
};
module_platform_driver_probe(aspeed_rtc_driver, aspeed_rtc_probe);
MODULE_DESCRIPTION("ASPEED RTC driver");
MODULE_AUTHOR("Joel Stanley <joel@jms.id.au>");
MODULE_LICENSE("GPL");
// SPDX-License-Identifier: GPL-2.0+
/* /*
* "RTT as Real Time Clock" driver for AT91SAM9 SoC family * "RTT as Real Time Clock" driver for AT91SAM9 SoC family
* *
* (C) 2007 Michel Benoit * (C) 2007 Michel Benoit
* *
* Based on rtc-at91rm9200.c by Rick Bronson * Based on rtc-at91rm9200.c by Rick Bronson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -47,21 +43,21 @@ ...@@ -47,21 +43,21 @@
* registers available, likewise usable for more than "RTC" support. * registers available, likewise usable for more than "RTC" support.
*/ */
#define AT91_RTT_MR 0x00 /* Real-time Mode Register */ #define AT91_RTT_MR 0x00 /* Real-time Mode Register */
#define AT91_RTT_RTPRES (0xffff << 0) /* Real-time Timer Prescaler Value */ #define AT91_RTT_RTPRES (0xffff << 0) /* Timer Prescaler Value */
#define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */ #define AT91_RTT_ALMIEN BIT(16) /* Alarm Interrupt Enable */
#define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */ #define AT91_RTT_RTTINCIEN BIT(17) /* Increment Interrupt Enable */
#define AT91_RTT_RTTRST (1 << 18) /* Real Time Timer Restart */ #define AT91_RTT_RTTRST BIT(18) /* Timer Restart */
#define AT91_RTT_AR 0x04 /* Real-time Alarm Register */ #define AT91_RTT_AR 0x04 /* Real-time Alarm Register */
#define AT91_RTT_ALMV (0xffffffff) /* Alarm Value */ #define AT91_RTT_ALMV (0xffffffff) /* Alarm Value */
#define AT91_RTT_VR 0x08 /* Real-time Value Register */ #define AT91_RTT_VR 0x08 /* Real-time Value Register */
#define AT91_RTT_CRTV (0xffffffff) /* Current Real-time Value */ #define AT91_RTT_CRTV (0xffffffff) /* Current Real-time Value */
#define AT91_RTT_SR 0x0c /* Real-time Status Register */ #define AT91_RTT_SR 0x0c /* Real-time Status Register */
#define AT91_RTT_ALMS (1 << 0) /* Real-time Alarm Status */ #define AT91_RTT_ALMS BIT(0) /* Alarm Status */
#define AT91_RTT_RTTINC (1 << 1) /* Real-time Timer Increment */ #define AT91_RTT_RTTINC BIT(1) /* Timer Increment */
/* /*
* We store ALARM_DISABLED in ALMV to record that no alarm is set. * We store ALARM_DISABLED in ALMV to record that no alarm is set.
...@@ -69,14 +65,13 @@ ...@@ -69,14 +65,13 @@
*/ */
#define ALARM_DISABLED ((u32)~0) #define ALARM_DISABLED ((u32)~0)
struct sam9_rtc { struct sam9_rtc {
void __iomem *rtt; void __iomem *rtt;
struct rtc_device *rtcdev; struct rtc_device *rtcdev;
u32 imr; u32 imr;
struct regmap *gpbr; struct regmap *gpbr;
unsigned int gpbr_offset; unsigned int gpbr_offset;
int irq; int irq;
struct clk *sclk; struct clk *sclk;
bool suspended; bool suspended;
unsigned long events; unsigned long events;
...@@ -122,7 +117,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm) ...@@ -122,7 +117,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
if (secs != secs2) if (secs != secs2)
secs = rtt_readl(rtc, VR); secs = rtt_readl(rtc, VR);
rtc_time_to_tm(offset + secs, tm); rtc_time64_to_tm(offset + secs, tm);
dev_dbg(dev, "%s: %ptR\n", __func__, tm); dev_dbg(dev, "%s: %ptR\n", __func__, tm);
...@@ -135,15 +130,12 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm) ...@@ -135,15 +130,12 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
{ {
struct sam9_rtc *rtc = dev_get_drvdata(dev); struct sam9_rtc *rtc = dev_get_drvdata(dev);
int err;
u32 offset, alarm, mr; u32 offset, alarm, mr;
unsigned long secs; unsigned long secs;
dev_dbg(dev, "%s: %ptR\n", __func__, tm); dev_dbg(dev, "%s: %ptR\n", __func__, tm);
err = rtc_tm_to_time(tm, &secs); secs = rtc_tm_to_time64(tm);
if (err != 0)
return err;
mr = rtt_readl(rtc, MR); mr = rtt_readl(rtc, MR);
...@@ -193,7 +185,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -193,7 +185,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
memset(alrm, 0, sizeof(*alrm)); memset(alrm, 0, sizeof(*alrm));
if (alarm != ALARM_DISABLED && offset != 0) { if (alarm != ALARM_DISABLED && offset != 0) {
rtc_time_to_tm(offset + alarm, tm); rtc_time64_to_tm(offset + alarm, tm);
dev_dbg(dev, "%s: %ptR\n", __func__, tm); dev_dbg(dev, "%s: %ptR\n", __func__, tm);
...@@ -211,11 +203,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -211,11 +203,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
unsigned long secs; unsigned long secs;
u32 offset; u32 offset;
u32 mr; u32 mr;
int err;
err = rtc_tm_to_time(tm, &secs); secs = rtc_tm_to_time64(tm);
if (err != 0)
return err;
offset = gpbr_readl(rtc); offset = gpbr_readl(rtc);
if (offset == 0) { if (offset == 0) {
...@@ -263,7 +252,7 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq) ...@@ -263,7 +252,7 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
u32 mr = rtt_readl(rtc, MR); u32 mr = rtt_readl(rtc, MR);
seq_printf(seq, "update_IRQ\t: %s\n", seq_printf(seq, "update_IRQ\t: %s\n",
(mr & AT91_RTT_RTTINCIEN) ? "yes" : "no"); (mr & AT91_RTT_RTTINCIEN) ? "yes" : "no");
return 0; return 0;
} }
...@@ -299,7 +288,7 @@ static void at91_rtc_flush_events(struct sam9_rtc *rtc) ...@@ -299,7 +288,7 @@ static void at91_rtc_flush_events(struct sam9_rtc *rtc)
rtc->events = 0; rtc->events = 0;
pr_debug("%s: num=%ld, events=0x%02lx\n", __func__, pr_debug("%s: num=%ld, events=0x%02lx\n", __func__,
rtc->events >> 8, rtc->events & 0x000000FF); rtc->events >> 8, rtc->events & 0x000000FF);
} }
/* /*
...@@ -340,13 +329,6 @@ static const struct rtc_class_ops at91_rtc_ops = { ...@@ -340,13 +329,6 @@ static const struct rtc_class_ops at91_rtc_ops = {
.alarm_irq_enable = at91_rtc_alarm_irq_enable, .alarm_irq_enable = at91_rtc_alarm_irq_enable,
}; };
static const struct regmap_config gpbr_regmap_config = {
.name = "gpbr",
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
};
/* /*
* Initialize and install RTC driver * Initialize and install RTC driver
*/ */
...@@ -357,6 +339,7 @@ static int at91_rtc_probe(struct platform_device *pdev) ...@@ -357,6 +339,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
int ret, irq; int ret, irq;
u32 mr; u32 mr;
unsigned int sclk_rate; unsigned int sclk_rate;
struct of_phandle_args args;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
...@@ -382,34 +365,14 @@ static int at91_rtc_probe(struct platform_device *pdev) ...@@ -382,34 +365,14 @@ static int at91_rtc_probe(struct platform_device *pdev)
if (IS_ERR(rtc->rtt)) if (IS_ERR(rtc->rtt))
return PTR_ERR(rtc->rtt); return PTR_ERR(rtc->rtt);
if (!pdev->dev.of_node) { ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
/* "atmel,rtt-rtc-time-reg", 1, 0,
* TODO: Remove this code chunk when removing non DT board &args);
* support. Remember to remove the gpbr_regmap_config if (ret)
* variable too. return ret;
*/
void __iomem *gpbr;
r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
gpbr = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(gpbr))
return PTR_ERR(gpbr);
rtc->gpbr = regmap_init_mmio(NULL, gpbr,
&gpbr_regmap_config);
} else {
struct of_phandle_args args;
ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
"atmel,rtt-rtc-time-reg", 1, 0,
&args);
if (ret)
return ret;
rtc->gpbr = syscon_node_to_regmap(args.np);
rtc->gpbr_offset = args.args[0];
}
rtc->gpbr = syscon_node_to_regmap(args.np);
rtc->gpbr_offset = args.args[0];
if (IS_ERR(rtc->gpbr)) { if (IS_ERR(rtc->gpbr)) {
dev_err(&pdev->dev, "failed to retrieve gpbr regmap, aborting.\n"); dev_err(&pdev->dev, "failed to retrieve gpbr regmap, aborting.\n");
return -ENOMEM; return -ENOMEM;
...@@ -444,13 +407,15 @@ static int at91_rtc_probe(struct platform_device *pdev) ...@@ -444,13 +407,15 @@ static int at91_rtc_probe(struct platform_device *pdev)
mr &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); mr &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
rtt_writel(rtc, MR, mr); rtt_writel(rtc, MR, mr);
rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name, rtc->rtcdev = devm_rtc_allocate_device(&pdev->dev);
&at91_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtcdev)) { if (IS_ERR(rtc->rtcdev)) {
ret = PTR_ERR(rtc->rtcdev); ret = PTR_ERR(rtc->rtcdev);
goto err_clk; goto err_clk;
} }
rtc->rtcdev->ops = &at91_rtc_ops;
rtc->rtcdev->range_max = U32_MAX;
/* register irq handler after we know what name we'll use */ /* register irq handler after we know what name we'll use */
ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt, ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt,
IRQF_SHARED | IRQF_COND_SUSPEND, IRQF_SHARED | IRQF_COND_SUSPEND,
...@@ -468,9 +433,9 @@ static int at91_rtc_probe(struct platform_device *pdev) ...@@ -468,9 +433,9 @@ static int at91_rtc_probe(struct platform_device *pdev)
if (gpbr_readl(rtc) == 0) if (gpbr_readl(rtc) == 0)
dev_warn(&pdev->dev, "%s: SET TIME!\n", dev_warn(&pdev->dev, "%s: SET TIME!\n",
dev_name(&rtc->rtcdev->dev)); dev_name(&rtc->rtcdev->dev));
return 0; return rtc_register_device(rtc->rtcdev);
err_clk: err_clk:
clk_disable_unprepare(rtc->sclk); clk_disable_unprepare(rtc->sclk);
...@@ -528,8 +493,9 @@ static int at91_rtc_suspend(struct device *dev) ...@@ -528,8 +493,9 @@ static int at91_rtc_suspend(struct device *dev)
/* don't let RTTINC cause wakeups */ /* don't let RTTINC cause wakeups */
if (mr & AT91_RTT_RTTINCIEN) if (mr & AT91_RTT_RTTINCIEN)
rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN); rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN);
} else } else {
rtt_writel(rtc, MR, mr & ~rtc->imr); rtt_writel(rtc, MR, mr & ~rtc->imr);
}
} }
return 0; return 0;
...@@ -561,13 +527,11 @@ static int at91_rtc_resume(struct device *dev) ...@@ -561,13 +527,11 @@ static int at91_rtc_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume);
#ifdef CONFIG_OF
static const struct of_device_id at91_rtc_dt_ids[] = { static const struct of_device_id at91_rtc_dt_ids[] = {
{ .compatible = "atmel,at91sam9260-rtt" }, { .compatible = "atmel,at91sam9260-rtt" },
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids); MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids);
#endif
static struct platform_driver at91_rtc_driver = { static struct platform_driver at91_rtc_driver = {
.probe = at91_rtc_probe, .probe = at91_rtc_probe,
......
...@@ -132,7 +132,7 @@ static int brcmstb_waketmr_gettime(struct device *dev, ...@@ -132,7 +132,7 @@ static int brcmstb_waketmr_gettime(struct device *dev,
wktmr_read(timer, &now); wktmr_read(timer, &now);
rtc_time_to_tm(now.sec, tm); rtc_time64_to_tm(now.sec, tm);
return 0; return 0;
} }
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2007-2009 ST-Ericsson AB * Copyright (C) 2007-2009 ST-Ericsson AB
* License terms: GNU General Public License (GPL) version 2
* Real Time Clock interface for ST-Ericsson AB COH 901 331 RTC. * Real Time Clock interface for ST-Ericsson AB COH 901 331 RTC.
* Author: Linus Walleij <linus.walleij@stericsson.com> * Author: Linus Walleij <linus.walleij@stericsson.com>
* Based on rtc-pl031.c by Deepak Saxena <dsaxena@plexity.net> * Based on rtc-pl031.c by Deepak Saxena <dsaxena@plexity.net>
...@@ -80,21 +80,22 @@ static int coh901331_read_time(struct device *dev, struct rtc_time *tm) ...@@ -80,21 +80,22 @@ static int coh901331_read_time(struct device *dev, struct rtc_time *tm)
clk_enable(rtap->clk); clk_enable(rtap->clk);
/* Check if the time is valid */ /* Check if the time is valid */
if (readl(rtap->virtbase + COH901331_VALID)) { if (!readl(rtap->virtbase + COH901331_VALID)) {
rtc_time_to_tm(readl(rtap->virtbase + COH901331_CUR_TIME), tm);
clk_disable(rtap->clk); clk_disable(rtap->clk);
return 0; return -EINVAL;
} }
rtc_time64_to_tm(readl(rtap->virtbase + COH901331_CUR_TIME), tm);
clk_disable(rtap->clk); clk_disable(rtap->clk);
return -EINVAL; return 0;
} }
static int coh901331_set_mmss(struct device *dev, unsigned long secs) static int coh901331_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct coh901331_port *rtap = dev_get_drvdata(dev); struct coh901331_port *rtap = dev_get_drvdata(dev);
clk_enable(rtap->clk); clk_enable(rtap->clk);
writel(secs, rtap->virtbase + COH901331_SET_TIME); writel(rtc_tm_to_time64(tm), rtap->virtbase + COH901331_SET_TIME);
clk_disable(rtap->clk); clk_disable(rtap->clk);
return 0; return 0;
...@@ -105,7 +106,7 @@ static int coh901331_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -105,7 +106,7 @@ static int coh901331_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
struct coh901331_port *rtap = dev_get_drvdata(dev); struct coh901331_port *rtap = dev_get_drvdata(dev);
clk_enable(rtap->clk); clk_enable(rtap->clk);
rtc_time_to_tm(readl(rtap->virtbase + COH901331_ALARM), &alarm->time); rtc_time64_to_tm(readl(rtap->virtbase + COH901331_ALARM), &alarm->time);
alarm->pending = readl(rtap->virtbase + COH901331_IRQ_EVENT) & 1U; alarm->pending = readl(rtap->virtbase + COH901331_IRQ_EVENT) & 1U;
alarm->enabled = readl(rtap->virtbase + COH901331_IRQ_MASK) & 1U; alarm->enabled = readl(rtap->virtbase + COH901331_IRQ_MASK) & 1U;
clk_disable(rtap->clk); clk_disable(rtap->clk);
...@@ -116,9 +117,8 @@ static int coh901331_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -116,9 +117,8 @@ static int coh901331_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
static int coh901331_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int coh901331_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{ {
struct coh901331_port *rtap = dev_get_drvdata(dev); struct coh901331_port *rtap = dev_get_drvdata(dev);
unsigned long time; unsigned long time = rtc_tm_to_time64(&alarm->time);
rtc_tm_to_time(&alarm->time, &time);
clk_enable(rtap->clk); clk_enable(rtap->clk);
writel(time, rtap->virtbase + COH901331_ALARM); writel(time, rtap->virtbase + COH901331_ALARM);
writel(alarm->enabled, rtap->virtbase + COH901331_IRQ_MASK); writel(alarm->enabled, rtap->virtbase + COH901331_IRQ_MASK);
...@@ -143,7 +143,7 @@ static int coh901331_alarm_irq_enable(struct device *dev, unsigned int enabled) ...@@ -143,7 +143,7 @@ static int coh901331_alarm_irq_enable(struct device *dev, unsigned int enabled)
static const struct rtc_class_ops coh901331_ops = { static const struct rtc_class_ops coh901331_ops = {
.read_time = coh901331_read_time, .read_time = coh901331_read_time,
.set_mmss = coh901331_set_mmss, .set_time = coh901331_set_time,
.read_alarm = coh901331_read_alarm, .read_alarm = coh901331_read_alarm,
.set_alarm = coh901331_set_alarm, .set_alarm = coh901331_set_alarm,
.alarm_irq_enable = coh901331_alarm_irq_enable, .alarm_irq_enable = coh901331_alarm_irq_enable,
...@@ -188,6 +188,13 @@ static int __init coh901331_probe(struct platform_device *pdev) ...@@ -188,6 +188,13 @@ static int __init coh901331_probe(struct platform_device *pdev)
return ret; return ret;
} }
rtap->rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtap->rtc))
return PTR_ERR(rtap->rtc);
rtap->rtc->ops = &coh901331_ops;
rtap->rtc->range_max = U32_MAX;
/* We enable/disable the clock only to assure it works */ /* We enable/disable the clock only to assure it works */
ret = clk_prepare_enable(rtap->clk); ret = clk_prepare_enable(rtap->clk);
if (ret) { if (ret) {
...@@ -197,12 +204,10 @@ static int __init coh901331_probe(struct platform_device *pdev) ...@@ -197,12 +204,10 @@ static int __init coh901331_probe(struct platform_device *pdev)
clk_disable(rtap->clk); clk_disable(rtap->clk);
platform_set_drvdata(pdev, rtap); platform_set_drvdata(pdev, rtap);
rtap->rtc = devm_rtc_device_register(&pdev->dev, "coh901331",
&coh901331_ops, THIS_MODULE); ret = rtc_register_device(rtap->rtc);
if (IS_ERR(rtap->rtc)) { if (ret)
ret = PTR_ERR(rtap->rtc);
goto out_no_rtc; goto out_no_rtc;
}
return 0; return 0;
......
/* rtc-da9063.c - Real time clock device driver for DA9063 // SPDX-License-Identifier: GPL-2.0+
/*
* Real time clock device driver for DA9063
* Copyright (C) 2013-2015 Dialog Semiconductor Ltd. * Copyright (C) 2013-2015 Dialog Semiconductor Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/ */
#include <linux/delay.h> #include <linux/delay.h>
...@@ -247,8 +239,8 @@ static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -247,8 +239,8 @@ static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm)
da9063_data_to_tm(data, tm, rtc); da9063_data_to_tm(data, tm, rtc);
rtc_tm_to_time(tm, &tm_secs); tm_secs = rtc_tm_to_time64(tm);
rtc_tm_to_time(&rtc->alarm_time, &al_secs); al_secs = rtc_tm_to_time64(&rtc->alarm_time);
/* handle the rtc synchronisation delay */ /* handle the rtc synchronisation delay */
if (rtc->rtc_sync == true && al_secs - tm_secs == 1) if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
...@@ -472,11 +464,14 @@ static int da9063_rtc_probe(struct platform_device *pdev) ...@@ -472,11 +464,14 @@ static int da9063_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, DA9063_DRVNAME_RTC, rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
&da9063_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtc_dev)) if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev); return PTR_ERR(rtc->rtc_dev);
rtc->rtc_dev->ops = &da9063_rtc_ops;
rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000;
rtc->rtc_dev->range_max = RTC_TIMESTAMP_END_2063;
da9063_data_to_tm(data, &rtc->alarm_time, rtc); da9063_data_to_tm(data, &rtc->alarm_time, rtc);
rtc->rtc_sync = false; rtc->rtc_sync = false;
...@@ -496,7 +491,7 @@ static int da9063_rtc_probe(struct platform_device *pdev) ...@@ -496,7 +491,7 @@ static int da9063_rtc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n", dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n",
irq_alarm, ret); irq_alarm, ret);
return ret; return rtc_register_device(rtc->rtc_dev);
} }
static struct platform_driver da9063_rtc_driver = { static struct platform_driver da9063_rtc_driver = {
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Real Time Clock driver for Conexant Digicolor * Real Time Clock driver for Conexant Digicolor
* *
* Copyright (C) 2015 Paradox Innovation Ltd. * Copyright (C) 2015 Paradox Innovation Ltd.
* *
* Author: Baruch Siach <baruch@tkos.co.il> * Author: Baruch Siach <baruch@tkos.co.il>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/ */
#include <linux/io.h> #include <linux/io.h>
...@@ -106,11 +102,11 @@ static int dc_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -106,11 +102,11 @@ static int dc_rtc_read_time(struct device *dev, struct rtc_time *tm)
return 0; return 0;
} }
static int dc_rtc_set_mmss(struct device *dev, unsigned long secs) static int dc_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct dc_rtc *rtc = dev_get_drvdata(dev); struct dc_rtc *rtc = dev_get_drvdata(dev);
return dc_rtc_write(rtc, secs); return dc_rtc_write(rtc, rtc_tm_to_time64(tm));
} }
static int dc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int dc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
...@@ -161,7 +157,7 @@ static int dc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) ...@@ -161,7 +157,7 @@ static int dc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
static const struct rtc_class_ops dc_rtc_ops = { static const struct rtc_class_ops dc_rtc_ops = {
.read_time = dc_rtc_read_time, .read_time = dc_rtc_read_time,
.set_mmss = dc_rtc_set_mmss, .set_time = dc_rtc_set_time,
.read_alarm = dc_rtc_read_alarm, .read_alarm = dc_rtc_read_alarm,
.set_alarm = dc_rtc_set_alarm, .set_alarm = dc_rtc_set_alarm,
.alarm_irq_enable = dc_rtc_alarm_irq_enable, .alarm_irq_enable = dc_rtc_alarm_irq_enable,
...@@ -192,6 +188,10 @@ static int __init dc_rtc_probe(struct platform_device *pdev) ...@@ -192,6 +188,10 @@ static int __init dc_rtc_probe(struct platform_device *pdev)
if (IS_ERR(rtc->regs)) if (IS_ERR(rtc->regs))
return PTR_ERR(rtc->regs); return PTR_ERR(rtc->regs);
rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) if (irq < 0)
return irq; return irq;
...@@ -200,12 +200,11 @@ static int __init dc_rtc_probe(struct platform_device *pdev) ...@@ -200,12 +200,11 @@ static int __init dc_rtc_probe(struct platform_device *pdev)
return ret; return ret;
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, pdev->name,
&dc_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
return 0; rtc->rtc_dev->ops = &dc_rtc_ops;
rtc->rtc_dev->range_max = U32_MAX;
return rtc_register_device(rtc->rtc_dev);
} }
static const struct of_device_id dc_dt_ids[] = { static const struct of_device_id dc_dt_ids[] = {
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* rtc-dm355evm.c - access battery-backed counter in MSP430 firmware * rtc-dm355evm.c - access battery-backed counter in MSP430 firmware
* *
* Copyright (c) 2008 by David Brownell * Copyright (c) 2008 by David Brownell
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -78,7 +74,7 @@ static int dm355evm_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -78,7 +74,7 @@ static int dm355evm_rtc_read_time(struct device *dev, struct rtc_time *tm)
dev_dbg(dev, "read timestamp %08x\n", time.value); dev_dbg(dev, "read timestamp %08x\n", time.value);
rtc_time_to_tm(le32_to_cpu(time.value), tm); rtc_time64_to_tm(le32_to_cpu(time.value), tm);
return 0; return 0;
} }
...@@ -88,7 +84,7 @@ static int dm355evm_rtc_set_time(struct device *dev, struct rtc_time *tm) ...@@ -88,7 +84,7 @@ static int dm355evm_rtc_set_time(struct device *dev, struct rtc_time *tm)
unsigned long value; unsigned long value;
int status; int status;
rtc_tm_to_time(tm, &value); value = rtc_tm_to_time64(tm);
time.value = cpu_to_le32(value); time.value = cpu_to_le32(value);
dev_dbg(dev, "write timestamp %08x\n", time.value); dev_dbg(dev, "write timestamp %08x\n", time.value);
...@@ -127,16 +123,16 @@ static int dm355evm_rtc_probe(struct platform_device *pdev) ...@@ -127,16 +123,16 @@ static int dm355evm_rtc_probe(struct platform_device *pdev)
{ {
struct rtc_device *rtc; struct rtc_device *rtc;
rtc = devm_rtc_device_register(&pdev->dev, pdev->name, rtc = devm_rtc_allocate_device(&pdev->dev);
&dm355evm_rtc_ops, THIS_MODULE); if (IS_ERR(rtc))
if (IS_ERR(rtc)) {
dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
PTR_ERR(rtc));
return PTR_ERR(rtc); return PTR_ERR(rtc);
}
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
return 0; rtc->ops = &dm355evm_rtc_ops;
rtc->range_max = U32_MAX;
return rtc_register_device(rtc);
} }
/* /*
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* An rtc/i2c driver for the Dallas DS1672 * An rtc/i2c driver for the Dallas DS1672
* Copyright 2005-06 Tower Technologies * Copyright 2005-06 Tower Technologies
* *
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/i2c.h> #include <linux/i2c.h>
...@@ -21,17 +18,16 @@ ...@@ -21,17 +18,16 @@
#define DS1672_REG_CONTROL_EOSC 0x80 #define DS1672_REG_CONTROL_EOSC 0x80
static struct i2c_driver ds1672_driver;
/* /*
* In the routines that deal directly with the ds1672 hardware, we use * In the routines that deal directly with the ds1672 hardware, we use
* rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch
* Epoch is initialized as 2000. Time is set to UTC. * Time is set to UTC.
*/ */
static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) static int ds1672_read_time(struct device *dev, struct rtc_time *tm)
{ {
struct i2c_client *client = to_i2c_client(dev);
unsigned long time; unsigned long time;
unsigned char addr = DS1672_REG_CNT_BASE; unsigned char addr = DS1672_REG_CONTROL;
unsigned char buf[4]; unsigned char buf[4];
struct i2c_msg msgs[] = { struct i2c_msg msgs[] = {
...@@ -43,11 +39,25 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) ...@@ -43,11 +39,25 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
{/* read date */ {/* read date */
.addr = client->addr, .addr = client->addr,
.flags = I2C_M_RD, .flags = I2C_M_RD,
.len = 4, .len = 1,
.buf = buf .buf = buf
}, },
}; };
/* read control register */
if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
dev_warn(&client->dev, "Unable to read the control register\n");
return -EIO;
}
if (buf[0] & DS1672_REG_CONTROL_EOSC) {
dev_warn(&client->dev, "Oscillator not enabled. Set time to enable.\n");
return -EINVAL;
}
addr = DS1672_REG_CNT_BASE;
msgs[1].len = 4;
/* read date registers */ /* read date registers */
if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
dev_err(&client->dev, "%s: read error\n", __func__); dev_err(&client->dev, "%s: read error\n", __func__);
...@@ -61,20 +71,19 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) ...@@ -61,20 +71,19 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
time = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | time = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
(buf[1] << 8) | buf[0]; (buf[1] << 8) | buf[0];
rtc_time_to_tm(time, tm); rtc_time64_to_tm(time, tm);
dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " dev_dbg(&client->dev, "%s: tm is %ptR\n", __func__, tm);
"mday=%d, mon=%d, year=%d, wday=%d\n",
__func__, tm->tm_sec, tm->tm_min, tm->tm_hour,
tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
return 0; return 0;
} }
static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs) static int ds1672_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct i2c_client *client = to_i2c_client(dev);
int xfer; int xfer;
unsigned char buf[6]; unsigned char buf[6];
unsigned long secs = rtc_tm_to_time64(tm);
buf[0] = DS1672_REG_CNT_BASE; buf[0] = DS1672_REG_CNT_BASE;
buf[1] = secs & 0x000000FF; buf[1] = secs & 0x000000FF;
...@@ -92,71 +101,15 @@ static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs) ...@@ -92,71 +101,15 @@ static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs)
return 0; return 0;
} }
static int ds1672_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
return ds1672_get_datetime(to_i2c_client(dev), tm);
}
static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs)
{
return ds1672_set_mmss(to_i2c_client(dev), secs);
}
static int ds1672_get_control(struct i2c_client *client, u8 *status)
{
unsigned char addr = DS1672_REG_CONTROL;
struct i2c_msg msgs[] = {
{/* setup read ptr */
.addr = client->addr,
.len = 1,
.buf = &addr
},
{/* read control */
.addr = client->addr,
.flags = I2C_M_RD,
.len = 1,
.buf = status
},
};
/* read control register */
if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
dev_err(&client->dev, "%s: read error\n", __func__);
return -EIO;
}
return 0;
}
/* following are the sysfs callback functions */
static ssize_t show_control(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
u8 control;
int err;
err = ds1672_get_control(client, &control);
if (err)
return err;
return sprintf(buf, "%s\n", (control & DS1672_REG_CONTROL_EOSC)
? "disabled" : "enabled");
}
static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);
static const struct rtc_class_ops ds1672_rtc_ops = { static const struct rtc_class_ops ds1672_rtc_ops = {
.read_time = ds1672_rtc_read_time, .read_time = ds1672_read_time,
.set_mmss = ds1672_rtc_set_mmss, .set_time = ds1672_set_time,
}; };
static int ds1672_probe(struct i2c_client *client, static int ds1672_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
int err = 0; int err = 0;
u8 control;
struct rtc_device *rtc; struct rtc_device *rtc;
dev_dbg(&client->dev, "%s\n", __func__); dev_dbg(&client->dev, "%s\n", __func__);
...@@ -164,29 +117,21 @@ static int ds1672_probe(struct i2c_client *client, ...@@ -164,29 +117,21 @@ static int ds1672_probe(struct i2c_client *client,
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV; return -ENODEV;
rtc = devm_rtc_device_register(&client->dev, ds1672_driver.driver.name, rtc = devm_rtc_allocate_device(&client->dev);
&ds1672_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) if (IS_ERR(rtc))
return PTR_ERR(rtc); return PTR_ERR(rtc);
i2c_set_clientdata(client, rtc); rtc->ops = &ds1672_rtc_ops;
rtc->range_max = U32_MAX;
/* read control register */ err = rtc_register_device(rtc);
err = ds1672_get_control(client, &control); if (err)
if (err) { return err;
dev_warn(&client->dev, "Unable to read the control register\n");
}
if (control & DS1672_REG_CONTROL_EOSC) if (IS_ERR(rtc))
dev_warn(&client->dev, "Oscillator not enabled. " return PTR_ERR(rtc);
"Set time to enable.\n");
/* Register sysfs hooks */ i2c_set_clientdata(client, rtc);
err = device_create_file(&client->dev, &dev_attr_control);
if (err)
dev_err(&client->dev, "Unable to create sysfs entry: %s\n",
dev_attr_control.attr.name);
return 0; return 0;
} }
......
This diff is collapsed.
/* // SPDX-License-Identifier: GPL-2.0
* Copyright (C) 2012 Sven Schnelle <svens@stackframe.org> // Copyright (C) 2012 Sven Schnelle <svens@stackframe.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -29,14 +23,6 @@ ...@@ -29,14 +23,6 @@
#define DS2404_COPY_SCRATCHPAD_CMD 0x55 #define DS2404_COPY_SCRATCHPAD_CMD 0x55
#define DS2404_READ_MEMORY_CMD 0xf0 #define DS2404_READ_MEMORY_CMD 0xf0
struct ds2404;
struct ds2404_chip_ops {
int (*map_io)(struct ds2404 *chip, struct platform_device *pdev,
struct ds2404_platform_data *pdata);
void (*unmap_io)(struct ds2404 *chip);
};
#define DS2404_RST 0 #define DS2404_RST 0
#define DS2404_CLK 1 #define DS2404_CLK 1
#define DS2404_DQ 2 #define DS2404_DQ 2
...@@ -48,7 +34,6 @@ struct ds2404_gpio { ...@@ -48,7 +34,6 @@ struct ds2404_gpio {
struct ds2404 { struct ds2404 {
struct ds2404_gpio *gpio; struct ds2404_gpio *gpio;
const struct ds2404_chip_ops *ops;
struct rtc_device *rtc; struct rtc_device *rtc;
}; };
...@@ -87,7 +72,7 @@ static int ds2404_gpio_map(struct ds2404 *chip, struct platform_device *pdev, ...@@ -87,7 +72,7 @@ static int ds2404_gpio_map(struct ds2404 *chip, struct platform_device *pdev,
return err; return err;
} }
static void ds2404_gpio_unmap(struct ds2404 *chip) static void ds2404_gpio_unmap(void *data)
{ {
int i; int i;
...@@ -95,11 +80,6 @@ static void ds2404_gpio_unmap(struct ds2404 *chip) ...@@ -95,11 +80,6 @@ static void ds2404_gpio_unmap(struct ds2404 *chip)
gpio_free(ds2404_gpio[i].gpio); gpio_free(ds2404_gpio[i].gpio);
} }
static const struct ds2404_chip_ops ds2404_gpio_ops = {
.map_io = ds2404_gpio_map,
.unmap_io = ds2404_gpio_unmap,
};
static void ds2404_reset(struct device *dev) static void ds2404_reset(struct device *dev)
{ {
gpio_set_value(ds2404_gpio[DS2404_RST].gpio, 0); gpio_set_value(ds2404_gpio[DS2404_RST].gpio, 0);
...@@ -206,20 +186,20 @@ static int ds2404_read_time(struct device *dev, struct rtc_time *dt) ...@@ -206,20 +186,20 @@ static int ds2404_read_time(struct device *dev, struct rtc_time *dt)
ds2404_read_memory(dev, 0x203, 4, (u8 *)&time); ds2404_read_memory(dev, 0x203, 4, (u8 *)&time);
time = le32_to_cpu(time); time = le32_to_cpu(time);
rtc_time_to_tm(time, dt); rtc_time64_to_tm(time, dt);
return 0; return 0;
} }
static int ds2404_set_mmss(struct device *dev, unsigned long secs) static int ds2404_set_time(struct device *dev, struct rtc_time *dt)
{ {
u32 time = cpu_to_le32(secs); u32 time = cpu_to_le32(rtc_tm_to_time64(dt));
ds2404_write_memory(dev, 0x203, 4, (u8 *)&time); ds2404_write_memory(dev, 0x203, 4, (u8 *)&time);
return 0; return 0;
} }
static const struct rtc_class_ops ds2404_rtc_ops = { static const struct rtc_class_ops ds2404_rtc_ops = {
.read_time = ds2404_read_time, .read_time = ds2404_read_time,
.set_mmss = ds2404_set_mmss, .set_time = ds2404_set_time,
}; };
static int rtc_probe(struct platform_device *pdev) static int rtc_probe(struct platform_device *pdev)
...@@ -232,11 +212,17 @@ static int rtc_probe(struct platform_device *pdev) ...@@ -232,11 +212,17 @@ static int rtc_probe(struct platform_device *pdev)
if (!chip) if (!chip)
return -ENOMEM; return -ENOMEM;
chip->ops = &ds2404_gpio_ops; chip->rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(chip->rtc))
return PTR_ERR(chip->rtc);
retval = chip->ops->map_io(chip, pdev, pdata); retval = ds2404_gpio_map(chip, pdev, pdata);
if (retval) if (retval)
goto err_chip; return retval;
retval = devm_add_action_or_reset(&pdev->dev, ds2404_gpio_unmap, chip);
if (retval)
return retval;
dev_info(&pdev->dev, "using GPIOs RST:%d, CLK:%d, DQ:%d\n", dev_info(&pdev->dev, "using GPIOs RST:%d, CLK:%d, DQ:%d\n",
chip->gpio[DS2404_RST].gpio, chip->gpio[DS2404_CLK].gpio, chip->gpio[DS2404_RST].gpio, chip->gpio[DS2404_CLK].gpio,
...@@ -244,34 +230,19 @@ static int rtc_probe(struct platform_device *pdev) ...@@ -244,34 +230,19 @@ static int rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip); platform_set_drvdata(pdev, chip);
chip->rtc = devm_rtc_device_register(&pdev->dev, "ds2404", chip->rtc->ops = &ds2404_rtc_ops;
&ds2404_rtc_ops, THIS_MODULE); chip->rtc->range_max = U32_MAX;
if (IS_ERR(chip->rtc)) {
retval = PTR_ERR(chip->rtc);
goto err_io;
}
ds2404_enable_osc(&pdev->dev); retval = rtc_register_device(chip->rtc);
return 0; if (retval)
return retval;
err_io:
chip->ops->unmap_io(chip);
err_chip:
return retval;
}
static int rtc_remove(struct platform_device *dev)
{
struct ds2404 *chip = platform_get_drvdata(dev);
chip->ops->unmap_io(chip);
ds2404_enable_osc(&pdev->dev);
return 0; return 0;
} }
static struct platform_driver rtc_device_driver = { static struct platform_driver rtc_device_driver = {
.probe = rtc_probe, .probe = rtc_probe,
.remove = rtc_remove,
.driver = { .driver = {
.name = "ds2404", .name = "ds2404",
}, },
......
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
# define DS3232_REG_SR_A1F 0x01 # define DS3232_REG_SR_A1F 0x01
#define DS3232_REG_TEMPERATURE 0x11 #define DS3232_REG_TEMPERATURE 0x11
#define DS3232_REG_SRAM_START 0x14
#define DS3232_REG_SRAM_END 0xFF
#define DS3232_REG_SRAM_SIZE 236
struct ds3232 { struct ds3232 {
struct device *dev; struct device *dev;
...@@ -461,11 +465,39 @@ static const struct rtc_class_ops ds3232_rtc_ops = { ...@@ -461,11 +465,39 @@ static const struct rtc_class_ops ds3232_rtc_ops = {
.alarm_irq_enable = ds3232_alarm_irq_enable, .alarm_irq_enable = ds3232_alarm_irq_enable,
}; };
static int ds3232_nvmem_read(void *priv, unsigned int offset, void *val,
size_t bytes)
{
struct regmap *ds3232_regmap = (struct regmap *)priv;
return regmap_bulk_read(ds3232_regmap, DS3232_REG_SRAM_START + offset,
val, bytes);
}
static int ds3232_nvmem_write(void *priv, unsigned int offset, void *val,
size_t bytes)
{
struct regmap *ds3232_regmap = (struct regmap *)priv;
return regmap_bulk_write(ds3232_regmap, DS3232_REG_SRAM_START + offset,
val, bytes);
}
static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq, static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
const char *name) const char *name)
{ {
struct ds3232 *ds3232; struct ds3232 *ds3232;
int ret; int ret;
struct nvmem_config nvmem_cfg = {
.name = "ds3232_sram",
.stride = 1,
.size = DS3232_REG_SRAM_SIZE,
.word_size = 1,
.reg_read = ds3232_nvmem_read,
.reg_write = ds3232_nvmem_write,
.priv = regmap,
.type = NVMEM_TYPE_BATTERY_BACKED
};
ds3232 = devm_kzalloc(dev, sizeof(*ds3232), GFP_KERNEL); ds3232 = devm_kzalloc(dev, sizeof(*ds3232), GFP_KERNEL);
if (!ds3232) if (!ds3232)
...@@ -490,6 +522,10 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq, ...@@ -490,6 +522,10 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
if (IS_ERR(ds3232->rtc)) if (IS_ERR(ds3232->rtc))
return PTR_ERR(ds3232->rtc); return PTR_ERR(ds3232->rtc);
ret = rtc_nvmem_register(ds3232->rtc, &nvmem_cfg);
if(ret)
return ret;
if (ds3232->irq > 0) { if (ds3232->irq > 0) {
ret = devm_request_threaded_irq(dev, ds3232->irq, NULL, ret = devm_request_threaded_irq(dev, ds3232->irq, NULL,
ds3232_irq, ds3232_irq,
...@@ -542,7 +578,7 @@ static int ds3232_i2c_probe(struct i2c_client *client, ...@@ -542,7 +578,7 @@ static int ds3232_i2c_probe(struct i2c_client *client,
static const struct regmap_config config = { static const struct regmap_config config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
.max_register = 0x13, .max_register = DS3232_REG_SRAM_END,
}; };
regmap = devm_regmap_init_i2c(client, &config); regmap = devm_regmap_init_i2c(client, &config);
...@@ -609,7 +645,7 @@ static int ds3234_probe(struct spi_device *spi) ...@@ -609,7 +645,7 @@ static int ds3234_probe(struct spi_device *spi)
static const struct regmap_config config = { static const struct regmap_config config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
.max_register = 0x13, .max_register = DS3232_REG_SRAM_END,
.write_flag_mask = 0x80, .write_flag_mask = 0x80,
}; };
struct regmap *regmap; struct regmap *regmap;
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* A driver for the RTC embedded in the Cirrus Logic EP93XX processors * A driver for the RTC embedded in the Cirrus Logic EP93XX processors
* Copyright (c) 2006 Tower Technologies * Copyright (c) 2006 Tower Technologies
* *
* Author: Alessandro Zummo <a.zummo@towertech.it> * Author: Alessandro Zummo <a.zummo@towertech.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/module.h> #include <linux/module.h>
...@@ -18,27 +15,23 @@ ...@@ -18,27 +15,23 @@
#define EP93XX_RTC_DATA 0x000 #define EP93XX_RTC_DATA 0x000
#define EP93XX_RTC_MATCH 0x004 #define EP93XX_RTC_MATCH 0x004
#define EP93XX_RTC_STATUS 0x008 #define EP93XX_RTC_STATUS 0x008
#define EP93XX_RTC_STATUS_INTR (1<<0) #define EP93XX_RTC_STATUS_INTR BIT(0)
#define EP93XX_RTC_LOAD 0x00C #define EP93XX_RTC_LOAD 0x00C
#define EP93XX_RTC_CONTROL 0x010 #define EP93XX_RTC_CONTROL 0x010
#define EP93XX_RTC_CONTROL_MIE (1<<0) #define EP93XX_RTC_CONTROL_MIE BIT(0)
#define EP93XX_RTC_SWCOMP 0x108 #define EP93XX_RTC_SWCOMP 0x108
#define EP93XX_RTC_SWCOMP_DEL_MASK 0x001f0000 #define EP93XX_RTC_SWCOMP_DEL_MASK 0x001f0000
#define EP93XX_RTC_SWCOMP_DEL_SHIFT 16 #define EP93XX_RTC_SWCOMP_DEL_SHIFT 16
#define EP93XX_RTC_SWCOMP_INT_MASK 0x0000ffff #define EP93XX_RTC_SWCOMP_INT_MASK 0x0000ffff
#define EP93XX_RTC_SWCOMP_INT_SHIFT 0 #define EP93XX_RTC_SWCOMP_INT_SHIFT 0
/*
* struct device dev.platform_data is used to store our private data
* because struct rtc_device does not have a variable to hold it.
*/
struct ep93xx_rtc { struct ep93xx_rtc {
void __iomem *mmio_base; void __iomem *mmio_base;
struct rtc_device *rtc; struct rtc_device *rtc;
}; };
static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
unsigned short *delete) unsigned short *delete)
{ {
struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev);
unsigned long comp; unsigned long comp;
...@@ -63,13 +56,14 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -63,13 +56,14 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA); time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
rtc_time_to_tm(time, tm); rtc_time64_to_tm(time, tm);
return 0; return 0;
} }
static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs) static int ep93xx_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev);
unsigned long secs = rtc_tm_to_time64(tm);
writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD); writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD);
return 0; return 0;
...@@ -89,31 +83,31 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq) ...@@ -89,31 +83,31 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
static const struct rtc_class_ops ep93xx_rtc_ops = { static const struct rtc_class_ops ep93xx_rtc_ops = {
.read_time = ep93xx_rtc_read_time, .read_time = ep93xx_rtc_read_time,
.set_mmss = ep93xx_rtc_set_mmss, .set_time = ep93xx_rtc_set_time,
.proc = ep93xx_rtc_proc, .proc = ep93xx_rtc_proc,
}; };
static ssize_t ep93xx_rtc_show_comp_preload(struct device *dev, static ssize_t comp_preload_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
unsigned short preload; unsigned short preload;
ep93xx_rtc_get_swcomp(dev, &preload, NULL); ep93xx_rtc_get_swcomp(dev->parent, &preload, NULL);
return sprintf(buf, "%d\n", preload); return sprintf(buf, "%d\n", preload);
} }
static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_rtc_show_comp_preload, NULL); static DEVICE_ATTR_RO(comp_preload);
static ssize_t ep93xx_rtc_show_comp_delete(struct device *dev, static ssize_t comp_delete_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
unsigned short delete; unsigned short delete;
ep93xx_rtc_get_swcomp(dev, NULL, &delete); ep93xx_rtc_get_swcomp(dev->parent, NULL, &delete);
return sprintf(buf, "%d\n", delete); return sprintf(buf, "%d\n", delete);
} }
static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_rtc_show_comp_delete, NULL); static DEVICE_ATTR_RO(comp_delete);
static struct attribute *ep93xx_rtc_attrs[] = { static struct attribute *ep93xx_rtc_attrs[] = {
&dev_attr_comp_preload.attr, &dev_attr_comp_preload.attr,
...@@ -140,33 +134,20 @@ static int ep93xx_rtc_probe(struct platform_device *pdev) ...@@ -140,33 +134,20 @@ static int ep93xx_rtc_probe(struct platform_device *pdev)
if (IS_ERR(ep93xx_rtc->mmio_base)) if (IS_ERR(ep93xx_rtc->mmio_base))
return PTR_ERR(ep93xx_rtc->mmio_base); return PTR_ERR(ep93xx_rtc->mmio_base);
pdev->dev.platform_data = ep93xx_rtc;
platform_set_drvdata(pdev, ep93xx_rtc); platform_set_drvdata(pdev, ep93xx_rtc);
ep93xx_rtc->rtc = devm_rtc_device_register(&pdev->dev, ep93xx_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
pdev->name, &ep93xx_rtc_ops, THIS_MODULE); if (IS_ERR(ep93xx_rtc->rtc))
if (IS_ERR(ep93xx_rtc->rtc)) { return PTR_ERR(ep93xx_rtc->rtc);
err = PTR_ERR(ep93xx_rtc->rtc);
goto exit;
}
err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); ep93xx_rtc->rtc->ops = &ep93xx_rtc_ops;
if (err) ep93xx_rtc->rtc->range_max = U32_MAX;
goto exit;
return 0;
exit: err = rtc_add_group(ep93xx_rtc->rtc, &ep93xx_rtc_sysfs_files);
pdev->dev.platform_data = NULL; if (err)
return err; return err;
}
static int ep93xx_rtc_remove(struct platform_device *pdev)
{
sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
pdev->dev.platform_data = NULL;
return 0; return rtc_register_device(ep93xx_rtc->rtc);
} }
static struct platform_driver ep93xx_rtc_driver = { static struct platform_driver ep93xx_rtc_driver = {
...@@ -174,7 +155,6 @@ static struct platform_driver ep93xx_rtc_driver = { ...@@ -174,7 +155,6 @@ static struct platform_driver ep93xx_rtc_driver = {
.name = "ep93xx-rtc", .name = "ep93xx-rtc",
}, },
.probe = ep93xx_rtc_probe, .probe = ep93xx_rtc_probe,
.remove = ep93xx_rtc_remove,
}; };
module_platform_driver(ep93xx_rtc_driver); module_platform_driver(ep93xx_rtc_driver);
......
// SPDX-License-Identifier: GPL-2.0
/* drivers/rtc/rtc-goldfish.c /* drivers/rtc/rtc-goldfish.c
* *
* Copyright (C) 2007 Google, Inc. * Copyright (C) 2007 Google, Inc.
* Copyright (C) 2017 Imagination Technologies Ltd. * Copyright (C) 2017 Imagination Technologies Ltd.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/ */
#include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/io.h>
#define TIMER_TIME_LOW 0x00 /* get low bits of current time */ #define TIMER_TIME_LOW 0x00 /* get low bits of current time */
/* and update TIMER_TIME_HIGH */ /* and update TIMER_TIME_HIGH */
...@@ -56,7 +48,7 @@ static int goldfish_rtc_read_alarm(struct device *dev, ...@@ -56,7 +48,7 @@ static int goldfish_rtc_read_alarm(struct device *dev,
do_div(rtc_alarm, NSEC_PER_SEC); do_div(rtc_alarm, NSEC_PER_SEC);
memset(alrm, 0, sizeof(struct rtc_wkalrm)); memset(alrm, 0, sizeof(struct rtc_wkalrm));
rtc_time_to_tm(rtc_alarm, &alrm->time); rtc_time64_to_tm(rtc_alarm, &alrm->time);
if (readl(base + TIMER_ALARM_STATUS)) if (readl(base + TIMER_ALARM_STATUS))
alrm->enabled = 1; alrm->enabled = 1;
...@@ -70,21 +62,15 @@ static int goldfish_rtc_set_alarm(struct device *dev, ...@@ -70,21 +62,15 @@ static int goldfish_rtc_set_alarm(struct device *dev,
struct rtc_wkalrm *alrm) struct rtc_wkalrm *alrm)
{ {
struct goldfish_rtc *rtcdrv; struct goldfish_rtc *rtcdrv;
unsigned long rtc_alarm;
u64 rtc_alarm64; u64 rtc_alarm64;
u64 rtc_status_reg; u64 rtc_status_reg;
void __iomem *base; void __iomem *base;
int ret = 0;
rtcdrv = dev_get_drvdata(dev); rtcdrv = dev_get_drvdata(dev);
base = rtcdrv->base; base = rtcdrv->base;
if (alrm->enabled) { if (alrm->enabled) {
ret = rtc_tm_to_time(&alrm->time, &rtc_alarm); rtc_alarm64 = rtc_tm_to_time64(&alrm->time) * NSEC_PER_SEC;
if (ret != 0)
return ret;
rtc_alarm64 = rtc_alarm * NSEC_PER_SEC;
writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH); writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH);
writel(rtc_alarm64, base + TIMER_ALARM_LOW); writel(rtc_alarm64, base + TIMER_ALARM_LOW);
} else { } else {
...@@ -98,7 +84,7 @@ static int goldfish_rtc_set_alarm(struct device *dev, ...@@ -98,7 +84,7 @@ static int goldfish_rtc_set_alarm(struct device *dev,
writel(1, base + TIMER_CLEAR_ALARM); writel(1, base + TIMER_CLEAR_ALARM);
} }
return ret; return 0;
} }
static int goldfish_rtc_alarm_irq_enable(struct device *dev, static int goldfish_rtc_alarm_irq_enable(struct device *dev,
...@@ -147,7 +133,7 @@ static int goldfish_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -147,7 +133,7 @@ static int goldfish_rtc_read_time(struct device *dev, struct rtc_time *tm)
do_div(time, NSEC_PER_SEC); do_div(time, NSEC_PER_SEC);
rtc_time_to_tm(time, tm); rtc_time64_to_tm(time, tm);
return 0; return 0;
} }
...@@ -156,21 +142,16 @@ static int goldfish_rtc_set_time(struct device *dev, struct rtc_time *tm) ...@@ -156,21 +142,16 @@ static int goldfish_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct goldfish_rtc *rtcdrv; struct goldfish_rtc *rtcdrv;
void __iomem *base; void __iomem *base;
unsigned long now;
u64 now64; u64 now64;
int ret;
rtcdrv = dev_get_drvdata(dev); rtcdrv = dev_get_drvdata(dev);
base = rtcdrv->base; base = rtcdrv->base;
ret = rtc_tm_to_time(tm, &now); now64 = rtc_tm_to_time64(tm) * NSEC_PER_SEC;
if (ret == 0) { writel((now64 >> 32), base + TIMER_TIME_HIGH);
now64 = now * NSEC_PER_SEC; writel(now64, base + TIMER_TIME_LOW);
writel((now64 >> 32), base + TIMER_TIME_HIGH);
writel(now64, base + TIMER_TIME_LOW);
}
return ret; return 0;
} }
static const struct rtc_class_ops goldfish_rtc_ops = { static const struct rtc_class_ops goldfish_rtc_ops = {
...@@ -205,19 +186,20 @@ static int goldfish_rtc_probe(struct platform_device *pdev) ...@@ -205,19 +186,20 @@ static int goldfish_rtc_probe(struct platform_device *pdev)
if (rtcdrv->irq < 0) if (rtcdrv->irq < 0)
return -ENODEV; return -ENODEV;
rtcdrv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, rtcdrv->rtc = devm_rtc_allocate_device(&pdev->dev);
&goldfish_rtc_ops,
THIS_MODULE);
if (IS_ERR(rtcdrv->rtc)) if (IS_ERR(rtcdrv->rtc))
return PTR_ERR(rtcdrv->rtc); return PTR_ERR(rtcdrv->rtc);
rtcdrv->rtc->ops = &goldfish_rtc_ops;
rtcdrv->rtc->range_max = U64_MAX / NSEC_PER_SEC;
err = devm_request_irq(&pdev->dev, rtcdrv->irq, err = devm_request_irq(&pdev->dev, rtcdrv->irq,
goldfish_rtc_interrupt, goldfish_rtc_interrupt,
0, pdev->name, rtcdrv); 0, pdev->name, rtcdrv);
if (err) if (err)
return err; return err;
return 0; return rtc_register_device(rtcdrv->rtc);
} }
static const struct of_device_id goldfish_rtc_of_match[] = { static const struct of_device_id goldfish_rtc_of_match[] = {
......
...@@ -205,8 +205,7 @@ static int hid_time_parse_report(struct platform_device *pdev, ...@@ -205,8 +205,7 @@ static int hid_time_parse_report(struct platform_device *pdev,
static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm) static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm)
{ {
unsigned long flags; unsigned long flags;
struct hid_time_state *time_state = struct hid_time_state *time_state = dev_get_drvdata(dev);
platform_get_drvdata(to_platform_device(dev));
int ret; int ret;
reinit_completion(&time_state->comp_last_time); reinit_completion(&time_state->comp_last_time);
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright 2010 Orex Computed Radiography * Copyright 2010 Orex Computed Radiography
*/ */
/*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
/* based on rtc-mc13892.c */
/* /*
* This driver uses the 47-bit 32 kHz counter in the Freescale DryIce block * This driver uses the 47-bit 32 kHz counter in the Freescale DryIce block
* to implement a Linux RTC. Times and alarms are truncated to seconds. * to implement a Linux RTC. Times and alarms are truncated to seconds.
...@@ -552,7 +542,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -552,7 +542,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm)
unsigned long now; unsigned long now;
now = readl(imxdi->ioaddr + DTCMR); now = readl(imxdi->ioaddr + DTCMR);
rtc_time_to_tm(now, tm); rtc_time64_to_tm(now, tm);
return 0; return 0;
} }
...@@ -561,7 +551,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -561,7 +551,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm)
* set the seconds portion of dryice time counter and clear the * set the seconds portion of dryice time counter and clear the
* fractional part. * fractional part.
*/ */
static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) static int dryice_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct imxdi_dev *imxdi = dev_get_drvdata(dev); struct imxdi_dev *imxdi = dev_get_drvdata(dev);
u32 dcr, dsr; u32 dcr, dsr;
...@@ -588,7 +578,7 @@ static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) ...@@ -588,7 +578,7 @@ static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs)
if (rc != 0) if (rc != 0)
return rc; return rc;
rc = di_write_wait(imxdi, secs, DTCMR); rc = di_write_wait(imxdi, rtc_tm_to_time64(tm), DTCMR);
if (rc != 0) if (rc != 0)
return rc; return rc;
...@@ -618,7 +608,7 @@ static int dryice_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -618,7 +608,7 @@ static int dryice_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
u32 dcamr; u32 dcamr;
dcamr = readl(imxdi->ioaddr + DCAMR); dcamr = readl(imxdi->ioaddr + DCAMR);
rtc_time_to_tm(dcamr, &alarm->time); rtc_time64_to_tm(dcamr, &alarm->time);
/* alarm is enabled if the interrupt is enabled */ /* alarm is enabled if the interrupt is enabled */
alarm->enabled = (readl(imxdi->ioaddr + DIER) & DIER_CAIE) != 0; alarm->enabled = (readl(imxdi->ioaddr + DIER) & DIER_CAIE) != 0;
...@@ -640,21 +630,10 @@ static int dryice_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -640,21 +630,10 @@ static int dryice_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{ {
struct imxdi_dev *imxdi = dev_get_drvdata(dev); struct imxdi_dev *imxdi = dev_get_drvdata(dev);
unsigned long now;
unsigned long alarm_time;
int rc; int rc;
rc = rtc_tm_to_time(&alarm->time, &alarm_time);
if (rc)
return rc;
/* don't allow setting alarm in the past */
now = readl(imxdi->ioaddr + DTCMR);
if (alarm_time < now)
return -EINVAL;
/* write the new alarm time */ /* write the new alarm time */
rc = di_write_wait(imxdi, (u32)alarm_time, DCAMR); rc = di_write_wait(imxdi, rtc_tm_to_time64(&alarm->time), DCAMR);
if (rc) if (rc)
return rc; return rc;
...@@ -668,7 +647,7 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -668,7 +647,7 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
static const struct rtc_class_ops dryice_rtc_ops = { static const struct rtc_class_ops dryice_rtc_ops = {
.read_time = dryice_rtc_read_time, .read_time = dryice_rtc_read_time,
.set_mmss = dryice_rtc_set_mmss, .set_time = dryice_rtc_set_time,
.alarm_irq_enable = dryice_rtc_alarm_irq_enable, .alarm_irq_enable = dryice_rtc_alarm_irq_enable,
.read_alarm = dryice_rtc_read_alarm, .read_alarm = dryice_rtc_read_alarm,
.set_alarm = dryice_rtc_set_alarm, .set_alarm = dryice_rtc_set_alarm,
...@@ -796,6 +775,10 @@ static int __init dryice_rtc_probe(struct platform_device *pdev) ...@@ -796,6 +775,10 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
mutex_init(&imxdi->write_mutex); mutex_init(&imxdi->write_mutex);
imxdi->rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(imxdi->rtc))
return PTR_ERR(imxdi->rtc);
imxdi->clk = devm_clk_get(&pdev->dev, NULL); imxdi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(imxdi->clk)) if (IS_ERR(imxdi->clk))
return PTR_ERR(imxdi->clk); return PTR_ERR(imxdi->clk);
...@@ -829,12 +812,13 @@ static int __init dryice_rtc_probe(struct platform_device *pdev) ...@@ -829,12 +812,13 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
} }
platform_set_drvdata(pdev, imxdi); platform_set_drvdata(pdev, imxdi);
imxdi->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&dryice_rtc_ops, THIS_MODULE); imxdi->rtc->ops = &dryice_rtc_ops;
if (IS_ERR(imxdi->rtc)) { imxdi->rtc->range_max = U32_MAX;
rc = PTR_ERR(imxdi->rtc);
rc = rtc_register_device(imxdi->rtc);
if (rc)
goto err; goto err;
}
return 0; return 0;
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de> * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
* Copyright (C) 2010, Paul Cercueil <paul@crapouillou.net> * Copyright (C) 2010, Paul Cercueil <paul@crapouillou.net>
* JZ4740 SoC RTC driver * JZ4740 SoC RTC driver
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -20,6 +11,7 @@ ...@@ -20,6 +11,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -156,6 +148,9 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time) ...@@ -156,6 +148,9 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time)
uint32_t secs, secs2; uint32_t secs, secs2;
int timeout = 5; int timeout = 5;
if (jz4740_rtc_reg_read(rtc, JZ_REG_RTC_SCRATCHPAD) != 0x12345678)
return -EINVAL;
/* If the seconds register is read while it is updated, it can contain a /* If the seconds register is read while it is updated, it can contain a
* bogus value. This can be avoided by making sure that two consecutive * bogus value. This can be avoided by making sure that two consecutive
* reads have the same value. * reads have the same value.
...@@ -171,16 +166,21 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time) ...@@ -171,16 +166,21 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time)
if (timeout == 0) if (timeout == 0)
return -EIO; return -EIO;
rtc_time_to_tm(secs, time); rtc_time64_to_tm(secs, time);
return 0; return 0;
} }
static int jz4740_rtc_set_mmss(struct device *dev, unsigned long secs) static int jz4740_rtc_set_time(struct device *dev, struct rtc_time *time)
{ {
struct jz4740_rtc *rtc = dev_get_drvdata(dev); struct jz4740_rtc *rtc = dev_get_drvdata(dev);
int ret;
return jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC, secs); ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC, rtc_tm_to_time64(time));
if (ret)
return ret;
return jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SCRATCHPAD, 0x12345678);
} }
static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
...@@ -196,18 +196,16 @@ static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -196,18 +196,16 @@ static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE); alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE);
alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF); alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF);
rtc_time_to_tm(secs, &alrm->time); rtc_time64_to_tm(secs, &alrm->time);
return rtc_valid_tm(&alrm->time); return 0;
} }
static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{ {
int ret; int ret;
struct jz4740_rtc *rtc = dev_get_drvdata(dev); struct jz4740_rtc *rtc = dev_get_drvdata(dev);
unsigned long secs; uint32_t secs = lower_32_bits(rtc_tm_to_time64(&alrm->time));
rtc_tm_to_time(&alrm->time, &secs);
ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC_ALARM, secs); ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC_ALARM, secs);
if (!ret) if (!ret)
...@@ -225,7 +223,7 @@ static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) ...@@ -225,7 +223,7 @@ static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
static const struct rtc_class_ops jz4740_rtc_ops = { static const struct rtc_class_ops jz4740_rtc_ops = {
.read_time = jz4740_rtc_read_time, .read_time = jz4740_rtc_read_time,
.set_mmss = jz4740_rtc_set_mmss, .set_time = jz4740_rtc_set_time,
.read_alarm = jz4740_rtc_read_alarm, .read_alarm = jz4740_rtc_read_alarm,
.set_alarm = jz4740_rtc_set_alarm, .set_alarm = jz4740_rtc_set_alarm,
.alarm_irq_enable = jz4740_rtc_alarm_irq_enable, .alarm_irq_enable = jz4740_rtc_alarm_irq_enable,
...@@ -309,7 +307,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev) ...@@ -309,7 +307,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
{ {
int ret; int ret;
struct jz4740_rtc *rtc; struct jz4740_rtc *rtc;
uint32_t scratchpad;
struct resource *mem; struct resource *mem;
const struct platform_device_id *id = platform_get_device_id(pdev); const struct platform_device_id *id = platform_get_device_id(pdev);
const struct of_device_id *of_id = of_match_device( const struct of_device_id *of_id = of_match_device(
...@@ -348,10 +345,24 @@ static int jz4740_rtc_probe(struct platform_device *pdev) ...@@ -348,10 +345,24 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, ret = dev_pm_set_wake_irq(&pdev->dev, rtc->irq);
&jz4740_rtc_ops, THIS_MODULE); if (ret) {
dev_err(&pdev->dev, "Failed to set wake irq: %d\n", ret);
return ret;
}
rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc->rtc)) { if (IS_ERR(rtc->rtc)) {
ret = PTR_ERR(rtc->rtc); ret = PTR_ERR(rtc->rtc);
dev_err(&pdev->dev, "Failed to allocate rtc device: %d\n", ret);
return ret;
}
rtc->rtc->ops = &jz4740_rtc_ops;
rtc->rtc->range_max = U32_MAX;
ret = rtc_register_device(rtc->rtc);
if (ret) {
dev_err(&pdev->dev, "Failed to register rtc device: %d\n", ret); dev_err(&pdev->dev, "Failed to register rtc device: %d\n", ret);
return ret; return ret;
} }
...@@ -363,16 +374,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev) ...@@ -363,16 +374,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
return ret; return ret;
} }
scratchpad = jz4740_rtc_reg_read(rtc, JZ_REG_RTC_SCRATCHPAD);
if (scratchpad != 0x12345678) {
ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SCRATCHPAD, 0x12345678);
ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC, 0);
if (ret) {
dev_err(&pdev->dev, "Could not write to RTC registers\n");
return ret;
}
}
if (np && of_device_is_system_power_controller(np)) { if (np && of_device_is_system_power_controller(np)) {
if (!pm_power_off) { if (!pm_power_off) {
/* Default: 60ms */ /* Default: 60ms */
...@@ -397,35 +398,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev) ...@@ -397,35 +398,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM
static int jz4740_rtc_suspend(struct device *dev)
{
struct jz4740_rtc *rtc = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
enable_irq_wake(rtc->irq);
return 0;
}
static int jz4740_rtc_resume(struct device *dev)
{
struct jz4740_rtc *rtc = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
disable_irq_wake(rtc->irq);
return 0;
}
static const struct dev_pm_ops jz4740_pm_ops = {
.suspend = jz4740_rtc_suspend,
.resume = jz4740_rtc_resume,
};
#define JZ4740_RTC_PM_OPS (&jz4740_pm_ops)
#else
#define JZ4740_RTC_PM_OPS NULL
#endif /* CONFIG_PM */
static const struct platform_device_id jz4740_rtc_ids[] = { static const struct platform_device_id jz4740_rtc_ids[] = {
{ "jz4740-rtc", ID_JZ4740 }, { "jz4740-rtc", ID_JZ4740 },
{ "jz4780-rtc", ID_JZ4780 }, { "jz4780-rtc", ID_JZ4780 },
...@@ -437,7 +409,6 @@ static struct platform_driver jz4740_rtc_driver = { ...@@ -437,7 +409,6 @@ static struct platform_driver jz4740_rtc_driver = {
.probe = jz4740_rtc_probe, .probe = jz4740_rtc_probe,
.driver = { .driver = {
.name = "jz4740-rtc", .name = "jz4740-rtc",
.pm = JZ4740_RTC_PM_OPS,
.of_match_table = of_match_ptr(jz4740_rtc_of_match), .of_match_table = of_match_ptr(jz4740_rtc_of_match),
}, },
.id_table = jz4740_rtc_ids, .id_table = jz4740_rtc_ids,
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Copyright (C) 2010 NXP Semiconductors * Copyright (C) 2010 NXP Semiconductors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -47,8 +39,6 @@ ...@@ -47,8 +39,6 @@
#define LPC32XX_RTC_KEY_ONSW_LOADVAL 0xB5C13F27 #define LPC32XX_RTC_KEY_ONSW_LOADVAL 0xB5C13F27
#define RTC_NAME "rtc-lpc32xx"
#define rtc_readl(dev, reg) \ #define rtc_readl(dev, reg) \
__raw_readl((dev)->rtc_base + (reg)) __raw_readl((dev)->rtc_base + (reg))
#define rtc_writel(dev, reg, val) \ #define rtc_writel(dev, reg, val) \
...@@ -68,14 +58,15 @@ static int lpc32xx_rtc_read_time(struct device *dev, struct rtc_time *time) ...@@ -68,14 +58,15 @@ static int lpc32xx_rtc_read_time(struct device *dev, struct rtc_time *time)
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
elapsed_sec = rtc_readl(rtc, LPC32XX_RTC_UCOUNT); elapsed_sec = rtc_readl(rtc, LPC32XX_RTC_UCOUNT);
rtc_time_to_tm(elapsed_sec, time); rtc_time64_to_tm(elapsed_sec, time);
return 0; return 0;
} }
static int lpc32xx_rtc_set_mmss(struct device *dev, unsigned long secs) static int lpc32xx_rtc_set_time(struct device *dev, struct rtc_time *time)
{ {
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
u32 secs = rtc_tm_to_time64(time);
u32 tmp; u32 tmp;
spin_lock_irq(&rtc->lock); spin_lock_irq(&rtc->lock);
...@@ -97,7 +88,7 @@ static int lpc32xx_rtc_read_alarm(struct device *dev, ...@@ -97,7 +88,7 @@ static int lpc32xx_rtc_read_alarm(struct device *dev,
{ {
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
rtc_time_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), &wkalrm->time); rtc_time64_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), &wkalrm->time);
wkalrm->enabled = rtc->alarm_enabled; wkalrm->enabled = rtc->alarm_enabled;
wkalrm->pending = !!(rtc_readl(rtc, LPC32XX_RTC_INTSTAT) & wkalrm->pending = !!(rtc_readl(rtc, LPC32XX_RTC_INTSTAT) &
LPC32XX_RTC_INTSTAT_MATCH0); LPC32XX_RTC_INTSTAT_MATCH0);
...@@ -111,13 +102,8 @@ static int lpc32xx_rtc_set_alarm(struct device *dev, ...@@ -111,13 +102,8 @@ static int lpc32xx_rtc_set_alarm(struct device *dev,
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
unsigned long alarmsecs; unsigned long alarmsecs;
u32 tmp; u32 tmp;
int ret;
ret = rtc_tm_to_time(&wkalrm->time, &alarmsecs); alarmsecs = rtc_tm_to_time64(&wkalrm->time);
if (ret < 0) {
dev_warn(dev, "Failed to convert time: %d\n", ret);
return ret;
}
spin_lock_irq(&rtc->lock); spin_lock_irq(&rtc->lock);
...@@ -191,7 +177,7 @@ static irqreturn_t lpc32xx_rtc_alarm_interrupt(int irq, void *dev) ...@@ -191,7 +177,7 @@ static irqreturn_t lpc32xx_rtc_alarm_interrupt(int irq, void *dev)
static const struct rtc_class_ops lpc32xx_rtc_ops = { static const struct rtc_class_ops lpc32xx_rtc_ops = {
.read_time = lpc32xx_rtc_read_time, .read_time = lpc32xx_rtc_read_time,
.set_mmss = lpc32xx_rtc_set_mmss, .set_time = lpc32xx_rtc_set_time,
.read_alarm = lpc32xx_rtc_read_alarm, .read_alarm = lpc32xx_rtc_read_alarm,
.set_alarm = lpc32xx_rtc_set_alarm, .set_alarm = lpc32xx_rtc_set_alarm,
.alarm_irq_enable = lpc32xx_rtc_alarm_irq_enable, .alarm_irq_enable = lpc32xx_rtc_alarm_irq_enable,
...@@ -201,21 +187,13 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev) ...@@ -201,21 +187,13 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
struct lpc32xx_rtc *rtc; struct lpc32xx_rtc *rtc;
int rtcirq; int err;
u32 tmp; u32 tmp;
rtcirq = platform_get_irq(pdev, 0);
if (rtcirq < 0) {
dev_warn(&pdev->dev, "Can't get interrupt resource\n");
rtcirq = -1;
}
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
if (unlikely(!rtc)) if (unlikely(!rtc))
return -ENOMEM; return -ENOMEM;
rtc->irq = rtcirq;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
rtc->rtc_base = devm_ioremap_resource(&pdev->dev, res); rtc->rtc_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(rtc->rtc_base)) if (IS_ERR(rtc->rtc_base))
...@@ -256,18 +234,25 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev) ...@@ -256,18 +234,25 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
rtc->rtc = devm_rtc_device_register(&pdev->dev, RTC_NAME, rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
&lpc32xx_rtc_ops, THIS_MODULE); if (IS_ERR(rtc->rtc))
if (IS_ERR(rtc->rtc)) {
dev_err(&pdev->dev, "Can't get RTC\n");
return PTR_ERR(rtc->rtc); return PTR_ERR(rtc->rtc);
}
rtc->rtc->ops = &lpc32xx_rtc_ops;
rtc->rtc->range_max = U32_MAX;
err = rtc_register_device(rtc->rtc);
if (err)
return err;
/* /*
* IRQ is enabled after device registration in case alarm IRQ * IRQ is enabled after device registration in case alarm IRQ
* is pending upon suspend exit. * is pending upon suspend exit.
*/ */
if (rtc->irq >= 0) { rtc->irq = platform_get_irq(pdev, 0);
if (rtc->irq < 0) {
dev_warn(&pdev->dev, "Can't get interrupt resource\n");
} else {
if (devm_request_irq(&pdev->dev, rtc->irq, if (devm_request_irq(&pdev->dev, rtc->irq,
lpc32xx_rtc_alarm_interrupt, lpc32xx_rtc_alarm_interrupt,
0, pdev->name, rtc) < 0) { 0, pdev->name, rtc) < 0) {
...@@ -374,7 +359,7 @@ static struct platform_driver lpc32xx_rtc_driver = { ...@@ -374,7 +359,7 @@ static struct platform_driver lpc32xx_rtc_driver = {
.probe = lpc32xx_rtc_probe, .probe = lpc32xx_rtc_probe,
.remove = lpc32xx_rtc_remove, .remove = lpc32xx_rtc_remove,
.driver = { .driver = {
.name = RTC_NAME, .name = "rtc-lpc32xx",
.pm = LPC32XX_RTC_PM_OPS, .pm = LPC32XX_RTC_PM_OPS,
.of_match_table = of_match_ptr(lpc32xx_rtc_match), .of_match_table = of_match_ptr(lpc32xx_rtc_match),
}, },
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Real Time Clock driver for Freescale MC13XXX PMIC * Real Time Clock driver for Freescale MC13XXX PMIC
* *
* (C) 2009 Sascha Hauer, Pengutronix * (C) 2009 Sascha Hauer, Pengutronix
* (C) 2009 Uwe Kleine-Koenig, Pengutronix * (C) 2009 Uwe Kleine-Koenig, Pengutronix
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/mfd/mc13xxx.h> #include <linux/mfd/mc13xxx.h>
...@@ -89,14 +86,14 @@ static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -89,14 +86,14 @@ static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
return 0; return 0;
} }
static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs) static int mc13xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct mc13xxx_rtc *priv = dev_get_drvdata(dev); struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
unsigned int seconds, days; unsigned int seconds, days;
unsigned int alarmseconds; unsigned int alarmseconds;
int ret; int ret;
days = div_s64_rem(secs, SEC_PER_DAY, &seconds); days = div_s64_rem(rtc_tm_to_time64(tm), SEC_PER_DAY, &seconds);
mc13xxx_lock(priv->mc13xxx); mc13xxx_lock(priv->mc13xxx);
...@@ -158,7 +155,7 @@ static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs) ...@@ -158,7 +155,7 @@ static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs)
static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{ {
struct mc13xxx_rtc *priv = dev_get_drvdata(dev); struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
unsigned seconds, days; unsigned int seconds, days;
time64_t s1970; time64_t s1970;
int enabled, pending; int enabled, pending;
int ret; int ret;
...@@ -253,7 +250,7 @@ static irqreturn_t mc13xxx_rtc_alarm_handler(int irq, void *dev) ...@@ -253,7 +250,7 @@ static irqreturn_t mc13xxx_rtc_alarm_handler(int irq, void *dev)
static const struct rtc_class_ops mc13xxx_rtc_ops = { static const struct rtc_class_ops mc13xxx_rtc_ops = {
.read_time = mc13xxx_rtc_read_time, .read_time = mc13xxx_rtc_read_time,
.set_mmss64 = mc13xxx_rtc_set_mmss, .set_time = mc13xxx_rtc_set_time,
.read_alarm = mc13xxx_rtc_read_alarm, .read_alarm = mc13xxx_rtc_read_alarm,
.set_alarm = mc13xxx_rtc_set_alarm, .set_alarm = mc13xxx_rtc_set_alarm,
.alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable,
...@@ -285,8 +282,15 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev) ...@@ -285,8 +282,15 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
priv->mc13xxx = mc13xxx; priv->mc13xxx = mc13xxx;
priv->valid = 1; priv->valid = 1;
priv->rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(priv->rtc))
return PTR_ERR(priv->rtc);
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
priv->rtc->ops = &mc13xxx_rtc_ops;
/* 15bit days + hours, minutes, seconds */
priv->rtc->range_max = (timeu64_t)(1 << 15) * SEC_PER_DAY - 1;
mc13xxx_lock(mc13xxx); mc13xxx_lock(mc13xxx);
mc13xxx_irq_ack(mc13xxx, MC13XXX_IRQ_RTCRST); mc13xxx_irq_ack(mc13xxx, MC13XXX_IRQ_RTCRST);
...@@ -303,8 +307,9 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev) ...@@ -303,8 +307,9 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
mc13xxx_unlock(mc13xxx); mc13xxx_unlock(mc13xxx);
priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, ret = rtc_register_device(priv->rtc);
&mc13xxx_rtc_ops, THIS_MODULE); if (ret)
goto err_irq_request;
return 0; return 0;
......
...@@ -343,7 +343,7 @@ static int mtk_rtc_probe(struct platform_device *pdev) ...@@ -343,7 +343,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
rtc->irq, ret); rtc->irq, ret);
goto out_dispose_irq; return ret;
} }
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
...@@ -359,9 +359,7 @@ static int mtk_rtc_probe(struct platform_device *pdev) ...@@ -359,9 +359,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)
return 0; return 0;
out_free_irq: out_free_irq:
free_irq(rtc->irq, rtc->rtc_dev); free_irq(rtc->irq, rtc);
out_dispose_irq:
irq_dispose_mapping(rtc->irq);
return ret; return ret;
} }
...@@ -369,8 +367,7 @@ static int mtk_rtc_remove(struct platform_device *pdev) ...@@ -369,8 +367,7 @@ static int mtk_rtc_remove(struct platform_device *pdev)
{ {
struct mt6397_rtc *rtc = platform_get_drvdata(pdev); struct mt6397_rtc *rtc = platform_get_drvdata(pdev);
free_irq(rtc->irq, rtc->rtc_dev); free_irq(rtc->irq, rtc);
irq_dispose_mapping(rtc->irq);
return 0; return 0;
} }
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Driver for the RTC in Marvell SoCs. * Driver for the RTC in Marvell SoCs.
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#include <linux/init.h> #include <linux/init.h>
...@@ -60,7 +57,7 @@ static int mv_rtc_set_time(struct device *dev, struct rtc_time *tm) ...@@ -60,7 +57,7 @@ static int mv_rtc_set_time(struct device *dev, struct rtc_time *tm)
rtc_reg = (bin2bcd(tm->tm_mday) << RTC_MDAY_OFFS) | rtc_reg = (bin2bcd(tm->tm_mday) << RTC_MDAY_OFFS) |
(bin2bcd(tm->tm_mon + 1) << RTC_MONTH_OFFS) | (bin2bcd(tm->tm_mon + 1) << RTC_MONTH_OFFS) |
(bin2bcd(tm->tm_year % 100) << RTC_YEAR_OFFS); (bin2bcd(tm->tm_year - 100) << RTC_YEAR_OFFS);
writel(rtc_reg, ioaddr + RTC_DATE_REG_OFFS); writel(rtc_reg, ioaddr + RTC_DATE_REG_OFFS);
return 0; return 0;
...@@ -159,7 +156,7 @@ static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) ...@@ -159,7 +156,7 @@ static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
<< RTC_MONTH_OFFS; << RTC_MONTH_OFFS;
if (alm->time.tm_year >= 0) if (alm->time.tm_year >= 0)
rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_year % 100)) rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_year - 100))
<< RTC_YEAR_OFFS; << RTC_YEAR_OFFS;
writel(rtc_reg, ioaddr + RTC_ALARM_DATE_REG_OFFS); writel(rtc_reg, ioaddr + RTC_ALARM_DATE_REG_OFFS);
...@@ -257,15 +254,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev) ...@@ -257,15 +254,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pdata); platform_set_drvdata(pdev, pdata);
if (pdata->irq >= 0) { pdata->rtc = devm_rtc_allocate_device(&pdev->dev);
device_init_wakeup(&pdev->dev, 1);
pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&mv_rtc_alarm_ops,
THIS_MODULE);
} else {
pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&mv_rtc_ops, THIS_MODULE);
}
if (IS_ERR(pdata->rtc)) { if (IS_ERR(pdata->rtc)) {
ret = PTR_ERR(pdata->rtc); ret = PTR_ERR(pdata->rtc);
goto out; goto out;
...@@ -281,7 +270,19 @@ static int __init mv_rtc_probe(struct platform_device *pdev) ...@@ -281,7 +270,19 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
} }
} }
return 0; if (pdata->irq >= 0) {
device_init_wakeup(&pdev->dev, 1);
pdata->rtc->ops = &mv_rtc_alarm_ops;
} else {
pdata->rtc->ops = &mv_rtc_ops;
}
pdata->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
pdata->rtc->range_max = RTC_TIMESTAMP_END_2099;
ret = rtc_register_device(pdata->rtc);
if (!ret)
return 0;
out: out:
if (!IS_ERR(pdata->clk)) if (!IS_ERR(pdata->clk))
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -253,20 +254,9 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -253,20 +254,9 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* /*
* This function sets the internal RTC time based on tm in Gregorian date. * This function sets the internal RTC time based on tm in Gregorian date.
*/ */
static int mxc_rtc_set_mmss(struct device *dev, time64_t time) static int mxc_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct rtc_plat_data *pdata = dev_get_drvdata(dev); time64_t time = rtc_tm_to_time64(tm);
/*
* TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only
*/
if (is_imx1_rtc(pdata)) {
struct rtc_time tm;
rtc_time64_to_tm(time, &tm);
tm.tm_year = 70;
time = rtc_tm_to_time64(&tm);
}
/* Avoid roll-over from reading the different registers */ /* Avoid roll-over from reading the different registers */
do { do {
...@@ -310,7 +300,7 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -310,7 +300,7 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
/* RTC layer */ /* RTC layer */
static const struct rtc_class_ops mxc_rtc_ops = { static const struct rtc_class_ops mxc_rtc_ops = {
.read_time = mxc_rtc_read_time, .read_time = mxc_rtc_read_time,
.set_mmss64 = mxc_rtc_set_mmss, .set_time = mxc_rtc_set_time,
.read_alarm = mxc_rtc_read_alarm, .read_alarm = mxc_rtc_read_alarm,
.set_alarm = mxc_rtc_set_alarm, .set_alarm = mxc_rtc_set_alarm,
.alarm_irq_enable = mxc_rtc_alarm_irq_enable, .alarm_irq_enable = mxc_rtc_alarm_irq_enable,
...@@ -318,7 +308,6 @@ static const struct rtc_class_ops mxc_rtc_ops = { ...@@ -318,7 +308,6 @@ static const struct rtc_class_ops mxc_rtc_ops = {
static int mxc_rtc_probe(struct platform_device *pdev) static int mxc_rtc_probe(struct platform_device *pdev)
{ {
struct resource *res;
struct rtc_device *rtc; struct rtc_device *rtc;
struct rtc_plat_data *pdata = NULL; struct rtc_plat_data *pdata = NULL;
u32 reg; u32 reg;
...@@ -336,11 +325,34 @@ static int mxc_rtc_probe(struct platform_device *pdev) ...@@ -336,11 +325,34 @@ static int mxc_rtc_probe(struct platform_device *pdev)
else else
pdata->devtype = pdev->id_entry->driver_data; pdata->devtype = pdev->id_entry->driver_data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pdata->ioaddr = devm_platform_ioremap_resource(pdev, 0);
pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pdata->ioaddr)) if (IS_ERR(pdata->ioaddr))
return PTR_ERR(pdata->ioaddr); return PTR_ERR(pdata->ioaddr);
rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
pdata->rtc = rtc;
rtc->ops = &mxc_rtc_ops;
if (is_imx1_rtc(pdata)) {
struct rtc_time tm;
/* 9bit days + hours minutes seconds */
rtc->range_max = (1 << 9) * 86400 - 1;
/*
* Set the start date as beginning of the current year. This can
* be overridden using device tree.
*/
rtc_time64_to_tm(ktime_get_real_seconds(), &tm);
rtc->start_secs = mktime64(tm.tm_year, 1, 1, 0, 0, 0);
rtc->set_start_time = true;
} else {
/* 16bit days + hours minutes seconds */
rtc->range_max = (1 << 16) * 86400ULL - 1;
}
pdata->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); pdata->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(pdata->clk_ipg)) { if (IS_ERR(pdata->clk_ipg)) {
dev_err(&pdev->dev, "unable to get ipg clock!\n"); dev_err(&pdev->dev, "unable to get ipg clock!\n");
...@@ -396,17 +408,16 @@ static int mxc_rtc_probe(struct platform_device *pdev) ...@@ -396,17 +408,16 @@ static int mxc_rtc_probe(struct platform_device *pdev)
pdata->irq = -1; pdata->irq = -1;
} }
if (pdata->irq >= 0) if (pdata->irq >= 0) {
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
ret = dev_pm_set_wake_irq(&pdev->dev, pdata->irq);
rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &mxc_rtc_ops, if (ret)
THIS_MODULE); dev_err(&pdev->dev, "failed to enable irq wake\n");
if (IS_ERR(rtc)) {
ret = PTR_ERR(rtc);
goto exit_put_clk_ref;
} }
pdata->rtc = rtc; ret = rtc_register_device(rtc);
if (ret)
goto exit_put_clk_ref;
return 0; return 0;
...@@ -428,35 +439,10 @@ static int mxc_rtc_remove(struct platform_device *pdev) ...@@ -428,35 +439,10 @@ static int mxc_rtc_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int mxc_rtc_suspend(struct device *dev)
{
struct rtc_plat_data *pdata = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
enable_irq_wake(pdata->irq);
return 0;
}
static int mxc_rtc_resume(struct device *dev)
{
struct rtc_plat_data *pdata = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
disable_irq_wake(pdata->irq);
return 0;
}
#endif
static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
static struct platform_driver mxc_rtc_driver = { static struct platform_driver mxc_rtc_driver = {
.driver = { .driver = {
.name = "mxc_rtc", .name = "mxc_rtc",
.of_match_table = of_match_ptr(imx_rtc_dt_ids), .of_match_table = of_match_ptr(imx_rtc_dt_ids),
.pm = &mxc_rtc_pm_ops,
}, },
.id_table = imx_rtc_devtype, .id_table = imx_rtc_devtype,
.probe = mxc_rtc_probe, .probe = mxc_rtc_probe,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#define SRTC_LPPDR_INIT 0x41736166 /* init for glitch detect */ #define SRTC_LPPDR_INIT 0x41736166 /* init for glitch detect */
...@@ -305,6 +306,9 @@ static int mxc_rtc_probe(struct platform_device *pdev) ...@@ -305,6 +306,9 @@ static int mxc_rtc_probe(struct platform_device *pdev)
return pdata->irq; return pdata->irq;
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
ret = dev_pm_set_wake_irq(&pdev->dev, pdata->irq);
if (ret)
dev_err(&pdev->dev, "failed to enable irq wake\n");
ret = clk_prepare_enable(pdata->clk); ret = clk_prepare_enable(pdata->clk);
if (ret) if (ret)
...@@ -367,30 +371,6 @@ static int mxc_rtc_remove(struct platform_device *pdev) ...@@ -367,30 +371,6 @@ static int mxc_rtc_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int mxc_rtc_suspend(struct device *dev)
{
struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
enable_irq_wake(pdata->irq);
return 0;
}
static int mxc_rtc_resume(struct device *dev)
{
struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
disable_irq_wake(pdata->irq);
return 0;
}
#endif
static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
static const struct of_device_id mxc_ids[] = { static const struct of_device_id mxc_ids[] = {
{ .compatible = "fsl,imx53-rtc", }, { .compatible = "fsl,imx53-rtc", },
{} {}
...@@ -400,7 +380,6 @@ static struct platform_driver mxc_rtc_driver = { ...@@ -400,7 +380,6 @@ static struct platform_driver mxc_rtc_driver = {
.driver = { .driver = {
.name = "mxc_rtc_v2", .name = "mxc_rtc_v2",
.of_match_table = mxc_ids, .of_match_table = mxc_ids,
.pm = &mxc_rtc_pm_ops,
}, },
.probe = mxc_rtc_probe, .probe = mxc_rtc_probe,
.remove = mxc_rtc_remove, .remove = mxc_rtc_remove,
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* TI OMAP Real Time Clock interface for Linux * TI OMAP Real Time Clock interface for Linux
* *
...@@ -6,11 +7,6 @@ ...@@ -6,11 +7,6 @@
* *
* Copyright (C) 2006 David Brownell (new RTC framework) * Copyright (C) 2006 David Brownell (new RTC framework)
* Copyright (C) 2014 Johan Hovold <johan@kernel.org> * Copyright (C) 2014 Johan Hovold <johan@kernel.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/ */
#include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/gpio.h>
...@@ -271,7 +267,7 @@ static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) ...@@ -271,7 +267,7 @@ static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
} }
/* this hardware doesn't support "don't care" alarm fields */ /* this hardware doesn't support "don't care" alarm fields */
static int tm2bcd(struct rtc_time *tm) static void tm2bcd(struct rtc_time *tm)
{ {
tm->tm_sec = bin2bcd(tm->tm_sec); tm->tm_sec = bin2bcd(tm->tm_sec);
tm->tm_min = bin2bcd(tm->tm_min); tm->tm_min = bin2bcd(tm->tm_min);
...@@ -279,13 +275,7 @@ static int tm2bcd(struct rtc_time *tm) ...@@ -279,13 +275,7 @@ static int tm2bcd(struct rtc_time *tm)
tm->tm_mday = bin2bcd(tm->tm_mday); tm->tm_mday = bin2bcd(tm->tm_mday);
tm->tm_mon = bin2bcd(tm->tm_mon + 1); tm->tm_mon = bin2bcd(tm->tm_mon + 1);
/* epoch == 1900 */
if (tm->tm_year < 100 || tm->tm_year > 199)
return -EINVAL;
tm->tm_year = bin2bcd(tm->tm_year - 100); tm->tm_year = bin2bcd(tm->tm_year - 100);
return 0;
} }
static void bcd2tm(struct rtc_time *tm) static void bcd2tm(struct rtc_time *tm)
...@@ -328,8 +318,7 @@ static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm) ...@@ -328,8 +318,7 @@ static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct omap_rtc *rtc = dev_get_drvdata(dev); struct omap_rtc *rtc = dev_get_drvdata(dev);
if (tm2bcd(tm) < 0) tm2bcd(tm);
return -EINVAL;
local_irq_disable(); local_irq_disable();
rtc_wait_not_busy(rtc); rtc_wait_not_busy(rtc);
...@@ -378,8 +367,7 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) ...@@ -378,8 +367,7 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
struct omap_rtc *rtc = dev_get_drvdata(dev); struct omap_rtc *rtc = dev_get_drvdata(dev);
u8 reg, irqwake_reg = 0; u8 reg, irqwake_reg = 0;
if (tm2bcd(&alm->time) < 0) tm2bcd(&alm->time);
return -EINVAL;
local_irq_disable(); local_irq_disable();
rtc_wait_not_busy(rtc); rtc_wait_not_busy(rtc);
...@@ -441,14 +429,10 @@ static void omap_rtc_power_off(void) ...@@ -441,14 +429,10 @@ static void omap_rtc_power_off(void)
omap_rtc_read_time_raw(rtc, &tm); omap_rtc_read_time_raw(rtc, &tm);
seconds = tm.tm_sec; seconds = tm.tm_sec;
bcd2tm(&tm); bcd2tm(&tm);
rtc_tm_to_time(&tm, &now); now = rtc_tm_to_time64(&tm);
rtc_time_to_tm(now + 1, &tm); rtc_time64_to_tm(now + 1, &tm);
if (tm2bcd(&tm) < 0) { tm2bcd(&tm);
dev_err(&rtc->rtc->dev, "power off failed\n");
rtc->type->lock(rtc);
return;
}
rtc_wait_not_busy(rtc); rtc_wait_not_busy(rtc);
...@@ -845,6 +829,8 @@ static int omap_rtc_probe(struct platform_device *pdev) ...@@ -845,6 +829,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
} }
rtc->rtc->ops = &omap_rtc_ops; rtc->rtc->ops = &omap_rtc_ops;
rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
rtc->rtc->range_max = RTC_TIMESTAMP_END_2099;
omap_rtc_nvmem_config.priv = rtc; omap_rtc_nvmem_config.priv = rtc;
/* handle periodic and alarm irqs */ /* handle periodic and alarm irqs */
......
...@@ -224,7 +224,7 @@ static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -224,7 +224,7 @@ static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
return rc; return rc;
} }
int opal_tpo_alarm_irq_enable(struct device *dev, unsigned int enabled) static int opal_tpo_alarm_irq_enable(struct device *dev, unsigned int enabled)
{ {
struct rtc_wkalrm alarm = { .enabled = 0 }; struct rtc_wkalrm alarm = { .enabled = 0 };
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* pcap rtc code for Motorola EZX phones * pcap rtc code for Motorola EZX phones
* *
...@@ -5,11 +6,6 @@ ...@@ -5,11 +6,6 @@
* Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com> * Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com>
* *
* Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola * Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -55,7 +51,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -55,7 +51,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days); ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
rtc_time_to_tm(secs, tm); rtc_time64_to_tm(secs, tm);
return 0; return 0;
} }
...@@ -63,12 +59,9 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -63,12 +59,9 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{ {
struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev); struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
struct rtc_time *tm = &alrm->time; unsigned long secs = rtc_tm_to_time64(&alrm->time);
unsigned long secs;
u32 tod, days; u32 tod, days;
rtc_tm_to_time(tm, &secs);
tod = secs % SEC_PER_DAY; tod = secs % SEC_PER_DAY;
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod); ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
...@@ -90,14 +83,15 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -90,14 +83,15 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm)
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days); ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
rtc_time_to_tm(secs, tm); rtc_time64_to_tm(secs, tm);
return 0; return 0;
} }
static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs) static int pcap_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev); struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
unsigned long secs = rtc_tm_to_time64(tm);
u32 tod, days; u32 tod, days;
tod = secs % SEC_PER_DAY; tod = secs % SEC_PER_DAY;
...@@ -128,9 +122,9 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en) ...@@ -128,9 +122,9 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en)
static const struct rtc_class_ops pcap_rtc_ops = { static const struct rtc_class_ops pcap_rtc_ops = {
.read_time = pcap_rtc_read_time, .read_time = pcap_rtc_read_time,
.set_time = pcap_rtc_set_time,
.read_alarm = pcap_rtc_read_alarm, .read_alarm = pcap_rtc_read_alarm,
.set_alarm = pcap_rtc_set_alarm, .set_alarm = pcap_rtc_set_alarm,
.set_mmss = pcap_rtc_set_mmss,
.alarm_irq_enable = pcap_rtc_alarm_irq_enable, .alarm_irq_enable = pcap_rtc_alarm_irq_enable,
}; };
...@@ -149,11 +143,13 @@ static int __init pcap_rtc_probe(struct platform_device *pdev) ...@@ -149,11 +143,13 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pcap_rtc); platform_set_drvdata(pdev, pcap_rtc);
pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap", pcap_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
&pcap_rtc_ops, THIS_MODULE);
if (IS_ERR(pcap_rtc->rtc)) if (IS_ERR(pcap_rtc->rtc))
return PTR_ERR(pcap_rtc->rtc); return PTR_ERR(pcap_rtc->rtc);
pcap_rtc->rtc->ops = &pcap_rtc_ops;
pcap_rtc->rtc->range_max = (1 << 14) * 86400ULL - 1;
timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
...@@ -167,7 +163,7 @@ static int __init pcap_rtc_probe(struct platform_device *pdev) ...@@ -167,7 +163,7 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
if (err) if (err)
return err; return err;
return 0; return rtc_register_device(pcap_rtc->rtc);
} }
static int __exit pcap_rtc_remove(struct platform_device *pdev) static int __exit pcap_rtc_remove(struct platform_device *pdev)
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* drivers/rtc/rtc-pcf85363.c * drivers/rtc/rtc-pcf85363.c
* *
* Driver for NXP PCF85363 real-time clock. * Driver for NXP PCF85363 real-time clock.
* *
* Copyright (C) 2017 Eric Nelson * Copyright (C) 2017 Eric Nelson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Based loosely on rtc-8583 by Russell King, Wolfram Sang and Juergen Beisert
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/i2c.h> #include <linux/i2c.h>
...@@ -112,10 +107,7 @@ ...@@ -112,10 +107,7 @@
#define NVRAM_SIZE 0x40 #define NVRAM_SIZE 0x40
static struct i2c_driver pcf85363_driver;
struct pcf85363 { struct pcf85363 {
struct device *dev;
struct rtc_device *rtc; struct rtc_device *rtc;
struct regmap *regmap; struct regmap *regmap;
}; };
...@@ -386,9 +378,6 @@ static int pcf85363_probe(struct i2c_client *client, ...@@ -386,9 +378,6 @@ static int pcf85363_probe(struct i2c_client *client,
if (data) if (data)
config = data; config = data;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
pcf85363 = devm_kzalloc(&client->dev, sizeof(struct pcf85363), pcf85363 = devm_kzalloc(&client->dev, sizeof(struct pcf85363),
GFP_KERNEL); GFP_KERNEL);
if (!pcf85363) if (!pcf85363)
...@@ -400,20 +389,21 @@ static int pcf85363_probe(struct i2c_client *client, ...@@ -400,20 +389,21 @@ static int pcf85363_probe(struct i2c_client *client,
return PTR_ERR(pcf85363->regmap); return PTR_ERR(pcf85363->regmap);
} }
pcf85363->dev = &client->dev;
i2c_set_clientdata(client, pcf85363); i2c_set_clientdata(client, pcf85363);
pcf85363->rtc = devm_rtc_allocate_device(pcf85363->dev); pcf85363->rtc = devm_rtc_allocate_device(&client->dev);
if (IS_ERR(pcf85363->rtc)) if (IS_ERR(pcf85363->rtc))
return PTR_ERR(pcf85363->rtc); return PTR_ERR(pcf85363->rtc);
pcf85363->rtc->ops = &rtc_ops; pcf85363->rtc->ops = &rtc_ops;
pcf85363->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
pcf85363->rtc->range_max = RTC_TIMESTAMP_END_2099;
if (client->irq > 0) { if (client->irq > 0) {
regmap_write(pcf85363->regmap, CTRL_FLAGS, 0); regmap_write(pcf85363->regmap, CTRL_FLAGS, 0);
regmap_update_bits(pcf85363->regmap, CTRL_PIN_IO, regmap_update_bits(pcf85363->regmap, CTRL_PIN_IO,
PIN_IO_INTA_OUT, PIN_IO_INTAPM); PIN_IO_INTA_OUT, PIN_IO_INTAPM);
ret = devm_request_threaded_irq(pcf85363->dev, client->irq, ret = devm_request_threaded_irq(&client->dev, client->irq,
NULL, pcf85363_rtc_handle_irq, NULL, pcf85363_rtc_handle_irq,
IRQF_TRIGGER_LOW | IRQF_ONESHOT, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"pcf85363", client); "pcf85363", client);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* PS3 RTC Driver * PS3 RTC Driver
* *
* Copyright 2009 Sony Corporation * Copyright 2009 Sony Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -40,16 +28,13 @@ static u64 read_rtc(void) ...@@ -40,16 +28,13 @@ static u64 read_rtc(void)
static int ps3_get_time(struct device *dev, struct rtc_time *tm) static int ps3_get_time(struct device *dev, struct rtc_time *tm)
{ {
rtc_time_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm); rtc_time64_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
return 0; return 0;
} }
static int ps3_set_time(struct device *dev, struct rtc_time *tm) static int ps3_set_time(struct device *dev, struct rtc_time *tm)
{ {
unsigned long now; ps3_os_area_set_rtc_diff(rtc_tm_to_time64(tm) - read_rtc());
rtc_tm_to_time(tm, &now);
ps3_os_area_set_rtc_diff(now - read_rtc());
return 0; return 0;
} }
...@@ -62,13 +47,16 @@ static int __init ps3_rtc_probe(struct platform_device *dev) ...@@ -62,13 +47,16 @@ static int __init ps3_rtc_probe(struct platform_device *dev)
{ {
struct rtc_device *rtc; struct rtc_device *rtc;
rtc = devm_rtc_device_register(&dev->dev, "rtc-ps3", &ps3_rtc_ops, rtc = devm_rtc_allocate_device(&dev->dev);
THIS_MODULE);
if (IS_ERR(rtc)) if (IS_ERR(rtc))
return PTR_ERR(rtc); return PTR_ERR(rtc);
rtc->ops = &ps3_rtc_ops;
rtc->range_max = U64_MAX;
platform_set_drvdata(dev, rtc); platform_set_drvdata(dev, rtc);
return 0;
return rtc_register_device(rtc);
} }
static struct platform_driver ps3_rtc_driver = { static struct platform_driver ps3_rtc_driver = {
......
...@@ -145,8 +145,7 @@ static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask) ...@@ -145,8 +145,7 @@ static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask)
static irqreturn_t pxa_rtc_irq(int irq, void *dev_id) static irqreturn_t pxa_rtc_irq(int irq, void *dev_id)
{ {
struct platform_device *pdev = to_platform_device(dev_id); struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev_id);
struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev);
u32 rtsr; u32 rtsr;
unsigned long events = 0; unsigned long events = 0;
......
...@@ -336,8 +336,7 @@ static const struct rtc_class_ops rk808_rtc_ops = { ...@@ -336,8 +336,7 @@ static const struct rtc_class_ops rk808_rtc_ops = {
/* Turn off the alarm if it should not be a wake source. */ /* Turn off the alarm if it should not be a wake source. */
static int rk808_rtc_suspend(struct device *dev) static int rk808_rtc_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct rk808_rtc *rk808_rtc = dev_get_drvdata(dev);
struct rk808_rtc *rk808_rtc = dev_get_drvdata(&pdev->dev);
if (device_may_wakeup(dev)) if (device_may_wakeup(dev))
enable_irq_wake(rk808_rtc->irq); enable_irq_wake(rk808_rtc->irq);
...@@ -350,8 +349,7 @@ static int rk808_rtc_suspend(struct device *dev) ...@@ -350,8 +349,7 @@ static int rk808_rtc_suspend(struct device *dev)
*/ */
static int rk808_rtc_resume(struct device *dev) static int rk808_rtc_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct rk808_rtc *rk808_rtc = dev_get_drvdata(dev);
struct rk808_rtc *rk808_rtc = dev_get_drvdata(&pdev->dev);
if (device_may_wakeup(dev)) if (device_may_wakeup(dev))
disable_irq_wake(rk808_rtc->irq); disable_irq_wake(rk808_rtc->irq);
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
/* RX-6110 Register definitions */ /* RX-6110 Register definitions */
...@@ -379,9 +381,16 @@ static const struct spi_device_id rx6110_id[] = { ...@@ -379,9 +381,16 @@ static const struct spi_device_id rx6110_id[] = {
}; };
MODULE_DEVICE_TABLE(spi, rx6110_id); MODULE_DEVICE_TABLE(spi, rx6110_id);
static const struct of_device_id rx6110_spi_of_match[] = {
{ .compatible = "epson,rx6110" },
{ },
};
MODULE_DEVICE_TABLE(of, rx6110_spi_of_match);
static struct spi_driver rx6110_driver = { static struct spi_driver rx6110_driver = {
.driver = { .driver = {
.name = RX6110_DRIVER_NAME, .name = RX6110_DRIVER_NAME,
.of_match_table = of_match_ptr(rx6110_spi_of_match),
}, },
.probe = rx6110_probe, .probe = rx6110_probe,
.remove = rx6110_remove, .remove = rx6110_remove,
......
...@@ -311,7 +311,7 @@ static int rx8025_read_alarm(struct device *dev, struct rtc_wkalrm *t) ...@@ -311,7 +311,7 @@ static int rx8025_read_alarm(struct device *dev, struct rtc_wkalrm *t)
t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12 t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12
+ (ald[1] & 0x20 ? 12 : 0); + (ald[1] & 0x20 ? 12 : 0);
dev_dbg(dev, "%s: date: %ptRr\n", __func__, t); dev_dbg(dev, "%s: date: %ptRr\n", __func__, &t->time);
t->enabled = !!(rx8025->ctrl1 & RX8025_BIT_CTRL1_DALE); t->enabled = !!(rx8025->ctrl1 & RX8025_BIT_CTRL1_DALE);
t->pending = (ctrl2 & RX8025_BIT_CTRL2_DAFG) && t->enabled; t->pending = (ctrl2 & RX8025_BIT_CTRL2_DAFG) && t->enabled;
......
...@@ -276,6 +276,9 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -276,6 +276,9 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
struct sh_rtc *rtc = dev_get_drvdata(dev); struct sh_rtc *rtc = dev_get_drvdata(dev);
unsigned int sec128, sec2, yr, yr100, cf_bit; unsigned int sec128, sec2, yr, yr100, cf_bit;
if (!(readb(rtc->regbase + RCR2) & RCR2_RTCEN))
return -EINVAL;
do { do {
unsigned int tmp; unsigned int tmp;
...@@ -466,7 +469,6 @@ static int __init sh_rtc_probe(struct platform_device *pdev) ...@@ -466,7 +469,6 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
{ {
struct sh_rtc *rtc; struct sh_rtc *rtc;
struct resource *res; struct resource *res;
struct rtc_time r;
char clk_name[6]; char clk_name[6];
int clk_id, ret; int clk_id, ret;
...@@ -528,6 +530,10 @@ static int __init sh_rtc_probe(struct platform_device *pdev) ...@@ -528,6 +530,10 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
rtc->clk = NULL; rtc->clk = NULL;
} }
rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
clk_enable(rtc->clk); clk_enable(rtc->clk);
rtc->capabilities = RTC_DEF_CAPABILITIES; rtc->capabilities = RTC_DEF_CAPABILITIES;
...@@ -591,21 +597,21 @@ static int __init sh_rtc_probe(struct platform_device *pdev) ...@@ -591,21 +597,21 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
sh_rtc_setaie(&pdev->dev, 0); sh_rtc_setaie(&pdev->dev, 0);
sh_rtc_setcie(&pdev->dev, 0); sh_rtc_setcie(&pdev->dev, 0);
rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "sh", rtc->rtc_dev->ops = &sh_rtc_ops;
&sh_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtc_dev)) {
ret = PTR_ERR(rtc->rtc_dev);
goto err_unmap;
}
rtc->rtc_dev->max_user_freq = 256; rtc->rtc_dev->max_user_freq = 256;
/* reset rtc to epoch 0 if time is invalid */ if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) {
if (rtc_read_time(rtc->rtc_dev, &r) < 0) { rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_1900;
rtc_time_to_tm(0, &r); rtc->rtc_dev->range_max = RTC_TIMESTAMP_END_9999;
rtc_set_time(rtc->rtc_dev, &r); } else {
rtc->rtc_dev->range_min = mktime64(1999, 1, 1, 0, 0, 0);
rtc->rtc_dev->range_max = mktime64(2098, 12, 31, 23, 59, 59);
} }
ret = rtc_register_device(rtc->rtc_dev);
if (ret)
goto err_unmap;
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
return 0; return 0;
......
...@@ -279,7 +279,7 @@ static const struct of_device_id sirfsoc_rtc_of_match[] = { ...@@ -279,7 +279,7 @@ static const struct of_device_id sirfsoc_rtc_of_match[] = {
{}, {},
}; };
const struct regmap_config sysrtc_regmap_config = { static const struct regmap_config sysrtc_regmap_config = {
.reg_bits = 32, .reg_bits = 32,
.val_bits = 32, .val_bits = 32,
.fast_io = true, .fast_io = true,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
...@@ -271,7 +272,6 @@ static const struct regmap_config snvs_rtc_config = { ...@@ -271,7 +272,6 @@ static const struct regmap_config snvs_rtc_config = {
static int snvs_rtc_probe(struct platform_device *pdev) static int snvs_rtc_probe(struct platform_device *pdev)
{ {
struct snvs_rtc_data *data; struct snvs_rtc_data *data;
struct resource *res;
int ret; int ret;
void __iomem *mmio; void __iomem *mmio;
...@@ -283,9 +283,8 @@ static int snvs_rtc_probe(struct platform_device *pdev) ...@@ -283,9 +283,8 @@ static int snvs_rtc_probe(struct platform_device *pdev)
if (IS_ERR(data->regmap)) { if (IS_ERR(data->regmap)) {
dev_warn(&pdev->dev, "snvs rtc: you use old dts file, please update it\n"); dev_warn(&pdev->dev, "snvs rtc: you use old dts file, please update it\n");
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mmio = devm_ioremap_resource(&pdev->dev, res); mmio = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(mmio)) if (IS_ERR(mmio))
return PTR_ERR(mmio); return PTR_ERR(mmio);
...@@ -332,6 +331,9 @@ static int snvs_rtc_probe(struct platform_device *pdev) ...@@ -332,6 +331,9 @@ static int snvs_rtc_probe(struct platform_device *pdev)
} }
device_init_wakeup(&pdev->dev, true); device_init_wakeup(&pdev->dev, true);
ret = dev_pm_set_wake_irq(&pdev->dev, data->irq);
if (ret)
dev_err(&pdev->dev, "failed to enable irq wake\n");
ret = devm_request_irq(&pdev->dev, data->irq, snvs_rtc_irq_handler, ret = devm_request_irq(&pdev->dev, data->irq, snvs_rtc_irq_handler,
IRQF_SHARED, "rtc alarm", &pdev->dev); IRQF_SHARED, "rtc alarm", &pdev->dev);
...@@ -358,18 +360,7 @@ static int snvs_rtc_probe(struct platform_device *pdev) ...@@ -358,18 +360,7 @@ static int snvs_rtc_probe(struct platform_device *pdev)
return ret; return ret;
} }
#ifdef CONFIG_PM_SLEEP static int __maybe_unused snvs_rtc_suspend_noirq(struct device *dev)
static int snvs_rtc_suspend(struct device *dev)
{
struct snvs_rtc_data *data = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
return enable_irq_wake(data->irq);
return 0;
}
static int snvs_rtc_suspend_noirq(struct device *dev)
{ {
struct snvs_rtc_data *data = dev_get_drvdata(dev); struct snvs_rtc_data *data = dev_get_drvdata(dev);
...@@ -379,17 +370,7 @@ static int snvs_rtc_suspend_noirq(struct device *dev) ...@@ -379,17 +370,7 @@ static int snvs_rtc_suspend_noirq(struct device *dev)
return 0; return 0;
} }
static int snvs_rtc_resume(struct device *dev) static int __maybe_unused snvs_rtc_resume_noirq(struct device *dev)
{
struct snvs_rtc_data *data = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
return disable_irq_wake(data->irq);
return 0;
}
static int snvs_rtc_resume_noirq(struct device *dev)
{ {
struct snvs_rtc_data *data = dev_get_drvdata(dev); struct snvs_rtc_data *data = dev_get_drvdata(dev);
...@@ -400,20 +381,9 @@ static int snvs_rtc_resume_noirq(struct device *dev) ...@@ -400,20 +381,9 @@ static int snvs_rtc_resume_noirq(struct device *dev)
} }
static const struct dev_pm_ops snvs_rtc_pm_ops = { static const struct dev_pm_ops snvs_rtc_pm_ops = {
.suspend = snvs_rtc_suspend, SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(snvs_rtc_suspend_noirq, snvs_rtc_resume_noirq)
.suspend_noirq = snvs_rtc_suspend_noirq,
.resume = snvs_rtc_resume,
.resume_noirq = snvs_rtc_resume_noirq,
}; };
#define SNVS_RTC_PM_OPS (&snvs_rtc_pm_ops)
#else
#define SNVS_RTC_PM_OPS NULL
#endif
static const struct of_device_id snvs_dt_ids[] = { static const struct of_device_id snvs_dt_ids[] = {
{ .compatible = "fsl,sec-v4.0-mon-rtc-lp", }, { .compatible = "fsl,sec-v4.0-mon-rtc-lp", },
{ /* sentinel */ } { /* sentinel */ }
...@@ -423,7 +393,7 @@ MODULE_DEVICE_TABLE(of, snvs_dt_ids); ...@@ -423,7 +393,7 @@ MODULE_DEVICE_TABLE(of, snvs_dt_ids);
static struct platform_driver snvs_rtc_driver = { static struct platform_driver snvs_rtc_driver = {
.driver = { .driver = {
.name = "snvs_rtc", .name = "snvs_rtc",
.pm = SNVS_RTC_PM_OPS, .pm = &snvs_rtc_pm_ops,
.of_match_table = snvs_dt_ids, .of_match_table = snvs_dt_ids,
}, },
.probe = snvs_rtc_probe, .probe = snvs_rtc_probe,
......
...@@ -788,11 +788,14 @@ static int stm32_rtc_probe(struct platform_device *pdev) ...@@ -788,11 +788,14 @@ static int stm32_rtc_probe(struct platform_device *pdev)
ret = device_init_wakeup(&pdev->dev, true); ret = device_init_wakeup(&pdev->dev, true);
if (rtc->data->has_wakeirq) { if (rtc->data->has_wakeirq) {
rtc->wakeirq_alarm = platform_get_irq(pdev, 1); rtc->wakeirq_alarm = platform_get_irq(pdev, 1);
if (rtc->wakeirq_alarm <= 0) if (rtc->wakeirq_alarm > 0) {
ret = rtc->wakeirq_alarm;
else
ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, ret = dev_pm_set_dedicated_wake_irq(&pdev->dev,
rtc->wakeirq_alarm); rtc->wakeirq_alarm);
} else {
ret = rtc->wakeirq_alarm;
if (rtc->wakeirq_alarm == -EPROBE_DEFER)
goto err;
}
} }
if (ret) if (ret)
dev_warn(&pdev->dev, "alarm can't wake up the system: %d", ret); dev_warn(&pdev->dev, "alarm can't wake up the system: %d", ret);
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems. /* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems.
* *
* Author: David S. Miller * Author: David S. Miller
* License: GPL
* *
* Copyright (C) 2008 David S. Miller <davem@davemloft.net> * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
*/ */
...@@ -39,7 +39,7 @@ static unsigned long hypervisor_get_time(void) ...@@ -39,7 +39,7 @@ static unsigned long hypervisor_get_time(void)
static int sun4v_read_time(struct device *dev, struct rtc_time *tm) static int sun4v_read_time(struct device *dev, struct rtc_time *tm)
{ {
rtc_time_to_tm(hypervisor_get_time(), tm); rtc_time64_to_tm(hypervisor_get_time(), tm);
return 0; return 0;
} }
...@@ -66,14 +66,7 @@ static int hypervisor_set_time(unsigned long secs) ...@@ -66,14 +66,7 @@ static int hypervisor_set_time(unsigned long secs)
static int sun4v_set_time(struct device *dev, struct rtc_time *tm) static int sun4v_set_time(struct device *dev, struct rtc_time *tm)
{ {
unsigned long secs; return hypervisor_set_time(rtc_tm_to_time64(tm));
int err;
err = rtc_tm_to_time(tm, &secs);
if (err)
return err;
return hypervisor_set_time(secs);
} }
static const struct rtc_class_ops sun4v_rtc_ops = { static const struct rtc_class_ops sun4v_rtc_ops = {
...@@ -85,13 +78,15 @@ static int __init sun4v_rtc_probe(struct platform_device *pdev) ...@@ -85,13 +78,15 @@ static int __init sun4v_rtc_probe(struct platform_device *pdev)
{ {
struct rtc_device *rtc; struct rtc_device *rtc;
rtc = devm_rtc_device_register(&pdev->dev, "sun4v", rtc = devm_rtc_allocate_device(&pdev->dev);
&sun4v_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) if (IS_ERR(rtc))
return PTR_ERR(rtc); return PTR_ERR(rtc);
rtc->ops = &sun4v_rtc_ops;
rtc->range_max = U64_MAX;
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
return 0;
return rtc_register_device(rtc);
} }
static struct platform_driver sun4v_rtc_driver = { static struct platform_driver sun4v_rtc_driver = {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -673,9 +673,16 @@ static const struct i2c_device_id x1205_id[] = { ...@@ -673,9 +673,16 @@ static const struct i2c_device_id x1205_id[] = {
}; };
MODULE_DEVICE_TABLE(i2c, x1205_id); MODULE_DEVICE_TABLE(i2c, x1205_id);
static const struct of_device_id x1205_dt_ids[] = {
{ .compatible = "xircom,x1205", },
{},
};
MODULE_DEVICE_TABLE(of, x1205_dt_ids);
static struct i2c_driver x1205_driver = { static struct i2c_driver x1205_driver = {
.driver = { .driver = {
.name = "rtc-x1205", .name = "rtc-x1205",
.of_match_table = x1205_dt_ids,
}, },
.probe = x1205_probe, .probe = x1205_probe,
.remove = x1205_remove, .remove = x1205_remove,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment