-/* $OpenBSD: aplpmu.c,v 1.5 2022/04/06 18:59:26 naddy Exp $ */
+/* $OpenBSD: aplpmu.c,v 1.6 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = aplpmu_gettime;
sc->sc_todr.todr_settime = aplpmu_settime;
+ sc->sc_todr.todr_quality = 0;
todr_attach(&sc->sc_todr);
aplpmu_sc = sc;
-/* $OpenBSD: aplsmc.c,v 1.13 2022/08/27 16:56:25 kettenis Exp $ */
+/* $OpenBSD: aplsmc.c,v 1.14 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = aplsmc_gettime;
sc->sc_todr.todr_settime = aplsmc_settime;
+ sc->sc_todr.todr_quality = 1000;
todr_attach(&sc->sc_todr);
}
-/* $OpenBSD: efi_machdep.c,v 1.1 2022/10/03 19:32:22 kettenis Exp $ */
+/* $OpenBSD: efi_machdep.c,v 1.2 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*/
#define EFI_SPACE_BITS 48
-extern todr_chip_handle_t todr_handle;
-
extern uint32_t mmap_size;
extern uint32_t mmap_desc_size;
extern uint32_t mmap_desc_ver;
if (status != EFI_SUCCESS)
return;
+ /*
+ * EDK II implementations provide an implementation of
+ * GetTime() that returns a fixed compiled-in time on hardware
+ * without a (supported) RTC. So only use this interface as a
+ * last resort.
+ */
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = efi_gettime;
sc->sc_todr.todr_settime = efi_settime;
- todr_handle = &sc->sc_todr;
+ sc->sc_todr.todr_quality = -1000;
+ todr_attach(&sc->sc_todr);
}
void
-/* $OpenBSD: mcclock.c,v 1.4 2020/05/25 13:16:06 visa Exp $ */
+/* $OpenBSD: mcclock.c,v 1.5 2022/10/12 13:39:50 kettenis Exp $ */
/* $NetBSD: mcclock.c,v 1.4 1996/10/13 02:59:41 christos Exp $ */
/*
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = mcclock_gettime;
sc->sc_todr.todr_settime = mcclock_settime;
+ sc->sc_todr.todr_quality = 0;
todr_attach(&sc->sc_todr);
}
-/* $OpenBSD: octrtc.c,v 1.14 2022/04/06 18:59:27 naddy Exp $ */
+/* $OpenBSD: octrtc.c,v 1.15 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014 Paul Irofti.
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = octrtc_gettime;
sc->sc_todr.todr_settime = octrtc_settime;
+ sc->sc_todr.todr_quality = 0;
todr_attach(&sc->sc_todr);
printf(": DS1337\n");
-/* $OpenBSD: opal.c,v 1.13 2022/04/06 18:59:27 naddy Exp $ */
+/* $OpenBSD: opal.c,v 1.14 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
sc->sc_todr.todr_gettime = opal_gettime;
sc->sc_todr.todr_settime = opal_settime;
+ sc->sc_todr.todr_quality = 0;
todr_attach(&sc->sc_todr);
node = OF_getnodebyname(faa->fa_node, "power-mgt");
-/* $OpenBSD: prtc.c,v 1.6 2021/10/24 17:05:04 mpi Exp $ */
+/* $OpenBSD: prtc.c,v 1.7 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
handle->bus_cookie = NULL;
handle->todr_setwen = NULL;
-
+ handle->todr_quality = 0;
todr_handle = handle;
}
-/* $OpenBSD: rtc.c,v 1.12 2021/10/24 17:05:04 mpi Exp $ */
+/* $OpenBSD: rtc.c,v 1.13 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 1992, 1993
handle->cookie = sc;
handle->todr_gettime = rtc_gettime;
handle->todr_settime = rtc_settime;
-
handle->bus_cookie = NULL;
handle->todr_setwen = NULL;
+ handle->todr_quality = 0;
todr_handle = handle;
/* The bq4802 is not compatible with the mc146818. */
-/* $OpenBSD: sbbc.c,v 1.14 2021/10/24 17:05:04 mpi Exp $ */
+/* $OpenBSD: sbbc.c,v 1.15 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
*
handle->cookie = tod;
handle->todr_gettime = sbbc_tod_gettime;
handle->todr_settime = sbbc_tod_settime;
-
handle->bus_cookie = NULL;
handle->todr_setwen = NULL;
+ handle->todr_quality = 0;
todr_handle = handle;
}
-/* $OpenBSD: vrtc.c,v 1.2 2021/10/24 17:05:04 mpi Exp $ */
+/* $OpenBSD: vrtc.c,v 1.3 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
*
handle->cookie = self;
handle->todr_gettime = vrtc_gettime;
handle->todr_settime = vrtc_settime;
-
handle->bus_cookie = NULL;
handle->todr_setwen = NULL;
+ handle->todr_quality = 0;
todr_handle = handle;
}
-/* $OpenBSD: clock_subr.h,v 1.7 2021/04/24 10:15:15 mpi Exp $ */
+/* $OpenBSD: clock_subr.h,v 1.8 2022/10/12 13:39:50 kettenis Exp $ */
/* $NetBSD: clock_subr.h,v 1.2 1997/03/15 18:11:17 is Exp $ */
/*-
void *cookie; /* Device specific data */
void *bus_cookie; /* Bus specific data */
+ int todr_quality;
int (*todr_gettime)(struct todr_chip_handle *, struct timeval *);
int (*todr_settime)(struct todr_chip_handle *, struct timeval *);
int (*todr_setwen)(struct todr_chip_handle *, int);
-/* $OpenBSD: dapmic.c,v 1.3 2022/10/03 21:02:02 jca Exp $ */
+/* $OpenBSD: dapmic.c,v 1.4 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = dapmic_gettime;
sc->sc_todr.todr_settime = dapmic_settime;
+ sc->sc_todr.todr_quality = 0;
todr_attach(&sc->sc_todr);
if (cpuresetfn == NULL)
-/* $OpenBSD: plrtc.c,v 1.2 2021/10/24 17:52:26 mpi Exp $ */
+/* $OpenBSD: plrtc.c,v 1.3 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2015 Jonathan Gray <jsg@openbsd.org>
handle->cookie = sc;
handle->todr_gettime = plrtc_gettime;
handle->todr_settime = plrtc_settime;
+ handle->todr_quality = 0;
todr_handle = handle;
/* enable the rtc */
-/* $OpenBSD: rkpmic.c,v 1.11 2022/10/10 17:45:35 kettenis Exp $ */
+/* $OpenBSD: rkpmic.c,v 1.12 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
#include <dev/clock_subr.h>
-extern todr_chip_handle_t todr_handle;
-
#define RK80X_SECONDS 0x00
#define RK80X_MINUTES 0x01
#define RK80X_HOURS 0x02
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = rkpmic_gettime;
sc->sc_todr.todr_settime = rkpmic_settime;
- if (todr_handle == NULL)
- todr_handle = &sc->sc_todr;
+ sc->sc_todr.todr_quality = 0;
+ todr_attach(&sc->sc_todr);
if (OF_is_compatible(node, "rockchip,rk805")) {
chip = "RK805";
-/* $OpenBSD: sxirtc.c,v 1.6 2021/10/24 17:52:27 mpi Exp $ */
+/* $OpenBSD: sxirtc.c,v 1.7 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
* Copyright (c) 2013 Artturi Alm
handle->todr_settime = sxirtc_settime;
handle->bus_cookie = NULL;
handle->todr_setwen = NULL;
+ handle->todr_quality = 0;
todr_handle = handle;
printf("\n");
-/* $OpenBSD: m41t8x.c,v 1.2 2020/10/23 20:55:15 patrick Exp $ */
+/* $OpenBSD: m41t8x.c,v 1.3 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = m41t8xrtc_gettime;
sc->sc_todr.todr_settime = m41t8xrtc_settime;
+ sc->sc_todr.todr_quality = 1000;
todr_attach(&sc->sc_todr);
printf("\n");
-/* $OpenBSD: pcf85063.c,v 1.2 2022/04/06 18:59:28 naddy Exp $ */
+/* $OpenBSD: pcf85063.c,v 1.3 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2005 Kimihiro Nonaka
sc->sc_tag = ia->ia_tag;
sc->sc_address = ia->ia_addr;
+
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = pcyrtc_gettime;
sc->sc_todr.todr_settime = pcyrtc_settime;
+ sc->sc_todr.todr_quality = 1000;
todr_attach(&sc->sc_todr);
/*
-/* $OpenBSD: pcf8523.c,v 1.7 2022/04/06 18:59:28 naddy Exp $ */
+/* $OpenBSD: pcf8523.c,v 1.8 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2005 Kimihiro Nonaka
sc->sc_tag = ia->ia_tag;
sc->sc_address = ia->ia_addr;
+
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = pcfrtc_gettime;
sc->sc_todr.todr_settime = pcfrtc_settime;
sc->sc_todr.todr_setwen = NULL;
-
-#if 0
+ sc->sc_todr.todr_quality = 1000;
todr_attach(&sc->sc_todr);
-#else
- /* XXX */
- {
- extern todr_chip_handle_t todr_handle;
- todr_handle = &sc->sc_todr;
- }
-#endif
/*
* Enable battery switch-over and battery low detection in
-/* $OpenBSD: pcf8563.c,v 1.6 2022/04/06 18:59:28 naddy Exp $ */
+/* $OpenBSD: pcf8563.c,v 1.7 2022/10/12 13:39:50 kettenis Exp $ */
/*
* Copyright (c) 2005 Kimihiro Nonaka
sc->sc_tag = ia->ia_tag;
sc->sc_address = ia->ia_addr;
+
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = pcxrtc_gettime;
sc->sc_todr.todr_settime = pcxrtc_settime;
sc->sc_todr.todr_setwen = NULL;
-
-#if 0
+ sc->sc_todr.todr_quality = 1000;
todr_attach(&sc->sc_todr);
-#else
- /* XXX */
- {
- extern todr_chip_handle_t todr_handle;
- todr_handle = &sc->sc_todr;
- }
-#endif
/* Enable. */
reg = pcxrtc_reg_read(sc, PCF8563_CONTROL1);
-/* $OpenBSD: rs5c372.c,v 1.7 2022/04/06 18:59:28 naddy Exp $ */
+/* $OpenBSD: rs5c372.c,v 1.8 2022/10/12 13:39:50 kettenis Exp $ */
/* $NetBSD: rs5c372.c,v 1.5 2006/03/29 06:41:24 thorpej Exp $ */
/*
sc->sc_tag = ia->ia_tag;
sc->sc_address = ia->ia_addr;
+
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = ricohrtc_gettime;
sc->sc_todr.todr_settime = ricohrtc_settime;
sc->sc_todr.todr_setwen = NULL;
-
-#if 0
+ sc->sc_todr.todr_quality = 1000;
todr_attach(&sc->sc_todr);
-#else
- /* XXX */
- {
- extern todr_chip_handle_t todr_handle;
- todr_handle = &sc->sc_todr;
- }
-#endif
/* Initialize RTC */
ricohrtc_reg_write(sc, RICOHRTC_CONTROL2, RICOHRTC_CONTROL2_24HRS);
-/* $OpenBSD: mk48txx.c,v 1.8 2021/04/24 10:15:15 mpi Exp $ */
+/* $OpenBSD: mk48txx.c,v 1.9 2022/10/12 13:39:50 kettenis Exp $ */
/* $NetBSD: mk48txx.c,v 1.7 2001/04/08 17:05:10 tsutsui Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
handle->todr_gettime = mk48txx_gettime;
handle->todr_settime = mk48txx_settime;
handle->todr_setwen = NULL;
+ handle->todr_quality = 0;
mk->mk_bt = bt;
mk->mk_bh = bh;
mk->mk_nvramsz = nvramsz;
-/* $OpenBSD: kern_time.c,v 1.157 2022/08/14 01:58:27 jsg Exp $ */
+/* $OpenBSD: kern_time.c,v 1.158 2022/10/12 13:39:50 kettenis Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
void
todr_attach(struct todr_chip_handle *todr)
{
- todr_handle = todr;
+ if (todr_handle == NULL ||
+ todr->todr_quality > todr_handle->todr_quality)
+ todr_handle = todr;
}
#define RESETTODR_PERIOD 1800