aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/piix.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/piix.c')
-rw-r--r--drivers/ide/pci/piix.c125
1 files changed, 36 insertions, 89 deletions
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 38c91ba6497b..a8dd0c0add35 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/piix.c Version 0.52 Jul 14, 2007 2 * linux/drivers/ide/pci/piix.c Version 0.53 Aug 9, 2007
3 * 3 *
4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
@@ -106,37 +106,6 @@
106static int no_piix_dma; 106static int no_piix_dma;
107 107
108/** 108/**
109 * piix_dma_2_pio - return the PIO mode matching DMA
110 * @xfer_rate: transfer speed
111 *
112 * Returns the nearest equivalent PIO timing for the DMA
113 * mode requested by the controller.
114 */
115
116static u8 piix_dma_2_pio (u8 xfer_rate) {
117 switch(xfer_rate) {
118 case XFER_UDMA_6:
119 case XFER_UDMA_5:
120 case XFER_UDMA_4:
121 case XFER_UDMA_3:
122 case XFER_UDMA_2:
123 case XFER_UDMA_1:
124 case XFER_UDMA_0:
125 case XFER_MW_DMA_2:
126 return 4;
127 case XFER_MW_DMA_1:
128 return 3;
129 case XFER_SW_DMA_2:
130 return 2;
131 case XFER_MW_DMA_0:
132 case XFER_SW_DMA_1:
133 case XFER_SW_DMA_0:
134 default:
135 return 0;
136 }
137}
138
139/**
140 * piix_set_pio_mode - set host controller for PIO mode 109 * piix_set_pio_mode - set host controller for PIO mode
141 * @drive: drive 110 * @drive: drive
142 * @pio: PIO mode number 111 * @pio: PIO mode number
@@ -263,6 +232,9 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
263 } else 232 } else
264 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 233 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
265 } else { 234 } else {
235 const u8 mwdma_to_pio[] = { 0, 3, 4 };
236 u8 pio;
237
266 if (reg48 & u_flag) 238 if (reg48 & u_flag)
267 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 239 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
268 if (reg4a & a_speed) 240 if (reg4a & a_speed)
@@ -271,30 +243,14 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
271 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 243 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
272 if (reg55 & w_flag) 244 if (reg55 & w_flag)
273 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 245 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
274 }
275 246
276 piix_set_pio_mode(drive, piix_dma_2_pio(speed)); 247 if (speed >= XFER_MW_DMA_0)
277} 248 pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
278 249 else
279/** 250 pio = 2; /* only SWDMA2 is allowed */
280 * piix_config_drive_xfer_rate - set up an IDE device
281 * @drive: IDE drive to configure
282 *
283 * Set up the PIIX interface for the best available speed on this
284 * interface, preferring DMA to PIO.
285 */
286
287static int piix_config_drive_xfer_rate (ide_drive_t *drive)
288{
289 drive->init_speed = 0;
290 251
291 if (ide_tune_dma(drive)) 252 piix_set_pio_mode(drive, pio);
292 return 0; 253 }
293
294 if (ide_use_fast_pio(drive))
295 ide_set_max_pio(drive);
296
297 return -1;
298} 254}
299 255
300/** 256/**
@@ -428,8 +384,6 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
428 return; 384 return;
429 } 385 }
430 386
431 hwif->autodma = 0;
432
433 hwif->set_pio_mode = &piix_set_pio_mode; 387 hwif->set_pio_mode = &piix_set_pio_mode;
434 hwif->set_dma_mode = &piix_set_dma_mode; 388 hwif->set_dma_mode = &piix_set_dma_mode;
435 389
@@ -456,13 +410,6 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
456 410
457 if (no_piix_dma) 411 if (no_piix_dma)
458 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; 412 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0;
459
460 hwif->ide_dma_check = &piix_config_drive_xfer_rate;
461 if (!noautodma)
462 hwif->autodma = 1;
463
464 hwif->drives[1].autodma = hwif->autodma;
465 hwif->drives[0].autodma = hwif->autodma;
466} 413}
467 414
468#define DECLARE_PIIX_DEV(name_str, udma) \ 415#define DECLARE_PIIX_DEV(name_str, udma) \
@@ -565,34 +512,34 @@ static void __devinit piix_check_450nx(void)
565 printk(KERN_WARNING "piix: A BIOS update may resolve this.\n"); 512 printk(KERN_WARNING "piix: A BIOS update may resolve this.\n");
566} 513}
567 514
568static struct pci_device_id piix_pci_tbl[] = { 515static const struct pci_device_id piix_pci_tbl[] = {
569 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371FB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 516 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_0), 0 },
570 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371FB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 517 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_1), 1 },
571 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371MX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 518 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), 2 },
572 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 519 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371SB_1), 3 },
573 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 520 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371AB), 4 },
574 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, 521 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AB_1), 5 },
575 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, 522 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82443MX_1), 6 },
576 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, 523 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AA_1), 7 },
577 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82372FB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, 524 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82372FB_1), 8 },
578 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82451NX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, 525 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82451NX), 9 },
579 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10}, 526 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_9), 10 },
580 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11}, 527 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_8), 11 },
581 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, 528 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_10), 12 },
582 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13}, 529 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_11), 13 },
583 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14}, 530 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_11), 14 },
584 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15}, 531 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_11), 15 },
585 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_11, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16}, 532 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801E_11), 16 },
586 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_10,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17}, 533 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_10), 17 },
587#ifdef CONFIG_BLK_DEV_IDE_SATA 534#ifdef CONFIG_BLK_DEV_IDE_SATA
588 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18}, 535 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_1), 18 },
589#endif 536#endif
590 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19}, 537 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB_2), 19 },
591 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_19, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20}, 538 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH6_19), 20 },
592 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21}, 539 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH7_21), 21 },
593 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22}, 540 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_1), 22 },
594 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 23}, 541 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB2_18), 23 },
595 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 24}, 542 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH8_6), 24 },
596 { 0, }, 543 { 0, },
597}; 544};
598MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 545MODULE_DEVICE_TABLE(pci, piix_pci_tbl);