summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2022-10-17 19:09:47 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2022-10-17 19:09:47 +0000
commitbc66683144037559685499cf0334177c2727eebd (patch)
treed6e03010dbe35a525f2303781f5965965d1232de
parent32e733357545e9b046d78923f2475eb4776a2fc4 (diff)
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@
-rw-r--r--sys/dev/fdt/acrtc.c7
-rw-r--r--sys/dev/fdt/exrtc.c7
-rw-r--r--sys/dev/fdt/gfrtc.c7
-rw-r--r--sys/dev/fdt/imxrtc.c7
-rw-r--r--sys/dev/fdt/mvrtc.c7
-rw-r--r--sys/dev/fdt/plrtc.c6
-rw-r--r--sys/dev/fdt/sxirtc.c7
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 <kettenis@openbsd.org>
*
@@ -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 <kettenis@openbsd.org>
*
@@ -28,8 +28,6 @@
#include <dev/clock_subr.h>
-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 <jsg@openbsd.org>
@@ -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 <kettenis@openbsd.org>
*
@@ -29,8 +29,6 @@
#include <dev/clock_subr.h>
-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 <kettenis@openbsd.org>
*
@@ -28,8 +28,6 @@
#include <dev/clock_subr.h>
-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 <jsg@openbsd.org>
@@ -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");
}