int __init setup_asuscom(struct IsdnCard *card) { char tmp[64]; strcpy(tmp, Asuscom_revision); printk(KERN_INFO "HiSax: Asuscom ISDNLink driver Rev. %s\n", HiSax_getrev(tmp)); #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_card *pb; struct pnp_dev *pd; while(adev->card_vendor) { if ((pb = pnp_find_card(adev->card_vendor, adev->card_device, pnp_c))) { pnp_c = pb; pd = NULL; if ((pd = pnp_find_dev(pnp_c, adev->vendor, adev->function, pd))) { printk(KERN_INFO "HiSax: %s detected\n", (char *)adev->driver_data); if (pnp_device_attach(pd) < 0) { printk(KERN_ERR "AsusPnP: attach failed\n"); return 0; } if (pnp_activate_dev(pd) < 0) { printk(KERN_ERR "AsusPnP: activate failed\n"); pnp_device_detach(pd); return 0; } if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0)) { printk(KERN_ERR "AsusPnP:some resources are missing %ld/%lx\n", pnp_irq(pd, 0), pnp_port_start(pd, 0)); pnp_device_detach(pd); return(0); } card->para[1] = pnp_port_start(pd, 0); card->para[0] = pnp_irq(pd, 0); break; } else { printk(KERN_ERR "AsusPnP: PnP error card found, no device\n"); } } adev++; pnp_c=NULL; } if (!adev->card_vendor) { printk(KERN_INFO "AsusPnP: no ISAPnP card found\n"); return(0); } } #endif if (asuscom_probe(card->cs, card) < 0) return 0; return 1; }
static int __devinit snd_mpu401_pnp(int dev, struct pnp_dev *device, const struct pnp_device_id *id) { if (!pnp_port_valid(device, 0) || pnp_port_flags(device, 0) & IORESOURCE_DISABLED) { snd_printk(KERN_ERR "no PnP port\n"); return -ENODEV; } if (pnp_port_len(device, 0) < IO_EXTENT) { snd_printk(KERN_ERR "PnP port length is %llu, expected %d\n", (unsigned long long)pnp_port_len(device, 0), IO_EXTENT); return -ENODEV; } port[dev] = pnp_port_start(device, 0); if (!pnp_irq_valid(device, 0) || pnp_irq_flags(device, 0) & IORESOURCE_DISABLED) { snd_printk(KERN_WARNING "no PnP irq, using polling\n"); irq[dev] = -1; } else { irq[dev] = pnp_irq(device, 0); } return 0; }
static int __devinit serial_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) { struct uart_port port; int ret, line, flags = dev_id->driver_data; if (flags & UNKNOWN_DEV) { ret = serial_pnp_guess_board(dev, &flags); if (ret < 0) return ret; } memset(&port, 0, sizeof(struct uart_port)); port.irq = pnp_irq(dev,0); port.iobase = pnp_port_start(dev, 0); #ifdef SERIAL_DEBUG_PNP printk("Setup PNP port: port %x, irq %d, type %d\n", port.iobase, port.irq, port.iotype); #endif port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; port.uartclk = 1843200; port.dev = &dev->dev; line = serial8250_register_port(&port); if (line >= 0) pnp_set_drvdata(dev, (void *)((long)line + 1)); return line >= 0 ? 0 : -ENODEV; }
static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) { hw_regs_t hw; ide_hwif_t *hwif; int index; if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) return -1; memset(&hw, 0, sizeof(hw)); ide_std_init_ports(&hw, pnp_port_start(dev, 0), pnp_port_start(dev, 1)); hw.irq = pnp_irq(dev, 0); hw.dma = NO_DMA; index = ide_register_hw(&hw, &hwif); if (index != -1) { printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); pnp_set_drvdata(dev,hwif); return 0; } return -1; }
static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) { hw_regs_t hw; ide_hwif_t *hwif; int index; if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) return -1; ide_setup_ports(&hw, (unsigned long) pnp_port_start(dev, 0), generic_ide_offsets, (unsigned long) pnp_port_start(dev, 1), 0, NULL, // generic_pnp_ide_iops, pnp_irq(dev, 0)); index = ide_register_hw(&hw, &hwif); if (index != -1) { printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); pnp_set_drvdata(dev,hwif); return 0; } return -1; }
static int __devinit setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt) { struct IsdnCardState *cs = card->cs; struct pnp_dev *pnp_d; if (!isapnp_present()) return -1; while(ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err<0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", __func__, err); return(0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n", card->para[0], card->para[1]); pnp_disable_dev(pnp_d); return(0); } cs->hw.sedl.cfg_reg = card->para[1]; cs->irq = card->para[0]; if (ipid->function == ISAPNP_FUNCTION(0x2)) { cs->subtyp = SEDL_SPEED_FAX; cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; *bytecnt = 16; } else { cs->subtyp = SEDL_SPEED_CARD_WIN; cs->hw.sedl.chip = SEDL_CHIP_TEST; } return (1); } else { printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n"); return(0); } } ipid++; pnp_c = NULL; } printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n"); return -1; }
/** * pnp_is_active - Determines if a device is active based on its current * resources * @dev: pointer to the desired PnP device */ int pnp_is_active(struct pnp_dev *dev) { if (!pnp_port_start(dev, 0) && pnp_port_len(dev, 0) <= 1 && !pnp_mem_start(dev, 0) && pnp_mem_len(dev, 0) <= 1 && pnp_irq(dev, 0) == -1 && pnp_dma(dev, 0) == -1) return 0; else return 1; }
static int serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { struct uart_8250_port uart; int ret, line, flags = dev_id->driver_data; struct resource *res = NULL; if (flags & UNKNOWN_DEV) { ret = serial_pnp_guess_board(dev); if (ret < 0) return ret; } memset(&uart, 0, sizeof(uart)); if (pnp_irq_valid(dev, 0)) uart.port.irq = pnp_irq(dev, 0); if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) res = pnp_get_resource(dev, IORESOURCE_IO, 2); else if (pnp_port_valid(dev, 0)) res = pnp_get_resource(dev, IORESOURCE_IO, 0); if (pnp_resource_enabled(res)) { uart.port.iobase = res->start; uart.port.iotype = UPIO_PORT; } else if (pnp_mem_valid(dev, 0)) { uart.port.mapbase = pnp_mem_start(dev, 0); uart.port.iotype = UPIO_MEM; uart.port.flags = UPF_IOREMAP; } else return -ENODEV; #ifdef SERIAL_DEBUG_PNP printk(KERN_DEBUG "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n", uart.port.iobase, uart.port.mapbase, uart.port.irq, uart.port.iotype); #endif if (flags & CIR_PORT) { uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE; uart.port.type = PORT_8250_CIR; } uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE) uart.port.flags |= UPF_SHARE_IRQ; uart.port.uartclk = 1843200; uart.port.dev = &dev->dev; line = serial8250_register_8250_port(&uart); if (line < 0 || (flags & CIR_PORT)) return -ENODEV; pnp_set_drvdata(dev, (void *)((long)line + 1)); return 0; }
static int snd_card_ad1816a_pnp(int dev, struct pnp_card_link *card, const struct pnp_card_device_id *id) { struct pnp_dev *pdev; int err; pdev = pnp_request_card_device(card, id->devs[0].id, NULL); if (pdev == NULL) return -EBUSY; err = pnp_activate_dev(pdev); if (err < 0) { printk(KERN_ERR PFX "AUDIO PnP configure failure\n"); return -EBUSY; } port[dev] = pnp_port_start(pdev, 2); fm_port[dev] = pnp_port_start(pdev, 1); dma1[dev] = pnp_dma(pdev, 0); dma2[dev] = pnp_dma(pdev, 1); irq[dev] = pnp_irq(pdev, 0); pdev = pnp_request_card_device(card, id->devs[1].id, NULL); if (pdev == NULL) { mpu_port[dev] = -1; snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n"); return 0; } err = pnp_activate_dev(pdev); if (err < 0) { printk(KERN_ERR PFX "MPU401 PnP configure failure\n"); mpu_port[dev] = -1; } else { mpu_port[dev] = pnp_port_start(pdev, 0); mpu_irq[dev] = pnp_irq(pdev, 0); } return 0; }
static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id) { struct ata_host *host; struct ata_port *ap; void __iomem *cmd_addr, *ctl_addr; int irq = 0; irq_handler_t handler = NULL; if (pnp_port_valid(idev, 0) == 0) return -ENODEV; if (pnp_irq_valid(idev, 0)) { irq = pnp_irq(idev, 0); handler = ata_sff_interrupt; } /* allocate host */ host = ata_host_alloc(&idev->dev, 1); if (!host) return -ENOMEM; /* acquire resources and fill host */ cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8); if (!cmd_addr) return -ENOMEM; ap = host->ports[0]; ap->ops = &isapnp_noalt_port_ops; ap->pio_mask = ATA_PIO0; ap->flags |= ATA_FLAG_SLAVE_POSS; ap->ioaddr.cmd_addr = cmd_addr; if (pnp_port_valid(idev, 1)) { ctl_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 1), 1); ap->ioaddr.altstatus_addr = ctl_addr; ap->ioaddr.ctl_addr = ctl_addr; ap->ops = &isapnp_port_ops; } ata_sff_std_ports(&ap->ioaddr); ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx", (unsigned long long)pnp_port_start(idev, 0), (unsigned long long)pnp_port_start(idev, 1)); /* activate */ return ata_host_activate(host, irq, handler, 0, &isapnp_sht); }
static int __devinit cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) { cmos_wake_setup(&pnp->dev); if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0)) return cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), 8); else return cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), pnp_irq(pnp, 0)); }
static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { hw_regs_t hw; ide_hwif_t *hwif; unsigned long base, ctl; if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) return -1; base = pnp_port_start(dev, 0); ctl = pnp_port_start(dev, 1); if (!request_region(base, 8, DRV_NAME)) { printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", DRV_NAME, base, base + 7); return -EBUSY; } if (!request_region(ctl, 1, DRV_NAME)) { printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", DRV_NAME, ctl); release_region(base, 8); return -EBUSY; } memset(&hw, 0, sizeof(hw)); ide_std_init_ports(&hw, base, ctl); hw.irq = pnp_irq(dev, 0); hw.chipset = ide_generic; hwif = ide_find_port(); if (hwif) { u8 index = hwif->index; u8 idx[4] = { index, 0xff, 0xff, 0xff }; ide_init_port_data(hwif, index); ide_init_port_hw(hwif, &hw); printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); pnp_set_drvdata(dev, hwif); ide_device_add(idx, NULL); return 0; } release_region(ctl, 1); release_region(base, 8); return -1; }
static int generic_NCR5380_pnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *id) { int base, irq; if (pnp_activate_dev(pdev) < 0) return -EBUSY; base = pnp_port_start(pdev, 0); irq = pnp_irq(pdev, 0); return generic_NCR5380_init_one(&driver_template, &pdev->dev, base, irq, id->driver_data); }
static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { struct ide_host *host; unsigned long base, ctl; int rc; struct ide_hw hw, *hws[] = { &hw }; #ifdef CONFIG_DEBUG_PRINTK printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); #else ; #endif if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) return -1; base = pnp_port_start(dev, 0); ctl = pnp_port_start(dev, 1); if (!request_region(base, 8, DRV_NAME)) { printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", DRV_NAME, base, base + 7); return -EBUSY; } if (!request_region(ctl, 1, DRV_NAME)) { printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", DRV_NAME, ctl); release_region(base, 8); return -EBUSY; } memset(&hw, 0, sizeof(hw)); ide_std_init_ports(&hw, base, ctl); hw.irq = pnp_irq(dev, 0); rc = ide_host_add(&ide_pnp_port_info, hws, 1, &host); if (rc) goto out; pnp_set_drvdata(dev, host); return 0; out: release_region(ctl, 1); release_region(base, 8); return rc; }
static int __devinit cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) { if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0)) /* Some machines contain a PNP entry for the RTC, but * don't define the IRQ. It should always be safe to * hardcode it in these cases */ return cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), 8); else return cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), pnp_irq(pnp, 0)); }
static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) { struct parport *pdata; unsigned long io_lo, io_hi; int dma, irq; if (pnp_port_valid(dev, 0) && !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) { io_lo = pnp_port_start(dev, 0); } else return -EINVAL; #if 0 if (pnp_port_valid(dev,1) && !(pnp_port_flags(dev,1) & IORESOURCE_DISABLED)) { io_hi = pnp_port_start(dev,1); } else io_hi = 0; #endif #if 0 if (pnp_irq_valid(dev,0) && !(pnp_irq_flags(dev,0) & IORESOURCE_DISABLED)) { irq = pnp_irq(dev,0); } else irq = PARPORT_IRQ_NONE; #endif #if 0 if (pnp_dma_valid(dev,0) && !(pnp_dma_flags(dev,0) & IORESOURCE_DISABLED)) { dma = pnp_dma(dev,0); } else dma = PARPORT_DMA_NONE; #endif #if 0 printk(KERN_INFO "parport: PnPBIOS parport detected.\n"); if (!(pdata = parport_pc_probe_port (io_lo, io_hi, irq, dma, NULL))) return -ENODEV; pnp_set_drvdata(dev,pdata); #endif return 0; }
static int __devinit serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { struct uart_port port; int ret, line, flags = dev_id->driver_data; if (flags & UNKNOWN_DEV) { ret = serial_pnp_guess_board(dev, &flags); if (ret < 0) return ret; } memset(&port, 0, sizeof(struct uart_port)); if (pnp_irq_valid(dev, 0)) port.irq = pnp_irq(dev, 0); if (pnp_port_valid(dev, 0)) { port.iobase = pnp_port_start(dev, 0); port.iotype = UPIO_PORT; } else if (pnp_mem_valid(dev, 0)) { port.mapbase = pnp_mem_start(dev, 0); port.iotype = UPIO_MEM; port.flags = UPF_IOREMAP; } else return -ENODEV; #ifdef SERIAL_DEBUG_PNP printk(KERN_DEBUG "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n", port.iobase, port.mapbase, port.irq, port.iotype); #endif port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE) port.flags |= UPF_SHARE_IRQ; port.uartclk = 1843200; port.dev = &dev->dev; line = serial8250_register_port(&port); if (line < 0) return -ENODEV; pnp_set_drvdata(dev, (void *)((long)line + 1)); return 0; }
static int __devinit fcpnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) { struct fritz_adapter *adapter; int retval; if (!pdev) return(-ENODEV); retval = -ENOMEM; adapter = new_adapter(); if (!adapter) goto err; pnp_set_drvdata(pdev, adapter); adapter->type = AVM_FRITZ_PNP; pnp_disable_dev(pdev); retval = pnp_activate_dev(pdev); if (retval < 0) { printk(KERN_WARNING "%s: pnp_activate_dev(%s) ret(%d)\n", __func__, (char *)dev_id->driver_data, retval); goto err_free; } adapter->io = pnp_port_start(pdev, 0); adapter->irq = pnp_irq(pdev, 0); printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at IO %#x irq %d\n", (char *) dev_id->driver_data, adapter->io, adapter->irq); retval = fcpcipnp_setup(adapter); if (retval) goto err_free; return 0; err_free: delete_adapter(adapter); err: return retval; }
/* it works in parport_pc's probe function, so why not here? */ static int c2_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) { if (pnp_port_valid(dev,0) && !(pnp_port_flags(dev,0) & IORESOURCE_DISABLED)) { io_base = pnp_port_start(dev,0); } else { return -EINVAL; } if (pnp_irq_valid(dev,0) && !(pnp_irq_flags(dev,0) & IORESOURCE_DISABLED)) { irq = pnp_irq(dev,0); if (request_irq(irq, c2_interrupt, SA_INTERRUPT, DEVICE_NAME, NULL)) { return -EINVAL; } } else { return -EINVAL; } return 0; }
static int __devinit snd_card_es968_pnp(struct snd_card *card, unsigned int n, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { struct snd_es1688 *chip = card->private_data; struct pnp_dev *pdev; int error; pdev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); if (pdev == NULL) return -ENODEV; error = pnp_activate_dev(pdev); if (error < 0) { snd_printk(KERN_ERR "ES968 pnp configure failure\n"); return error; } port[n] = pnp_port_start(pdev, 0); dma8[n] = pnp_dma(pdev, 0); irq[n] = pnp_irq(pdev, 0); return snd_es1688_create(card, chip, port[n], mpu_port[n], irq[n], mpu_irq[n], dma8[n], ES1688_HW_AUTO); }
static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pnp_dev *isapnp_dev; int ret; unsigned long iobase; int board; unsigned int irq; /* allocate private area */ ret = ni_alloc_private(dev); if (ret < 0) return ret; devpriv->stc_writew = &ni_atmio_win_out; devpriv->stc_readw = &ni_atmio_win_in; devpriv->stc_writel = &win_out2; devpriv->stc_readl = &win_in2; iobase = it->options[0]; irq = it->options[1]; isapnp_dev = NULL; if (iobase == 0) { ret = ni_isapnp_find_board(&isapnp_dev); if (ret < 0) return ret; iobase = pnp_port_start(isapnp_dev, 0); irq = pnp_irq(isapnp_dev, 0); devpriv->isapnp_dev = isapnp_dev; } /* reserve our I/O region */ printk("comedi%d: ni_atmio: 0x%04lx", dev->minor, iobase); if (!request_region(iobase, NI_SIZE, "ni_atmio")) { printk(" I/O port conflict\n"); return -EIO; } dev->iobase = iobase; #ifdef DEBUG /* board existence sanity check */ { int i; printk(" board fingerprint:"); for (i = 0; i < 16; i += 2) { printk(" %04x %02x", inw(dev->iobase + i), inb(dev->iobase + i + 1)); } } #endif /* get board type */ board = ni_getboardtype(dev); if (board < 0) return -EIO; dev->board_ptr = ni_boards + board; printk(" %s", boardtype.name); dev->board_name = boardtype.name; /* irq stuff */ if (irq != 0) { if (irq > 15 || ni_irqpin[irq] == -1) { printk(" invalid irq %u\n", irq); return -EINVAL; } printk(" ( irq = %u )", irq); ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS, "ni_atmio", dev); if (ret < 0) { printk(" irq not available\n"); return -EINVAL; } dev->irq = irq; } /* generic E series stuff in ni_mio_common.c */ ret = ni_E_init(dev, it); if (ret < 0) return ret; return 0; }
int __devinit setup_teles3(struct IsdnCard *card) { u_char val; struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, teles3_revision); printk(KERN_INFO "HiSax: Teles IO driver Rev. %s\n", HiSax_getrev(tmp)); if ((cs->typ != ISDN_CTYPE_16_3) && (cs->typ != ISDN_CTYPE_PNP) && (cs->typ != ISDN_CTYPE_TELESPCMCIA) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA)) return (0); #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; while(ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err<0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", __FUNCTION__, err); return(0); } card->para[3] = pnp_port_start(pnp_d, 2); card->para[2] = pnp_port_start(pnp_d, 1); card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1] || !card->para[2]) { printk(KERN_ERR "Teles PnP:some resources are missing %ld/%lx/%lx\n", card->para[0], card->para[1], card->para[2]); pnp_disable_dev(pnp_d); return(0); } break; } else { printk(KERN_ERR "Teles PnP: PnP error card found, no device\n"); } } ipid++; pnp_c = NULL; } if (!ipid->card_vendor) { printk(KERN_INFO "Teles PnP: no ISAPnP card found\n"); return(0); } } #endif if (cs->typ == ISDN_CTYPE_16_3) { cs->hw.teles3.cfg_reg = card->para[1]; switch (cs->hw.teles3.cfg_reg) { case 0x180: case 0x280: case 0x380: cs->hw.teles3.cfg_reg |= 0xc00; break; } cs->hw.teles3.isac = cs->hw.teles3.cfg_reg - 0x420; cs->hw.teles3.hscx[0] = cs->hw.teles3.cfg_reg - 0xc20; cs->hw.teles3.hscx[1] = cs->hw.teles3.cfg_reg - 0x820; } else if (cs->typ == ISDN_CTYPE_TELESPCMCIA) { cs->hw.teles3.cfg_reg = 0; cs->hw.teles3.hscx[0] = card->para[1] - 0x20; cs->hw.teles3.hscx[1] = card->para[1]; cs->hw.teles3.isac = card->para[1] + 0x20; } else if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { cs->hw.teles3.cfg_reg = card->para[3]; cs->hw.teles3.isac = card->para[2] - 32; cs->hw.teles3.hscx[0] = card->para[1] - 32; cs->hw.teles3.hscx[1] = card->para[1]; } else { /* PNP */ cs->hw.teles3.cfg_reg = 0; cs->hw.teles3.isac = card->para[1] - 32; cs->hw.teles3.hscx[0] = card->para[2] - 32; cs->hw.teles3.hscx[1] = card->para[2]; } cs->irq = card->para[0]; cs->hw.teles3.isacfifo = cs->hw.teles3.isac + 0x3e; cs->hw.teles3.hscxfifo[0] = cs->hw.teles3.hscx[0] + 0x3e; cs->hw.teles3.hscxfifo[1] = cs->hw.teles3.hscx[1] + 0x3e; if (cs->typ == ISDN_CTYPE_TELESPCMCIA) { if (!request_region(cs->hw.teles3.hscx[1], 96, "HiSax Teles PCMCIA")) { printk(KERN_WARNING "HiSax: %s ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.hscx[1], cs->hw.teles3.hscx[1] + 96); return (0); } } else { if (cs->hw.teles3.cfg_reg) { if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { if (!request_region(cs->hw.teles3.cfg_reg, 1, "teles3 cfg")) { printk(KERN_WARNING "HiSax: %s config port %x already in use\n", CardType[card->typ], cs->hw.teles3.cfg_reg); return (0); } } else { if (!request_region(cs->hw.teles3.cfg_reg, 8, "teles3 cfg")) { printk(KERN_WARNING "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.teles3.cfg_reg, cs->hw.teles3.cfg_reg + 8); return (0); } } } if (!request_region(cs->hw.teles3.isac + 32, 32, "HiSax isac")) { printk(KERN_WARNING "HiSax: %s isac ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.isac + 32, cs->hw.teles3.isac + 64); if (cs->hw.teles3.cfg_reg) { if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { release_region(cs->hw.teles3.cfg_reg, 1); } else { release_region(cs->hw.teles3.cfg_reg, 8); } } return (0); } if (!request_region(cs->hw.teles3.hscx[0] + 32, 32, "HiSax hscx A")) { printk(KERN_WARNING "HiSax: %s hscx A ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.hscx[0] + 32, cs->hw.teles3.hscx[0] + 64); if (cs->hw.teles3.cfg_reg) { if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { release_region(cs->hw.teles3.cfg_reg, 1); } else { release_region(cs->hw.teles3.cfg_reg, 8); } } release_ioregs(cs, 1); return (0); } if (!request_region(cs->hw.teles3.hscx[1] + 32, 32, "HiSax hscx B")) { printk(KERN_WARNING "HiSax: %s hscx B ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.hscx[1] + 32, cs->hw.teles3.hscx[1] + 64); if (cs->hw.teles3.cfg_reg) { if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { release_region(cs->hw.teles3.cfg_reg, 1); } else { release_region(cs->hw.teles3.cfg_reg, 8); } } release_ioregs(cs, 3); return (0); } } if ((cs->hw.teles3.cfg_reg) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA)) { if ((val = bytein(cs->hw.teles3.cfg_reg + 0)) != 0x51) { printk(KERN_WARNING "Teles: 16.3 Byte at %x is %x\n", cs->hw.teles3.cfg_reg + 0, val); release_io_teles3(cs); return (0); } if ((val = bytein(cs->hw.teles3.cfg_reg + 1)) != 0x93) { printk(KERN_WARNING "Teles: 16.3 Byte at %x is %x\n", cs->hw.teles3.cfg_reg + 1, val); release_io_teles3(cs); return (0); } val = bytein(cs->hw.teles3.cfg_reg + 2);/* 0x1e=without AB * 0x1f=with AB * 0x1c 16.3 ??? * 0x39 16.3 1.1 * 0x38 16.3 1.3 * 0x46 16.3 with AB + Video (Teles-Vision) */ if (val != 0x46 && val != 0x39 && val != 0x38 && val != 0x1c && val != 0x1e && val != 0x1f) { printk(KERN_WARNING "Teles: 16.3 Byte at %x is %x\n", cs->hw.teles3.cfg_reg + 2, val); release_io_teles3(cs); return (0); } } printk(KERN_INFO "HiSax: %s config irq:%d isac:0x%X cfg:0x%X\n", CardType[cs->typ], cs->irq, cs->hw.teles3.isac + 32, cs->hw.teles3.cfg_reg); printk(KERN_INFO "HiSax: hscx A:0x%X hscx B:0x%X\n", cs->hw.teles3.hscx[0] + 32, cs->hw.teles3.hscx[1] + 32); setup_isac(cs); if (reset_teles3(cs)) { printk(KERN_WARNING "Teles3: wrong IRQ\n"); release_io_teles3(cs); return (0); } cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->BC_Read_Reg = &ReadHSCX; cs->BC_Write_Reg = &WriteHSCX; cs->BC_Send_Data = &hscx_fill_fifo; cs->cardmsg = &Teles_card_msg; cs->irq_func = &teles3_interrupt; ISACVersion(cs, "Teles3:"); if (HscxVersion(cs, "Teles3:")) { printk(KERN_WARNING "Teles3: wrong HSCX versions check IO address\n"); release_io_teles3(cs); return (0); } return (1); }
int __devinit setup_ix1micro(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, ix1_revision); printk(KERN_INFO "HiSax: ITK IX1 driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_IX1MICROR2) return (0); #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; while(ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err<0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", __FUNCTION__, err); return(0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "ITK PnP:some resources are missing %ld/%lx\n", card->para[0], card->para[1]); pnp_disable_dev(pnp_d); return(0); } break; } else { printk(KERN_ERR "ITK PnP: PnP error card found, no device\n"); } } ipid++; pnp_c = NULL; } if (!ipid->card_vendor) { printk(KERN_INFO "ITK PnP: no ISAPnP card found\n"); return(0); } } #endif /* IO-Ports */ cs->hw.ix1.isac_ale = card->para[1] + ISAC_COMMAND_OFFSET; cs->hw.ix1.hscx_ale = card->para[1] + HSCX_COMMAND_OFFSET; cs->hw.ix1.isac = card->para[1] + ISAC_DATA_OFFSET; cs->hw.ix1.hscx = card->para[1] + HSCX_DATA_OFFSET; cs->hw.ix1.cfg_reg = card->para[1]; cs->irq = card->para[0]; if (cs->hw.ix1.cfg_reg) { if (!request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg")) { printk(KERN_WARNING "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.ix1.cfg_reg, cs->hw.ix1.cfg_reg + 4); return (0); } } printk(KERN_INFO "HiSax: %s config irq:%d io:0x%X\n", CardType[cs->typ], cs->irq, cs->hw.ix1.cfg_reg); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->BC_Read_Reg = &ReadHSCX; cs->BC_Write_Reg = &WriteHSCX; cs->BC_Send_Data = &hscx_fill_fifo; cs->cardmsg = &ix1_card_msg; cs->irq_func = &ix1micro_interrupt; ISACVersion(cs, "ix1-Micro:"); if (HscxVersion(cs, "ix1-Micro:")) { printk(KERN_WARNING "ix1-Micro: wrong HSCX versions check IO address\n"); release_io_ix1micro(cs); return (0); } return (1); }
static int setup_diva_isapnp(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; struct pnp_dev *pnp_d; if (!isapnp_present()) return (-1); /* card not found; continue search */ while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", __func__, err); return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n", card->para[0], card->para[1]); pnp_disable_dev(pnp_d); return (0); } cs->hw.diva.cfg_reg = card->para[1]; cs->irq = card->para[0]; if (ipid->function == ISAPNP_FUNCTION(0xA1)) { cs->subtyp = DIVA_IPAC_ISA; cs->hw.diva.ctrl = 0; cs->hw.diva.isac = card->para[1] + DIVA_IPAC_DATA; cs->hw.diva.hscx = card->para[1] + DIVA_IPAC_DATA; cs->hw.diva.isac_adr = card->para[1] + DIVA_IPAC_ADR; cs->hw.diva.hscx_adr = card->para[1] + DIVA_IPAC_ADR; test_and_set_bit(HW_IPAC, &cs->HW_Flags); } else { cs->subtyp = DIVA_ISA; cs->hw.diva.ctrl = card->para[1] + DIVA_ISA_CTRL; cs->hw.diva.isac = card->para[1] + DIVA_ISA_ISAC_DATA; cs->hw.diva.hscx = card->para[1] + DIVA_HSCX_DATA; cs->hw.diva.isac_adr = card->para[1] + DIVA_ISA_ISAC_ADR; cs->hw.diva.hscx_adr = card->para[1] + DIVA_HSCX_ADR; } return (1); /* card found */ } else { printk(KERN_ERR "Diva PnP: PnP error card found, no device\n"); return (0); } } ipid++; pnp_c = NULL; } return (-1); /* card not found; continue search */ }
int __devinit setup_isurf(struct IsdnCard *card) { int ver; struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, ISurf_revision); printk(KERN_INFO "HiSax: ISurf driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_ISURF) return(0); if (card->para[1] && card->para[2]) { cs->hw.isurf.reset = card->para[1]; cs->hw.isurf.phymem = card->para[2]; cs->irq = card->para[0]; } else { #ifdef __ISAPNP__ if (isapnp_present()) { struct pnp_dev *pnp_d = NULL; int err; cs->subtyp = 0; if ((pnp_c = pnp_find_card( ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0010), pnp_c))) { if (!(pnp_d = pnp_find_dev(pnp_c, ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0010), pnp_d))) { printk(KERN_ERR "ISurfPnP: PnP error card found, no device\n"); return (0); } pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); cs->hw.isurf.reset = pnp_port_start(pnp_d, 0); cs->hw.isurf.phymem = pnp_mem_start(pnp_d, 1); cs->irq = pnp_irq(pnp_d, 0); if (!cs->irq || !cs->hw.isurf.reset || !cs->hw.isurf.phymem) { printk(KERN_ERR "ISurfPnP:some resources are missing %d/%x/%lx\n", cs->irq, cs->hw.isurf.reset, cs->hw.isurf.phymem); pnp_disable_dev(pnp_d); return(0); } } else { printk(KERN_INFO "ISurfPnP: no ISAPnP card found\n"); return(0); } } else { printk(KERN_INFO "ISurfPnP: no ISAPnP bus found\n"); return(0); } #else printk(KERN_WARNING "HiSax: Siemens I-Surf port/mem not set\n"); return (0); #endif } if (!request_region(cs->hw.isurf.reset, 1, "isurf isdn")) { printk(KERN_WARNING "HiSax: Siemens I-Surf config port %x already in use\n", cs->hw.isurf.reset); return (0); } if (!request_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE, "isurf iomem")) { printk(KERN_WARNING "HiSax: Siemens I-Surf memory region " "%lx-%lx already in use\n", cs->hw.isurf.phymem, cs->hw.isurf.phymem + ISURF_IOMEM_SIZE); release_region(cs->hw.isurf.reset, 1); return (0); } cs->hw.isurf.isar = ioremap(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE); cs->hw.isurf.isac = cs->hw.isurf.isar + ISURF_ISAC_OFFSET; printk(KERN_INFO "ISurf: defined at 0x%x 0x%lx IRQ %d\n", cs->hw.isurf.reset, cs->hw.isurf.phymem, cs->irq); setup_isac(cs); cs->cardmsg = &ISurf_card_msg; cs->irq_func = &isurf_interrupt; cs->auxcmd = &isurf_auxcmd; cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->bcs[0].hw.isar.reg = &cs->hw.isurf.isar_r; cs->bcs[1].hw.isar.reg = &cs->hw.isurf.isar_r; test_and_set_bit(HW_ISAR, &cs->HW_Flags); ISACVersion(cs, "ISurf:"); cs->BC_Read_Reg = &ReadISAR; cs->BC_Write_Reg = &WriteISAR; cs->BC_Send_Data = &isar_fill_fifo; ver = ISARVersion(cs, "ISurf:"); if (ver < 0) { printk(KERN_WARNING "ISurf: wrong ISAR version (ret = %d)\n", ver); release_io_isurf(cs); return (0); } return (1); }
static int sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) { struct net_device *dev; unsigned short ioaddr[2], irq; unsigned int serial_number; int error = -ENODEV; if (pnp_device_attach(pdev) < 0) return -ENODEV; if (pnp_activate_dev(pdev) < 0) goto out_detach; if (!pnp_port_valid(pdev, 0) || !pnp_port_valid(pdev, 1)) goto out_disable; if (!pnp_irq_valid(pdev, 0)) goto out_disable; serial_number = pdev->card->serial; ioaddr[0] = pnp_port_start(pdev, 0); ioaddr[1] = pnp_port_start(pdev, 0); irq = pnp_irq(pdev, 0); if (!request_region(ioaddr[0], 16, "sb1000")) goto out_disable; if (!request_region(ioaddr[1], 16, "sb1000")) goto out_release_region0; dev = alloc_etherdev(sizeof(struct sb1000_private)); if (!dev) { error = -ENOMEM; goto out_release_regions; } dev->base_addr = ioaddr[0]; /* mem_start holds the second I/O address */ dev->mem_start = ioaddr[1]; dev->irq = irq; if (sb1000_debug > 0) printk(KERN_NOTICE "%s: sb1000 at (%#3.3lx,%#3.3lx), " "S/N %#8.8x, IRQ %d.\n", dev->name, dev->base_addr, dev->mem_start, serial_number, dev->irq); /* * The SB1000 is an rx-only cable modem device. The uplink is a modem * and we do not want to arp on it. */ dev->flags = IFF_POINTOPOINT|IFF_NOARP; SET_NETDEV_DEV(dev, &pdev->dev); if (sb1000_debug > 0) printk(KERN_NOTICE "%s", version); dev->netdev_ops = &sb1000_netdev_ops; /* hardware address is 0:0:serial_number */ dev->dev_addr[2] = serial_number >> 24 & 0xff; dev->dev_addr[3] = serial_number >> 16 & 0xff; dev->dev_addr[4] = serial_number >> 8 & 0xff; dev->dev_addr[5] = serial_number >> 0 & 0xff; pnp_set_drvdata(pdev, dev); error = register_netdev(dev); if (error) goto out_free_netdev; return 0; out_free_netdev: free_netdev(dev); out_release_regions: release_region(ioaddr[1], 16); out_release_region0: release_region(ioaddr[0], 16); out_disable: pnp_disable_dev(pdev); out_detach: pnp_device_detach(pdev); return error; }
/* allocate memory, probe hardware, and initialize everything */ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) { const struct ite_dev_params *dev_desc = NULL; struct ite_dev *itdev = NULL; struct rc_dev *rdev = NULL; int ret = -ENOMEM; int model_no; int io_rsrc_no; ite_dbg("%s called", __func__); itdev = kzalloc(sizeof(struct ite_dev), GFP_KERNEL); if (!itdev) return ret; /* input device for IR remote (and tx) */ rdev = rc_allocate_device(); if (!rdev) goto exit_free_dev_rdev; itdev->rdev = rdev; ret = -ENODEV; /* get the model number */ model_no = (int)dev_id->driver_data; ite_pr(KERN_NOTICE, "Auto-detected model: %s\n", ite_dev_descs[model_no].model); if (model_number >= 0 && model_number < ARRAY_SIZE(ite_dev_descs)) { model_no = model_number; ite_pr(KERN_NOTICE, "The model has been fixed by a module " "parameter."); } ite_pr(KERN_NOTICE, "Using model: %s\n", ite_dev_descs[model_no].model); /* get the description for the device */ dev_desc = &ite_dev_descs[model_no]; io_rsrc_no = dev_desc->io_rsrc_no; /* validate pnp resources */ if (!pnp_port_valid(pdev, io_rsrc_no) || pnp_port_len(pdev, io_rsrc_no) != dev_desc->io_region_size) { dev_err(&pdev->dev, "IR PNP Port not valid!\n"); goto exit_free_dev_rdev; } if (!pnp_irq_valid(pdev, 0)) { dev_err(&pdev->dev, "PNP IRQ not valid!\n"); goto exit_free_dev_rdev; } /* store resource values */ itdev->cir_addr = pnp_port_start(pdev, io_rsrc_no); itdev->cir_irq = pnp_irq(pdev, 0); /* initialize spinlocks */ spin_lock_init(&itdev->lock); /* initialize raw event */ init_ir_raw_event(&itdev->rawir); /* set driver data into the pnp device */ pnp_set_drvdata(pdev, itdev); itdev->pdev = pdev; /* initialize waitqueues for transmission */ init_waitqueue_head(&itdev->tx_queue); init_waitqueue_head(&itdev->tx_ended); /* copy model-specific parameters */ itdev->params = *dev_desc; /* apply any overrides */ if (sample_period > 0) itdev->params.sample_period = sample_period; if (tx_carrier_freq > 0) itdev->params.tx_carrier_freq = tx_carrier_freq; if (tx_duty_cycle > 0 && tx_duty_cycle <= 100) itdev->params.tx_duty_cycle = tx_duty_cycle; if (rx_low_carrier_freq > 0) itdev->params.rx_low_carrier_freq = rx_low_carrier_freq; if (rx_high_carrier_freq > 0) itdev->params.rx_high_carrier_freq = rx_high_carrier_freq; /* print out parameters */ ite_pr(KERN_NOTICE, "TX-capable: %d\n", (int) itdev->params.hw_tx_capable); ite_pr(KERN_NOTICE, "Sample period (ns): %ld\n", (long) itdev->params.sample_period); ite_pr(KERN_NOTICE, "TX carrier frequency (Hz): %d\n", (int) itdev->params.tx_carrier_freq); ite_pr(KERN_NOTICE, "TX duty cycle (%%): %d\n", (int) itdev->params.tx_duty_cycle); ite_pr(KERN_NOTICE, "RX low carrier frequency (Hz): %d\n", (int) itdev->params.rx_low_carrier_freq); ite_pr(KERN_NOTICE, "RX high carrier frequency (Hz): %d\n", (int) itdev->params.rx_high_carrier_freq); /* set up hardware initial state */ itdev->params.init_hardware(itdev); /* set up ir-core props */ rdev->priv = itdev; rdev->driver_type = RC_DRIVER_IR_RAW; rdev->allowed_protos = RC_BIT_ALL; rdev->open = ite_open; rdev->close = ite_close; rdev->s_idle = ite_s_idle; rdev->s_rx_carrier_range = ite_set_rx_carrier_range; rdev->min_timeout = ITE_MIN_IDLE_TIMEOUT; rdev->max_timeout = ITE_MAX_IDLE_TIMEOUT; rdev->timeout = ITE_IDLE_TIMEOUT; rdev->rx_resolution = ITE_BAUDRATE_DIVISOR * itdev->params.sample_period; rdev->tx_resolution = ITE_BAUDRATE_DIVISOR * itdev->params.sample_period; /* set up transmitter related values if needed */ if (itdev->params.hw_tx_capable) { rdev->tx_ir = ite_tx_ir; rdev->s_tx_carrier = ite_set_tx_carrier; rdev->s_tx_duty_cycle = ite_set_tx_duty_cycle; } rdev->input_name = dev_desc->model; rdev->input_id.bustype = BUS_HOST; rdev->input_id.vendor = PCI_VENDOR_ID_ITE; rdev->input_id.product = 0; rdev->input_id.version = 0; rdev->driver_name = ITE_DRIVER_NAME; rdev->map_name = RC_MAP_RC6_MCE; ret = rc_register_device(rdev); if (ret) goto exit_free_dev_rdev; ret = -EBUSY; /* now claim resources */ if (!request_region(itdev->cir_addr, dev_desc->io_region_size, ITE_DRIVER_NAME)) goto exit_unregister_device; if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED, ITE_DRIVER_NAME, (void *)itdev)) goto exit_release_cir_addr; ite_pr(KERN_NOTICE, "driver has been successfully loaded\n"); return 0; exit_release_cir_addr: release_region(itdev->cir_addr, itdev->params.io_region_size); exit_unregister_device: rc_unregister_device(rdev); exit_free_dev_rdev: rc_free_device(rdev); kfree(itdev); return ret; }
/* Allocate memory, probe hardware, and initialize everything */ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) { struct fintek_dev *fintek; struct rc_dev *rdev; int ret = -ENOMEM; fintek = kzalloc(sizeof(struct fintek_dev), GFP_KERNEL); if (!fintek) return ret; /* input device for IR remote (and tx) */ rdev = rc_allocate_device(); if (!rdev) goto exit_free_dev_rdev; ret = -ENODEV; /* validate pnp resources */ if (!pnp_port_valid(pdev, 0)) { dev_err(&pdev->dev, "IR PNP Port not valid!\n"); goto exit_free_dev_rdev; } if (!pnp_irq_valid(pdev, 0)) { dev_err(&pdev->dev, "IR PNP IRQ not valid!\n"); goto exit_free_dev_rdev; } fintek->cir_addr = pnp_port_start(pdev, 0); fintek->cir_irq = pnp_irq(pdev, 0); fintek->cir_port_len = pnp_port_len(pdev, 0); fintek->cr_ip = CR_INDEX_PORT; fintek->cr_dp = CR_DATA_PORT; spin_lock_init(&fintek->fintek_lock); pnp_set_drvdata(pdev, fintek); fintek->pdev = pdev; ret = fintek_hw_detect(fintek); if (ret) goto exit_free_dev_rdev; /* Initialize CIR & CIR Wake Logical Devices */ fintek_config_mode_enable(fintek); fintek_cir_ldev_init(fintek); fintek_config_mode_disable(fintek); /* Initialize CIR & CIR Wake Config Registers */ fintek_cir_regs_init(fintek); /* Set up the rc device */ rdev->priv = fintek; rdev->driver_type = RC_DRIVER_IR_RAW; rdev->allowed_protocols = RC_BIT_ALL; rdev->open = fintek_open; rdev->close = fintek_close; rdev->input_name = FINTEK_DESCRIPTION; rdev->input_phys = "fintek/cir0"; rdev->input_id.bustype = BUS_HOST; rdev->input_id.vendor = VENDOR_ID_FINTEK; rdev->input_id.product = fintek->chip_major; rdev->input_id.version = fintek->chip_minor; rdev->dev.parent = &pdev->dev; rdev->driver_name = FINTEK_DRIVER_NAME; rdev->map_name = RC_MAP_RC6_MCE; rdev->timeout = US_TO_NS(1000); /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */ rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD); fintek->rdev = rdev; ret = -EBUSY; /* now claim resources */ if (!request_region(fintek->cir_addr, fintek->cir_port_len, FINTEK_DRIVER_NAME)) goto exit_free_dev_rdev; if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED, FINTEK_DRIVER_NAME, (void *)fintek)) goto exit_free_cir_addr; ret = rc_register_device(rdev); if (ret) goto exit_free_irq; device_init_wakeup(&pdev->dev, true); fit_pr(KERN_NOTICE, "driver has been successfully loaded\n"); if (debug) cir_dump_regs(fintek); return 0; exit_free_irq: free_irq(fintek->cir_irq, fintek); exit_free_cir_addr: release_region(fintek->cir_addr, fintek->cir_port_len); exit_free_dev_rdev: rc_free_device(rdev); kfree(fintek); return ret; }
static int snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *card, const struct pnp_card_device_id *id) { struct pnp_dev *pdev; int err; /* Check for each logical device. */ /* CS4232 chip (aka "windows sound system") is logical device 0 */ acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); if (acard->wss == NULL) return -EBUSY; /* there is a game port at logical device 1, but we ignore it completely */ /* the control interface is logical device 2, but we ignore it completely. in fact, nobody even seems to know what it does. */ /* Only configure the CS4232 MIDI interface if its been specifically requested. It is logical device 3. */ if (use_cs4232_midi[dev]) { acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); if (acard->mpu == NULL) return -EBUSY; } /* The ICS2115 synth is logical device 4 */ acard->synth = pnp_request_card_device(card, id->devs[3].id, NULL); if (acard->synth == NULL) return -EBUSY; /* PCM/FM initialization */ pdev = acard->wss; /* An interesting note from the Tropez+ FAQ: Q. [Ports] Why is the base address of the WSS I/O ports off by 4? A. WSS I/O requires a block of 8 I/O addresses ("ports"). Of these, the first 4 are used to identify and configure the board. With the advent of PnP, these first 4 addresses have become obsolete, and software applications only use the last 4 addresses to control the codec chip. Therefore, the base address setting "skips past" the 4 unused addresses. */ err = pnp_activate_dev(pdev); if (err < 0) { snd_printk(KERN_ERR "PnP WSS pnp configure failure\n"); return err; } cs4232_pcm_port[dev] = pnp_port_start(pdev, 0); fm_port[dev] = pnp_port_start(pdev, 1); dma1[dev] = pnp_dma(pdev, 0); dma2[dev] = pnp_dma(pdev, 1); cs4232_pcm_irq[dev] = pnp_irq(pdev, 0); /* Synth initialization */ pdev = acard->synth; err = pnp_activate_dev(pdev); if (err < 0) { snd_printk(KERN_ERR "PnP ICS2115 pnp configure failure\n"); return err; } ics2115_port[dev] = pnp_port_start(pdev, 0); ics2115_irq[dev] = pnp_irq(pdev, 0); /* CS4232 MPU initialization. Configure this only if explicitly requested, since its physically inaccessible and consumes another IRQ. */ if (use_cs4232_midi[dev]) { pdev = acard->mpu; err = pnp_activate_dev(pdev); if (err < 0) { snd_printk(KERN_ERR "PnP MPU401 pnp configure failure\n"); cs4232_mpu_port[dev] = SNDRV_AUTO_PORT; } else { cs4232_mpu_port[dev] = pnp_port_start(pdev, 0); cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); } snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n", cs4232_mpu_port[dev], cs4232_mpu_irq[dev]); } snd_printdd ("CS4232: pcm port=0x%lx, fm port=0x%lx, dma1=%i, dma2=%i, irq=%i\nICS2115: port=0x%lx, irq=%i\n", cs4232_pcm_port[dev], fm_port[dev], dma1[dev], dma2[dev], cs4232_pcm_irq[dev], ics2115_port[dev], ics2115_irq[dev]); return 0; }
int __init setup_niccy(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, niccy_revision); printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_NICCY) return (0); #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d = NULL; int err; if ((pnp_c = pnp_find_card( ISAPNP_VENDOR('S', 'D', 'A'), ISAPNP_FUNCTION(0x0150), pnp_c))) { if (!(pnp_d = pnp_find_dev(pnp_c, ISAPNP_VENDOR('S', 'D', 'A'), ISAPNP_FUNCTION(0x0150), pnp_d))) { printk(KERN_ERR "NiccyPnP: PnP error card found, no device\n"); return (0); } pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err<0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", __FUNCTION__, err); return(0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[2] = pnp_port_start(pnp_d, 1); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1] || !card->para[2]) { printk(KERN_ERR "NiccyPnP:some resources are missing %ld/%lx/%lx\n", card->para[0], card->para[1], card->para[2]); pnp_disable_dev(pnp_d); return(0); } } else { printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n"); } } #endif if (card->para[1]) { cs->hw.niccy.isac = card->para[1] + ISAC_PNP; cs->hw.niccy.hscx = card->para[1] + HSCX_PNP; cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP; cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP; cs->hw.niccy.cfg_reg = 0; cs->subtyp = NICCY_PNP; cs->irq = card->para[0]; if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) { printk(KERN_WARNING "HiSax: %s data port %x-%x already in use\n", CardType[card->typ], cs->hw.niccy.isac, cs->hw.niccy.isac + 1); return (0); } if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) { printk(KERN_WARNING "HiSax: %s address port %x-%x already in use\n", CardType[card->typ], cs->hw.niccy.isac_ale, cs->hw.niccy.isac_ale + 1); release_region(cs->hw.niccy.isac, 2); return (0); } } else { #ifdef CONFIG_PCI u_int pci_ioaddr; cs->subtyp = 0; if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY, niccy_dev))) { if (pci_enable_device(niccy_dev)) return(0); /* get IRQ */ if (!niccy_dev->irq) { printk(KERN_WARNING "Niccy: No IRQ for PCI card found\n"); return(0); } cs->irq = niccy_dev->irq; cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0); if (!cs->hw.niccy.cfg_reg) { printk(KERN_WARNING "Niccy: No IO-Adr for PCI cfg found\n"); return(0); } pci_ioaddr = pci_resource_start(niccy_dev, 1); if (!pci_ioaddr) { printk(KERN_WARNING "Niccy: No IO-Adr for PCI card found\n"); return(0); } cs->subtyp = NICCY_PCI; } else { printk(KERN_WARNING "Niccy: No PCI card found\n"); return(0); } cs->irq_flags |= SA_SHIRQ; cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA; cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR; cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA; cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR; if (!request_region(cs->hw.niccy.isac, 4, "niccy")) { printk(KERN_WARNING "HiSax: %s data port %x-%x already in use\n", CardType[card->typ], cs->hw.niccy.isac, cs->hw.niccy.isac + 4); return (0); } if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) { printk(KERN_WARNING "HiSax: %s pci port %x-%x already in use\n", CardType[card->typ], cs->hw.niccy.cfg_reg, cs->hw.niccy.cfg_reg + 0x40); release_region(cs->hw.niccy.isac, 4); return (0); } #else printk(KERN_WARNING "Niccy: io0 0 and NO_PCI_BIOS\n"); printk(KERN_WARNING "Niccy: unable to config NICCY PCI\n"); return (0); #endif /* CONFIG_PCI */ } printk(KERN_INFO "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n", CardType[cs->typ], (cs->subtyp==1) ? "PnP":"PCI", cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->BC_Read_Reg = &ReadHSCX; cs->BC_Write_Reg = &WriteHSCX; cs->BC_Send_Data = &hscx_fill_fifo; cs->cardmsg = &niccy_card_msg; cs->irq_func = &niccy_interrupt; ISACVersion(cs, "Niccy:"); if (HscxVersion(cs, "Niccy:")) { printk(KERN_WARNING "Niccy: wrong HSCX versions check IO address\n"); release_io_niccy(cs); return (0); } return (1); }