Skip to contentSkip to conversation

rtc: bbnsm: Enable RTC by default to fix time read failure

PATCH In review Frank Li 2 participants 5 messages Nov 15, 2024 – Dec 5, 2024

Subsystems (2)
lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH 1/1 rtc: bbnsm: Enable RTC by default to fix time read failure

From: Jacky Bai <[email protected]>

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")
---
 drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-nxp-bbnsm.c +3 -0
index fa3b0328c7a25..6610db2f75125 100644
@@ -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);
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · Frank Li

From: Jacky Bai <[email protected]>

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?

Quoted 25 lines
Fixes eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
---
 drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-nxp-bbnsm.c +3 -0
index fa3b0328c7a25..6610db2f75125 100644
@@ -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);
 
Signature · 1 line
2.34.1
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw
Quoted 7 lines · Alexandre Belloni
Quoted 6 lines · Frank Li

From: Jacky Bai <[email protected]>

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:

Quoted 5 lines
Quoted 2 lines

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.

Quoted 32 lines
Quoted 27 lines
Fixes eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
---
 drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-nxp-bbnsm.c +3 -0
index fa3b0328c7a25..6610db2f75125 100644
@@ -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);
 
Signature · 1 line
2.34.1
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author maintainer
#3 lore raw
Quoted 8 lines · Alexandre Belloni
Quoted 7 lines · Alexandre Belloni
Quoted 6 lines · Frank Li

From: Jacky Bai <[email protected]>

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:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

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

Quoted 37 lines
Quoted 24 lines
Quoted 24 lines
Fixes eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
---
 drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-nxp-bbnsm.c +3 -0
index fa3b0328c7a25..6610db2f75125 100644
@@ -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);
 
Quoted 8 lines
Quoted 3 lines

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

author maintainer
#4 lore raw
Quoted 9 lines · Frank Li
Quoted 8 lines · Alexandre Belloni
Quoted 7 lines · Alexandre Belloni
Quoted 6 lines · Frank Li

From: Jacky Bai <[email protected]>

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:

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

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

Quoted 42 lines

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

Frank

Quoted 37 lines
Quoted 24 lines
Quoted 24 lines
Fixes eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
---
 drivers/rtc/rtc-nxp-bbnsm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-nxp-bbnsm.c +3 -0
index fa3b0328c7a25..6610db2f75125 100644
@@ -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);
 
Quoted 8 lines
Quoted 3 lines

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