Skip to content

Commit ed06106

Browse files
Camel Guoalexandrebelloni
authored andcommitted
rtc: rs5c372: fix incorrect oscillation value on r2221tl
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. Signed-off-by: Camel Guo <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dd93849 commit ed06106

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/rtc/rtc-rs5c372.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define RS5C372_REG_MONTH 5
2929
#define RS5C372_REG_YEAR 6
3030
#define RS5C372_REG_TRIM 7
31-
# define RS5C372_TRIM_XSL 0x80
31+
# define RS5C372_TRIM_XSL 0x80 /* only if RS5C372[a|b] */
3232
# define RS5C372_TRIM_MASK 0x7F
3333
# define R2221TL_TRIM_DEV (1 << 7) /* only if R2221TL */
3434
# define RS5C372_TRIM_DECR (1 << 6)
@@ -326,8 +326,12 @@ static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
326326
struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
327327
u8 tmp = rs5c372->regs[RS5C372_REG_TRIM];
328328

329-
if (osc)
330-
*osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
329+
if (osc) {
330+
if (rs5c372->type == rtc_rs5c372a || rs5c372->type == rtc_rs5c372b)
331+
*osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
332+
else
333+
*osc = 32768;
334+
}
331335

332336
if (trim) {
333337
dev_dbg(&client->dev, "%s: raw trim=%x\n", __func__, tmp);

0 commit comments

Comments
 (0)