예제 #1
0
int __init
init_nm256(void)
{
    struct pci_dev *pcidev = NULL;
    int count = 0;

    if(! pci_present())
	return -ENODEV;

    while((pcidev = pci_find_device(PCI_VENDOR_ID_NEOMAGIC,
				    PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO,
				    pcidev)) != NULL) {
	count += nm256_install(pcidev, REV_NM256AV, "256AV");
    }

    while((pcidev = pci_find_device(PCI_VENDOR_ID_NEOMAGIC,
				    PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO,
				    pcidev)) != NULL) {
	count += nm256_install(pcidev, REV_NM256ZX, "256ZX");
    }

    if (count == 0)
	return -ENODEV;

    printk (KERN_INFO "Done installing NM256 audio driver.\n");
    return 0;
}
예제 #2
0
static int __init
hysdn_init(void)
{
	char tmp[50];

	strcpy(tmp, hysdn_init_revision);
	printk(KERN_NOTICE "HYSDN: module Rev: %s loaded\n", hysdn_getrev(tmp));
	strcpy(tmp, hysdn_net_revision);
	printk(KERN_NOTICE "HYSDN: network interface Rev: %s \n", hysdn_getrev(tmp));
	if (!pci_present()) {
		printk(KERN_ERR "HYSDN: no PCI bus present, module not loaded\n");
		return (-1);
	}
	search_cards();
	printk(KERN_INFO "HYSDN: %d card(s) found.\n", cardmax);

	if (hysdn_procconf_init()) {
		free_resources();	/* proc file_sys not created */
		return (-1);
	}
#ifdef CONFIG_HYSDN_CAPI
	if(cardmax > 0) {
		if(hycapi_init()) {
			printk(KERN_ERR "HYCAPI: init failed\n");
			return(-1);
		}
	}
#endif /* CONFIG_HYSDN_CAPI */
	return (0);		/* no error */
}				/* init_module */
예제 #3
0
/* Locate SiS bridge and correct base address for SIS5595 */
int sis5595_find_sis(int *address)
{
	u16 val;
	int *i;

	if (!pci_present())
		return -ENODEV;

	if (!(s_bridge =
	      pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503,
			     NULL)))
		return -ENODEV;

	/* Look for imposters */
	for(i = blacklist; *i != 0; i++) {
		if (pci_find_device(PCI_VENDOR_ID_SI, *i, NULL)) {
			printk("sis5595.o: Error: Looked for SIS5595 but found unsupported device %.4X\n", *i);
			return -ENODEV;
		}
	}

	if (PCIBIOS_SUCCESSFUL !=
	    pci_read_config_word(s_bridge, SIS5595_BASE_REG, &val))
		return -ENODEV;

	*address = val & ~(SIS5595_EXTENT - 1);
	if (*address == 0 && force_addr == 0) {
		printk("sis5595.o: base address not set - upgrade BIOS or use force_addr=0xaddr\n");
		return -ENODEV;
	}
	if (force_addr)
		*address = force_addr;	/* so detect will get called */

	return 0;
}
예제 #4
0
static __init int bios_init(void)
{
	printk(KERN_INFO "BIOS driver v" BIOS_VERSION " (writing %s) for "
			UTS_RELEASE "\n", write?"enabled":"disabled");

#if !defined(UTC_BIOS) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
	if (!pci_present()) {
		printk(KERN_WARNING "BIOS: No PCI system.");
		return -EBUSY;
	}
#endif

	/* Probe for flash devices */
	probe_system();

	if (flashcount==0) {
		printk(KERN_WARNING "BIOS: No flash devices found.\n");
		return -EBUSY;
	}

	if (register_chrdev(BIOS_MAJOR, "bios",  &bios_fops) == -EBUSY) {
		printk(KERN_WARNING "BIOS: Could not register bios device.\n");
		free_iomaps();
		return -EBUSY;
	}

#ifdef CONFIG_PROC_FS
	bios_proc_register();
#endif
	return 0;
}
예제 #5
0
static int __init emu10k1_init_module(void)
{
	struct pci_dev *dev = NULL;
	const struct pci_device_id *pci_id = emu10k1_pci_driver.id_table;

	printk(KERN_INFO "Creative EMU10K1 PCI Audio Driver, version " DRIVER_VERSION ", " __TIME__ " " __DATE__ "\n");

	if (!pci_present())
		return -ENODEV;

	while (pci_id->vendor) {
		while ((dev = pci_find_device(pci_id->vendor, pci_id->device, dev)))
			emu10k1_probe(dev, pci_id);

		pci_id++;
	}
	return 0;
}
예제 #6
0
/* walk through every ethernet PCI devices to see if some of them are matched with our card list*/
int sis900_probe (struct device * net_dev)
{
	int found = 0;
	struct pci_dev * pci_dev = NULL;
		
	if (!pci_present())
		return -ENODEV;
		
	while ((pci_dev = pci_find_class (PCI_CLASS_NETWORK_ETHERNET << 8, pci_dev)) != NULL) {
		/* pci_dev contains all ethernet devices */
		u32 pci_io_base;
		struct mac_chip_info * mac;

		for (mac = mac_chip_table; mac->vendor_id; mac++) {
			/* try to match our card list */
			if (pci_dev->vendor == mac->vendor_id &&
			    pci_dev->device == mac->device_id)
				break;
		}
		
		if (mac->vendor_id == 0)
			/* pci_dev does not match any of our cards */
			continue;
		
		/* now, pci_dev should be either 900 or 7016 */
		pci_io_base = pci_dev->base_address[0] & PCI_BASE_ADDRESS_IO_MASK;
		if ((mac->flags & PCI_COMMAND_IO ) && 
		    check_region(pci_io_base, mac->io_size))
			continue;
		
		/* setup various bits in PCI command register */
		pci_set_master(pci_dev);

		/* do the real low level jobs */
		net_dev = mac->probe(mac, pci_dev, net_dev);
		
		if (net_dev != NULL) {
			found++;
		}
		net_dev = NULL;
	}
	return found ? 0 : -ENODEV;
}
예제 #7
0
/* When exactly was the new pci interface introduced? */
static int find_via(void)
{
	struct pci_dev *s_bridge;
	u16 base;
	u8 rev;

	if (!pci_present())
		return -ENODEV;

	s_bridge = pci_find_device(VENDOR, DEVICE, NULL);

	if (!s_bridge) {
		printk("i2c-via.o: vt82c586b not found\n");
		return -ENODEV;
	}

	if (PCIBIOS_SUCCESSFUL !=
	    pci_read_config_byte(s_bridge, PM_CFG_REVID, &rev))
		return -ENODEV;

	switch (rev) {
	case 0x00:
		base = PM_CFG_IOBASE0;
		break;
	case 0x01:
	case 0x10:
		base = PM_CFG_IOBASE1;
		break;

	default:
		base = PM_CFG_IOBASE1;
		/* later revision */
	}

	if (PCIBIOS_SUCCESSFUL !=
	    pci_read_config_word(s_bridge, base, &pm_io_base))
		    return -ENODEV;

	pm_io_base &= (0xff << 8);
	return 0;
}
예제 #8
0
static int find_hydra(void)
{
	struct pci_dev *dev;
	unsigned int base_addr;

	if (!pci_present())
		return -ENODEV;

	dev = pci_find_device(VENDOR, DEVICE, NULL);
	if (!dev) {
		printk("Hydra not found\n");
		return -ENODEV;
	}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
	base_addr = dev->resource[0].start;
#else
	base_addr = dev->base_address[0];
#endif
	hydra_base = (unsigned long) ioremap(base_addr, 0x100);

	return 0;
}
예제 #9
0
/*
   Search DM910X board ,allocate space and register it
 */
int dmfe_probe(struct device *dev)
{
	unsigned long pci_iobase;
	u16 dm9102_count = 0;
	u8 pci_irqline;
	static int index = 0;	/* For multiple call */
	struct dmfe_board_info *db;	/* Point a board information structure */
	int i;
	struct pci_dev *net_dev = NULL;

	DMFE_DBUG(0, "dmfe_probe()", 0);

	if (!pci_present())
		return -ENODEV;

	index = 0;
	while ((net_dev = pci_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, net_dev)))
	{
		u32 pci_id;
		u32 dev_rev;
		u8 pci_cmd;

		index++;
		if (pci_read_config_dword(net_dev, PCI_VENDOR_ID, &pci_id) != DMFE_SUCC)
			continue;

		if ((pci_id != PCI_DM9102_ID) && (pci_id != PCI_DM9132_ID))
			continue;

		/* read PCI IO base address and IRQ to check */
		pci_iobase = net_dev->base_address[0];
		pci_irqline = net_dev->irq;
		pci_iobase &= ~0x7f;	/* mask off bit0~6 */

		/* Enable Master/IO access, Disable memory access */
		pci_read_config_byte(net_dev, PCI_COMMAND, &pci_cmd);
		pci_cmd |= PCI_COMMAND_IO + PCI_COMMAND_MASTER;
		pci_cmd &= ~PCI_COMMAND_MEMORY;
		pci_write_config_byte(net_dev, PCI_COMMAND, pci_cmd);

		/* Set Latency Timer 80h */
		pci_write_config_byte(net_dev, PCI_LATENCY_TIMER, 0x80);

		/* Read Chip revesion */
		pci_read_config_dword(net_dev, PCI_REVISION_ID, &dev_rev);

		/* IO range check */
		if (check_region(pci_iobase, CHK_IO_SIZE(pci_id, dev_rev))) 
			continue;

		/* Interrupt check */
		if (pci_irqline == 0) {
			printk(KERN_ERR "dmfe: Interrupt wrong : IRQ=%d\n", pci_irqline);
			continue;
		}
		/* Found DM9102 card and PCI resource allocated OK */
		dm9102_count++;	/* Found a DM9102 card */

		/* Init network device */
		dev = init_etherdev(dev, 0);

		/* Allocated board information structure */
		db = (void *) (kmalloc(sizeof(*db), GFP_KERNEL | GFP_DMA));
		memset(db, 0, sizeof(*db));
		dev->priv = db;	/* link device and board info */
		db->next_dev = dmfe_root_dev;
		dmfe_root_dev = dev;

		db->chip_id = pci_id;	/* keep Chip vandor/Device ID */
		db->ioaddr = pci_iobase;
		db->chip_revesion = dev_rev;

		db->net_dev = net_dev;

		dev->base_addr = pci_iobase;
		dev->irq = pci_irqline;
		dev->open = &dmfe_open;
		dev->hard_start_xmit = &dmfe_start_xmit;
		dev->stop = &dmfe_stop;
		dev->get_stats = &dmfe_get_stats;
		dev->set_multicast_list = &dmfe_set_filter_mode;
		dev->do_ioctl = &dmfe_do_ioctl;

		request_region(pci_iobase, CHK_IO_SIZE(pci_id, dev_rev), dev->name);

		/* read 64 word srom data */
		for (i = 0; i < 64; i++)
			((u16 *) db->srom)[i] = read_srom_word(pci_iobase, i);

		/* Set Node address */
		for (i = 0; i < 6; i++)
			dev->dev_addr[i] = db->srom[20 + i];

		dev = 0;	/* NULL device */
	}
	return dm9102_count ? 0 : -ENODEV;
}
예제 #10
0
int _open_PLX9052(int *pci_handle, unsigned int *mmap_io_ptr, int *interrupt_line, int print){
#ifdef __QNX__
	volatile unsigned char	*BASE0, *BASE1;
	unsigned		flags, lastbus, version, hardware, bus, device;
	int			temp;
	unsigned		pci_index=0;
	struct			_pci_config_regs pci_reg;

    /* CONNECT TO PCI SERVER */
	*pci_handle=pci_attach(flags);
	if (*pci_handle == -1){
		perror("Cannot attach to PCI system");
		return -1;
	}

    /* CHECK FOR PCI BUS */
	temp=pci_present(&lastbus, &version, &hardware);
	if(temp != PCI_SUCCESS){
		perror("Cannot find PCI BIOS");
		return -1;
	}

    /* FIND DEVICE */
	temp=pci_find_device(DEVICE_ID, VENDOR_ID, pci_index, &bus, &device);
	if(temp != PCI_SUCCESS){
		perror("Cannot find GC314-PCI/FS Digital Receiver Card");
		return -1;
	}
	
    /* READ THE DEVICE PCI CONFIGURATION */
	temp=pci_read_config32(bus, device, 0, 16, (char *)&pci_reg);
	if(temp != PCI_SUCCESS){
		perror("Cannot read from configuration space of the GC314 PCI/FS digital receiver card");
		return -1;
	}
	BASEIO=(int)pci_reg.Base_Address_Regs[1]-1;

    /* ALLOW I/O ACCESS ON THIS THREAD */
	temp=ThreadCtl(_NTO_TCTL_IO,0);
	if (temp==-1){
		perror("Unable to attach I/O privileges to thread");
		return -1;
	}

    /* MAP THE IO SPACE TO BE ABLE TO R/W TO PCI IO */
	*mmap_io_ptr=(unsigned int *)mmap_device_io(16, pci_reg.Base_Address_Regs[2]);
	if ((int)mmap_io_ptr == MAP_DEVICE_FAILED){
		perror("Device I/O mapping failed");
		return -1;
	}

    /* TRY TO MEMORY MAP TO THE DEVICE REGISTER SPACE */
	//BASE0=mmap_device_memory(0, 256, PROT_EXEC|PROT_READ|PROT_WRITE|PROT_NOCACHE, 0, pci_reg.Base_Address_Regs[0]);
	//BASE1=mmap_device_memory(0, 1048576, PROT_EXEC|PROT_READ|PROT_WRITE|PROT_NOCACHE, 0, pci_reg.Base_Address_Regs[2]);
	//if ((BASE0 == MAP_FAILED) | (BASE1 == MAP_FAILED)){
	//	perror("Device Memory mapping failed");
	//	return -1;
	//}

    /* TRY TO READ PCI DEVICE PARAMETERS */
	//pci_write_config16(bus, device, PLX9656_PCIICR, 1, &vPLX9656_PCIICR);

	//*((uint16*)(BASE0+PLX9656_BIGEND))=vPLX9656_BIGEND;
	//*((uint16*)(BASE0+PLX9656_BIGEND))=0;
	//*((uint32*)(BASE0+0x4c))=0x48;
	//temp=*((uint32*)(BASE0+0x4c));
	//printf(" INTCSR is %x\n",temp);
	//temp=in32(BASEIO+0x4c);
	//printf(" INTCSR is %x\n",temp);
	//*BASEA=(int)mmap_io_ptr;
	//*BASEB=0;
	*interrupt_line=pci_reg.Interrupt_Line;

    /* PRINT PLX9656 PARAMETERS */
	if (print == 1){
		printf("	PCI DEVICE PARAMETERS:\n");
		printf("	  lastbus=		%d\n", lastbus);
		printf("	  version=		%d\n", version);
		printf("	  hardware=		%d\n", hardware);
		printf("	  bus=			%d\n", bus);
		printf("	  device=		%d\n", device);
		printf("	MEMORY ALLOCATION:\n");
		printf("	  IO Base0=		0x%x\n", pci_reg.Base_Address_Regs[0]);
		printf("	  IO Base1=		0x%x\n", pci_reg.Base_Address_Regs[1]);
		printf("	  IO Base2=		0x%x\n", pci_reg.Base_Address_Regs[2]);
	}

	*mmap_io_ptr=pci_reg.Base_Address_Regs[2]-1;
	return 1;
#else
 return 1;
#endif
}
예제 #11
0
파일: diva.c 프로젝트: nhanh0/hah
int __init
setup_diva(struct IsdnCard *card)
{
	int bytecnt;
	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];
		bytecnt = 8;
	} else {
#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 {
			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->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;
		}
	}

	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" : "IPAC PCI",
		cs->hw.diva.cfg_reg, cs->irq);
	if ((cs->subtyp == DIVA_IPAC_PCI) || (cs->subtyp == DIVA_PCI))
		printk(KERN_INFO "Diva: %s PCI space at %#lx\n",
			(cs->subtyp == DIVA_PCI) ? "PCI" : "IPAC PCI",
			cs->hw.diva.pci_cfg);
	if (cs->subtyp != DIVA_IPAC_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 { /* 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);
}
예제 #12
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);
}
예제 #13
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;
}
예제 #14
0
__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 
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);
}
예제 #16
0
void __init ebus_init(void)
{
	struct pci_pbm_info *pbm;
	struct linux_ebus_device *dev;
	struct linux_ebus *ebus;
	struct pci_dev *pdev;
	struct pcidev_cookie *cookie;
	int nd, ebusnd;
	int num_ebus = 0;

	if (!pci_present())
		return;

	pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, 0);
	if (!pdev) {
		printk("ebus: No EBus's found.\n");
		return;
	}

	cookie = pdev->sysdata;
	ebusnd = cookie->prom_node;

	ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
	ebus->next = 0;

	while (ebusnd) {
		/* SUNW,pci-qfe uses four empty ebuses on it.
		   I think we should not consider them here,
		   as they have half of the properties this
		   code expects and once we do PCI hot-plug,
		   we'd have to tweak with the ebus_chain
		   in the runtime after initialization. -jj */
		if (!prom_getchild (ebusnd)) {
			pdev = pci_find_device(PCI_VENDOR_ID_SUN, 
					       PCI_DEVICE_ID_SUN_EBUS, pdev);
			if (!pdev) {
				if (ebus == ebus_chain) {
					ebus_chain = NULL;
					printk("ebus: No EBus's found.\n");
					return;
				}
				break;
			}
			
			cookie = pdev->sysdata;
			ebusnd = cookie->prom_node;
			continue;
		}
		printk("ebus%d:", num_ebus);

		prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name));
		ebus->index = num_ebus;
		ebus->prom_node = ebusnd;
		ebus->self = pdev;
		ebus->parent = pbm = cookie->pbm;

		ebus_ranges_init(ebus);
		ebus_intmap_init(ebus);

		nd = prom_getchild(ebusnd);
		if (!nd)
			goto next_ebus;

		ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));

		dev = ebus->devices;
		dev->next = 0;
		dev->children = 0;
		dev->bus = ebus;
		fill_ebus_device(nd, dev);

		while ((nd = prom_getsibling(nd))) {
			dev->next = ebus_alloc(sizeof(struct linux_ebus_device));

			dev = dev->next;
			dev->next = 0;
			dev->children = 0;
			dev->bus = ebus;
			fill_ebus_device(nd, dev);
		}

	next_ebus:
		printk("\n");

		pdev = pci_find_device(PCI_VENDOR_ID_SUN,
				       PCI_DEVICE_ID_SUN_EBUS, pdev);
		if (!pdev)
			break;

		cookie = pdev->sysdata;
		ebusnd = cookie->prom_node;

		ebus->next = ebus_alloc(sizeof(struct linux_ebus));
		ebus = ebus->next;
		ebus->next = 0;
		++num_ebus;
	}

#ifdef CONFIG_SUN_AUXIO
	auxio_probe();
#endif
	clock_probe();
	power_init();
}
예제 #17
0
int __init
setup_niccy(struct IsdnCard *card)
{
	struct IsdnCardState *cs = card->cs;
	char tmp[64];

	strcpy(tmp, niccy_revision);
	printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ != ISDN_CTYPE_NICCY)
		return (0);
#ifdef __ISAPNP__
	if (!card->para[1] && isapnp_present()) {
		struct pci_bus *pb;
		struct pci_dev *pd;

		if ((pb = isapnp_find_card(
			ISAPNP_VENDOR('S', 'D', 'A'),
			ISAPNP_FUNCTION(0x0150), pnp_c))) {
			pnp_c = pb;
			pd = NULL;
			if (!(pd = isapnp_find_dev(pnp_c,
				ISAPNP_VENDOR('S', 'D', 'A'),
				ISAPNP_FUNCTION(0x0150), pd))) {
				printk(KERN_ERR "NiccyPnP: PnP error card found, no device\n");
				return (0);
			}
			pd->prepare(pd);
			pd->deactivate(pd);
			pd->activate(pd);
			card->para[1] = pd->resource[0].start;
			card->para[2] = pd->resource[1].start;
			card->para[0] = pd->irq_resource[0].start;
			if (!card->para[0] || !card->para[1] || !card->para[2]) {
				printk(KERN_ERR "NiccyPnP:some resources are missing %ld/%lx/%lx\n",
					card->para[0], card->para[1], card->para[2]);
				pd->deactivate(pd);
				return(0);
			}
		} else {
			printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n");
		}
	}
#endif
	if (card->para[1]) {
		cs->hw.niccy.isac = card->para[1] + ISAC_PNP;
		cs->hw.niccy.hscx = card->para[1] + HSCX_PNP;
		cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP;
		cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP;
		cs->hw.niccy.cfg_reg = 0;
		cs->subtyp = NICCY_PNP;
		cs->irq = card->para[0];
		if (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_int pci_ioaddr;
		if (!pci_present()) {
			printk(KERN_ERR "Niccy: no PCI bus present\n");
			return(0);
		}
		cs->subtyp = 0;
		if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM,
			PCI_DEVICE_ID_SATSAGEM_NICCY, niccy_dev))) {
			if (pci_enable_device(niccy_dev))
				return(0);
			/* get IRQ */
			if (!niccy_dev->irq) {
				printk(KERN_WARNING "Niccy: No IRQ for PCI card found\n");
				return(0);
			}
			cs->irq = niccy_dev->irq;
			cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0);
			if (!cs->hw.niccy.cfg_reg) {
				printk(KERN_WARNING "Niccy: No IO-Adr for PCI cfg found\n");
				return(0);
			}
			pci_ioaddr = pci_resource_start(niccy_dev, 1);
			if (!pci_ioaddr) {
				printk(KERN_WARNING "Niccy: No IO-Adr for PCI card found\n");
				return(0);
			}
			cs->subtyp = NICCY_PCI;
		} else {
			printk(KERN_WARNING "Niccy: No PCI card found\n");
			return(0);
		}
		cs->irq_flags |= SA_SHIRQ;
		cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA;
		cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR;
		cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA;
		cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
		if (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, 0x40)) {
			printk(KERN_WARNING
			       "HiSax: %s pci port %x-%x already in use\n",
				CardType[card->typ],
				cs->hw.niccy.cfg_reg,
				cs->hw.niccy.cfg_reg + 0x40);
			release_region(cs->hw.niccy.isac, 4);
			return (0);
		} else {
			request_region(cs->hw.niccy.cfg_reg, 0x40, "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;
	cs->irq_func = &niccy_interrupt;
	ISACVersion(cs, "Niccy:");
	if (HscxVersion(cs, "Niccy:")) {
		printk(KERN_WARNING
		    "Niccy: wrong HSCX versions check IO address\n");
		release_io_niccy(cs);
		return (0);
	}
	return (1);
}
예제 #18
0
__initfunc(int
	   setup_sct_quadro(struct IsdnCard *card))
{
	struct IsdnCardState *cs = card->cs;
	char tmp[64];
#if CONFIG_PCI
	u_char pci_bus = 0, pci_device_fn = 0, pci_irq = 0, pci_rev_id;
	u_int found = 0;
	u_int pci_ioaddr1, pci_ioaddr2, pci_ioaddr3, pci_ioaddr4, pci_ioaddr5;
#endif

	strcpy(tmp, sct_quadro_revision);
	printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ == ISDN_CTYPE_SCT_QUADRO) {
		cs->subtyp = SCT_1;	/* Preset */
	} else
		return (0);

	/* Identify subtype by para[0] */
	if (card->para[0] >= SCT_1 && card->para[0] <= SCT_4)
		cs->subtyp = card->para[0];
	else
		printk(KERN_WARNING "HiSax: %s: Invalid subcontroller in configuration, default to 1\n",
		       CardType[card->typ]);
#if CONFIG_PCI
	if (!pci_present()) {
		printk(KERN_ERR "bkm_a4t: no PCI bus present\n");
		return (0);
	}
	if ((dev_a8 = pci_find_device(PLX_VENDOR_ID, PLX_DEVICE_ID, dev_a8))) {
		u_int sub_sys_id = 0;

		pci_read_config_dword(dev_a8, PCI_SUBSYSTEM_VENDOR_ID,
			&sub_sys_id);
		if (sub_sys_id == ((SCT_SUBSYS_ID << 16) | SCT_SUBVEN_ID)) {
			found = 1;
			pci_ioaddr1 = dev_a8->base_address[ 1];
			pci_irq = dev_a8->irq;
			pci_bus = dev_a8->bus->number;
			pci_device_fn = dev_a8->devfn;
		}
	}
	if (!found) {
		printk(KERN_WARNING "HiSax: %s (%s): Card not found\n",
		       CardType[card->typ],
		       sct_quadro_subtypes[cs->subtyp]);
		return (0);
	}
	if (!pci_irq) {		/* IRQ range check ?? */
		printk(KERN_WARNING "HiSax: %s (%s): No IRQ\n",
		       CardType[card->typ],
		       sct_quadro_subtypes[cs->subtyp]);
		return (0);
	}
#ifdef ATTEMPT_PCI_REMAPPING
/* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */
	pcibios_read_config_byte(pci_bus, pci_device_fn, PCI_REVISION_ID, &pci_rev_id);
	if ((pci_ioaddr1 & 0x80) && (pci_rev_id == 1)) {
		printk(KERN_WARNING "HiSax: %s (%s): PLX rev 1, remapping required!\n",
			CardType[card->typ],
			sct_quadro_subtypes[cs->subtyp]);
		/* Restart PCI negotiation */
		pcibios_write_config_dword(pci_bus, pci_device_fn,
			PCI_BASE_ADDRESS_1, (u_int) - 1);
		/* Move up by 0x80 byte */
		pci_ioaddr1 += 0x80;
		pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK;
		pcibios_write_config_dword(pci_bus, pci_device_fn,
			PCI_BASE_ADDRESS_1, pci_ioaddr1);
		dev_a8->base_address[ 1] = pci_ioaddr1;
	}
/* End HACK */
#endif
	pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &pci_ioaddr1);
	pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_2, &pci_ioaddr2);
	pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_3, &pci_ioaddr3);
	pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_4, &pci_ioaddr4);
	pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_5, &pci_ioaddr5);
	if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) {
		printk(KERN_WARNING "HiSax: %s (%s): No IO base address(es)\n",
		       CardType[card->typ],
		       sct_quadro_subtypes[cs->subtyp]);
		return (0);
	}
	pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK;
	pci_ioaddr2 &= PCI_BASE_ADDRESS_IO_MASK;
	pci_ioaddr3 &= PCI_BASE_ADDRESS_IO_MASK;
	pci_ioaddr4 &= PCI_BASE_ADDRESS_IO_MASK;
	pci_ioaddr5 &= PCI_BASE_ADDRESS_IO_MASK;
	/* Take over */
	cs->irq = pci_irq;
	cs->irq_flags |= SA_SHIRQ;
	/* pci_ioaddr1 is unique to all subdevices */
	/* pci_ioaddr2 is for the fourth subdevice only */
	/* pci_ioaddr3 is for the third subdevice only */
	/* pci_ioaddr4 is for the second subdevice only */
	/* pci_ioaddr5 is for the first subdevice only */
	cs->hw.ax.plx_adr = pci_ioaddr1;
	/* Enter all ipac_base addresses */
	ipac_state[SCT_1].base = pci_ioaddr5 + 0x00;
	ipac_state[SCT_2].base = pci_ioaddr4 + 0x08;
	ipac_state[SCT_3].base = pci_ioaddr3 + 0x10;
	ipac_state[SCT_4].base = pci_ioaddr2 + 0x20;
	/* For isac and hscx control path */
	cs->hw.ax.base = ipac_state[cs->subtyp].base;
	/* For isac and hscx data path */
	cs->hw.ax.data_adr = cs->hw.ax.base + 4;
#else
	printk(KERN_WARNING "HiSax: %s (%s): NO_PCI_BIOS\n",
	       CardType[card->typ],
	       sct_quadro_subtypes[cs->subtyp]);
	printk(KERN_WARNING "HiSax: %s (%s): Unable to configure\n",
	       CardType[card->typ],
	       sct_quadro_subtypes[cs->subtyp]);
	return (0);
#endif				/* CONFIG_PCI */
	printk(KERN_INFO "HiSax: %s (%s) configured at 0x%.4X, 0x%.4X, 0x%.4X and IRQ %d\n",
	       CardType[card->typ],
	       sct_quadro_subtypes[cs->subtyp],
	       cs->hw.ax.plx_adr,
	       cs->hw.ax.base,
	       cs->hw.ax.data_adr,
	       cs->irq);

	test_and_set_bit(HW_IPAC, &cs->HW_Flags);

	/* Disable all currently not active ipacs */
	if (!is_ipac_active(SCT_1))
		set_ipac_active(SCT_1, 0);
	if (!is_ipac_active(SCT_2))
		set_ipac_active(SCT_2, 0);
	if (!is_ipac_active(SCT_3))
		set_ipac_active(SCT_3, 0);
	if (!is_ipac_active(SCT_4))
		set_ipac_active(SCT_4, 0);

	/* Perfom general reset (if possible) */
	reset_bkm(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 = &BKM_card_msg;
	cs->irq_func = &bkm_interrupt_ipac;

	printk(KERN_INFO "HiSax: %s (%s): IPAC Version %d\n",
		CardType[card->typ],
		sct_quadro_subtypes[cs->subtyp],
		readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID));
	return (1);
}
예제 #19
0
/* Detect whether a compatible device can be found, and initialize it. */
int vt596_setup(void)
{
	unsigned char temp;

	struct pci_dev *VT596_dev = NULL;

	/* First check whether we can access PCI at all */
	if (pci_present() == 0)
		return(-ENODEV);

	/* Look for a supported device/function */
	do {
		if((VT596_dev = pci_find_device(PCI_VENDOR_ID_VIA, num->dev,
					        VT596_dev)))
			break;
	} while ((++num)->dev);

	if (VT596_dev == NULL)
		return(-ENODEV);
	printk("i2c-viapro.o: Found Via %s device\n", num->name);

/* Determine the address of the SMBus areas */
	smb_cf_hstcfg = num->hstcfg;
	if (force_addr) {
		vt596_smba = force_addr & 0xfff0;
		force = 0;
	} else {
		if ((pci_read_config_word(VT596_dev, num->base, &vt596_smba))
		    || !(vt596_smba & 0x1)) {
			/* try 2nd address and config reg. for 596 */
			if((num->dev == PCI_DEVICE_ID_VIA_82C596_3) &&
			   (!pci_read_config_word(VT596_dev, SMBBA2, &vt596_smba)) &&
			   (vt596_smba & 0x1)) {
				smb_cf_hstcfg = 0x84;
			} else {
			        /* no matches at all */
			        printk("i2c-viapro.o: Cannot configure SMBus "
				       "I/O Base address\n");
			        return(-ENODEV);
			}
		}
		vt596_smba &= 0xfff0;
		if(vt596_smba == 0) {
			printk(KERN_ERR "i2c-viapro.o: SMBus base address"
			   "uninitialized - upgrade BIOS or use force_addr=0xaddr\n");
			return -ENODEV;
		}
	}

	if (check_region(vt596_smba, 8)) {
		printk("i2c-viapro.o: SMBus region 0x%x already in use!\n",
		        vt596_smba);
		return(-ENODEV);
	}

	pci_read_config_byte(VT596_dev, SMBHSTCFG, &temp);
/* If force_addr is set, we program the new address here. Just to make
   sure, we disable the VT596 first. */
	if (force_addr) {
		pci_write_config_byte(VT596_dev, SMBHSTCFG, temp & 0xfe);
		pci_write_config_word(VT596_dev, num->base, vt596_smba);
		pci_write_config_byte(VT596_dev, SMBHSTCFG, temp | 0x01);
		printk
		    ("i2c-viapro.o: WARNING: SMBus interface set to new "
		     "address 0x%04x!\n", vt596_smba);
	} else if ((temp & 1) == 0) {
		if (force) {
/* 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(VT596_dev, SMBHSTCFG,
					      temp | 1);
			printk
			    ("i2c-viapro.o: enabling SMBus device\n");
		} else {
			printk
			    ("SMBUS: Error: Host SMBus controller not enabled! - "
			     "upgrade BIOS or use force=1\n");
			return(-ENODEV);
		}
	}

	/* Everything is happy, let's grab the memory and set things up. */
	request_region(vt596_smba, 8, "viapro-smbus");

#ifdef DEBUG
	if ((temp & 0x0E) == 8)
		printk("i2c-viapro.o: using Interrupt 9 for SMBus.\n");
	else if ((temp & 0x0E) == 0)
		printk("i2c-viapro.o: using Interrupt SMI# for SMBus.\n");
	else
		printk
		    ("i2c-viapro.o: Illegal Interrupt configuration (or code out "
		     "of date)!\n");

	pci_read_config_byte(VT596_dev, SMBREV, &temp);
	printk("i2c-viapro.o: SMBREV = 0x%X\n", temp);
	printk("i2c-viapro.o: VT596_smba = 0x%X\n", vt596_smba);
#endif				/* DEBUG */

	return(0);
}
예제 #20
0
int awc4500_pci_probe(struct net_device *dev)
{
    int cards_found = 0;
    static int pci_index;	/* Static, for multiple probe calls. */
    u8 pci_irq_line = 0;
//	int p;

    unsigned char awc_pci_dev, awc_pci_bus;

    if (!pci_present())
        return -1;

    for (; pci_index < 0xff; pci_index++) {
        u16 vendor, device, pci_command, new_command;
        u32 pci_memaddr;
        u32 pci_ioaddr;
        u32 pci_cisaddr;
        struct pci_dev *pdev;

        if (pcibios_find_class	(PCI_CLASS_NETWORK_OTHER << 8,
                                 reverse_probe ? 0xfe - pci_index : pci_index,
                                 &awc_pci_bus, &awc_pci_dev) != PCIBIOS_SUCCESSFUL) {
            if (reverse_probe) {
                continue;
            } else {
                break;
            }
        }
        pdev = pci_find_slot(awc_pci_bus, awc_pci_dev);
        if (!pdev)
            continue;
        if (pci_enable_device(pdev))
            continue;
        vendor = pdev->vendor;
        device = pdev->device;
        pci_irq_line = pdev->irq;
        pci_memaddr = pci_resource_start (pdev, 0);
        pci_cisaddr = pci_resource_start (pdev, 1);
        pci_ioaddr = pci_resource_start (pdev, 2);

//		printk("\n pci capabilities %x and ptr %x \n",pci_caps,pci_caps_ptr);
        /* Remove I/O space marker in bit 0. */

        if (vendor != PCI_VENDOR_ID_AIRONET)
            continue;
        if (device != PCI_DEVICE_AIRONET_4800_1 &&
                device != PCI_DEVICE_AIRONET_4800 &&
                device != PCI_DEVICE_AIRONET_4500 )
            continue;

//		if (check_region(pci_ioaddr, AIRONET4X00_IO_SIZE) ||
//			check_region(pci_cisaddr, AIRONET4X00_CIS_SIZE) ||
//			check_region(pci_memaddr, AIRONET4X00_MEM_SIZE)) {
//				printk(KERN_ERR "aironet4X00 mem addrs not available for maping \n");
//				continue;
//		}
        if (!request_region(pci_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"))
            continue;
//		request_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
//		request_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");

        mdelay(10);

        pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
        new_command = pci_command | PCI_COMMAND_SERR;
        if (pci_command != new_command)
            pci_write_config_word(pdev, PCI_COMMAND, new_command);


        /*		if (device == PCI_DEVICE_AIRONET_4800)
        			pci_write_config_dword(pdev, 0x40, 0x00000000);

        		udelay(1000);
        */
        if (device == PCI_DEVICE_AIRONET_4800)
            pci_write_config_dword(pdev, 0x40, 0x40000000);

        if (awc_pci_init(dev, pdev, pci_ioaddr,pci_cisaddr,pci_memaddr,pci_irq_line)) {
            printk(KERN_ERR "awc4800 pci init failed \n");
            break;
        }
        dev = 0;
        cards_found++;
    }

    return cards_found ? 0 : -ENODEV;
}
예제 #21
0
파일: sedlbauer.c 프로젝트: TitaniumBoy/lin
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 {
/* 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 */
	}	
	
	/* 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);
}
예제 #22
0
static int __init
setup_gazelpci(struct IsdnCardState *cs)
{
    u_int pci_ioaddr0 = 0, pci_ioaddr1 = 0;
    u_char pci_irq = 0, found;
    u_int nbseek, seekcard;

    printk(KERN_WARNING "Gazel: PCI card automatic recognition\n");

    found = 0;
    if (!pci_present()) {
        printk(KERN_WARNING "Gazel: No PCI bus present\n");
        return 1;
    }
    seekcard = PCI_DEVICE_ID_PLX_R685;
    for (nbseek = 0; nbseek < 3; nbseek++) {
        if ((dev_tel = pci_find_device(PCI_VENDOR_ID_PLX, seekcard, dev_tel))) {
            if (pci_enable_device(dev_tel))
                return 1;
            pci_irq = dev_tel->irq;
            pci_ioaddr0 = pci_resource_start(dev_tel, 1);
            pci_ioaddr1 = pci_resource_start(dev_tel, 2);
            found = 1;
        }
        if (found)
            break;
        else {
            switch (seekcard) {
            case PCI_DEVICE_ID_PLX_R685:
                seekcard = PCI_DEVICE_ID_PLX_R753;
                break;
            case PCI_DEVICE_ID_PLX_R753:
                seekcard = PCI_DEVICE_ID_PLX_DJINN_ITOO;
                break;
            }
        }
    }
    if (!found) {
        printk(KERN_WARNING "Gazel: No PCI card found\n");
        return (1);
    }
    if (!pci_irq) {
        printk(KERN_WARNING "Gazel: No IRQ for PCI card found\n");
        return 1;
    }
    cs->hw.gazel.pciaddr[0] = pci_ioaddr0;
    cs->hw.gazel.pciaddr[1] = pci_ioaddr1;

    pci_ioaddr1 &= 0xfffe;
    cs->hw.gazel.cfg_reg = pci_ioaddr0 & 0xfffe;
    cs->hw.gazel.ipac = pci_ioaddr1;
    cs->hw.gazel.isac = pci_ioaddr1 + 0x80;
    cs->hw.gazel.hscx[0] = pci_ioaddr1;
    cs->hw.gazel.hscx[1] = pci_ioaddr1 + 0x40;
    cs->hw.gazel.isacfifo = cs->hw.gazel.isac;
    cs->hw.gazel.hscxfifo[0] = cs->hw.gazel.hscx[0];
    cs->hw.gazel.hscxfifo[1] = cs->hw.gazel.hscx[1];
    cs->irq = pci_irq;
    cs->irq_flags |= SA_SHIRQ;

    switch (seekcard) {
    case PCI_DEVICE_ID_PLX_R685:
        printk(KERN_INFO "Gazel: Card PCI R685 found\n");
        cs->subtyp = R685;
        cs->dc.isac.adf2 = 0x87;
        printk(KERN_INFO
               "Gazel: config irq:%d isac:0x%X  cfg:0x%X\n",
               cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg);
        printk(KERN_INFO
               "Gazel: hscx A:0x%X  hscx B:0x%X\n",
               cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]);
        break;
    case PCI_DEVICE_ID_PLX_R753:
    case PCI_DEVICE_ID_PLX_DJINN_ITOO:
        printk(KERN_INFO "Gazel: Card PCI R753 found\n");
        cs->subtyp = R753;
        test_and_set_bit(HW_IPAC, &cs->HW_Flags);
        printk(KERN_INFO
               "Gazel: config irq:%d ipac:0x%X  cfg:0x%X\n",
               cs->irq, cs->hw.gazel.ipac, cs->hw.gazel.cfg_reg);
        break;
    }

    return (0);
}
예제 #23
0
__initfunc(void ebus_init(void))
{
    struct linux_prom_pci_registers regs[PROMREG_MAX];
    struct linux_pbm_info *pbm;
    struct linux_ebus_device *dev;
    struct linux_ebus *ebus;
    struct pci_dev *pdev;
    struct pcidev_cookie *cookie;
    char lbuf[128];
    unsigned long addr, *base;
    unsigned short pci_command;
    int nd, len, ebusnd;
    int reg, rng, nreg;
    int num_ebus = 0;

    if (!pci_present())
        return;

    pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, 0);
    if (!pdev) {
        printk("ebus: No EBus's found.\n");
#ifdef PROM_DEBUG
        dprintf("ebus: No EBus's found.\n");
#endif
        return;
    }

    cookie = pdev->sysdata;
    ebusnd = cookie->prom_node;

    ebus_chain = ebus = (struct linux_ebus *)
                        ebus_alloc(sizeof(struct linux_ebus));
    ebus->next = 0;

    while (ebusnd) {
        printk("ebus%d:", num_ebus);
#ifdef PROM_DEBUG
        dprintf("ebus%d:", num_ebus);
#endif

        prom_getstring(ebusnd, "name", lbuf, sizeof(lbuf));
        ebus->prom_node = ebusnd;
        strcpy(ebus->prom_name, lbuf);

        ebus->self = pdev;
        ebus->parent = pbm = cookie->pbm;

        /* Enable BUS Master. */
        pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
        pci_command |= PCI_COMMAND_MASTER;
        pci_write_config_word(pdev, PCI_COMMAND, pci_command);

        len = prom_getproperty(ebusnd, "reg", (void *)regs,
                               sizeof(regs));
        if (len == 0 || len == -1) {
            prom_printf("%s: can't find reg property\n",
                        __FUNCTION__);
            prom_halt();
        }
        nreg = len / sizeof(struct linux_prom_pci_registers);

        base = &ebus->self->base_address[0];
        for (reg = 0; reg < nreg; reg++) {
            if (!(regs[reg].phys_hi & 0x03000000))
                continue;

            for (rng = 0; rng < pbm->num_pbm_ranges; rng++) {
                struct linux_prom_pci_ranges *rp =
                        &pbm->pbm_ranges[rng];

                if ((rp->child_phys_hi ^ regs[reg].phys_hi)
                        & 0x03000000)
                    continue;

                addr = (u64)regs[reg].phys_lo;
                addr += (u64)regs[reg].phys_mid << 32UL;
                addr += (u64)rp->parent_phys_lo;
                addr += (u64)rp->parent_phys_hi << 32UL;
                *base++ = (unsigned long)__va(addr);

                printk(" %lx[%x]", (unsigned long)__va(addr),
                       regs[reg].size_lo);
#ifdef PROM_DEBUG
                dprintf(" %lx[%x]", (unsigned long)__va(addr),
                        regs[reg].size_lo);
#endif
                break;
            }
        }
        printk("\n");
#ifdef PROM_DEBUG
        dprintf("\n");
#endif

        prom_ebus_ranges_init(ebus);
        prom_ebus_intmap_init(ebus);

        nd = prom_getchild(ebusnd);
        if (!nd)
            goto next_ebus;

        ebus->devices = (struct linux_ebus_device *)
                        ebus_alloc(sizeof(struct linux_ebus_device));

        dev = ebus->devices;
        dev->next = 0;
        dev->children = 0;
        dev->bus = ebus;
        fill_ebus_device(nd, dev);

        while ((nd = prom_getsibling(nd))) {
            dev->next = (struct linux_ebus_device *)
                        ebus_alloc(sizeof(struct linux_ebus_device));

            dev = dev->next;
            dev->next = 0;
            dev->children = 0;
            dev->bus = ebus;
            fill_ebus_device(nd, dev);
        }

next_ebus:
        pdev = pci_find_device(PCI_VENDOR_ID_SUN,
                               PCI_DEVICE_ID_SUN_EBUS, pdev);
        if (!pdev)
            break;

        cookie = pdev->sysdata;
        ebusnd = cookie->prom_node;

        ebus->next = (struct linux_ebus *)
                     ebus_alloc(sizeof(struct linux_ebus));
        ebus = ebus->next;
        ebus->next = 0;
        ++num_ebus;
    }

#ifdef CONFIG_SUN_OPENPROMIO
    openprom_init();
#endif
#ifdef CONFIG_SPARCAUDIO
    sparcaudio_init();
#endif
#ifdef CONFIG_SUN_BPP
    bpp_init();
#endif
#ifdef CONFIG_SUN_AUXIO
    auxio_probe();
#endif
#ifdef CONFIG_ENVCTRL
    envctrl_init();
#endif
#ifdef CONFIG_OBP_FLASH
    flash_init();
#endif
    clock_probe();
}
예제 #24
0
static int __init i2c_pcfisa_init(void)
{
#ifdef __alpha__
    /* check to see we have memory mapped PCF8584 connected to the
    Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
    if ((base == 0) && pci_present()) {

        struct pci_dev *cy693_dev =
            pci_find_device(PCI_VENDOR_ID_CONTAQ,
                            PCI_DEVICE_ID_CONTAQ_82C693, NULL);

        if (cy693_dev) {
            char config;
            /* yeap, we've found cypress, let's check config */
            if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {

                DEB3(printk("i2c-elektor.o: found cy82c693, config register 0x47 = 0x%02x.\n", config));

                /* UP2000 board has this register set to 0xe1,
                                   but the most significant bit as seems can be
                   reset during the proper initialisation
                                   sequence if guys from API decides to do that
                                   (so, we can even enable Tsunami Pchip
                                   window for the upper 1 Gb) */

                /* so just check for ROMCS at 0xe0000,
                                   ROMCS enabled for writes
                   and external XD Bus buffer in use. */
                if ((config & 0x7f) == 0x61) {
                    /* seems to be UP2000 like board */
                    base = 0xe0000;
                    /* I don't know why we need to
                       write twice */
                    mmapped = 2;
                    /* UP2000 drives ISA with
                    8.25 MHz (PCI/4) clock
                    			   (this can be read from cypress) */
                    clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
                    printk("i2c-elektor.o: found API UP2000 like board, will probe PCF8584 later.\n");
                }
            }
        }
    }
#endif

    /* sanity checks for mmapped I/O */
    if (mmapped && base < 0xc8000) {
        printk("i2c-elektor.o: incorrect base address (0x%0X) specified for mmapped I/O.\n", base);
        return -ENODEV;
    }

    printk("i2c-elektor.o: i2c pcf8584-isa adapter module\n");

    if (base == 0) {
        base = DEFAULT_BASE;
    }

#if (LINUX_VERSION_CODE >= 0x020301)
    init_waitqueue_head(&pcf_wait);
#endif
    if (pcf_isa_init() == 0) {
        if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
            return -ENODEV;
    } else {
        return -ENODEV;
    }

    printk("i2c-elektor.o: found device at %#x.\n", base);

    return 0;
}
예제 #25
0
int __init
setup_bkm_a4t(struct IsdnCard *card)
{
	struct IsdnCardState *cs = card->cs;
	char tmp[64];
	u_int pci_memaddr = 0, found = 0;
	I20_REGISTER_FILE *pI20_Regs;
#if CONFIG_PCI
#endif

	strcpy(tmp, bkm_a4t_revision);
	printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ == ISDN_CTYPE_BKM_A4T) {
		cs->subtyp = BKM_A4T;
	} else
		return (0);

#if CONFIG_PCI
	if (!pci_present()) {
		printk(KERN_ERR "bkm_a4t: no PCI bus present\n");
		return (0);
	}
	while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN,
		PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) {
		u16 sub_sys;
		u16 sub_vendor;

		sub_vendor = dev_a4t->subsystem_vendor;
		sub_sys = dev_a4t->subsystem_device;
		if ((sub_sys == PCI_DEVICE_ID_BERKOM_A4T) && (sub_vendor == PCI_VENDOR_ID_BERKOM)) {
			if (pci_enable_device(dev_a4t))
				return(0);
			found = 1;
			pci_memaddr = pci_resource_start(dev_a4t, 0);
			cs->irq = dev_a4t->irq;
			break;
		}
	}
	if (!found) {
		printk(KERN_WARNING "HiSax: %s: Card not found\n", CardType[card->typ]);
		return (0);
	}
	if (!cs->irq) {		/* IRQ range check ?? */
		printk(KERN_WARNING "HiSax: %s: No IRQ\n", CardType[card->typ]);
		return (0);
	}
	if (!pci_memaddr) {
		printk(KERN_WARNING "HiSax: %s: No Memory base address\n", CardType[card->typ]);
		return (0);
	}
	cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096);
	/* Check suspecious address */
	pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
	if ((pI20_Regs->i20IntStatus & 0x8EFFFFFF) != 0) {
		printk(KERN_WARNING "HiSax: %s address %lx-%lx suspecious\n",
		       CardType[card->typ], cs->hw.ax.base, cs->hw.ax.base + 4096);
		iounmap((void *) cs->hw.ax.base);
		cs->hw.ax.base = 0;
		return (0);
	}
	cs->hw.ax.isac_adr = cs->hw.ax.base + PO_OFFSET;
	cs->hw.ax.jade_adr = cs->hw.ax.base + PO_OFFSET;
	cs->hw.ax.isac_ale = GCS_1;
	cs->hw.ax.jade_ale = GCS_3;
#else
	printk(KERN_WARNING "HiSax: %s: NO_PCI_BIOS\n", CardType[card->typ]);
	printk(KERN_WARNING "HiSax: %s: unable to configure\n", CardType[card->typ]);
	return (0);
#endif				/* CONFIG_PCI */
	printk(KERN_INFO "HiSax: %s: Card configured at 0x%lX IRQ %d\n",
	       CardType[card->typ], cs->hw.ax.base, cs->irq);

	reset_bkm(cs);
	cs->readisac = &ReadISAC;
	cs->writeisac = &WriteISAC;
	cs->readisacfifo = &ReadISACfifo;
	cs->writeisacfifo = &WriteISACfifo;
	cs->BC_Read_Reg = &ReadJADE;
	cs->BC_Write_Reg = &WriteJADE;
	cs->BC_Send_Data = &jade_fill_fifo;
	cs->cardmsg = &BKM_card_msg;
	cs->irq_func = &bkm_interrupt;
	cs->irq_flags |= SA_SHIRQ;
	ISACVersion(cs, "Telekom A4T:");
	/* Jade version */
	JadeVersion(cs, "Telekom A4T:");
	return (1);
}
예제 #26
0
파일: bkm_a8.c 프로젝트: janfj/dd-wrt
int __init
setup_sct_quadro(struct IsdnCard *card)
{
#if CONFIG_PCI
    struct IsdnCardState *cs = card->cs;
    char tmp[64];
    u_char pci_rev_id;
    u_int found = 0;
    u_int pci_ioaddr1, pci_ioaddr2, pci_ioaddr3, pci_ioaddr4, pci_ioaddr5;

    strcpy(tmp, sct_quadro_revision);
    printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
    if (cs->typ == ISDN_CTYPE_SCT_QUADRO) {
        cs->subtyp = SCT_1;	/* Preset */
    } else
        return (0);

    /* Identify subtype by para[0] */
    if (card->para[0] >= SCT_1 && card->para[0] <= SCT_4)
        cs->subtyp = card->para[0];
    else {
        printk(KERN_WARNING "HiSax: %s: Invalid subcontroller in configuration, default to 1\n",
               CardType[card->typ]);
        return (0);
    }
    if ((cs->subtyp != SCT_1) && ((sub_sys_id != PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) ||
                                  (sub_vendor_id != PCI_VENDOR_ID_BERKOM)))
        return (0);
    if (cs->subtyp == SCT_1) {
        if (!pci_present()) {
            printk(KERN_ERR "bkm_a4t: no PCI bus present\n");
            return (0);
        }
        while ((dev_a8 = pci_find_device(PCI_VENDOR_ID_PLX,
                                         PCI_DEVICE_ID_PLX_9050, dev_a8))) {

            pci_get_sub_vendor(dev_a8,sub_vendor_id);
            pci_get_sub_system(dev_a8,sub_sys_id);
            if ((sub_sys_id == PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) &&
                    (sub_vendor_id == PCI_VENDOR_ID_BERKOM)) {
                if (pci_enable_device(dev_a8))
                    return(0);
                pci_ioaddr1 = pci_resource_start_io(dev_a8, 1);
                pci_irq = dev_a8->irq;
                pci_bus = dev_a8->bus->number;
                pci_device_fn = dev_a8->devfn;
                found = 1;
                break;
            }
        }
        if (!found) {
            printk(KERN_WARNING "HiSax: %s (%s): Card not found\n",
                   CardType[card->typ],
                   sct_quadro_subtypes[cs->subtyp]);
            return (0);
        }
#ifdef ATTEMPT_PCI_REMAPPING
        /* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */
        pcibios_read_config_byte(pci_bus, pci_device_fn,
                                 PCI_REVISION_ID, &pci_rev_id);
        if ((pci_ioaddr1 & 0x80) && (pci_rev_id == 1)) {
            printk(KERN_WARNING "HiSax: %s (%s): PLX rev 1, remapping required!\n",
                   CardType[card->typ],
                   sct_quadro_subtypes[cs->subtyp]);
            /* Restart PCI negotiation */
            pcibios_write_config_dword(pci_bus, pci_device_fn,
                                       PCI_BASE_ADDRESS_1, (u_int) - 1);
            /* Move up by 0x80 byte */
            pci_ioaddr1 += 0x80;
            pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK;
            pcibios_write_config_dword(pci_bus, pci_device_fn,
                                       PCI_BASE_ADDRESS_1, pci_ioaddr1);
            get_pcibase(dev_a8, 1) = pci_ioaddr1;
        }
#endif /* End HACK */
    }
    if (!pci_irq) {		/* IRQ range check ?? */
        printk(KERN_WARNING "HiSax: %s (%s): No IRQ\n",
               CardType[card->typ],
               sct_quadro_subtypes[cs->subtyp]);
        return (0);
    }
    pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &pci_ioaddr1);
    pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_2, &pci_ioaddr2);
    pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_3, &pci_ioaddr3);
    pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_4, &pci_ioaddr4);
    pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_5, &pci_ioaddr5);
    if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) {
        printk(KERN_WARNING "HiSax: %s (%s): No IO base address(es)\n",
               CardType[card->typ],
               sct_quadro_subtypes[cs->subtyp]);
        return (0);
    }
    pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK;
    pci_ioaddr2 &= PCI_BASE_ADDRESS_IO_MASK;
    pci_ioaddr3 &= PCI_BASE_ADDRESS_IO_MASK;
    pci_ioaddr4 &= PCI_BASE_ADDRESS_IO_MASK;
    pci_ioaddr5 &= PCI_BASE_ADDRESS_IO_MASK;
    /* Take over */
    cs->irq = pci_irq;
    cs->irq_flags |= SA_SHIRQ;
    /* pci_ioaddr1 is unique to all subdevices */
    /* pci_ioaddr2 is for the fourth subdevice only */
    /* pci_ioaddr3 is for the third subdevice only */
    /* pci_ioaddr4 is for the second subdevice only */
    /* pci_ioaddr5 is for the first subdevice only */
    cs->hw.ax.plx_adr = pci_ioaddr1;
    /* Enter all ipac_base addresses */
    switch(cs->subtyp) {
    case 1:
        cs->hw.ax.base = pci_ioaddr5 + 0x00;
        if (sct_alloc_io(pci_ioaddr1, 128))
            return(0);
        if (sct_alloc_io(pci_ioaddr5, 64))
            return(0);
        /* disable all IPAC */
        writereg(pci_ioaddr5, pci_ioaddr5 + 4,
                 IPAC_MASK, 0xFF);
        writereg(pci_ioaddr4 + 0x08, pci_ioaddr4 + 0x0c,
                 IPAC_MASK, 0xFF);
        writereg(pci_ioaddr3 + 0x10, pci_ioaddr3 + 0x14,
                 IPAC_MASK, 0xFF);
        writereg(pci_ioaddr2 + 0x20, pci_ioaddr2 + 0x24,
                 IPAC_MASK, 0xFF);
        break;
    case 2:
        cs->hw.ax.base = pci_ioaddr4 + 0x08;
        if (sct_alloc_io(pci_ioaddr4, 64))
            return(0);
        break;
    case 3:
        cs->hw.ax.base = pci_ioaddr3 + 0x10;
        if (sct_alloc_io(pci_ioaddr3, 64))
            return(0);
        break;
    case 4:
        cs->hw.ax.base = pci_ioaddr2 + 0x20;
        if (sct_alloc_io(pci_ioaddr2, 64))
            return(0);
        break;
    }
    /* For isac and hscx data path */
    cs->hw.ax.data_adr = cs->hw.ax.base + 4;

    printk(KERN_INFO "HiSax: %s (%s) configured at 0x%.4lX, 0x%.4lX, 0x%.4lX and IRQ %d\n",
           CardType[card->typ],
           sct_quadro_subtypes[cs->subtyp],
           cs->hw.ax.plx_adr,
           cs->hw.ax.base,
           cs->hw.ax.data_adr,
           cs->irq);

    test_and_set_bit(HW_IPAC, &cs->HW_Flags);

    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 = &BKM_card_msg;
    cs->irq_func = &bkm_interrupt_ipac;

    printk(KERN_INFO "HiSax: %s (%s): IPAC Version %d\n",
           CardType[card->typ],
           sct_quadro_subtypes[cs->subtyp],
           readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID));
    return (1);
#else
    printk(KERN_ERR "HiSax: bkm_a8 only supported on PCI Systems\n");
#endif /* CONFIG_PCI */
}
예제 #27
0
/* Detect whether a ALI15X3 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 ali15x3_setup(void)
{
	u16 a;
	unsigned char temp;

	struct pci_dev *ALI15X3_dev;

	/* First check whether we can access PCI at all */
	if (pci_present() == 0) {
		printk("i2c-ali15x3.o: Error: No PCI-bus found!\n");
		return -ENODEV;
	}

	/* Look for the ALI15X3, M7101 device */
	ALI15X3_dev = NULL;
	ALI15X3_dev = pci_find_device(PCI_VENDOR_ID_AL,
				      PCI_DEVICE_ID_AL_M7101, ALI15X3_dev);
	if (ALI15X3_dev == NULL) {
		printk("i2c-ali15x3.o: Error: Can't detect ali15x3!\n");
		return -ENODEV;
	}

/* Check the following things:
	- SMB I/O address is initialized
	- Device is enabled
	- We can use the addresses
*/

/* Unlock the register.
   The data sheet says that the address registers are read-only
   if the lock bits are 1, but in fact the address registers
   are zero unless you clear the lock bits.
*/
	pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp);
	if (temp & ALI15X3_LOCK) {
		temp &= ~ALI15X3_LOCK;
		pci_write_config_byte(ALI15X3_dev, SMBATPC, temp);
	}

/* Determine the address of the SMBus area */
	pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba);
	ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1));
	if (ali15x3_smba == 0 && force_addr == 0) {
		printk
		    ("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr\n");
		return -ENODEV;
	}

	if(force_addr)
		ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);

	if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) {
		printk
		    ("i2c-ali15x3.o: ALI15X3_smb region 0x%x already in use!\n",
		     ali15x3_smba);
		return -ENODEV;
	}

	if(force_addr) {
		printk("i2c-ali15x3.o: forcing ISA address 0x%04X\n", ali15x3_smba);
		if (PCIBIOS_SUCCESSFUL !=
		    pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba))
			return -ENODEV;
		if (PCIBIOS_SUCCESSFUL !=
		    pci_read_config_word(ALI15X3_dev, SMBBA, &a))
			return -ENODEV;
		if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
			/* make sure it works */
			printk("i2c-ali15x3.o: force address failed - not supported?\n");
			return -ENODEV;
		}
	}
/* check if whole device is enabled */
	pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp);
	if ((temp & 1) == 0) {
		printk("i2c-ali15x3: enabling SMBus device\n");
		pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01);
	}

/* Is SMB Host controller enabled? */
	pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp);
	if ((temp & 1) == 0) {
		printk("i2c-ali15x3: enabling SMBus controller\n");
		pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01);
	}

/* set SMB clock to 74KHz as recommended in data sheet */
	pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20);

	/* Everything is happy, let's grab the memory and set things up. */
	request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-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-ali15x3.o: ALI15X3 using Interrupt 9 for SMBus.\n");
*/
	pci_read_config_byte(ALI15X3_dev, SMBREV, &temp);
	printk("i2c-ali15x3.o: SMBREV = 0x%X\n", temp);
	printk("i2c-ali15x3.o: ALI15X3_smba = 0x%X\n", ali15x3_smba);
#endif				/* DEBUG */

	return 0;
}
예제 #28
0
파일: nj_u.c 프로젝트: nhanh0/hah
int __init
setup_netjet_u(struct IsdnCard *card)
{
	int bytecnt;
	struct IsdnCardState *cs = card->cs;
	char tmp[64];
	long flags;
#if CONFIG_PCI
#endif
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
	strcpy(tmp, NETjet_U_revision);
	printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ != ISDN_CTYPE_NETJET_U)
		return(0);
	test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);

#if CONFIG_PCI

	for ( ;; )
	{
		if (!pci_present()) {
			printk(KERN_ERR "Netjet: no PCI bus present\n");
			return(0);
		}
		if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
			PCI_DEVICE_ID_TIGERJET_300,  dev_netjet))) {
			if (pci_enable_device(dev_netjet))
				return(0);
			pci_set_master(dev_netjet);
			cs->irq = dev_netjet->irq;
			if (!cs->irq) {
				printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n");
				return(0);
			}
			cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
			if (!cs->hw.njet.base) {
				printk(KERN_WARNING "NETspider-U: No IO-Adr for PCI card found\n");
				return(0);
			}
		} else {
			printk(KERN_WARNING "NETspider-U: No PCI card found\n");
			return(0);
		}

		cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
		cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;

		save_flags(flags);
		sti();

		cs->hw.njet.ctrl_reg = 0xff;  /* Reset On */
		byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);

		set_current_state(TASK_UNINTERRUPTIBLE);
		schedule_timeout((10*HZ)/1000);	/* Timeout 10ms */

		cs->hw.njet.ctrl_reg = 0x00;  /* Reset Off and status read clear */
		byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);

		set_current_state(TASK_UNINTERRUPTIBLE);
		schedule_timeout((10*HZ)/1000);	/* Timeout 10ms */

		restore_flags(flags);

		cs->hw.njet.auxd = 0xC0;
		cs->hw.njet.dmactrl = 0;

		byteout(cs->hw.njet.auxa, 0);
		byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
		byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
		byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);

		switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) )
		{
			case 3 :
				break;

			case 0 :
				printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" );
				continue;

			default :
				printk( KERN_WARNING "NETspider-U: No PCI card found\n" );
				return 0;
                }
                break;
	}
#else

	printk(KERN_WARNING "NETspider-U: NO_PCI_BIOS\n");
	printk(KERN_WARNING "NETspider-U: unable to config NETspider-U PCI\n");
	return (0);

#endif /* CONFIG_PCI */

	bytecnt = 256;

	printk(KERN_INFO
		"NETspider-U: PCI card configured at %#lx IRQ %d\n",
		cs->hw.njet.base, cs->irq);
	if (check_region(cs->hw.njet.base, bytecnt)) {
		printk(KERN_WARNING
		       "HiSax: %s config port %#lx-%#lx already in use\n",
		       CardType[card->typ],
		       cs->hw.njet.base,
		       cs->hw.njet.base + bytecnt);
		return (0);
	} else {
		request_region(cs->hw.njet.base, bytecnt, "netspider-u isdn");
	}
	reset_netjet_u(cs);
	cs->readisac  = &NETjet_ReadIC;
	cs->writeisac = &NETjet_WriteIC;
	cs->readisacfifo  = &NETjet_ReadICfifo;
	cs->writeisacfifo = &NETjet_WriteICfifo;
	cs->BC_Read_Reg  = &dummyrr;
	cs->BC_Write_Reg = &dummywr;
	cs->BC_Send_Data = &netjet_fill_dma;
	cs->cardmsg = &NETjet_U_card_msg;
	cs->irq_func = &netjet_u_interrupt;
	cs->irq_flags |= SA_SHIRQ;
	ICCVersion(cs, "NETspider-U:");
	return (1);
}
예제 #29
0
int __init
setup_telespci(struct IsdnCard *card)
{
	struct IsdnCardState *cs = card->cs;
	char tmp[64];

#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
	strcpy(tmp, telespci_revision);
	printk(KERN_INFO "HiSax: Teles/PCI driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ != ISDN_CTYPE_TELESPCI)
		return (0);
#if CONFIG_PCI
	if (!pci_present()) {
		printk(KERN_ERR "TelesPCI: no PCI bus present\n");
		return(0);
	}
	if ((dev_tel = pci_find_device (PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_tel))) {
		if (pci_enable_device(dev_tel))
			return(0);
		cs->irq = dev_tel->irq;
		if (!cs->irq) {
			printk(KERN_WARNING "Teles: No IRQ for PCI card found\n");
			return(0);
		}
		cs->hw.teles0.membase = (u_long) ioremap(pci_resource_start(dev_tel, 0),
			PAGE_SIZE);
		printk(KERN_INFO "Found: Zoran, base-address: 0x%lx, irq: 0x%x\n",
			pci_resource_start(dev_tel, 0), dev_tel->irq);
	} else {
		printk(KERN_WARNING "TelesPCI: No PCI card found\n");
		return(0);
	}
#else
	printk(KERN_WARNING "HiSax: Teles/PCI and NO_PCI_BIOS\n");
	printk(KERN_WARNING "HiSax: Teles/PCI unable to config\n");
	return (0);
#endif /* CONFIG_PCI */

	/* Initialize Zoran PCI controller */
	writel(0x00000000, cs->hw.teles0.membase + 0x28);
	writel(0x01000000, cs->hw.teles0.membase + 0x28);
	writel(0x01000000, cs->hw.teles0.membase + 0x28);
	writel(0x7BFFFFFF, cs->hw.teles0.membase + 0x2C);
	writel(0x70000000, cs->hw.teles0.membase + 0x3C);
	writel(0x61000000, cs->hw.teles0.membase + 0x40);
	/* writel(0x00800000, cs->hw.teles0.membase + 0x200); */

	printk(KERN_INFO
	       "HiSax: %s config irq:%d mem:%lx\n",
	       CardType[cs->typ], cs->irq,
	       cs->hw.teles0.membase);

	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 = &TelesPCI_card_msg;
	cs->irq_func = &telespci_interrupt;
	cs->irq_flags |= SA_SHIRQ;
	ISACVersion(cs, "TelesPCI:");
	if (HscxVersion(cs, "TelesPCI:")) {
		printk(KERN_WARNING
		 "TelesPCI: wrong HSCX versions check IO/MEM addresses\n");
		release_io_telespci(cs);
		return (0);
	}
	return (1);
}
예제 #30
0
int pciregions_read_proc(char *buf, char **start, off_t offset,
                   int len, int *eof, void *data)
{
    int i, pos=0;
    int bus, devfn, is_multi = 0;
    unsigned char headertype, pribus, secbus;
    u16 vendorid, deviceid = 0;

    /* to print information about several buses, keep an array of them */
    #define MAXNBUS 8
    int buses[MAXNBUS] = {0,};
    int lastbus = 0; /* only one bus, by default, bus 0 */
    int busindex = 0;

    /* this macro helps keeping the following lines short */
    #define PRINTF(fmt, args...) sprintf(buf+len, fmt, ## args)
    len=0;

    /* Loop through the devices (code not printed in the book) */

    if (!pci_present())
        return sprintf(buf, "PCI not available in this computer\n");

    bus = buses[busindex]; /* first bus (bus 0) */
    for (devfn=0; pos < PAGE_SIZE; devfn++) {
	struct pci_dev *dev = NULL;
	/*
	 * A clean implementation
	 * would have a separate function to dump a single bus, but i
	 * preferred to keep it in one function to include part of it
	 * in the book (the printed code is automagically extracted from
	 * this file).
	 *
	 * Instead, I use a dirty trick to fold two loops in one.
	 */
	if (devfn > 0xff) { /* end of this bus */
	    if (busindex == lastbus) break; 
	    /* loop over to the next bus */
	    bus = buses[++busindex];
	    devfn = 0;
	}

	/*
	 * This code is derived from "drivers/pci/pci.c" in version
	 * 2.0, although it has been modified to work with the 2.4 interface.
	 * This means that the GPL applies to this source file
	 * and credit is due to the original authors
	 * (Drew Eckhardt, Frederic Potter, David Mosberger-Tang)
	 */

        if (PCI_FUNC(devfn) && !is_multi) /* not multi-function */
	    continue;

	dev = pci_find_slot(bus, devfn);
	if (!dev) {
	    if (!PCI_FUNC(devfn)) is_multi = 0; /* no first implies no other */
	    continue; /* no such device */
	}
	pci_read_config_byte(dev, PCI_HEADER_TYPE, &headertype);
        if (!PCI_FUNC(devfn)) /* first function */
	    is_multi = headertype & 0x80;
	headertype &= 0x7f; /* mask multi-function bit */

	/* FIXME: should get rid of the PAGE_SIZE limit */
        if (len > PAGE_SIZE / 2) { /* a big margin, just to be sure */
	    *eof = 1; return len;
	}
	vendorid = dev->vendor;
	deviceid = dev->device;

        len += PRINTF("Bus %i, device %2i, devfn %2i (id %04x-%04x,"
		      " headertype 0x%02x)\n",
		      bus, devfn>>3, devfn & 7,
		      vendorid, deviceid, headertype);
	if (headertype == PCI_HEADER_TYPE_BRIDGE) {
	    /* This is a bridge, print what it does */
	    pci_read_config_byte(dev, PCI_PRIMARY_BUS, &pribus);
	    pci_read_config_byte(dev, PCI_SECONDARY_BUS, &secbus);
	    len += PRINTF("\tbridge connecting PCI bus %i to PCI bus %i\n",
			  secbus, pribus);
	    /* remember about this bus, to dump it later */
	    if (lastbus <= MAXNBUS-1) {
		lastbus++;
		buses[lastbus] = secbus;
		len += PRINTF("\t(bus %i is dumped below)\n", secbus);
	    } else {
		len += PRINTF("\t(bus %i won't be dumped)\n", secbus);
	    }
	    pci_release_device(dev); /* 2.0 compatibility */
	    continue;
	} else if (headertype == PCI_HEADER_TYPE_CARDBUS) {
	    /* This is a CardBus bridge, print what it does */
	    pci_read_config_byte(dev, PCI_CB_PRIMARY_BUS,&pribus);
	    pci_read_config_byte(dev, PCI_CB_CARD_BUS,&secbus);
	    len += PRINTF("\tbridge connecting CardBus %i to PCI bus %i\n",
			  secbus, pribus);
	    pci_release_device(dev); /* 2.0 compatibility */
	    continue;
	} else if (headertype != PCI_HEADER_TYPE_NORMAL) {
	    len += PRINTF("\tunknown header type, skipping\n");
	    pci_release_device(dev); /* 2.0 compatibility */
	    continue;
	}
		
        /* Print the address regions of this device */
        for (i=0; addresses[i]; i++) {
            u32 curr, mask, size;
            char *type;

            pci_read_config_dword(dev, addresses[i],&curr);
            cli();
            pci_write_config_dword(dev, addresses[i],~0);
            pci_read_config_dword(dev, addresses[i],&mask);
            pci_write_config_dword(dev, addresses[i],curr);
            sti();

            if (!mask)
		continue; /* there may be other regions */

	    /*
	     * apply the I/O or memory mask to current position
	     * note that I/O is limited to 0xffff, and 64-bit is not
	     * supported by this simple imeplementation
	     */
	    if (curr & PCI_BASE_ADDRESS_SPACE_IO) {
		curr &= PCI_BASE_ADDRESS_IO_MASK;
	    } else {
		curr &= PCI_BASE_ADDRESS_MEM_MASK;
	    }
		
            len += PRINTF("\tregion %i: mask 0x%08lx, now at 0x%08lx\n", i,
                           (unsigned long)mask,
                           (unsigned long)curr);
            /* extract the type, and the programmable bits */
            if (mask & PCI_BASE_ADDRESS_SPACE_IO) {
                type = "I/O"; mask &= PCI_BASE_ADDRESS_IO_MASK;
		size = (~mask + 1) & 0xffff; /* Bleah */
            } else {
                type = "mem"; mask &= PCI_BASE_ADDRESS_MEM_MASK;
		size = ~mask + 1;
            }
            len += PRINTF("\tregion %i: type %s, size %i (%i%s)\n", i,
                          type, size,
			  (size & 0xfffff) == 0 ? size >> 20 :
			    (size & 0x3ff) == 0 ? size >> 10 : size,
			  (size & 0xfffff) == 0 ? "MB" :
			    (size & 0x3ff) == 0 ? "KB" : "B");
	    if (len > PAGE_SIZE / 2) {
		len += PRINTF("... more info skipped ...\n");
		*eof = 1; return len;
	    }
        }
	pci_release_device(dev); /* 2.0 compatibility */
    } /* devfn */
    *eof = 1;
    return len;
}