Skip to content

Commit fd3f578

Browse files
Pull up following revision(s) (requested by hgutch in ticket #54):
sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.4 sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.5 Wii: size of ead is 4 bytes each 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 df51fc9 commit fd3f578

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: rtcsram.c,v 1.2 2024/02/10 11:00:15 jmcneill Exp $ */
1+
/* $NetBSD: rtcsram.c,v 1.2.4.1 2025/10/17 08:35:27 martin 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.2 2024/02/10 11:00:15 jmcneill Exp $");
30+
__KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.2.4.1 2025/10/17 08:35:27 martin Exp $");
3131

3232
#include <sys/param.h>
3333
#include <sys/bus.h>
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.2 2024/02/10 11:00:15 jmcneill Exp $")
4949

5050
struct rtcsram_sram {
5151
uint16_t checksum[2];
52-
uint16_t ead[2];
52+
uint32_t ead[2];
5353
int32_t counter_bias;
5454
int8_t display_offset_h;
5555
uint8_t ntd;
@@ -108,9 +108,7 @@ rtcsram_attach(device_t parent, device_t self, void *aux)
108108
sc->sc_chan = eaa->eaa_chan;
109109
sc->sc_device = eaa->eaa_device;
110110

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

@@ -161,7 +159,7 @@ rtcsram_gettime(todr_chip_handle_t ch, struct timeval *tv)
161159
uint32_t val;
162160

163161
val = rtcsram_read_4(sc, RTC_BASE);
164-
tv->tv_sec = (uint64_t)val + sc->sc_sram.counter_bias;
162+
tv->tv_sec = (uint64_t)val;
165163
tv->tv_usec = 0;
166164

167165
return 0;
@@ -172,7 +170,7 @@ rtcsram_settime(todr_chip_handle_t ch, struct timeval *tv)
172170
{
173171
struct rtcsram_softc * const sc = ch->cookie;
174172

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

177175
return 0;
178176
}

0 commit comments

Comments
 (0)