[BACK]Return to tartc.c CVS log [TXT][DIR] Up to [local] / funnyos / arch / testarm / dev

Annotation of funnyos/arch/testarm/dev/tartc.c, Revision 1.4

1.1       init        1: /*
1.4     ! init        2:  * $Id: tartc.c,v 1.3 2007/10/29 21:10:03 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);
1.3       init       16: void   tartc_interrupt(struct device *);
1.2       init       17:
                     18:
                     19: struct driver tartc_dr = {
                     20:        sizeof(struct tartc_dd),
                     21:        tartc_attach,
1.3       init       22:        NULL,
                     23:        tartc_interrupt
1.2       init       24: };
1.1       init       25:
                     26:
                     27: int
1.2       init       28: tartc_attach(struct device *self, uint32_t loc, uint8_t flags)
1.1       init       29: {
1.2       init       30:        struct tartc_dd *ddp = self->dv_devdata;
                     31:        uint32_t seconds;
1.1       init       32:
1.2       init       33:        /* acquire bus_handle from parent */
                     34:        ddp->td_bushandlep = self->dv_parent->dv_aux;
                     35:
                     36:        /* save our location on parent (or use default if loc == 0) */
                     37:        ddp->td_ioaddr = (loc != 0) ? loc : TARTC_REG_BASE;
                     38:
                     39:        /*
                     40:         * Read seconds past Epoch.
                     41:         */
                     42:        /* trigger clock update on host */
                     43:        bus_write_1(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_CLOCKUPDATE, 1);
                     44:
                     45:        /* get seconds past Epoch */
                     46:        seconds = bus_read_4(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_READSECONDS);
                     47:
                     48:        printf("testarm Real Time Clock (%d seconds past Epoch)\n", seconds);
1.1       init       49:
1.4     ! init       50:        /* XXX set timer */
        !            51:        bus_write_1(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_TMRINTRFREQ, 1);
        !            52:
1.1       init       53:        return(0);
1.3       init       54:
                     55: }
                     56:
                     57:
                     58: void
                     59: tartc_interrupt(struct device *self)
                     60: {
                     61:        /* TODO */
1.4     ! init       62:        struct tartc_dd *ddp = self->dv_devdata;
        !            63:
        !            64:        /* acknowledge one timer intr */
        !            65:        bus_write_1(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_TMRINTRACK, 0xff);
        !            66:
        !            67:        /*
        !            68:         * Update seconds and print it.
        !            69:         */
        !            70:        bus_write_1(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_CLOCKUPDATE, 0xff);
        !            71:        printf("tartc intr: %d seconds past Epoch\n",
        !            72:                bus_read_4(ddp->td_bushandlep, ddp->td_ioaddr + TARTC_OFF_READSECONDS));
1.1       init       73:
1.4     ! init       74:        printf("tartc intr\n");
1.1       init       75: }
                     76:

CVSweb