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

📄 aic7xxx_pci.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 4 页
字号:
	 * bank setting serves as a multiplexor	 * for the cable detection logic.	 * BRDDAT5 controls the bank switch.	 */	write_brdctl(ahc, 0);	/*	 * Now read the state of the internal	 * connectors.  BRDDAT6 is INT50 and	 * BRDDAT7 is INT68.	 */	brdctl = read_brdctl(ahc);	*internal50_present = (brdctl & BRDDAT6) ? 0 : 1;	*internal68_present = (brdctl & BRDDAT7) ? 0 : 1;	/*	 * Set the rom bank to 1 and determine	 * the other signals.	 */	write_brdctl(ahc, BRDDAT5);	/*	 * Now read the state of the external	 * connectors.  BRDDAT6 is EXT68 and	 * BRDDAT7 is EPROMPS.	 */	brdctl = read_brdctl(ahc);	*externalcable_present = (brdctl & BRDDAT6) ? 0 : 1;	*eeprom_present = (brdctl & BRDDAT7) ? 1 : 0;}static voidaic785X_cable_detect(struct ahc_softc *ahc, int *internal50_present,		     int *externalcable_present, int *eeprom_present){	uint8_t brdctl;	ahc_outb(ahc, BRDCTL, BRDRW|BRDCS);	ahc_outb(ahc, BRDCTL, 0);	brdctl = ahc_inb(ahc, BRDCTL);	*internal50_present = (brdctl & BRDDAT5) ? 0 : 1;	*externalcable_present = (brdctl & BRDDAT6) ? 0 : 1;	*eeprom_present = (ahc_inb(ahc, SPIOCAP) & EEPROM) ? 1 : 0;}	static intacquire_seeprom(struct ahc_softc *ahc, struct seeprom_descriptor *sd){	int wait;	if ((ahc->features & AHC_SPIOCAP) != 0	 && (ahc_inb(ahc, SPIOCAP) & SEEPROM) == 0)		return (0);	/*	 * Request access of the memory port.  When access is	 * granted, SEERDY will go high.  We use a 1 second	 * timeout which should be near 1 second more than	 * is needed.  Reason: after the chip reset, there	 * should be no contention.	 */	SEEPROM_OUTB(sd, sd->sd_MS);	wait = 1000;  /* 1 second timeout in msec */	while (--wait && ((SEEPROM_STATUS_INB(sd) & sd->sd_RDY) == 0)) {		ahc_delay(1000);  /* delay 1 msec */	}	if ((SEEPROM_STATUS_INB(sd) & sd->sd_RDY) == 0) {		SEEPROM_OUTB(sd, 0); 		return (0);	}	return(1);}static voidrelease_seeprom(struct seeprom_descriptor *sd){	/* Release access to the memory port and the serial EEPROM. */	SEEPROM_OUTB(sd, 0);}static voidwrite_brdctl(struct ahc_softc *ahc, uint8_t value){	uint8_t brdctl;	if ((ahc->chip & AHC_CHIPID_MASK) == AHC_AIC7895) {		brdctl = BRDSTB;	 	if (ahc->channel == 'B')			brdctl |= BRDCS;	} else if ((ahc->features & AHC_ULTRA2) != 0) {		brdctl = 0;	} else {		brdctl = BRDSTB|BRDCS;	}	ahc_outb(ahc, BRDCTL, brdctl);	ahc_flush_device_writes(ahc);	brdctl |= value;	ahc_outb(ahc, BRDCTL, brdctl);	ahc_flush_device_writes(ahc);	if ((ahc->features & AHC_ULTRA2) != 0)		brdctl |= BRDSTB_ULTRA2;	else		brdctl &= ~BRDSTB;	ahc_outb(ahc, BRDCTL, brdctl);	ahc_flush_device_writes(ahc);	if ((ahc->features & AHC_ULTRA2) != 0)		brdctl = 0;	else		brdctl &= ~BRDCS;	ahc_outb(ahc, BRDCTL, brdctl);}static uint8_tread_brdctl(ahc)	struct 	ahc_softc *ahc;{	uint8_t brdctl;	uint8_t value;	if ((ahc->chip & AHC_CHIPID_MASK) == AHC_AIC7895) {		brdctl = BRDRW;	 	if (ahc->channel == 'B')			brdctl |= BRDCS;	} else if ((ahc->features & AHC_ULTRA2) != 0) {		brdctl = BRDRW_ULTRA2;	} else {		brdctl = BRDRW|BRDCS;	}	ahc_outb(ahc, BRDCTL, brdctl);	ahc_flush_device_writes(ahc);	value = ahc_inb(ahc, BRDCTL);	ahc_outb(ahc, BRDCTL, 0);	return (value);}#define	DPE	0x80#define SSE	0x40#define	RMA	0x20#define	RTA	0x10#define STA	0x08#define DPR	0x01voidahc_pci_intr(struct ahc_softc *ahc){	u_int error;	u_int status1;	error = ahc_inb(ahc, ERROR);	if ((error & PCIERRSTAT) == 0)		return;	status1 = ahc_pci_read_config(ahc->dev_softc,				      PCIR_STATUS + 1, /*bytes*/1);	printf("%s: PCI error Interrupt at seqaddr = 0x%x\n",	      ahc_name(ahc),	      ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));	if (status1 & DPE) {		printf("%s: Data Parity Error Detected during address "		       "or write data phase\n", ahc_name(ahc));	}	if (status1 & SSE) {		printf("%s: Signal System Error Detected\n", ahc_name(ahc));	}	if (status1 & RMA) {		printf("%s: Received a Master Abort\n", ahc_name(ahc));	}	if (status1 & RTA) {		printf("%s: Received a Target Abort\n", ahc_name(ahc));	}	if (status1 & STA) {		printf("%s: Signaled a Target Abort\n", ahc_name(ahc));	}	if (status1 & DPR) {		printf("%s: Data Parity Error has been reported via PERR#\n",		       ahc_name(ahc));	}	/* Clear latched errors. */	ahc_pci_write_config(ahc->dev_softc, PCIR_STATUS + 1,			     status1, /*bytes*/1);	if ((status1 & (DPE|SSE|RMA|RTA|STA|DPR)) == 0) {		printf("%s: Latched PCIERR interrupt with "		       "no status bits set\n", ahc_name(ahc)); 	} else {		ahc_outb(ahc, CLRINT, CLRPARERR);	}	ahc_unpause(ahc);}static intahc_aic785X_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	uint8_t rev;	pci = ahc->dev_softc;	ahc->channel = 'A';	ahc->chip = AHC_AIC7850;	ahc->features = AHC_AIC7850_FE;	ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);	if (rev >= 1)		ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;	return (0);}static intahc_aic7860_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	uint8_t rev;	pci = ahc->dev_softc;	ahc->channel = 'A';	ahc->chip = AHC_AIC7860;	ahc->features = AHC_AIC7860_FE;	ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);	if (rev >= 1)		ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;	return (0);}static intahc_apa1480_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	int error;	pci = ahc->dev_softc;	error = ahc_aic7860_setup(ahc);	if (error != 0)		return (error);	ahc->features |= AHC_REMOVABLE;	return (0);}static intahc_aic7870_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	ahc->channel = 'A';	ahc->chip = AHC_AIC7870;	ahc->features = AHC_AIC7870_FE;	ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;	return (0);}static intahc_aha394X_setup(struct ahc_softc *ahc){	int error;	error = ahc_aic7870_setup(ahc);	if (error == 0)		error = ahc_aha394XX_setup(ahc);	return (error);}static intahc_aha398X_setup(struct ahc_softc *ahc){	int error;	error = ahc_aic7870_setup(ahc);	if (error == 0)		error = ahc_aha398XX_setup(ahc);	return (error);}static intahc_aha494X_setup(struct ahc_softc *ahc){	int error;	error = ahc_aic7870_setup(ahc);	if (error == 0)		error = ahc_aha494XX_setup(ahc);	return (error);}static intahc_aic7880_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	uint8_t rev;	pci = ahc->dev_softc;	ahc->channel = 'A';	ahc->chip = AHC_AIC7880;	ahc->features = AHC_AIC7880_FE;	ahc->bugs |= AHC_TMODE_WIDEODD_BUG;	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);	if (rev >= 1) {		ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;	} else {		ahc->bugs |= AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;	}	return (0);}static intahc_aha2940Pro_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	int error;	pci = ahc->dev_softc;	ahc->flags |= AHC_INT50_SPEEDFLEX;	error = ahc_aic7880_setup(ahc);	return (0);}static intahc_aha394XU_setup(struct ahc_softc *ahc){	int error;	error = ahc_aic7880_setup(ahc);	if (error == 0)		error = ahc_aha394XX_setup(ahc);	return (error);}static intahc_aha398XU_setup(struct ahc_softc *ahc){	int error;	error = ahc_aic7880_setup(ahc);	if (error == 0)		error = ahc_aha398XX_setup(ahc);	return (error);}static intahc_aic7890_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	uint8_t rev;	pci = ahc->dev_softc;	ahc->channel = 'A';	ahc->chip = AHC_AIC7890;	ahc->features = AHC_AIC7890_FE;	ahc->flags |= AHC_NEWEEPROM_FMT;	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);	if (rev == 0)		ahc->bugs |= AHC_AUTOFLUSH_BUG|AHC_CACHETHEN_BUG;	return (0);}static intahc_aic7892_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	ahc->channel = 'A';	ahc->chip = AHC_AIC7892;	ahc->features = AHC_AIC7892_FE;	ahc->flags |= AHC_NEWEEPROM_FMT;	ahc->bugs |= AHC_SCBCHAN_UPLOAD_BUG;	return (0);}static intahc_aic7895_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	uint8_t rev;	pci = ahc->dev_softc;	ahc->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';	/*	 * The 'C' revision of the aic7895 has a few additional features.	 */	rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);	if (rev >= 4) {		ahc->chip = AHC_AIC7895C;		ahc->features = AHC_AIC7895C_FE;	} else  {		u_int command;		ahc->chip = AHC_AIC7895;		ahc->features = AHC_AIC7895_FE;		/*		 * The BIOS disables the use of MWI transactions		 * since it does not have the MWI bug work around		 * we have.  Disabling MWI reduces performance, so		 * turn it on again.		 */		command = ahc_pci_read_config(pci, PCIR_COMMAND, /*bytes*/1);		command |= PCIM_CMD_MWRICEN;		ahc_pci_write_config(pci, PCIR_COMMAND, command, /*bytes*/1);		ahc->bugs |= AHC_PCI_MWI_BUG;	}	/*	 * XXX Does CACHETHEN really not work???  What about PCI retry?	 * on C level chips.  Need to test, but for now, play it safe.	 */	ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_PCI_2_1_RETRY_BUG		  |  AHC_CACHETHEN_BUG;#if 0	uint32_t devconfig;	/*	 * Cachesize must also be zero due to stray DAC	 * problem when sitting behind some bridges.	 */	ahc_pci_write_config(pci, CSIZE_LATTIME, 0, /*bytes*/1);	devconfig = ahc_pci_read_config(pci, DEVCONFIG, /*bytes*/1);	devconfig |= MRDCEN;	ahc_pci_write_config(pci, DEVCONFIG, devconfig, /*bytes*/1);#endif	ahc->flags |= AHC_NEWEEPROM_FMT;	return (0);}static intahc_aic7896_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	ahc->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';	ahc->chip = AHC_AIC7896;	ahc->features = AHC_AIC7896_FE;	ahc->flags |= AHC_NEWEEPROM_FMT;	ahc->bugs |= AHC_CACHETHEN_DIS_BUG;	return (0);}static intahc_aic7899_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	ahc->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';	ahc->chip = AHC_AIC7899;	ahc->features = AHC_AIC7899_FE;	ahc->flags |= AHC_NEWEEPROM_FMT;	ahc->bugs |= AHC_SCBCHAN_UPLOAD_BUG;	return (0);}static intahc_aha29160C_setup(struct ahc_softc *ahc){	int error;	error = ahc_aic7899_setup(ahc);	if (error != 0)		return (error);	ahc->features |= AHC_REMOVABLE;	return (0);}static intahc_raid_setup(struct ahc_softc *ahc){	printf("RAID functionality unsupported\n");	return (ENXIO);}static intahc_aha394XX_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	switch (ahc_get_pci_slot(pci)) {	case AHC_394X_SLOT_CHANNEL_A:		ahc->channel = 'A';		break;	case AHC_394X_SLOT_CHANNEL_B:		ahc->channel = 'B';		break;	default:		printf("adapter at unexpected slot %d\n"		       "unable to map to a channel\n",		       ahc_get_pci_slot(pci));		ahc->channel = 'A';	}	return (0);}static intahc_aha398XX_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	switch (ahc_get_pci_slot(pci)) {	case AHC_398X_SLOT_CHANNEL_A:		ahc->channel = 'A';		break;	case AHC_398X_SLOT_CHANNEL_B:		ahc->channel = 'B';		break;	case AHC_398X_SLOT_CHANNEL_C:		ahc->channel = 'C';		break;	default:		printf("adapter at unexpected slot %d\n"		       "unable to map to a channel\n",		       ahc_get_pci_slot(pci));		ahc->channel = 'A';		break;	}	ahc->flags |= AHC_LARGE_SEEPROM;	return (0);}static intahc_aha494XX_setup(struct ahc_softc *ahc){	ahc_dev_softc_t pci;	pci = ahc->dev_softc;	switch (ahc_get_pci_slot(pci)) {	case AHC_494X_SLOT_CHANNEL_A:		ahc->channel = 'A';		break;	case AHC_494X_SLOT_CHANNEL_B:		ahc->channel = 'B';		break;	case AHC_494X_SLOT_CHANNEL_C:		ahc->channel = 'C';		break;	case AHC_494X_SLOT_CHANNEL_D:		ahc->channel = 'D';		break;	default:		printf("adapter at unexpected slot %d\n"		       "unable to map to a channel\n",		       ahc_get_pci_slot(pci));		ahc->channel = 'A';	}	ahc->flags |= AHC_LARGE_SEEPROM;	return (0);}

⌨️ 快捷键说明

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