lkml.org 
[lkml]   [2022]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] rtc: hym8563: try multiple times to init device
Date
From: Peter Geis <pgwipeout@gmail.com>

RTC sometimes does not respond the first time in init.
Try multiple times to get a response.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
drivers/rtc/rtc-hym8563.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 90e602e99d03..9adcedaa4613 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -13,6 +13,7 @@
#include <linux/clk-provider.h>
#include <linux/i2c.h>
#include <linux/bcd.h>
+#include <linux/delay.h>
#include <linux/rtc.h>

#define HYM8563_CTL1 0x00
@@ -438,10 +439,16 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id)

static int hym8563_init_device(struct i2c_client *client)
{
- int ret;
+ int ret, i;

/* Clear stop flag if present */
- ret = i2c_smbus_write_byte_data(client, HYM8563_CTL1, 0);
+ for (i = 0; i < 3; i++) {
+ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL1, 0);
+ if (ret == 0)
+ break;
+ msleep(20);
+ }
+
if (ret < 0)
return ret;

--
2.34.1
\
 
 \ /
  Last update: 2022-06-08 18:22    [W:0.116 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site