Skip to content

Commit 38a46a6

Browse files
committed
Garbage-collect the "base_year_is_2000" property and associated
DSRTC_YEAR_START_2K config option (only used by Iyonix GENERIC). Instead, set the "start-year" property to 2000 as needed (matches the property name in the Devicetree RTC bindings used for the same purpose).
1 parent 87bc3ba commit 38a46a6

5 files changed

Lines changed: 23 additions & 44 deletions

File tree

sys/arch/evbarm/iyonix/autoconf.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: autoconf.c,v 1.3 2025/10/03 14:05:11 thorpej Exp $ */
1+
/* $NetBSD: autoconf.c,v 1.4 2025/10/13 14:49:16 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
3030
*/
3131

3232
#include <sys/cdefs.h>
33-
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2025/10/03 14:05:11 thorpej Exp $");
33+
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2025/10/13 14:49:16 thorpej Exp $");
3434

3535
#include "opt_md.h"
3636

@@ -184,8 +184,7 @@ device_register(device_t dev, void *aux)
184184
prop_dictionary_set_uint32(dict, "address", fbaddr);
185185
}
186186
if (device_is_a(dev, "dsrtc")) {
187-
/* XXX omg this property name */
188-
prop_dictionary_t dict = device_properties(dev);
189-
prop_dictionary_set_bool(dict, "base_year_is_2000", 1);
187+
/* RISC OS RTC epoch is 2000. */
188+
device_setprop_uint(dev, "start-year", 2000);
190189
}
191190
}

sys/arch/iyonix/conf/GENERIC

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: GENERIC,v 1.117 2024/01/29 18:27:13 christos Exp $
1+
# $NetBSD: GENERIC,v 1.118 2025/10/13 14:49:16 thorpej Exp $
22
#
33
# GENERIC machine description file
44
#
@@ -22,7 +22,7 @@ include "arch/iyonix/conf/std.iyonix"
2222

2323
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
2424

25-
#ident "GENERIC-$Revision: 1.117 $"
25+
#ident "GENERIC-$Revision: 1.118 $"
2626

2727
maxusers 32 # estimated number of users
2828

@@ -193,9 +193,8 @@ pci0 at iopxs? bus ? # PCI/PCI-X support
193193
# The curious can see their RAM timings.
194194
spdmem* at iic1 addr 0x56
195195

196-
# onboard RTC. RISC OS starts counting years at 2000
196+
# onboard RTC.
197197
dsrtc0 at iic0 addr 0x68
198-
options DSRTC_YEAR_START_2K
199198

200199
# PCI bridges
201200
ppb* at pci? dev ? function ? # PCI-PCI bridges

sys/arch/iyonix/iyonix/autoconf.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: autoconf.c,v 1.19 2025/10/03 14:05:12 thorpej Exp $ */
1+
/* $NetBSD: autoconf.c,v 1.20 2025/10/13 14:49:16 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
3030
*/
3131

3232
#include <sys/cdefs.h>
33-
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.19 2025/10/03 14:05:12 thorpej Exp $");
33+
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.20 2025/10/13 14:49:16 thorpej Exp $");
3434

3535
#include "opt_md.h"
3636

@@ -184,8 +184,7 @@ device_register(device_t dev, void *aux)
184184
prop_dictionary_set_uint32(dict, "address", fbaddr);
185185
}
186186
if (device_is_a(dev, "dsrtc")) {
187-
/* XXX omg this prop name */
188-
prop_dictionary_t dict = device_properties(dev);
189-
prop_dictionary_set_bool(dict, "base_year_is_2000", 1);
187+
/* RISC OS RTC epoch is 2000. */
188+
device_setprop_uint(dev, "start-year", 2000);
190189
}
191190
}

sys/dev/i2c/ds1307.c

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: ds1307.c,v 1.42 2025/09/07 21:45:15 thorpej Exp $ */
1+
/* $NetBSD: ds1307.c,v 1.43 2025/10/13 14:49:17 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
3636
*/
3737

3838
#include <sys/cdefs.h>
39-
__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.42 2025/09/07 21:45:15 thorpej Exp $");
39+
__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.43 2025/10/13 14:49:17 thorpej Exp $");
4040

4141
#include <sys/param.h>
4242
#include <sys/systm.h>
@@ -72,7 +72,6 @@ struct dsrtc_model {
7272
#define DSRTC_FLAG_BCD 0x02
7373
#define DSRTC_FLAG_TEMP 0x04
7474
#define DSRTC_FLAG_VBATEN 0x08
75-
#define DSRTC_FLAG_YEAR_START_2K 0x10
7675
#define DSRTC_FLAG_CLOCK_HOLD_REVERSED 0x20
7776
};
7877

@@ -190,6 +189,7 @@ struct dsrtc_softc {
190189
struct todr_chip_handle sc_todr;
191190
struct sysmon_envsys *sc_sme;
192191
envsys_data_t sc_sensor;
192+
unsigned int sc_base_year;
193193
};
194194

195195
static void dsrtc_attach(device_t, device_t, void *);
@@ -298,8 +298,6 @@ dsrtc_attach(device_t parent, device_t self, void *arg)
298298
struct dsrtc_softc *sc = device_private(self);
299299
struct i2c_attach_args *ia = arg;
300300
const struct dsrtc_model *dm;
301-
prop_dictionary_t dict = device_properties(self);
302-
bool base_2k = FALSE;
303301

304302
if ((dm = dsrtc_model_by_compat(ia)) == NULL)
305303
dm = dsrtc_model_by_number(device_cfdata(self)->cf_flags);
@@ -329,13 +327,8 @@ dsrtc_attach(device_t parent, device_t self, void *arg)
329327
sc->sc_todr.todr_settime = dsrtc_settime_timeval;
330328
}
331329

332-
#ifdef DSRTC_YEAR_START_2K
333-
sc->sc_model.dm_flags |= DSRTC_FLAG_YEAR_START_2K;
334-
#endif
335-
336-
prop_dictionary_get_bool(dict, "base_year_is_2000", &base_2k);
337-
if (base_2k) sc->sc_model.dm_flags |= DSRTC_FLAG_YEAR_START_2K;
338-
330+
sc->sc_base_year = device_getprop_uint_default(self, "start-year",
331+
POSIX_BASE_YEAR);
339332

340333
todr_attach(&sc->sc_todr);
341334
if ((sc->sc_model.dm_flags & DSRTC_FLAG_TEMP) != 0) {
@@ -565,13 +558,9 @@ dsrtc_clock_read_ymdhms(struct dsrtc_softc *sc, struct clock_ymdhms *dt)
565558
dt->dt_day = bcdtobin(bcd[DSXXXX_DATE] & DSXXXX_DATE_MASK);
566559
dt->dt_mon = bcdtobin(bcd[DSXXXX_MONTH] & DSXXXX_MONTH_MASK);
567560

568-
/* XXX: Should be an MD way to specify EPOCH used by BIOS/Firmware */
569-
if (sc->sc_model.dm_flags & DSRTC_FLAG_YEAR_START_2K)
570-
dt->dt_year = bcdtobin(bcd[DSXXXX_YEAR]) + 2000;
571-
else {
572-
dt->dt_year = bcdtobin(bcd[DSXXXX_YEAR]) + POSIX_BASE_YEAR;
573-
if (bcd[DSXXXX_MONTH] & DSXXXX_MONTH_CENTURY)
574-
dt->dt_year += 100;
561+
dt->dt_year = bcdtobin(bcd[DSXXXX_YEAR]) + sc->sc_base_year;
562+
if (bcd[DSXXXX_MONTH] & DSXXXX_MONTH_CENTURY) {
563+
dt->dt_year += 100;
575564
}
576565

577566
return 1;
@@ -582,7 +571,7 @@ dsrtc_clock_write_ymdhms(struct dsrtc_softc *sc, struct clock_ymdhms *dt)
582571
{
583572
struct dsrtc_model * const dm = &sc->sc_model;
584573
uint8_t bcd[DSXXXX_RTC_SIZE], cmdbuf[2];
585-
int error, offset;
574+
int error;
586575

587576
KASSERT(DSXXXX_RTC_SIZE >= dm->dm_rtc_size);
588577

@@ -597,14 +586,8 @@ dsrtc_clock_write_ymdhms(struct dsrtc_softc *sc, struct clock_ymdhms *dt)
597586
bcd[DSXXXX_DAY] = bintobcd(dt->dt_wday);
598587
bcd[DSXXXX_MONTH] = bintobcd(dt->dt_mon);
599588

600-
if (sc->sc_model.dm_flags & DSRTC_FLAG_YEAR_START_2K) {
601-
offset = 2000;
602-
} else {
603-
offset = POSIX_BASE_YEAR;
604-
}
605-
606-
bcd[DSXXXX_YEAR] = bintobcd((dt->dt_year - offset) % 100);
607-
if (dt->dt_year - offset >= 100)
589+
bcd[DSXXXX_YEAR] = bintobcd((dt->dt_year - sc->sc_base_year) % 100);
590+
if (dt->dt_year - sc->sc_base_year >= 100)
608591
bcd[DSXXXX_MONTH] |= DSXXXX_MONTH_CENTURY;
609592

610593
if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0) {

sys/dev/i2c/files.i2c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: files.i2c,v 1.135 2025/09/07 03:53:37 thorpej Exp $
1+
# $NetBSD: files.i2c,v 1.136 2025/10/13 14:49:17 thorpej Exp $
22

33
obsolete defflag opt_i2cbus.h I2C_SCAN
44
define i2cbus { }
@@ -124,7 +124,6 @@ file dev/i2c/lm87.c lmenv
124124
device dsrtc: sysmon_envsys
125125
attach dsrtc at iic
126126
file dev/i2c/ds1307.c dsrtc
127-
defflag opt_dsrtc.h DSRTC_YEAR_START_2K
128127

129128
# Xicor X1226 Real Time Clock
130129
device xrtc

0 commit comments

Comments
 (0)