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.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 689786df1ede..dc915cb22bec 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/siimage.c Version 1.17 Oct 18 2007 2 * linux/drivers/ide/pci/siimage.c Version 1.18 Oct 18 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>
@@ -57,8 +57,8 @@
57 57
58static int pdev_is_sata(struct pci_dev *pdev) 58static int pdev_is_sata(struct pci_dev *pdev)
59{ 59{
60 switch(pdev->device) 60#ifdef CONFIG_BLK_DEV_IDE_SATA
61 { 61 switch(pdev->device) {
62 case PCI_DEVICE_ID_SII_3112: 62 case PCI_DEVICE_ID_SII_3112:
63 case PCI_DEVICE_ID_SII_1210SA: 63 case PCI_DEVICE_ID_SII_1210SA:
64 return 1; 64 return 1;
@@ -66,9 +66,10 @@ static int pdev_is_sata(struct pci_dev *pdev)
66 return 0; 66 return 0;
67 } 67 }
68 BUG(); 68 BUG();
69#endif
69 return 0; 70 return 0;
70} 71}
71 72
72/** 73/**
73 * is_sata - check if hwif is SATA 74 * is_sata - check if hwif is SATA
74 * @hwif: interface to check 75 * @hwif: interface to check
@@ -136,7 +137,7 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
136 * SI3112 SATA controller life is a bit simpler. 137 * SI3112 SATA controller life is a bit simpler.
137 */ 138 */
138 139
139static u8 sil_udma_filter(ide_drive_t *drive) 140static u8 sil_pata_udma_filter(ide_drive_t *drive)
140{ 141{
141 ide_hwif_t *hwif = drive->hwif; 142 ide_hwif_t *hwif = drive->hwif;
142 unsigned long base = (unsigned long) hwif->hwif_data; 143 unsigned long base = (unsigned long) hwif->hwif_data;
@@ -147,23 +148,23 @@ static u8 sil_udma_filter(ide_drive_t *drive)
147 else 148 else
148 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); 149 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
149 150
150 if (is_sata(hwif)) {
151 mask = strstr(drive->id->model, "Maxtor") ? 0x3f : 0x7f;
152 goto out;
153 }
154
155 if ((scsc & 0x30) == 0x10) /* 133 */ 151 if ((scsc & 0x30) == 0x10) /* 133 */
156 mask = 0x7f; 152 mask = ATA_UDMA6;
157 else if ((scsc & 0x30) == 0x20) /* 2xPCI */ 153 else if ((scsc & 0x30) == 0x20) /* 2xPCI */
158 mask = 0x7f; 154 mask = ATA_UDMA6;
159 else if ((scsc & 0x30) == 0x00) /* 100 */ 155 else if ((scsc & 0x30) == 0x00) /* 100 */
160 mask = 0x3f; 156 mask = ATA_UDMA5;
161 else /* Disabled ? */ 157 else /* Disabled ? */
162 BUG(); 158 BUG();
163out: 159
164 return mask; 160 return mask;
165} 161}
166 162
163static u8 sil_sata_udma_filter(ide_drive_t *drive)
164{
165 return strstr(drive->id->model, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6;
166}
167
167/** 168/**
168 * sil_set_pio_mode - set host controller for PIO mode 169 * sil_set_pio_mode - set host controller for PIO mode
169 * @drive: drive 170 * @drive: drive
@@ -340,10 +341,11 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive)
340static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) 341static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
341{ 342{
342 ide_hwif_t *hwif = HWIF(drive); 343 ide_hwif_t *hwif = HWIF(drive);
343 unsigned long base = (unsigned long)hwif->hwif_data;
344 unsigned long addr = siimage_selreg(hwif, 0x1); 344 unsigned long addr = siimage_selreg(hwif, 0x1);
345 345
346 if (SATA_ERROR_REG) { 346 if (SATA_ERROR_REG) {
347 unsigned long base = (unsigned long)hwif->hwif_data;
348
347 u32 ext_stat = readl((void __iomem *)(base + 0x10)); 349 u32 ext_stat = readl((void __iomem *)(base + 0x10));
348 u8 watchdog = 0; 350 u8 watchdog = 0;
349 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { 351 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
@@ -376,7 +378,7 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
376} 378}
377 379
378/** 380/**
379 * siimage_busproc - bus isolation ioctl 381 * sil_sata_busproc - bus isolation IOCTL
380 * @drive: drive to isolate/restore 382 * @drive: drive to isolate/restore
381 * @state: bus state to set 383 * @state: bus state to set
382 * 384 *
@@ -384,8 +386,8 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
384 * SATA controller the work required is quite limited, we 386 * SATA controller the work required is quite limited, we
385 * just have to clean up the statistics 387 * just have to clean up the statistics
386 */ 388 */
387 389
388static int siimage_busproc (ide_drive_t * drive, int state) 390static int sil_sata_busproc(ide_drive_t * drive, int state)
389{ 391{
390 ide_hwif_t *hwif = HWIF(drive); 392 ide_hwif_t *hwif = HWIF(drive);
391 u32 stat_config = 0; 393 u32 stat_config = 0;
@@ -417,14 +419,14 @@ static int siimage_busproc (ide_drive_t * drive, int state)
417} 419}
418 420
419/** 421/**
420 * siimage_reset_poll - wait for sata reset 422 * sil_sata_reset_poll - wait for SATA reset
421 * @drive: drive we are resetting 423 * @drive: drive we are resetting
422 * 424 *
423 * Poll the SATA phy and see whether it has come back from the dead 425 * Poll the SATA phy and see whether it has come back from the dead
424 * yet. 426 * yet.
425 */ 427 */
426 428
427static int siimage_reset_poll (ide_drive_t *drive) 429static int sil_sata_reset_poll(ide_drive_t *drive)
428{ 430{
429 if (SATA_STATUS_REG) { 431 if (SATA_STATUS_REG) {
430 ide_hwif_t *hwif = HWIF(drive); 432 ide_hwif_t *hwif = HWIF(drive);
@@ -436,27 +438,22 @@ static int siimage_reset_poll (ide_drive_t *drive)
436 HWGROUP(drive)->polling = 0; 438 HWGROUP(drive)->polling = 0;
437 return ide_started; 439 return ide_started;
438 } 440 }
439 return 0;
440 } else {
441 return 0;
442 } 441 }
442
443 return 0;
443} 444}
444 445
445/** 446/**
446 * siimage_pre_reset - reset hook 447 * sil_sata_pre_reset - reset hook
447 * @drive: IDE device being reset 448 * @drive: IDE device being reset
448 * 449 *
449 * For the SATA devices we need to handle recalibration/geometry 450 * For the SATA devices we need to handle recalibration/geometry
450 * differently 451 * differently
451 */ 452 */
452
453static void siimage_pre_reset (ide_drive_t *drive)
454{
455 if (drive->media != ide_disk)
456 return;
457 453
458 if (is_sata(HWIF(drive))) 454static void sil_sata_pre_reset(ide_drive_t *drive)
459 { 455{
456 if (drive->media == ide_disk) {
460 drive->special.b.set_geometry = 0; 457 drive->special.b.set_geometry = 0;
461 drive->special.b.recalibrate = 0; 458 drive->special.b.recalibrate = 0;
462 } 459 }
@@ -502,7 +499,6 @@ static void siimage_reset (ide_drive_t *drive)
502 drive->failures++; 499 drive->failures++;
503 } 500 }
504 } 501 }
505
506} 502}
507 503
508/** 504/**
@@ -758,16 +754,11 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
758 hwif->sata_misc[SATA_IEN_OFFSET] = base + 0x148; 754 hwif->sata_misc[SATA_IEN_OFFSET] = base + 0x148;
759 } 755 }
760 756
761 hw.irq = hwif->pci_dev->irq; 757 memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports));
762 758
763 memcpy(&hwif->hw, &hw, sizeof(hw)); 759 hwif->irq = dev->irq;
764 memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
765 760
766 hwif->irq = hw.irq; 761 hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00);
767
768 base = (unsigned long) addr;
769
770 hwif->dma_base = base + (ch ? 0x08 : 0x00);
771 762
772 hwif->mmio = 1; 763 hwif->mmio = 1;
773} 764}
@@ -864,28 +855,31 @@ static u8 __devinit ata66_siimage(ide_hwif_t *hwif)
864 855
865static void __devinit init_hwif_siimage(ide_hwif_t *hwif) 856static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
866{ 857{
858 u8 sata = is_sata(hwif);
859
867 hwif->resetproc = &siimage_reset; 860 hwif->resetproc = &siimage_reset;
868 hwif->set_pio_mode = &sil_set_pio_mode; 861 hwif->set_pio_mode = &sil_set_pio_mode;
869 hwif->set_dma_mode = &sil_set_dma_mode; 862 hwif->set_dma_mode = &sil_set_dma_mode;
870 hwif->reset_poll = &siimage_reset_poll;
871 hwif->pre_reset = &siimage_pre_reset;
872 hwif->udma_filter = &sil_udma_filter;
873 863
874 if(is_sata(hwif)) { 864 if (sata) {
875 static int first = 1; 865 static int first = 1;
876 866
877 hwif->busproc = &siimage_busproc; 867 hwif->busproc = &sil_sata_busproc;
868 hwif->reset_poll = &sil_sata_reset_poll;
869 hwif->pre_reset = &sil_sata_pre_reset;
870 hwif->udma_filter = &sil_sata_udma_filter;
878 871
879 if (first) { 872 if (first) {
880 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); 873 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n");
881 first = 0; 874 first = 0;
882 } 875 }
883 } 876 } else
877 hwif->udma_filter = &sil_pata_udma_filter;
884 878
885 if (hwif->dma_base == 0) 879 if (hwif->dma_base == 0)
886 return; 880 return;
887 881
888 if (is_sata(hwif)) 882 if (sata)
889 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 883 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
890 884
891 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 885 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
@@ -911,7 +905,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
911 .udma_mask = ATA_UDMA6, \ 905 .udma_mask = ATA_UDMA6, \
912 } 906 }
913 907
914static ide_pci_device_t siimage_chipsets[] __devinitdata = { 908static const struct ide_port_info siimage_chipsets[] __devinitdata = {
915 /* 0 */ DECLARE_SII_DEV("SiI680"), 909 /* 0 */ DECLARE_SII_DEV("SiI680"),
916 /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), 910 /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"),
917 /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") 911 /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA")