rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT
Alexandre Belloni
maintainerPATCH 1/29 rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT
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.
--- drivers/rtc/rtc-ds1685.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1685.c +1 -1
@@ -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;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 2/29 rtc: ds1685: drop no_irq
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.
--- drivers/rtc/rtc-ds1685.c | 14 +++++--------- include/linux/rtc/ds1685.h | 1 - 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/rtc/rtc-ds1685.c +5 -9
@@ -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. */
include/linux/rtc/ds1685.h +0 -1
@@ -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 );
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 3/29 rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1307.c +1 -1
@@ -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) {
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 4/29 rtc: mpc5121: let the core handle the alarm resolution
In reply to Alexandre BelloniSet 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.
--- drivers/rtc/rtc-mpc5121.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/rtc/rtc-mpc5121.c +1 -14
@@ -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 */
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 5/29 rtc: mpc5121: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-mpc5121.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-mpc5121.c +1 -1
@@ -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 */
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 6/29 rtc: m41t80: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-m41t80.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/rtc/rtc-m41t80.c +2 -4
@@ -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 );
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 7/29 rtc: opal: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-opal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-opal.c +1 -1
@@ -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); }
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 8/29 rtc: pcf2123: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-pcf2123.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf2123.c +1 -1
@@ -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 ;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 9/29 rtc: pcf2123: set RTC_FEATURE_ALARM_RES_MINUTE
In reply to Alexandre BelloniAlarms have a resolution of a minute.
--- drivers/rtc/rtc-pcf2123.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-pcf2123.c +1 -0
@@ -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 ;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 10/29 rtc: pcf2127: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-pcf2127.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf2127.c +1 -1
@@ -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 ) {
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 11/29 rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
In reply to Alexandre BelloniThe 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.
--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-pcf2127.c +1 -0
@@ -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);
Signature · 1 line
2.35.1
Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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.
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1
Signature · 1 line
Hugo Villeneuve <[email protected]>
Alexandre Belloni
maintainerRe: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
Quoted 12 lines · Hugo Villeneuve
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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).
Quoted 27 lines
Hugo.
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1Signature · 1 line
Hugo Villeneuve <[email protected]>
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
Quoted 11 lines · On Thu, 10 Mar 2022 21:58:49 +0100 Alexandre Belloni…
Quoted 10 lines · Hugo Villeneuve
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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?
Quoted 7 lines
Quoted 2 lines
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.
Quoted 1 line
I'm going to test again soon (and also reply to your series).
Ok, great.
Quoted 33 lines
Quoted 27 lines
Hugo.
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1Signature · 1 line
Hugo Villeneuve <[email protected]>Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Signature · 1 line
Hugo Villeneuve <[email protected]>
Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
In reply to Alexandre BelloniQuoted 14 lines · On Thu, 10 Mar 2022 21:58:49 +0100 Alexandre Belloni…
Quoted 12 lines · Hugo Villeneuve
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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.
Quoted 6 lines
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.
Quoted 30 lines
Quoted 24 lines
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1Signature · 1 line
Hugo Villeneuve <[email protected]>Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Signature · 1 line
Hugo Villeneuve <[email protected]>
Alexandre Belloni
maintainerRe: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
Hi,
Quoted 22 lines · Hugo Villeneuve
Quoted 19 lines · On Thu, 10 Mar 2022 21:58:49 +0100 Alexandre Belloni…
Quoted 12 lines · Hugo Villeneuve
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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).
Quoted 5 lines
Quoted 1 line
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...
Quoted 7 lines
I have been able to test with it by sending ioctl
RTC_UIE_ONand 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.
[...]
Quoted 12 lines
I even did some tests where, in
pcf2127_rtc_set_alarm(), I disabled all the alarm registers (set to0x80), 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.
Quoted 6 lines
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.
Quoted 38 lines
Hugo.
Quoted 30 lines
Quoted 24 lines
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1Signature · 1 line
Hugo Villeneuve <[email protected]>Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.comSignature · 1 line
Hugo Villeneuve <[email protected]>
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
Quoted 59 lines · On Thu, 17 Mar 2022 18:16:17 +0100 Alexandre Belloni…
Hi,
Quoted 22 lines · Hugo Villeneuve
Quoted 19 lines · On Thu, 10 Mar 2022 21:58:49 +0100 Alexandre Belloni…
Quoted 12 lines · Hugo Villeneuve
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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).Quoted 5 lines
Quoted 1 line
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...
Quoted 7 lines
I have been able to test with it by sending ioctl
RTC_UIE_ONand 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.
[...]
Quoted 12 lines
I even did some tests where, in
pcf2127_rtc_set_alarm(), I disabled all the alarm registers (set to0x80), 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.
Quoted 8 lines
Quoted 6 lines
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.
Quoted 40 lines
Quoted 34 lines
Quoted 30 lines
Quoted 24 lines
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1Signature · 1 line
Hugo Villeneuve <[email protected]>Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.comSignature · 1 line
Hugo Villeneuve <[email protected]>Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Signature · 1 line
Hugo Villeneuve <[email protected]>
Re: [PATCH 11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S
In reply to Alexandre BelloniQuoted 14 lines · On Thu, 10 Mar 2022 21:58:49 +0100 Alexandre Belloni…
Quoted 12 lines · Hugo Villeneuve
Quoted 3 lines · On Wed, 9 Mar 2022 17:22:42 +0100 Alexandre Belloni…
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.
Quoted 6 lines
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
Quoted 30 lines
Quoted 24 lines
Quoted 20 lines
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-pcf2127.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-pcf2127.c +1
-0@@ -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);Signature · 1 line
2.35.1Signature · 1 line
Hugo Villeneuve <[email protected]>Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Signature · 1 line
Hugo Villeneuve <[email protected]>
Alexandre Belloni
maintainerPATCH 12/29 rtc: pcf85063: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-pcf85063.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf85063.c +1 -1
@@ -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 ) {
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 13/29 rtc: pcf85063: set RTC_FEATURE_ALARM_RES_2S
In reply to Alexandre BelloniThe 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.
--- drivers/rtc/rtc-pcf85063.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-pcf85063.c +1 -0
@@ -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);
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 14/29 rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-pcf8523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf8523.c +1 -1
@@ -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 );
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 15/29 rtc: pcf8523: let the core handle the alarm resolution
In reply to Alexandre BelloniSet 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.
--- drivers/rtc/rtc-pcf8523.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/rtc/rtc-pcf8523.c +1 -8
@@ -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 ) {
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 16/29 rtc: pcf8563: let the core handle the alarm resolution
In reply to Alexandre BelloniSet 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.
--- drivers/rtc/rtc-pcf8563.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/rtc/rtc-pcf8563.c +1 -13
@@ -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;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 17/29 rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-pcf8563.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf8563.c +1 -1
@@ -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;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 18/29 rtc: spear: switch to devm_rtc_allocate_device
In reply to Alexandre BelloniSwitch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver.
--- drivers/rtc/rtc-spear.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/rtc/rtc-spear.c +9 -9
@@ -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 );
Signature · 1 line
2.35.1
Re: [PATCH 18/29] rtc: spear: switch to devm_rtc_allocate_device
Quoted 8 lines · Alexandre Belloni
Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver.
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-spear.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
Alexandre Belloni
maintainerPATCH 19/29 rtc: spear: set range
In reply to Alexandre BelloniWhile 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.
--- drivers/rtc/rtc-spear.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rtc/rtc-spear.c +2 -0
@@ -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);
Signature · 1 line
2.35.1
Re: [PATCH 19/29] rtc: spear: set range
Quoted 3 lines · Alexandre Belloni
While the RTC can store dates from year 0000 to 9999, leap years where not tested fro 2100. The driver currently stores
tm_yeardirectly which will
from*
Quoted 6 lines
probably fail at that time or more probably in 2300.
Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-spear.c | 2 ++ 1 file changed, 2 insertions(+)
Alexandre Belloni
maintainerPATCH 20/29 rtc: spear: drop uie_unsupported
In reply to Alexandre BelloniSince 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.
--- drivers/rtc/rtc-spear.c | 1 - 1 file changed, 1 deletion(-)
drivers/rtc/rtc-spear.c +0 -1
@@ -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)
Signature · 1 line
2.35.1
Re: [PATCH 20/29] rtc: spear: drop uie_unsupported
Quoted 9 lines · Alexandre Belloni
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_unsupportednow to reflect that.Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-spear.c | 1 - 1 file changed, 1 deletion(-)
Alexandre Belloni
maintainerPATCH 21/29 rtc: spear: fix spear_rtc_read_time
In reply to Alexandre BelloniThe reference manual doesn't specify whether the registers are latched and they probably aren't, ensure the read time and date are consistent.
--- drivers/rtc/rtc-spear.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rtc/rtc-spear.c +4 -2
@@ -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 ;
Signature · 1 line
2.35.1
Re: [PATCH 21/29] rtc: spear: fix spear_rtc_read_time
Quoted 8 lines · Alexandre Belloni
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 <[email protected]>--- drivers/rtc/rtc-spear.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Alexandre Belloni
maintainerPATCH 22/29 rtc: add new RTC_FEATURE_ALARM_WAKEUP_ONLY feature
In reply to Alexandre BelloniSome 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.
--- include/uapi/linux/rtc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/linux/rtc.h +2 -1
@@ -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
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 23/29 rtc: efi: switch to devm_rtc_allocate_device
In reply to Alexandre BelloniSwitch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver.
--- drivers/rtc/rtc-efi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/rtc/rtc-efi.c +5 -4
@@ -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 = {
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 24/29 rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop 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,.
--- drivers/rtc/rtc-efi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-efi.c +2 -1
@@ -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); }
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 25/29 rtc: hym8563: switch to devm_rtc_allocate_device
In reply to Alexandre BelloniSwitch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver.
--- drivers/rtc/rtc-hym8563.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/rtc/rtc-hym8563.c +6 -6
@@ -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[] = {
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 26/29 rtc: hym8563: let the core handle the alarm resolution
In reply to Alexandre BelloniSet 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.
--- drivers/rtc/rtc-hym8563.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/rtc/rtc-hym8563.c +1 -18
@@ -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 ;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 27/29 rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPT
In reply to Alexandre BelloniStop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
--- drivers/rtc/rtc-hym8563.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-hym8563.c +1 -2
@@ -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);
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 28/29 rtc: xgene: stop using uie_unsupported
In reply to Alexandre BelloniRemove bogus use of uie_unsupported.
--- drivers/rtc/rtc-xgene.c | 2 -- 1 file changed, 2 deletions(-)
drivers/rtc/rtc-xgene.c +0 -2
@@ -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 ;
Signature · 1 line
2.35.1
Alexandre Belloni
maintainerPATCH 29/29 rtc: remove uie_unsupported
In reply to Alexandre Belloniuie_unsupported is not used by any drivers anymore, remove it.
--- drivers/rtc/class.c | 3 --- include/linux/rtc.h | 2 -- 2 files changed, 5 deletions(-)
drivers/rtc/class.c +0 -3
@@ -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);
include/linux/rtc.h +0 -2
@@ -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.
Signature · 1 line
2.35.1