Rev 44 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 44 | Rev 362 | ||
|---|---|---|---|
| Line 143... | Line 143... | ||
| 143 | return IRQ_RETVAL(0); |
143 | return IRQ_RETVAL(0); |
| 144 | } |
144 | } |
| 145 | 145 | ||
| 146 | static int request_io_memory(PCIConfig *pPch) |
146 | static int request_io_memory(PCIConfig *pPch) |
| 147 | { |
147 | { |
| 148 | if ( |
148 | if (!request_mem_region(pci_resource_start(pPch->pciDev, 0), LCR_SPACE, DEVICE_NAME) ) { |
| 149 | { |
- | |
| - | 149 | PRINTK(KERN_WARNING "%s: LCR memory region %llx-%llx already in use\n", DEVICE_NAME, |
|
| 150 |
|
150 | pci_resource_start(pPch->pciDev, 0), pci_resource_start(pPch->pciDev, 0) + LCR_SPACE ); |
| - | 151 | kfree(pPch); |
|
| 151 | return |
152 | return EBUSY; |
| 152 | } |
- | |
| 153 | 153 | ||
| - | 154 | }; |
|
| 154 | if ( |
155 | if (!request_mem_region(pci_resource_start(pPch->pciDev, 2), CTL_SPACE, DEVICE_NAME) ){ |
| 155 | { |
- | |
| - | 156 | PRINTK(KERN_WARNING "%s: CTL memory region %llx-%llx already in use\n", DEVICE_NAME, |
|
| 156 |
|
157 | pci_resource_start(pPch->pciDev, 0), pci_resource_start(pPch->pciDev, 2) + CTL_SPACE ); |
| - | 158 | kfree(pPch); |
|
| 157 | return |
159 | return EBUSY; |
| 158 | } |
- | |
| 159 | 160 | ||
| 160 | if (check_mem_region(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE)) |
- | |
| 161 | { |
- | |
| 162 | PRINTK(KERN_DEBUG "%s : VME 0x%08lx\n", DEVICE_NAME, (long unsigned int) pci_resource_start(pPch->pciDev, 2) + CTL_SPACE); |
- | |
| 163 | return -EBUSY; |
- | |
| 164 | } |
161 | } |
| - | 162 | if (!request_mem_region(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE, DEVICE_NAME) ){ |
|
| - | 163 | PRINTK(KERN_WARNING "%s: VME memory region %llx-%llx already in use\n", DEVICE_NAME, |
|
| - | 164 | pci_resource_start(pPch->pciDev, 0)+CTL_SPACE, pci_resource_start(pPch->pciDev, 0) + LCR_SPACE+VME_SPACE ); |
|
| - | 165 | kfree(pPch); |
|
| - | 166 | return EBUSY; |
|
| 165 | 167 | ||
| 166 | request_mem_region(pci_resource_start(pPch->pciDev, 0), LCR_SPACE, DEVICE_NAME); |
- | |
| 167 | request_mem_region(pci_resource_start(pPch->pciDev, 2), CTL_SPACE, DEVICE_NAME); |
- | |
| 168 | request_mem_region(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE, DEVICE_NAME); |
- | |
| 169 | 168 | }; |
|
| 170 | return 0; |
169 | return 0; |
| 171 | } |
170 | } |
| 172 | 171 | ||
| 173 | static void release_io_memory(PCIConfig *pPch) |
172 | static void release_io_memory(PCIConfig *pPch) |
| 174 | { |
173 | { |
| 175 | release_mem_region(pci_resource_start(pPch->pciDev, 0), LCR_SPACE); |
174 | release_mem_region(pci_resource_start(pPch->pciDev, 0), LCR_SPACE); |
| 176 | release_mem_region(pci_resource_start(pPch->pciDev, 2), CTL_SPACE); |
175 | release_mem_region(pci_resource_start(pPch->pciDev, 2), CTL_SPACE); |
| 177 | release_mem_region(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE); |
176 | release_mem_region(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE); |
| 178 | } |
177 | } |
| 179 | 178 | ||
| Line 193... | Line 192... | ||
| 193 | { |
192 | { |
| 194 | pd->pPhysVME = pci_resource_start(pPch->pciDev, 2) + CTL_SPACE; |
193 | pd->pPhysVME = pci_resource_start(pPch->pciDev, 2) + CTL_SPACE; |
| 195 | 194 | ||
| 196 | pd->pCtl = (u32)ioremap(pci_resource_start(pPch->pciDev, 2) , CTL_SPACE); |
195 | pd->pCtl = (u32)ioremap(pci_resource_start(pPch->pciDev, 2) , CTL_SPACE); |
| 197 | pd->pVME = (u32)ioremap(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE); |
196 | pd->pVME = (u32)ioremap(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE); |
| 198 | } |
197 | } |
| 199 | 198 | ||
| 200 | return 0; |
199 | return 0; |
| 201 | } |
200 | } |
| 202 | 201 | ||
| 203 | static void un_translate_addresses(DEVICE_OBJ *pd, PCIConfig *pPch) |
202 | static void un_translate_addresses(DEVICE_OBJ *pd, PCIConfig *pPch) |
| 204 | { |
203 | { |
| Line 260... | Line 259... | ||
| 260 | u32 dwStore; |
259 | u32 dwStore; |
| 261 | u16 wRet; |
260 | u16 wRet; |
| 262 | 261 | ||
| 263 | cntrl_store = readw((const volatile void *) pd->pPCIADACntrl); /* read CONTROL register */ |
262 | cntrl_store = readw((const volatile void *) pd->pPCIADACntrl); /* read CONTROL register */ |
| 264 | intCSR_store = readw((const volatile void *) pd->pPCIADAIntCSR); /* read interrupt + CSR register */ |
263 | intCSR_store = readw((const volatile void *) pd->pPCIADAIntCSR); /* read interrupt + CSR register */ |
| 265 | 264 | ||
| 266 | writew(0, (volatile void *) pd->pPCIADAIntCSR); /* disable interrupts */ |
265 | writew(0, (volatile void *) pd->pPCIADAIntCSR); /* disable interrupts */ |
| 267 | writew(cntrl_store | 0x0180, (volatile void *) pd->pPCIADACntrl); /* enable access */ |
266 | writew(cntrl_store | 0x0180, (volatile void *) pd->pPCIADACntrl); /* enable access */ |
| 268 | 267 | ||
| 269 | // save adr register |
268 | // save adr register |
| 270 | dwStore = readl((const volatile void *) dwADRHL); |
269 | dwStore = readl((const volatile void *) dwADRHL); |
| 271 | for (i = 1000; i; i--) |
270 | for (i = 1000; i; i--) |
| 272 | { |
271 | { |
| 273 | writew(0x5555, (volatile void *) dwADRH); |
272 | writew(0x5555, (volatile void *) dwADRH); |
| 274 | writew(0xAAAA, (volatile void *) dwADRL); |
273 | writew(0xAAAA, (volatile void *) dwADRL); |
| 275 | wRet = readw((const volatile void *) dwADRH); |
274 | wRet = readw((const volatile void *) dwADRH); |
| 276 | if (wRet != 0x5555) |
275 | if (wRet != 0x5555) |
| 277 | { |
276 | { |
| 278 | error = 1; |
277 | error = 1; |
| 279 | break; |
278 | break; |
| 280 | } |
279 | } |
| 281 | 280 | ||
| 282 | writew(0xAAAA, (volatile void *) dwADRH); |
281 | writew(0xAAAA, (volatile void *) dwADRH); |
| 283 | writew(0x5555, (volatile void *) dwADRL); |
282 | writew(0x5555, (volatile void *) dwADRL); |
| 284 | wRet = readw((const volatile void *) dwADRH); |
283 | wRet = readw((const volatile void *) dwADRH); |
| 285 | if (wRet != 0xAAAA) |
284 | if (wRet != 0xAAAA) |
| 286 | { |
285 | { |
| 287 | error = 1; |
286 | error = 1; |
| 288 | break; |
287 | break; |
| 289 | } |
288 | } |
| 290 | 289 | ||
| 291 | writew(0x0000, (volatile void *) dwADRH); |
290 | writew(0x0000, (volatile void *) dwADRH); |
| 292 | writew(0xFFFF, (volatile void *) dwADRL); |
291 | writew(0xFFFF, (volatile void *) dwADRL); |
| 293 | wRet = readw((const volatile void *) dwADRH); |
292 | wRet = readw((const volatile void *) dwADRH); |
| 294 | if (wRet != 0x0000) |
293 | if (wRet != 0x0000) |
| 295 | { |
294 | { |
| 296 | error = 1; |
295 | error = 1; |
| 297 | break; |
296 | break; |
| 298 | } |
297 | } |
| 299 | 298 | ||
| 300 | writew(0xFFFF, (volatile void *) dwADRH); |
299 | writew(0xFFFF, (volatile void *) dwADRH); |
| 301 | writew(0x0000, (volatile void *) dwADRL); |
300 | writew(0x0000, (volatile void *) dwADRL); |
| 302 | wRet = readw((const volatile void *) dwADRH); |
301 | wRet = readw((const volatile void *) dwADRH); |
| 303 | if (wRet != 0xFFFF) |
302 | if (wRet != 0xFFFF) |
| Line 365... | Line 364... | ||
| 365 | } |
364 | } |
| 366 | 365 | ||
| 367 | return found; |
366 | return found; |
| 368 | } |
367 | } |
| 369 | 368 | ||
| 370 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
- | |
| 371 | static int pcivme_read_proc(char *buf, char **start, off_t offset, int len) |
- | |
| 372 | #else |
- | |
| 373 | //static int pcivme_read_proc(char *buf, char **start, off_t offset, int len, int *eof, void *data) |
369 | //static int pcivme_read_proc(char *buf, char **start, off_t offset, int len, int *eof, void *data) |
| 374 | static |
370 | static ssize_t pcivme_read_proc(struct file *filp,char *buf,size_t count,loff_t *offp ) |
| 375 | #endif |
- | |
| 376 | { |
371 | { |
| 377 | int pos = 0; |
372 | int pos = 0; |
| 378 | DEVICE_OBJ *pd; |
373 | DEVICE_OBJ *pd; |
| 379 | PCIConfig *ch; |
374 | PCIConfig *ch; |
| 380 | u16 cntrl; |
375 | u16 cntrl; |
| 381 | char *cause = "none"; |
376 | char *cause = "none"; |
| 382 | struct list_head *ptr; |
377 | struct list_head *ptr; |
| 383 | PRINTK(KERN_DEBUG "%s : pcivme_read_proc()\n",DEVICE_NAME); |
378 | PRINTK(KERN_DEBUG "%s : pcivme_read_proc()\n",DEVICE_NAME); |
| 384 | 379 | ||
| 385 | if (*offp != 0) return 0; |
380 | if (*offp != 0) return 0; |
| 386 | pos += sprintf(buf + pos, "\nPCIVME information. Version %d.%d |
381 | pos += sprintf(buf + pos, "\nPCIVME information. Version %d.%d from Klaus Hitschler.\n", VERSION_HI, VERSION_LO); |
| 387 | 382 | ||
| 388 | pos += sprintf(buf + pos, " ---------------------\n"); |
383 | pos += sprintf(buf + pos, " ---------------------\n"); |
| 389 | pos += sprintf(buf + pos, " Interfaces found : %d\n", drv.count); |
384 | pos += sprintf(buf + pos, " Interfaces found : %d\n", drv.count); |
| 390 | pos += sprintf(buf + pos, " Major Number : %d\n", drv.nMajor); |
385 | pos += sprintf(buf + pos, " Major Number : %d\n", drv.nMajor); |
| 391 | 386 | ||
| Line 427... | Line 422... | ||
| 427 | if (pos>count) { |
422 | if (pos>count) { |
| 428 | buf[count-1]=0; |
423 | buf[count-1]=0; |
| 429 | pos=count; |
424 | pos=count; |
| 430 | } |
425 | } |
| 431 | PRINTK(KERN_DEBUG "%s : pcivme_read_proc() end count=%d\n",DEVICE_NAME, pos); |
426 | PRINTK(KERN_DEBUG "%s : pcivme_read_proc() end count=%d\n",DEVICE_NAME, pos); |
| 432 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) |
- | |
| 433 | //*eof = 1; |
427 | //*eof = 1; |
| 434 | #endif |
- | |
| 435 | *offp = pos; |
428 | *offp = pos; |
| 436 | - | ||
| 437 | return pos; |
429 | return pos; |
| 438 | } |
430 | } |
| 439 | 431 | ||
| 440 | - | ||
| 441 | - | ||
| 442 | - | ||
| 443 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
- | |
| 444 | struct proc_dir_entry pcimod_proc_entry = |
- | |
| 445 | { |
- | |
| 446 | namelen: 7, /* len of name */ |
- | |
| 447 | name: DEVICE_NAME, /* entry name */ |
- | |
| 448 | mode: S_IFREG | S_IRUGO, /* mode */ |
- | |
| 449 | nlink: 1, /* nlinks */ |
- | |
| 450 | get_info: pcivme_read_proc, /* function used to read data */ |
- | |
| 451 | }; |
- | |
| 452 | #else |
- | |
| 453 |
|
432 | static const struct proc_ops pcivme_read_proc_fops = { |
| 454 |
|
433 | proc_read: pcivme_read_proc |
| 455 | }; |
434 | }; |
| 456 | #endif |
- | |
| 457 | 435 | ||
| 458 | static void deleteMyLists(void) |
436 | static void deleteMyLists(void) |
| 459 | { |
437 | { |
| 460 | DEVICE_OBJ *pd; |
438 | DEVICE_OBJ *pd; |
| 461 | 439 | ||
| Line 529... | Line 507... | ||
| 529 | pd->pCSR = pd->pCtl + CSR; |
507 | pd->pCSR = pd->pCtl + CSR; |
| 530 | 508 | ||
| 531 | pd->pPCIADACntrl = pd->pLCR + PLX9050_CNTRL; |
509 | pd->pPCIADACntrl = pd->pLCR + PLX9050_CNTRL; |
| 532 | pd->pPCIADAIntCSR = pd->pLCR + PLX9050_INTCSR; |
510 | pd->pPCIADAIntCSR = pd->pLCR + PLX9050_INTCSR; |
| 533 | 511 | ||
| 534 |
|
512 | //if (request_irq(pd->pPch->pciDev->irq, pcivme_irqhandler, IRQF_DISABLED| IRQF_SHARED, DEVICE_NAME, pd)) |
| - | 513 | if (request_irq(pd->pPch->pciDev->irq, pcivme_irqhandler, IRQF_SHARED, DEVICE_NAME, pd)) |
|
| 535 | { |
514 | { |
| 536 | printk(KERN_ERR "%s : can't get irq @ %d\n", DEVICE_NAME, pd->pPch->pciDev->irq); |
515 | printk(KERN_ERR "%s : can't get irq @ %d\n", DEVICE_NAME, pd->pPch->pciDev->irq); |
| 537 | kfree_s(pd, sizeof(*pd)); // FREE(pd); |
516 | kfree_s(pd, sizeof(*pd)); // FREE(pd); |
| 538 | } |
517 | } |
| 539 | else |
518 | else |
| Line 603... | Line 582... | ||
| 603 | PRINTK(KERN_DEBUG "%s : cleanup_module.\n", DEVICE_NAME); |
582 | PRINTK(KERN_DEBUG "%s : cleanup_module.\n", DEVICE_NAME); |
| 604 | 583 | ||
| 605 | unregister_chrdev(drv.nMajor, DEVICE_NAME); |
584 | unregister_chrdev(drv.nMajor, DEVICE_NAME); |
| 606 | 585 | ||
| 607 | /* unregister the proc device */ |
586 | /* unregister the proc device */ |
| 608 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
- | |
| 609 | proc_unregister(&proc_root, pcimod_proc_entry.low_ino); |
- | |
| 610 | #else |
- | |
| 611 | remove_proc_entry(DEVICE_NAME, NULL); |
587 | remove_proc_entry(DEVICE_NAME, NULL); |
| 612 | #endif |
- | |
| 613 | 588 | ||
| 614 | /* redo all */ |
589 | /* redo all */ |
| 615 | for (ptr = drv.devList.next; ptr != &drv.devList; ptr = ptr->next) |
590 | for (ptr = drv.devList.next; ptr != &drv.devList; ptr = ptr->next) |
| 616 | { |
591 | { |
| 617 | pd = list_entry(ptr, DEVICE_OBJ, list); |
592 | pd = list_entry(ptr, DEVICE_OBJ, list); |