12 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <asm/uaccess.h>
18 #include <linux/pci.h>
20 #include <linux/list.h>
21 #include <linux/poll.h>
39 static char *main_revision =
"$Revision: 1.55.4.6 $";
53 "Eicon DIVA Server driver (http://www.melware.net)";
54 static char *DRIVERLNAME =
"divas";
82 #if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2)
83 #define PCI_DEVICE_ID_EICON_MAESTRAP_2 0xE015
86 #if !defined(PCI_DEVICE_ID_EICON_4BRI_VOIP)
87 #define PCI_DEVICE_ID_EICON_4BRI_VOIP 0xE016
90 #if !defined(PCI_DEVICE_ID_EICON_4BRI_2_VOIP)
91 #define PCI_DEVICE_ID_EICON_4BRI_2_VOIP 0xE017
94 #if !defined(PCI_DEVICE_ID_EICON_BRI2M_2)
95 #define PCI_DEVICE_ID_EICON_BRI2M_2 0xE018
98 #if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP)
99 #define PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP 0xE019
102 #if !defined(PCI_DEVICE_ID_EICON_2F)
103 #define PCI_DEVICE_ID_EICON_2F 0xE01A
106 #if !defined(PCI_DEVICE_ID_EICON_BRI2M_2_VOIP)
107 #define PCI_DEVICE_ID_EICON_BRI2M_2_VOIP 0xE01B
151 static int divas_init_one(
struct pci_dev *pdev,
157 .probe = divas_init_one,
159 .id_table = divas_pci_tbl,
165 static char *getrev(
const char *
revision)
169 if ((p =
strchr(revision,
':'))) {
181 unsigned char line[160];
184 vsnprintf(line,
sizeof(line), format, args);
194 strcpy(tmprev, main_revision);
205 return ((
byte) pdev->
bus->number);
215 void *pci_dev_handle)
217 unsigned char irq = 0;
222 return ((
unsigned long)
irq);
226 int bar,
void *pci_dev_handle)
228 unsigned long ret = 0;
235 DBG_TRC((
"GOT BAR[%d]=%08x", bar, ret));
238 unsigned long type = (ret & 0x00000001);
253 void *pci_dev_handle)
259 pci_write_config_byte(dev, offset,
260 *(
unsigned char *) data);
263 pci_write_config_word(dev, offset,
264 *(
unsigned short *) data);
267 pci_write_config_dword(dev, offset,
268 *(
unsigned int *) data);
272 if (!(length % 4) && !(length & 0x03)) {
277 pci_write_config_dword(dev, offset,
285 pci_write_config_byte(dev, offset,
294 void *pci_dev_handle)
300 pci_read_config_byte(dev, offset, (
unsigned char *) data);
303 pci_read_config_word(dev, offset, (
unsigned short *) data);
306 pci_read_config_dword(dev, offset, (
unsigned int *) data);
310 if (!(length % 4) && !(length & 0x03)) {
315 pci_read_config_dword(dev, offset,
323 pci_read_config_byte(dev, offset,
336 static void *diva_pci_alloc_consistent(
struct pci_dev *hwdev,
361 for (i = 0; i < nentries; i++) {
362 if (!(cpu_addr = diva_pci_alloc_consistent(pdev,
372 DBG_TRC((
"dma map alloc [%d]=(%08lx:%08x:%08lx)",
373 i, (
unsigned long) cpu_addr,
375 (
unsigned long) addr_handle))}
394 for (i = 0; (pmap !=
NULL); i++) {
403 DBG_TRC((
"dma map free [%d]=(%08lx:%08x:%08lx)", i,
404 (
unsigned long) cpu_addr, (
dword) dma_handle,
405 (
unsigned long) addr_handle))
418 unsigned long length,
const char *
name,
int id)
422 DBG_ERR((
"A: I/O: can't register port=%08x", port))
434 DBG_TRC((
"remap(%08x)->%p", bar, ret));
450 return (
inb((
unsigned long) addr));
455 return (
inw((
unsigned long) addr));
460 insw((
unsigned long) addr, (
word *) P, length >> 1);
465 outsw((
unsigned long) addr, (
word *) P, length >> 1);
470 outw(w, (
unsigned long) addr);
475 outb(p, (
unsigned long) addr);
496 static void diva_os_dpc_proc(
unsigned long context)
506 void *callback_context)
511 if (!(psoft_isr->
object = pdpc)) {
514 memset(pdpc, 0x00,
sizeof(*pdpc));
525 if (psoft_isr && psoft_isr->
object) {
542 if (psoft_isr && psoft_isr->
object) {
550 diva_os_free(0,
mem);
558 xdi_copy_to_user(
void *os_handle,
void __user *
dst,
const void *
src,
int length)
567 xdi_copy_from_user(
void *os_handle,
void *dst,
const void __user *src,
int length)
583 static int divas_release(
struct inode *inode,
struct file *file)
591 static ssize_t divas_write(
struct file *file,
const char __user *
buf,
592 size_t count, loff_t *ppos)
606 buf, count, xdi_copy_from_user);
618 DBG_TRC((
"write: ret %d", ret));
622 static ssize_t divas_read(
struct file *file,
char __user *buf,
623 size_t count, loff_t *ppos)
637 buf, count, xdi_copy_to_user);
649 DBG_TRC((
"read: ret %d", ret));
653 static unsigned int divas_poll(
struct file *file,
poll_table *
wait)
665 .write = divas_write,
668 .release = divas_release
671 static void divas_unregister_chrdev(
void)
673 unregister_chrdev(major,
DEVNAME);
676 static int __init divas_register_chrdev(
void)
678 if ((major = register_chrdev(0,
DEVNAME, &divas_fops)) < 0)
698 DBG_TRC((
"%s bus: %08x fn: %08x insertion.\n",
702 DRIVERLNAME, CardProperties[ent->
driver_data].Name,
706 DBG_TRC((
"%s: %s bus: %08x fn: %08x device init failed.\n",
715 Name, pdev->
bus->number,
724 DBG_TRC((
"%s: bus: %08x fn: %08x fix latency.\n",
725 DRIVERLNAME, pdev->bus->number, pdev->devfn))
728 DRIVERLNAME, pdev->
bus->number, pdev->devfn);
729 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, new_latency);
733 DBG_TRC((
"%s: %s bus: %08x fn: %08x card init failed.\n",
741 CardProperties[ent->driver_data].
742 Name, pdev->
bus->number,
747 pci_set_drvdata(pdev, pdiva);
754 void *pdiva = pci_get_drvdata(pdev);
756 DBG_TRC((
"bus: %08x fn: %08x removal.\n",
757 pdev->bus->number, pdev->devfn))
759 DRIVERLNAME, pdev->
bus->number, pdev->devfn);
770 static int __init divas_init(
void)
777 strcpy(tmprev, main_revision);
778 printk(
"%s Build: %s(%s)\n", getrev(tmprev),
781 #ifdef CONFIG_ISDN_DIVAS_BRIPCI
784 #ifdef CONFIG_ISDN_DIVAS_PRIPCI
796 if (!divas_register_chrdev()) {
806 divas_unregister_chrdev();
815 if ((ret = pci_register_driver(&diva_pci_driver))) {
818 divas_unregister_chrdev();
834 static void __exit divas_exit(
void)
838 divas_unregister_chrdev();