Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | /* * Copyright (C) Eicon Technology Corporation, 2000. * * Eicon File Revision : 1.9 * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #include <linux/fs.h> #undef N_DATA /* Because we have our own definition */ #include <asm/segment.h> #include <asm/io.h> #include "sys.h" #include "idi.h" #include "constant.h" #include "divas.h" #undef ID_MASK #include "pc.h" #include "pr_pc.h" #include "adapter.h" #include "uxio.h" #include <linux/pci.h> #include <linux/kernel.h> #include <linux/ioport.h> struct file_operations Divas_fops; int Divas_major; extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, unsigned int command, unsigned long arg); extern unsigned int do_poll(struct file *pFile, struct poll_table_struct *pPollTable); extern ssize_t do_read(struct file *pFile, char *pUserBuffer, size_t BufferSize, loff_t *pOffset); extern int do_open(struct inode *, struct file *); extern int do_release(struct inode *, struct file *); int FPGA_Done=0; int DivasCardsDiscover(void) { word wNumCards = 0, wDeviceIndex = 0; byte byBus, byFunc; word wPCIConsultation, PCItmp; dword j, i; unsigned int PCIserial; dia_card_t Card; byte *b; while (wDeviceIndex < 10) { wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAQ, wDeviceIndex, &byBus, &byFunc); if (wPCIConsultation == PCIBIOS_SUCCESSFUL) { dword dwRAM, dwDivasIOBase, dwCFG, dwCTL; byte byIRQ; printk(KERN_DEBUG "Divas: DIVA Server 4BRI Found\n"); pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2,(unsigned int *) &dwRAM); dwRAM &= 0xFFC00000; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1,(unsigned int *) &dwDivasIOBase); dwDivasIOBase &= 0xFFFFFF00; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_0,(unsigned int *) &dwCFG); dwCFG &= 0xFFFFFF00; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_3,(unsigned int *) &dwCTL); dwCTL &= 0xFFFFE000; pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ); /* Retrieve the serial number */ pcibios_write_config_word(byBus,byFunc,0x4E,0x00FC); for (j=0, PCItmp=0; j<10000 && !PCItmp; j++) { pcibios_read_config_word(byBus,byFunc,0x4E, &PCItmp); PCItmp &= 0x8000; // extract done flag } pcibios_read_config_dword(byBus,byFunc,0x50, &PCIserial); Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x400000); Card.memory[DIVAS_CTL_MEMORY] = ioremap(dwCTL, 0x2000); Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x100); Card.io_base=dwDivasIOBase; Card.irq = byIRQ; Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_Q; Card.bus_type = DIA_BUS_TYPE_PCI; FPGA_Done = 0; /* Create four virtual card structures as we want to treat the 4Bri card as 4 Bri cards*/ for(i=0;i<4;i++) { b=Card.memory[DIVAS_RAM_MEMORY]; b+=(MQ_PROTCODE_OFFSET) * (i==0?0:1); DPRINTF(("divas: offset = 0x%x", i* MQ_PROTCODE_OFFSET)); Card.memory[DIVAS_RAM_MEMORY]=b; b = Card.memory[DIVAS_RAM_MEMORY]; b += MQ_SM_OFFSET; Card.memory[DIVAS_SHARED_MEMORY] = b; Card.bus_num = byBus; Card.func_num = byFunc; Card.slot = -1; /* Fill in Name */ Card.name[0] = 'D'; Card.name[1] = 'I'; Card.name[2] = 'V'; Card.name[3] = 'A'; Card.name[4] = 'S'; Card.name[5] = 'Q'; Card.name[6] = '0' + i; Card.name[7] = '\0'; Card.serial = PCIserial; Card.card_id = wNumCards; if (DivasCardNew(&Card) != 0) { // Force for loop to terminate i = 4; continue; } wNumCards++; }//for } wDeviceIndex++; } wDeviceIndex = 0; while (wDeviceIndex < 10) { wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRA, wDeviceIndex, &byBus, &byFunc); if (wPCIConsultation == PCIBIOS_SUCCESSFUL) { dword dwPLXIOBase, dwDivasIOBase; byte byIRQ; printk(KERN_DEBUG "Divas: DIVA Server BRI (S/T) Found\n"); pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1, (unsigned int *) &dwPLXIOBase); dwPLXIOBase &= 0xFFFFFF80; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwDivasIOBase); dwDivasIOBase &= 0xFFFFFFFC; pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ); Card.card_id = wNumCards; Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B; Card.bus_type = DIA_BUS_TYPE_PCI; Card.irq = byIRQ; Card.reset_base = dwPLXIOBase; Card.io_base = dwDivasIOBase; Card.bus_num = byBus; Card.func_num = byFunc; Card.slot = -1; Card.name[0] = 'D'; Card.name[1] = 'I'; Card.name[2] = 'V'; Card.name[3] = 'A'; Card.name[4] = 'S'; Card.name[5] = 'B'; Card.name[6] = '\0'; if (check_region(Card.io_base, 0x20)) { printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F); wDeviceIndex++; continue; } if (check_region(Card.reset_base, 0x80)) { printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F); wDeviceIndex++; continue; } if (DivasCardNew(&Card) != 0) { wDeviceIndex++; continue; } wNumCards++; } wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAQ_U, wDeviceIndex, &byBus, &byFunc); if (wPCIConsultation == PCIBIOS_SUCCESSFUL) { dword dwPLXIOBase, dwDivasIOBase; byte byIRQ; printk(KERN_DEBUG "Divas: DIVA Server BRI (U) Found\n"); pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1, (unsigned int *) &dwPLXIOBase); dwPLXIOBase &= 0xFFFFFF80; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwDivasIOBase); dwDivasIOBase &= 0xFFFFFFFC; pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ); Card.card_id = wNumCards; Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B; Card.bus_type = DIA_BUS_TYPE_PCI; Card.irq = byIRQ; Card.reset_base = dwPLXIOBase; Card.io_base = dwDivasIOBase; Card.bus_num = byBus; Card.func_num = byFunc; Card.slot = -1; Card.name[0] = 'D'; Card.name[1] = 'I'; Card.name[2] = 'V'; Card.name[3] = 'A'; Card.name[4] = 'S'; Card.name[5] = 'B'; Card.name[6] = '\0'; if (check_region(Card.io_base, 0x20)) { printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F); wDeviceIndex++; continue; } if (check_region(Card.reset_base, 0x80)) { printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F); wDeviceIndex++; continue; } if (DivasCardNew(&Card) != 0) { wDeviceIndex++; continue; } wNumCards++; } wDeviceIndex++; } wDeviceIndex = 0; while (wDeviceIndex < 10) { wPCIConsultation = pcibios_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAP, wDeviceIndex, &byBus, &byFunc); if (wPCIConsultation == PCIBIOS_SUCCESSFUL) { dword dwRAM, dwREG, dwCFG; byte byIRQ; printk(KERN_DEBUG "Divas: DIVA Server PRI Found\n"); pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_0, (unsigned int *) &dwRAM); dwRAM &= 0xFFFFF000; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwREG); dwREG &= 0xFFFFF000; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_4, (unsigned int *) &dwCFG); dwCFG &= 0xFFFFF000; pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ); Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x10000); Card.memory[DIVAS_REG_MEMORY] = ioremap(dwREG, 0x4000); Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x1000); Card.memory[DIVAS_SHARED_MEMORY] = Card.memory[DIVAS_RAM_MEMORY] + DIVAS_SHARED_OFFSET; /* pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_1, (unsigned int *) &dwPLXIOBase); dwPLXIOBase &= 0xFFFFFFFc; pcibios_read_config_dword(byBus, byFunc, PCI_BASE_ADDRESS_2, (unsigned int *) &dwDivasIOBase); dwDivasIOBase &= 0xFFFFFF80; pcibios_read_config_byte(byBus, byFunc, PCI_INTERRUPT_LINE, &byIRQ); */ Card.card_id = wNumCards; Card.card_type = DIA_CARD_TYPE_DIVA_SERVER; Card.bus_type = DIA_BUS_TYPE_PCI; Card.irq = byIRQ; /* Card.reset_base = dwPLXIOBase; Card.io_base = dwDivasIOBase;*/ Card.bus_num = byBus; Card.func_num = byFunc; Card.slot = -1; Card.name[0] = 'D'; Card.name[1] = 'I'; Card.name[2] = 'V'; Card.name[3] = 'A'; Card.name[4] = 'S'; Card.name[5] = 'P'; Card.name[6] = '\0'; if (DivasCardNew(&Card) != 0) { wDeviceIndex++; continue; } wNumCards++; } wDeviceIndex++; } printk(KERN_INFO "Divas: %d cards detected\n", wNumCards); if(wNumCards == 0) { return -1; } Divas_fops.ioctl = do_ioctl; Divas_fops.poll = do_poll; Divas_fops.read = do_read; Divas_fops.open = do_open; Divas_fops.release = do_release; Divas_major = register_chrdev(0, "Divas", &Divas_fops); if (Divas_major < 0) { printk(KERN_WARNING "Divas: Unable to register character driver\n"); return -1; } return 0; } /* Error return -1 */ int DivasConfigGet(dia_card_t *card) { /* Retrieve Config from O/S? Not in Linux */ return 0; } dia_config_t *DivasConfig(card_t *card, dia_config_t *config) { /* If config retrieved from OS then copy the data into a dia_config_t structure here and return the pointer here. If the config 'came from above' then just return config; */ return config; } |