From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AD71C433EF for ; Fri, 8 Jul 2022 16:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238350AbiGHQSY (ORCPT ); Fri, 8 Jul 2022 12:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236500AbiGHQSY (ORCPT ); Fri, 8 Jul 2022 12:18:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22D76796BA; Fri, 8 Jul 2022 09:18:23 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FDB7106F; Fri, 8 Jul 2022 09:18:23 -0700 (PDT) Received: from [10.57.86.102] (unknown [10.57.86.102]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2FDB3F66F; Fri, 8 Jul 2022 09:18:20 -0700 (PDT) Message-ID: <5611d1c5-44db-4144-3c46-256323d39fe3@arm.com> Date: Fri, 8 Jul 2022 17:17:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 1/2] rtc: hym8563: try multiple times to init device Content-Language: en-GB To: Frank Wunderlich , linux-rockchip@lists.infradead.org Cc: Frank Wunderlich , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Alessandro Zummo , Alexandre Belloni , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Peter Geis References: <20220608161150.58919-1-linux@fw-web.de> <20220608161150.58919-2-linux@fw-web.de> From: Robin Murphy In-Reply-To: <20220608161150.58919-2-linux@fw-web.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org On 2022-06-08 17:11, Frank Wunderlich wrote: > From: Peter Geis > > RTC sometimes does not respond the first time in init. > Try multiple times to get a response. FWIW, given that HYM8563 is fairly common on RK3288 boards - I can't say I've ever noticed an issue with mine, for instance - it seems dubious that this would be a general issue of the chip itself. Are you sure it's not a SoC or board-level issue with the I2C bus being in a funny initial state, timings being marginal, or suchlike? Robin. > Signed-off-by: Peter Geis > Signed-off-by: Frank Wunderlich > --- > 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 > #include > #include > +#include > #include > > #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; >