public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings
@ 2026-04-01 16:52 Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 2/6] rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity Alexander Shiyan
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-01 16:52 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton, Alexander Shiyan

The OF match table contains legacy compatibles "st,rv4162" and "rv4162"
which were added 9 years ago for compatibility reasons but are not
documented in the binding.
Remove them as they are no longer needed after the device tree has
been updated to use the correct "microcrystal,rv4162".

Fixes: a897bf138c9b ("rtc: m41t80: Add proper compatible for rv4162")
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index b26afef37d9c..155eded2a921 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -131,15 +131,6 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = {
 		.compatible = "microcrystal,rv4162",
 		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT)
 	},
-	/* DT compatibility only, do not use compatibles below: */
-	{
-		.compatible = "st,rv4162",
-		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT)
-	},
-	{
-		.compatible = "rv4162",
-		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT)
-	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, m41t80_of_match);
-- 
2.52.0


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

* [PATCH 2/6] rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity
  2026-04-01 16:52 [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings Alexander Shiyan
@ 2026-04-01 16:52 ` Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution Alexander Shiyan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-01 16:52 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton, Alexander Shiyan

The FEATURE_WD flag indicates extra watchdog resolution support.
Rename it to FEATURE_WDR to better reflect its purpose
(WatchDog Resolution). No functional change.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 155eded2a921..52f398107d35 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -67,12 +67,12 @@
 #define M41T80_FEATURE_HT	BIT(0)	/* Halt feature */
 #define M41T80_FEATURE_BL	BIT(1)	/* Battery low indicator */
 #define M41T80_FEATURE_SQ	BIT(2)	/* Squarewave feature */
-#define M41T80_FEATURE_WD	BIT(3)	/* Extra watchdog resolution */
+#define M41T80_FEATURE_WDR	BIT(3)	/* Extra watchdog resolution */
 #define M41T80_FEATURE_SQ_ALT	BIT(4)	/* RSx bits are in reg 4 */
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT },
-	{ "m41t65", M41T80_FEATURE_WD },
+	{ "m41t65", M41T80_FEATURE_WDR },
 	{ "m41t80", M41T80_FEATURE_SQ },
 	{ "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
 	{ "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
@@ -81,7 +81,7 @@ static const struct i2c_device_id m41t80_id[] = {
 	{ "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
 	{ "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
 	{ "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
-	{ "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT },
+	{ "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, m41t80_id);
@@ -93,7 +93,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = {
 	},
 	{
 		.compatible = "st,m41t65",
-		.data = (void *)(M41T80_FEATURE_WD)
+		.data = (void *)(M41T80_FEATURE_WDR)
 	},
 	{
 		.compatible = "st,m41t80",
@@ -129,7 +129,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = {
 	},
 	{
 		.compatible = "microcrystal,rv4162",
-		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT)
+		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT)
 	},
 	{ }
 };
@@ -661,7 +661,7 @@ static void wdt_ping(void)
 	 * M41T65 has three bits for watchdog resolution.  Don't set bit 7, as
 	 * that would be an invalid resolution.
 	 */
-	if (clientdata->features & M41T80_FEATURE_WD)
+	if (clientdata->features & M41T80_FEATURE_WDR)
 		i2c_data[1] &= ~M41T80_WATCHDOG_RB2;
 
 	i2c_transfer(save_client->adapter, msgs1, 1);
-- 
2.52.0


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

* [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution
  2026-04-01 16:52 [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 2/6] rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity Alexander Shiyan
@ 2026-04-01 16:52 ` Alexander Shiyan
  2026-04-02 11:31   ` Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 4/6] rtc: m41t80: Add FEATURE_HT to all chips supporting extra watchdog resolution Alexander Shiyan
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-01 16:52 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton, Alexander Shiyan

For chips without the extra watchdog resolution (i.e., those with only 2
resolution bits), bit 7 (RB2) must be cleared to avoid invalid settings.
The current logic clears RB2 only when extra resolution is present.
Reverse the condition.

Fixes: d3a126fcf9df ("rtc: rtc-m41t80.c: add support for the ST M41T65 RTC")
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 52f398107d35..11ef8195e786 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -658,10 +658,10 @@ static void wdt_ping(void)
 		i2c_data[1] = wdt_margin << 2 | 0x82;
 
 	/*
-	 * M41T65 has three bits for watchdog resolution.  Don't set bit 7, as
-	 * that would be an invalid resolution.
+	 * Chips with extra watchdog resolution have three bits.
+	 * Don't set bit 7, as that would be an invalid resolution.
 	 */
-	if (clientdata->features & M41T80_FEATURE_WDR)
+	if (!(clientdata->features & M41T80_FEATURE_WDR))
 		i2c_data[1] &= ~M41T80_WATCHDOG_RB2;
 
 	i2c_transfer(save_client->adapter, msgs1, 1);
-- 
2.52.0


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

* [PATCH 4/6] rtc: m41t80: Add FEATURE_HT to all chips supporting extra watchdog resolution
  2026-04-01 16:52 [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 2/6] rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution Alexander Shiyan
@ 2026-04-01 16:52 ` Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 5/6] rtc: m41t80: Add missing FEATURE_HT and FEATURE_WDR for m41t62 Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 6/6] rtc: m41t80: Fix typo: WTD -> WDT Alexander Shiyan
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-01 16:52 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton, Alexander Shiyan

The watchdog driver is only registered if the chip has the Halt
feature (FEATURE_HT). Chips like m41t65 and rv4162 support watchdog
but lack FEATURE_HT, preventing watchdog registration.
Add FEATURE_HT to those entries so that the watchdog becomes available.

Fixes: 289642767c2e ("rtc: m41t80: remove HT feature for m41t65")
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 11ef8195e786..0ef0c1f19e15 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -72,7 +72,7 @@
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT },
-	{ "m41t65", M41T80_FEATURE_WDR },
+	{ "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WDR },
 	{ "m41t80", M41T80_FEATURE_SQ },
 	{ "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
 	{ "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
@@ -81,7 +81,7 @@ static const struct i2c_device_id m41t80_id[] = {
 	{ "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
 	{ "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
 	{ "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
-	{ "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT },
+	{ "rv4162", M41T80_FEATURE_HT | M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, m41t80_id);
@@ -93,7 +93,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = {
 	},
 	{
 		.compatible = "st,m41t65",
-		.data = (void *)(M41T80_FEATURE_WDR)
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_WDR)
 	},
 	{
 		.compatible = "st,m41t80",
@@ -129,7 +129,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = {
 	},
 	{
 		.compatible = "microcrystal,rv4162",
-		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT)
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT)
 	},
 	{ }
 };
-- 
2.52.0


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

* [PATCH 5/6] rtc: m41t80: Add missing FEATURE_HT and FEATURE_WDR for m41t62
  2026-04-01 16:52 [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings Alexander Shiyan
                   ` (2 preceding siblings ...)
  2026-04-01 16:52 ` [PATCH 4/6] rtc: m41t80: Add FEATURE_HT to all chips supporting extra watchdog resolution Alexander Shiyan
@ 2026-04-01 16:52 ` Alexander Shiyan
  2026-04-01 16:52 ` [PATCH 6/6] rtc: m41t80: Fix typo: WTD -> WDT Alexander Shiyan
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-01 16:52 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton, Alexander Shiyan

The m41t62 chip supports both Halt feature and extra watchdog resolution.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 0ef0c1f19e15..5ba714b25e4d 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -71,7 +71,7 @@
 #define M41T80_FEATURE_SQ_ALT	BIT(4)	/* RSx bits are in reg 4 */
 
 static const struct i2c_device_id m41t80_id[] = {
-	{ "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT },
+	{ "m41t62", M41T80_FEATURE_HT | M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT },
 	{ "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WDR },
 	{ "m41t80", M41T80_FEATURE_SQ },
 	{ "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
@@ -89,7 +89,7 @@ MODULE_DEVICE_TABLE(i2c, m41t80_id);
 static const __maybe_unused struct of_device_id m41t80_of_match[] = {
 	{
 		.compatible = "st,m41t62",
-		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT)
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT)
 	},
 	{
 		.compatible = "st,m41t65",
-- 
2.52.0


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

* [PATCH 6/6] rtc: m41t80: Fix typo: WTD -> WDT
  2026-04-01 16:52 [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings Alexander Shiyan
                   ` (3 preceding siblings ...)
  2026-04-01 16:52 ` [PATCH 5/6] rtc: m41t80: Add missing FEATURE_HT and FEATURE_WDR for m41t62 Alexander Shiyan
@ 2026-04-01 16:52 ` Alexander Shiyan
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-01 16:52 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton, Alexander Shiyan

Correct a typo in the watchdog identity string that contain "WTD"
instead of "WDT".

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 5ba714b25e4d..91b919c7940f 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -748,7 +748,7 @@ static int wdt_ioctl(struct file *file, unsigned int cmd,
 		.options = WDIOF_POWERUNDER | WDIOF_KEEPALIVEPING |
 			WDIOF_SETTIMEOUT,
 		.firmware_version = 1,
-		.identity = "M41T80 WTD"
+		.identity = "M41T80 WDT"
 	};
 
 	switch (cmd) {
-- 
2.52.0


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

* Re: [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution
  2026-04-01 16:52 ` [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution Alexander Shiyan
@ 2026-04-02 11:31   ` Alexander Shiyan
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Shiyan @ 2026-04-02 11:31 UTC (permalink / raw)
  To: linux-rtc
  Cc: Alexandre Belloni, Steven A . Falco, Atsushi Nemoto,
	Alessandro Zummo, Andrew Morton

Hello.

Unfortunately, I have reviewed this patch and come to the conclusion
that it is incorrect.
Please skip its review (3/6).

> For chips without the extra watchdog resolution (i.e., those with only 2
> resolution bits), bit 7 (RB2) must be cleared to avoid invalid settings.
> The current logic clears RB2 only when extra resolution is present.
> Reverse the condition.
>
> Fixes: d3a126fcf9df ("rtc: rtc-m41t80.c: add support for the ST M41T65 RTC")
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
>  drivers/rtc/rtc-m41t80.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
> index 52f398107d35..11ef8195e786 100644
> --- a/drivers/rtc/rtc-m41t80.c
> +++ b/drivers/rtc/rtc-m41t80.c
> @@ -658,10 +658,10 @@ static void wdt_ping(void)
>                 i2c_data[1] = wdt_margin << 2 | 0x82;
>
>         /*
> -        * M41T65 has three bits for watchdog resolution.  Don't set bit 7, as
> -        * that would be an invalid resolution.
> +        * Chips with extra watchdog resolution have three bits.
> +        * Don't set bit 7, as that would be an invalid resolution.
>          */
> -       if (clientdata->features & M41T80_FEATURE_WDR)
> +       if (!(clientdata->features & M41T80_FEATURE_WDR))
>                 i2c_data[1] &= ~M41T80_WATCHDOG_RB2;
>
>         i2c_transfer(save_client->adapter, msgs1, 1);
> --
> 2.52.0
>

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

end of thread, other threads:[~2026-04-02 11:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 16:52 [PATCH 1/6] rtc: m41t80: Remove deprecated and undocumented compatible strings Alexander Shiyan
2026-04-01 16:52 ` [PATCH 2/6] rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity Alexander Shiyan
2026-04-01 16:52 ` [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution Alexander Shiyan
2026-04-02 11:31   ` Alexander Shiyan
2026-04-01 16:52 ` [PATCH 4/6] rtc: m41t80: Add FEATURE_HT to all chips supporting extra watchdog resolution Alexander Shiyan
2026-04-01 16:52 ` [PATCH 5/6] rtc: m41t80: Add missing FEATURE_HT and FEATURE_WDR for m41t62 Alexander Shiyan
2026-04-01 16:52 ` [PATCH 6/6] rtc: m41t80: Fix typo: WTD -> WDT Alexander Shiyan

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