* [PATCH resubmit] rtc: ds1307: Detect oscillator fail on mcp794xx
@ 2024-06-21 8:05 Csókás, Bence
2024-06-27 22:37 ` Alexandre Belloni
0 siblings, 1 reply; 3+ messages in thread
From: Csókás, Bence @ 2024-06-21 8:05 UTC (permalink / raw)
To: linux-rtc, linux-kernel
Cc: Csókás, Bence, Szentendrei, Tamás,
Alexandre Belloni
This patch enables the detection of the oscillator failure
on mcp794xx chips.
Co-developed-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
Signed-off-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
---
drivers/rtc/rtc-ds1307.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 506b7d1c2397..bdb7b201a160 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -65,6 +65,7 @@ enum ds_type {
# define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */
# define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */
#define DS1307_REG_WDAY 0x03 /* 01-07 */
+# define MCP794XX_BIT_OSCRUN BIT(5)
# define MCP794XX_BIT_VBATEN 0x08
#define DS1307_REG_MDAY 0x04 /* 01-31 */
#define DS1307_REG_MONTH 0x05 /* 01-12 */
@@ -242,6 +243,10 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
regs[DS1307_REG_MIN] & M41T0_BIT_OF) {
dev_warn_once(dev, "oscillator failed, set time!\n");
return -EINVAL;
+ } else if (ds1307->type == mcp794xx &&
+ !(regs[DS1307_REG_WDAY] & MCP794XX_BIT_OSCRUN)) {
+ dev_warn_once(dev, "oscillator failed, set time!\n");
+ return -EINVAL;
}
tmp = regs[DS1307_REG_SECS];
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH resubmit] rtc: ds1307: Detect oscillator fail on mcp794xx
2024-06-21 8:05 [PATCH resubmit] rtc: ds1307: Detect oscillator fail on mcp794xx Csókás, Bence
@ 2024-06-27 22:37 ` Alexandre Belloni
2024-06-28 8:58 ` Csókás Bence
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2024-06-27 22:37 UTC (permalink / raw)
To: Csókás, Bence; +Cc: linux-rtc, linux-kernel, Szentendrei, Tamás
Hello,
It is not clear to me why your resent this one but not the other one,
can you elaborate?
On 21/06/2024 10:05:13+0200, Csókás, Bence wrote:
> This patch enables the detection of the oscillator failure
> on mcp794xx chips.
>
> Co-developed-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
> Signed-off-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
> ---
> drivers/rtc/rtc-ds1307.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 506b7d1c2397..bdb7b201a160 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -65,6 +65,7 @@ enum ds_type {
> # define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */
> # define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */
> #define DS1307_REG_WDAY 0x03 /* 01-07 */
> +# define MCP794XX_BIT_OSCRUN BIT(5)
> # define MCP794XX_BIT_VBATEN 0x08
> #define DS1307_REG_MDAY 0x04 /* 01-31 */
> #define DS1307_REG_MONTH 0x05 /* 01-12 */
> @@ -242,6 +243,10 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
> regs[DS1307_REG_MIN] & M41T0_BIT_OF) {
> dev_warn_once(dev, "oscillator failed, set time!\n");
> return -EINVAL;
> + } else if (ds1307->type == mcp794xx &&
> + !(regs[DS1307_REG_WDAY] & MCP794XX_BIT_OSCRUN)) {
> + dev_warn_once(dev, "oscillator failed, set time!\n");
> + return -EINVAL;
> }
>
> tmp = regs[DS1307_REG_SECS];
> --
> 2.34.1
>
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH resubmit] rtc: ds1307: Detect oscillator fail on mcp794xx
2024-06-27 22:37 ` Alexandre Belloni
@ 2024-06-28 8:58 ` Csókás Bence
0 siblings, 0 replies; 3+ messages in thread
From: Csókás Bence @ 2024-06-28 8:58 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Szentendrei, Tamás
Hi!
On 6/28/24 00:37, Alexandre Belloni wrote:
> Hello,
>
> It is not clear to me why your resent this one but not the other one,
> can you elaborate?
It was kind of an unrelated patch, I'll send it after I get this one
merged. But so far, there hasn't been any movements on this series at all.
> On 21/06/2024 10:05:13+0200, Csókás, Bence wrote:
>> This patch enables the detection of the oscillator failure
>> on mcp794xx chips.
>>
>> Co-developed-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
>> Signed-off-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
>> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
The "other one", I assume, refers to this:
On 6/11/24 09:24, Csókás, Bence wrote:
> `tm_year` may go up to 299 if the device supports the
> century bit. Therefore, subtracting may not give us
> a valid 2-digit number, but modulo does.
>
> Co-developed-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
> Signed-off-by: Szentendrei, Tamás <szentendrei.tamas@prolan.hu>
> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
And the only thing they had in common is that they were in the same
file, which my colleague, Tamás, put into one commit in our tree, that I
split for upstreaming purposes. But really, they are not really related
or interdependent on one another.
Bence
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-28 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-21 8:05 [PATCH resubmit] rtc: ds1307: Detect oscillator fail on mcp794xx Csókás, Bence
2024-06-27 22:37 ` Alexandre Belloni
2024-06-28 8:58 ` Csókás Bence
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox