diff mbox series

[11/29] rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2S

Message ID 20220309162301.61679-11-alexandre.belloni@bootlin.com
State Accepted
Headers show
Series [01/29] rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPT | expand

Commit Message

Alexandre Belloni March 9, 2022, 4:22 p.m. UTC
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(+)

Comments

Hugo Villeneuve March 10, 2022, 4:09 p.m. UTC | #1
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
>
Alexandre Belloni March 10, 2022, 8:58 p.m. UTC | #2
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>
Hugo Villeneuve March 10, 2022, 9:12 p.m. UTC | #3
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 March 17, 2022, 3:28 p.m. UTC | #4
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
>
Alexandre Belloni March 17, 2022, 5:16 p.m. UTC | #5
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>
Hugo Villeneuve May 24, 2022, 3:10 p.m. UTC | #6
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 Dec. 15, 2022, 3:12 p.m. UTC | #7
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
>
diff mbox series

Patch

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);