mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
Merge tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"The VL_READ and VL_CLR ioctls have been reworked to be more useful.
This will not break userspace as there are very few users and they are
using the integer value as a boolean.
Apart from that, two drivers were reworked and a few fixes here and
there for a net reduction of number of lines.
Summary:
Subsystem:
- the VL_READ and VL_CLR ioctls are now documented and their behavior
is unified across all the drivers.
- RTC_I2C_AND_SPI Kconfig option rework to avoid selecting both
REGMAP_I2C and REGMAP_SPI unecessarily.
Drivers:
- at91rm9200: remove deprecated procfs, add sam9x60, sama5d4 and
sama5d2 compatibles.
- cmos: solve lost interrupts issue on MS Surface 3
- hym8563: return proper errno when time is invalid
- rv3029: many fixes, nvram support"
* tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (63 commits)
dt-bindings: rtc: at91rm9200: document clocks property
rtc: i2c/spi: Avoid inclusion of REGMAP support when not needed
rtc: Kconfig: select REGMAP_I2C when necessary
rtc: Kconfig: properly indent sd3078 entry
rtc: cmos: Refactor code by using the new dmi_get_bios_year() helper
rtc: cmos: Use predefined value for RTC IRQ on legacy x86
rtc: cmos: Stop using shared IRQ
rtc: tps6586x: Use IRQ_NOAUTOEN flag
rtc: at91rm9200: use FIELD_PREP/FIELD_GET
rtc: at91rm9200: avoid time readout in at91_rtc_setalarm
rtc: at91rm9200: move register definitions to C file
rtc: at91rm9200: add sama5d4 and sama5d2 compatibles
dt-bindings: rtc: at91rm9200: convert bindings to json-schema
rtc: at91rm9200: remove procfs information
dt-bindings: atmel, at91rm9200-rtc: add microchip, sam9x60-rtc
rtc: pcf8563: Use BIT
rtc: moxart: Convert to SPDX identifier
rtc: ds1343: Remove unused struct spi_device in struct ds1343_priv
rtc: rx8025: Remove struct i2c_client from struct rx8025_data
rtc: hym8563: Read the valid flag directly instead of caching it
...
This commit is contained in:
1
.mailmap
1
.mailmap
@@ -18,6 +18,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com>
|
||||
Aleksandar Markovic <aleksandar.markovic@mips.com> <aleksandar.markovic@imgtec.com>
|
||||
Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@intel.com>
|
||||
Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@linaro.org>
|
||||
Alexandre Belloni <alexandre.belloni@bootlin.com> <alexandre.belloni@free-electrons.com>
|
||||
Alexei Starovoitov <ast@kernel.org> <ast@plumgrid.com>
|
||||
Alexei Starovoitov <ast@kernel.org> <alexei.starovoitov@gmail.com>
|
||||
Alexei Starovoitov <ast@kernel.org> <ast@fb.com>
|
||||
|
||||
@@ -33,6 +33,14 @@ Description:
|
||||
Requires a separate RTC_PIE_ON call to enable the periodic
|
||||
interrupts.
|
||||
|
||||
* RTC_VL_READ: Read the voltage inputs status of the RTC when
|
||||
supported. The value is a bit field of RTC_VL_*, giving the
|
||||
status of the main and backup voltages.
|
||||
|
||||
* RTC_VL_CLEAR: Clear the voltage status of the RTC. Some RTCs
|
||||
need user interaction when the backup power provider is
|
||||
replaced or charged to be able to clear the status.
|
||||
|
||||
The ioctl() calls supported by the older /dev/rtc interface are
|
||||
also supported by the newer RTC class framework. However,
|
||||
because the chips and systems are not standardized, some PC/AT
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
Atmel AT91RM9200 Real Time Clock
|
||||
|
||||
Required properties:
|
||||
- compatible: should be: "atmel,at91rm9200-rtc" or "atmel,at91sam9x5-rtc"
|
||||
- reg: physical base address of the controller and length of memory mapped
|
||||
region.
|
||||
- interrupts: rtc alarm/event interrupt
|
||||
- clocks: phandle to input clock.
|
||||
|
||||
Example:
|
||||
|
||||
rtc@fffffe00 {
|
||||
compatible = "atmel,at91rm9200-rtc";
|
||||
reg = <0xfffffe00 0x100>;
|
||||
interrupts = <1 4 7>;
|
||||
clocks = <&clk32k>;
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/rtc/atmel,at91rm9200-rtc.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Atmel AT91 RTC Device Tree Bindings
|
||||
|
||||
allOf:
|
||||
- $ref: "rtc.yaml#"
|
||||
|
||||
maintainers:
|
||||
- Alexandre Belloni <alexandre.belloni@bootlin.com>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- atmel,at91rm9200-rtc
|
||||
- atmel,at91sam9x5-rtc
|
||||
- atmel,sama5d4-rtc
|
||||
- atmel,sama5d2-rtc
|
||||
- microchip,sam9x60-rtc
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- interrupts
|
||||
- clocks
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
rtc@fffffe00 {
|
||||
compatible = "atmel,at91rm9200-rtc";
|
||||
reg = <0xfffffe00 0x100>;
|
||||
interrupts = <1 4 7>;
|
||||
clocks = <&clk32k>;
|
||||
};
|
||||
...
|
||||
@@ -240,6 +240,7 @@ config RTC_DRV_AS3722
|
||||
|
||||
config RTC_DRV_DS1307
|
||||
tristate "Dallas/Maxim DS1307/37/38/39/40/41, ST M41T00, EPSON RX-8025, ISL12057"
|
||||
select REGMAP_I2C
|
||||
help
|
||||
If you say yes here you get support for various compatible RTC
|
||||
chips (often with battery backup) connected with I2C. This driver
|
||||
@@ -622,6 +623,7 @@ config RTC_DRV_RX8010
|
||||
|
||||
config RTC_DRV_RX8581
|
||||
tristate "Epson RX-8571/RX-8581"
|
||||
select REGMAP_I2C
|
||||
help
|
||||
If you say yes here you will get support for the Epson RX-8571/
|
||||
RX-8581.
|
||||
@@ -649,6 +651,7 @@ config RTC_DRV_EM3027
|
||||
|
||||
config RTC_DRV_RV3028
|
||||
tristate "Micro Crystal RV3028"
|
||||
select REGMAP_I2C
|
||||
help
|
||||
If you say yes here you get support for the Micro Crystal
|
||||
RV3028.
|
||||
@@ -677,13 +680,14 @@ config RTC_DRV_S5M
|
||||
will be called rtc-s5m.
|
||||
|
||||
config RTC_DRV_SD3078
|
||||
tristate "ZXW Shenzhen whwave SD3078"
|
||||
help
|
||||
If you say yes here you get support for the ZXW Shenzhen whwave
|
||||
SD3078 RTC chips.
|
||||
tristate "ZXW Shenzhen whwave SD3078"
|
||||
select REGMAP_I2C
|
||||
help
|
||||
If you say yes here you get support for the ZXW Shenzhen whwave
|
||||
SD3078 RTC chips.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called rtc-sd3078
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called rtc-sd3078
|
||||
|
||||
endif # I2C
|
||||
|
||||
@@ -849,14 +853,14 @@ config RTC_I2C_AND_SPI
|
||||
default m if I2C=m
|
||||
default y if I2C=y
|
||||
default y if SPI_MASTER=y
|
||||
select REGMAP_I2C if I2C
|
||||
select REGMAP_SPI if SPI_MASTER
|
||||
|
||||
comment "SPI and I2C RTC drivers"
|
||||
|
||||
config RTC_DRV_DS3232
|
||||
tristate "Dallas/Maxim DS3232/DS3234"
|
||||
depends on RTC_I2C_AND_SPI
|
||||
select REGMAP_I2C if I2C
|
||||
select REGMAP_SPI if SPI_MASTER
|
||||
help
|
||||
If you say yes here you get support for Dallas Semiconductor
|
||||
DS3232 and DS3234 real-time clock chips. If an interrupt is associated
|
||||
@@ -876,6 +880,8 @@ config RTC_DRV_DS3232_HWMON
|
||||
config RTC_DRV_PCF2127
|
||||
tristate "NXP PCF2127"
|
||||
depends on RTC_I2C_AND_SPI
|
||||
select REGMAP_I2C if I2C
|
||||
select REGMAP_SPI if SPI_MASTER
|
||||
select WATCHDOG_CORE if WATCHDOG
|
||||
help
|
||||
If you say yes here you get support for the NXP PCF2127/29 RTC
|
||||
@@ -892,6 +898,8 @@ config RTC_DRV_PCF2127
|
||||
config RTC_DRV_RV3029C2
|
||||
tristate "Micro Crystal RV3029/3049"
|
||||
depends on RTC_I2C_AND_SPI
|
||||
select REGMAP_I2C if I2C
|
||||
select REGMAP_SPI if SPI_MASTER
|
||||
help
|
||||
If you say yes here you get support for the Micro Crystal
|
||||
RV3029 and RV3049 RTC chips.
|
||||
|
||||
@@ -523,12 +523,9 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
tmp = !!(status & ABX8XX_STATUS_BLF);
|
||||
tmp = status & ABX8XX_STATUS_BLF ? RTC_VL_BACKUP_LOW : 0;
|
||||
|
||||
if (copy_to_user((void __user *)arg, &tmp, sizeof(int)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
return put_user(tmp, (unsigned int __user *)arg);
|
||||
|
||||
case RTC_VL_CLR:
|
||||
status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
|
||||
|
||||
@@ -264,6 +264,9 @@ static int asm9260_rtc_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(priv->iobase);
|
||||
|
||||
priv->clk = devm_clk_get(dev, "ahb");
|
||||
if (IS_ERR(priv->clk))
|
||||
return PTR_ERR(priv->clk);
|
||||
|
||||
ret = clk_prepare_enable(priv->clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to enable clk!\n");
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/bcd.h>
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -30,7 +31,51 @@
|
||||
#include <linux/time.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include "rtc-at91rm9200.h"
|
||||
#define AT91_RTC_CR 0x00 /* Control Register */
|
||||
#define AT91_RTC_UPDTIM BIT(0) /* Update Request Time Register */
|
||||
#define AT91_RTC_UPDCAL BIT(1) /* Update Request Calendar Register */
|
||||
|
||||
#define AT91_RTC_MR 0x04 /* Mode Register */
|
||||
|
||||
#define AT91_RTC_TIMR 0x08 /* Time Register */
|
||||
#define AT91_RTC_SEC GENMASK(6, 0) /* Current Second */
|
||||
#define AT91_RTC_MIN GENMASK(14, 8) /* Current Minute */
|
||||
#define AT91_RTC_HOUR GENMASK(21, 16) /* Current Hour */
|
||||
#define AT91_RTC_AMPM BIT(22) /* Ante Meridiem Post Meridiem Indicator */
|
||||
|
||||
#define AT91_RTC_CALR 0x0c /* Calendar Register */
|
||||
#define AT91_RTC_CENT GENMASK(6, 0) /* Current Century */
|
||||
#define AT91_RTC_YEAR GENMASK(15, 8) /* Current Year */
|
||||
#define AT91_RTC_MONTH GENMASK(20, 16) /* Current Month */
|
||||
#define AT91_RTC_DAY GENMASK(23, 21) /* Current Day */
|
||||
#define AT91_RTC_DATE GENMASK(29, 24) /* Current Date */
|
||||
|
||||
#define AT91_RTC_TIMALR 0x10 /* Time Alarm Register */
|
||||
#define AT91_RTC_SECEN BIT(7) /* Second Alarm Enable */
|
||||
#define AT91_RTC_MINEN BIT(15) /* Minute Alarm Enable */
|
||||
#define AT91_RTC_HOUREN BIT(23) /* Hour Alarm Enable */
|
||||
|
||||
#define AT91_RTC_CALALR 0x14 /* Calendar Alarm Register */
|
||||
#define AT91_RTC_MTHEN BIT(23) /* Month Alarm Enable */
|
||||
#define AT91_RTC_DATEEN BIT(31) /* Date Alarm Enable */
|
||||
|
||||
#define AT91_RTC_SR 0x18 /* Status Register */
|
||||
#define AT91_RTC_ACKUPD BIT(0) /* Acknowledge for Update */
|
||||
#define AT91_RTC_ALARM BIT(1) /* Alarm Flag */
|
||||
#define AT91_RTC_SECEV BIT(2) /* Second Event */
|
||||
#define AT91_RTC_TIMEV BIT(3) /* Time Event */
|
||||
#define AT91_RTC_CALEV BIT(4) /* Calendar Event */
|
||||
|
||||
#define AT91_RTC_SCCR 0x1c /* Status Clear Command Register */
|
||||
#define AT91_RTC_IER 0x20 /* Interrupt Enable Register */
|
||||
#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
|
||||
#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
|
||||
|
||||
#define AT91_RTC_VER 0x2c /* Valid Entry Register */
|
||||
#define AT91_RTC_NVTIM BIT(0) /* Non valid Time */
|
||||
#define AT91_RTC_NVCAL BIT(1) /* Non valid Calendar */
|
||||
#define AT91_RTC_NVTIMALR BIT(2) /* Non valid Time Alarm */
|
||||
#define AT91_RTC_NVCALALR BIT(3) /* Non valid Calendar Alarm */
|
||||
|
||||
#define at91_rtc_read(field) \
|
||||
readl_relaxed(at91_rtc_regs + field)
|
||||
@@ -117,20 +162,20 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
|
||||
} while ((time != at91_rtc_read(timereg)) ||
|
||||
(date != at91_rtc_read(calreg)));
|
||||
|
||||
tm->tm_sec = bcd2bin((time & AT91_RTC_SEC) >> 0);
|
||||
tm->tm_min = bcd2bin((time & AT91_RTC_MIN) >> 8);
|
||||
tm->tm_hour = bcd2bin((time & AT91_RTC_HOUR) >> 16);
|
||||
tm->tm_sec = bcd2bin(FIELD_GET(AT91_RTC_SEC, time));
|
||||
tm->tm_min = bcd2bin(FIELD_GET(AT91_RTC_MIN, time));
|
||||
tm->tm_hour = bcd2bin(FIELD_GET(AT91_RTC_HOUR, time));
|
||||
|
||||
/*
|
||||
* The Calendar Alarm register does not have a field for
|
||||
* the year - so these will return an invalid value.
|
||||
*/
|
||||
tm->tm_year = bcd2bin(date & AT91_RTC_CENT) * 100; /* century */
|
||||
tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8); /* year */
|
||||
tm->tm_year += bcd2bin(FIELD_GET(AT91_RTC_YEAR, date)); /* year */
|
||||
|
||||
tm->tm_wday = bcd2bin((date & AT91_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */
|
||||
tm->tm_mon = bcd2bin((date & AT91_RTC_MONTH) >> 16) - 1;
|
||||
tm->tm_mday = bcd2bin((date & AT91_RTC_DATE) >> 24);
|
||||
tm->tm_wday = bcd2bin(FIELD_GET(AT91_RTC_DAY, date)) - 1; /* day of the week [0-6], Sunday=0 */
|
||||
tm->tm_mon = bcd2bin(FIELD_GET(AT91_RTC_MONTH, date)) - 1;
|
||||
tm->tm_mday = bcd2bin(FIELD_GET(AT91_RTC_DATE, date));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -167,16 +212,17 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
|
||||
at91_rtc_write_idr(AT91_RTC_ACKUPD);
|
||||
|
||||
at91_rtc_write(AT91_RTC_TIMR,
|
||||
bin2bcd(tm->tm_sec) << 0
|
||||
| bin2bcd(tm->tm_min) << 8
|
||||
| bin2bcd(tm->tm_hour) << 16);
|
||||
FIELD_PREP(AT91_RTC_SEC, bin2bcd(tm->tm_sec))
|
||||
| FIELD_PREP(AT91_RTC_MIN, bin2bcd(tm->tm_min))
|
||||
| FIELD_PREP(AT91_RTC_HOUR, bin2bcd(tm->tm_hour)));
|
||||
|
||||
at91_rtc_write(AT91_RTC_CALR,
|
||||
bin2bcd((tm->tm_year + 1900) / 100) /* century */
|
||||
| bin2bcd(tm->tm_year % 100) << 8 /* year */
|
||||
| bin2bcd(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */
|
||||
| bin2bcd(tm->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */
|
||||
| bin2bcd(tm->tm_mday) << 24);
|
||||
FIELD_PREP(AT91_RTC_CENT,
|
||||
bin2bcd((tm->tm_year + 1900) / 100))
|
||||
| FIELD_PREP(AT91_RTC_YEAR, bin2bcd(tm->tm_year % 100))
|
||||
| FIELD_PREP(AT91_RTC_MONTH, bin2bcd(tm->tm_mon + 1))
|
||||
| FIELD_PREP(AT91_RTC_DAY, bin2bcd(tm->tm_wday + 1))
|
||||
| FIELD_PREP(AT91_RTC_DATE, bin2bcd(tm->tm_mday)));
|
||||
|
||||
/* Restart Time/Calendar */
|
||||
cr = at91_rtc_read(AT91_RTC_CR);
|
||||
@@ -211,25 +257,17 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
*/
|
||||
static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
{
|
||||
struct rtc_time tm;
|
||||
|
||||
at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, &tm);
|
||||
|
||||
tm.tm_mon = alrm->time.tm_mon;
|
||||
tm.tm_mday = alrm->time.tm_mday;
|
||||
tm.tm_hour = alrm->time.tm_hour;
|
||||
tm.tm_min = alrm->time.tm_min;
|
||||
tm.tm_sec = alrm->time.tm_sec;
|
||||
struct rtc_time tm = alrm->time;
|
||||
|
||||
at91_rtc_write_idr(AT91_RTC_ALARM);
|
||||
at91_rtc_write(AT91_RTC_TIMALR,
|
||||
bin2bcd(tm.tm_sec) << 0
|
||||
| bin2bcd(tm.tm_min) << 8
|
||||
| bin2bcd(tm.tm_hour) << 16
|
||||
FIELD_PREP(AT91_RTC_SEC, bin2bcd(alrm->time.tm_sec))
|
||||
| FIELD_PREP(AT91_RTC_MIN, bin2bcd(alrm->time.tm_min))
|
||||
| FIELD_PREP(AT91_RTC_HOUR, bin2bcd(alrm->time.tm_hour))
|
||||
| AT91_RTC_HOUREN | AT91_RTC_MINEN | AT91_RTC_SECEN);
|
||||
at91_rtc_write(AT91_RTC_CALALR,
|
||||
bin2bcd(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */
|
||||
| bin2bcd(tm.tm_mday) << 24
|
||||
FIELD_PREP(AT91_RTC_MONTH, bin2bcd(alrm->time.tm_mon + 1))
|
||||
| FIELD_PREP(AT91_RTC_DATE, bin2bcd(alrm->time.tm_mday))
|
||||
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
|
||||
|
||||
if (alrm->enabled) {
|
||||
@@ -254,20 +292,6 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Provide additional RTC information in /proc/driver/rtc
|
||||
*/
|
||||
static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
|
||||
{
|
||||
unsigned long imr = at91_rtc_read_imr();
|
||||
|
||||
seq_printf(seq, "update_IRQ\t: %s\n",
|
||||
(imr & AT91_RTC_ACKUPD) ? "yes" : "no");
|
||||
seq_printf(seq, "periodic_IRQ\t: %s\n",
|
||||
(imr & AT91_RTC_SECEV) ? "yes" : "no");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* IRQ handler for the RTC
|
||||
@@ -326,6 +350,12 @@ static const struct of_device_id at91_rtc_dt_ids[] = {
|
||||
}, {
|
||||
.compatible = "atmel,at91sam9x5-rtc",
|
||||
.data = &at91sam9x5_config,
|
||||
}, {
|
||||
.compatible = "atmel,sama5d4-rtc",
|
||||
.data = &at91rm9200_config,
|
||||
}, {
|
||||
.compatible = "atmel,sama5d2-rtc",
|
||||
.data = &at91rm9200_config,
|
||||
}, {
|
||||
/* sentinel */
|
||||
}
|
||||
@@ -337,7 +367,6 @@ static const struct rtc_class_ops at91_rtc_ops = {
|
||||
.set_time = at91_rtc_settime,
|
||||
.read_alarm = at91_rtc_readalarm,
|
||||
.set_alarm = at91_rtc_setalarm,
|
||||
.proc = at91_rtc_proc,
|
||||
.alarm_irq_enable = at91_rtc_alarm_irq_enable,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* arch/arm/mach-at91/include/mach/at91_rtc.h
|
||||
*
|
||||
* Copyright (C) 2005 Ivan Kokshaysky
|
||||
* Copyright (C) SAN People
|
||||
*
|
||||
* Real Time Clock (RTC) - System peripheral registers.
|
||||
* Based on AT91RM9200 datasheet revision E.
|
||||
*/
|
||||
|
||||
#ifndef AT91_RTC_H
|
||||
#define AT91_RTC_H
|
||||
|
||||
#define AT91_RTC_CR 0x00 /* Control Register */
|
||||
#define AT91_RTC_UPDTIM (1 << 0) /* Update Request Time Register */
|
||||
#define AT91_RTC_UPDCAL (1 << 1) /* Update Request Calendar Register */
|
||||
#define AT91_RTC_TIMEVSEL (3 << 8) /* Time Event Selection */
|
||||
#define AT91_RTC_TIMEVSEL_MINUTE (0 << 8)
|
||||
#define AT91_RTC_TIMEVSEL_HOUR (1 << 8)
|
||||
#define AT91_RTC_TIMEVSEL_DAY24 (2 << 8)
|
||||
#define AT91_RTC_TIMEVSEL_DAY12 (3 << 8)
|
||||
#define AT91_RTC_CALEVSEL (3 << 16) /* Calendar Event Selection */
|
||||
#define AT91_RTC_CALEVSEL_WEEK (0 << 16)
|
||||
#define AT91_RTC_CALEVSEL_MONTH (1 << 16)
|
||||
#define AT91_RTC_CALEVSEL_YEAR (2 << 16)
|
||||
|
||||
#define AT91_RTC_MR 0x04 /* Mode Register */
|
||||
#define AT91_RTC_HRMOD (1 << 0) /* 12/24 Hour Mode */
|
||||
|
||||
#define AT91_RTC_TIMR 0x08 /* Time Register */
|
||||
#define AT91_RTC_SEC (0x7f << 0) /* Current Second */
|
||||
#define AT91_RTC_MIN (0x7f << 8) /* Current Minute */
|
||||
#define AT91_RTC_HOUR (0x3f << 16) /* Current Hour */
|
||||
#define AT91_RTC_AMPM (1 << 22) /* Ante Meridiem Post Meridiem Indicator */
|
||||
|
||||
#define AT91_RTC_CALR 0x0c /* Calendar Register */
|
||||
#define AT91_RTC_CENT (0x7f << 0) /* Current Century */
|
||||
#define AT91_RTC_YEAR (0xff << 8) /* Current Year */
|
||||
#define AT91_RTC_MONTH (0x1f << 16) /* Current Month */
|
||||
#define AT91_RTC_DAY (7 << 21) /* Current Day */
|
||||
#define AT91_RTC_DATE (0x3f << 24) /* Current Date */
|
||||
|
||||
#define AT91_RTC_TIMALR 0x10 /* Time Alarm Register */
|
||||
#define AT91_RTC_SECEN (1 << 7) /* Second Alarm Enable */
|
||||
#define AT91_RTC_MINEN (1 << 15) /* Minute Alarm Enable */
|
||||
#define AT91_RTC_HOUREN (1 << 23) /* Hour Alarm Enable */
|
||||
|
||||
#define AT91_RTC_CALALR 0x14 /* Calendar Alarm Register */
|
||||
#define AT91_RTC_MTHEN (1 << 23) /* Month Alarm Enable */
|
||||
#define AT91_RTC_DATEEN (1 << 31) /* Date Alarm Enable */
|
||||
|
||||
#define AT91_RTC_SR 0x18 /* Status Register */
|
||||
#define AT91_RTC_ACKUPD (1 << 0) /* Acknowledge for Update */
|
||||
#define AT91_RTC_ALARM (1 << 1) /* Alarm Flag */
|
||||
#define AT91_RTC_SECEV (1 << 2) /* Second Event */
|
||||
#define AT91_RTC_TIMEV (1 << 3) /* Time Event */
|
||||
#define AT91_RTC_CALEV (1 << 4) /* Calendar Event */
|
||||
|
||||
#define AT91_RTC_SCCR 0x1c /* Status Clear Command Register */
|
||||
#define AT91_RTC_IER 0x20 /* Interrupt Enable Register */
|
||||
#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
|
||||
#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
|
||||
|
||||
#define AT91_RTC_VER 0x2c /* Valid Entry Register */
|
||||
#define AT91_RTC_NVTIM (1 << 0) /* Non valid Time */
|
||||
#define AT91_RTC_NVCAL (1 << 1) /* Non valid Calendar */
|
||||
#define AT91_RTC_NVTIMALR (1 << 2) /* Non valid Time Alarm */
|
||||
#define AT91_RTC_NVCALALR (1 << 3) /* Non valid Calendar Alarm */
|
||||
|
||||
#endif
|
||||
@@ -850,7 +850,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
|
||||
rtc_cmos_int_handler = cmos_interrupt;
|
||||
|
||||
retval = request_irq(rtc_irq, rtc_cmos_int_handler,
|
||||
IRQF_SHARED, dev_name(&cmos_rtc.rtc->dev),
|
||||
0, dev_name(&cmos_rtc.rtc->dev),
|
||||
cmos_rtc.rtc);
|
||||
if (retval < 0) {
|
||||
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
|
||||
@@ -1197,8 +1197,6 @@ static void rtc_wake_off(struct device *dev)
|
||||
/* Enable use_acpi_alarm mode for Intel platforms no earlier than 2015 */
|
||||
static void use_acpi_alarm_quirks(void)
|
||||
{
|
||||
int year;
|
||||
|
||||
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
|
||||
return;
|
||||
|
||||
@@ -1208,8 +1206,10 @@ static void use_acpi_alarm_quirks(void)
|
||||
if (!is_hpet_enabled())
|
||||
return;
|
||||
|
||||
if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year >= 2015)
|
||||
use_acpi_alarm = true;
|
||||
if (dmi_get_bios_year() < 2015)
|
||||
return;
|
||||
|
||||
use_acpi_alarm = true;
|
||||
}
|
||||
#else
|
||||
static inline void use_acpi_alarm_quirks(void) { }
|
||||
@@ -1305,7 +1305,7 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
|
||||
* hardcode it on systems with a legacy PIC.
|
||||
*/
|
||||
if (nr_legacy_irqs())
|
||||
irq = 8;
|
||||
irq = RTC_IRQ;
|
||||
#endif
|
||||
return cmos_do_probe(&pnp->dev,
|
||||
pnp_get_resource(pnp, IORESOURCE_IO, 0), irq);
|
||||
|
||||
@@ -75,7 +75,6 @@ static const struct spi_device_id ds1343_id[] = {
|
||||
MODULE_DEVICE_TABLE(spi, ds1343_id);
|
||||
|
||||
struct ds1343_priv {
|
||||
struct spi_device *spi;
|
||||
struct rtc_device *rtc;
|
||||
struct regmap *map;
|
||||
int irq;
|
||||
@@ -362,12 +361,13 @@ static int ds1343_probe(struct spi_device *spi)
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->spi = spi;
|
||||
|
||||
/* RTC DS1347 works in spi mode 3 and
|
||||
* its chip select is active high
|
||||
* its chip select is active high. Active high should be defined as
|
||||
* "inverse polarity" as GPIO-based chip selects can be logically
|
||||
* active high but inverted by the GPIO library.
|
||||
*/
|
||||
spi->mode = SPI_MODE_3 | SPI_CS_HIGH;
|
||||
spi->mode |= SPI_MODE_3;
|
||||
spi->mode ^= SPI_CS_HIGH;
|
||||
spi->bits_per_word = 8;
|
||||
res = spi_setup(spi);
|
||||
if (res)
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
struct hym8563 {
|
||||
struct i2c_client *client;
|
||||
struct rtc_device *rtc;
|
||||
bool valid;
|
||||
#ifdef CONFIG_COMMON_CLK
|
||||
struct clk_hw clkout_hw;
|
||||
#endif
|
||||
@@ -91,19 +90,19 @@ struct hym8563 {
|
||||
static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct hym8563 *hym8563 = i2c_get_clientdata(client);
|
||||
u8 buf[7];
|
||||
int ret;
|
||||
|
||||
if (!hym8563->valid) {
|
||||
dev_warn(&client->dev, "no valid clock/calendar values available\n");
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
ret = i2c_smbus_read_i2c_block_data(client, HYM8563_SEC, 7, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (buf[0] & HYM8563_SEC_VL) {
|
||||
dev_warn(&client->dev,
|
||||
"no valid clock/calendar values available\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tm->tm_sec = bcd2bin(buf[0] & HYM8563_SEC_MASK);
|
||||
tm->tm_min = bcd2bin(buf[1] & HYM8563_MIN_MASK);
|
||||
tm->tm_hour = bcd2bin(buf[2] & HYM8563_HOUR_MASK);
|
||||
@@ -118,7 +117,6 @@ static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
static int hym8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct hym8563 *hym8563 = i2c_get_clientdata(client);
|
||||
u8 buf[7];
|
||||
int ret;
|
||||
|
||||
@@ -157,8 +155,6 @@ static int hym8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
hym8563->valid = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -556,9 +552,8 @@ static int hym8563_probe(struct i2c_client *client,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
hym8563->valid = !(ret & HYM8563_SEC_VL);
|
||||
dev_dbg(&client->dev, "rtc information is %s\n",
|
||||
hym8563->valid ? "valid" : "invalid");
|
||||
(ret & HYM8563_SEC_VL) ? "invalid" : "valid");
|
||||
|
||||
hym8563->rtc = devm_rtc_device_register(&client->dev, client->name,
|
||||
&hym8563_rtc_ops, THIS_MODULE);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* MOXA ART RTC driver.
|
||||
*
|
||||
@@ -7,10 +8,6 @@
|
||||
*
|
||||
* Based on code from
|
||||
* Moxa Technology Co., Ltd. <www.moxa.com>
|
||||
*
|
||||
* This file is licensed under the terms of the GNU General Public
|
||||
* License version 2. This program is licensed "as is" without any
|
||||
* warranty of any kind, whether express or implied.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
|
||||
@@ -297,15 +297,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)
|
||||
|
||||
rtc->rtc_dev->ops = &mtk_rtc_ops;
|
||||
|
||||
ret = rtc_register_device(rtc->rtc_dev);
|
||||
if (ret)
|
||||
goto out_free_irq;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_irq:
|
||||
free_irq(rtc->irq, rtc);
|
||||
return ret;
|
||||
return rtc_register_device(rtc->rtc_dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
||||
@@ -616,7 +616,7 @@ static int rtc_pinconf_get(struct pinctrl_dev *pctldev,
|
||||
break;
|
||||
default:
|
||||
return -ENOTSUPP;
|
||||
};
|
||||
}
|
||||
|
||||
*config = pinconf_to_config_packed(param, arg);
|
||||
|
||||
|
||||
@@ -199,11 +199,9 @@ static int pcf2127_rtc_ioctl(struct device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
touser = touser & PCF2127_BIT_CTRL3_BLF ? 1 : 0;
|
||||
touser = touser & PCF2127_BIT_CTRL3_BLF ? RTC_VL_BACKUP_LOW : 0;
|
||||
|
||||
if (copy_to_user((void __user *)arg, &touser, sizeof(int)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return put_user(touser, (unsigned int __user *)arg);
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
|
||||
@@ -289,21 +289,9 @@ static int pcf85063_ioctl(struct device *dev, unsigned int cmd,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (status & PCF85063_REG_SC_OS)
|
||||
dev_warn(&pcf85063->rtc->dev, "Voltage low, data loss detected.\n");
|
||||
status = status & PCF85063_REG_SC_OS ? RTC_VL_DATA_INVALID : 0;
|
||||
|
||||
status &= PCF85063_REG_SC_OS;
|
||||
|
||||
if (copy_to_user((void __user *)arg, &status, sizeof(int)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
|
||||
case RTC_VL_CLR:
|
||||
ret = regmap_update_bits(pcf85063->regmap, PCF85063_REG_SC,
|
||||
PCF85063_REG_SC_OS, 0);
|
||||
|
||||
return ret;
|
||||
return put_user(status, (unsigned int __user *)arg);
|
||||
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
|
||||
@@ -282,11 +282,11 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
|
||||
ret = pcf8523_voltage_low(client);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret)
|
||||
ret = RTC_VL_BACKUP_LOW;
|
||||
|
||||
if (copy_to_user((void __user *)arg, &ret, sizeof(int)))
|
||||
return -EFAULT;
|
||||
return put_user(ret, (unsigned int __user *)arg);
|
||||
|
||||
return 0;
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#define PCF8563_REG_ST1 0x00 /* status */
|
||||
#define PCF8563_REG_ST2 0x01
|
||||
#define PCF8563_BIT_AIE (1 << 1)
|
||||
#define PCF8563_BIT_AF (1 << 3)
|
||||
#define PCF8563_BIT_AIE BIT(1)
|
||||
#define PCF8563_BIT_AF BIT(3)
|
||||
#define PCF8563_BITS_ST2_N (7 << 5)
|
||||
|
||||
#define PCF8563_REG_SC 0x02 /* datetime */
|
||||
@@ -76,7 +76,6 @@ struct pcf8563 {
|
||||
* 1970...2069.
|
||||
*/
|
||||
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
|
||||
int voltage_low; /* incicates if a low_voltage was detected */
|
||||
|
||||
struct i2c_client *client;
|
||||
#ifdef CONFIG_COMMON_CLK
|
||||
@@ -208,7 +207,6 @@ static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
return err;
|
||||
|
||||
if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) {
|
||||
pcf8563->voltage_low = 1;
|
||||
dev_err(&client->dev,
|
||||
"low voltage detected, date/time is not reliable.\n");
|
||||
return -EINVAL;
|
||||
@@ -276,43 +274,23 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||
9 - PCF8563_REG_SC, buf + PCF8563_REG_SC);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RTC_INTF_DEV
|
||||
static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct pcf8563 *pcf8563 = i2c_get_clientdata(to_i2c_client(dev));
|
||||
struct rtc_time tm;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
int ret;
|
||||
|
||||
switch (cmd) {
|
||||
case RTC_VL_READ:
|
||||
if (pcf8563->voltage_low)
|
||||
dev_info(dev, "low voltage detected, date/time is not reliable.\n");
|
||||
ret = i2c_smbus_read_byte_data(client, PCF8563_REG_SC);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (copy_to_user((void __user *)arg, &pcf8563->voltage_low,
|
||||
sizeof(int)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
case RTC_VL_CLR:
|
||||
/*
|
||||
* Clear the VL bit in the seconds register in case
|
||||
* the time has not been set already (which would
|
||||
* have cleared it). This does not really matter
|
||||
* because of the cached voltage_low value but do it
|
||||
* anyway for consistency.
|
||||
*/
|
||||
if (pcf8563_rtc_read_time(dev, &tm))
|
||||
pcf8563_rtc_set_time(dev, &tm);
|
||||
|
||||
/* Clear the cached value. */
|
||||
pcf8563->voltage_low = 0;
|
||||
|
||||
return 0;
|
||||
return put_user(ret & PCF8563_SC_LV ? RTC_VL_DATA_INVALID : 0,
|
||||
(unsigned int __user *)arg);
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define pcf8563_rtc_ioctl NULL
|
||||
#endif
|
||||
|
||||
static int pcf8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *tm)
|
||||
{
|
||||
|
||||
@@ -428,21 +428,8 @@ static int rv3028_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (status & RV3028_STATUS_PORF)
|
||||
dev_warn(&rv3028->rtc->dev, "Voltage low, data loss detected.\n");
|
||||
|
||||
status &= RV3028_STATUS_PORF;
|
||||
|
||||
if (copy_to_user((void __user *)arg, &status, sizeof(int)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
|
||||
case RTC_VL_CLR:
|
||||
ret = regmap_update_bits(rv3028->regmap, RV3028_STATUS,
|
||||
RV3028_STATUS_PORF, 0);
|
||||
|
||||
return ret;
|
||||
status = status & RV3028_STATUS_PORF ? RTC_VL_DATA_INVALID : 0;
|
||||
return put_user(status, (unsigned int __user *)arg);
|
||||
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user