Skip to contentSkip to conversation

rtc: m41t80: Remove deprecated and undocumented compatible strings

PATCH In review Alexander Shiyan 1 participant 7 messages Apr 1 – Apr 2 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 rtc: m41t80: Remove deprecated and undocumented compatible strings

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")
---
 drivers/rtc/rtc-m41t80.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/rtc/rtc-m41t80.c +0 -9
index b26afef37d9c..155eded2a921 100644
@@ -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);
Signature · 1 line
2.52.0
#1 lore raw

PATCH 2/6 rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity

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

---
 drivers/rtc/rtc-m41t80.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/rtc/rtc-m41t80.c +6 -6
index 155eded2a921..52f398107d35 100644
@@ -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);
Signature · 1 line
2.52.0
#2 lore raw

PATCH 3/6 rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution

In reply to 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")
---
 drivers/rtc/rtc-m41t80.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-m41t80.c +3 -3
index 52f398107d35..11ef8195e786 100644
@@ -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);
Signature · 1 line
2.52.0
#3 lore raw

Re: [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution

Hello.

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

Quoted 32 lines

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")
---
 drivers/rtc/rtc-m41t80.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-m41t80.c +3 -4
index 52f398107d35..11ef8195e786 100644
@@ -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

#4 lore raw

PATCH 4/6 rtc: m41t80: Add FEATURE_HT to all chips supporting extra watchdog resolution

In reply to 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")
---
 drivers/rtc/rtc-m41t80.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-m41t80.c +4 -4
index 11ef8195e786..0ef0c1f19e15 100644
@@ -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)
 	},
 	{ }
 };
Signature · 1 line
2.52.0
#5 lore raw

PATCH 5/6 rtc: m41t80: Add missing FEATURE_HT and FEATURE_WDR for m41t62

In reply to Alexander Shiyan

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

---
 drivers/rtc/rtc-m41t80.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-m41t80.c +2 -2
index 0ef0c1f19e15..5ba714b25e4d 100644
@@ -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",
Signature · 1 line
2.52.0
#6 lore raw

PATCH 6/6 rtc: m41t80: Fix typo: WTD -> WDT

In reply to Alexander Shiyan

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

---
 drivers/rtc/rtc-m41t80.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-m41t80.c +1 -1
index 5ba714b25e4d..91b919c7940f 100644
@@ -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) {
Signature · 1 line
2.52.0