📄 amd74xx.c
字号:
drive->init_speed = speed; drive->current_speed = speed; return 0;}/* * amd74xx_tune_drive() is a callback from upper layers for * PIO-only tuning. */static void amd74xx_tune_drive(ide_drive_t *drive, u8 pio){ if (!((amd_enabled >> HWIF(drive)->channel) & 1)) return; if (pio == 255) { amd_set_drive(drive, ide_find_best_mode(drive, XFER_PIO | XFER_EPIO)); return; } amd_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5));}/* * amd74xx_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(). */static int amd74xx_ide_dma_check(ide_drive_t *drive){ int w80 = HWIF(drive)->udma_four; u8 speed = ide_find_best_mode(drive, XFER_PIO | XFER_EPIO | XFER_MWDMA | XFER_UDMA | ((amd_config->flags & AMD_BAD_SWDMA) ? 0 : XFER_SWDMA) | (w80 && (amd_config->flags & AMD_UDMA) >= AMD_UDMA_66 ? XFER_UDMA_66 : 0) | (w80 && (amd_config->flags & AMD_UDMA) >= AMD_UDMA_100 ? XFER_UDMA_100 : 0) | (w80 && (amd_config->flags & AMD_UDMA) >= AMD_UDMA_133 ? XFER_UDMA_133 : 0)); amd_set_drive(drive, speed); if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) return HWIF(drive)->ide_dma_on(drive); return HWIF(drive)->ide_dma_off_quietly(drive);}/* * The initialization callback. Here we determine the IDE chip type * and initialize its drive independent registers. */static unsigned int __init init_chipset_amd74xx(struct pci_dev *dev, const char *name){ unsigned char t; unsigned int u; int i;/* * Check for bad SWDMA. */ if (amd_config->flags & AMD_CHECK_SWDMA) { pci_read_config_byte(dev, PCI_REVISION_ID, &t); if (t <= 7) amd_config->flags |= AMD_BAD_SWDMA; }/* * Check 80-wire cable presence. */ switch (amd_config->flags & AMD_UDMA) { case AMD_UDMA_133: case AMD_UDMA_100: pci_read_config_byte(dev, AMD_CABLE_DETECT, &t); pci_read_config_dword(dev, AMD_UDMA_TIMING, &u); amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); if(dev->vendor == PCI_VENDOR_ID_NVIDIA) amd_80w = ((t & 0x4) ? 0 : 1) | ((t & 0x8) ? 0 : 2); for (i = 24; i >= 0; i -= 8) if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { printk(KERN_WARNING "AMD_IDE: Bios didn't set cable bits corectly. Enabling workaround.\n"); amd_80w |= (1 << (1 - (i >> 4))); } break; case AMD_UDMA_66: pci_read_config_dword(dev, AMD_UDMA_TIMING, &u); for (i = 24; i >= 0; i -= 8) if ((u >> i) & 4) amd_80w |= (1 << (1 - (i >> 4))); break; } pci_read_config_dword(dev, AMD_IDE_ENABLE, &u); amd_enabled = ((u & 1) ? 2 : 0) | ((u & 2) ? 1 : 0);/* * Take care of prefetch & postwrite. */ pci_read_config_byte(dev, AMD_IDE_CONFIG, &t); pci_write_config_byte(dev, AMD_IDE_CONFIG, (amd_config->flags & AMD_BAD_FIFO) ? (t & 0x0f) : (t | 0xf0));/* * Determine the system bus clock. */ amd_clock = system_bus_clock() * 1000; switch (amd_clock) { case 33000: amd_clock = 33333; break; case 37000: amd_clock = 37500; break; case 41000: amd_clock = 41666; break; } if (amd_clock < 20000 || amd_clock > 50000) { printk(KERN_WARNING "AMD_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", amd_clock); printk(KERN_WARNING "AMD_IDE: Use ide0=ata66 if you want to assume 80-wire cable\n"); amd_clock = 33333; }/* * Print the boot message. */ pci_read_config_byte(dev, PCI_REVISION_ID, &t); printk(KERN_INFO "AMD_IDE: %s (rev %02x) %s controller on pci%s\n", dev->name, t, amd_dma[amd_config->flags & AMD_UDMA], dev->slot_name);/* * Register /proc/ide/amd74xx entry */#if defined(DISPLAY_AMD_TIMINGS) && defined(CONFIG_PROC_FS) if (!amd74xx_proc) { amd_base = pci_resource_start(dev, 4); bmide_dev = dev; ide_pci_register_host_proc(&amd74xx_procs[0]); amd74xx_proc = 1; }#endif /* DISPLAY_AMD_TIMINGS && CONFIG_PROC_FS */ return 0;}static unsigned int __init ata66_amd74xx(ide_hwif_t *hwif){ return ((amd_enabled & amd_80w) >> hwif->channel) & 1;}static void __init init_hwif_amd74xx(ide_hwif_t *hwif){ int i; hwif->autodma = 0; hwif->tuneproc = &amd74xx_tune_drive; hwif->speedproc = &amd_set_drive; for (i = 0; i < 2; i++) { hwif->drives[i].io_32bit = 1; hwif->drives[i].unmask = 1; hwif->drives[i].autotune = 1; hwif->drives[i].dn = hwif->channel * 2 + i; } if (!hwif->dma_base) return; hwif->atapi_dma = 1; hwif->ultra_mask = 0x7f; hwif->mwdma_mask = 0x07; hwif->swdma_mask = 0x07; if (!(hwif->udma_four)) hwif->udma_four = ((amd_enabled & amd_80w) >> hwif->channel) & 1; hwif->ide_dma_check = &amd74xx_ide_dma_check; if (!noautodma) hwif->autodma = 1; hwif->drives[0].autodma = hwif->autodma; hwif->drives[1].autodma = hwif->autodma;}/* * We allow the BM-DMA driver only work on enabled interfaces. */static void __init init_dma_amd74xx(ide_hwif_t *hwif, unsigned long dmabase){ if ((amd_enabled >> hwif->channel) & 1) ide_setup_dma(hwif, dmabase, 8);}extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id){ ide_pci_device_t *d = amd74xx_chipsets + id->driver_data; amd_config = amd_ide_chips + id->driver_data; if (dev->device != d->device) BUG(); if (dev->device != amd_config->id) BUG(); ide_setup_pci_device(dev, d); MOD_INC_USE_COUNT; return 0;}static struct pci_device_id amd74xx_pci_tbl[] __devinitdata = { { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_COBRA_7401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7409, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7411, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_OPUS_7441, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13}, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, { 0, },};static struct pci_driver driver = { .name = "AMD IDE", .id_table = amd74xx_pci_tbl, .probe = amd74xx_probe,};static int amd74xx_ide_init(void){ return ide_pci_register_driver(&driver);}static void amd74xx_ide_exit(void){ ide_pci_unregister_driver(&driver);}module_init(amd74xx_ide_init);module_exit(amd74xx_ide_exit);MODULE_AUTHOR("Vojtech Pavlik");MODULE_DESCRIPTION("AMD PCI IDE driver");MODULE_LICENSE("GPL");EXPORT_NO_SYMBOLS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -