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

📄 cy82c693.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
			}		}	}        return __ide_dma_on(drive);}/* * tune ide drive - set PIO mode */static void cy82c693_tune_drive (ide_drive_t *drive, u8 pio){	ide_hwif_t *hwif = HWIF(drive);	struct pci_dev *dev = hwif->pci_dev;	pio_clocks_t pclk;	unsigned int addrCtrl;	/* select primary or secondary channel */	if (hwif->index > 0) {  /* drive is on the secondary channel */		dev = pci_find_slot(dev->bus->number, dev->devfn+1);		if (!dev) {			printk(KERN_ERR "%s: tune_drive: "				"Cannot find secondary interface!\n",				drive->name);			return;		}	}#if CY82C693_DEBUG_LOGS	/* for debug let's show the register values */	       	if (drive->select.b.unit == 0) {		/*		 * get master drive registers               			 * address setup control register		 * is 32 bit !!!		 */ 	  	pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);                		addrCtrl &= 0x0F;		/* now let's get the remaining registers */		pci_read_config_byte(dev, CY82_IDE_MASTER_IOR, &pclk.time_16r);		pci_read_config_byte(dev, CY82_IDE_MASTER_IOW, &pclk.time_16w);		pci_read_config_byte(dev, CY82_IDE_MASTER_8BIT, &pclk.time_8);	} else {		/*		 * set slave drive registers		 * address setup control register		 * is 32 bit !!!		 */ 		pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);		addrCtrl &= 0xF0;		addrCtrl >>= 4;		/* now let's get the remaining registers */		pci_read_config_byte(dev, CY82_IDE_SLAVE_IOR, &pclk.time_16r);		pci_read_config_byte(dev, CY82_IDE_SLAVE_IOW, &pclk.time_16w);		pci_read_config_byte(dev, CY82_IDE_SLAVE_8BIT, &pclk.time_8);	}	printk(KERN_INFO "%s (ch=%d, dev=%d): PIO timing is "		"(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n",		drive->name, hwif->channel, drive->select.b.unit,		addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);#endif /* CY82C693_DEBUG_LOGS */	/* first let's calc the pio modes */	pio = ide_get_best_pio_mode(drive, pio, CY82C693_MAX_PIO, NULL);#if CY82C693_DEBUG_INFO	printk (KERN_INFO "%s: Selected PIO mode %d\n", drive->name, pio);#endif /* CY82C693_DEBUG_INFO */	/* let's calc the values for this PIO mode */	compute_clocks(pio, &pclk);	/* now let's write  the clocks registers */	if (drive->select.b.unit == 0) {		/*		 * set master drive		 * address setup control register		 * is 32 bit !!!		 */ 		pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);				addrCtrl &= (~0xF);		addrCtrl |= (unsigned int)pclk.address_time;		pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl);		/* now let's set the remaining registers */		pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, pclk.time_16r);		pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, pclk.time_16w);		pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, pclk.time_8);				addrCtrl &= 0xF;	} else {		/*		 * set slave drive		 * address setup control register		 * is 32 bit !!!		 */ 		pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);		addrCtrl &= (~0xF0);		addrCtrl |= ((unsigned int)pclk.address_time<<4);		pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl);		/* now let's set the remaining registers */		pci_write_config_byte(dev, CY82_IDE_SLAVE_IOR, pclk.time_16r);		pci_write_config_byte(dev, CY82_IDE_SLAVE_IOW, pclk.time_16w);		pci_write_config_byte(dev, CY82_IDE_SLAVE_8BIT, pclk.time_8);		addrCtrl >>= 4;		addrCtrl &= 0xF;	}	#if CY82C693_DEBUG_INFO	printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to "		"(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n",		drive->name, hwif->channel, drive->select.b.unit,		addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);#endif /* CY82C693_DEBUG_INFO */}/* * this function is called during init and is used to setup the cy82c693 chip */static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const char *name){	if (PCI_FUNC(dev->devfn) != 1)		return 0;#ifdef CY82C693_SETDMA_CLOCK	u8 data = 0;#endif /* CY82C693_SETDMA_CLOCK */ 	/* write info about this verion of the driver */	printk(KERN_INFO CY82_VERSION "\n");#ifdef CY82C693_SETDMA_CLOCK       /* okay let's set the DMA clock speed */                outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT);        data = inb(CY82_DATA_PORT);#if CY82C693_DEBUG_INFO	printk(KERN_INFO "%s: Peripheral Configuration Register: 0x%X\n",		name, data);#endif /* CY82C693_DEBUG_INFO */        /*	 * for some reason sometimes the DMA controller	 * speed is set to ATCLK/2 ???? - we fix this here	 * 	 * note: i don't know what causes this strange behaviour,	 *       but even changing the dma speed doesn't solve it :-(	 *       the ide performance is still only half the normal speed 	 * 	 *       if anybody knows what goes wrong with my machine, please	 *       let me know - ASK         */	data |= 0x03;        outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT);        outb(data, CY82_DATA_PORT);#if CY82C693_DEBUG_INFO	printk (KERN_INFO "%s: New Peripheral Configuration Register: 0x%X\n",		name, data);#endif /* CY82C693_DEBUG_INFO */#endif /* CY82C693_SETDMA_CLOCK */	return 0;}/* * the init function - called for each ide channel once */static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif){	hwif->autodma = 0;	hwif->chipset = ide_cy82c693;	hwif->tuneproc = &cy82c693_tune_drive;	if (!hwif->dma_base) {		hwif->drives[0].autotune = 1;		hwif->drives[1].autotune = 1;		return;	}	hwif->atapi_dma = 1;	hwif->mwdma_mask = 0x04;	hwif->swdma_mask = 0x04;	hwif->ide_dma_on = &cy82c693_ide_dma_on;	if (!noautodma)		hwif->autodma = 1;	hwif->drives[0].autodma = hwif->autodma;	hwif->drives[1].autodma = hwif->autodma;}static __devinitdata ide_hwif_t *primary;static void __devinit init_iops_cy82c693(ide_hwif_t *hwif){	if (PCI_FUNC(hwif->pci_dev->devfn) == 1)		primary = hwif;	else {		hwif->mate = primary;		hwif->channel = 1;	}}static ide_pci_device_t cy82c693_chipsets[] __devinitdata = {	{	/* 0 */		.name		= "CY82C693",		.init_chipset	= init_chipset_cy82c693,		.init_iops	= init_iops_cy82c693,		.init_hwif	= init_hwif_cy82c693,		.channels	= 1,		.autodma	= AUTODMA,		.bootable	= ON_BOARD,	}};static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_device_id *id){	ide_pci_device_t *d = &cy82c693_chipsets[id->driver_data];	struct pci_dev *dev2;	int ret = -ENODEV;	/* CY82C693 is more than only a IDE controller.	   Function 1 is primary IDE channel, function 2 - secondary. */        if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE &&	    PCI_FUNC(dev->devfn) == 1) {		dev2 = pci_find_slot(dev->bus->number, dev->devfn + 1);		ret = ide_setup_pci_devices(dev, dev2, d);	}	return ret;}static struct pci_device_id cy82c693_pci_tbl[] = {	{ PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},	{ 0, },};MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl);static struct pci_driver driver = {	.name		= "Cypress_IDE",	.id_table	= cy82c693_pci_tbl,	.probe		= cy82c693_init_one,};static int cy82c693_ide_init(void){	return ide_pci_register_driver(&driver);}module_init(cy82c693_ide_init);MODULE_AUTHOR("Andreas Krebs, Andre Hedrick");MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE");MODULE_LICENSE("GPL");

⌨️ 快捷键说明

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