File: /usr/src/linux/drivers/isdn/eicon/eicon_pci.c

1     /* $Id: eicon_pci.c,v 1.15.6.2 2001/02/16 09:09:50 armin Exp $
2      *
3      * ISDN low-level module for Eicon active ISDN-Cards.
4      * Hardware-specific code for PCI cards.
5      *
6      * Copyright 1998-2000 by Armin Schindler (mac@melware.de)
7      * Copyright 1999,2000 Cytronics & Melware (info@melware.de)
8      *
9      * Thanks to	Eicon Networks for 
10      *		documents, informations and hardware. 
11      *
12      * This program is free software; you can redistribute it and/or modify
13      * it under the terms of the GNU General Public License as published by
14      * the Free Software Foundation; either version 2, or (at your option)
15      * any later version.
16      *
17      * This program is distributed in the hope that it will be useful,
18      * but WITHOUT ANY WARRANTY; without even the implied warranty of
19      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20      * GNU General Public License for more details.
21      *
22      * You should have received a copy of the GNU General Public License
23      * along with this program; if not, write to the Free Software
24      * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
25      *
26      */
27     
28     #include <linux/config.h>
29     #include <linux/pci.h>
30     
31     #include "eicon.h"
32     #include "eicon_pci.h"
33     
34     #undef N_DATA
35     #include "adapter.h"
36     #include "uxio.h"
37     
38     char *eicon_pci_revision = "$Revision: 1.15.6.2 $";
39     
40     #if CONFIG_PCI	         /* intire stuff is only for PCI */
41     #ifdef CONFIG_ISDN_DRV_EICON_PCI
42     
43     int eicon_pci_find_card(char *ID)
44     {
45     	int pci_cards = 0;
46     	int card_id = 0;
47     	int had_q = 0;
48     	int ctype = 0;
49     	char did[20];
50     	card_t *pCard;
51     	word wCardIndex;
52     
53     	pCard = DivasCards;
54     	for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
55     	{
56     	if ((pCard->hw) && (pCard->hw->in_use))
57     		{
58     			switch(pCard->hw->card_type) {
59     				case DIA_CARD_TYPE_DIVA_SERVER:
60     					ctype = EICON_CTYPE_MAESTRAP;
61     					card_id++;
62     					had_q = 0;
63     					break;
64     				case DIA_CARD_TYPE_DIVA_SERVER_B:
65     					ctype = EICON_CTYPE_MAESTRA;
66     					card_id++;
67     					had_q = 0;
68     					break;
69     				case DIA_CARD_TYPE_DIVA_SERVER_Q:
70     					ctype = EICON_CTYPE_MAESTRAQ;
71     					if (!had_q)
72     						card_id++;
73     					if (++had_q >=4)
74     						had_q = 0;
75     					break;
76     				default:
77     					printk(KERN_ERR "eicon_pci: unknown card type %d !\n",
78     						pCard->hw->card_type);
79     					goto err;
80     			}
81     			sprintf(did, "%s%d", (strlen(ID) < 1) ? "eicon":ID, pci_cards);
82     			if ((!ctype) || (!(eicon_addcard(ctype, 0, pCard->hw->irq, did, card_id)))) {
83     				printk(KERN_ERR "eicon_pci: Card could not be added !\n");
84     			} else {
85     				pci_cards++;
86     				printk(KERN_INFO "%s: DriverID='%s' CardID=%d\n",
87     					eicon_ctype_name[ctype], did, card_id);
88     			}
89     err:;
90     		}
91     		pCard++;
92     	}
93     	return pci_cards;
94     }
95     
96     void
97     eicon_pci_init_conf(eicon_card *card)
98     {
99     	int j;
100     
101     	/* initializing some variables */
102     	card->ReadyInt = 0;
103     
104     	for(j = 0; j < 256; j++)
105     		card->IdTable[j] = NULL;
106     
107     	for(j = 0; j < (card->d->channels + 1); j++) {
108     		card->bch[j].e.busy = 0;
109     		card->bch[j].e.D3Id = 0;
110     		card->bch[j].e.B2Id = 0;
111     		card->bch[j].e.ref = 0;
112     		card->bch[j].e.Req = 0;
113     		card->bch[j].e.complete = 1;
114     		card->bch[j].fsm_state = EICON_STATE_NULL;
115     	}
116     }
117     
118     #endif
119     #endif	/* CONFIG_PCI */
120     
121