Re: Multiple RTCs
> Date: Tue, 10 Apr 2018 15:57:30 +0300 > From: Artturi Alm > > On Sat, Apr 07, 2018 at 08:39:43PM +0200, Mark Kettenis wrote: > > I have an RK3399 system that has two RTCs. One of those is the RTC > > integrated on the RK808 PMIC that is a companion chip to the RK3399. > > The second one is an ISL1208 I2C chip. Only the ISL1208 is battery > > powered, so obviously we want to use that one. But rkpmic(4) attaches > > after islrtc(4) on this board and therefore it wins. The diff below > > makes sure the RTC of the RK808 PMIC is only enabled if no other RTC > > installed itself. > > > > Off-topic, but related enough i hope. > instead of fixing up RTCVDD(lack of battery) on all my sunxi boards, > i'm going to rather add cheap&separate I2C RTCs for each. > > What do you think about kern.timecounter.{choice,hardware}-type solution? That wouldn't work. The clock is set early on, before sysctl(8) runs. If you modify the hardware like this, you should modify the device tree as well. Just disable the original RTC when you add yours. That only is a problem for multi-function devices like the RK808. But that one is covered now.
Re: Multiple RTCs
On Sat, Apr 07, 2018 at 08:39:43PM +0200, Mark Kettenis wrote: > I have an RK3399 system that has two RTCs. One of those is the RTC > integrated on the RK808 PMIC that is a companion chip to the RK3399. > The second one is an ISL1208 I2C chip. Only the ISL1208 is battery > powered, so obviously we want to use that one. But rkpmic(4) attaches > after islrtc(4) on this board and therefore it wins. The diff below > makes sure the RTC of the RK808 PMIC is only enabled if no other RTC > installed itself. > Off-topic, but related enough i hope. instead of fixing up RTCVDD(lack of battery) on all my sunxi boards, i'm going to rather add cheap&separate I2C RTCs for each. What do you think about kern.timecounter.{choice,hardware}-type solution? i'm kind of covered, either way, as maxrtc(4) does this in maxrtc_attach(): 126 /* register our time handlers */ 127 if (todr_handle != NULL) { 128 printf("%s: overwriting existing rtc handler\n", 129 sc->sc_dev.dv_xname); 130 } 131 /* XXX just overwrite existing rtc handler? */ 132 todr_handle = &sc->sc_todr; -Artturi > ok? > > > Index: dev/fdt/rkpmic.c > === > RCS file: /cvs/src/sys/dev/fdt/rkpmic.c,v > retrieving revision 1.4 > diff -u -p -r1.4 rkpmic.c > --- dev/fdt/rkpmic.c 25 Feb 2018 20:43:33 - 1.4 > +++ dev/fdt/rkpmic.c 7 Apr 2018 18:31:41 - > @@ -127,7 +127,8 @@ rkpmic_attach(struct device *parent, str > sc->sc_todr.cookie = sc; > sc->sc_todr.todr_gettime = rkpmic_gettime; > sc->sc_todr.todr_settime = rkpmic_settime; > - todr_handle = &sc->sc_todr; > + if (todr_handle == NULL) > + todr_handle = &sc->sc_todr; > > if (OF_is_compatible(node, "rockchip,rk805")) { > chip = "RK805"; >
Multiple RTCs
I have an RK3399 system that has two RTCs. One of those is the RTC integrated on the RK808 PMIC that is a companion chip to the RK3399. The second one is an ISL1208 I2C chip. Only the ISL1208 is battery powered, so obviously we want to use that one. But rkpmic(4) attaches after islrtc(4) on this board and therefore it wins. The diff below makes sure the RTC of the RK808 PMIC is only enabled if no other RTC installed itself. ok? Index: dev/fdt/rkpmic.c === RCS file: /cvs/src/sys/dev/fdt/rkpmic.c,v retrieving revision 1.4 diff -u -p -r1.4 rkpmic.c --- dev/fdt/rkpmic.c25 Feb 2018 20:43:33 - 1.4 +++ dev/fdt/rkpmic.c7 Apr 2018 18:31:41 - @@ -127,7 +127,8 @@ rkpmic_attach(struct device *parent, str sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = rkpmic_gettime; sc->sc_todr.todr_settime = rkpmic_settime; - todr_handle = &sc->sc_todr; + if (todr_handle == NULL) + todr_handle = &sc->sc_todr; if (OF_is_compatible(node, "rockchip,rk805")) { chip = "RK805";