Annotation of funnyos/arch/testarm/dev/tartc.c, Revision 1.2
1.1 init 1: /*
1.2 ! init 2: * $Id: tartc.c,v 1.1.1.1 2007/10/16 08:41:04 init Exp $
1.1 init 3: */
4: #include <sys/types.h>
5: #include <sys/device.h>
1.2 ! init 6: #include <sys/bus.h>
! 7:
! 8: #include <arch/testarm/dev/tartcvar.h>
! 9: #include <arch/testarm/dev/tartcreg.h>
1.1 init 10: #include <libkern/printf.h>
11:
12: /*
13: * testarm Real Time Clock driver.
14: */
1.2 ! init 15: int tartc_attach(struct device *, uint32_t loc, uint8_t flags);
! 16:
! 17:
! 18: struct driver tartc_dr = {
! 19: sizeof(struct tartc_dd),
! 20: tartc_attach,
! 21: NULL
! 22: };
1.1 init 23:
24:
25: int
1.2 ! init 26: tartc_attach(struct device *self, uint32_t loc, uint8_t flags)
1.1 init 27: {
1.2 ! init 28: struct tartc_dd *ddp = self->dv_devdata;
! 29: uint32_t seconds;
1.1 init 30:
1.2 ! init 31: /* acquire bus_handle from parent */
! 32: ddp->td_bushandlep = self->dv_parent->dv_aux;
! 33:
! 34: /* save our location on parent (or use default if loc == 0) */
! 35: ddp->td_ioaddr = (loc != 0) ? loc : TARTC_REG_BASE;
! 36:
! 37: /*
! 38: * Read seconds past Epoch.
! 39: */
! 40: /* trigger clock update on host */
! 41: bus_write_1(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_CLOCKUPDATE, 1);
! 42:
! 43: /* get seconds past Epoch */
! 44: seconds = bus_read_4(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_READSECONDS);
! 45:
! 46: printf("testarm Real Time Clock (%d seconds past Epoch)\n", seconds);
1.1 init 47:
48: return(0);
49:
50: }
51:
CVSweb