/* Detect whether a I801 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 i801_setup(void) { int error_return = 0; int *num = supported; unsigned char temp; /* First check whether we can access PCI at all */ if (pci_present() == 0) { printk(KERN_WARNING "i2c-i801.o: Error: No PCI-bus found!\n"); error_return = -ENODEV; goto END; } /* Look for each chip */ /* Note: we keep on searching until we have found 'function 3' */ I801_dev = NULL; do { if((I801_dev = pci_find_device(PCI_VENDOR_ID_INTEL, *num, I801_dev))) { if(PCI_FUNC(I801_dev->devfn) != 3) continue; break; } num++; } while (*num != 0); if (I801_dev == NULL) { printk (KERN_WARNING "i2c-i801.o: Error: Can't detect I801, function 3!\n"); error_return = -ENODEV; goto END; } isich4 = ((*num == PCI_DEVICE_ID_INTEL_82801DB_SMBUS) || (*num == PCI_DEVICE_ID_INTEL_82801EB_SMBUS)); /* Determine the address of the SMBus areas */ if (force_addr) { i801_smba = force_addr & 0xfff0; } else { pci_read_config_word(I801_dev, SMBBA, &i801_smba); i801_smba &= 0xfff0; if(i801_smba == 0) { printk(KERN_ERR "i2c-i801.o: SMB base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); return -ENODEV; } } if (check_region(i801_smba, (isich4 ? 16 : 8))) { printk (KERN_ERR "i2c-i801.o: I801_smb region 0x%x already in use!\n", i801_smba); error_return = -ENODEV; goto END; } pci_read_config_byte(I801_dev, SMBHSTCFG, &temp); temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ pci_write_config_byte(I801_dev, SMBHSTCFG, temp); /* If force_addr is set, we program the new address here. Just to make sure, we disable the device first. */ if (force_addr) { pci_write_config_byte(I801_dev, SMBHSTCFG, temp & 0xfe); pci_write_config_word(I801_dev, SMBBA, i801_smba); pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 0x01); printk (KERN_WARNING "i2c-i801.o: WARNING: I801 SMBus interface set to new " "address %04x!\n", i801_smba); } else if ((temp & 1) == 0) { pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 1); printk(KERN_WARNING "i2c-i801.o: enabling SMBus device\n"); } request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus"); #ifdef DEBUG if (temp & 0x02) printk (KERN_DEBUG "i2c-i801.o: I801 using Interrupt SMI# for SMBus.\n"); else printk (KERN_DEBUG "i2c-i801.o: I801 using PCI Interrupt for SMBus.\n"); pci_read_config_byte(I801_dev, SMBREV, &temp); printk(KERN_DEBUG "i2c-i801.o: SMBREV = 0x%X\n", temp); printk(KERN_DEBUG "i2c-i801.o: I801_smba = 0x%X\n", i801_smba); #endif /* DEBUG */ END: return error_return; }
static int b1isa_add_card(struct capi_driver *driver, struct capicardparams *p) { avmctrl_info *cinfo; avmcard *card; int retval; MOD_INC_USE_COUNT; card = (avmcard *) kmalloc(sizeof(avmcard), GFP_ATOMIC); if (!card) { printk(KERN_WARNING "b1isa: no memory.\n"); 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 "b1isa: no memory.\n"); kfree(card); MOD_DEC_USE_COUNT; return -ENOMEM; } memset(cinfo, 0, sizeof(avmctrl_info)); card->ctrlinfo = cinfo; cinfo->card = card; sprintf(card->name, "b1isa-%x", p->port); card->port = p->port; card->irq = p->irq; card->cardtype = avm_b1isa; if (check_region(card->port, AVMB1_PORTLEN)) { printk(KERN_WARNING "b1isa: ports 0x%03x-0x%03x in use.\n", card->port, card->port + AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } if (b1_irq_table[card->irq & 0xf] == 0) { printk(KERN_WARNING "b1isa: irq %d not valid.\n", card->irq); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EINVAL; } if ( card->port != 0x150 && card->port != 0x250 && card->port != 0x300 && card->port != 0x340) { printk(KERN_WARNING "b1isa: illegal port 0x%x.\n", card->port); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EINVAL; } 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); 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, b1isa_interrupt, 0, card->name, card); if (retval) { printk(KERN_ERR "b1isa: unable to get IRQ %d.\n", 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 "b1isa: attach controller failed.\n"); free_irq(card->irq, card); release_region(card->port, AVMB1_PORTLEN); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } printk(KERN_INFO "%s: AVM B1 ISA at i/o %#x, irq %d, revision %d\n", driver->name, card->port, card->irq, card->revision); return 0; }
int __init 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; #ifdef __BIG_ENDIAN #error "not running on big endian machines now" #endif strcpy(tmp, w6692_revision); printk(KERN_INFO "HiSax: W6692 driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_W6692) return (0); #if CONFIG_PCI if (!pci_present()) { printk(KERN_ERR "W6692: no PCI bus present\n"); return (0); } while (id_list[id_idx].vendor_id) { dev_w6692 = pci_find_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 (check_region((cs->hw.w6692.iobase), 256)) { 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); } else { request_region(cs->hw.w6692.iobase, 256, id_list[cs->subtyp].card_name); } #else printk(KERN_WARNING "HiSax: W6692 and NO_PCI_BIOS\n"); printk(KERN_WARNING "HiSax: W6692 unable to config\n"); return (0); #endif /* CONFIG_PCI */ printk(KERN_INFO "HiSax: %s config irq:%d I/O:%x\n", id_list[cs->subtyp].card_name, cs->irq, cs->hw.w6692.iobase); 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 |= SA_SHIRQ; 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); }
int apricot_probe(struct device *dev) { int i; struct i596_private *lp; int checksum = 0; int ioaddr = 0x300; char eth_addr[6]; /* this is easy the ethernet interface can only be at 0x300 */ /* first check nothing is already registered here */ if (check_region(ioaddr, APRICOT_TOTAL_SIZE)) return ENODEV; for (i = 0; i < 8; i++) { eth_addr[i] = inb(ioaddr+8+i); checksum += eth_addr[i]; } /* checksum is a multiple of 0x100, got this wrong first time some machines have 0x100, some 0x200. The DOS driver doesn't even bother with the checksum */ if (checksum % 0x100) return ENODEV; /* Some other boards trip the checksum.. but then appear as ether address 0. Trap these - AC */ if(memcmp(eth_addr,"\x00\x00\x49",3)!= 0) return ENODEV; request_region(ioaddr, APRICOT_TOTAL_SIZE, "apricot"); dev->base_addr = ioaddr; ether_setup(dev); printk("%s: Apricot 82596 at %#3x,", dev->name, ioaddr); for (i = 0; i < 6; i++) printk(" %2.2X", dev->dev_addr[i] = eth_addr[i]); dev->base_addr = ioaddr; dev->irq = 10; printk(" IRQ %d.\n", dev->irq); if (i596_debug > 0) printk(version); /* The APRICOT-specific entries in the device structure. */ dev->open = &i596_open; dev->stop = &i596_close; dev->hard_start_xmit = &i596_start_xmit; dev->get_stats = &i596_get_stats; dev->set_multicast_list = &set_multicast_list; dev->mem_start = (int)kmalloc(sizeof(struct i596_private)+ 0x0f, GFP_KERNEL); /* align for scp */ dev->priv = (void *)((dev->mem_start + 0xf) & 0xfffffff0); lp = (struct i596_private *)dev->priv; memset((void *)lp, 0, sizeof(struct i596_private)); lp->scb.command = 0; lp->scb.cmd = (struct i596_cmd *) I596_NULL; lp->scb.rfd = (struct i596_rfd *)I596_NULL; return 0; }
int __init setup_diva(struct IsdnCard *card) { int bytecnt = 8; u_char val; struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, Diva_revision); printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_DIEHLDIVA) return(0); cs->hw.diva.status = 0; if (card->para[1]) { cs->hw.diva.ctrl_reg = 0; cs->hw.diva.cfg_reg = card->para[1]; val = readreg(cs->hw.diva.cfg_reg + DIVA_IPAC_ADR, cs->hw.diva.cfg_reg + DIVA_IPAC_DATA, IPAC_ID); printk(KERN_INFO "Diva: IPAC version %x\n", val); if ((val == 1) || (val==2)) { 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; } cs->irq = card->para[0]; } else { #ifdef __ISAPNP__ if (isapnp_present()) { struct pci_bus *pb; struct pci_dev *pd; while(pdev->card_vendor) { if ((pb = isapnp_find_card(pdev->card_vendor, pdev->card_device, pnp_c))) { pnp_c = pb; pd = NULL; if ((pd = isapnp_find_dev(pnp_c, pdev->vendor, pdev->function, pd))) { printk(KERN_INFO "HiSax: %s detected\n", (char *)pdev->driver_data); pd->prepare(pd); pd->deactivate(pd); pd->activate(pd); card->para[1] = pd->resource[0].start; card->para[0] = pd->irq_resource[0].start; 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]); pd->deactivate(pd); return(0); } cs->hw.diva.cfg_reg = card->para[1]; cs->irq = card->para[0]; if (pdev->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; } goto ready; } else { printk(KERN_ERR "Diva PnP: PnP error card found, no device\n"); return(0); } } pdev++; pnp_c=NULL; } if (!pdev->card_vendor) { printk(KERN_INFO "Diva PnP: no ISAPnP card found\n"); } } #endif #if CONFIG_PCI if (!pci_present()) { printk(KERN_ERR "Diva: no PCI bus present\n"); return(0); } cs->subtyp = 0; if ((dev_diva = pci_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) { if (pci_enable_device(dev_diva)) return(0); cs->subtyp = DIVA_PCI; cs->irq = dev_diva->irq; cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2); } else if ((dev_diva_u = pci_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { if (pci_enable_device(dev_diva_u)) return(0); cs->subtyp = DIVA_PCI; cs->irq = dev_diva_u->irq; cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2); } else if ((dev_diva201 = pci_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { if (pci_enable_device(dev_diva201)) return(0); cs->subtyp = DIVA_IPAC_PCI; cs->irq = dev_diva201->irq; cs->hw.diva.pci_cfg = (ulong) ioremap(pci_resource_start(dev_diva201, 0), 4096); cs->hw.diva.cfg_reg = (ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096); } else if ((dev_diva202 = pci_find_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { if (pci_enable_device(dev_diva202)) return(0); cs->subtyp = DIVA_IPACX_PCI; cs->irq = dev_diva202->irq; cs->hw.diva.pci_cfg = (ulong) ioremap(pci_resource_start(dev_diva202, 0), 4096); cs->hw.diva.cfg_reg = (ulong) ioremap(pci_resource_start(dev_diva202, 1), 4096); } else { printk(KERN_WARNING "Diva: No PCI card found\n"); return(0); } if (!cs->irq) { printk(KERN_WARNING "Diva: No IRQ for PCI card found\n"); return(0); } if (!cs->hw.diva.cfg_reg) { printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n"); return(0); } cs->irq_flags |= SA_SHIRQ; #else printk(KERN_WARNING "Diva: cfgreg 0 and NO_PCI_BIOS\n"); printk(KERN_WARNING "Diva: unable to config DIVA PCI\n"); return (0); #endif /* CONFIG_PCI */ if ((cs->subtyp == DIVA_IPAC_PCI) || (cs->subtyp == DIVA_IPACX_PCI) ) { cs->hw.diva.ctrl = 0; cs->hw.diva.isac = 0; cs->hw.diva.hscx = 0; cs->hw.diva.isac_adr = 0; cs->hw.diva.hscx_adr = 0; test_and_set_bit(HW_IPAC, &cs->HW_Flags); bytecnt = 0; } else { cs->hw.diva.ctrl = cs->hw.diva.cfg_reg + DIVA_PCI_CTRL; cs->hw.diva.isac = cs->hw.diva.cfg_reg + DIVA_PCI_ISAC_DATA; cs->hw.diva.hscx = cs->hw.diva.cfg_reg + DIVA_HSCX_DATA; cs->hw.diva.isac_adr = cs->hw.diva.cfg_reg + DIVA_PCI_ISAC_ADR; cs->hw.diva.hscx_adr = cs->hw.diva.cfg_reg + DIVA_HSCX_ADR; bytecnt = 32; } } ready: printk(KERN_INFO "Diva: %s card configured at %#lx IRQ %d\n", (cs->subtyp == DIVA_PCI) ? "PCI" : (cs->subtyp == DIVA_ISA) ? "ISA" : (cs->subtyp == DIVA_IPAC_ISA) ? "IPAC ISA" : (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", cs->hw.diva.cfg_reg, cs->irq); if ((cs->subtyp == DIVA_IPAC_PCI) || (cs->subtyp == DIVA_IPACX_PCI) || (cs->subtyp == DIVA_PCI) ) printk(KERN_INFO "Diva: %s space at %#lx\n", (cs->subtyp == DIVA_PCI) ? "PCI" : (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", cs->hw.diva.pci_cfg); if ((cs->subtyp != DIVA_IPAC_PCI) && (cs->subtyp != DIVA_IPACX_PCI) ) { if (check_region(cs->hw.diva.cfg_reg, bytecnt)) { printk(KERN_WARNING "HiSax: %s config port %lx-%lx already in use\n", CardType[card->typ], cs->hw.diva.cfg_reg, cs->hw.diva.cfg_reg + bytecnt); return (0); } else { request_region(cs->hw.diva.cfg_reg, bytecnt, "diva isdn"); } } reset_diva(cs); cs->BC_Read_Reg = &ReadHSCX; cs->BC_Write_Reg = &WriteHSCX; cs->BC_Send_Data = &hscx_fill_fifo; cs->cardmsg = &Diva_card_msg; if (cs->subtyp == DIVA_IPAC_ISA) { cs->readisac = &ReadISAC_IPAC; cs->writeisac = &WriteISAC_IPAC; cs->readisacfifo = &ReadISACfifo_IPAC; cs->writeisacfifo = &WriteISACfifo_IPAC; cs->irq_func = &diva_irq_ipac_isa; val = readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, IPAC_ID); printk(KERN_INFO "Diva: IPAC version %x\n", val); } else if (cs->subtyp == DIVA_IPAC_PCI) { cs->readisac = &MemReadISAC_IPAC; cs->writeisac = &MemWriteISAC_IPAC; cs->readisacfifo = &MemReadISACfifo_IPAC; cs->writeisacfifo = &MemWriteISACfifo_IPAC; cs->BC_Read_Reg = &MemReadHSCX; cs->BC_Write_Reg = &MemWriteHSCX; cs->BC_Send_Data = &Memhscx_fill_fifo; cs->irq_func = &diva_irq_ipac_pci; val = memreadreg(cs->hw.diva.cfg_reg, IPAC_ID); printk(KERN_INFO "Diva: IPAC version %x\n", val); } else if (cs->subtyp == DIVA_IPACX_PCI) { cs->readisac = &MemReadISAC_IPACX; cs->writeisac = &MemWriteISAC_IPACX; cs->readisacfifo = &MemReadISACfifo_IPACX; cs->writeisacfifo = &MemWriteISACfifo_IPACX; cs->BC_Read_Reg = &MemReadHSCX_IPACX; cs->BC_Write_Reg = &MemWriteHSCX_IPACX; cs->BC_Send_Data = 0; // function located in ipacx module cs->irq_func = &diva_irq_ipacx_pci; printk(KERN_INFO "Diva: IPACX Design Id: %x\n", MemReadISAC_IPACX(cs, IPACX_ID) &0x3F); } else { /* DIVA 2.0 */ cs->hw.diva.tl.function = (void *) diva_led_handler; cs->hw.diva.tl.data = (long) cs; init_timer(&cs->hw.diva.tl); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->irq_func = &diva_interrupt; ISACVersion(cs, "Diva:"); if (HscxVersion(cs, "Diva:")) { printk(KERN_WARNING "Diva: wrong HSCX versions check IO address\n"); release_io_diva(cs); return (0); } } return (1); }
int pcwd_checkcard(void) { int card_dat, prev_card_dat, found = 0, count = 0, done = 0; /* As suggested by Alan Cox */ if (check_region(current_ctlport, WD_PORT_EXTENT)) { printk("pcwd: Port 0x%x unavailable.\n", current_ctlport); return 0; } card_dat = 0x00; prev_card_dat = 0x00; prev_card_dat = inb(current_readport); while(count < WD_TIMEOUT) { #ifdef DEBUG printk("pcwd: Run #%d on port 0x%03x\n", count, current_readport); #endif /* Read the raw card data from the port, and strip off the first 4 bits */ card_dat = inb_p(current_readport); card_dat &= 0x000F; /* Sleep 1/2 second (or 500000 microseconds :) */ udelay(500000L); done = 0; /* 0x0F usually means that no card data is present, or the card is not installed on this port. If 0x0F is present here, it's normally safe to assume there's no card at that base address. */ if (card_dat == 0x0F) { count++; done = 1; #ifdef DEBUG printk("pcwd: I show nothing on this port.\n"); #endif } /* If there's a heart beat in both instances, then this means we found our card. This also means that either the card was previously reset, or the computer was power-cycled. */ if ((card_dat & WD_HRTBT) && (prev_card_dat & WD_HRTBT) && (!done)) { found = 1; done = 1; #ifdef DEBUG printk("pcwd: I show alternate heart beats. Card detected.\n"); #endif break; } /* If the card data is exactly the same as the previous card data, it's safe to assume that we should check again. The manual says that the heart beat will change every second (or the bit will toggle), and this can be used to see if the card is there. If the card was powered up with a cold boot, then the card will not start blinking until 2.5 minutes after a reboot, so this bit will stay at 1. */ if ((card_dat == prev_card_dat) && (!done)) { count++; #ifdef DEBUG printk("pcwd: The card data is exactly the same (possibility).\n"); #endif done = 1; } /* If the card data is toggling any bits, this means that the heart beat was detected, or something else about the card is set. */ if ((card_dat != prev_card_dat) && (!done)) { done = 1; found = 1; #ifdef DEBUG printk("pcwd: I show alternate heart beats. Card detected.\n"); #endif break; } /* Otherwise something else strange happened. */ if (!done) count++; } return((found) ? 1 : 0); }
int __init setup_hfcs(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, hfcs_revision); printk(KERN_INFO "HiSax: HFC-S driver Rev. %s\n", HiSax_getrev(tmp)); #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pci_bus *pb; struct pci_dev *pd; while(hdev->card_vendor) { if ((pb = isapnp_find_card(hdev->card_vendor, hdev->card_device, pnp_c))) { pnp_c = pb; pd = NULL; if ((pd = isapnp_find_dev(pnp_c, hdev->vendor, hdev->function, pd))) { printk(KERN_INFO "HiSax: %s detected\n", (char *)hdev->driver_data); pd->prepare(pd); pd->deactivate(pd); pd->activate(pd); card->para[1] = pd->resource[0].start; card->para[0] = pd->irq_resource[0].start; if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n", card->para[0], card->para[1]); pd->deactivate(pd); return(0); } break; } else { printk(KERN_ERR "HFC PnP: PnP error card found, no device\n"); } } hdev++; pnp_c=NULL; } if (!hdev->card_vendor) { printk(KERN_INFO "HFC PnP: no ISAPnP card found\n"); return(0); } } #endif cs->hw.hfcD.addr = card->para[1] & 0xfffe; cs->irq = card->para[0]; cs->hw.hfcD.cip = 0; cs->hw.hfcD.int_s1 = 0; cs->hw.hfcD.send = NULL; cs->bcs[0].hw.hfc.send = NULL; cs->bcs[1].hw.hfc.send = NULL; cs->hw.hfcD.dfifosize = 512; cs->dc.hfcd.ph_state = 0; cs->hw.hfcD.fifo = 255; if (cs->typ == ISDN_CTYPE_TELES3C) { cs->hw.hfcD.bfifosize = 1024 + 512; } else if (cs->typ == ISDN_CTYPE_ACERP10) { cs->hw.hfcD.bfifosize = 7*1024 + 512; } else return (0); if (check_region((cs->hw.hfcD.addr), 2)) { printk(KERN_WARNING "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.hfcD.addr, cs->hw.hfcD.addr + 2); return (0); } else { request_region(cs->hw.hfcD.addr, 2, "HFCS isdn"); } printk(KERN_INFO "HFCS: defined at 0x%x IRQ %d HZ %d\n", cs->hw.hfcD.addr, cs->irq, HZ); if (cs->typ == ISDN_CTYPE_TELES3C) { /* Teles 16.3c IO ADR is 0x200 | YY0U (YY Bit 15/14 address) */ outb(0x00, cs->hw.hfcD.addr); outb(0x56, cs->hw.hfcD.addr | 1); } else if (cs->typ == ISDN_CTYPE_ACERP10) { /* Acer P10 IO ADR is 0x300 */ outb(0x00, cs->hw.hfcD.addr); outb(0x57, cs->hw.hfcD.addr | 1); } set_cs_func(cs); cs->hw.hfcD.timer.function = (void *) hfcs_Timer; cs->hw.hfcD.timer.data = (long) cs; init_timer(&cs->hw.hfcD.timer); reset_hfcs(cs); cs->cardmsg = &hfcs_card_msg; cs->irq_func = &hfcs_interrupt; return (1); }
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); 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 (check_region((cs->hw.teles3.hscx[1]), 96 )) { 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 request_region(cs->hw.teles3.hscx[1], 96, "HiSax Teles PCMCIA"); } else { if (cs->hw.teles3.cfg_reg) { if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { if (check_region((cs->hw.teles3.cfg_reg), 1)) { printk(KERN_WARNING "HiSax: %s config port %x already in use\n", CardType[card->typ], cs->hw.teles3.cfg_reg); return (0); } else request_region(cs->hw.teles3.cfg_reg, 1, "teles3 cfg"); } else { if (check_region((cs->hw.teles3.cfg_reg), 8)) { 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); } else request_region(cs->hw.teles3.cfg_reg, 8, "teles3 cfg"); } } if (check_region((cs->hw.teles3.isac + 32), 32)) { 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); } else request_region(cs->hw.teles3.isac + 32, 32, "HiSax isac"); if (check_region((cs->hw.teles3.hscx[0] + 32), 32)) { 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); } else request_region(cs->hw.teles3.hscx[0] + 32, 32, "HiSax hscx A"); if (check_region((cs->hw.teles3.hscx[1] + 32), 32)) { 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); } else request_region(cs->hw.teles3.hscx[1] + 32, 32, "HiSax hscx B"); } 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); 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); }
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_port(void) { unsigned long flags; /* Check io region*/ #ifdef LIRC_PORT if((check_region(port,8))==-EBUSY) { #if 0 /* this is the correct behaviour but many people have the serial driver compiled into the kernel... */ printk(KERN_ERR LIRC_DRIVER_NAME ": port %04x already in use\n", port); return(-EBUSY); #else printk(KERN_ERR LIRC_DRIVER_NAME ": port %04x already in use, proceding anyway\n", port); printk(KERN_WARNING LIRC_DRIVER_NAME ": compile the serial port driver as module and\n"); printk(KERN_WARNING LIRC_DRIVER_NAME ": make sure this module is loaded first\n"); release_region(port,8); #endif } /* Reserve io region. */ request_region(port, 8, LIRC_DRIVER_NAME); #endif save_flags(flags);cli(); #ifndef CONFIG_COLDFIRE /* Set DLAB 0. */ soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB)); /* First of all, disable all interrupts */ soutp(UART_IER, sinp(UART_IER)& (~(UART_IER_MSI|UART_IER_RLSI|UART_IER_THRI|UART_IER_RDI))); /* Clear registers. */ sinp(UART_LSR); sinp(UART_RX); sinp(UART_IIR); sinp(UART_MSR); /* Set line for power source */ soutp(UART_MCR, LIRC_OFF); /* Clear registers again to be sure. */ sinp(UART_LSR); sinp(UART_RX); sinp(UART_IIR); sinp(UART_MSR); #ifdef LIRC_SERIAL_IRDEO /* setup port to 7N1 @ 115200 Baud */ /* 7N1+start = 9 bits at 115200 ~ 3 bits at 38kHz */ /* Set DLAB 1. */ soutp(UART_LCR, sinp(UART_LCR) | UART_LCR_DLAB); /* Set divisor to 1 => 115200 Baud */ soutp(UART_DLM,0); soutp(UART_DLL,1); /* Set DLAB 0 + 7N1 */ soutp(UART_LCR,UART_LCR_WLEN7); /* THR interrupt already disabled at this point */ #endif #else /* CONFIG_COLDFIRE */ { volatile unsigned char *uartp; #ifdef CONFIG_M5272 volatile unsigned long *icrp; #else volatile unsigned char *icrp; #endif /* * we need a fast timer */ coldfire_fast_init(); /* * Setup the interrupts */ #ifdef CONFIG_M5272 #ifndef LIRC_PORT /* nothing to do */ #else icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR2); switch (LIRC_PORT) { case MCFUART_BASE1: *icrp = 0xe0000000; break; case MCFUART_BASE2: *icrp = 0x0e000000; break; default: printk("SERIAL: don't know how to handle UART %d interrupt?\n", LIRC_PORT; return; } #endif #else switch (LIRC_PORT) { case MCFUART_BASE1: icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_UART1ICR); *icrp = /*MCFSIM_ICR_AUTOVEC |*/ MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1; mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1); break; case MCFUART_BASE2: icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_UART2ICR); *icrp = /*MCFSIM_ICR_AUTOVEC |*/ MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2; mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2); break; default: printk("SERIAL: don't know how to handle UART %d interrupt?\n", LIRC_PORT); return(-EIO); } soutp(MCFUART_UIVR, LIRC_IRQ); #endif #ifdef LIRC_PORT /* * disable all interrupts */ soutp(MCFUART_UIMR, 0); soutp(MCFUART_UCR, MCFUART_UCR_CMDRESETRX); /* reset RX */ soutp(MCFUART_UCR, MCFUART_UCR_CMDRESETTX); /* reset TX */ soutp(MCFUART_UCR, MCFUART_UCR_CMDRESETMRPTR); /* reset MR pointer */ /* * Set port for defined baud , 8 data bits, 1 stop bit, no parity. */ soutp(MCFUART_UMR, MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8); soutp(MCFUART_UMR, MCFUART_MR2_STOP1); #define clk ((MCF_CLK / 32) / 115200) soutp(MCFUART_UBG1, (clk & 0xff00) >> 8); /* set msb baud */ soutp(MCFUART_UBG2, (clk & 0xff)); /* set lsb baud */ #undef clk soutp(MCFUART_UCSR, MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER); soutp(MCFUART_UCR, 0 /* MCFUART_UCR_RXENABLE */); /* * Allow COS interrupts */ soutp(MCFUART_UACR, MCFUART_UACR_IEC); /* * turn on RTS for power */ soutp(MCFUART_UOP1, MCFUART_UOP_RTS); #endif /* LIRC_PORT */ } #endif /* CONFIG_COLDFIRE */ restore_flags(flags); /* If pin is high, then this must be an active low receiver. */ if(sense==-1) { #if DAVIDM /* wait 1 sec for the power supply */ # ifdef KERNEL_2_1 sleep_on_timeout(&power_supply_queue,HZ); # else init_timer(&power_supply_timer); power_supply_timer.expires=jiffies+HZ; power_supply_timer.data=(unsigned long) current; power_supply_timer.function=power_supply_up; add_timer(&power_supply_timer); sleep_on(&power_supply_queue); del_timer(&power_supply_timer); # endif #ifndef LIRC_PORT sense=(pin_status & LIRC_SIGNAL_PIN) ? 1:0; #else sense=(sinp(UART_MSR) & LIRC_SIGNAL_PIN) ? 1:0; #endif #else sense = 0; #endif /* DAVIDM */ printk(KERN_INFO LIRC_DRIVER_NAME ": auto-detected active " "%s receiver\n",sense ? "low":"high"); } else { printk(KERN_INFO LIRC_DRIVER_NAME ": Manually using active " "%s receiver\n",sense ? "low":"high"); }; return 0; }
static int check_arcofi(struct IsdnCardState *cs) { int arcofi_present = 0; char tmp[40]; char *t; u_char *p; if (!cs->dc.isac.mon_tx) if (!(cs->dc.isac.mon_tx=kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "ISAC MON TX out of buffers!"); return(0); } cs->dc.isac.arcofi_bc = 0; arcofi_fsm(cs, ARCOFI_START, &ARCOFI_VERSION); interruptible_sleep_on(&cs->dc.isac.arcofi_wait); if (!test_and_clear_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags)) { debugl1(cs, "Arcofi response received %d bytes", cs->dc.isac.mon_rxp); p = cs->dc.isac.mon_rx; t = tmp; t += sprintf(tmp, "Arcofi data"); QuickHex(t, p, cs->dc.isac.mon_rxp); debugl1(cs, tmp); if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) { switch(cs->dc.isac.mon_rx[1]) { case 0x80: debugl1(cs, "Arcofi 2160 detected"); arcofi_present = 1; break; case 0x82: debugl1(cs, "Arcofi 2165 detected"); arcofi_present = 2; break; case 0x84: debugl1(cs, "Arcofi 2163 detected"); arcofi_present = 3; break; default: debugl1(cs, "unknown Arcofi response"); break; } } else debugl1(cs, "undefined Monitor response"); cs->dc.isac.mon_rxp = 0; } else if (cs->dc.isac.mon_tx) { debugl1(cs, "Arcofi not detected"); } if (arcofi_present) { if (cs->subtyp==ELSA_QS1000) { cs->subtyp = ELSA_QS3000; printk(KERN_INFO "Elsa: %s detected modem at 0x%lx\n", Elsa_Types[cs->subtyp], cs->hw.elsa.base+8); release_region(cs->hw.elsa.base, 8); if (check_region(cs->hw.elsa.base, 16)) { printk(KERN_WARNING "HiSax: %s config port %lx-%lx already in use\n", Elsa_Types[cs->subtyp], cs->hw.elsa.base + 8, cs->hw.elsa.base + 16); } else request_region(cs->hw.elsa.base, 16, "elsa isdn modem"); } else if (cs->subtyp==ELSA_PCC16) { cs->subtyp = ELSA_PCF; printk(KERN_INFO "Elsa: %s detected modem at 0x%lx\n", Elsa_Types[cs->subtyp], cs->hw.elsa.base+8); release_region(cs->hw.elsa.base, 8); if (check_region(cs->hw.elsa.base, 16)) { printk(KERN_WARNING "HiSax: %s config port %lx-%lx already in use\n", Elsa_Types[cs->subtyp], cs->hw.elsa.base + 8, cs->hw.elsa.base + 16); } else request_region(cs->hw.elsa.base, 16, "elsa isdn modem"); } else printk(KERN_INFO "Elsa: %s detected modem at 0x%lx\n", Elsa_Types[cs->subtyp], cs->hw.elsa.base+8); arcofi_fsm(cs, ARCOFI_START, &ARCOFI_XOP_0); interruptible_sleep_on(&cs->dc.isac.arcofi_wait); return(1); } return(0); }
static struct ns558* ns558_isa_probe(int io, struct ns558 *next) { int i, j, b; unsigned char c, u, v; struct ns558 *port; /* * No one should be using this address. */ if (check_region(io, 1)) return next; /* * We must not be able to write arbitrary values to the port. * The lower two axis bits must be 1 after a write. */ c = inb(io); outb(~c & ~3, io); if (~(u = v = inb(io)) & 3) { outb(c, io); return next; } /* * After a trigger, there must be at least some bits changing. */ for (i = 0; i < 1000; i++) v &= inb(io); if (u == v) { outb(c, io); return next; } wait_ms(3); /* * After some time (4ms) the axes shouldn't change anymore. */ u = inb(io); for (i = 0; i < 1000; i++) if ((u ^ inb(io)) & 0xf) { outb(c, io); return next; } /* * And now find the number of mirrors of the port. */ for (i = 1; i < 5; i++) { if (check_region(io & (-1 << i), (1 << i))) /* Don't disturb anyone */ break; outb(0xff, io & (-1 << i)); for (j = b = 0; j < 1000; j++) if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++; wait_ms(3); if (b > 300) /* We allow 30% difference */ break; } i--; if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) { printk(KERN_ERR "Memory allocation failed.\n"); return next; } memset(port, 0, sizeof(struct ns558)); port->next = next; port->type = NS558_ISA; port->gameport.io = io & (-1 << i); port->gameport.size = (1 << i); request_region(port->gameport.io, port->gameport.size, "ns558-isa"); gameport_register_port(&port->gameport); printk(KERN_INFO "gameport%d: NS558 ISA at %#x", port->gameport.number, port->gameport.io); if (port->gameport.size > 1) printk(" size %d", port->gameport.size); printk(" speed %d kHz\n", port->gameport.speed); return port; }
static int mpc30x_ide_check_region(ide_ioreg_t from, unsigned int extent) { return check_region(from, extent); }
static int c4_add_card(struct capi_driver *driver, struct capicardparams *p, int nr) { avmctrl_info *cinfo; avmcard *card; int retval; int i; 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)*4, 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)*4); card->ctrlinfo = cinfo; for (i=0; i < 4; i++) { cinfo = &card->ctrlinfo[i]; cinfo->card = card; } sprintf(card->name, "%s-%x", driver->name, p->port); card->port = p->port; card->irq = p->irq; card->membase = p->membase; card->cardtype = nr == 4 ? avm_c4 : avm_c2; 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, 128); if (card->mbase == 0) { 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; } if ((retval = c4_detect(card)) != 0) { printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n", driver->name, card->port, retval); iounmap(card->mbase); kfree(card->ctrlinfo); kfree(card->dma); kfree(card); MOD_DEC_USE_COUNT; return -EIO; } c4_reset(card); request_region(p->port, AVMB1_PORTLEN, card->name); retval = request_irq(card->irq, c4_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; } for (i=0; i < nr ; i++) { cinfo = &card->ctrlinfo[i]; cinfo->card = card; cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo); if (!cinfo->capi_ctrl) { printk(KERN_ERR "%s: attach controller failed (%d).\n", driver->name, i); for (i--; i >= 0; i--) { cinfo = &card->ctrlinfo[i]; di->detach_ctr(cinfo->capi_ctrl); } iounmap(card->mbase); free_irq(card->irq, card); release_region(card->port, AVMB1_PORTLEN); kfree(card->dma); kfree(card->ctrlinfo); kfree(card); MOD_DEC_USE_COUNT; return -EBUSY; } if (i == 0) card->cardnr = cinfo->capi_ctrl->cnr; } skb_queue_head_init(&card->dma->send_queue); printk(KERN_INFO "%s: AVM C%d at i/o %#x, irq %d, mem %#lx\n", driver->name, nr, card->port, card->irq, card->membase); return 0; }
int __init mcd_init(void) { int count; unsigned char result[3]; char msg[80]; if (mcd_port <= 0 || mcd_irq <= 0) { printk(KERN_INFO "mcd: not probing.\n"); return -EIO; } if (devfs_register_blkdev(MAJOR_NR, "mcd", &mcd_bdops) != 0) { printk(KERN_ERR "mcd: Unable to get major %d for Mitsumi CD-ROM\n", MAJOR_NR); return -EIO; } if (check_region(mcd_port, 4)) { cleanup(1); printk(KERN_ERR "mcd: Initialization failed, I/O port (%X) already in use\n", mcd_port); return -EIO; } blksize_size[MAJOR_NR] = mcd_blocksizes; blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST, &mcd_spinlock); read_ahead[MAJOR_NR] = 4; /* check for card */ outb(0, MCDPORT(1)); /* send reset */ for (count = 0; count < 2000000; count++) (void) inb(MCDPORT(1)); /* delay a bit */ outb(0x40, MCDPORT(0)); /* send get-stat cmd */ for (count = 0; count < 2000000; count++) if (!(inb(MCDPORT(1)) & MFL_STATUS)) break; if (count >= 2000000) { printk(KERN_INFO "mcd: initialisation failed - No mcd device at 0x%x irq %d\n", mcd_port, mcd_irq); cleanup(1); return -EIO; } count = inb(MCDPORT(0)); /* pick up the status */ outb(MCMD_GET_VERSION, MCDPORT(0)); for (count = 0; count < 3; count++) if (getValue(result + count)) { printk(KERN_ERR "mcd: mitsumi get version failed at 0x%x\n", mcd_port); cleanup(1); return -EIO; } if (result[0] == result[1] && result[1] == result[2]) { cleanup(1); return -EIO; } mcdVersion = result[2]; if (mcdVersion >= 4) outb(4, MCDPORT(2)); /* magic happens */ /* don't get the IRQ until we know for sure the drive is there */ if (request_irq(mcd_irq, mcd_interrupt, SA_INTERRUPT, "Mitsumi CD", NULL)) { printk(KERN_ERR "mcd: Unable to get IRQ%d for Mitsumi CD-ROM\n", mcd_irq); cleanup(1); return -EIO; } if (result[1] == 'D') { MCMD_DATA_READ = MCMD_2X_READ; /* Added flag to drop to 1x speed if too many errors */ mcdDouble = 1; } else mcd_info.speed = 1; sprintf(msg, " mcd: Mitsumi %s Speed CD-ROM at port=0x%x," " irq=%d\n", mcd_info.speed == 1 ? "Single" : "Double", mcd_port, mcd_irq); request_region(mcd_port, 4, "mcd"); outb(MCMD_CONFIG_DRIVE, MCDPORT(0)); outb(0x02, MCDPORT(0)); outb(0x00, MCDPORT(0)); getValue(result); outb(MCMD_CONFIG_DRIVE, MCDPORT(0)); outb(0x10, MCDPORT(0)); outb(0x04, MCDPORT(0)); getValue(result); mcd_invalidate_buffers(); mcdPresent = 1; mcd_info.dev = mk_kdev(MAJOR_NR, 0); if (register_cdrom(&mcd_info) != 0) { printk(KERN_ERR "mcd: Unable to register Mitsumi CD-ROM.\n"); cleanup(3); return -EIO; } devfs_plain_cdrom(&mcd_info, &mcd_bdops); printk(msg); return 0; }
/* 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; }
bool probe_hardware( int minor ) { int erc, trans; byte rx_buffer[256]; int port = base_address[minor]; int irq = pclta_interrupt[minor]; struct pclta_device * device; if( !port || !irq ) return 0; VERBOSE_MSG( "probing minor = %d, I/O = %#x-%#x, interrupt request = %d ... ", minor, port, port+3, irq ); if( 0 > check_region( port, 4 ) ) { VERBOSE_MSG( "error(%d) PCLTA_IOPERM.\n", PCLTA_IOPERM ); return false; } init_hw( port, 0x00, CLK_10 ); // initialize device hardware, no IRQ if( ! wait_reset( port, 500 ) ) { VERBOSE_MSG( "error(%d) PCLTA_LRESET.\n", PCLTA_LRESET ); return false; } // waiting to leave reset state setup_timeout( 200 ); while( !pclta_timeout ); // Why wait? Because, when PCLTA gets out of RESET state, it sets // status register BEFORE preparing uplink reset. So, I read the // packet of length 0 and get an error. Stupid! // wait for reset command response if( ! wait_uplink_buffer( port, 500, rx_buffer ) ) { VERBOSE_MSG( "error(%d) PCLTA_RESP. \n", PCLTA_RESP ); return false; } // make sure the reset was successful if( rx_buffer[0] != 1 || rx_buffer[1] != niRESET ) { VERBOSE_MSG( "error(%d) PCLTA_RESP. Reset not successfull. \n", PCLTA_RESP ); return false; } // set up internal interrupt register write_byte_wait( port, CMD_XFER ); write_byte_wait( port, 2 ); write_byte_wait( port, niIRQENA ); write_byte_wait( port, IRQPLRTY | RESET_ENABLE | DLREADY_ENABLE | DLPBA_ENABLE | DLBA_ENABLE | ULREADY_ENABLE ); // write a command to get transciever status write_byte_wait( port, CMD_XFER ); write_byte_wait( port, 1 ); write_byte_wait( port, niSSTATUS ); // wait for response if( ! wait_uplink_buffer( port, 500, rx_buffer ) ) { VERBOSE_MSG( "error(%d) PCLTA_STAT.\n", PCLTA_STAT ); return false; } // get transceiver type trans = rx_buffer[2]>>3; if( ! *pclta_transceiver[trans] ) { VERBOSE_MSG( "error(%d) PCLTA_TSCV.\n", PCLTA_TSCV ); return false; // transciever not supported } // register character device if( 0 > (pclta_major = register_chrdev( 0, "pclta", &pclta_fops )) ) { VERBOSE_MSG( "error(%d) PCLTA_MAJOR.\n", PCLTA_MAJOR ); return false; } // request interrupt permission OLD LOCATION // if( 0 > ( erc = request_irq( irq, pclta_interrupt, 0, "pclta", NULL ) ) ) { SLOW INT // if( 0 > ( erc = request_irq( irq, pclta_interrupt,SA_INTERRUPT, "pclta", device ) ) ) { // VERBOSE_MSG( "error(%d) PCLTA_IRQPERM.\n", PCLTA_IRQPERM ); // return false; // } // create device descriptor device = create_device( port, irq, pclta_clock[rx_buffer[2]>>3] ); if( device == NULL ) { VERBOSE_MSG( "error(%d) PCLTA_CDEV.\n", PCLTA_CDEV ); return false; } // request interrupt permission NEW LOCATION SO WE HAVE DEVICE STRUCT // if( 0 > ( erc = request_irq( irq, pclta_interrupt, 0, "pclta", NULL ) ) ) { SLOW INT if( 0 > ( erc = request_irq( irq, pclta_interrupt_handler,0, "pclta", device) ) ) { VERBOSE_MSG( "error(%d) PCLTA_IRQPERM.\n", PCLTA_IRQPERM ); return false; } // set up pointers to device descriptor pclta_device_table[minor] = device; pclta_interrupt_table[minor] = device; // remember minor number device->minor = minor; // claim I/O space request_region( port, 4, "pclta" ); // start up the interupts removed 07/07 by karl. // init_hw( port,irq_mask[irq], CLK_10 ); // initialize device hardware, no IRQ DEBUG_MSG( "Transceiver type: %s", pclta_transceiver[trans] ); MESSAGE("Device pclta%d installed.", minor ); return true; }
int __init setup_TeleInt(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; strcpy(tmp, TeleInt_revision); printk(KERN_INFO "HiSax: TeleInt driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_TELEINT) return (0); cs->hw.hfc.addr = card->para[1] & 0x3fe; cs->irq = card->para[0]; cs->hw.hfc.cirm = HFC_CIRM; cs->hw.hfc.isac_spcr = 0x00; cs->hw.hfc.cip = 0; cs->hw.hfc.ctmt = HFC_CTMT | HFC_CLTIMER; cs->bcs[0].hw.hfc.send = NULL; cs->bcs[1].hw.hfc.send = NULL; cs->hw.hfc.fifosize = 7 * 1024 + 512; cs->hw.hfc.timer.function = (void *) TeleInt_Timer; cs->hw.hfc.timer.data = (long) cs; init_timer(&cs->hw.hfc.timer); if (check_region((cs->hw.hfc.addr), 2)) { printk(KERN_WARNING "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.hfc.addr, cs->hw.hfc.addr + 2); return (0); } else { request_region(cs->hw.hfc.addr, 2, "TeleInt isdn"); } /* HW IO = IO */ byteout(cs->hw.hfc.addr, cs->hw.hfc.addr & 0xff); byteout(cs->hw.hfc.addr | 1, ((cs->hw.hfc.addr & 0x300) >> 8) | 0x54); switch (cs->irq) { case 3: cs->hw.hfc.cirm |= HFC_INTA; break; case 4: cs->hw.hfc.cirm |= HFC_INTB; break; case 5: cs->hw.hfc.cirm |= HFC_INTC; break; case 7: cs->hw.hfc.cirm |= HFC_INTD; break; case 10: cs->hw.hfc.cirm |= HFC_INTE; break; case 11: cs->hw.hfc.cirm |= HFC_INTF; break; default: printk(KERN_WARNING "TeleInt: wrong IRQ\n"); release_io_TeleInt(cs); return (0); } byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.cirm); byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.ctmt); printk(KERN_INFO "TeleInt: defined at 0x%x IRQ %d\n", cs->hw.hfc.addr, cs->irq); reset_TeleInt(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->BC_Read_Reg = &ReadHFC; cs->BC_Write_Reg = &WriteHFC; cs->cardmsg = &TeleInt_card_msg; cs->irq_func = &TeleInt_interrupt; ISACVersion(cs, "TeleInt:"); return (1); }
__initfunc(int 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); #if CONFIG_PCI if (!pci_present()) { printk(KERN_ERR "W6692: no PCI bus present\n"); return (0); } while (id_list[id_idx].vendor_id) { dev_w6692 = pci_find_device(id_list[id_idx].vendor_id, id_list[id_idx].device_id, dev_w6692); if (dev_w6692) 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 = dev_w6692->base_address[ 1]; } 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); } pci_ioaddr &= PCI_BASE_ADDRESS_IO_MASK; 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[id_idx].vendor_name, id_list[id_idx].card_name, pci_ioaddr, dev_w6692->irq); if (check_region((cs->hw.w6692.iobase), 256)) { printk(KERN_WARNING "HiSax: %s I/O ports %x-%x already in use\n", id_list[id_idx].card_name, cs->hw.w6692.iobase, cs->hw.w6692.iobase + 255); return (0); } else { request_region(cs->hw.w6692.iobase, 256, id_list[id_idx].card_name); } #else printk(KERN_WARNING "HiSax: W6692 and NO_PCI_BIOS\n"); printk(KERN_WARNING "HiSax: W6692 unable to config\n"); return (0); #endif /* CONFIG_PCI */ printk(KERN_INFO "HiSax: %s config irq:%d I/O:%x\n", id_list[id_idx].card_name, cs->irq, cs->hw.w6692.iobase); 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; 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); }
int __init init_module(void) { int result; word divisor; unsigned char reg; struct resource *base_res; printk("<1>""uart: INIT_MOD\n"); #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) base_res = request_region(PORT_COM1,8,"uart"); if (!base_res) { printk("<1>""uart: can't get I/O address 0x%x\n",PORT_COM1); return 1; } #else if ( check_region(PORT_COM1, 8) ) { printk(KERN_INFO "uart: Can't get I/O address 0x%x\n", PORT_COM1); return -1; } request_region(PORT_COM1, 8, "uart"); #endif #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) if(uart_major) { if ( register_chrdev_region(MKDEV(uart_major,0), 1, "uart") < 0 ) { printk ("register_chrdev_region() fail\n"); release_region(PORT_COM1,8); return -1; } } else { if (alloc_chrdev_region(&devno, 0, 1, "uart") < 0) { printk ("alloc_chrdev_region() fail\n"); release_region(PORT_COM1,8); return -1; } uart_major=MAJOR(devno); } cdev_init(&mycdev, &uart_fops); mycdev.owner=THIS_MODULE; if(cdev_add(&mycdev, MKDEV(uart_major,0), 1)) { printk ("Error adding cdev\n"); unregister_chrdev_region(MKDEV(uart_major, 0), 1); release_region(PORT_COM1,8); } #else uart_major = register_chrdev(0, "uart", &uart_fops); if (uart_major < 0) { printk("<1>" "uart: can't get major number\n"); release_region(PORT_COM1,8); return -1; } #endif prbuf = (unsigned char *)__get_free_page(GFP_KERNEL); pwbuf = (unsigned char *)__get_free_page(GFP_KERNEL); if ( !prbuf || !pwbuf ) { #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) cdev_del(&mycdev); unregister_chrdev_region(MKDEV(uart_major, 0), 1); #else unregister_chrdev(uart_major, "uart"); #endif release_region(PORT_COM1,8); return -ENOMEM; } outb(DLR_ON,(PORT_COM1 + REG_LCR)); reg = inb(PORT_COM1+REG_LCR); printk("<1>""REG_LCR %x\n", reg); divisor = 48; outw(divisor, PORT_COM1); outb((BITS_8 | PARITY_NONE | STOP_ONE), (PORT_COM1 + REG_LCR)); result = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) result = request_irq(COM_IRQ, uart_interrupt,SA_INTERRUPT,"uart",NULL); #else result = request_irq(COM_IRQ, uart_interrupt,IRQF_DISABLED,"uart",NULL); #endif if(result) { printk("uart: can't register irq\n"); if( prbuf) free_page((unsigned long)prbuf); if( pwbuf) free_page((unsigned long)pwbuf); release_region(PORT_COM1,8); #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) cdev_del(&mycdev); unregister_chrdev_region(MKDEV(uart_major, 0), 1); #else unregister_chrdev(uart_major, "uart"); #endif return -EFAULT; } else { printk("interrupt on\n"); outb(COM1_IRQ_ON,(PORT_COM1 + REG_MCR)); outb(REC_IRQ_ON,(PORT_COM1 + REG_IER)); } ring_buffer_init (&ring); return 0; }
int __devinit setup_sedlbauer(struct IsdnCard *card) { int bytecnt, ver, val; struct IsdnCardState *cs = card->cs; char tmp[64]; u16 sub_vendor_id, sub_id; long flags; strcpy(tmp, Sedlbauer_revision); printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ == ISDN_CTYPE_SEDLBAUER) { cs->subtyp = SEDL_SPEED_CARD_WIN; cs->hw.sedl.bus = SEDL_BUS_ISA; cs->hw.sedl.chip = SEDL_CHIP_TEST; } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) { cs->subtyp = SEDL_SPEED_STAR; cs->hw.sedl.bus = SEDL_BUS_PCMCIA; cs->hw.sedl.chip = SEDL_CHIP_TEST; } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_FAX) { cs->subtyp = SEDL_SPEED_FAX; cs->hw.sedl.bus = SEDL_BUS_ISA; cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; } else return (0); bytecnt = 8; if (card->para[1]) { cs->hw.sedl.cfg_reg = card->para[1]; cs->irq = card->para[0]; if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { bytecnt = 16; } } else { #ifdef __ISAPNP__ if (isapnp_present()) { struct pci_bus *pb; struct pci_dev *pd; while(pdev->card_vendor) { if ((pb = isapnp_find_card(pdev->card_vendor, pdev->card_device, pnp_c))) { pnp_c = pb; pd = NULL; if ((pd = isapnp_find_dev(pnp_c, pdev->vendor, pdev->function, pd))) { printk(KERN_INFO "HiSax: %s detected\n", (char *)pdev->driver_data); pd->prepare(pd); pd->deactivate(pd); pd->activate(pd); card->para[1] = pd->resource[0].start; card->para[0] = pd->irq_resource[0].start; 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]); pd->deactivate(pd); return(0); } cs->hw.sedl.cfg_reg = card->para[1]; cs->irq = card->para[0]; if (pdev->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; } goto ready; } else { printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n"); return(0); } } pdev++; pnp_c=NULL; } if (!pdev->card_vendor) { printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n"); } } #endif /* Probe for Sedlbauer speed pci */ #if CONFIG_PCI if (!pci_present()) { printk(KERN_ERR "Sedlbauer: no PCI bus present\n"); return(0); } if ((dev_sedl = pci_find_device(PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) { if (pci_enable_device(dev_sedl)) return(0); cs->irq = dev_sedl->irq; if (!cs->irq) { printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n"); return(0); } cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0); } else { printk(KERN_WARNING "Sedlbauer: No PCI card found\n"); return(0); } cs->irq_flags |= SA_SHIRQ; cs->hw.sedl.bus = SEDL_BUS_PCI; sub_vendor_id = dev_sedl->subsystem_vendor; sub_id = dev_sedl->subsystem_device; printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n", sub_vendor_id, sub_id); printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n", cs->hw.sedl.cfg_reg); if (sub_id != PCI_SUB_ID_SEDLBAUER) { printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id); return(0); } if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) { cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; cs->subtyp = SEDL_SPEEDFAX_PYRAMID; } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) { cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; cs->subtyp = SEDL_SPEEDFAX_PCI; } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) { cs->hw.sedl.chip = SEDL_CHIP_IPAC; cs->subtyp = SEDL_SPEED_PCI; } else { printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n", sub_vendor_id); return(0); } bytecnt = 256; cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON; cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF; byteout(cs->hw.sedl.cfg_reg, 0xff); byteout(cs->hw.sedl.cfg_reg, 0x00); byteout(cs->hw.sedl.cfg_reg+ 2, 0xdd); byteout(cs->hw.sedl.cfg_reg+ 5, 0x02); byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on); save_flags(flags); sti(); current->state = TASK_UNINTERRUPTIBLE; schedule_timeout((10*HZ)/1000); byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off); restore_flags(flags); #else printk(KERN_WARNING "Sedlbauer: NO_PCI_BIOS\n"); return (0); #endif /* CONFIG_PCI */ } ready: /* In case of the sedlbauer pcmcia card, this region is in use, * reserved for us by the card manager. So we do not check it * here, it would fail. */ if (cs->hw.sedl.bus != SEDL_BUS_PCMCIA && check_region((cs->hw.sedl.cfg_reg), bytecnt)) { printk(KERN_WARNING "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.sedl.cfg_reg, cs->hw.sedl.cfg_reg + bytecnt); return (0); } else { request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn"); } printk(KERN_INFO "Sedlbauer: defined at 0x%x-0x%x IRQ %d\n", cs->hw.sedl.cfg_reg, cs->hw.sedl.cfg_reg + bytecnt, cs->irq); cs->BC_Read_Reg = &ReadHSCX; cs->BC_Write_Reg = &WriteHSCX; cs->BC_Send_Data = &hscx_fill_fifo; cs->cardmsg = &Sedl_card_msg; /* * testing ISA and PCMCIA Cards for IPAC, default is ISAC * do not test for PCI card, because ports are different * and PCI card uses only IPAC (for the moment) */ if (cs->hw.sedl.bus != SEDL_BUS_PCI) { val = readreg(cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR, cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC, IPAC_ID); printk(KERN_DEBUG "Sedlbauer: testing IPAC version %x\n", val); if ((val == 1) || (val == 2)) { /* IPAC */ cs->subtyp = SEDL_SPEED_WIN2_PC104; if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) { cs->subtyp = SEDL_SPEED_STAR2; } cs->hw.sedl.chip = SEDL_CHIP_IPAC; } else { /* ISAC_HSCX oder ISAC_ISAR */ if (cs->hw.sedl.chip == SEDL_CHIP_TEST) { cs->hw.sedl.chip = SEDL_CHIP_ISAC_HSCX; } } } /* * hw.sedl.chip is now properly set */ printk(KERN_INFO "Sedlbauer: %s detected\n", Sedlbauer_Types[cs->subtyp]); if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) { if (cs->hw.sedl.bus == SEDL_BUS_PCI) { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC; } else { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC; } test_and_set_bit(HW_IPAC, &cs->HW_Flags); cs->readisac = &ReadISAC_IPAC; cs->writeisac = &WriteISAC_IPAC; cs->readisacfifo = &ReadISACfifo_IPAC; cs->writeisacfifo = &WriteISACfifo_IPAC; cs->irq_func = &sedlbauer_interrupt_ipac; val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ID); printk(KERN_INFO "Sedlbauer: IPAC version %x\n", val); reset_sedlbauer(cs); } else { /* ISAC_HSCX oder ISAC_ISAR */ cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { if (cs->hw.sedl.bus == SEDL_BUS_PCI) { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_ISAR_PCI_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_ISAR_PCI_ISAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_ISAR_PCI_ISAR; } else { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_ISAR_ISA_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_ISAR_ISA_ISAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_ISAR_ISA_ISAR; cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_ISAR_ISA_ISAR_RESET_ON; cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_ISAR_ISA_ISAR_RESET_OFF; } cs->bcs[0].hw.isar.reg = &cs->hw.sedl.isar; cs->bcs[1].hw.isar.reg = &cs->hw.sedl.isar; test_and_set_bit(HW_ISAR, &cs->HW_Flags); cs->irq_func = &sedlbauer_interrupt_isar; cs->auxcmd = &isar_auxcmd; ISACVersion(cs, "Sedlbauer:"); cs->BC_Read_Reg = &ReadISAR; cs->BC_Write_Reg = &WriteISAR; cs->BC_Send_Data = &isar_fill_fifo; ver = ISARVersion(cs, "Sedlbauer:"); if (ver < 0) { printk(KERN_WARNING "Sedlbauer: wrong ISAR version (ret = %d)\n", ver); release_io_sedlbauer(cs); return (0); } } else { if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ISAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_HSCX; cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET; cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET; } else { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ISAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_HSCX; cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_ON; cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_OFF; } cs->irq_func = &sedlbauer_interrupt; ISACVersion(cs, "Sedlbauer:"); if (HscxVersion(cs, "Sedlbauer:")) { printk(KERN_WARNING "Sedlbauer: wrong HSCX versions check IO address\n"); release_io_sedlbauer(cs); return (0); } reset_sedlbauer(cs); } } return (1); }
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; }
/* probe for SB1000 using Plug-n-Play mechanism */ int sb1000_probe(struct net_device *dev) { unsigned short ioaddr[2], irq; struct pci_dev *idev=NULL; unsigned int serial_number; while(1) { /* * Find the card */ idev=isapnp_find_dev(NULL, ISAPNP_VENDOR('G','I','C'), ISAPNP_FUNCTION(0x1000), idev); /* * No card */ if(idev==NULL) return -ENODEV; /* * Bring it online */ idev->prepare(idev); idev->activate(idev); /* * Ports free ? */ if(!idev->resource[0].start || check_region(idev->resource[0].start, 16)) continue; if(!idev->resource[1].start || check_region(idev->resource[1].start, 16)) continue; serial_number = idev->bus->serial; ioaddr[0]=idev->resource[0].start; ioaddr[1]=idev->resource[1].start; irq = idev->irq_resource[0].start; /* check I/O base and IRQ */ if (dev->base_addr != 0 && dev->base_addr != ioaddr[0]) continue; if (dev->rmem_end != 0 && dev->rmem_end != ioaddr[1]) continue; if (dev->irq != 0 && dev->irq != irq) continue; /* * Ok set it up. */ if (!request_region(ioaddr[0], 16, dev->name)) continue; if (!request_region(ioaddr[1], 16, dev->name)) { release_region(ioaddr[0], 16); continue; } dev->base_addr = ioaddr[0]; /* rmem_end holds the second I/O address - fv */ dev->rmem_end = 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->rmem_end, serial_number, dev->irq); dev = init_etherdev(dev, 0); if (!dev) return -ENOMEM; SET_MODULE_OWNER(dev); /* Make up a SB1000-specific-data structure. */ dev->priv = kmalloc(sizeof(struct sb1000_private), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; memset(dev->priv, 0, sizeof(struct sb1000_private)); if (sb1000_debug > 0) printk(KERN_NOTICE "%s", version); /* The SB1000-specific entries in the device structure. */ dev->open = sb1000_open; dev->do_ioctl = sb1000_dev_ioctl; dev->hard_start_xmit = sb1000_start_xmit; dev->stop = sb1000_close; dev->get_stats = sb1000_stats; /* Fill in the generic fields of the device structure. */ dev->change_mtu = NULL; dev->hard_header = NULL; dev->rebuild_header = NULL; dev->set_mac_address = NULL; dev->header_cache_update= NULL; dev->type = ARPHRD_ETHER; dev->hard_header_len = 0; dev->mtu = 1500; dev->addr_len = ETH_ALEN; /* hardware address is 0:0:serial_number */ dev->dev_addr[0] = 0; dev->dev_addr[1] = 0; 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; dev->tx_queue_len = 0; /* New-style flags. */ dev->flags = IFF_POINTOPOINT|IFF_NOARP; /* Lock resources */ return 0; } }
__initfunc(int 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); 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 (check_region((cs->hw.niccy.isac), 2)) { 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); } else request_region(cs->hw.niccy.isac, 2, "niccy data"); if (check_region((cs->hw.niccy.isac_ale), 2)) { 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 request_region(cs->hw.niccy.isac_ale, 2, "niccy addr"); } else { #if CONFIG_PCI u_char pci_bus, pci_device_fn, pci_irq; u_int pci_ioaddr; cs->subtyp = 0; for (; pci_index < 0xff; pci_index++) { if (pcibios_find_device(PCI_VENDOR_DR_NEUHAUS, PCI_NICCY_ID, pci_index, &pci_bus, &pci_device_fn) == PCIBIOS_SUCCESSFUL) cs->subtyp = NICCY_PCI; else break; /* get IRQ */ pcibios_read_config_byte(pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pci_irq); /* get IO pci AMCC address */ pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_0, &pci_ioaddr); if (!pci_ioaddr) { printk(KERN_WARNING "Niccy: No IO-Adr for PCI cfg found\n"); return(0); } cs->hw.niccy.cfg_reg = pci_ioaddr & ~3 ; /* get IO address */ pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &pci_ioaddr); if (cs->subtyp) break; } if (!cs->subtyp) { printk(KERN_WARNING "Niccy: No PCI card found\n"); return(0); } pci_index++; if (!pci_irq) { printk(KERN_WARNING "Niccy: No IRQ for PCI card found\n"); return(0); } if (!pci_ioaddr) { printk(KERN_WARNING "Niccy: No IO-Adr for PCI card found\n"); return(0); } pci_ioaddr &= ~3; /* remove io/mem flag */ 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; cs->irq = pci_irq; if (check_region((cs->hw.niccy.isac), 4)) { 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); } else request_region(cs->hw.niccy.isac, 4, "niccy"); if (check_region(cs->hw.niccy.cfg_reg, 0x80)) { 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 + 0x80); release_region(cs->hw.niccy.isac, 4); return (0); } else { request_region(cs->hw.niccy.cfg_reg, 0x80, "niccy pci"); } #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); 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; 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); }
static int __init probe_maui(struct address_info *hw_config) { int i; int tmp1, tmp2, ret; if (check_region(hw_config->io_base, 8)) return 0; maui_base = hw_config->io_base; maui_osp = hw_config->osp; if (request_irq(hw_config->irq, mauiintr, 0, "Maui", NULL) < 0) return 0; /* * Initialize the processor if necessary */ if (maui_osLen > 0) { if (!(inb(HOST_STAT_PORT) & STAT_TX_AVAIL) || !maui_write(0x9F) || /* Report firmware version */ !maui_short_wait(STAT_RX_AVAIL) || maui_read() == -1 || maui_read() == -1) if (!maui_init(hw_config->irq)) { free_irq(hw_config->irq, NULL); return 0; } } if (!maui_write(0xCF)) /* Report hardware version */ { printk(KERN_ERR "No WaveFront firmware detected (card uninitialized?)\n"); free_irq(hw_config->irq, NULL); return 0; } if ((tmp1 = maui_read()) == -1 || (tmp2 = maui_read()) == -1) { printk(KERN_ERR "No WaveFront firmware detected (card uninitialized?)\n"); free_irq(hw_config->irq, NULL); return 0; } if (tmp1 == 0xff || tmp2 == 0xff) { free_irq(hw_config->irq, NULL); return 0; } printk(KERN_DEBUG "WaveFront hardware version %d.%d\n", tmp1, tmp2); if (!maui_write(0x9F)) /* Report firmware version */ return 0; if ((tmp1 = maui_read()) == -1 || (tmp2 = maui_read()) == -1) return 0; printk(KERN_DEBUG "WaveFront firmware version %d.%d\n", tmp1, tmp2); if (!maui_write(0x85)) /* Report free DRAM */ return 0; tmp1 = 0; for (i = 0; i < 4; i++) { tmp1 |= maui_read() << (7 * i); } printk(KERN_DEBUG "Available DRAM %dk\n", tmp1 / 1024); for (i = 0; i < 1000; i++) if (probe_mpu401(hw_config)) break; ret = probe_mpu401(hw_config); if (ret) request_region(hw_config->io_base + 2, 6, "Maui"); return ret; }
void ahc_linux_eisa_init(void) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) struct eisa_device_id *eid; struct aic7770_identity *id; int i; if (aic7xxx_probe_eisa_vl == 0) return; /* * Linux requires the EISA IDs to be specified in * the EISA ID string format. Perform the conversion * and setup a table with a NUL terminal entry. */ aic7770_driver.id_table = malloc(sizeof(struct eisa_device_id) * (ahc_num_aic7770_devs + 1), M_DEVBUF, M_NOWAIT); if (aic7770_driver.id_table == NULL) return; for (eid = (struct eisa_device_id *)aic7770_driver.id_table, id = aic7770_ident_table, i = 0; i < ahc_num_aic7770_devs; eid++, id++, i++) { sprintf(eid->sig, "%c%c%c%03X%01X", EISA_MFCTR_CHAR0(id->full_id), EISA_MFCTR_CHAR1(id->full_id), EISA_MFCTR_CHAR2(id->full_id), EISA_PRODUCT_ID(id->full_id), EISA_REVISION_ID(id->full_id)); eid->driver_data = i; } eid->sig[0] = 0; eisa_driver_register(&aic7770_driver); #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */ struct aic7770_identity *entry; u_int slot; u_int eisaBase; u_int i; if (aic7xxx_probe_eisa_vl == 0) return; eisaBase = 0x1000 + AHC_EISA_SLOT_OFFSET; for (slot = 1; slot < NUMSLOTS; eisaBase+=0x1000, slot++) { uint32_t eisa_id; size_t id_size; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) if (check_region(eisaBase, AHC_EISA_IOSIZE) != 0) continue; request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx"); #else if (request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx") == 0) continue; #endif eisa_id = 0; id_size = sizeof(eisa_id); for (i = 0; i < 4; i++) { /* VLcards require priming*/ outb(0x80 + i, eisaBase + IDOFFSET); eisa_id |= inb(eisaBase + IDOFFSET + i) << ((id_size-i-1) * 8); } release_region(eisaBase, AHC_EISA_IOSIZE); if (eisa_id & 0x80000000) continue; /* no EISA card in slot */ entry = aic7770_find_device(eisa_id); if (entry != NULL) aic7770_linux_config(entry, NULL, eisaBase); } #endif }
int __init ltpc_probe(struct net_device *dev) { int err; int x=0,y=0; int timeout; int autoirq; unsigned long flags; unsigned long f; SET_MODULE_OWNER(dev); save_flags(flags); /* probe for the I/O port address */ if (io != 0x240 && !check_region(0x220,8)) { x = inb_p(0x220+6); if ( (x!=0xff) && (x>=0xf0) ) io = 0x220; } if (io != 0x220 && !check_region(0x240,8)) { y = inb_p(0x240+6); if ( (y!=0xff) && (y>=0xf0) ) io = 0x240; } if(io) { /* found it, now grab it */ request_region(io,8,"ltpc"); } else { /* give up in despair */ printk ("LocalTalk card not found; 220 = %02x, 240 = %02x.\n", x,y); restore_flags(flags); return -1; } /* probe for the IRQ line */ if (irq < 2) { autoirq_setup(2); /* reset the interrupt line */ inb_p(io+7); inb_p(io+7); /* trigger an interrupt (I hope) */ inb_p(io+6); autoirq = autoirq_report(1); if (autoirq == 0) { printk("ltpc: probe at %#x failed to detect IRQ line.\n", io); } else { irq = autoirq; } } /* allocate a DMA buffer */ ltdmabuf = (unsigned char *) dma_mem_alloc(1000); if (ltdmabuf) ltdmacbuf = <dmabuf[800]; if (!ltdmabuf) { printk("ltpc: mem alloc failed\n"); restore_flags(flags); return(-1); } if(debug&DEBUG_VERBOSE) { printk("ltdmabuf pointer %08lx\n",(unsigned long) ltdmabuf); } /* reset the card */ inb_p(io+1); inb_p(io+3); timeout = jiffies+2*HZ/100; while(time_before(jiffies, timeout)) ; /* hold it in reset for a coupla jiffies */ inb_p(io+0); inb_p(io+2); inb_p(io+7); /* clear reset */ inb_p(io+4); inb_p(io+5); inb_p(io+5); /* enable dma */ inb_p(io+6); /* tri-state interrupt line */ timeout = jiffies+100*HZ/100; while(time_before(jiffies, timeout)) { /* wait for the card to complete initialization */ } /* now, figure out which dma channel we're using, unless it's already been specified */ /* well, 0 is a legal DMA channel, but the LTPC card doesn't use it... */ if (dma == 0) { dma = ltpc_probe_dma(io); if (!dma) { /* no dma channel */ printk("No DMA channel found on ltpc card.\n"); restore_flags(flags); return -1; } } /* print out friendly message */ if(irq) printk("Apple/Farallon LocalTalk-PC card at %03x, IR%d, DMA%d.\n",io,irq,dma); else printk("Apple/Farallon LocalTalk-PC card at %03x, DMA%d. Using polled mode.\n",io,dma); /* seems more logical to do this *after* probing the card... */ err = ltpc_init(dev); if (err) return err; dev->base_addr = io; dev->irq = irq; dev->dma = dma; /* the card will want to send a result at this point */ /* (I think... leaving out this part makes the kernel crash, so I put it back in...) */ f=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma,DMA_MODE_READ); set_dma_addr(dma,virt_to_bus(ltdmabuf)); set_dma_count(dma,0x100); enable_dma(dma); release_dma_lock(f); (void) inb_p(io+3); (void) inb_p(io+2); timeout = jiffies+100*HZ/100; while(time_before(jiffies, timeout)) { if( 0xf9 == inb_p(io+6)) break; } if(debug&DEBUG_VERBOSE) { printk("setting up timer and irq\n"); } if (irq) { /* grab it and don't let go :-) */ (void) request_irq( irq, <pc_interrupt, 0, "ltpc", dev); (void) inb_p(io+7); /* enable interrupts from board */ (void) inb_p(io+7); /* and reset irq line */ } else { /* polled mode -- 20 times per second */ /* this is really, really slow... should it poll more often? */ init_timer(<pc_timer); ltpc_timer.function=ltpc_poll; ltpc_timer.data = (unsigned long) dev; ltpc_timer.expires = jiffies + 5; add_timer(<pc_timer); restore_flags(flags); } return 0; }
int rtl8139_probe(struct device *dev) { int cards_found = 0; int pci_index = 0; unsigned char pci_bus, pci_device_fn; if ( ! pcibios_present()) return -ENODEV; for (; pci_index < 0xff; pci_index++) { u16 vendor, device, pci_command, new_command; int chip_idx, irq; long ioaddr; if (pcibios_find_class (PCI_CLASS_NETWORK_ETHERNET << 8, pci_index, &pci_bus, &pci_device_fn) != PCIBIOS_SUCCESSFUL) break; pcibios_read_config_word(pci_bus, pci_device_fn, PCI_VENDOR_ID, &vendor); pcibios_read_config_word(pci_bus, pci_device_fn, PCI_DEVICE_ID, &device); for (chip_idx = 0; pci_tbl[chip_idx].vendor_id; chip_idx++) if (vendor == pci_tbl[chip_idx].vendor_id && (device & pci_tbl[chip_idx].device_id_mask) == pci_tbl[chip_idx].device_id) break; if (pci_tbl[chip_idx].vendor_id == 0) /* Compiled out! */ continue; { #if defined(PCI_SUPPORT_VER2) struct pci_dev *pdev = pci_find_slot(pci_bus, pci_device_fn); ioaddr = pdev->base_address[0] & ~3; irq = pdev->irq; #else u32 pci_ioaddr; u8 pci_irq_line; pcibios_read_config_byte(pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pci_irq_line); pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_0, &pci_ioaddr); ioaddr = pci_ioaddr & ~3; irq = pci_irq_line; #endif } if ((pci_tbl[chip_idx].flags & PCI_USES_IO) && check_region(ioaddr, pci_tbl[chip_idx].io_size)) continue; /* Activate the card: fix for brain-damaged Win98 BIOSes. */ pcibios_read_config_word(pci_bus, pci_device_fn, PCI_COMMAND, &pci_command); new_command = pci_command | (pci_tbl[chip_idx].flags & 7); if (pci_command != new_command) { printk(KERN_INFO " The PCI BIOS has not enabled the" " device at %d/%d! Updating PCI command %4.4x->%4.4x.\n", pci_bus, pci_device_fn, pci_command, new_command); pcibios_write_config_word(pci_bus, pci_device_fn, PCI_COMMAND, new_command); } dev = pci_tbl[chip_idx].probe1(pci_bus, pci_device_fn, dev, ioaddr, irq, chip_idx, cards_found); if (dev && (pci_tbl[chip_idx].flags & PCI_COMMAND_MASTER)) { u8 pci_latency; pcibios_read_config_byte(pci_bus, pci_device_fn, PCI_LATENCY_TIMER, &pci_latency); if (pci_latency < 32) { printk(KERN_NOTICE " PCI latency timer (CFLT) is " "unreasonably low at %d. Setting to 64 clocks.\n", pci_latency); pcibios_write_config_byte(pci_bus, pci_device_fn, PCI_LATENCY_TIMER, 64); } } dev = 0; cards_found++; } return cards_found ? 0 : -ENODEV; }
/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */ int i2c_detect(struct i2c_adapter *adapter, struct i2c_address_data *address_data, i2c_found_addr_proc * found_proc) { int addr, i, found, j, err; struct i2c_force_data *this_force; int is_isa = i2c_is_isa_adapter(adapter); int adapter_id = is_isa ? SENSORS_ISA_BUS : i2c_adapter_id(adapter); /* Forget it if we can't probe using SMBUS_QUICK */ if ((!is_isa) && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) return -1; for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { if ((is_isa && check_region(addr, 1)) || (!is_isa && i2c_check_addr(adapter, addr))) continue; /* If it is in one of the force entries, we don't do any detection at all */ found = 0; for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) { for (j = 0; !found && (this_force->force[j] != SENSORS_I2C_END); j += 2) { if ( ((adapter_id == this_force->force[j]) || ((this_force-> force[j] == SENSORS_ANY_I2C_BUS) && !is_isa)) && (addr == this_force->force[j + 1])) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found force parameter for adapter %d, addr %04x\n", adapter_id, addr); #endif if ( (err = found_proc(adapter, addr, 0, this_force-> kind))) return err; found = 1; } } } if (found) continue; /* If this address is in one of the ignores, we can forget about it right now */ for (i = 0; !found && (address_data->ignore[i] != SENSORS_I2C_END); i += 2) { if ( ((adapter_id == address_data->ignore[i]) || ((address_data-> ignore[i] == SENSORS_ANY_I2C_BUS) && !is_isa)) && (addr == address_data->ignore[i + 1])) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found ignore parameter for adapter %d, " "addr %04x\n", adapter_id, addr); #endif found = 1; } } for (i = 0; !found && (address_data->ignore_range[i] != SENSORS_I2C_END); i += 3) { if ( ((adapter_id == address_data->ignore_range[i]) || ((address_data-> ignore_range[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) && (addr >= address_data->ignore_range[i + 1]) && (addr <= address_data->ignore_range[i + 2])) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found ignore_range parameter for adapter %d, " "addr %04x\n", adapter_id, addr); #endif found = 1; } } if (found) continue; /* Now, we will do a detection, but only if it is in the normal or probe entries */ if (is_isa) { for (i = 0; !found && (address_data->normal_isa[i] != SENSORS_ISA_END); i += 1) { if (addr == address_data->normal_isa[i]) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found normal isa entry for adapter %d, " "addr %04x\n", adapter_id, addr); #endif found = 1; } } for (i = 0; !found && (address_data->normal_isa_range[i] != SENSORS_ISA_END); i += 3) { if ((addr >= address_data->normal_isa_range[i]) && (addr <= address_data->normal_isa_range[i + 1]) && ((addr - address_data->normal_isa_range[i]) % address_data->normal_isa_range[i + 2] == 0)) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found normal isa_range entry for adapter %d, " "addr %04x", adapter_id, addr); #endif found = 1; } } } else { for (i = 0; !found && (address_data->normal_i2c[i] != SENSORS_I2C_END); i += 1) { if (addr == address_data->normal_i2c[i]) { found = 1; #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found normal i2c entry for adapter %d, " "addr %02x", adapter_id, addr); #endif } } for (i = 0; !found && (address_data->normal_i2c_range[i] != SENSORS_I2C_END); i += 2) { if ((addr >= address_data->normal_i2c_range[i]) && (addr <= address_data->normal_i2c_range[i + 1])) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found normal i2c_range entry for adapter %d, " "addr %04x\n", adapter_id, addr); #endif found = 1; } } } for (i = 0; !found && (address_data->probe[i] != SENSORS_I2C_END); i += 2) { if (((adapter_id == address_data->probe[i]) || ((address_data-> probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) && (addr == address_data->probe[i + 1])) { #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found probe parameter for adapter %d, " "addr %04x\n", adapter_id, addr); #endif found = 1; } } for (i = 0; !found && (address_data->probe_range[i] != SENSORS_I2C_END); i += 3) { if ( ((adapter_id == address_data->probe_range[i]) || ((address_data->probe_range[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) && (addr >= address_data->probe_range[i + 1]) && (addr <= address_data->probe_range[i + 2])) { found = 1; #ifdef DEBUG printk (KERN_DEBUG "i2c-proc.o: found probe_range parameter for adapter %d, " "addr %04x\n", adapter_id, addr); #endif } } if (!found) continue; /* OK, so we really should examine this address. First check whether there is some client here at all! */ if (is_isa || (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0)) if ((err = found_proc(adapter, addr, 0, -1))) return err; } return 0; }
/* It is called at boot time AND for module init. */ int __init my_gscd_init (void) { int i; int result; printk (KERN_INFO "GSCD: version %s\n", GSCD_VERSION); printk (KERN_INFO "GSCD: Trying to detect a Goldstar R420 CD-ROM drive at 0x%X.\n", gscd_port); if (check_region(gscd_port, 4)) { printk("GSCD: Init failed, I/O port (%X) already in use.\n", gscd_port); return -EIO; } /* check for card */ result = wait_drv_ready (); if ( result == 0x09 ) { printk ("GSCD: DMA kann ich noch nicht!\n" ); return -EIO; } if ( result == 0x0b ) { drv_mode = result; i = find_drives (); if ( i == 0 ) { printk ( "GSCD: GoldStar CD-ROM Drive is not found.\n" ); return -EIO; } } if ( (result != 0x0b) && (result != 0x09) ) { printk ("GSCD: GoldStar Interface Adapter does not exist or H/W error\n" ); return -EIO; } /* reset all drives */ i = 0; while ( drv_states[i] != 0 ) { curr_drv_state = drv_states[i]; printk (KERN_INFO "GSCD: Reset unit %d ... ",i ); cc_Reset (); printk ( "done\n" ); i++; } if (devfs_register_blkdev(MAJOR_NR, "gscd", &gscd_fops) != 0) { printk("GSCD: Unable to get major %d for GoldStar CD-ROM\n", MAJOR_NR); return -EIO; } devfs_register (NULL, "gscd", DEVFS_FL_DEFAULT, MAJOR_NR, 0, S_IFBLK | S_IRUGO | S_IWUGO, &gscd_fops, NULL); blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST); blksize_size[MAJOR_NR] = gscd_blocksizes; read_ahead[MAJOR_NR] = 4; disk_state = 0; gscdPresent = 1; request_region(gscd_port, 4, "gscd"); register_disk(NULL, MKDEV(MAJOR_NR,0), 1, &gscd_fops, 0); printk (KERN_INFO "GSCD: GoldStar CD-ROM Drive found.\n" ); return 0; }