2022-06-08 16:47:17

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH 0/2] Support RTC on BPI-R2 Pro

From: Frank Wunderlich <[email protected]>

This series is updating hym8563 rtc driver and add devicetree nodes
for Bananapi R2 Pro board.

Frank Wunderlich (1):
arm64: dts: rockchip: add RTC to BPI-R2 Pro

Peter Geis (1):
rtc: hym8563: try multiple times to init device

.../boot/dts/rockchip/rk3568-bpi-r2-pro.dts | 23 +++++++++++++++++++
drivers/rtc/rtc-hym8563.c | 11 +++++++--
2 files changed, 32 insertions(+), 2 deletions(-)

--
2.34.1


2022-06-08 16:47:22

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH 1/2] rtc: hym8563: try multiple times to init device

From: Peter Geis <[email protected]>

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

Signed-off-by: Peter Geis <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
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

2022-06-11 16:06:33

by Heiko Stuebner

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/2] Support RTC on BPI-R2 Pro

On Wed, 8 Jun 2022 18:11:47 +0200, Frank Wunderlich wrote:
> This series is updating hym8563 rtc driver and add devicetree nodes
> for Bananapi R2 Pro board.
>
> Frank Wunderlich (1):
> arm64: dts: rockchip: add RTC to BPI-R2 Pro
>
> Peter Geis (1):
> rtc: hym8563: try multiple times to init device
>
> [...]

Applied, thanks!

[2/2] arm64: dts: rockchip: add RTC to BPI-R2 Pro
commit: efaa0c1378ed800abd1abe0aa51ffd30002efdb4

I've changed the node name to hym8563: rtc@...

The node name should be the class of device i.e. rtc in this case.

Best regards,
--
Heiko Stuebner <[email protected]>

2022-07-08 15:56:07

by Frank Wunderlich

[permalink] [raw]
Subject: Aw: [PATCH 1/2] rtc: hym8563: try multiple times to init device

Hi,

just a gentle ping...any comment on this?

regards Frank

2022-07-08 17:04:05

by Robin Murphy

[permalink] [raw]
Subject: Re: [PATCH 1/2] rtc: hym8563: try multiple times to init device

On 2022-06-08 17:11, Frank Wunderlich wrote:
> From: Peter Geis <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Frank Wunderlich <[email protected]>
> ---
> 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;
>

2022-07-08 18:55:12

by Peter Geis

[permalink] [raw]
Subject: Re: [PATCH 1/2] rtc: hym8563: try multiple times to init device

On Fri, Jul 8, 2022 at 12:18 PM Robin Murphy <[email protected]> wrote:
>
> On 2022-06-08 17:11, Frank Wunderlich wrote:
> > From: Peter Geis <[email protected]>
> >
> > 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?

I don't think this is an SoC issue since this is the first instance
I've encountered it. Mind you we don't have the reset lines hooked up
at all for the Rockchip i2c driver, so it's possible that's the case,
but I'd imagine it would be observed more broadly if that was the
case. I've tried pushing the timings out pretty far as well as bumping
up the drive strength to no change. It seems to occur only with the
hym rtc used on this board. I suspect it's a new variant of the hym
that has slightly different behavior.

>
> Robin.
>
> > Signed-off-by: Peter Geis <[email protected]>
> > Signed-off-by: Frank Wunderlich <[email protected]>
> > ---
> > 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;
> >