* [PATCH 1/5] rtc: imxdi: set range
@ 2019-04-16 8:34 Alexandre Belloni
2019-04-16 8:34 ` [PATCH 2/5] rtc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alexandre Belloni @ 2019-04-16 8:34 UTC (permalink / raw)
To: linux-rtc
Cc: Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-arm-kernel, linux-kernel, Alexandre Belloni
The RTC Time Counter MSB Register contains the 32 most significant bits
(47:16) of the 47-bit RTC Time Counter. Clocked by a 32.768 KHz clock, this
register is effectively a 32-bit seconds counter.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-imxdi.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 80931114c899..43d9cad69241 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -796,6 +796,10 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
mutex_init(&imxdi->write_mutex);
+ imxdi->rtc = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(imxdi->rtc))
+ return PTR_ERR(imxdi->rtc);
+
imxdi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(imxdi->clk))
return PTR_ERR(imxdi->clk);
@@ -829,12 +833,13 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, imxdi);
- imxdi->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
- &dryice_rtc_ops, THIS_MODULE);
- if (IS_ERR(imxdi->rtc)) {
- rc = PTR_ERR(imxdi->rtc);
+
+ imxdi->rtc->ops = &dryice_rtc_ops;
+ imxdi->rtc->range_max = U32_MAX;
+
+ rc = rtc_register_device(imxdi->rtc);
+ if (rc)
goto err;
- }
return 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/5] rtc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64
2019-04-16 8:34 [PATCH 1/5] rtc: imxdi: set range Alexandre Belloni
@ 2019-04-16 8:34 ` Alexandre Belloni
2019-04-16 8:34 ` [PATCH 3/5] rtc: imxdi: use .set_time Alexandre Belloni
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2019-04-16 8:34 UTC (permalink / raw)
To: linux-rtc
Cc: Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-arm-kernel, linux-kernel, Alexandre Belloni
Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-imxdi.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 43d9cad69241..8a7ad1502e4f 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -552,7 +552,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm)
unsigned long now;
now = readl(imxdi->ioaddr + DTCMR);
- rtc_time_to_tm(now, tm);
+ rtc_time64_to_tm(now, tm);
return 0;
}
@@ -618,7 +618,7 @@ static int dryice_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
u32 dcamr;
dcamr = readl(imxdi->ioaddr + DCAMR);
- rtc_time_to_tm(dcamr, &alarm->time);
+ rtc_time64_to_tm(dcamr, &alarm->time);
/* alarm is enabled if the interrupt is enabled */
alarm->enabled = (readl(imxdi->ioaddr + DIER) & DIER_CAIE) != 0;
@@ -644,9 +644,7 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
unsigned long alarm_time;
int rc;
- rc = rtc_tm_to_time(&alarm->time, &alarm_time);
- if (rc)
- return rc;
+ alarm_time = rtc_tm_to_time64(&alarm->time);
/* don't allow setting alarm in the past */
now = readl(imxdi->ioaddr + DTCMR);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/5] rtc: imxdi: use .set_time
2019-04-16 8:34 [PATCH 1/5] rtc: imxdi: set range Alexandre Belloni
2019-04-16 8:34 ` [PATCH 2/5] rtc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
@ 2019-04-16 8:34 ` Alexandre Belloni
2019-04-16 8:34 ` [PATCH 4/5] rtc: imxdi: remove unnecessary check Alexandre Belloni
2019-04-16 8:34 ` [PATCH 5/5] rtc: imxdi: convert to SPDX identifier Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2019-04-16 8:34 UTC (permalink / raw)
To: linux-rtc
Cc: Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-arm-kernel, linux-kernel, Alexandre Belloni
Use .set_time instead of the deprecated .set_mmss.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-imxdi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 8a7ad1502e4f..254bc894105b 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -561,7 +561,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm)
* set the seconds portion of dryice time counter and clear the
* fractional part.
*/
-static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int dryice_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct imxdi_dev *imxdi = dev_get_drvdata(dev);
u32 dcr, dsr;
@@ -588,7 +588,7 @@ static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs)
if (rc != 0)
return rc;
- rc = di_write_wait(imxdi, secs, DTCMR);
+ rc = di_write_wait(imxdi, rtc_tm_to_time64(tm), DTCMR);
if (rc != 0)
return rc;
@@ -666,7 +666,7 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
static const struct rtc_class_ops dryice_rtc_ops = {
.read_time = dryice_rtc_read_time,
- .set_mmss = dryice_rtc_set_mmss,
+ .set_time = dryice_rtc_set_time,
.alarm_irq_enable = dryice_rtc_alarm_irq_enable,
.read_alarm = dryice_rtc_read_alarm,
.set_alarm = dryice_rtc_set_alarm,
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] rtc: imxdi: remove unnecessary check
2019-04-16 8:34 [PATCH 1/5] rtc: imxdi: set range Alexandre Belloni
2019-04-16 8:34 ` [PATCH 2/5] rtc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
2019-04-16 8:34 ` [PATCH 3/5] rtc: imxdi: use .set_time Alexandre Belloni
@ 2019-04-16 8:34 ` Alexandre Belloni
2019-04-16 8:34 ` [PATCH 5/5] rtc: imxdi: convert to SPDX identifier Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2019-04-16 8:34 UTC (permalink / raw)
To: linux-rtc
Cc: Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-arm-kernel, linux-kernel, Alexandre Belloni
The RTC core already ensures the alarm is set to a time in the future, it
is not necessary to check again in the driver.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-imxdi.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 254bc894105b..2e1f5069c67f 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -641,18 +641,10 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct imxdi_dev *imxdi = dev_get_drvdata(dev);
unsigned long now;
- unsigned long alarm_time;
int rc;
- alarm_time = rtc_tm_to_time64(&alarm->time);
-
- /* don't allow setting alarm in the past */
- now = readl(imxdi->ioaddr + DTCMR);
- if (alarm_time < now)
- return -EINVAL;
-
/* write the new alarm time */
- rc = di_write_wait(imxdi, (u32)alarm_time, DCAMR);
+ rc = di_write_wait(imxdi, rtc_tm_to_time64(&alarm->time), DCAMR);
if (rc)
return rc;
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] rtc: imxdi: convert to SPDX identifier
2019-04-16 8:34 [PATCH 1/5] rtc: imxdi: set range Alexandre Belloni
` (2 preceding siblings ...)
2019-04-16 8:34 ` [PATCH 4/5] rtc: imxdi: remove unnecessary check Alexandre Belloni
@ 2019-04-16 8:34 ` Alexandre Belloni
3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2019-04-16 8:34 UTC (permalink / raw)
To: linux-rtc
Cc: Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-arm-kernel, linux-kernel, Alexandre Belloni
Use SPDX-License-Identifier instead of a verbose license text.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-imxdi.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 2e1f5069c67f..6342bc403645 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -1,19 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright 2010 Orex Computed Radiography
*/
-/*
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/* based on rtc-mc13892.c */
-
/*
* This driver uses the 47-bit 32 kHz counter in the Freescale DryIce block
* to implement a Linux RTC. Times and alarms are truncated to seconds.
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-16 8:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 8:34 [PATCH 1/5] rtc: imxdi: set range Alexandre Belloni
2019-04-16 8:34 ` [PATCH 2/5] rtc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
2019-04-16 8:34 ` [PATCH 3/5] rtc: imxdi: use .set_time Alexandre Belloni
2019-04-16 8:34 ` [PATCH 4/5] rtc: imxdi: remove unnecessary check Alexandre Belloni
2019-04-16 8:34 ` [PATCH 5/5] rtc: imxdi: convert to SPDX identifier Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).