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

📄 pata_ali.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	.qc_issue	= ata_qc_issue_prot,	.data_xfer	= ata_data_xfer,	.irq_handler	= ata_interrupt,	.irq_clear	= ata_bmdma_irq_clear,	.irq_on		= ata_irq_on,	.port_start	= ata_sff_port_start,};/* *	Port operations for DMA capable ALi without cable *	detect */static struct ata_port_operations ali_20_port_ops = {	.set_piomode	= ali_set_piomode,	.set_dmamode	= ali_set_dmamode,	.mode_filter	= ali_20_filter,	.tf_load	= ata_tf_load,	.tf_read	= ata_tf_read,	.check_status 	= ata_check_status,	.exec_command	= ata_exec_command,	.dev_select 	= ata_std_dev_select,	.dev_config	= ali_lock_sectors,	.freeze		= ata_bmdma_freeze,	.thaw		= ata_bmdma_thaw,	.error_handler	= ata_bmdma_error_handler,	.post_internal_cmd = ata_bmdma_post_internal_cmd,	.cable_detect	= ata_cable_40wire,	.bmdma_setup 	= ata_bmdma_setup,	.bmdma_start 	= ata_bmdma_start,	.bmdma_stop	= ata_bmdma_stop,	.bmdma_status 	= ata_bmdma_status,	.qc_prep 	= ata_qc_prep,	.qc_issue	= ata_qc_issue_prot,	.data_xfer	= ata_data_xfer,	.irq_handler	= ata_interrupt,	.irq_clear	= ata_bmdma_irq_clear,	.irq_on		= ata_irq_on,	.port_start	= ata_sff_port_start,};/* *	Port operations for DMA capable ALi with cable detect */static struct ata_port_operations ali_c2_port_ops = {	.set_piomode	= ali_set_piomode,	.set_dmamode	= ali_set_dmamode,	.mode_filter	= ata_pci_default_filter,	.tf_load	= ata_tf_load,	.tf_read	= ata_tf_read,	.check_atapi_dma = ali_check_atapi_dma,	.check_status 	= ata_check_status,	.exec_command	= ata_exec_command,	.dev_select 	= ata_std_dev_select,	.dev_config	= ali_lock_sectors,	.freeze		= ata_bmdma_freeze,	.thaw		= ata_bmdma_thaw,	.error_handler	= ata_bmdma_error_handler,	.post_internal_cmd = ata_bmdma_post_internal_cmd,	.cable_detect	= ali_c2_cable_detect,	.bmdma_setup 	= ata_bmdma_setup,	.bmdma_start 	= ata_bmdma_start,	.bmdma_stop	= ata_bmdma_stop,	.bmdma_status 	= ata_bmdma_status,	.qc_prep 	= ata_qc_prep,	.qc_issue	= ata_qc_issue_prot,	.data_xfer	= ata_data_xfer,	.irq_handler	= ata_interrupt,	.irq_clear	= ata_bmdma_irq_clear,	.irq_on		= ata_irq_on,	.port_start	= ata_sff_port_start,};/* *	Port operations for DMA capable ALi with cable detect and LBA48 */static struct ata_port_operations ali_c5_port_ops = {	.set_piomode	= ali_set_piomode,	.set_dmamode	= ali_set_dmamode,	.mode_filter	= ata_pci_default_filter,	.tf_load	= ata_tf_load,	.tf_read	= ata_tf_read,	.check_atapi_dma = ali_check_atapi_dma,	.check_status 	= ata_check_status,	.exec_command	= ata_exec_command,	.dev_select 	= ata_std_dev_select,	.freeze		= ata_bmdma_freeze,	.thaw		= ata_bmdma_thaw,	.error_handler	= ata_bmdma_error_handler,	.post_internal_cmd = ata_bmdma_post_internal_cmd,	.cable_detect	= ali_c2_cable_detect,	.bmdma_setup 	= ata_bmdma_setup,	.bmdma_start 	= ata_bmdma_start,	.bmdma_stop	= ata_bmdma_stop,	.bmdma_status 	= ata_bmdma_status,	.qc_prep 	= ata_qc_prep,	.qc_issue	= ata_qc_issue_prot,	.data_xfer	= ata_data_xfer,	.irq_handler	= ata_interrupt,	.irq_clear	= ata_bmdma_irq_clear,	.irq_on		= ata_irq_on,	.port_start	= ata_sff_port_start,};/** *	ali_init_chipset	-	chip setup function *	@pdev: PCI device of ATA controller * *	Perform the setup on the device that must be done both at boot *	and at resume time. */static void ali_init_chipset(struct pci_dev *pdev){	u8 tmp;	struct pci_dev *north, *isa_bridge;	/*	 * The chipset revision selects the driver operations and	 * mode data.	 */	if (pdev->revision >= 0x20 && pdev->revision < 0xC2) {		/* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */		pci_read_config_byte(pdev, 0x4B, &tmp);		/* Clear CD-ROM DMA write bit */		tmp &= 0x7F;		pci_write_config_byte(pdev, 0x4B, tmp);	} else if (pdev->revision >= 0xC2) {		/* Enable cable detection logic */		pci_read_config_byte(pdev, 0x4B, &tmp);		pci_write_config_byte(pdev, 0x4B, tmp | 0x08);	}	north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0));	isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);	if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) {		/* Configure the ALi bridge logic. For non ALi rely on BIOS.		   Set the south bridge enable bit */		pci_read_config_byte(isa_bridge, 0x79, &tmp);		if (pdev->revision == 0xC2)			pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04);		else if (pdev->revision > 0xC2 && pdev->revision < 0xC5)			pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02);	}	if (pdev->revision >= 0x20) {		/*		 * CD_ROM DMA on (0x53 bit 0). Enable this even if we want		 * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control		 * via 0x54/55.		 */		pci_read_config_byte(pdev, 0x53, &tmp);		if (pdev->revision <= 0x20)			tmp &= ~0x02;		if (pdev->revision >= 0xc7)			tmp |= 0x03;		else			tmp |= 0x01;	/* CD_ROM enable for DMA */		pci_write_config_byte(pdev, 0x53, tmp);	}	pci_dev_put(isa_bridge);	pci_dev_put(north);	ata_pci_clear_simplex(pdev);}/** *	ali_init_one		-	discovery callback *	@pdev: PCI device ID *	@id: PCI table info * *	An ALi IDE interface has been discovered. Figure out what revision *	and perform configuration work before handing it to the ATA layer */static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id){	static const struct ata_port_info info_early = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS,		.pio_mask = 0x1f,		.port_ops = &ali_early_port_ops	};	/* Revision 0x20 added DMA */	static const struct ata_port_info info_20 = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,		.pio_mask = 0x1f,		.mwdma_mask = 0x07,		.port_ops = &ali_20_port_ops	};	/* Revision 0x20 with support logic added UDMA */	static const struct ata_port_info info_20_udma = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,		.pio_mask = 0x1f,		.mwdma_mask = 0x07,		.udma_mask = 0x07,	/* UDMA33 */		.port_ops = &ali_20_port_ops	};	/* Revision 0xC2 adds UDMA66 */	static const struct ata_port_info info_c2 = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,		.pio_mask = 0x1f,		.mwdma_mask = 0x07,		.udma_mask = ATA_UDMA4,		.port_ops = &ali_c2_port_ops	};	/* Revision 0xC3 is UDMA66 for now */	static const struct ata_port_info info_c3 = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,		.pio_mask = 0x1f,		.mwdma_mask = 0x07,		.udma_mask = ATA_UDMA4,		.port_ops = &ali_c2_port_ops	};	/* Revision 0xC4 is UDMA100 */	static const struct ata_port_info info_c4 = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,		.pio_mask = 0x1f,		.mwdma_mask = 0x07,		.udma_mask = ATA_UDMA5,		.port_ops = &ali_c2_port_ops	};	/* Revision 0xC5 is UDMA133 with LBA48 DMA */	static const struct ata_port_info info_c5 = {		.sht = &ali_sht,		.flags = ATA_FLAG_SLAVE_POSS,		.pio_mask = 0x1f,		.mwdma_mask = 0x07,		.udma_mask = ATA_UDMA6,		.port_ops = &ali_c5_port_ops	};	const struct ata_port_info *ppi[] = { NULL, NULL };	u8 tmp;	struct pci_dev *isa_bridge;	/*	 * The chipset revision selects the driver operations and	 * mode data.	 */	if (pdev->revision < 0x20) {		ppi[0] = &info_early;	} else if (pdev->revision < 0xC2) {        	ppi[0] = &info_20;	} else if (pdev->revision == 0xC2) {        	ppi[0] = &info_c2;	} else if (pdev->revision == 0xC3) {        	ppi[0] = &info_c3;	} else if (pdev->revision == 0xC4) {        	ppi[0] = &info_c4;	} else        	ppi[0] = &info_c5;	ali_init_chipset(pdev);	isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);	if (isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) {		/* Are we paired with a UDMA capable chip */		pci_read_config_byte(isa_bridge, 0x5E, &tmp);		if ((tmp & 0x1E) == 0x12)	        	ppi[0] = &info_20_udma;		pci_dev_put(isa_bridge);	}	return ata_pci_init_one(pdev, ppi);}#ifdef CONFIG_PMstatic int ali_reinit_one(struct pci_dev *pdev){	ali_init_chipset(pdev);	return ata_pci_device_resume(pdev);}#endifstatic const struct pci_device_id ali[] = {	{ PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), },	{ PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), },	{ },};static struct pci_driver ali_pci_driver = {	.name 		= DRV_NAME,	.id_table	= ali,	.probe 		= ali_init_one,	.remove		= ata_pci_remove_one,#ifdef CONFIG_PM	.suspend	= ata_pci_device_suspend,	.resume		= ali_reinit_one,#endif};static int __init ali_init(void){	return pci_register_driver(&ali_pci_driver);}static void __exit ali_exit(void){	pci_unregister_driver(&ali_pci_driver);}MODULE_AUTHOR("Alan Cox");MODULE_DESCRIPTION("low-level driver for ALi PATA");MODULE_LICENSE("GPL");MODULE_DEVICE_TABLE(pci, ali);MODULE_VERSION(DRV_VERSION);module_init(ali_init);module_exit(ali_exit);

⌨️ 快捷键说明

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