2 * Copyright (C) Eicon Technology Corporation, 2000.
4 * Eicon File Revision : 1.9
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
12 #undef N_DATA /* Because we have our own definition */
14 #include <asm/segment.h>
28 #include <linux/pci.h>
29 #include <linux/kernel.h>
30 #include <linux/ioport.h>
32 struct file_operations Divas_fops;
35 extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile,
36 unsigned int command, unsigned long arg);
37 extern unsigned int do_poll(struct file *pFile, struct poll_table_struct *pPollTable);
38 extern ssize_t do_read(struct file *pFile, char *pUserBuffer, size_t BufferSize, loff_t *pOffset);
39 extern int do_open(struct inode *, struct file *);
40 extern int do_release(struct inode *, struct file *);
44 int DivasCardsDiscover(void)
46 word wNumCards = 0, wDeviceIndex = 0;
48 word wPCIConsultation, PCItmp;
50 unsigned int PCIserial;
54 while (wDeviceIndex < 10)
56 wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON,
57 PCI_DEVICE_ID_EICON_MAESTRAQ,
61 if (wPCIConsultation == PCIBIOS_SUCCESSFUL)
64 dword dwRAM, dwDivasIOBase, dwCFG, dwCTL;
67 printk(KERN_DEBUG "Divas: DIVA Server 4BRI Found\n");
68 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2,(unsigned int *) &dwRAM);
71 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1,(unsigned int *) &dwDivasIOBase);
72 dwDivasIOBase &= 0xFFFFFF00;
74 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_0,(unsigned int *) &dwCFG);
77 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_3,(unsigned int *) &dwCTL);
81 pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ);
82 /* Retrieve the serial number */
84 pcibios_write_config_word(byBus,byFunc,0x4E,0x00FC);
86 for (j=0, PCItmp=0; j<10000 && !PCItmp; j++)
88 pcibios_read_config_word(byBus,byFunc,0x4E, &PCItmp);
89 PCItmp &= 0x8000; // extract done flag
92 pcibios_read_config_dword(byBus,byFunc,0x50, &PCIserial);
95 Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x400000);
96 Card.memory[DIVAS_CTL_MEMORY] = ioremap(dwCTL, 0x2000);
97 Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x100);
98 Card.io_base=dwDivasIOBase;
102 Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_Q;
103 Card.bus_type = DIA_BUS_TYPE_PCI;
107 /* Create four virtual card structures as we want to treat
108 the 4Bri card as 4 Bri cards*/
112 b=Card.memory[DIVAS_RAM_MEMORY];
113 b+=(MQ_PROTCODE_OFFSET) * (i==0?0:1);
114 DPRINTF(("divas: offset = 0x%x", i* MQ_PROTCODE_OFFSET));
115 Card.memory[DIVAS_RAM_MEMORY]=b;
117 b = Card.memory[DIVAS_RAM_MEMORY];
119 Card.memory[DIVAS_SHARED_MEMORY] = b;
121 Card.bus_num = byBus;
122 Card.func_num = byFunc;
133 Card.name[6] = '0' + i;
136 Card.serial = PCIserial;
138 Card.card_id = wNumCards;
140 if (DivasCardNew(&Card) != 0)
142 // Force for loop to terminate
155 while (wDeviceIndex < 10)
157 wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON,
158 PCI_DEVICE_ID_EICON_MAESTRA,
162 if (wPCIConsultation == PCIBIOS_SUCCESSFUL)
164 dword dwPLXIOBase, dwDivasIOBase;
167 printk(KERN_DEBUG "Divas: DIVA Server BRI (S/T) Found\n");
168 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1, (unsigned int *) &dwPLXIOBase);
169 dwPLXIOBase &= 0xFFFFFF80;
171 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwDivasIOBase);
172 dwDivasIOBase &= 0xFFFFFFFC;
174 pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ);
176 Card.card_id = wNumCards;
177 Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B;
178 Card.bus_type = DIA_BUS_TYPE_PCI;
180 Card.reset_base = dwPLXIOBase;
181 Card.io_base = dwDivasIOBase;
182 Card.bus_num = byBus;
183 Card.func_num = byFunc;
193 if (check_region(Card.io_base, 0x20))
195 printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F);
200 if (check_region(Card.reset_base, 0x80))
202 printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F);
207 if (DivasCardNew(&Card) != 0)
215 wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON,
216 PCI_DEVICE_ID_EICON_MAESTRAQ_U,
220 if (wPCIConsultation == PCIBIOS_SUCCESSFUL)
222 dword dwPLXIOBase, dwDivasIOBase;
225 printk(KERN_DEBUG "Divas: DIVA Server BRI (U) Found\n");
227 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1, (unsigned int *) &dwPLXIOBase);
228 dwPLXIOBase &= 0xFFFFFF80;
230 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwDivasIOBase);
231 dwDivasIOBase &= 0xFFFFFFFC;
233 pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ);
235 Card.card_id = wNumCards;
236 Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B;
237 Card.bus_type = DIA_BUS_TYPE_PCI;
239 Card.reset_base = dwPLXIOBase;
240 Card.io_base = dwDivasIOBase;
241 Card.bus_num = byBus;
242 Card.func_num = byFunc;
252 if (check_region(Card.io_base, 0x20))
254 printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F);
259 if (check_region(Card.reset_base, 0x80))
261 printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F);
266 if (DivasCardNew(&Card) != 0)
279 while (wDeviceIndex < 10)
281 wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON,
282 PCI_DEVICE_ID_EICON_MAESTRAP,
286 if (wPCIConsultation == PCIBIOS_SUCCESSFUL)
288 dword dwRAM, dwREG, dwCFG;
291 printk(KERN_DEBUG "Divas: DIVA Server PRI Found\n");
293 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_0, (unsigned int *) &dwRAM);
296 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwREG);
299 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_4, (unsigned int *) &dwCFG);
302 pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ);
304 Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x10000);
305 Card.memory[DIVAS_REG_MEMORY] = ioremap(dwREG, 0x4000);
306 Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x1000);
307 Card.memory[DIVAS_SHARED_MEMORY] = Card.memory[DIVAS_RAM_MEMORY] + DIVAS_SHARED_OFFSET;
309 /* pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1, (unsigned int *) &dwPLXIOBase);
310 dwPLXIOBase &= 0xFFFFFFFc;
312 pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwDivasIOBase);
313 dwDivasIOBase &= 0xFFFFFF80;
315 pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ);
317 Card.card_id = wNumCards;
318 Card.card_type = DIA_CARD_TYPE_DIVA_SERVER;
319 Card.bus_type = DIA_BUS_TYPE_PCI;
321 /* Card.reset_base = dwPLXIOBase;
322 Card.io_base = dwDivasIOBase;*/
323 Card.bus_num = byBus;
324 Card.func_num = byFunc;
334 if (DivasCardNew(&Card) != 0)
346 printk(KERN_INFO "Divas: %d cards detected\n", wNumCards);
353 Divas_fops.ioctl = do_ioctl;
354 Divas_fops.poll = do_poll;
355 Divas_fops.read = do_read;
356 Divas_fops.open = do_open;
357 Divas_fops.release = do_release;
359 Divas_major = register_chrdev(0, "Divas", &Divas_fops);
363 printk(KERN_WARNING "Divas: Unable to register character driver\n");
370 /* Error return -1 */
371 int DivasConfigGet(dia_card_t *card)
373 /* Retrieve Config from O/S? Not in Linux */
377 dia_config_t *DivasConfig(card_t *card, dia_config_t *config)
379 /* If config retrieved from OS then copy the data into a dia_config_t structure here
380 and return the pointer here. If the config 'came from above' then just