Update to new friendlier todr entry points. While here, ANSIfy.
This commit is contained in:
parent
a3925b6374
commit
1a001de39f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: intersil7170.c,v 1.6 2006/09/04 23:45:30 gdamore Exp $ */
|
||||
/* $NetBSD: intersil7170.c,v 1.7 2006/09/07 05:09:29 gdamore Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: intersil7170.c,v 1.6 2006/09/04 23:45:30 gdamore Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: intersil7170.c,v 1.7 2006/09/07 05:09:29 gdamore Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
@ -61,16 +61,13 @@ struct intersil7170_softc {
|
||||
int sil_year0;
|
||||
};
|
||||
|
||||
int intersil7170_gettime(todr_chip_handle_t, volatile struct timeval *);
|
||||
int intersil7170_settime(todr_chip_handle_t, volatile struct timeval *);
|
||||
int intersil7170_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
|
||||
int intersil7170_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
|
||||
|
||||
int intersil7170_auto_century_adjust = 1;
|
||||
|
||||
todr_chip_handle_t
|
||||
intersil7170_attach(bt, bh, year0)
|
||||
bus_space_tag_t bt;
|
||||
bus_space_handle_t bh;
|
||||
int year0;
|
||||
intersil7170_attach(bus_space_tag_t bt, bus_space_handle_t bh, int year0)
|
||||
{
|
||||
todr_chip_handle_t handle;
|
||||
struct intersil7170_softc *sil;
|
||||
@ -83,8 +80,11 @@ intersil7170_attach(bt, bh, year0)
|
||||
sil = (struct intersil7170_softc *)((u_long)handle +
|
||||
ALIGN(sizeof(struct todr_chip_handle)));
|
||||
handle->cookie = sil;
|
||||
handle->todr_gettime = intersil7170_gettime;
|
||||
handle->todr_settime = intersil7170_settime;
|
||||
handle->todr_gettime = NULL;
|
||||
handle->todr_settime = NULL;
|
||||
handle->todr_setwen = NULL;
|
||||
handle->todr_gettime_ymdhms = intersil7170_gettime_ymdhms;
|
||||
handle->todr_settime_ymdhms = intersil7170_settime_ymdhms;
|
||||
sil->sil_bt = bt;
|
||||
sil->sil_bh = bh;
|
||||
sil->sil_year0 = year0;
|
||||
@ -96,14 +96,11 @@ intersil7170_attach(bt, bh, year0)
|
||||
* Set up the system's time, given a `reasonable' time value.
|
||||
*/
|
||||
int
|
||||
intersil7170_gettime(handle, tv)
|
||||
todr_chip_handle_t handle;
|
||||
volatile struct timeval *tv;
|
||||
intersil7170_gettime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
{
|
||||
struct intersil7170_softc *sil = handle->cookie;
|
||||
bus_space_tag_t bt = sil->sil_bt;
|
||||
bus_space_handle_t bh = sil->sil_bh;
|
||||
struct clock_ymdhms dt;
|
||||
u_int8_t cmd;
|
||||
int year;
|
||||
int s;
|
||||
@ -117,13 +114,13 @@ intersil7170_gettime(handle, tv)
|
||||
|
||||
/* The order of reading out the clock elements is important */
|
||||
bus_space_read_1(bt, bh, INTERSIL_ICSEC); /* not used */
|
||||
dt.dt_hour = bus_space_read_1(bt, bh, INTERSIL_IHOUR);
|
||||
dt.dt_min = bus_space_read_1(bt, bh, INTERSIL_IMIN);
|
||||
dt.dt_sec = bus_space_read_1(bt, bh, INTERSIL_ISEC);
|
||||
dt.dt_mon = bus_space_read_1(bt, bh, INTERSIL_IMON);
|
||||
dt.dt_day = bus_space_read_1(bt, bh, INTERSIL_IDAY);
|
||||
dt->dt_hour = bus_space_read_1(bt, bh, INTERSIL_IHOUR);
|
||||
dt->dt_min = bus_space_read_1(bt, bh, INTERSIL_IMIN);
|
||||
dt->dt_sec = bus_space_read_1(bt, bh, INTERSIL_ISEC);
|
||||
dt->dt_mon = bus_space_read_1(bt, bh, INTERSIL_IMON);
|
||||
dt->dt_day = bus_space_read_1(bt, bh, INTERSIL_IDAY);
|
||||
year = bus_space_read_1(bt, bh, INTERSIL_IYEAR);
|
||||
dt.dt_wday = bus_space_read_1(bt, bh, INTERSIL_IDOW);
|
||||
dt->dt_wday = bus_space_read_1(bt, bh, INTERSIL_IDOW);
|
||||
|
||||
/* Done writing (time wears on) */
|
||||
cmd = intersil_command(INTERSIL_CMD_RUN, INTERSIL_CMD_IENABLE);
|
||||
@ -134,10 +131,8 @@ intersil7170_gettime(handle, tv)
|
||||
if (year < 1970 && intersil7170_auto_century_adjust != 0)
|
||||
year += 100;
|
||||
|
||||
dt.dt_year = year;
|
||||
dt->dt_year = year;
|
||||
|
||||
tv->tv_sec = clock_ymdhms_to_secs(&dt);
|
||||
tv->tv_usec = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -145,23 +140,16 @@ intersil7170_gettime(handle, tv)
|
||||
* Reset the clock based on the current time.
|
||||
*/
|
||||
int
|
||||
intersil7170_settime(handle, tv)
|
||||
todr_chip_handle_t handle;
|
||||
volatile struct timeval *tv;
|
||||
intersil7170_settime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
|
||||
{
|
||||
struct intersil7170_softc *sil = handle->cookie;
|
||||
bus_space_tag_t bt = sil->sil_bt;
|
||||
bus_space_handle_t bh = sil->sil_bh;
|
||||
struct clock_ymdhms dt;
|
||||
u_int8_t cmd;
|
||||
int year;
|
||||
long sec;
|
||||
int s;
|
||||
|
||||
sec = tv->tv_sec + ((tv->tv_usec < 500000) ? 0 : 1);
|
||||
clock_secs_to_ymdhms(sec, &dt);
|
||||
|
||||
year = dt.dt_year - sil->sil_year0;
|
||||
year = dt->dt_year - sil->sil_year0;
|
||||
if (year > 99 && intersil7170_auto_century_adjust != 0)
|
||||
year -= 100;
|
||||
|
||||
@ -174,13 +162,13 @@ intersil7170_settime(handle, tv)
|
||||
|
||||
/* The order of reading writing the clock elements is important */
|
||||
bus_space_write_1(bt, bh, INTERSIL_ICSEC, 0);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IHOUR, dt.dt_hour);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IMIN, dt.dt_min);
|
||||
bus_space_write_1(bt, bh, INTERSIL_ISEC, dt.dt_sec);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IMON, dt.dt_mon);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IDAY, dt.dt_day);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IHOUR, dt->dt_hour);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IMIN, dt->dt_min);
|
||||
bus_space_write_1(bt, bh, INTERSIL_ISEC, dt->dt_sec);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IMON, dt->dt_mon);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IDAY, dt->dt_day);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IYEAR, year);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IDOW, dt.dt_wday);
|
||||
bus_space_write_1(bt, bh, INTERSIL_IDOW, dt->dt_wday);
|
||||
|
||||
/* Done writing (time wears on) */
|
||||
cmd = intersil_command(INTERSIL_CMD_RUN, INTERSIL_CMD_IENABLE);
|
||||
|
Loading…
Reference in New Issue
Block a user