use the inline bcdtobin and bintobcd directly instead through a macro.
This commit is contained in:
parent
0600c9daff
commit
b59f66e17c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mvsocrtc.c,v 1.2 2011/07/01 20:30:21 dyoung Exp $ */
|
||||
/* $NetBSD: mvsocrtc.c,v 1.3 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mvsocrtc.c,v 1.2 2011/07/01 20:30:21 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mvsocrtc.c,v 1.3 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -142,12 +142,12 @@ again:
|
||||
* XXXX this assumption will fail in 2100, but somehow I don't think
|
||||
* I or the hardware will be functioning to see it.
|
||||
*/
|
||||
dt->dt_year = FROMBCD(rtcyear) + 2000;
|
||||
dt->dt_mon = FROMBCD(rtcmonth);
|
||||
dt->dt_day = FROMBCD(rtcday);
|
||||
dt->dt_hour = FROMBCD(rtchour);
|
||||
dt->dt_min = FROMBCD(rtcmin);
|
||||
dt->dt_sec = FROMBCD(rtcsec);
|
||||
dt->dt_year = bcdtobin(rtcyear) + 2000;
|
||||
dt->dt_mon = bcdtobin(rtcmonth);
|
||||
dt->dt_day = bcdtobin(rtcday);
|
||||
dt->dt_hour = bcdtobin(rtchour);
|
||||
dt->dt_min = bcdtobin(rtcmin);
|
||||
dt->dt_sec = bcdtobin(rtcsec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -159,17 +159,17 @@ mvsocrtc_todr_settime(todr_chip_handle_t ch, struct clock_ymdhms *dt)
|
||||
uint32_t reg;
|
||||
|
||||
/* compose & write time register contents */
|
||||
reg = (TOBCD(dt->dt_sec) << MVSOCRTC_SECOND_OFFSET) |
|
||||
(TOBCD(dt->dt_min) << MVSOCRTC_MINUTE_OFFSET) |
|
||||
(TOBCD(dt->dt_hour) << MVSOCRTC_HOUR_OFFSET) |
|
||||
(TOBCD(dt->dt_wday) << MVSOCRTC_WDAY_OFFSET);
|
||||
reg = (bintobcd(dt->dt_sec) << MVSOCRTC_SECOND_OFFSET) |
|
||||
(bintobcd(dt->dt_min) << MVSOCRTC_MINUTE_OFFSET) |
|
||||
(bintobcd(dt->dt_hour) << MVSOCRTC_HOUR_OFFSET) |
|
||||
(bintobcd(dt->dt_wday) << MVSOCRTC_WDAY_OFFSET);
|
||||
|
||||
bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVSOCRTC_TIME, reg);
|
||||
|
||||
/* compose & write date register contents */
|
||||
reg = (TOBCD(dt->dt_day) << MVSOCRTC_DAY_OFFSET) |
|
||||
(TOBCD(dt->dt_mon) << MVSOCRTC_MONTH_OFFSET) |
|
||||
(TOBCD(dt->dt_year % 100) << MVSOCRTC_YEAR_OFFSET);
|
||||
reg = (bintobcd(dt->dt_day) << MVSOCRTC_DAY_OFFSET) |
|
||||
(bintobcd(dt->dt_mon) << MVSOCRTC_MONTH_OFFSET) |
|
||||
(bintobcd(dt->dt_year % 100) << MVSOCRTC_YEAR_OFFSET);
|
||||
|
||||
bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVSOCRTC_DATE, reg);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: omap_rtc.c,v 1.5 2011/07/01 20:30:21 dyoung Exp $ */
|
||||
/* $NetBSD: omap_rtc.c,v 1.6 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* OMAP RTC driver, based on i80321_timer.c.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: omap_rtc.c,v 1.5 2011/07/01 20:30:21 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: omap_rtc.c,v 1.6 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -127,31 +127,31 @@ omaprtc_gettime(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
}
|
||||
|
||||
dt->dt_year =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
YEARS_REG)) + BASEYEAR;
|
||||
dt->dt_mon =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
MONTHS_REG));
|
||||
dt->dt_wday =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
WEEKS_REG) & 0x0f);
|
||||
dt->dt_day =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
DAYS_REG));
|
||||
dt->dt_sec =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
SECONDS_REG));
|
||||
dt->dt_hour =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
HOURS_REG));
|
||||
dt->dt_min =
|
||||
FROMBCD(bus_space_read_1(sc->sc_iot,
|
||||
bcdtobin(bus_space_read_1(sc->sc_iot,
|
||||
sc->sc_ioh,
|
||||
MINUTES_REG));
|
||||
restore_interrupts(s);
|
||||
@ -177,19 +177,19 @@ omaprtc_settime(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
*/
|
||||
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
YEARS_REG, TOBCD(dt->dt_year - BASEYEAR));
|
||||
YEARS_REG, bintobcd(dt->dt_year - BASEYEAR));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
MONTHS_REG, TOBCD(dt->dt_mon));
|
||||
MONTHS_REG, bintobcd(dt->dt_mon));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
WEEKS_REG, TOBCD(dt->dt_wday & 0x0f));
|
||||
WEEKS_REG, bintobcd(dt->dt_wday & 0x0f));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
DAYS_REG, TOBCD(dt->dt_day));
|
||||
DAYS_REG, bintobcd(dt->dt_day));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
SECONDS_REG, TOBCD(dt->dt_sec));
|
||||
SECONDS_REG, bintobcd(dt->dt_sec));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
HOURS_REG, TOBCD(dt->dt_hour));
|
||||
HOURS_REG, bintobcd(dt->dt_hour));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh,
|
||||
MINUTES_REG, TOBCD(dt->dt_min));
|
||||
MINUTES_REG, bintobcd(dt->dt_min));
|
||||
restore_interrupts(s);
|
||||
return 0;
|
||||
}
|
||||
|
@ -103,31 +103,31 @@ ssrtc_todr_gettime(struct todr_chip_handle *h, struct timeval *tv)
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC);
|
||||
DPRINTF(("BCDSEC: %02X\n", reg));
|
||||
dt.dt_sec = FROMBCD(reg);
|
||||
dt.dt_sec = bcdtobin(reg);
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN);
|
||||
DPRINTF(("BCDMIN: %02X\n", reg));
|
||||
dt.dt_min = FROMBCD(reg);
|
||||
dt.dt_min = bcdtobin(reg);
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR);
|
||||
DPRINTF(("BCDHOUR: %02X\n", reg));
|
||||
dt.dt_hour = FROMBCD(reg);
|
||||
dt.dt_hour = bcdtobin(reg);
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE);
|
||||
DPRINTF(("BCDDATE: %02X\n", reg));
|
||||
dt.dt_day = FROMBCD(reg);
|
||||
dt.dt_day = bcdtobin(reg);
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY);
|
||||
DPRINTF(("BCDDAY: %02X\n", reg));
|
||||
dt.dt_wday = FROMBCD(reg);
|
||||
dt.dt_wday = bcdtobin(reg);
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON);
|
||||
DPRINTF(("BCDMON: %02X\n", reg));
|
||||
dt.dt_mon = FROMBCD(reg);
|
||||
dt.dt_mon = bcdtobin(reg);
|
||||
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR);
|
||||
DPRINTF(("BCDYEAR: %02X\n", reg));
|
||||
dt.dt_year = SSRTC_YEAR_ZERO + FROMBCD(reg);
|
||||
dt.dt_year = SSRTC_YEAR_ZERO + bcdtobin(reg);
|
||||
|
||||
DPRINTF(("Seconds: %d\n", dt.dt_sec));
|
||||
DPRINTF(("Minutes: %d\n", dt.dt_min));
|
||||
@ -158,13 +158,13 @@ ssrtc_todr_settime(struct todr_chip_handle *h, struct timeval *tv)
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON);
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON, reg | RTCCON_RTCEN);
|
||||
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC, TOBCD(dt.dt_sec));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN, TOBCD(dt.dt_min));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR, TOBCD(dt.dt_hour));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE, TOBCD(dt.dt_day));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY, TOBCD(dt.dt_wday));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON, TOBCD(dt.dt_mon));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR, TOBCD(dt.dt_year-SSRTC_YEAR_ZERO));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC, bintobcd(dt.dt_sec));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN, bintobcd(dt.dt_min));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR, bintobcd(dt.dt_hour));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE, bintobcd(dt.dt_day));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY, bintobcd(dt.dt_wday));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON, bintobcd(dt.dt_mon));
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR, bintobcd(dt.dt_year-SSRTC_YEAR_ZERO));
|
||||
|
||||
/* Clear RTCEN */
|
||||
reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tsrtc.c,v 1.7 2011/07/01 19:11:34 dyoung Exp $ */
|
||||
/* $NetBSD: tsrtc.c,v 1.8 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tsrtc.c,v 1.7 2011/07/01 19:11:34 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tsrtc.c,v 1.8 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
@ -86,13 +86,13 @@ tsrtc_match(device_t parent, cfdata_t cf, void *aux)
|
||||
return (0);
|
||||
|
||||
/* Read from the seconds counter. */
|
||||
t1 = FROMBCD(tsrtc_read(sc, MC_SEC));
|
||||
t1 = bcdtobin(tsrtc_read(sc, MC_SEC));
|
||||
if (t1 > 59)
|
||||
goto unmap;
|
||||
|
||||
/* Wait, then look again. */
|
||||
DELAY(1100000);
|
||||
t2 = FROMBCD(tsrtc_read(sc, MC_SEC));
|
||||
t2 = bcdtobin(tsrtc_read(sc, MC_SEC));
|
||||
if (t2 > 59)
|
||||
goto unmap;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ds1743.c,v 1.9 2011/07/01 19:03:50 dyoung Exp $ */
|
||||
/* $NetBSD: ds1743.c,v 1.10 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2002 Wasabi Sysetms, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.9 2011/07/01 19:03:50 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.10 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -234,14 +234,14 @@ dsrtc_write(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
|
||||
key = ds1743_lock(sc, DS_CTL_W);
|
||||
|
||||
ds1743_write(sc, DS_SECONDS, TOBCD(dt->dt_sec) & 0x7f);
|
||||
ds1743_write(sc, DS_MINUTES, TOBCD(dt->dt_min) & 0x7f);
|
||||
ds1743_write(sc, DS_HOURS, TOBCD(dt->dt_hour) & 0x3f);
|
||||
ds1743_write(sc, DS_DATE, TOBCD(dt->dt_day) & 0x3f);
|
||||
ds1743_write(sc, DS_MONTH, TOBCD(dt->dt_mon) & 0x1f);
|
||||
ds1743_write(sc, DS_YEAR, TOBCD(dt->dt_year % 100));
|
||||
ds1743_write(sc, DS_SECONDS, bintobcd(dt->dt_sec) & 0x7f);
|
||||
ds1743_write(sc, DS_MINUTES, bintobcd(dt->dt_min) & 0x7f);
|
||||
ds1743_write(sc, DS_HOURS, bintobcd(dt->dt_hour) & 0x3f);
|
||||
ds1743_write(sc, DS_DATE, bintobcd(dt->dt_day) & 0x3f);
|
||||
ds1743_write(sc, DS_MONTH, bintobcd(dt->dt_mon) & 0x1f);
|
||||
ds1743_write(sc, DS_YEAR, bintobcd(dt->dt_year % 100));
|
||||
ds1743_write(sc, DS_CENTURY, ((ds1743_read(sc, DS_CENTURY) & DS_CTL_RW)
|
||||
| TOBCD(dt->dt_year / 100)));
|
||||
| bintobcd(dt->dt_year / 100)));
|
||||
|
||||
ds1743_unlock(sc, key);
|
||||
return(0);
|
||||
@ -254,14 +254,14 @@ dsrtc_read(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
u_char key;
|
||||
|
||||
key = ds1743_lock(sc, DS_CTL_R);
|
||||
dt->dt_sec = FROMBCD(ds1743_read(sc, DS_SECONDS) & 0x7f);
|
||||
dt->dt_min = FROMBCD(ds1743_read(sc, DS_MINUTES) & 0x7f);
|
||||
dt->dt_hour = FROMBCD(ds1743_read(sc, DS_HOURS) & 0x3f);
|
||||
dt->dt_day = FROMBCD(ds1743_read(sc, DS_DATE) & 0x3f);
|
||||
dt->dt_mon = FROMBCD(ds1743_read(sc, DS_MONTH) & 0x1f);
|
||||
dt->dt_sec = bcdtobin(ds1743_read(sc, DS_SECONDS) & 0x7f);
|
||||
dt->dt_min = bcdtobin(ds1743_read(sc, DS_MINUTES) & 0x7f);
|
||||
dt->dt_hour = bcdtobin(ds1743_read(sc, DS_HOURS) & 0x3f);
|
||||
dt->dt_day = bcdtobin(ds1743_read(sc, DS_DATE) & 0x3f);
|
||||
dt->dt_mon = bcdtobin(ds1743_read(sc, DS_MONTH) & 0x1f);
|
||||
dt->dt_year =
|
||||
FROMBCD(ds1743_read(sc, DS_YEAR)) +
|
||||
FROMBCD(ds1743_read(sc, DS_CENTURY) & ~DS_CTL_RW) * 100;
|
||||
bcdtobin(ds1743_read(sc, DS_YEAR)) +
|
||||
bcdtobin(ds1743_read(sc, DS_CENTURY) & ~DS_CTL_RW) * 100;
|
||||
|
||||
ds1743_unlock(sc, key);
|
||||
return(0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: timekeeper.c,v 1.14 2014/03/18 18:20:41 riastradh Exp $ */
|
||||
/* $NetBSD: timekeeper.c,v 1.15 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: timekeeper.c,v 1.14 2014/03/18 18:20:41 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: timekeeper.c,v 1.15 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -124,13 +124,13 @@ mkclock_get(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
|
||||
s = splclock();
|
||||
chiptime[MK_CSR] |= MK_CSR_READ; /* enable read (stop time) */
|
||||
dt->dt_sec = FROMBCD(chiptime[MK_SEC]);
|
||||
dt->dt_min = FROMBCD(chiptime[MK_MIN]);
|
||||
dt->dt_hour = FROMBCD(chiptime[MK_HOUR]);
|
||||
dt->dt_wday = FROMBCD(chiptime[MK_DOW]);
|
||||
dt->dt_day = FROMBCD(chiptime[MK_DOM]);
|
||||
dt->dt_mon = FROMBCD(chiptime[MK_MONTH]);
|
||||
dt->dt_year = FROMBCD(chiptime[MK_YEAR]) + YEAR0;
|
||||
dt->dt_sec = bcdtobin(chiptime[MK_SEC]);
|
||||
dt->dt_min = bcdtobin(chiptime[MK_MIN]);
|
||||
dt->dt_hour = bcdtobin(chiptime[MK_HOUR]);
|
||||
dt->dt_wday = bcdtobin(chiptime[MK_DOW]);
|
||||
dt->dt_day = bcdtobin(chiptime[MK_DOM]);
|
||||
dt->dt_mon = bcdtobin(chiptime[MK_MONTH]);
|
||||
dt->dt_year = bcdtobin(chiptime[MK_YEAR]) + YEAR0;
|
||||
chiptime[MK_CSR] &= ~MK_CSR_READ; /* time wears on */
|
||||
splx(s);
|
||||
return 0;
|
||||
@ -149,13 +149,13 @@ mkclock_set(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
|
||||
s = splclock();
|
||||
chiptime[MK_CSR] |= MK_CSR_WRITE; /* enable write */
|
||||
chiptime[MK_SEC] = TOBCD(dt->dt_sec);
|
||||
chiptime[MK_MIN] = TOBCD(dt->dt_min);
|
||||
chiptime[MK_HOUR] = TOBCD(dt->dt_hour);
|
||||
chiptime[MK_DOW] = TOBCD(dt->dt_wday);
|
||||
chiptime[MK_DOM] = TOBCD(dt->dt_day);
|
||||
chiptime[MK_MONTH] = TOBCD(dt->dt_mon);
|
||||
chiptime[MK_YEAR] = TOBCD(dt->dt_year - YEAR0);
|
||||
chiptime[MK_SEC] = bintobcd(dt->dt_sec);
|
||||
chiptime[MK_MIN] = bintobcd(dt->dt_min);
|
||||
chiptime[MK_HOUR] = bintobcd(dt->dt_hour);
|
||||
chiptime[MK_DOW] = bintobcd(dt->dt_wday);
|
||||
chiptime[MK_DOM] = bintobcd(dt->dt_day);
|
||||
chiptime[MK_MONTH] = bintobcd(dt->dt_mon);
|
||||
chiptime[MK_YEAR] = bintobcd(dt->dt_year - YEAR0);
|
||||
chiptime[MK_CSR] &= ~MK_CSR_WRITE; /* load them up */
|
||||
splx(s);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mkclock.c,v 1.11 2012/10/27 17:18:03 chs Exp $ */
|
||||
/* $NetBSD: mkclock.c,v 1.12 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.11 2012/10/27 17:18:03 chs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.12 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -100,14 +100,14 @@ mk_read(struct mkclock_softc *sc, int reg)
|
||||
u_int8_t val;
|
||||
|
||||
val = bus_space_read_1(sc->sc_bst, sc->sc_bsh, DATA_PORT + reg*4);
|
||||
return FROMBCD(val);
|
||||
return bcdtobin(val);
|
||||
}
|
||||
|
||||
static void
|
||||
mk_write(struct mkclock_softc *sc, int reg, int val)
|
||||
{
|
||||
bus_space_write_1(sc->sc_bst, sc->sc_bsh,
|
||||
DATA_PORT + reg*4, TOBCD(val));
|
||||
DATA_PORT + reg*4, bintobcd(val));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1,21 +1,13 @@
|
||||
/* $NetBSD: chiptotime.c,v 1.6 2014/11/20 15:50:25 christos Exp $ */
|
||||
/* $NetBSD: chiptotime.c,v 1.7 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/clock.h>
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <machine/prom.h>
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
#include "libsa.h"
|
||||
|
||||
/*
|
||||
* BCD to decimal and decimal to BCD.
|
||||
*/
|
||||
#define FROMBCD(x) (int)((((unsigned int)(x)) >> 4) * 10 +\
|
||||
(((unsigned int)(x)) & 0xf))
|
||||
#define TOBCD(x) (int)((((unsigned int)(x)) / 10 * 16) +\
|
||||
(((unsigned int)(x)) % 10))
|
||||
|
||||
#define YEAR0 68
|
||||
|
||||
/*
|
||||
@ -30,12 +22,12 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year)
|
||||
{
|
||||
int days, yr;
|
||||
|
||||
sec = FROMBCD(sec);
|
||||
min = FROMBCD(min);
|
||||
hour = FROMBCD(hour);
|
||||
day = FROMBCD(day);
|
||||
mon = FROMBCD(mon);
|
||||
year = FROMBCD(year) + YEAR0;
|
||||
sec = bcdtobin(sec);
|
||||
min = bcdtobin(min);
|
||||
hour = bcdtobin(hour);
|
||||
day = bcdtobin(day);
|
||||
mon = bcdtobin(mon);
|
||||
year = bcdtobin(year) + YEAR0;
|
||||
if (year < 70)
|
||||
year = 70;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* $NetBSD: clock.c,v 1.10 2014/11/17 02:15:48 christos Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.11 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dev/clock_subr.h>
|
||||
#include <machine/prom.h>
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
@ -10,11 +11,6 @@
|
||||
/*
|
||||
* BCD to decimal and decimal to BCD.
|
||||
*/
|
||||
#define FROMBCD(x) (int)((((unsigned int)(x)) >> 4) * 10 +\
|
||||
(((unsigned int)(x)) & 0xf))
|
||||
#define TOBCD(x) (int)((((unsigned int)(x)) / 10 * 16) +\
|
||||
(((unsigned int)(x)) % 10))
|
||||
|
||||
#define YEAR0 68
|
||||
|
||||
/*
|
||||
@ -29,12 +25,12 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year)
|
||||
{
|
||||
int days, yr;
|
||||
|
||||
sec = FROMBCD(sec);
|
||||
min = FROMBCD(min);
|
||||
hour = FROMBCD(hour);
|
||||
day = FROMBCD(day);
|
||||
mon = FROMBCD(mon);
|
||||
year = FROMBCD(year) + YEAR0;
|
||||
sec = bcdtobin(sec);
|
||||
min = bcdtobin(min);
|
||||
hour = bcdtobin(hour);
|
||||
day = bcdtobin(day);
|
||||
mon = bcdtobin(mon);
|
||||
year = bcdtobin(year) + YEAR0;
|
||||
if (year < 70)
|
||||
year = 70;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mkclock_isa.c,v 1.14 2011/07/01 20:50:00 dyoung Exp $ */
|
||||
/* $NetBSD: mkclock_isa.c,v 1.15 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
__KERNEL_RCSID(0, "$NetBSD: mkclock_isa.c,v 1.14 2011/07/01 20:50:00 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mkclock_isa.c,v 1.15 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -121,7 +121,7 @@ mkclock_isa_match(device_t parent, cfdata_t cf, void *aux)
|
||||
goto restore;
|
||||
|
||||
/* Read from the seconds counter. */
|
||||
t1 = FROMBCD(mkclock_isa_nvrd(sc, MK48T18_CLKOFF + MK48TXX_ISEC));
|
||||
t1 = bcdtobin(mkclock_isa_nvrd(sc, MK48T18_CLKOFF + MK48TXX_ISEC));
|
||||
if (t1 > 59)
|
||||
goto restore;
|
||||
|
||||
@ -129,7 +129,7 @@ mkclock_isa_match(device_t parent, cfdata_t cf, void *aux)
|
||||
mkclock_isa_nvwr(sc, MK48T18_CLKOFF + MK48TXX_ICSR, ocsr);
|
||||
DELAY(1100000);
|
||||
mkclock_isa_nvwr(sc, MK48T18_CLKOFF + MK48TXX_ICSR, csr);
|
||||
t2 = FROMBCD(mkclock_isa_nvrd(sc, MK48T18_CLKOFF + MK48TXX_ISEC));
|
||||
t2 = bcdtobin(mkclock_isa_nvrd(sc, MK48T18_CLKOFF + MK48TXX_ISEC));
|
||||
if (t2 > 59)
|
||||
goto restore;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clock.c,v 1.4 2014/11/17 02:15:49 christos Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.5 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* This is a slightly modified version of mvme68k's standalone clock.c.
|
||||
@ -14,9 +14,6 @@
|
||||
#include "libsa.h"
|
||||
#include "bugsyscalls.h"
|
||||
|
||||
#define FROMBCD(x) (int)((((unsigned int)(x)) >> 4) * 10 +\
|
||||
(((unsigned int)(x)) & 0xf))
|
||||
|
||||
#define YEAR0 68
|
||||
|
||||
/*
|
||||
@ -31,12 +28,12 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year)
|
||||
{
|
||||
int days, yr;
|
||||
|
||||
sec = FROMBCD(sec);
|
||||
min = FROMBCD(min);
|
||||
hour = FROMBCD(hour);
|
||||
day = FROMBCD(day);
|
||||
mon = FROMBCD(mon);
|
||||
year = FROMBCD(year) + YEAR0;
|
||||
sec = bcdtobin(sec);
|
||||
min = bcdtobin(min);
|
||||
hour = bcdtobin(hour);
|
||||
day = bcdtobin(day);
|
||||
mon = bcdtobin(mon);
|
||||
year = bcdtobin(year) + YEAR0;
|
||||
if (year < 70)
|
||||
year = 70;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtc.c,v 1.17 2014/03/24 20:01:03 christos Exp $ */
|
||||
/* $NetBSD: rtc.c,v 1.18 2014/11/20 16:34:25 christos Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1998 Darrin Jewell
|
||||
* Copyright (c) 1997 Rolf Grossmann
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.17 2014/03/24 20:01:03 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.18 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h> /* for panic */
|
||||
@ -272,20 +272,20 @@ gettime_old(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
{
|
||||
u_char h, y;
|
||||
|
||||
y = FROMBCD(rtc_read(RTC_YR));
|
||||
y = bcdtobin(rtc_read(RTC_YR));
|
||||
if (y >= 69) {
|
||||
dt->dt_year = 1900+y;
|
||||
} else {
|
||||
dt->dt_year = 2000+y;
|
||||
}
|
||||
|
||||
dt->dt_mon = FROMBCD(rtc_read(RTC_MON)&0x1f);
|
||||
dt->dt_day = FROMBCD(rtc_read(RTC_DATE)&0x3f);
|
||||
dt->dt_wday = FROMBCD(rtc_read(RTC_DAY)&0x7);
|
||||
dt->dt_mon = bcdtobin(rtc_read(RTC_MON)&0x1f);
|
||||
dt->dt_day = bcdtobin(rtc_read(RTC_DATE)&0x3f);
|
||||
dt->dt_wday = bcdtobin(rtc_read(RTC_DAY)&0x7);
|
||||
|
||||
h = rtc_read(RTC_HRS);
|
||||
if (h & 0x80) { /* time is am/pm format */
|
||||
dt->dt_hour = FROMBCD(h&0x1f);
|
||||
dt->dt_hour = bcdtobin(h&0x1f);
|
||||
if (h & 0x20) { /* pm */
|
||||
if (dt->dt_hour < 12) dt->dt_hour += 12;
|
||||
} else { /* am */
|
||||
@ -294,12 +294,12 @@ gettime_old(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
#ifdef notdef
|
||||
} else { /* time is 24 hour format */
|
||||
struct clock_ymdhms val;
|
||||
val.dt_hour = FROMBCD(h & 0x3f);
|
||||
val.dt_hour = bcdtobin(h & 0x3f);
|
||||
#endif
|
||||
}
|
||||
|
||||
dt->dt_min = FROMBCD(rtc_read(RTC_MIN)&0x7f);
|
||||
dt->dt_sec = FROMBCD(rtc_read(RTC_SEC)&0x7f);
|
||||
dt->dt_min = bcdtobin(rtc_read(RTC_MIN)&0x7f);
|
||||
dt->dt_sec = bcdtobin(rtc_read(RTC_SEC)&0x7f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -317,25 +317,25 @@ settime_old(todr_chip_handle_t tcr, struct clock_ymdhms *dt)
|
||||
rtc_print();
|
||||
#endif
|
||||
|
||||
rtc_write(RTC_SEC,TOBCD(dt->dt_sec));
|
||||
rtc_write(RTC_MIN,TOBCD(dt->dt_min));
|
||||
rtc_write(RTC_SEC,bintobcd(dt->dt_sec));
|
||||
rtc_write(RTC_MIN,bintobcd(dt->dt_min));
|
||||
h = rtc_read(RTC_HRS);
|
||||
if (h & 0x80) { /* time is am/pm format */
|
||||
if (dt->dt_hour == 0) {
|
||||
rtc_write(RTC_HRS,TOBCD(12)|0x80);
|
||||
rtc_write(RTC_HRS,bintobcd(12)|0x80);
|
||||
} else if (dt->dt_hour < 12) { /* am */
|
||||
rtc_write(RTC_HRS,TOBCD(dt->dt_hour)|0x80);
|
||||
rtc_write(RTC_HRS,bintobcd(dt->dt_hour)|0x80);
|
||||
} else if (dt->dt_hour == 12) {
|
||||
rtc_write(RTC_HRS,TOBCD(12)|0x80|0x20);
|
||||
rtc_write(RTC_HRS,bintobcd(12)|0x80|0x20);
|
||||
} else /* pm */
|
||||
rtc_write(RTC_HRS,TOBCD(dt->dt_hour-12)|0x80|0x20);
|
||||
rtc_write(RTC_HRS,bintobcd(dt->dt_hour-12)|0x80|0x20);
|
||||
} else { /* time is 24 hour format */
|
||||
rtc_write(RTC_HRS,TOBCD(dt->dt_hour));
|
||||
rtc_write(RTC_HRS,bintobcd(dt->dt_hour));
|
||||
}
|
||||
rtc_write(RTC_DAY,TOBCD(dt->dt_wday));
|
||||
rtc_write(RTC_DATE,TOBCD(dt->dt_day));
|
||||
rtc_write(RTC_MON,TOBCD(dt->dt_mon));
|
||||
rtc_write(RTC_YR,TOBCD(dt->dt_year%100));
|
||||
rtc_write(RTC_DAY,bintobcd(dt->dt_wday));
|
||||
rtc_write(RTC_DATE,bintobcd(dt->dt_day));
|
||||
rtc_write(RTC_MON,bintobcd(dt->dt_mon));
|
||||
rtc_write(RTC_YR,bintobcd(dt->dt_year%100));
|
||||
|
||||
#ifdef RTC_DEBUG
|
||||
printf("Regs after:\n",secs);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clock.c,v 1.10 2014/07/04 08:09:47 martin Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.11 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.10 2014/07/04 08:09:47 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include "debug_playstation2.h"
|
||||
|
||||
@ -82,12 +82,12 @@ get_bootinfo_tod(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
(void *)MIPS_PHYS_TO_KSEG1(BOOTINFO_BLOCK_BASE + BOOTINFO_RTC);
|
||||
|
||||
/* PS2 RTC is JST */
|
||||
dt->dt_year = FROMBCD(rtc->year) + 2000;
|
||||
dt->dt_mon = FROMBCD(rtc->mon);
|
||||
dt->dt_day = FROMBCD(rtc->day);
|
||||
dt->dt_hour = FROMBCD(rtc->hour);
|
||||
dt->dt_min = FROMBCD(rtc->min);
|
||||
dt->dt_sec = FROMBCD(rtc->sec);
|
||||
dt->dt_year = bcdtobin(rtc->year) + 2000;
|
||||
dt->dt_mon = bcdtobin(rtc->mon);
|
||||
dt->dt_day = bcdtobin(rtc->day);
|
||||
dt->dt_hour = bcdtobin(rtc->hour);
|
||||
dt->dt_min = bcdtobin(rtc->min);
|
||||
dt->dt_sec = bcdtobin(rtc->sec);
|
||||
|
||||
/* convert to UTC */
|
||||
utc = clock_ymdhms_to_secs(dt) - 9*60*60;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtc.c,v 1.19 2011/07/09 16:59:40 matt Exp $ */
|
||||
/* $NetBSD: rtc.c,v 1.20 2014/11/20 16:34:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2002 Wasabi Systems, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.19 2011/07/09 16:59:40 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.20 2014/11/20 16:34:25 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
@ -160,18 +160,18 @@ xirtc_settime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms)
|
||||
WRITERTC(sc, X1241REG_SR, X1241REG_SR_WEL | X1241REG_SR_RWEL);
|
||||
|
||||
/* set the time */
|
||||
WRITERTC(sc, X1241REG_HR, TOBCD(ymdhms->dt_hour) | X1241REG_HR_MIL);
|
||||
WRITERTC(sc, X1241REG_MN, TOBCD(ymdhms->dt_min));
|
||||
WRITERTC(sc, X1241REG_SC, TOBCD(ymdhms->dt_sec));
|
||||
WRITERTC(sc, X1241REG_HR, bintobcd(ymdhms->dt_hour) | X1241REG_HR_MIL);
|
||||
WRITERTC(sc, X1241REG_MN, bintobcd(ymdhms->dt_min));
|
||||
WRITERTC(sc, X1241REG_SC, bintobcd(ymdhms->dt_sec));
|
||||
|
||||
/* set the date */
|
||||
y2k = (ymdhms->dt_year >= 2000) ? 0x20 : 0x19;
|
||||
year = ymdhms->dt_year % 100;
|
||||
|
||||
WRITERTC(sc, X1241REG_MO, TOBCD(ymdhms->dt_mon));
|
||||
WRITERTC(sc, X1241REG_DT, TOBCD(ymdhms->dt_day));
|
||||
WRITERTC(sc, X1241REG_YR, TOBCD(year));
|
||||
WRITERTC(sc, X1241REG_Y2K, TOBCD(y2k));
|
||||
WRITERTC(sc, X1241REG_MO, bintobcd(ymdhms->dt_mon));
|
||||
WRITERTC(sc, X1241REG_DT, bintobcd(ymdhms->dt_day));
|
||||
WRITERTC(sc, X1241REG_YR, bintobcd(year));
|
||||
WRITERTC(sc, X1241REG_Y2K, bintobcd(y2k));
|
||||
|
||||
/* lock writes again */
|
||||
WRITERTC(sc, X1241REG_SR, 0);
|
||||
@ -187,17 +187,17 @@ xirtc_gettime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms)
|
||||
uint8_t status;
|
||||
|
||||
time_smbus_init(sc->sc_smbus_chan);
|
||||
ymdhms->dt_day = FROMBCD(READRTC(sc, X1241REG_DT));
|
||||
ymdhms->dt_mon = FROMBCD(READRTC(sc, X1241REG_MO));
|
||||
ymdhms->dt_day = bcdtobin(READRTC(sc, X1241REG_DT));
|
||||
ymdhms->dt_mon = bcdtobin(READRTC(sc, X1241REG_MO));
|
||||
year = READRTC(sc, X1241REG_YR);
|
||||
y2k = READRTC(sc, X1241REG_Y2K);
|
||||
ymdhms->dt_year = FROMBCD(y2k) * 100 + FROMBCD(year);
|
||||
ymdhms->dt_year = bcdtobin(y2k) * 100 + bcdtobin(year);
|
||||
|
||||
|
||||
ymdhms->dt_sec = FROMBCD(READRTC(sc, X1241REG_SC));
|
||||
ymdhms->dt_min = FROMBCD(READRTC(sc, X1241REG_MN));
|
||||
ymdhms->dt_sec = bcdtobin(READRTC(sc, X1241REG_SC));
|
||||
ymdhms->dt_min = bcdtobin(READRTC(sc, X1241REG_MN));
|
||||
hour = READRTC(sc, X1241REG_HR);
|
||||
ymdhms->dt_hour = FROMBCD(hour & ~X1241REG_HR_MIL);
|
||||
ymdhms->dt_hour = bcdtobin(hour & ~X1241REG_HR_MIL);
|
||||
|
||||
status = READRTC(sc, X1241REG_SR);
|
||||
|
||||
@ -265,19 +265,19 @@ strtc_settime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms)
|
||||
|
||||
time_smbus_init(sc->sc_smbus_chan);
|
||||
|
||||
hour = TOBCD(ymdhms->dt_hour);
|
||||
hour = bintobcd(ymdhms->dt_hour);
|
||||
if (ymdhms->dt_year >= 2000) /* Should be always true! */
|
||||
hour |= M41T81_HOUR_CB | M41T81_HOUR_CEB;
|
||||
|
||||
/* set the time */
|
||||
WRITERTC(sc, M41T81_SEC, TOBCD(ymdhms->dt_sec));
|
||||
WRITERTC(sc, M41T81_MIN, TOBCD(ymdhms->dt_min));
|
||||
WRITERTC(sc, M41T81_SEC, bintobcd(ymdhms->dt_sec));
|
||||
WRITERTC(sc, M41T81_MIN, bintobcd(ymdhms->dt_min));
|
||||
WRITERTC(sc, M41T81_HOUR, hour);
|
||||
|
||||
/* set the date */
|
||||
WRITERTC(sc, M41T81_DATE, TOBCD(ymdhms->dt_day));
|
||||
WRITERTC(sc, M41T81_MON, TOBCD(ymdhms->dt_mon));
|
||||
WRITERTC(sc, M41T81_YEAR, TOBCD(ymdhms->dt_year % 100));
|
||||
WRITERTC(sc, M41T81_DATE, bintobcd(ymdhms->dt_day));
|
||||
WRITERTC(sc, M41T81_MON, bintobcd(ymdhms->dt_mon));
|
||||
WRITERTC(sc, M41T81_YEAR, bintobcd(ymdhms->dt_year % 100));
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -290,14 +290,14 @@ strtc_gettime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms)
|
||||
|
||||
time_smbus_init(sc->sc_smbus_chan);
|
||||
|
||||
ymdhms->dt_sec = FROMBCD(READRTC(sc, M41T81_SEC));
|
||||
ymdhms->dt_min = FROMBCD(READRTC(sc, M41T81_MIN));
|
||||
ymdhms->dt_sec = bcdtobin(READRTC(sc, M41T81_SEC));
|
||||
ymdhms->dt_min = bcdtobin(READRTC(sc, M41T81_MIN));
|
||||
hour = READRTC(sc, M41T81_HOUR & M41T81_HOUR_MASK);
|
||||
ymdhms->dt_hour = FROMBCD(hour & M41T81_HOUR_MASK);
|
||||
ymdhms->dt_hour = bcdtobin(hour & M41T81_HOUR_MASK);
|
||||
|
||||
ymdhms->dt_day = FROMBCD(READRTC(sc, M41T81_DATE));
|
||||
ymdhms->dt_mon = FROMBCD(READRTC(sc, M41T81_MON));
|
||||
ymdhms->dt_year = 1900 + FROMBCD(READRTC(sc, M41T81_YEAR));
|
||||
ymdhms->dt_day = bcdtobin(READRTC(sc, M41T81_DATE));
|
||||
ymdhms->dt_mon = bcdtobin(READRTC(sc, M41T81_MON));
|
||||
ymdhms->dt_year = 1900 + bcdtobin(READRTC(sc, M41T81_YEAR));
|
||||
if (hour & M41T81_HOUR_CB)
|
||||
ymdhms->dt_year += 100;
|
||||
|
||||
@ -305,7 +305,7 @@ strtc_gettime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms)
|
||||
}
|
||||
|
||||
#define NITERS 3
|
||||
#define RTC_SECONDS(rtc) FROMBCD(READRTC((rtc), X1241REG_SC))
|
||||
#define RTC_SECONDS(rtc) bcdtobin(READRTC((rtc), X1241REG_SC))
|
||||
|
||||
/*
|
||||
* Since it takes so long to read the complete time/date values from
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dpclock.c,v 1.4 2012/10/27 17:18:09 chs Exp $ */
|
||||
/* $NetBSD: dpclock.c,v 1.5 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Erik Reid
|
||||
@ -140,11 +140,11 @@ dpclock_gettime(struct todr_chip_handle *todrch, struct timeval *tv)
|
||||
for (i = 0; i < 32; i++)
|
||||
regs[i] = bus_space_read_1(sc->sc_rtct, sc->sc_rtch, i);
|
||||
|
||||
dt.dt_sec = FROMBCD(regs[DP8573A_SAVE_SEC]);
|
||||
dt.dt_min = FROMBCD(regs[DP8573A_SAVE_MIN]);
|
||||
dt.dt_sec = bcdtobin(regs[DP8573A_SAVE_SEC]);
|
||||
dt.dt_min = bcdtobin(regs[DP8573A_SAVE_MIN]);
|
||||
|
||||
if (regs[DP8573A_RT_MODE] & DP8573A_RT_MODE_1224) {
|
||||
dt.dt_hour = FROMBCD(regs[DP8573A_SAVE_HOUR] &
|
||||
dt.dt_hour = bcdtobin(regs[DP8573A_SAVE_HOUR] &
|
||||
DP8573A_HOUR_12HR_MASK) +
|
||||
((regs[DP8573A_SAVE_HOUR] & DP8573A_RT_MODE_1224) ? 0 : 12);
|
||||
|
||||
@ -157,14 +157,14 @@ dpclock_gettime(struct todr_chip_handle *todrch, struct timeval *tv)
|
||||
if (dt.dt_hour == 24)
|
||||
dt.dt_hour = 0;
|
||||
} else {
|
||||
dt.dt_hour = FROMBCD(regs[DP8573A_SAVE_HOUR] &
|
||||
dt.dt_hour = bcdtobin(regs[DP8573A_SAVE_HOUR] &
|
||||
DP8573A_HOUR_24HR_MASK);
|
||||
}
|
||||
|
||||
dt.dt_wday = FROMBCD(regs[DP8573A_DOW]); /* Not from time saved */
|
||||
dt.dt_day = FROMBCD(regs[DP8573A_SAVE_DOM]);
|
||||
dt.dt_mon = FROMBCD(regs[DP8573A_SAVE_MONTH]);
|
||||
dt.dt_year = FROM_IRIX_YEAR(FROMBCD(regs[DP8573A_YEAR]));
|
||||
dt.dt_wday = bcdtobin(regs[DP8573A_DOW]); /* Not from time saved */
|
||||
dt.dt_day = bcdtobin(regs[DP8573A_SAVE_DOM]);
|
||||
dt.dt_mon = bcdtobin(regs[DP8573A_SAVE_MONTH]);
|
||||
dt.dt_year = FROM_IRIX_YEAR(bcdtobin(regs[DP8573A_YEAR]));
|
||||
|
||||
/* simple sanity checks */
|
||||
if (dt.dt_mon > 12 || dt.dt_day > 31 ||
|
||||
@ -204,13 +204,13 @@ dpclock_settime(struct todr_chip_handle *todrch, struct timeval *tv)
|
||||
regs[i] = bus_space_read_1(sc->sc_rtct, sc->sc_rtch, i);
|
||||
|
||||
regs[DP8573A_SUBSECOND] = 0;
|
||||
regs[DP8573A_SECOND] = TOBCD(dt.dt_sec);
|
||||
regs[DP8573A_MINUTE] = TOBCD(dt.dt_min);
|
||||
regs[DP8573A_HOUR] = TOBCD(dt.dt_hour) & DP8573A_HOUR_24HR_MASK;
|
||||
regs[DP8573A_DOW] = TOBCD(dt.dt_wday);
|
||||
regs[DP8573A_DOM] = TOBCD(dt.dt_day);
|
||||
regs[DP8573A_MONTH] = TOBCD(dt.dt_mon);
|
||||
regs[DP8573A_YEAR] = TOBCD(TO_IRIX_YEAR(dt.dt_year));
|
||||
regs[DP8573A_SECOND] = bintobcd(dt.dt_sec);
|
||||
regs[DP8573A_MINUTE] = bintobcd(dt.dt_min);
|
||||
regs[DP8573A_HOUR] = bintobcd(dt.dt_hour) & DP8573A_HOUR_24HR_MASK;
|
||||
regs[DP8573A_DOW] = bintobcd(dt.dt_wday);
|
||||
regs[DP8573A_DOM] = bintobcd(dt.dt_day);
|
||||
regs[DP8573A_MONTH] = bintobcd(dt.dt_mon);
|
||||
regs[DP8573A_YEAR] = bintobcd(TO_IRIX_YEAR(dt.dt_year));
|
||||
|
||||
s = splhigh();
|
||||
i = bus_space_read_1(sc->sc_rtct, sc->sc_rtch, DP8573A_RT_MODE);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dsclock.c,v 1.5 2011/07/01 18:53:46 dyoung Exp $ */
|
||||
/* $NetBSD: dsclock.c,v 1.6 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Rafal K. Boni
|
||||
@ -34,7 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dsclock.c,v 1.5 2011/07/01 18:53:46 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dsclock.c,v 1.6 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -126,12 +126,12 @@ dsclock_gettime_ymdhms(struct todr_chip_handle *todrch, struct clock_ymdhms *dt)
|
||||
DS1286_GETTOD(sc, ®s)
|
||||
splx(s);
|
||||
|
||||
dt->dt_sec = FROMBCD(regs[DS1286_SEC]);
|
||||
dt->dt_min = FROMBCD(regs[DS1286_MIN]);
|
||||
dt->dt_sec = bcdtobin(regs[DS1286_SEC]);
|
||||
dt->dt_min = bcdtobin(regs[DS1286_MIN]);
|
||||
|
||||
if (regs[DS1286_HOUR] & DS1286_HOUR_12MODE) {
|
||||
dt->dt_hour =
|
||||
FROMBCD(regs[DS1286_HOUR] & DS1286_HOUR_12HR_MASK)
|
||||
bcdtobin(regs[DS1286_HOUR] & DS1286_HOUR_12HR_MASK)
|
||||
+ ((regs[DS1286_HOUR] & DS1286_HOUR_12HR_PM) ? 12 : 0);
|
||||
|
||||
/*
|
||||
@ -143,13 +143,13 @@ dsclock_gettime_ymdhms(struct todr_chip_handle *todrch, struct clock_ymdhms *dt)
|
||||
dt->dt_hour = 0;
|
||||
} else {
|
||||
dt->dt_hour =
|
||||
FROMBCD(regs[DS1286_HOUR] & DS1286_HOUR_24HR_MASK);
|
||||
bcdtobin(regs[DS1286_HOUR] & DS1286_HOUR_24HR_MASK);
|
||||
}
|
||||
|
||||
dt->dt_wday = FROMBCD(regs[DS1286_DOW]);
|
||||
dt->dt_day = FROMBCD(regs[DS1286_DOM]);
|
||||
dt->dt_mon = FROMBCD(regs[DS1286_MONTH] & DS1286_MONTH_MASK);
|
||||
dt->dt_year = FROM_IRIX_YEAR(FROMBCD(regs[DS1286_YEAR]));
|
||||
dt->dt_wday = bcdtobin(regs[DS1286_DOW]);
|
||||
dt->dt_day = bcdtobin(regs[DS1286_DOM]);
|
||||
dt->dt_mon = bcdtobin(regs[DS1286_MONTH] & DS1286_MONTH_MASK);
|
||||
dt->dt_year = FROM_IRIX_YEAR(bcdtobin(regs[DS1286_YEAR]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -169,17 +169,17 @@ dsclock_settime_ymdhms(struct todr_chip_handle *todrch, struct clock_ymdhms *dt)
|
||||
splx(s);
|
||||
|
||||
regs[DS1286_SUBSEC] = 0;
|
||||
regs[DS1286_SEC] = TOBCD(dt->dt_sec);
|
||||
regs[DS1286_MIN] = TOBCD(dt->dt_min);
|
||||
regs[DS1286_HOUR] = TOBCD(dt->dt_hour) & DS1286_HOUR_24HR_MASK;
|
||||
regs[DS1286_DOW] = TOBCD(dt->dt_wday);
|
||||
regs[DS1286_DOM] = TOBCD(dt->dt_day);
|
||||
regs[DS1286_SEC] = bintobcd(dt->dt_sec);
|
||||
regs[DS1286_MIN] = bintobcd(dt->dt_min);
|
||||
regs[DS1286_HOUR] = bintobcd(dt->dt_hour) & DS1286_HOUR_24HR_MASK;
|
||||
regs[DS1286_DOW] = bintobcd(dt->dt_wday);
|
||||
regs[DS1286_DOM] = bintobcd(dt->dt_day);
|
||||
|
||||
/* Leave wave-generator bits as set originally */
|
||||
regs[DS1286_MONTH] &= ~DS1286_MONTH_MASK;
|
||||
regs[DS1286_MONTH] |= TOBCD(dt->dt_mon) & DS1286_MONTH_MASK;
|
||||
regs[DS1286_MONTH] |= bintobcd(dt->dt_mon) & DS1286_MONTH_MASK;
|
||||
|
||||
regs[DS1286_YEAR] = TOBCD(TO_IRIX_YEAR(dt->dt_year));
|
||||
regs[DS1286_YEAR] = bintobcd(TO_IRIX_YEAR(dt->dt_year));
|
||||
|
||||
s = splhigh();
|
||||
DS1286_PUTTOD(sc, ®s);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mcclock_mace.c,v 1.15 2013/12/16 15:45:29 mrg Exp $ */
|
||||
/* $NetBSD: mcclock_mace.c,v 1.16 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Antti Kantee. All Rights Reserved.
|
||||
@ -65,7 +65,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_mace.c,v 1.15 2013/12/16 15:45:29 mrg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_mace.c,v 1.16 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -187,14 +187,14 @@ mcclock_mace_gettime_ymdhms(todr_chip_handle_t todrch, struct clock_ymdhms *dt)
|
||||
DS1687_GETTOD(sc, ®s);
|
||||
splx(s);
|
||||
|
||||
dt->dt_sec = FROMBCD(regs[DS1687_SOFT_SEC]);
|
||||
dt->dt_min = FROMBCD(regs[DS1687_SOFT_MIN]);
|
||||
dt->dt_hour = FROMBCD(regs[DS1687_SOFT_HOUR]);
|
||||
dt->dt_wday = FROMBCD(regs[DS1687_SOFT_DOW]);
|
||||
dt->dt_day = FROMBCD(regs[DS1687_SOFT_DOM]);
|
||||
dt->dt_mon = FROMBCD(regs[DS1687_SOFT_MONTH]);
|
||||
dt->dt_year = FROMBCD(regs[DS1687_SOFT_YEAR]) +
|
||||
(100 * FROMBCD(regs[DS1687_SOFT_CENTURY]));
|
||||
dt->dt_sec = bcdtobin(regs[DS1687_SOFT_SEC]);
|
||||
dt->dt_min = bcdtobin(regs[DS1687_SOFT_MIN]);
|
||||
dt->dt_hour = bcdtobin(regs[DS1687_SOFT_HOUR]);
|
||||
dt->dt_wday = bcdtobin(regs[DS1687_SOFT_DOW]);
|
||||
dt->dt_day = bcdtobin(regs[DS1687_SOFT_DOM]);
|
||||
dt->dt_mon = bcdtobin(regs[DS1687_SOFT_MONTH]);
|
||||
dt->dt_year = bcdtobin(regs[DS1687_SOFT_YEAR]) +
|
||||
(100 * bcdtobin(regs[DS1687_SOFT_CENTURY]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -208,14 +208,14 @@ mcclock_mace_settime_ymdhms(todr_chip_handle_t todrch, struct clock_ymdhms *dt)
|
||||
|
||||
memset(®s, 0, sizeof(regs));
|
||||
|
||||
regs[DS1687_SOFT_SEC] = TOBCD(dt->dt_sec);
|
||||
regs[DS1687_SOFT_MIN] = TOBCD(dt->dt_min);
|
||||
regs[DS1687_SOFT_HOUR] = TOBCD(dt->dt_hour);
|
||||
regs[DS1687_SOFT_DOW] = TOBCD(dt->dt_wday);
|
||||
regs[DS1687_SOFT_DOM] = TOBCD(dt->dt_day);
|
||||
regs[DS1687_SOFT_MONTH] = TOBCD(dt->dt_mon);
|
||||
regs[DS1687_SOFT_YEAR] = TOBCD(dt->dt_year % 100);
|
||||
regs[DS1687_SOFT_CENTURY] = TOBCD(dt->dt_year / 100);
|
||||
regs[DS1687_SOFT_SEC] = bintobcd(dt->dt_sec);
|
||||
regs[DS1687_SOFT_MIN] = bintobcd(dt->dt_min);
|
||||
regs[DS1687_SOFT_HOUR] = bintobcd(dt->dt_hour);
|
||||
regs[DS1687_SOFT_DOW] = bintobcd(dt->dt_wday);
|
||||
regs[DS1687_SOFT_DOM] = bintobcd(dt->dt_day);
|
||||
regs[DS1687_SOFT_MONTH] = bintobcd(dt->dt_mon);
|
||||
regs[DS1687_SOFT_YEAR] = bintobcd(dt->dt_year % 100);
|
||||
regs[DS1687_SOFT_CENTURY] = bintobcd(dt->dt_year / 100);
|
||||
s = splhigh();
|
||||
DS1687_PUTTOD(sc, ®s);
|
||||
splx(s);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtc.c,v 1.9 2014/09/08 10:00:18 martin Exp $ */
|
||||
/* $NetBSD: rtc.c,v 1.10 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.9 2014/09/08 10:00:18 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.10 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -180,11 +180,11 @@ rtc_gettime_ymdhms(todr_chip_handle_t h, struct clock_ymdhms *dt)
|
||||
year = _reg_read_1(SH3_RYRCNT);
|
||||
else
|
||||
year = _reg_read_2(SH4_RYRCNT) & 0x00ff;
|
||||
dt->dt_year = FROMBCD(year);
|
||||
dt->dt_year = bcdtobin(year);
|
||||
|
||||
/* read counter */
|
||||
#define RTCGET(x, y) \
|
||||
dt->dt_ ## x = FROMBCD(_reg_read_1(SH_(R ## y ## CNT)))
|
||||
dt->dt_ ## x = bcdtobin(_reg_read_1(SH_(R ## y ## CNT)))
|
||||
|
||||
RTCGET(mon, MON);
|
||||
RTCGET(wday, WK);
|
||||
@ -231,7 +231,7 @@ rtc_settime_ymdhms(todr_chip_handle_t h, struct clock_ymdhms *dt)
|
||||
if (year > 99)
|
||||
year -= 100;
|
||||
|
||||
year = TOBCD(year);
|
||||
year = bintobcd(year);
|
||||
|
||||
r = _reg_read_1(SH_(RCR2));
|
||||
|
||||
@ -245,7 +245,7 @@ rtc_settime_ymdhms(todr_chip_handle_t h, struct clock_ymdhms *dt)
|
||||
_reg_write_2(SH4_RYRCNT, year);
|
||||
|
||||
#define RTCSET(x, y) \
|
||||
_reg_write_1(SH_(R ## x ## CNT), TOBCD(dt->dt_ ## y))
|
||||
_reg_write_1(SH_(R ## x ## CNT), bintobcd(dt->dt_ ## y))
|
||||
|
||||
RTCSET(MON, mon);
|
||||
RTCSET(WK, wday);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ds1307.c,v 1.20 2014/10/13 10:29:27 martin Exp $ */
|
||||
/* $NetBSD: ds1307.c,v 1.21 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Wasabi Systems, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.20 2014/10/13 10:29:27 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.21 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -432,23 +432,23 @@ dsrtc_clock_read_ymdhms(struct dsrtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the RTC's register values into something useable
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[DSXXXX_SECONDS] & DSXXXX_SECONDS_MASK);
|
||||
dt->dt_min = FROMBCD(bcd[DSXXXX_MINUTES] & DSXXXX_MINUTES_MASK);
|
||||
dt->dt_sec = bcdtobin(bcd[DSXXXX_SECONDS] & DSXXXX_SECONDS_MASK);
|
||||
dt->dt_min = bcdtobin(bcd[DSXXXX_MINUTES] & DSXXXX_MINUTES_MASK);
|
||||
|
||||
if ((bcd[DSXXXX_HOURS] & DSXXXX_HOURS_12HRS_MODE) != 0) {
|
||||
dt->dt_hour = FROMBCD(bcd[DSXXXX_HOURS] &
|
||||
dt->dt_hour = bcdtobin(bcd[DSXXXX_HOURS] &
|
||||
DSXXXX_HOURS_12MASK) % 12; /* 12AM -> 0, 12PM -> 12 */
|
||||
if (bcd[DSXXXX_HOURS] & DSXXXX_HOURS_12HRS_PM)
|
||||
dt->dt_hour += 12;
|
||||
} else
|
||||
dt->dt_hour = FROMBCD(bcd[DSXXXX_HOURS] &
|
||||
dt->dt_hour = bcdtobin(bcd[DSXXXX_HOURS] &
|
||||
DSXXXX_HOURS_24MASK);
|
||||
|
||||
dt->dt_day = FROMBCD(bcd[DSXXXX_DATE] & DSXXXX_DATE_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[DSXXXX_MONTH] & DSXXXX_MONTH_MASK);
|
||||
dt->dt_day = bcdtobin(bcd[DSXXXX_DATE] & DSXXXX_DATE_MASK);
|
||||
dt->dt_mon = bcdtobin(bcd[DSXXXX_MONTH] & DSXXXX_MONTH_MASK);
|
||||
|
||||
/* XXX: Should be an MD way to specify EPOCH used by BIOS/Firmware */
|
||||
dt->dt_year = FROMBCD(bcd[DSXXXX_YEAR]) + POSIX_BASE_YEAR;
|
||||
dt->dt_year = bcdtobin(bcd[DSXXXX_YEAR]) + POSIX_BASE_YEAR;
|
||||
if (bcd[DSXXXX_MONTH] & DSXXXX_MONTH_CENTURY)
|
||||
dt->dt_year += 100;
|
||||
|
||||
@ -468,13 +468,13 @@ dsrtc_clock_write_ymdhms(struct dsrtc_softc *sc, struct clock_ymdhms *dt)
|
||||
* Convert our time representation into something the DSXXXX
|
||||
* can understand.
|
||||
*/
|
||||
bcd[DSXXXX_SECONDS] = TOBCD(dt->dt_sec);
|
||||
bcd[DSXXXX_MINUTES] = TOBCD(dt->dt_min);
|
||||
bcd[DSXXXX_HOURS] = TOBCD(dt->dt_hour); /* DSXXXX_HOURS_12HRS_MODE=0 */
|
||||
bcd[DSXXXX_DATE] = TOBCD(dt->dt_day);
|
||||
bcd[DSXXXX_DAY] = TOBCD(dt->dt_wday);
|
||||
bcd[DSXXXX_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[DSXXXX_YEAR] = TOBCD((dt->dt_year - POSIX_BASE_YEAR) % 100);
|
||||
bcd[DSXXXX_SECONDS] = bintobcd(dt->dt_sec);
|
||||
bcd[DSXXXX_MINUTES] = bintobcd(dt->dt_min);
|
||||
bcd[DSXXXX_HOURS] = bintobcd(dt->dt_hour); /* DSXXXX_HOURS_12HRS_MODE=0 */
|
||||
bcd[DSXXXX_DATE] = bintobcd(dt->dt_day);
|
||||
bcd[DSXXXX_DAY] = bintobcd(dt->dt_wday);
|
||||
bcd[DSXXXX_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[DSXXXX_YEAR] = bintobcd((dt->dt_year - POSIX_BASE_YEAR) % 100);
|
||||
if (dt->dt_year - POSIX_BASE_YEAR >= 100)
|
||||
bcd[DSXXXX_MONTH] |= DSXXXX_MONTH_CENTURY;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: m41st84.c,v 1.21 2014/07/25 08:10:37 dholland Exp $ */
|
||||
/* $NetBSD: m41st84.c,v 1.22 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Wasabi Systems, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.21 2014/07/25 08:10:37 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.22 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include "opt_strtc.h"
|
||||
|
||||
@ -346,14 +346,14 @@ strtc_clock_read(struct strtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the M41ST84's register values into something useable
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[M41ST84_REG_SEC] & M41ST84_SEC_MASK);
|
||||
dt->dt_min = FROMBCD(bcd[M41ST84_REG_MIN] & M41ST84_MIN_MASK);
|
||||
dt->dt_hour = FROMBCD(bcd[M41ST84_REG_CENHR] & M41ST84_HOUR_MASK);
|
||||
dt->dt_day = FROMBCD(bcd[M41ST84_REG_DATE] & M41ST84_DATE_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[M41ST84_REG_MONTH] & M41ST84_MONTH_MASK);
|
||||
dt->dt_sec = bcdtobin(bcd[M41ST84_REG_SEC] & M41ST84_SEC_MASK);
|
||||
dt->dt_min = bcdtobin(bcd[M41ST84_REG_MIN] & M41ST84_MIN_MASK);
|
||||
dt->dt_hour = bcdtobin(bcd[M41ST84_REG_CENHR] & M41ST84_HOUR_MASK);
|
||||
dt->dt_day = bcdtobin(bcd[M41ST84_REG_DATE] & M41ST84_DATE_MASK);
|
||||
dt->dt_mon = bcdtobin(bcd[M41ST84_REG_MONTH] & M41ST84_MONTH_MASK);
|
||||
|
||||
/* XXX: Should be an MD way to specify EPOCH used by BIOS/Firmware */
|
||||
dt->dt_year = FROMBCD(bcd[M41ST84_REG_YEAR]) + POSIX_BASE_YEAR;
|
||||
dt->dt_year = bcdtobin(bcd[M41ST84_REG_YEAR]) + POSIX_BASE_YEAR;
|
||||
|
||||
return (1);
|
||||
}
|
||||
@ -368,14 +368,14 @@ strtc_clock_write(struct strtc_softc *sc, struct clock_ymdhms *dt)
|
||||
* Convert our time representation into something the M41ST84
|
||||
* can understand.
|
||||
*/
|
||||
bcd[M41ST84_REG_CSEC] = TOBCD(0); /* must always write as 0 */
|
||||
bcd[M41ST84_REG_SEC] = TOBCD(dt->dt_sec);
|
||||
bcd[M41ST84_REG_MIN] = TOBCD(dt->dt_min);
|
||||
bcd[M41ST84_REG_CENHR] = TOBCD(dt->dt_hour);
|
||||
bcd[M41ST84_REG_DATE] = TOBCD(dt->dt_day);
|
||||
bcd[M41ST84_REG_DAY] = TOBCD(dt->dt_wday);
|
||||
bcd[M41ST84_REG_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[M41ST84_REG_YEAR] = TOBCD((dt->dt_year - POSIX_BASE_YEAR) % 100);
|
||||
bcd[M41ST84_REG_CSEC] = bintobcd(0); /* must always write as 0 */
|
||||
bcd[M41ST84_REG_SEC] = bintobcd(dt->dt_sec);
|
||||
bcd[M41ST84_REG_MIN] = bintobcd(dt->dt_min);
|
||||
bcd[M41ST84_REG_CENHR] = bintobcd(dt->dt_hour);
|
||||
bcd[M41ST84_REG_DATE] = bintobcd(dt->dt_day);
|
||||
bcd[M41ST84_REG_DAY] = bintobcd(dt->dt_wday);
|
||||
bcd[M41ST84_REG_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[M41ST84_REG_YEAR] = bintobcd((dt->dt_year - POSIX_BASE_YEAR) % 100);
|
||||
|
||||
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
|
||||
aprint_error_dev(sc->sc_dev,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: m41t00.c,v 1.18 2014/07/25 08:10:37 dholland Exp $ */
|
||||
/* $NetBSD: m41t00.c,v 1.19 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Wasabi Systems, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: m41t00.c,v 1.18 2014/07/25 08:10:37 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: m41t00.c,v 1.19 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -311,13 +311,13 @@ m41t00_clock_read(struct m41t00_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the M41T00's register values into something useable
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[M41T00_SEC] & M41T00_SEC_MASK);
|
||||
dt->dt_min = FROMBCD(bcd[M41T00_MIN] & M41T00_MIN_MASK);
|
||||
dt->dt_hour = FROMBCD(bcd[M41T00_CENHR] & M41T00_HOUR_MASK);
|
||||
dt->dt_day = FROMBCD(bcd[M41T00_DATE] & M41T00_DATE_MASK);
|
||||
dt->dt_wday = FROMBCD(bcd[M41T00_DAY] & M41T00_DAY_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[M41T00_MONTH] & M41T00_MONTH_MASK);
|
||||
dt->dt_year = FROMBCD(bcd[M41T00_YEAR] & M41T00_YEAR_MASK);
|
||||
dt->dt_sec = bcdtobin(bcd[M41T00_SEC] & M41T00_SEC_MASK);
|
||||
dt->dt_min = bcdtobin(bcd[M41T00_MIN] & M41T00_MIN_MASK);
|
||||
dt->dt_hour = bcdtobin(bcd[M41T00_CENHR] & M41T00_HOUR_MASK);
|
||||
dt->dt_day = bcdtobin(bcd[M41T00_DATE] & M41T00_DATE_MASK);
|
||||
dt->dt_wday = bcdtobin(bcd[M41T00_DAY] & M41T00_DAY_MASK);
|
||||
dt->dt_mon = bcdtobin(bcd[M41T00_MONTH] & M41T00_MONTH_MASK);
|
||||
dt->dt_year = bcdtobin(bcd[M41T00_YEAR] & M41T00_YEAR_MASK);
|
||||
|
||||
/*
|
||||
* Since the m41t00 just stores 00-99, and this is 2003 as I write
|
||||
@ -339,13 +339,13 @@ m41t00_clock_write(struct m41t00_softc *sc, struct clock_ymdhms *dt)
|
||||
* Convert our time representation into something the MAX6900
|
||||
* can understand.
|
||||
*/
|
||||
bcd[M41T00_SEC] = TOBCD(dt->dt_sec);
|
||||
bcd[M41T00_MIN] = TOBCD(dt->dt_min);
|
||||
bcd[M41T00_CENHR] = TOBCD(dt->dt_hour);
|
||||
bcd[M41T00_DATE] = TOBCD(dt->dt_day);
|
||||
bcd[M41T00_DAY] = TOBCD(dt->dt_wday);
|
||||
bcd[M41T00_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[M41T00_YEAR] = TOBCD(dt->dt_year % 100);
|
||||
bcd[M41T00_SEC] = bintobcd(dt->dt_sec);
|
||||
bcd[M41T00_MIN] = bintobcd(dt->dt_min);
|
||||
bcd[M41T00_CENHR] = bintobcd(dt->dt_hour);
|
||||
bcd[M41T00_DATE] = bintobcd(dt->dt_day);
|
||||
bcd[M41T00_DAY] = bintobcd(dt->dt_wday);
|
||||
bcd[M41T00_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[M41T00_YEAR] = bintobcd(dt->dt_year % 100);
|
||||
|
||||
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
|
||||
aprint_error_dev(sc->sc_dev,
|
||||
@ -386,7 +386,7 @@ m41t00_clock_write(struct m41t00_softc *sc, struct clock_ymdhms *dt)
|
||||
"INITIAL SECONDS\n");
|
||||
return 0;
|
||||
}
|
||||
init_seconds = FROMBCD(init_seconds & M41T00_SEC_MASK);
|
||||
init_seconds = bcdtobin(init_seconds & M41T00_SEC_MASK);
|
||||
|
||||
for (i = 1; i < M41T00_DATE_BYTES; i++) {
|
||||
cmdbuf[0] = m41t00_rtc_offset[i];
|
||||
@ -411,7 +411,7 @@ m41t00_clock_write(struct m41t00_softc *sc, struct clock_ymdhms *dt)
|
||||
"FINAL SECONDS\n");
|
||||
return 0;
|
||||
}
|
||||
final_seconds = FROMBCD(final_seconds & M41T00_SEC_MASK);
|
||||
final_seconds = bcdtobin(final_seconds & M41T00_SEC_MASK);
|
||||
|
||||
if ((init_seconds != final_seconds) &&
|
||||
(((init_seconds + 1) % 60) != final_seconds)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: max6900.c,v 1.14 2014/07/25 08:10:37 dholland Exp $ */
|
||||
/* $NetBSD: max6900.c,v 1.15 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Wasabi Systems, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: max6900.c,v 1.14 2014/07/25 08:10:37 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: max6900.c,v 1.15 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -338,24 +338,24 @@ maxrtc_clock_read(struct maxrtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the MAX6900's register values into something useable
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[MAX6900_BURST_SECOND] & MAX6900_SECOND_MASK);
|
||||
dt->dt_min = FROMBCD(bcd[MAX6900_BURST_MINUTE] & MAX6900_MINUTE_MASK);
|
||||
dt->dt_sec = bcdtobin(bcd[MAX6900_BURST_SECOND] & MAX6900_SECOND_MASK);
|
||||
dt->dt_min = bcdtobin(bcd[MAX6900_BURST_MINUTE] & MAX6900_MINUTE_MASK);
|
||||
|
||||
if (bcd[MAX6900_BURST_HOUR] & MAX6900_HOUR_12HRS) {
|
||||
dt->dt_hour = FROMBCD(bcd[MAX6900_BURST_HOUR] &
|
||||
dt->dt_hour = bcdtobin(bcd[MAX6900_BURST_HOUR] &
|
||||
MAX6900_HOUR_12MASK);
|
||||
if (bcd[MAX6900_BURST_HOUR] & MAX6900_HOUR_12HRS_PM)
|
||||
dt->dt_hour += 12;
|
||||
} else {
|
||||
dt->dt_hour = FROMBCD(bcd[MAX6900_BURST_HOUR] &
|
||||
dt->dt_hour = bcdtobin(bcd[MAX6900_BURST_HOUR] &
|
||||
MAX6900_HOUR_24MASK);
|
||||
}
|
||||
|
||||
dt->dt_day = FROMBCD(bcd[MAX6900_BURST_DATE] & MAX6900_DATE_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[MAX6900_BURST_MONTH] & MAX6900_MONTH_MASK);
|
||||
dt->dt_year = FROMBCD(bcd[MAX6900_BURST_YEAR]);
|
||||
dt->dt_day = bcdtobin(bcd[MAX6900_BURST_DATE] & MAX6900_DATE_MASK);
|
||||
dt->dt_mon = bcdtobin(bcd[MAX6900_BURST_MONTH] & MAX6900_MONTH_MASK);
|
||||
dt->dt_year = bcdtobin(bcd[MAX6900_BURST_YEAR]);
|
||||
/* century in the burst control slot */
|
||||
dt->dt_year += (int)FROMBCD(bcd[MAX6900_BURST_CONTROL]) * 100;
|
||||
dt->dt_year += (int)bcdtobin(bcd[MAX6900_BURST_CONTROL]) * 100;
|
||||
|
||||
return (1);
|
||||
}
|
||||
@ -371,15 +371,15 @@ maxrtc_clock_write(struct maxrtc_softc *sc, struct clock_ymdhms *dt)
|
||||
* Convert our time representation into something the MAX6900
|
||||
* can understand.
|
||||
*/
|
||||
bcd[MAX6900_BURST_SECOND] = TOBCD(dt->dt_sec);
|
||||
bcd[MAX6900_BURST_MINUTE] = TOBCD(dt->dt_min);
|
||||
bcd[MAX6900_BURST_HOUR] = TOBCD(dt->dt_hour) & MAX6900_HOUR_24MASK;
|
||||
bcd[MAX6900_BURST_DATE] = TOBCD(dt->dt_day);
|
||||
bcd[MAX6900_BURST_WDAY] = TOBCD(dt->dt_wday);
|
||||
bcd[MAX6900_BURST_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[MAX6900_BURST_YEAR] = TOBCD(dt->dt_year % 100);
|
||||
bcd[MAX6900_BURST_SECOND] = bintobcd(dt->dt_sec);
|
||||
bcd[MAX6900_BURST_MINUTE] = bintobcd(dt->dt_min);
|
||||
bcd[MAX6900_BURST_HOUR] = bintobcd(dt->dt_hour) & MAX6900_HOUR_24MASK;
|
||||
bcd[MAX6900_BURST_DATE] = bintobcd(dt->dt_day);
|
||||
bcd[MAX6900_BURST_WDAY] = bintobcd(dt->dt_wday);
|
||||
bcd[MAX6900_BURST_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[MAX6900_BURST_YEAR] = bintobcd(dt->dt_year % 100);
|
||||
/* century in control slot */
|
||||
bcd[MAX6900_BURST_CONTROL] = TOBCD(dt->dt_year / 100);
|
||||
bcd[MAX6900_BURST_CONTROL] = bintobcd(dt->dt_year / 100);
|
||||
|
||||
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
|
||||
aprint_error_dev(sc->sc_dev,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcf8563.c,v 1.3 2012/01/07 21:02:15 phx Exp $ */
|
||||
/* $NetBSD: pcf8563.c,v 1.4 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Jonathan A. Kollasch
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.3 2012/01/07 21:02:15 phx Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.4 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -136,12 +136,12 @@ pcf8563rtc_clock_read(struct pcf8563rtc_softc *sc, struct clock_ymdhms *dt)
|
||||
|
||||
iic_release_bus(sc->sc_tag, I2C_F_POLL);
|
||||
|
||||
dt->dt_sec = FROMBCD(bcd[PCF8563_R_SECOND] & PCF8563_M_SECOND);
|
||||
dt->dt_min = FROMBCD(bcd[PCF8563_R_MINUTE] & PCF8563_M_MINUTE);
|
||||
dt->dt_hour = FROMBCD(bcd[PCF8563_R_HOUR] & PCF8563_M_HOUR);
|
||||
dt->dt_day = FROMBCD(bcd[PCF8563_R_DAY] & PCF8563_M_DAY);
|
||||
dt->dt_mon = FROMBCD(bcd[PCF8563_R_MONTH] & PCF8563_M_MONTH);
|
||||
dt->dt_year = FROMBCD(bcd[PCF8563_R_YEAR] & PCF8563_M_YEAR);
|
||||
dt->dt_sec = bcdtobin(bcd[PCF8563_R_SECOND] & PCF8563_M_SECOND);
|
||||
dt->dt_min = bcdtobin(bcd[PCF8563_R_MINUTE] & PCF8563_M_MINUTE);
|
||||
dt->dt_hour = bcdtobin(bcd[PCF8563_R_HOUR] & PCF8563_M_HOUR);
|
||||
dt->dt_day = bcdtobin(bcd[PCF8563_R_DAY] & PCF8563_M_DAY);
|
||||
dt->dt_mon = bcdtobin(bcd[PCF8563_R_MONTH] & PCF8563_M_MONTH);
|
||||
dt->dt_year = bcdtobin(bcd[PCF8563_R_YEAR] & PCF8563_M_YEAR);
|
||||
dt->dt_year += 2000;
|
||||
|
||||
return 1;
|
||||
@ -153,13 +153,13 @@ pcf8563rtc_clock_write(struct pcf8563rtc_softc *sc, struct clock_ymdhms *dt)
|
||||
uint8_t bcd[PCF8563_NREGS];
|
||||
uint8_t reg = PCF8563_R_SECOND;
|
||||
|
||||
bcd[PCF8563_R_SECOND] = TOBCD(dt->dt_sec);
|
||||
bcd[PCF8563_R_MINUTE] = TOBCD(dt->dt_min);
|
||||
bcd[PCF8563_R_HOUR] = TOBCD(dt->dt_hour);
|
||||
bcd[PCF8563_R_DAY] = TOBCD(dt->dt_day);
|
||||
bcd[PCF8563_R_WEEKDAY] = TOBCD(dt->dt_wday);
|
||||
bcd[PCF8563_R_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[PCF8563_R_YEAR] = TOBCD(dt->dt_year % 100);
|
||||
bcd[PCF8563_R_SECOND] = bintobcd(dt->dt_sec);
|
||||
bcd[PCF8563_R_MINUTE] = bintobcd(dt->dt_min);
|
||||
bcd[PCF8563_R_HOUR] = bintobcd(dt->dt_hour);
|
||||
bcd[PCF8563_R_DAY] = bintobcd(dt->dt_day);
|
||||
bcd[PCF8563_R_WEEKDAY] = bintobcd(dt->dt_wday);
|
||||
bcd[PCF8563_R_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[PCF8563_R_YEAR] = bintobcd(dt->dt_year % 100);
|
||||
|
||||
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
|
||||
device_printf(sc->sc_dev, "acquire bus for write failed\n");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcf8583.c,v 1.15 2014/07/25 08:10:37 dholland Exp $ */
|
||||
/* $NetBSD: pcf8583.c,v 1.16 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Wasabi Systems, Inc.
|
||||
@ -43,7 +43,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pcf8583.c,v 1.15 2014/07/25 08:10:37 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pcf8583.c,v 1.16 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -354,18 +354,18 @@ pcfrtc_clock_read(struct pcfrtc_softc *sc, struct clock_ymdhms *dt,
|
||||
/*
|
||||
* Convert the PCF8583's register values into something useable
|
||||
*/
|
||||
*centi = FROMBCD(bcd[PCF8583_REG_CENTI]);
|
||||
dt->dt_sec = FROMBCD(bcd[PCF8583_REG_SEC]);
|
||||
dt->dt_min = FROMBCD(bcd[PCF8583_REG_MIN]);
|
||||
dt->dt_hour = FROMBCD(bcd[PCF8583_REG_HOUR] & PCF8583_HOUR_MASK);
|
||||
*centi = bcdtobin(bcd[PCF8583_REG_CENTI]);
|
||||
dt->dt_sec = bcdtobin(bcd[PCF8583_REG_SEC]);
|
||||
dt->dt_min = bcdtobin(bcd[PCF8583_REG_MIN]);
|
||||
dt->dt_hour = bcdtobin(bcd[PCF8583_REG_HOUR] & PCF8583_HOUR_MASK);
|
||||
if (bcd[PCF8583_REG_HOUR] & PCF8583_HOUR_12H) {
|
||||
dt->dt_hour %= 12; /* 12AM -> 0, 12PM -> 12 */
|
||||
if (bcd[PCF8583_REG_HOUR] & PCF8583_HOUR_PM)
|
||||
dt->dt_hour += 12;
|
||||
}
|
||||
|
||||
dt->dt_day = FROMBCD(bcd[PCF8583_REG_YEARDATE] & PCF8583_DATE_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[PCF8583_REG_WKDYMON] & PCF8583_MON_MASK);
|
||||
dt->dt_day = bcdtobin(bcd[PCF8583_REG_YEARDATE] & PCF8583_DATE_MASK);
|
||||
dt->dt_mon = bcdtobin(bcd[PCF8583_REG_WKDYMON] & PCF8583_MON_MASK);
|
||||
|
||||
dt->dt_year = bcd[8] + (bcd[9] * 100);
|
||||
/* Try to notice if the year's rolled over. */
|
||||
@ -394,12 +394,12 @@ pcfrtc_clock_write(struct pcfrtc_softc *sc, struct clock_ymdhms *dt,
|
||||
* can understand.
|
||||
*/
|
||||
bcd[PCF8583_REG_CENTI] = centi;
|
||||
bcd[PCF8583_REG_SEC] = TOBCD(dt->dt_sec);
|
||||
bcd[PCF8583_REG_MIN] = TOBCD(dt->dt_min);
|
||||
bcd[PCF8583_REG_HOUR] = TOBCD(dt->dt_hour) & PCF8583_HOUR_MASK;
|
||||
bcd[PCF8583_REG_YEARDATE] = TOBCD(dt->dt_day) |
|
||||
bcd[PCF8583_REG_SEC] = bintobcd(dt->dt_sec);
|
||||
bcd[PCF8583_REG_MIN] = bintobcd(dt->dt_min);
|
||||
bcd[PCF8583_REG_HOUR] = bintobcd(dt->dt_hour) & PCF8583_HOUR_MASK;
|
||||
bcd[PCF8583_REG_YEARDATE] = bintobcd(dt->dt_day) |
|
||||
((dt->dt_year % 4) << PCF8583_YEAR_SHIFT);
|
||||
bcd[PCF8583_REG_WKDYMON] = TOBCD(dt->dt_mon) |
|
||||
bcd[PCF8583_REG_WKDYMON] = bintobcd(dt->dt_mon) |
|
||||
((dt->dt_wday % 4) << PCF8583_WKDY_SHIFT);
|
||||
bcd[8] = dt->dt_year % 100;
|
||||
bcd[9] = dt->dt_year / 100;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: r2025.c,v 1.6 2009/12/12 14:44:10 tsutsui Exp $ */
|
||||
/* $NetBSD: r2025.c,v 1.7 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Shigeyuki Fukushima.
|
||||
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: r2025.c,v 1.6 2009/12/12 14:44:10 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: r2025.c,v 1.7 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -125,9 +125,9 @@ r2025rtc_gettime(struct todr_chip_handle *ch, struct timeval *tv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
dt.dt_sec = FROMBCD(bcd[R2025_REG_SEC] & R2025_REG_SEC_MASK);
|
||||
dt.dt_min = FROMBCD(bcd[R2025_REG_MIN] & R2025_REG_MIN_MASK);
|
||||
hour = FROMBCD(bcd[R2025_REG_HOUR] & R2025_REG_HOUR_MASK);
|
||||
dt.dt_sec = bcdtobin(bcd[R2025_REG_SEC] & R2025_REG_SEC_MASK);
|
||||
dt.dt_min = bcdtobin(bcd[R2025_REG_MIN] & R2025_REG_MIN_MASK);
|
||||
hour = bcdtobin(bcd[R2025_REG_HOUR] & R2025_REG_HOUR_MASK);
|
||||
if (rctrl & R2025_REG_CTRL1_H1224) {
|
||||
dt.dt_hour = hour;
|
||||
} else {
|
||||
@ -141,10 +141,10 @@ r2025rtc_gettime(struct todr_chip_handle *ch, struct timeval *tv)
|
||||
dt.dt_hour = hour;
|
||||
}
|
||||
}
|
||||
dt.dt_wday = FROMBCD(bcd[R2025_REG_WDAY] & R2025_REG_WDAY_MASK);
|
||||
dt.dt_day = FROMBCD(bcd[R2025_REG_DAY] & R2025_REG_DAY_MASK);
|
||||
dt.dt_mon = FROMBCD(bcd[R2025_REG_MON] & R2025_REG_MON_MASK);
|
||||
dt.dt_year = FROMBCD(bcd[R2025_REG_YEAR] & R2025_REG_YEAR_MASK)
|
||||
dt.dt_wday = bcdtobin(bcd[R2025_REG_WDAY] & R2025_REG_WDAY_MASK);
|
||||
dt.dt_day = bcdtobin(bcd[R2025_REG_DAY] & R2025_REG_DAY_MASK);
|
||||
dt.dt_mon = bcdtobin(bcd[R2025_REG_MON] & R2025_REG_MON_MASK);
|
||||
dt.dt_year = bcdtobin(bcd[R2025_REG_YEAR] & R2025_REG_YEAR_MASK)
|
||||
+ ((bcd[R2025_REG_MON] & R2025_REG_MON_Y1920) ? 2000 : 1900);
|
||||
|
||||
tv->tv_sec = clock_ymdhms_to_secs(&dt);
|
||||
@ -179,14 +179,14 @@ r2025rtc_settime(struct todr_chip_handle *ch, struct timeval *tv)
|
||||
rctrl |= R2025_REG_CTRL1_H1224;
|
||||
|
||||
/* setup registers 0x00-0x06 (7 byte) */
|
||||
bcd[R2025_REG_SEC] = TOBCD(dt.dt_sec) & R2025_REG_SEC_MASK;
|
||||
bcd[R2025_REG_MIN] = TOBCD(dt.dt_min) & R2025_REG_MIN_MASK;
|
||||
bcd[R2025_REG_HOUR] = TOBCD(dt.dt_hour) & R2025_REG_HOUR_MASK;
|
||||
bcd[R2025_REG_WDAY] = TOBCD(dt.dt_wday) & R2025_REG_WDAY_MASK;
|
||||
bcd[R2025_REG_DAY] = TOBCD(dt.dt_day) & R2025_REG_DAY_MASK;
|
||||
bcd[R2025_REG_MON] = (TOBCD(dt.dt_mon) & R2025_REG_MON_MASK)
|
||||
bcd[R2025_REG_SEC] = bintobcd(dt.dt_sec) & R2025_REG_SEC_MASK;
|
||||
bcd[R2025_REG_MIN] = bintobcd(dt.dt_min) & R2025_REG_MIN_MASK;
|
||||
bcd[R2025_REG_HOUR] = bintobcd(dt.dt_hour) & R2025_REG_HOUR_MASK;
|
||||
bcd[R2025_REG_WDAY] = bintobcd(dt.dt_wday) & R2025_REG_WDAY_MASK;
|
||||
bcd[R2025_REG_DAY] = bintobcd(dt.dt_day) & R2025_REG_DAY_MASK;
|
||||
bcd[R2025_REG_MON] = (bintobcd(dt.dt_mon) & R2025_REG_MON_MASK)
|
||||
| ((dt.dt_year >= 2000) ? R2025_REG_MON_Y1920 : 0);
|
||||
bcd[R2025_REG_YEAR] = TOBCD(dt.dt_year % 100) & R2025_REG_YEAR_MASK;
|
||||
bcd[R2025_REG_YEAR] = bintobcd(dt.dt_year % 100) & R2025_REG_YEAR_MASK;
|
||||
|
||||
/* Write RTC register */
|
||||
if (r2025rtc_reg_write(sc, R2025_REG_CTRL1, &rctrl, 1) != 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rs5c372.c,v 1.13 2014/06/29 04:04:02 tsutsui Exp $ */
|
||||
/* $NetBSD: rs5c372.c,v 1.14 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 2005 NONAKA Kimihiro <nonaka@netbsd.org>
|
||||
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.13 2014/06/29 04:04:02 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.14 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -175,12 +175,12 @@ rs5c372rtc_clock_read(struct rs5c372rtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the RS5C372's register values into something useable
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[RS5C372_SECONDS] & RS5C372_SECONDS_MASK);
|
||||
dt->dt_min = FROMBCD(bcd[RS5C372_MINUTES] & RS5C372_MINUTES_MASK);
|
||||
dt->dt_hour = FROMBCD(bcd[RS5C372_HOURS] & RS5C372_HOURS_24MASK);
|
||||
dt->dt_day = FROMBCD(bcd[RS5C372_DATE] & RS5C372_DATE_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[RS5C372_MONTH] & RS5C372_MONTH_MASK);
|
||||
dt->dt_year = FROMBCD(bcd[RS5C372_YEAR]) + 2000;
|
||||
dt->dt_sec = bcdtobin(bcd[RS5C372_SECONDS] & RS5C372_SECONDS_MASK);
|
||||
dt->dt_min = bcdtobin(bcd[RS5C372_MINUTES] & RS5C372_MINUTES_MASK);
|
||||
dt->dt_hour = bcdtobin(bcd[RS5C372_HOURS] & RS5C372_HOURS_24MASK);
|
||||
dt->dt_day = bcdtobin(bcd[RS5C372_DATE] & RS5C372_DATE_MASK);
|
||||
dt->dt_mon = bcdtobin(bcd[RS5C372_MONTH] & RS5C372_MONTH_MASK);
|
||||
dt->dt_year = bcdtobin(bcd[RS5C372_YEAR]) + 2000;
|
||||
|
||||
return (1);
|
||||
}
|
||||
@ -195,13 +195,13 @@ rs5c372rtc_clock_write(struct rs5c372rtc_softc *sc, struct clock_ymdhms *dt)
|
||||
* Convert our time representation into something the RS5C372
|
||||
* can understand.
|
||||
*/
|
||||
bcd[RS5C372_SECONDS] = TOBCD(dt->dt_sec);
|
||||
bcd[RS5C372_MINUTES] = TOBCD(dt->dt_min);
|
||||
bcd[RS5C372_HOURS] = TOBCD(dt->dt_hour);
|
||||
bcd[RS5C372_DATE] = TOBCD(dt->dt_day);
|
||||
bcd[RS5C372_DAY] = TOBCD(dt->dt_wday);
|
||||
bcd[RS5C372_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[RS5C372_YEAR] = TOBCD(dt->dt_year % 100);
|
||||
bcd[RS5C372_SECONDS] = bintobcd(dt->dt_sec);
|
||||
bcd[RS5C372_MINUTES] = bintobcd(dt->dt_min);
|
||||
bcd[RS5C372_HOURS] = bintobcd(dt->dt_hour);
|
||||
bcd[RS5C372_DATE] = bintobcd(dt->dt_day);
|
||||
bcd[RS5C372_DAY] = bintobcd(dt->dt_wday);
|
||||
bcd[RS5C372_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[RS5C372_YEAR] = bintobcd(dt->dt_year % 100);
|
||||
|
||||
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
|
||||
aprint_error_dev(sc->sc_dev, "rs5c372rtc_clock_write: failed to "
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: s390.c,v 1.2 2011/05/28 13:59:31 phx Exp $ */
|
||||
/* $NetBSD: s390.c,v 1.3 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Frank Wille.
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.2 2011/05/28 13:59:31 phx Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.3 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -160,12 +160,12 @@ s390rtc_clock_read(struct s390rtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the register values into something useable.
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[S390_RT1_SECOND]);
|
||||
dt->dt_min = FROMBCD(bcd[S390_RT1_MINUTE]);
|
||||
dt->dt_hour = FROMBCD(bcd[S390_RT1_HOUR] & 0x3f);
|
||||
dt->dt_day = FROMBCD(bcd[S390_RT1_DAY]);
|
||||
dt->dt_mon = FROMBCD(bcd[S390_RT1_MONTH]);
|
||||
dt->dt_year = FROMBCD(bcd[S390_RT1_YEAR]) + 2000;
|
||||
dt->dt_sec = bcdtobin(bcd[S390_RT1_SECOND]);
|
||||
dt->dt_min = bcdtobin(bcd[S390_RT1_MINUTE]);
|
||||
dt->dt_hour = bcdtobin(bcd[S390_RT1_HOUR] & 0x3f);
|
||||
dt->dt_day = bcdtobin(bcd[S390_RT1_DAY]);
|
||||
dt->dt_mon = bcdtobin(bcd[S390_RT1_MONTH]);
|
||||
dt->dt_year = bcdtobin(bcd[S390_RT1_YEAR]) + 2000;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -179,13 +179,13 @@ s390rtc_clock_write(struct s390rtc_softc *sc, struct clock_ymdhms *dt)
|
||||
* Convert our time representation into something the S-xx390
|
||||
* can understand.
|
||||
*/
|
||||
bcd[S390_RT1_SECOND] = TOBCD(dt->dt_sec);
|
||||
bcd[S390_RT1_MINUTE] = TOBCD(dt->dt_min);
|
||||
bcd[S390_RT1_HOUR] = TOBCD(dt->dt_hour);
|
||||
bcd[S390_RT1_DAY] = TOBCD(dt->dt_day);
|
||||
bcd[S390_RT1_WDAY] = TOBCD(dt->dt_wday);
|
||||
bcd[S390_RT1_MONTH] = TOBCD(dt->dt_mon);
|
||||
bcd[S390_RT1_YEAR] = TOBCD(dt->dt_year % 100);
|
||||
bcd[S390_RT1_SECOND] = bintobcd(dt->dt_sec);
|
||||
bcd[S390_RT1_MINUTE] = bintobcd(dt->dt_min);
|
||||
bcd[S390_RT1_HOUR] = bintobcd(dt->dt_hour);
|
||||
bcd[S390_RT1_DAY] = bintobcd(dt->dt_day);
|
||||
bcd[S390_RT1_WDAY] = bintobcd(dt->dt_wday);
|
||||
bcd[S390_RT1_MONTH] = bintobcd(dt->dt_mon);
|
||||
bcd[S390_RT1_YEAR] = bintobcd(dt->dt_year % 100);
|
||||
|
||||
return s390rtc_write(sc, S390_REALTIME1, bcd, S390_RT1_NBYTES);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tps65950.c,v 1.4 2014/02/25 18:30:09 pooka Exp $ */
|
||||
/* $NetBSD: tps65950.c,v 1.5 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2012 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tps65950.c,v 1.4 2014/02/25 18:30:09 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tps65950.c,v 1.5 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -361,13 +361,13 @@ tps65950_rtc_gettime(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
RTC_READ(TPS65950_ID4_REG_WEEKS_REG, weeks_reg);
|
||||
iic_release_bus(sc->sc_i2c, 0);
|
||||
|
||||
dt->dt_sec = FROMBCD(seconds_reg);
|
||||
dt->dt_min = FROMBCD(minutes_reg);
|
||||
dt->dt_hour = FROMBCD(hours_reg);
|
||||
dt->dt_day = FROMBCD(days_reg);
|
||||
dt->dt_mon = FROMBCD(months_reg);
|
||||
dt->dt_year = FROMBCD(years_reg) + 2000;
|
||||
dt->dt_wday = FROMBCD(weeks_reg);
|
||||
dt->dt_sec = bcdtobin(seconds_reg);
|
||||
dt->dt_min = bcdtobin(minutes_reg);
|
||||
dt->dt_hour = bcdtobin(hours_reg);
|
||||
dt->dt_day = bcdtobin(days_reg);
|
||||
dt->dt_mon = bcdtobin(months_reg);
|
||||
dt->dt_year = bcdtobin(years_reg) + 2000;
|
||||
dt->dt_wday = bcdtobin(weeks_reg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -380,13 +380,13 @@ tps65950_rtc_settime(todr_chip_handle_t tch, struct clock_ymdhms *dt)
|
||||
|
||||
iic_acquire_bus(sc->sc_i2c, 0);
|
||||
tps65950_rtc_enable(sc, false);
|
||||
RTC_WRITE(TPS65950_ID4_REG_SECONDS_REG, TOBCD(dt->dt_sec));
|
||||
RTC_WRITE(TPS65950_ID4_REG_MINUTES_REG, TOBCD(dt->dt_min));
|
||||
RTC_WRITE(TPS65950_ID4_REG_HOURS_REG, TOBCD(dt->dt_hour));
|
||||
RTC_WRITE(TPS65950_ID4_REG_DAYS_REG, TOBCD(dt->dt_day));
|
||||
RTC_WRITE(TPS65950_ID4_REG_MONTHS_REG, TOBCD(dt->dt_mon));
|
||||
RTC_WRITE(TPS65950_ID4_REG_YEARS_REG, TOBCD(dt->dt_year % 100));
|
||||
RTC_WRITE(TPS65950_ID4_REG_WEEKS_REG, TOBCD(dt->dt_wday));
|
||||
RTC_WRITE(TPS65950_ID4_REG_SECONDS_REG, bintobcd(dt->dt_sec));
|
||||
RTC_WRITE(TPS65950_ID4_REG_MINUTES_REG, bintobcd(dt->dt_min));
|
||||
RTC_WRITE(TPS65950_ID4_REG_HOURS_REG, bintobcd(dt->dt_hour));
|
||||
RTC_WRITE(TPS65950_ID4_REG_DAYS_REG, bintobcd(dt->dt_day));
|
||||
RTC_WRITE(TPS65950_ID4_REG_MONTHS_REG, bintobcd(dt->dt_mon));
|
||||
RTC_WRITE(TPS65950_ID4_REG_YEARS_REG, bintobcd(dt->dt_year % 100));
|
||||
RTC_WRITE(TPS65950_ID4_REG_WEEKS_REG, bintobcd(dt->dt_wday));
|
||||
tps65950_rtc_enable(sc, true);
|
||||
iic_release_bus(sc->sc_i2c, 0);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: x1226.c,v 1.18 2014/08/04 23:28:19 joerg Exp $ */
|
||||
/* $NetBSD: x1226.c,v 1.19 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Shigeyuki Fukushima.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: x1226.c,v 1.18 2014/08/04 23:28:19 joerg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: x1226.c,v 1.19 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -317,29 +317,29 @@ xrtc_clock_read(struct xrtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert the X1226's register bcd values
|
||||
*/
|
||||
dt->dt_sec = FROMBCD(bcd[X1226_REG_SC - X1226_REG_RTC_BASE]
|
||||
dt->dt_sec = bcdtobin(bcd[X1226_REG_SC - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_SC_MASK);
|
||||
dt->dt_min = FROMBCD(bcd[X1226_REG_MN - X1226_REG_RTC_BASE]
|
||||
dt->dt_min = bcdtobin(bcd[X1226_REG_MN - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_MN_MASK);
|
||||
if (!(bcd[X1226_REG_HR - X1226_REG_RTC_BASE] & X1226_FLAG_HR_24H)) {
|
||||
dt->dt_hour = FROMBCD(bcd[X1226_REG_HR - X1226_REG_RTC_BASE]
|
||||
dt->dt_hour = bcdtobin(bcd[X1226_REG_HR - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_HR12_MASK);
|
||||
if (bcd[X1226_REG_HR - X1226_REG_RTC_BASE] & X1226_FLAG_HR_12HPM) {
|
||||
dt->dt_hour += 12;
|
||||
}
|
||||
} else {
|
||||
dt->dt_hour = FROMBCD(bcd[X1226_REG_HR - X1226_REG_RTC_BASE]
|
||||
dt->dt_hour = bcdtobin(bcd[X1226_REG_HR - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_HR24_MASK);
|
||||
}
|
||||
dt->dt_wday = FROMBCD(bcd[X1226_REG_DW - X1226_REG_RTC_BASE]
|
||||
dt->dt_wday = bcdtobin(bcd[X1226_REG_DW - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_DT_MASK);
|
||||
dt->dt_day = FROMBCD(bcd[X1226_REG_DT - X1226_REG_RTC_BASE]
|
||||
dt->dt_day = bcdtobin(bcd[X1226_REG_DT - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_DT_MASK);
|
||||
dt->dt_mon = FROMBCD(bcd[X1226_REG_MO - X1226_REG_RTC_BASE]
|
||||
dt->dt_mon = bcdtobin(bcd[X1226_REG_MO - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_MO_MASK);
|
||||
dt->dt_year = FROMBCD(bcd[X1226_REG_YR - X1226_REG_RTC_BASE]
|
||||
dt->dt_year = bcdtobin(bcd[X1226_REG_YR - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_YR_MASK);
|
||||
dt->dt_year += FROMBCD(bcd[X1226_REG_Y2K - X1226_REG_RTC_BASE]
|
||||
dt->dt_year += bcdtobin(bcd[X1226_REG_Y2K - X1226_REG_RTC_BASE]
|
||||
& X1226_REG_Y2K_MASK) * 100;
|
||||
|
||||
return (1);
|
||||
@ -354,15 +354,15 @@ xrtc_clock_write(struct xrtc_softc *sc, struct clock_ymdhms *dt)
|
||||
/*
|
||||
* Convert our time to bcd values
|
||||
*/
|
||||
bcd[X1226_REG_SC - X1226_REG_RTC_BASE] = TOBCD(dt->dt_sec);
|
||||
bcd[X1226_REG_MN - X1226_REG_RTC_BASE] = TOBCD(dt->dt_min);
|
||||
bcd[X1226_REG_HR - X1226_REG_RTC_BASE] = TOBCD(dt->dt_hour)
|
||||
bcd[X1226_REG_SC - X1226_REG_RTC_BASE] = bintobcd(dt->dt_sec);
|
||||
bcd[X1226_REG_MN - X1226_REG_RTC_BASE] = bintobcd(dt->dt_min);
|
||||
bcd[X1226_REG_HR - X1226_REG_RTC_BASE] = bintobcd(dt->dt_hour)
|
||||
| X1226_FLAG_HR_24H;
|
||||
bcd[X1226_REG_DW - X1226_REG_RTC_BASE] = TOBCD(dt->dt_wday);
|
||||
bcd[X1226_REG_DT - X1226_REG_RTC_BASE] = TOBCD(dt->dt_day);
|
||||
bcd[X1226_REG_MO - X1226_REG_RTC_BASE] = TOBCD(dt->dt_mon);
|
||||
bcd[X1226_REG_YR - X1226_REG_RTC_BASE] = TOBCD(dt->dt_year % 100);
|
||||
bcd[X1226_REG_Y2K - X1226_REG_RTC_BASE] = TOBCD(dt->dt_year / 100);
|
||||
bcd[X1226_REG_DW - X1226_REG_RTC_BASE] = bintobcd(dt->dt_wday);
|
||||
bcd[X1226_REG_DT - X1226_REG_RTC_BASE] = bintobcd(dt->dt_day);
|
||||
bcd[X1226_REG_MO - X1226_REG_RTC_BASE] = bintobcd(dt->dt_mon);
|
||||
bcd[X1226_REG_YR - X1226_REG_RTC_BASE] = bintobcd(dt->dt_year % 100);
|
||||
bcd[X1226_REG_Y2K - X1226_REG_RTC_BASE] = bintobcd(dt->dt_year / 100);
|
||||
|
||||
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
|
||||
aprint_error_dev(sc->sc_dev,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mc146818.c,v 1.18 2008/12/13 17:32:53 tsutsui Exp $ */
|
||||
/* $NetBSD: mc146818.c,v 1.19 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 Izumi Tsutsui. All rights reserved.
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.18 2008/12/13 17:32:53 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.19 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -97,7 +97,7 @@ mc146818_gettime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
}
|
||||
}
|
||||
|
||||
#define FROMREG(x) ((sc->sc_flag & MC146818_BCD) ? FROMBCD(x) : (x))
|
||||
#define FROMREG(x) ((sc->sc_flag & MC146818_BCD) ? bcdtobin(x) : (x))
|
||||
|
||||
dt->dt_sec = FROMREG((*sc->sc_mcread)(sc, MC_SEC));
|
||||
dt->dt_min = FROMREG((*sc->sc_mcread)(sc, MC_MIN));
|
||||
@ -150,7 +150,7 @@ mc146818_settime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
(*sc->sc_mcwrite)(sc, MC_REGB,
|
||||
(*sc->sc_mcread)(sc, MC_REGB) | MC_REGB_SET);
|
||||
|
||||
#define TOREG(x) ((sc->sc_flag & MC146818_BCD) ? TOBCD(x) : (x))
|
||||
#define TOREG(x) ((sc->sc_flag & MC146818_BCD) ? bintobcd(x) : (x))
|
||||
|
||||
(*sc->sc_mcwrite)(sc, MC_SEC, TOREG(dt->dt_sec));
|
||||
(*sc->sc_mcwrite)(sc, MC_MIN, TOREG(dt->dt_min));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mk48txx.c,v 1.26 2011/01/04 01:28:15 matt Exp $ */
|
||||
/* $NetBSD: mk48txx.c,v 1.27 2014/11/20 16:34:26 christos Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mk48txx.c,v 1.26 2011/01/04 01:28:15 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mk48txx.c,v 1.27 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -120,16 +120,16 @@ mk48txx_gettime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
csr |= MK48TXX_CSR_READ;
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_ICSR, csr);
|
||||
|
||||
dt->dt_sec = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_ISEC));
|
||||
dt->dt_min = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IMIN));
|
||||
dt->dt_hour = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IHOUR));
|
||||
dt->dt_day = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IDAY));
|
||||
dt->dt_wday = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IWDAY));
|
||||
dt->dt_mon = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IMON));
|
||||
year = FROMBCD((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IYEAR));
|
||||
dt->dt_sec = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_ISEC));
|
||||
dt->dt_min = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IMIN));
|
||||
dt->dt_hour = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IHOUR));
|
||||
dt->dt_day = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IDAY));
|
||||
dt->dt_wday = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IWDAY));
|
||||
dt->dt_mon = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IMON));
|
||||
year = bcdtobin((*sc->sc_nvrd)(sc, clkoff + MK48TXX_IYEAR));
|
||||
|
||||
if (sc->sc_flag & MK48TXX_HAVE_CENT_REG) {
|
||||
year += 100*FROMBCD(csr & MK48TXX_CSR_CENT_MASK);
|
||||
year += 100*bcdtobin(csr & MK48TXX_CSR_CENT_MASK);
|
||||
} else {
|
||||
year += sc->sc_year0;
|
||||
if (year < POSIX_BASE_YEAR &&
|
||||
@ -181,22 +181,22 @@ mk48txx_settime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
csr |= MK48TXX_CSR_WRITE;
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_ICSR, csr);
|
||||
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_ISEC, TOBCD(dt->dt_sec));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IMIN, TOBCD(dt->dt_min));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IHOUR, TOBCD(dt->dt_hour));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IWDAY, TOBCD(dt->dt_wday));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IDAY, TOBCD(dt->dt_day));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IMON, TOBCD(dt->dt_mon));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IYEAR, TOBCD(year));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_ISEC, bintobcd(dt->dt_sec));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IMIN, bintobcd(dt->dt_min));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IHOUR, bintobcd(dt->dt_hour));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IWDAY, bintobcd(dt->dt_wday));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IDAY, bintobcd(dt->dt_day));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IMON, bintobcd(dt->dt_mon));
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_IYEAR, bintobcd(year));
|
||||
|
||||
/*
|
||||
* If we have a century register and the century has changed
|
||||
* update it.
|
||||
*/
|
||||
if ((sc->sc_flag & MK48TXX_HAVE_CENT_REG)
|
||||
&& (csr & MK48TXX_CSR_CENT_MASK) != TOBCD(cent)) {
|
||||
&& (csr & MK48TXX_CSR_CENT_MASK) != bintobcd(cent)) {
|
||||
csr &= ~MK48TXX_CSR_CENT_MASK;
|
||||
csr |= MK48TXX_CSR_CENT_MASK & TOBCD(cent);
|
||||
csr |= MK48TXX_CSR_CENT_MASK & bintobcd(cent);
|
||||
(*sc->sc_nvwr)(sc, clkoff + MK48TXX_ICSR, csr);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mm58167.c,v 1.15 2013/07/25 04:21:47 msaitoh Exp $ */
|
||||
/* $NetBSD: mm58167.c,v 1.16 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -34,7 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mm58167.c,v 1.15 2013/07/25 04:21:47 msaitoh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mm58167.c,v 1.16 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
@ -104,7 +104,7 @@ mm58167_gettime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
do {
|
||||
#define _MM58167_GET(dt_f, mm_f) \
|
||||
byte_value = mm58167_read(sc, mm_f); \
|
||||
dt->dt_f = FROMBCD(byte_value)
|
||||
dt->dt_f = bcdtobin(byte_value)
|
||||
|
||||
_MM58167_GET(dt_mon, mm58167_mon);
|
||||
_MM58167_GET(dt_day, mm58167_day);
|
||||
@ -246,7 +246,7 @@ mm58167_settime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
|
||||
/* Load everything. */
|
||||
#define _MM58167_PUT(dt_f, mm_f) \
|
||||
byte_value = TOBCD(dt->dt_f); \
|
||||
byte_value = bintobcd(dt->dt_f); \
|
||||
mm58167_write(sc, mm_f, byte_value)
|
||||
|
||||
_MM58167_PUT(dt_mon, mm58167_mon);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rs5c313.c,v 1.9 2010/04/06 15:29:19 nonaka Exp $ */
|
||||
/* $NetBSD: rs5c313.c,v 1.10 2014/11/20 16:34:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rs5c313.c,v 1.9 2010/04/06 15:29:19 nonaka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rs5c313.c,v 1.10 2014/11/20 16:34:26 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -229,7 +229,7 @@ rs5c313_todr_settime_ymdhms(todr_chip_handle_t todr, struct clock_ymdhms *dt)
|
||||
|
||||
#define RTCSET(x, y) \
|
||||
do { \
|
||||
t = TOBCD(dt->dt_ ## y) & 0xff; \
|
||||
t = bintobcd(dt->dt_ ## y) & 0xff; \
|
||||
rs5c313_write_reg(sc, RS5C313_ ## x ## 1, t & 0x0f); \
|
||||
rs5c313_write_reg(sc, RS5C313_ ## x ## 10, (t >> 4) & 0x0f); \
|
||||
} while (/* CONSTCOND */0)
|
||||
@ -243,7 +243,7 @@ rs5c313_todr_settime_ymdhms(todr_chip_handle_t todr, struct clock_ymdhms *dt)
|
||||
#undef RTCSET
|
||||
|
||||
t = dt->dt_year % 100;
|
||||
t = TOBCD(t);
|
||||
t = bintobcd(t);
|
||||
rs5c313_write_reg(sc, RS5C313_YEAR1, t & 0x0f);
|
||||
rs5c313_write_reg(sc, RS5C313_YEAR10, (t >> 4) & 0x0f);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user