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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [isdn/] [sc/] [timer.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *  $Id: timer.c,v 1.1.1.1 2001-09-10 07:44:19 simons Exp $
3
 *  Copyright (C) 1996  SpellCaster Telecommunications Inc.
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 *
19
 *  For more information, please contact gpl-info@spellcast.com or write:
20
 *
21
 *     SpellCaster Telecommunications Inc.
22
 *     5621 Finch Avenue East, Unit #3
23
 *     Scarborough, Ontario  Canada
24
 *     M1B 2T9
25
 *     +1 (416) 297-8565
26
 *     +1 (416) 297-6433 Facsimile
27
 */
28
 
29
#define __NO_VERSION__
30
#include "includes.h"
31
#include "hardware.h"
32
#include "message.h"
33
#include "card.h"
34
 
35
extern board *adapter[];
36
 
37
extern void flushreadfifo(int);
38
extern int  startproc(int);
39
extern int  indicate_status(int, int, unsigned long, char *);
40
extern int  sendmessage(int, unsigned int, unsigned int, unsigned int,
41
        unsigned int, unsigned int, unsigned int, unsigned int *);
42
 
43
 
44
/*
45
 * Write the proper values into the I/O ports following a reset
46
 */
47
void setup_ports(int card)
48
{
49
 
50
        outb((adapter[card]->rambase >> 12), adapter[card]->ioport[EXP_BASE]);
51
 
52
        /* And the IRQ */
53
        outb((adapter[card]->interrupt | 0x80),
54
                adapter[card]->ioport[IRQ_SELECT]);
55
}
56
 
57
/*
58
 * Timed function to check the status of a previous reset
59
 * Must be very fast as this function runs in the context of
60
 * an interrupt handler.
61
 *
62
 * Setup the ioports for the board that were cleared by the reset.
63
 * Then, check to see if the signate has been set. Next, set the
64
 * signature to a known value and issue a startproc if needed.
65
 */
66
void check_reset(unsigned long data)
67
{
68
        unsigned long flags;
69
        unsigned long sig;
70
        int card = (unsigned int) data;
71
 
72
        pr_debug("%s: check_timer timer called\n", adapter[card]->devicename);
73
 
74
        /* Setup the io ports */
75
        setup_ports(card);
76
 
77
        save_flags(flags);
78
        cli();
79
        outb(adapter[card]->ioport[adapter[card]->shmem_pgport],
80
                (adapter[card]->shmem_magic>>14) | 0x80);
81
        sig = (unsigned long) *((unsigned long *)(adapter[card]->rambase + SIG_OFFSET));
82
 
83
        /* check the signature */
84
        if(sig == SIGNATURE) {
85
                flushreadfifo(card);
86
                restore_flags(flags);
87
                /* See if we need to do a startproc */
88
                if (adapter[card]->StartOnReset)
89
                        startproc(card);
90
        }
91
        else  {
92
                pr_debug("%s: No signature yet, waiting another %d jiffies.\n",
93
                        adapter[card]->devicename, CHECKRESET_TIME);
94
                del_timer(&adapter[card]->reset_timer);
95
                adapter[card]->reset_timer.expires = jiffies + CHECKRESET_TIME;
96
                add_timer(&adapter[card]->reset_timer);
97
        }
98
        restore_flags(flags);
99
 
100
}
101
 
102
/*
103
 * Timed function to check the status of a previous reset
104
 * Must be very fast as this function runs in the context of
105
 * an interrupt handler.
106
 *
107
 * Send check adapter->phystat to see if the channels are up
108
 * If they are, tell ISDN4Linux that the board is up. If not,
109
 * tell IADN4Linux that it is up. Always reset the timer to
110
 * fire again (endless loop).
111
 */
112
void check_phystat(unsigned long data)
113
{
114
        unsigned long flags;
115
        int card = (unsigned int) data;
116
 
117
        pr_debug("%s: Checking status...\n", adapter[card]->devicename);
118
        /*
119
         * check the results of the last PhyStat and change only if
120
         * has changed drastically
121
         */
122
        if (adapter[card]->nphystat && !adapter[card]->phystat) {   /* All is well */
123
                pr_debug("PhyStat transition to RUN\n");
124
                pr_info("%s: Switch contacted, transmitter enabled\n",
125
                        adapter[card]->devicename);
126
                indicate_status(card, ISDN_STAT_RUN, 0, NULL);
127
        }
128
        else if (!adapter[card]->nphystat && adapter[card]->phystat) {   /* All is not well */
129
                pr_debug("PhyStat transition to STOP\n");
130
                pr_info("%s: Switch connection lost, transmitter disabled\n",
131
                        adapter[card]->devicename);
132
 
133
                indicate_status(card, ISDN_STAT_STOP, 0, NULL);
134
        }
135
 
136
        adapter[card]->phystat = adapter[card]->nphystat;
137
 
138
        /* Reinitialize the timer */
139
        save_flags(flags);
140
        cli();
141
        del_timer(&adapter[card]->stat_timer);
142
        adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME;
143
        add_timer(&adapter[card]->stat_timer);
144
        restore_flags(flags);
145
 
146
        /* Send a new cePhyStatus message */
147
        sendmessage(card, CEPID,ceReqTypePhy,ceReqClass2,
148
                ceReqPhyStatus,0,0,NULL);
149
}
150
 
151
/*
152
 * When in trace mode, this callback is used to swap the working shared
153
 * RAM page to the trace page(s) and process all received messages. It
154
 * must be called often enough to get all of the messages out of RAM before
155
 * it loops around.
156
 * Trace messages are \n terminated strings.
157
 * We output the messages in 64 byte chunks through readstat. Each chunk
158
 * is scanned for a \n followed by a time stamp. If the timerstamp is older
159
 * than the current time, scanning stops and the page and offset are recorded
160
 * as the starting point the next time the trace timer is called. The final
161
 * step is to restore the working page and reset the timer.
162
 */
163
void trace_timer(unsigned long data)
164
{
165
        unsigned long flags;
166
 
167
        /*
168
         * Disable interrupts and swap the first page
169
         */
170
        save_flags(flags);
171
        cli();
172
}

powered by: WebSVN 2.1.0

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