Skip to content

Commit cfc5e40

Browse files
committed
wii: rtcsram: Ignore counter bias when reading/writing RTC.
Counter bias is used by system menu as an offset from the RTC for the time displayed in the Wii's OS. Since Wii doesn't have a concept of time zones, this bias is useless to us. Due to a previous bug with parsing SRAM data, the bias read was always 0. Now that the bias is read correctly, we're reading and writing preposterous times -- remove the bias from the calculation to restore the previous setting. So with this change, the RTC is always in UTC and the Wii system menu date/time settings adjusts the bias as an offset from that.
1 parent c648d98 commit cfc5e40

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

sys/arch/evbppc/wii/dev/rtcsram.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: rtcsram.c,v 1.4 2025/10/13 23:31:22 hgutch Exp $ */
1+
/* $NetBSD: rtcsram.c,v 1.5 2025/10/15 00:01:00 jmcneill Exp $ */
22

33
/*-
44
* Copyright (c) 2024 Jared McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
2727
*/
2828

2929
#include <sys/cdefs.h>
30-
__KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.4 2025/10/13 23:31:22 hgutch Exp $");
30+
__KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.5 2025/10/15 00:01:00 jmcneill Exp $");
3131

3232
#include <sys/param.h>
3333
#include <sys/bus.h>
@@ -110,9 +110,7 @@ rtcsram_attach(device_t parent, device_t self, void *aux)
110110
sc->sc_chan = eaa->eaa_chan;
111111
sc->sc_device = eaa->eaa_device;
112112

113-
/* Read RTC counter bias from SRAM. */
114113
rtcsram_read_buf(sc, SRAM_BASE, &sc->sc_sram, sizeof(sc->sc_sram));
115-
aprint_debug_dev(self, "counter bias %d\n", sc->sc_sram.counter_bias);
116114
hexdump(aprint_debug, device_xname(self), &sc->sc_sram,
117115
sizeof(sc->sc_sram));
118116

@@ -163,7 +161,7 @@ rtcsram_gettime(todr_chip_handle_t ch, struct timeval *tv)
163161
uint32_t val;
164162

165163
val = rtcsram_read_4(sc, RTC_BASE);
166-
tv->tv_sec = (uint64_t)val + sc->sc_sram.counter_bias;
164+
tv->tv_sec = (uint64_t)val;
167165
tv->tv_usec = 0;
168166

169167
return 0;
@@ -174,7 +172,7 @@ rtcsram_settime(todr_chip_handle_t ch, struct timeval *tv)
174172
{
175173
struct rtcsram_softc * const sc = device_private(ch->todr_dev);
176174

177-
rtcsram_write_4(sc, RTC_BASE, tv->tv_sec - sc->sc_sram.counter_bias);
175+
rtcsram_write_4(sc, RTC_BASE, tv->tv_sec);
178176

179177
return 0;
180178
}

0 commit comments

Comments
 (0)