Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure
@ 2024-11-15 19:48 Frank Li
  2024-11-16 19:36 ` Alexandre Belloni
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2024-11-15 19:48 UTC (permalink / raw)
  To: Alexandre Belloni, Jacky Bai, Peng Fan,
	open list:REAL TIME CLOCK (RTC) SUBSYSTEM, open list
  Cc: imx

From: Jacky Bai <ping.bai@nxp.com>

Enable the RTC by default even when no valid time is set to ensure the
RTC's time read and alarm functions work properly. Without this, running
hwclock results in the following error:

hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument

Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
index fa3b0328c7a25..6610db2f75125 100644
--- a/drivers/rtc/rtc-nxp-bbnsm.c
+++ b/drivers/rtc/rtc-nxp-bbnsm.c
@@ -189,6 +189,9 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
 	/* clear all the pending events */
 	regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
 
+	/* Enable the Real-Time counter */
+	regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN);
+
 	device_init_wakeup(&pdev->dev, true);
 	dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
 
-- 
2.34.1


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

* Re: [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure
  2024-11-15 19:48 [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure Frank Li
@ 2024-11-16 19:36 ` Alexandre Belloni
  2024-11-17 22:08   ` Alexandre Belloni
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Belloni @ 2024-11-16 19:36 UTC (permalink / raw)
  To: Frank Li
  Cc: Jacky Bai, Peng Fan, open list:REAL TIME CLOCK (RTC) SUBSYSTEM,
	open list, imx

On 15/11/2024 14:48:58-0500, Frank Li wrote:
> From: Jacky Bai <ping.bai@nxp.com>
> 
> Enable the RTC by default even when no valid time is set to ensure the
> RTC's time read and alarm functions work properly. Without this, running
> hwclock results in the following error:
> 
> hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
> 


What is providing your hwclock and which version does it have?


> Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
> index fa3b0328c7a25..6610db2f75125 100644
> --- a/drivers/rtc/rtc-nxp-bbnsm.c
> +++ b/drivers/rtc/rtc-nxp-bbnsm.c
> @@ -189,6 +189,9 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
>  	/* clear all the pending events */
>  	regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
>  
> +	/* Enable the Real-Time counter */
> +	regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN);
> +
>  	device_init_wakeup(&pdev->dev, true);
>  	dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
>  
> -- 
> 2.34.1
> 

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

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

* Re: [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure
  2024-11-16 19:36 ` Alexandre Belloni
@ 2024-11-17 22:08   ` Alexandre Belloni
  2024-11-18 19:25     ` Frank Li
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Belloni @ 2024-11-17 22:08 UTC (permalink / raw)
  To: Frank Li
  Cc: Jacky Bai, Peng Fan, open list:REAL TIME CLOCK (RTC) SUBSYSTEM,
	open list, imx

On 16/11/2024 20:36:54+0100, Alexandre Belloni wrote:
> On 15/11/2024 14:48:58-0500, Frank Li wrote:
> > From: Jacky Bai <ping.bai@nxp.com>
> > 
> > Enable the RTC by default even when no valid time is set to ensure the
> > RTC's time read and alarm functions work properly. Without this, running
> > hwclock results in the following error:
> > 
> > hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
> > 
> 
> 
> What is providing your hwclock and which version does it have?


This is a bug in util-linux that needs to be fixed.
> 
> 
> > Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
> > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >  drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
> > index fa3b0328c7a25..6610db2f75125 100644
> > --- a/drivers/rtc/rtc-nxp-bbnsm.c
> > +++ b/drivers/rtc/rtc-nxp-bbnsm.c
> > @@ -189,6 +189,9 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
> >  	/* clear all the pending events */
> >  	regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
> >  
> > +	/* Enable the Real-Time counter */
> > +	regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN);
> > +
> >  	device_init_wakeup(&pdev->dev, true);
> >  	dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
> >  
> > -- 
> > 2.34.1
> > 
> 
> -- 
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

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

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

* Re: [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure
  2024-11-17 22:08   ` Alexandre Belloni
@ 2024-11-18 19:25     ` Frank Li
  2024-12-05 17:20       ` Frank Li
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2024-11-18 19:25 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Jacky Bai, Peng Fan, open list:REAL TIME CLOCK (RTC) SUBSYSTEM,
	open list, imx

On Sun, Nov 17, 2024 at 11:08:43PM +0100, Alexandre Belloni wrote:
> On 16/11/2024 20:36:54+0100, Alexandre Belloni wrote:
> > On 15/11/2024 14:48:58-0500, Frank Li wrote:
> > > From: Jacky Bai <ping.bai@nxp.com>
> > >
> > > Enable the RTC by default even when no valid time is set to ensure the
> > > RTC's time read and alarm functions work properly. Without this, running
> > > hwclock results in the following error:
> > >
> > > hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
> > >
> >
> >
> > What is providing your hwclock and which version does it have?
>
>
> This is a bug in util-linux that needs to be fixed.

What's suposed/expected beheavor? I think rtc should be enable by default.

Frank

> >
> >
> > > Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
> > > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > ---
> > >  drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
> > > index fa3b0328c7a25..6610db2f75125 100644
> > > --- a/drivers/rtc/rtc-nxp-bbnsm.c
> > > +++ b/drivers/rtc/rtc-nxp-bbnsm.c
> > > @@ -189,6 +189,9 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
> > >  	/* clear all the pending events */
> > >  	regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
> > >
> > > +	/* Enable the Real-Time counter */
> > > +	regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN);
> > > +
> > >  	device_init_wakeup(&pdev->dev, true);
> > >  	dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
> > >
> > > --
> > > 2.34.1
> > >
> >
> > --
> > Alexandre Belloni, co-owner and COO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

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

* Re: [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure
  2024-11-18 19:25     ` Frank Li
@ 2024-12-05 17:20       ` Frank Li
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2024-12-05 17:20 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Jacky Bai, Peng Fan, open list:REAL TIME CLOCK (RTC) SUBSYSTEM,
	open list, imx

On Mon, Nov 18, 2024 at 02:25:13PM -0500, Frank Li wrote:
> On Sun, Nov 17, 2024 at 11:08:43PM +0100, Alexandre Belloni wrote:
> > On 16/11/2024 20:36:54+0100, Alexandre Belloni wrote:
> > > On 15/11/2024 14:48:58-0500, Frank Li wrote:
> > > > From: Jacky Bai <ping.bai@nxp.com>
> > > >
> > > > Enable the RTC by default even when no valid time is set to ensure the
> > > > RTC's time read and alarm functions work properly. Without this, running
> > > > hwclock results in the following error:
> > > >
> > > > hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
> > > >
> > >
> > >
> > > What is providing your hwclock and which version does it have?
> >
> >
> > This is a bug in util-linux that needs to be fixed.

Alexandre:

	I can't understand what your means. Why it is util-linux issue?
This driver return failure at read because check hardware bit RTC_EN.

	I suppose RTC should be always enable after probe?

Frank

>
> What's suposed/expected beheavor? I think rtc should be enable by default.
>
> Frank
>
> > >
> > >
> > > > Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
> > > > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > > > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > > ---
> > > >  drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
> > > > index fa3b0328c7a25..6610db2f75125 100644
> > > > --- a/drivers/rtc/rtc-nxp-bbnsm.c
> > > > +++ b/drivers/rtc/rtc-nxp-bbnsm.c
> > > > @@ -189,6 +189,9 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
> > > >  	/* clear all the pending events */
> > > >  	regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
> > > >
> > > > +	/* Enable the Real-Time counter */
> > > > +	regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN);
> > > > +
> > > >  	device_init_wakeup(&pdev->dev, true);
> > > >  	dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
> > > >
> > > > --
> > > > 2.34.1
> > > >
> > >
> > > --
> > > Alexandre Belloni, co-owner and COO, Bootlin
> > > Embedded Linux and Kernel engineering
> > > https://bootlin.com
> >
> > --
> > Alexandre Belloni, co-owner and COO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com

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

end of thread, other threads:[~2024-12-05 17:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 19:48 [PATCH 1/1] rtc: bbnsm: Enable RTC by default to fix time read failure Frank Li
2024-11-16 19:36 ` Alexandre Belloni
2024-11-17 22:08   ` Alexandre Belloni
2024-11-18 19:25     ` Frank Li
2024-12-05 17:20       ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox