aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-02-02 15:58:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-02-02 15:58:57 -0500
commit9135f1901ee6449dfe338adf6e40e9c2025b8150 (patch)
tree05e1ab38563a93cf0df8c05d21062b85b14f8491 /drivers/ide/pci
parent124d3b7041f9a0ca7c43a6293e1cae4576c32fd5 (diff)
parentd59823fa44f7d9babf586b3c705db314aa0f9822 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (95 commits) ide-tape: remove idetape_config_t typedef ide-tape: remove mtio.h related comments ide-tape: make function name more accurate ide-tape: remove unused sense packet commands. ide-tape: use generic byteorder macros ide-tape: remove EXPERIMENTAL driver status ide-tape: use generic scsi commands ide-tape: remove struct idetape_block_size_page_t ide-tape: remove structs os_partition_t, os_dat_entry_t, os_dat_t ide-tape: remove struct idetape_parameter_block_descriptor_t ide-tape: remove struct idetape_medium_partition_page_t ide-tape: remove struct idetape_data_compression_page_t ide-tape: remove struct idetape_inquiry_result_t ide-tape: remove struct idetape_capabilities_page_t ide-tape: remove IDETAPE_DEBUG_BUGS ide-tape: remove IDETAPE_DEBUG_INFO ide-tape: dump gcw fields on error in idetape_identify_device() ide-tape: remove struct idetape_mode_parameter_header_t ide-tape: remove struct idetape_request_sense_result_t ide-tape: remove dead code ...
Diffstat (limited to 'drivers/ide/pci')
-rw-r--r--drivers/ide/pci/aec62xx.c26
-rw-r--r--drivers/ide/pci/alim15x3.c6
-rw-r--r--drivers/ide/pci/amd74xx.c21
-rw-r--r--drivers/ide/pci/atiixp.c30
-rw-r--r--drivers/ide/pci/cmd640.c33
-rw-r--r--drivers/ide/pci/cmd64x.c6
-rw-r--r--drivers/ide/pci/cs5520.c12
-rw-r--r--drivers/ide/pci/cs5530.c8
-rw-r--r--drivers/ide/pci/cs5535.c10
-rw-r--r--drivers/ide/pci/cy82c693.c1
-rw-r--r--drivers/ide/pci/delkin_cb.c41
-rw-r--r--drivers/ide/pci/generic.c7
-rw-r--r--drivers/ide/pci/hpt34x.c7
-rw-r--r--drivers/ide/pci/hpt366.c89
-rw-r--r--drivers/ide/pci/it8213.c24
-rw-r--r--drivers/ide/pci/it821x.c8
-rw-r--r--drivers/ide/pci/jmicron.c9
-rw-r--r--drivers/ide/pci/ns87415.c4
-rw-r--r--drivers/ide/pci/opti621.c15
-rw-r--r--drivers/ide/pci/pdc202xx_new.c14
-rw-r--r--drivers/ide/pci/pdc202xx_old.c17
-rw-r--r--drivers/ide/pci/piix.c9
-rw-r--r--drivers/ide/pci/rz1000.c10
-rw-r--r--drivers/ide/pci/sc1200.c8
-rw-r--r--drivers/ide/pci/scc_pata.c10
-rw-r--r--drivers/ide/pci/serverworks.c11
-rw-r--r--drivers/ide/pci/sgiioc4.c20
-rw-r--r--drivers/ide/pci/siimage.c31
-rw-r--r--drivers/ide/pci/sis5513.c14
-rw-r--r--drivers/ide/pci/sl82c105.c6
-rw-r--r--drivers/ide/pci/slc90e66.c26
-rw-r--r--drivers/ide/pci/tc86c001.c24
-rw-r--r--drivers/ide/pci/triflex.c5
-rw-r--r--drivers/ide/pci/trm290.c7
-rw-r--r--drivers/ide/pci/via82cxxx.c10
35 files changed, 237 insertions, 342 deletions
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 824df78c7012..cfb3265bc1a8 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -7,7 +7,6 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/pci.h> 9#include <linux/pci.h>
10#include <linux/delay.h>
11#include <linux/hdreg.h> 10#include <linux/hdreg.h>
12#include <linux/ide.h> 11#include <linux/ide.h>
13#include <linux/init.h> 12#include <linux/init.h>
@@ -166,6 +165,16 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
166 return dev->irq; 165 return dev->irq;
167} 166}
168 167
168static u8 __devinit atp86x_cable_detect(ide_hwif_t *hwif)
169{
170 struct pci_dev *dev = to_pci_dev(hwif->dev);
171 u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;
172
173 pci_read_config_byte(dev, 0x49, &ata66);
174
175 return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
176}
177
169static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) 178static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
170{ 179{
171 struct pci_dev *dev = to_pci_dev(hwif->dev); 180 struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -174,21 +183,10 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
174 183
175 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) 184 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
176 hwif->set_dma_mode = &aec6210_set_mode; 185 hwif->set_dma_mode = &aec6210_set_mode;
177 else 186 else {
178 hwif->set_dma_mode = &aec6260_set_mode; 187 hwif->set_dma_mode = &aec6260_set_mode;
179 188
180 if (hwif->dma_base == 0) 189 hwif->cable_detect = atp86x_cable_detect;
181 return;
182
183 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
184 return;
185
186 if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
187 u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;
188
189 pci_read_config_byte(dev, 0x49, &ata66);
190
191 hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
192 } 190 }
193} 191}
194 192
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 130cc6e784e5..b3b6f514ce2d 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -31,7 +31,6 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/delay.h>
35#include <linux/hdreg.h> 34#include <linux/hdreg.h>
36#include <linux/ide.h> 35#include <linux/ide.h>
37#include <linux/init.h> 36#include <linux/init.h>
@@ -666,13 +665,12 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
666 hwif->set_dma_mode = &ali_set_dma_mode; 665 hwif->set_dma_mode = &ali_set_dma_mode;
667 hwif->udma_filter = &ali_udma_filter; 666 hwif->udma_filter = &ali_udma_filter;
668 667
668 hwif->cable_detect = ata66_ali15x3;
669
669 if (hwif->dma_base == 0) 670 if (hwif->dma_base == 0)
670 return; 671 return;
671 672
672 hwif->dma_setup = &ali15x3_dma_setup; 673 hwif->dma_setup = &ali15x3_dma_setup;
673
674 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
675 hwif->cbl = ata66_ali15x3(hwif);
676} 674}
677 675
678/** 676/**
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 8c52bc9eaa59..2ef890ce8097 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -17,12 +17,9 @@
17 17
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/ioport.h>
21#include <linux/blkdev.h>
22#include <linux/pci.h> 20#include <linux/pci.h>
23#include <linux/init.h> 21#include <linux/init.h>
24#include <linux/ide.h> 22#include <linux/ide.h>
25#include <asm/io.h>
26 23
27#include "ide-timing.h" 24#include "ide-timing.h"
28 25
@@ -199,6 +196,14 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev,
199 return dev->irq; 196 return dev->irq;
200} 197}
201 198
199static u8 __devinit amd_cable_detect(ide_hwif_t *hwif)
200{
201 if ((amd_80w >> hwif->channel) & 1)
202 return ATA_CBL_PATA80;
203 else
204 return ATA_CBL_PATA40;
205}
206
202static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) 207static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
203{ 208{
204 struct pci_dev *dev = to_pci_dev(hwif->dev); 209 struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -209,15 +214,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
209 hwif->set_pio_mode = &amd_set_pio_mode; 214 hwif->set_pio_mode = &amd_set_pio_mode;
210 hwif->set_dma_mode = &amd_set_drive; 215 hwif->set_dma_mode = &amd_set_drive;
211 216
212 if (!hwif->dma_base) 217 hwif->cable_detect = amd_cable_detect;
213 return;
214
215 if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
216 if ((amd_80w >> hwif->channel) & 1)
217 hwif->cbl = ATA_CBL_PATA80;
218 else
219 hwif->cbl = ATA_CBL_PATA40;
220 }
221} 218}
222 219
223#define IDE_HFLAGS_AMD \ 220#define IDE_HFLAGS_AMD \
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index b56274af1782..7e037c880cb0 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -6,15 +6,11 @@
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/ioport.h>
10#include <linux/pci.h> 9#include <linux/pci.h>
11#include <linux/hdreg.h> 10#include <linux/hdreg.h>
12#include <linux/ide.h> 11#include <linux/ide.h>
13#include <linux/delay.h>
14#include <linux/init.h> 12#include <linux/init.h>
15 13
16#include <asm/io.h>
17
18#define ATIIXP_IDE_PIO_TIMING 0x40 14#define ATIIXP_IDE_PIO_TIMING 0x40
19#define ATIIXP_IDE_MDMA_TIMING 0x44 15#define ATIIXP_IDE_MDMA_TIMING 0x44
20#define ATIIXP_IDE_PIO_CONTROL 0x48 16#define ATIIXP_IDE_PIO_CONTROL 0x48
@@ -121,6 +117,19 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)
121 spin_unlock_irqrestore(&atiixp_lock, flags); 117 spin_unlock_irqrestore(&atiixp_lock, flags);
122} 118}
123 119
120static u8 __devinit atiixp_cable_detect(ide_hwif_t *hwif)
121{
122 struct pci_dev *pdev = to_pci_dev(hwif->dev);
123 u8 udma_mode = 0, ch = hwif->channel;
124
125 pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode);
126
127 if ((udma_mode & 0x07) >= 0x04 || (udma_mode & 0x70) >= 0x40)
128 return ATA_CBL_PATA80;
129 else
130 return ATA_CBL_PATA40;
131}
132
124/** 133/**
125 * init_hwif_atiixp - fill in the hwif for the ATIIXP 134 * init_hwif_atiixp - fill in the hwif for the ATIIXP
126 * @hwif: IDE interface 135 * @hwif: IDE interface
@@ -131,21 +140,10 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)
131 140
132static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) 141static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
133{ 142{
134 struct pci_dev *pdev = to_pci_dev(hwif->dev);
135 u8 udma_mode = 0, ch = hwif->channel;
136
137 hwif->set_pio_mode = &atiixp_set_pio_mode; 143 hwif->set_pio_mode = &atiixp_set_pio_mode;
138 hwif->set_dma_mode = &atiixp_set_dma_mode; 144 hwif->set_dma_mode = &atiixp_set_dma_mode;
139 145
140 if (!hwif->dma_base) 146 hwif->cable_detect = atiixp_cable_detect;
141 return;
142
143 pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode);
144
145 if ((udma_mode & 0x07) >= 0x04 || (udma_mode & 0x70) >= 0x40)
146 hwif->cbl = ATA_CBL_PATA80;
147 else
148 hwif->cbl = ATA_CBL_PATA40;
149} 147}
150 148
151static const struct ide_port_info atiixp_pci_info[] __devinitdata = { 149static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index 7240c20b9593..bd24dad3cfc6 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -103,10 +103,6 @@
103#include <linux/types.h> 103#include <linux/types.h>
104#include <linux/kernel.h> 104#include <linux/kernel.h>
105#include <linux/delay.h> 105#include <linux/delay.h>
106#include <linux/timer.h>
107#include <linux/mm.h>
108#include <linux/ioport.h>
109#include <linux/blkdev.h>
110#include <linux/hdreg.h> 106#include <linux/hdreg.h>
111#include <linux/ide.h> 107#include <linux/ide.h>
112#include <linux/init.h> 108#include <linux/init.h>
@@ -703,6 +699,18 @@ static int pci_conf2(void)
703 return 0; 699 return 0;
704} 700}
705 701
702static const struct ide_port_info cmd640_port_info __initdata = {
703 .chipset = ide_cmd640,
704 .host_flags = IDE_HFLAG_SERIALIZE |
705 IDE_HFLAG_NO_DMA |
706 IDE_HFLAG_NO_AUTOTUNE |
707 IDE_HFLAG_ABUSE_PREFETCH |
708 IDE_HFLAG_ABUSE_FAST_DEVSEL,
709#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
710 .pio_mask = ATA_PIO5,
711#endif
712};
713
706/* 714/*
707 * Probe for a cmd640 chipset, and initialize it if found. 715 * Probe for a cmd640 chipset, and initialize it if found.
708 */ 716 */
@@ -760,11 +768,7 @@ static int __init cmd640x_init(void)
760 setup_device_ptrs (); 768 setup_device_ptrs ();
761 printk("%s: buggy cmd640%c interface on %s, config=0x%02x\n", 769 printk("%s: buggy cmd640%c interface on %s, config=0x%02x\n",
762 cmd_hwif0->name, 'a' + cmd640_chip_version - 1, bus_type, cfr); 770 cmd_hwif0->name, 'a' + cmd640_chip_version - 1, bus_type, cfr);
763 cmd_hwif0->chipset = ide_cmd640;
764#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 771#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
765 cmd_hwif0->host_flags = IDE_HFLAG_ABUSE_PREFETCH |
766 IDE_HFLAG_ABUSE_FAST_DEVSEL;
767 cmd_hwif0->pio_mask = ATA_PIO5;
768 cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; 772 cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode;
769#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 773#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
770 774
@@ -815,23 +819,14 @@ static int __init cmd640x_init(void)
815 * Initialize data for secondary cmd640 port, if enabled 819 * Initialize data for secondary cmd640 port, if enabled
816 */ 820 */
817 if (second_port_cmd640) { 821 if (second_port_cmd640) {
818 cmd_hwif0->serialized = 1;
819 cmd_hwif1->serialized = 1;
820 cmd_hwif1->chipset = ide_cmd640;
821 cmd_hwif0->mate = cmd_hwif1;
822 cmd_hwif1->mate = cmd_hwif0;
823 cmd_hwif1->channel = 1;
824#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 822#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
825 cmd_hwif1->host_flags = IDE_HFLAG_ABUSE_PREFETCH |
826 IDE_HFLAG_ABUSE_FAST_DEVSEL;
827 cmd_hwif1->pio_mask = ATA_PIO5;
828 cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; 823 cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode;
829#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 824#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
830 825
831 idx[1] = cmd_hwif1->index; 826 idx[1] = cmd_hwif1->index;
832 } 827 }
833 printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name, 828 printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name,
834 cmd_hwif0->serialized ? "" : "not ", port2); 829 second_port_cmd640 ? "" : "not ", port2);
835 830
836 /* 831 /*
837 * Establish initial timings/prefetch for all drives. 832 * Establish initial timings/prefetch for all drives.
@@ -876,7 +871,7 @@ static int __init cmd640x_init(void)
876 cmd640_dump_regs(); 871 cmd640_dump_regs();
877#endif 872#endif
878 873
879 ide_device_add(idx); 874 ide_device_add(idx, &cmd640_port_info);
880 875
881 return 1; 876 return 1;
882} 877}
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 04aa9e59670e..edabe6299efd 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/delay.h>
17#include <linux/hdreg.h> 16#include <linux/hdreg.h>
18#include <linux/ide.h> 17#include <linux/ide.h>
19#include <linux/init.h> 18#include <linux/init.h>
@@ -393,6 +392,8 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
393 hwif->set_pio_mode = &cmd64x_set_pio_mode; 392 hwif->set_pio_mode = &cmd64x_set_pio_mode;
394 hwif->set_dma_mode = &cmd64x_set_dma_mode; 393 hwif->set_dma_mode = &cmd64x_set_dma_mode;
395 394
395 hwif->cable_detect = ata66_cmd64x;
396
396 if (!hwif->dma_base) 397 if (!hwif->dma_base)
397 return; 398 return;
398 399
@@ -411,9 +412,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
411 if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5) 412 if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5)
412 hwif->ultra_mask = 0x00; 413 hwif->ultra_mask = 0x00;
413 414
414 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
415 hwif->cbl = ata66_cmd64x(hwif);
416
417 switch (dev->device) { 415 switch (dev->device) {
418 case PCI_DEVICE_ID_CMD_648: 416 case PCI_DEVICE_ID_CMD_648:
419 case PCI_DEVICE_ID_CMD_649: 417 case PCI_DEVICE_ID_CMD_649:
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index eb68a9ad0c98..0be1a824102b 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -35,22 +35,12 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/delay.h>
39#include <linux/timer.h>
40#include <linux/mm.h>
41#include <linux/ioport.h>
42#include <linux/blkdev.h>
43#include <linux/hdreg.h> 38#include <linux/hdreg.h>
44
45#include <linux/interrupt.h>
46#include <linux/init.h> 39#include <linux/init.h>
47#include <linux/pci.h> 40#include <linux/pci.h>
48#include <linux/ide.h> 41#include <linux/ide.h>
49#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
50 43
51#include <asm/io.h>
52#include <asm/irq.h>
53
54struct pio_clocks 44struct pio_clocks
55{ 45{
56 int address; 46 int address;
@@ -180,7 +170,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
180 170
181 ide_pci_setup_ports(dev, d, 14, &idx[0]); 171 ide_pci_setup_ports(dev, d, 14, &idx[0]);
182 172
183 ide_device_add(idx); 173 ide_device_add(idx, d);
184 174
185 return 0; 175 return 0;
186} 176}
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index 765aac397ced..941a1344820b 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -15,18 +15,12 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/delay.h>
19#include <linux/timer.h>
20#include <linux/mm.h>
21#include <linux/ioport.h>
22#include <linux/blkdev.h>
23#include <linux/hdreg.h> 18#include <linux/hdreg.h>
24#include <linux/interrupt.h>
25#include <linux/pci.h> 19#include <linux/pci.h>
26#include <linux/init.h> 20#include <linux/init.h>
27#include <linux/ide.h> 21#include <linux/ide.h>
22
28#include <asm/io.h> 23#include <asm/io.h>
29#include <asm/irq.h>
30 24
31/* 25/*
32 * Here are the standard PIO mode 0-4 timings for each "format". 26 * Here are the standard PIO mode 0-4 timings for each "format".
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 66433aa53f59..d7b5ea992e94 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -155,8 +155,9 @@ static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio)
155 cs5535_set_speed(drive, XFER_PIO_0 + pio); 155 cs5535_set_speed(drive, XFER_PIO_0 + pio);
156} 156}
157 157
158static u8 __devinit cs5535_cable_detect(struct pci_dev *dev) 158static u8 __devinit cs5535_cable_detect(ide_hwif_t *hwif)
159{ 159{
160 struct pci_dev *dev = to_pci_dev(hwif->dev);
160 u8 bit; 161 u8 bit;
161 162
162 /* if a 80 wire cable was detected */ 163 /* if a 80 wire cable was detected */
@@ -175,15 +176,10 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)
175 */ 176 */
176static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) 177static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
177{ 178{
178 struct pci_dev *dev = to_pci_dev(hwif->dev);
179
180 hwif->set_pio_mode = &cs5535_set_pio_mode; 179 hwif->set_pio_mode = &cs5535_set_pio_mode;
181 hwif->set_dma_mode = &cs5535_set_dma_mode; 180 hwif->set_dma_mode = &cs5535_set_dma_mode;
182 181
183 if (hwif->dma_base == 0) 182 hwif->cable_detect = cs5535_cable_detect;
184 return;
185
186 hwif->cbl = cs5535_cable_detect(dev);
187} 183}
188 184
189static const struct ide_port_info cs5535_chipset __devinitdata = { 185static const struct ide_port_info cs5535_chipset __devinitdata = {
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 50100ac8770f..724cbacf4e5b 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -45,7 +45,6 @@
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/types.h> 46#include <linux/types.h>
47#include <linux/pci.h> 47#include <linux/pci.h>
48#include <linux/delay.h>
49#include <linux/ide.h> 48#include <linux/ide.h>
50#include <linux/init.h> 49#include <linux/init.h>
51 50
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 27e47fc97100..3f9cd64c26a6 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -16,15 +16,14 @@
16 * License. See the file COPYING in the main directory of this archive for 16 * License. See the file COPYING in the main directory of this archive for
17 * more details. 17 * more details.
18 */ 18 */
19#include <linux/autoconf.h> 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/blkdev.h>
24#include <linux/hdreg.h> 22#include <linux/hdreg.h>
25#include <linux/ide.h> 23#include <linux/ide.h>
26#include <linux/init.h> 24#include <linux/init.h>
27#include <linux/pci.h> 25#include <linux/pci.h>
26
28#include <asm/io.h> 27#include <asm/io.h>
29 28
30/* 29/*
@@ -52,6 +51,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
52 ide_hwif_t *hwif = NULL; 51 ide_hwif_t *hwif = NULL;
53 ide_drive_t *drive; 52 ide_drive_t *drive;
54 int i, rc; 53 int i, rc;
54 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
55 55
56 rc = pci_enable_device(dev); 56 rc = pci_enable_device(dev);
57 if (rc) { 57 if (rc) {
@@ -78,12 +78,27 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
78 hw.irq = dev->irq; 78 hw.irq = dev->irq;
79 hw.chipset = ide_pci; /* this enables IRQ sharing */ 79 hw.chipset = ide_pci; /* this enables IRQ sharing */
80 80
81 rc = ide_register_hw(&hw, &ide_undecoded_slave, &hwif); 81 hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]);
82 if (rc < 0) { 82 if (hwif == NULL)
83 printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); 83 goto out_disable;
84 pci_disable_device(dev); 84
85 return -ENODEV; 85 i = hwif->index;
86 } 86
87 if (hwif->present)
88 ide_unregister(i, 0, 0);
89 else if (!hwif->hold)
90 ide_init_port_data(hwif, i);
91
92 ide_init_port_hw(hwif, &hw);
93 hwif->quirkproc = &ide_undecoded_slave;
94
95 idx[0] = i;
96
97 ide_device_add(idx, NULL);
98
99 if (!hwif->present)
100 goto out_disable;
101
87 pci_set_drvdata(dev, hwif); 102 pci_set_drvdata(dev, hwif);
88 hwif->dev = &dev->dev; 103 hwif->dev = &dev->dev;
89 drive = &hwif->drives[0]; 104 drive = &hwif->drives[0];
@@ -92,6 +107,11 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
92 drive->unmask = 1; 107 drive->unmask = 1;
93 } 108 }
94 return 0; 109 return 0;
110
111out_disable:
112 printk(KERN_ERR "delkin_cb: no IDE devices found\n");
113 pci_disable_device(dev);
114 return -ENODEV;
95} 115}
96 116
97static void 117static void
@@ -100,7 +120,8 @@ delkin_cb_remove (struct pci_dev *dev)
100 ide_hwif_t *hwif = pci_get_drvdata(dev); 120 ide_hwif_t *hwif = pci_get_drvdata(dev);
101 121
102 if (hwif) 122 if (hwif)
103 ide_unregister(hwif->index); 123 ide_unregister(hwif->index, 0, 0);
124
104 pci_disable_device(dev); 125 pci_disable_device(dev);
105} 126}
106 127
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 59ebe84f1053..9262a9174b4e 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -22,18 +22,11 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/delay.h>
26#include <linux/timer.h>
27#include <linux/mm.h>
28#include <linux/ioport.h>
29#include <linux/blkdev.h>
30#include <linux/hdreg.h> 25#include <linux/hdreg.h>
31#include <linux/pci.h> 26#include <linux/pci.h>
32#include <linux/ide.h> 27#include <linux/ide.h>
33#include <linux/init.h> 28#include <linux/init.h>
34 29
35#include <asm/io.h>
36
37static int ide_generic_all; /* Set to claim all devices */ 30static int ide_generic_all; /* Set to claim all devices */
38 31
39/* 32/*
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 25dbb814822d..9f01da46b016 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -26,20 +26,13 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/delay.h>
30#include <linux/timer.h>
31#include <linux/mm.h>
32#include <linux/ioport.h> 29#include <linux/ioport.h>
33#include <linux/blkdev.h>
34#include <linux/hdreg.h> 30#include <linux/hdreg.h>
35#include <linux/interrupt.h> 31#include <linux/interrupt.h>
36#include <linux/pci.h> 32#include <linux/pci.h>
37#include <linux/init.h> 33#include <linux/init.h>
38#include <linux/ide.h> 34#include <linux/ide.h>
39 35
40#include <asm/io.h>
41#include <asm/irq.h>
42
43#define HPT343_DEBUG_DRIVE_INFO 0 36#define HPT343_DEBUG_DRIVE_INFO 0
44 37
45static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) 38static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed)
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 5623cad569da..d0f7bb8b8adf 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -121,12 +121,8 @@
121#include <linux/module.h> 121#include <linux/module.h>
122#include <linux/kernel.h> 122#include <linux/kernel.h>
123#include <linux/delay.h> 123#include <linux/delay.h>
124#include <linux/timer.h>
125#include <linux/mm.h>
126#include <linux/ioport.h>
127#include <linux/blkdev.h> 124#include <linux/blkdev.h>
128#include <linux/hdreg.h> 125#include <linux/hdreg.h>
129
130#include <linux/interrupt.h> 126#include <linux/interrupt.h>
131#include <linux/pci.h> 127#include <linux/pci.h>
132#include <linux/init.h> 128#include <linux/init.h>
@@ -134,7 +130,6 @@
134 130
135#include <asm/uaccess.h> 131#include <asm/uaccess.h>
136#include <asm/io.h> 132#include <asm/io.h>
137#include <asm/irq.h>
138 133
139/* various tuning parameters */ 134/* various tuning parameters */
140#define HPT_RESET_STATE_ENGINE 135#define HPT_RESET_STATE_ENGINE
@@ -1279,12 +1274,55 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1279 return dev->irq; 1274 return dev->irq;
1280} 1275}
1281 1276
1277static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
1278{
1279 struct pci_dev *dev = to_pci_dev(hwif->dev);
1280 struct hpt_info *info = pci_get_drvdata(dev);
1281 u8 chip_type = info->chip_type;
1282 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
1283
1284 /*
1285 * The HPT37x uses the CBLID pins as outputs for MA15/MA16
1286 * address lines to access an external EEPROM. To read valid
1287 * cable detect state the pins must be enabled as inputs.
1288 */
1289 if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) {
1290 /*
1291 * HPT374 PCI function 1
1292 * - set bit 15 of reg 0x52 to enable TCBLID as input
1293 * - set bit 15 of reg 0x56 to enable FCBLID as input
1294 */
1295 u8 mcr_addr = hwif->select_data + 2;
1296 u16 mcr;
1297
1298 pci_read_config_word(dev, mcr_addr, &mcr);
1299 pci_write_config_word(dev, mcr_addr, (mcr | 0x8000));
1300 /* now read cable id register */
1301 pci_read_config_byte(dev, 0x5a, &scr1);
1302 pci_write_config_word(dev, mcr_addr, mcr);
1303 } else if (chip_type >= HPT370) {
1304 /*
1305 * HPT370/372 and 374 pcifn 0
1306 * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs
1307 */
1308 u8 scr2 = 0;
1309
1310 pci_read_config_byte(dev, 0x5b, &scr2);
1311 pci_write_config_byte(dev, 0x5b, (scr2 & ~1));
1312 /* now read cable id register */
1313 pci_read_config_byte(dev, 0x5a, &scr1);
1314 pci_write_config_byte(dev, 0x5b, scr2);
1315 } else
1316 pci_read_config_byte(dev, 0x5a, &scr1);
1317
1318 return (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
1319}
1320
1282static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1321static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1283{ 1322{
1284 struct pci_dev *dev = to_pci_dev(hwif->dev); 1323 struct pci_dev *dev = to_pci_dev(hwif->dev);
1285 struct hpt_info *info = pci_get_drvdata(dev); 1324 struct hpt_info *info = pci_get_drvdata(dev);
1286 int serialize = HPT_SERIALIZE_IO; 1325 int serialize = HPT_SERIALIZE_IO;
1287 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
1288 u8 chip_type = info->chip_type; 1326 u8 chip_type = info->chip_type;
1289 u8 new_mcr, old_mcr = 0; 1327 u8 new_mcr, old_mcr = 0;
1290 1328
@@ -1301,6 +1339,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1301 hwif->udma_filter = &hpt3xx_udma_filter; 1339 hwif->udma_filter = &hpt3xx_udma_filter;
1302 hwif->mdma_filter = &hpt3xx_mdma_filter; 1340 hwif->mdma_filter = &hpt3xx_mdma_filter;
1303 1341
1342 hwif->cable_detect = hpt3xx_cable_detect;
1343
1304 /* 1344 /*
1305 * HPT3xxN chips have some complications: 1345 * HPT3xxN chips have some complications:
1306 * 1346 *
@@ -1346,43 +1386,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1346 if (hwif->dma_base == 0) 1386 if (hwif->dma_base == 0)
1347 return; 1387 return;
1348 1388
1349 /*
1350 * The HPT37x uses the CBLID pins as outputs for MA15/MA16
1351 * address lines to access an external EEPROM. To read valid
1352 * cable detect state the pins must be enabled as inputs.
1353 */
1354 if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) {
1355 /*
1356 * HPT374 PCI function 1
1357 * - set bit 15 of reg 0x52 to enable TCBLID as input
1358 * - set bit 15 of reg 0x56 to enable FCBLID as input
1359 */
1360 u8 mcr_addr = hwif->select_data + 2;
1361 u16 mcr;
1362
1363 pci_read_config_word (dev, mcr_addr, &mcr);
1364 pci_write_config_word(dev, mcr_addr, (mcr | 0x8000));
1365 /* now read cable id register */
1366 pci_read_config_byte (dev, 0x5a, &scr1);
1367 pci_write_config_word(dev, mcr_addr, mcr);
1368 } else if (chip_type >= HPT370) {
1369 /*
1370 * HPT370/372 and 374 pcifn 0
1371 * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs
1372 */
1373 u8 scr2 = 0;
1374
1375 pci_read_config_byte (dev, 0x5b, &scr2);
1376 pci_write_config_byte(dev, 0x5b, (scr2 & ~1));
1377 /* now read cable id register */
1378 pci_read_config_byte (dev, 0x5a, &scr1);
1379 pci_write_config_byte(dev, 0x5b, scr2);
1380 } else
1381 pci_read_config_byte (dev, 0x5a, &scr1);
1382
1383 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
1384 hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
1385
1386 if (chip_type >= HPT374) { 1389 if (chip_type >= HPT374) {
1387 hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; 1390 hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq;
1388 hwif->ide_dma_end = &hpt374_ide_dma_end; 1391 hwif->ide_dma_end = &hpt374_ide_dma_end;
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index df74e588a530..e3427eaab430 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -10,13 +10,10 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/delay.h>
14#include <linux/hdreg.h> 13#include <linux/hdreg.h>
15#include <linux/ide.h> 14#include <linux/ide.h>
16#include <linux/init.h> 15#include <linux/init.h>
17 16
18#include <asm/io.h>
19
20/** 17/**
21 * it8213_set_pio_mode - set host controller for PIO mode 18 * it8213_set_pio_mode - set host controller for PIO mode
22 * @drive: drive 19 * @drive: drive
@@ -143,6 +140,16 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
143 } 140 }
144} 141}
145 142
143static u8 __devinit it8213_cable_detect(ide_hwif_t *hwif)
144{
145 struct pci_dev *dev = to_pci_dev(hwif->dev);
146 u8 reg42h = 0;
147
148 pci_read_config_byte(dev, 0x42, &reg42h);
149
150 return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
151}
152
146/** 153/**
147 * init_hwif_it8213 - set up hwif structs 154 * init_hwif_it8213 - set up hwif structs
148 * @hwif: interface to set up 155 * @hwif: interface to set up
@@ -152,19 +159,10 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
152 159
153static void __devinit init_hwif_it8213(ide_hwif_t *hwif) 160static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
154{ 161{
155 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 u8 reg42h = 0;
157
158 hwif->set_dma_mode = &it8213_set_dma_mode; 162 hwif->set_dma_mode = &it8213_set_dma_mode;
159 hwif->set_pio_mode = &it8213_set_pio_mode; 163 hwif->set_pio_mode = &it8213_set_pio_mode;
160 164
161 if (!hwif->dma_base) 165 hwif->cable_detect = it8213_cable_detect;
162 return;
163
164 pci_read_config_byte(dev, 0x42, &reg42h);
165
166 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
167 hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
168} 166}
169 167
170 168
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 938d35f35c81..1597f0cc1bf1 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -63,13 +63,10 @@
63#include <linux/types.h> 63#include <linux/types.h>
64#include <linux/module.h> 64#include <linux/module.h>
65#include <linux/pci.h> 65#include <linux/pci.h>
66#include <linux/delay.h>
67#include <linux/hdreg.h> 66#include <linux/hdreg.h>
68#include <linux/ide.h> 67#include <linux/ide.h>
69#include <linux/init.h> 68#include <linux/init.h>
70 69
71#include <asm/io.h>
72
73struct it821x_dev 70struct it821x_dev
74{ 71{
75 unsigned int smart:1, /* Are we in smart raid mode */ 72 unsigned int smart:1, /* Are we in smart raid mode */
@@ -579,14 +576,13 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
579 } else 576 } else
580 hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; 577 hwif->host_flags |= IDE_HFLAG_NO_SET_MODE;
581 578
579 hwif->cable_detect = ata66_it821x;
580
582 if (hwif->dma_base == 0) 581 if (hwif->dma_base == 0)
583 return; 582 return;
584 583
585 hwif->ultra_mask = ATA_UDMA6; 584 hwif->ultra_mask = ATA_UDMA6;
586 hwif->mwdma_mask = ATA_MWDMA2; 585 hwif->mwdma_mask = ATA_MWDMA2;
587
588 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
589 hwif->cbl = ata66_it821x(hwif);
590} 586}
591 587
592static void __devinit it8212_disable_raid(struct pci_dev *dev) 588static void __devinit it8212_disable_raid(struct pci_dev *dev)
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index 8b40f6479c55..a56bcb4f22f4 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -8,13 +8,10 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/delay.h>
12#include <linux/hdreg.h> 11#include <linux/hdreg.h>
13#include <linux/ide.h> 12#include <linux/ide.h>
14#include <linux/init.h> 13#include <linux/init.h>
15 14
16#include <asm/io.h>
17
18typedef enum { 15typedef enum {
19 PORT_PATA0 = 0, 16 PORT_PATA0 = 0,
20 PORT_PATA1 = 1, 17 PORT_PATA1 = 1,
@@ -111,11 +108,7 @@ static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
111 hwif->set_pio_mode = &jmicron_set_pio_mode; 108 hwif->set_pio_mode = &jmicron_set_pio_mode;
112 hwif->set_dma_mode = &jmicron_set_dma_mode; 109 hwif->set_dma_mode = &jmicron_set_dma_mode;
113 110
114 if (hwif->dma_base == 0) 111 hwif->cable_detect = ata66_jmicron;
115 return;
116
117 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
118 hwif->cbl = ata66_jmicron(hwif);
119} 112}
120 113
121static const struct ide_port_info jmicron_chipset __devinitdata = { 114static const struct ide_port_info jmicron_chipset __devinitdata = {
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index fc9eee9ccac3..bf0d3b2931f1 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -10,11 +10,7 @@
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/timer.h>
14#include <linux/mm.h>
15#include <linux/ioport.h>
16#include <linux/interrupt.h> 13#include <linux/interrupt.h>
17#include <linux/blkdev.h>
18#include <linux/hdreg.h> 14#include <linux/hdreg.h>
19#include <linux/pci.h> 15#include <linux/pci.h>
20#include <linux/delay.h> 16#include <linux/delay.h>
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 0ce92d323036..46e8748f507e 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -87,11 +87,6 @@
87#include <linux/types.h> 87#include <linux/types.h>
88#include <linux/module.h> 88#include <linux/module.h>
89#include <linux/kernel.h> 89#include <linux/kernel.h>
90#include <linux/delay.h>
91#include <linux/timer.h>
92#include <linux/mm.h>
93#include <linux/ioport.h>
94#include <linux/blkdev.h>
95#include <linux/pci.h> 90#include <linux/pci.h>
96#include <linux/hdreg.h> 91#include <linux/hdreg.h>
97#include <linux/ide.h> 92#include <linux/ide.h>
@@ -320,14 +315,18 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
320 spin_unlock_irqrestore(&opti621_lock, flags); 315 spin_unlock_irqrestore(&opti621_lock, flags);
321} 316}
322 317
318static void __devinit opti621_port_init_devs(ide_hwif_t *hwif)
319{
320 hwif->drives[0].drive_data = PIO_DONT_KNOW;
321 hwif->drives[1].drive_data = PIO_DONT_KNOW;
322}
323
323/* 324/*
324 * init_hwif_opti621() is called once for each hwif found at boot. 325 * init_hwif_opti621() is called once for each hwif found at boot.
325 */ 326 */
326static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) 327static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
327{ 328{
328 hwif->drives[0].drive_data = PIO_DONT_KNOW; 329 hwif->port_init_devs = opti621_port_init_devs;
329 hwif->drives[1].drive_data = PIO_DONT_KNOW;
330
331 hwif->set_pio_mode = &opti621_set_pio_mode; 330 hwif->set_pio_mode = &opti621_set_pio_mode;
332} 331}
333 332
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index bb29db03540e..1c8cb7797a4a 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -19,18 +19,12 @@
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/timer.h>
23#include <linux/mm.h>
24#include <linux/ioport.h>
25#include <linux/blkdev.h>
26#include <linux/hdreg.h> 22#include <linux/hdreg.h>
27#include <linux/interrupt.h>
28#include <linux/pci.h> 23#include <linux/pci.h>
29#include <linux/init.h> 24#include <linux/init.h>
30#include <linux/ide.h> 25#include <linux/ide.h>
31 26
32#include <asm/io.h> 27#include <asm/io.h>
33#include <asm/irq.h>
34 28
35#ifdef CONFIG_PPC_PMAC 29#ifdef CONFIG_PPC_PMAC
36#include <asm/prom.h> 30#include <asm/prom.h>
@@ -197,7 +191,7 @@ static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio)
197 } 191 }
198} 192}
199 193
200static u8 pdcnew_cable_detect(ide_hwif_t *hwif) 194static u8 __devinit pdcnew_cable_detect(ide_hwif_t *hwif)
201{ 195{
202 if (get_indexed_reg(hwif, 0x0b) & 0x04) 196 if (get_indexed_reg(hwif, 0x0b) & 0x04)
203 return ATA_CBL_PATA40; 197 return ATA_CBL_PATA40;
@@ -456,11 +450,7 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
456 hwif->quirkproc = &pdcnew_quirkproc; 450 hwif->quirkproc = &pdcnew_quirkproc;
457 hwif->resetproc = &pdcnew_reset; 451 hwif->resetproc = &pdcnew_reset;
458 452
459 if (hwif->dma_base == 0) 453 hwif->cable_detect = pdcnew_cable_detect;
460 return;
461
462 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
463 hwif->cbl = pdcnew_cable_detect(hwif);
464} 454}
465 455
466static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) 456static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 31a1308414a0..da4329790387 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -32,18 +32,13 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/timer.h>
36#include <linux/mm.h>
37#include <linux/ioport.h>
38#include <linux/blkdev.h> 35#include <linux/blkdev.h>
39#include <linux/hdreg.h> 36#include <linux/hdreg.h>
40#include <linux/interrupt.h>
41#include <linux/pci.h> 37#include <linux/pci.h>
42#include <linux/init.h> 38#include <linux/init.h>
43#include <linux/ide.h> 39#include <linux/ide.h>
44 40
45#include <asm/io.h> 41#include <asm/io.h>
46#include <asm/irq.h>
47 42
48#define PDC202XX_DEBUG_DRIVE_INFO 0 43#define PDC202XX_DEBUG_DRIVE_INFO 0
49 44
@@ -140,10 +135,10 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
140 pdc202xx_set_mode(drive, XFER_PIO_0 + pio); 135 pdc202xx_set_mode(drive, XFER_PIO_0 + pio);
141} 136}
142 137
143static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) 138static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
144{ 139{
145 struct pci_dev *dev = to_pci_dev(hwif->dev); 140 struct pci_dev *dev = to_pci_dev(hwif->dev);
146 u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10); 141 u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10);
147 142
148 pci_read_config_word(dev, 0x50, &CIS); 143 pci_read_config_word(dev, 0x50, &CIS);
149 144
@@ -311,9 +306,12 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
311 306
312 hwif->quirkproc = &pdc202xx_quirkproc; 307 hwif->quirkproc = &pdc202xx_quirkproc;
313 308
314 if (dev->device != PCI_DEVICE_ID_PROMISE_20246) 309 if (dev->device != PCI_DEVICE_ID_PROMISE_20246) {
315 hwif->resetproc = &pdc202xx_reset; 310 hwif->resetproc = &pdc202xx_reset;
316 311
312 hwif->cable_detect = pdc2026x_old_cable_detect;
313 }
314
317 if (hwif->dma_base == 0) 315 if (hwif->dma_base == 0)
318 return; 316 return;
319 317
@@ -321,9 +319,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
321 hwif->dma_timeout = &pdc202xx_dma_timeout; 319 hwif->dma_timeout = &pdc202xx_dma_timeout;
322 320
323 if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { 321 if (dev->device != PCI_DEVICE_ID_PROMISE_20246) {
324 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
325 hwif->cbl = pdc202xx_old_cable_detect(hwif);
326
327 hwif->dma_start = &pdc202xx_old_ide_dma_start; 322 hwif->dma_start = &pdc202xx_old_ide_dma_start;
328 hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; 323 hwif->ide_dma_end = &pdc202xx_old_ide_dma_end;
329 } 324 }
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index c1a6b68337d5..decef0f47674 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -47,11 +47,9 @@
47#include <linux/types.h> 47#include <linux/types.h>
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/kernel.h> 49#include <linux/kernel.h>
50#include <linux/ioport.h>
51#include <linux/pci.h> 50#include <linux/pci.h>
52#include <linux/hdreg.h> 51#include <linux/hdreg.h>
53#include <linux/ide.h> 52#include <linux/ide.h>
54#include <linux/delay.h>
55#include <linux/init.h> 53#include <linux/init.h>
56 54
57#include <asm/io.h> 55#include <asm/io.h>
@@ -290,14 +288,11 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
290 hwif->set_pio_mode = &piix_set_pio_mode; 288 hwif->set_pio_mode = &piix_set_pio_mode;
291 hwif->set_dma_mode = &piix_set_dma_mode; 289 hwif->set_dma_mode = &piix_set_dma_mode;
292 290
291 hwif->cable_detect = piix_cable_detect;
292
293 if (!hwif->dma_base) 293 if (!hwif->dma_base)
294 return; 294 return;
295 295
296 if (hwif->ultra_mask & 0x78) {
297 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
298 hwif->cbl = piix_cable_detect(hwif);
299 }
300
301 if (no_piix_dma) 296 if (no_piix_dma)
302 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; 297 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0;
303} 298}
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c
index 7ed6625819d4..51676612f78f 100644
--- a/drivers/ide/pci/rz1000.c
+++ b/drivers/ide/pci/rz1000.c
@@ -16,18 +16,11 @@
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/delay.h>
20#include <linux/timer.h>
21#include <linux/mm.h>
22#include <linux/ioport.h>
23#include <linux/blkdev.h>
24#include <linux/hdreg.h> 19#include <linux/hdreg.h>
25#include <linux/pci.h> 20#include <linux/pci.h>
26#include <linux/ide.h> 21#include <linux/ide.h>
27#include <linux/init.h> 22#include <linux/init.h>
28 23
29#include <asm/io.h>
30
31static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) 24static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif)
32{ 25{
33 struct pci_dev *dev = to_pci_dev(hwif->dev); 26 struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -40,8 +33,7 @@ static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif)
40 } else { 33 } else {
41 if (hwif->mate) 34 if (hwif->mate)
42 hwif->mate->serialized = hwif->serialized = 1; 35 hwif->mate->serialized = hwif->serialized = 1;
43 hwif->drives[0].no_unmask = 1; 36 hwif->host_flags |= IDE_HFLAG_NO_UNMASK_IRQS;
44 hwif->drives[1].no_unmask = 1;
45 printk(KERN_INFO "%s: serialized, disabled unmasking " 37 printk(KERN_INFO "%s: serialized, disabled unmasking "
46 "(buggy RZ1000/RZ1001)\n", hwif->name); 38 "(buggy RZ1000/RZ1001)\n", hwif->name);
47 } 39 }
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index af499a60eb31..561aa47c7720 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -14,19 +14,13 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/delay.h>
18#include <linux/timer.h>
19#include <linux/mm.h>
20#include <linux/ioport.h>
21#include <linux/blkdev.h>
22#include <linux/hdreg.h> 17#include <linux/hdreg.h>
23#include <linux/interrupt.h>
24#include <linux/pci.h> 18#include <linux/pci.h>
25#include <linux/init.h> 19#include <linux/init.h>
26#include <linux/ide.h> 20#include <linux/ide.h>
27#include <linux/pm.h> 21#include <linux/pm.h>
22
28#include <asm/io.h> 23#include <asm/io.h>
29#include <asm/irq.h>
30 24
31#define SC1200_REV_A 0x00 25#define SC1200_REV_A 0x00
32#define SC1200_REV_B1 0x01 26#define SC1200_REV_B1 0x01
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 7694969b02ce..238e3e181e87 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -644,6 +644,11 @@ static void __devinit init_iops_scc(ide_hwif_t *hwif)
644 init_mmio_iops_scc(hwif); 644 init_mmio_iops_scc(hwif);
645} 645}
646 646
647static u8 __devinit scc_cable_detect(ide_hwif_t *hwif)
648{
649 return ATA_CBL_PATA80;
650}
651
647/** 652/**
648 * init_hwif_scc - set up hwif 653 * init_hwif_scc - set up hwif
649 * @hwif: interface to set up 654 * @hwif: interface to set up
@@ -678,8 +683,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
678 else 683 else
679 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ 684 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */
680 685
681 /* we support 80c cable only. */ 686 hwif->cable_detect = scc_cable_detect;
682 hwif->cbl = ATA_CBL_PATA80;
683} 687}
684 688
685#define DECLARE_SCC_DEV(name_str) \ 689#define DECLARE_SCC_DEV(name_str) \
@@ -732,7 +736,7 @@ static void __devexit scc_remove(struct pci_dev *dev)
732 hwif->dmatable_cpu = NULL; 736 hwif->dmatable_cpu = NULL;
733 } 737 }
734 738
735 ide_unregister(hwif->index); 739 ide_unregister(hwif->index, 0, 0);
736 740
737 hwif->chipset = ide_unknown; 741 hwif->chipset = ide_unknown;
738 iounmap((void*)ports->dma); 742 iounmap((void*)ports->dma);
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index f495253b7d41..c11880b0709f 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -31,12 +31,10 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/ioport.h>
35#include <linux/pci.h> 34#include <linux/pci.h>
36#include <linux/hdreg.h> 35#include <linux/hdreg.h>
37#include <linux/ide.h> 36#include <linux/ide.h>
38#include <linux/init.h> 37#include <linux/init.h>
39#include <linux/delay.h>
40 38
41#include <asm/io.h> 39#include <asm/io.h>
42 40
@@ -346,13 +344,8 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
346 hwif->set_dma_mode = &svwks_set_dma_mode; 344 hwif->set_dma_mode = &svwks_set_dma_mode;
347 hwif->udma_filter = &svwks_udma_filter; 345 hwif->udma_filter = &svwks_udma_filter;
348 346
349 if (!hwif->dma_base) 347 if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)
350 return; 348 hwif->cable_detect = ata66_svwks;
351
352 if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
353 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
354 hwif->cbl = ata66_svwks(hwif);
355 }
356} 349}
357 350
358#define IDE_HFLAGS_SVWKS \ 351#define IDE_HFLAGS_SVWKS \
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 85902074b1fc..054626497be4 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -25,8 +25,6 @@
25#include <linux/hdreg.h> 25#include <linux/hdreg.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/timer.h>
29#include <linux/mm.h>
30#include <linux/ioport.h> 28#include <linux/ioport.h>
31#include <linux/blkdev.h> 29#include <linux/blkdev.h>
32#include <linux/scatterlist.h> 30#include <linux/scatterlist.h>
@@ -555,7 +553,6 @@ static void __devinit
555ide_init_sgiioc4(ide_hwif_t * hwif) 553ide_init_sgiioc4(ide_hwif_t * hwif)
556{ 554{
557 hwif->mmio = 1; 555 hwif->mmio = 1;
558 hwif->pio_mask = 0x00;
559 hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ 556 hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */
560 hwif->set_dma_mode = &sgiioc4_set_dma_mode; 557 hwif->set_dma_mode = &sgiioc4_set_dma_mode;
561 hwif->selectproc = NULL;/* Use the default routine to select drive */ 558 hwif->selectproc = NULL;/* Use the default routine to select drive */
@@ -572,8 +569,6 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
572 if (hwif->dma_base == 0) 569 if (hwif->dma_base == 0)
573 return; 570 return;
574 571
575 hwif->mwdma_mask = ATA_MWDMA2_ONLY;
576
577 hwif->dma_host_set = &sgiioc4_dma_host_set; 572 hwif->dma_host_set = &sgiioc4_dma_host_set;
578 hwif->dma_setup = &sgiioc4_ide_dma_setup; 573 hwif->dma_setup = &sgiioc4_ide_dma_setup;
579 hwif->dma_start = &sgiioc4_ide_dma_start; 574 hwif->dma_start = &sgiioc4_ide_dma_start;
@@ -583,6 +578,13 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
583 hwif->dma_timeout = &ide_dma_timeout; 578 hwif->dma_timeout = &ide_dma_timeout;
584} 579}
585 580
581static const struct ide_port_info sgiioc4_port_info __devinitdata = {
582 .chipset = ide_pci,
583 .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
584 IDE_HFLAG_NO_AUTOTUNE,
585 .mwdma_mask = ATA_MWDMA2_ONLY,
586};
587
586static int __devinit 588static int __devinit
587sgiioc4_ide_setup_pci_device(struct pci_dev *dev) 589sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
588{ 590{
@@ -593,6 +595,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
593 int h; 595 int h;
594 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 596 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
595 hw_regs_t hw; 597 hw_regs_t hw;
598 struct ide_port_info d = sgiioc4_port_info;
596 599
597 /* 600 /*
598 * Find an empty HWIF; if none available, return -ENOMEM. 601 * Find an empty HWIF; if none available, return -ENOMEM.
@@ -641,7 +644,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
641 ide_init_port_hw(hwif, &hw); 644 ide_init_port_hw(hwif, &hw);
642 645
643 hwif->dev = &dev->dev; 646 hwif->dev = &dev->dev;
644 hwif->channel = 0; /* Single Channel chip */
645 647
646 /* The IOC4 uses MMIO rather than Port IO. */ 648 /* The IOC4 uses MMIO rather than Port IO. */
647 default_hwif_mmiops(hwif); 649 default_hwif_mmiops(hwif);
@@ -649,15 +651,17 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
649 /* Initializing chipset IRQ Registers */ 651 /* Initializing chipset IRQ Registers */
650 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 652 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
651 653
652 if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) 654 if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) {
653 printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", 655 printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n",
654 hwif->name, DRV_NAME); 656 hwif->name, DRV_NAME);
657 d.mwdma_mask = 0;
658 }
655 659
656 ide_init_sgiioc4(hwif); 660 ide_init_sgiioc4(hwif);
657 661
658 idx[0] = hwif->index; 662 idx[0] = hwif->index;
659 663
660 if (ide_device_add(idx)) 664 if (ide_device_add(idx, &d))
661 return -EIO; 665 return -EIO;
662 666
663 return 0; 667 return 0;
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 4877bc8cd599..ef5b39fa042b 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -39,7 +39,6 @@
39#include <linux/types.h> 39#include <linux/types.h>
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/pci.h> 41#include <linux/pci.h>
42#include <linux/delay.h>
43#include <linux/hdreg.h> 42#include <linux/hdreg.h>
44#include <linux/ide.h> 43#include <linux/ide.h>
45#include <linux/init.h> 44#include <linux/init.h>
@@ -332,15 +331,18 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
332{ 331{
333 ide_hwif_t *hwif = HWIF(drive); 332 ide_hwif_t *hwif = HWIF(drive);
334 unsigned long addr = siimage_selreg(hwif, 0x1); 333 unsigned long addr = siimage_selreg(hwif, 0x1);
334 void __iomem *sata_error_addr
335 = (void __iomem *)hwif->sata_scr[SATA_ERROR_OFFSET];
335 336
336 if (SATA_ERROR_REG) { 337 if (sata_error_addr) {
337 unsigned long base = (unsigned long)hwif->hwif_data; 338 unsigned long base = (unsigned long)hwif->hwif_data;
338
339 u32 ext_stat = readl((void __iomem *)(base + 0x10)); 339 u32 ext_stat = readl((void __iomem *)(base + 0x10));
340 u8 watchdog = 0; 340 u8 watchdog = 0;
341
341 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { 342 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
342 u32 sata_error = readl((void __iomem *)SATA_ERROR_REG); 343 u32 sata_error = readl(sata_error_addr);
343 writel(sata_error, (void __iomem *)SATA_ERROR_REG); 344
345 writel(sata_error, sata_error_addr);
344 watchdog = (sata_error & 0x00680000) ? 1 : 0; 346 watchdog = (sata_error & 0x00680000) ? 1 : 0;
345 printk(KERN_WARNING "%s: sata_error = 0x%08x, " 347 printk(KERN_WARNING "%s: sata_error = 0x%08x, "
346 "watchdog = %d, %s\n", 348 "watchdog = %d, %s\n",
@@ -419,13 +421,17 @@ static int sil_sata_busproc(ide_drive_t * drive, int state)
419 421
420static int sil_sata_reset_poll(ide_drive_t *drive) 422static int sil_sata_reset_poll(ide_drive_t *drive)
421{ 423{
422 if (SATA_STATUS_REG) { 424 ide_hwif_t *hwif = drive->hwif;
423 ide_hwif_t *hwif = HWIF(drive); 425 void __iomem *sata_status_addr
426 = (void __iomem *)hwif->sata_scr[SATA_STATUS_OFFSET];
424 427
425 /* SATA_STATUS_REG is valid only when in MMIO mode */ 428 if (sata_status_addr) {
426 if ((readl((void __iomem *)SATA_STATUS_REG) & 0x03) != 0x03) { 429 /* SATA Status is available only when in MMIO mode */
430 u32 sata_stat = readl(sata_status_addr);
431
432 if ((sata_stat & 0x03) != 0x03) {
427 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", 433 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
428 hwif->name, readl((void __iomem *)SATA_STATUS_REG)); 434 hwif->name, sata_stat);
429 HWGROUP(drive)->polling = 0; 435 HWGROUP(drive)->polling = 0;
430 return ide_started; 436 return ide_started;
431 } 437 }
@@ -827,15 +833,14 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
827 } else 833 } else
828 hwif->udma_filter = &sil_pata_udma_filter; 834 hwif->udma_filter = &sil_pata_udma_filter;
829 835
836 hwif->cable_detect = ata66_siimage;
837
830 if (hwif->dma_base == 0) 838 if (hwif->dma_base == 0)
831 return; 839 return;
832 840
833 if (sata) 841 if (sata)
834 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 842 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
835 843
836 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
837 hwif->cbl = ata66_siimage(hwif);
838
839 if (hwif->mmio) { 844 if (hwif->mmio) {
840 hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; 845 hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq;
841 } else { 846 } else {
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 2a461de22aa0..512bb4c1fd5c 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -47,20 +47,11 @@
47#include <linux/types.h> 47#include <linux/types.h>
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/kernel.h> 49#include <linux/kernel.h>
50#include <linux/delay.h>
51#include <linux/timer.h>
52#include <linux/mm.h>
53#include <linux/ioport.h>
54#include <linux/blkdev.h>
55#include <linux/hdreg.h> 50#include <linux/hdreg.h>
56
57#include <linux/interrupt.h>
58#include <linux/pci.h> 51#include <linux/pci.h>
59#include <linux/init.h> 52#include <linux/init.h>
60#include <linux/ide.h> 53#include <linux/ide.h>
61 54
62#include <asm/irq.h>
63
64#include "ide-timing.h" 55#include "ide-timing.h"
65 56
66/* registers layout and init values are chipset family dependant */ 57/* registers layout and init values are chipset family dependant */
@@ -565,13 +556,12 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
565 if (chipset_family >= ATA_133) 556 if (chipset_family >= ATA_133)
566 hwif->udma_filter = sis5513_ata133_udma_filter; 557 hwif->udma_filter = sis5513_ata133_udma_filter;
567 558
559 hwif->cable_detect = ata66_sis5513;
560
568 if (hwif->dma_base == 0) 561 if (hwif->dma_base == 0)
569 return; 562 return;
570 563
571 hwif->ultra_mask = udma_rates[chipset_family]; 564 hwif->ultra_mask = udma_rates[chipset_family];
572
573 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
574 hwif->cbl = ata66_sis5513(hwif);
575} 565}
576 566
577static const struct ide_port_info sis5513_chipset __devinitdata = { 567static const struct ide_port_info sis5513_chipset __devinitdata = {
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index da13a1298ada..ee261ae15b6f 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -17,17 +17,11 @@
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/timer.h>
21#include <linux/mm.h>
22#include <linux/ioport.h>
23#include <linux/interrupt.h>
24#include <linux/blkdev.h>
25#include <linux/hdreg.h> 20#include <linux/hdreg.h>
26#include <linux/pci.h> 21#include <linux/pci.h>
27#include <linux/ide.h> 22#include <linux/ide.h>
28 23
29#include <asm/io.h> 24#include <asm/io.h>
30#include <asm/dma.h>
31 25
32#undef DEBUG 26#undef DEBUG
33 27
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index a6cf810c4699..65f4c2ffaa59 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -10,15 +10,11 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/ioport.h>
14#include <linux/pci.h> 13#include <linux/pci.h>
15#include <linux/hdreg.h> 14#include <linux/hdreg.h>
16#include <linux/ide.h> 15#include <linux/ide.h>
17#include <linux/delay.h>
18#include <linux/init.h> 16#include <linux/init.h>
19 17
20#include <asm/io.h>
21
22static DEFINE_SPINLOCK(slc90e66_lock); 18static DEFINE_SPINLOCK(slc90e66_lock);
23 19
24static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) 20static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
@@ -118,23 +114,23 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
118 } 114 }
119} 115}
120 116
121static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) 117static u8 __devinit slc90e66_cable_detect(ide_hwif_t *hwif)
122{ 118{
123 struct pci_dev *dev = to_pci_dev(hwif->dev); 119 struct pci_dev *dev = to_pci_dev(hwif->dev);
124 u8 reg47 = 0; 120 u8 reg47 = 0, mask = hwif->channel ? 0x01 : 0x02;
125 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */
126
127 hwif->set_pio_mode = &slc90e66_set_pio_mode;
128 hwif->set_dma_mode = &slc90e66_set_dma_mode;
129 121
130 pci_read_config_byte(dev, 0x47, &reg47); 122 pci_read_config_byte(dev, 0x47, &reg47);
131 123
132 if (hwif->dma_base == 0) 124 /* bit[0(1)]: 0:80, 1:40 */
133 return; 125 return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
126}
127
128static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif)
129{
130 hwif->set_pio_mode = &slc90e66_set_pio_mode;
131 hwif->set_dma_mode = &slc90e66_set_dma_mode;
134 132
135 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 133 hwif->cable_detect = slc90e66_cable_detect;
136 /* bit[0(1)]: 0:80, 1:40 */
137 hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
138} 134}
139 135
140static const struct ide_port_info slc90e66_chipset __devinitdata = { 136static const struct ide_port_info slc90e66_chipset __devinitdata = {
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 9fbbb4f2dd54..2ef2ed2f2b32 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -160,6 +160,19 @@ static int tc86c001_busproc(ide_drive_t *drive, int state)
160 return 0; 160 return 0;
161} 161}
162 162
163static u8 __devinit tc86c001_cable_detect(ide_hwif_t *hwif)
164{
165 struct pci_dev *dev = to_pci_dev(hwif->dev);
166 unsigned long sc_base = pci_resource_start(dev, 5);
167 u16 scr1 = inw(sc_base + 0x00);
168
169 /*
170 * System Control 1 Register bit 13 (PDIAGN):
171 * 0=80-pin cable, 1=40-pin cable
172 */
173 return (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
174}
175
163static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) 176static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
164{ 177{
165 struct pci_dev *dev = to_pci_dev(hwif->dev); 178 struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -183,6 +196,8 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
183 196
184 hwif->busproc = &tc86c001_busproc; 197 hwif->busproc = &tc86c001_busproc;
185 198
199 hwif->cable_detect = tc86c001_cable_detect;
200
186 if (!hwif->dma_base) 201 if (!hwif->dma_base)
187 return; 202 return;
188 203
@@ -196,15 +211,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
196 hwif->rqsize = 0xffff; 211 hwif->rqsize = 0xffff;
197 212
198 hwif->dma_start = &tc86c001_dma_start; 213 hwif->dma_start = &tc86c001_dma_start;
199
200 if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
201 /*
202 * System Control 1 Register bit 13 (PDIAGN):
203 * 0=80-pin cable, 1=40-pin cable
204 */
205 scr1 = inw(sc_base + 0x00);
206 hwif->cbl = (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
207 }
208} 214}
209 215
210static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, 216static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev,
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index 852b72693736..a67d02a3f96e 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -28,11 +28,6 @@
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/delay.h>
32#include <linux/timer.h>
33#include <linux/mm.h>
34#include <linux/ioport.h>
35#include <linux/blkdev.h>
36#include <linux/hdreg.h> 31#include <linux/hdreg.h>
37#include <linux/pci.h> 32#include <linux/pci.h>
38#include <linux/ide.h> 33#include <linux/ide.h>
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
index d9ebb698953a..de750f7a43e9 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/pci/trm290.c
@@ -131,14 +131,12 @@
131#include <linux/types.h> 131#include <linux/types.h>
132#include <linux/module.h> 132#include <linux/module.h>
133#include <linux/kernel.h> 133#include <linux/kernel.h>
134#include <linux/mm.h>
135#include <linux/ioport.h> 134#include <linux/ioport.h>
136#include <linux/interrupt.h> 135#include <linux/interrupt.h>
137#include <linux/blkdev.h> 136#include <linux/blkdev.h>
138#include <linux/init.h> 137#include <linux/init.h>
139#include <linux/hdreg.h> 138#include <linux/hdreg.h>
140#include <linux/pci.h> 139#include <linux/pci.h>
141#include <linux/delay.h>
142#include <linux/ide.h> 140#include <linux/ide.h>
143 141
144#include <asm/io.h> 142#include <asm/io.h>
@@ -179,10 +177,7 @@ static void trm290_selectproc (ide_drive_t *drive)
179 177
180static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command) 178static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command)
181{ 179{
182 BUG_ON(HWGROUP(drive)->handler != NULL); /* paranoia check */ 180 ide_execute_command(drive, command, &ide_dma_intr, WAIT_CMD, NULL);
183 ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
184 /* issue cmd to drive */
185 outb(command, IDE_COMMAND_REG);
186} 181}
187 182
188static int trm290_dma_setup(ide_drive_t *drive) 183static int trm290_dma_setup(ide_drive_t *drive)
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 24cb9047fb41..f3f79f805813 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -26,15 +26,11 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/ioport.h>
30#include <linux/blkdev.h>
31#include <linux/pci.h> 29#include <linux/pci.h>
32#include <linux/init.h> 30#include <linux/init.h>
33#include <linux/ide.h> 31#include <linux/ide.h>
34#include <linux/dmi.h> 32#include <linux/dmi.h>
35 33
36#include <asm/io.h>
37
38#ifdef CONFIG_PPC_CHRP 34#ifdef CONFIG_PPC_CHRP
39#include <asm/processor.h> 35#include <asm/processor.h>
40#endif 36#endif
@@ -424,11 +420,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
424 hwif->set_pio_mode = &via_set_pio_mode; 420 hwif->set_pio_mode = &via_set_pio_mode;
425 hwif->set_dma_mode = &via_set_drive; 421 hwif->set_dma_mode = &via_set_drive;
426 422
427 if (!hwif->dma_base) 423 hwif->cable_detect = via82cxxx_cable_detect;
428 return;
429
430 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
431 hwif->cbl = via82cxxx_cable_detect(hwif);
432} 424}
433 425
434static const struct ide_port_info via82cxxx_chipset __devinitdata = { 426static const struct ide_port_info via82cxxx_chipset __devinitdata = {