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

📄 alim15x3.c

📁 at91rm9200处理器ide接口驱动程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif /* CONFIG_BLK_DEV_IDEDMA */	drive->current_speed = speed;	return (err);}static void config_chipset_for_pio (ide_drive_t *drive){	ali15x3_tune_drive(drive, 5);}#ifdef CONFIG_BLK_DEV_IDEDMAstatic int config_chipset_for_dma (ide_drive_t *drive, byte ultra33){	struct hd_driveid *id	= drive->id;	byte speed		= 0x00;	byte ultra66		= eighty_ninty_three(drive);	byte ultra100		= (m5229_revision>=0xc4) ? 1 : 0;	int  rval;	if ((id->dma_ultra & 0x0020) && (ultra100) && (ultra66) && (ultra33)) {		speed = XFER_UDMA_5;	} else if ((id->dma_ultra & 0x0010) && (ultra66) && (ultra33)) {		speed = XFER_UDMA_4;	} else if ((id->dma_ultra & 0x0008) && (ultra66) && (ultra33)) {		speed = XFER_UDMA_3;	} else if ((id->dma_ultra & 0x0004) && (ultra33)) {		speed = XFER_UDMA_2;	} else if ((id->dma_ultra & 0x0002) && (ultra33)) {		speed = XFER_UDMA_1;	} else if ((id->dma_ultra & 0x0001) && (ultra33)) {		speed = XFER_UDMA_0;	} else if (id->dma_mword & 0x0004) {		speed = XFER_MW_DMA_2;	} else if (id->dma_mword & 0x0002) {		speed = XFER_MW_DMA_1;	} else if (id->dma_mword & 0x0001) {		speed = XFER_MW_DMA_0;	} else if (id->dma_1word & 0x0004) {		speed = XFER_SW_DMA_2;	} else if (id->dma_1word & 0x0002) {		speed = XFER_SW_DMA_1;	} else if (id->dma_1word & 0x0001) {		speed = XFER_SW_DMA_0;	} else {		return ((int) ide_dma_off_quietly);	}	(void) ali15x3_tune_chipset(drive, speed);	if (!drive->init_speed)		drive->init_speed = speed;	rval = (int)(	((id->dma_ultra >> 11) & 3) ? ide_dma_on :			((id->dma_ultra >> 8) & 7) ? ide_dma_on :			((id->dma_mword >> 8) & 7) ? ide_dma_on :			((id->dma_1word >> 8) & 7) ? ide_dma_on :						     ide_dma_off_quietly);	return rval;}static byte ali15x3_can_ultra (ide_drive_t *drive){#ifndef CONFIG_WDC_ALI15X3	struct hd_driveid *id	= drive->id;#endif /* CONFIG_WDC_ALI15X3 */	if (m5229_revision <= 0x20) {		return 0;	} else if ((m5229_revision < 0xC2) &&#ifndef CONFIG_WDC_ALI15X3		   ((chip_is_1543c_e && strstr(id->model, "WDC ")) ||		    (drive->media!=ide_disk))) {#else /* CONFIG_WDC_ALI15X3 */		   (drive->media!=ide_disk)) {#endif /* CONFIG_WDC_ALI15X3 */		return 0;	} else {		return 1;	}}static int ali15x3_config_drive_for_dma(ide_drive_t *drive){	struct hd_driveid *id		= drive->id;	ide_hwif_t *hwif		= HWIF(drive);	ide_dma_action_t dma_func	= ide_dma_on;	byte can_ultra_dma		= ali15x3_can_ultra(drive);	if ((m5229_revision<=0x20) && (drive->media!=ide_disk))		return hwif->dmaproc(ide_dma_off_quietly, drive);	if ((id != NULL) && ((id->capability & 1) != 0) && hwif->autodma) {		/* Consult the list of known "bad" drives */		if (ide_dmaproc(ide_dma_bad_drive, drive)) {			dma_func = ide_dma_off;			goto fast_ata_pio;		}		dma_func = ide_dma_off_quietly;		if ((id->field_valid & 4) && (m5229_revision >= 0xC2)) {			if (id->dma_ultra & 0x003F) {				/* Force if Capable UltraDMA */				dma_func = config_chipset_for_dma(drive, can_ultra_dma);				if ((id->field_valid & 2) &&				    (dma_func != ide_dma_on))					goto try_dma_modes;			}		} else if (id->field_valid & 2) {try_dma_modes:			if ((id->dma_mword & 0x0007) ||			    (id->dma_1word & 0x0007)) {				/* Force if Capable regular DMA modes */				dma_func = config_chipset_for_dma(drive, can_ultra_dma);				if (dma_func != ide_dma_on)					goto no_dma_set;			}		} else if (ide_dmaproc(ide_dma_good_drive, drive)) {			if (id->eide_dma_time > 150) {				goto no_dma_set;			}			/* Consult the list of known "good" drives */			dma_func = config_chipset_for_dma(drive, can_ultra_dma);			if (dma_func != ide_dma_on)				goto no_dma_set;		} else {			goto fast_ata_pio;		}	} else if ((id->capability & 8) || (id->field_valid & 2)) {fast_ata_pio:		dma_func = ide_dma_off_quietly;no_dma_set:		config_chipset_for_pio(drive);	}	return hwif->dmaproc(dma_func, drive);}static int ali15x3_dmaproc (ide_dma_action_t func, ide_drive_t *drive){	switch(func) {		case ide_dma_check:			return ali15x3_config_drive_for_dma(drive);		case ide_dma_write:			if ((m5229_revision < 0xC2) && (drive->media != ide_disk))				return 1;	/* try PIO instead of DMA */			break;		default:			break;	}	return ide_dmaproc(func, drive);	/* use standard DMA stuff */}#endif /* CONFIG_BLK_DEV_IDEDMA */unsigned int __init pci_init_ali15x3 (struct pci_dev *dev, const char *name){	unsigned long fixdma_base = pci_resource_start(dev, 4);	pci_read_config_byte(dev, PCI_REVISION_ID, &m5229_revision);	isa_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);	if (!fixdma_base) {		/*		 *		 */	} else {		/*		 * enable DMA capable bit, and "not" simplex only		 */		outb(inb(fixdma_base+2) & 0x60, fixdma_base+2);		if (inb(fixdma_base+2) & 0x80)			printk("%s: simplex device: DMA will fail!!\n", name);	}#if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS)	if (!ali_proc) {		ali_proc = 1;		bmide_dev = dev;		ali_display_info = &ali_get_info;	}#endif  /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) */	return 0;}/* * This checks if the controller and the cable are capable * of UDMA66 transfers. It doesn't check the drives. * But see note 2 below! */unsigned int __init ata66_ali15x3 (ide_hwif_t *hwif){	struct pci_dev *dev	= hwif->pci_dev;	unsigned int ata66	= 0;	byte cable_80_pin[2]	= { 0, 0 };	unsigned long flags;	byte tmpbyte;	__save_flags(flags);	__cli();	if (m5229_revision >= 0xC2) {		/*		 * 1543C-B?, 1535, 1535D, 1553		 * Note 1: not all "motherboard" support this detection		 * Note 2: if no udma 66 device, the detection may "error".		 *         but in this case, we will not set the device to		 *         ultra 66, the detection result is not important		 */		/*		 * enable "Cable Detection", m5229, 0x4b, bit3		 */		pci_read_config_byte(dev, 0x4b, &tmpbyte);		pci_write_config_byte(dev, 0x4b, tmpbyte | 0x08);		/*		 * set south-bridge's enable bit, m1533, 0x79		 */		pci_read_config_byte(isa_dev, 0x79, &tmpbyte);		if (m5229_revision == 0xC2) {			/*			 * 1543C-B0 (m1533, 0x79, bit 2)			 */			pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x04);		} else if (m5229_revision >= 0xC3) {			/*			 * 1553/1535 (m1533, 0x79, bit 1)			 */			pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x02);		}		/*		 * Ultra66 cable detection (from Host View)		 * m5229, 0x4a, bit0: primary, bit1: secondary 80 pin		 */		pci_read_config_byte(dev, 0x4a, &tmpbyte);		/*		 * 0x4a, bit0 is 0 => primary channel		 * has 80-pin (from host view)		 */		if (!(tmpbyte & 0x01)) cable_80_pin[0] = 1;		/*		 * 0x4a, bit1 is 0 => secondary channel		 * has 80-pin (from host view)		 */		if (!(tmpbyte & 0x02)) cable_80_pin[1] = 1;		/*		 * Allow ata66 if cable of current channel has 80 pins		 */		ata66 = (hwif->channel)?cable_80_pin[1]:cable_80_pin[0];	} else {		/*		 * revision 0x20 (1543-E, 1543-F)		 * revision 0xC0, 0xC1 (1543C-C, 1543C-D, 1543C-E)		 * clear CD-ROM DMA write bit, m5229, 0x4b, bit 7		 */		pci_read_config_byte(dev, 0x4b, &tmpbyte);		/*		 * clear bit 7		 */		pci_write_config_byte(dev, 0x4b, tmpbyte & 0x7F);		/*		 * check m1533, 0x5e, bit 1~4 == 1001 => & 00011110 = 00010010		 */		pci_read_config_byte(isa_dev, 0x5e, &tmpbyte);		chip_is_1543c_e = ((tmpbyte & 0x1e) == 0x12) ? 1: 0;	}	/*	 * CD_ROM DMA on (m5229, 0x53, bit0)	 *      Enable this bit even if we want to use PIO	 * PIO FIFO off (m5229, 0x53, bit1)	 *      The hardware will use 0x54h and 0x55h to control PIO FIFO	 */	pci_read_config_byte(dev, 0x53, &tmpbyte);	tmpbyte = (tmpbyte & (~0x02)) | 0x01;	pci_write_config_byte(dev, 0x53, tmpbyte);	__restore_flags(flags);	return(ata66);}void __init ide_init_ali15x3 (ide_hwif_t *hwif){#ifndef CONFIG_SPARC64	byte ideic, inmir;	byte irq_routing_table[] = { -1,  9, 3, 10, 4,  5, 7,  6,				      1, 11, 0, 12, 0, 14, 0, 15 };	hwif->irq = hwif->channel ? 15 : 14;	if (isa_dev) {		/*		 * read IDE interface control		 */		pci_read_config_byte(isa_dev, 0x58, &ideic);		/* bit0, bit1 */		ideic = ideic & 0x03;		/* get IRQ for IDE Controller */		if ((hwif->channel && ideic == 0x03) || (!hwif->channel && !ideic)) {			/*			 * get SIRQ1 routing table			 */			pci_read_config_byte(isa_dev, 0x44, &inmir);			inmir = inmir & 0x0f;			hwif->irq = irq_routing_table[inmir];		} else if (hwif->channel && !(ideic & 0x01)) {			/*			 * get SIRQ2 routing table			 */			pci_read_config_byte(isa_dev, 0x75, &inmir);			inmir = inmir & 0x0f;			hwif->irq = irq_routing_table[inmir];		}	}#endif /* CONFIG_SPARC64 */	hwif->tuneproc = &ali15x3_tune_drive;	hwif->drives[0].autotune = 1;	hwif->drives[1].autotune = 1;	hwif->speedproc = &ali15x3_tune_chipset;#ifdef CONFIG_BLK_DEV_IDEDMA	if ((hwif->dma_base) && (m5229_revision >= 0x20)) {		/*		 * M1543C or newer for DMAing		 */		hwif->dmaproc = &ali15x3_dmaproc;		hwif->autodma = 1;	}	if (noautodma)		hwif->autodma = 0;#else	hwif->autodma = 0;#endif /* CONFIG_BLK_DEV_IDEDMA */}void __init ide_dmacapable_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase){	if ((dmabase) && (m5229_revision < 0x20)) {		return;	}	ide_setup_dma(hwif, dmabase, 8);}

⌨️ 快捷键说明

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