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

📄 pata_sis.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	.sg_tablesize		= LIBATA_MAX_PRD,	.cmd_per_lun		= ATA_SHT_CMD_PER_LUN,	.emulated		= ATA_SHT_EMULATED,	.use_clustering		= ATA_SHT_USE_CLUSTERING,	.proc_name		= DRV_NAME,	.dma_boundary		= ATA_DMA_BOUNDARY,	.slave_configure	= ata_scsi_slave_config,	.slave_destroy		= ata_scsi_slave_destroy,	.bios_param		= ata_std_bios_param,};static const struct ata_port_operations sis_133_ops = {	.set_piomode		= sis_133_set_piomode,	.set_dmamode		= sis_133_set_dmamode,	.mode_filter		= ata_pci_default_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,	.freeze			= ata_bmdma_freeze,	.thaw			= ata_bmdma_thaw,	.error_handler		= sis_error_handler,	.post_internal_cmd	= ata_bmdma_post_internal_cmd,	.cable_detect		= sis_133_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,};static const struct ata_port_operations sis_133_for_sata_ops = {	.set_piomode		= sis_133_set_piomode,	.set_dmamode		= sis_133_set_dmamode,	.mode_filter		= ata_pci_default_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,	.freeze			= ata_bmdma_freeze,	.thaw			= ata_bmdma_thaw,	.error_handler		= ata_bmdma_error_handler,	.post_internal_cmd	= ata_bmdma_post_internal_cmd,	.cable_detect		= sis_133_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,};static const struct ata_port_operations sis_133_early_ops = {	.set_piomode		= sis_100_set_piomode,	.set_dmamode		= sis_133_early_set_dmamode,	.mode_filter		= ata_pci_default_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,	.freeze			= ata_bmdma_freeze,	.thaw			= ata_bmdma_thaw,	.error_handler		= sis_error_handler,	.post_internal_cmd	= ata_bmdma_post_internal_cmd,	.cable_detect		= sis_66_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,};static const struct ata_port_operations sis_100_ops = {	.set_piomode		= sis_100_set_piomode,	.set_dmamode		= sis_100_set_dmamode,	.mode_filter		= ata_pci_default_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,	.freeze			= ata_bmdma_freeze,	.thaw			= ata_bmdma_thaw,	.error_handler		= sis_error_handler,	.post_internal_cmd	= ata_bmdma_post_internal_cmd,	.cable_detect		= sis_66_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,};static const struct ata_port_operations sis_66_ops = {	.set_piomode		= sis_old_set_piomode,	.set_dmamode		= sis_66_set_dmamode,	.mode_filter		= ata_pci_default_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,	.cable_detect		= sis_66_cable_detect,	.freeze			= ata_bmdma_freeze,	.thaw			= ata_bmdma_thaw,	.error_handler		= sis_error_handler,	.post_internal_cmd	= ata_bmdma_post_internal_cmd,	.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,};static const struct ata_port_operations sis_old_ops = {	.set_piomode		= sis_old_set_piomode,	.set_dmamode		= sis_old_set_dmamode,	.mode_filter		= ata_pci_default_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,	.freeze			= ata_bmdma_freeze,	.thaw			= ata_bmdma_thaw,	.error_handler		= sis_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,};static const struct ata_port_info sis_info = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.pio_mask	= 0x1f,	/* pio0-4 */	.mwdma_mask	= 0x07,	.udma_mask	= 0,	.port_ops	= &sis_old_ops,};static const struct ata_port_info sis_info33 = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.pio_mask	= 0x1f,	/* pio0-4 */	.mwdma_mask	= 0x07,	.udma_mask	= ATA_UDMA2,	/* UDMA 33 */	.port_ops	= &sis_old_ops,};static const struct ata_port_info sis_info66 = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.pio_mask	= 0x1f,	/* pio0-4 */	.udma_mask	= ATA_UDMA4,	/* UDMA 66 */	.port_ops	= &sis_66_ops,};static const struct ata_port_info sis_info100 = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.pio_mask	= 0x1f,	/* pio0-4 */	.udma_mask	= ATA_UDMA5,	.port_ops	= &sis_100_ops,};static const struct ata_port_info sis_info100_early = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.udma_mask	= ATA_UDMA5,	.pio_mask	= 0x1f,	/* pio0-4 */	.port_ops	= &sis_66_ops,};static const struct ata_port_info sis_info133 = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.pio_mask	= 0x1f,	/* pio0-4 */	.udma_mask	= ATA_UDMA6,	.port_ops	= &sis_133_ops,};const struct ata_port_info sis_info133_for_sata = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,	.pio_mask	= 0x1f,	/* pio0-4 */	.udma_mask	= ATA_UDMA6,	.port_ops	= &sis_133_for_sata_ops,};static const struct ata_port_info sis_info133_early = {	.sht		= &sis_sht,	.flags		= ATA_FLAG_SLAVE_POSS,	.pio_mask	= 0x1f,	/* pio0-4 */	.udma_mask	= ATA_UDMA6,	.port_ops	= &sis_133_early_ops,};/* Privately shared with the SiS180 SATA driver, not for use elsewhere */EXPORT_SYMBOL_GPL(sis_info133_for_sata);static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis){	u16 regw;	u8 reg;	if (sis->info == &sis_info133) {		pci_read_config_word(pdev, 0x50, &regw);		if (regw & 0x08)			pci_write_config_word(pdev, 0x50, regw & ~0x08);		pci_read_config_word(pdev, 0x52, &regw);		if (regw & 0x08)			pci_write_config_word(pdev, 0x52, regw & ~0x08);		return;	}	if (sis->info == &sis_info133_early || sis->info == &sis_info100) {		/* Fix up latency */		pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);		/* Set compatibility bit */		pci_read_config_byte(pdev, 0x49, &reg);		if (!(reg & 0x01))			pci_write_config_byte(pdev, 0x49, reg | 0x01);		return;	}	if (sis->info == &sis_info66 || sis->info == &sis_info100_early) {		/* Fix up latency */		pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);		/* Set compatibility bit */		pci_read_config_byte(pdev, 0x52, &reg);		if (!(reg & 0x04))			pci_write_config_byte(pdev, 0x52, reg | 0x04);		return;	}	if (sis->info == &sis_info33) {		pci_read_config_byte(pdev, PCI_CLASS_PROG, &reg);		if (( reg & 0x0F ) != 0x00)			pci_write_config_byte(pdev, PCI_CLASS_PROG, reg & 0xF0);		/* Fall through to ATA16 fixup below */	}	if (sis->info == &sis_info || sis->info == &sis_info33) {		/* force per drive recovery and active timings		   needed on ATA_33 and below chips */		pci_read_config_byte(pdev, 0x52, &reg);		if (!(reg & 0x08))			pci_write_config_byte(pdev, 0x52, reg|0x08);		return;	}	BUG();}/** *	sis_init_one - Register SiS ATA PCI device with kernel services *	@pdev: PCI device to register *	@ent: Entry in sis_pci_tbl matching with @pdev * *	Called from kernel PCI layer.  We probe for combined mode (sigh), *	and then hand over control to libata, for it to do the rest. * *	LOCKING: *	Inherited from PCI layer (may sleep). * *	RETURNS: *	Zero on success, or -ERRNO value. */static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent){	static int printed_version;	struct ata_port_info port;	const struct ata_port_info *ppi[] = { &port, NULL };	struct pci_dev *host = NULL;	struct sis_chipset *chipset = NULL;	struct sis_chipset *sets;	static struct sis_chipset sis_chipsets[] = {		{ 0x0968, &sis_info133 },		{ 0x0966, &sis_info133 },		{ 0x0965, &sis_info133 },		{ 0x0745, &sis_info100 },		{ 0x0735, &sis_info100 },		{ 0x0733, &sis_info100 },		{ 0x0635, &sis_info100 },		{ 0x0633, &sis_info100 },		{ 0x0730, &sis_info100_early },	/* 100 with ATA 66 layout */		{ 0x0550, &sis_info100_early },	/* 100 with ATA 66 layout */		{ 0x0640, &sis_info66 },		{ 0x0630, &sis_info66 },		{ 0x0620, &sis_info66 },		{ 0x0540, &sis_info66 },		{ 0x0530, &sis_info66 },		{ 0x5600, &sis_info33 },		{ 0x5598, &sis_info33 },		{ 0x5597, &sis_info33 },		{ 0x5591, &sis_info33 },		{ 0x5582, &sis_info33 },		{ 0x5581, &sis_info33 },		{ 0x5596, &sis_info },		{ 0x5571, &sis_info },		{ 0x5517, &sis_info },		{ 0x5511, &sis_info },		{0}	};	static struct sis_chipset sis133_early = {		0x0, &sis_info133_early	};	static struct sis_chipset sis133 = {		0x0, &sis_info133	};	static struct sis_chipset sis100_early = {		0x0, &sis_info100_early	};	static struct sis_chipset sis100 = {		0x0, &sis_info100	};	if (!printed_version++)		dev_printk(KERN_DEBUG, &pdev->dev,			   "version " DRV_VERSION "\n");	/* We have to find the bridge first */	for (sets = &sis_chipsets[0]; sets->device; sets++) {		host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL);		if (host != NULL) {			chipset = sets;			/* Match found */			if (sets->device == 0x630) {	/* SIS630 */				if (host->revision >= 0x30)	/* 630 ET */					chipset = &sis100_early;			}			break;		}	}	/* Look for concealed bridges */	if (chipset == NULL) {		/* Second check */		u32 idemisc;		u16 trueid;		/* Disable ID masking and register remapping then		   see what the real ID is */		pci_read_config_dword(pdev, 0x54, &idemisc);		pci_write_config_dword(pdev, 0x54, idemisc & 0x7fffffff);		pci_read_config_word(pdev, PCI_DEVICE_ID, &trueid);		pci_write_config_dword(pdev, 0x54, idemisc);		switch(trueid) {		case 0x5518:	/* SIS 962/963 */			chipset = &sis133;			if ((idemisc & 0x40000000) == 0) {				pci_write_config_dword(pdev, 0x54, idemisc | 0x40000000);				printk(KERN_INFO "SIS5513: Switching to 5513 register mapping\n");			}			break;		case 0x0180:	/* SIS 965/965L */			chipset =  &sis133;			break;		case 0x1180:	/* SIS 966/966L */			chipset =  &sis133;			break;		}	}	/* Further check */	if (chipset == NULL) {		struct pci_dev *lpc_bridge;		u16 trueid;		u8 prefctl;		u8 idecfg;		/* Try the second unmasking technique */		pci_read_config_byte(pdev, 0x4a, &idecfg);		pci_write_config_byte(pdev, 0x4a, idecfg | 0x10);		pci_read_config_word(pdev, PCI_DEVICE_ID, &trueid);		pci_write_config_byte(pdev, 0x4a, idecfg);		switch(trueid) {		case 0x5517:			lpc_bridge = pci_get_slot(pdev->bus, 0x10); /* Bus 0 Dev 2 Fn 0 */			if (lpc_bridge == NULL)				break;			pci_read_config_byte(pdev, 0x49, &prefctl);			pci_dev_put(lpc_bridge);			if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) {				chipset = &sis133_early;				break;			}			chipset = &sis100;			break;		}	}	pci_dev_put(host);	/* No chipset info, no support */	if (chipset == NULL)		return -ENODEV;	port = *chipset->info;	port.private_data = chipset;	sis_fixup(pdev, chipset);	return ata_pci_init_one(pdev, ppi);}static const struct pci_device_id sis_pci_tbl[] = {	{ PCI_VDEVICE(SI, 0x5513), },	/* SiS 5513 */	{ PCI_VDEVICE(SI, 0x5518), },	/* SiS 5518 */	{ PCI_VDEVICE(SI, 0x1180), },	/* SiS 1180 */	{ }};static struct pci_driver sis_pci_driver = {	.name			= DRV_NAME,	.id_table		= sis_pci_tbl,	.probe			= sis_init_one,	.remove			= ata_pci_remove_one,#ifdef CONFIG_PM	.suspend		= ata_pci_device_suspend,	.resume			= ata_pci_device_resume,#endif};static int __init sis_init(void){	return pci_register_driver(&sis_pci_driver);}static void __exit sis_exit(void){	pci_unregister_driver(&sis_pci_driver);}module_init(sis_init);module_exit(sis_exit);MODULE_AUTHOR("Alan Cox");MODULE_DESCRIPTION("SCSI low-level driver for SiS ATA");MODULE_LICENSE("GPL");MODULE_DEVICE_TABLE(pci, sis_pci_tbl);MODULE_VERSION(DRV_VERSION);

⌨️ 快捷键说明

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