aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/siimage.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/siimage.c')
-rw-r--r--drivers/ide/pci/siimage.c113
1 files changed, 50 insertions, 63 deletions
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 4ff89c7d990a..7b4c189a9d99 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * linux/drivers/ide/pci/siimage.c Version 1.07 Nov 30, 2003 2 * linux/drivers/ide/pci/siimage.c Version 1.11 Jan 27, 2007
3 * 3 *
4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 5 * Copyright (C) 2003 Red Hat <alan@redhat.com>
6 * Copyright (C) 2007 MontaVista Software, Inc.
6 * 7 *
7 * May be copied or modified under the terms of the GNU General Public License 8 * May be copied or modified under the terms of the GNU General Public License
8 * 9 *
@@ -205,41 +206,39 @@ static void siimage_tuneproc (ide_drive_t *drive, byte mode_wanted)
205 unsigned long tfaddr = siimage_selreg(hwif, 0x02); 206 unsigned long tfaddr = siimage_selreg(hwif, 0x02);
206 207
207 /* cheat for now and use the docs */ 208 /* cheat for now and use the docs */
208 switch(mode_wanted) { 209 switch (mode_wanted) {
209 case 4: 210 case 4:
210 speedp = 0x10c1; 211 speedp = 0x10c1;
211 speedt = 0x10c1; 212 speedt = 0x10c1;
212 break; 213 break;
213 case 3: 214 case 3:
214 speedp = 0x10C3; 215 speedp = 0x10c3;
215 speedt = 0x10C3; 216 speedt = 0x10c3;
216 break; 217 break;
217 case 2: 218 case 2:
218 speedp = 0x1104; 219 speedp = 0x1104;
219 speedt = 0x1281; 220 speedt = 0x1281;
220 break; 221 break;
221 case 1: 222 case 1:
222 speedp = 0x2283; 223 speedp = 0x2283;
223 speedt = 0x1281; 224 speedt = 0x2283;
224 break; 225 break;
225 case 0: 226 case 0:
226 default: 227 default:
227 speedp = 0x328A; 228 speedp = 0x328a;
228 speedt = 0x328A; 229 speedt = 0x328a;
229 break; 230 break;
230 } 231 }
231 if (hwif->mmio) 232
232 { 233 if (hwif->mmio) {
233 hwif->OUTW(speedt, addr); 234 hwif->OUTW(speedp, addr);
234 hwif->OUTW(speedp, tfaddr); 235 hwif->OUTW(speedt, tfaddr);
235 /* Now set up IORDY */ 236 /* Now set up IORDY */
236 if(mode_wanted == 3 || mode_wanted == 4) 237 if(mode_wanted == 3 || mode_wanted == 4)
237 hwif->OUTW(hwif->INW(tfaddr-2)|0x200, tfaddr-2); 238 hwif->OUTW(hwif->INW(tfaddr-2)|0x200, tfaddr-2);
238 else 239 else
239 hwif->OUTW(hwif->INW(tfaddr-2)&~0x200, tfaddr-2); 240 hwif->OUTW(hwif->INW(tfaddr-2)&~0x200, tfaddr-2);
240 } 241 } else {
241 else
242 {
243 pci_write_config_word(hwif->pci_dev, addr, speedp); 242 pci_write_config_word(hwif->pci_dev, addr, speedp);
244 pci_write_config_word(hwif->pci_dev, tfaddr, speedt); 243 pci_write_config_word(hwif->pci_dev, tfaddr, speedt);
245 pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp); 244 pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp);
@@ -397,12 +396,9 @@ static int config_chipset_for_dma (ide_drive_t *drive)
397 if (!speed) 396 if (!speed)
398 return 0; 397 return 0;
399 398
400 if (ide_set_xfer_rate(drive, speed)) 399 if (siimage_tune_chipset(drive, speed))
401 return 0; 400 return 0;
402 401
403 if (!drive->init_speed)
404 drive->init_speed = speed;
405
406 return ide_dma_enable(drive); 402 return ide_dma_enable(drive);
407} 403}
408 404
@@ -418,25 +414,13 @@ static int config_chipset_for_dma (ide_drive_t *drive)
418 414
419static int siimage_config_drive_for_dma (ide_drive_t *drive) 415static int siimage_config_drive_for_dma (ide_drive_t *drive)
420{ 416{
421 ide_hwif_t *hwif = HWIF(drive); 417 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
422 struct hd_driveid *id = drive->id; 418 return 0;
423
424 if ((id->capability & 1) != 0 && drive->autodma) {
425
426 if (ide_use_dma(drive)) {
427 if (config_chipset_for_dma(drive))
428 return hwif->ide_dma_on(drive);
429 }
430
431 goto fast_ata_pio;
432 419
433 } else if ((id->capability & 8) || (id->field_valid & 2)) { 420 if (ide_use_fast_pio(drive))
434fast_ata_pio:
435 config_chipset_for_pio(drive, 1); 421 config_chipset_for_pio(drive, 1);
436 return hwif->ide_dma_off_quietly(drive); 422
437 } 423 return -1;
438 /* IORDY not supported */
439 return 0;
440} 424}
441 425
442/* returns 1 if dma irq issued, 0 otherwise */ 426/* returns 1 if dma irq issued, 0 otherwise */
@@ -472,11 +456,11 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
472 unsigned long addr = siimage_selreg(hwif, 0x1); 456 unsigned long addr = siimage_selreg(hwif, 0x1);
473 457
474 if (SATA_ERROR_REG) { 458 if (SATA_ERROR_REG) {
475 u32 ext_stat = hwif->INL(base + 0x10); 459 u32 ext_stat = readl((void __iomem *)(base + 0x10));
476 u8 watchdog = 0; 460 u8 watchdog = 0;
477 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { 461 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
478 u32 sata_error = hwif->INL(SATA_ERROR_REG); 462 u32 sata_error = readl((void __iomem *)SATA_ERROR_REG);
479 hwif->OUTL(sata_error, SATA_ERROR_REG); 463 writel(sata_error, (void __iomem *)SATA_ERROR_REG);
480 watchdog = (sata_error & 0x00680000) ? 1 : 0; 464 watchdog = (sata_error & 0x00680000) ? 1 : 0;
481 printk(KERN_WARNING "%s: sata_error = 0x%08x, " 465 printk(KERN_WARNING "%s: sata_error = 0x%08x, "
482 "watchdog = %d, %s\n", 466 "watchdog = %d, %s\n",
@@ -493,11 +477,11 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
493 } 477 }
494 478
495 /* return 1 if INTR asserted */ 479 /* return 1 if INTR asserted */
496 if ((hwif->INB(hwif->dma_status) & 0x04) == 0x04) 480 if ((readb((void __iomem *)hwif->dma_status) & 0x04) == 0x04)
497 return 1; 481 return 1;
498 482
499 /* return 1 if Device INTR asserted */ 483 /* return 1 if Device INTR asserted */
500 if ((hwif->INB(addr) & 8) == 8) 484 if ((readb((void __iomem *)addr) & 8) == 8)
501 return 0; //return 1; 485 return 0; //return 1;
502 486
503 return 0; 487 return 0;
@@ -519,9 +503,9 @@ static int siimage_busproc (ide_drive_t * drive, int state)
519 u32 stat_config = 0; 503 u32 stat_config = 0;
520 unsigned long addr = siimage_selreg(hwif, 0); 504 unsigned long addr = siimage_selreg(hwif, 0);
521 505
522 if (hwif->mmio) { 506 if (hwif->mmio)
523 stat_config = hwif->INL(addr); 507 stat_config = readl((void __iomem *)addr);
524 } else 508 else
525 pci_read_config_dword(hwif->pci_dev, addr, &stat_config); 509 pci_read_config_dword(hwif->pci_dev, addr, &stat_config);
526 510
527 switch (state) { 511 switch (state) {
@@ -557,9 +541,10 @@ static int siimage_reset_poll (ide_drive_t *drive)
557 if (SATA_STATUS_REG) { 541 if (SATA_STATUS_REG) {
558 ide_hwif_t *hwif = HWIF(drive); 542 ide_hwif_t *hwif = HWIF(drive);
559 543
560 if ((hwif->INL(SATA_STATUS_REG) & 0x03) != 0x03) { 544 /* SATA_STATUS_REG is valid only when in MMIO mode */
545 if ((readl((void __iomem *)SATA_STATUS_REG) & 0x03) != 0x03) {
561 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", 546 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
562 hwif->name, hwif->INL(SATA_STATUS_REG)); 547 hwif->name, readl((void __iomem *)SATA_STATUS_REG));
563 HWGROUP(drive)->polling = 0; 548 HWGROUP(drive)->polling = 0;
564 return ide_started; 549 return ide_started;
565 } 550 }
@@ -619,7 +604,8 @@ static void siimage_reset (ide_drive_t *drive)
619 } 604 }
620 605
621 if (SATA_STATUS_REG) { 606 if (SATA_STATUS_REG) {
622 u32 sata_stat = hwif->INL(SATA_STATUS_REG); 607 /* SATA_STATUS_REG is valid only when in MMIO mode */
608 u32 sata_stat = readl((void __iomem *)SATA_STATUS_REG);
623 printk(KERN_WARNING "%s: reset phy, status=0x%08x, %s\n", 609 printk(KERN_WARNING "%s: reset phy, status=0x%08x, %s\n",
624 hwif->name, sata_stat, __FUNCTION__); 610 hwif->name, sata_stat, __FUNCTION__);
625 if (!(sata_stat)) { 611 if (!(sata_stat)) {
@@ -898,7 +884,8 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
898 base = (unsigned long) addr; 884 base = (unsigned long) addr;
899 885
900 hwif->dma_base = base + (ch ? 0x08 : 0x00); 886 hwif->dma_base = base + (ch ? 0x08 : 0x00);
901 hwif->mmio = 2; 887
888 hwif->mmio = 1;
902} 889}
903 890
904static int is_dev_seagate_sata(ide_drive_t *drive) 891static int is_dev_seagate_sata(ide_drive_t *drive)