include upstream ip1000a driver version 2.09f
[linux-2.4.git] / drivers / isdn / eicon / eicon_pci.c
1 /* $Id: eicon_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai 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  * This software may be used and distributed according to the terms
10  * of the GNU General Public License, incorporated herein by reference.
11  *
12  * Thanks to    Eicon Networks for 
13  *              documents, informations and hardware. 
14  *
15  */
16
17 #include <linux/config.h>
18 #include <linux/pci.h>
19
20 #include "eicon.h"
21 #include "eicon_pci.h"
22
23 #undef N_DATA
24 #include "adapter.h"
25 #include "uxio.h"
26
27 char *eicon_pci_revision = "$Revision: 1.1.4.1 $";
28
29 #if CONFIG_PCI           /* intire stuff is only for PCI */
30 #ifdef CONFIG_ISDN_DRV_EICON_PCI
31
32 int eicon_pci_find_card(char *ID)
33 {
34         int pci_cards = 0;
35         int card_id = 0;
36         int had_q = 0;
37         int ctype = 0;
38         char did[20];
39         card_t *pCard;
40         word wCardIndex;
41
42         pCard = DivasCards;
43         for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
44         {
45         if ((pCard->hw) && (pCard->hw->in_use))
46                 {
47                         switch(pCard->hw->card_type) {
48                                 case DIA_CARD_TYPE_DIVA_SERVER:
49                                         ctype = EICON_CTYPE_MAESTRAP;
50                                         card_id++;
51                                         had_q = 0;
52                                         break;
53                                 case DIA_CARD_TYPE_DIVA_SERVER_B:
54                                         ctype = EICON_CTYPE_MAESTRA;
55                                         card_id++;
56                                         had_q = 0;
57                                         break;
58                                 case DIA_CARD_TYPE_DIVA_SERVER_Q:
59                                         ctype = EICON_CTYPE_MAESTRAQ;
60                                         if (!had_q)
61                                                 card_id++;
62                                         if (++had_q >=4)
63                                                 had_q = 0;
64                                         break;
65                                 default:
66                                         printk(KERN_ERR "eicon_pci: unknown card type %d !\n",
67                                                 pCard->hw->card_type);
68                                         goto err;
69                         }
70                         sprintf(did, "%s%d", (strlen(ID) < 1) ? "eicon":ID, pci_cards);
71                         if ((!ctype) || (!(eicon_addcard(ctype, 0, pCard->hw->irq, did, card_id)))) {
72                                 printk(KERN_ERR "eicon_pci: Card could not be added !\n");
73                         } else {
74                                 pci_cards++;
75                                 printk(KERN_INFO "%s: DriverID='%s' CardID=%d\n",
76                                         eicon_ctype_name[ctype], did, card_id);
77                         }
78 err:;
79                 }
80                 pCard++;
81         }
82         return pci_cards;
83 }
84
85 void
86 eicon_pci_init_conf(eicon_card *card)
87 {
88         int j;
89
90         /* initializing some variables */
91         card->ReadyInt = 0;
92
93         for(j = 0; j < 256; j++)
94                 card->IdTable[j] = NULL;
95
96         for(j = 0; j < (card->d->channels + 1); j++) {
97                 card->bch[j].e.busy = 0;
98                 card->bch[j].e.D3Id = 0;
99                 card->bch[j].e.B2Id = 0;
100                 card->bch[j].e.ref = 0;
101                 card->bch[j].e.Req = 0;
102                 card->bch[j].e.complete = 1;
103                 card->bch[j].fsm_state = EICON_STATE_NULL;
104         }
105 }
106
107 #endif
108 #endif  /* CONFIG_PCI */
109