summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-02-22 09:54:19 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2021-02-22 09:54:19 -0800
commit0328b5f2ef4af8ba060e64baa928c94037e7308f (patch)
treee9f0f54ca32399ac6a08024c788e5870e50c8cc4 /drivers/rtc
parent36c1b20d15703662aa0f14a32a8bd19ab3a33076 (diff)
parent49dfc1f16b03a6abc17721d4600f7a0bf3d3e4ed (diff)
downloadlinux-0328b5f2ef4af8ba060e64baa928c94037e7308f.tar.gz
linux-0328b5f2ef4af8ba060e64baa928c94037e7308f.tar.bz2
linux-0328b5f2ef4af8ba060e64baa928c94037e7308f.zip
Merge tag 'rtc-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni: "Many cleanups and a few drivers removal this cycle. Subsystem: - Introduce features bitfield and the first feature: RTC_FEATURE_ALARM Removed drivers: - ab3100 - coh901331 - tx4939 - sirfsoc Drivers: - use rtc_lock and rtc_unlock instead of opencoding - constify all struct rtc_class_ops - quiet maybe-unused variable warning - replace spin_lock_irqsave with spin_lock in hard IRQ - pcf2127: disable Power-On Reset Override and run OTP refresh" * tag 'rtc-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (81 commits) rtc: abx80x: Add utility function for writing configuration key rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) rtc: pcf8563: Add NXP PCA8565 compatible rtc: s3c: quiet maybe-unused variable warning rtc: s3c: stop setting bogus time rtc: sd3078: quiet maybe-unused variable warning rtc: s35390a: quiet maybe-unused variable warning rtc: rx8581: quiet maybe-unused variable warning rtc: rx8010: quiet maybe-unused variable warning rtc: rv8803: quiet maybe-unused variable warning rtc: rv3032: quiet maybe-unused variable warning rtc: rv3029: quiet maybe-unused variable warning rtc: rv3028: quiet maybe-unused variable warning rtc: rs5c372: quiet maybe-unused variable warning rtc: pcf85363: quiet maybe-unused variable warning rtc: pcf85063: quiet maybe-unused variable warnings rtc: meson: quiet maybe-unused variable warning rtc: m41t80: quiet maybe-unused variable warning rtc: isl1208: quiet maybe-unused variable warning rtc: ds3232: quiet maybe-unused variable warning ...
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/Kconfig38
-rw-r--r--drivers/rtc/Makefile4
-rw-r--r--drivers/rtc/class.c10
-rw-r--r--drivers/rtc/interface.c12
-rw-r--r--drivers/rtc/rtc-ab3100.c254
-rw-r--r--drivers/rtc/rtc-abx80x.c39
-rw-r--r--drivers/rtc/rtc-ac100.c4
-rw-r--r--drivers/rtc/rtc-armada38x.c21
-rw-r--r--drivers/rtc/rtc-asm9260.c6
-rw-r--r--drivers/rtc/rtc-bq32k.c2
-rw-r--r--drivers/rtc/rtc-brcmstb-waketimer.c2
-rw-r--r--drivers/rtc/rtc-cmos.c17
-rw-r--r--drivers/rtc/rtc-coh901331.c290
-rw-r--r--drivers/rtc/rtc-digicolor.c2
-rw-r--r--drivers/rtc/rtc-ds1305.c5
-rw-r--r--drivers/rtc/rtc-ds1307.c5
-rw-r--r--drivers/rtc/rtc-ds1672.c2
-rw-r--r--drivers/rtc/rtc-ds1685.c6
-rw-r--r--drivers/rtc/rtc-ds3232.c7
-rw-r--r--drivers/rtc/rtc-hym8563.c5
-rw-r--r--drivers/rtc/rtc-isl1208.c2
-rw-r--r--drivers/rtc/rtc-m41t80.c25
-rw-r--r--drivers/rtc/rtc-m48t59.c22
-rw-r--r--drivers/rtc/rtc-mcp795.c5
-rw-r--r--drivers/rtc/rtc-meson.c2
-rw-r--r--drivers/rtc/rtc-mv.c14
-rw-r--r--drivers/rtc/rtc-mxc.c5
-rw-r--r--drivers/rtc/rtc-mxc_v2.c7
-rw-r--r--drivers/rtc/rtc-opal.c27
-rw-r--r--drivers/rtc/rtc-pcf2123.c5
-rw-r--r--drivers/rtc/rtc-pcf2127.c46
-rw-r--r--drivers/rtc/rtc-pcf85063.c49
-rw-r--r--drivers/rtc/rtc-pcf85363.c10
-rw-r--r--drivers/rtc/rtc-pcf8563.c2
-rw-r--r--drivers/rtc/rtc-pl031.c8
-rw-r--r--drivers/rtc/rtc-pm8xxx.c18
-rw-r--r--drivers/rtc/rtc-r7301.c5
-rw-r--r--drivers/rtc/rtc-rs5c372.c2
-rw-r--r--drivers/rtc/rtc-rv3028.c23
-rw-r--r--drivers/rtc/rtc-rv3029c2.c22
-rw-r--r--drivers/rtc/rtc-rv3032.c13
-rw-r--r--drivers/rtc/rtc-rv8803.c13
-rw-r--r--drivers/rtc/rtc-rx6110.c4
-rw-r--r--drivers/rtc/rtc-rx8010.c21
-rw-r--r--drivers/rtc/rtc-rx8025.c5
-rw-r--r--drivers/rtc/rtc-rx8581.c2
-rw-r--r--drivers/rtc/rtc-s35390a.c2
-rw-r--r--drivers/rtc/rtc-s3c.c17
-rw-r--r--drivers/rtc/rtc-s5m.c33
-rw-r--r--drivers/rtc/rtc-sd3078.c2
-rw-r--r--drivers/rtc/rtc-sirfsoc.c446
-rw-r--r--drivers/rtc/rtc-stm32.c4
-rw-r--r--drivers/rtc/rtc-tegra.c6
-rw-r--r--drivers/rtc/rtc-tps65910.c19
-rw-r--r--drivers/rtc/rtc-tx4939.c303
55 files changed, 259 insertions, 1661 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 2a402c10f8f1..ce723dc54aa4 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -692,6 +692,7 @@ config RTC_DRV_S5M
tristate "Samsung S2M/S5M series"
depends on MFD_SEC_CORE || COMPILE_TEST
select REGMAP_IRQ
+ select REGMAP_I2C
help
If you say yes here you will get support for the
RTC of Samsung S2MPS14 and S5M PMIC series.
@@ -1258,14 +1259,6 @@ config RTC_DRV_PCF50633
If you say yes here you get support for the RTC subsystem of the
NXP PCF50633 used in embedded systems.
-config RTC_DRV_AB3100
- tristate "ST-Ericsson AB3100 RTC"
- depends on AB3100_CORE
- default y if AB3100_CORE
- help
- Select this to enable the ST-Ericsson AB3100 Mixed Signal IC RTC
- support. This chip contains a battery- and capacitor-backed RTC.
-
config RTC_DRV_AB8500
tristate "ST-Ericsson AB8500 RTC"
depends on AB8500_CORE
@@ -1288,7 +1281,7 @@ config RTC_DRV_OPAL
config RTC_DRV_ZYNQMP
tristate "Xilinx Zynq Ultrascale+ MPSoC RTC"
- depends on OF
+ depends on OF && HAS_IOMEM
help
If you say yes here you get support for the RTC controller found on
Xilinx Zynq Ultrascale+ MPSoC.
@@ -1575,13 +1568,6 @@ config RTC_DRV_STARFIRE
If you say Y here you will get support for the RTC found on
Starfire systems.
-config RTC_DRV_TX4939
- tristate "TX4939 SoC"
- depends on SOC_TX4939 || COMPILE_TEST
- help
- Driver for the internal RTC (Realtime Clock) module found on
- Toshiba TX4939 SoC.
-
config RTC_DRV_MV
tristate "Marvell SoC RTC"
depends on ARCH_DOVE || ARCH_MVEBU || COMPILE_TEST
@@ -1596,6 +1582,7 @@ config RTC_DRV_MV
config RTC_DRV_ARMADA38X
tristate "Armada 38x Marvell SoC RTC"
depends on ARCH_MVEBU || COMPILE_TEST
+ depends on OF
help
If you say yes here you will get support for the in-chip RTC
that can be found in the Armada 38x Marvell's SoC device
@@ -1633,18 +1620,6 @@ config RTC_DRV_PS3
This driver can also be built as a module. If so, the module
will be called rtc-ps3.
-config RTC_DRV_COH901331
- tristate "ST-Ericsson COH 901 331 RTC"
- depends on ARCH_U300 || COMPILE_TEST
- help
- If you say Y here you will get access to ST-Ericsson
- COH 901 331 RTC clock found in some ST-Ericsson Mobile
- Platforms.
-
- This driver can also be built as a module. If so, the module
- will be called "rtc-coh901331".
-
-
config RTC_DRV_STMP
tristate "Freescale STMP3xxx/i.MX23/i.MX28 RTC"
depends on ARCH_MXS || COMPILE_TEST
@@ -1787,13 +1762,6 @@ config RTC_DRV_IMX_SC
If you say yes here you get support for the NXP i.MX System
Controller RTC module.
-config RTC_DRV_SIRFSOC
- tristate "SiRFSOC RTC"
- depends on ARCH_SIRF
- help
- Say "yes" here to support the real time clock on SiRF SOC chips.
- This driver can also be built as a module called rtc-sirfsoc.
-
config RTC_DRV_ST_LPC
tristate "STMicroelectronics LPC RTC"
depends on ARCH_STI
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index f8ac4f574522..4e930183c170 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -19,7 +19,6 @@ rtc-core-$(CONFIG_RTC_INTF_SYSFS) += sysfs.o
obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o
obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o
-obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o
obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o
obj-$(CONFIG_RTC_DRV_ABB5ZES3) += rtc-ab-b5ze-s3.o
obj-$(CONFIG_RTC_DRV_ABEOZ9) += rtc-ab-eoz9.o
@@ -38,7 +37,6 @@ obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o
obj-$(CONFIG_RTC_DRV_BRCMSTB) += rtc-brcmstb-waketimer.o
obj-$(CONFIG_RTC_DRV_CADENCE) += rtc-cadence.o
obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
-obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o
obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o
obj-$(CONFIG_RTC_DRV_CROS_EC) += rtc-cros-ec.o
obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o
@@ -154,7 +152,6 @@ obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o
obj-$(CONFIG_RTC_DRV_SC27XX) += rtc-sc27xx.o
obj-$(CONFIG_RTC_DRV_SD3078) += rtc-sd3078.o
obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o
-obj-$(CONFIG_RTC_DRV_SIRFSOC) += rtc-sirfsoc.o
obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o
obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o
obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o
@@ -171,7 +168,6 @@ obj-$(CONFIG_RTC_DRV_TPS6586X) += rtc-tps6586x.o
obj-$(CONFIG_RTC_DRV_TPS65910) += rtc-tps65910.o
obj-$(CONFIG_RTC_DRV_TPS80031) += rtc-tps80031.o
obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o
-obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o
obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 7e470fbd5e4d..f77bc089eb6b 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -231,6 +231,8 @@ static struct rtc_device *rtc_allocate_device(void)
rtc->pie_timer.function = rtc_pie_update_irq;
rtc->pie_enabled = 0;
+ set_bit(RTC_FEATURE_ALARM, rtc->features);
+
return rtc;
}
@@ -322,11 +324,6 @@ static void rtc_device_get_offset(struct rtc_device *rtc)
rtc->offset_secs = 0;
}
-/**
- * rtc_device_unregister - removes the previously registered RTC class device
- *
- * @rtc: the RTC class device to destroy
- */
static void devm_rtc_unregister_device(void *data)
{
struct rtc_device *rtc = data;
@@ -386,6 +383,9 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
return -EINVAL;
}
+ if (!rtc->ops->set_alarm)
+ clear_bit(RTC_FEATURE_ALARM, rtc->features);
+
rtc->owner = owner;
rtc_device_get_offset(rtc);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 794a4f036b99..dcb34c73319e 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -186,7 +186,7 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc,
if (!rtc->ops) {
err = -ENODEV;
- } else if (!rtc->ops->read_alarm) {
+ } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->read_alarm) {
err = -EINVAL;
} else {
alarm->enabled = 0;
@@ -392,7 +392,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
return err;
if (!rtc->ops) {
err = -ENODEV;
- } else if (!rtc->ops->read_alarm) {
+ } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->read_alarm) {
err = -EINVAL;
} else {
memset(alarm, 0, sizeof(struct rtc_wkalrm));
@@ -436,7 +436,7 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
if (!rtc->ops)
err = -ENODEV;
- else if (!rtc->ops->set_alarm)
+ else if (!test_bit(RTC_FEATURE_ALARM, rtc->features))
err = -EINVAL;
else
err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
@@ -451,7 +451,7 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
if (!rtc->ops)
return -ENODEV;
- else if (!rtc->ops->set_alarm)
+ else if (!test_bit(RTC_FEATURE_ALARM, rtc->features))
return -EINVAL;
err = rtc_valid_tm(&alarm->time);
@@ -531,7 +531,7 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
/* nothing */;
else if (!rtc->ops)
err = -ENODEV;
- else if (!rtc->ops->alarm_irq_enable)
+ else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->alarm_irq_enable)
err = -EINVAL;
else
err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled);
@@ -843,7 +843,7 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
static void rtc_alarm_disable(struct rtc_device *rtc)
{
- if (!rtc->ops || !rtc->ops->alarm_irq_enable)
+ if (!rtc->ops || !test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->alarm_irq_enable)
return;
rtc->ops->alarm_irq_enable(rtc->dev.parent, false);
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c
deleted file mode 100644
index e4fd961e8bf6..000000000000
--- a/drivers/rtc/rtc-ab3100.c
+++ /dev/null
@@ -1,254 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2007-2009 ST-Ericsson AB
- * RTC clock driver for the AB3100 Analog Baseband Chip
- * Author: Linus Walleij <linus.walleij@stericsson.com>
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/rtc.h>
-#include <linux/mfd/abx500.h>
-
-/* Clock rate in Hz */
-#define AB3100_RTC_CLOCK_RATE 32768
-
-/*
- * The AB3100 RTC registers. These are the same for
- * AB3000 and AB3100.
- * Control register:
- * Bit 0: RTC Monitor cleared=0, active=1, if you set it
- * to 1 it remains active until RTC power is lost.
- * Bit 1: 32 kHz Oscillator, 0 = on, 1 = bypass
- * Bit 2: Alarm on, 0 = off, 1 = on
- * Bit 3: 32 kHz buffer disabling, 0 = enabled, 1 = disabled
- */
-#define AB3100_RTC 0x53
-/* default setting, buffer disabled, alarm on */
-#define RTC_SETTING 0x30
-/* Alarm when AL0-AL3 == TI0-TI3 */
-#define AB3100_AL0 0x56
-#define AB3100_AL1 0x57
-#define AB3100_AL2 0x58
-#define AB3100_AL3 0x59
-/* This 48-bit register that counts up at 32768 Hz */
-#define AB3100_TI0 0x5a
-#define AB3100_TI1 0x5b
-#define AB3100_TI2 0x5c
-#define AB3100_TI3 0x5d
-#define AB3100_TI4 0x5e
-#define AB3100_TI5 0x5f
-
-/*
- * RTC clock functions and device struct declaration
- */
-static int ab3100_rtc_set_time(struct device *dev, struct rtc_time *tm)
-{
- u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2,
- AB3100_TI3, AB3100_TI4, AB3100_TI5};
- unsigned char buf[6];
- u64 hw_counter = rtc_tm_to_time64(tm) * AB3100_RTC_CLOCK_RATE * 2;
- int err = 0;
- int i;
-
- buf[0] = (hw_counter) & 0xFF;
- buf[1] = (hw_counter >> 8) & 0xFF;
- buf[2] = (hw_counter >> 16) & 0xFF;
- buf[3] = (hw_counter >> 24) & 0xFF;
- buf[4] = (hw_counter >> 32) & 0xFF;
- buf[5] = (hw_counter >> 40) & 0xFF;
-
- for (i = 0; i < 6; i++) {
- err = abx500_set_register_interruptible(dev, 0,
- regs[i], buf[i]);
- if (err)
- return err;
- }
-
- /* Set the flag to mark that the clock is now set */
- return abx500_mask_and_set_register_interruptible(dev, 0,
- AB3100_RTC,
- 0x01, 0x01);
-
-}
-
-static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
-{
- time64_t time;
- u8 rtcval;
- int err;
-
- err = abx500_get_register_interruptible(dev, 0,
- AB3100_RTC, &rtcval);
- if (err)
- return err;
-
- if (!(rtcval & 0x01)) {
- dev_info(dev, "clock not set (lost power)");
- return -EINVAL;
- } else {
- u64 hw_counter;
- u8 buf[6];
-
- /* Read out time registers */
- err = abx500_get_register_page_interruptible(dev, 0,
- AB3100_TI0,
- buf, 6);
- if (err != 0)
- return err;
-
- hw_counter = ((u64) buf[5] << 40) | ((u64) buf[4] << 32) |
- ((u64) buf[3] << 24) | ((u64) buf[2] << 16) |
- ((u64) buf[1] << 8) | (u64) buf[0];
- time = hw_counter / (u64) (AB3100_RTC_CLOCK_RATE * 2);
- }
-
- rtc_time64_to_tm(time, tm);
-
- return 0;
-}
-
-static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
-{
- time64_t time;
- u64 hw_counter;
- u8 buf[6];
- u8 rtcval;
- int err;
-
- /* Figure out if alarm is enabled or not */
- err = abx500_get_register_interruptible(dev, 0,
- AB3100_RTC, &rtcval);
- if (err)
- return err;
- if (rtcval & 0x04)
- alarm->enabled = 1;
- else
- alarm->enabled = 0;
- /* No idea how this could be represented */
- alarm->pending = 0;
- /* Read out alarm registers, only 4 bytes */
- err = abx500_get_register_page_interruptible(dev, 0,
- AB3100_AL0, buf, 4);
- if (err)
- return err;
- hw_counter = ((u64) buf[3] << 40) | ((u64) buf[2] << 32) |
- ((u64) buf[1] << 24) | ((u64) buf[0] << 16);
- time = hw_counter / (u64) (AB3100_RTC_CLOCK_RATE * 2);
-
- rtc_time64_to_tm(time, &alarm->time);
-
- return rtc_valid_tm(&alarm->time);
-}
-
-static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
-{
- u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3};
- unsigned char buf[4];
- time64_t secs;
- u64 hw_counter;
- int err;
- int i;
-
- secs = rtc_tm_to_time64(&alarm->time);
- hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2;
- buf[0] = (hw_counter >> 16) & 0xFF;
- buf[1] = (hw_counter >> 24) & 0xFF;
- buf[2] = (hw_counter >> 32) & 0xFF;
- buf[3] = (hw_counter >> 40) & 0xFF;
-
- /* Set the alarm */
- for (i = 0; i < 4; i++) {
- err = abx500_set_register_interruptible(dev, 0,
- regs[i], buf[i]);
- if (err)
- return err;
- }
- /* Then enable the alarm */
- return abx500_mask_and_set_register_interruptible(dev, 0,
- AB3100_RTC, (1 << 2),
- alarm->enabled << 2);
-}
-
-static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
-{
- /*
- * It's not possible to enable/disable the alarm IRQ for this RTC.
- * It does not actually trigger any IRQ: instead its only function is
- * to power up the system, if it wasn't on. This will manifest as
- * a "power up cause" in the AB3100 power driver (battery charging etc)
- * and need to be handled there instead.
- */
- if (enabled)
- return abx500_mask_and_set_register_interruptible(dev, 0,
- AB3100_RTC, (1 << 2),
- 1 << 2);
- else
- return abx500_mask_and_set_register_interruptible(dev, 0,
- AB3100_RTC, (1 << 2),
- 0);
-}
-
-static const struct rtc_class_ops ab3100_rtc_ops = {
- .read_time = ab3100_rtc_read_time,
- .set_time = ab3100_rtc_set_time,
- .read_alarm = ab3100_rtc_read_alarm,
- .set_alarm = ab3100_rtc_set_alarm,
- .alarm_irq_enable = ab3100_rtc_irq_enable,
-};
-
-static int __init ab3100_rtc_probe(struct platform_device *pdev)
-{
- int err;
- u8 regval;
- struct rtc_device *rtc;
-
- /* The first RTC register needs special treatment */
- err = abx500_get_register_interruptible(&pdev->dev, 0,
- AB3100_RTC, &regval);
- if (err) {
- dev_err(&pdev->dev, "unable to read RTC register\n");
- return -ENODEV;
- }
-
- if ((regval & 0xFE) != RTC_SETTING) {
- dev_warn(&pdev->dev, "not default value in RTC reg 0x%x\n",
- regval);
- }
-
- if ((regval & 1) == 0) {
- /*
- * Set bit to detect power loss.
- * This bit remains until RTC power is lost.
- */
- regval = 1 | RTC_SETTING;
- err = abx500_set_register_interruptible(&pdev->dev, 0,
- AB3100_RTC, regval);
- /* Ignore any error on this write */
- }
-
- rtc = devm_rtc_allocate_device(&pdev->dev);
- if (IS_ERR(rtc))
- return PTR_ERR(rtc);
-
- rtc->ops = &ab3100_rtc_ops;
- /* 48bit counter at (AB3100_RTC_CLOCK_RATE * 2) */
- rtc->range_max = U32_MAX;
-
- platform_set_drvdata(pdev, rtc);
-
- return devm_rtc_register_device(rtc);
-}
-
-static struct platform_driver ab3100_rtc_driver = {
- .driver = {
- .name = "ab3100-rtc",
- },
-};
-
-module_platform_driver_probe(ab3100_rtc_driver, ab3100_rtc_probe);
-
-MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
-MODULE_DESCRIPTION("AB3100 RTC Driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 6733bb0df674..9b0138d07232 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -117,6 +117,16 @@ struct abx80x_priv {
struct watchdog_device wdog;
};
+static int abx80x_write_config_key(struct i2c_client *client, u8 key)
+{
+ if (i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY, key) < 0) {
+ dev_err(&client->dev, "Unable to write configuration key\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
static int abx80x_is_rc_mode(struct i2c_client *client)
{
int flags = 0;
@@ -140,12 +150,8 @@ static int abx80x_enable_trickle_charger(struct i2c_client *client,
* Write the configuration key register to enable access to the Trickle
* register
*/
- err = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_MISC);
- if (err < 0) {
- dev_err(&client->dev, "Unable to write configuration key\n");
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_MISC) < 0)
return -EIO;
- }
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_TRICKLE,
ABX8XX_TRICKLE_CHARGE_ENABLE |
@@ -358,12 +364,8 @@ static int abx80x_rtc_set_autocalibration(struct device *dev,
}
/* Unlock write access to Oscillator Control Register */
- retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_OSC);
- if (retval < 0) {
- dev_err(dev, "Failed to write CONFIG_KEY register\n");
- return retval;
- }
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_OSC) < 0)
+ return -EIO;
retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_OSC, flags);
@@ -450,12 +452,8 @@ static ssize_t oscillator_store(struct device *dev,
flags |= (ABX8XX_OSC_OSEL);
/* Unlock write access on Oscillator Control register */
- retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_OSC);
- if (retval < 0) {
- dev_err(dev, "Failed to write CONFIG_KEY register\n");
- return retval;
- }
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_OSC) < 0)
+ return -EIO;
retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_OSC, flags);
if (retval < 0) {
@@ -762,13 +760,8 @@ static int abx80x_probe(struct i2c_client *client,
* Write the configuration key register to enable access to
* the config2 register
*/
- err = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_MISC);
- if (err < 0) {
- dev_err(&client->dev,
- "Unable to write configuration key\n");
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_MISC) < 0)
return -EIO;
- }
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_OUT_CTRL,
data | ABX8XX_OUT_CTRL_EXDS);
diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
index 1ddbef99e38f..66783cb5e711 100644
--- a/drivers/rtc/rtc-ac100.c
+++ b/drivers/rtc/rtc-ac100.c
@@ -528,7 +528,7 @@ static irqreturn_t ac100_rtc_irq(int irq, void *data)
unsigned int val = 0;
int ret;
- mutex_lock(&chip->rtc->ops_lock);
+ rtc_lock(chip->rtc);
/* read status */
ret = regmap_read(regmap, AC100_ALM_INT_STA, &val);
@@ -551,7 +551,7 @@ static irqreturn_t ac100_rtc_irq(int irq, void *data)
}
out:
- mutex_unlock(&chip->rtc->ops_lock);
+ rtc_unlock(chip->rtc);
return IRQ_HANDLED;
}
diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
index 807a79c07f08..cc542e6b1d5b 100644
--- a/drivers/rtc/rtc-armada38x.c
+++ b/drivers/rtc/rtc-armada38x.c
@@ -458,14 +458,6 @@ static const struct rtc_class_ops armada38x_rtc_ops = {
.set_offset = armada38x_rtc_set_offset,
};
-static const struct rtc_class_ops armada38x_rtc_ops_noirq = {
- .read_time = armada38x_rtc_read_time,
- .set_time = armada38x_rtc_set_time,
- .read_alarm = armada38x_rtc_read_alarm,
- .read_offset = armada38x_rtc_read_offset,
- .set_offset = armada38x_rtc_set_off