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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [hisax/] [teles3c.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/* $Id: teles3c.c,v 1.1 2005-12-20 10:17:01 jcastillo Exp $
2
 
3
 * teles3c.c     low level stuff for teles 16.3c
4
 *
5
 * Author     Karsten Keil (keil@isdn4linux.de)
6
 *
7
 *
8
 * $Log: not supported by cvs2svn $
9
 * Revision 1.1.1.1  2001/09/10 07:44:19  simons
10
 * Initial import
11
 *
12
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
13
 * Initial revision
14
 *
15
 * Revision 1.1.2.3  1998/11/03 00:07:40  keil
16
 * certification related changes
17
 * fixed logging for smaller stack use
18
 *
19
 * Revision 1.1.2.2  1998/01/27 22:40:37  keil
20
 * fixed IRQ latency, B-channel selection and more
21
 *
22
 * Revision 1.1.2.1  1998/01/11 22:54:04  keil
23
 * Teles 16.3c (HFC 2BDS0) first version
24
 *
25
 *
26
 */
27
 
28
#define __NO_VERSION__
29
#include "hisax.h"
30
#include "hfc_2bds0.h"
31
#include "isdnl1.h"
32
 
33
extern const char *CardType[];
34
 
35
const char *teles163c_revision = "$Revision: 1.1 $";
36
 
37
static void
38
t163c_interrupt(int intno, void *dev_id, struct pt_regs *regs)
39
{
40
        struct IsdnCardState *cs = dev_id;
41
        u_char val, stat;
42
 
43
        if (!cs) {
44
                printk(KERN_WARNING "teles3c: Spurious interrupt!\n");
45
                return;
46
        }
47
        if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) &
48
                (stat = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_STAT))) {
49
                val = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_INT_S1);
50
                if (cs->debug & L1_DEB_ISAC)
51
                        debugl1(cs, "teles3c: stat(%02x) s1(%02x)", stat, val);
52
                hfc2bds0_interrupt(cs, val);
53
        } else {
54
                if (cs->debug & L1_DEB_ISAC)
55
                        debugl1(cs, "teles3c: irq_no_irq stat(%02x)", stat);
56
        }
57
}
58
 
59
static void
60
t163c_Timer(struct IsdnCardState *cs)
61
{
62
        cs->hw.hfcD.timer.expires = jiffies + 75;
63
        /* WD RESET */
64
/*      WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt | 0x80);
65
        add_timer(&cs->hw.hfcD.timer);
66
*/
67
}
68
 
69
void
70
release_io_t163c(struct IsdnCardState *cs)
71
{
72
        release2bds0(cs);
73
        del_timer(&cs->hw.hfcD.timer);
74
        if (cs->hw.hfcD.addr)
75
                release_region(cs->hw.hfcD.addr, 2);
76
}
77
 
78
static void
79
reset_t163c(struct IsdnCardState *cs)
80
{
81
        long flags;
82
 
83
        printk(KERN_INFO "teles3c: resetting card\n");
84
        cs->hw.hfcD.cirm = HFCD_RESET | HFCD_MEM8K;
85
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm);   /* Reset On */
86
        save_flags(flags);
87
        sti();
88
        current->state = TASK_INTERRUPTIBLE;
89
        current->timeout = jiffies + 3;
90
        schedule();
91
        cs->hw.hfcD.cirm = HFCD_MEM8K;
92
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm);   /* Reset Off */
93
        current->state = TASK_INTERRUPTIBLE;
94
        current->timeout = jiffies + 1;
95
        schedule();
96
        cs->hw.hfcD.cirm |= HFCD_INTB;
97
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm);   /* INT B */
98
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CLKDEL, 0x0e);
99
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_TEST, HFCD_AUTO_AWAKE); /* S/T Auto awake */
100
        cs->hw.hfcD.ctmt = HFCD_TIM25 | HFCD_AUTO_TIMER;
101
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
102
        cs->hw.hfcD.int_m2 = HFCD_IRQ_ENABLE;
103
        cs->hw.hfcD.int_m1 = HFCD_INTS_B1TRANS | HFCD_INTS_B2TRANS |
104
                HFCD_INTS_DTRANS | HFCD_INTS_B1REC | HFCD_INTS_B2REC |
105
                HFCD_INTS_DREC | HFCD_INTS_L1STATE;
106
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M1, cs->hw.hfcD.int_m1);
107
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M2, cs->hw.hfcD.int_m2);
108
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, HFCD_LOAD_STATE | 2); /* HFC ST 2 */
109
        udelay(10);
110
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, 2); /* HFC ST 2 */
111
        cs->hw.hfcD.mst_m = 0;
112
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, HFCD_MASTER); /* HFC Master */
113
        cs->hw.hfcD.sctrl = 0;
114
        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl);
115
        restore_flags(flags);
116
}
117
 
118
static int
119
t163c_card_msg(struct IsdnCardState *cs, int mt, void *arg)
120
{
121
        long flags;
122
 
123
        if (cs->debug & L1_DEB_ISAC)
124
                debugl1(cs, "teles3c: card_msg %x", mt);
125
        switch (mt) {
126
                case CARD_RESET:
127
                        reset_t163c(cs);
128
                        return(0);
129
                case CARD_RELEASE:
130
                        release_io_t163c(cs);
131
                        return(0);
132
                case CARD_SETIRQ:
133
                        cs->hw.hfcD.timer.expires = jiffies + 75;
134
                        add_timer(&cs->hw.hfcD.timer);
135
                        return(request_irq(cs->irq, &t163c_interrupt,
136
                                        I4L_IRQ_FLAG, "HiSax", cs));
137
                case CARD_INIT:
138
                        init2bds0(cs);
139
                        save_flags(flags);
140
                        sti();
141
                        current->state = TASK_INTERRUPTIBLE;
142
                        current->timeout = jiffies + (80*HZ)/1000;
143
                        schedule();
144
                        cs->hw.hfcD.ctmt |= HFCD_TIM800;
145
                        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
146
                        cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
147
                        restore_flags(flags);
148
                        return(0);
149
                case CARD_TEST:
150
                        return(0);
151
        }
152
        return(0);
153
}
154
 
155
__initfunc(int
156
setup_t163c(struct IsdnCard *card))
157
{
158
        struct IsdnCardState *cs = card->cs;
159
        char tmp[64];
160
 
161
        strcpy(tmp, teles163c_revision);
162
        printk(KERN_INFO "HiSax: Teles 16.3c driver Rev. %s\n", HiSax_getrev(tmp));
163
        if (cs->typ != ISDN_CTYPE_TELES3C)
164
                return (0);
165
        cs->debug = 0xff;
166
        cs->hw.hfcD.addr = card->para[1] & 0xfffe;
167
        cs->irq = card->para[0];
168
        cs->hw.hfcD.cip = 0;
169
        cs->hw.hfcD.int_s1 = 0;
170
        cs->hw.hfcD.send = NULL;
171
        cs->bcs[0].hw.hfc.send = NULL;
172
        cs->bcs[1].hw.hfc.send = NULL;
173
        cs->hw.hfcD.bfifosize = 1024 + 512;
174
        cs->hw.hfcD.dfifosize = 512;
175
        cs->ph_state = 0;
176
        cs->hw.hfcD.fifo = 255;
177
        if (check_region((cs->hw.hfcD.addr), 2)) {
178
                printk(KERN_WARNING
179
                       "HiSax: %s config port %x-%x already in use\n",
180
                       CardType[card->typ],
181
                       cs->hw.hfcD.addr,
182
                       cs->hw.hfcD.addr + 2);
183
                return (0);
184
        } else {
185
                request_region(cs->hw.hfcD.addr, 2, "teles3c isdn");
186
        }
187
        /* Teles 16.3c IO ADR is 0x200 | YY0U (YY Bit 15/14 address) */
188
        outb(0x00, cs->hw.hfcD.addr);
189
        outb(0x56, cs->hw.hfcD.addr | 1);
190
        printk(KERN_INFO
191
               "teles3c: defined at 0x%x IRQ %d HZ %d\n",
192
               cs->hw.hfcD.addr,
193
               cs->irq, HZ);
194
 
195
        set_cs_func(cs);
196
        cs->hw.hfcD.timer.function = (void *) t163c_Timer;
197
        cs->hw.hfcD.timer.data = (long) cs;
198
        init_timer(&cs->hw.hfcD.timer);
199
        reset_t163c(cs);
200
        cs->cardmsg = &t163c_card_msg;
201
        return (1);
202
}

powered by: WebSVN 2.1.0

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