mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 16:53:54 +08:00
RTC for 5.11
Subsystem: - Remove nvram ABI. There was no complaints about the deprecation for the last 3 years. - Improve RTC device allocation and registration - Now available for ARCH=um Drivers: - at91rm9200: correction and sam9x60 support - ds1307: improve ACPI support - mxc: now DT only - pcf2127: watchdog support now needs the reset-source property - pcf8523: set range - rx6110: i2c support -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl/eeIQACgkQ2wIijOdR NOU06g//Xf2697Zc59SziSwhbEFCEyfhY4P+Qm24ymuOb2wkApmaWGifdCRclcvR VncDLhyW9u5SpJiQY0ZMryTOmuE2KtbGfJX/tY9AGgQZioCxUIxELREwnqkQ2/8c cOu0C8nrBCAnDNi3jTryPCyFJN1oLCztcbMGWXGG7Irkehq7ywQ1TCxxWzF+w3su z38UzB1664ULfYYj3M2m/+2MV2rkf81P/4BTokKkZ2RLL1Q19wM0rFE0aXcKedel pZy/DXGwBWK4fDR/Q2YYxRnpEf8UzYzgCQWAiaJGdRane9Tx6H8wy9TcHc5OQfjn gtDtXje9Xwb+UJ27Mz19hNMts96n2G9S1Y0Pq5n0DD4AO0pDchYL41V5Z4hEDgMW Fm/ZQG+khVJCllMUPbwPU2H7iDrH6IVsi2pjfdw1EeLW5Zx2/0jPfuAeQ1KdDKQt UZ1SNxLZy2O7QL5Y+00pHlVFizTyGITz1H2IBG1Fn62abh7H9G5wfsB4AEldR+tr 9Di/o7Q1Oo5goBtVdmqn3xfOr1QWlfU+/7qSwiz2uqXMR/UWVMlLSp7k2Hav1m5H 6osjgRI6oQYHIbBwAQ3Hf98y/jOiddK6Wov6+gZGauO6M1//Q5NouQOXTe7RHwuG R5JP6lgCoZJPky0156qApAH8I6r6xV1A7W7CEnNKOK1JITqj5Hw= =n8V2 -----END PGP SIGNATURE----- Merge tag 'rtc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC updates from Alexandre Belloni: "Subsystem: - Remove nvram ABI. There was no complaints about the deprecation for the last 3 years. - Improve RTC device allocation and registration - Now available for ARCH=um Drivers: - at91rm9200: correction and sam9x60 support - ds1307: improve ACPI support - mxc: now DT only - pcf2127: watchdog support now needs the reset-source property - pcf8523: set range - rx6110: i2c support" * tag 'rtc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (43 commits) rtc: pcf2127: only use watchdog when explicitly available dt-bindings: rtc: add reset-source property rtc: fix RTC removal rtc: s3c: Remove dead code related to periodic tick handling rtc: s3c: Disable all enable (RTC, tick) bits in the probe rtc: ep93xx: Fix NULL pointer dereference in ep93xx_rtc_read_time rtc: test: remove debug message rtc: mxc{,_v2}: enable COMPILE_TEST rtc: enable RTC framework on ARCH=um rtc: pcf8523: use BIT rtc: pcf8523: set range rtc: pcf8523: switch to devm_rtc_allocate_device rtc: destroy mutex when releasing the device rtc: shrink devm_rtc_allocate_device() rtc: rework rtc_register_device() resource management rtc: nvmem: emit an error message when nvmem registration fails rtc: add devm_ prefix to rtc_nvmem_register() rtc: nvmem: remove nvram ABI Documentation: list RTC devres helpers in devres.rst rtc: omap: use devm_pinctrl_register() ...
This commit is contained in:
commit
f4a2f7866f
@ -63,6 +63,11 @@ properties:
|
||||
description:
|
||||
Enables wake up of host system on alarm.
|
||||
|
||||
reset-source:
|
||||
$ref: /schemas/types.yaml#/definitions/flag
|
||||
description:
|
||||
The RTC is able to reset the machine.
|
||||
|
||||
additionalProperties: true
|
||||
|
||||
...
|
||||
|
@ -411,6 +411,12 @@ RESET
|
||||
devm_reset_control_get()
|
||||
devm_reset_controller_register()
|
||||
|
||||
RTC
|
||||
devm_rtc_device_register()
|
||||
devm_rtc_allocate_device()
|
||||
devm_rtc_register_device()
|
||||
devm_rtc_nvmem_register()
|
||||
|
||||
SERDEV
|
||||
devm_serdev_device_open()
|
||||
|
||||
|
@ -1183,7 +1183,7 @@ F: Documentation/devicetree/bindings/interrupt-controller/google,goldfish-pic.tx
|
||||
F: drivers/irqchip/irq-goldfish-pic.c
|
||||
|
||||
ANDROID GOLDFISH RTC DRIVER
|
||||
M: Miodrag Dinic <miodrag.dinic@mips.com>
|
||||
M: Jiaxun Yang <jiaxun.yang@flygoat.com>
|
||||
S: Supported
|
||||
F: Documentation/devicetree/bindings/rtc/google,goldfish-rtc.txt
|
||||
F: drivers/rtc/rtc-goldfish.c
|
||||
|
@ -216,6 +216,6 @@ alpha_rtc_init(void)
|
||||
rtc->ops = &remote_rtc_ops;
|
||||
#endif
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
device_initcall(alpha_rtc_init);
|
||||
|
@ -1119,7 +1119,7 @@ static inline void menelaus_rtc_init(struct menelaus_chip *m)
|
||||
menelaus_write_reg(MENELAUS_RTC_CTRL, m->rtc_control);
|
||||
}
|
||||
|
||||
err = rtc_register_device(m->rtc);
|
||||
err = devm_rtc_register_device(m->rtc);
|
||||
if (err) {
|
||||
if (alarm) {
|
||||
menelaus_remove_irq_work(MENELAUS_RTCALM_IRQ);
|
||||
|
@ -13,7 +13,7 @@ config RTC_MC146818_LIB
|
||||
menuconfig RTC_CLASS
|
||||
bool "Real Time Clock"
|
||||
default n
|
||||
depends on !S390 && !UML
|
||||
depends on !S390
|
||||
select RTC_LIB
|
||||
help
|
||||
Generic RTC class support. If you say yes here, you will
|
||||
@ -817,15 +817,6 @@ config RTC_DRV_RX4581
|
||||
This driver can also be built as a module. If so the module
|
||||
will be called rtc-rx4581.
|
||||
|
||||
config RTC_DRV_RX6110
|
||||
tristate "Epson RX-6110"
|
||||
select REGMAP_SPI
|
||||
help
|
||||
If you say yes here you will get support for the Epson RX-6610.
|
||||
|
||||
This driver can also be built as a module. If so the module
|
||||
will be called rtc-rx6110.
|
||||
|
||||
config RTC_DRV_RS5C348
|
||||
tristate "Ricoh RS5C348A/B"
|
||||
help
|
||||
@ -936,6 +927,17 @@ config RTC_DRV_RV3029_HWMON
|
||||
Say Y here if you want to expose temperature sensor data on
|
||||
rtc-rv3029.
|
||||
|
||||
config RTC_DRV_RX6110
|
||||
tristate "Epson RX-6110"
|
||||
depends on RTC_I2C_AND_SPI
|
||||
select REGMAP_SPI if SPI_MASTER
|
||||
select REGMAP_I2C if I2C
|
||||
help
|
||||
If you say yes here you will get support for the Epson RX-6110.
|
||||
|
||||
This driver can also be built as a module. If so the module
|
||||
will be called rtc-rx6110.
|
||||
|
||||
comment "Platform RTC drivers"
|
||||
|
||||
# this 'CMOS' RTC driver is arch dependent because it requires
|
||||
@ -1017,6 +1019,7 @@ config RTC_DRV_DS1553
|
||||
|
||||
config RTC_DRV_DS1685_FAMILY
|
||||
tristate "Dallas/Maxim DS1685 Family"
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
If you say yes here you get support for the Dallas/Maxim DS1685
|
||||
family of real time chips. This family includes the DS1685/DS1687,
|
||||
@ -1150,6 +1153,7 @@ config RTC_DRV_STK17TA8
|
||||
|
||||
config RTC_DRV_M48T86
|
||||
tristate "ST M48T86/Dallas DS12887"
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
If you say Y here you will get support for the
|
||||
ST M48T86 and Dallas DS12887 RTC chips.
|
||||
@ -1752,7 +1756,9 @@ config RTC_DRV_LOONGSON1
|
||||
|
||||
config RTC_DRV_MXC
|
||||
tristate "Freescale MXC Real Time Clock"
|
||||
depends on ARCH_MXC
|
||||
depends on ARCH_MXC || COMPILE_TEST
|
||||
depends on HAS_IOMEM
|
||||
depends on OF
|
||||
help
|
||||
If you say yes here you get support for the Freescale MXC
|
||||
RTC module.
|
||||
@ -1762,7 +1768,9 @@ config RTC_DRV_MXC
|
||||
|
||||
config RTC_DRV_MXC_V2
|
||||
tristate "Freescale MXC Real Time Clock for i.MX53"
|
||||
depends on ARCH_MXC
|
||||
depends on ARCH_MXC || COMPILE_TEST
|
||||
depends on HAS_IOMEM
|
||||
depends on OF
|
||||
help
|
||||
If you say yes here you get support for the Freescale MXC
|
||||
SRTC module in i.MX53 processor.
|
||||
@ -1935,7 +1943,6 @@ config RTC_DRV_HID_SENSOR_TIME
|
||||
config RTC_DRV_GOLDFISH
|
||||
tristate "Goldfish Real Time Clock"
|
||||
depends on OF && HAS_IOMEM
|
||||
depends on GOLDFISH || COMPILE_TEST
|
||||
help
|
||||
Say yes to enable RTC driver for the Goldfish based virtual platform.
|
||||
|
||||
|
@ -28,6 +28,7 @@ static void rtc_device_release(struct device *dev)
|
||||
struct rtc_device *rtc = to_rtc_device(dev);
|
||||
|
||||
ida_simple_remove(&rtc_ida, rtc->id);
|
||||
mutex_destroy(&rtc->ops_lock);
|
||||
kfree(rtc);
|
||||
}
|
||||
|
||||
@ -326,8 +327,10 @@ static void rtc_device_get_offset(struct rtc_device *rtc)
|
||||
*
|
||||
* @rtc: the RTC class device to destroy
|
||||
*/
|
||||
static void rtc_device_unregister(struct rtc_device *rtc)
|
||||
static void devm_rtc_unregister_device(void *data)
|
||||
{
|
||||
struct rtc_device *rtc = data;
|
||||
|
||||
mutex_lock(&rtc->ops_lock);
|
||||
/*
|
||||
* Remove innards of this RTC, then disable it, before
|
||||
@ -337,60 +340,43 @@ static void rtc_device_unregister(struct rtc_device *rtc)
|
||||
cdev_device_del(&rtc->char_dev, &rtc->dev);
|
||||
rtc->ops = NULL;
|
||||
mutex_unlock(&rtc->ops_lock);
|
||||
put_device(&rtc->dev);
|
||||
}
|
||||
|
||||
static void devm_rtc_release_device(struct device *dev, void *res)
|
||||
static void devm_rtc_release_device(void *res)
|
||||
{
|
||||
struct rtc_device *rtc = *(struct rtc_device **)res;
|
||||
struct rtc_device *rtc = res;
|
||||
|
||||
rtc_nvmem_unregister(rtc);
|
||||
|
||||
if (rtc->registered)
|
||||
rtc_device_unregister(rtc);
|
||||
else
|
||||
put_device(&rtc->dev);
|
||||
put_device(&rtc->dev);
|
||||
}
|
||||
|
||||
struct rtc_device *devm_rtc_allocate_device(struct device *dev)
|
||||
{
|
||||
struct rtc_device **ptr, *rtc;
|
||||
struct rtc_device *rtc;
|
||||
int id, err;
|
||||
|
||||
id = rtc_device_get_id(dev);
|
||||
if (id < 0)
|
||||
return ERR_PTR(id);
|
||||
|
||||
ptr = devres_alloc(devm_rtc_release_device, sizeof(*ptr), GFP_KERNEL);
|
||||
if (!ptr) {
|
||||
err = -ENOMEM;
|
||||
goto exit_ida;
|
||||
}
|
||||
|
||||
rtc = rtc_allocate_device();
|
||||
if (!rtc) {
|
||||
err = -ENOMEM;
|
||||
goto exit_devres;
|
||||
ida_simple_remove(&rtc_ida, id);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
*ptr = rtc;
|
||||
devres_add(dev, ptr);
|
||||
|
||||
rtc->id = id;
|
||||
rtc->dev.parent = dev;
|
||||
dev_set_name(&rtc->dev, "rtc%d", id);
|
||||
|
||||
return rtc;
|
||||
err = devm_add_action_or_reset(dev, devm_rtc_release_device, rtc);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
exit_devres:
|
||||
devres_free(ptr);
|
||||
exit_ida:
|
||||
ida_simple_remove(&rtc_ida, id);
|
||||
return ERR_PTR(err);
|
||||
return rtc;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_rtc_allocate_device);
|
||||
|
||||
int __rtc_register_device(struct module *owner, struct rtc_device *rtc)
|
||||
int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
|
||||
{
|
||||
struct rtc_wkalrm alrm;
|
||||
int err;
|
||||
@ -420,7 +406,6 @@ int __rtc_register_device(struct module *owner, struct rtc_device *rtc)
|
||||
|
||||
rtc_proc_add_device(rtc);
|
||||
|
||||
rtc->registered = true;
|
||||
dev_info(rtc->dev.parent, "registered as %s\n",
|
||||
dev_name(&rtc->dev));
|
||||
|
||||
@ -429,9 +414,10 @@ int __rtc_register_device(struct module *owner, struct rtc_device *rtc)
|
||||
rtc_hctosys(rtc);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return devm_add_action_or_reset(rtc->dev.parent,
|
||||
devm_rtc_unregister_device, rtc);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__rtc_register_device);
|
||||
EXPORT_SYMBOL_GPL(__devm_rtc_register_device);
|
||||
|
||||
/**
|
||||
* devm_rtc_device_register - resource managed rtc_device_register()
|
||||
@ -461,7 +447,7 @@ struct rtc_device *devm_rtc_device_register(struct device *dev,
|
||||
|
||||
rtc->ops = ops;
|
||||
|
||||
err = __rtc_register_device(owner, rtc);
|
||||
err = __devm_rtc_register_device(owner, rtc);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
|
@ -9,99 +9,22 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/nvmem-consumer.h>
|
||||
#include <linux/rtc.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
|
||||
/*
|
||||
* Deprecated ABI compatibility, this should be removed at some point
|
||||
*/
|
||||
|
||||
static const char nvram_warning[] = "Deprecated ABI, please use nvmem";
|
||||
|
||||
static ssize_t
|
||||
rtc_nvram_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
dev_warn_once(kobj_to_dev(kobj), nvram_warning);
|
||||
|
||||
return nvmem_device_read(attr->private, off, count, buf);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rtc_nvram_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
dev_warn_once(kobj_to_dev(kobj), nvram_warning);
|
||||
|
||||
return nvmem_device_write(attr->private, off, count, buf);
|
||||
}
|
||||
|
||||
static int rtc_nvram_register(struct rtc_device *rtc,
|
||||
struct nvmem_device *nvmem, size_t size)
|
||||
{
|
||||
int err;
|
||||
|
||||
rtc->nvram = kzalloc(sizeof(*rtc->nvram), GFP_KERNEL);
|
||||
if (!rtc->nvram)
|
||||
return -ENOMEM;
|
||||
|
||||
rtc->nvram->attr.name = "nvram";
|
||||
rtc->nvram->attr.mode = 0644;
|
||||
rtc->nvram->private = nvmem;
|
||||
|
||||
sysfs_bin_attr_init(rtc->nvram);
|
||||
|
||||
rtc->nvram->read = rtc_nvram_read;
|
||||
rtc->nvram->write = rtc_nvram_write;
|
||||
rtc->nvram->size = size;
|
||||
|
||||
err = sysfs_create_bin_file(&rtc->dev.parent->kobj,
|
||||
rtc->nvram);
|
||||
if (err) {
|
||||
kfree(rtc->nvram);
|
||||
rtc->nvram = NULL;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void rtc_nvram_unregister(struct rtc_device *rtc)
|
||||
{
|
||||
sysfs_remove_bin_file(&rtc->dev.parent->kobj, rtc->nvram);
|
||||
kfree(rtc->nvram);
|
||||
rtc->nvram = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* New ABI, uses nvmem
|
||||
*/
|
||||
int rtc_nvmem_register(struct rtc_device *rtc,
|
||||
int devm_rtc_nvmem_register(struct rtc_device *rtc,
|
||||
struct nvmem_config *nvmem_config)
|
||||
{
|
||||
struct device *dev = rtc->dev.parent;
|
||||
struct nvmem_device *nvmem;
|
||||
|
||||
if (!nvmem_config)
|
||||
return -ENODEV;
|
||||
|
||||
nvmem_config->dev = rtc->dev.parent;
|
||||
nvmem_config->dev = dev;
|
||||
nvmem_config->owner = rtc->owner;
|
||||
nvmem = devm_nvmem_register(rtc->dev.parent, nvmem_config);
|
||||
nvmem = devm_nvmem_register(dev, nvmem_config);
|
||||
if (IS_ERR(nvmem))
|
||||
return PTR_ERR(nvmem);
|
||||
dev_err(dev, "failed to register nvmem device for RTC\n");
|
||||
|
||||
/* Register the old ABI */
|
||||
if (rtc->nvram_old_abi)
|
||||
rtc_nvram_register(rtc, nvmem, nvmem_config->size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rtc_nvmem_register);
|
||||
|
||||
void rtc_nvmem_unregister(struct rtc_device *rtc)
|
||||
{
|
||||
/* unregister the old ABI */
|
||||
if (rtc->nvram)
|
||||
rtc_nvram_unregister(rtc);
|
||||
return PTR_ERR_OR_ZERO(nvmem);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register);
|
||||
|
@ -294,7 +294,7 @@ static int pm80x_rtc_probe(struct platform_device *pdev)
|
||||
info->rtc_dev->ops = &pm80x_rtc_ops;
|
||||
info->rtc_dev->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(info->rtc_dev);
|
||||
ret = devm_rtc_register_device(info->rtc_dev);
|
||||
if (ret)
|
||||
goto out_rtc;
|
||||
|
||||
|
@ -307,7 +307,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
|
||||
info->rtc_dev->ops = &pm860x_rtc_ops;
|
||||
info->rtc_dev->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(info->rtc_dev);
|
||||
ret = devm_rtc_register_device(info->rtc_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -892,7 +892,7 @@ static int abb5zes3_probe(struct i2c_client *client,
|
||||
}
|
||||
}
|
||||
|
||||
ret = rtc_register_device(data->rtc);
|
||||
ret = devm_rtc_register_device(data->rtc);
|
||||
|
||||
err:
|
||||
if (ret && data->irq)
|
||||
|
@ -420,7 +420,7 @@ static int abeoz9_probe(struct i2c_client *client,
|
||||
data->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
data->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
ret = rtc_register_device(data->rtc);
|
||||
ret = devm_rtc_register_device(data->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -238,7 +238,7 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, rtc);
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static struct platform_driver ab3100_rtc_driver = {
|
||||
|
@ -404,7 +404,7 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static int ab8500_rtc_remove(struct platform_device *pdev)
|
||||
|
@ -851,7 +851,7 @@ static int abx80x_probe(struct i2c_client *client,
|
||||
return err;
|
||||
}
|
||||
|
||||
return rtc_register_device(priv->rtc);
|
||||
return devm_rtc_register_device(priv->rtc);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id abx80x_id[] = {
|
||||
|
@ -610,7 +610,7 @@ static int ac100_rtc_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return rtc_register_device(chip->rtc);
|
||||
return devm_rtc_register_device(chip->rtc);
|
||||
}
|
||||
|
||||
static int ac100_rtc_remove(struct platform_device *pdev)
|
||||
|
@ -556,7 +556,7 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
rtc->rtc_dev->range_max = U32_MAX;
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
@ -104,7 +104,7 @@ static int aspeed_rtc_probe(struct platform_device *pdev)
|
||||
rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_1900;
|
||||
rtc->rtc_dev->range_max = 38814989399LL; /* 3199-12-31 23:59:59 */
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
static const struct of_device_id aspeed_rtc_match[] = {
|
||||
|
@ -36,6 +36,10 @@
|
||||
#define AT91_RTC_UPDCAL BIT(1) /* Update Request Calendar Register */
|
||||
|
||||
#define AT91_RTC_MR 0x04 /* Mode Register */
|
||||
#define AT91_RTC_HRMOD BIT(0) /* 12/24 hour mode */
|
||||
#define AT91_RTC_NEGPPM BIT(4) /* Negative PPM correction */
|
||||
#define AT91_RTC_CORRECTION GENMASK(14, 8) /* Slow clock correction */
|
||||
#define AT91_RTC_HIGHPPM BIT(15) /* High PPM correction */
|
||||
|
||||
#define AT91_RTC_TIMR 0x08 /* Time Register */
|
||||
#define AT91_RTC_SEC GENMASK(6, 0) /* Current Second */
|
||||
@ -77,6 +81,9 @@
|
||||
#define AT91_RTC_NVTIMALR BIT(2) /* Non valid Time Alarm */
|
||||
#define AT91_RTC_NVCALALR BIT(3) /* Non valid Calendar Alarm */
|
||||
|
||||
#define AT91_RTC_CORR_DIVIDEND 3906000
|
||||
#define AT91_RTC_CORR_LOW_RATIO 20
|
||||
|
||||
#define at91_rtc_read(field) \
|
||||
readl_relaxed(at91_rtc_regs + field)
|
||||
#define at91_rtc_write(field, val) \
|
||||
@ -84,6 +91,7 @@
|
||||
|
||||
struct at91_rtc_config {
|
||||
bool use_shadow_imr;
|
||||
bool has_correction;
|
||||
};
|
||||
|
||||
static const struct at91_rtc_config *at91_rtc_config;
|
||||
@ -293,6 +301,75 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int at91_rtc_readoffset(struct device *dev, long *offset)
|
||||
{
|
||||
u32 mr = at91_rtc_read(AT91_RTC_MR);
|
||||
long val = FIELD_GET(AT91_RTC_CORRECTION, mr);
|
||||
|
||||
if (!val) {
|
||||
*offset = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
val++;
|
||||
|
||||
if (!(mr & AT91_RTC_NEGPPM))
|
||||
val = -val;
|
||||
|
||||
if (!(mr & AT91_RTC_HIGHPPM))
|
||||
val *= AT91_RTC_CORR_LOW_RATIO;
|
||||
|
||||
*offset = DIV_ROUND_CLOSEST(AT91_RTC_CORR_DIVIDEND, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int at91_rtc_setoffset(struct device *dev, long offset)
|
||||
{
|
||||
long corr;
|
||||
u32 mr;
|
||||
|
||||
if (offset > AT91_RTC_CORR_DIVIDEND / 2)
|
||||
return -ERANGE;
|
||||
if (offset < -AT91_RTC_CORR_DIVIDEND / 2)
|
||||
return -ERANGE;
|
||||
|
||||
mr = at91_rtc_read(AT91_RTC_MR);
|
||||
mr &= ~(AT91_RTC_NEGPPM | AT91_RTC_CORRECTION | AT91_RTC_HIGHPPM);
|
||||
|
||||
if (offset > 0)
|
||||
mr |= AT91_RTC_NEGPPM;
|
||||
else
|
||||
offset = -offset;
|
||||
|
||||
/* offset less than 764 ppb, disable correction*/
|
||||
if (offset < 764) {
|
||||
at91_rtc_write(AT91_RTC_MR, mr & ~AT91_RTC_NEGPPM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 29208 ppb is the perfect cutoff between low range and high range
|
||||
* low range values are never better than high range value after that.
|
||||
*/
|
||||
if (offset < 29208) {
|
||||
corr = DIV_ROUND_CLOSEST(AT91_RTC_CORR_DIVIDEND, offset * AT91_RTC_CORR_LOW_RATIO);
|
||||
} else {
|
||||
corr = DIV_ROUND_CLOSEST(AT91_RTC_CORR_DIVIDEND, offset);
|
||||
mr |= AT91_RTC_HIGHPPM;
|
||||
}
|
||||
|
||||
if (corr > 128)
|
||||
corr = 128;
|
||||
|
||||
mr |= FIELD_PREP(AT91_RTC_CORRECTION, corr - 1);
|
||||
|
||||
at91_rtc_write(AT91_RTC_MR, mr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* IRQ handler for the RTC
|
||||
*/
|
||||
@ -343,6 +420,10 @@ static const struct at91_rtc_config at91sam9x5_config = {
|
||||
.use_shadow_imr = true,
|
||||
};
|
||||
|
||||
static const struct at91_rtc_config sama5d4_config = {
|
||||
.has_correction = true,
|
||||
};
|
||||
|
||||
static const struct of_device_id at91_rtc_dt_ids[] = {
|
||||
{
|
||||
.compatible = "atmel,at91rm9200-rtc",
|
||||
@ -352,10 +433,13 @@ static const struct of_device_id at91_rtc_dt_ids[] = {
|
||||
.data = &at91sam9x5_config,
|
||||
}, {
|
||||
.compatible = "atmel,sama5d4-rtc",
|
||||
.data = &at91rm9200_config,
|
||||
.data = &sama5d4_config,
|
||||
}, {
|
||||
.compatible = "atmel,sama5d2-rtc",
|
||||
.data = &at91rm9200_config,
|
||||
.data = &sama5d4_config,
|
||||
}, {
|
||||
.compatible = "microchip,sam9x60-rtc",
|
||||
.data = &sama5d4_config,
|
||||
}, {
|
||||
/* sentinel */
|
||||
}
|
||||
@ -370,6 +454,16 @@ static const struct rtc_class_ops at91_rtc_ops = {
|
||||
.alarm_irq_enable = at91_rtc_alarm_irq_enable,
|
||||
};
|
||||
|
||||
static const struct rtc_class_ops sama5d4_rtc_ops = {
|
||||
.read_time = at91_rtc_readtime,
|
||||
.set_time = at91_rtc_settime,
|
||||
.read_alarm = at91_rtc_readalarm,
|
||||
.set_alarm = at91_rtc_setalarm,
|
||||
.alarm_irq_enable = at91_rtc_alarm_irq_enable,
|
||||
.set_offset = at91_rtc_setoffset,
|
||||
.read_offset = at91_rtc_readoffset,
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize and install RTC driver
|
||||
*/
|
||||
@ -416,7 +510,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
at91_rtc_write(AT91_RTC_CR, 0);
|
||||
at91_rtc_write(AT91_RTC_MR, 0); /* 24 hour mode */
|
||||
at91_rtc_write(AT91_RTC_MR, at91_rtc_read(AT91_RTC_MR) & ~AT91_RTC_HRMOD);
|
||||
|
||||
/* Disable all interrupts */
|
||||
at91_rtc_write_idr(AT91_RTC_ACKUPD | AT91_RTC_ALARM |
|
||||
@ -437,10 +531,14 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
|
||||
if (!device_can_wakeup(&pdev->dev))
|
||||
device_init_wakeup(&pdev->dev, 1);
|
||||
|
||||
rtc->ops = &at91_rtc_ops;
|
||||
if (at91_rtc_config->has_correction)
|
||||
rtc->ops = &sama5d4_rtc_ops;
|
||||
else
|
||||
rtc->ops = &at91_rtc_ops;
|
||||
|
||||
rtc->range_min = RTC_TIMESTAMP_BEGIN_1900;
|
||||
rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
ret = rtc_register_device(rtc);
|
||||
ret = devm_rtc_register_device(rtc);
|
||||
if (ret)
|
||||
goto err_clk;
|
||||
|
||||
|
@ -431,7 +431,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
|
||||
dev_warn(&pdev->dev, "%s: SET TIME!\n",
|
||||
dev_name(&rtc->rtcdev->dev));
|
||||
|
||||
return rtc_register_device(rtc->rtcdev);
|
||||
return devm_rtc_register_device(rtc->rtcdev);
|
||||
|
||||
err_clk:
|
||||
clk_disable_unprepare(rtc->sclk);
|
||||
|
@ -104,7 +104,7 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, rtcdev);
|
||||
|
||||
return rtc_register_device(rtcdev);
|
||||
return devm_rtc_register_device(rtcdev);
|
||||
}
|
||||
|
||||
static struct platform_driver au1xrtc_driver = {
|
||||
|
@ -604,7 +604,7 @@ static int bd70528_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static const struct platform_device_id bd718x7_rtc_id[] = {
|
||||
|
@ -252,7 +252,7 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev)
|
||||
timer->rtc->ops = &brcmstb_waketmr_ops;
|
||||
timer->rtc->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(timer->rtc);
|
||||
ret = devm_rtc_register_device(timer->rtc);
|
||||
if (ret)
|
||||
goto err_notifier;
|
||||
|
||||
@ -264,8 +264,7 @@ err_notifier:
|
||||
unregister_reboot_notifier(&timer->reboot_notifier);
|
||||
|
||||
err_clk:
|
||||
if (timer->clk)
|
||||
clk_disable_unprepare(timer->clk);
|
||||
clk_disable_unprepare(timer->clk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ static int cdns_rtc_probe(struct platform_device *pdev)
|
||||
writel(0, crtc->regs + CDNS_RTC_HMR);
|
||||
writel(CDNS_RTC_KRTCR_KRTC, crtc->regs + CDNS_RTC_KRTCR);
|
||||
|
||||
ret = rtc_register_device(crtc->rtc_dev);
|
||||
ret = devm_rtc_register_device(crtc->rtc_dev);
|
||||
if (ret)
|
||||
goto err_disable_wakeup;
|
||||
|
||||
|
@ -863,8 +863,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
|
||||
cmos_rtc.rtc->ops = &cmos_rtc_ops_no_alarm;
|
||||
}
|
||||
|
||||
cmos_rtc.rtc->nvram_old_abi = true;
|
||||
retval = rtc_register_device(cmos_rtc.rtc);
|
||||
retval = devm_rtc_register_device(cmos_rtc.rtc);
|
||||
if (retval)
|
||||
goto cleanup2;
|
||||
|
||||
@ -873,8 +872,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
|
||||
|
||||
/* export at least the first block of NVRAM */
|
||||
nvmem_cfg.size = address_space - NVRAM_OFFSET;
|
||||
if (rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg))
|
||||
dev_err(dev, "nvmem registration failed\n");
|
||||
devm_rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg);
|
||||
|
||||
dev_info(dev, "%s%s, %d bytes nvram%s\n",
|
||||
!is_valid_irq(rtc_irq) ? "no alarms" :
|
||||
|
@ -203,7 +203,7 @@ static int __init coh901331_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, rtap);
|
||||
|
||||
ret = rtc_register_device(rtap->rtc);
|
||||
ret = devm_rtc_register_device(rtap->rtc);
|
||||
if (ret)
|
||||
goto out_no_rtc;
|
||||
|
||||
|
@ -269,7 +269,8 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
rtc->alarm_irq = platform_get_irq(pdev, 0);
|
||||
err = devm_request_threaded_irq(dev, rtc->alarm_irq, NULL,
|
||||
cpcap_rtc_alarm_irq, IRQF_TRIGGER_NONE,
|
||||
cpcap_rtc_alarm_irq,
|
||||
IRQF_TRIGGER_NONE | IRQF_ONESHOT,
|
||||
"rtc_alarm", rtc);
|
||||
if (err) {
|
||||
dev_err(dev, "Could not request alarm irq: %d\n", err);
|
||||
@ -285,7 +286,8 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
|
||||
*/
|
||||
rtc->update_irq = platform_get_irq(pdev, 1);
|
||||
err = devm_request_threaded_irq(dev, rtc->update_irq, NULL,
|
||||
cpcap_rtc_update_irq, IRQF_TRIGGER_NONE,
|
||||
cpcap_rtc_update_irq,
|
||||
IRQF_TRIGGER_NONE | IRQF_ONESHOT,
|
||||
"rtc_1hz", rtc);
|
||||
if (err) {
|
||||
dev_err(dev, "Could not request update irq: %d\n", err);
|
||||
@ -299,7 +301,7 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
|
||||
/* ignore error and continue without wakeup support */
|
||||
}
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
static const struct of_device_id cpcap_rtc_of_match[] = {
|
||||
|
@ -350,7 +350,7 @@ static int cros_ec_rtc_probe(struct platform_device *pdev)
|
||||
cros_ec_rtc->rtc->ops = &cros_ec_rtc_ops;
|
||||
cros_ec_rtc->rtc->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(cros_ec_rtc->rtc);
|
||||
ret = devm_rtc_register_device(cros_ec_rtc->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -304,7 +304,7 @@ static int da9052_rtc_probe(struct platform_device *pdev)
|
||||
rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rtc->rtc->range_max = RTC_TIMESTAMP_END_2063;
|
||||
|
||||
ret = rtc_register_device(rtc->rtc);
|
||||
ret = devm_rtc_register_device(rtc->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -243,7 +243,7 @@ static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
al_secs = rtc_tm_to_time64(&rtc->alarm_time);
|
||||
|
||||
/* handle the rtc synchronisation delay */
|
||||
if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
|
||||
if (rtc->rtc_sync && al_secs - tm_secs == 1)
|
||||
memcpy(tm, &rtc->alarm_time, sizeof(struct rtc_time));
|
||||
else
|
||||
rtc->rtc_sync = false;
|
||||
@ -494,7 +494,7 @@ static int da9063_rtc_probe(struct platform_device *pdev)
|
||||
dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n",
|
||||
irq_alarm, ret);
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
static struct platform_driver da9063_rtc_driver = {
|
||||
|
@ -484,7 +484,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
device_init_wakeup(&pdev->dev, 0);
|
||||
|
||||
return rtc_register_device(davinci_rtc->rtc);
|
||||
return devm_rtc_register_device(davinci_rtc->rtc);
|
||||
}
|
||||
|
||||
static int __exit davinci_rtc_remove(struct platform_device *pdev)
|
||||
|
@ -202,7 +202,7 @@ static int __init dc_rtc_probe(struct platform_device *pdev)
|
||||
rtc->rtc_dev->ops = &dc_rtc_ops;
|
||||
rtc->rtc_dev->range_max = U32_MAX;
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
static const struct of_device_id dc_dt_ids[] = {
|
||||
|
@ -132,7 +132,7 @@ static int dm355evm_rtc_probe(struct platform_device *pdev)
|
||||
rtc->ops = &dm355evm_rtc_ops;
|
||||
rtc->range_max = U32_MAX;
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -694,12 +694,11 @@ static int ds1305_probe(struct spi_device *spi)
|
||||
ds1305->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
ds1305_nvmem_cfg.priv = ds1305;
|
||||
ds1305->rtc->nvram_old_abi = true;
|
||||
status = rtc_register_device(ds1305->rtc);
|
||||
status = devm_rtc_register_device(ds1305->rtc);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
rtc_nvmem_register(ds1305->rtc, &ds1305_nvmem_cfg);
|
||||
devm_rtc_nvmem_register(ds1305->rtc, &ds1305_nvmem_cfg);
|
||||
|
||||
/* Maybe set up alarm IRQ; be ready to handle it triggering right
|
||||
* away. NOTE that we don't share this. The signal is active low,
|
||||
|
@ -8,12 +8,12 @@
|
||||
* Copyright (C) 2012 Bertrand Achard (nvram access fixes)
|
||||
*/
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/bcd.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/rtc/ds1307.h>
|
||||
#include <linux/rtc.h>
|
||||
#include <linux/slab.h>
|
||||
@ -31,6 +31,7 @@
|
||||
* That's a natural job for a factory or repair bench.
|
||||
*/
|
||||
enum ds_type {
|
||||
unknown_ds_type, /* always first and 0 */
|
||||
ds_1307,
|
||||
ds_1308,
|
||||
ds_1337,
|
||||
@ -1090,7 +1091,6 @@ static const struct i2c_device_id ds1307_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ds1307_id);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id ds1307_of_match[] = {
|
||||
{
|
||||
.compatible = "dallas,ds1307",
|
||||
@ -1167,32 +1167,6 @@ static const struct of_device_id ds1307_of_match[] = {
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ds1307_of_match);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
static const struct acpi_device_id ds1307_acpi_ids[] = {
|
||||
{ .id = "DS1307", .driver_data = ds_1307 },
|
||||
{ .id = "DS1308", .driver_data = ds_1308 },
|
||||
{ .id = "DS1337", .driver_data = ds_1337 },
|
||||
{ .id = "DS1338", .driver_data = ds_1338 },
|
||||
{ .id = "DS1339", .driver_data = ds_1339 },
|
||||
{ .id = "DS1388", .driver_data = ds_1388 },
|
||||
{ .id = "DS1340", .driver_data = ds_1340 },
|
||||
{ .id = "DS1341", .driver_data = ds_1341 },
|
||||
{ .id = "DS3231", .driver_data = ds_3231 },
|
||||
{ .id = "M41T0", .driver_data = m41t0 },
|
||||
{ .id = "M41T00", .driver_data = m41t00 },
|
||||
{ .id = "M41T11", .driver_data = m41t11 },
|
||||
{ .id = "MCP7940X", .driver_data = mcp794xx },
|
||||
{ .id = "MCP7941X", .driver_data = mcp794xx },
|
||||
{ .id = "PT7C4338", .driver_data = ds_1307 },
|
||||
{ .id = "RX8025", .driver_data = rx_8025 },
|
||||
{ .id = "ISL12057", .driver_data = ds_1337 },
|
||||
{ .id = "RX8130", .driver_data = rx_8130 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, ds1307_acpi_ids);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ds1337 and ds1339 both have two alarms, but we only use the first
|
||||
@ -1626,13 +1600,16 @@ static const struct clk_ops ds3231_clk_32khz_ops = {
|
||||
.recalc_rate = ds3231_clk_32khz_recalc_rate,
|
||||
};
|
||||
|
||||
static const char *ds3231_clks_names[] = {
|
||||
[DS3231_CLK_SQW] = "ds3231_clk_sqw",
|
||||
[DS3231_CLK_32KHZ] = "ds3231_clk_32khz",
|
||||
};
|
||||
|
||||
static struct clk_init_data ds3231_clks_init[] = {
|
||||
[DS3231_CLK_SQW] = {
|
||||
.name = "ds3231_clk_sqw",
|
||||
.ops = &ds3231_clk_sqw_ops,
|
||||
},
|
||||
[DS3231_CLK_32KHZ] = {
|
||||
.name = "ds3231_clk_32khz",
|
||||
.ops = &ds3231_clk_32khz_ops,
|
||||
},
|
||||
};
|
||||
@ -1653,6 +1630,11 @@ static int ds3231_clks_register(struct ds1307 *ds1307)
|
||||
if (!onecell->clks)
|
||||
return -ENOMEM;
|
||||
|
||||
/* optional override of the clockname */
|
||||
device_property_read_string_array(ds1307->dev, "clock-output-names",
|
||||
ds3231_clks_names,
|
||||
ARRAY_SIZE(ds3231_clks_names));
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(ds3231_clks_init); i++) {
|
||||
struct clk_init_data init = ds3231_clks_init[i];
|
||||
|
||||
@ -1663,9 +1645,7 @@ static int ds3231_clks_register(struct ds1307 *ds1307)
|
||||
if (i == DS3231_CLK_SQW && test_bit(HAS_ALARM, &ds1307->flags))
|
||||
continue;
|
||||
|
||||
/* optional override of the clockname */
|
||||
of_property_read_string_index(node, "clock-output-names", i,
|
||||
&init.name);
|
||||
init.name = ds3231_clks_names[i];
|
||||
ds1307->clks[i].init = &init;
|
||||
|
||||
onecell->clks[i] = devm_clk_register(ds1307->dev,
|
||||
@ -1674,10 +1654,8 @@ static int ds3231_clks_register(struct ds1307 *ds1307)
|
||||
return PTR_ERR(onecell->clks[i]);
|
||||
}
|
||||
|
||||
if (!node)
|
||||
return 0;
|
||||
|
||||
of_clk_add_provider(node, of_clk_src_onecell_get, onecell);
|
||||
if (node)
|
||||
of_clk_add_provider(node, of_clk_src_onecell_get, onecell);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1761,6 +1739,7 @@ static int ds1307_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct ds1307 *ds1307;
|
||||
const void *match;
|
||||
int err = -ENODEV;
|
||||
int tmp;
|
||||
const struct chip_desc *chip;
|
||||
@ -1786,22 +1765,15 @@ static int ds1307_probe(struct i2c_client *client,
|
||||
|
||||
i2c_set_clientdata(client, ds1307);
|
||||
|
||||
if (client->dev.of_node) {
|
||||
ds1307->type = (enum ds_type)
|
||||
of_device_get_match_data(&client->dev);
|
||||
match = device_get_match_data(&client->dev);
|
||||
if (match) {
|
||||
ds1307->type = (enum ds_type)match;
|
||||
chip = &chips[ds1307->type];
|
||||
} else if (id) {
|
||||
chip = &chips[id->driver_data];
|
||||
ds1307->type = id->driver_data;
|
||||
} else {
|
||||
const struct acpi_device_id *acpi_id;
|
||||
|
||||
acpi_id = acpi_match_device(ACPI_PTR(ds1307_acpi_ids),
|
||||
ds1307->dev);
|
||||
if (!acpi_id)
|
||||
return -ENODEV;
|
||||
chip = &chips[acpi_id->driver_data];
|
||||
ds1307->type = acpi_id->driver_data;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
want_irq = client->irq > 0 && chip->alarm;
|
||||
@ -1819,7 +1791,6 @@ static int ds1307_probe(struct i2c_client *client,
|
||||
trickle_charger_setup);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
/*
|
||||
* For devices with no IRQ directly connected to the SoC, the RTC chip
|
||||
* can be forced as a wakeup source by stating that explicitly in
|
||||
@ -1828,10 +1799,8 @@ static int ds1307_probe(struct i2c_client *client,
|
||||
* This will guarantee the 'wakealarm' sysfs entry is available on the device,
|
||||
* if supported by the RTC.
|
||||
*/
|
||||
if (chip->alarm && of_property_read_bool(client->dev.of_node,
|
||||
"wakeup-source"))
|
||||
if (chip->alarm && device_property_read_bool(&client->dev, "wakeup-source"))
|
||||
ds1307_can_wakeup_device = true;
|
||||
#endif
|
||||
|
||||
switch (ds1307->type) {
|
||||
case ds_1337:
|
||||
@ -2032,7 +2001,7 @@ static int ds1307_probe(struct i2c_client *client,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = rtc_register_device(ds1307->rtc);
|
||||
err = devm_rtc_register_device(ds1307->rtc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -2047,8 +2016,7 @@ static int ds1307_probe(struct i2c_client *client,
|
||||
.priv = ds1307,
|
||||
};
|
||||
|
||||
ds1307->rtc->nvram_old_abi = true;
|
||||
rtc_nvmem_register(ds1307->rtc, &nvmem_cfg);
|
||||
devm_rtc_nvmem_register(ds1307->rtc, &nvmem_cfg);
|
||||
}
|
||||
|
||||
ds1307_hwmon_register(ds1307);
|
||||
@ -2064,8 +2032,7 @@ exit:
|
||||
static struct i2c_driver ds1307_driver = {
|
||||
.driver = {
|
||||
.name = "rtc-ds1307",
|
||||
.of_match_table = of_match_ptr(ds1307_of_match),
|
||||
.acpi_match_table = ACPI_PTR(ds1307_acpi_ids),
|
||||
.of_match_table = ds1307_of_match,
|
||||
},
|
||||
.probe = ds1307_probe,
|
||||
.id_table = ds1307_id,
|
||||
|
@ -399,7 +399,6 @@ static int ds1343_probe(struct spi_device *spi)
|
||||
if (IS_ERR(priv->rtc))
|
||||
return PTR_ERR(priv->rtc);
|
||||
|
||||
priv->rtc->nvram_old_abi = true;
|
||||
priv->rtc->ops = &ds1343_rtc_ops;
|
||||
priv->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
priv->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
@ -409,12 +408,12 @@ static int ds1343_probe(struct spi_device *spi)
|
||||
dev_err(&spi->dev,
|
||||
"unable to create sysfs entries for rtc ds1343\n");
|
||||
|
||||
res = rtc_register_device(priv->rtc);
|
||||
res = devm_rtc_register_device(priv->rtc);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
nvmem_cfg.priv = priv;
|
||||
rtc_nvmem_register(priv->rtc, &nvmem_cfg);
|
||||
devm_rtc_nvmem_register(priv->rtc, &nvmem_cfg);
|
||||
|
||||
priv->irq = spi->irq;
|
||||
|
||||
|
@ -166,7 +166,7 @@ static int ds1347_probe(struct spi_device *spi)
|
||||
rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
|
||||
rtc->range_max = RTC_TIMESTAMP_END_9999;
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static struct spi_driver ds1347_driver = {
|
||||
|
@ -508,7 +508,7 @@ static int ds1374_probe(struct i2c_client *client,
|
||||
ds1374->rtc->ops = &ds1374_rtc_ops;
|
||||
ds1374->rtc->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(ds1374->rtc);
|
||||
ret = devm_rtc_register_device(ds1374->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -466,13 +466,11 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
pdata->rtc->ops = &ds1511_rtc_ops;
|
||||
|
||||
pdata->rtc->nvram_old_abi = true;
|
||||
|
||||
ret = rtc_register_device(pdata->rtc);
|
||||
ret = devm_rtc_register_device(pdata->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
rtc_nvmem_register(pdata->rtc, &ds1511_nvmem_cfg);
|
||||
devm_rtc_nvmem_register(pdata->rtc, &ds1511_nvmem_cfg);
|
||||
|
||||
/*
|
||||
* if the platform has an interrupt in mind for this device,
|
||||
|
@ -294,9 +294,8 @@ static int ds1553_rtc_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(pdata->rtc);
|
||||
|
||||
pdata->rtc->ops = &ds1553_rtc_ops;
|
||||
pdata->rtc->nvram_old_abi = true;
|
||||
|
||||
ret = rtc_register_device(pdata->rtc);
|
||||
ret = devm_rtc_register_device(pdata->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -310,8 +309,7 @@ static int ds1553_rtc_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
if (rtc_nvmem_register(pdata->rtc, &nvmem_cfg))
|
||||
dev_err(&pdev->dev, "unable to register nvmem\n");
|
||||
devm_rtc_nvmem_register(pdata->rtc, &nvmem_cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ static int ds1672_probe(struct i2c_client *client,
|
||||
rtc->ops = &ds1672_rtc_ops;
|
||||
rtc->range_max = U32_MAX;
|
||||
|
||||
err = rtc_register_device(rtc);
|
||||
err = devm_rtc_register_device(rtc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -1316,13 +1316,12 @@ ds1685_rtc_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
rtc_dev->nvram_old_abi = true;
|
||||
nvmem_cfg.priv = rtc;
|
||||
ret = rtc_nvmem_register(rtc_dev, &nvmem_cfg);
|
||||
ret = devm_rtc_nvmem_register(rtc_dev, &nvmem_cfg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return rtc_register_device(rtc_dev);
|
||||
return devm_rtc_register_device(rtc_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,14 +190,12 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(rtc);
|
||||
|
||||
rtc->ops = &ds1742_rtc_ops;
|
||||
rtc->nvram_old_abi = true;
|
||||
|
||||
ret = rtc_register_device(rtc);
|
||||
ret = devm_rtc_register_device(rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (rtc_nvmem_register(rtc, &nvmem_cfg))
|
||||
dev_err(&pdev->dev, "Unable to register nvmem\n");
|
||||
devm_rtc_nvmem_register(rtc, &nvmem_cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ static int rtc_probe(struct platform_device *pdev)
|
||||
chip->rtc->ops = &ds2404_rtc_ops;
|
||||
chip->rtc->range_max = U32_MAX;
|
||||
|
||||
retval = rtc_register_device(chip->rtc);
|
||||
retval = devm_rtc_register_device(chip->rtc);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@ -518,7 +518,7 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
|
||||
if (IS_ERR(ds3232->rtc))
|
||||
return PTR_ERR(ds3232->rtc);
|
||||
|
||||
ret = rtc_nvmem_register(ds3232->rtc, &nvmem_cfg);
|
||||
ret = devm_rtc_nvmem_register(ds3232->rtc, &nvmem_cfg);
|
||||
if(ret)
|
||||
return ret;
|
||||
|
||||
|
@ -33,7 +33,7 @@ struct ep93xx_rtc {
|
||||
static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
|
||||
unsigned short *delete)
|
||||
{
|
||||
struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev);
|
||||
struct ep93xx_rtc *ep93xx_rtc = dev_get_drvdata(dev);
|
||||
unsigned long comp;
|
||||
|
||||
comp = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP);
|
||||
@ -51,7 +51,7 @@ static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
|
||||
|
||||
static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
{
|
||||
struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev);
|
||||
struct ep93xx_rtc *ep93xx_rtc = dev_get_drvdata(dev);
|
||||
unsigned long time;
|
||||
|
||||
time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
|
||||
@ -62,7 +62,7 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
|
||||
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_drvdata(dev);
|
||||
unsigned long secs = rtc_tm_to_time64(tm);
|
||||
|
||||
writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD);
|
||||
@ -145,7 +145,7 @@ static int ep93xx_rtc_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return rtc_register_device(ep93xx_rtc->rtc);
|
||||
return devm_rtc_register_device(ep93xx_rtc->rtc);
|
||||
}
|
||||
|
||||
static struct platform_driver ep93xx_rtc_driver = {
|
||||
|
@ -290,7 +290,7 @@ static int ftm_rtc_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "failed to enable irq wake\n");
|
||||
|
||||
ret = rtc_register_device(rtc->rtc_dev);
|
||||
ret = devm_rtc_register_device(rtc->rtc_dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "can't register rtc device\n");
|
||||
return ret;
|
||||
|
@ -176,7 +176,7 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
static int ftrtc010_rtc_remove(struct platform_device *pdev)
|
||||
|
@ -194,7 +194,7 @@ static int goldfish_rtc_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return rtc_register_device(rtcdrv->rtc);
|
||||
return devm_rtc_register_device(rtcdrv->rtc);
|
||||
}
|
||||
|
||||
static const struct of_device_id goldfish_rtc_of_match[] = {
|
||||
|
@ -527,8 +527,6 @@ static int hym8563_probe(struct i2c_client *client,
|
||||
hym8563->client = client;
|
||||
i2c_set_clientdata(client, hym8563);
|
||||
|
||||
device_set_wakeup_capable(&client->dev, true);
|
||||
|
||||
ret = hym8563_init_device(client);
|
||||
if (ret) {
|
||||
dev_err(&client->dev, "could not init device, %d\n", ret);
|
||||
@ -547,6 +545,11 @@ static int hym8563_probe(struct i2c_client *client,
|
||||
}
|
||||
}
|
||||
|
||||
if (client->irq > 0 ||
|
||||
device_property_read_bool(&client->dev, "wakeup-source")) {
|
||||
device_init_wakeup(&client->dev, true);
|
||||
}
|
||||
|
||||
/* check state of calendar information */
|
||||
ret = i2c_smbus_read_byte_data(client, HYM8563_SEC);
|
||||
if (ret < 0)
|
||||
|
@ -166,7 +166,7 @@ static int imx_sc_rtc_probe(struct platform_device *pdev)
|
||||
imx_sc_rtc->range_min = 0;
|
||||
imx_sc_rtc->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(imx_sc_rtc);
|
||||
ret = devm_rtc_register_device(imx_sc_rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -814,7 +814,7 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
|
||||
imxdi->rtc->ops = &dryice_rtc_ops;
|
||||
imxdi->rtc->range_max = U32_MAX;
|
||||
|
||||
rc = rtc_register_device(imxdi->rtc);
|
||||
rc = devm_rtc_register_device(imxdi->rtc);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
|
@ -465,11 +465,11 @@ static int isl12026_probe_new(struct i2c_client *client)
|
||||
|
||||
priv->rtc->ops = &isl12026_rtc_ops;
|
||||
nvm_cfg.priv = priv;
|
||||
ret = rtc_nvmem_register(priv->rtc, &nvm_cfg);
|
||||
ret = devm_rtc_nvmem_register(priv->rtc, &nvm_cfg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return rtc_register_device(priv->rtc);
|
||||
return devm_rtc_register_device(priv->rtc);
|
||||
}
|
||||
|
||||
static int isl12026_remove(struct i2c_client *client)
|
||||
|
@ -890,11 +890,11 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = rtc_nvmem_register(isl1208->rtc, &isl1208->nvmem_config);
|
||||
rc = devm_rtc_nvmem_register(isl1208->rtc, &isl1208->nvmem_config);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return rtc_register_device(isl1208->rtc);
|
||||
return devm_rtc_register_device(isl1208->rtc);
|
||||
}
|
||||
|
||||
static struct i2c_driver isl1208_driver = {
|
||||
|
@ -375,7 +375,7 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
|
||||
/* Each 1 Hz pulse should happen after (rate) ticks */
|
||||
jz4740_rtc_reg_write(rtc, JZ_REG_RTC_REGULATOR, rate - 1);
|
||||
|
||||
ret = rtc_register_device(rtc->rtc);
|
||||
ret = devm_rtc_register_device(rtc->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -239,7 +239,7 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev)
|
||||
rtc->rtc->ops = &lpc32xx_rtc_ops;
|
||||
rtc->rtc->range_max = U32_MAX;
|
||||
|
||||
err = rtc_register_device(rtc->rtc);
|
||||
err = devm_rtc_register_device(rtc->rtc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -176,7 +176,7 @@ static int ls1x_rtc_probe(struct platform_device *pdev)
|
||||
rtcdev->range_min = RTC_TIMESTAMP_BEGIN_1900;
|
||||
rtcdev->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
return rtc_register_device(rtcdev);
|
||||
return devm_rtc_register_device(rtcdev);
|
||||
}
|
||||
|
||||
static struct platform_driver ls1x_rtc_driver = {
|
||||
|
@ -977,7 +977,7 @@ static int m41t80_probe(struct i2c_client *client,
|
||||
m41t80_sqw_register_clk(m41t80_data);
|
||||
#endif
|
||||
|
||||
rc = rtc_register_device(m41t80_data->rtc);
|
||||
rc = devm_rtc_register_device(m41t80_data->rtc);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
|
@ -463,15 +463,14 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(m48t59->rtc))
|
||||
return PTR_ERR(m48t59->rtc);
|
||||
|
||||
m48t59->rtc->nvram_old_abi = true;
|
||||
m48t59->rtc->ops = ops;
|
||||
|
||||
nvmem_cfg.size = pdata->offset;
|
||||
ret = rtc_nvmem_register(m48t59->rtc, &nvmem_cfg);
|
||||
ret = devm_rtc_nvmem_register(m48t59->rtc, &nvmem_cfg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = rtc_register_device(m48t59->rtc);
|
||||
ret = devm_rtc_register_device(m48t59->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -254,13 +254,12 @@ static int m48t86_rtc_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(info->rtc);
|
||||
|
||||
info->rtc->ops = &m48t86_rtc_ops;
|
||||
info->rtc->nvram_old_abi = true;
|
||||
|
||||
err = rtc_register_device(info->rtc);
|
||||
err = devm_rtc_register_device(info->rtc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
rtc_nvmem_register(info->rtc, &m48t86_nvmem_cfg);
|
||||
devm_rtc_nvmem_register(info->rtc, &m48t86_nvmem_cfg);
|
||||
|
||||
/* read battery status */
|
||||
reg = m48t86_readb(&pdev->dev, M48T86_D);
|
||||
|
@ -307,7 +307,7 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
mc13xxx_unlock(mc13xxx);
|
||||
|
||||
ret = rtc_register_device(priv->rtc);
|
||||
ret = devm_rtc_register_device(priv->rtc);
|
||||
if (ret) {
|
||||
mc13xxx_lock(mc13xxx);
|
||||
goto err_irq_request;
|
||||
|
@ -83,7 +83,7 @@ static int meson_vrtc_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(vrtc->rtc);
|
||||
|
||||
vrtc->rtc->ops = &meson_vrtc_ops;
|
||||
return rtc_register_device(vrtc->rtc);
|
||||
return devm_rtc_register_device(vrtc->rtc);
|
||||
}
|
||||
|
||||
static int __maybe_unused meson_vrtc_suspend(struct device *dev)
|
||||
|
@ -365,11 +365,11 @@ static int meson_rtc_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
meson_rtc_nvmem_config.priv = rtc;
|
||||
ret = rtc_nvmem_register(rtc->rtc, &meson_rtc_nvmem_config);
|
||||
ret = devm_rtc_nvmem_register(rtc->rtc, &meson_rtc_nvmem_config);
|
||||
if (ret)
|
||||
goto out_disable_vdd;
|
||||
|
||||
ret = rtc_register_device(rtc->rtc);
|
||||
ret = devm_rtc_register_device(rtc->rtc);
|
||||
if (ret)
|
||||
goto out_disable_vdd;
|
||||
|
||||
|
@ -371,7 +371,7 @@ static int mpc5121_rtc_probe(struct platform_device *op)
|
||||
rtc->rtc->range_max = U32_MAX;
|
||||
}
|
||||
|
||||
err = rtc_register_device(rtc->rtc);
|
||||
err = devm_rtc_register_device(rtc->rtc);
|
||||
if (err)
|
||||
goto out_dispose2;
|
||||
|
||||
|
@ -361,7 +361,7 @@ static int vrtc_mrst_do_probe(struct device *dev, struct resource *iomem,
|
||||
}
|
||||
}
|
||||
|
||||
retval = rtc_register_device(mrst_rtc.rtc);
|
||||
retval = devm_rtc_register_device(mrst_rtc.rtc);
|
||||
if (retval)
|
||||
goto cleanup0;
|
||||
|
||||
|
@ -352,7 +352,7 @@ static int mt2712_rtc_probe(struct platform_device *pdev)
|
||||
mt2712_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
mt2712_rtc->rtc->range_max = MT2712_RTC_TIMESTAMP_END_2127;
|
||||
|
||||
return rtc_register_device(mt2712_rtc->rtc);
|
||||
return devm_rtc_register_device(mt2712_rtc->rtc);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
@ -301,7 +301,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
rtc->rtc_dev->ops = &mtk_rtc_ops;
|
||||
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
return devm_rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
@ -278,7 +278,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
|
||||
pdata->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
pdata->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
ret = rtc_register_device(pdata->rtc);
|
||||
ret = devm_rtc_register_device(pdata->rtc);
|
||||
if (!ret)
|
||||
return 0;
|
||||
out:
|
||||
|
@ -70,27 +70,12 @@ struct rtc_plat_data {
|
||||
enum imx_rtc_type devtype;
|
||||
};
|
||||
|
||||
static const struct platform_device_id imx_rtc_devtype[] = {
|
||||
{
|
||||
.name = "imx1-rtc",
|
||||
.driver_data = IMX1_RTC,
|
||||
}, {
|
||||
.name = "imx21-rtc",
|
||||
.driver_data = IMX21_RTC,
|
||||
}, {
|
||||
/* sentinel */
|
||||
}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(platform, imx_rtc_devtype);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id imx_rtc_dt_ids[] = {
|
||||
{ .compatible = "fsl,imx1-rtc", .data = (const void *)IMX1_RTC },
|
||||
{ .compatible = "fsl,imx21-rtc", .data = (const void *)IMX21_RTC },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, imx_rtc_dt_ids);
|
||||
#endif
|
||||
|
||||
static inline int is_imx1_rtc(struct rtc_plat_data *data)
|
||||
{
|
||||
@ -322,17 +307,12 @@ static int mxc_rtc_probe(struct platform_device *pdev)
|
||||
u32 reg;
|
||||
unsigned long rate;
|
||||
int ret;
|
||||
const struct of_device_id *of_id;
|
||||
|
||||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return -ENOMEM;
|
||||
|
||||
of_id = of_match_device(imx_rtc_dt_ids, &pdev->dev);
|
||||
if (of_id)
|
||||
pdata->devtype = (enum imx_rtc_type)of_id->data;
|
||||
else
|
||||
pdata->devtype = pdev->id_entry->driver_data;
|
||||
pdata->devtype = (enum imx_rtc_type)of_device_get_match_data(&pdev->dev);
|
||||
|
||||
pdata->ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(pdata->ioaddr))
|
||||
@ -428,7 +408,7 @@ static int mxc_rtc_probe(struct platform_device *pdev)
|
||||
dev_err(&pdev->dev, "failed to enable irq wake\n");
|
||||
}
|
||||
|
||||
ret = rtc_register_device(rtc);
|
||||
ret = devm_rtc_register_device(rtc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -438,7 +418,6 @@ static struct platform_driver mxc_rtc_driver = {
|
||||
.name = "mxc_rtc",
|
||||
.of_match_table = of_match_ptr(imx_rtc_dt_ids),
|
||||
},
|
||||
.id_table = imx_rtc_devtype,
|
||||
.probe = mxc_rtc_probe,
|
||||
};
|
||||
|
||||
|
@ -354,7 +354,7 @@ static int mxc_rtc_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = rtc_register_device(pdata->rtc);
|
||||
ret = devm_rtc_register_device(pdata->rtc);
|
||||
if (ret < 0)
|
||||
clk_unprepare(pdata->clk);
|
||||
|
||||
|
@ -879,18 +879,18 @@ static int omap_rtc_probe(struct platform_device *pdev)
|
||||
/* Support ext_wakeup pinconf */
|
||||
rtc_pinctrl_desc.name = dev_name(&pdev->dev);
|
||||
|
||||
rtc->pctldev = pinctrl_register(&rtc_pinctrl_desc, &pdev->dev, rtc);
|
||||
rtc->pctldev = devm_pinctrl_register(&pdev->dev, &rtc_pinctrl_desc, rtc);
|
||||
if (IS_ERR(rtc->pctldev)) {
|
||||
dev_err(&pdev->dev, "Couldn't register pinctrl driver\n");
|
||||
ret = PTR_ERR(rtc->pctldev);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = rtc_register_device(rtc->rtc);
|
||||
ret = devm_rtc_register_device(rtc->rtc);
|
||||
if (ret)
|
||||
goto err_deregister_pinctrl;
|
||||
goto err;
|
||||
|
||||
rtc_nvmem_register(rtc->rtc, &omap_rtc_nvmem_config);
|
||||
devm_rtc_nvmem_register(rtc->rtc, &omap_rtc_nvmem_config);
|
||||
|
||||
if (rtc->is_pmic_controller) {
|
||||
if (!pm_power_off) {
|
||||
@ -901,8 +901,6 @@ static int omap_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
return 0;
|
||||
|
||||
err_deregister_pinctrl:
|
||||
pinctrl_unregister(rtc->pctldev);
|
||||
err:
|
||||
clk_disable_unprepare(rtc->clk);
|
||||
device_init_wakeup(&pdev->dev, false);
|
||||
@ -945,9 +943,6 @@ static int omap_rtc_remove(struct platform_device *pdev)
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
/* Remove ext_wakeup pinconf */
|
||||
pinctrl_unregister(rtc->pctldev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return rtc_register_device(pcap_rtc->rtc);
|
||||
return devm_rtc_register_device(pcap_rtc->rtc);
|
||||
}
|
||||
|
||||
static int __exit pcap_rtc_remove(struct platform_device *pdev)
|
||||
|
@ -434,7 +434,7 @@ static int pcf2123_probe(struct spi_device *spi)
|
||||
rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
rtc->set_start_time = true;
|
||||
|
||||
ret = rtc_register_device(rtc);
|
||||
ret = devm_rtc_register_device(rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -243,10 +243,8 @@ static int pcf2127_nvmem_read(void *priv, unsigned int offset,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = regmap_bulk_read(pcf2127->regmap, PCF2127_REG_RAM_RD_CMD,
|
||||
val, bytes);
|
||||
|
||||
return ret ?: bytes;
|
||||
return regmap_bulk_read(pcf2127->regmap, PCF2127_REG_RAM_RD_CMD,
|
||||
val, bytes);
|
||||
}
|
||||
|
||||
static int pcf2127_nvmem_write(void *priv, unsigned int offset,
|
||||
@ -261,10 +259,8 @@ static int pcf2127_nvmem_write(void *priv, unsigned int offset,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = regmap_bulk_write(pcf2127->regmap, PCF2127_REG_RAM_WRT_CMD,
|
||||
val, bytes);
|
||||
|
||||
return ret ?: bytes;
|
||||
return regmap_bulk_write(pcf2127->regmap, PCF2127_REG_RAM_WRT_CMD,
|
||||
val, bytes);
|
||||
}
|
||||
|
||||
/* watchdog driver */
|
||||
@ -335,6 +331,37 @@ static const struct watchdog_ops pcf2127_watchdog_ops = {
|
||||
.set_timeout = pcf2127_wdt_set_timeout,
|
||||
};
|
||||
|
||||
static int pcf2127_watchdog_init(struct device *dev, struct pcf2127 *pcf2127)
|
||||
{
|
||||
u32 wdd_timeout;
|
||||
int ret;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_WATCHDOG) ||
|
||||
!device_property_read_bool(dev, "reset-source"))
|
||||
return 0;
|
||||
|
||||
pcf2127->wdd.parent = dev;
|
||||
pcf2127->wdd.info = &pcf2127_wdt_info;
|
||||
pcf2127->wdd.ops = &pcf2127_watchdog_ops;
|
||||
pcf2127->wdd.min_timeout = PCF2127_WD_VAL_MIN;
|
||||
pcf2127->wdd.max_timeout = PCF2127_WD_VAL_MAX;
|
||||
pcf2127->wdd.timeout = PCF2127_WD_VAL_DEFAULT;
|
||||
pcf2127->wdd.min_hw_heartbeat_ms = 500;
|
||||
pcf2127->wdd.status = WATCHDOG_NOWAYOUT_INIT_STATUS;
|
||||
|
||||
watchdog_set_drvdata(&pcf2127->wdd, pcf2127);
|
||||
|
||||
/* Test if watchdog timer is started by bootloader */
|
||||
ret = regmap_read(pcf2127->regmap, PCF2127_REG_WD_VAL, &wdd_timeout);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (wdd_timeout)
|
||||
set_bit(WDOG_HW_RUNNING, &pcf2127->wdd.status);
|
||||
|
||||
return devm_watchdog_register_device(dev, &pcf2127->wdd);
|
||||
}
|
||||
|
||||
/* Alarm */
|
||||
static int pcf2127_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
{
|
||||
@ -536,7 +563,6 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||
int alarm_irq, const char *name, bool has_nvmem)
|
||||
{
|
||||
struct pcf2127 *pcf2127;
|
||||
u32 wdd_timeout;
|
||||
int ret = 0;
|
||||
|
||||
dev_dbg(dev, "%s\n", __func__);
|
||||
@ -575,17 +601,6 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||
pcf2127->rtc->ops = &pcf2127_rtc_alrm_ops;
|
||||
}
|
||||
|
||||
pcf2127->wdd.parent = dev;
|
||||
pcf2127->wdd.info = &pcf2127_wdt_info;
|
||||
pcf2127->wdd.ops = &pcf2127_watchdog_ops;
|
||||
pcf2127->wdd.min_timeout = PCF2127_WD_VAL_MIN;
|
||||
pcf2127->wdd.max_timeout = PCF2127_WD_VAL_MAX;
|
||||
pcf2127->wdd.timeout = PCF2127_WD_VAL_DEFAULT;
|
||||
pcf2127->wdd.min_hw_heartbeat_ms = 500;
|
||||
pcf2127->wdd.status = WATCHDOG_NOWAYOUT_INIT_STATUS;
|
||||
|
||||
watchdog_set_drvdata(&pcf2127->wdd, pcf2127);
|
||||
|
||||
if (has_nvmem) {
|
||||
struct nvmem_config nvmem_cfg = {
|
||||
.priv = pcf2127,
|
||||
@ -594,7 +609,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||
.size = 512,
|
||||
};
|
||||
|
||||
ret = rtc_nvmem_register(pcf2127->rtc, &nvmem_cfg);
|
||||
ret = devm_rtc_nvmem_register(pcf2127->rtc, &nvmem_cfg);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -615,19 +630,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Test if watchdog timer is started by bootloader */
|
||||
ret = regmap_read(pcf2127->regmap, PCF2127_REG_WD_VAL, &wdd_timeout);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (wdd_timeout)
|
||||
set_bit(WDOG_HW_RUNNING, &pcf2127->wdd.status);
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
ret = devm_watchdog_register_device(dev, &pcf2127->wdd);
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif /* CONFIG_WATCHDOG */
|
||||
pcf2127_watchdog_init(dev, pcf2127);
|
||||
|
||||
/*
|
||||
* Disable battery low/switch-over timestamp and interrupts.
|
||||
@ -680,7 +683,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return rtc_register_device(pcf2127->rtc);
|
||||
return devm_rtc_register_device(pcf2127->rtc);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
|
@ -607,14 +607,14 @@ static int pcf85063_probe(struct i2c_client *client)
|
||||
}
|
||||
|
||||
nvmem_cfg.priv = pcf85063->regmap;
|
||||
rtc_nvmem_register(pcf85063->rtc, &nvmem_cfg);
|
||||
devm_rtc_nvmem_register(pcf85063->rtc, &nvmem_cfg);
|
||||
|
||||
#ifdef CONFIG_COMMON_CLK
|
||||
/* register clk in common clk framework */
|
||||
pcf85063_clkout_register_clk(pcf85063);
|
||||
#endif
|
||||
|
||||
return rtc_register_device(pcf85063->rtc);
|
||||
return devm_rtc_register_device(pcf85063->rtc);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
|
@ -12,18 +12,18 @@
|
||||
#define DRIVER_NAME "rtc-pcf8523"
|
||||
|
||||
#define REG_CONTROL1 0x00
|
||||
#define REG_CONTROL1_CAP_SEL (1 << 7)
|
||||
#define REG_CONTROL1_STOP (1 << 5)
|
||||
#define REG_CONTROL1_CAP_SEL BIT(7)
|
||||
#define REG_CONTROL1_STOP BIT(5)
|
||||
|
||||
#define REG_CONTROL3 0x02
|
||||
#define REG_CONTROL3_PM_BLD (1 << 7) /* battery low detection disabled */
|
||||
#define REG_CONTROL3_PM_VDD (1 << 6) /* switch-over disabled */
|
||||
#define REG_CONTROL3_PM_DSM (1 << 5) /* direct switching mode */
|
||||
#define REG_CONTROL3_PM_BLD BIT(7) /* battery low detection disabled */
|
||||
#define REG_CONTROL3_PM_VDD BIT(6) /* switch-over disabled */
|
||||
#define REG_CONTROL3_PM_DSM BIT(5) /* direct switching mode */
|
||||
#define REG_CONTROL3_PM_MASK 0xe0
|
||||
#define REG_CONTROL3_BLF (1 << 2) /* battery low bit, read-only */
|
||||
#define REG_CONTROL3_BLF BIT(2) /* battery low bit, read-only */
|
||||
|
||||
#define REG_SECONDS 0x03
|
||||
#define REG_SECONDS_OS (1 << 7)
|
||||
#define REG_SECONDS_OS BIT(7)
|
||||
|
||||
#define REG_MINUTES 0x04
|
||||
#define REG_HOURS 0x05
|
||||
@ -226,17 +226,6 @@ static int pcf8523_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||
u8 regs[8];
|
||||
int err;
|
||||
|
||||
/*
|
||||
* The hardware can only store values between 0 and 99 in it's YEAR
|
||||
* register (with 99 overflowing to 0 on increment).
|
||||
* After 2100-02-28 we could start interpreting the year to be in the
|
||||
* interval [2100, 2199], but there is no path to switch in a smooth way
|
||||
* because the chip handles YEAR=0x00 (and the out-of-spec
|
||||
* YEAR=0xa0) as a leap year, but 2100 isn't.
|
||||
*/
|
||||
if (tm->tm_year < 100 || tm->tm_year >= 200)
|
||||
return -EINVAL;
|
||||
|
||||
err = pcf8523_stop_rtc(client);
|
||||
if (err < 0)
|
||||
return err;
|
||||
@ -356,12 +345,15 @@ static int pcf8523_probe(struct i2c_client *client,
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME,
|
||||
&pcf8523_rtc_ops, THIS_MODULE);
|
||||
rtc = devm_rtc_allocate_device(&client->dev);
|
||||
if (IS_ERR(rtc))
|
||||
return PTR_ERR(rtc);
|
||||
|
||||
return 0;
|
||||
rtc->ops = &pcf8523_rtc_ops;
|
||||
rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id pcf8523_id[] = {
|
||||
|
@ -418,11 +418,11 @@ static int pcf85363_probe(struct i2c_client *client,
|
||||
pcf85363->rtc->ops = &rtc_ops_alarm;
|
||||
}
|
||||
|
||||
ret = rtc_register_device(pcf85363->rtc);
|
||||
ret = devm_rtc_register_device(pcf85363->rtc);
|
||||
|
||||
for (i = 0; i < config->num_nvram; i++) {
|
||||
nvmem_cfg[i].priv = pcf85363;
|
||||
rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg[i]);
|
||||
devm_rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -582,7 +582,7 @@ static int pcf8563_probe(struct i2c_client *client,
|
||||
}
|
||||
}
|
||||
|
||||
err = rtc_register_device(pcf8563->rtc);
|
||||
err = devm_rtc_register_device(pcf8563->rtc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -338,7 +338,7 @@ static int pic32_rtc_probe(struct platform_device *pdev)
|
||||
pdata->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
pdata->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
ret = rtc_register_device(pdata->rtc);
|
||||
ret = devm_rtc_register_device(pdata->rtc);
|
||||
if (ret)
|
||||
goto err_nortc;
|
||||
|
||||
|
@ -121,7 +121,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
|
||||
if (ret)
|
||||
goto err_irq;
|
||||
|
||||
ret = rtc_register_device(rtc->rtc);
|
||||
ret = devm_rtc_register_device(rtc->rtc);
|
||||
if (ret)
|
||||
goto err_reg;
|
||||
|
||||
|
@ -361,14 +361,16 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
|
||||
|
||||
device_init_wakeup(&adev->dev, true);
|
||||
ldata->rtc = devm_rtc_allocate_device(&adev->dev);
|
||||
if (IS_ERR(ldata->rtc))
|
||||
return PTR_ERR(ldata->rtc);
|
||||
if (IS_ERR(ldata->rtc)) {
|
||||
ret = PTR_ERR(ldata->rtc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ldata->rtc->ops = ops;
|
||||
ldata->rtc->range_min = vendor->range_min;
|
||||
ldata->rtc->range_max = vendor->range_max;
|
||||
|
||||
ret = rtc_register_device(ldata->rtc);
|
||||
ret = devm_rtc_register_device(ldata->rtc);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
@ -508,7 +508,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rtc_register_device(rtc_dd->rtc);
|
||||
return devm_rtc_register_device(rtc_dd->rtc);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
@ -56,7 +56,7 @@ static int __init ps3_rtc_probe(struct platform_device *dev)
|
||||
|
||||
platform_set_drvdata(dev, rtc);
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static struct platform_driver ps3_rtc_driver = {
|
||||
|
@ -127,7 +127,7 @@ static int r9701_probe(struct spi_device *spi)
|
||||
rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static struct spi_driver r9701_driver = {
|
||||
|
@ -426,7 +426,7 @@ static int rc5t619_rtc_probe(struct platform_device *pdev)
|
||||
dev_warn(&pdev->dev, "rc5t619 interrupt is disabled\n");
|
||||
}
|
||||
|
||||
return rtc_register_device(rtc->rtc);
|
||||
return devm_rtc_register_device(rtc->rtc);
|
||||
}
|
||||
|
||||
static struct platform_driver rc5t619_rtc_driver = {
|
||||
|
@ -447,7 +447,7 @@ static int rk808_rtc_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return rtc_register_device(rk808_rtc->rtc);
|
||||
return devm_rtc_register_device(rk808_rtc->rtc);
|
||||
}
|
||||
|
||||
static struct platform_driver rk808_rtc_driver = {
|
||||
|
@ -251,16 +251,15 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
|
||||
return PTR_ERR(rtc);
|
||||
|
||||
rtc->ops = &rp5c01_rtc_ops;
|
||||
rtc->nvram_old_abi = true;
|
||||
|
||||
priv->rtc = rtc;
|
||||
|
||||
nvmem_cfg.priv = priv;
|
||||
error = rtc_nvmem_register(rtc, &nvmem_cfg);
|
||||
error = devm_rtc_nvmem_register(rtc, &nvmem_cfg);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static struct platform_driver rp5c01_rtc_driver = {
|
||||
|
@ -197,7 +197,7 @@ static int rs5c348_probe(struct spi_device *spi)
|
||||
|
||||
rtc->ops = &rs5c348_rtc_ops;
|
||||
|
||||
return rtc_register_device(rtc);
|
||||
return devm_rtc_register_device(rtc);
|
||||
}
|
||||
|
||||
static struct spi_driver rs5c348_driver = {
|
||||
|
@ -886,14 +886,14 @@ static int rv3028_probe(struct i2c_client *client)
|
||||
rv3028->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rv3028->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
rv3028->rtc->ops = &rv3028_rtc_ops;
|
||||
ret = rtc_register_device(rv3028->rtc);
|
||||
ret = devm_rtc_register_device(rv3028->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
nvmem_cfg.priv = rv3028->regmap;
|
||||
rtc_nvmem_register(rv3028->rtc, &nvmem_cfg);
|
||||
devm_rtc_nvmem_register(rv3028->rtc, &nvmem_cfg);
|
||||
eeprom_cfg.priv = rv3028;
|
||||
rtc_nvmem_register(rv3028->rtc, &eeprom_cfg);
|
||||
devm_rtc_nvmem_register(rv3028->rtc, &eeprom_cfg);
|
||||
|
||||
rv3028->rtc->max_user_freq = 1;
|
||||
|
||||
|
@ -750,12 +750,12 @@ static int rv3029_probe(struct device *dev, struct regmap *regmap, int irq,
|
||||
rv3029->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rv3029->rtc->range_max = RTC_TIMESTAMP_END_2079;
|
||||
|
||||
rc = rtc_register_device(rv3029->rtc);
|
||||
rc = devm_rtc_register_device(rv3029->rtc);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
nvmem_cfg.priv = rv3029->regmap;
|
||||
rtc_nvmem_register(rv3029->rtc, &nvmem_cfg);
|
||||
devm_rtc_nvmem_register(rv3029->rtc, &nvmem_cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -885,14 +885,14 @@ static int rv3032_probe(struct i2c_client *client)
|
||||
rv3032->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rv3032->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
rv3032->rtc->ops = &rv3032_rtc_ops;
|
||||
ret = rtc_register_device(rv3032->rtc);
|
||||
ret = devm_rtc_register_device(rv3032->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
nvmem_cfg.priv = rv3032;
|
||||
rtc_nvmem_register(rv3032->rtc, &nvmem_cfg);
|
||||
nvmem_cfg.priv = rv3032->regmap;
|
||||
devm_rtc_nvmem_register(rv3032->rtc, &nvmem_cfg);
|
||||
eeprom_cfg.priv = rv3032;
|
||||
rtc_nvmem_register(rv3032->rtc, &eeprom_cfg);
|
||||
devm_rtc_nvmem_register(rv3032->rtc, &eeprom_cfg);
|
||||
|
||||
rv3032->rtc->max_user_freq = 1;
|
||||
|
||||
|
@ -585,14 +585,13 @@ static int rv8803_probe(struct i2c_client *client,
|
||||
}
|
||||
|
||||
rv8803->rtc->ops = &rv8803_rtc_ops;
|
||||
rv8803->rtc->nvram_old_abi = true;
|
||||
rv8803->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rv8803->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
err = rtc_register_device(rv8803->rtc);
|
||||
err = devm_rtc_register_device(rv8803->rtc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
rtc_nvmem_register(rv8803->rtc, &nvmem_cfg);
|
||||
devm_rtc_nvmem_register(rv8803->rtc, &nvmem_cfg);
|
||||
|
||||
rv8803->rtc->max_user_freq = 1;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/i2c.h>
|
||||
|
||||
/* RX-6110 Register definitions */
|
||||
#define RX6110_REG_SEC 0x10
|
||||
@ -310,6 +311,27 @@ static const struct rtc_class_ops rx6110_rtc_ops = {
|
||||
.set_time = rx6110_set_time,
|
||||
};
|
||||
|
||||
static int rx6110_probe(struct rx6110_data *rx6110, struct device *dev)
|
||||
{
|
||||
int err;
|
||||
|
||||
rx6110->rtc = devm_rtc_device_register(dev,
|
||||
RX6110_DRIVER_NAME,
|
||||
&rx6110_rtc_ops, THIS_MODULE);
|
||||
|
||||
if (IS_ERR(rx6110->rtc))
|
||||
return PTR_ERR(rx6110->rtc);
|
||||
|
||||
err = rx6110_init(rx6110);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
rx6110->rtc->max_user_freq = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_MASTER
|
||||
static struct regmap_config regmap_spi_config = {
|
||||
.reg_bits = 8,
|
||||
.val_bits = 8,
|
||||
@ -318,13 +340,12 @@ static struct regmap_config regmap_spi_config = {
|
||||
};
|
||||
|
||||
/**
|
||||
* rx6110_probe - initialize rtc driver
|
||||
* rx6110_spi_probe - initialize rtc driver
|
||||
* @spi: pointer to spi device
|
||||
*/
|
||||
static int rx6110_probe(struct spi_device *spi)
|
||||
static int rx6110_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
struct rx6110_data *rx6110;
|
||||
int err;
|
||||
|
||||
if ((spi->bits_per_word && spi->bits_per_word != 8) ||
|
||||
(spi->max_speed_hz > 2000000) ||
|
||||
@ -346,27 +367,14 @@ static int rx6110_probe(struct spi_device *spi)
|
||||
|
||||
spi_set_drvdata(spi, rx6110);
|
||||
|
||||
rx6110->rtc = devm_rtc_device_register(&spi->dev,
|
||||
RX6110_DRIVER_NAME,
|
||||
&rx6110_rtc_ops, THIS_MODULE);
|
||||
|
||||
if (IS_ERR(rx6110->rtc))
|
||||
return PTR_ERR(rx6110->rtc);
|
||||
|
||||
err = rx6110_init(rx6110);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
rx6110->rtc->max_user_freq = 1;
|
||||
|
||||
return 0;
|
||||
return rx6110_probe(rx6110, &spi->dev);
|
||||
}
|
||||
|
||||
static const struct spi_device_id rx6110_id[] = {
|
||||
static const struct spi_device_id rx6110_spi_id[] = {
|
||||
{ "rx6110", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, rx6110_id);
|
||||
MODULE_DEVICE_TABLE(spi, rx6110_spi_id);
|
||||
|
||||
static const struct of_device_id rx6110_spi_of_match[] = {
|
||||
{ .compatible = "epson,rx6110" },
|
||||
@ -374,16 +382,127 @@ static const struct of_device_id rx6110_spi_of_match[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rx6110_spi_of_match);
|
||||
|
||||
static struct spi_driver rx6110_driver = {
|
||||
static struct spi_driver rx6110_spi_driver = {
|
||||
.driver = {
|
||||
.name = RX6110_DRIVER_NAME,
|
||||
.of_match_table = of_match_ptr(rx6110_spi_of_match),
|
||||
},
|
||||
.probe = rx6110_probe,
|
||||
.id_table = rx6110_id,
|
||||
.probe = rx6110_spi_probe,
|
||||
.id_table = rx6110_spi_id,
|
||||
};
|
||||
|
||||
module_spi_driver(rx6110_driver);
|
||||
static int rx6110_spi_register(void)
|
||||
{
|
||||
return spi_register_driver(&rx6110_spi_driver);
|
||||
}
|
||||
|
||||
static void rx6110_spi_unregister(void)
|
||||
{
|
||||
spi_unregister_driver(&rx6110_spi_driver);
|
||||
}
|
||||
#else
|
||||
static int rx6110_spi_register(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rx6110_spi_unregister(void)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_SPI_MASTER */
|
||||
|
||||
#ifdef CONFIG_I2C
|
||||
static struct regmap_config regmap_i2c_config = {
|
||||
.reg_bits = 8,
|
||||
.val_bits = 8,
|
||||
.max_register = RX6110_REG_IRQ,
|
||||
.read_flag_mask = 0x80,
|
||||
};
|
||||
|
||||
static int rx6110_i2c_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
|
||||
struct rx6110_data *rx6110;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA
|
||||
| I2C_FUNC_SMBUS_I2C_BLOCK)) {
|
||||
dev_err(&adapter->dev,
|
||||
"doesn't support required functionality\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rx6110 = devm_kzalloc(&client->dev, sizeof(*rx6110), GFP_KERNEL);
|
||||
if (!rx6110)
|
||||
return -ENOMEM;
|
||||
|
||||
rx6110->regmap = devm_regmap_init_i2c(client, ®map_i2c_config);
|
||||
if (IS_ERR(rx6110->regmap)) {
|
||||
dev_err(&client->dev, "regmap init failed for rtc rx6110\n");
|
||||
return PTR_ERR(rx6110->regmap);
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, rx6110);
|
||||
|
||||
return rx6110_probe(rx6110, &client->dev);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id rx6110_i2c_id[] = {
|
||||
{ "rx6110", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, rx6110_i2c_id);
|
||||
|
||||
static struct i2c_driver rx6110_i2c_driver = {
|
||||
.driver = {
|
||||
.name = RX6110_DRIVER_NAME,
|
||||
},
|
||||
.probe = rx6110_i2c_probe,
|
||||
.id_table = rx6110_i2c_id,
|
||||
};
|
||||
|
||||
static int rx6110_i2c_register(void)
|
||||
{
|
||||
return i2c_add_driver(&rx6110_i2c_driver);
|
||||
}
|
||||
|
||||
static void rx6110_i2c_unregister(void)
|
||||
{
|
||||
i2c_del_driver(&rx6110_i2c_driver);
|
||||
}
|
||||
#else
|
||||
static int rx6110_i2c_register(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rx6110_i2c_unregister(void)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_I2C */
|
||||
|
||||
static int __init rx6110_module_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = rx6110_spi_register();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = rx6110_i2c_register();
|
||||
if (ret)
|
||||
rx6110_spi_unregister();
|
||||
|
||||
return ret;
|
||||
}
|
||||
module_init(rx6110_module_init);
|
||||
|
||||
static void __exit rx6110_module_exit(void)
|
||||
{
|
||||
rx6110_spi_unregister();
|
||||
rx6110_i2c_unregister();
|
||||
}
|
||||
module_exit(rx6110_module_exit);
|
||||
|
||||
MODULE_AUTHOR("Val Krutov <val.krutov@erd.epson.com>");
|
||||
MODULE_DESCRIPTION("RX-6110 SA RTC driver");
|
||||
|
@ -419,7 +419,7 @@ static int rx8010_probe(struct i2c_client *client)
|
||||
rx8010->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rx8010->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
return rtc_register_device(rx8010->rtc);
|
||||
return devm_rtc_register_device(rx8010->rtc);
|
||||
}
|
||||
|
||||
static struct i2c_driver rx8010_driver = {
|
||||
|
@ -298,11 +298,11 @@ static int rx8581_probe(struct i2c_client *client,
|
||||
rx8581->rtc->start_secs = 0;
|
||||
rx8581->rtc->set_start_time = true;
|
||||
|
||||
ret = rtc_register_device(rx8581->rtc);
|
||||
ret = devm_rtc_register_device(rx8581->rtc);
|
||||
|
||||
for (i = 0; i < config->num_nvram; i++) {
|
||||
nvmem_cfg[i].priv = rx8581;
|
||||
rtc_nvmem_register(rx8581->rtc, &nvmem_cfg[i]);
|
||||
devm_rtc_nvmem_register(rx8581->rtc, &nvmem_cfg[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -497,7 +497,7 @@ static int s35390a_probe(struct i2c_client *client,
|
||||
if (status1 & S35390A_FLAG_INT2)
|
||||
rtc_update_irq(s35390a->rtc, 1, RTC_AF);
|
||||
|
||||
return rtc_register_device(s35390a->rtc);
|
||||
return devm_rtc_register_device(s35390a->rtc);
|
||||
}
|
||||
|
||||
static struct i2c_driver s35390a_driver = {
|
||||
|
@ -42,26 +42,15 @@ struct s3c_rtc {
|
||||
const struct s3c_rtc_data *data;
|
||||
|
||||
int irq_alarm;
|
||||
int irq_tick;
|
||||
|
||||
spinlock_t pie_lock;
|
||||
spinlock_t alarm_lock;
|
||||
|
||||
int ticnt_save;
|
||||
int ticnt_en_save;
|
||||
bool wake_en;
|
||||
};
|
||||
|
||||
struct s3c_rtc_data {
|
||||
int max_user_freq;
|
||||
bool needs_src_clk;
|
||||
|
||||
void (*irq_handler) (struct s3c_rtc *info, int mask);
|
||||
void (*set_freq) (struct s3c_rtc *info, int freq);
|
||||
void (*enable_tick) (struct s3c_rtc *info, struct seq_file *seq);
|
||||
void (*select_tick_clk) (struct s3c_rtc *info);
|
||||
void (*save_tick_cnt) (struct s3c_rtc *info);
|
||||
void (*restore_tick_cnt) (struct s3c_rtc *info);
|
||||
void (*enable) (struct s3c_rtc *info);
|
||||
void (*disable) (struct s3c_rtc *info);
|
||||
};
|
||||
@ -91,17 +80,7 @@ static void s3c_rtc_disable_clk(struct s3c_rtc *info)
|
||||
clk_disable(info->rtc_clk);
|
||||
}
|
||||
|
||||
/* IRQ Handlers */
|
||||
static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
|
||||
{
|
||||
struct s3c_rtc *info = (struct s3c_rtc *)id;
|
||||
|
||||
if (info->data->irq_handler)
|
||||
info->data->irq_handler(info, S3C2410_INTP_TIC);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/* IRQ Handler */
|
||||
static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
|
||||
{
|
||||
struct s3c_rtc *info = (struct s3c_rtc *)id;
|
||||
@ -148,28 +127,6 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set RTC frequency */
|
||||
static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!is_power_of_2(freq))
|
||||
return -EINVAL;
|
||||
|
||||
ret = s3c_rtc_enable_clk(info);
|
||||
if (ret)
|
||||
return ret;
|
||||
spin_lock_irq(&info->pie_lock);
|
||||
|
||||
if (info->data->set_freq)
|
||||
info->data->set_freq(info, freq);
|
||||
|
||||
spin_unlock_irq(&info->pie_lock);
|
||||
s3c_rtc_disable_clk(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Time read/write */
|
||||
static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
|
||||
{
|
||||
@ -348,29 +305,11 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s3c_rtc_proc(struct device *dev, struct seq_file *seq)
|
||||
{
|
||||
struct s3c_rtc *info = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
ret = s3c_rtc_enable_clk(info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (info->data->enable_tick)
|
||||
info->data->enable_tick(info, seq);
|
||||
|
||||
s3c_rtc_disable_clk(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct rtc_class_ops s3c_rtcops = {
|
||||
.read_time = s3c_rtc_gettime,
|
||||
.set_time = s3c_rtc_settime,
|
||||
.read_alarm = s3c_rtc_getalarm,
|
||||
.set_alarm = s3c_rtc_setalarm,
|
||||
.proc = s3c_rtc_proc,
|
||||
.alarm_irq_enable = s3c_rtc_setaie,
|
||||
};
|
||||
|
||||
@ -450,18 +389,12 @@ static int s3c_rtc_probe(struct platform_device *pdev)
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
/* find the IRQs */
|
||||
info->irq_tick = platform_get_irq(pdev, 1);
|
||||
if (info->irq_tick < 0)
|
||||
return info->irq_tick;
|
||||
|
||||
info->dev = &pdev->dev;
|
||||
info->data = of_device_get_match_data(&pdev->dev);
|
||||
if (!info->data) {
|
||||
dev_err(&pdev->dev, "failed getting s3c_rtc_data\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
spin_lock_init(&info->pie_lock);
|
||||
spin_lock_init(&info->alarm_lock);
|
||||
|
||||
platform_set_drvdata(pdev, info);
|
||||
@ -470,8 +403,7 @@ static int s3c_rtc_probe(struct platform_device *pdev)
|
||||
if (info->irq_alarm < 0)
|
||||
return info->irq_alarm;
|
||||
|
||||
dev_dbg(&pdev->dev, "s3c2410_rtc: tick irq %d, alarm irq %d\n",
|
||||
info->irq_tick, info->irq_alarm);
|
||||
dev_dbg(&pdev->dev, "s3c2410_rtc: alarm irq %d\n", info->irq_alarm);
|
||||
|
||||
/* get the memory region */
|
||||
info->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
@ -503,6 +435,10 @@ static int s3c_rtc_probe(struct platform_device *pdev)
|
||||
goto err_src_clk;
|
||||
}
|
||||
|
||||
/* disable RTC enable bits potentially set by the bootloader */
|
||||
if (info->data->disable)
|
||||
info->data->disable(info);
|
||||
|
||||
/* check to see if everything is setup correctly */
|
||||
if (info->data->enable)
|
||||
info->data->enable(info);
|
||||
@ -542,18 +478,6 @@ static int s3c_rtc_probe(struct platform_device *pdev)
|
||||
goto err_nortc;
|
||||
}
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, info->irq_tick, s3c_rtc_tickirq,
|
||||
0, "s3c2410-rtc tick", info);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq_tick, ret);
|
||||
goto err_nortc;
|
||||
}
|
||||
|
||||
if (info->data->select_tick_clk)
|
||||
info->data->select_tick_clk(info);
|
||||
|
||||
s3c_rtc_setfreq(info, 1);
|
||||
|
||||
s3c_rtc_disable_clk(info);
|
||||
|
||||
return 0;
|
||||
@ -581,10 +505,6 @@ static int s3c_rtc_suspend(struct device *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* save TICNT for anyone using periodic interrupts */
|
||||
if (info->data->save_tick_cnt)
|
||||
info->data->save_tick_cnt(info);
|
||||
|
||||
if (info->data->disable)
|
||||
info->data->disable(info);
|
||||
|
||||
@ -605,9 +525,6 @@ static int s3c_rtc_resume(struct device *dev)
|
||||
if (info->data->enable)
|
||||
info->data->enable(info);
|
||||
|
||||
if (info->data->restore_tick_cnt)
|
||||
info->data->restore_tick_cnt(info);
|
||||
|
||||
s3c_rtc_disable_clk(info);
|
||||
|
||||
if (device_may_wakeup(dev) && info->wake_en) {
|
||||
@ -631,162 +548,27 @@ static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask)
|
||||
writeb(mask, info->base + S3C2410_INTP);
|
||||
}
|
||||
|
||||
static void s3c2410_rtc_setfreq(struct s3c_rtc *info, int freq)
|
||||
{
|
||||
unsigned int tmp = 0;
|
||||
int val;
|
||||
|
||||
tmp = readb(info->base + S3C2410_TICNT);
|
||||
tmp &= S3C2410_TICNT_ENABLE;
|
||||
|
||||
val = (info->rtc->max_user_freq / freq) - 1;
|
||||
tmp |= val;
|
||||
|
||||
writel(tmp, info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c2416_rtc_setfreq(struct s3c_rtc *info, int freq)
|
||||
{
|
||||
unsigned int tmp = 0;
|
||||
int val;
|
||||
|
||||
tmp = readb(info->base + S3C2410_TICNT);
|
||||
tmp &= S3C2410_TICNT_ENABLE;
|
||||
|
||||
val = (info->rtc->max_user_freq / freq) - 1;
|
||||
|
||||
tmp |= S3C2443_TICNT_PART(val);
|
||||
writel(S3C2443_TICNT1_PART(val), info->base + S3C2443_TICNT1);
|
||||
|
||||
writel(S3C2416_TICNT2_PART(val), info->base + S3C2416_TICNT2);
|
||||
|
||||
writel(tmp, info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c2443_rtc_setfreq(struct s3c_rtc *info, int freq)
|
||||
{
|
||||
unsigned int tmp = 0;
|
||||
int val;
|
||||
|
||||
tmp = readb(info->base + S3C2410_TICNT);
|
||||
tmp &= S3C2410_TICNT_ENABLE;
|
||||
|
||||
val = (info->rtc->max_user_freq / freq) - 1;
|
||||
|
||||
tmp |= S3C2443_TICNT_PART(val);
|
||||
writel(S3C2443_TICNT1_PART(val), info->base + S3C2443_TICNT1);
|
||||
|
||||
writel(tmp, info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c6410_rtc_setfreq(struct s3c_rtc *info, int freq)
|
||||
{
|
||||
int val;
|
||||
|
||||
val = (info->rtc->max_user_freq / freq) - 1;
|
||||
writel(val, info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c24xx_rtc_enable_tick(struct s3c_rtc *info, struct seq_file *seq)
|
||||
{
|
||||
unsigned int ticnt;
|
||||
|
||||
ticnt = readb(info->base + S3C2410_TICNT);
|
||||
ticnt &= S3C2410_TICNT_ENABLE;
|
||||
|
||||
seq_printf(seq, "periodic_IRQ\t: %s\n", ticnt ? "yes" : "no");
|
||||
}
|
||||
|
||||
static void s3c2416_rtc_select_tick_clk(struct s3c_rtc *info)
|
||||
{
|
||||
unsigned int con;
|
||||
|
||||
con = readw(info->base + S3C2410_RTCCON);
|
||||
con |= S3C2443_RTCCON_TICSEL;
|
||||
writew(con, info->base + S3C2410_RTCCON);
|
||||
}
|
||||
|
||||
static void s3c6410_rtc_enable_tick(struct s3c_rtc *info, struct seq_file *seq)
|
||||
{
|
||||
unsigned int ticnt;
|
||||
|
||||
ticnt = readw(info->base + S3C2410_RTCCON);
|
||||
ticnt &= S3C64XX_RTCCON_TICEN;
|
||||
|
||||
seq_printf(seq, "periodic_IRQ\t: %s\n", ticnt ? "yes" : "no");
|
||||
}
|
||||
|
||||
static void s3c24xx_rtc_save_tick_cnt(struct s3c_rtc *info)
|
||||
{
|
||||
info->ticnt_save = readb(info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c24xx_rtc_restore_tick_cnt(struct s3c_rtc *info)
|
||||
{
|
||||
writeb(info->ticnt_save, info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c6410_rtc_save_tick_cnt(struct s3c_rtc *info)
|
||||
{
|
||||
info->ticnt_en_save = readw(info->base + S3C2410_RTCCON);
|
||||
info->ticnt_en_save &= S3C64XX_RTCCON_TICEN;
|
||||
info->ticnt_save = readl(info->base + S3C2410_TICNT);
|
||||
}
|
||||
|
||||
static void s3c6410_rtc_restore_tick_cnt(struct s3c_rtc *info)
|
||||
{
|
||||
unsigned int con;
|
||||
|
||||
writel(info->ticnt_save, info->base + S3C2410_TICNT);
|
||||
if (info->ticnt_en_save) {
|
||||
con = readw(info->base + S3C2410_RTCCON);
|
||||
writew(con | info->ticnt_en_save, info->base + S3C2410_RTCCON);
|
||||
}
|
||||
}
|
||||
|
||||
static struct s3c_rtc_data const s3c2410_rtc_data = {
|
||||
.max_user_freq = 128,
|
||||
.irq_handler = s3c24xx_rtc_irq,
|
||||
.set_freq = s3c2410_rtc_setfreq,
|
||||
.enable_tick = s3c24xx_rtc_enable_tick,
|
||||
.save_tick_cnt = s3c24xx_rtc_save_tick_cnt,
|
||||
.restore_tick_cnt = s3c24xx_rtc_restore_tick_cnt,
|
||||
.enable = s3c24xx_rtc_enable,
|
||||
.disable = s3c24xx_rtc_disable,
|
||||
};
|
||||
|
||||
static struct s3c_rtc_data const s3c2416_rtc_data = {
|
||||
.max_user_freq = 32768,
|
||||
.irq_handler = s3c24xx_rtc_irq,
|
||||
.set_freq = s3c2416_rtc_setfreq,
|
||||
.enable_tick = s3c24xx_rtc_enable_tick,
|
||||
.select_tick_clk = s3c2416_rtc_select_tick_clk,
|
||||
.save_tick_cnt = s3c24xx_rtc_save_tick_cnt,
|
||||
.restore_tick_cnt = s3c24xx_rtc_restore_tick_cnt,
|
||||
.enable = s3c24xx_rtc_enable,
|
||||
.disable = s3c24xx_rtc_disable,
|
||||
};
|
||||
|
||||
static struct s3c_rtc_data const s3c2443_rtc_data = {
|
||||
.max_user_freq = 32768,
|
||||
.irq_handler = s3c24xx_rtc_irq,
|
||||
.set_freq = s3c2443_rtc_setfreq,
|
||||
.enable_tick = s3c24xx_rtc_enable_tick,
|
||||
.select_tick_clk = s3c2416_rtc_select_tick_clk,
|
||||
.save_tick_cnt = s3c24xx_rtc_save_tick_cnt,
|
||||
.restore_tick_cnt = s3c24xx_rtc_restore_tick_cnt,
|
||||
.enable = s3c24xx_rtc_enable,
|
||||
.disable = s3c24xx_rtc_disable,
|
||||
};
|
||||
|
||||
static struct s3c_rtc_data const s3c6410_rtc_data = {
|
||||
.max_user_freq = 32768,
|
||||
.needs_src_clk = true,
|
||||
.irq_handler = s3c6410_rtc_irq,
|
||||
.set_freq = s3c6410_rtc_setfreq,
|
||||
.enable_tick = s3c6410_rtc_enable_tick,
|
||||
.save_tick_cnt = s3c6410_rtc_save_tick_cnt,
|
||||
.restore_tick_cnt = s3c6410_rtc_restore_tick_cnt,
|
||||
.enable = s3c24xx_rtc_enable,
|
||||
.disable = s3c6410_rtc_disable,
|
||||
};
|
||||
|
@ -205,7 +205,7 @@ int sa1100_rtc_init(struct platform_device *pdev, struct sa1100_rtc *info)
|
||||
info->rtc->max_user_freq = RTC_FREQ;
|
||||
info->rtc->range_max = U32_MAX;
|
||||
|
||||
ret = rtc_register_device(info->rtc);
|
||||
ret = devm_rtc_register_device(info->rtc);
|
||||
if (ret) {
|
||||
clk_disable_unprepare(info->clk);
|
||||
return ret;
|
||||
|
@ -299,33 +299,6 @@ static int sprd_rtc_set_secs(struct sprd_rtc *rtc, enum sprd_rtc_reg_types type,
|
||||
sts_mask);
|
||||
}
|
||||
|
||||
static int sprd_rtc_read_aux_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
{
|
||||
struct sprd_rtc *rtc = dev_get_drvdata(dev);
|
||||
time64_t secs;
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
ret = sprd_rtc_get_secs(rtc, SPRD_RTC_AUX_ALARM, &secs);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
rtc_time64_to_tm(secs, &alrm->time);
|
||||
|
||||
ret = regmap_read(rtc->regmap, rtc->base + SPRD_RTC_INT_EN, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
alrm->enabled = !!(val & SPRD_RTC_AUXALM_EN);
|
||||
|
||||
ret = regmap_read(rtc->regmap, rtc->base + SPRD_RTC_INT_RAW_STS, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
alrm->pending = !!(val & SPRD_RTC_AUXALM_EN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sprd_rtc_set_aux_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
{
|
||||
struct sprd_rtc *rtc = dev_get_drvdata(dev);
|
||||
@ -415,16 +388,9 @@ static int sprd_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
u32 val;
|
||||
|
||||
/*
|
||||
* Before RTC device is registered, it will check to see if there is an
|
||||
* alarm already set in RTC hardware, and we always read the normal
|
||||
* alarm at this time.
|
||||
*
|
||||
* Or if aie_timer is enabled, we should get the normal alarm time.
|
||||
* Otherwise we should get auxiliary alarm time.
|
||||
* The RTC core checks to see if there is an alarm already set in RTC
|
||||
* hardware, and we always read the normal alarm at this time.
|
||||
*/
|
||||
if (rtc->rtc && rtc->rtc->registered && rtc->rtc->aie_timer.enabled == 0)
|
||||
return sprd_rtc_read_aux_alarm(dev, alrm);
|
||||
|
||||
ret = sprd_rtc_get_secs(rtc, SPRD_RTC_ALARM, &secs);
|
||||
if (ret)
|
||||
return ret;
|
||||
@ -563,7 +529,7 @@ static int sprd_rtc_check_power_down(struct sprd_rtc *rtc)
|
||||
* means the RTC has been powered down, so the RTC time values are
|
||||
* invalid.
|
||||
*/
|
||||
rtc->valid = val == SPRD_RTC_POWER_RESET_VALUE ? false : true;
|
||||
rtc->valid = val != SPRD_RTC_POWER_RESET_VALUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -652,7 +618,7 @@ static int sprd_rtc_probe(struct platform_device *pdev)
|
||||
rtc->rtc->ops = &sprd_rtc_ops;
|
||||
rtc->rtc->range_min = 0;
|
||||
rtc->rtc->range_max = 5662310399LL;
|
||||
ret = rtc_register_device(rtc->rtc);
|
||||
ret = devm_rtc_register_device(rtc->rtc);
|
||||
if (ret) {
|
||||
device_init_wakeup(&pdev->dev, 0);
|
||||
return ret;
|
||||
|
@ -192,7 +192,7 @@ static int sd3078_probe(struct i2c_client *client,
|
||||
sd3078->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
sd3078->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
||||
ret = rtc_register_device(sd3078->rtc);
|
||||
ret = devm_rtc_register_device(sd3078->rtc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user