From af06e7267acc0ce33d14c1bec1405b1f7a528703 Mon Sep 17 00:00:00 2001 From: Weixin Zhou Date: Thu, 8 Aug 2024 11:41:55 +0800 Subject: [PATCH] rtc: hym8563: i2c read once at the probe/resume entry In some manufacturers, we have found that the i2c clk/data pullup power is disabled when the system is shutdown or suspended, As a result, the first i2c communication fails when probing or resuming. Therefore, it is necessary to perform i2c communication once by default when probing or resuming. Change-Id: I0819d733ff3a6f9172c1d3bf7b8e5bf72bc52730 Signed-off-by: Weixin Zhou --- drivers/rtc/rtc-hym8563.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c index b653b77df942..417c4ccc79e4 100644 --- a/drivers/rtc/rtc-hym8563.c +++ b/drivers/rtc/rtc-hym8563.c @@ -468,6 +468,11 @@ static int hym8563_init_device(struct i2c_client *client) { int ret; + ret = i2c_smbus_read_byte_data(client, HYM8563_CTL1); + if (ret < 0) + dev_err(&client->dev, "%s: error read i2c data %d\n", + __func__, ret); + /* Clear stop flag if present */ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL1, 0); if (ret < 0) @@ -517,6 +522,12 @@ static int hym8563_suspend(struct device *dev) static int hym8563_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + int ret; + + ret = i2c_smbus_read_byte_data(client, HYM8563_CTL1); + if (ret < 0) + dev_err(&client->dev, "%s: error read i2c data %d\n", + __func__, ret); if (device_may_wakeup(dev)) disable_irq_wake(client->irq);