int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; unsigned long flags; int retval; b1dma_reset(card); if ((retval = b1_load_t4file(card, &data->firmware))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load t4file!!\n", card->name); return retval; } if (data->configuration.len > 0 && data->configuration.data) { if ((retval = b1_load_config(card, &data->configuration))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load config!!\n", card->name); return retval; } } if (!b1dma_loaded(card)) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load t4file.\n", card->name); return -EIO; } save_flags(flags); cli(); card->csr = AVM_FLAG; b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); b1dmaoutmeml(card->mbase+AMCC_MCSR, EN_A2P_TRANSFERS|EN_P2A_TRANSFERS |A2P_HI_PRIORITY|P2A_HI_PRIORITY |RESET_A2P_FLAGS|RESET_P2A_FLAGS); t1outp(card->port, 0x07, 0x30); t1outp(card->port, 0x10, 0xF0); card->dma->recvlen = 0; b1dmaoutmeml(card->mbase+AMCC_RXPTR, virt_to_phys(card->dma->recvbuf)); b1dmaoutmeml(card->mbase+AMCC_RXLEN, 4); card->csr |= EN_RX_TC_INT; b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); restore_flags(flags); b1dma_send_init(card); return 0; }
int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; int retval; b1dma_reset(card); if ((retval = b1_load_t4file(card, &data->firmware))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load t4file!!\n", card->name); return retval; } if (data->configuration.len > 0 && data->configuration.data) { if ((retval = b1_load_config(card, &data->configuration))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load config!!\n", card->name); return retval; } } if (!b1dma_loaded(card)) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load t4file.\n", card->name); return -EIO; } card->csr = AVM_FLAG; b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_writel(card, EN_A2P_TRANSFERS | EN_P2A_TRANSFERS | A2P_HI_PRIORITY | P2A_HI_PRIORITY | RESET_A2P_FLAGS | RESET_P2A_FLAGS, AMCC_MCSR); t1outp(card->port, 0x07, 0x30); t1outp(card->port, 0x10, 0xF0); card->dma->recvlen = 0; b1dma_writel(card, card->dma->recvbuf.dmaaddr, AMCC_RXPTR); b1dma_writel(card, 4, AMCC_RXLEN); card->csr |= EN_RX_TC_INT; b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_send_init(card); return 0; }
void b1dma_reset_ctr(struct capi_ctr *ctrl) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; b1dma_reset(card); memset(cinfo->version, 0, sizeof(cinfo->version)); ctrl->reseted(ctrl); }
static void b1pciv4_remove(struct pci_dev *pdev) { avmcard *card = pci_get_drvdata(pdev); avmctrl_info *cinfo = card->ctrlinfo; b1dma_reset(card); detach_capi_ctr(&cinfo->capi_ctrl); free_irq(card->irq, card); iounmap(card->mbase); release_region(card->port, AVMB1_PORTLEN); avmcard_dma_free(card->dma); b1_free_card(card); }
void b1dma_reset_ctr(struct capi_ctr *ctrl) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; unsigned long flags; spin_lock_irqsave(&card->lock, flags); b1dma_reset(card); memset(cinfo->version, 0, sizeof(cinfo->version)); capilib_release(&cinfo->ncci_head); spin_unlock_irqrestore(&card->lock, flags); capi_ctr_down(ctrl); }
static void t1pci_remove_ctr(struct capi_ctr *ctrl) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; b1dma_reset(card); di->detach_ctr(ctrl); free_irq(card->irq, card); iounmap(card->mbase); release_region(card->port, AVMB1_PORTLEN); ctrl->driverdata = 0; kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; }
static int b1pciv4_probe(struct capicardparams *p, struct pci_dev *pdev) { avmcard *card; avmctrl_info *cinfo; int retval; card = b1_alloc_card(1); if (!card) { printk(KERN_WARNING "b1pci: no memory.\n"); retval = -ENOMEM; goto err; } card->dma = avmcard_dma_alloc("b1pci", pdev, 2048+128, 2048+128); if (!card->dma) { printk(KERN_WARNING "b1pci: dma alloc.\n"); retval = -ENOMEM; goto err_free; } cinfo = card->ctrlinfo; sprintf(card->name, "b1pciv4-%x", p->port); card->port = p->port; card->irq = p->irq; card->membase = p->membase; card->cardtype = avm_b1pci; if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { printk(KERN_WARNING "b1pci: ports 0x%03x-0x%03x in use.\n", card->port, card->port + AVMB1_PORTLEN); retval = -EBUSY; goto err_free_dma; } card->mbase = ioremap(card->membase, 64); if (!card->mbase) { printk(KERN_NOTICE "b1pci: can't remap memory at 0x%lx\n", card->membase); retval = -ENOMEM; goto err_release_region; } b1dma_reset(card); retval = b1pciv4_detect(card); if (retval) { printk(KERN_NOTICE "b1pci: NO card at 0x%x (%d)\n", card->port, retval); retval = -ENODEV; goto err_unmap; } b1dma_reset(card); b1_getrevision(card); retval = request_irq(card->irq, b1dma_interrupt, IRQF_SHARED, card->name, card); if (retval) { printk(KERN_ERR "b1pci: unable to get IRQ %d.\n", card->irq); retval = -EBUSY; goto err_unmap; } cinfo->capi_ctrl.owner = THIS_MODULE; cinfo->capi_ctrl.driver_name = "b1pciv4"; cinfo->capi_ctrl.driverdata = cinfo; cinfo->capi_ctrl.register_appl = b1dma_register_appl; cinfo->capi_ctrl.release_appl = b1dma_release_appl; cinfo->capi_ctrl.send_message = b1dma_send_message; cinfo->capi_ctrl.load_firmware = b1dma_load_firmware; cinfo->capi_ctrl.reset_ctr = b1dma_reset_ctr; cinfo->capi_ctrl.procinfo = b1pciv4_procinfo; cinfo->capi_ctrl.proc_fops = &b1dmactl_proc_fops; strcpy(cinfo->capi_ctrl.name, card->name); retval = attach_capi_ctr(&cinfo->capi_ctrl); if (retval) { printk(KERN_ERR "b1pci: attach controller failed.\n"); goto err_free_irq; } card->cardnr = cinfo->capi_ctrl.cnr; printk(KERN_INFO "b1pci: AVM B1 PCI V4 at i/o %#x, irq %d, mem %#lx, revision %d (dma)\n", card->port, card->irq, card->membase, card->revision); pci_set_drvdata(pdev, card); return 0; err_free_irq: free_irq(card->irq, card); err_unmap: iounmap(card->mbase); err_release_region: release_region(card->port, AVMB1_PORTLEN); err_free_dma: avmcard_dma_free(card->dma); err_free: b1_free_card(card); err: return retval; }
static int b1pciv4_add_card(struct capi_driver *driver, struct capicardparams *p) { unsigned long base, page_offset; avmcard *card; avmctrl_info *cinfo; int retval; MOD_INC_USE_COUNT; card = (avmcard *) kmalloc(sizeof(avmcard), GFP_ATOMIC); if (!card) { printk(KERN_WARNING "%s: no memory.\n", driver->name); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(card, 0, sizeof(avmcard)); card->dma = (avmcard_dmainfo *) kmalloc(sizeof(avmcard_dmainfo), GFP_ATOMIC); if (!card->dma) { printk(KERN_WARNING "%s: no memory.\n", driver->name); kfree(card); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(card->dma, 0, sizeof(avmcard_dmainfo)); cinfo = (avmctrl_info *) kmalloc(sizeof(avmctrl_info), GFP_ATOMIC); if (!cinfo) { printk(KERN_WARNING "%s: no memory.\n", driver->name); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(cinfo, 0, sizeof(avmctrl_info)); card->ctrlinfo = cinfo; cinfo->card = card; sprintf(card->name, "b1pciv4-%x", p->port); card->port = p->port; card->irq = p->irq; card->membase = p->membase; card->cardtype = avm_b1pci; if (check_region(card->port, AVMB1_PORTLEN)) { printk(KERN_WARNING "%s: ports 0x%03x-0x%03x in use.\n", driver->name, card->port, card->port + AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } base = card->membase & PAGE_MASK; page_offset = card->membase - base; card->mbase = ioremap_nocache(base, page_offset + 64); if (card->mbase) { card->mbase += page_offset; } else { printk(KERN_NOTICE "%s: can't remap memory at 0x%lx\n", driver->name, card->membase); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EIO; } b1dma_reset(card); if ((retval = b1pciv4_detect(card)) != 0) { printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n", driver->name, card->port, retval); iounmap((void *) (((unsigned long) card->mbase) & PAGE_MASK)); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EIO; } b1dma_reset(card); b1_getrevision(card); request_region(p->port, AVMB1_PORTLEN, card->name); retval = request_irq(card->irq, b1dma_interrupt, SA_SHIRQ, card->name, card); if (retval) { printk(KERN_ERR "%s: unable to get IRQ %d.\n", driver->name, card->irq); iounmap((void *) (((unsigned long) card->mbase) & PAGE_MASK)); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } cinfo->capi_ctrl = div4->attach_ctr(driver, card->name, cinfo); if (!cinfo->capi_ctrl) { printk(KERN_ERR "%s: attach controller failed.\n", driver->name); iounmap((void *) (((unsigned long) card->mbase) & PAGE_MASK)); free_irq(card->irq, card); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } card->cardnr = cinfo->capi_ctrl->cnr; skb_queue_head_init(&card->dma->send_queue); printk(KERN_INFO "%s: AVM B1 PCI V4 at i/o %#x, irq %d, mem %#lx, revision %d (dma)\n", driver->name, card->port, card->irq, card->membase, card->revision); return 0; }
static int t1pci_add_card(struct capicardparams *p, struct pci_dev *pdev) { avmcard *card; avmctrl_info *cinfo; int retval; card = b1_alloc_card(1); if (!card) { printk(KERN_WARNING "t1pci: no memory.\n"); retval = -ENOMEM; goto err; } card->dma = avmcard_dma_alloc("t1pci", pdev, 2048+128, 2048+128); if (!card->dma) { printk(KERN_WARNING "t1pci: no memory.\n"); retval = -ENOMEM; goto err_free; } cinfo = card->ctrlinfo; sprintf(card->name, "t1pci-%x", p->port); card->port = p->port; card->irq = p->irq; card->membase = p->membase; card->cardtype = avm_t1pci; if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { printk(KERN_WARNING "t1pci: ports 0x%03x-0x%03x in use.\n", card->port, card->port + AVMB1_PORTLEN); retval = -EBUSY; goto err_free_dma; } card->mbase = ioremap(card->membase, 64); if (!card->mbase) { printk(KERN_NOTICE "t1pci: can't remap memory at 0x%lx\n", card->membase); retval = -EIO; goto err_release_region; } b1dma_reset(card); retval = t1pci_detect(card); if (retval != 0) { if (retval < 6) printk(KERN_NOTICE "t1pci: NO card at 0x%x (%d)\n", card->port, retval); else printk(KERN_NOTICE "t1pci: card at 0x%x, but cable not connected or T1 has no power (%d)\n", card->port, retval); retval = -EIO; goto err_unmap; } b1dma_reset(card); retval = request_irq(card->irq, b1dma_interrupt, SA_SHIRQ, card->name, card); if (retval) { printk(KERN_ERR "t1pci: unable to get IRQ %d.\n", card->irq); retval = -EBUSY; goto err_unmap; } cinfo->capi_ctrl.owner = THIS_MODULE; cinfo->capi_ctrl.driver_name = "t1pci"; cinfo->capi_ctrl.driverdata = cinfo; cinfo->capi_ctrl.register_appl = b1dma_register_appl; cinfo->capi_ctrl.release_appl = b1dma_release_appl; cinfo->capi_ctrl.send_message = b1dma_send_message; cinfo->capi_ctrl.load_firmware = b1dma_load_firmware; cinfo->capi_ctrl.reset_ctr = b1dma_reset_ctr; cinfo->capi_ctrl.procinfo = t1pci_procinfo; cinfo->capi_ctrl.ctr_read_proc = b1dmactl_read_proc; strcpy(cinfo->capi_ctrl.name, card->name); retval = attach_capi_ctr(&cinfo->capi_ctrl); if (retval) { printk(KERN_ERR "t1pci: attach controller failed.\n"); retval = -EBUSY; goto err_free_irq; } card->cardnr = cinfo->capi_ctrl.cnr; printk(KERN_INFO "t1pci: AVM T1 PCI at i/o %#x, irq %d, mem %#lx\n", card->port, card->irq, card->membase); pci_set_drvdata(pdev, card); return 0; err_free_irq: free_irq(card->irq, card); err_unmap: iounmap(card->mbase); err_release_region: release_region(card->port, AVMB1_PORTLEN); err_free_dma: avmcard_dma_free(card->dma); err_free: b1_free_card(card); err: return retval; }
int iavc_load(capi_softc_t *capi_sc, int len, u_int8_t *cp) { iavc_softc_t *sc = (iavc_softc_t*) capi_sc->ctx; u_int8_t val; if(bootverbose) printf("iavc%d: reset card ....\n", sc->sc_unit); if (sc->sc_dma) b1dma_reset(sc); /* PCI cards */ else if (sc->sc_t1) t1_reset(sc); /* ISA attachment T1 */ else b1_reset(sc); /* ISA attachment B1 */ DELAY(1000); if(bootverbose) printf("iavc%d: start loading %d bytes firmware ....\n", sc->sc_unit, len); while (len && b1io_save_put_byte(sc, *cp++) == 0) len--; if (len) { printf("iavc%d: loading failed, can't write to card, len = %d\n", sc->sc_unit, len); return (EIO); } if(bootverbose) printf("iavc%d: firmware loaded, wait for ACK ....\n", sc->sc_unit); if(sc->sc_capi.card_type == CARD_TYPEC_AVM_B1_ISA) iavc_put_byte(sc, SEND_POLL); else iavc_put_byte(sc, SEND_POLLACK); for (len = 0; len < 1000 && !iavc_rx_full(sc); len++) DELAY(100); if (!iavc_rx_full(sc)) { printf("iavc%d: loading failed, no ack\n", sc->sc_unit); return (EIO); } val = iavc_get_byte(sc); if ((sc->sc_dma && val != RECEIVE_POLLDWORD) || (!sc->sc_dma && val != RECEIVE_POLL)) { printf("iavc%d: loading failed, bad ack = %02x\n", sc->sc_unit, val); return (EIO); } if(bootverbose) printf("iavc%d: got ACK = 0x%02x\n", sc->sc_unit, val); if (sc->sc_dma) { /* Start the DMA engine */ int s = SPLI4B(); sc->sc_csr = AVM_FLAG; AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr); AMCC_WRITE(sc, AMCC_MCSR, (EN_A2P_TRANSFERS|EN_P2A_TRANSFERS| A2P_HI_PRIORITY|P2A_HI_PRIORITY| RESET_A2P_FLAGS|RESET_P2A_FLAGS)); iavc_write_port(sc, 0x07, 0x30); /* XXX magic numbers from */ iavc_write_port(sc, 0x10, 0xf0); /* XXX the linux driver */ sc->sc_recvlen = 0; AMCC_WRITE(sc, AMCC_RXPTR, vtophys(&sc->sc_recvbuf[0])); AMCC_WRITE(sc, AMCC_RXLEN, 4); sc->sc_csr |= EN_RX_TC_INT|EN_TX_TC_INT; AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr); splx(s); } if(sc->sc_capi.card_type == CARD_TYPEC_AVM_B1_ISA) b1isa_setup_irq(sc); iavc_send_init(sc); return 0; }
static int t1pci_add_card(struct capi_driver *driver, struct capicardparams *p) { avmcard *card; avmctrl_info *cinfo; int retval; MOD_INC_USE_COUNT; card = (avmcard *) kmalloc(sizeof(avmcard), GFP_ATOMIC); if (!card) { printk(KERN_WARNING "%s: no memory.\n", driver->name); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(card, 0, sizeof(avmcard)); card->dma = (avmcard_dmainfo *) kmalloc(sizeof(avmcard_dmainfo), GFP_ATOMIC); if (!card->dma) { printk(KERN_WARNING "%s: no memory.\n", driver->name); kfree(card); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(card->dma, 0, sizeof(avmcard_dmainfo)); cinfo = (avmctrl_info *) kmalloc(sizeof(avmctrl_info), GFP_ATOMIC); if (!cinfo) { printk(KERN_WARNING "%s: no memory.\n", driver->name); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(cinfo, 0, sizeof(avmctrl_info)); card->ctrlinfo = cinfo; cinfo->card = card; sprintf(card->name, "t1pci-%x", p->port); card->port = p->port; card->irq = p->irq; card->membase = p->membase; card->cardtype = avm_t1pci; if (check_region(card->port, AVMB1_PORTLEN)) { printk(KERN_WARNING "%s: ports 0x%03x-0x%03x in use.\n", driver->name, card->port, card->port + AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } card->mbase = ioremap_nocache(card->membase, 64); if (!card->mbase) { printk(KERN_NOTICE "%s: can't remap memory at 0x%lx\n", driver->name, card->membase); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EIO; } b1dma_reset(card); if ((retval = t1pci_detect(card)) != 0) { if (retval < 6) printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n", driver->name, card->port, retval); else printk(KERN_NOTICE "%s: card at 0x%x, but cabel not connected or T1 has no power (%d)\n", driver->name, card->port, retval); iounmap(card->mbase); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EIO; } b1dma_reset(card); request_region(p->port, AVMB1_PORTLEN, card->name); retval = request_irq(card->irq, b1dma_interrupt, SA_SHIRQ, card->name, card); if (retval) { printk(KERN_ERR "%s: unable to get IRQ %d.\n", driver->name, card->irq); iounmap(card->mbase); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo); if (!cinfo->capi_ctrl) { printk(KERN_ERR "%s: attach controller failed.\n", driver->name); iounmap(card->mbase); free_irq(card->irq, card); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } card->cardnr = cinfo->capi_ctrl->cnr; skb_queue_head_init(&card->dma->send_queue); printk(KERN_INFO "%s: AVM T1 PCI at i/o %#x, irq %d, mem %#lx\n", driver->name, card->port, card->irq, card->membase); return 0; }