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

📄 serverworks.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
📖 第 1 页 / 共 2 页
字号:
}static int config_chipset_for_dma (ide_drive_t *drive){	u8 speed = ide_dma_speed(drive, svwks_ratemask(drive));	if (!(speed))		speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL);	(void) svwks_tune_chipset(drive, speed);	return ide_dma_enable(drive);}static int svwks_config_drive_xfer_rate (ide_drive_t *drive){	ide_hwif_t *hwif	= HWIF(drive);	struct hd_driveid *id	= drive->id;	drive->init_speed = 0;	if (id && (id->capability & 1) && drive->autodma) {		/* Consult the list of known "bad" drives */		if (hwif->ide_dma_bad_drive(drive))			goto fast_ata_pio;		if (id->field_valid & 4) {			if (id->dma_ultra & hwif->ultra_mask) {				/* Force if Capable UltraDMA */				int dma = config_chipset_for_dma(drive);				if ((id->field_valid & 2) && !dma)					goto try_dma_modes;			}		} else if (id->field_valid & 2) {try_dma_modes:			if ((id->dma_mword & hwif->mwdma_mask) ||			    (id->dma_1word & hwif->swdma_mask)) {				/* Force if Capable regular DMA modes */				if (!config_chipset_for_dma(drive))					goto no_dma_set;			}		} else if (hwif->ide_dma_good_drive(drive) &&			   (id->eide_dma_time < 150)) {			/* Consult the list of known "good" drives */			if (!config_chipset_for_dma(drive))				goto no_dma_set;		} else {			goto no_dma_set;		}	} else if ((id->capability & 8) || (id->field_valid & 2)) {fast_ata_pio:no_dma_set:		config_chipset_for_pio(drive);		//	hwif->tuneproc(drive, 5);		return hwif->ide_dma_off_quietly(drive);	}	return hwif->ide_dma_on(drive);}static int svwks_ide_dma_end (ide_drive_t *drive){	/*	 *	We never place the OSB4 into a UDMA mode with a disk	 *	medium, that means the UDMA "all my data is 4 byte shifted"	 *	problem cannot occur.	 */#if 0	ide_hwif_t *hwif	= HWIF(drive);	u8 dma_stat		= hwif->INB(hwif->dma_status);	if ((dma_stat & 1) && drive->media == ide_disk)	{		printk(KERN_CRIT "Serverworks OSB4 in impossible state.\n");		printk(KERN_CRIT "Disable UDMA or if you are using Seagate then try switching disk types\n");		printk(KERN_CRIT "on this controller. Please report this event to osb4-bug@ide.cabal.tm\n");		/* Panic might sys_sync -> death by corrupt disk */		printk(KERN_CRIT "OSB4: continuing might cause disk corruption.\n");		while(1)			cpu_relax();	}#endif		return __ide_dma_end(drive);}static unsigned int __init init_chipset_svwks (struct pci_dev *dev, const char *name){	unsigned int reg;	u8 btr;	/* save revision id to determine DMA capability */	pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision);	/* force Master Latency Timer value to 64 PCICLKs */	pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);	/* OSB4 : South Bridge and IDE */	if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {		isa_dev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,			  PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL);		if (isa_dev) {			pci_read_config_dword(isa_dev, 0x64, &reg);			reg &= ~0x00002000; /* disable 600ns interrupt mask */			if(!(reg & 0x00004000))				printk(KERN_DEBUG "%s: UDMA not BIOS enabled.\n", name);			reg |=  0x00004000; /* enable UDMA/33 support */			pci_write_config_dword(isa_dev, 0x64, reg);		}	}	/* setup CSB5/CSB6 : South Bridge and IDE option RAID */	else if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||		 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||		 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {//		u32 pioreg = 0, dmareg = 0;		/* Third Channel Test */		if (!(PCI_FUNC(dev->devfn) & 1)) {#if 1			struct pci_dev * findev = NULL;			u32 reg4c = 0;			findev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,				PCI_DEVICE_ID_SERVERWORKS_CSB5, NULL);			if (findev) {				pci_read_config_dword(findev, 0x4C, &reg4c);				reg4c &= ~0x000007FF;				reg4c |=  0x00000040;				reg4c |=  0x00000020;				pci_write_config_dword(findev, 0x4C, reg4c);			}#endif			outb_p(0x06, 0x0c00);			dev->irq = inb_p(0x0c01);#if 0			/* WE need to figure out how to get the correct one */			printk("%s: interrupt %d\n", name, dev->irq);			if (dev->irq != 0x0B)				dev->irq = 0x0B;#endif#if 0			printk("%s: device class (0x%04x)\n",				name, dev->class);#else			if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {				dev->class &= ~0x000F0F00;		//		dev->class |= ~0x00000400;				dev->class |= ~0x00010100;				/**/			}#endif		} else {			struct pci_dev * findev = NULL;			u8 reg41 = 0;			findev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,					PCI_DEVICE_ID_SERVERWORKS_CSB6, NULL);			if (findev) {				pci_read_config_byte(findev, 0x41, &reg41);				reg41 &= ~0x40;				pci_write_config_byte(findev, 0x41, reg41);			}			/*			 * This is a device pin issue on CSB6.			 * Since there will be a future raid mode,			 * early versions of the chipset require the			 * interrupt pin to be set, and it is a compatablity			 * mode issue.			 */			dev->irq = 0;		}//		pci_read_config_dword(dev, 0x40, &pioreg)//		pci_write_config_dword(dev, 0x40, 0x99999999);//		pci_read_config_dword(dev, 0x44, &dmareg);//		pci_write_config_dword(dev, 0x44, 0xFFFFFFFF);		/* setup the UDMA Control register		 *		 * 1. clear bit 6 to enable DMA		 * 2. enable DMA modes with bits 0-1		 * 	00 : legacy		 * 	01 : udma2		 * 	10 : udma2/udma4		 * 	11 : udma2/udma4/udma5		 */		pci_read_config_byte(dev, 0x5A, &btr);		btr &= ~0x40;		if (!(PCI_FUNC(dev->devfn) & 1))			btr |= 0x2;		else			btr |= (svwks_revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;		pci_write_config_byte(dev, 0x5A, btr);	}#if defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS)	svwks_devs[n_svwks_devs++] = dev;	if (!svwks_proc) {		svwks_proc = 1;		ide_pci_register_host_proc(&svwks_procs[0]);	}#endif /* DISPLAY_SVWKS_TIMINGS && CONFIG_PROC_FS */	return (dev->irq) ? dev->irq : 0;}static unsigned int __init ata66_svwks_svwks (ide_hwif_t *hwif){//	struct pci_dev *dev = hwif->pci_dev;//	return 0;	return 1;}/* On Dell PowerEdge servers with a CSB5/CSB6, the top two bits * of the subsystem device ID indicate presence of an 80-pin cable. * Bit 15 clear = secondary IDE channel does not have 80-pin cable. * Bit 15 set   = secondary IDE channel has 80-pin cable. * Bit 14 clear = primary IDE channel does not have 80-pin cable. * Bit 14 set   = primary IDE channel has 80-pin cable. */static unsigned int __init ata66_svwks_dell (ide_hwif_t *hwif){	struct pci_dev *dev = hwif->pci_dev;	if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL &&	    dev->vendor	== PCI_VENDOR_ID_SERVERWORKS &&	    (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ||	     dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE))		return ((1 << (hwif->channel + 14)) &			dev->subsystem_device) ? 1 : 0;	return 0;}/* Sun Cobalt Alpine hardware avoids the 80-pin cable * detect issue by attaching the drives directly to the board. * This check follows the Dell precedent (how scary is that?!) * * WARNING: this only works on Alpine hardware! */static unsigned int __init ata66_svwks_cobalt (ide_hwif_t *hwif){	struct pci_dev *dev = hwif->pci_dev;	if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN &&	    dev->vendor	== PCI_VENDOR_ID_SERVERWORKS &&	    dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)		return ((1 << (hwif->channel + 14)) &			dev->subsystem_device) ? 1 : 0;	return 0;}static unsigned int __init ata66_svwks (ide_hwif_t *hwif){	struct pci_dev *dev = hwif->pci_dev;	/* Per Specified Design by OEM, and ASIC Architect */	if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||	    (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))		return 1;	/* Server Works */	if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS)		return ata66_svwks_svwks (hwif);		/* Dell PowerEdge */	if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL)		return ata66_svwks_dell (hwif);	/* Cobalt Alpine */	if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN)		return ata66_svwks_cobalt (hwif);	return 0;}#undef CAN_SW_DMAstatic void __init init_hwif_svwks (ide_hwif_t *hwif){	u8 dma_stat = 0;	if (!hwif->irq)		hwif->irq = hwif->channel ? 15 : 14;	hwif->tuneproc = &svwks_tune_drive;	hwif->speedproc = &svwks_tune_chipset;	hwif->atapi_dma = 1;	if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)		hwif->ultra_mask = 0x3f;	hwif->mwdma_mask = 0x07;#ifdef CAN_SW_DMA	hwif->swdma_mask = 0x07;#endif /* CAN_SW_DMA */	hwif->autodma = 0;	if (!hwif->dma_base) {		hwif->drives[0].autotune = 1;		hwif->drives[1].autotune = 1;		return;	}	hwif->ide_dma_check = &svwks_config_drive_xfer_rate;	if (hwif->pci_dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)		hwif->ide_dma_end = &svwks_ide_dma_end;	else if (!(hwif->udma_four))		hwif->udma_four = ata66_svwks(hwif);	if (!noautodma)		hwif->autodma = 1;	dma_stat = hwif->INB(hwif->dma_status);	hwif->drives[0].autodma = (dma_stat & 0x20);	hwif->drives[1].autodma = (dma_stat & 0x40);	hwif->drives[0].autotune = (!(dma_stat & 0x20));	hwif->drives[1].autotune = (!(dma_stat & 0x40));//	hwif->drives[0].autodma = hwif->autodma;//	hwif->drives[1].autodma = hwif->autodma;}/* * We allow the BM-DMA driver to only work on enabled interfaces. */static void __init init_dma_svwks (ide_hwif_t *hwif, unsigned long dmabase){	struct pci_dev *dev = hwif->pci_dev;	if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||	     (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&	    (!(PCI_FUNC(dev->devfn) & 1)) && (hwif->channel))		return;	ide_setup_dma(hwif, dmabase, 8);}extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);static void __init init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d){	ide_setup_pci_device(dev, d);}static void __init init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d){	if (!(PCI_FUNC(dev->devfn) & 1)) {		d->bootable = NEVER_BOARD;		if (dev->resource[0].start == 0x01f1)			d->bootable = ON_BOARD;	} else {		if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE)			return;	}#if 0	if ((IDE_PCI_DEVID_EQ(d->devid, DEVID_CSB6) &&             (!(PCI_FUNC(dev->devfn) & 1)))		d->autodma = AUTODMA;#endif	d->channels = (((d->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||			(d->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&		       (!(PCI_FUNC(dev->devfn) & 1))) ? 1 : 2;	ide_setup_pci_device(dev, d);}/** *	svwks_init_one	-	called when a OSB/CSB is found *	@dev: the svwks device *	@id: the matching pci id * *	Called when the PCI registration layer (or the IDE initialization) *	finds a device matching our IDE device tables. */ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device_id *id){	ide_pci_device_t *d = &serverworks_chipsets[id->driver_data];	if (dev->device != d->device)		BUG();	d->init_setup(dev, d);	MOD_INC_USE_COUNT;	return 0;}static struct pci_device_id svwks_pci_tbl[] __devinitdata = {	{ PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},	{ PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},	{ PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},	{ PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},	{ 0, },};static struct pci_driver driver = {	.name		= "Serverworks IDE",	.id_table	= svwks_pci_tbl,	.probe		= svwks_init_one,#if 0	/* FIXME: implement */	.suspend	= ,	.resume		= ,#endif};static int svwks_ide_init(void){	return ide_pci_register_driver(&driver);}static void svwks_ide_exit(void){	ide_pci_unregister_driver(&driver);}module_init(svwks_ide_init);module_exit(svwks_ide_exit);MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick");MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE");MODULE_LICENSE("GPL");EXPORT_NO_SYMBOLS;

⌨️ 快捷键说明

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