aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/it821x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r--drivers/ide/pci/it821x.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 46edd083b348..995e18bb3139 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -138,8 +138,7 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
138 struct pci_dev *dev = to_pci_dev(hwif->dev); 138 struct pci_dev *dev = to_pci_dev(hwif->dev);
139 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 139 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
140 int channel = hwif->channel; 140 int channel = hwif->channel;
141 int unit = drive->select.b.unit; 141 u8 unit = drive->dn & 1, conf;
142 u8 conf;
143 142
144 /* Program UDMA timing bits */ 143 /* Program UDMA timing bits */
145 if(itdev->clock_mode == ATA_66) 144 if(itdev->clock_mode == ATA_66)
@@ -168,13 +167,11 @@ static void it821x_clock_strategy(ide_drive_t *drive)
168 ide_hwif_t *hwif = drive->hwif; 167 ide_hwif_t *hwif = drive->hwif;
169 struct pci_dev *dev = to_pci_dev(hwif->dev); 168 struct pci_dev *dev = to_pci_dev(hwif->dev);
170 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 169 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
170 ide_drive_t *pair;
171 int clock, altclock, sel = 0;
172 u8 unit = drive->dn & 1, v;
171 173
172 u8 unit = drive->select.b.unit; 174 pair = &hwif->drives[1 - unit];
173 ide_drive_t *pair = &hwif->drives[1-unit];
174
175 int clock, altclock;
176 u8 v;
177 int sel = 0;
178 175
179 if(itdev->want[0][0] > itdev->want[1][0]) { 176 if(itdev->want[0][0] > itdev->want[1][0]) {
180 clock = itdev->want[0][1]; 177 clock = itdev->want[0][1];
@@ -240,16 +237,17 @@ static void it821x_clock_strategy(ide_drive_t *drive)
240 237
241static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) 238static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
242{ 239{
243 ide_hwif_t *hwif = drive->hwif; 240 ide_hwif_t *hwif = drive->hwif;
244 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 241 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
245 int unit = drive->select.b.unit; 242 ide_drive_t *pair;
246 ide_drive_t *pair = &hwif->drives[1 - unit]; 243 u8 unit = drive->dn & 1, set_pio = pio;
247 u8 set_pio = pio;
248 244
249 /* Spec says 89 ref driver uses 88 */ 245 /* Spec says 89 ref driver uses 88 */
250 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; 246 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
251 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; 247 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
252 248
249 pair = &hwif->drives[1 - unit];
250
253 /* 251 /*
254 * Compute the best PIO mode we can for a given device. We must 252 * Compute the best PIO mode we can for a given device. We must
255 * pick a speed that does not cause problems with the other device 253 * pick a speed that does not cause problems with the other device
@@ -286,9 +284,7 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted)
286 ide_hwif_t *hwif = drive->hwif; 284 ide_hwif_t *hwif = drive->hwif;
287 struct pci_dev *dev = to_pci_dev(hwif->dev); 285 struct pci_dev *dev = to_pci_dev(hwif->dev);
288 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 286 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif);
289 int unit = drive->select.b.unit; 287 u8 unit = drive->dn & 1, channel = hwif->channel, conf;
290 int channel = hwif->channel;
291 u8 conf;
292 288
293 static u16 dma[] = { 0x8866, 0x3222, 0x3121 }; 289 static u16 dma[] = { 0x8866, 0x3222, 0x3121 };
294 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY }; 290 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY };
@@ -325,9 +321,7 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted)
325 ide_hwif_t *hwif = drive->hwif; 321 ide_hwif_t *hwif = drive->hwif;
326 struct pci_dev *dev = to_pci_dev(hwif->dev); 322 struct pci_dev *dev = to_pci_dev(hwif->dev);
327 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 323 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
328 int unit = drive->select.b.unit; 324 u8 unit = drive->dn & 1, channel = hwif->channel, conf;
329 int channel = hwif->channel;
330 u8 conf;
331 325
332 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 }; 326 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 };
333 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 }; 327 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 };
@@ -369,7 +363,8 @@ static void it821x_dma_start(ide_drive_t *drive)
369{ 363{
370 ide_hwif_t *hwif = drive->hwif; 364 ide_hwif_t *hwif = drive->hwif;
371 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 365 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
372 int unit = drive->select.b.unit; 366 u8 unit = drive->dn & 1;
367
373 if(itdev->mwdma[unit] != MWDMA_OFF) 368 if(itdev->mwdma[unit] != MWDMA_OFF)
374 it821x_program(drive, itdev->mwdma[unit]); 369 it821x_program(drive, itdev->mwdma[unit]);
375 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10) 370 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10)
@@ -389,9 +384,10 @@ static void it821x_dma_start(ide_drive_t *drive)
389static int it821x_dma_end(ide_drive_t *drive) 384static int it821x_dma_end(ide_drive_t *drive)
390{ 385{
391 ide_hwif_t *hwif = drive->hwif; 386 ide_hwif_t *hwif = drive->hwif;
392 int unit = drive->select.b.unit;
393 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 387 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
394 int ret = __ide_dma_end(drive); 388 int ret = ide_dma_end(drive);
389 u8 unit = drive->dn & 1;
390
395 if(itdev->mwdma[unit] != MWDMA_OFF) 391 if(itdev->mwdma[unit] != MWDMA_OFF)
396 it821x_program(drive, itdev->pio[unit]); 392 it821x_program(drive, itdev->pio[unit]);
397 return ret; 393 return ret;
@@ -454,7 +450,7 @@ static void it821x_quirkproc(ide_drive_t *drive)
454 * IRQ mask as we may well be in PIO (eg rev 0x10) 450 * IRQ mask as we may well be in PIO (eg rev 0x10)
455 * for now and we know unmasking is safe on this chipset. 451 * for now and we know unmasking is safe on this chipset.
456 */ 452 */
457 drive->unmask = 1; 453 drive->dev_flags |= IDE_DFLAG_UNMASK;
458 } else { 454 } else {
459 /* 455 /*
460 * Perform fixups on smart mode. We need to "lose" some 456 * Perform fixups on smart mode. We need to "lose" some
@@ -680,7 +676,7 @@ static const struct pci_device_id it821x_pci_tbl[] = {
680 676
681MODULE_DEVICE_TABLE(pci, it821x_pci_tbl); 677MODULE_DEVICE_TABLE(pci, it821x_pci_tbl);
682 678
683static struct pci_driver driver = { 679static struct pci_driver it821x_pci_driver = {
684 .name = "ITE821x IDE", 680 .name = "ITE821x IDE",
685 .id_table = it821x_pci_tbl, 681 .id_table = it821x_pci_tbl,
686 .probe = it821x_init_one, 682 .probe = it821x_init_one,
@@ -691,12 +687,12 @@ static struct pci_driver driver = {
691 687
692static int __init it821x_ide_init(void) 688static int __init it821x_ide_init(void)
693{ 689{
694 return ide_pci_register_driver(&driver); 690 return ide_pci_register_driver(&it821x_pci_driver);
695} 691}
696 692
697static void __exit it821x_ide_exit(void) 693static void __exit it821x_ide_exit(void)
698{ 694{
699 pci_unregister_driver(&driver); 695 pci_unregister_driver(&it821x_pci_driver);
700} 696}
701 697
702module_init(it821x_ide_init); 698module_init(it821x_ide_init);