devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Support RTC on BPI-R2 Pro
@ 2022-06-08 16:11 Frank Wunderlich
  2022-06-08 16:11 ` [PATCH 1/2] rtc: hym8563: try multiple times to init device Frank Wunderlich
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Frank Wunderlich @ 2022-06-08 16:11 UTC (permalink / raw)
  To: linux-rockchip
  Cc: Frank Wunderlich, Rob Herring, Krzysztof Kozlowski,
	Heiko Stuebner, Alessandro Zummo, Alexandre Belloni, devicetree,
	linux-arm-kernel, linux-kernel, linux-rtc

From: Frank Wunderlich <frank-w@public-files.de>

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] rtc: hym8563: try multiple times to init device
  2022-06-08 16:11 [PATCH 0/2] Support RTC on BPI-R2 Pro Frank Wunderlich
@ 2022-06-08 16:11 ` Frank Wunderlich
  2022-07-08 15:42   ` Aw: " Frank Wunderlich
  2022-07-08 16:17   ` Robin Murphy
  2022-06-08 16:11 ` [PATCH 2/2] arm64: dts: rockchip: add RTC to BPI-R2 Pro Frank Wunderlich
  2022-06-11 15:15 ` (subset) [PATCH 0/2] Support RTC on " Heiko Stuebner
  2 siblings, 2 replies; 7+ messages in thread
From: Frank Wunderlich @ 2022-06-08 16:11 UTC (permalink / raw)
  To: linux-rockchip
  Cc: Frank Wunderlich, Rob Herring, Krzysztof Kozlowski,
	Heiko Stuebner, Alessandro Zummo, Alexandre Belloni, devicetree,
	linux-arm-kernel, linux-kernel, linux-rtc, Peter Geis

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] arm64: dts: rockchip: add RTC to BPI-R2 Pro
  2022-06-08 16:11 [PATCH 0/2] Support RTC on BPI-R2 Pro Frank Wunderlich
  2022-06-08 16:11 ` [PATCH 1/2] rtc: hym8563: try multiple times to init device Frank Wunderlich
@ 2022-06-08 16:11 ` Frank Wunderlich
  2022-06-11 15:15 ` (subset) [PATCH 0/2] Support RTC on " Heiko Stuebner
  2 siblings, 0 replies; 7+ messages in thread
From: Frank Wunderlich @ 2022-06-08 16:11 UTC (permalink / raw)
  To: linux-rockchip
  Cc: Frank Wunderlich, Rob Herring, Krzysztof Kozlowski,
	Heiko Stuebner, Alessandro Zummo, Alexandre Belloni, devicetree,
	linux-arm-kernel, linux-kernel, linux-rtc

From: Frank Wunderlich <frank-w@public-files.de>

Add devicetree node for hym8563 rtc to Bananapi R2 Pro board.

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
 .../boot/dts/rockchip/rk3568-bpi-r2-pro.dts   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts b/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts
index 40cf2236c0b6..7e5b3947e28f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts
@@ -389,6 +389,23 @@ regulator-state-mem {
 	};
 };
 
+&i2c3 {
+	status = "okay";
+
+	hym8563: hym8563@51 {
+		compatible = "haoyu,hym8563";
+		reg = <0x51>;
+		#clock-cells = <0>;
+		clock-frequency = <32768>;
+		clock-output-names = "rtcic_32kout";
+		interrupt-parent = <&gpio0>;
+		interrupts = <RK_PD3 IRQ_TYPE_EDGE_FALLING>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&hym8563_int>;
+		wakeup-source;
+	};
+};
+
 &i2c5 {
 	/* pin 3 (SDA) + 4 (SCL) of header con2 */
 	status = "disabled";
@@ -411,6 +428,12 @@ green_led_pin: green-led-pin {
 		};
 	};
 
+	hym8563 {
+		hym8563_int: hym8563-int {
+			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+
 	pmic {
 		pmic_int: pmic_int {
 			rockchip,pins =
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: (subset) [PATCH 0/2] Support RTC on BPI-R2 Pro
  2022-06-08 16:11 [PATCH 0/2] Support RTC on BPI-R2 Pro Frank Wunderlich
  2022-06-08 16:11 ` [PATCH 1/2] rtc: hym8563: try multiple times to init device Frank Wunderlich
  2022-06-08 16:11 ` [PATCH 2/2] arm64: dts: rockchip: add RTC to BPI-R2 Pro Frank Wunderlich
@ 2022-06-11 15:15 ` Heiko Stuebner
  2 siblings, 0 replies; 7+ messages in thread
From: Heiko Stuebner @ 2022-06-11 15:15 UTC (permalink / raw)
  To: Frank Wunderlich, linux-rockchip
  Cc: Heiko Stuebner, linux-arm-kernel, Krzysztof Kozlowski,
	Rob Herring, linux-rtc, linux-kernel, Alessandro Zummo,
	devicetree, Frank Wunderlich, Alexandre Belloni

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 <heiko@sntech.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Aw: [PATCH 1/2] rtc: hym8563: try multiple times to init device
  2022-06-08 16:11 ` [PATCH 1/2] rtc: hym8563: try multiple times to init device Frank Wunderlich
@ 2022-07-08 15:42   ` Frank Wunderlich
  2022-07-08 16:17   ` Robin Murphy
  1 sibling, 0 replies; 7+ messages in thread
From: Frank Wunderlich @ 2022-07-08 15:42 UTC (permalink / raw)
  To: Frank Wunderlich
  Cc: linux-rockchip, Rob Herring, Krzysztof Kozlowski, Heiko Stuebner,
	Alessandro Zummo, Alexandre Belloni, devicetree,
	linux-arm-kernel, linux-kernel, linux-rtc, Peter Geis

Hi,

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

regards Frank

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rtc: hym8563: try multiple times to init device
  2022-06-08 16:11 ` [PATCH 1/2] rtc: hym8563: try multiple times to init device Frank Wunderlich
  2022-07-08 15:42   ` Aw: " Frank Wunderlich
@ 2022-07-08 16:17   ` Robin Murphy
  2022-07-08 18:41     ` Peter Geis
  1 sibling, 1 reply; 7+ messages in thread
From: Robin Murphy @ 2022-07-08 16:17 UTC (permalink / raw)
  To: Frank Wunderlich, linux-rockchip
  Cc: Frank Wunderlich, Rob Herring, Krzysztof Kozlowski,
	Heiko Stuebner, Alessandro Zummo, Alexandre Belloni, devicetree,
	linux-arm-kernel, linux-kernel, linux-rtc, Peter Geis

On 2022-06-08 17:11, Frank Wunderlich wrote:
> From: Peter Geis <pgwipeout@gmail.com>
> 
> 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 <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;
>   

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rtc: hym8563: try multiple times to init device
  2022-07-08 16:17   ` Robin Murphy
@ 2022-07-08 18:41     ` Peter Geis
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Geis @ 2022-07-08 18:41 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Frank Wunderlich, open list:ARM/Rockchip SoC...,
	Frank Wunderlich, Rob Herring, Krzysztof Kozlowski,
	Heiko Stuebner, Alessandro Zummo, Alexandre Belloni, devicetree,
	arm-mail-list, Linux Kernel Mailing List, linux-rtc

On Fri, Jul 8, 2022 at 12:18 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2022-06-08 17:11, Frank Wunderlich wrote:
> > From: Peter Geis <pgwipeout@gmail.com>
> >
> > 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 <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;
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-08 18:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 16:11 [PATCH 0/2] Support RTC on BPI-R2 Pro Frank Wunderlich
2022-06-08 16:11 ` [PATCH 1/2] rtc: hym8563: try multiple times to init device Frank Wunderlich
2022-07-08 15:42   ` Aw: " Frank Wunderlich
2022-07-08 16:17   ` Robin Murphy
2022-07-08 18:41     ` Peter Geis
2022-06-08 16:11 ` [PATCH 2/2] arm64: dts: rockchip: add RTC to BPI-R2 Pro Frank Wunderlich
2022-06-11 15:15 ` (subset) [PATCH 0/2] Support RTC on " Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).