From bc66683144037559685499cf0334177c2727eebd Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Mon, 17 Oct 2022 19:09:47 +0000 Subject: Convert more drivers to use todr_attach(). The quality of the RTC is set such that "discrete" RTC chips are preferred over RTCs integrated on a SoC. ok deraadt@, miod@ --- sys/dev/fdt/acrtc.c | 7 +++---- sys/dev/fdt/exrtc.c | 7 +++---- sys/dev/fdt/gfrtc.c | 7 +++---- sys/dev/fdt/imxrtc.c | 7 +++---- sys/dev/fdt/mvrtc.c | 7 +++---- sys/dev/fdt/plrtc.c | 6 ++---- sys/dev/fdt/sxirtc.c | 7 ++----- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/sys/dev/fdt/acrtc.c b/sys/dev/fdt/acrtc.c index 72cc66ab51d..c657e2ce718 100644 --- a/sys/dev/fdt/acrtc.c +++ b/sys/dev/fdt/acrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acrtc.c,v 1.5 2021/10/24 17:52:26 mpi Exp $ */ +/* $OpenBSD: acrtc.c,v 1.6 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -30,8 +30,6 @@ #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) -extern todr_chip_handle_t todr_handle; - #define CK32K_OUT_CTRL1 0xc1 #define CK32K_OUT_CTRL_PRE_DIV_MASK (0x7 << 5) #define CK32K_OUT_CTRL_PRE_DIV_32K (0x7 << 5) @@ -112,7 +110,8 @@ acrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = acrtc_gettime; sc->sc_todr.todr_settime = acrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); node = OF_getnodebyname(ra->ra_node, "rtc"); if (node == 0) diff --git a/sys/dev/fdt/exrtc.c b/sys/dev/fdt/exrtc.c index 6bdb4e54b56..8785dce5490 100644 --- a/sys/dev/fdt/exrtc.c +++ b/sys/dev/fdt/exrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exrtc.c,v 1.4 2021/10/24 17:52:26 mpi Exp $ */ +/* $OpenBSD: exrtc.c,v 1.5 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -28,8 +28,6 @@ #include -extern todr_chip_handle_t todr_handle; - #define RTCCTRL 0x40 #define RTCCTRL_RTCEN (1 << 0) @@ -91,7 +89,8 @@ exrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = exrtc_gettime; sc->sc_todr.todr_settime = exrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 0; + todr_attach(&sc->sc_todr); } int diff --git a/sys/dev/fdt/gfrtc.c b/sys/dev/fdt/gfrtc.c index b946b514bd2..2f6c945ca5e 100644 --- a/sys/dev/fdt/gfrtc.c +++ b/sys/dev/fdt/gfrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gfrtc.c,v 1.2 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: gfrtc.c,v 1.3 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2021 Jonathan Gray @@ -38,8 +38,6 @@ #define ALARM_LOW 0x0c #define CLEAR_INTERRUPT 0x10 -extern todr_chip_handle_t todr_handle; - struct gfrtc_softc { struct device sc_dev; bus_space_tag_t sc_iot; @@ -113,7 +111,8 @@ gfrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = gfrtc_gettime; sc->sc_todr.todr_settime = gfrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); printf("\n"); } diff --git a/sys/dev/fdt/imxrtc.c b/sys/dev/fdt/imxrtc.c index c68e35bb287..271e3dcbfa7 100644 --- a/sys/dev/fdt/imxrtc.c +++ b/sys/dev/fdt/imxrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxrtc.c,v 1.2 2021/10/24 17:52:26 mpi Exp $ */ +/* $OpenBSD: imxrtc.c,v 1.3 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -29,8 +29,6 @@ #include -extern todr_chip_handle_t todr_handle; - /* Registers. */ #define LPCR 0x38 #define LPCR_SRTC_ENV (1 << 0) @@ -91,7 +89,8 @@ imxrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = imxrtc_gettime; sc->sc_todr.todr_settime = imxrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 0; + todr_attach(&sc->sc_todr); } int diff --git a/sys/dev/fdt/mvrtc.c b/sys/dev/fdt/mvrtc.c index 535744c8992..d98f814bd3b 100644 --- a/sys/dev/fdt/mvrtc.c +++ b/sys/dev/fdt/mvrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mvrtc.c,v 1.2 2021/10/24 17:52:26 mpi Exp $ */ +/* $OpenBSD: mvrtc.c,v 1.3 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -28,8 +28,6 @@ #include -extern todr_chip_handle_t todr_handle; - /* Registers. */ #define RTC_STATUS 0x0000 #define RTC_TIME 0x000c @@ -123,7 +121,8 @@ mvrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = mvrtc_gettime; sc->sc_todr.todr_settime = mvrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 0; + todr_attach(&sc->sc_todr); } int diff --git a/sys/dev/fdt/plrtc.c b/sys/dev/fdt/plrtc.c index 3f3f9564ebd..f63d91fc391 100644 --- a/sys/dev/fdt/plrtc.c +++ b/sys/dev/fdt/plrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: plrtc.c,v 1.3 2022/10/12 13:39:50 kettenis Exp $ */ +/* $OpenBSD: plrtc.c,v 1.4 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2015 Jonathan Gray @@ -39,8 +39,6 @@ #define RTCCR_START (1 << 0) -extern todr_chip_handle_t todr_handle; - struct plrtc_softc { struct device sc_dev; bus_space_tag_t sc_iot; @@ -121,7 +119,7 @@ plrtc_attach(struct device *parent, struct device *self, void *aux) handle->todr_gettime = plrtc_gettime; handle->todr_settime = plrtc_settime; handle->todr_quality = 0; - todr_handle = handle; + todr_attach(handle); /* enable the rtc */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, RTCCR, RTCCR_START); diff --git a/sys/dev/fdt/sxirtc.c b/sys/dev/fdt/sxirtc.c index b1d305ece2a..06c29482762 100644 --- a/sys/dev/fdt/sxirtc.c +++ b/sys/dev/fdt/sxirtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxirtc.c,v 1.7 2022/10/12 13:39:50 kettenis Exp $ */ +/* $OpenBSD: sxirtc.c,v 1.8 2022/10/17 19:09:46 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * Copyright (c) 2013 Artturi Alm @@ -46,9 +46,6 @@ (y) % 100 != 0) || \ (y) % 400 == 0) - -extern todr_chip_handle_t todr_handle; - struct sxirtc_softc { struct device sc_dev; bus_space_tag_t sc_iot; @@ -149,7 +146,7 @@ sxirtc_attach(struct device *parent, struct device *self, void *aux) handle->bus_cookie = NULL; handle->todr_setwen = NULL; handle->todr_quality = 0; - todr_handle = handle; + todr_attach(handle); printf("\n"); } -- cgit v1.2.3