123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849 |
- /* $Id: divasmain.c,v 1.55.4.6 2005/02/09 19:28:20 armin Exp $
- *
- * Low level driver for Eicon DIVA Server ISDN cards.
- *
- * Copyright 2000-2003 by Armin Schindler (mac@melware.de)
- * Copyright 2000-2003 Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- */
- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/kernel.h>
- #include <asm/uaccess.h>
- #include <asm/io.h>
- #include <linux/ioport.h>
- #include <linux/pci.h>
- #include <linux/interrupt.h>
- #include <linux/list.h>
- #include <linux/poll.h>
- #include <linux/kmod.h>
- #include "platform.h"
- #undef ID_MASK
- #undef N_DATA
- #include "pc.h"
- #include "di_defs.h"
- #include "divasync.h"
- #include "diva.h"
- #include "di.h"
- #include "io.h"
- #include "xdi_msg.h"
- #include "xdi_adapter.h"
- #include "xdi_vers.h"
- #include "diva_dma.h"
- #include "diva_pci.h"
- static char *main_revision = "$Revision: 1.55.4.6 $";
- static int major;
- static int dbgmask;
- MODULE_DESCRIPTION("Kernel driver for Eicon DIVA Server cards");
- MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
- MODULE_LICENSE("GPL");
- module_param(dbgmask, int, 0);
- MODULE_PARM_DESC(dbgmask, "initial debug mask");
- static char *DRIVERNAME =
- "Eicon DIVA Server driver (http://www.melware.net)";
- static char *DRIVERLNAME = "divas";
- static char *DEVNAME = "Divas";
- char *DRIVERRELEASE_DIVAS = "2.0";
- extern irqreturn_t diva_os_irq_wrapper(int irq, void *context);
- extern int create_divas_proc(void);
- extern void remove_divas_proc(void);
- extern void diva_get_vserial_number(PISDN_ADAPTER IoAdapter, char *buf);
- extern int divasfunc_init(int dbgmask);
- extern void divasfunc_exit(void);
- typedef struct _diva_os_thread_dpc {
- struct tasklet_struct divas_task;
- diva_os_soft_isr_t *psoft_isr;
- } diva_os_thread_dpc_t;
- /* --------------------------------------------------------------------------
- PCI driver interface section
- -------------------------------------------------------------------------- */
- /*
- vendor, device Vendor and device ID to match (or PCI_ANY_ID)
- subvendor, Subsystem vendor and device ID to match (or PCI_ANY_ID)
- subdevice
- class, Device class to match. The class_mask tells which bits
- class_mask of the class are honored during the comparison.
- driver_data Data private to the driver.
- */
- #if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2)
- #define PCI_DEVICE_ID_EICON_MAESTRAP_2 0xE015
- #endif
- #if !defined(PCI_DEVICE_ID_EICON_4BRI_VOIP)
- #define PCI_DEVICE_ID_EICON_4BRI_VOIP 0xE016
- #endif
- #if !defined(PCI_DEVICE_ID_EICON_4BRI_2_VOIP)
- #define PCI_DEVICE_ID_EICON_4BRI_2_VOIP 0xE017
- #endif
- #if !defined(PCI_DEVICE_ID_EICON_BRI2M_2)
- #define PCI_DEVICE_ID_EICON_BRI2M_2 0xE018
- #endif
- #if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP)
- #define PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP 0xE019
- #endif
- #if !defined(PCI_DEVICE_ID_EICON_2F)
- #define PCI_DEVICE_ID_EICON_2F 0xE01A
- #endif
- #if !defined(PCI_DEVICE_ID_EICON_BRI2M_2_VOIP)
- #define PCI_DEVICE_ID_EICON_BRI2M_2_VOIP 0xE01B
- #endif
- /*
- This table should be sorted by PCI device ID
- */
- static struct pci_device_id divas_pci_tbl[] = {
- /* Diva Server BRI-2M PCI 0xE010 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRA),
- CARDTYPE_MAESTRA_PCI },
- /* Diva Server 4BRI-8M PCI 0xE012 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAQ),
- CARDTYPE_DIVASRV_Q_8M_PCI },
- /* Diva Server 4BRI-8M 2.0 PCI 0xE013 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAQ_U),
- CARDTYPE_DIVASRV_Q_8M_V2_PCI },
- /* Diva Server PRI-30M PCI 0xE014 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAP),
- CARDTYPE_DIVASRV_P_30M_PCI },
- /* Diva Server PRI 2.0 adapter 0xE015 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAP_2),
- CARDTYPE_DIVASRV_P_30M_V2_PCI },
- /* Diva Server Voice 4BRI-8M PCI 0xE016 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_4BRI_VOIP),
- CARDTYPE_DIVASRV_VOICE_Q_8M_PCI },
- /* Diva Server Voice 4BRI-8M 2.0 PCI 0xE017 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_4BRI_2_VOIP),
- CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI },
- /* Diva Server BRI-2M 2.0 PCI 0xE018 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_BRI2M_2),
- CARDTYPE_DIVASRV_B_2M_V2_PCI },
- /* Diva Server Voice PRI 2.0 PCI 0xE019 */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP),
- CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI },
- /* Diva Server 2FX 0xE01A */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_2F),
- CARDTYPE_DIVASRV_B_2F_PCI },
- /* Diva Server Voice BRI-2M 2.0 PCI 0xE01B */
- { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_BRI2M_2_VOIP),
- CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI },
- { 0, } /* 0 terminated list. */
- };
- MODULE_DEVICE_TABLE(pci, divas_pci_tbl);
- static int divas_init_one(struct pci_dev *pdev,
- const struct pci_device_id *ent);
- static void divas_remove_one(struct pci_dev *pdev);
- static struct pci_driver diva_pci_driver = {
- .name = "divas",
- .probe = divas_init_one,
- .remove = divas_remove_one,
- .id_table = divas_pci_tbl,
- };
- /*********************************************************
- ** little helper functions
- *********************************************************/
- static char *getrev(const char *revision)
- {
- char *rev;
- char *p;
- if ((p = strchr(revision, ':'))) {
- rev = p + 2;
- p = strchr(rev, '$');
- *--p = 0;
- } else
- rev = "1.0";
- return rev;
- }
- void diva_log_info(unsigned char *format, ...)
- {
- va_list args;
- unsigned char line[160];
- va_start(args, format);
- vsnprintf(line, sizeof(line), format, args);
- va_end(args);
- printk(KERN_INFO "%s: %s\n", DRIVERLNAME, line);
- }
- void divas_get_version(char *p)
- {
- char tmprev[32];
- strcpy(tmprev, main_revision);
- sprintf(p, "%s: %s(%s) %s(%s) major=%d\n", DRIVERLNAME, DRIVERRELEASE_DIVAS,
- getrev(tmprev), diva_xdi_common_code_build, DIVA_BUILD, major);
- }
- /* --------------------------------------------------------------------------
- PCI Bus services
- -------------------------------------------------------------------------- */
- byte diva_os_get_pci_bus(void *pci_dev_handle)
- {
- struct pci_dev *pdev = (struct pci_dev *) pci_dev_handle;
- return ((byte) pdev->bus->number);
- }
- byte diva_os_get_pci_func(void *pci_dev_handle)
- {
- struct pci_dev *pdev = (struct pci_dev *) pci_dev_handle;
- return ((byte) pdev->devfn);
- }
- unsigned long divasa_get_pci_irq(unsigned char bus, unsigned char func,
- void *pci_dev_handle)
- {
- unsigned char irq = 0;
- struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
- irq = dev->irq;
- return ((unsigned long) irq);
- }
- unsigned long divasa_get_pci_bar(unsigned char bus, unsigned char func,
- int bar, void *pci_dev_handle)
- {
- unsigned long ret = 0;
- struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
- if (bar < 6) {
- ret = dev->resource[bar].start;
- }
- DBG_TRC(("GOT BAR[%d]=%08x", bar, ret));
- {
- unsigned long type = (ret & 0x00000001);
- if (type & PCI_BASE_ADDRESS_SPACE_IO) {
- DBG_TRC((" I/O"));
- ret &= PCI_BASE_ADDRESS_IO_MASK;
- } else {
- DBG_TRC((" memory"));
- ret &= PCI_BASE_ADDRESS_MEM_MASK;
- }
- DBG_TRC((" final=%08x", ret));
- }
- return (ret);
- }
- void PCIwrite(byte bus, byte func, int offset, void *data, int length,
- void *pci_dev_handle)
- {
- struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
- switch (length) {
- case 1: /* byte */
- pci_write_config_byte(dev, offset,
- *(unsigned char *) data);
- break;
- case 2: /* word */
- pci_write_config_word(dev, offset,
- *(unsigned short *) data);
- break;
- case 4: /* dword */
- pci_write_config_dword(dev, offset,
- *(unsigned int *) data);
- break;
- default: /* buffer */
- if (!(length % 4) && !(length & 0x03)) { /* Copy as dword */
- dword *p = (dword *) data;
- length /= 4;
- while (length--) {
- pci_write_config_dword(dev, offset,
- *(unsigned int *)
- p++);
- }
- } else { /* copy as byte stream */
- byte *p = (byte *) data;
- while (length--) {
- pci_write_config_byte(dev, offset,
- *(unsigned char *)
- p++);
- }
- }
- }
- }
- void PCIread(byte bus, byte func, int offset, void *data, int length,
- void *pci_dev_handle)
- {
- struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
- switch (length) {
- case 1: /* byte */
- pci_read_config_byte(dev, offset, (unsigned char *) data);
- break;
- case 2: /* word */
- pci_read_config_word(dev, offset, (unsigned short *) data);
- break;
- case 4: /* dword */
- pci_read_config_dword(dev, offset, (unsigned int *) data);
- break;
- default: /* buffer */
- if (!(length % 4) && !(length & 0x03)) { /* Copy as dword */
- dword *p = (dword *) data;
- length /= 4;
- while (length--) {
- pci_read_config_dword(dev, offset,
- (unsigned int *)
- p++);
- }
- } else { /* copy as byte stream */
- byte *p = (byte *) data;
- while (length--) {
- pci_read_config_byte(dev, offset,
- (unsigned char *)
- p++);
- }
- }
- }
- }
- /*
- Init map with DMA pages. It is not problem if some allocations fail -
- the channels that will not get one DMA page will use standard PIO
- interface
- */
- static void *diva_pci_alloc_consistent(struct pci_dev *hwdev,
- size_t size,
- dma_addr_t *dma_handle,
- void **addr_handle)
- {
- void *addr = pci_alloc_consistent(hwdev, size, dma_handle);
- *addr_handle = addr;
- return (addr);
- }
- void diva_init_dma_map(void *hdev,
- struct _diva_dma_map_entry **ppmap, int nentries)
- {
- struct pci_dev *pdev = (struct pci_dev *) hdev;
- struct _diva_dma_map_entry *pmap =
- diva_alloc_dma_map(hdev, nentries);
- if (pmap) {
- int i;
- dma_addr_t dma_handle;
- void *cpu_addr;
- void *addr_handle;
- for (i = 0; i < nentries; i++) {
- if (!(cpu_addr = diva_pci_alloc_consistent(pdev,
- PAGE_SIZE,
- &dma_handle,
- &addr_handle)))
- {
- break;
- }
- diva_init_dma_map_entry(pmap, i, cpu_addr,
- (dword) dma_handle,
- addr_handle);
- DBG_TRC(("dma map alloc [%d]=(%08lx:%08x:%08lx)",
- i, (unsigned long) cpu_addr,
- (dword) dma_handle,
- (unsigned long) addr_handle))}
- }
- *ppmap = pmap;
- }
- /*
- Free all contained in the map entries and memory used by the map
- Should be always called after adapter removal from DIDD array
- */
- void diva_free_dma_map(void *hdev, struct _diva_dma_map_entry *pmap)
- {
- struct pci_dev *pdev = (struct pci_dev *) hdev;
- int i;
- dword phys_addr;
- void *cpu_addr;
- dma_addr_t dma_handle;
- void *addr_handle;
- for (i = 0; (pmap != NULL); i++) {
- diva_get_dma_map_entry(pmap, i, &cpu_addr, &phys_addr);
- if (!cpu_addr) {
- break;
- }
- addr_handle = diva_get_entry_handle(pmap, i);
- dma_handle = (dma_addr_t) phys_addr;
- pci_free_consistent(pdev, PAGE_SIZE, addr_handle,
- dma_handle);
- DBG_TRC(("dma map free [%d]=(%08lx:%08x:%08lx)", i,
- (unsigned long) cpu_addr, (dword) dma_handle,
- (unsigned long) addr_handle))
- }
- diva_free_dma_mapping(pmap);
- }
- /*********************************************************
- ** I/O port utilities
- *********************************************************/
- int
- diva_os_register_io_port(void *adapter, int on, unsigned long port,
- unsigned long length, const char *name, int id)
- {
- if (on) {
- if (!request_region(port, length, name)) {
- DBG_ERR(("A: I/O: can't register port=%08x", port))
- return (-1);
- }
- } else {
- release_region(port, length);
- }
- return (0);
- }
- void __iomem *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a, int id, unsigned long bar, unsigned long area_length)
- {
- void __iomem *ret = ioremap(bar, area_length);
- DBG_TRC(("remap(%08x)->%p", bar, ret));
- return (ret);
- }
- void divasa_unmap_pci_bar(void __iomem *bar)
- {
- if (bar) {
- iounmap(bar);
- }
- }
- /*********************************************************
- ** I/O port access
- *********************************************************/
- inline byte inpp(void __iomem *addr)
- {
- return (inb((unsigned long) addr));
- }
- inline word inppw(void __iomem *addr)
- {
- return (inw((unsigned long) addr));
- }
- inline void inppw_buffer(void __iomem *addr, void *P, int length)
- {
- insw((unsigned long) addr, (word *) P, length >> 1);
- }
- inline void outppw_buffer(void __iomem *addr, void *P, int length)
- {
- outsw((unsigned long) addr, (word *) P, length >> 1);
- }
- inline void outppw(void __iomem *addr, word w)
- {
- outw(w, (unsigned long) addr);
- }
- inline void outpp(void __iomem *addr, word p)
- {
- outb(p, (unsigned long) addr);
- }
- /* --------------------------------------------------------------------------
- IRQ request / remove
- -------------------------------------------------------------------------- */
- int diva_os_register_irq(void *context, byte irq, const char *name)
- {
- int result = request_irq(irq, diva_os_irq_wrapper,
- IRQF_SHARED, name, context);
- return (result);
- }
- void diva_os_remove_irq(void *context, byte irq)
- {
- free_irq(irq, context);
- }
- /* --------------------------------------------------------------------------
- DPC framework implementation
- -------------------------------------------------------------------------- */
- static void diva_os_dpc_proc(unsigned long context)
- {
- diva_os_thread_dpc_t *psoft_isr = (diva_os_thread_dpc_t *) context;
- diva_os_soft_isr_t *pisr = psoft_isr->psoft_isr;
- (*(pisr->callback)) (pisr, pisr->callback_context);
- }
- int diva_os_initialize_soft_isr(diva_os_soft_isr_t *psoft_isr,
- diva_os_soft_isr_callback_t callback,
- void *callback_context)
- {
- diva_os_thread_dpc_t *pdpc;
- pdpc = (diva_os_thread_dpc_t *) diva_os_malloc(0, sizeof(*pdpc));
- if (!(psoft_isr->object = pdpc)) {
- return (-1);
- }
- memset(pdpc, 0x00, sizeof(*pdpc));
- psoft_isr->callback = callback;
- psoft_isr->callback_context = callback_context;
- pdpc->psoft_isr = psoft_isr;
- tasklet_init(&pdpc->divas_task, diva_os_dpc_proc, (unsigned long)pdpc);
- return (0);
- }
- int diva_os_schedule_soft_isr(diva_os_soft_isr_t *psoft_isr)
- {
- if (psoft_isr && psoft_isr->object) {
- diva_os_thread_dpc_t *pdpc =
- (diva_os_thread_dpc_t *) psoft_isr->object;
- tasklet_schedule(&pdpc->divas_task);
- }
- return (1);
- }
- int diva_os_cancel_soft_isr(diva_os_soft_isr_t *psoft_isr)
- {
- return (0);
- }
- void diva_os_remove_soft_isr(diva_os_soft_isr_t *psoft_isr)
- {
- if (psoft_isr && psoft_isr->object) {
- diva_os_thread_dpc_t *pdpc =
- (diva_os_thread_dpc_t *) psoft_isr->object;
- void *mem;
- tasklet_kill(&pdpc->divas_task);
- mem = psoft_isr->object;
- psoft_isr->object = NULL;
- diva_os_free(0, mem);
- }
- }
- /*
- * kernel/user space copy functions
- */
- static int
- xdi_copy_to_user(void *os_handle, void __user *dst, const void *src, int length)
- {
- if (copy_to_user(dst, src, length)) {
- return (-EFAULT);
- }
- return (length);
- }
- static int
- xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int length)
- {
- if (copy_from_user(dst, src, length)) {
- return (-EFAULT);
- }
- return (length);
- }
- /*
- * device node operations
- */
- static int divas_open(struct inode *inode, struct file *file)
- {
- return (0);
- }
- static int divas_release(struct inode *inode, struct file *file)
- {
- if (file->private_data) {
- diva_xdi_close_adapter(file->private_data, file);
- }
- return (0);
- }
- static ssize_t divas_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
- {
- diva_xdi_um_cfg_cmd_t msg;
- int ret = -EINVAL;
- if (!file->private_data) {
- file->private_data = diva_xdi_open_adapter(file, buf,
- count, &msg,
- xdi_copy_from_user);
- if (!file->private_data)
- return (-ENODEV);
- ret = diva_xdi_write(file->private_data, file,
- buf, count, &msg, xdi_copy_from_user);
- } else {
- ret = diva_xdi_write(file->private_data, file,
- buf, count, NULL, xdi_copy_from_user);
- }
- switch (ret) {
- case -1: /* Message should be removed from rx mailbox first */
- ret = -EBUSY;
- break;
- case -2: /* invalid adapter was specified in this call */
- ret = -ENOMEM;
- break;
- case -3:
- ret = -ENXIO;
- break;
- }
- DBG_TRC(("write: ret %d", ret));
- return (ret);
- }
- static ssize_t divas_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
- {
- diva_xdi_um_cfg_cmd_t msg;
- int ret = -EINVAL;
- if (!file->private_data) {
- file->private_data = diva_xdi_open_adapter(file, buf,
- count, &msg,
- xdi_copy_from_user);
- }
- if (!file->private_data) {
- return (-ENODEV);
- }
- ret = diva_xdi_read(file->private_data, file,
- buf, count, xdi_copy_to_user);
- switch (ret) {
- case -1: /* RX mailbox is empty */
- ret = -EAGAIN;
- break;
- case -2: /* no memory, mailbox was cleared, last command is failed */
- ret = -ENOMEM;
- break;
- case -3: /* can't copy to user, retry */
- ret = -EFAULT;
- break;
- }
- DBG_TRC(("read: ret %d", ret));
- return (ret);
- }
- static unsigned int divas_poll(struct file *file, poll_table *wait)
- {
- if (!file->private_data) {
- return (POLLERR);
- }
- return (POLLIN | POLLRDNORM);
- }
- static const struct file_operations divas_fops = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .read = divas_read,
- .write = divas_write,
- .poll = divas_poll,
- .open = divas_open,
- .release = divas_release
- };
- static void divas_unregister_chrdev(void)
- {
- unregister_chrdev(major, DEVNAME);
- }
- static int __init divas_register_chrdev(void)
- {
- if ((major = register_chrdev(0, DEVNAME, &divas_fops)) < 0)
- {
- printk(KERN_ERR "%s: failed to create /dev entry.\n",
- DRIVERLNAME);
- return (0);
- }
- return (1);
- }
- /* --------------------------------------------------------------------------
- PCI driver section
- -------------------------------------------------------------------------- */
- static int divas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
- {
- void *pdiva = NULL;
- u8 pci_latency;
- u8 new_latency = 32;
- DBG_TRC(("%s bus: %08x fn: %08x insertion.\n",
- CardProperties[ent->driver_data].Name,
- pdev->bus->number, pdev->devfn))
- printk(KERN_INFO "%s: %s bus: %08x fn: %08x insertion.\n",
- DRIVERLNAME, CardProperties[ent->driver_data].Name,
- pdev->bus->number, pdev->devfn);
- if (pci_enable_device(pdev)) {
- DBG_TRC(("%s: %s bus: %08x fn: %08x device init failed.\n",
- DRIVERLNAME,
- CardProperties[ent->driver_data].Name,
- pdev->bus->number,
- pdev->devfn))
- printk(KERN_ERR
- "%s: %s bus: %08x fn: %08x device init failed.\n",
- DRIVERLNAME,
- CardProperties[ent->driver_data].
- Name, pdev->bus->number,
- pdev->devfn);
- return (-EIO);
- }
- pci_set_master(pdev);
- pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
- if (!pci_latency) {
- DBG_TRC(("%s: bus: %08x fn: %08x fix latency.\n",
- DRIVERLNAME, pdev->bus->number, pdev->devfn))
- printk(KERN_INFO
- "%s: bus: %08x fn: %08x fix latency.\n",
- DRIVERLNAME, pdev->bus->number, pdev->devfn);
- pci_write_config_byte(pdev, PCI_LATENCY_TIMER, new_latency);
- }
- if (!(pdiva = diva_driver_add_card(pdev, ent->driver_data))) {
- DBG_TRC(("%s: %s bus: %08x fn: %08x card init failed.\n",
- DRIVERLNAME,
- CardProperties[ent->driver_data].Name,
- pdev->bus->number,
- pdev->devfn))
- printk(KERN_ERR
- "%s: %s bus: %08x fn: %08x card init failed.\n",
- DRIVERLNAME,
- CardProperties[ent->driver_data].
- Name, pdev->bus->number,
- pdev->devfn);
- return (-EIO);
- }
- pci_set_drvdata(pdev, pdiva);
- return (0);
- }
- static void divas_remove_one(struct pci_dev *pdev)
- {
- void *pdiva = pci_get_drvdata(pdev);
- DBG_TRC(("bus: %08x fn: %08x removal.\n",
- pdev->bus->number, pdev->devfn))
- printk(KERN_INFO "%s: bus: %08x fn: %08x removal.\n",
- DRIVERLNAME, pdev->bus->number, pdev->devfn);
- if (pdiva) {
- diva_driver_remove_card(pdiva);
- }
- }
- /* --------------------------------------------------------------------------
- Driver Load / Startup
- -------------------------------------------------------------------------- */
- static int __init divas_init(void)
- {
- char tmprev[50];
- int ret = 0;
- printk(KERN_INFO "%s\n", DRIVERNAME);
- printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIVAS);
- strcpy(tmprev, main_revision);
- printk("%s Build: %s(%s)\n", getrev(tmprev),
- diva_xdi_common_code_build, DIVA_BUILD);
- printk(KERN_INFO "%s: support for: ", DRIVERLNAME);
- #ifdef CONFIG_ISDN_DIVAS_BRIPCI
- printk("BRI/PCI ");
- #endif
- #ifdef CONFIG_ISDN_DIVAS_PRIPCI
- printk("PRI/PCI ");
- #endif
- printk("adapters\n");
- if (!divasfunc_init(dbgmask)) {
- printk(KERN_ERR "%s: failed to connect to DIDD.\n",
- DRIVERLNAME);
- ret = -EIO;
- goto out;
- }
- if (!divas_register_chrdev()) {
- #ifdef MODULE
- divasfunc_exit();
- #endif
- ret = -EIO;
- goto out;
- }
- if (!create_divas_proc()) {
- #ifdef MODULE
- divas_unregister_chrdev();
- divasfunc_exit();
- #endif
- printk(KERN_ERR "%s: failed to create proc entry.\n",
- DRIVERLNAME);
- ret = -EIO;
- goto out;
- }
- if ((ret = pci_register_driver(&diva_pci_driver))) {
- #ifdef MODULE
- remove_divas_proc();
- divas_unregister_chrdev();
- divasfunc_exit();
- #endif
- printk(KERN_ERR "%s: failed to init pci driver.\n",
- DRIVERLNAME);
- goto out;
- }
- printk(KERN_INFO "%s: started with major %d\n", DRIVERLNAME, major);
- out:
- return (ret);
- }
- /* --------------------------------------------------------------------------
- Driver Unload
- -------------------------------------------------------------------------- */
- static void __exit divas_exit(void)
- {
- pci_unregister_driver(&diva_pci_driver);
- remove_divas_proc();
- divas_unregister_chrdev();
- divasfunc_exit();
- printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
- }
- module_init(divas_init);
- module_exit(divas_exit);
|