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 <zwx@rock-chips.com>
This commit is contained in:
Weixin Zhou
2024-08-08 11:41:55 +08:00
committed by Tao Huang
parent 48aa220b8b
commit af06e7267a

View File

@@ -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);