/** * usb_hcd_pci_probe - initialize PCI-based HCDs * @dev: USB Host Controller being probed * @id: pci hotplug id connecting controller to HCD framework * Context: !in_interrupt() * * Allocates basic PCI resources for this USB host controller, and * then invokes the start() method for the HCD associated with it * through the hotplug entry's driver_data. * * Store this function in the HCD's struct pci_driver as probe(). */ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) { struct hc_driver *driver; struct usb_hcd *hcd; int retval; if (usb_disabled()) return -ENODEV; if (!id || !(driver = (struct hc_driver *) id->driver_data)) return -EINVAL; if (pci_enable_device (dev) < 0) return -ENODEV; dev->current_state = PCI_D0; dev->dev.power.power_state = PMSG_ON; if (!dev->irq) { dev_err (&dev->dev, "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", pci_name(dev)); retval = -ENODEV; goto err1; } hcd = usb_create_hcd (driver, &dev->dev, pci_name(dev)); if (!hcd) { retval = -ENOMEM; goto err1; } if (driver->flags & HCD_MEMORY) { // EHCI, OHCI hcd->rsrc_start = pci_resource_start (dev, 0); hcd->rsrc_len = pci_resource_len (dev, 0); if (!request_mem_region (hcd->rsrc_start, hcd->rsrc_len, driver->description)) { dev_dbg (&dev->dev, "controller already in use\n"); retval = -EBUSY; goto err2; } hcd->regs = ioremap_nocache (hcd->rsrc_start, hcd->rsrc_len); if (hcd->regs == NULL) { dev_dbg (&dev->dev, "error mapping memory\n"); retval = -EFAULT; goto err3; } } else { // UHCI int region; for (region = 0; region < PCI_ROM_RESOURCE; region++) { if (!(pci_resource_flags (dev, region) & IORESOURCE_IO)) continue; hcd->rsrc_start = pci_resource_start (dev, region); hcd->rsrc_len = pci_resource_len (dev, region); if (request_region (hcd->rsrc_start, hcd->rsrc_len, driver->description)) break; } if (region == PCI_ROM_RESOURCE) { dev_dbg (&dev->dev, "no i/o regions available\n"); retval = -EBUSY; goto err1; } } #ifdef CONFIG_PCI_NAMES hcd->product_desc = dev->pretty_name; #endif pci_set_master (dev); retval = usb_add_hcd (hcd, dev->irq, SA_SHIRQ); if (retval != 0) goto err4; return retval; err4: if (driver->flags & HCD_MEMORY) { iounmap (hcd->regs); err3: release_mem_region (hcd->rsrc_start, hcd->rsrc_len); } else release_region (hcd->rsrc_start, hcd->rsrc_len); err2: usb_put_hcd (hcd); err1: pci_disable_device (dev); dev_err (&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); return retval; }
static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev, const struct pci_device_id *id) { unsigned short smba_idx = 0xcd6; u8 smba_en_lo, smba_en_hi, i2ccfg, i2ccfg_offset = 0x10, smb_en = 0x2c; /* SB800 and later SMBus does not support forcing address */ if (force || force_addr) { dev_err(&PIIX4_dev->dev, "SMBus does not support " "forcing address!\n"); return -EINVAL; } /* Determine the address of the SMBus areas */ if (!request_region(smba_idx, 2, "smba_idx")) { dev_err(&PIIX4_dev->dev, "SMBus base address index region " "0x%x already in use!\n", smba_idx); return -EBUSY; } outb_p(smb_en, smba_idx); smba_en_lo = inb_p(smba_idx + 1); outb_p(smb_en + 1, smba_idx); smba_en_hi = inb_p(smba_idx + 1); release_region(smba_idx, 2); if ((smba_en_lo & 1) == 0) { dev_err(&PIIX4_dev->dev, "Host SMBus controller not enabled!\n"); return -ENODEV; } piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0; if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) return -ENODEV; if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n", piix4_smba); return -EBUSY; } /* Request the SMBus I2C bus config region */ if (!request_region(piix4_smba + i2ccfg_offset, 1, "i2ccfg")) { dev_err(&PIIX4_dev->dev, "SMBus I2C bus config region " "0x%x already in use!\n", piix4_smba + i2ccfg_offset); release_region(piix4_smba, SMBIOSIZE); piix4_smba = 0; return -EBUSY; } i2ccfg = inb_p(piix4_smba + i2ccfg_offset); release_region(piix4_smba + i2ccfg_offset, 1); if (i2ccfg & 1) dev_dbg(&PIIX4_dev->dev, "Using IRQ for SMBus.\n"); else dev_dbg(&PIIX4_dev->dev, "Using SMI# for SMBus.\n"); dev_info(&PIIX4_dev->dev, "SMBus Host Controller at 0x%x, revision %d\n", piix4_smba, i2ccfg >> 4); return 0; }
static int __devinit cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id) { struct Scsi_Host *host; int ret; ret = ecard_request_resources(ec); if (ret) goto out; host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata)); if (!host) { ret = -ENOMEM; goto out_release; } priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW), ecard_resource_len(ec, ECARD_RES_IOCSLOW)); priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), ecard_resource_len(ec, ECARD_RES_MEMC)); if (!priv(host)->base || !priv(host)->dma) { ret = -ENOMEM; goto out_unmap; } host->irq = ec->irq; NCR5380_init(host, 0); priv(host)->ctrl = 0; writeb(0, priv(host)->base + CTRL); host->n_io_port = 255; if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) { ret = -EBUSY; goto out_unmap; } ret = request_irq(host->irq, cumanascsi_intr, IRQF_DISABLED, "CumanaSCSI-1", host); if (ret) { // printk("scsi%d: IRQ%d not free: %d\n", ; goto out_unmap; } // printk("scsi%d: at port 0x%08lx irq %d", ; // printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", ; ; NCR5380_print_options(host); ; ret = scsi_add_host(host, &ec->dev); if (ret) goto out_free_irq; scsi_scan_host(host); goto out; out_free_irq: free_irq(host->irq, host); out_unmap: iounmap(priv(host)->base); iounmap(priv(host)->dma); scsi_host_put(host); out_release: ecard_release_resources(ec); out: return ret; }
int snd_gus_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, int timer_dev, int voices, int pcm_channels, int effect, struct snd_gus_card **rgus) { struct snd_gus_card *gus; int err; static struct snd_device_ops ops = { .dev_free = snd_gus_dev_free, }; *rgus = NULL; gus = kzalloc(sizeof(*gus), GFP_KERNEL); if (gus == NULL) return -ENOMEM; gus->gf1.irq = -1; gus->gf1.dma1 = -1; gus->gf1.dma2 = -1; gus->card = card; gus->gf1.port = port; /* fill register variables for speedup */ gus->gf1.reg_page = GUSP(gus, GF1PAGE); gus->gf1.reg_regsel = GUSP(gus, GF1REGSEL); gus->gf1.reg_data8 = GUSP(gus, GF1DATAHIGH); gus->gf1.reg_data16 = GUSP(gus, GF1DATALOW); gus->gf1.reg_irqstat = GUSP(gus, IRQSTAT); gus->gf1.reg_dram = GUSP(gus, DRAM); gus->gf1.reg_timerctrl = GUSP(gus, TIMERCNTRL); gus->gf1.reg_timerdata = GUSP(gus, TIMERDATA); /* allocate resources */ if ((gus->gf1.res_port1 = request_region(port, 16, "GUS GF1 (Adlib/SB)")) == NULL) { snd_printk(KERN_ERR "gus: can't grab SB port 0x%lx\n", port); snd_gus_free(gus); return -EBUSY; } if ((gus->gf1.res_port2 = request_region(port + 0x100, 12, "GUS GF1 (Synth)")) == NULL) { snd_printk(KERN_ERR "gus: can't grab synth port 0x%lx\n", port + 0x100); snd_gus_free(gus); return -EBUSY; } if (irq >= 0 && request_irq(irq, snd_gus_interrupt, SA_INTERRUPT, "GUS GF1", (void *) gus)) { snd_printk(KERN_ERR "gus: can't grab irq %d\n", irq); snd_gus_free(gus); return -EBUSY; } gus->gf1.irq = irq; if (request_dma(dma1, "GUS - 1")) { snd_printk(KERN_ERR "gus: can't grab DMA1 %d\n", dma1); snd_gus_free(gus); return -EBUSY; } gus->gf1.dma1 = dma1; if (dma2 >= 0 && dma1 != dma2) { if (request_dma(dma2, "GUS - 2")) { snd_printk(KERN_ERR "gus: can't grab DMA2 %d\n", dma2); snd_gus_free(gus); return -EBUSY; } gus->gf1.dma2 = dma2; } else { gus->gf1.dma2 = gus->gf1.dma1; gus->equal_dma = 1; } gus->timer_dev = timer_dev; if (voices < 14) voices = 14; if (voices > 32) voices = 32; if (pcm_channels < 0) pcm_channels = 0; if (pcm_channels > 8) pcm_channels = 8; pcm_channels++; pcm_channels &= ~1; gus->gf1.effect = effect ? 1 : 0; gus->gf1.active_voices = voices; gus->gf1.pcm_channels = pcm_channels; gus->gf1.volume_ramp = 25; gus->gf1.smooth_pan = 1; spin_lock_init(&gus->reg_lock); spin_lock_init(&gus->voice_alloc); spin_lock_init(&gus->active_voice_lock); spin_lock_init(&gus->event_lock); spin_lock_init(&gus->dma_lock); spin_lock_init(&gus->pcm_volume_level_lock); spin_lock_init(&gus->uart_cmd_lock); mutex_init(&gus->dma_mutex); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, gus, &ops)) < 0) { snd_gus_free(gus); return err; } *rgus = gus; 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; }
static int init_mediavision(void) { int id; int idec, decst; int i; unsigned char i2c_defs[]={ 0x4C,0x30,0x00,0xE8, 0xB6,0xE2,0x00,0x00, 0xFF,0xFF,0x00,0x00, 0x00,0x00,0x78,0x98, 0x00,0x00,0x00,0x00, 0x34,0x0A,0xF4,0xCE, 0xE4 }; mem = ioremap(mem_base, 0x800); if (!mem) return -ENOMEM; if (!request_region(0x9A01, 1, "Mediavision PMS config")) { printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n"); iounmap(mem); return -EBUSY; } if (!request_region(io_port, 3, "Mediavision PMS")) { printk(KERN_WARNING "mediavision: I/O port %d in use.\n", io_port); release_region(0x9A01, 1); iounmap(mem); return -EBUSY; } outb(0xB8, 0x9A01); /* Unlock */ outb(io_port>>4, 0x9A01); /* Set IO port */ id=mvv_read(3); decst=pms_i2c_stat(0x43); if(decst!=-1) idec=2; else if(pms_i2c_stat(0xb9)!=-1) idec=3; else if(pms_i2c_stat(0x8b)!=-1) idec=1; else idec=0; printk(KERN_INFO "PMS type is %d\n", idec); if(idec == 0) { release_region(io_port, 3); release_region(0x9A01, 1); iounmap(mem); return -ENODEV; } /* * Ok we have a PMS of some sort */ mvv_write(0x04, mem_base>>12); /* Set the memory area */ /* Ok now load the defaults */ for(i=0;i<0x19;i++) { if(i2c_defs[i]==0xFF) pms_i2c_andor(0x8A, i, 0x07,0x00); else pms_i2c_write(0x8A, i, i2c_defs[i]); } pms_i2c_write(0xB8,0x00,0x12); pms_i2c_write(0xB8,0x04,0x00); pms_i2c_write(0xB8,0x07,0x00); pms_i2c_write(0xB8,0x08,0x00); pms_i2c_write(0xB8,0x09,0xFF); pms_i2c_write(0xB8,0x0A,0x00); pms_i2c_write(0xB8,0x0B,0x10); pms_i2c_write(0xB8,0x10,0x03); mvv_write(0x01, 0x00); mvv_write(0x05, 0xA0); mvv_write(0x08, 0x25); mvv_write(0x09, 0x00); mvv_write(0x0A, 0x20|MVVMEMORYWIDTH); mvv_write(0x10, 0x02); mvv_write(0x1E, 0x0C); mvv_write(0x1F, 0x03); mvv_write(0x26, 0x06); mvv_write(0x2B, 0x00); mvv_write(0x2C, 0x20); mvv_write(0x2D, 0x00); mvv_write(0x2F, 0x70); mvv_write(0x32, 0x00); mvv_write(0x33, MVVMEMORYWIDTH); mvv_write(0x34, 0x00); mvv_write(0x35, 0x00); mvv_write(0x3A, 0x80); mvv_write(0x3B, 0x10); mvv_write(0x20, 0x00); mvv_write(0x21, 0x00); mvv_write(0x30, 0x22); return 0; }
static int __init ultra32_probe1(struct net_device *dev, int ioaddr) { int i, edge, media, retval; int checksum = 0; const char *model_name; static unsigned version_printed; /* Values from various config regs. */ unsigned char idreg; unsigned char reg4; const char *ifmap[] = {"UTP No Link", "", "UTP/AUI", "UTP/BNC"}; if (!request_region(ioaddr, ULTRA32_IO_EXTENT, DRV_NAME)) return -EBUSY; if (inb(ioaddr + ULTRA32_IDPORT) == 0xff || inl(ioaddr + ULTRA32_IDPORT) != ULTRA32_ID) { retval = -ENODEV; goto out; } media = inb(ioaddr + ULTRA32_CFG7) & 0x03; edge = inb(ioaddr + ULTRA32_CFG5) & 0x08; printk("SMC Ultra32 in EISA Slot %d, Media: %s, %s IRQs.\n", ioaddr >> 12, ifmap[media], (edge ? "Edge Triggered" : "Level Sensitive")); idreg = inb(ioaddr + 7); reg4 = inb(ioaddr + 4) & 0x7f; /* Check the ID nibble. */ if ((idreg & 0xf0) != 0x20) { /* SMC Ultra */ retval = -ENODEV; goto out; } /* Select the station address register set. */ outb(reg4, ioaddr + 4); for (i = 0; i < 8; i++) checksum += inb(ioaddr + 8 + i); if ((checksum & 0xff) != 0xff) { retval = -ENODEV; goto out; } if (ei_debug && version_printed++ == 0) printk(version); model_name = "SMC Ultra32"; for (i = 0; i < 6; i++) dev->dev_addr[i] = inb(ioaddr + 8 + i); printk("%s: %s at 0x%X, %pM", dev->name, model_name, ioaddr, dev->dev_addr); /* Switch from the station address to the alternate register set and read the useful registers there. */ outb(0x80 | reg4, ioaddr + 4); /* Enable FINE16 mode to avoid BIOS ROM width mismatches @ reboot. */ outb(0x80 | inb(ioaddr + 0x0c), ioaddr + 0x0c); /* Reset RAM addr. */ outb(0x00, ioaddr + 0x0b); /* Switch back to the station address register set so that the MS-DOS driver can find the card after a warm boot. */ outb(reg4, ioaddr + 4); if ((inb(ioaddr + ULTRA32_CFG5) & 0x40) == 0) { printk("\nsmc-ultra32: Card RAM is disabled! " "Run EISA config utility.\n"); retval = -ENODEV; goto out; } if ((inb(ioaddr + ULTRA32_CFG2) & 0x04) == 0) printk("\nsmc-ultra32: Ignoring Bus-Master enable bit. " "Run EISA config utility.\n"); if (dev->irq < 2) { unsigned char irqmap[] = {0, 9, 3, 5, 7, 10, 11, 15}; int irq = irqmap[inb(ioaddr + ULTRA32_CFG5) & 0x07]; if (irq == 0) { printk(", failed to detect IRQ line.\n"); retval = -EAGAIN; goto out; } dev->irq = irq; } /* The 8390 isn't at the base address, so fake the offset */ dev->base_addr = ioaddr + ULTRA32_NIC_OFFSET; /* Save RAM address in the unused reg0 to avoid excess inb's. */ ei_status.reg0 = inb(ioaddr + ULTRA32_CFG3) & 0xfc; dev->mem_start = 0xc0000 + ((ei_status.reg0 & 0x7c) << 11); ei_status.name = model_name; ei_status.word16 = 1; ei_status.tx_start_page = 0; ei_status.rx_start_page = TX_PAGES; /* All Ultra32 cards have 32KB memory with an 8KB window. */ ei_status.stop_page = 128; ei_status.mem = ioremap(dev->mem_start, 0x2000); if (!ei_status.mem) { printk(", failed to ioremap.\n"); retval = -ENOMEM; goto out; } dev->mem_end = dev->mem_start + 0x1fff; printk(", IRQ %d, 32KB memory, 8KB window at 0x%lx-0x%lx.\n", dev->irq, dev->mem_start, dev->mem_end); ei_status.block_input = &ultra32_block_input; ei_status.block_output = &ultra32_block_output; ei_status.get_8390_hdr = &ultra32_get_8390_hdr; ei_status.reset_8390 = &ultra32_reset_8390; dev->netdev_ops = &ultra32_netdev_ops; NS8390_init(dev, 0); return 0; out: release_region(ioaddr, ULTRA32_IO_EXTENT); return retval; }
static int __init cs89x0_probe1(struct net_device *dev, int ioaddr) { struct net_local *lp; static unsigned version_printed = 0; int i; unsigned rev_type = 0; /* irq2dev_map[0] = dev; */ #ifdef CONFIG_UCSIMM /* set up the chip select */ *(volatile unsigned char *)0xfffff42b |= 0x01; /* output /sleep */ *(volatile unsigned short *)0xfffff428 |= 0x0101; /* not sleeping */ *(volatile unsigned char *)0xfffff42b &= ~0x02; /* input irq5 */ *(volatile unsigned short *)0xfffff428 &= ~0x0202; /* irq5 fcn on */ *(volatile unsigned short *)0xfffff102 = 0x8000; /* 0x04000000 */ *(volatile unsigned short *)0xfffff112 = 0x01e1; /* 128k, 2ws, FLASH, en */ #endif #ifdef CONFIG_ARCH_ATMEL *(volatile unsigned int *) AIC_IDCR = AIC_IRQ1; /* disable interrupt IRQ1 */ #ifdef CONFIG_EB40LS *(volatile unsigned int *) PIO_DISABLE_REGISTER = (1 << 10); /* disable PIO for IRQ1 */ #endif *(volatile unsigned int *) AIC_ICCR = AIC_IRQ1; /* clear interrupt IRQ1 */ *(volatile unsigned int *) AIC_IECR = AIC_IRQ1; /* enable interrupt IRQ1 */ #endif #ifdef CONFIG_ALMA_ANS /* * Make sure the chip select (CSA1) is enabled * Note, that we don't have to program the base address, since * it is programmed once for both CSA0 and CSA1 in *-head.S */ PFSEL &= ~PF_CSA1; PFDIR |= PF_CSA1; /* Make sure that interrupt line (irq3) is enabled too */ PDSEL &= ~PD_IRQ3; PDDIR &= ~PD_IRQ3; PDKBEN |= PD_IRQ3; #endif /* Initialize the device structure. */ if (dev->priv == NULL) { dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); memset(dev->priv, 0, sizeof(struct net_local)); } dev->base_addr = ioaddr; lp = (struct net_local *)dev->priv; if (readreg(dev, PP_ChipID) != CHIP_EISA_ID_SIG) { printk("cs89x0.c: No CrystalLan device found.\n"); return ENODEV; } /* get the chip type */ rev_type = readreg(dev, PRODUCT_ID_ADD); lp->chip_type = rev_type &~ REVISON_BITS; lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A'; /* Check the chip type and revision in order to set the correct send command CS8920 revision C and CS8900 revision F can use the faster send. */ lp->send_cmd = TX_AFTER_ALL; #if 0 if (lp->chip_type == CS8900 && lp->chip_revision >= 'F') lp->send_cmd = TX_NOW; if (lp->chip_type != CS8900 && lp->chip_revision >= 'C') lp->send_cmd = TX_NOW; #endif if (net_debug && version_printed++ == 0) printk(version); printk("%s: cs89%c0%s rev %c found at 0x%.8lx %s", dev->name, lp->chip_type==CS8900?'0':'2', lp->chip_type==CS8920M?"M":"", lp->chip_revision, dev->base_addr, readreg(dev, PP_SelfST) & ACTIVE_33V ? "3.3Volts" : "5Volts"); reset_chip(dev); /* Fill this in, we don't have an EEPROM */ lp->adapter_cnf = A_CNF_10B_T | A_CNF_MEDIA_10B_T; lp->auto_neg_cnf = EE_AUTO_NEG_ENABLE | IMM_BIT; printk(" media %s%s%s", (lp->adapter_cnf & A_CNF_10B_T)?"RJ-45,":"", (lp->adapter_cnf & A_CNF_AUI)?"AUI,":"", (lp->adapter_cnf & A_CNF_10B_2)?"BNC,":""); lp->irq_map = 0xffff; /* dev->dev_addr[0] through dev->dev_addr[6] holds the mac address * of this ethernet device. This can be set to anything we want it * to be. But care should be taken to make this number unique... */ #if defined(CONFIG_UCSIMM) || defined(CONFIG_EB40LS) || \ defined(CONFIG_BLIP) || defined(CONFIG_UCLINKII) { extern unsigned char *cs8900a_hwaddr; memcpy(dev->dev_addr, cs8900a_hwaddr, 6); } #elif defined (CONFIG_BOARD_UCLINKII) || \ defined (CONFIG_BOARD_EVS3C4530LII) || \ defined (CONFIG_BOARD_EVS3C4530HEI) memcpy(dev->dev_addr, get_MAC_address("dev1"), 6); #else #error MAC address is not defined #endif /* print the ethernet address. */ for (i = 0; i < ETH_ALEN; i++) printk(" %2.2x", dev->dev_addr[i]); #ifdef FIXME /* Grab the region so we can find another board if autoIRQ fails. */ request_region(ioaddr, NETCARD_IO_EXTENT,"cs89x0"); #endif dev->open = net_open; dev->stop = net_close; dev->hard_start_xmit = net_send_packet; dev->get_stats = net_get_stats; dev->set_multicast_list = &set_multicast_list; dev->set_mac_address = &set_mac_address; /* Fill in the fields of the device structure with ethernet values. */ ether_setup(dev); printk("\n"); return 0; }
static int b1isa_probe(struct pci_dev *pdev) { avmctrl_info *cinfo; avmcard *card; int retval; card = b1_alloc_card(1); if (!card) { printk(KERN_WARNING "b1isa: no memory.\n"); retval = -ENOMEM; goto err; } cinfo = card->ctrlinfo; card->port = pci_resource_start(pdev, 0); card->irq = pdev->irq; card->cardtype = avm_b1isa; sprintf(card->name, "b1isa-%x", card->port); if ( card->port != 0x150 && card->port != 0x250 && card->port != 0x300 && card->port != 0x340) { printk(KERN_WARNING "b1isa: invalid port 0x%x.\n", card->port); retval = -EINVAL; goto err_free; } if (b1_irq_table[card->irq & 0xf] == 0) { printk(KERN_WARNING "b1isa: irq %d not valid.\n", card->irq); retval = -EINVAL; goto err_free; } if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { printk(KERN_WARNING "b1isa: ports 0x%03x-0x%03x in use.\n", card->port, card->port + AVMB1_PORTLEN); retval = -EBUSY; goto err_free; } retval = request_irq(card->irq, b1_interrupt, 0, card->name, card); if (retval) { printk(KERN_ERR "b1isa: unable to get IRQ %d.\n", card->irq); goto err_release_region; } b1_reset(card->port); if ((retval = b1_detect(card->port, card->cardtype)) != 0) { printk(KERN_NOTICE "b1isa: NO card at 0x%x (%d)\n", card->port, retval); retval = -ENODEV; goto err_free_irq; } b1_reset(card->port); b1_getrevision(card); cinfo->capi_ctrl.owner = THIS_MODULE; cinfo->capi_ctrl.driver_name = "b1isa"; cinfo->capi_ctrl.driverdata = cinfo; cinfo->capi_ctrl.register_appl = b1_register_appl; cinfo->capi_ctrl.release_appl = b1_release_appl; cinfo->capi_ctrl.send_message = b1_send_message; cinfo->capi_ctrl.load_firmware = b1_load_firmware; cinfo->capi_ctrl.reset_ctr = b1_reset_ctr; cinfo->capi_ctrl.procinfo = b1isa_procinfo; cinfo->capi_ctrl.proc_fops = &b1ctl_proc_fops; strcpy(cinfo->capi_ctrl.name, card->name); retval = attach_capi_ctr(&cinfo->capi_ctrl); if (retval) { printk(KERN_ERR "b1isa: attach controller failed.\n"); goto err_free_irq; } printk(KERN_INFO "b1isa: AVM B1 ISA at i/o %#x, irq %d, revision %d\n", card->port, card->irq, card->revision); pci_set_drvdata(pdev, cinfo); return 0; err_free_irq: free_irq(card->irq, card); err_release_region: release_region(card->port, AVMB1_PORTLEN); err_free: b1_free_card(card); err: return retval; }
static int b1pci_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)); cinfo = (avmctrl_info *) kmalloc(sizeof(avmctrl_info), GFP_ATOMIC); if (!cinfo) { printk(KERN_WARNING "%s: no memory.\n", driver->name); kfree(card); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(cinfo, 0, sizeof(avmctrl_info)); card->ctrlinfo = cinfo; cinfo->card = card; sprintf(card->name, "b1pci-%x", p->port); card->port = p->port; card->irq = p->irq; 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); MOD_DEC_USE_COUNT; return -EBUSY; } b1_reset(card->port); if ((retval = b1_detect(card->port, card->cardtype)) != 0) { printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n", driver->name, card->port, retval); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EIO; } b1_reset(card->port); b1_getrevision(card); request_region(p->port, AVMB1_PORTLEN, card->name); retval = request_irq(card->irq, b1pci_interrupt, SA_SHIRQ, card->name, card); if (retval) { printk(KERN_ERR "%s: unable to get IRQ %d.\n", driver->name, card->irq); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); 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); free_irq(card->irq, card); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } if (card->revision >= 4) { printk(KERN_INFO "%s: AVM B1 PCI V4 at i/o %#x, irq %d, revision %d (no dma)\n", driver->name, card->port, card->irq, card->revision); } else { printk(KERN_INFO "%s: AVM B1 PCI at i/o %#x, irq %d, revision %d\n", driver->name, card->port, card->irq, card->revision); } return 0; }
static int __init n2_run(unsigned long io, unsigned long irq, unsigned long winbase, long valid0, long valid1) { card_t *card; u8 cnt, pcr; int i; if (io < 0x200 || io > 0x3FF || (io % N2_IOPORTS) != 0) { printk(KERN_ERR "n2: invalid I/O port value\n"); return -ENODEV; } if (irq < 3 || irq > 15 || irq == 6) { /* FIXME */ printk(KERN_ERR "n2: invalid IRQ value\n"); return -ENODEV; } if (winbase < 0xA0000 || winbase > 0xFFFFF || (winbase & 0xFFF) != 0) { printk(KERN_ERR "n2: invalid RAM value\n"); return -ENODEV; } card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { printk(KERN_ERR "n2: unable to allocate memory\n"); return -ENOBUFS; } card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); if (!card->ports[0].dev || !card->ports[1].dev) { printk(KERN_ERR "n2: unable to allocate memory\n"); n2_destroy_card(card); return -ENOMEM; } if (!request_region(io, N2_IOPORTS, devname)) { printk(KERN_ERR "n2: I/O port region in use\n"); n2_destroy_card(card); return -EBUSY; } card->io = io; if (request_irq(irq, &sca_intr, 0, devname, card)) { printk(KERN_ERR "n2: could not allocate IRQ\n"); n2_destroy_card(card); return(-EBUSY); } card->irq = irq; if (!request_mem_region(winbase, USE_WINDOWSIZE, devname)) { printk(KERN_ERR "n2: could not request RAM window\n"); n2_destroy_card(card); return(-EBUSY); } card->phy_winbase = winbase; card->winbase = ioremap(winbase, USE_WINDOWSIZE); if (!card->winbase) { printk(KERN_ERR "n2: ioremap() failed\n"); n2_destroy_card(card); return -EFAULT; } outb(0, io + N2_PCR); outb(winbase >> 12, io + N2_BAR); switch (USE_WINDOWSIZE) { case 16384: outb(WIN16K, io + N2_PSR); break; case 32768: outb(WIN32K, io + N2_PSR); break; case 65536: outb(WIN64K, io + N2_PSR); break; default: printk(KERN_ERR "n2: invalid window size\n"); n2_destroy_card(card); return -ENODEV; } pcr = PCR_ENWIN | PCR_VPM | (USE_BUS16BITS ? PCR_BUS16 : 0); outb(pcr, io + N2_PCR); card->ram_size = sca_detect_ram(card, card->winbase, MAX_RAM_SIZE); /* number of TX + RX buffers for one port */ i = card->ram_size / ((valid0 + valid1) * (sizeof(pkt_desc) + HDLC_MAX_MRU)); card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS); card->rx_ring_buffers = i - card->tx_ring_buffers; card->buff_offset = (valid0 + valid1) * sizeof(pkt_desc) * (card->tx_ring_buffers + card->rx_ring_buffers); printk(KERN_INFO "n2: RISCom/N2 %u KB RAM, IRQ%u, " "using %u TX + %u RX packets rings\n", card->ram_size / 1024, card->irq, card->tx_ring_buffers, card->rx_ring_buffers); if (card->tx_ring_buffers < 1) { printk(KERN_ERR "n2: RAM test failed\n"); n2_destroy_card(card); return -EIO; } pcr |= PCR_RUNSCA; /* run SCA */ outb(pcr, io + N2_PCR); outb(0, io + N2_MCR); sca_init(card, 0); for (cnt = 0; cnt < 2; cnt++) { port_t *port = &card->ports[cnt]; struct net_device *dev = port_to_dev(port); hdlc_device *hdlc = dev_to_hdlc(dev); if ((cnt == 0 && !valid0) || (cnt == 1 && !valid1)) continue; port->phy_node = cnt; port->valid = 1; if ((cnt == 1) && valid0) port->log_node = 1; spin_lock_init(&port->lock); SET_MODULE_OWNER(dev); dev->irq = irq; dev->mem_start = winbase; dev->mem_end = winbase + USE_WINDOWSIZE - 1; dev->tx_queue_len = 50; dev->do_ioctl = n2_ioctl; dev->open = n2_open; dev->stop = n2_close; hdlc->attach = sca_attach; hdlc->xmit = sca_xmit; port->settings.clock_type = CLOCK_EXT; port->card = card; if (register_hdlc_device(dev)) { printk(KERN_WARNING "n2: unable to register hdlc " "device\n"); port->card = NULL; n2_destroy_card(card); return -ENOBUFS; } sca_init_sync_port(port); /* Set up SCA memory */ printk(KERN_INFO "%s: RISCom/N2 node %d\n", dev->name, port->phy_node); } *new_card = card; new_card = &card->next_card; return 0; }
static long acq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int options, retval = -EINVAL; void __user *argp = (void __user *)arg; int __user *p = argp; static struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .firmware_version = 1, .identity = WATCHDOG_NAME, }; switch (cmd) { case WDIOC_GETSUPPORT: return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0, p); case WDIOC_SETOPTIONS: { if (get_user(options, p)) return -EFAULT; if (options & WDIOS_DISABLECARD) { acq_stop(); retval = 0; } if (options & WDIOS_ENABLECARD) { acq_keepalive(); retval = 0; } return retval; } case WDIOC_KEEPALIVE: acq_keepalive(); return 0; case WDIOC_GETTIMEOUT: return put_user(WATCHDOG_HEARTBEAT, p); default: return -ENOTTY; } } static int acq_open(struct inode *inode, struct file *file) { if (test_and_set_bit(0, &acq_is_open)) return -EBUSY; if (nowayout) __module_get(THIS_MODULE); /* Activate */ acq_keepalive(); return nonseekable_open(inode, file); } static int acq_close(struct inode *inode, struct file *file) { if (expect_close == 42) { acq_stop(); } else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); acq_keepalive(); } clear_bit(0, &acq_is_open); expect_close = 0; return 0; } /* * Kernel Interfaces */ static const struct file_operations acq_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = acq_write, .unlocked_ioctl = acq_ioctl, .open = acq_open, .release = acq_close, }; static struct miscdevice acq_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &acq_fops, }; /* * Init & exit routines */ static int __devinit acq_probe(struct platform_device *dev) { int ret; if (wdt_stop != wdt_start) { if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", wdt_stop); ret = -EIO; goto out; } } if (!request_region(wdt_start, 1, WATCHDOG_NAME)) { printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", wdt_start); ret = -EIO; goto unreg_stop; } ret = misc_register(&acq_miscdev); if (ret != 0) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto unreg_regions; } printk(KERN_INFO PFX "initialized. (nowayout=%d)\n", nowayout); return 0; unreg_regions: release_region(wdt_start, 1); unreg_stop: if (wdt_stop != wdt_start) release_region(wdt_stop, 1); out: return ret; } static int __devexit acq_remove(struct platform_device *dev) { misc_deregister(&acq_miscdev); release_region(wdt_start, 1); if (wdt_stop != wdt_start) release_region(wdt_stop, 1); return 0; }
static int __init rtc_init(void) { struct proc_dir_entry *ent; #if defined(__alpha__) || defined(__mips__) unsigned int year, ctrl; char *guess = NULL; #endif #ifdef __sparc__ struct linux_ebus *ebus; struct linux_ebus_device *edev; #ifdef __sparc_v9__ struct sparc_isa_bridge *isa_br; struct sparc_isa_device *isa_dev; #endif #endif #ifdef __sparc__ for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { if(strcmp(edev->prom_name, "rtc") == 0) { rtc_port = edev->resource[0].start; rtc_irq = edev->irqs[0]; goto found; } } } #ifdef __sparc_v9__ for_each_isa(isa_br) { for_each_isadev(isa_dev, isa_br) { if (strcmp(isa_dev->prom_name, "rtc") == 0) { rtc_port = isa_dev->resource.start; rtc_irq = isa_dev->irq; goto found; } } } #endif printk(KERN_ERR "rtc_init: no PC rtc found\n"); return -EIO; found: if (rtc_irq == PCI_IRQ_NONE) { rtc_has_irq = 0; goto no_irq; } /* * XXX Interrupt pin #7 in Espresso is shared between RTC and * PCI Slot 2 INTA# (and some INTx# in Slot 1). */ if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) { /* * Standard way for sparc to print irq's is to use * __irq_itoa(). I think for EBus it's ok to use %d. */ printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); return -EIO; } no_irq: #else if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc")) { printk(KERN_ERR "rtc: I/O port %d is not free.\n", RTC_PORT (0)); return -EIO; } #ifdef RTC_IRQ if (is_hpet_enabled()) { rtc_int_handler_ptr = hpet_rtc_interrupt; } else { rtc_int_handler_ptr = rtc_interrupt; } if(request_irq(RTC_IRQ, rtc_int_handler_ptr, SA_INTERRUPT, "rtc", NULL)) { /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); release_region(RTC_PORT(0), RTC_IO_EXTENT); return -EIO; } hpet_rtc_timer_init(); #endif #endif /* __sparc__ vs. others */ if (misc_register(&rtc_dev)) { #ifdef RTC_IRQ free_irq(RTC_IRQ, NULL); #endif release_region(RTC_PORT(0), RTC_IO_EXTENT); return -ENODEV; } ent = create_proc_entry("driver/rtc", 0, NULL); if (!ent) { #ifdef RTC_IRQ free_irq(RTC_IRQ, NULL); #endif release_region(RTC_PORT(0), RTC_IO_EXTENT); misc_deregister(&rtc_dev); return -ENOMEM; } ent->proc_fops = &rtc_proc_fops; #if defined(__alpha__) || defined(__mips__) rtc_freq = HZ; /* Each operating system on an Alpha uses its own epoch. Let's try to guess which one we are using now. */ if (rtc_is_updating() != 0) msleep(20); spin_lock_irq(&rtc_lock); year = CMOS_READ(RTC_YEAR); ctrl = CMOS_READ(RTC_CONTROL); spin_unlock_irq(&rtc_lock); if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) BCD_TO_BIN(year); /* This should never happen... */ if (year < 20) { epoch = 2000; guess = "SRM (post-2000)"; } else if (year >= 20 && year < 48) { epoch = 1980; guess = "ARC console"; } else if (year >= 48 && year < 72) { epoch = 1952; guess = "Digital UNIX"; #if defined(__mips__) } else if (year >= 72 && year < 74) { epoch = 2000; guess = "Digital DECstation"; #else } else if (year >= 70) { epoch = 1900; guess = "Standard PC (1900)"; #endif } if (guess) printk(KERN_INFO "rtc: %s epoch (%lu) detected\n", guess, epoch); #endif #ifdef RTC_IRQ if (rtc_has_irq == 0) goto no_irq2; init_timer(&rtc_irq_timer); rtc_irq_timer.function = rtc_dropped_irq; spin_lock_irq(&rtc_lock); rtc_freq = 1024; if (!hpet_set_periodic_freq(rtc_freq)) { /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */ CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT); } spin_unlock_irq(&rtc_lock); no_irq2: #endif (void) init_sysctl(); printk(KERN_INFO "Real Time Clock Driver v" RTC_VERSION "\n"); return 0; }
static int ni52_probe1(struct device *dev,int ioaddr) { long memaddrs[] = { 0xd0000,0xd2000,0xc8000,0xca000,0xd4000,0xd6000,0xd8000, 0 }; int i,size; for(i=0;i<ETH_ALEN;i++) dev->dev_addr[i] = inb(dev->base_addr+i); if(dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1 || dev->dev_addr[2] != NI52_ADDR2) return ENODEV; printk("%s: Ni52 found at %#3lx, ",dev->name,dev->base_addr); request_region(ioaddr,NI52_TOTAL_SIZE,"ni52"); dev->priv = (void *) kmalloc(sizeof(struct priv),GFP_KERNEL); /* warning: we don't free it on errors */ if (dev->priv == NULL) return -ENOMEM; memset((char *) dev->priv,0,sizeof(struct priv)); /* * check (or search) IO-Memory, 8K and 16K */ if(dev->mem_start != 0) /* no auto-mem-probe */ { size = 0x4000; /* check for 16K mem */ if(!check586(dev,(char *) dev->mem_start,size)) { size = 0x2000; /* check for 8K mem */ if(!check586(dev,(char *) dev->mem_start,size)) { printk("?memprobe, Can't find memory at 0x%lx!\n",dev->mem_start); return ENODEV; } } } else { for(i=0;;i++) { if(!memaddrs[i]) { printk("?memprobe, Can't find io-memory!\n"); return ENODEV; } dev->mem_start = memaddrs[i]; size = 0x2000; /* check for 8K mem */ if(check586(dev,(char *)dev->mem_start,size)) /* 8K-check */ break; size = 0x4000; /* check for 16K mem */ if(check586(dev,(char *)dev->mem_start,size)) /* 16K-check */ break; } } dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */ ((struct priv *) (dev->priv))->base = dev->mem_start + size - 0x01000000; alloc586(dev); /* set number of receive-buffs according to memsize */ if(size == 0x2000) ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8; else ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16; printk("Memaddr: 0x%lx, Memsize: %d, ",dev->mem_start,size); if(dev->irq < 2) { autoirq_setup(0); ni_reset586(); ni_attn586(); if(!(dev->irq = autoirq_report(2))) { printk("?autoirq, Failed to detect IRQ line!\n"); return 1; } } else if(dev->irq == 2) dev->irq = 9; printk("IRQ %d.\n",dev->irq); dev->open = &ni52_open; dev->stop = &ni52_close; dev->get_stats = &ni52_get_stats; dev->hard_start_xmit = &ni52_send_packet; dev->set_multicast_list = &set_multicast_list; dev->if_port = 0; ether_setup(dev); dev->tbusy = 0; dev->interrupt = 0; dev->start = 0; return 0; }
/* initialise HIL */ static int __init hil_keyb_init(void) { unsigned char c; unsigned int i, kbid; wait_queue_head_t hil_wait; int err; if (hil_dev.dev) { return -ENODEV; /* already initialized */ } spin_lock_init(&hil_dev.lock); hil_dev.dev = input_allocate_device(); if (!hil_dev.dev) return -ENOMEM; #if defined(CONFIG_HP300) if (!hwreg_present((void *)(HILBASE + HIL_DATA))) { printk(KERN_ERR "HIL: hardware register was not found\n"); err = -ENODEV; goto err1; } if (!request_region(HILBASE + HIL_DATA, 2, "hil")) { printk(KERN_ERR "HIL: IOPORT region already used\n"); err = -EIO; goto err1; } #endif err = request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id); if (err) { printk(KERN_ERR "HIL: Can't get IRQ\n"); goto err2; } /* Turn on interrupts */ hil_do(HIL_INTON, NULL, 0); /* Look for keyboards */ hil_dev.valid = 0; /* clear any pending data */ hil_do(HIL_READKBDSADR, NULL, 0); init_waitqueue_head(&hil_wait); wait_event_interruptible_timeout(hil_wait, hil_dev.valid, 3*HZ); if (!hil_dev.valid) { printk(KERN_WARNING "HIL: timed out, assuming no keyboard present\n"); } c = hil_dev.c; hil_dev.valid = 0; if (c == 0) { kbid = -1; printk(KERN_WARNING "HIL: no keyboard present\n"); } else { kbid = ffz(~c); printk(KERN_INFO "HIL: keyboard found at id %d\n", kbid); } /* set it to raw mode */ c = 0; hil_do(HIL_WRITEKBDSADR, &c, 1); for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++) if (hphilkeyb_keycode[i] != KEY_RESERVED) set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit); hil_dev.dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); hil_dev.dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); hil_dev.dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; hil_dev.dev->keycodesize= sizeof(hphilkeyb_keycode[0]); hil_dev.dev->keycode = hphilkeyb_keycode; hil_dev.dev->name = "HIL keyboard"; hil_dev.dev->phys = "hpkbd/input0"; hil_dev.dev->id.bustype = BUS_HIL; hil_dev.dev->id.vendor = PCI_VENDOR_ID_HP; hil_dev.dev->id.product = 0x0001; hil_dev.dev->id.version = 0x0010; err = input_register_device(hil_dev.dev); if (err) { printk(KERN_ERR "HIL: Can't register device\n"); goto err3; } printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n", hil_dev.dev->name, kbid, HILBASE, HIL_IRQ); return 0; err3: hil_do(HIL_INTOFF, NULL, 0); disable_irq(HIL_IRQ); free_irq(HIL_IRQ, hil_dev.dev_id); err2: #if defined(CONFIG_HP300) release_region(HILBASE + HIL_DATA, 2); err1: #endif input_free_device(hil_dev.dev); hil_dev.dev = NULL; return err; }
static int __init pc8736x_gpio_init(void) { int rc; dev_t devid; pdev = platform_device_alloc(DEVNAME, 0); if (!pdev) return -ENOMEM; rc = platform_device_add(pdev); if (rc) { rc = -ENODEV; goto undo_platform_dev_alloc; } dev_info(&pdev->dev, "NatSemi pc8736x GPIO Driver Initializing\n"); if (!pc8736x_superio_present()) { rc = -ENODEV; dev_err(&pdev->dev, "no device found\n"); goto undo_platform_dev_add; } pc8736x_gpio_ops.dev = &pdev->dev; /* Verify that chip and it's GPIO unit are both enabled. My BIOS does this, so I take minimum action here */ rc = superio_inb(SIO_CF1); if (!(rc & 0x01)) { rc = -ENODEV; dev_err(&pdev->dev, "device not enabled\n"); goto undo_platform_dev_add; } device_select(SIO_GPIO_UNIT); if (!superio_inb(SIO_UNIT_ACT)) { rc = -ENODEV; dev_err(&pdev->dev, "GPIO unit not enabled\n"); goto undo_platform_dev_add; } /* read the GPIO unit base addr that chip responds to */ pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8 | superio_inb(SIO_BASE_LADDR)); if (!request_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE, DEVNAME)) { rc = -ENODEV; dev_err(&pdev->dev, "GPIO ioport %x busy\n", pc8736x_gpio_base); goto undo_platform_dev_add; } dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base); if (major) { devid = MKDEV(major, 0); rc = register_chrdev_region(devid, PC8736X_GPIO_CT, DEVNAME); } else { rc = alloc_chrdev_region(&devid, 0, PC8736X_GPIO_CT, DEVNAME); major = MAJOR(devid); } if (rc < 0) { dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); goto undo_request_region; } if (!major) { major = rc; dev_dbg(&pdev->dev, "got dynamic major %d\n", major); } pc8736x_init_shadow(); /* ignore minor errs, and succeed */ cdev_init(&pc8736x_gpio_cdev, &pc8736x_gpio_fileops); cdev_add(&pc8736x_gpio_cdev, devid, PC8736X_GPIO_CT); return 0; undo_request_region: release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE); undo_platform_dev_add: platform_device_del(pdev); undo_platform_dev_alloc: platform_device_put(pdev); return rc; }
static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; int new_timeout; static const struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .firmware_version = 1, .identity = "W83697UG WDT", }; switch (cmd) { case WDIOC_GETSUPPORT: if (copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; break; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0, p); case WDIOC_SETOPTIONS: { int options, retval = -EINVAL; if (get_user(options, p)) return -EFAULT; if (options & WDIOS_DISABLECARD) { wdt_disable(); retval = 0; } if (options & WDIOS_ENABLECARD) { wdt_ping(); retval = 0; } return retval; } case WDIOC_KEEPALIVE: wdt_ping(); break; case WDIOC_SETTIMEOUT: if (get_user(new_timeout, p)) return -EFAULT; if (wdt_set_heartbeat(new_timeout)) return -EINVAL; wdt_ping(); /* Fall */ case WDIOC_GETTIMEOUT: return put_user(timeout, p); default: return -ENOTTY; } return 0; } static int wdt_open(struct inode *inode, struct file *file) { if (test_and_set_bit(0, &wdt_is_open)) return -EBUSY; /* * Activate */ wdt_ping(); return nonseekable_open(inode, file); } static int wdt_close(struct inode *inode, struct file *file) { if (expect_close == 42) wdt_disable(); else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); wdt_ping(); } expect_close = 0; clear_bit(0, &wdt_is_open); return 0; } /* * Notifier for system down */ static int wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { if (code == SYS_DOWN || code == SYS_HALT) wdt_disable(); /* Turn the WDT off */ return NOTIFY_DONE; } /* * Kernel Interfaces */ static const struct file_operations wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = wdt_write, .unlocked_ioctl = wdt_ioctl, .open = wdt_open, .release = wdt_close, }; static struct miscdevice wdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &wdt_fops, }; /* * The WDT needs to learn about soft shutdowns in order to * turn the timebomb registers off. */ static struct notifier_block wdt_notifier = { .notifier_call = wdt_notify_sys, }; static int __init wdt_init(void) { int ret; printk(KERN_INFO "WDT driver for the Winbond(TM) W83697UG/UF Super I/O chip initialising.\n"); if (wdt_set_heartbeat(timeout)) { wdt_set_heartbeat(WATCHDOG_TIMEOUT); printk(KERN_INFO PFX "timeout value must be 1<=timeout<=255, using %d\n", WATCHDOG_TIMEOUT); } if (!request_region(wdt_io, 1, WATCHDOG_NAME)) { printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", wdt_io); ret = -EIO; goto out; } w83697ug_init(); ret = register_reboot_notifier(&wdt_notifier); if (ret != 0) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); goto unreg_regions; } ret = misc_register(&wdt_miscdev); if (ret != 0) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto unreg_reboot; } printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n", timeout, nowayout); out: return ret; unreg_reboot: unregister_reboot_notifier(&wdt_notifier); unreg_regions: release_region(wdt_io, 1); goto out; } static void __exit wdt_exit(void) { misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier); release_region(wdt_io, 1); }
int probe_uart401(struct address_info *hw_config, struct module *owner) { uart401_devc *devc; char *name = "MPU-401 (UART) MIDI"; int ok = 0; unsigned long flags; DDB(printk("Entered probe_uart401()\n")); /* Default to "not found" */ hw_config->slots[4] = -1; if (!request_region(hw_config->io_base, 4, "MPU-401 UART")) { printk(KERN_INFO "uart401: could not request_region(%d, 4)\n", hw_config->io_base); return 0; } devc = kmalloc(sizeof(uart401_devc), GFP_KERNEL); if (!devc) { printk(KERN_WARNING "uart401: Can't allocate memory\n"); goto cleanup_region; } devc->base = hw_config->io_base; devc->irq = hw_config->irq; devc->osp = hw_config->osp; devc->midi_input_intr = NULL; devc->opened = 0; devc->input_byte = 0; devc->my_dev = 0; devc->share_irq = 0; spin_lock_init(&devc->lock); spin_lock_irqsave(&devc->lock,flags); ok = reset_uart401(devc); spin_unlock_irqrestore(&devc->lock,flags); if (!ok) goto cleanup_devc; if (hw_config->name) name = hw_config->name; if (devc->irq < 0) { devc->share_irq = 1; devc->irq *= -1; } else devc->share_irq = 0; if (!devc->share_irq) if (request_irq(devc->irq, uart401intr, 0, "MPU-401 UART", devc) < 0) { printk(KERN_WARNING "uart401: Failed to allocate IRQ%d\n", devc->irq); devc->share_irq = 1; } devc->my_dev = sound_alloc_mididev(); enter_uart_mode(devc); if (devc->my_dev == -1) { printk(KERN_INFO "uart401: Too many midi devices detected\n"); goto cleanup_irq; } conf_printf(name, hw_config); midi_devs[devc->my_dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL); if (!midi_devs[devc->my_dev]) { printk(KERN_ERR "uart401: Failed to allocate memory\n"); goto cleanup_unload_mididev; } memcpy(midi_devs[devc->my_dev], &uart401_operations, sizeof(struct midi_operations)); if (owner) midi_devs[devc->my_dev]->owner = owner; midi_devs[devc->my_dev]->devc = devc; midi_devs[devc->my_dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL); if (!midi_devs[devc->my_dev]->converter) { printk(KERN_WARNING "uart401: Failed to allocate memory\n"); goto cleanup_midi_devs; } memcpy(midi_devs[devc->my_dev]->converter, &std_midi_synth, sizeof(struct synth_operations)); strcpy(midi_devs[devc->my_dev]->info.name, name); midi_devs[devc->my_dev]->converter->id = "UART401"; midi_devs[devc->my_dev]->converter->midi_dev = devc->my_dev; if (owner) midi_devs[devc->my_dev]->converter->owner = owner; hw_config->slots[4] = devc->my_dev; sequencer_init(); devc->opened = 0; return 1; cleanup_midi_devs: kfree(midi_devs[devc->my_dev]); cleanup_unload_mididev: sound_unload_mididev(devc->my_dev); cleanup_irq: if (!devc->share_irq) free_irq(devc->irq, devc); cleanup_devc: kfree(devc); cleanup_region: release_region(hw_config->io_base, 4); return 0; }
/* 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 failure; 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 failure; } if (!pnp_irq_valid(pdev, 0)) { dev_err(&pdev->dev, "PNP IRQ not valid!\n"); goto failure; } /* 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_TYPE_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 = -EBUSY; /* now claim resources */ if (!request_region(itdev->cir_addr, dev_desc->io_region_size, ITE_DRIVER_NAME)) goto failure; if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED, ITE_DRIVER_NAME, (void *)itdev)) goto failure; ret = rc_register_device(rdev); if (ret) goto failure; itdev->rdev = rdev; ite_pr(KERN_NOTICE, "driver has been successfully loaded\n"); return 0; failure: if (itdev->cir_irq) free_irq(itdev->cir_irq, itdev); if (itdev->cir_addr) release_region(itdev->cir_addr, itdev->params.io_region_size); rc_free_device(rdev); kfree(itdev); return ret; }
static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev) { struct snd_sb *chip; struct snd_card *card; struct snd_sb8 *acard; struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_sb8)); if (card == NULL) return -ENOMEM; acard = card->private_data; card->private_free = snd_sb8_free; /* block the 0x388 port to avoid PnP conflicts */ acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); if (port[dev] != SNDRV_AUTO_PORT) { if ((err = snd_sbdsp_create(card, port[dev], irq[dev], snd_sb8_interrupt, dma8[dev], -1, SB_HW_AUTO, &chip)) < 0) goto _err; } else { /* auto-probe legacy ports */ static unsigned long possible_ports[] = { 0x220, 0x240, 0x260, }; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { err = snd_sbdsp_create(card, possible_ports[i], irq[dev], snd_sb8_interrupt, dma8[dev], -1, SB_HW_AUTO, &chip); if (err >= 0) { port[dev] = possible_ports[i]; break; } } if (i >= ARRAY_SIZE(possible_ports)) goto _err; } acard->chip = chip; if (chip->hardware >= SB_HW_16) { if (chip->hardware == SB_HW_ALS100) snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n", port[dev]); else snd_printk(KERN_WARNING "SB 16 chip detected at 0x%lx, try snd-sb16 module\n", port[dev]); err = -ENODEV; goto _err; } if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) goto _err; if ((err = snd_sbmixer_new(chip)) < 0) goto _err; if (chip->hardware == SB_HW_10 || chip->hardware == SB_HW_20) { if ((err = snd_opl3_create(card, chip->port + 8, 0, OPL3_HW_AUTO, 1, &opl3)) < 0) { snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx\n", chip->port + 8); } } else { if ((err = snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_AUTO, 1, &opl3)) < 0) { snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx-0x%lx\n", chip->port, chip->port + 2); } } if (err >= 0) { if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) goto _err; } if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0) goto _err; strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8"); strcpy(card->shortname, chip->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", chip->name, chip->port, irq[dev], dma8[dev]); snd_card_set_dev(card, pdev); if ((err = snd_card_register(card)) < 0) goto _err; dev_set_drvdata(pdev, card); return 0; _err: snd_card_free(card); return err; }
static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) { acpi_status status = 0; union acpi_object object = { 0 }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; int cpu_index; static int cpu0_initialized; if (!pr) return -EINVAL; if (num_online_cpus() > 1) errata.smp = TRUE; acpi_processor_errata(pr); /* * Check to see if we have bus mastering arbitration control. This * is required for proper C3 usage (to maintain cache coherency). */ if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) { pr->flags.bm_control = 1; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Bus mastering arbitration control present\n")); } else ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No bus mastering arbitration control\n")); /* Check if it is a Device with HID and UID */ if (has_uid) { unsigned long value; status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, NULL, &value); if (ACPI_FAILURE(status)) { printk(KERN_ERR PREFIX "Evaluating processor _UID\n"); return -ENODEV; } pr->acpi_id = value; } else { /* * Evalute the processor object. Note that it is common on SMP to * have the first (boot) processor with a valid PBLK address while * all others have a NULL address. */ status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); if (ACPI_FAILURE(status)) { printk(KERN_ERR PREFIX "Evaluating processor object\n"); return -ENODEV; } /* * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c */ pr->acpi_id = object.processor.proc_id; } cpu_index = get_cpu_id(pr->handle, pr->acpi_id); /* Handle UP system running SMP kernel, with no LAPIC in MADT */ if (!cpu0_initialized && (cpu_index == -1) && (num_online_cpus() == 1)) { cpu_index = 0; } cpu0_initialized = 1; pr->id = cpu_index; /* * Extra Processor objects may be enumerated on MP systems with * less than the max # of CPUs. They should be ignored _iff * they are physically not present. */ if (pr->id == -1) { if (ACPI_FAILURE (acpi_processor_hotadd_init(pr->handle, &pr->id))) { return -ENODEV; } } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, pr->acpi_id)); if (!object.processor.pblk_address) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); else if (object.processor.pblk_length != 6) printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n", object.processor.pblk_length); else { pr->throttling.address = object.processor.pblk_address; pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; pr->throttling.duty_width = acpi_gbl_FADT.duty_width; pr->pblk = object.processor.pblk_address; /* * We don't care about error returns - we just try to mark * these reserved so that nobody else is confused into thinking * that this region might be unused.. * * (In particular, allocating the IO range for Cardbus) */ request_region(pr->throttling.address, 6, "ACPI CPU throttle"); } return 0; }
static int c4_add_card(struct capicardparams *p, struct pci_dev *dev, int nr_controllers) { avmcard *card; avmctrl_info *cinfo; int retval; int i; card = b1_alloc_card(nr_controllers); if (!card) { printk(KERN_WARNING "c4: no memory.\n"); retval = -ENOMEM; goto err; } card->dma = avmcard_dma_alloc("c4", dev, 2048+128, 2048+128); if (!card->dma) { printk(KERN_WARNING "c4: no memory.\n"); retval = -ENOMEM; goto err_free; } sprintf(card->name, "c%d-%x", nr_controllers, p->port); card->port = p->port; card->irq = p->irq; card->membase = p->membase; card->cardtype = (nr_controllers == 4) ? avm_c4 : avm_c2; if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { printk(KERN_WARNING "c4: 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, 128); if (card->mbase == 0) { printk(KERN_NOTICE "c4: can't remap memory at 0x%lx\n", card->membase); retval = -EIO; goto err_release_region; } retval = c4_detect(card); if (retval != 0) { printk(KERN_NOTICE "c4: NO card at 0x%x error(%d)\n", card->port, retval); retval = -EIO; goto err_unmap; } c4_reset(card); retval = request_irq(card->irq, c4_interrupt, SA_SHIRQ, card->name, card); if (retval) { printk(KERN_ERR "c4: unable to get IRQ %d.\n",card->irq); retval = -EBUSY; goto err_unmap; } for (i=0; i < nr_controllers ; i++) { cinfo = &card->ctrlinfo[i]; cinfo->capi_ctrl.owner = THIS_MODULE; cinfo->capi_ctrl.driver_name = "c4"; cinfo->capi_ctrl.driverdata = cinfo; cinfo->capi_ctrl.register_appl = c4_register_appl; cinfo->capi_ctrl.release_appl = c4_release_appl; cinfo->capi_ctrl.send_message = c4_send_message; cinfo->capi_ctrl.load_firmware = c4_load_firmware; cinfo->capi_ctrl.reset_ctr = c4_reset_ctr; cinfo->capi_ctrl.procinfo = c4_procinfo; cinfo->capi_ctrl.ctr_read_proc = c4_read_proc; strcpy(cinfo->capi_ctrl.name, card->name); retval = attach_capi_ctr(&cinfo->capi_ctrl); if (retval) { printk(KERN_ERR "c4: attach controller failed (%d).\n", i); for (i--; i >= 0; i--) { cinfo = &card->ctrlinfo[i]; detach_capi_ctr(&cinfo->capi_ctrl); } goto err_free_irq; } if (i == 0) card->cardnr = cinfo->capi_ctrl.cnr; } printk(KERN_INFO "c4: AVM C%d at i/o %#x, irq %d, mem %#lx\n", nr_controllers, card->port, card->irq, card->membase); pci_set_drvdata(dev, 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; }
/* Detect whether a ALI1535 can be found, and initialize it, where necessary. Note the differences between kernels with the old PCI BIOS interface and newer kernels with the real PCI interface. In compat.h some things are defined to make the transition easier. */ int ali1535_setup(void) { int error_return = 0; unsigned char temp; struct pci_dev *ALI1535_dev; /* First check whether we can access PCI at all */ if (pci_present() == 0) { printk("i2c-ali1535.o: Error: No PCI-bus found!\n"); error_return = -ENODEV; goto END; } /* Look for the ALI1535, M7101 device */ ALI1535_dev = NULL; ALI1535_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, ALI1535_dev); if (ALI1535_dev == NULL) { printk("i2c-ali1535.o: Error: Can't detect ali1535!\n"); error_return = -ENODEV; goto END; } /* Check the following things: - SMB I/O address is initialized - Device is enabled - We can use the addresses */ /* Determine the address of the SMBus area */ pci_read_config_word(ALI1535_dev, SMBBA, &ali1535_smba); ali1535_smba &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1)); if (ali1535_smba == 0) { printk ("i2c-ali1535.o: ALI1535_smb region uninitialized - upgrade BIOS?\n"); error_return = -ENODEV; } if (error_return == -ENODEV) goto END; if (check_region(ali1535_smba, ALI1535_SMB_IOSIZE)) { printk ("i2c-ali1535.o: ALI1535_smb region 0x%x already in use!\n", ali1535_smba); error_return = -ENODEV; } if (error_return == -ENODEV) goto END; /* check if whole device is enabled */ pci_read_config_byte(ALI1535_dev, SMBCFG, &temp); if ((temp & ALI1535_SMBIO_EN) == 0) { printk ("i2c-ali1535.o: SMB device not enabled - upgrade BIOS?\n"); error_return = -ENODEV; goto END; } /* Is SMB Host controller enabled? */ pci_read_config_byte(ALI1535_dev, SMBHSTCFG, &temp); if ((temp & 1) == 0) { printk ("i2c-ali1535.o: SMBus controller not enabled - upgrade BIOS?\n"); error_return = -ENODEV; goto END; } /* set SMB clock to 74KHz as recommended in data sheet */ pci_write_config_byte(ALI1535_dev, SMBCLK, 0x20); /* Everything is happy, let's grab the memory and set things up. */ request_region(ali1535_smba, ALI1535_SMB_IOSIZE, "ali1535-smb"); #ifdef DEBUG /* The interrupt routing for SMB is set up in register 0x77 in the 1533 ISA Bridge device, NOT in the 7101 device. Don't bother with finding the 1533 device and reading the register. if ((....... & 0x0F) == 1) printk("i2c-ali1535.o: ALI1535 using Interrupt 9 for SMBus.\n"); */ pci_read_config_byte(ALI1535_dev, SMBREV, &temp); printk("i2c-ali1535.o: SMBREV = 0x%X\n", temp); printk("i2c-ali1535.o: ALI1535_smba = 0x%X\n", ali1535_smba); #endif /* DEBUG */ END: return error_return; }
static void sm_output_open(struct sm_state *sm, const char *ifname) { enum uart u = c_uart_unknown; struct parport *pp = NULL; sm->hdrv.ptt_out.flags = 0; if (sm->hdrv.ptt_out.seriobase > 0 && sm->hdrv.ptt_out.seriobase <= 0x1000-SER_EXTENT && ((u = check_uart(sm->hdrv.ptt_out.seriobase))) != c_uart_unknown) { sm->hdrv.ptt_out.flags |= SP_SER; request_region(sm->hdrv.ptt_out.seriobase, SER_EXTENT, "sm ser ptt"); outb(0, UART_IER(sm->hdrv.ptt_out.seriobase)); /* 5 bits, 1 stop, no parity, no break, Div latch access */ outb(0x80, UART_LCR(sm->hdrv.ptt_out.seriobase)); outb(0, UART_DLM(sm->hdrv.ptt_out.seriobase)); outb(1, UART_DLL(sm->hdrv.ptt_out.seriobase)); /* as fast as possible */ /* LCR and MCR set by output_status */ } sm->pardev = NULL; if (sm->hdrv.ptt_out.pariobase > 0) { pp = parport_enumerate(); while (pp && pp->base != sm->hdrv.ptt_out.pariobase) pp = pp->next; if (!pp) printk(KERN_WARNING "%s: parport at address 0x%x not found\n", sm_drvname, sm->hdrv.ptt_out.pariobase); else if ((~pp->modes) & (PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT)) printk(KERN_WARNING "%s: parport at address 0x%x cannot be used\n", sm_drvname, sm->hdrv.ptt_out.pariobase); else { sm->pardev = parport_register_device(pp, ifname, NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); if (!sm->pardev) { pp = NULL; printk(KERN_WARNING "%s: cannot register parport device (address 0x%x)\n", sm_drvname, sm->hdrv.ptt_out.pariobase); } else { if (parport_claim(sm->pardev)) { parport_unregister_device(sm->pardev); sm->pardev = NULL; printk(KERN_WARNING "%s: cannot claim parport at address 0x%x\n", sm_drvname, sm->hdrv.ptt_out.pariobase); } else sm->hdrv.ptt_out.flags |= SP_PAR; } } } if (sm->hdrv.ptt_out.midiiobase > 0 && sm->hdrv.ptt_out.midiiobase <= 0x1000-MIDI_EXTENT && check_midi(sm->hdrv.ptt_out.midiiobase)) { sm->hdrv.ptt_out.flags |= SP_MIDI; request_region(sm->hdrv.ptt_out.midiiobase, MIDI_EXTENT, "sm midi ptt"); } sm_output_status(sm); printk(KERN_INFO "%s: ptt output:", sm_drvname); if (sm->hdrv.ptt_out.flags & SP_SER) printk(" serial interface at 0x%x, uart %s", sm->hdrv.ptt_out.seriobase, uart_str[u]); if (sm->hdrv.ptt_out.flags & SP_PAR) printk(" parallel interface at 0x%x", sm->hdrv.ptt_out.pariobase); if (sm->hdrv.ptt_out.flags & SP_MIDI) printk(" mpu401 (midi) interface at 0x%x", sm->hdrv.ptt_out.midiiobase); if (!sm->hdrv.ptt_out.flags) printk(" none"); printk("\n"); }
int __devinit setup_ix1micro(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, ix1_revision); ; 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", ; pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err<0) { // printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", ; 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", ; pnp_disable_dev(pnp_d); return(0); } break; } else { ; } } ipid++; pnp_c = NULL; } if (!ipid->card_vendor) { ; 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: ITK ix1-micro Rev.2 config port " // "%x-%x already in use\n", // cs->hw.ix1.cfg_reg, ; return (0); } } // printk(KERN_INFO "HiSax: ITK ix1-micro Rev.2 config irq:%d io:0x%X\n", ; 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 ; release_io_ix1micro(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; }
static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id) { unsigned char temp; if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5)) srvrworks_csb5_delay = 1; /* On some motherboards, it was reported that accessing the SMBus caused severe hardware problems */ if (dmi_check_system(piix4_dmi_blacklist)) { dev_err(&PIIX4_dev->dev, "Accessing the SMBus on this system is unsafe!\n"); return -EPERM; } /* Don't access SMBus on IBM systems which get corrupted eeproms */ if (dmi_check_system(piix4_dmi_ibm) && PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) { dev_err(&PIIX4_dev->dev, "IBM system detected; this module " "may corrupt your serial eeprom! Refusing to load " "module!\n"); return -EPERM; } /* Determine the address of the SMBus areas */ if (force_addr) { piix4_smba = force_addr & 0xfff0; force = 0; } else { pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba); piix4_smba &= 0xfff0; if(piix4_smba == 0) { dev_err(&PIIX4_dev->dev, "SMBus base address " "uninitialized - upgrade BIOS or use " "force_addr=0xaddr\n"); return -ENODEV; } } if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) return -ENODEV; if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n", piix4_smba); return -EBUSY; } pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp); /* If force_addr is set, we program the new address here. Just to make sure, we disable the PIIX4 first. */ if (force_addr) { pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe); pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba); pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01); dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to " "new address %04x!\n", piix4_smba); } else if ((temp & 1) == 0) { if (force) { /* This should never need to be done, but has been * noted that many Dell machines have the SMBus * interface on the PIIX4 disabled!? NOTE: This assumes * I/O space and other allocations WERE done by the * Bios! Don't complain if your hardware does weird * things after enabling this. :') Check for Bios * updates before resorting to this. */ pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 1); dev_printk(KERN_NOTICE, &PIIX4_dev->dev, "WARNING: SMBus interface has been " "FORCEFULLY ENABLED!\n"); } else { dev_err(&PIIX4_dev->dev, "Host SMBus controller not enabled!\n"); release_region(piix4_smba, SMBIOSIZE); piix4_smba = 0; return -ENODEV; } } if (((temp & 0x0E) == 8) || ((temp & 0x0E) == 2)) dev_dbg(&PIIX4_dev->dev, "Using Interrupt 9 for SMBus.\n"); else if ((temp & 0x0E) == 0) dev_dbg(&PIIX4_dev->dev, "Using Interrupt SMI# for SMBus.\n"); else dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration " "(or code out of date)!\n"); pci_read_config_byte(PIIX4_dev, SMBREV, &temp); dev_info(&PIIX4_dev->dev, "SMBus Host Controller at 0x%x, revision %d\n", piix4_smba, temp); return 0; }
int __devinit setup_w6692(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; u_char found = 0; u_char pci_irq = 0; u_int pci_ioaddr = 0; strcpy(tmp, w6692_revision); printk(KERN_INFO "HiSax: W6692 driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_W6692) return (0); while (id_list[id_idx].vendor_id) { dev_w6692 = hisax_find_pci_device(id_list[id_idx].vendor_id, id_list[id_idx].device_id, dev_w6692); if (dev_w6692) { if (pci_enable_device(dev_w6692)) continue; cs->subtyp = id_idx; break; } id_idx++; } if (dev_w6692) { found = 1; pci_irq = dev_w6692->irq; /* I think address 0 is allways the configuration area */ /* and address 1 is the real IO space KKe 03.09.99 */ pci_ioaddr = pci_resource_start(dev_w6692, 1); /* USR ISDN PCI card TA need some special handling */ if (cs->subtyp == W6692_WINBOND) { if ((W6692_SV_USR == dev_w6692->subsystem_vendor) && (W6692_SD_USR == dev_w6692->subsystem_device)) { cs->subtyp = W6692_USR; } } } if (!found) { printk(KERN_WARNING "W6692: No PCI card found\n"); return (0); } cs->irq = pci_irq; if (!cs->irq) { printk(KERN_WARNING "W6692: No IRQ for PCI card found\n"); return (0); } if (!pci_ioaddr) { printk(KERN_WARNING "W6692: NO I/O Base Address found\n"); return (0); } cs->hw.w6692.iobase = pci_ioaddr; printk(KERN_INFO "Found: %s %s, I/O base: 0x%x, irq: %d\n", id_list[cs->subtyp].vendor_name, id_list[cs->subtyp].card_name, pci_ioaddr, pci_irq); if (!request_region(cs->hw.w6692.iobase, 256, id_list[cs->subtyp].card_name)) { printk(KERN_WARNING "HiSax: %s I/O ports %x-%x already in use\n", id_list[cs->subtyp].card_name, cs->hw.w6692.iobase, cs->hw.w6692.iobase + 255); return (0); } printk(KERN_INFO "HiSax: %s config irq:%d I/O:%x\n", id_list[cs->subtyp].card_name, cs->irq, cs->hw.w6692.iobase); INIT_WORK(&cs->tqueue, W6692_bh); cs->readW6692 = &ReadW6692; cs->writeW6692 = &WriteW6692; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->BC_Read_Reg = &ReadW6692B; cs->BC_Write_Reg = &WriteW6692B; cs->BC_Send_Data = &W6692B_fill_fifo; cs->cardmsg = &w6692_card_msg; cs->irq_func = &W6692_interrupt; cs->irq_flags |= IRQF_SHARED; W6692Version(cs, "W6692:"); printk(KERN_INFO "W6692 ISTA=0x%X\n", ReadW6692(cs, W_ISTA)); printk(KERN_INFO "W6692 IMASK=0x%X\n", ReadW6692(cs, W_IMASK)); printk(KERN_INFO "W6692 D_EXIR=0x%X\n", ReadW6692(cs, W_D_EXIR)); printk(KERN_INFO "W6692 D_EXIM=0x%X\n", ReadW6692(cs, W_D_EXIM)); printk(KERN_INFO "W6692 D_RSTA=0x%X\n", ReadW6692(cs, W_D_RSTA)); return (1); }
static long sp5100_tco_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int new_options, retval = -EINVAL; int new_heartbeat; void __user *argp = (void __user *)arg; int __user *p = argp; static const struct watchdog_info ident = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .firmware_version = 0, .identity = TCO_MODULE_NAME, }; switch (cmd) { case WDIOC_GETSUPPORT: return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0, p); case WDIOC_SETOPTIONS: if (get_user(new_options, p)) return -EFAULT; if (new_options & WDIOS_DISABLECARD) { tco_timer_stop(); retval = 0; } if (new_options & WDIOS_ENABLECARD) { tco_timer_start(); tco_timer_keepalive(); retval = 0; } return retval; case WDIOC_KEEPALIVE: tco_timer_keepalive(); return 0; case WDIOC_SETTIMEOUT: if (get_user(new_heartbeat, p)) return -EFAULT; if (tco_timer_set_heartbeat(new_heartbeat)) return -EINVAL; tco_timer_keepalive(); /* Fall through */ case WDIOC_GETTIMEOUT: return put_user(heartbeat, p); default: return -ENOTTY; } } /* * Kernel Interfaces */ static const struct file_operations sp5100_tco_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = sp5100_tco_write, .unlocked_ioctl = sp5100_tco_ioctl, .open = sp5100_tco_open, .release = sp5100_tco_release, }; static struct miscdevice sp5100_tco_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &sp5100_tco_fops, }; /* * Data for PCI driver interface * * This data only exists for exporting the supported * PCI ids via MODULE_DEVICE_TABLE. We do not actually * register a pci_driver, because someone else might * want to register another driver on the same PCI id. */ static DEFINE_PCI_DEVICE_TABLE(sp5100_tco_pci_tbl) = { { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID, PCI_ANY_ID, }, { 0, }, /* End of list */ }; MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl); /* * Init & exit routines */ static unsigned char sp5100_tco_setupdevice(void) { struct pci_dev *dev = NULL; u32 val; /* Match the PCI device */ for_each_pci_dev(dev) { if (pci_match_id(sp5100_tco_pci_tbl, dev) != NULL) { sp5100_tco_pci = dev; break; } } if (!sp5100_tco_pci) return 0; /* Request the IO ports used by this driver */ pm_iobase = SP5100_IO_PM_INDEX_REG; if (!request_region(pm_iobase, SP5100_PM_IOPORTS_SIZE, "SP5100 TCO")) { pr_err("I/O address 0x%04x already in use\n", pm_iobase); goto exit; } /* Find the watchdog base address. */ outb(SP5100_PM_WATCHDOG_BASE3, SP5100_IO_PM_INDEX_REG); val = inb(SP5100_IO_PM_DATA_REG); outb(SP5100_PM_WATCHDOG_BASE2, SP5100_IO_PM_INDEX_REG); val = val << 8 | inb(SP5100_IO_PM_DATA_REG); outb(SP5100_PM_WATCHDOG_BASE1, SP5100_IO_PM_INDEX_REG); val = val << 8 | inb(SP5100_IO_PM_DATA_REG); outb(SP5100_PM_WATCHDOG_BASE0, SP5100_IO_PM_INDEX_REG); /* Low three bits of BASE0 are reserved. */ val = val << 8 | (inb(SP5100_IO_PM_DATA_REG) & 0xf8); if (!request_mem_region_exclusive(val, SP5100_WDT_MEM_MAP_SIZE, "SP5100 TCO")) { pr_err("mmio address 0x%04x already in use\n", val); goto unreg_region; } tcobase_phys = val; tcobase = ioremap(val, SP5100_WDT_MEM_MAP_SIZE); if (!tcobase) { pr_err("failed to get tcobase address\n"); goto unreg_mem_region; } /* Enable watchdog decode bit */ pci_read_config_dword(sp5100_tco_pci, SP5100_PCI_WATCHDOG_MISC_REG, &val); val |= SP5100_PCI_WATCHDOG_DECODE_EN; pci_write_config_dword(sp5100_tco_pci, SP5100_PCI_WATCHDOG_MISC_REG, val); /* Enable Watchdog timer and set the resolution to 1 sec. */ outb(SP5100_PM_WATCHDOG_CONTROL, SP5100_IO_PM_INDEX_REG); val = inb(SP5100_IO_PM_DATA_REG); val |= SP5100_PM_WATCHDOG_SECOND_RES; val &= ~SP5100_PM_WATCHDOG_DISABLE; outb(val, SP5100_IO_PM_DATA_REG); /* Check that the watchdog action is set to reset the system. */ val = readl(SP5100_WDT_CONTROL(tcobase)); val &= ~SP5100_PM_WATCHDOG_ACTION_RESET; writel(val, SP5100_WDT_CONTROL(tcobase)); /* Set a reasonable heartbeat before we stop the timer */ tco_timer_set_heartbeat(heartbeat); /* * Stop the TCO before we change anything so we don't race with * a zeroed timer. */ tco_timer_stop(); /* Done */ return 1; unreg_mem_region: release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE); unreg_region: release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE); exit: return 0; } static int sp5100_tco_init(struct platform_device *dev) { int ret; u32 val; /* Check whether or not the hardware watchdog is there. If found, then * set it up. */ if (!sp5100_tco_setupdevice()) return -ENODEV; /* Check to see if last reboot was due to watchdog timeout */ pr_info("Watchdog reboot %sdetected\n", readl(SP5100_WDT_CONTROL(tcobase)) & SP5100_PM_WATCHDOG_FIRED ? "" : "not "); /* Clear out the old status */ val = readl(SP5100_WDT_CONTROL(tcobase)); val &= ~SP5100_PM_WATCHDOG_FIRED; writel(val, SP5100_WDT_CONTROL(tcobase)); /* * Check that the heartbeat value is within it's range. * If not, reset to the default. */ if (tco_timer_set_heartbeat(heartbeat)) { heartbeat = WATCHDOG_HEARTBEAT; tco_timer_set_heartbeat(heartbeat); } ret = misc_register(&sp5100_tco_miscdev); if (ret != 0) { pr_err("cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto exit; } clear_bit(0, &timer_alive); pr_info("initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", tcobase, heartbeat, nowayout); return 0; exit: iounmap(tcobase); release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE); release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE); return ret; } static void sp5100_tco_cleanup(void) { /* Stop the timer before we leave */ if (!nowayout) tco_timer_stop(); /* Deregister */ misc_deregister(&sp5100_tco_miscdev); iounmap(tcobase); release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE); release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE); } static int sp5100_tco_remove(struct platform_device *dev) { if (tcobase) sp5100_tco_cleanup(); return 0; } static void sp5100_tco_shutdown(struct platform_device *dev) { tco_timer_stop(); } static struct platform_driver sp5100_tco_driver = { .probe = sp5100_tco_init, .remove = sp5100_tco_remove, .shutdown = sp5100_tco_shutdown, .driver = { .owner = THIS_MODULE, .name = TCO_MODULE_NAME, }, }; static int __init sp5100_tco_init_module(void) { int err; pr_info("SP5100 TCO WatchDog Timer Driver v%s\n", TCO_VERSION); err = platform_driver_register(&sp5100_tco_driver); if (err) return err; sp5100_tco_platform_device = platform_device_register_simple( TCO_MODULE_NAME, -1, NULL, 0); if (IS_ERR(sp5100_tco_platform_device)) { err = PTR_ERR(sp5100_tco_platform_device); goto unreg_platform_driver; } return 0; unreg_platform_driver: platform_driver_unregister(&sp5100_tco_driver); return err; }
static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int i; const struct comedi_lrange *current_range_type, *voltage_range_type; unsigned long iobase; iobase = it->options[0]; printk(KERN_INFO "comedi%d: dt2815: 0x%04lx ", dev->minor, iobase); if (!request_region(iobase, DT2815_SIZE, "dt2815")) { printk(KERN_WARNING "I/O port conflict\n"); return -EIO; } dev->iobase = iobase; dev->board_name = "dt2815"; if (alloc_subdevices(dev, 1) < 0) return -ENOMEM; if (alloc_private(dev, sizeof(struct dt2815_private)) < 0) return -ENOMEM; s = dev->subdevices; /* ao subdevice */ s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->maxdata = 0xfff; s->n_chan = 8; s->insn_write = dt2815_ao_insn; s->insn_read = dt2815_ao_insn_read; s->range_table_list = devpriv->range_type_list; current_range_type = (it->options[3]) ? &range_dt2815_ao_20_current : &range_dt2815_ao_32_current; voltage_range_type = (it->options[2]) ? &range_bipolar5 : &range_unipolar5; for (i = 0; i < 8; i++) { devpriv->range_type_list[i] = (it->options[5 + i]) ? current_range_type : voltage_range_type; } /* Init the 2815 */ outb(0x00, dev->iobase + DT2815_STATUS); for (i = 0; i < 100; i++) { /* This is incredibly slow (approx 20 ms) */ unsigned int status; udelay(1000); status = inb(dev->iobase + DT2815_STATUS); if (status == 4) { unsigned int program; program = (it->options[4] & 0x3) << 3 | 0x7; outb(program, dev->iobase + DT2815_DATA); printk(KERN_INFO ", program: 0x%x (@t=%d)\n", program, i); break; } else if (status != 0x00) { printk(KERN_WARNING "dt2815: unexpected status 0x%x " "(@t=%d)\n", status, i); if (status & 0x60) outb(0x00, dev->iobase + DT2815_STATUS); } } return 0; }