Skip to content

Commit d89f8f7

Browse files
Pull up following revision(s) (requested by hgutch in ticket #1172):
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 157544e commit d89f8f7

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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.1.2.2 2024/02/03 11:47:04 martin Exp $ */
1+
/* $NetBSD: rtcsram.c,v 1.1.2.3 2025/10/17 08:37:45 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.1.2.2 2024/02/03 11:47:04 martin Exp $");
30+
__KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.1.2.3 2025/10/17 08:37:45 martin Exp $");
3131

3232
#include <sys/param.h>
3333
#include <sys/bus.h>
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.1.2.2 2024/02/03 11:47:04 martin Exp $
4848

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

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

@@ -160,7 +158,7 @@ rtcsram_gettime(todr_chip_handle_t ch, struct timeval *tv)
160158
uint32_t val;
161159

162160
val = rtcsram_read_4(sc, RTC_BASE);
163-
tv->tv_sec = (uint64_t)val + sc->sc_sram.counter_bias;
161+
tv->tv_sec = (uint64_t)val;
164162
tv->tv_usec = 0;
165163

166164
return 0;
@@ -171,7 +169,7 @@ rtcsram_settime(todr_chip_handle_t ch, struct timeval *tv)
171169
{
172170
struct rtcsram_softc * const sc = ch->cookie;
173171

174-
rtcsram_write_4(sc, RTC_BASE, tv->tv_sec - sc->sc_sram.counter_bias);
172+
rtcsram_write_4(sc, RTC_BASE, tv->tv_sec);
175173

176174
return 0;
177175
}

0 commit comments

Comments
 (0)