⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gazel.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
}static intreset_gazel(struct IsdnCardState *cs){	unsigned long plxcntrl, addr = cs->hw.gazel.cfg_reg;	switch (cs->subtyp) {		case R647:			writereg(addr, 0, 0);			HZDELAY(10);			writereg(addr, 0, 1);			HZDELAY(2);			break;		case R685:			plxcntrl = inl(addr + PLX_CNTRL);			plxcntrl |= (RESET_9050 + RESET_GAZEL);			outl(plxcntrl, addr + PLX_CNTRL);			plxcntrl &= ~(RESET_9050 + RESET_GAZEL);			HZDELAY(4);			outl(plxcntrl, addr + PLX_CNTRL);			HZDELAY(10);			outb(INT_ISAC_EN + INT_HSCX_EN + INT_PCI_EN, addr + PLX_INCSR);			break;		case R753:			plxcntrl = inl(addr + PLX_CNTRL);			plxcntrl |= (RESET_9050 + RESET_GAZEL);			outl(plxcntrl, addr + PLX_CNTRL);			plxcntrl &= ~(RESET_9050 + RESET_GAZEL);			WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20);			HZDELAY(4);			outl(plxcntrl, addr + PLX_CNTRL);			HZDELAY(10);			WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00);			WriteISAC(cs, IPAC_ACFG - 0x80, 0xff);			WriteISAC(cs, IPAC_AOE - 0x80, 0x0);			WriteISAC(cs, IPAC_MASK - 0x80, 0xff);			WriteISAC(cs, IPAC_CONF - 0x80, 0x1);			outb(INT_IPAC_EN + INT_PCI_EN, addr + PLX_INCSR);			WriteISAC(cs, IPAC_MASK - 0x80, 0xc0);			break;		case R742:			WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20);			HZDELAY(4);			WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00);			WriteISAC(cs, IPAC_ACFG - 0x80, 0xff);			WriteISAC(cs, IPAC_AOE - 0x80, 0x0);			WriteISAC(cs, IPAC_MASK - 0x80, 0xff);			WriteISAC(cs, IPAC_CONF - 0x80, 0x1);			WriteISAC(cs, IPAC_MASK - 0x80, 0xc0);			break;	}	return (0);}static intGazel_card_msg(struct IsdnCardState *cs, int mt, void *arg){	u_long flags;	switch (mt) {		case CARD_RESET:			spin_lock_irqsave(&cs->lock, flags);			reset_gazel(cs);			spin_unlock_irqrestore(&cs->lock, flags);			return (0);		case CARD_RELEASE:			release_io_gazel(cs);			return (0);		case CARD_INIT:			spin_lock_irqsave(&cs->lock, flags);			inithscxisac(cs, 1);			if ((cs->subtyp==R647)||(cs->subtyp==R685)) {				int i;				for (i=0;i<(2+MAX_WAITING_CALLS);i++) {					cs->bcs[i].hw.hscx.tsaxr0 = 0x1f;					cs->bcs[i].hw.hscx.tsaxr1 = 0x23;				}			}			spin_unlock_irqrestore(&cs->lock, flags);			return (0);		case CARD_TEST:			return (0);	}	return (0);}static intreserve_regions(struct IsdnCard *card, struct IsdnCardState *cs){	unsigned int i, j, base = 0, adr = 0, len = 0;	switch (cs->subtyp) {		case R647:			base = cs->hw.gazel.hscx[0];			if (!request_region(adr = (0xC000 + base), len = 1, "gazel"))				goto error;			for (i = 0x0000; i < 0xC000; i += 0x1000) {				if (!request_region(adr = (i + base), len = 16, "gazel"))					goto error;			}			if (i != 0xC000) {				for (j = 0; j < i; j+= 0x1000)					release_region(j + base, 16);				release_region(0xC000 + base, 1);				goto error;			}			break;		case R685:			if (!request_region(adr = cs->hw.gazel.hscx[0], len = 0x100, "gazel"))				goto error;			if (!request_region(adr = cs->hw.gazel.cfg_reg, len = 0x80, "gazel")) {				release_region(cs->hw.gazel.hscx[0],0x100);				goto error;			}			break;		case R753:			if (!request_region(adr = cs->hw.gazel.ipac, len = 0x8, "gazel"))				goto error;			if (!request_region(adr = cs->hw.gazel.cfg_reg, len = 0x80, "gazel")) {				release_region(cs->hw.gazel.ipac, 8);				goto error;			}			break;		case R742:			if (!request_region(adr = cs->hw.gazel.ipac, len = 0x8, "gazel"))				goto error;			break;	}	return 0;      error:	printk(KERN_WARNING "Gazel: %s io ports 0x%x-0x%x already in use\n",	       CardType[cs->typ], adr, adr + len);	return 1;}static int __initsetup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs){	printk(KERN_INFO "Gazel: ISA PnP card automatic recognition\n");	// we got an irq parameter, assume it is an ISA card	// R742 decodes address even in not started...	// R647 returns FF if not present or not started	// eventually needs improvment	if (readreg_ipac(card->para[1], IPAC_ID) == 1)		cs->subtyp = R742;	else		cs->subtyp = R647;	setup_isac(cs);	cs->hw.gazel.cfg_reg = card->para[1] + 0xC000;	cs->hw.gazel.ipac = card->para[1];	cs->hw.gazel.isac = card->para[1] + 0x8000;	cs->hw.gazel.hscx[0] = card->para[1];	cs->hw.gazel.hscx[1] = card->para[1] + 0x4000;	cs->irq = card->para[0];	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];	switch (cs->subtyp) {		case R647:			printk(KERN_INFO "Gazel: Card ISA R647/R648 found\n");			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 R742:			printk(KERN_INFO "Gazel: Card ISA R742 found\n");			test_and_set_bit(HW_IPAC, &cs->HW_Flags);			printk(KERN_INFO			       "Gazel: config irq:%d ipac:0x%X\n",			       cs->irq, cs->hw.gazel.ipac);			break;	}	return (0);}static struct pci_dev *dev_tel __initdata = NULL;static int __initsetup_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;	seekcard = PCI_DEVICE_ID_PLX_R685;	for (nbseek = 0; nbseek < 4; 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;				case PCI_DEVICE_ID_PLX_DJINN_ITOO:					seekcard = PCI_DEVICE_ID_PLX_OLITEC;					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;	setup_isac(cs);	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:		case PCI_DEVICE_ID_PLX_OLITEC:			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);}int __initsetup_gazel(struct IsdnCard *card){	struct IsdnCardState *cs = card->cs;	char tmp[64];	u_char val;	strcpy(tmp, gazel_revision);	printk(KERN_INFO "Gazel: Driver Revision %s\n", HiSax_getrev(tmp));	if (cs->typ != ISDN_CTYPE_GAZEL)		return (0);	if (card->para[0]) {		if (setup_gazelisa(card, cs))			return (0);	} else {#ifdef CONFIG_PCI		if (setup_gazelpci(cs))			return (0);#else		printk(KERN_WARNING "Gazel: Card PCI requested and NO_PCI_BIOS, unable to config\n");		return (0);#endif				/* CONFIG_PCI */	}	if (reserve_regions(card, cs)) {		return (0);	}	if (reset_gazel(cs)) {		printk(KERN_WARNING "Gazel: wrong IRQ\n");		release_io_gazel(cs);		return (0);	}	cs->readisac = &ReadISAC;	cs->writeisac = &WriteISAC;	cs->readisacfifo = &ReadISACfifo;	cs->writeisacfifo = &WriteISACfifo;	cs->BC_Read_Reg = &ReadHSCX;	cs->BC_Write_Reg = &WriteHSCX;	cs->BC_Send_Data = &hscx_fill_fifo;	cs->cardmsg = &Gazel_card_msg;	switch (cs->subtyp) {		case R647:		case R685:			cs->irq_func = &gazel_interrupt;			ISACVersion(cs, "Gazel:");			if (HscxVersion(cs, "Gazel:")) {				printk(KERN_WARNING				       "Gazel: wrong HSCX versions check IO address\n");				release_io_gazel(cs);				return (0);			}			break;		case R742:		case R753:			cs->irq_func = &gazel_interrupt_ipac;			val = ReadISAC(cs, IPAC_ID - 0x80);			printk(KERN_INFO "Gazel: IPAC version %x\n", val);			break;	}	return (1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -