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

📄 via82cxxx.c

📁 em85xx的大硬盘修正代码包
💻 C
📖 第 1 页 / 共 2 页
字号:
	pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)),		((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1));	pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn),		((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1));	switch (via_config->flags & VIA_UDMA) {		case VIA_UDMA_33:  t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break;		case VIA_UDMA_66:  t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break;		case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break;		default: return;	}	pci_write_config_byte(dev, VIA_UDMA_TIMING + (3 - dn), t);}/* * via_set_drive() computes timing values configures the drive and * the chipset to a desired transfer mode. It also can be called * by upper layers. */static int via_set_drive(ide_drive_t *drive, unsigned char speed){	ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1);	struct ide_timing t, p;	int T, UT;	if (speed != XFER_PIO_SLOW && speed != drive->current_speed)		if (ide_config_drive_speed(drive, speed))			printk(KERN_WARNING "ide%d: Drive %d didn't accept speed setting. Oh, well.\n",				drive->dn >> 1, drive->dn & 1);	T = 1000 / via_clock;	switch (via_config->flags & VIA_UDMA) {		case VIA_UDMA_33:   UT = T;   break;		case VIA_UDMA_66:   UT = T/2; break;		case VIA_UDMA_100:  UT = T/3; break;		default:	    UT = T;   break;	}	ide_timing_compute(drive, speed, &t, T, UT);	if (peer->present) {		ide_timing_compute(peer, peer->current_speed, &p, T, UT);		ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT);	}	via_set_speed(HWIF(drive)->pci_dev, drive->dn, &t);	if (!drive->init_speed)		drive->init_speed = speed;	drive->current_speed = speed;	return 0;}/* * via82cxxx_tune_drive() is a callback from upper layers for * PIO-only tuning. */static void via82cxxx_tune_drive(ide_drive_t *drive, unsigned char pio){	if (!((via_enabled >> HWIF(drive)->channel) & 1))		return;	if (pio == 255) {		via_set_drive(drive, ide_find_best_mode(drive, XFER_PIO | XFER_EPIO));		return;	}	via_set_drive(drive, XFER_PIO_0 + MIN(pio, 5));}#ifdef CONFIG_BLK_DEV_IDEDMA/* * via82cxxx_dmaproc() is a callback from upper layers that can do * a lot, but we use it for DMA/PIO tuning only, delegating everything * else to the default ide_dmaproc(). */int via82cxxx_dmaproc(ide_dma_action_t func, ide_drive_t *drive){	if (func == ide_dma_check) {		short w80 = HWIF(drive)->udma_four;		short speed = ide_find_best_mode(drive,			XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA |			(via_config->flags & VIA_UDMA ? XFER_UDMA : 0) |			(w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) |			(w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0));		via_set_drive(drive, speed);		func = (HWIF(drive)->autodma && (speed & XFER_MODE) != XFER_PIO)			? ide_dma_on : ide_dma_off_quietly;	}	return ide_dmaproc(func, drive);}#endif /* CONFIG_BLK_DEV_IDEDMA *//* * The initialization callback. Here we determine the IDE chip type * and initialize its drive independent registers. */unsigned int __init pci_init_via82cxxx(struct pci_dev *dev, const char *name){	struct pci_dev *isa = NULL;	unsigned char t, v;	unsigned int u;	int i;/* * Find the ISA bridge to see how good the IDE is. */	for (via_config = via_isa_bridges; via_config->id; via_config++)		if ((isa = pci_find_device(PCI_VENDOR_ID_VIA, via_config->id, NULL))) {			pci_read_config_byte(isa, PCI_REVISION_ID, &t);			if (t >= via_config->rev_min && t <= via_config->rev_max)				break;		}	if (!via_config->id) {		printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, contact Vojtech Pavlik <vojtech@suse.cz>\n");		return -ENODEV;	}/* * Check 80-wire cable presence and setup Clk66. */	switch (via_config->flags & VIA_UDMA) {		case VIA_UDMA_100:			pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);			for (i = 24; i >= 0; i -= 8)				if (((u >> i) & 0x10) || (((u >> i) & 0x20) && (((u >> i) & 7) < 3)))					via_80w |= (1 << (1 - (i >> 4)));	/* BIOS 80-wire bit or UDMA w/ < 50ns/cycle */			break;		case VIA_UDMA_66:			pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);	/* Enable Clk66 */			pci_write_config_dword(dev, VIA_UDMA_TIMING, u | 0x80008);			for (i = 24; i >= 0; i -= 8)				if (((u >> (i & 16)) & 8) && ((u >> i) & 0x20) && (((u >> i) & 7) < 2))					via_80w |= (1 << (1 - (i >> 4)));	/* 2x PCI clock and UDMA w/ < 3T/cycle */			break;	}	if (via_config->flags & VIA_BAD_CLK66) {			/* Disable Clk66 */		pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);	/* Would cause trouble on 596a and 686 */		pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008);	}/* * Check whether interfaces are enabled. */	pci_read_config_byte(dev, VIA_IDE_ENABLE, &v);	via_enabled = ((v & 1) ? 2 : 0) | ((v & 2) ? 1 : 0);/* * Set up FIFO sizes and thresholds. */	pci_read_config_byte(dev, VIA_FIFO_CONFIG, &t);	if (via_config->flags & VIA_BAD_PREQ)				/* Disable PREQ# till DDACK# */		t &= 0x7f;						/* Would crash on 586b rev 41 */	if (via_config->flags & VIA_SET_FIFO) {				/* Fix FIFO split between channels */		t &= (t & 0x9f);		switch (via_enabled) {			case 1: t |= 0x00; break;			/* 16 on primary */			case 2: t |= 0x60; break;			/* 16 on secondary */			case 3: t |= 0x20; break;			/* 8 pri 8 sec */		}	}	pci_write_config_byte(dev, VIA_FIFO_CONFIG, t);/* * Determine system bus clock. */	via_clock = system_bus_clock();	if (via_clock < 20 || via_clock > 50) {		printk(KERN_WARNING "VP_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", via_clock);		printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want to force UDMA66/UDMA100.\n");		via_clock = 33;	}/* * Print the boot message. */	pci_read_config_byte(isa, PCI_REVISION_ID, &t);	printk(KERN_INFO "VP_IDE: VIA %s (rev %02x) IDE %s controller on pci%s\n",		via_config->name, t, via_dma[via_config->flags & VIA_UDMA], dev->slot_name);/* * Setup /proc/ide/via entry. */#ifdef CONFIG_PROC_FS	if (!via_proc) {		via_base = pci_resource_start(dev, 4);		bmide_dev = dev;		isa_dev = isa;		via_display_info = &via_get_info;		via_proc = 1;	}#endif	return 0;}unsigned int __init ata66_via82cxxx(ide_hwif_t *hwif){	return ((via_enabled & via_80w) >> hwif->channel) & 1;}void __init ide_init_via82cxxx(ide_hwif_t *hwif){	int i;	hwif->tuneproc = &via82cxxx_tune_drive;	hwif->speedproc = &via_set_drive;	hwif->autodma = 0;	for (i = 0; i < 2; i++) {		hwif->drives[i].io_32bit = 1;		hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1;		hwif->drives[i].autotune = 1;		hwif->drives[i].dn = hwif->channel * 2 + i;	}#ifdef CONFIG_BLK_DEV_IDEDMA	if (hwif->dma_base) {		hwif->dmaproc = &via82cxxx_dmaproc;#ifdef CONFIG_IDEDMA_AUTO		if (!noautodma)			hwif->autodma = 1;#endif	}#endif /* CONFIG_BLK_DEV_IDEDMA */}/* * We allow the BM-DMA driver to only work on enabled interfaces. */void __init ide_dmacapable_via82cxxx(ide_hwif_t *hwif, unsigned long dmabase){	if ((via_enabled >> hwif->channel) & 1)		ide_setup_dma(hwif, dmabase, 8);}

⌨️ 快捷键说明

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