Skip to contentSkip to conversation

rtc: rs5c372: fix incorrect oscillation value on r2221tl

PATCH Applied Camel Guo 2 participants 2 messages Dec 6, 2021 – Jan 5, 2022 Real time clock (RTC)

lore
Share & tools
lore

Camel Guo

author
#0 lore raw

PATCH 1/1 rtc: rs5c372: fix incorrect oscillation value on r2221tl

From: Camel Guo <[email protected]>

The XSL bit only exists in RS5C372A/B. On other Ricoh RTC chips supported in rs5c372, this bit has different meaning. For example, on R2221x and R2223x, this bit of oscillation adjustment register determines the operation frequency of oscillation adjustment circuit and the oscillation is always 32768HZ. But rs5c372_get_trim gives 32000HZ to osc when DEV is 1.

---
 drivers/rtc/rtc-rs5c372.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-rs5c372.c +7 -3
index 80980414890c..f031f83fa1a2 100644
@@ -28,7 +28,7 @@
 #define RS5C372_REG_MONTH	5
 #define RS5C372_REG_YEAR	6
 #define RS5C372_REG_TRIM	7
-#	define RS5C372_TRIM_XSL		0x80
+#	define RS5C372_TRIM_XSL		0x80		/* only if RS5C372[a|b] */
 #	define RS5C372_TRIM_MASK	0x7F
 
 #define RS5C_REG_ALARM_A_MIN	8			/* or ALARM_W */
@@ -324,8 +324,12 @@ static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
 	struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
 	u8 tmp = rs5c372->regs[RS5C372_REG_TRIM];
 
-	if (osc)
-		*osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
+	if (osc) {
+		if (rs5c372->type == rtc_rs5c372a || rs5c372->type == rtc_rs5c372b)
+			*osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
+		else
+			*osc = 32768;
+	}
 
 	if (trim) {
 		dev_dbg(&client->dev, "%s: raw trim=%x\n", __func__, tmp);
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 10 lines · Camel Guo

From: Camel Guo <[email protected]>

The XSL bit only exists in RS5C372A/B. On other Ricoh RTC chips supported in rs5c372, this bit has different meaning. For example, on R2221x and R2223x, this bit of oscillation adjustment register determines the operation frequency of oscillation adjustment circuit and the oscillation is always 32768HZ. But rs5c372_get_trim gives 32000HZ to osc when DEV is 1.

[...]

Applied, thanks!

[1/1] rtc: rs5c372: fix incorrect oscillation value on r2221tl

      commit: ed06106614341301b3c4b84b6c0b497a72caec7d

Best regards,

Signature · 1 line
Alexandre Belloni <[email protected]>