OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [arch-a5k/] [time.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/arch-a5k/time.h
3
 *
4
 * Copyright (c) 1996 Russell King.
5
 *
6
 * Changelog:
7
 *  24-Sep-1996 RMK     Created
8
 *  10-Oct-1996 RMK     Brought up to date with arch-sa110eval
9
 *  04-Dec-1997 RMK     Updated for new arch/arm/time.c
10
 */
11
 
12
extern __inline__ unsigned long gettimeoffset (void)
13
{
14
        unsigned int count1, count2, status1, status2;
15
        unsigned long offset = 0;
16
 
17
        status1 = inb(IOC_IRQREQA);
18
        barrier ();
19
        outb (0, IOC_T0LATCH);
20
        barrier ();
21
        count1 = inb(IOC_T0CNTL) | (inb(IOC_T0CNTH) << 8);
22
        barrier ();
23
        status2 = inb(IOC_IRQREQA);
24
        barrier ();
25
        outb (0, IOC_T0LATCH);
26
        barrier ();
27
        count2 = inb(IOC_T0CNTL) | (inb(IOC_T0CNTH) << 8);
28
 
29
        if (count2 < count1) {
30
                /*
31
                 * This means that we haven't just had an interrupt
32
                 * while reading into status2.
33
                 */
34
                if (status2 & (1 << 5))
35
                        offset = tick;
36
                count1 = count2;
37
        } else if (count2 > count1) {
38
                /*
39
                 * We have just had another interrupt while reading
40
                 * status2.
41
                 */
42
                offset += tick;
43
                count1 = count2;
44
        }
45
 
46
        count1 = LATCH - count1;
47
        /*
48
         * count1 = number of clock ticks since last interrupt
49
         */
50
        offset += count1 * tick / LATCH;
51
        return offset;
52
}
53
 
54
/*
55
 * No need to reset the timer at every irq
56
 */
57
#define reset_timer() 1
58
 
59
/*
60
 * Updating of the RTC.  We don't currently write the time to the
61
 * CMOS clock.
62
 */
63
#define update_rtc()
64
 
65
/*
66
 * Set up timer interrupt, and return the current time in seconds.
67
 */
68
extern __inline__ unsigned long setup_timer (void)
69
{
70
        extern int iic_control (unsigned char, int, char *, int);
71
        unsigned int year, mon, day, hour, min, sec;
72
        char buf[8];
73
 
74
        outb(LATCH & 255, IOC_T0LTCHL);
75
        outb(LATCH >> 8, IOC_T0LTCHH);
76
        outb(0, IOC_T0GO);
77
 
78
        iic_control (0xa0, 0xc0, buf, 1);
79
        year = buf[0];
80
        if ((year += 1900) < 1970)
81
                year += 100;
82
 
83
        iic_control (0xa0, 2, buf, 5);
84
        mon  = buf[4] & 0x1f;
85
        day  = buf[3] & 0x3f;
86
        hour = buf[2];
87
        min  = buf[1];
88
        sec  = buf[0];
89
        BCD_TO_BIN(mon);
90
        BCD_TO_BIN(day);
91
        BCD_TO_BIN(hour);
92
        BCD_TO_BIN(min);
93
        BCD_TO_BIN(sec);
94
 
95
        return mktime(year, mon, day, hour, min, sec);
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.