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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [arch-trio/] [time.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/arch-trio/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
        struct trio_timers* tt = (struct trio_timers*) (PERIPH_BASE+TC_OFFSET);
15
        struct trio_timer_channel* tc = &tt->chans[1].ch;
16
 
17
        return tc->cv * (ARM_CLK/128);
18
}
19
 
20
#if 0
21
{
22
        unsigned int count1, count2, status1, status2;
23
        unsigned long offset = 0;
24
 
25
        status1 = inb(IOC_IRQREQA);
26
        barrier ();
27
        outb (0, IOC_T0LATCH);
28
        barrier ();
29
        count1 = inb(IOC_T0CNTL) | (inb(IOC_T0CNTH) << 8);
30
        barrier ();
31
        status2 = inb(IOC_IRQREQA);
32
        barrier ();
33
        outb (0, IOC_T0LATCH);
34
        barrier ();
35
        count2 = inb(IOC_T0CNTL) | (inb(IOC_T0CNTH) << 8);
36
 
37
        if (count2 < count1) {
38
                /*
39
                 * This means that we haven't just had an interrupt
40
                 * while reading into status2.
41
                 */
42
                if (status2 & (1 << 5))
43
                        offset = tick;
44
                count1 = count2;
45
        } else if (count2 > count1) {
46
                /*
47
                 * We have just had another interrupt while reading
48
                 * status2.
49
                 */
50
                offset += tick;
51
                count1 = count2;
52
        }
53
 
54
        count1 = LATCH - count1;
55
        /*
56
         * count1 = number of clock ticks since last interrupt
57
         */
58
        offset += count1 * tick / LATCH;
59
        return offset;
60
}
61
#endif
62
 
63
/*
64
 * No need to reset the timer at every irq
65
 */
66
extern __inline__ int reset_timer()
67
{
68
        struct trio_timers* tt = (struct trio_timers*) (PERIPH_BASE+TC_OFFSET);
69
        volatile struct  trio_timer_channel* tc = &tt->chans[1].ch;
70
        unsigned long v = tc->sr;
71
 
72
        return (1);
73
 
74
}
75
 
76
/*
77
 * Updating of the RTC.  We don't currently write the time to the
78
 * CMOS clock.
79
 */
80
#define update_rtc()
81
 
82
/*
83
 * Set up timer interrupt, and return the current time in seconds.
84
 */
85
 
86
 
87
extern __inline__ unsigned long setup_timer (void)
88
{
89
        register volatile struct trio_timers* tt = (struct trio_timers*) (PERIPH_BASE+TC_OFFSET);
90
        register volatile struct trio_timer_channel* tc = &tt->chans[1].ch;
91
        unsigned long v;
92
 
93
 
94
 
95
        /* program NO signal on XC1 */
96
        v = tt->bcr;
97
        v = (v & ~(3 << 2)) | (1 << 2);
98
        tt->bcr = v;
99
 
100
        tc->ccr = 0x20;  /* disable the channel */
101
 
102
        /* select ACLK/128 as inupt frequensy for TC1 */
103
        tc->cmr = 3;
104
 
105
        tc->idr = ~0ul;  /* disable all interrupt */
106
        tc->ier = 1 << 4;  /* enable CPCS interrupt */
107
        tc->rc = ((ARM_CLK/128)/HZ - 1);   /* load the count limit into the CR register */
108
 
109
        /* enable the channel */
110
        tc->ccr = 1;
111
 
112
        return mktime(1999, 11, 1, 0, 0, 0);
113
 
114
 
115
}
116
 
117
#if 0
118
{
119
        extern int iic_control (unsigned char, int, char *, int);
120
        unsigned int year, mon, day, hour, min, sec;
121
        char buf[8];
122
 
123
        outb(LATCH & 255, IOC_T0LTCHL);
124
        outb(LATCH >> 8, IOC_T0LTCHH);
125
        outb(0, IOC_T0GO);
126
 
127
        iic_control (0xa0, 0xc0, buf, 1);
128
        year = buf[0];
129
        if ((year += 1900) < 1970)
130
                year += 100;
131
 
132
        iic_control (0xa0, 2, buf, 5);
133
        mon  = buf[4] & 0x1f;
134
        day  = buf[3] & 0x3f;
135
        hour = buf[2];
136
        min  = buf[1];
137
        sec  = buf[0];
138
        BCD_TO_BIN(mon);
139
        BCD_TO_BIN(day);
140
        BCD_TO_BIN(hour);
141
        BCD_TO_BIN(min);
142
        BCD_TO_BIN(sec);
143
 
144
        return mktime(year, mon, day, hour, min, sec);
145
}
146
#endif

powered by: WebSVN 2.1.0

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