Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch HPW-50PA PERSONA seems to use a different RTC base ...
details: https://anonhg.NetBSD.org/src/rev/678b5ed46359
branches: trunk
changeset: 755093:678b5ed46359
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sat May 22 15:51:31 2010 +0000
description:
HPW-50PA PERSONA seems to use a different RTC base year value
(1996, not 1900 or 2000) so handle the quirk by device properties
and set it in MD device_register().
Also make RTC baseyear value patchable in sh3/dev/rtc.c.
No visible changes to other sh3 RTC users.
diffstat:
sys/arch/hpcsh/hpcsh/autoconf.c | 32 ++++++++++++++++++++++++++++++--
sys/arch/hpcsh/include/types.h | 4 +++-
sys/arch/sh3/dev/rtc.c | 32 +++++++++++++++++++++++++++-----
3 files changed, 60 insertions(+), 8 deletions(-)
diffs (162 lines):
diff -r 2a5fff1bd74f -r 678b5ed46359 sys/arch/hpcsh/hpcsh/autoconf.c
--- a/sys/arch/hpcsh/hpcsh/autoconf.c Sat May 22 15:37:58 2010 +0000
+++ b/sys/arch/hpcsh/hpcsh/autoconf.c Sat May 22 15:51:31 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.22 2009/03/18 10:22:30 cegger Exp $ */
+/* $NetBSD: autoconf.c,v 1.23 2010/05/22 15:51:31 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.22 2009/03/18 10:22:30 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23 2010/05/22 15:51:31 tsutsui Exp $");
#include "opt_md.h"
@@ -93,6 +93,8 @@
#include <machine/config_hook.h>
#include <machine/autoconf.h>
+#include <machine/platid.h>
+#include <machine/platid_mask.h>
#include <hpcsh/dev/hd64461/hd64461var.h>
#include <hpcsh/dev/hd64465/hd64465var.h>
@@ -148,6 +150,32 @@
strncpy(booted_device_name, cp, 16);
}
+void
+device_register(device_t dev, void *aux)
+{
+ device_t parent;
+
+ parent = device_parent(dev);
+
+ if (device_is_a(dev, "rtc") &&
+ parent != NULL && device_is_a(parent, "shb") &&
+ platid_match(&platid, &platid_mask_MACH_HITACHI_PERSONA_HPW50PAD)) {
+ prop_number_t rtc_baseyear;
+
+#define HPW50PAD_RTC_BASE 1996
+
+ rtc_baseyear = prop_number_create_integer(HPW50PAD_RTC_BASE);
+ KASSERT(rtc_baseyear != NULL);
+
+ if (prop_dictionary_set(device_properties(dev),
+ "sh3_rtc_baseyear", rtc_baseyear) == false)
+ printf("WARNING: unable to set sh3_rtc_baseyear "
+ "property for %s\n", device_xname(dev));
+ prop_object_release(rtc_baseyear);
+ return;
+ }
+}
+
#ifndef MEMORY_DISK_IS_ROOT
static void
get_device(char *name)
diff -r 2a5fff1bd74f -r 678b5ed46359 sys/arch/hpcsh/include/types.h
--- a/sys/arch/hpcsh/include/types.h Sat May 22 15:37:58 2010 +0000
+++ b/sys/arch/hpcsh/include/types.h Sat May 22 15:51:31 2010 +0000
@@ -1,7 +1,9 @@
-/* $NetBSD: types.h,v 1.3 2002/02/28 03:17:28 simonb Exp $ */
+/* $NetBSD: types.h,v 1.4 2010/05/22 15:51:32 tsutsui Exp $ */
#ifndef _HPCSH_TYPES_H_
#define _HPCSH_TYPES_H_
#include <sh3/types.h>
+#define __HAVE_DEVICE_REGISTER
+
#endif /* _HPCSH_TYPES_H_ */
diff -r 2a5fff1bd74f -r 678b5ed46359 sys/arch/sh3/dev/rtc.c
--- a/sys/arch/sh3/dev/rtc.c Sat May 22 15:37:58 2010 +0000
+++ b/sys/arch/sh3/dev/rtc.c Sat May 22 15:51:31 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtc.c,v 1.7 2009/04/05 00:17:56 uwe Exp $ */
+/* $NetBSD: rtc.c,v 1.8 2010/05/22 15:51:32 tsutsui Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.7 2009/04/05 00:17:56 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.8 2010/05/22 15:51:32 tsutsui Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -55,6 +55,7 @@
int sc_valid;
struct todr_chip_handle sc_todr;
+ u_int sc_year0;
};
static int rtc_match(device_t, cfdata_t, void *);
@@ -68,7 +69,10 @@
static int rtc_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
static int rtc_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
-
+#ifndef SH3_RTC_BASEYEAR
+#define SH3_RTC_BASEYEAR 1900
+#endif
+u_int sh3_rtc_baseyear = SH3_RTC_BASEYEAR;
static int
rtc_match(device_t parent, cfdata_t cfp, void *aux)
@@ -83,6 +87,7 @@
{
struct rtc_softc *sc;
uint8_t r;
+ prop_number_t prop_rtc_baseyear;
#ifdef RTC_DEBUG
char bits[128];
#endif
@@ -119,6 +124,19 @@
sc->sc_todr.todr_gettime_ymdhms = rtc_gettime_ymdhms;
sc->sc_todr.todr_settime_ymdhms = rtc_settime_ymdhms;
+ prop_rtc_baseyear = prop_dictionary_get(device_properties(self),
+ "sh3_rtc_baseyear");
+ if (prop_rtc_baseyear != NULL) {
+ sh3_rtc_baseyear =
+ (u_int)prop_number_integer_value(prop_rtc_baseyear);
+#ifdef RTC_DEBUG
+ aprint_debug_dev(self,
+ "using baseyear %u passed via device property\n",
+ sh3_rtc_baseyear);
+#endif
+ }
+ sc->sc_year0 = sh3_rtc_baseyear;
+
todr_attach(&sc->sc_todr);
#ifdef RTC_DEBUG
@@ -184,7 +202,7 @@
return EIO;
}
- dt->dt_year += 1900;
+ dt->dt_year += sc->sc_year0;
if (dt->dt_year < POSIX_BASE_YEAR)
dt->dt_year += 100;
@@ -209,7 +227,11 @@
unsigned int year;
uint8_t r;
- year = TOBCD(dt->dt_year % 100);
+ year = dt->dt_year - sc->sc_year0;
+ if (year > 99)
+ year -= 100;
+
+ year = TOBCD(year);
r = _reg_read_1(SH_(RCR2));
Home |
Main Index |
Thread Index |
Old Index