linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT
@ 2022-03-09 16:22 Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 02/29] rtc: ds1685: drop no_irq Alexandre Belloni
                   ` (27 more replies)
  0 siblings, 28 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Joshua Kinard, Alexandre Belloni
  Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
There is currently a missing information as to why this is not supported on
ioc3.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-ds1685.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c
index 75db7ab654a5..0ec1e44e3431 100644
--- a/drivers/rtc/rtc-ds1685.c
+++ b/drivers/rtc/rtc-ds1685.c
@@ -1273,7 +1273,7 @@ ds1685_rtc_probe(struct platform_device *pdev)
 
 	/* See if the platform doesn't support UIE. */
 	if (pdata->uie_unsupported)
-		rtc_dev->uie_unsupported = 1;
+		clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc_dev->features);
 
 	rtc->dev = rtc_dev;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 02/29] rtc: ds1685: drop no_irq
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 03/29] rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Joshua Kinard, Alexandre Belloni
  Cc: linux-rtc, linux-kernel

No platforms are currently setting no_irq. Anyway, letting platform_get_irq
fail is fine as this means that there is no IRQ. In that case, clear
RTC_FEATURE_ALARM so the core knows there are no alarms.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-ds1685.c   | 14 +++++---------
 include/linux/rtc/ds1685.h |  1 -
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c
index 0ec1e44e3431..a24331ba8a5f 100644
--- a/drivers/rtc/rtc-ds1685.c
+++ b/drivers/rtc/rtc-ds1685.c
@@ -1285,13 +1285,10 @@ ds1685_rtc_probe(struct platform_device *pdev)
 	 * there won't be an automatic way of notifying the kernel about it,
 	 * unless ctrlc is explicitly polled.
 	 */
-	if (!pdata->no_irq) {
-		ret = platform_get_irq(pdev, 0);
-		if (ret <= 0)
-			return ret;
-
-		rtc->irq_num = ret;
-
+	rtc->irq_num = platform_get_irq(pdev, 0);
+	if (rtc->irq_num <= 0) {
+		clear_bit(RTC_FEATURE_ALARM, rtc_dev->features);
+	} else {
 		/* Request an IRQ. */
 		ret = devm_request_threaded_irq(&pdev->dev, rtc->irq_num,
 				       NULL, ds1685_rtc_irq_handler,
@@ -1305,7 +1302,6 @@ ds1685_rtc_probe(struct platform_device *pdev)
 			rtc->irq_num = 0;
 		}
 	}
-	rtc->no_irq = pdata->no_irq;
 
 	/* Setup complete. */
 	ds1685_rtc_switch_to_bank0(rtc);
@@ -1394,7 +1390,7 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 		 * have been taken care of by the shutdown scripts and this
 		 * is the final function call.
 		 */
-		if (!rtc->no_irq)
+		if (rtc->irq_num)
 			disable_irq_nosync(rtc->irq_num);
 
 		/* Oscillator must be on and the countdown chain enabled. */
diff --git a/include/linux/rtc/ds1685.h b/include/linux/rtc/ds1685.h
index 67ee9d20cc5a..5a41c3bbcbe3 100644
--- a/include/linux/rtc/ds1685.h
+++ b/include/linux/rtc/ds1685.h
@@ -46,7 +46,6 @@ struct ds1685_priv {
 	u32 regstep;
 	int irq_num;
 	bool bcd_mode;
-	bool no_irq;
 	u8 (*read)(struct ds1685_priv *, int);
 	void (*write)(struct ds1685_priv *, int, u8);
 	void (*prepare_poweroff)(void);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 03/29] rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 02/29] rtc: ds1685: drop no_irq Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 04/29] rtc: mpc5121: let the core handle the alarm resolution Alexandre Belloni
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-ds1307.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 336cb9aa5e33..d51565bcc189 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1955,7 +1955,7 @@ static int ds1307_probe(struct i2c_client *client,
 		dev_info(ds1307->dev,
 			 "'wakeup-source' is set, request for an IRQ is disabled!\n");
 		/* We cannot support UIE mode if we do not have an IRQ line */
-		ds1307->rtc->uie_unsupported = 1;
+		clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, ds1307->rtc->features);
 	}
 
 	if (want_irq) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 04/29] rtc: mpc5121: let the core handle the alarm resolution
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 02/29] rtc: ds1685: drop no_irq Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 03/29] rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 05/29] rtc: mpc5121: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a
resolution of a minute. Also, the core will properly round down the alarm
instead of up.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-mpc5121.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index bb2ea9bc56f2..6bd9779da3c6 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -210,20 +210,6 @@ static int mpc5121_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
 	struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
 
-	/*
-	 * the alarm has no seconds so deal with it
-	 */
-	if (alarm->time.tm_sec) {
-		alarm->time.tm_sec = 0;
-		alarm->time.tm_min++;
-		if (alarm->time.tm_min >= 60) {
-			alarm->time.tm_min = 0;
-			alarm->time.tm_hour++;
-			if (alarm->time.tm_hour >= 24)
-				alarm->time.tm_hour = 0;
-		}
-	}
-
 	alarm->time.tm_mday = -1;
 	alarm->time.tm_mon = -1;
 	alarm->time.tm_year = -1;
@@ -349,6 +335,7 @@ static int mpc5121_rtc_probe(struct platform_device *op)
 	}
 
 	rtc->rtc->ops = &mpc5200_rtc_ops;
+	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtc->features);
 	rtc->rtc->uie_unsupported = 1;
 	rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
 	rtc->rtc->range_max = 65733206399ULL; /* 4052-12-31 23:59:59 */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 05/29] rtc: mpc5121: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (2 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 04/29] rtc: mpc5121: let the core handle the alarm resolution Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 06/29] rtc: m41t80: " Alexandre Belloni
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-mpc5121.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index 6bd9779da3c6..6d7656a75cae 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -336,7 +336,7 @@ static int mpc5121_rtc_probe(struct platform_device *op)
 
 	rtc->rtc->ops = &mpc5200_rtc_ops;
 	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtc->features);
-	rtc->rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtc->features);
 	rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
 	rtc->rtc->range_max = 65733206399ULL; /* 4052-12-31 23:59:59 */
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 06/29] rtc: m41t80: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (3 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 05/29] rtc: mpc5121: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 07/29] rtc: opal: " Alexandre Belloni
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-m41t80.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 6d383b629d20..d868458cd40e 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -932,10 +932,8 @@ static int m41t80_probe(struct i2c_client *client,
 	m41t80_data->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	m41t80_data->rtc->range_max = RTC_TIMESTAMP_END_2099;
 
-	if (client->irq <= 0) {
-		/* We cannot support UIE mode if we do not have an IRQ line */
-		m41t80_data->rtc->uie_unsupported = 1;
-	}
+	if (client->irq <= 0)
+		clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, m41t80_data->rtc->features);
 
 	/* Make sure HT (Halt Update) bit is cleared */
 	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 07/29] rtc: opal: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (4 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 06/29] rtc: m41t80: " Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 08/29] rtc: pcf2123: " Alexandre Belloni
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, Alexandre Belloni
  Cc: linux-rtc, linuxppc-dev, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-opal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
index f8f49a969c23..ad41aaf8a17f 100644
--- a/drivers/rtc/rtc-opal.c
+++ b/drivers/rtc/rtc-opal.c
@@ -250,7 +250,7 @@ static int opal_rtc_probe(struct platform_device *pdev)
 	rtc->ops = &opal_rtc_ops;
 	rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
 	rtc->range_max = RTC_TIMESTAMP_END_9999;
-	rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
 
 	return devm_rtc_register_device(rtc);
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 08/29] rtc: pcf2123: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (5 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 07/29] rtc: opal: " Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 09/29] rtc: pcf2123: set RTC_FEATURE_ALARM_RES_MINUTE Alexandre Belloni
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf2123.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index 7473e6c8a183..da0e4066ef45 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -427,7 +427,7 @@ static int pcf2123_probe(struct spi_device *spi)
 	 * support to this driver to generate interrupts more than once
 	 * per minute.
 	 */
-	rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
 	rtc->ops = &pcf2123_rtc_ops;
 	rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	rtc->range_max = RTC_TIMESTAMP_END_2099;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 09/29] rtc: pcf2123: set RTC_FEATURE_ALARM_RES_MINUTE
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (6 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 08/29] rtc: pcf2123: " Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 10/29] rtc: pcf2127: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Alarms have a resolution of a minute.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf2123.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index da0e4066ef45..e13b5e695d06 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -427,6 +427,7 @@ static int pcf2123_probe(struct spi_device *spi)
 	 * support to this driver to generate interrupts more than once
 	 * per minute.
 	 */
+	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->features);
 	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
 	rtc->ops = &pcf2123_rtc_ops;
 	rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 10/29] rtc: pcf2127: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (7 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 09/29] rtc: pcf2123: set RTC_FEATURE_ALARM_RES_MINUTE Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf2127.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index eae9ecbc7fb5..f8469b134411 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -656,7 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
 	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
 	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
-	pcf2127->rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
 	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
 
 	if (alarm_irq > 0) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (8 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 10/29] rtc: pcf2127: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-10 16:09   ` Hugo Villeneuve
  2022-03-09 16:22 ` [PATCH 12/29] rtc: pcf85063: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (17 subsequent siblings)
  27 siblings, 1 reply; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

The PCF2127 doesn't support UIE because setting an alarm to fire every
second confuses the chip and the fastest we can go is an alarm every 2
seconds.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf2127.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index f8469b134411..63b275b014bd 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
 	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
 	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
+	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
 	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
 	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 12/29] rtc: pcf85063: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (9 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 13/29] rtc: pcf85063: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf85063.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index df2b072c394d..3c2477454063 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -616,7 +616,7 @@ static int pcf85063_probe(struct i2c_client *client)
 	pcf85063->rtc->ops = &pcf85063_rtc_ops;
 	pcf85063->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	pcf85063->rtc->range_max = RTC_TIMESTAMP_END_2099;
-	pcf85063->rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf85063->rtc->features);
 	clear_bit(RTC_FEATURE_ALARM, pcf85063->rtc->features);
 
 	if (config->has_alarms && client->irq > 0) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 13/29] rtc: pcf85063: set RTC_FEATURE_ALARM_RES_2S
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (10 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 12/29] rtc: pcf85063: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 14/29] rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

The PCF85063 doesn't support UIE because setting an alarm to fire every
second confuses the chip and the fastest we can go is an alarm every 2
seconds.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf85063.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 3c2477454063..9760824ec199 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -616,6 +616,7 @@ static int pcf85063_probe(struct i2c_client *client)
 	pcf85063->rtc->ops = &pcf85063_rtc_ops;
 	pcf85063->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	pcf85063->rtc->range_max = RTC_TIMESTAMP_END_2099;
+	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf85063->rtc->features);
 	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf85063->rtc->features);
 	clear_bit(RTC_FEATURE_ALARM, pcf85063->rtc->features);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 14/29] rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (11 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 13/29] rtc: pcf85063: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 15/29] rtc: pcf8523: let the core handle the alarm resolution Alexandre Belloni
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf8523.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index baa89f431ebd..cd55fdfe1d39 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -450,7 +450,7 @@ static int pcf8523_probe(struct i2c_client *client,
 	rtc->ops = &pcf8523_rtc_ops;
 	rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	rtc->range_max = RTC_TIMESTAMP_END_2099;
-	rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
 
 	if (client->irq > 0) {
 		err = regmap_write(pcf8523->regmap, PCF8523_TMR_CLKOUT_CTRL, 0x38);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 15/29] rtc: pcf8523: let the core handle the alarm resolution
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (12 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 14/29] rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 16/29] rtc: pcf8563: " Alexandre Belloni
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a
resolution of a minute. Also, the core will properly round down the alarm
instead of up.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf8523.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index cd55fdfe1d39..b1b1943de844 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -212,14 +212,6 @@ static int pcf8523_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm)
 	if (err < 0)
 		return err;
 
-	/* The alarm has no seconds, round up to nearest minute */
-	if (tm->time.tm_sec) {
-		time64_t alarm_time = rtc_tm_to_time64(&tm->time);
-
-		alarm_time += 60 - tm->time.tm_sec;
-		rtc_time64_to_tm(alarm_time, &tm->time);
-	}
-
 	regs[0] = bin2bcd(tm->time.tm_min);
 	regs[1] = bin2bcd(tm->time.tm_hour);
 	regs[2] = bin2bcd(tm->time.tm_mday);
@@ -450,6 +442,7 @@ static int pcf8523_probe(struct i2c_client *client,
 	rtc->ops = &pcf8523_rtc_ops;
 	rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	rtc->range_max = RTC_TIMESTAMP_END_2099;
+	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->features);
 	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
 
 	if (client->irq > 0) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 16/29] rtc: pcf8563: let the core handle the alarm resolution
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (13 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 15/29] rtc: pcf8523: let the core handle the alarm resolution Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 17/29] rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a
resolution of a minute. Also, the core will properly round down the alarm
instead of up.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf8563.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index c8bddfb94129..530f06c810fa 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -330,19 +330,6 @@ static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm)
 	unsigned char buf[4];
 	int err;
 
-	/* The alarm has no seconds, round up to nearest minute */
-	if (tm->time.tm_sec) {
-		time64_t alarm_time = rtc_tm_to_time64(&tm->time);
-
-		alarm_time += 60 - tm->time.tm_sec;
-		rtc_time64_to_tm(alarm_time, &tm->time);
-	}
-
-	dev_dbg(dev, "%s, min=%d hour=%d wday=%d mday=%d "
-		"enabled=%d pending=%d\n", __func__,
-		tm->time.tm_min, tm->time.tm_hour, tm->time.tm_wday,
-		tm->time.tm_mday, tm->enabled, tm->pending);
-
 	buf[0] = bin2bcd(tm->time.tm_min);
 	buf[1] = bin2bcd(tm->time.tm_hour);
 	buf[2] = bin2bcd(tm->time.tm_mday);
@@ -566,6 +553,7 @@ static int pcf8563_probe(struct i2c_client *client,
 	pcf8563->rtc->ops = &pcf8563_rtc_ops;
 	/* the pcf8563 alarm only supports a minute accuracy */
 	pcf8563->rtc->uie_unsupported = 1;
+	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, pcf8563->rtc->features);
 	pcf8563->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	pcf8563->rtc->range_max = RTC_TIMESTAMP_END_2099;
 	pcf8563->rtc->set_start_time = true;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 17/29] rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (14 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 16/29] rtc: pcf8563: " Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device Alexandre Belloni
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-pcf8563.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 530f06c810fa..9d06813e2e6d 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -552,8 +552,8 @@ static int pcf8563_probe(struct i2c_client *client,
 
 	pcf8563->rtc->ops = &pcf8563_rtc_ops;
 	/* the pcf8563 alarm only supports a minute accuracy */
-	pcf8563->rtc->uie_unsupported = 1;
 	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, pcf8563->rtc->features);
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf8563->rtc->features);
 	pcf8563->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	pcf8563->rtc->range_max = RTC_TIMESTAMP_END_2099;
 	pcf8563->rtc->set_start_time = true;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (15 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 17/29] rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-10  3:29   ` Viresh Kumar
  2022-03-09 16:22 ` [PATCH 19/29] rtc: spear: set range Alexandre Belloni
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows
for further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-spear.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index b4a520056b1a..1b40380aaba2 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -352,6 +352,10 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	if (!config)
 		return -ENOMEM;
 
+	config->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(config->rtc))
+		return PTR_ERR(config->rtc);
+
 	/* alarm irqs */
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
@@ -380,17 +384,13 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	spin_lock_init(&config->lock);
 	platform_set_drvdata(pdev, config);
 
-	config->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-					&spear_rtc_ops, THIS_MODULE);
-	if (IS_ERR(config->rtc)) {
-		dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
-				PTR_ERR(config->rtc));
-		status = PTR_ERR(config->rtc);
-		goto err_disable_clock;
-	}
-
+	config->rtc->ops = &spear_rtc_ops;
 	config->rtc->uie_unsupported = 1;
 
+	status = devm_rtc_register_device(config->rtc);
+	if (status)
+		goto err_disable_clock;
+
 	if (!device_can_wakeup(&pdev->dev))
 		device_init_wakeup(&pdev->dev, 1);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 19/29] rtc: spear: set range
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (16 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-10  3:28   ` Viresh Kumar
  2022-03-09 16:22 ` [PATCH 20/29] rtc: spear: drop uie_unsupported Alexandre Belloni
                   ` (9 subsequent siblings)
  27 siblings, 1 reply; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

While the RTC can store dates from year 0000 to 9999, leap years where not
tested fro 2100. The driver currently stores tm_year directly which will
probably fail at that time or more probably in 2300.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-spear.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index 1b40380aaba2..e386bd714b52 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -385,6 +385,8 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, config);
 
 	config->rtc->ops = &spear_rtc_ops;
+	config->rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
+	config->rtc->range_min = RTC_TIMESTAMP_END_9999;
 	config->rtc->uie_unsupported = 1;
 
 	status = devm_rtc_register_device(config->rtc);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 20/29] rtc: spear: drop uie_unsupported
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (17 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 19/29] rtc: spear: set range Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-10  3:29   ` Viresh Kumar
  2022-03-09 16:22 ` [PATCH 21/29] rtc: spear: fix spear_rtc_read_time Alexandre Belloni
                   ` (8 subsequent siblings)
  27 siblings, 1 reply; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Since commitc9f5c7e7a84f ("rtc: rtc-spear: Provide flag for no support of
UIE mode") which was in 2012, the core changed a lot and UIE are now
supported using regular alarms. Drop uie_unsupported now to reflect that.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-spear.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index e386bd714b52..c395af3ebc91 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -387,7 +387,6 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	config->rtc->ops = &spear_rtc_ops;
 	config->rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
 	config->rtc->range_min = RTC_TIMESTAMP_END_9999;
-	config->rtc->uie_unsupported = 1;
 
 	status = devm_rtc_register_device(config->rtc);
 	if (status)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 21/29] rtc: spear: fix spear_rtc_read_time
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (18 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 20/29] rtc: spear: drop uie_unsupported Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-10  3:28   ` Viresh Kumar
  2022-03-09 16:22 ` [PATCH 22/29] rtc: add new RTC_FEATURE_ALARM_WAKEUP_ONLY feature Alexandre Belloni
                   ` (7 subsequent siblings)
  27 siblings, 1 reply; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

The reference manual doesn't specify whether the registers are latched and
they probably aren't, ensure the read time and date are consistent.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-spear.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index c395af3ebc91..d4777b01ab22 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -204,8 +204,10 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	/* we don't report wday/yday/isdst ... */
 	rtc_wait_not_busy(config);
 
-	time = readl(config->ioaddr + TIME_REG);
-	date = readl(config->ioaddr + DATE_REG);
+	do {
+		time = readl(config->ioaddr + TIME_REG);
+		date = readl(config->ioaddr + DATE_REG);
+	} while (time == readl(config->ioaddr + TIME_REG));
 	tm->tm_sec = (time >> SECOND_SHIFT) & SECOND_MASK;
 	tm->tm_min = (time >> MINUTE_SHIFT) & MIN_MASK;
 	tm->tm_hour = (time >> HOUR_SHIFT) & HOUR_MASK;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 22/29] rtc: add new RTC_FEATURE_ALARM_WAKEUP_ONLY feature
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (19 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 21/29] rtc: spear: fix spear_rtc_read_time Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 23/29] rtc: efi: switch to devm_rtc_allocate_device Alexandre Belloni
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Some RTCs have an IRQ pin that is not connected to a CPU interrupt but
rather directly to a PMIC or power supply. In that case, it is still useful
to be able to set alarms but we shouldn't expect interrupts.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 include/uapi/linux/rtc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/rtc.h b/include/uapi/linux/rtc.h
index 03e5b776e597..97aca4503a6a 100644
--- a/include/uapi/linux/rtc.h
+++ b/include/uapi/linux/rtc.h
@@ -133,7 +133,8 @@ struct rtc_param {
 #define RTC_FEATURE_UPDATE_INTERRUPT	4
 #define RTC_FEATURE_CORRECTION		5
 #define RTC_FEATURE_BACKUP_SWITCH_MODE	6
-#define RTC_FEATURE_CNT			7
+#define RTC_FEATURE_ALARM_WAKEUP_ONLY	7
+#define RTC_FEATURE_CNT			8
 
 /* parameter list */
 #define RTC_PARAM_FEATURES		0
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 23/29] rtc: efi: switch to devm_rtc_allocate_device
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (20 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 22/29] rtc: add new RTC_FEATURE_ALARM_WAKEUP_ONLY feature Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 24/29] rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows
for further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-efi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 138c5e0046c8..0c0e382c22e2 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -261,15 +261,16 @@ static int __init efi_rtc_probe(struct platform_device *dev)
 	if (efi.get_time(&eft, &cap) != EFI_SUCCESS)
 		return -ENODEV;
 
-	rtc = devm_rtc_device_register(&dev->dev, "rtc-efi", &efi_rtc_ops,
-					THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&dev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
-	rtc->uie_unsupported = 1;
 	platform_set_drvdata(dev, rtc);
 
-	return 0;
+	rtc->ops = &efi_rtc_ops;
+	rtc->uie_unsupported = 1;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static struct platform_driver efi_rtc_driver = {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 24/29] rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (21 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 23/29] rtc: efi: switch to devm_rtc_allocate_device Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 25/29] rtc: hym8563: switch to devm_rtc_allocate_device Alexandre Belloni
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
Also the driver doesn't supports UIE because it doesn't handle interrupts
so set RTC_FEATURE_ALARM_WAKEUP_ONLY,.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-efi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 0c0e382c22e2..11850c2880ad 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -268,7 +268,8 @@ static int __init efi_rtc_probe(struct platform_device *dev)
 	platform_set_drvdata(dev, rtc);
 
 	rtc->ops = &efi_rtc_ops;
-	rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
+	set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features);
 
 	return devm_rtc_register_device(rtc);
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 25/29] rtc: hym8563: switch to devm_rtc_allocate_device
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (22 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 24/29] rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 26/29] rtc: hym8563: let the core handle the alarm resolution Alexandre Belloni
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows
for further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-hym8563.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 0751cae27285..ce4cbf0f48e7 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -523,6 +523,10 @@ static int hym8563_probe(struct i2c_client *client,
 	if (!hym8563)
 		return -ENOMEM;
 
+	hym8563->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(hym8563->rtc))
+		return PTR_ERR(hym8563->rtc);
+
 	hym8563->client = client;
 	i2c_set_clientdata(client, hym8563);
 
@@ -557,11 +561,7 @@ static int hym8563_probe(struct i2c_client *client,
 	dev_dbg(&client->dev, "rtc information is %s\n",
 		(ret & HYM8563_SEC_VL) ? "invalid" : "valid");
 
-	hym8563->rtc = devm_rtc_device_register(&client->dev, client->name,
-						&hym8563_rtc_ops, THIS_MODULE);
-	if (IS_ERR(hym8563->rtc))
-		return PTR_ERR(hym8563->rtc);
-
+	hym8563->rtc->ops = &hym8563_rtc_ops;
 	/* the hym8563 alarm only supports a minute accuracy */
 	hym8563->rtc->uie_unsupported = 1;
 
@@ -569,7 +569,7 @@ static int hym8563_probe(struct i2c_client *client,
 	hym8563_clkout_register_clk(hym8563);
 #endif
 
-	return 0;
+	return devm_rtc_register_device(hym8563->rtc);
 }
 
 static const struct i2c_device_id hym8563_id[] = {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 26/29] rtc: hym8563: let the core handle the alarm resolution
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (23 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 25/29] rtc: hym8563: switch to devm_rtc_allocate_device Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 27/29] rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a
resolution of a minute. Also, the core will properly round down the alarm
instead of up.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-hym8563.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index ce4cbf0f48e7..78f21f623d89 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -220,24 +220,6 @@ static int hym8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
 	u8 buf[4];
 	int ret;
 
-	/*
-	 * The alarm has no seconds so deal with it
-	 */
-	if (alm_tm->tm_sec) {
-		alm_tm->tm_sec = 0;
-		alm_tm->tm_min++;
-		if (alm_tm->tm_min >= 60) {
-			alm_tm->tm_min = 0;
-			alm_tm->tm_hour++;
-			if (alm_tm->tm_hour >= 24) {
-				alm_tm->tm_hour = 0;
-				alm_tm->tm_mday++;
-				if (alm_tm->tm_mday > 31)
-					alm_tm->tm_mday = 0;
-			}
-		}
-	}
-
 	ret = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
 	if (ret < 0)
 		return ret;
@@ -562,6 +544,7 @@ static int hym8563_probe(struct i2c_client *client,
 		(ret & HYM8563_SEC_VL) ? "invalid" : "valid");
 
 	hym8563->rtc->ops = &hym8563_rtc_ops;
+	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, hym8563->rtc->features);
 	/* the hym8563 alarm only supports a minute accuracy */
 	hym8563->rtc->uie_unsupported = 1;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 27/29] rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPT
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (24 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 26/29] rtc: hym8563: let the core handle the alarm resolution Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:22 ` [PATCH 28/29] rtc: xgene: stop using uie_unsupported Alexandre Belloni
  2022-03-09 16:23 ` [PATCH 29/29] rtc: remove uie_unsupported Alexandre Belloni
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-hym8563.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 78f21f623d89..90e602e99d03 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -545,8 +545,7 @@ static int hym8563_probe(struct i2c_client *client,
 
 	hym8563->rtc->ops = &hym8563_rtc_ops;
 	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, hym8563->rtc->features);
-	/* the hym8563 alarm only supports a minute accuracy */
-	hym8563->rtc->uie_unsupported = 1;
+	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, hym8563->rtc->features);
 
 #ifdef CONFIG_COMMON_CLK
 	hym8563_clkout_register_clk(hym8563);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 28/29] rtc: xgene: stop using uie_unsupported
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (25 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 27/29] rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
@ 2022-03-09 16:22 ` Alexandre Belloni
  2022-03-09 16:23 ` [PATCH 29/29] rtc: remove uie_unsupported Alexandre Belloni
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:22 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Remove bogus use of uie_unsupported.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-xgene.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c
index cf68a9b1c9eb..d3d0054e21fd 100644
--- a/drivers/rtc/rtc-xgene.c
+++ b/drivers/rtc/rtc-xgene.c
@@ -180,8 +180,6 @@ static int xgene_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	/* HW does not support update faster than 1 seconds */
-	pdata->rtc->uie_unsupported = 1;
 	pdata->rtc->ops = &xgene_rtc_ops;
 	pdata->rtc->range_max = U32_MAX;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 29/29] rtc: remove uie_unsupported
  2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
                   ` (26 preceding siblings ...)
  2022-03-09 16:22 ` [PATCH 28/29] rtc: xgene: stop using uie_unsupported Alexandre Belloni
@ 2022-03-09 16:23 ` Alexandre Belloni
  27 siblings, 0 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-09 16:23 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

uie_unsupported is not used by any drivers anymore, remove it.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/class.c | 3 ---
 include/linux/rtc.h | 2 --
 2 files changed, 5 deletions(-)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 40d504dac1a9..3c8eec2218df 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -399,9 +399,6 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 	if (!rtc->ops->set_alarm)
 		clear_bit(RTC_FEATURE_ALARM, rtc->features);
 
-	if (rtc->uie_unsupported)
-		clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
-
 	if (rtc->ops->set_offset)
 		set_bit(RTC_FEATURE_CORRECTION, rtc->features);
 
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 47fd1c2d3a57..1fd9c6a21ebe 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -110,8 +110,6 @@ struct rtc_device {
 	struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */
 	int pie_enabled;
 	struct work_struct irqwork;
-	/* Some hardware can't support UIE mode */
-	int uie_unsupported;
 
 	/*
 	 * This offset specifies the update timing of the RTC.
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 21/29] rtc: spear: fix spear_rtc_read_time
  2022-03-09 16:22 ` [PATCH 21/29] rtc: spear: fix spear_rtc_read_time Alexandre Belloni
@ 2022-03-10  3:28   ` Viresh Kumar
  0 siblings, 0 replies; 40+ messages in thread
From: Viresh Kumar @ 2022-03-10  3:28 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, Linux Kernel Mailing List

On Wed, Mar 9, 2022 at 10:26 PM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> The reference manual doesn't specify whether the registers are latched and
> they probably aren't, ensure the read time and date are consistent.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/rtc-spear.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 19/29] rtc: spear: set range
  2022-03-09 16:22 ` [PATCH 19/29] rtc: spear: set range Alexandre Belloni
@ 2022-03-10  3:28   ` Viresh Kumar
  0 siblings, 0 replies; 40+ messages in thread
From: Viresh Kumar @ 2022-03-10  3:28 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, Linux Kernel Mailing List

On Wed, Mar 9, 2022 at 10:26 PM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> While the RTC can store dates from year 0000 to 9999, leap years where not
> tested fro 2100. The driver currently stores tm_year directly which will

from*

> probably fail at that time or more probably in 2300.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/rtc-spear.c | 2 ++
>  1 file changed, 2 insertions(+)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 20/29] rtc: spear: drop uie_unsupported
  2022-03-09 16:22 ` [PATCH 20/29] rtc: spear: drop uie_unsupported Alexandre Belloni
@ 2022-03-10  3:29   ` Viresh Kumar
  0 siblings, 0 replies; 40+ messages in thread
From: Viresh Kumar @ 2022-03-10  3:29 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, Linux Kernel Mailing List

On Wed, Mar 9, 2022 at 10:26 PM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> Since commitc9f5c7e7a84f ("rtc: rtc-spear: Provide flag for no support of
> UIE mode") which was in 2012, the core changed a lot and UIE are now
> supported using regular alarms. Drop uie_unsupported now to reflect that.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/rtc-spear.c | 1 -
>  1 file changed, 1 deletion(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device
  2022-03-09 16:22 ` [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device Alexandre Belloni
@ 2022-03-10  3:29   ` Viresh Kumar
  0 siblings, 0 replies; 40+ messages in thread
From: Viresh Kumar @ 2022-03-10  3:29 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, Linux Kernel Mailing List

On Wed, Mar 9, 2022 at 10:26 PM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows
> for further improvement of the driver.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/rtc-spear.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-09 16:22 ` [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
@ 2022-03-10 16:09   ` Hugo Villeneuve
  2022-03-10 20:58     ` Alexandre Belloni
  0 siblings, 1 reply; 40+ messages in thread
From: Hugo Villeneuve @ 2022-03-10 16:09 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On Wed,  9 Mar 2022 17:22:42 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:

> The PCF2127 doesn't support UIE because setting an alarm to fire every
> second confuses the chip and the fastest we can go is an alarm every 2
> seconds.

Hi Alexandre,
can you describe what "confuses the chip" means?

In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.

Hugo.


> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/rtc-pcf2127.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> index f8469b134411..63b275b014bd 100644
> --- a/drivers/rtc/rtc-pcf2127.c
> +++ b/drivers/rtc/rtc-pcf2127.c
> @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
>  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
>  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
>  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
>  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
>  
> -- 
> 2.35.1
> 


-- 
Hugo Villeneuve <hugo@hugovil.com>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-10 16:09   ` Hugo Villeneuve
@ 2022-03-10 20:58     ` Alexandre Belloni
  2022-03-10 21:12       ` Hugo Villeneuve
                         ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-10 20:58 UTC (permalink / raw)
  To: Hugo Villeneuve; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On 10/03/2022 11:09:18-0500, Hugo Villeneuve wrote:
> On Wed,  9 Mar 2022 17:22:42 +0100
> Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> 
> > The PCF2127 doesn't support UIE because setting an alarm to fire every
> > second confuses the chip and the fastest we can go is an alarm every 2
> > seconds.
> 
> Hi Alexandre,
> can you describe what "confuses the chip" means?
> 
> In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.
> 

Did you remove uie_unsupported? Else, you may have been using uie
emulation. In my tests last year, the pcf2127 was failing to reassert
the interrupt if an alarm was set every second. The same happens on
other NXP based RTCs (i.e. including microcrystal ones).

I'm going to test again soon (and also reply to your series).

> Hugo.
> 
> 
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > ---
> >  drivers/rtc/rtc-pcf2127.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > index f8469b134411..63b275b014bd 100644
> > --- a/drivers/rtc/rtc-pcf2127.c
> > +++ b/drivers/rtc/rtc-pcf2127.c
> > @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> >  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> >  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
> >  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> > +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
> >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
> >  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
> >  
> > -- 
> > 2.35.1
> > 
> 
> 
> -- 
> Hugo Villeneuve <hugo@hugovil.com>

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-10 20:58     ` Alexandre Belloni
@ 2022-03-10 21:12       ` Hugo Villeneuve
  2022-03-17 15:28       ` Hugo Villeneuve
  2022-12-15 15:12       ` Hugo Villeneuve
  2 siblings, 0 replies; 40+ messages in thread
From: Hugo Villeneuve @ 2022-03-10 21:12 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On Thu, 10 Mar 2022 21:58:49 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:

> On 10/03/2022 11:09:18-0500, Hugo Villeneuve wrote:
> > On Wed,  9 Mar 2022 17:22:42 +0100
> > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > 
> > > The PCF2127 doesn't support UIE because setting an alarm to fire every
> > > second confuses the chip and the fastest we can go is an alarm every 2
> > > seconds.
> > 
> > Hi Alexandre,
> > can you describe what "confuses the chip" means?
> > 
> > In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.
> > 
> 
> Did you remove uie_unsupported? Else, you may have been using uie
> emulation. In my tests last year, the pcf2127 was failing to reassert
> the interrupt if an alarm was set every second. The same happens on
> other NXP based RTCs (i.e. including microcrystal ones).

Hi,
yes, I did remove uie_unsupported, and I specifically disabled UIE emulation in my kernel configuration.

> I'm going to test again soon (and also reply to your series).

Ok, great.

> > Hugo.
> > 
> > 
> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > ---
> > >  drivers/rtc/rtc-pcf2127.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > index f8469b134411..63b275b014bd 100644
> > > --- a/drivers/rtc/rtc-pcf2127.c
> > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > >  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> > >  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
> > >  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> > > +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
> > >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
> > >  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
> > >  
> > > -- 
> > > 2.35.1
> > > 
> > 
> > 
> > -- 
> > Hugo Villeneuve <hugo@hugovil.com>
> 
> -- 
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 


-- 
Hugo Villeneuve <hugo@hugovil.com>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-10 20:58     ` Alexandre Belloni
  2022-03-10 21:12       ` Hugo Villeneuve
@ 2022-03-17 15:28       ` Hugo Villeneuve
  2022-03-17 17:16         ` Alexandre Belloni
  2022-12-15 15:12       ` Hugo Villeneuve
  2 siblings, 1 reply; 40+ messages in thread
From: Hugo Villeneuve @ 2022-03-17 15:28 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On Thu, 10 Mar 2022 21:58:49 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:

> On 10/03/2022 11:09:18-0500, Hugo Villeneuve wrote:
> > On Wed,  9 Mar 2022 17:22:42 +0100
> > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > 
> > > The PCF2127 doesn't support UIE because setting an alarm to fire every
> > > second confuses the chip and the fastest we can go is an alarm every 2
> > > seconds.
> > 
> > Hi Alexandre,
> > can you describe what "confuses the chip" means?
> > 
> > In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.
> > 
> 
> Did you remove uie_unsupported? Else, you may have been using uie
> emulation. In my tests last year, the pcf2127 was failing to reassert
> the interrupt if an alarm was set every second. The same happens on
> other NXP based RTCs (i.e. including microcrystal ones).
> 
> I'm going to test again soon (and also reply to your series).

Hi,
I have now access to a board with a PCF2129T.

I have been able to test with it by sending ioctl RTC_UIE_ON and confirm that it exhibits the problem you reported. Basically, the first alarm triggers the IRQ after 1s, as expected, but the next configured alarm 1s into the future never triggers the IRQ again. But the time/date registers seem to be updating (incrementin) correctly after that.

Here is a log of my tests, adding dump of registers and a lot of debug traces:

[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 04 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:04 (month=17)
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 04 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:04 (month=17)
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 04 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:04 (month=17)
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_set_alarm
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 04                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C gwrite: [0A] 00000000: 05 00 15 17 80                                   .....
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_alarm
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 04                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [0A] 00000000: 05 00 15 17 80                                   .....
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_alarm: 15:00:05 (month=17)
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 04 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:04 (month=17)
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_alarm_irq_enable: enable = 1
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 04                                               .
[Thu Mar 17 11:02:43 2022] rtc-pcf2127-i2c 4-0051: I2C write:  [01] 00000000: 06                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_irq: irq = 211
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [00] 00000000: 00 16 00 05 00 15 17 04 03 22 05 00 15 17 80 20  ........."..... 
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [00] 00000010: 82 00 80 00 00 00 00 00 00 08                    ..........
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 16                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [00] 00000000: 00                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C write:  [01] 00000000: 06                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 05 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:05 (month=17)
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 05 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:05 (month=17)
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_set_alarm
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 06                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C gwrite: [0A] 00000000: 06 00 15 17 80                                   .....
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_alarm
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 06                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [0A] 00000000: 06 00 15 17 80                                   .....
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_alarm: 15:00:06 (month=17)
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [02] 00000000: 00                                               .
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [03] 00000000: 05 00 15 17 04 03 22                             ......"
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_read_time: 15:00:05 (month=17)
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: pcf2127_rtc_alarm_irq_enable: enable = 1
[Thu Mar 17 11:02:44 2022] rtc-pcf2127-i2c 4-0051: I2C read:   [01] 00000000: 06   

Note: doing the same tests without dump and debug traces doesn't improve things.

I even did some tests where, in pcf2127_rtc_set_alarm(), I disabled all the alarm registers (set to 0x80), except for the SECONDS alarm register. In this case, I observed that the IRQ is triggered after 61s. This seems to indicate that the alarm detection circuitry is still somewhat operating (AF flag / INT pin), but there is probably a bug in the IC when the configured alarm is close to current time after AF is set once...

I also have done other tests by disabling then re-enabling AIE, stopping and restarting the oscillator (STOP bit), etc, but to no avail.

However, in pcf2127_rtc_set_alarm(), if I set the alarm 2s past the current time, instead of 1s, then the IRQ is always triggered after 2s.

I have opened a support case with NXP to investigate this strange behavior.

Hugo.


> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > ---
> > >  drivers/rtc/rtc-pcf2127.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > index f8469b134411..63b275b014bd 100644
> > > --- a/drivers/rtc/rtc-pcf2127.c
> > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > >  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> > >  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
> > >  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> > > +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
> > >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
> > >  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
> > >  
> > > -- 
> > > 2.35.1
> > > 
> > 
> > 
> > -- 
> > Hugo Villeneuve <hugo@hugovil.com>
> 
> -- 
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 


-- 
Hugo Villeneuve <hugo@hugovil.com>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-17 15:28       ` Hugo Villeneuve
@ 2022-03-17 17:16         ` Alexandre Belloni
  2022-05-24 15:10           ` Hugo Villeneuve
  0 siblings, 1 reply; 40+ messages in thread
From: Alexandre Belloni @ 2022-03-17 17:16 UTC (permalink / raw)
  To: Hugo Villeneuve; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

Hi,

On 17/03/2022 11:28:20-0400, Hugo Villeneuve wrote:
> On Thu, 10 Mar 2022 21:58:49 +0100
> Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> 
> > On 10/03/2022 11:09:18-0500, Hugo Villeneuve wrote:
> > > On Wed,  9 Mar 2022 17:22:42 +0100
> > > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > > 
> > > > The PCF2127 doesn't support UIE because setting an alarm to fire every
> > > > second confuses the chip and the fastest we can go is an alarm every 2
> > > > seconds.
> > > 
> > > Hi Alexandre,
> > > can you describe what "confuses the chip" means?
> > > 
> > > In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.
> > > 
> > 
> > Did you remove uie_unsupported? Else, you may have been using uie
> > emulation. In my tests last year, the pcf2127 was failing to reassert
> > the interrupt if an alarm was set every second. The same happens on
> > other NXP based RTCs (i.e. including microcrystal ones).
> > 
> > I'm going to test again soon (and also reply to your series).
> 
> Hi,
> I have now access to a board with a PCF2129T.
> 

I actually did the test again this afternoon with a pcf2127...

> I have been able to test with it by sending ioctl RTC_UIE_ON and
> confirm that it exhibits the problem you reported. Basically, the
> first alarm triggers the IRQ after 1s, as expected, but the next
> configured alarm 1s into the future never triggers the IRQ again. But
> the time/date registers seem to be updating (incrementin) correctly
> after that.
> 

...and so we agree on what we observe. My guess is that the alarm
comparator has a latch that triggers only every second update and so you
need 2 seconds between each alarms.

[...]

> I even did some tests where, in pcf2127_rtc_set_alarm(), I disabled
> all the alarm registers (set to 0x80), except for the SECONDS alarm
> register. In this case, I observed that the IRQ is triggered after
> 61s. This seems to indicate that the alarm detection circuitry is
> still somewhat operating (AF flag / INT pin), but there is probably a
> bug in the IC when the configured alarm is close to current time after
> AF is set once...
> 
> I also have done other tests by disabling then re-enabling AIE,
> stopping and restarting the oscillator (STOP bit), etc, but to no
> avail.
> 
> However, in pcf2127_rtc_set_alarm(), if I set the alarm 2s past the
> current time, instead of 1s, then the IRQ is always triggered after
> 2s.
> 
> I have opened a support case with NXP to investigate this strange
> behavior.

Let me know if you ever get a reply.

> 
> Hugo.
> 
> 
> > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > > ---
> > > >  drivers/rtc/rtc-pcf2127.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > > 
> > > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > > index f8469b134411..63b275b014bd 100644
> > > > --- a/drivers/rtc/rtc-pcf2127.c
> > > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > > @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > > >  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> > > >  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
> > > >  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> > > > +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
> > > >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
> > > >  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
> > > >  
> > > > -- 
> > > > 2.35.1
> > > > 
> > > 
> > > 
> > > -- 
> > > Hugo Villeneuve <hugo@hugovil.com>
> > 
> > -- 
> > Alexandre Belloni, co-owner and COO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
> > 
> 
> 
> -- 
> Hugo Villeneuve <hugo@hugovil.com>

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-17 17:16         ` Alexandre Belloni
@ 2022-05-24 15:10           ` Hugo Villeneuve
  0 siblings, 0 replies; 40+ messages in thread
From: Hugo Villeneuve @ 2022-05-24 15:10 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On Thu, 17 Mar 2022 18:16:17 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:

> Hi,
> 
> On 17/03/2022 11:28:20-0400, Hugo Villeneuve wrote:
> > On Thu, 10 Mar 2022 21:58:49 +0100
> > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > 
> > > On 10/03/2022 11:09:18-0500, Hugo Villeneuve wrote:
> > > > On Wed,  9 Mar 2022 17:22:42 +0100
> > > > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > > > 
> > > > > The PCF2127 doesn't support UIE because setting an alarm to fire every
> > > > > second confuses the chip and the fastest we can go is an alarm every 2
> > > > > seconds.
> > > > 
> > > > Hi Alexandre,
> > > > can you describe what "confuses the chip" means?
> > > > 
> > > > In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.
> > > > 
> > > 
> > > Did you remove uie_unsupported? Else, you may have been using uie
> > > emulation. In my tests last year, the pcf2127 was failing to reassert
> > > the interrupt if an alarm was set every second. The same happens on
> > > other NXP based RTCs (i.e. including microcrystal ones).
> > > 
> > > I'm going to test again soon (and also reply to your series).
> > 
> > Hi,
> > I have now access to a board with a PCF2129T.
> > 
> 
> I actually did the test again this afternoon with a pcf2127...
> 
> > I have been able to test with it by sending ioctl RTC_UIE_ON and
> > confirm that it exhibits the problem you reported. Basically, the
> > first alarm triggers the IRQ after 1s, as expected, but the next
> > configured alarm 1s into the future never triggers the IRQ again. But
> > the time/date registers seem to be updating (incrementin) correctly
> > after that.
> > 
> 
> ...and so we agree on what we observe. My guess is that the alarm
> comparator has a latch that triggers only every second update and so you
> need 2 seconds between each alarms.
> 
> [...]
> 
> > I even did some tests where, in pcf2127_rtc_set_alarm(), I disabled
> > all the alarm registers (set to 0x80), except for the SECONDS alarm
> > register. In this case, I observed that the IRQ is triggered after
> > 61s. This seems to indicate that the alarm detection circuitry is
> > still somewhat operating (AF flag / INT pin), but there is probably a
> > bug in the IC when the configured alarm is close to current time after
> > AF is set once...
> > 
> > I also have done other tests by disabling then re-enabling AIE,
> > stopping and restarting the oscillator (STOP bit), etc, but to no
> > avail.
> > 
> > However, in pcf2127_rtc_set_alarm(), if I set the alarm 2s past the
> > current time, instead of 1s, then the IRQ is always triggered after
> > 2s.
> > 
> > I have opened a support case with NXP to investigate this strange
> > behavior.
> 
> Let me know if you ever get a reply.

Hi Alexandre,
after two months and a lot of emails with NXP awful technical support, I was never able to have a valid answer to the problem, apart from "Use a new device as the PCF2127 is not recommended for new designs" :(

On the other hand, have you had time to look at my patch series for the PCF2131 driver?

Thank you, Hugo.


> > > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > > > ---
> > > > >  drivers/rtc/rtc-pcf2127.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > > 
> > > > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > > > index f8469b134411..63b275b014bd 100644
> > > > > --- a/drivers/rtc/rtc-pcf2127.c
> > > > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > > > @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > > > >  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> > > > >  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
> > > > >  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> > > > > +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
> > > > >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
> > > > >  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
> > > > >  
> > > > > -- 
> > > > > 2.35.1
> > > > > 
> > > > 
> > > > 
> > > > -- 
> > > > Hugo Villeneuve <hugo@hugovil.com>
> > > 
> > > -- 
> > > Alexandre Belloni, co-owner and COO, Bootlin
> > > Embedded Linux and Kernel engineering
> > > https://bootlin.com
> > > 
> > 
> > 
> > -- 
> > Hugo Villeneuve <hugo@hugovil.com>
> 
> -- 
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 


-- 
Hugo Villeneuve <hugo@hugovil.com>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
  2022-03-10 20:58     ` Alexandre Belloni
  2022-03-10 21:12       ` Hugo Villeneuve
  2022-03-17 15:28       ` Hugo Villeneuve
@ 2022-12-15 15:12       ` Hugo Villeneuve
  2 siblings, 0 replies; 40+ messages in thread
From: Hugo Villeneuve @ 2022-12-15 15:12 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On Thu, 10 Mar 2022 21:58:49 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:

> On 10/03/2022 11:09:18-0500, Hugo Villeneuve wrote:
> > On Wed,  9 Mar 2022 17:22:42 +0100
> > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > 
> > > The PCF2127 doesn't support UIE because setting an alarm to fire every
> > > second confuses the chip and the fastest we can go is an alarm every 2
> > > seconds.
> > 
> > Hi Alexandre,
> > can you describe what "confuses the chip" means?
> > 
> > In my experimental PCF2131 driver, I activated UIE and it seems to be working fine at 1s intervals, but since it is similar to PCF2127, maybe there is still a problem and I just didn't see it.
> > 
> 
> Did you remove uie_unsupported? Else, you may have been using uie
> emulation. In my tests last year, the pcf2127 was failing to reassert
> the interrupt if an alarm was set every second. The same happens on
> other NXP based RTCs (i.e. including microcrystal ones).
> 
> I'm going to test again soon (and also reply to your series).

Hi Alexandre,
after 9 months, I decided to resend my PCF2131 driver serie (V3), rebased on your latest rtc-next branch. I would appreciate if you or someone could take a look at it and comment.

Thank you,
Hugo Villeneuve


> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > ---
> > >  drivers/rtc/rtc-pcf2127.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > index f8469b134411..63b275b014bd 100644
> > > --- a/drivers/rtc/rtc-pcf2127.c
> > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > @@ -656,6 +656,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > >  	pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> > >  	pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
> > >  	pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
> > > +	set_bit(RTC_FEATURE_ALARM_RES_2S, pcf2127->rtc->features);
> > >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf2127->rtc->features);
> > >  	clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
> > >  
> > > -- 
> > > 2.35.1
> > > 
> > 
> > 
> > -- 
> > Hugo Villeneuve <hugo@hugovil.com>
> 
> -- 
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 


-- 
Hugo Villeneuve <hugo@hugovil.com>

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2022-12-15 15:14 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 16:22 [PATCH 01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 02/29] rtc: ds1685: drop no_irq Alexandre Belloni
2022-03-09 16:22 ` [PATCH 03/29] rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 04/29] rtc: mpc5121: let the core handle the alarm resolution Alexandre Belloni
2022-03-09 16:22 ` [PATCH 05/29] rtc: mpc5121: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 06/29] rtc: m41t80: " Alexandre Belloni
2022-03-09 16:22 ` [PATCH 07/29] rtc: opal: " Alexandre Belloni
2022-03-09 16:22 ` [PATCH 08/29] rtc: pcf2123: " Alexandre Belloni
2022-03-09 16:22 ` [PATCH 09/29] rtc: pcf2123: set RTC_FEATURE_ALARM_RES_MINUTE Alexandre Belloni
2022-03-09 16:22 ` [PATCH 10/29] rtc: pcf2127: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
2022-03-10 16:09   ` Hugo Villeneuve
2022-03-10 20:58     ` Alexandre Belloni
2022-03-10 21:12       ` Hugo Villeneuve
2022-03-17 15:28       ` Hugo Villeneuve
2022-03-17 17:16         ` Alexandre Belloni
2022-05-24 15:10           ` Hugo Villeneuve
2022-12-15 15:12       ` Hugo Villeneuve
2022-03-09 16:22 ` [PATCH 12/29] rtc: pcf85063: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 13/29] rtc: pcf85063: set RTC_FEATURE_ALARM_RES_2S Alexandre Belloni
2022-03-09 16:22 ` [PATCH 14/29] rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 15/29] rtc: pcf8523: let the core handle the alarm resolution Alexandre Belloni
2022-03-09 16:22 ` [PATCH 16/29] rtc: pcf8563: " Alexandre Belloni
2022-03-09 16:22 ` [PATCH 17/29] rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device Alexandre Belloni
2022-03-10  3:29   ` Viresh Kumar
2022-03-09 16:22 ` [PATCH 19/29] rtc: spear: set range Alexandre Belloni
2022-03-10  3:28   ` Viresh Kumar
2022-03-09 16:22 ` [PATCH 20/29] rtc: spear: drop uie_unsupported Alexandre Belloni
2022-03-10  3:29   ` Viresh Kumar
2022-03-09 16:22 ` [PATCH 21/29] rtc: spear: fix spear_rtc_read_time Alexandre Belloni
2022-03-10  3:28   ` Viresh Kumar
2022-03-09 16:22 ` [PATCH 22/29] rtc: add new RTC_FEATURE_ALARM_WAKEUP_ONLY feature Alexandre Belloni
2022-03-09 16:22 ` [PATCH 23/29] rtc: efi: switch to devm_rtc_allocate_device Alexandre Belloni
2022-03-09 16:22 ` [PATCH 24/29] rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 25/29] rtc: hym8563: switch to devm_rtc_allocate_device Alexandre Belloni
2022-03-09 16:22 ` [PATCH 26/29] rtc: hym8563: let the core handle the alarm resolution Alexandre Belloni
2022-03-09 16:22 ` [PATCH 27/29] rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPT Alexandre Belloni
2022-03-09 16:22 ` [PATCH 28/29] rtc: xgene: stop using uie_unsupported Alexandre Belloni
2022-03-09 16:23 ` [PATCH 29/29] rtc: remove uie_unsupported 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).