aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/libata.tmpl12
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/ata/Kconfig150
-rw-r--r--drivers/ata/Makefile21
-rw-r--r--drivers/ata/ahci.c (renamed from drivers/scsi/ahci.c)719
-rw-r--r--drivers/ata/ata_piix.c (renamed from drivers/scsi/ata_piix.c)80
-rw-r--r--drivers/ata/libata-core.c (renamed from drivers/scsi/libata-core.c)584
-rw-r--r--drivers/ata/libata-eh.c (renamed from drivers/scsi/libata-eh.c)18
-rw-r--r--drivers/ata/libata-scsi.c (renamed from drivers/scsi/libata-scsi.c)223
-rw-r--r--drivers/ata/libata-sff.c (renamed from drivers/scsi/libata-bmdma.c)188
-rw-r--r--drivers/ata/libata.h (renamed from drivers/scsi/libata.h)5
-rw-r--r--drivers/ata/pdc_adma.c (renamed from drivers/scsi/pdc_adma.c)48
-rw-r--r--drivers/ata/sata_mv.c (renamed from drivers/scsi/sata_mv.c)100
-rw-r--r--drivers/ata/sata_nv.c (renamed from drivers/scsi/sata_nv.c)60
-rw-r--r--drivers/ata/sata_promise.c (renamed from drivers/scsi/sata_promise.c)56
-rw-r--r--drivers/ata/sata_promise.h (renamed from drivers/scsi/sata_promise.h)0
-rw-r--r--drivers/ata/sata_qstor.c (renamed from drivers/scsi/sata_qstor.c)46
-rw-r--r--drivers/ata/sata_sil.c (renamed from drivers/scsi/sata_sil.c)59
-rw-r--r--drivers/ata/sata_sil24.c (renamed from drivers/scsi/sata_sil24.c)67
-rw-r--r--drivers/ata/sata_sis.c (renamed from drivers/scsi/sata_sis.c)20
-rw-r--r--drivers/ata/sata_svw.c (renamed from drivers/scsi/sata_svw.c)12
-rw-r--r--drivers/ata/sata_sx4.c (renamed from drivers/scsi/sata_sx4.c)66
-rw-r--r--drivers/ata/sata_uli.c (renamed from drivers/scsi/sata_uli.c)10
-rw-r--r--drivers/ata/sata_via.c (renamed from drivers/scsi/sata_via.c)7
-rw-r--r--drivers/ata/sata_vsc.c (renamed from drivers/scsi/sata_vsc.c)18
-rw-r--r--drivers/pci/quirks.c6
-rw-r--r--drivers/scsi/Kconfig138
-rw-r--r--drivers/scsi/Makefile16
-rw-r--r--include/asm-alpha/libata-portmap.h1
-rw-r--r--include/asm-generic/libata-portmap.h12
-rw-r--r--include/asm-i386/libata-portmap.h1
-rw-r--r--include/asm-ia64/libata-portmap.h1
-rw-r--r--include/asm-powerpc/libata-portmap.h1
-rw-r--r--include/asm-sparc/libata-portmap.h1
-rw-r--r--include/asm-sparc64/libata-portmap.h1
-rw-r--r--include/asm-x86_64/libata-portmap.h1
-rw-r--r--include/linux/ata.h22
-rw-r--r--include/linux/libata.h72
39 files changed, 1690 insertions, 1155 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index e97c32314541..065e8dc23e3a 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -868,18 +868,18 @@ and other resources, etc.
868 868
869 <chapter id="libataExt"> 869 <chapter id="libataExt">
870 <title>libata Library</title> 870 <title>libata Library</title>
871!Edrivers/scsi/libata-core.c 871!Edrivers/ata/libata-core.c
872 </chapter> 872 </chapter>
873 873
874 <chapter id="libataInt"> 874 <chapter id="libataInt">
875 <title>libata Core Internals</title> 875 <title>libata Core Internals</title>
876!Idrivers/scsi/libata-core.c 876!Idrivers/ata/libata-core.c
877 </chapter> 877 </chapter>
878 878
879 <chapter id="libataScsiInt"> 879 <chapter id="libataScsiInt">
880 <title>libata SCSI translation/emulation</title> 880 <title>libata SCSI translation/emulation</title>
881!Edrivers/scsi/libata-scsi.c 881!Edrivers/ata/libata-scsi.c
882!Idrivers/scsi/libata-scsi.c 882!Idrivers/ata/libata-scsi.c
883 </chapter> 883 </chapter>
884 884
885 <chapter id="ataExceptions"> 885 <chapter id="ataExceptions">
@@ -1600,12 +1600,12 @@ and other resources, etc.
1600 1600
1601 <chapter id="PiixInt"> 1601 <chapter id="PiixInt">
1602 <title>ata_piix Internals</title> 1602 <title>ata_piix Internals</title>
1603!Idrivers/scsi/ata_piix.c 1603!Idrivers/ata/ata_piix.c
1604 </chapter> 1604 </chapter>
1605 1605
1606 <chapter id="SILInt"> 1606 <chapter id="SILInt">
1607 <title>sata_sil Internals</title> 1607 <title>sata_sil Internals</title>
1608!Idrivers/scsi/sata_sil.c 1608!Idrivers/ata/sata_sil.c
1609 </chapter> 1609 </chapter>
1610 1610
1611 <chapter id="libataThanks"> 1611 <chapter id="libataThanks">
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 8b11cebe65df..263e86ddc1a4 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -18,6 +18,8 @@ source "drivers/ide/Kconfig"
18 18
19source "drivers/scsi/Kconfig" 19source "drivers/scsi/Kconfig"
20 20
21source "drivers/ata/Kconfig"
22
21source "drivers/cdrom/Kconfig" 23source "drivers/cdrom/Kconfig"
22 24
23source "drivers/md/Kconfig" 25source "drivers/md/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index fc2d744a4e4a..4ac14dab3079 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_PPC_PMAC) += macintosh/
34obj-$(CONFIG_IDE) += ide/ 34obj-$(CONFIG_IDE) += ide/
35obj-$(CONFIG_FC4) += fc4/ 35obj-$(CONFIG_FC4) += fc4/
36obj-$(CONFIG_SCSI) += scsi/ 36obj-$(CONFIG_SCSI) += scsi/
37obj-$(CONFIG_ATA) += ata/
37obj-$(CONFIG_FUSION) += message/ 38obj-$(CONFIG_FUSION) += message/
38obj-$(CONFIG_IEEE1394) += ieee1394/ 39obj-$(CONFIG_IEEE1394) += ieee1394/
39obj-y += cdrom/ 40obj-y += cdrom/
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
new file mode 100644
index 000000000000..13027d56b7f6
--- /dev/null
+++ b/drivers/ata/Kconfig
@@ -0,0 +1,150 @@
1#
2# SATA/PATA driver configuration
3#
4
5menu "Serial ATA (prod) and Parallel ATA (experimental) drivers"
6
7config ATA
8 tristate "ATA device support"
9 select SCSI
10 ---help---
11 If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or
12 any other ATA device under Linux, say Y and make sure that you know
13 the name of your ATA host adapter (the card inside your computer
14 that "speaks" the ATA protocol, also called ATA controller),
15 because you will be asked for it.
16
17if ATA
18
19config SATA_AHCI
20 tristate "AHCI SATA support"
21 depends on PCI
22 help
23 This option enables support for AHCI Serial ATA.
24
25 If unsure, say N.
26
27config SATA_SVW
28 tristate "ServerWorks Frodo / Apple K2 SATA support"
29 depends on PCI
30 help
31 This option enables support for Broadcom/Serverworks/Apple K2
32 SATA support.
33
34 If unsure, say N.
35
36config ATA_PIIX
37 tristate "Intel PIIX/ICH SATA support"
38 depends on PCI
39 help
40 This option enables support for ICH5/6/7/8 Serial ATA.
41 If PATA support was enabled previously, this enables
42 support for select Intel PIIX/ICH PATA host controllers.
43
44 If unsure, say N.
45
46config SATA_MV
47 tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)"
48 depends on PCI && EXPERIMENTAL
49 help
50 This option enables support for the Marvell Serial ATA family.
51 Currently supports 88SX[56]0[48][01] chips.
52
53 If unsure, say N.
54
55config SATA_NV
56 tristate "NVIDIA SATA support"
57 depends on PCI
58 help
59 This option enables support for NVIDIA Serial ATA.
60
61 If unsure, say N.
62
63config PDC_ADMA
64 tristate "Pacific Digital ADMA support"
65 depends on PCI
66 help
67 This option enables support for Pacific Digital ADMA controllers
68
69 If unsure, say N.
70
71config SATA_QSTOR
72 tristate "Pacific Digital SATA QStor support"
73 depends on PCI
74 help
75 This option enables support for Pacific Digital Serial ATA QStor.
76
77 If unsure, say N.
78
79config SATA_PROMISE
80 tristate "Promise SATA TX2/TX4 support"
81 depends on PCI
82 help
83 This option enables support for Promise Serial ATA TX2/TX4.
84
85 If unsure, say N.
86
87config SATA_SX4
88 tristate "Promise SATA SX4 support"
89 depends on PCI && EXPERIMENTAL
90 help
91 This option enables support for Promise Serial ATA SX4.
92
93 If unsure, say N.
94
95config SATA_SIL
96 tristate "Silicon Image SATA support"
97 depends on PCI
98 help
99 This option enables support for Silicon Image Serial ATA.
100
101 If unsure, say N.
102
103config SATA_SIL24
104 tristate "Silicon Image 3124/3132 SATA support"
105 depends on PCI
106 help
107 This option enables support for Silicon Image 3124/3132 Serial ATA.
108
109 If unsure, say N.
110
111config SATA_SIS
112 tristate "SiS 964/180 SATA support"
113 depends on PCI
114 help
115 This option enables support for SiS Serial ATA 964/180.
116
117 If unsure, say N.
118
119config SATA_ULI
120 tristate "ULi Electronics SATA support"
121 depends on PCI
122 help
123 This option enables support for ULi Electronics SATA.
124
125 If unsure, say N.
126
127config SATA_VIA
128 tristate "VIA SATA support"
129 depends on PCI
130 help
131 This option enables support for VIA Serial ATA.
132
133 If unsure, say N.
134
135config SATA_VITESSE
136 tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
137 depends on PCI
138 help
139 This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
140
141 If unsure, say N.
142
143config SATA_INTEL_COMBINED
144 bool
145 depends on IDE=y && !BLK_DEV_IDE_SATA && (SATA_AHCI || ATA_PIIX)
146 default y
147
148endif
149endmenu
150
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
new file mode 100644
index 000000000000..e260e3fe65c8
--- /dev/null
+++ b/drivers/ata/Makefile
@@ -0,0 +1,21 @@
1
2obj-$(CONFIG_ATA) += libata.o
3
4obj-$(CONFIG_SATA_AHCI) += ahci.o
5obj-$(CONFIG_SATA_SVW) += sata_svw.o
6obj-$(CONFIG_ATA_PIIX) += ata_piix.o
7obj-$(CONFIG_SATA_PROMISE) += sata_promise.o
8obj-$(CONFIG_SATA_QSTOR) += sata_qstor.o
9obj-$(CONFIG_SATA_SIL) += sata_sil.o
10obj-$(CONFIG_SATA_SIL24) += sata_sil24.o
11obj-$(CONFIG_SATA_VIA) += sata_via.o
12obj-$(CONFIG_SATA_VITESSE) += sata_vsc.o
13obj-$(CONFIG_SATA_SIS) += sata_sis.o
14obj-$(CONFIG_SATA_SX4) += sata_sx4.o
15obj-$(CONFIG_SATA_NV) += sata_nv.o
16obj-$(CONFIG_SATA_ULI) += sata_uli.o
17obj-$(CONFIG_SATA_MV) += sata_mv.o
18obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
19
20libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o
21
diff --git a/drivers/scsi/ahci.c b/drivers/ata/ahci.c
index 904c25fb4ba4..3f1106fdaed1 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/ata/ahci.c
@@ -92,7 +92,9 @@ enum {
92 HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ 92 HOST_AHCI_EN = (1 << 31), /* AHCI enabled */
93 93
94 /* HOST_CAP bits */ 94 /* HOST_CAP bits */
95 HOST_CAP_SSC = (1 << 14), /* Slumber capable */
95 HOST_CAP_CLO = (1 << 24), /* Command List Override support */ 96 HOST_CAP_CLO = (1 << 24), /* Command List Override support */
97 HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
96 HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ 98 HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */
97 HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */ 99 HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */
98 100
@@ -155,6 +157,7 @@ enum {
155 PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */ 157 PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */
156 PORT_CMD_START = (1 << 0), /* Enable port DMA engine */ 158 PORT_CMD_START = (1 << 0), /* Enable port DMA engine */
157 159
160 PORT_CMD_ICC_MASK = (0xf << 28), /* i/f ICC state mask */
158 PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */ 161 PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */
159 PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ 162 PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */
160 PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ 163 PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */
@@ -212,6 +215,10 @@ static void ahci_freeze(struct ata_port *ap);
212static void ahci_thaw(struct ata_port *ap); 215static void ahci_thaw(struct ata_port *ap);
213static void ahci_error_handler(struct ata_port *ap); 216static void ahci_error_handler(struct ata_port *ap);
214static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); 217static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
218static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
219static int ahci_port_resume(struct ata_port *ap);
220static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
221static int ahci_pci_device_resume(struct pci_dev *pdev);
215static void ahci_remove_one (struct pci_dev *pdev); 222static void ahci_remove_one (struct pci_dev *pdev);
216 223
217static struct scsi_host_template ahci_sht = { 224static struct scsi_host_template ahci_sht = {
@@ -231,6 +238,8 @@ static struct scsi_host_template ahci_sht = {
231 .slave_configure = ata_scsi_slave_config, 238 .slave_configure = ata_scsi_slave_config,
232 .slave_destroy = ata_scsi_slave_destroy, 239 .slave_destroy = ata_scsi_slave_destroy,
233 .bios_param = ata_std_bios_param, 240 .bios_param = ata_std_bios_param,
241 .suspend = ata_scsi_device_suspend,
242 .resume = ata_scsi_device_resume,
234}; 243};
235 244
236static const struct ata_port_operations ahci_ops = { 245static const struct ata_port_operations ahci_ops = {
@@ -257,6 +266,9 @@ static const struct ata_port_operations ahci_ops = {
257 .error_handler = ahci_error_handler, 266 .error_handler = ahci_error_handler,
258 .post_internal_cmd = ahci_post_internal_cmd, 267 .post_internal_cmd = ahci_post_internal_cmd,
259 268
269 .port_suspend = ahci_port_suspend,
270 .port_resume = ahci_port_resume,
271
260 .port_start = ahci_port_start, 272 .port_start = ahci_port_start,
261 .port_stop = ahci_port_stop, 273 .port_stop = ahci_port_stop,
262}; 274};
@@ -265,7 +277,7 @@ static const struct ata_port_info ahci_port_info[] = {
265 /* board_ahci */ 277 /* board_ahci */
266 { 278 {
267 .sht = &ahci_sht, 279 .sht = &ahci_sht,
268 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 280 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
269 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 281 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
270 ATA_FLAG_SKIP_D2H_BSY, 282 ATA_FLAG_SKIP_D2H_BSY,
271 .pio_mask = 0x1f, /* pio0-4 */ 283 .pio_mask = 0x1f, /* pio0-4 */
@@ -275,7 +287,7 @@ static const struct ata_port_info ahci_port_info[] = {
275 /* board_ahci_vt8251 */ 287 /* board_ahci_vt8251 */
276 { 288 {
277 .sht = &ahci_sht, 289 .sht = &ahci_sht,
278 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 290 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
279 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 291 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
280 ATA_FLAG_SKIP_D2H_BSY | 292 ATA_FLAG_SKIP_D2H_BSY |
281 AHCI_FLAG_RESET_NEEDS_CLO | AHCI_FLAG_NO_NCQ, 293 AHCI_FLAG_RESET_NEEDS_CLO | AHCI_FLAG_NO_NCQ,
@@ -350,6 +362,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
350 { PCI_VENDOR_ID_NVIDIA, 0x044f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 362 { PCI_VENDOR_ID_NVIDIA, 0x044f, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
351 board_ahci }, /* MCP65 */ 363 board_ahci }, /* MCP65 */
352 364
365 /* SiS */
366 { PCI_VENDOR_ID_SI, 0x1184, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
367 board_ahci }, /* SiS 966 */
368 { PCI_VENDOR_ID_SI, 0x1185, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
369 board_ahci }, /* SiS 966 */
370 { PCI_VENDOR_ID_SI, 0x0186, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
371 board_ahci }, /* SiS 968 */
372
353 { } /* terminate list */ 373 { } /* terminate list */
354}; 374};
355 375
@@ -358,6 +378,8 @@ static struct pci_driver ahci_pci_driver = {
358 .name = DRV_NAME, 378 .name = DRV_NAME,
359 .id_table = ahci_pci_tbl, 379 .id_table = ahci_pci_tbl,
360 .probe = ahci_init_one, 380 .probe = ahci_init_one,
381 .suspend = ahci_pci_device_suspend,
382 .resume = ahci_pci_device_resume,
361 .remove = ahci_remove_one, 383 .remove = ahci_remove_one,
362}; 384};
363 385
@@ -372,177 +394,288 @@ static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int por
372 return (void __iomem *) ahci_port_base_ul((unsigned long)base, port); 394 return (void __iomem *) ahci_port_base_ul((unsigned long)base, port);
373} 395}
374 396
375static int ahci_port_start(struct ata_port *ap) 397static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
376{ 398{
377 struct device *dev = ap->host_set->dev; 399 unsigned int sc_reg;
378 struct ahci_host_priv *hpriv = ap->host_set->private_data;
379 struct ahci_port_priv *pp;
380 void __iomem *mmio = ap->host_set->mmio_base;
381 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
382 void *mem;
383 dma_addr_t mem_dma;
384 int rc;
385
386 pp = kmalloc(sizeof(*pp), GFP_KERNEL);
387 if (!pp)
388 return -ENOMEM;
389 memset(pp, 0, sizeof(*pp));
390 400
391 rc = ata_pad_alloc(ap, dev); 401 switch (sc_reg_in) {
392 if (rc) { 402 case SCR_STATUS: sc_reg = 0; break;
393 kfree(pp); 403 case SCR_CONTROL: sc_reg = 1; break;
394 return rc; 404 case SCR_ERROR: sc_reg = 2; break;
405 case SCR_ACTIVE: sc_reg = 3; break;
406 default:
407 return 0xffffffffU;
395 } 408 }
396 409
397 mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL); 410 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
398 if (!mem) { 411}
399 ata_pad_free(ap, dev);
400 kfree(pp);
401 return -ENOMEM;
402 }
403 memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
404 412
405 /*
406 * First item in chunk of DMA memory: 32-slot command table,
407 * 32 bytes each in size
408 */
409 pp->cmd_slot = mem;
410 pp->cmd_slot_dma = mem_dma;
411 413
412 mem += AHCI_CMD_SLOT_SZ; 414static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
413 mem_dma += AHCI_CMD_SLOT_SZ; 415 u32 val)
416{
417 unsigned int sc_reg;
414 418
415 /* 419 switch (sc_reg_in) {
416 * Second item: Received-FIS area 420 case SCR_STATUS: sc_reg = 0; break;
417 */ 421 case SCR_CONTROL: sc_reg = 1; break;
418 pp->rx_fis = mem; 422 case SCR_ERROR: sc_reg = 2; break;
419 pp->rx_fis_dma = mem_dma; 423 case SCR_ACTIVE: sc_reg = 3; break;
424 default:
425 return;
426 }
420 427
421 mem += AHCI_RX_FIS_SZ; 428 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
422 mem_dma += AHCI_RX_FIS_SZ; 429}
423 430
424 /* 431static void ahci_start_engine(void __iomem *port_mmio)
425 * Third item: data area for storing a single command 432{
426 * and its scatter-gather table 433 u32 tmp;
427 */
428 pp->cmd_tbl = mem;
429 pp->cmd_tbl_dma = mem_dma;
430 434
431 ap->private_data = pp; 435 /* start DMA */
436 tmp = readl(port_mmio + PORT_CMD);
437 tmp |= PORT_CMD_START;
438 writel(tmp, port_mmio + PORT_CMD);
439 readl(port_mmio + PORT_CMD); /* flush */
440}
432 441
433 if (hpriv->cap & HOST_CAP_64) 442static int ahci_stop_engine(void __iomem *port_mmio)
434 writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI); 443{
435 writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR); 444 u32 tmp;
436 readl(port_mmio + PORT_LST_ADDR); /* flush */
437 445
438 if (hpriv->cap & HOST_CAP_64) 446 tmp = readl(port_mmio + PORT_CMD);
439 writel((pp->rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
440 writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
441 readl(port_mmio + PORT_FIS_ADDR); /* flush */
442 447
443 writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX | 448 /* check if the HBA is idle */
444 PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP | 449 if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0)
445 PORT_CMD_START, port_mmio + PORT_CMD); 450 return 0;
446 readl(port_mmio + PORT_CMD); /* flush */ 451
452 /* setting HBA to idle */
453 tmp &= ~PORT_CMD_START;
454 writel(tmp, port_mmio + PORT_CMD);
455
456 /* wait for engine to stop. This could be as long as 500 msec */
457 tmp = ata_wait_register(port_mmio + PORT_CMD,
458 PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
459 if (tmp & PORT_CMD_LIST_ON)
460 return -EIO;
447 461
448 return 0; 462 return 0;
449} 463}
450 464
465static void ahci_start_fis_rx(void __iomem *port_mmio, u32 cap,
466 dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
467{
468 u32 tmp;
451 469
452static void ahci_port_stop(struct ata_port *ap) 470 /* set FIS registers */
471 if (cap & HOST_CAP_64)
472 writel((cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
473 writel(cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
474
475 if (cap & HOST_CAP_64)
476 writel((rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
477 writel(rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
478
479 /* enable FIS reception */
480 tmp = readl(port_mmio + PORT_CMD);
481 tmp |= PORT_CMD_FIS_RX;
482 writel(tmp, port_mmio + PORT_CMD);
483
484 /* flush */
485 readl(port_mmio + PORT_CMD);
486}
487
488static int ahci_stop_fis_rx(void __iomem *port_mmio)
453{ 489{
454 struct device *dev = ap->host_set->dev;
455 struct ahci_port_priv *pp = ap->private_data;
456 void __iomem *mmio = ap->host_set->mmio_base;
457 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
458 u32 tmp; 490 u32 tmp;
459 491
492 /* disable FIS reception */
460 tmp = readl(port_mmio + PORT_CMD); 493 tmp = readl(port_mmio + PORT_CMD);
461 tmp &= ~(PORT_CMD_START | PORT_CMD_FIS_RX); 494 tmp &= ~PORT_CMD_FIS_RX;
462 writel(tmp, port_mmio + PORT_CMD); 495 writel(tmp, port_mmio + PORT_CMD);
463 readl(port_mmio + PORT_CMD); /* flush */
464 496
465 /* spec says 500 msecs for each PORT_CMD_{START,FIS_RX} bit, so 497 /* wait for completion, spec says 500ms, give it 1000 */
466 * this is slightly incorrect. 498 tmp = ata_wait_register(port_mmio + PORT_CMD, PORT_CMD_FIS_ON,
467 */ 499 PORT_CMD_FIS_ON, 10, 1000);
468 msleep(500); 500 if (tmp & PORT_CMD_FIS_ON)
501 return -EBUSY;
469 502
470 ap->private_data = NULL; 503 return 0;
471 dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
472 pp->cmd_slot, pp->cmd_slot_dma);
473 ata_pad_free(ap, dev);
474 kfree(pp);
475} 504}
476 505
477static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in) 506static void ahci_power_up(void __iomem *port_mmio, u32 cap)
478{ 507{
479 unsigned int sc_reg; 508 u32 cmd;
480 509
481 switch (sc_reg_in) { 510 cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
482 case SCR_STATUS: sc_reg = 0; break; 511
483 case SCR_CONTROL: sc_reg = 1; break; 512 /* spin up device */
484 case SCR_ERROR: sc_reg = 2; break; 513 if (cap & HOST_CAP_SSS) {
485 case SCR_ACTIVE: sc_reg = 3; break; 514 cmd |= PORT_CMD_SPIN_UP;
486 default: 515 writel(cmd, port_mmio + PORT_CMD);
487 return 0xffffffffU;
488 } 516 }
489 517
490 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); 518 /* wake up link */
519 writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD);
491} 520}
492 521
522static void ahci_power_down(void __iomem *port_mmio, u32 cap)
523{
524 u32 cmd, scontrol;
493 525
494static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in, 526 cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
495 u32 val) 527
528 if (cap & HOST_CAP_SSC) {
529 /* enable transitions to slumber mode */
530 scontrol = readl(port_mmio + PORT_SCR_CTL);
531 if ((scontrol & 0x0f00) > 0x100) {
532 scontrol &= ~0xf00;
533 writel(scontrol, port_mmio + PORT_SCR_CTL);
534 }
535
536 /* put device into slumber mode */
537 writel(cmd | PORT_CMD_ICC_SLUMBER, port_mmio + PORT_CMD);
538
539 /* wait for the transition to complete */
540 ata_wait_register(port_mmio + PORT_CMD, PORT_CMD_ICC_SLUMBER,
541 PORT_CMD_ICC_SLUMBER, 1, 50);
542 }
543
544 /* put device into listen mode */
545 if (cap & HOST_CAP_SSS) {
546 /* first set PxSCTL.DET to 0 */
547 scontrol = readl(port_mmio + PORT_SCR_CTL);
548 scontrol &= ~0xf;
549 writel(scontrol, port_mmio + PORT_SCR_CTL);
550
551 /* then set PxCMD.SUD to 0 */
552 cmd &= ~PORT_CMD_SPIN_UP;
553 writel(cmd, port_mmio + PORT_CMD);
554 }
555}
556
557static void ahci_init_port(void __iomem *port_mmio, u32 cap,
558 dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
496{ 559{
497 unsigned int sc_reg; 560 /* power up */
561 ahci_power_up(port_mmio, cap);
498 562
499 switch (sc_reg_in) { 563 /* enable FIS reception */
500 case SCR_STATUS: sc_reg = 0; break; 564 ahci_start_fis_rx(port_mmio, cap, cmd_slot_dma, rx_fis_dma);
501 case SCR_CONTROL: sc_reg = 1; break; 565
502 case SCR_ERROR: sc_reg = 2; break; 566 /* enable DMA */
503 case SCR_ACTIVE: sc_reg = 3; break; 567 ahci_start_engine(port_mmio);
504 default: 568}
505 return; 569
570static int ahci_deinit_port(void __iomem *port_mmio, u32 cap, const char **emsg)
571{
572 int rc;
573
574 /* disable DMA */
575 rc = ahci_stop_engine(port_mmio);
576 if (rc) {
577 *emsg = "failed to stop engine";
578 return rc;
506 } 579 }
507 580
508 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); 581 /* disable FIS reception */
582 rc = ahci_stop_fis_rx(port_mmio);
583 if (rc) {
584 *emsg = "failed stop FIS RX";
585 return rc;
586 }
587
588 /* put device into slumber mode */
589 ahci_power_down(port_mmio, cap);
590
591 return 0;
509} 592}
510 593
511static int ahci_stop_engine(struct ata_port *ap) 594static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev)
512{ 595{
513 void __iomem *mmio = ap->host_set->mmio_base; 596 u32 cap_save, tmp;
514 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
515 int work;
516 u32 tmp;
517 597
518 tmp = readl(port_mmio + PORT_CMD); 598 cap_save = readl(mmio + HOST_CAP);
519 tmp &= ~PORT_CMD_START; 599 cap_save &= ( (1<<28) | (1<<17) );
520 writel(tmp, port_mmio + PORT_CMD); 600 cap_save |= (1 << 27);
601
602 /* global controller reset */
603 tmp = readl(mmio + HOST_CTL);
604 if ((tmp & HOST_RESET) == 0) {
605 writel(tmp | HOST_RESET, mmio + HOST_CTL);
606 readl(mmio + HOST_CTL); /* flush */
607 }
521 608
522 /* wait for engine to stop. TODO: this could be 609 /* reset must complete within 1 second, or
523 * as long as 500 msec 610 * the hardware should be considered fried.
524 */ 611 */
525 work = 1000; 612 ssleep(1);
526 while (work-- > 0) { 613
527 tmp = readl(port_mmio + PORT_CMD); 614 tmp = readl(mmio + HOST_CTL);
528 if ((tmp & PORT_CMD_LIST_ON) == 0) 615 if (tmp & HOST_RESET) {
529 return 0; 616 dev_printk(KERN_ERR, &pdev->dev,
530 udelay(10); 617 "controller reset failed (0x%x)\n", tmp);
618 return -EIO;
531 } 619 }
532 620
533 return -EIO; 621 writel(HOST_AHCI_EN, mmio + HOST_CTL);
622 (void) readl(mmio + HOST_CTL); /* flush */
623 writel(cap_save, mmio + HOST_CAP);
624 writel(0xf, mmio + HOST_PORTS_IMPL);
625 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
626
627 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
628 u16 tmp16;
629
630 /* configure PCS */
631 pci_read_config_word(pdev, 0x92, &tmp16);
632 tmp16 |= 0xf;
633 pci_write_config_word(pdev, 0x92, tmp16);
634 }
635
636 return 0;
534} 637}
535 638
536static void ahci_start_engine(struct ata_port *ap) 639static void ahci_init_controller(void __iomem *mmio, struct pci_dev *pdev,
640 int n_ports, u32 cap)
537{ 641{
538 void __iomem *mmio = ap->host_set->mmio_base; 642 int i, rc;
539 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
540 u32 tmp; 643 u32 tmp;
541 644
542 tmp = readl(port_mmio + PORT_CMD); 645 for (i = 0; i < n_ports; i++) {
543 tmp |= PORT_CMD_START; 646 void __iomem *port_mmio = ahci_port_base(mmio, i);
544 writel(tmp, port_mmio + PORT_CMD); 647 const char *emsg = NULL;
545 readl(port_mmio + PORT_CMD); /* flush */ 648
649#if 0 /* BIOSen initialize this incorrectly */
650 if (!(hpriv->port_map & (1 << i)))
651 continue;
652#endif
653
654 /* make sure port is not active */
655 rc = ahci_deinit_port(port_mmio, cap, &emsg);
656 if (rc)
657 dev_printk(KERN_WARNING, &pdev->dev,
658 "%s (%d)\n", emsg, rc);
659
660 /* clear SError */
661 tmp = readl(port_mmio + PORT_SCR_ERR);
662 VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
663 writel(tmp, port_mmio + PORT_SCR_ERR);
664
665 /* clear port IRQ */
666 tmp = readl(port_mmio + PORT_IRQ_STAT);
667 VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
668 if (tmp)
669 writel(tmp, port_mmio + PORT_IRQ_STAT);
670
671 writel(1 << i, mmio + HOST_IRQ_STAT);
672 }
673
674 tmp = readl(mmio + HOST_CTL);
675 VPRINTK("HOST_CTL 0x%x\n", tmp);
676 writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
677 tmp = readl(mmio + HOST_CTL);
678 VPRINTK("HOST_CTL 0x%x\n", tmp);
546} 679}
547 680
548static unsigned int ahci_dev_classify(struct ata_port *ap) 681static unsigned int ahci_dev_classify(struct ata_port *ap)
@@ -576,7 +709,7 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
576static int ahci_clo(struct ata_port *ap) 709static int ahci_clo(struct ata_port *ap)
577{ 710{
578 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; 711 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
579 struct ahci_host_priv *hpriv = ap->host_set->private_data; 712 struct ahci_host_priv *hpriv = ap->host->private_data;
580 u32 tmp; 713 u32 tmp;
581 714
582 if (!(hpriv->cap & HOST_CAP_CLO)) 715 if (!(hpriv->cap & HOST_CAP_CLO))
@@ -608,7 +741,7 @@ static int ahci_prereset(struct ata_port *ap)
608static int ahci_softreset(struct ata_port *ap, unsigned int *class) 741static int ahci_softreset(struct ata_port *ap, unsigned int *class)
609{ 742{
610 struct ahci_port_priv *pp = ap->private_data; 743 struct ahci_port_priv *pp = ap->private_data;
611 void __iomem *mmio = ap->host_set->mmio_base; 744 void __iomem *mmio = ap->host->mmio_base;
612 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 745 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
613 const u32 cmd_fis_len = 5; /* five dwords */ 746 const u32 cmd_fis_len = 5; /* five dwords */
614 const char *reason = NULL; 747 const char *reason = NULL;
@@ -626,7 +759,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
626 } 759 }
627 760
628 /* prepare for SRST (AHCI-1.1 10.4.1) */ 761 /* prepare for SRST (AHCI-1.1 10.4.1) */
629 rc = ahci_stop_engine(ap); 762 rc = ahci_stop_engine(port_mmio);
630 if (rc) { 763 if (rc) {
631 reason = "failed to stop engine"; 764 reason = "failed to stop engine";
632 goto fail_restart; 765 goto fail_restart;
@@ -647,7 +780,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
647 } 780 }
648 781
649 /* restart engine */ 782 /* restart engine */
650 ahci_start_engine(ap); 783 ahci_start_engine(port_mmio);
651 784
652 ata_tf_init(ap->device, &tf); 785 ata_tf_init(ap->device, &tf);
653 fis = pp->cmd_tbl; 786 fis = pp->cmd_tbl;
@@ -706,7 +839,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
706 return 0; 839 return 0;
707 840
708 fail_restart: 841 fail_restart:
709 ahci_start_engine(ap); 842 ahci_start_engine(port_mmio);
710 fail: 843 fail:
711 ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason); 844 ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason);
712 return rc; 845 return rc;
@@ -717,11 +850,13 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
717 struct ahci_port_priv *pp = ap->private_data; 850 struct ahci_port_priv *pp = ap->private_data;
718 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; 851 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
719 struct ata_taskfile tf; 852 struct ata_taskfile tf;
853 void __iomem *mmio = ap->host->mmio_base;
854 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
720 int rc; 855 int rc;
721 856
722 DPRINTK("ENTER\n"); 857 DPRINTK("ENTER\n");
723 858
724 ahci_stop_engine(ap); 859 ahci_stop_engine(port_mmio);
725 860
726 /* clear D2H reception area to properly wait for D2H FIS */ 861 /* clear D2H reception area to properly wait for D2H FIS */
727 ata_tf_init(ap->device, &tf); 862 ata_tf_init(ap->device, &tf);
@@ -730,7 +865,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
730 865
731 rc = sata_std_hardreset(ap, class); 866 rc = sata_std_hardreset(ap, class);
732 867
733 ahci_start_engine(ap); 868 ahci_start_engine(port_mmio);
734 869
735 if (rc == 0 && ata_port_online(ap)) 870 if (rc == 0 && ata_port_online(ap))
736 *class = ahci_dev_classify(ap); 871 *class = ahci_dev_classify(ap);
@@ -904,7 +1039,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
904 1039
905static void ahci_host_intr(struct ata_port *ap) 1040static void ahci_host_intr(struct ata_port *ap)
906{ 1041{
907 void __iomem *mmio = ap->host_set->mmio_base; 1042 void __iomem *mmio = ap->host->mmio_base;
908 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 1043 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
909 struct ata_eh_info *ehi = &ap->eh_info; 1044 struct ata_eh_info *ehi = &ap->eh_info;
910 u32 status, qc_active; 1045 u32 status, qc_active;
@@ -956,7 +1091,7 @@ static void ahci_irq_clear(struct ata_port *ap)
956 1091
957static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 1092static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
958{ 1093{
959 struct ata_host_set *host_set = dev_instance; 1094 struct ata_host *host = dev_instance;
960 struct ahci_host_priv *hpriv; 1095 struct ahci_host_priv *hpriv;
961 unsigned int i, handled = 0; 1096 unsigned int i, handled = 0;
962 void __iomem *mmio; 1097 void __iomem *mmio;
@@ -964,8 +1099,8 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *r
964 1099
965 VPRINTK("ENTER\n"); 1100 VPRINTK("ENTER\n");
966 1101
967 hpriv = host_set->private_data; 1102 hpriv = host->private_data;
968 mmio = host_set->mmio_base; 1103 mmio = host->mmio_base;
969 1104
970 /* sigh. 0xffffffff is a valid return from h/w */ 1105 /* sigh. 0xffffffff is a valid return from h/w */
971 irq_stat = readl(mmio + HOST_IRQ_STAT); 1106 irq_stat = readl(mmio + HOST_IRQ_STAT);
@@ -973,22 +1108,22 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *r
973 if (!irq_stat) 1108 if (!irq_stat)
974 return IRQ_NONE; 1109 return IRQ_NONE;
975 1110
976 spin_lock(&host_set->lock); 1111 spin_lock(&host->lock);
977 1112
978 for (i = 0; i < host_set->n_ports; i++) { 1113 for (i = 0; i < host->n_ports; i++) {
979 struct ata_port *ap; 1114 struct ata_port *ap;
980 1115
981 if (!(irq_stat & (1 << i))) 1116 if (!(irq_stat & (1 << i)))
982 continue; 1117 continue;
983 1118
984 ap = host_set->ports[i]; 1119 ap = host->ports[i];
985 if (ap) { 1120 if (ap) {
986 ahci_host_intr(ap); 1121 ahci_host_intr(ap);
987 VPRINTK("port %u\n", i); 1122 VPRINTK("port %u\n", i);
988 } else { 1123 } else {
989 VPRINTK("port %u (no irq)\n", i); 1124 VPRINTK("port %u (no irq)\n", i);
990 if (ata_ratelimit()) 1125 if (ata_ratelimit())
991 dev_printk(KERN_WARNING, host_set->dev, 1126 dev_printk(KERN_WARNING, host->dev,
992 "interrupt on disabled port %u\n", i); 1127 "interrupt on disabled port %u\n", i);
993 } 1128 }
994 1129
@@ -1000,7 +1135,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *r
1000 handled = 1; 1135 handled = 1;
1001 } 1136 }
1002 1137
1003 spin_unlock(&host_set->lock); 1138 spin_unlock(&host->lock);
1004 1139
1005 VPRINTK("EXIT\n"); 1140 VPRINTK("EXIT\n");
1006 1141
@@ -1022,7 +1157,7 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
1022 1157
1023static void ahci_freeze(struct ata_port *ap) 1158static void ahci_freeze(struct ata_port *ap)
1024{ 1159{
1025 void __iomem *mmio = ap->host_set->mmio_base; 1160 void __iomem *mmio = ap->host->mmio_base;
1026 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 1161 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1027 1162
1028 /* turn IRQ off */ 1163 /* turn IRQ off */
@@ -1031,7 +1166,7 @@ static void ahci_freeze(struct ata_port *ap)
1031 1166
1032static void ahci_thaw(struct ata_port *ap) 1167static void ahci_thaw(struct ata_port *ap)
1033{ 1168{
1034 void __iomem *mmio = ap->host_set->mmio_base; 1169 void __iomem *mmio = ap->host->mmio_base;
1035 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 1170 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1036 u32 tmp; 1171 u32 tmp;
1037 1172
@@ -1046,10 +1181,13 @@ static void ahci_thaw(struct ata_port *ap)
1046 1181
1047static void ahci_error_handler(struct ata_port *ap) 1182static void ahci_error_handler(struct ata_port *ap)
1048{ 1183{
1184 void __iomem *mmio = ap->host->mmio_base;
1185 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1186
1049 if (!(ap->pflags & ATA_PFLAG_FROZEN)) { 1187 if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
1050 /* restart engine */ 1188 /* restart engine */
1051 ahci_stop_engine(ap); 1189 ahci_stop_engine(port_mmio);
1052 ahci_start_engine(ap); 1190 ahci_start_engine(port_mmio);
1053 } 1191 }
1054 1192
1055 /* perform recovery */ 1193 /* perform recovery */
@@ -1060,15 +1198,176 @@ static void ahci_error_handler(struct ata_port *ap)
1060static void ahci_post_internal_cmd(struct ata_queued_cmd *qc) 1198static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
1061{ 1199{
1062 struct ata_port *ap = qc->ap; 1200 struct ata_port *ap = qc->ap;
1201 void __iomem *mmio = ap->host->mmio_base;
1202 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1063 1203
1064 if (qc->flags & ATA_QCFLAG_FAILED) 1204 if (qc->flags & ATA_QCFLAG_FAILED)
1065 qc->err_mask |= AC_ERR_OTHER; 1205 qc->err_mask |= AC_ERR_OTHER;
1066 1206
1067 if (qc->err_mask) { 1207 if (qc->err_mask) {
1068 /* make DMA engine forget about the failed command */ 1208 /* make DMA engine forget about the failed command */
1069 ahci_stop_engine(ap); 1209 ahci_stop_engine(port_mmio);
1070 ahci_start_engine(ap); 1210 ahci_start_engine(port_mmio);
1211 }
1212}
1213
1214static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
1215{
1216 struct ahci_host_priv *hpriv = ap->host->private_data;
1217 struct ahci_port_priv *pp = ap->private_data;
1218 void __iomem *mmio = ap->host->mmio_base;
1219 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1220 const char *emsg = NULL;
1221 int rc;
1222
1223 rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
1224 if (rc) {
1225 ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
1226 ahci_init_port(port_mmio, hpriv->cap,
1227 pp->cmd_slot_dma, pp->rx_fis_dma);
1228 }
1229
1230 return rc;
1231}
1232
1233static int ahci_port_resume(struct ata_port *ap)
1234{
1235 struct ahci_port_priv *pp = ap->private_data;
1236 struct ahci_host_priv *hpriv = ap->host->private_data;
1237 void __iomem *mmio = ap->host->mmio_base;
1238 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1239
1240 ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
1241
1242 return 0;
1243}
1244
1245static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
1246{
1247 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1248 void __iomem *mmio = host->mmio_base;
1249 u32 ctl;
1250
1251 if (mesg.event == PM_EVENT_SUSPEND) {
1252 /* AHCI spec rev1.1 section 8.3.3:
1253 * Software must disable interrupts prior to requesting a
1254 * transition of the HBA to D3 state.
1255 */
1256 ctl = readl(mmio + HOST_CTL);
1257 ctl &= ~HOST_IRQ_EN;
1258 writel(ctl, mmio + HOST_CTL);
1259 readl(mmio + HOST_CTL); /* flush */
1260 }
1261
1262 return ata_pci_device_suspend(pdev, mesg);
1263}
1264
1265static int ahci_pci_device_resume(struct pci_dev *pdev)
1266{
1267 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1268 struct ahci_host_priv *hpriv = host->private_data;
1269 void __iomem *mmio = host->mmio_base;
1270 int rc;
1271
1272 ata_pci_device_do_resume(pdev);
1273
1274 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
1275 rc = ahci_reset_controller(mmio, pdev);
1276 if (rc)
1277 return rc;
1278
1279 ahci_init_controller(mmio, pdev, host->n_ports, hpriv->cap);
1071 } 1280 }
1281
1282 ata_host_resume(host);
1283
1284 return 0;
1285}
1286
1287static int ahci_port_start(struct ata_port *ap)
1288{
1289 struct device *dev = ap->host->dev;
1290 struct ahci_host_priv *hpriv = ap->host->private_data;
1291 struct ahci_port_priv *pp;
1292 void __iomem *mmio = ap->host->mmio_base;
1293 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1294 void *mem;
1295 dma_addr_t mem_dma;
1296 int rc;
1297
1298 pp = kmalloc(sizeof(*pp), GFP_KERNEL);
1299 if (!pp)
1300 return -ENOMEM;
1301 memset(pp, 0, sizeof(*pp));
1302
1303 rc = ata_pad_alloc(ap, dev);
1304 if (rc) {
1305 kfree(pp);
1306 return rc;
1307 }
1308
1309 mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
1310 if (!mem) {
1311 ata_pad_free(ap, dev);
1312 kfree(pp);
1313 return -ENOMEM;
1314 }
1315 memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
1316
1317 /*
1318 * First item in chunk of DMA memory: 32-slot command table,
1319 * 32 bytes each in size
1320 */
1321 pp->cmd_slot = mem;
1322 pp->cmd_slot_dma = mem_dma;
1323
1324 mem += AHCI_CMD_SLOT_SZ;
1325 mem_dma += AHCI_CMD_SLOT_SZ;
1326
1327 /*
1328 * Second item: Received-FIS area
1329 */
1330 pp->rx_fis = mem;
1331 pp->rx_fis_dma = mem_dma;
1332
1333 mem += AHCI_RX_FIS_SZ;
1334 mem_dma += AHCI_RX_FIS_SZ;
1335
1336 /*
1337 * Third item: data area for storing a single command
1338 * and its scatter-gather table
1339 */
1340 pp->cmd_tbl = mem;
1341 pp->cmd_tbl_dma = mem_dma;
1342
1343 ap->private_data = pp;
1344
1345 /* initialize port */
1346 ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
1347
1348 return 0;
1349}
1350
1351static void ahci_port_stop(struct ata_port *ap)
1352{
1353 struct device *dev = ap->host->dev;
1354 struct ahci_host_priv *hpriv = ap->host->private_data;
1355 struct ahci_port_priv *pp = ap->private_data;
1356 void __iomem *mmio = ap->host->mmio_base;
1357 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1358 const char *emsg = NULL;
1359 int rc;
1360
1361 /* de-initialize port */
1362 rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
1363 if (rc)
1364 ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
1365
1366 ap->private_data = NULL;
1367 dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
1368 pp->cmd_slot, pp->cmd_slot_dma);
1369 ata_pad_free(ap, dev);
1370 kfree(pp);
1072} 1371}
1073 1372
1074static void ahci_setup_port(struct ata_ioports *port, unsigned long base, 1373static void ahci_setup_port(struct ata_ioports *port, unsigned long base,
@@ -1089,47 +1388,12 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
1089 struct ahci_host_priv *hpriv = probe_ent->private_data; 1388 struct ahci_host_priv *hpriv = probe_ent->private_data;
1090 struct pci_dev *pdev = to_pci_dev(probe_ent->dev); 1389 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
1091 void __iomem *mmio = probe_ent->mmio_base; 1390 void __iomem *mmio = probe_ent->mmio_base;
1092 u32 tmp, cap_save; 1391 unsigned int i, using_dac;
1093 unsigned int i, j, using_dac;
1094 int rc; 1392 int rc;
1095 void __iomem *port_mmio;
1096
1097 cap_save = readl(mmio + HOST_CAP);
1098 cap_save &= ( (1<<28) | (1<<17) );
1099 cap_save |= (1 << 27);
1100 1393
1101 /* global controller reset */ 1394 rc = ahci_reset_controller(mmio, pdev);
1102 tmp = readl(mmio + HOST_CTL); 1395 if (rc)
1103 if ((tmp & HOST_RESET) == 0) { 1396 return rc;
1104 writel(tmp | HOST_RESET, mmio + HOST_CTL);
1105 readl(mmio + HOST_CTL); /* flush */
1106 }
1107
1108 /* reset must complete within 1 second, or
1109 * the hardware should be considered fried.
1110 */
1111 ssleep(1);
1112
1113 tmp = readl(mmio + HOST_CTL);
1114 if (tmp & HOST_RESET) {
1115 dev_printk(KERN_ERR, &pdev->dev,
1116 "controller reset failed (0x%x)\n", tmp);
1117 return -EIO;
1118 }
1119
1120 writel(HOST_AHCI_EN, mmio + HOST_CTL);
1121 (void) readl(mmio + HOST_CTL); /* flush */
1122 writel(cap_save, mmio + HOST_CAP);
1123 writel(0xf, mmio + HOST_PORTS_IMPL);
1124 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
1125
1126 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
1127 u16 tmp16;
1128
1129 pci_read_config_word(pdev, 0x92, &tmp16);
1130 tmp16 |= 0xf;
1131 pci_write_config_word(pdev, 0x92, tmp16);
1132 }
1133 1397
1134 hpriv->cap = readl(mmio + HOST_CAP); 1398 hpriv->cap = readl(mmio + HOST_CAP);
1135 hpriv->port_map = readl(mmio + HOST_PORTS_IMPL); 1399 hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
@@ -1165,63 +1429,10 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
1165 } 1429 }
1166 } 1430 }
1167 1431
1168 for (i = 0; i < probe_ent->n_ports; i++) { 1432 for (i = 0; i < probe_ent->n_ports; i++)
1169#if 0 /* BIOSen initialize this incorrectly */ 1433 ahci_setup_port(&probe_ent->port[i], (unsigned long) mmio, i);
1170 if (!(hpriv->port_map & (1 << i)))
1171 continue;
1172#endif
1173
1174 port_mmio = ahci_port_base(mmio, i);
1175 VPRINTK("mmio %p port_mmio %p\n", mmio, port_mmio);
1176
1177 ahci_setup_port(&probe_ent->port[i],
1178 (unsigned long) mmio, i);
1179 1434
1180 /* make sure port is not active */ 1435 ahci_init_controller(mmio, pdev, probe_ent->n_ports, hpriv->cap);
1181 tmp = readl(port_mmio + PORT_CMD);
1182 VPRINTK("PORT_CMD 0x%x\n", tmp);
1183 if (tmp & (PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
1184 PORT_CMD_FIS_RX | PORT_CMD_START)) {
1185 tmp &= ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
1186 PORT_CMD_FIS_RX | PORT_CMD_START);
1187 writel(tmp, port_mmio + PORT_CMD);
1188 readl(port_mmio + PORT_CMD); /* flush */
1189
1190 /* spec says 500 msecs for each bit, so
1191 * this is slightly incorrect.
1192 */
1193 msleep(500);
1194 }
1195
1196 writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD);
1197
1198 j = 0;
1199 while (j < 100) {
1200 msleep(10);
1201 tmp = readl(port_mmio + PORT_SCR_STAT);
1202 if ((tmp & 0xf) == 0x3)
1203 break;
1204 j++;
1205 }
1206
1207 tmp = readl(port_mmio + PORT_SCR_ERR);
1208 VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
1209 writel(tmp, port_mmio + PORT_SCR_ERR);
1210
1211 /* ack any pending irq events for this port */
1212 tmp = readl(port_mmio + PORT_IRQ_STAT);
1213 VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
1214 if (tmp)
1215 writel(tmp, port_mmio + PORT_IRQ_STAT);
1216
1217 writel(1 << i, mmio + HOST_IRQ_STAT);
1218 }
1219
1220 tmp = readl(mmio + HOST_CTL);
1221 VPRINTK("HOST_CTL 0x%x\n", tmp);
1222 writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
1223 tmp = readl(mmio + HOST_CTL);
1224 VPRINTK("HOST_CTL 0x%x\n", tmp);
1225 1436
1226 pci_set_master(pdev); 1437 pci_set_master(pdev);
1227 1438
@@ -1370,7 +1581,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1370 memset(hpriv, 0, sizeof(*hpriv)); 1581 memset(hpriv, 0, sizeof(*hpriv));
1371 1582
1372 probe_ent->sht = ahci_port_info[board_idx].sht; 1583 probe_ent->sht = ahci_port_info[board_idx].sht;
1373 probe_ent->host_flags = ahci_port_info[board_idx].host_flags; 1584 probe_ent->port_flags = ahci_port_info[board_idx].flags;
1374 probe_ent->pio_mask = ahci_port_info[board_idx].pio_mask; 1585 probe_ent->pio_mask = ahci_port_info[board_idx].pio_mask;
1375 probe_ent->udma_mask = ahci_port_info[board_idx].udma_mask; 1586 probe_ent->udma_mask = ahci_port_info[board_idx].udma_mask;
1376 probe_ent->port_ops = ahci_port_info[board_idx].port_ops; 1587 probe_ent->port_ops = ahci_port_info[board_idx].port_ops;
@@ -1388,9 +1599,9 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1388 if (rc) 1599 if (rc)
1389 goto err_out_hpriv; 1600 goto err_out_hpriv;
1390 1601
1391 if (!(probe_ent->host_flags & AHCI_FLAG_NO_NCQ) && 1602 if (!(probe_ent->port_flags & AHCI_FLAG_NO_NCQ) &&
1392 (hpriv->cap & HOST_CAP_NCQ)) 1603 (hpriv->cap & HOST_CAP_NCQ))
1393 probe_ent->host_flags |= ATA_FLAG_NCQ; 1604 probe_ent->port_flags |= ATA_FLAG_NCQ;
1394 1605
1395 ahci_print_info(probe_ent); 1606 ahci_print_info(probe_ent);
1396 1607
@@ -1421,27 +1632,27 @@ err_out:
1421static void ahci_remove_one (struct pci_dev *pdev) 1632static void ahci_remove_one (struct pci_dev *pdev)
1422{ 1633{
1423 struct device *dev = pci_dev_to_dev(pdev); 1634 struct device *dev = pci_dev_to_dev(pdev);
1424 struct ata_host_set *host_set = dev_get_drvdata(dev); 1635 struct ata_host *host = dev_get_drvdata(dev);
1425 struct ahci_host_priv *hpriv = host_set->private_data; 1636 struct ahci_host_priv *hpriv = host->private_data;
1426 unsigned int i; 1637 unsigned int i;
1427 int have_msi; 1638 int have_msi;
1428 1639
1429 for (i = 0; i < host_set->n_ports; i++) 1640 for (i = 0; i < host->n_ports; i++)
1430 ata_port_detach(host_set->ports[i]); 1641 ata_port_detach(host->ports[i]);
1431 1642
1432 have_msi = hpriv->flags & AHCI_FLAG_MSI; 1643 have_msi = hpriv->flags & AHCI_FLAG_MSI;
1433 free_irq(host_set->irq, host_set); 1644 free_irq(host->irq, host);
1434 1645
1435 for (i = 0; i < host_set->n_ports; i++) { 1646 for (i = 0; i < host->n_ports; i++) {
1436 struct ata_port *ap = host_set->ports[i]; 1647 struct ata_port *ap = host->ports[i];
1437 1648
1438 ata_scsi_release(ap->host); 1649 ata_scsi_release(ap->scsi_host);
1439 scsi_host_put(ap->host); 1650 scsi_host_put(ap->scsi_host);
1440 } 1651 }
1441 1652
1442 kfree(hpriv); 1653 kfree(hpriv);
1443 pci_iounmap(pdev, host_set->mmio_base); 1654 pci_iounmap(pdev, host->mmio_base);
1444 kfree(host_set); 1655 kfree(host);
1445 1656
1446 if (have_msi) 1657 if (have_msi)
1447 pci_disable_msi(pdev); 1658 pci_disable_msi(pdev);
@@ -1454,7 +1665,7 @@ static void ahci_remove_one (struct pci_dev *pdev)
1454 1665
1455static int __init ahci_init(void) 1666static int __init ahci_init(void)
1456{ 1667{
1457 return pci_module_init(&ahci_pci_driver); 1668 return pci_register_driver(&ahci_pci_driver);
1458} 1669}
1459 1670
1460static void __exit ahci_exit(void) 1671static void __exit ahci_exit(void)
diff --git a/drivers/scsi/ata_piix.c b/drivers/ata/ata_piix.c
index 2d20caf377f5..22b2dba90b9a 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -151,7 +151,7 @@ struct piix_host_priv {
151 151
152static int piix_init_one (struct pci_dev *pdev, 152static int piix_init_one (struct pci_dev *pdev,
153 const struct pci_device_id *ent); 153 const struct pci_device_id *ent);
154static void piix_host_stop(struct ata_host_set *host_set); 154static void piix_host_stop(struct ata_host *host);
155static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); 155static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
156static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); 156static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
157static void piix_pata_error_handler(struct ata_port *ap); 157static void piix_pata_error_handler(struct ata_port *ap);
@@ -362,7 +362,7 @@ static struct ata_port_info piix_port_info[] = {
362 /* piix4_pata */ 362 /* piix4_pata */
363 { 363 {
364 .sht = &piix_sht, 364 .sht = &piix_sht,
365 .host_flags = ATA_FLAG_SLAVE_POSS, 365 .flags = ATA_FLAG_SLAVE_POSS,
366 .pio_mask = 0x1f, /* pio0-4 */ 366 .pio_mask = 0x1f, /* pio0-4 */
367#if 0 367#if 0
368 .mwdma_mask = 0x06, /* mwdma1-2 */ 368 .mwdma_mask = 0x06, /* mwdma1-2 */
@@ -376,7 +376,7 @@ static struct ata_port_info piix_port_info[] = {
376 /* ich5_pata */ 376 /* ich5_pata */
377 { 377 {
378 .sht = &piix_sht, 378 .sht = &piix_sht,
379 .host_flags = ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR, 379 .flags = ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR,
380 .pio_mask = 0x1f, /* pio0-4 */ 380 .pio_mask = 0x1f, /* pio0-4 */
381#if 0 381#if 0
382 .mwdma_mask = 0x06, /* mwdma1-2 */ 382 .mwdma_mask = 0x06, /* mwdma1-2 */
@@ -390,7 +390,7 @@ static struct ata_port_info piix_port_info[] = {
390 /* ich5_sata */ 390 /* ich5_sata */
391 { 391 {
392 .sht = &piix_sht, 392 .sht = &piix_sht,
393 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR | 393 .flags = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR |
394 PIIX_FLAG_IGNORE_PCS, 394 PIIX_FLAG_IGNORE_PCS,
395 .pio_mask = 0x1f, /* pio0-4 */ 395 .pio_mask = 0x1f, /* pio0-4 */
396 .mwdma_mask = 0x07, /* mwdma0-2 */ 396 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -401,7 +401,7 @@ static struct ata_port_info piix_port_info[] = {
401 /* i6300esb_sata */ 401 /* i6300esb_sata */
402 { 402 {
403 .sht = &piix_sht, 403 .sht = &piix_sht,
404 .host_flags = ATA_FLAG_SATA | 404 .flags = ATA_FLAG_SATA |
405 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS, 405 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS,
406 .pio_mask = 0x1f, /* pio0-4 */ 406 .pio_mask = 0x1f, /* pio0-4 */
407 .mwdma_mask = 0x07, /* mwdma0-2 */ 407 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -412,7 +412,7 @@ static struct ata_port_info piix_port_info[] = {
412 /* ich6_sata */ 412 /* ich6_sata */
413 { 413 {
414 .sht = &piix_sht, 414 .sht = &piix_sht,
415 .host_flags = ATA_FLAG_SATA | 415 .flags = ATA_FLAG_SATA |
416 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR, 416 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR,
417 .pio_mask = 0x1f, /* pio0-4 */ 417 .pio_mask = 0x1f, /* pio0-4 */
418 .mwdma_mask = 0x07, /* mwdma0-2 */ 418 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -423,7 +423,7 @@ static struct ata_port_info piix_port_info[] = {
423 /* ich6_sata_ahci */ 423 /* ich6_sata_ahci */
424 { 424 {
425 .sht = &piix_sht, 425 .sht = &piix_sht,
426 .host_flags = ATA_FLAG_SATA | 426 .flags = ATA_FLAG_SATA |
427 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR | 427 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
428 PIIX_FLAG_AHCI, 428 PIIX_FLAG_AHCI,
429 .pio_mask = 0x1f, /* pio0-4 */ 429 .pio_mask = 0x1f, /* pio0-4 */
@@ -435,7 +435,7 @@ static struct ata_port_info piix_port_info[] = {
435 /* ich6m_sata_ahci */ 435 /* ich6m_sata_ahci */
436 { 436 {
437 .sht = &piix_sht, 437 .sht = &piix_sht,
438 .host_flags = ATA_FLAG_SATA | 438 .flags = ATA_FLAG_SATA |
439 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR | 439 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
440 PIIX_FLAG_AHCI, 440 PIIX_FLAG_AHCI,
441 .pio_mask = 0x1f, /* pio0-4 */ 441 .pio_mask = 0x1f, /* pio0-4 */
@@ -447,7 +447,7 @@ static struct ata_port_info piix_port_info[] = {
447 /* ich8_sata_ahci */ 447 /* ich8_sata_ahci */
448 { 448 {
449 .sht = &piix_sht, 449 .sht = &piix_sht,
450 .host_flags = ATA_FLAG_SATA | 450 .flags = ATA_FLAG_SATA |
451 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR | 451 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
452 PIIX_FLAG_AHCI, 452 PIIX_FLAG_AHCI,
453 .pio_mask = 0x1f, /* pio0-4 */ 453 .pio_mask = 0x1f, /* pio0-4 */
@@ -485,7 +485,7 @@ MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around "
485 */ 485 */
486static void piix_pata_cbl_detect(struct ata_port *ap) 486static void piix_pata_cbl_detect(struct ata_port *ap)
487{ 487{
488 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 488 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
489 u8 tmp, mask; 489 u8 tmp, mask;
490 490
491 /* no 80c support in host controller? */ 491 /* no 80c support in host controller? */
@@ -493,7 +493,7 @@ static void piix_pata_cbl_detect(struct ata_port *ap)
493 goto cbl40; 493 goto cbl40;
494 494
495 /* check BIOS cable detect results */ 495 /* check BIOS cable detect results */
496 mask = ap->hard_port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC; 496 mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
497 pci_read_config_byte(pdev, PIIX_IOCFG, &tmp); 497 pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
498 if ((tmp & mask) == 0) 498 if ((tmp & mask) == 0)
499 goto cbl40; 499 goto cbl40;
@@ -517,9 +517,9 @@ cbl40:
517 */ 517 */
518static int piix_pata_prereset(struct ata_port *ap) 518static int piix_pata_prereset(struct ata_port *ap)
519{ 519{
520 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 520 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
521 521
522 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) { 522 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
523 ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n"); 523 ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
524 ap->eh_context.i.action &= ~ATA_EH_RESET_MASK; 524 ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
525 return 0; 525 return 0;
@@ -551,10 +551,10 @@ static void piix_pata_error_handler(struct ata_port *ap)
551 */ 551 */
552static unsigned int piix_sata_present_mask(struct ata_port *ap) 552static unsigned int piix_sata_present_mask(struct ata_port *ap)
553{ 553{
554 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 554 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
555 struct piix_host_priv *hpriv = ap->host_set->private_data; 555 struct piix_host_priv *hpriv = ap->host->private_data;
556 const unsigned int *map = hpriv->map; 556 const unsigned int *map = hpriv->map;
557 int base = 2 * ap->hard_port_no; 557 int base = 2 * ap->port_no;
558 unsigned int present_mask = 0; 558 unsigned int present_mask = 0;
559 int port, i; 559 int port, i;
560 u16 pcs; 560 u16 pcs;
@@ -631,9 +631,9 @@ static void piix_sata_error_handler(struct ata_port *ap)
631static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev) 631static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
632{ 632{
633 unsigned int pio = adev->pio_mode - XFER_PIO_0; 633 unsigned int pio = adev->pio_mode - XFER_PIO_0;
634 struct pci_dev *dev = to_pci_dev(ap->host_set->dev); 634 struct pci_dev *dev = to_pci_dev(ap->host->dev);
635 unsigned int is_slave = (adev->devno != 0); 635 unsigned int is_slave = (adev->devno != 0);
636 unsigned int master_port= ap->hard_port_no ? 0x42 : 0x40; 636 unsigned int master_port= ap->port_no ? 0x42 : 0x40;
637 unsigned int slave_port = 0x44; 637 unsigned int slave_port = 0x44;
638 u16 master_data; 638 u16 master_data;
639 u8 slave_data; 639 u8 slave_data;
@@ -651,10 +651,10 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
651 /* enable PPE, IE and TIME */ 651 /* enable PPE, IE and TIME */
652 master_data |= 0x0070; 652 master_data |= 0x0070;
653 pci_read_config_byte(dev, slave_port, &slave_data); 653 pci_read_config_byte(dev, slave_port, &slave_data);
654 slave_data &= (ap->hard_port_no ? 0x0f : 0xf0); 654 slave_data &= (ap->port_no ? 0x0f : 0xf0);
655 slave_data |= 655 slave_data |=
656 (timings[pio][0] << 2) | 656 (timings[pio][0] << 2) |
657 (timings[pio][1] << (ap->hard_port_no ? 4 : 0)); 657 (timings[pio][1] << (ap->port_no ? 4 : 0));
658 } else { 658 } else {
659 master_data &= 0xccf8; 659 master_data &= 0xccf8;
660 /* enable PPE, IE and TIME */ 660 /* enable PPE, IE and TIME */
@@ -683,10 +683,10 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
683static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev) 683static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev)
684{ 684{
685 unsigned int udma = adev->dma_mode; /* FIXME: MWDMA too */ 685 unsigned int udma = adev->dma_mode; /* FIXME: MWDMA too */
686 struct pci_dev *dev = to_pci_dev(ap->host_set->dev); 686 struct pci_dev *dev = to_pci_dev(ap->host->dev);
687 u8 maslave = ap->hard_port_no ? 0x42 : 0x40; 687 u8 maslave = ap->port_no ? 0x42 : 0x40;
688 u8 speed = udma; 688 u8 speed = udma;
689 unsigned int drive_dn = (ap->hard_port_no ? 2 : 0) + adev->devno; 689 unsigned int drive_dn = (ap->port_no ? 2 : 0) + adev->devno;
690 int a_speed = 3 << (drive_dn * 4); 690 int a_speed = 3 << (drive_dn * 4);
691 int u_flag = 1 << drive_dn; 691 int u_flag = 1 << drive_dn;
692 int v_flag = 0x01 << drive_dn; 692 int v_flag = 0x01 << drive_dn;
@@ -835,13 +835,13 @@ static void __devinit piix_init_pcs(struct pci_dev *pdev,
835 if (force_pcs == 1) { 835 if (force_pcs == 1) {
836 dev_printk(KERN_INFO, &pdev->dev, 836 dev_printk(KERN_INFO, &pdev->dev,
837 "force ignoring PCS (0x%x)\n", new_pcs); 837 "force ignoring PCS (0x%x)\n", new_pcs);
838 pinfo[0].host_flags |= PIIX_FLAG_IGNORE_PCS; 838 pinfo[0].flags |= PIIX_FLAG_IGNORE_PCS;
839 pinfo[1].host_flags |= PIIX_FLAG_IGNORE_PCS; 839 pinfo[1].flags |= PIIX_FLAG_IGNORE_PCS;
840 } else if (force_pcs == 2) { 840 } else if (force_pcs == 2) {
841 dev_printk(KERN_INFO, &pdev->dev, 841 dev_printk(KERN_INFO, &pdev->dev,
842 "force honoring PCS (0x%x)\n", new_pcs); 842 "force honoring PCS (0x%x)\n", new_pcs);
843 pinfo[0].host_flags &= ~PIIX_FLAG_IGNORE_PCS; 843 pinfo[0].flags &= ~PIIX_FLAG_IGNORE_PCS;
844 pinfo[1].host_flags &= ~PIIX_FLAG_IGNORE_PCS; 844 pinfo[1].flags &= ~PIIX_FLAG_IGNORE_PCS;
845 } 845 }
846} 846}
847 847
@@ -881,7 +881,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
881 default: 881 default:
882 printk(" P%d", map[i]); 882 printk(" P%d", map[i]);
883 if (i & 1) 883 if (i & 1)
884 pinfo[i / 2].host_flags |= ATA_FLAG_SLAVE_POSS; 884 pinfo[i / 2].flags |= ATA_FLAG_SLAVE_POSS;
885 break; 885 break;
886 } 886 }
887 } 887 }
@@ -916,7 +916,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
916 struct ata_port_info port_info[2]; 916 struct ata_port_info port_info[2];
917 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; 917 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
918 struct piix_host_priv *hpriv; 918 struct piix_host_priv *hpriv;
919 unsigned long host_flags; 919 unsigned long port_flags;
920 920
921 if (!printed_version++) 921 if (!printed_version++)
922 dev_printk(KERN_DEBUG, &pdev->dev, 922 dev_printk(KERN_DEBUG, &pdev->dev,
@@ -935,9 +935,9 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
935 port_info[0].private_data = hpriv; 935 port_info[0].private_data = hpriv;
936 port_info[1].private_data = hpriv; 936 port_info[1].private_data = hpriv;
937 937
938 host_flags = port_info[0].host_flags; 938 port_flags = port_info[0].flags;
939 939
940 if (host_flags & PIIX_FLAG_AHCI) { 940 if (port_flags & PIIX_FLAG_AHCI) {
941 u8 tmp; 941 u8 tmp;
942 pci_read_config_byte(pdev, PIIX_SCC, &tmp); 942 pci_read_config_byte(pdev, PIIX_SCC, &tmp);
943 if (tmp == PIIX_AHCI_DEVICE) { 943 if (tmp == PIIX_AHCI_DEVICE) {
@@ -948,7 +948,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
948 } 948 }
949 949
950 /* Initialize SATA map */ 950 /* Initialize SATA map */
951 if (host_flags & ATA_FLAG_SATA) { 951 if (port_flags & ATA_FLAG_SATA) {
952 piix_init_sata_map(pdev, port_info, 952 piix_init_sata_map(pdev, port_info,
953 piix_map_db_table[ent->driver_data]); 953 piix_map_db_table[ent->driver_data]);
954 piix_init_pcs(pdev, port_info, 954 piix_init_pcs(pdev, port_info,
@@ -961,7 +961,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
961 * MSI is disabled (and it is disabled, as we don't use 961 * MSI is disabled (and it is disabled, as we don't use
962 * message-signalled interrupts currently). 962 * message-signalled interrupts currently).
963 */ 963 */
964 if (host_flags & PIIX_FLAG_CHECKINTR) 964 if (port_flags & PIIX_FLAG_CHECKINTR)
965 pci_intx(pdev, 1); 965 pci_intx(pdev, 1);
966 966
967 if (piix_check_450nx_errata(pdev)) { 967 if (piix_check_450nx_errata(pdev)) {
@@ -976,19 +976,21 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
976 return ata_pci_init_one(pdev, ppinfo, 2); 976 return ata_pci_init_one(pdev, ppinfo, 2);
977} 977}
978 978
979static void piix_host_stop(struct ata_host_set *host_set) 979static void piix_host_stop(struct ata_host *host)
980{ 980{
981 if (host_set->next == NULL) 981 struct piix_host_priv *hpriv = host->private_data;
982 kfree(host_set->private_data); 982
983 ata_host_stop(host_set); 983 ata_host_stop(host);
984
985 kfree(hpriv);
984} 986}
985 987
986static int __init piix_init(void) 988static int __init piix_init(void)
987{ 989{
988 int rc; 990 int rc;
989 991
990 DPRINTK("pci_module_init\n"); 992 DPRINTK("pci_register_driver\n");
991 rc = pci_module_init(&piix_pci_driver); 993 rc = pci_register_driver(&piix_pci_driver);
992 if (rc) 994 if (rc)
993 return rc; 995 return rc;
994 996
diff --git a/drivers/scsi/libata-core.c b/drivers/ata/libata-core.c
index 73dd6c8deede..1c9315401f7a 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -50,7 +50,6 @@
50#include <linux/jiffies.h> 50#include <linux/jiffies.h>
51#include <linux/scatterlist.h> 51#include <linux/scatterlist.h>
52#include <scsi/scsi.h> 52#include <scsi/scsi.h>
53#include "scsi_priv.h"
54#include <scsi/scsi_cmnd.h> 53#include <scsi/scsi_cmnd.h>
55#include <scsi/scsi_host.h> 54#include <scsi/scsi_host.h>
56#include <linux/libata.h> 55#include <linux/libata.h>
@@ -387,9 +386,13 @@ static const char *ata_mode_string(unsigned int xfer_mask)
387 "PIO2", 386 "PIO2",
388 "PIO3", 387 "PIO3",
389 "PIO4", 388 "PIO4",
389 "PIO5",
390 "PIO6",
390 "MWDMA0", 391 "MWDMA0",
391 "MWDMA1", 392 "MWDMA1",
392 "MWDMA2", 393 "MWDMA2",
394 "MWDMA3",
395 "MWDMA4",
393 "UDMA/16", 396 "UDMA/16",
394 "UDMA/25", 397 "UDMA/25",
395 "UDMA/33", 398 "UDMA/33",
@@ -876,6 +879,23 @@ static unsigned int ata_id_xfermask(const u16 *id)
876 879
877 mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07; 880 mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07;
878 881
882 if (ata_id_is_cfa(id)) {
883 /*
884 * Process compact flash extended modes
885 */
886 int pio = id[163] & 0x7;
887 int dma = (id[163] >> 3) & 7;
888
889 if (pio)
890 pio_mask |= (1 << 5);
891 if (pio > 1)
892 pio_mask |= (1 << 6);
893 if (dma)
894 mwdma_mask |= (1 << 3);
895 if (dma > 1)
896 mwdma_mask |= (1 << 4);
897 }
898
879 udma_mask = 0; 899 udma_mask = 0;
880 if (id[ATA_ID_FIELD_VALID] & (1 << 2)) 900 if (id[ATA_ID_FIELD_VALID] & (1 << 2))
881 udma_mask = id[ATA_ID_UDMA_MODES] & 0xff; 901 udma_mask = id[ATA_ID_UDMA_MODES] & 0xff;
@@ -1315,7 +1335,7 @@ static void ata_dev_config_ncq(struct ata_device *dev,
1315 } 1335 }
1316 1336
1317 if (ap->flags & ATA_FLAG_NCQ) { 1337 if (ap->flags & ATA_FLAG_NCQ) {
1318 hdepth = min(ap->host->can_queue, ATA_MAX_QUEUE - 1); 1338 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1);
1319 dev->flags |= ATA_DFLAG_NCQ; 1339 dev->flags |= ATA_DFLAG_NCQ;
1320 } 1340 }
1321 1341
@@ -1329,12 +1349,13 @@ static void ata_set_port_max_cmd_len(struct ata_port *ap)
1329{ 1349{
1330 int i; 1350 int i;
1331 1351
1332 if (ap->host) { 1352 if (ap->scsi_host) {
1333 ap->host->max_cmd_len = 0; 1353 unsigned int len = 0;
1354
1334 for (i = 0; i < ATA_MAX_DEVICES; i++) 1355 for (i = 0; i < ATA_MAX_DEVICES; i++)
1335 ap->host->max_cmd_len = max_t(unsigned int, 1356 len = max(len, ap->device[i].cdb_len);
1336 ap->host->max_cmd_len, 1357
1337 ap->device[i].cdb_len); 1358 ap->scsi_host->max_cmd_len = len;
1338 } 1359 }
1339} 1360}
1340 1361
@@ -1357,6 +1378,7 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1357 struct ata_port *ap = dev->ap; 1378 struct ata_port *ap = dev->ap;
1358 const u16 *id = dev->id; 1379 const u16 *id = dev->id;
1359 unsigned int xfer_mask; 1380 unsigned int xfer_mask;
1381 char revbuf[7]; /* XYZ-99\0 */
1360 int rc; 1382 int rc;
1361 1383
1362 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 1384 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
@@ -1400,6 +1422,15 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1400 1422
1401 /* ATA-specific feature tests */ 1423 /* ATA-specific feature tests */
1402 if (dev->class == ATA_DEV_ATA) { 1424 if (dev->class == ATA_DEV_ATA) {
1425 if (ata_id_is_cfa(id)) {
1426 if (id[162] & 1) /* CPRM may make this media unusable */
1427 ata_dev_printk(dev, KERN_WARNING, "ata%u: device %u supports DRM functions and may not be fully accessable.\n",
1428 ap->id, dev->devno);
1429 snprintf(revbuf, 7, "CFA");
1430 }
1431 else
1432 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
1433
1403 dev->n_sectors = ata_id_n_sectors(id); 1434 dev->n_sectors = ata_id_n_sectors(id);
1404 1435
1405 if (ata_id_has_lba(id)) { 1436 if (ata_id_has_lba(id)) {
@@ -1418,9 +1449,9 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1418 1449
1419 /* print device info to dmesg */ 1450 /* print device info to dmesg */
1420 if (ata_msg_drv(ap) && print_info) 1451 if (ata_msg_drv(ap) && print_info)
1421 ata_dev_printk(dev, KERN_INFO, "ATA-%d, " 1452 ata_dev_printk(dev, KERN_INFO, "%s, "
1422 "max %s, %Lu sectors: %s %s\n", 1453 "max %s, %Lu sectors: %s %s\n",
1423 ata_id_major_version(id), 1454 revbuf,
1424 ata_mode_string(xfer_mask), 1455 ata_mode_string(xfer_mask),
1425 (unsigned long long)dev->n_sectors, 1456 (unsigned long long)dev->n_sectors,
1426 lba_desc, ncq_desc); 1457 lba_desc, ncq_desc);
@@ -1441,9 +1472,9 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1441 1472
1442 /* print device info to dmesg */ 1473 /* print device info to dmesg */
1443 if (ata_msg_drv(ap) && print_info) 1474 if (ata_msg_drv(ap) && print_info)
1444 ata_dev_printk(dev, KERN_INFO, "ATA-%d, " 1475 ata_dev_printk(dev, KERN_INFO, "%s, "
1445 "max %s, %Lu sectors: CHS %u/%u/%u\n", 1476 "max %s, %Lu sectors: CHS %u/%u/%u\n",
1446 ata_id_major_version(id), 1477 revbuf,
1447 ata_mode_string(xfer_mask), 1478 ata_mode_string(xfer_mask),
1448 (unsigned long long)dev->n_sectors, 1479 (unsigned long long)dev->n_sectors,
1449 dev->cylinders, dev->heads, 1480 dev->cylinders, dev->heads,
@@ -1528,7 +1559,7 @@ err_out_nosup:
1528 * Zero on success, negative errno otherwise. 1559 * Zero on success, negative errno otherwise.
1529 */ 1560 */
1530 1561
1531static int ata_bus_probe(struct ata_port *ap) 1562int ata_bus_probe(struct ata_port *ap)
1532{ 1563{
1533 unsigned int classes[ATA_MAX_DEVICES]; 1564 unsigned int classes[ATA_MAX_DEVICES];
1534 int tries[ATA_MAX_DEVICES]; 1565 int tries[ATA_MAX_DEVICES];
@@ -1632,7 +1663,7 @@ static int ata_bus_probe(struct ata_port *ap)
1632 * Modify @ap data structure such that the system 1663 * Modify @ap data structure such that the system
1633 * thinks that the entire port is enabled. 1664 * thinks that the entire port is enabled.
1634 * 1665 *
1635 * LOCKING: host_set lock, or some other form of 1666 * LOCKING: host lock, or some other form of
1636 * serialization. 1667 * serialization.
1637 */ 1668 */
1638 1669
@@ -1770,7 +1801,7 @@ struct ata_device *ata_dev_pair(struct ata_device *adev)
1770 * never attempt to probe or communicate with devices 1801 * never attempt to probe or communicate with devices
1771 * on this port. 1802 * on this port.
1772 * 1803 *
1773 * LOCKING: host_set lock, or some other form of 1804 * LOCKING: host lock, or some other form of
1774 * serialization. 1805 * serialization.
1775 */ 1806 */
1776 1807
@@ -1901,10 +1932,11 @@ int sata_set_spd(struct ata_port *ap)
1901 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik 1932 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
1902 */ 1933 */
1903/* 1934/*
1904 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). 1935 * PIO 0-4, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
1905 * These were taken from ATA/ATAPI-6 standard, rev 0a, except 1936 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
1906 * for PIO 5, which is a nonstandard extension and UDMA6, which 1937 * for UDMA6, which is currently supported only by Maxtor drives.
1907 * is currently supported only by Maxtor drives. 1938 *
1939 * For PIO 5/6 MWDMA 3/4 see the CFA specification 3.0.
1908 */ 1940 */
1909 1941
1910static const struct ata_timing ata_timing[] = { 1942static const struct ata_timing ata_timing[] = {
@@ -1914,6 +1946,8 @@ static const struct ata_timing ata_timing[] = {
1914 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 }, 1946 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 },
1915 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 }, 1947 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 },
1916 1948
1949 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 80, 0 },
1950 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 100, 0 },
1917 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 }, 1951 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 },
1918 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 }, 1952 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 },
1919 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, 1953 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
@@ -1928,7 +1962,8 @@ static const struct ata_timing ata_timing[] = {
1928 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, 1962 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
1929 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, 1963 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
1930 1964
1931/* { XFER_PIO_5, 20, 50, 30, 100, 50, 30, 100, 0 }, */ 1965 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 80, 0 },
1966 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 100, 0 },
1932 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 }, 1967 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 },
1933 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 }, 1968 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 },
1934 1969
@@ -2224,8 +2259,8 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2224 /* Record simplex status. If we selected DMA then the other 2259 /* Record simplex status. If we selected DMA then the other
2225 * host channels are not permitted to do so. 2260 * host channels are not permitted to do so.
2226 */ 2261 */
2227 if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX)) 2262 if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX))
2228 ap->host_set->simplex_claimed = 1; 2263 ap->host->simplex_claimed = 1;
2229 2264
2230 /* step5: chip specific finalisation */ 2265 /* step5: chip specific finalisation */
2231 if (ap->ops->post_set_mode) 2266 if (ap->ops->post_set_mode)
@@ -2247,7 +2282,7 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2247 * other threads. 2282 * other threads.
2248 * 2283 *
2249 * LOCKING: 2284 * LOCKING:
2250 * spin_lock_irqsave(host_set lock) 2285 * spin_lock_irqsave(host lock)
2251 */ 2286 */
2252 2287
2253static inline void ata_tf_to_host(struct ata_port *ap, 2288static inline void ata_tf_to_host(struct ata_port *ap,
@@ -2411,7 +2446,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
2411 * 2446 *
2412 * LOCKING: 2447 * LOCKING:
2413 * PCI/etc. bus probe sem. 2448 * PCI/etc. bus probe sem.
2414 * Obtains host_set lock. 2449 * Obtains host lock.
2415 * 2450 *
2416 * SIDE EFFECTS: 2451 * SIDE EFFECTS:
2417 * Sets ATA_FLAG_DISABLED if bus reset fails. 2452 * Sets ATA_FLAG_DISABLED if bus reset fails.
@@ -3040,20 +3075,16 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
3040 * known limits including host controller limits, device 3075 * known limits including host controller limits, device
3041 * blacklist, etc... 3076 * blacklist, etc...
3042 * 3077 *
3043 * FIXME: The current implementation limits all transfer modes to
3044 * the fastest of the lowested device on the port. This is not
3045 * required on most controllers.
3046 *
3047 * LOCKING: 3078 * LOCKING:
3048 * None. 3079 * None.
3049 */ 3080 */
3050static void ata_dev_xfermask(struct ata_device *dev) 3081static void ata_dev_xfermask(struct ata_device *dev)
3051{ 3082{
3052 struct ata_port *ap = dev->ap; 3083 struct ata_port *ap = dev->ap;
3053 struct ata_host_set *hs = ap->host_set; 3084 struct ata_host *host = ap->host;
3054 unsigned long xfer_mask; 3085 unsigned long xfer_mask;
3055 int i;
3056 3086
3087 /* controller modes available */
3057 xfer_mask = ata_pack_xfermask(ap->pio_mask, 3088 xfer_mask = ata_pack_xfermask(ap->pio_mask,
3058 ap->mwdma_mask, ap->udma_mask); 3089 ap->mwdma_mask, ap->udma_mask);
3059 3090
@@ -3063,34 +3094,31 @@ static void ata_dev_xfermask(struct ata_device *dev)
3063 if (ap->cbl == ATA_CBL_PATA40) 3094 if (ap->cbl == ATA_CBL_PATA40)
3064 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); 3095 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
3065 3096
3066 /* FIXME: Use port-wide xfermask for now */ 3097 xfer_mask &= ata_pack_xfermask(dev->pio_mask,
3067 for (i = 0; i < ATA_MAX_DEVICES; i++) { 3098 dev->mwdma_mask, dev->udma_mask);
3068 struct ata_device *d = &ap->device[i]; 3099 xfer_mask &= ata_id_xfermask(dev->id);
3069
3070 if (ata_dev_absent(d))
3071 continue;
3072
3073 if (ata_dev_disabled(d)) {
3074 /* to avoid violating device selection timing */
3075 xfer_mask &= ata_pack_xfermask(d->pio_mask,
3076 UINT_MAX, UINT_MAX);
3077 continue;
3078 }
3079 3100
3080 xfer_mask &= ata_pack_xfermask(d->pio_mask, 3101 /*
3081 d->mwdma_mask, d->udma_mask); 3102 * CFA Advanced TrueIDE timings are not allowed on a shared
3082 xfer_mask &= ata_id_xfermask(d->id); 3103 * cable
3083 if (ata_dma_blacklisted(d)) 3104 */
3084 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 3105 if (ata_dev_pair(dev)) {
3106 /* No PIO5 or PIO6 */
3107 xfer_mask &= ~(0x03 << (ATA_SHIFT_PIO + 5));
3108 /* No MWDMA3 or MWDMA 4 */
3109 xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA + 3));
3085 } 3110 }
3086 3111
3087 if (ata_dma_blacklisted(dev)) 3112 if (ata_dma_blacklisted(dev)) {
3113 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
3088 ata_dev_printk(dev, KERN_WARNING, 3114 ata_dev_printk(dev, KERN_WARNING,
3089 "device is on DMA blacklist, disabling DMA\n"); 3115 "device is on DMA blacklist, disabling DMA\n");
3116 }
3090 3117
3091 if (hs->flags & ATA_HOST_SIMPLEX) { 3118 if ((host->flags & ATA_HOST_SIMPLEX) && host->simplex_claimed) {
3092 if (hs->simplex_claimed) 3119 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
3093 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 3120 ata_dev_printk(dev, KERN_WARNING, "simplex DMA is claimed by "
3121 "other device, disabling DMA\n");
3094 } 3122 }
3095 3123
3096 if (ap->ops->mode_filter) 3124 if (ap->ops->mode_filter)
@@ -3180,7 +3208,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,
3180 * Unmap all mapped DMA memory associated with this command. 3208 * Unmap all mapped DMA memory associated with this command.
3181 * 3209 *
3182 * LOCKING: 3210 * LOCKING:
3183 * spin_lock_irqsave(host_set lock) 3211 * spin_lock_irqsave(host lock)
3184 */ 3212 */
3185 3213
3186static void ata_sg_clean(struct ata_queued_cmd *qc) 3214static void ata_sg_clean(struct ata_queued_cmd *qc)
@@ -3240,7 +3268,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
3240 * associated with the current disk command. 3268 * associated with the current disk command.
3241 * 3269 *
3242 * LOCKING: 3270 * LOCKING:
3243 * spin_lock_irqsave(host_set lock) 3271 * spin_lock_irqsave(host lock)
3244 * 3272 *
3245 */ 3273 */
3246static void ata_fill_sg(struct ata_queued_cmd *qc) 3274static void ata_fill_sg(struct ata_queued_cmd *qc)
@@ -3292,7 +3320,7 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
3292 * supplied PACKET command. 3320 * supplied PACKET command.
3293 * 3321 *
3294 * LOCKING: 3322 * LOCKING:
3295 * spin_lock_irqsave(host_set lock) 3323 * spin_lock_irqsave(host lock)
3296 * 3324 *
3297 * RETURNS: 0 when ATAPI DMA can be used 3325 * RETURNS: 0 when ATAPI DMA can be used
3298 * nonzero otherwise 3326 * nonzero otherwise
@@ -3314,7 +3342,7 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc)
3314 * Prepare ATA taskfile for submission. 3342 * Prepare ATA taskfile for submission.
3315 * 3343 *
3316 * LOCKING: 3344 * LOCKING:
3317 * spin_lock_irqsave(host_set lock) 3345 * spin_lock_irqsave(host lock)
3318 */ 3346 */
3319void ata_qc_prep(struct ata_queued_cmd *qc) 3347void ata_qc_prep(struct ata_queued_cmd *qc)
3320{ 3348{
@@ -3336,7 +3364,7 @@ void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
3336 * to point to a single memory buffer, @buf of byte length @buflen. 3364 * to point to a single memory buffer, @buf of byte length @buflen.
3337 * 3365 *
3338 * LOCKING: 3366 * LOCKING:
3339 * spin_lock_irqsave(host_set lock) 3367 * spin_lock_irqsave(host lock)
3340 */ 3368 */
3341 3369
3342void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 3370void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
@@ -3367,7 +3395,7 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
3367 * elements. 3395 * elements.
3368 * 3396 *
3369 * LOCKING: 3397 * LOCKING:
3370 * spin_lock_irqsave(host_set lock) 3398 * spin_lock_irqsave(host lock)
3371 */ 3399 */
3372 3400
3373void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 3401void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
@@ -3386,7 +3414,7 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
3386 * DMA-map the memory buffer associated with queued_cmd @qc. 3414 * DMA-map the memory buffer associated with queued_cmd @qc.
3387 * 3415 *
3388 * LOCKING: 3416 * LOCKING:
3389 * spin_lock_irqsave(host_set lock) 3417 * spin_lock_irqsave(host lock)
3390 * 3418 *
3391 * RETURNS: 3419 * RETURNS:
3392 * Zero on success, negative on error. 3420 * Zero on success, negative on error.
@@ -3455,7 +3483,7 @@ skip_map:
3455 * DMA-map the scatter-gather table associated with queued_cmd @qc. 3483 * DMA-map the scatter-gather table associated with queued_cmd @qc.
3456 * 3484 *
3457 * LOCKING: 3485 * LOCKING:
3458 * spin_lock_irqsave(host_set lock) 3486 * spin_lock_irqsave(host lock)
3459 * 3487 *
3460 * RETURNS: 3488 * RETURNS:
3461 * Zero on success, negative on error. 3489 * Zero on success, negative on error.
@@ -3964,7 +3992,7 @@ static inline int ata_hsm_ok_in_wq(struct ata_port *ap, struct ata_queued_cmd *q
3964 * Finish @qc which is running on standard HSM. 3992 * Finish @qc which is running on standard HSM.
3965 * 3993 *
3966 * LOCKING: 3994 * LOCKING:
3967 * If @in_wq is zero, spin_lock_irqsave(host_set lock). 3995 * If @in_wq is zero, spin_lock_irqsave(host lock).
3968 * Otherwise, none on entry and grabs host lock. 3996 * Otherwise, none on entry and grabs host lock.
3969 */ 3997 */
3970static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) 3998static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
@@ -3976,8 +4004,8 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
3976 if (in_wq) { 4004 if (in_wq) {
3977 spin_lock_irqsave(ap->lock, flags); 4005 spin_lock_irqsave(ap->lock, flags);
3978 4006
3979 /* EH might have kicked in while host_set lock 4007 /* EH might have kicked in while host lock is
3980 * is released. 4008 * released.
3981 */ 4009 */
3982 qc = ata_qc_from_tag(ap, qc->tag); 4010 qc = ata_qc_from_tag(ap, qc->tag);
3983 if (qc) { 4011 if (qc) {
@@ -4342,7 +4370,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev)
4342 * in case something prevents using it. 4370 * in case something prevents using it.
4343 * 4371 *
4344 * LOCKING: 4372 * LOCKING:
4345 * spin_lock_irqsave(host_set lock) 4373 * spin_lock_irqsave(host lock)
4346 */ 4374 */
4347void ata_qc_free(struct ata_queued_cmd *qc) 4375void ata_qc_free(struct ata_queued_cmd *qc)
4348{ 4376{
@@ -4395,7 +4423,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
4395 * command has completed, with either an ok or not-ok status. 4423 * command has completed, with either an ok or not-ok status.
4396 * 4424 *
4397 * LOCKING: 4425 * LOCKING:
4398 * spin_lock_irqsave(host_set lock) 4426 * spin_lock_irqsave(host lock)
4399 */ 4427 */
4400void ata_qc_complete(struct ata_queued_cmd *qc) 4428void ata_qc_complete(struct ata_queued_cmd *qc)
4401{ 4429{
@@ -4458,7 +4486,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
4458 * and commands are completed accordingly. 4486 * and commands are completed accordingly.
4459 * 4487 *
4460 * LOCKING: 4488 * LOCKING:
4461 * spin_lock_irqsave(host_set lock) 4489 * spin_lock_irqsave(host lock)
4462 * 4490 *
4463 * RETURNS: 4491 * RETURNS:
4464 * Number of completed commands on success, -errno otherwise. 4492 * Number of completed commands on success, -errno otherwise.
@@ -4529,7 +4557,7 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
4529 * writing the taskfile to hardware, starting the command. 4557 * writing the taskfile to hardware, starting the command.
4530 * 4558 *
4531 * LOCKING: 4559 * LOCKING:
4532 * spin_lock_irqsave(host_set lock) 4560 * spin_lock_irqsave(host lock)
4533 */ 4561 */
4534void ata_qc_issue(struct ata_queued_cmd *qc) 4562void ata_qc_issue(struct ata_queued_cmd *qc)
4535{ 4563{
@@ -4590,7 +4618,7 @@ err:
4590 * May be used as the qc_issue() entry in ata_port_operations. 4618 * May be used as the qc_issue() entry in ata_port_operations.
4591 * 4619 *
4592 * LOCKING: 4620 * LOCKING:
4593 * spin_lock_irqsave(host_set lock) 4621 * spin_lock_irqsave(host lock)
4594 * 4622 *
4595 * RETURNS: 4623 * RETURNS:
4596 * Zero on success, AC_ERR_* mask on failure 4624 * Zero on success, AC_ERR_* mask on failure
@@ -4719,7 +4747,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4719 * handled via polling with interrupts disabled (nIEN bit). 4747 * handled via polling with interrupts disabled (nIEN bit).
4720 * 4748 *
4721 * LOCKING: 4749 * LOCKING:
4722 * spin_lock_irqsave(host_set lock) 4750 * spin_lock_irqsave(host lock)
4723 * 4751 *
4724 * RETURNS: 4752 * RETURNS:
4725 * One if interrupt was handled, zero if not (shared irq). 4753 * One if interrupt was handled, zero if not (shared irq).
@@ -4806,14 +4834,14 @@ idle_irq:
4806/** 4834/**
4807 * ata_interrupt - Default ATA host interrupt handler 4835 * ata_interrupt - Default ATA host interrupt handler
4808 * @irq: irq line (unused) 4836 * @irq: irq line (unused)
4809 * @dev_instance: pointer to our ata_host_set information structure 4837 * @dev_instance: pointer to our ata_host information structure
4810 * @regs: unused 4838 * @regs: unused
4811 * 4839 *
4812 * Default interrupt handler for PCI IDE devices. Calls 4840 * Default interrupt handler for PCI IDE devices. Calls
4813 * ata_host_intr() for each port that is not disabled. 4841 * ata_host_intr() for each port that is not disabled.
4814 * 4842 *
4815 * LOCKING: 4843 * LOCKING:
4816 * Obtains host_set lock during operation. 4844 * Obtains host lock during operation.
4817 * 4845 *
4818 * RETURNS: 4846 * RETURNS:
4819 * IRQ_NONE or IRQ_HANDLED. 4847 * IRQ_NONE or IRQ_HANDLED.
@@ -4821,18 +4849,18 @@ idle_irq:
4821 4849
4822irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 4850irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4823{ 4851{
4824 struct ata_host_set *host_set = dev_instance; 4852 struct ata_host *host = dev_instance;
4825 unsigned int i; 4853 unsigned int i;
4826 unsigned int handled = 0; 4854 unsigned int handled = 0;
4827 unsigned long flags; 4855 unsigned long flags;
4828 4856
4829 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ 4857 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
4830 spin_lock_irqsave(&host_set->lock, flags); 4858 spin_lock_irqsave(&host->lock, flags);
4831 4859
4832 for (i = 0; i < host_set->n_ports; i++) { 4860 for (i = 0; i < host->n_ports; i++) {
4833 struct ata_port *ap; 4861 struct ata_port *ap;
4834 4862
4835 ap = host_set->ports[i]; 4863 ap = host->ports[i];
4836 if (ap && 4864 if (ap &&
4837 !(ap->flags & ATA_FLAG_DISABLED)) { 4865 !(ap->flags & ATA_FLAG_DISABLED)) {
4838 struct ata_queued_cmd *qc; 4866 struct ata_queued_cmd *qc;
@@ -4844,7 +4872,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4844 } 4872 }
4845 } 4873 }
4846 4874
4847 spin_unlock_irqrestore(&host_set->lock, flags); 4875 spin_unlock_irqrestore(&host->lock, flags);
4848 4876
4849 return IRQ_RETVAL(handled); 4877 return IRQ_RETVAL(handled);
4850} 4878}
@@ -5009,15 +5037,15 @@ int ata_flush_cache(struct ata_device *dev)
5009 return 0; 5037 return 0;
5010} 5038}
5011 5039
5012static int ata_host_set_request_pm(struct ata_host_set *host_set, 5040static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
5013 pm_message_t mesg, unsigned int action, 5041 unsigned int action, unsigned int ehi_flags,
5014 unsigned int ehi_flags, int wait) 5042 int wait)
5015{ 5043{
5016 unsigned long flags; 5044 unsigned long flags;
5017 int i, rc; 5045 int i, rc;
5018 5046
5019 for (i = 0; i < host_set->n_ports; i++) { 5047 for (i = 0; i < host->n_ports; i++) {
5020 struct ata_port *ap = host_set->ports[i]; 5048 struct ata_port *ap = host->ports[i];
5021 5049
5022 /* Previous resume operation might still be in 5050 /* Previous resume operation might still be in
5023 * progress. Wait for PM_PENDING to clear. 5051 * progress. Wait for PM_PENDING to clear.
@@ -5057,11 +5085,11 @@ static int ata_host_set_request_pm(struct ata_host_set *host_set,
5057} 5085}
5058 5086
5059/** 5087/**
5060 * ata_host_set_suspend - suspend host_set 5088 * ata_host_suspend - suspend host
5061 * @host_set: host_set to suspend 5089 * @host: host to suspend
5062 * @mesg: PM message 5090 * @mesg: PM message
5063 * 5091 *
5064 * Suspend @host_set. Actual operation is performed by EH. This 5092 * Suspend @host. Actual operation is performed by EH. This
5065 * function requests EH to perform PM operations and waits for EH 5093 * function requests EH to perform PM operations and waits for EH
5066 * to finish. 5094 * to finish.
5067 * 5095 *
@@ -5071,11 +5099,11 @@ static int ata_host_set_request_pm(struct ata_host_set *host_set,
5071 * RETURNS: 5099 * RETURNS:
5072 * 0 on success, -errno on failure. 5100 * 0 on success, -errno on failure.
5073 */ 5101 */
5074int ata_host_set_suspend(struct ata_host_set *host_set, pm_message_t mesg) 5102int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5075{ 5103{
5076 int i, j, rc; 5104 int i, j, rc;
5077 5105
5078 rc = ata_host_set_request_pm(host_set, mesg, 0, ATA_EHI_QUIET, 1); 5106 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
5079 if (rc) 5107 if (rc)
5080 goto fail; 5108 goto fail;
5081 5109
@@ -5083,8 +5111,8 @@ int ata_host_set_suspend(struct ata_host_set *host_set, pm_message_t mesg)
5083 * This happens if hotplug occurs between completion of device 5111 * This happens if hotplug occurs between completion of device
5084 * suspension and here. 5112 * suspension and here.
5085 */ 5113 */
5086 for (i = 0; i < host_set->n_ports; i++) { 5114 for (i = 0; i < host->n_ports; i++) {
5087 struct ata_port *ap = host_set->ports[i]; 5115 struct ata_port *ap = host->ports[i];
5088 5116
5089 for (j = 0; j < ATA_MAX_DEVICES; j++) { 5117 for (j = 0; j < ATA_MAX_DEVICES; j++) {
5090 struct ata_device *dev = &ap->device[j]; 5118 struct ata_device *dev = &ap->device[j];
@@ -5099,30 +5127,30 @@ int ata_host_set_suspend(struct ata_host_set *host_set, pm_message_t mesg)
5099 } 5127 }
5100 } 5128 }
5101 5129
5102 host_set->dev->power.power_state = mesg; 5130 host->dev->power.power_state = mesg;
5103 return 0; 5131 return 0;
5104 5132
5105 fail: 5133 fail:
5106 ata_host_set_resume(host_set); 5134 ata_host_resume(host);
5107 return rc; 5135 return rc;
5108} 5136}
5109 5137
5110/** 5138/**
5111 * ata_host_set_resume - resume host_set 5139 * ata_host_resume - resume host
5112 * @host_set: host_set to resume 5140 * @host: host to resume
5113 * 5141 *
5114 * Resume @host_set. Actual operation is performed by EH. This 5142 * Resume @host. Actual operation is performed by EH. This
5115 * function requests EH to perform PM operations and returns. 5143 * function requests EH to perform PM operations and returns.
5116 * Note that all resume operations are performed parallely. 5144 * Note that all resume operations are performed parallely.
5117 * 5145 *
5118 * LOCKING: 5146 * LOCKING:
5119 * Kernel thread context (may sleep). 5147 * Kernel thread context (may sleep).
5120 */ 5148 */
5121void ata_host_set_resume(struct ata_host_set *host_set) 5149void ata_host_resume(struct ata_host *host)
5122{ 5150{
5123 ata_host_set_request_pm(host_set, PMSG_ON, ATA_EH_SOFTRESET, 5151 ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET,
5124 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0); 5152 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
5125 host_set->dev->power.power_state = PMSG_ON; 5153 host->dev->power.power_state = PMSG_ON;
5126} 5154}
5127 5155
5128/** 5156/**
@@ -5179,10 +5207,10 @@ void ata_port_stop (struct ata_port *ap)
5179 ata_pad_free(ap, dev); 5207 ata_pad_free(ap, dev);
5180} 5208}
5181 5209
5182void ata_host_stop (struct ata_host_set *host_set) 5210void ata_host_stop (struct ata_host *host)
5183{ 5211{
5184 if (host_set->mmio_base) 5212 if (host->mmio_base)
5185 iounmap(host_set->mmio_base); 5213 iounmap(host->mmio_base);
5186} 5214}
5187 5215
5188/** 5216/**
@@ -5204,7 +5232,7 @@ void ata_dev_init(struct ata_device *dev)
5204 5232
5205 /* High bits of dev->flags are used to record warm plug 5233 /* High bits of dev->flags are used to record warm plug
5206 * requests which occur asynchronously. Synchronize using 5234 * requests which occur asynchronously. Synchronize using
5207 * host_set lock. 5235 * host lock.
5208 */ 5236 */
5209 spin_lock_irqsave(ap->lock, flags); 5237 spin_lock_irqsave(ap->lock, flags);
5210 dev->flags &= ~ATA_DFLAG_INIT_MASK; 5238 dev->flags &= ~ATA_DFLAG_INIT_MASK;
@@ -5218,45 +5246,33 @@ void ata_dev_init(struct ata_device *dev)
5218} 5246}
5219 5247
5220/** 5248/**
5221 * ata_host_init - Initialize an ata_port structure 5249 * ata_port_init - Initialize an ata_port structure
5222 * @ap: Structure to initialize 5250 * @ap: Structure to initialize
5223 * @host: associated SCSI mid-layer structure 5251 * @host: Collection of hosts to which @ap belongs
5224 * @host_set: Collection of hosts to which @ap belongs
5225 * @ent: Probe information provided by low-level driver 5252 * @ent: Probe information provided by low-level driver
5226 * @port_no: Port number associated with this ata_port 5253 * @port_no: Port number associated with this ata_port
5227 * 5254 *
5228 * Initialize a new ata_port structure, and its associated 5255 * Initialize a new ata_port structure.
5229 * scsi_host.
5230 * 5256 *
5231 * LOCKING: 5257 * LOCKING:
5232 * Inherited from caller. 5258 * Inherited from caller.
5233 */ 5259 */
5234static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, 5260void ata_port_init(struct ata_port *ap, struct ata_host *host,
5235 struct ata_host_set *host_set, 5261 const struct ata_probe_ent *ent, unsigned int port_no)
5236 const struct ata_probe_ent *ent, unsigned int port_no)
5237{ 5262{
5238 unsigned int i; 5263 unsigned int i;
5239 5264
5240 host->max_id = 16; 5265 ap->lock = &host->lock;
5241 host->max_lun = 1;
5242 host->max_channel = 1;
5243 host->unique_id = ata_unique_id++;
5244 host->max_cmd_len = 12;
5245
5246 ap->lock = &host_set->lock;
5247 ap->flags = ATA_FLAG_DISABLED; 5266 ap->flags = ATA_FLAG_DISABLED;
5248 ap->id = host->unique_id; 5267 ap->id = ata_unique_id++;
5249 ap->host = host;
5250 ap->ctl = ATA_DEVCTL_OBS; 5268 ap->ctl = ATA_DEVCTL_OBS;
5251 ap->host_set = host_set; 5269 ap->host = host;
5252 ap->dev = ent->dev; 5270 ap->dev = ent->dev;
5253 ap->port_no = port_no; 5271 ap->port_no = port_no;
5254 ap->hard_port_no =
5255 ent->legacy_mode ? ent->hard_port_no : port_no;
5256 ap->pio_mask = ent->pio_mask; 5272 ap->pio_mask = ent->pio_mask;
5257 ap->mwdma_mask = ent->mwdma_mask; 5273 ap->mwdma_mask = ent->mwdma_mask;
5258 ap->udma_mask = ent->udma_mask; 5274 ap->udma_mask = ent->udma_mask;
5259 ap->flags |= ent->host_flags; 5275 ap->flags |= ent->port_flags;
5260 ap->ops = ent->port_ops; 5276 ap->ops = ent->port_ops;
5261 ap->hw_sata_spd_limit = UINT_MAX; 5277 ap->hw_sata_spd_limit = UINT_MAX;
5262 ap->active_tag = ATA_TAG_POISON; 5278 ap->active_tag = ATA_TAG_POISON;
@@ -5298,9 +5314,30 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
5298} 5314}
5299 5315
5300/** 5316/**
5301 * ata_host_add - Attach low-level ATA driver to system 5317 * ata_port_init_shost - Initialize SCSI host associated with ATA port
5318 * @ap: ATA port to initialize SCSI host for
5319 * @shost: SCSI host associated with @ap
5320 *
5321 * Initialize SCSI host @shost associated with ATA port @ap.
5322 *
5323 * LOCKING:
5324 * Inherited from caller.
5325 */
5326static void ata_port_init_shost(struct ata_port *ap, struct Scsi_Host *shost)
5327{
5328 ap->scsi_host = shost;
5329
5330 shost->unique_id = ap->id;
5331 shost->max_id = 16;
5332 shost->max_lun = 1;
5333 shost->max_channel = 1;
5334 shost->max_cmd_len = 12;
5335}
5336
5337/**
5338 * ata_port_add - Attach low-level ATA driver to system
5302 * @ent: Information provided by low-level driver 5339 * @ent: Information provided by low-level driver
5303 * @host_set: Collections of ports to which we add 5340 * @host: Collections of ports to which we add
5304 * @port_no: Port number associated with this host 5341 * @port_no: Port number associated with this host
5305 * 5342 *
5306 * Attach low-level ATA driver to system. 5343 * Attach low-level ATA driver to system.
@@ -5311,43 +5348,55 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
5311 * RETURNS: 5348 * RETURNS:
5312 * New ata_port on success, for NULL on error. 5349 * New ata_port on success, for NULL on error.
5313 */ 5350 */
5314 5351static struct ata_port * ata_port_add(const struct ata_probe_ent *ent,
5315static struct ata_port * ata_host_add(const struct ata_probe_ent *ent, 5352 struct ata_host *host,
5316 struct ata_host_set *host_set,
5317 unsigned int port_no) 5353 unsigned int port_no)
5318{ 5354{
5319 struct Scsi_Host *host; 5355 struct Scsi_Host *shost;
5320 struct ata_port *ap; 5356 struct ata_port *ap;
5321 int rc;
5322 5357
5323 DPRINTK("ENTER\n"); 5358 DPRINTK("ENTER\n");
5324 5359
5325 if (!ent->port_ops->error_handler && 5360 if (!ent->port_ops->error_handler &&
5326 !(ent->host_flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST))) { 5361 !(ent->port_flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST))) {
5327 printk(KERN_ERR "ata%u: no reset mechanism available\n", 5362 printk(KERN_ERR "ata%u: no reset mechanism available\n",
5328 port_no); 5363 port_no);
5329 return NULL; 5364 return NULL;
5330 } 5365 }
5331 5366
5332 host = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); 5367 shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port));
5333 if (!host) 5368 if (!shost)
5334 return NULL; 5369 return NULL;
5335 5370
5336 host->transportt = &ata_scsi_transport_template; 5371 shost->transportt = &ata_scsi_transport_template;
5337
5338 ap = ata_shost_to_port(host);
5339 5372
5340 ata_host_init(ap, host, host_set, ent, port_no); 5373 ap = ata_shost_to_port(shost);
5341 5374
5342 rc = ap->ops->port_start(ap); 5375 ata_port_init(ap, host, ent, port_no);
5343 if (rc) 5376 ata_port_init_shost(ap, shost);
5344 goto err_out;
5345 5377
5346 return ap; 5378 return ap;
5379}
5347 5380
5348err_out: 5381/**
5349 scsi_host_put(host); 5382 * ata_sas_host_init - Initialize a host struct
5350 return NULL; 5383 * @host: host to initialize
5384 * @dev: device host is attached to
5385 * @flags: host flags
5386 * @ops: port_ops
5387 *
5388 * LOCKING:
5389 * PCI/etc. bus probe sem.
5390 *
5391 */
5392
5393void ata_host_init(struct ata_host *host, struct device *dev,
5394 unsigned long flags, const struct ata_port_operations *ops)
5395{
5396 spin_lock_init(&host->lock);
5397 host->dev = dev;
5398 host->flags = flags;
5399 host->ops = ops;
5351} 5400}
5352 5401
5353/** 5402/**
@@ -5370,78 +5419,106 @@ err_out:
5370 */ 5419 */
5371int ata_device_add(const struct ata_probe_ent *ent) 5420int ata_device_add(const struct ata_probe_ent *ent)
5372{ 5421{
5373 unsigned int count = 0, i; 5422 unsigned int i;
5374 struct device *dev = ent->dev; 5423 struct device *dev = ent->dev;
5375 struct ata_host_set *host_set; 5424 struct ata_host *host;
5376 int rc; 5425 int rc;
5377 5426
5378 DPRINTK("ENTER\n"); 5427 DPRINTK("ENTER\n");
5379 /* alloc a container for our list of ATA ports (buses) */ 5428 /* alloc a container for our list of ATA ports (buses) */
5380 host_set = kzalloc(sizeof(struct ata_host_set) + 5429 host = kzalloc(sizeof(struct ata_host) +
5381 (ent->n_ports * sizeof(void *)), GFP_KERNEL); 5430 (ent->n_ports * sizeof(void *)), GFP_KERNEL);
5382 if (!host_set) 5431 if (!host)
5383 return 0; 5432 return 0;
5384 spin_lock_init(&host_set->lock);
5385 5433
5386 host_set->dev = dev; 5434 ata_host_init(host, dev, ent->_host_flags, ent->port_ops);
5387 host_set->n_ports = ent->n_ports; 5435 host->n_ports = ent->n_ports;
5388 host_set->irq = ent->irq; 5436 host->irq = ent->irq;
5389 host_set->mmio_base = ent->mmio_base; 5437 host->irq2 = ent->irq2;
5390 host_set->private_data = ent->private_data; 5438 host->mmio_base = ent->mmio_base;
5391 host_set->ops = ent->port_ops; 5439 host->private_data = ent->private_data;
5392 host_set->flags = ent->host_set_flags;
5393 5440
5394 /* register each port bound to this device */ 5441 /* register each port bound to this device */
5395 for (i = 0; i < ent->n_ports; i++) { 5442 for (i = 0; i < host->n_ports; i++) {
5396 struct ata_port *ap; 5443 struct ata_port *ap;
5397 unsigned long xfer_mode_mask; 5444 unsigned long xfer_mode_mask;
5445 int irq_line = ent->irq;
5398 5446
5399 ap = ata_host_add(ent, host_set, i); 5447 ap = ata_port_add(ent, host, i);
5400 if (!ap) 5448 if (!ap)
5401 goto err_out; 5449 goto err_out;
5402 5450
5403 host_set->ports[i] = ap; 5451 host->ports[i] = ap;
5452
5453 /* dummy? */
5454 if (ent->dummy_port_mask & (1 << i)) {
5455 ata_port_printk(ap, KERN_INFO, "DUMMY\n");
5456 ap->ops = &ata_dummy_port_ops;
5457 continue;
5458 }
5459
5460 /* start port */
5461 rc = ap->ops->port_start(ap);
5462 if (rc) {
5463 host->ports[i] = NULL;
5464 scsi_host_put(ap->scsi_host);
5465 goto err_out;
5466 }
5467
5468 /* Report the secondary IRQ for second channel legacy */
5469 if (i == 1 && ent->irq2)
5470 irq_line = ent->irq2;
5471
5404 xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) | 5472 xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
5405 (ap->mwdma_mask << ATA_SHIFT_MWDMA) | 5473 (ap->mwdma_mask << ATA_SHIFT_MWDMA) |
5406 (ap->pio_mask << ATA_SHIFT_PIO); 5474 (ap->pio_mask << ATA_SHIFT_PIO);
5407 5475
5408 /* print per-port info to dmesg */ 5476 /* print per-port info to dmesg */
5409 ata_port_printk(ap, KERN_INFO, "%cATA max %s cmd 0x%lX " 5477 ata_port_printk(ap, KERN_INFO, "%cATA max %s cmd 0x%lX "
5410 "ctl 0x%lX bmdma 0x%lX irq %lu\n", 5478 "ctl 0x%lX bmdma 0x%lX irq %d\n",
5411 ap->flags & ATA_FLAG_SATA ? 'S' : 'P', 5479 ap->flags & ATA_FLAG_SATA ? 'S' : 'P',
5412 ata_mode_string(xfer_mode_mask), 5480 ata_mode_string(xfer_mode_mask),
5413 ap->ioaddr.cmd_addr, 5481 ap->ioaddr.cmd_addr,
5414 ap->ioaddr.ctl_addr, 5482 ap->ioaddr.ctl_addr,
5415 ap->ioaddr.bmdma_addr, 5483 ap->ioaddr.bmdma_addr,
5416 ent->irq); 5484 irq_line);
5417 5485
5418 ata_chk_status(ap); 5486 ata_chk_status(ap);
5419 host_set->ops->irq_clear(ap); 5487 host->ops->irq_clear(ap);
5420 ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */ 5488 ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */
5421 count++;
5422 } 5489 }
5423 5490
5424 if (!count) 5491 /* obtain irq, that may be shared between channels */
5425 goto err_free_ret;
5426
5427 /* obtain irq, that is shared between channels */
5428 rc = request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags, 5492 rc = request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags,
5429 DRV_NAME, host_set); 5493 DRV_NAME, host);
5430 if (rc) { 5494 if (rc) {
5431 dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n", 5495 dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n",
5432 ent->irq, rc); 5496 ent->irq, rc);
5433 goto err_out; 5497 goto err_out;
5434 } 5498 }
5435 5499
5500 /* do we have a second IRQ for the other channel, eg legacy mode */
5501 if (ent->irq2) {
5502 /* We will get weird core code crashes later if this is true
5503 so trap it now */
5504 BUG_ON(ent->irq == ent->irq2);
5505
5506 rc = request_irq(ent->irq2, ent->port_ops->irq_handler, ent->irq_flags,
5507 DRV_NAME, host);
5508 if (rc) {
5509 dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n",
5510 ent->irq2, rc);
5511 goto err_out_free_irq;
5512 }
5513 }
5514
5436 /* perform each probe synchronously */ 5515 /* perform each probe synchronously */
5437 DPRINTK("probe begin\n"); 5516 DPRINTK("probe begin\n");
5438 for (i = 0; i < count; i++) { 5517 for (i = 0; i < host->n_ports; i++) {
5439 struct ata_port *ap; 5518 struct ata_port *ap = host->ports[i];
5440 u32 scontrol; 5519 u32 scontrol;
5441 int rc; 5520 int rc;
5442 5521
5443 ap = host_set->ports[i];
5444
5445 /* init sata_spd_limit to the current value */ 5522 /* init sata_spd_limit to the current value */
5446 if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { 5523 if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) {
5447 int spd = (scontrol >> 4) & 0xf; 5524 int spd = (scontrol >> 4) & 0xf;
@@ -5449,7 +5526,7 @@ int ata_device_add(const struct ata_probe_ent *ent)
5449 } 5526 }
5450 ap->sata_spd_limit = ap->hw_sata_spd_limit; 5527 ap->sata_spd_limit = ap->hw_sata_spd_limit;
5451 5528
5452 rc = scsi_add_host(ap->host, dev); 5529 rc = scsi_add_host(ap->scsi_host, dev);
5453 if (rc) { 5530 if (rc) {
5454 ata_port_printk(ap, KERN_ERR, "scsi_add_host failed\n"); 5531 ata_port_printk(ap, KERN_ERR, "scsi_add_host failed\n");
5455 /* FIXME: do something useful here */ 5532 /* FIXME: do something useful here */
@@ -5497,27 +5574,29 @@ int ata_device_add(const struct ata_probe_ent *ent)
5497 5574
5498 /* probes are done, now scan each port's disk(s) */ 5575 /* probes are done, now scan each port's disk(s) */
5499 DPRINTK("host probe begin\n"); 5576 DPRINTK("host probe begin\n");
5500 for (i = 0; i < count; i++) { 5577 for (i = 0; i < host->n_ports; i++) {
5501 struct ata_port *ap = host_set->ports[i]; 5578 struct ata_port *ap = host->ports[i];
5502 5579
5503 ata_scsi_scan_host(ap); 5580 ata_scsi_scan_host(ap);
5504 } 5581 }
5505 5582
5506 dev_set_drvdata(dev, host_set); 5583 dev_set_drvdata(dev, host);
5507 5584
5508 VPRINTK("EXIT, returning %u\n", ent->n_ports); 5585 VPRINTK("EXIT, returning %u\n", ent->n_ports);
5509 return ent->n_ports; /* success */ 5586 return ent->n_ports; /* success */
5510 5587
5588err_out_free_irq:
5589 free_irq(ent->irq, host);
5511err_out: 5590err_out:
5512 for (i = 0; i < count; i++) { 5591 for (i = 0; i < host->n_ports; i++) {
5513 struct ata_port *ap = host_set->ports[i]; 5592 struct ata_port *ap = host->ports[i];
5514 if (ap) { 5593 if (ap) {
5515 ap->ops->port_stop(ap); 5594 ap->ops->port_stop(ap);
5516 scsi_host_put(ap->host); 5595 scsi_host_put(ap->scsi_host);
5517 } 5596 }
5518 } 5597 }
5519err_free_ret: 5598
5520 kfree(host_set); 5599 kfree(host);
5521 VPRINTK("EXIT, returning 0\n"); 5600 VPRINTK("EXIT, returning 0\n");
5522 return 0; 5601 return 0;
5523} 5602}
@@ -5577,12 +5656,12 @@ void ata_port_detach(struct ata_port *ap)
5577 5656
5578 skip_eh: 5657 skip_eh:
5579 /* remove the associated SCSI host */ 5658 /* remove the associated SCSI host */
5580 scsi_remove_host(ap->host); 5659 scsi_remove_host(ap->scsi_host);
5581} 5660}
5582 5661
5583/** 5662/**
5584 * ata_host_set_remove - PCI layer callback for device removal 5663 * ata_host_remove - PCI layer callback for device removal
5585 * @host_set: ATA host set that was removed 5664 * @host: ATA host set that was removed
5586 * 5665 *
5587 * Unregister all objects associated with this host set. Free those 5666 * Unregister all objects associated with this host set. Free those
5588 * objects. 5667 * objects.
@@ -5591,36 +5670,39 @@ void ata_port_detach(struct ata_port *ap)
5591 * Inherited from calling layer (may sleep). 5670 * Inherited from calling layer (may sleep).
5592 */ 5671 */
5593 5672
5594void ata_host_set_remove(struct ata_host_set *host_set) 5673void ata_host_remove(struct ata_host *host)
5595{ 5674{
5596 unsigned int i; 5675 unsigned int i;
5597 5676
5598 for (i = 0; i < host_set->n_ports; i++) 5677 for (i = 0; i < host->n_ports; i++)
5599 ata_port_detach(host_set->ports[i]); 5678 ata_port_detach(host->ports[i]);
5600 5679
5601 free_irq(host_set->irq, host_set); 5680 free_irq(host->irq, host);
5681 if (host->irq2)
5682 free_irq(host->irq2, host);
5602 5683
5603 for (i = 0; i < host_set->n_ports; i++) { 5684 for (i = 0; i < host->n_ports; i++) {
5604 struct ata_port *ap = host_set->ports[i]; 5685 struct ata_port *ap = host->ports[i];
5605 5686
5606 ata_scsi_release(ap->host); 5687 ata_scsi_release(ap->scsi_host);
5607 5688
5608 if ((ap->flags & ATA_FLAG_NO_LEGACY) == 0) { 5689 if ((ap->flags & ATA_FLAG_NO_LEGACY) == 0) {
5609 struct ata_ioports *ioaddr = &ap->ioaddr; 5690 struct ata_ioports *ioaddr = &ap->ioaddr;
5610 5691
5611 if (ioaddr->cmd_addr == 0x1f0) 5692 /* FIXME: Add -ac IDE pci mods to remove these special cases */
5612 release_region(0x1f0, 8); 5693 if (ioaddr->cmd_addr == ATA_PRIMARY_CMD)
5613 else if (ioaddr->cmd_addr == 0x170) 5694 release_region(ATA_PRIMARY_CMD, 8);
5614 release_region(0x170, 8); 5695 else if (ioaddr->cmd_addr == ATA_SECONDARY_CMD)
5696 release_region(ATA_SECONDARY_CMD, 8);
5615 } 5697 }
5616 5698
5617 scsi_host_put(ap->host); 5699 scsi_host_put(ap->scsi_host);
5618 } 5700 }
5619 5701
5620 if (host_set->ops->host_stop) 5702 if (host->ops->host_stop)
5621 host_set->ops->host_stop(host_set); 5703 host->ops->host_stop(host);
5622 5704
5623 kfree(host_set); 5705 kfree(host);
5624} 5706}
5625 5707
5626/** 5708/**
@@ -5637,9 +5719,9 @@ void ata_host_set_remove(struct ata_host_set *host_set)
5637 * One. 5719 * One.
5638 */ 5720 */
5639 5721
5640int ata_scsi_release(struct Scsi_Host *host) 5722int ata_scsi_release(struct Scsi_Host *shost)
5641{ 5723{
5642 struct ata_port *ap = ata_shost_to_port(host); 5724 struct ata_port *ap = ata_shost_to_port(shost);
5643 5725
5644 DPRINTK("ENTER\n"); 5726 DPRINTK("ENTER\n");
5645 5727
@@ -5650,6 +5732,31 @@ int ata_scsi_release(struct Scsi_Host *host)
5650 return 1; 5732 return 1;
5651} 5733}
5652 5734
5735struct ata_probe_ent *
5736ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
5737{
5738 struct ata_probe_ent *probe_ent;
5739
5740 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
5741 if (!probe_ent) {
5742 printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
5743 kobject_name(&(dev->kobj)));
5744 return NULL;
5745 }
5746
5747 INIT_LIST_HEAD(&probe_ent->node);
5748 probe_ent->dev = dev;
5749
5750 probe_ent->sht = port->sht;
5751 probe_ent->port_flags = port->flags;
5752 probe_ent->pio_mask = port->pio_mask;
5753 probe_ent->mwdma_mask = port->mwdma_mask;
5754 probe_ent->udma_mask = port->udma_mask;
5755 probe_ent->port_ops = port->port_ops;
5756
5757 return probe_ent;
5758}
5759
5653/** 5760/**
5654 * ata_std_ports - initialize ioaddr with standard port offsets. 5761 * ata_std_ports - initialize ioaddr with standard port offsets.
5655 * @ioaddr: IO address structure to be initialized 5762 * @ioaddr: IO address structure to be initialized
@@ -5679,11 +5786,11 @@ void ata_std_ports(struct ata_ioports *ioaddr)
5679 5786
5680#ifdef CONFIG_PCI 5787#ifdef CONFIG_PCI
5681 5788
5682void ata_pci_host_stop (struct ata_host_set *host_set) 5789void ata_pci_host_stop (struct ata_host *host)
5683{ 5790{
5684 struct pci_dev *pdev = to_pci_dev(host_set->dev); 5791 struct pci_dev *pdev = to_pci_dev(host->dev);
5685 5792
5686 pci_iounmap(pdev, host_set->mmio_base); 5793 pci_iounmap(pdev, host->mmio_base);
5687} 5794}
5688 5795
5689/** 5796/**
@@ -5703,12 +5810,9 @@ void ata_pci_host_stop (struct ata_host_set *host_set)
5703void ata_pci_remove_one (struct pci_dev *pdev) 5810void ata_pci_remove_one (struct pci_dev *pdev)
5704{ 5811{
5705 struct device *dev = pci_dev_to_dev(pdev); 5812 struct device *dev = pci_dev_to_dev(pdev);
5706 struct ata_host_set *host_set = dev_get_drvdata(dev); 5813 struct ata_host *host = dev_get_drvdata(dev);
5707 struct ata_host_set *host_set2 = host_set->next;
5708 5814
5709 ata_host_set_remove(host_set); 5815 ata_host_remove(host);
5710 if (host_set2)
5711 ata_host_set_remove(host_set2);
5712 5816
5713 pci_release_regions(pdev); 5817 pci_release_regions(pdev);
5714 pci_disable_device(pdev); 5818 pci_disable_device(pdev);
@@ -5749,11 +5853,11 @@ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
5749 return (tmp == bits->val) ? 1 : 0; 5853 return (tmp == bits->val) ? 1 : 0;
5750} 5854}
5751 5855
5752void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t state) 5856void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg)
5753{ 5857{
5754 pci_save_state(pdev); 5858 pci_save_state(pdev);
5755 5859
5756 if (state.event == PM_EVENT_SUSPEND) { 5860 if (mesg.event == PM_EVENT_SUSPEND) {
5757 pci_disable_device(pdev); 5861 pci_disable_device(pdev);
5758 pci_set_power_state(pdev, PCI_D3hot); 5862 pci_set_power_state(pdev, PCI_D3hot);
5759 } 5863 }
@@ -5767,37 +5871,26 @@ void ata_pci_device_do_resume(struct pci_dev *pdev)
5767 pci_set_master(pdev); 5871 pci_set_master(pdev);
5768} 5872}
5769 5873
5770int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state) 5874int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
5771{ 5875{
5772 struct ata_host_set *host_set = dev_get_drvdata(&pdev->dev); 5876 struct ata_host *host = dev_get_drvdata(&pdev->dev);
5773 int rc = 0; 5877 int rc = 0;
5774 5878
5775 rc = ata_host_set_suspend(host_set, state); 5879 rc = ata_host_suspend(host, mesg);
5776 if (rc) 5880 if (rc)
5777 return rc; 5881 return rc;
5778 5882
5779 if (host_set->next) { 5883 ata_pci_device_do_suspend(pdev, mesg);
5780 rc = ata_host_set_suspend(host_set->next, state);
5781 if (rc) {
5782 ata_host_set_resume(host_set);
5783 return rc;
5784 }
5785 }
5786
5787 ata_pci_device_do_suspend(pdev, state);
5788 5884
5789 return 0; 5885 return 0;
5790} 5886}
5791 5887
5792int ata_pci_device_resume(struct pci_dev *pdev) 5888int ata_pci_device_resume(struct pci_dev *pdev)
5793{ 5889{
5794 struct ata_host_set *host_set = dev_get_drvdata(&pdev->dev); 5890 struct ata_host *host = dev_get_drvdata(&pdev->dev);
5795 5891
5796 ata_pci_device_do_resume(pdev); 5892 ata_pci_device_do_resume(pdev);
5797 ata_host_set_resume(host_set); 5893 ata_host_resume(host);
5798 if (host_set->next)
5799 ata_host_set_resume(host_set->next);
5800
5801 return 0; 5894 return 0;
5802} 5895}
5803#endif /* CONFIG_PCI */ 5896#endif /* CONFIG_PCI */
@@ -5897,6 +5990,39 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
5897} 5990}
5898 5991
5899/* 5992/*
5993 * Dummy port_ops
5994 */
5995static void ata_dummy_noret(struct ata_port *ap) { }
5996static int ata_dummy_ret0(struct ata_port *ap) { return 0; }
5997static void ata_dummy_qc_noret(struct ata_queued_cmd *qc) { }
5998
5999static u8 ata_dummy_check_status(struct ata_port *ap)
6000{
6001 return ATA_DRDY;
6002}
6003
6004static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
6005{
6006 return AC_ERR_SYSTEM;
6007}
6008
6009const struct ata_port_operations ata_dummy_port_ops = {
6010 .port_disable = ata_port_disable,
6011 .check_status = ata_dummy_check_status,
6012 .check_altstatus = ata_dummy_check_status,
6013 .dev_select = ata_noop_dev_select,
6014 .qc_prep = ata_noop_qc_prep,
6015 .qc_issue = ata_dummy_qc_issue,
6016 .freeze = ata_dummy_noret,
6017 .thaw = ata_dummy_noret,
6018 .error_handler = ata_dummy_noret,
6019 .post_internal_cmd = ata_dummy_qc_noret,
6020 .irq_clear = ata_dummy_noret,
6021 .port_start = ata_dummy_ret0,
6022 .port_stop = ata_dummy_noret,
6023};
6024
6025/*
5900 * libata is essentially a library of internal helper functions for 6026 * libata is essentially a library of internal helper functions for
5901 * low-level ATA host controller drivers. As such, the API/ABI is 6027 * low-level ATA host controller drivers. As such, the API/ABI is
5902 * likely to change as new drivers are added and updated. 6028 * likely to change as new drivers are added and updated.
@@ -5906,11 +6032,13 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
5906EXPORT_SYMBOL_GPL(sata_deb_timing_normal); 6032EXPORT_SYMBOL_GPL(sata_deb_timing_normal);
5907EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); 6033EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
5908EXPORT_SYMBOL_GPL(sata_deb_timing_long); 6034EXPORT_SYMBOL_GPL(sata_deb_timing_long);
6035EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
5909EXPORT_SYMBOL_GPL(ata_std_bios_param); 6036EXPORT_SYMBOL_GPL(ata_std_bios_param);
5910EXPORT_SYMBOL_GPL(ata_std_ports); 6037EXPORT_SYMBOL_GPL(ata_std_ports);
6038EXPORT_SYMBOL_GPL(ata_host_init);
5911EXPORT_SYMBOL_GPL(ata_device_add); 6039EXPORT_SYMBOL_GPL(ata_device_add);
5912EXPORT_SYMBOL_GPL(ata_port_detach); 6040EXPORT_SYMBOL_GPL(ata_port_detach);
5913EXPORT_SYMBOL_GPL(ata_host_set_remove); 6041EXPORT_SYMBOL_GPL(ata_host_remove);
5914EXPORT_SYMBOL_GPL(ata_sg_init); 6042EXPORT_SYMBOL_GPL(ata_sg_init);
5915EXPORT_SYMBOL_GPL(ata_sg_init_one); 6043EXPORT_SYMBOL_GPL(ata_sg_init_one);
5916EXPORT_SYMBOL_GPL(ata_hsm_move); 6044EXPORT_SYMBOL_GPL(ata_hsm_move);
@@ -5977,8 +6105,8 @@ EXPORT_SYMBOL_GPL(sata_scr_write);
5977EXPORT_SYMBOL_GPL(sata_scr_write_flush); 6105EXPORT_SYMBOL_GPL(sata_scr_write_flush);
5978EXPORT_SYMBOL_GPL(ata_port_online); 6106EXPORT_SYMBOL_GPL(ata_port_online);
5979EXPORT_SYMBOL_GPL(ata_port_offline); 6107EXPORT_SYMBOL_GPL(ata_port_offline);
5980EXPORT_SYMBOL_GPL(ata_host_set_suspend); 6108EXPORT_SYMBOL_GPL(ata_host_suspend);
5981EXPORT_SYMBOL_GPL(ata_host_set_resume); 6109EXPORT_SYMBOL_GPL(ata_host_resume);
5982EXPORT_SYMBOL_GPL(ata_id_string); 6110EXPORT_SYMBOL_GPL(ata_id_string);
5983EXPORT_SYMBOL_GPL(ata_id_c_string); 6111EXPORT_SYMBOL_GPL(ata_id_c_string);
5984EXPORT_SYMBOL_GPL(ata_scsi_simulate); 6112EXPORT_SYMBOL_GPL(ata_scsi_simulate);
diff --git a/drivers/scsi/libata-eh.c b/drivers/ata/libata-eh.c
index 29f59345305d..b1b510493c2d 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -39,7 +39,7 @@
39#include <scsi/scsi_eh.h> 39#include <scsi/scsi_eh.h>
40#include <scsi/scsi_device.h> 40#include <scsi/scsi_device.h>
41#include <scsi/scsi_cmnd.h> 41#include <scsi/scsi_cmnd.h>
42#include "scsi_transport_api.h" 42#include "../scsi/scsi_transport_api.h"
43 43
44#include <linux/libata.h> 44#include <linux/libata.h>
45 45
@@ -200,7 +200,7 @@ void ata_scsi_error(struct Scsi_Host *host)
200 /* synchronize with port task */ 200 /* synchronize with port task */
201 ata_port_flush_task(ap); 201 ata_port_flush_task(ap);
202 202
203 /* synchronize with host_set lock and sort out timeouts */ 203 /* synchronize with host lock and sort out timeouts */
204 204
205 /* For new EH, all qcs are finished in one of three ways - 205 /* For new EH, all qcs are finished in one of three ways -
206 * normal completion, error completion, and SCSI timeout. 206 * normal completion, error completion, and SCSI timeout.
@@ -377,7 +377,7 @@ void ata_port_wait_eh(struct ata_port *ap)
377 spin_unlock_irqrestore(ap->lock, flags); 377 spin_unlock_irqrestore(ap->lock, flags);
378 378
379 /* make sure SCSI EH is complete */ 379 /* make sure SCSI EH is complete */
380 if (scsi_host_in_recovery(ap->host)) { 380 if (scsi_host_in_recovery(ap->scsi_host)) {
381 msleep(10); 381 msleep(10);
382 goto retry; 382 goto retry;
383 } 383 }
@@ -486,7 +486,7 @@ void ata_eng_timeout(struct ata_port *ap)
486 * other commands are drained. 486 * other commands are drained.
487 * 487 *
488 * LOCKING: 488 * LOCKING:
489 * spin_lock_irqsave(host_set lock) 489 * spin_lock_irqsave(host lock)
490 */ 490 */
491void ata_qc_schedule_eh(struct ata_queued_cmd *qc) 491void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
492{ 492{
@@ -513,14 +513,14 @@ void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
513 * all commands are drained. 513 * all commands are drained.
514 * 514 *
515 * LOCKING: 515 * LOCKING:
516 * spin_lock_irqsave(host_set lock) 516 * spin_lock_irqsave(host lock)
517 */ 517 */
518void ata_port_schedule_eh(struct ata_port *ap) 518void ata_port_schedule_eh(struct ata_port *ap)
519{ 519{
520 WARN_ON(!ap->ops->error_handler); 520 WARN_ON(!ap->ops->error_handler);
521 521
522 ap->pflags |= ATA_PFLAG_EH_PENDING; 522 ap->pflags |= ATA_PFLAG_EH_PENDING;
523 scsi_schedule_eh(ap->host); 523 scsi_schedule_eh(ap->scsi_host);
524 524
525 DPRINTK("port EH scheduled\n"); 525 DPRINTK("port EH scheduled\n");
526} 526}
@@ -532,7 +532,7 @@ void ata_port_schedule_eh(struct ata_port *ap)
532 * Abort all active qc's of @ap and schedule EH. 532 * Abort all active qc's of @ap and schedule EH.
533 * 533 *
534 * LOCKING: 534 * LOCKING:
535 * spin_lock_irqsave(host_set lock) 535 * spin_lock_irqsave(host lock)
536 * 536 *
537 * RETURNS: 537 * RETURNS:
538 * Number of aborted qc's. 538 * Number of aborted qc's.
@@ -575,7 +575,7 @@ int ata_port_abort(struct ata_port *ap)
575 * is frozen. 575 * is frozen.
576 * 576 *
577 * LOCKING: 577 * LOCKING:
578 * spin_lock_irqsave(host_set lock) 578 * spin_lock_irqsave(host lock)
579 */ 579 */
580static void __ata_port_freeze(struct ata_port *ap) 580static void __ata_port_freeze(struct ata_port *ap)
581{ 581{
@@ -596,7 +596,7 @@ static void __ata_port_freeze(struct ata_port *ap)
596 * Abort and freeze @ap. 596 * Abort and freeze @ap.
597 * 597 *
598 * LOCKING: 598 * LOCKING:
599 * spin_lock_irqsave(host_set lock) 599 * spin_lock_irqsave(host lock)
600 * 600 *
601 * RETURNS: 601 * RETURNS:
602 * Number of aborted commands. 602 * Number of aborted commands.
diff --git a/drivers/scsi/libata-scsi.c b/drivers/ata/libata-scsi.c
index e92c31d698ff..3986ec8741b4 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -321,7 +321,7 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
321 * current command. 321 * current command.
322 * 322 *
323 * LOCKING: 323 * LOCKING:
324 * spin_lock_irqsave(host_set lock) 324 * spin_lock_irqsave(host lock)
325 * 325 *
326 * RETURNS: 326 * RETURNS:
327 * Command allocated, or %NULL if none available. 327 * Command allocated, or %NULL if none available.
@@ -400,7 +400,7 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf)
400/** 400/**
401 * ata_scsi_device_suspend - suspend ATA device associated with sdev 401 * ata_scsi_device_suspend - suspend ATA device associated with sdev
402 * @sdev: the SCSI device to suspend 402 * @sdev: the SCSI device to suspend
403 * @state: target power management state 403 * @mesg: target power management message
404 * 404 *
405 * Request suspend EH action on the ATA device associated with 405 * Request suspend EH action on the ATA device associated with
406 * @sdev and wait for the operation to complete. 406 * @sdev and wait for the operation to complete.
@@ -411,7 +411,7 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf)
411 * RETURNS: 411 * RETURNS:
412 * 0 on success, -errno otherwise. 412 * 0 on success, -errno otherwise.
413 */ 413 */
414int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state) 414int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg)
415{ 415{
416 struct ata_port *ap = ata_shost_to_port(sdev->host); 416 struct ata_port *ap = ata_shost_to_port(sdev->host);
417 struct ata_device *dev = ata_scsi_find_dev(ap, sdev); 417 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
@@ -438,7 +438,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
438 438
439 /* request suspend */ 439 /* request suspend */
440 action = ATA_EH_SUSPEND; 440 action = ATA_EH_SUSPEND;
441 if (state.event != PM_EVENT_SUSPEND) 441 if (mesg.event != PM_EVENT_SUSPEND)
442 action |= ATA_EH_PM_FREEZE; 442 action |= ATA_EH_PM_FREEZE;
443 ap->eh_info.dev_action[dev->devno] |= action; 443 ap->eh_info.dev_action[dev->devno] |= action;
444 ap->eh_info.flags |= ATA_EHI_QUIET; 444 ap->eh_info.flags |= ATA_EHI_QUIET;
@@ -463,7 +463,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
463 spin_unlock_irqrestore(ap->lock, flags); 463 spin_unlock_irqrestore(ap->lock, flags);
464 out: 464 out:
465 if (rc == 0) 465 if (rc == 0)
466 sdev->sdev_gendev.power.power_state = state; 466 sdev->sdev_gendev.power.power_state = mesg;
467 return rc; 467 return rc;
468} 468}
469 469
@@ -537,7 +537,7 @@ int ata_scsi_device_resume(struct scsi_device *sdev)
537 * format sense blocks. 537 * format sense blocks.
538 * 538 *
539 * LOCKING: 539 * LOCKING:
540 * spin_lock_irqsave(host_set lock) 540 * spin_lock_irqsave(host lock)
541 */ 541 */
542void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, 542void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
543 u8 *ascq, int verbose) 543 u8 *ascq, int verbose)
@@ -649,7 +649,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
649 * block. Clear sense key, ASC & ASCQ if there is no error. 649 * block. Clear sense key, ASC & ASCQ if there is no error.
650 * 650 *
651 * LOCKING: 651 * LOCKING:
652 * spin_lock_irqsave(host_set lock) 652 * spin_lock_irqsave(host lock)
653 */ 653 */
654void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) 654void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
655{ 655{
@@ -918,7 +918,7 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
918 * [See SAT revision 5 at www.t10.org] 918 * [See SAT revision 5 at www.t10.org]
919 * 919 *
920 * LOCKING: 920 * LOCKING:
921 * spin_lock_irqsave(host_set lock) 921 * spin_lock_irqsave(host lock)
922 * 922 *
923 * RETURNS: 923 * RETURNS:
924 * Zero on success, non-zero on error. 924 * Zero on success, non-zero on error.
@@ -986,7 +986,7 @@ invalid_fld:
986 * FLUSH CACHE EXT. 986 * FLUSH CACHE EXT.
987 * 987 *
988 * LOCKING: 988 * LOCKING:
989 * spin_lock_irqsave(host_set lock) 989 * spin_lock_irqsave(host lock)
990 * 990 *
991 * RETURNS: 991 * RETURNS:
992 * Zero on success, non-zero on error. 992 * Zero on success, non-zero on error.
@@ -1109,7 +1109,7 @@ static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1109 * Converts SCSI VERIFY command to an ATA READ VERIFY command. 1109 * Converts SCSI VERIFY command to an ATA READ VERIFY command.
1110 * 1110 *
1111 * LOCKING: 1111 * LOCKING:
1112 * spin_lock_irqsave(host_set lock) 1112 * spin_lock_irqsave(host lock)
1113 * 1113 *
1114 * RETURNS: 1114 * RETURNS:
1115 * Zero on success, non-zero on error. 1115 * Zero on success, non-zero on error.
@@ -1233,7 +1233,7 @@ nothing_to_do:
1233 * %WRITE_16 are currently supported. 1233 * %WRITE_16 are currently supported.
1234 * 1234 *
1235 * LOCKING: 1235 * LOCKING:
1236 * spin_lock_irqsave(host_set lock) 1236 * spin_lock_irqsave(host lock)
1237 * 1237 *
1238 * RETURNS: 1238 * RETURNS:
1239 * Zero on success, non-zero on error. 1239 * Zero on success, non-zero on error.
@@ -1467,7 +1467,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1467 * issued to @dev. 1467 * issued to @dev.
1468 * 1468 *
1469 * LOCKING: 1469 * LOCKING:
1470 * spin_lock_irqsave(host_set lock) 1470 * spin_lock_irqsave(host lock)
1471 * 1471 *
1472 * RETURNS: 1472 * RETURNS:
1473 * 1 if deferring is needed, 0 otherwise. 1473 * 1 if deferring is needed, 0 otherwise.
@@ -1510,7 +1510,7 @@ static int ata_scmd_need_defer(struct ata_device *dev, int is_io)
1510 * termination. 1510 * termination.
1511 * 1511 *
1512 * LOCKING: 1512 * LOCKING:
1513 * spin_lock_irqsave(host_set lock) 1513 * spin_lock_irqsave(host lock)
1514 * 1514 *
1515 * RETURNS: 1515 * RETURNS:
1516 * 0 on success, SCSI_ML_QUEUE_DEVICE_BUSY if the command 1516 * 0 on success, SCSI_ML_QUEUE_DEVICE_BUSY if the command
@@ -1589,7 +1589,7 @@ defer:
1589 * Maps buffer contained within SCSI command @cmd. 1589 * Maps buffer contained within SCSI command @cmd.
1590 * 1590 *
1591 * LOCKING: 1591 * LOCKING:
1592 * spin_lock_irqsave(host_set lock) 1592 * spin_lock_irqsave(host lock)
1593 * 1593 *
1594 * RETURNS: 1594 * RETURNS:
1595 * Length of response buffer. 1595 * Length of response buffer.
@@ -1623,7 +1623,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out)
1623 * Unmaps response buffer contained within @cmd. 1623 * Unmaps response buffer contained within @cmd.
1624 * 1624 *
1625 * LOCKING: 1625 * LOCKING:
1626 * spin_lock_irqsave(host_set lock) 1626 * spin_lock_irqsave(host lock)
1627 */ 1627 */
1628 1628
1629static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf) 1629static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
@@ -1649,7 +1649,7 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
1649 * and sense buffer are assumed to be set). 1649 * and sense buffer are assumed to be set).
1650 * 1650 *
1651 * LOCKING: 1651 * LOCKING:
1652 * spin_lock_irqsave(host_set lock) 1652 * spin_lock_irqsave(host lock)
1653 */ 1653 */
1654 1654
1655void ata_scsi_rbuf_fill(struct ata_scsi_args *args, 1655void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
@@ -1680,7 +1680,7 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1680 * with non-VPD INQUIRY command output. 1680 * with non-VPD INQUIRY command output.
1681 * 1681 *
1682 * LOCKING: 1682 * LOCKING:
1683 * spin_lock_irqsave(host_set lock) 1683 * spin_lock_irqsave(host lock)
1684 */ 1684 */
1685 1685
1686unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 1686unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
@@ -1736,7 +1736,7 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1736 * Returns list of inquiry VPD pages available. 1736 * Returns list of inquiry VPD pages available.
1737 * 1737 *
1738 * LOCKING: 1738 * LOCKING:
1739 * spin_lock_irqsave(host_set lock) 1739 * spin_lock_irqsave(host lock)
1740 */ 1740 */
1741 1741
1742unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf, 1742unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
@@ -1764,7 +1764,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1764 * Returns ATA device serial number. 1764 * Returns ATA device serial number.
1765 * 1765 *
1766 * LOCKING: 1766 * LOCKING:
1767 * spin_lock_irqsave(host_set lock) 1767 * spin_lock_irqsave(host lock)
1768 */ 1768 */
1769 1769
1770unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, 1770unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
@@ -1797,7 +1797,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1797 * name ("ATA "), model and serial numbers. 1797 * name ("ATA "), model and serial numbers.
1798 * 1798 *
1799 * LOCKING: 1799 * LOCKING:
1800 * spin_lock_irqsave(host_set lock) 1800 * spin_lock_irqsave(host lock)
1801 */ 1801 */
1802 1802
1803unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, 1803unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
@@ -1849,7 +1849,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1849 * that the caller should successfully complete this SCSI command. 1849 * that the caller should successfully complete this SCSI command.
1850 * 1850 *
1851 * LOCKING: 1851 * LOCKING:
1852 * spin_lock_irqsave(host_set lock) 1852 * spin_lock_irqsave(host lock)
1853 */ 1853 */
1854 1854
1855unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf, 1855unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf,
@@ -1990,7 +1990,7 @@ static int ata_dev_supports_fua(u16 *id)
1990 * descriptor for other device types. 1990 * descriptor for other device types.
1991 * 1991 *
1992 * LOCKING: 1992 * LOCKING:
1993 * spin_lock_irqsave(host_set lock) 1993 * spin_lock_irqsave(host lock)
1994 */ 1994 */
1995 1995
1996unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, 1996unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
@@ -2129,7 +2129,7 @@ saving_not_supp:
2129 * Simulate READ CAPACITY commands. 2129 * Simulate READ CAPACITY commands.
2130 * 2130 *
2131 * LOCKING: 2131 * LOCKING:
2132 * spin_lock_irqsave(host_set lock) 2132 * spin_lock_irqsave(host lock)
2133 */ 2133 */
2134 2134
2135unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf, 2135unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
@@ -2204,7 +2204,7 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2204 * Simulate REPORT LUNS command. 2204 * Simulate REPORT LUNS command.
2205 * 2205 *
2206 * LOCKING: 2206 * LOCKING:
2207 * spin_lock_irqsave(host_set lock) 2207 * spin_lock_irqsave(host lock)
2208 */ 2208 */
2209 2209
2210unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf, 2210unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
@@ -2256,7 +2256,7 @@ void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
2256 * and the specified additional sense codes. 2256 * and the specified additional sense codes.
2257 * 2257 *
2258 * LOCKING: 2258 * LOCKING:
2259 * spin_lock_irqsave(host_set lock) 2259 * spin_lock_irqsave(host lock)
2260 */ 2260 */
2261 2261
2262void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq) 2262void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq)
@@ -2421,7 +2421,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2421 * @scsicmd: SCSI CDB associated with this PACKET command 2421 * @scsicmd: SCSI CDB associated with this PACKET command
2422 * 2422 *
2423 * LOCKING: 2423 * LOCKING:
2424 * spin_lock_irqsave(host_set lock) 2424 * spin_lock_irqsave(host lock)
2425 * 2425 *
2426 * RETURNS: 2426 * RETURNS:
2427 * Zero on success, non-zero on failure. 2427 * Zero on success, non-zero on failure.
@@ -2500,7 +2500,7 @@ static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap,
2500 * Determine if commands should be sent to the specified device. 2500 * Determine if commands should be sent to the specified device.
2501 * 2501 *
2502 * LOCKING: 2502 * LOCKING:
2503 * spin_lock_irqsave(host_set lock) 2503 * spin_lock_irqsave(host lock)
2504 * 2504 *
2505 * RETURNS: 2505 * RETURNS:
2506 * 0 if commands are not allowed / 1 if commands are allowed 2506 * 0 if commands are not allowed / 1 if commands are allowed
@@ -2534,7 +2534,7 @@ static int ata_scsi_dev_enabled(struct ata_device *dev)
2534 * SCSI command to be sent. 2534 * SCSI command to be sent.
2535 * 2535 *
2536 * LOCKING: 2536 * LOCKING:
2537 * spin_lock_irqsave(host_set lock) 2537 * spin_lock_irqsave(host lock)
2538 * 2538 *
2539 * RETURNS: 2539 * RETURNS:
2540 * Associated ATA device, or %NULL if not found. 2540 * Associated ATA device, or %NULL if not found.
@@ -2808,7 +2808,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd,
2808 * ATA and ATAPI devices appearing as SCSI devices. 2808 * ATA and ATAPI devices appearing as SCSI devices.
2809 * 2809 *
2810 * LOCKING: 2810 * LOCKING:
2811 * Releases scsi-layer-held lock, and obtains host_set lock. 2811 * Releases scsi-layer-held lock, and obtains host lock.
2812 * 2812 *
2813 * RETURNS: 2813 * RETURNS:
2814 * Return value from __ata_scsi_queuecmd() if @cmd can be queued, 2814 * Return value from __ata_scsi_queuecmd() if @cmd can be queued,
@@ -2852,7 +2852,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
2852 * that can be handled internally. 2852 * that can be handled internally.
2853 * 2853 *
2854 * LOCKING: 2854 * LOCKING:
2855 * spin_lock_irqsave(host_set lock) 2855 * spin_lock_irqsave(host lock)
2856 */ 2856 */
2857 2857
2858void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 2858void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
@@ -2944,7 +2944,7 @@ void ata_scsi_scan_host(struct ata_port *ap)
2944 if (!ata_dev_enabled(dev) || dev->sdev) 2944 if (!ata_dev_enabled(dev) || dev->sdev)
2945 continue; 2945 continue;
2946 2946
2947 sdev = __scsi_add_device(ap->host, 0, i, 0, NULL); 2947 sdev = __scsi_add_device(ap->scsi_host, 0, i, 0, NULL);
2948 if (!IS_ERR(sdev)) { 2948 if (!IS_ERR(sdev)) {
2949 dev->sdev = sdev; 2949 dev->sdev = sdev;
2950 scsi_device_put(sdev); 2950 scsi_device_put(sdev);
@@ -2958,11 +2958,11 @@ void ata_scsi_scan_host(struct ata_port *ap)
2958 * 2958 *
2959 * This function is called from ata_eh_hotplug() and responsible 2959 * This function is called from ata_eh_hotplug() and responsible
2960 * for taking the SCSI device attached to @dev offline. This 2960 * for taking the SCSI device attached to @dev offline. This
2961 * function is called with host_set lock which protects dev->sdev 2961 * function is called with host lock which protects dev->sdev
2962 * against clearing. 2962 * against clearing.
2963 * 2963 *
2964 * LOCKING: 2964 * LOCKING:
2965 * spin_lock_irqsave(host_set lock) 2965 * spin_lock_irqsave(host lock)
2966 * 2966 *
2967 * RETURNS: 2967 * RETURNS:
2968 * 1 if attached SCSI device exists, 0 otherwise. 2968 * 1 if attached SCSI device exists, 0 otherwise.
@@ -2998,16 +2998,16 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
2998 * be removed if there is __scsi_device_get() interface which 2998 * be removed if there is __scsi_device_get() interface which
2999 * increments reference counts regardless of device state. 2999 * increments reference counts regardless of device state.
3000 */ 3000 */
3001 mutex_lock(&ap->host->scan_mutex); 3001 mutex_lock(&ap->scsi_host->scan_mutex);
3002 spin_lock_irqsave(ap->lock, flags); 3002 spin_lock_irqsave(ap->lock, flags);
3003 3003
3004 /* clearing dev->sdev is protected by host_set lock */ 3004 /* clearing dev->sdev is protected by host lock */
3005 sdev = dev->sdev; 3005 sdev = dev->sdev;
3006 dev->sdev = NULL; 3006 dev->sdev = NULL;
3007 3007
3008 if (sdev) { 3008 if (sdev) {
3009 /* If user initiated unplug races with us, sdev can go 3009 /* If user initiated unplug races with us, sdev can go
3010 * away underneath us after the host_set lock and 3010 * away underneath us after the host lock and
3011 * scan_mutex are released. Hold onto it. 3011 * scan_mutex are released. Hold onto it.
3012 */ 3012 */
3013 if (scsi_device_get(sdev) == 0) { 3013 if (scsi_device_get(sdev) == 0) {
@@ -3024,7 +3024,7 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
3024 } 3024 }
3025 3025
3026 spin_unlock_irqrestore(ap->lock, flags); 3026 spin_unlock_irqrestore(ap->lock, flags);
3027 mutex_unlock(&ap->host->scan_mutex); 3027 mutex_unlock(&ap->scsi_host->scan_mutex);
3028 3028
3029 if (sdev) { 3029 if (sdev) {
3030 ata_dev_printk(dev, KERN_INFO, "detaching (SCSI %s)\n", 3030 ata_dev_printk(dev, KERN_INFO, "detaching (SCSI %s)\n",
@@ -3171,3 +3171,152 @@ void ata_scsi_dev_rescan(void *data)
3171 scsi_rescan_device(&(dev->sdev->sdev_gendev)); 3171 scsi_rescan_device(&(dev->sdev->sdev_gendev));
3172 } 3172 }
3173} 3173}
3174
3175/**
3176 * ata_sas_port_alloc - Allocate port for a SAS attached SATA device
3177 * @pdev: PCI device that the scsi device is attached to
3178 * @port_info: Information from low-level host driver
3179 * @shost: SCSI host that the scsi device is attached to
3180 *
3181 * LOCKING:
3182 * PCI/etc. bus probe sem.
3183 *
3184 * RETURNS:
3185 * ata_port pointer on success / NULL on failure.
3186 */
3187
3188struct ata_port *ata_sas_port_alloc(struct ata_host *host,
3189 struct ata_port_info *port_info,
3190 struct Scsi_Host *shost)
3191{
3192 struct ata_port *ap = kzalloc(sizeof(*ap), GFP_KERNEL);
3193 struct ata_probe_ent *ent;
3194
3195 if (!ap)
3196 return NULL;
3197
3198 ent = ata_probe_ent_alloc(host->dev, port_info);
3199 if (!ent) {
3200 kfree(ap);
3201 return NULL;
3202 }
3203
3204 ata_port_init(ap, host, ent, 0);
3205 ap->lock = shost->host_lock;
3206 kfree(ent);
3207 return ap;
3208}
3209EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
3210
3211/**
3212 * ata_sas_port_start - Set port up for dma.
3213 * @ap: Port to initialize
3214 *
3215 * Called just after data structures for each port are
3216 * initialized. Allocates DMA pad.
3217 *
3218 * May be used as the port_start() entry in ata_port_operations.
3219 *
3220 * LOCKING:
3221 * Inherited from caller.
3222 */
3223int ata_sas_port_start(struct ata_port *ap)
3224{
3225 return ata_pad_alloc(ap, ap->dev);
3226}
3227EXPORT_SYMBOL_GPL(ata_sas_port_start);
3228
3229/**
3230 * ata_port_stop - Undo ata_sas_port_start()
3231 * @ap: Port to shut down
3232 *
3233 * Frees the DMA pad.
3234 *
3235 * May be used as the port_stop() entry in ata_port_operations.
3236 *
3237 * LOCKING:
3238 * Inherited from caller.
3239 */
3240
3241void ata_sas_port_stop(struct ata_port *ap)
3242{
3243 ata_pad_free(ap, ap->dev);
3244}
3245EXPORT_SYMBOL_GPL(ata_sas_port_stop);
3246
3247/**
3248 * ata_sas_port_init - Initialize a SATA device
3249 * @ap: SATA port to initialize
3250 *
3251 * LOCKING:
3252 * PCI/etc. bus probe sem.
3253 *
3254 * RETURNS:
3255 * Zero on success, non-zero on error.
3256 */
3257
3258int ata_sas_port_init(struct ata_port *ap)
3259{
3260 int rc = ap->ops->port_start(ap);
3261
3262 if (!rc)
3263 rc = ata_bus_probe(ap);
3264
3265 return rc;
3266}
3267EXPORT_SYMBOL_GPL(ata_sas_port_init);
3268
3269/**
3270 * ata_sas_port_destroy - Destroy a SATA port allocated by ata_sas_port_alloc
3271 * @ap: SATA port to destroy
3272 *
3273 */
3274
3275void ata_sas_port_destroy(struct ata_port *ap)
3276{
3277 ap->ops->port_stop(ap);
3278 kfree(ap);
3279}
3280EXPORT_SYMBOL_GPL(ata_sas_port_destroy);
3281
3282/**
3283 * ata_sas_slave_configure - Default slave_config routine for libata devices
3284 * @sdev: SCSI device to configure
3285 * @ap: ATA port to which SCSI device is attached
3286 *
3287 * RETURNS:
3288 * Zero.
3289 */
3290
3291int ata_sas_slave_configure(struct scsi_device *sdev, struct ata_port *ap)
3292{
3293 ata_scsi_sdev_config(sdev);
3294 ata_scsi_dev_config(sdev, ap->device);
3295 return 0;
3296}
3297EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
3298
3299/**
3300 * ata_sas_queuecmd - Issue SCSI cdb to libata-managed device
3301 * @cmd: SCSI command to be sent
3302 * @done: Completion function, called when command is complete
3303 * @ap: ATA port to which the command is being sent
3304 *
3305 * RETURNS:
3306 * Zero.
3307 */
3308
3309int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3310 struct ata_port *ap)
3311{
3312 ata_scsi_dump_cdb(ap, cmd);
3313
3314 if (likely(ata_scsi_dev_enabled(ap->device)))
3315 __ata_scsi_queuecmd(cmd, done, ap->device);
3316 else {
3317 cmd->result = (DID_BAD_TARGET << 16);
3318 done(cmd);
3319 }
3320 return 0;
3321}
3322EXPORT_SYMBOL_GPL(ata_sas_queuecmd);
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/ata/libata-sff.c
index 9ce221f25954..760502859821 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/ata/libata-sff.c
@@ -193,7 +193,7 @@ void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
193 * synchronization with interrupt handler / other threads. 193 * synchronization with interrupt handler / other threads.
194 * 194 *
195 * LOCKING: 195 * LOCKING:
196 * spin_lock_irqsave(host_set lock) 196 * spin_lock_irqsave(host lock)
197 */ 197 */
198 198
199static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf) 199static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
@@ -216,7 +216,7 @@ static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile
216 * FIXME: missing write posting for 400nS delay enforcement 216 * FIXME: missing write posting for 400nS delay enforcement
217 * 217 *
218 * LOCKING: 218 * LOCKING:
219 * spin_lock_irqsave(host_set lock) 219 * spin_lock_irqsave(host lock)
220 */ 220 */
221 221
222static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 222static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
@@ -237,7 +237,7 @@ static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
237 * synchronization with interrupt handler / other threads. 237 * synchronization with interrupt handler / other threads.
238 * 238 *
239 * LOCKING: 239 * LOCKING:
240 * spin_lock_irqsave(host_set lock) 240 * spin_lock_irqsave(host lock)
241 */ 241 */
242void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) 242void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
243{ 243{
@@ -422,7 +422,7 @@ u8 ata_altstatus(struct ata_port *ap)
422 * @qc: Info associated with this ATA transaction. 422 * @qc: Info associated with this ATA transaction.
423 * 423 *
424 * LOCKING: 424 * LOCKING:
425 * spin_lock_irqsave(host_set lock) 425 * spin_lock_irqsave(host lock)
426 */ 426 */
427 427
428static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc) 428static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
@@ -452,7 +452,7 @@ static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
452 * @qc: Info associated with this ATA transaction. 452 * @qc: Info associated with this ATA transaction.
453 * 453 *
454 * LOCKING: 454 * LOCKING:
455 * spin_lock_irqsave(host_set lock) 455 * spin_lock_irqsave(host lock)
456 */ 456 */
457 457
458static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc) 458static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
@@ -483,7 +483,7 @@ static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
483 * @qc: Info associated with this ATA transaction. 483 * @qc: Info associated with this ATA transaction.
484 * 484 *
485 * LOCKING: 485 * LOCKING:
486 * spin_lock_irqsave(host_set lock) 486 * spin_lock_irqsave(host lock)
487 */ 487 */
488 488
489static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc) 489static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
@@ -511,7 +511,7 @@ static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
511 * @qc: Info associated with this ATA transaction. 511 * @qc: Info associated with this ATA transaction.
512 * 512 *
513 * LOCKING: 513 * LOCKING:
514 * spin_lock_irqsave(host_set lock) 514 * spin_lock_irqsave(host lock)
515 */ 515 */
516 516
517static void ata_bmdma_start_pio (struct ata_queued_cmd *qc) 517static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
@@ -535,7 +535,7 @@ static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
535 * May be used as the bmdma_start() entry in ata_port_operations. 535 * May be used as the bmdma_start() entry in ata_port_operations.
536 * 536 *
537 * LOCKING: 537 * LOCKING:
538 * spin_lock_irqsave(host_set lock) 538 * spin_lock_irqsave(host lock)
539 */ 539 */
540void ata_bmdma_start(struct ata_queued_cmd *qc) 540void ata_bmdma_start(struct ata_queued_cmd *qc)
541{ 541{
@@ -557,7 +557,7 @@ void ata_bmdma_start(struct ata_queued_cmd *qc)
557 * May be used as the bmdma_setup() entry in ata_port_operations. 557 * May be used as the bmdma_setup() entry in ata_port_operations.
558 * 558 *
559 * LOCKING: 559 * LOCKING:
560 * spin_lock_irqsave(host_set lock) 560 * spin_lock_irqsave(host lock)
561 */ 561 */
562void ata_bmdma_setup(struct ata_queued_cmd *qc) 562void ata_bmdma_setup(struct ata_queued_cmd *qc)
563{ 563{
@@ -577,7 +577,7 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
577 * May be used as the irq_clear() entry in ata_port_operations. 577 * May be used as the irq_clear() entry in ata_port_operations.
578 * 578 *
579 * LOCKING: 579 * LOCKING:
580 * spin_lock_irqsave(host_set lock) 580 * spin_lock_irqsave(host lock)
581 */ 581 */
582 582
583void ata_bmdma_irq_clear(struct ata_port *ap) 583void ata_bmdma_irq_clear(struct ata_port *ap)
@@ -605,7 +605,7 @@ void ata_bmdma_irq_clear(struct ata_port *ap)
605 * May be used as the bmdma_status() entry in ata_port_operations. 605 * May be used as the bmdma_status() entry in ata_port_operations.
606 * 606 *
607 * LOCKING: 607 * LOCKING:
608 * spin_lock_irqsave(host_set lock) 608 * spin_lock_irqsave(host lock)
609 */ 609 */
610 610
611u8 ata_bmdma_status(struct ata_port *ap) 611u8 ata_bmdma_status(struct ata_port *ap)
@@ -629,7 +629,7 @@ u8 ata_bmdma_status(struct ata_port *ap)
629 * May be used as the bmdma_stop() entry in ata_port_operations. 629 * May be used as the bmdma_stop() entry in ata_port_operations.
630 * 630 *
631 * LOCKING: 631 * LOCKING:
632 * spin_lock_irqsave(host_set lock) 632 * spin_lock_irqsave(host lock)
633 */ 633 */
634 634
635void ata_bmdma_stop(struct ata_queued_cmd *qc) 635void ata_bmdma_stop(struct ata_queued_cmd *qc)
@@ -797,32 +797,6 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
797} 797}
798 798
799#ifdef CONFIG_PCI 799#ifdef CONFIG_PCI
800static struct ata_probe_ent *
801ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
802{
803 struct ata_probe_ent *probe_ent;
804
805 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
806 if (!probe_ent) {
807 printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
808 kobject_name(&(dev->kobj)));
809 return NULL;
810 }
811
812 INIT_LIST_HEAD(&probe_ent->node);
813 probe_ent->dev = dev;
814
815 probe_ent->sht = port->sht;
816 probe_ent->host_flags = port->host_flags;
817 probe_ent->pio_mask = port->pio_mask;
818 probe_ent->mwdma_mask = port->mwdma_mask;
819 probe_ent->udma_mask = port->udma_mask;
820 probe_ent->port_ops = port->port_ops;
821
822 return probe_ent;
823}
824
825
826/** 800/**
827 * ata_pci_init_native_mode - Initialize native-mode driver 801 * ata_pci_init_native_mode - Initialize native-mode driver
828 * @pdev: pci device to be initialized 802 * @pdev: pci device to be initialized
@@ -864,7 +838,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
864 bmdma = pci_resource_start(pdev, 4); 838 bmdma = pci_resource_start(pdev, 4);
865 if (bmdma) { 839 if (bmdma) {
866 if (inb(bmdma + 2) & 0x80) 840 if (inb(bmdma + 2) & 0x80)
867 probe_ent->host_set_flags |= ATA_HOST_SIMPLEX; 841 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
868 probe_ent->port[p].bmdma_addr = bmdma; 842 probe_ent->port[p].bmdma_addr = bmdma;
869 } 843 }
870 ata_std_ports(&probe_ent->port[p]); 844 ata_std_ports(&probe_ent->port[p]);
@@ -880,7 +854,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
880 if (bmdma) { 854 if (bmdma) {
881 bmdma += 8; 855 bmdma += 8;
882 if(inb(bmdma + 2) & 0x80) 856 if(inb(bmdma + 2) & 0x80)
883 probe_ent->host_set_flags |= ATA_HOST_SIMPLEX; 857 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
884 probe_ent->port[p].bmdma_addr = bmdma; 858 probe_ent->port[p].bmdma_addr = bmdma;
885 } 859 }
886 ata_std_ports(&probe_ent->port[p]); 860 ata_std_ports(&probe_ent->port[p]);
@@ -893,44 +867,48 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
893 867
894 868
895static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, 869static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
896 struct ata_port_info *port, int port_num) 870 struct ata_port_info **port, int port_mask)
897{ 871{
898 struct ata_probe_ent *probe_ent; 872 struct ata_probe_ent *probe_ent;
899 unsigned long bmdma; 873 unsigned long bmdma = pci_resource_start(pdev, 4);
900 874
901 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port); 875 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
902 if (!probe_ent) 876 if (!probe_ent)
903 return NULL; 877 return NULL;
904 878
905 probe_ent->legacy_mode = 1; 879 probe_ent->n_ports = 2;
906 probe_ent->n_ports = 1; 880 probe_ent->private_data = port[0]->private_data;
907 probe_ent->hard_port_no = port_num;
908 probe_ent->private_data = port->private_data;
909
910 switch(port_num)
911 {
912 case 0:
913 probe_ent->irq = 14;
914 probe_ent->port[0].cmd_addr = 0x1f0;
915 probe_ent->port[0].altstatus_addr =
916 probe_ent->port[0].ctl_addr = 0x3f6;
917 break;
918 case 1:
919 probe_ent->irq = 15;
920 probe_ent->port[0].cmd_addr = 0x170;
921 probe_ent->port[0].altstatus_addr =
922 probe_ent->port[0].ctl_addr = 0x376;
923 break;
924 }
925 881
926 bmdma = pci_resource_start(pdev, 4); 882 if (port_mask & ATA_PORT_PRIMARY) {
927 if (bmdma != 0) { 883 probe_ent->irq = 14;
928 bmdma += 8 * port_num; 884 probe_ent->port[0].cmd_addr = ATA_PRIMARY_CMD;
929 probe_ent->port[0].bmdma_addr = bmdma; 885 probe_ent->port[0].altstatus_addr =
930 if (inb(bmdma + 2) & 0x80) 886 probe_ent->port[0].ctl_addr = ATA_PRIMARY_CTL;
931 probe_ent->host_set_flags |= ATA_HOST_SIMPLEX; 887 if (bmdma) {
932 } 888 probe_ent->port[0].bmdma_addr = bmdma;
933 ata_std_ports(&probe_ent->port[0]); 889 if (inb(bmdma + 2) & 0x80)
890 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
891 }
892 ata_std_ports(&probe_ent->port[0]);
893 } else
894 probe_ent->dummy_port_mask |= ATA_PORT_PRIMARY;
895
896 if (port_mask & ATA_PORT_SECONDARY) {
897 if (probe_ent->irq)
898 probe_ent->irq2 = 15;
899 else
900 probe_ent->irq = 15;
901 probe_ent->port[1].cmd_addr = ATA_SECONDARY_CMD;
902 probe_ent->port[1].altstatus_addr =
903 probe_ent->port[1].ctl_addr = ATA_SECONDARY_CTL;
904 if (bmdma) {
905 probe_ent->port[1].bmdma_addr = bmdma + 8;
906 if (inb(bmdma + 10) & 0x80)
907 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
908 }
909 ata_std_ports(&probe_ent->port[1]);
910 } else
911 probe_ent->dummy_port_mask |= ATA_PORT_SECONDARY;
934 912
935 return probe_ent; 913 return probe_ent;
936} 914}
@@ -950,6 +928,10 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
950 * regions, sets the dma mask, enables bus master mode, and calls 928 * regions, sets the dma mask, enables bus master mode, and calls
951 * ata_device_add() 929 * ata_device_add()
952 * 930 *
931 * ASSUMPTION:
932 * Nobody makes a single channel controller that appears solely as
933 * the secondary legacy port on PCI.
934 *
953 * LOCKING: 935 * LOCKING:
954 * Inherited from PCI layer (may sleep). 936 * Inherited from PCI layer (may sleep).
955 * 937 *
@@ -960,7 +942,7 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
960int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 942int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
961 unsigned int n_ports) 943 unsigned int n_ports)
962{ 944{
963 struct ata_probe_ent *probe_ent = NULL, *probe_ent2 = NULL; 945 struct ata_probe_ent *probe_ent = NULL;
964 struct ata_port_info *port[2]; 946 struct ata_port_info *port[2];
965 u8 tmp8, mask; 947 u8 tmp8, mask;
966 unsigned int legacy_mode = 0; 948 unsigned int legacy_mode = 0;
@@ -975,7 +957,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
975 else 957 else
976 port[1] = port[0]; 958 port[1] = port[0];
977 959
978 if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0 960 if ((port[0]->flags & ATA_FLAG_NO_LEGACY) == 0
979 && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { 961 && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
980 /* TODO: What if one channel is in native mode ... */ 962 /* TODO: What if one channel is in native mode ... */
981 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); 963 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
@@ -1009,35 +991,34 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1009 goto err_out; 991 goto err_out;
1010 } 992 }
1011 993
1012 /* FIXME: Should use platform specific mappers for legacy port ranges */
1013 if (legacy_mode) { 994 if (legacy_mode) {
1014 if (!request_region(0x1f0, 8, "libata")) { 995 if (!request_region(ATA_PRIMARY_CMD, 8, "libata")) {
1015 struct resource *conflict, res; 996 struct resource *conflict, res;
1016 res.start = 0x1f0; 997 res.start = ATA_PRIMARY_CMD;
1017 res.end = 0x1f0 + 8 - 1; 998 res.end = ATA_PRIMARY_CMD + 8 - 1;
1018 conflict = ____request_resource(&ioport_resource, &res); 999 conflict = ____request_resource(&ioport_resource, &res);
1019 if (!strcmp(conflict->name, "libata")) 1000 if (!strcmp(conflict->name, "libata"))
1020 legacy_mode |= (1 << 0); 1001 legacy_mode |= ATA_PORT_PRIMARY;
1021 else { 1002 else {
1022 disable_dev_on_err = 0; 1003 disable_dev_on_err = 0;
1023 printk(KERN_WARNING "ata: 0x1f0 IDE port busy\n"); 1004 printk(KERN_WARNING "ata: 0x%0X IDE port busy\n", ATA_PRIMARY_CMD);
1024 } 1005 }
1025 } else 1006 } else
1026 legacy_mode |= (1 << 0); 1007 legacy_mode |= ATA_PORT_PRIMARY;
1027 1008
1028 if (!request_region(0x170, 8, "libata")) { 1009 if (!request_region(ATA_SECONDARY_CMD, 8, "libata")) {
1029 struct resource *conflict, res; 1010 struct resource *conflict, res;
1030 res.start = 0x170; 1011 res.start = ATA_SECONDARY_CMD;
1031 res.end = 0x170 + 8 - 1; 1012 res.end = ATA_SECONDARY_CMD + 8 - 1;
1032 conflict = ____request_resource(&ioport_resource, &res); 1013 conflict = ____request_resource(&ioport_resource, &res);
1033 if (!strcmp(conflict->name, "libata")) 1014 if (!strcmp(conflict->name, "libata"))
1034 legacy_mode |= (1 << 1); 1015 legacy_mode |= ATA_PORT_SECONDARY;
1035 else { 1016 else {
1036 disable_dev_on_err = 0; 1017 disable_dev_on_err = 0;
1037 printk(KERN_WARNING "ata: 0x170 IDE port busy\n"); 1018 printk(KERN_WARNING "ata: 0x%X IDE port busy\n", ATA_SECONDARY_CMD);
1038 } 1019 }
1039 } else 1020 } else
1040 legacy_mode |= (1 << 1); 1021 legacy_mode |= ATA_PORT_SECONDARY;
1041 } 1022 }
1042 1023
1043 /* we have legacy mode, but all ports are unavailable */ 1024 /* we have legacy mode, but all ports are unavailable */
@@ -1055,17 +1036,14 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1055 goto err_out_regions; 1036 goto err_out_regions;
1056 1037
1057 if (legacy_mode) { 1038 if (legacy_mode) {
1058 if (legacy_mode & (1 << 0)) 1039 probe_ent = ata_pci_init_legacy_port(pdev, port, legacy_mode);
1059 probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0);
1060 if (legacy_mode & (1 << 1))
1061 probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1);
1062 } else { 1040 } else {
1063 if (n_ports == 2) 1041 if (n_ports == 2)
1064 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 1042 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
1065 else 1043 else
1066 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY); 1044 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY);
1067 } 1045 }
1068 if (!probe_ent && !probe_ent2) { 1046 if (!probe_ent) {
1069 rc = -ENOMEM; 1047 rc = -ENOMEM;
1070 goto err_out_regions; 1048 goto err_out_regions;
1071 } 1049 }
@@ -1073,35 +1051,17 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1073 pci_set_master(pdev); 1051 pci_set_master(pdev);
1074 1052
1075 /* FIXME: check ata_device_add return */ 1053 /* FIXME: check ata_device_add return */
1076 if (legacy_mode) { 1054 ata_device_add(probe_ent);
1077 struct device *dev = &pdev->dev;
1078 struct ata_host_set *host_set = NULL;
1079
1080 if (legacy_mode & (1 << 0)) {
1081 ata_device_add(probe_ent);
1082 host_set = dev_get_drvdata(dev);
1083 }
1084
1085 if (legacy_mode & (1 << 1)) {
1086 ata_device_add(probe_ent2);
1087 if (host_set) {
1088 host_set->next = dev_get_drvdata(dev);
1089 dev_set_drvdata(dev, host_set);
1090 }
1091 }
1092 } else
1093 ata_device_add(probe_ent);
1094 1055
1095 kfree(probe_ent); 1056 kfree(probe_ent);
1096 kfree(probe_ent2);
1097 1057
1098 return 0; 1058 return 0;
1099 1059
1100err_out_regions: 1060err_out_regions:
1101 if (legacy_mode & (1 << 0)) 1061 if (legacy_mode & ATA_PORT_PRIMARY)
1102 release_region(0x1f0, 8); 1062 release_region(ATA_PRIMARY_CMD, 8);
1103 if (legacy_mode & (1 << 1)) 1063 if (legacy_mode & ATA_PORT_SECONDARY)
1104 release_region(0x170, 8); 1064 release_region(ATA_SECONDARY_CMD, 8);
1105 pci_release_regions(pdev); 1065 pci_release_regions(pdev);
1106err_out: 1066err_out:
1107 if (disable_dev_on_err) 1067 if (disable_dev_on_err)
diff --git a/drivers/scsi/libata.h b/drivers/ata/libata.h
index c325679d9b54..a5ecb71390a9 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/ata/libata.h
@@ -69,6 +69,10 @@ extern int ata_flush_cache(struct ata_device *dev);
69extern void ata_dev_init(struct ata_device *dev); 69extern void ata_dev_init(struct ata_device *dev);
70extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); 70extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
71extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); 71extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
72extern void ata_port_init(struct ata_port *ap, struct ata_host *host,
73 const struct ata_probe_ent *ent, unsigned int port_no);
74extern struct ata_probe_ent *ata_probe_ent_alloc(struct device *dev,
75 const struct ata_port_info *port);
72 76
73 77
74/* libata-scsi.c */ 78/* libata-scsi.c */
@@ -107,6 +111,7 @@ extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
107 u8 *rbuf, unsigned int buflen)); 111 u8 *rbuf, unsigned int buflen));
108extern void ata_schedule_scsi_eh(struct Scsi_Host *shost); 112extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
109extern void ata_scsi_dev_rescan(void *data); 113extern void ata_scsi_dev_rescan(void *data);
114extern int ata_bus_probe(struct ata_port *ap);
110 115
111/* libata-eh.c */ 116/* libata-eh.c */
112extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); 117extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
diff --git a/drivers/scsi/pdc_adma.c b/drivers/ata/pdc_adma.c
index efc8fff1d250..912211ada816 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -127,7 +127,7 @@ static int adma_ata_init_one (struct pci_dev *pdev,
127static irqreturn_t adma_intr (int irq, void *dev_instance, 127static irqreturn_t adma_intr (int irq, void *dev_instance,
128 struct pt_regs *regs); 128 struct pt_regs *regs);
129static int adma_port_start(struct ata_port *ap); 129static int adma_port_start(struct ata_port *ap);
130static void adma_host_stop(struct ata_host_set *host_set); 130static void adma_host_stop(struct ata_host *host);
131static void adma_port_stop(struct ata_port *ap); 131static void adma_port_stop(struct ata_port *ap);
132static void adma_phy_reset(struct ata_port *ap); 132static void adma_phy_reset(struct ata_port *ap);
133static void adma_qc_prep(struct ata_queued_cmd *qc); 133static void adma_qc_prep(struct ata_queued_cmd *qc);
@@ -182,7 +182,7 @@ static struct ata_port_info adma_port_info[] = {
182 /* board_1841_idx */ 182 /* board_1841_idx */
183 { 183 {
184 .sht = &adma_ata_sht, 184 .sht = &adma_ata_sht,
185 .host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | 185 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST |
186 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO | 186 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO |
187 ATA_FLAG_PIO_POLLING, 187 ATA_FLAG_PIO_POLLING,
188 .pio_mask = 0x10, /* pio4 */ 188 .pio_mask = 0x10, /* pio4 */
@@ -237,7 +237,7 @@ static void adma_reset_engine(void __iomem *chan)
237static void adma_reinit_engine(struct ata_port *ap) 237static void adma_reinit_engine(struct ata_port *ap)
238{ 238{
239 struct adma_port_priv *pp = ap->private_data; 239 struct adma_port_priv *pp = ap->private_data;
240 void __iomem *mmio_base = ap->host_set->mmio_base; 240 void __iomem *mmio_base = ap->host->mmio_base;
241 void __iomem *chan = ADMA_REGS(mmio_base, ap->port_no); 241 void __iomem *chan = ADMA_REGS(mmio_base, ap->port_no);
242 242
243 /* mask/clear ATA interrupts */ 243 /* mask/clear ATA interrupts */
@@ -265,7 +265,7 @@ static void adma_reinit_engine(struct ata_port *ap)
265 265
266static inline void adma_enter_reg_mode(struct ata_port *ap) 266static inline void adma_enter_reg_mode(struct ata_port *ap)
267{ 267{
268 void __iomem *chan = ADMA_REGS(ap->host_set->mmio_base, ap->port_no); 268 void __iomem *chan = ADMA_REGS(ap->host->mmio_base, ap->port_no);
269 269
270 writew(aPIOMD4, chan + ADMA_CONTROL); 270 writew(aPIOMD4, chan + ADMA_CONTROL);
271 readb(chan + ADMA_STATUS); /* flush */ 271 readb(chan + ADMA_STATUS); /* flush */
@@ -412,7 +412,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc)
412static inline void adma_packet_start(struct ata_queued_cmd *qc) 412static inline void adma_packet_start(struct ata_queued_cmd *qc)
413{ 413{
414 struct ata_port *ap = qc->ap; 414 struct ata_port *ap = qc->ap;
415 void __iomem *chan = ADMA_REGS(ap->host_set->mmio_base, ap->port_no); 415 void __iomem *chan = ADMA_REGS(ap->host->mmio_base, ap->port_no);
416 416
417 VPRINTK("ENTER, ap %p\n", ap); 417 VPRINTK("ENTER, ap %p\n", ap);
418 418
@@ -442,13 +442,13 @@ static unsigned int adma_qc_issue(struct ata_queued_cmd *qc)
442 return ata_qc_issue_prot(qc); 442 return ata_qc_issue_prot(qc);
443} 443}
444 444
445static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) 445static inline unsigned int adma_intr_pkt(struct ata_host *host)
446{ 446{
447 unsigned int handled = 0, port_no; 447 unsigned int handled = 0, port_no;
448 u8 __iomem *mmio_base = host_set->mmio_base; 448 u8 __iomem *mmio_base = host->mmio_base;
449 449
450 for (port_no = 0; port_no < host_set->n_ports; ++port_no) { 450 for (port_no = 0; port_no < host->n_ports; ++port_no) {
451 struct ata_port *ap = host_set->ports[port_no]; 451 struct ata_port *ap = host->ports[port_no];
452 struct adma_port_priv *pp; 452 struct adma_port_priv *pp;
453 struct ata_queued_cmd *qc; 453 struct ata_queued_cmd *qc;
454 void __iomem *chan = ADMA_REGS(mmio_base, port_no); 454 void __iomem *chan = ADMA_REGS(mmio_base, port_no);
@@ -476,13 +476,13 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
476 return handled; 476 return handled;
477} 477}
478 478
479static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) 479static inline unsigned int adma_intr_mmio(struct ata_host *host)
480{ 480{
481 unsigned int handled = 0, port_no; 481 unsigned int handled = 0, port_no;
482 482
483 for (port_no = 0; port_no < host_set->n_ports; ++port_no) { 483 for (port_no = 0; port_no < host->n_ports; ++port_no) {
484 struct ata_port *ap; 484 struct ata_port *ap;
485 ap = host_set->ports[port_no]; 485 ap = host->ports[port_no];
486 if (ap && (!(ap->flags & ATA_FLAG_DISABLED))) { 486 if (ap && (!(ap->flags & ATA_FLAG_DISABLED))) {
487 struct ata_queued_cmd *qc; 487 struct ata_queued_cmd *qc;
488 struct adma_port_priv *pp = ap->private_data; 488 struct adma_port_priv *pp = ap->private_data;
@@ -511,14 +511,14 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
511 511
512static irqreturn_t adma_intr(int irq, void *dev_instance, struct pt_regs *regs) 512static irqreturn_t adma_intr(int irq, void *dev_instance, struct pt_regs *regs)
513{ 513{
514 struct ata_host_set *host_set = dev_instance; 514 struct ata_host *host = dev_instance;
515 unsigned int handled = 0; 515 unsigned int handled = 0;
516 516
517 VPRINTK("ENTER\n"); 517 VPRINTK("ENTER\n");
518 518
519 spin_lock(&host_set->lock); 519 spin_lock(&host->lock);
520 handled = adma_intr_pkt(host_set) | adma_intr_mmio(host_set); 520 handled = adma_intr_pkt(host) | adma_intr_mmio(host);
521 spin_unlock(&host_set->lock); 521 spin_unlock(&host->lock);
522 522
523 VPRINTK("EXIT\n"); 523 VPRINTK("EXIT\n");
524 524
@@ -544,7 +544,7 @@ static void adma_ata_setup_port(struct ata_ioports *port, unsigned long base)
544 544
545static int adma_port_start(struct ata_port *ap) 545static int adma_port_start(struct ata_port *ap)
546{ 546{
547 struct device *dev = ap->host_set->dev; 547 struct device *dev = ap->host->dev;
548 struct adma_port_priv *pp; 548 struct adma_port_priv *pp;
549 int rc; 549 int rc;
550 550
@@ -582,10 +582,10 @@ err_out:
582 582
583static void adma_port_stop(struct ata_port *ap) 583static void adma_port_stop(struct ata_port *ap)
584{ 584{
585 struct device *dev = ap->host_set->dev; 585 struct device *dev = ap->host->dev;
586 struct adma_port_priv *pp = ap->private_data; 586 struct adma_port_priv *pp = ap->private_data;
587 587
588 adma_reset_engine(ADMA_REGS(ap->host_set->mmio_base, ap->port_no)); 588 adma_reset_engine(ADMA_REGS(ap->host->mmio_base, ap->port_no));
589 if (pp != NULL) { 589 if (pp != NULL) {
590 ap->private_data = NULL; 590 ap->private_data = NULL;
591 if (pp->pkt != NULL) 591 if (pp->pkt != NULL)
@@ -596,14 +596,14 @@ static void adma_port_stop(struct ata_port *ap)
596 ata_port_stop(ap); 596 ata_port_stop(ap);
597} 597}
598 598
599static void adma_host_stop(struct ata_host_set *host_set) 599static void adma_host_stop(struct ata_host *host)
600{ 600{
601 unsigned int port_no; 601 unsigned int port_no;
602 602
603 for (port_no = 0; port_no < ADMA_PORTS; ++port_no) 603 for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
604 adma_reset_engine(ADMA_REGS(host_set->mmio_base, port_no)); 604 adma_reset_engine(ADMA_REGS(host->mmio_base, port_no));
605 605
606 ata_pci_host_stop(host_set); 606 ata_pci_host_stop(host);
607} 607}
608 608
609static void adma_host_init(unsigned int chip_id, 609static void adma_host_init(unsigned int chip_id,
@@ -684,7 +684,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
684 INIT_LIST_HEAD(&probe_ent->node); 684 INIT_LIST_HEAD(&probe_ent->node);
685 685
686 probe_ent->sht = adma_port_info[board_idx].sht; 686 probe_ent->sht = adma_port_info[board_idx].sht;
687 probe_ent->host_flags = adma_port_info[board_idx].host_flags; 687 probe_ent->port_flags = adma_port_info[board_idx].flags;
688 probe_ent->pio_mask = adma_port_info[board_idx].pio_mask; 688 probe_ent->pio_mask = adma_port_info[board_idx].pio_mask;
689 probe_ent->mwdma_mask = adma_port_info[board_idx].mwdma_mask; 689 probe_ent->mwdma_mask = adma_port_info[board_idx].mwdma_mask;
690 probe_ent->udma_mask = adma_port_info[board_idx].udma_mask; 690 probe_ent->udma_mask = adma_port_info[board_idx].udma_mask;
@@ -722,7 +722,7 @@ err_out:
722 722
723static int __init adma_ata_init(void) 723static int __init adma_ata_init(void)
724{ 724{
725 return pci_module_init(&adma_ata_pci_driver); 725 return pci_register_driver(&adma_ata_pci_driver);
726} 726}
727 727
728static void __exit adma_ata_exit(void) 728static void __exit adma_ata_exit(void)
diff --git a/drivers/scsi/sata_mv.c b/drivers/ata/sata_mv.c
index 1053c7c76b7d..34f1939b44c9 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -342,7 +342,7 @@ static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
342static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 342static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
343static void mv_phy_reset(struct ata_port *ap); 343static void mv_phy_reset(struct ata_port *ap);
344static void __mv_phy_reset(struct ata_port *ap, int can_sleep); 344static void __mv_phy_reset(struct ata_port *ap, int can_sleep);
345static void mv_host_stop(struct ata_host_set *host_set); 345static void mv_host_stop(struct ata_host *host);
346static int mv_port_start(struct ata_port *ap); 346static int mv_port_start(struct ata_port *ap);
347static void mv_port_stop(struct ata_port *ap); 347static void mv_port_stop(struct ata_port *ap);
348static void mv_qc_prep(struct ata_queued_cmd *qc); 348static void mv_qc_prep(struct ata_queued_cmd *qc);
@@ -480,35 +480,35 @@ static const struct ata_port_operations mv_iie_ops = {
480static const struct ata_port_info mv_port_info[] = { 480static const struct ata_port_info mv_port_info[] = {
481 { /* chip_504x */ 481 { /* chip_504x */
482 .sht = &mv_sht, 482 .sht = &mv_sht,
483 .host_flags = MV_COMMON_FLAGS, 483 .flags = MV_COMMON_FLAGS,
484 .pio_mask = 0x1f, /* pio0-4 */ 484 .pio_mask = 0x1f, /* pio0-4 */
485 .udma_mask = 0x7f, /* udma0-6 */ 485 .udma_mask = 0x7f, /* udma0-6 */
486 .port_ops = &mv5_ops, 486 .port_ops = &mv5_ops,
487 }, 487 },
488 { /* chip_508x */ 488 { /* chip_508x */
489 .sht = &mv_sht, 489 .sht = &mv_sht,
490 .host_flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC), 490 .flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
491 .pio_mask = 0x1f, /* pio0-4 */ 491 .pio_mask = 0x1f, /* pio0-4 */
492 .udma_mask = 0x7f, /* udma0-6 */ 492 .udma_mask = 0x7f, /* udma0-6 */
493 .port_ops = &mv5_ops, 493 .port_ops = &mv5_ops,
494 }, 494 },
495 { /* chip_5080 */ 495 { /* chip_5080 */
496 .sht = &mv_sht, 496 .sht = &mv_sht,
497 .host_flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC), 497 .flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
498 .pio_mask = 0x1f, /* pio0-4 */ 498 .pio_mask = 0x1f, /* pio0-4 */
499 .udma_mask = 0x7f, /* udma0-6 */ 499 .udma_mask = 0x7f, /* udma0-6 */
500 .port_ops = &mv5_ops, 500 .port_ops = &mv5_ops,
501 }, 501 },
502 { /* chip_604x */ 502 { /* chip_604x */
503 .sht = &mv_sht, 503 .sht = &mv_sht,
504 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS), 504 .flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
505 .pio_mask = 0x1f, /* pio0-4 */ 505 .pio_mask = 0x1f, /* pio0-4 */
506 .udma_mask = 0x7f, /* udma0-6 */ 506 .udma_mask = 0x7f, /* udma0-6 */
507 .port_ops = &mv6_ops, 507 .port_ops = &mv6_ops,
508 }, 508 },
509 { /* chip_608x */ 509 { /* chip_608x */
510 .sht = &mv_sht, 510 .sht = &mv_sht,
511 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS | 511 .flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS |
512 MV_FLAG_DUAL_HC), 512 MV_FLAG_DUAL_HC),
513 .pio_mask = 0x1f, /* pio0-4 */ 513 .pio_mask = 0x1f, /* pio0-4 */
514 .udma_mask = 0x7f, /* udma0-6 */ 514 .udma_mask = 0x7f, /* udma0-6 */
@@ -516,14 +516,14 @@ static const struct ata_port_info mv_port_info[] = {
516 }, 516 },
517 { /* chip_6042 */ 517 { /* chip_6042 */
518 .sht = &mv_sht, 518 .sht = &mv_sht,
519 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS), 519 .flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
520 .pio_mask = 0x1f, /* pio0-4 */ 520 .pio_mask = 0x1f, /* pio0-4 */
521 .udma_mask = 0x7f, /* udma0-6 */ 521 .udma_mask = 0x7f, /* udma0-6 */
522 .port_ops = &mv_iie_ops, 522 .port_ops = &mv_iie_ops,
523 }, 523 },
524 { /* chip_7042 */ 524 { /* chip_7042 */
525 .sht = &mv_sht, 525 .sht = &mv_sht,
526 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS | 526 .flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS |
527 MV_FLAG_DUAL_HC), 527 MV_FLAG_DUAL_HC),
528 .pio_mask = 0x1f, /* pio0-4 */ 528 .pio_mask = 0x1f, /* pio0-4 */
529 .udma_mask = 0x7f, /* udma0-6 */ 529 .udma_mask = 0x7f, /* udma0-6 */
@@ -618,12 +618,12 @@ static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port)
618 618
619static inline void __iomem *mv_ap_base(struct ata_port *ap) 619static inline void __iomem *mv_ap_base(struct ata_port *ap)
620{ 620{
621 return mv_port_base(ap->host_set->mmio_base, ap->port_no); 621 return mv_port_base(ap->host->mmio_base, ap->port_no);
622} 622}
623 623
624static inline int mv_get_hc_count(unsigned long host_flags) 624static inline int mv_get_hc_count(unsigned long port_flags)
625{ 625{
626 return ((host_flags & MV_FLAG_DUAL_HC) ? 2 : 1); 626 return ((port_flags & MV_FLAG_DUAL_HC) ? 2 : 1);
627} 627}
628 628
629static void mv_irq_clear(struct ata_port *ap) 629static void mv_irq_clear(struct ata_port *ap)
@@ -809,7 +809,7 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
809 809
810/** 810/**
811 * mv_host_stop - Host specific cleanup/stop routine. 811 * mv_host_stop - Host specific cleanup/stop routine.
812 * @host_set: host data structure 812 * @host: host data structure
813 * 813 *
814 * Disable ints, cleanup host memory, call general purpose 814 * Disable ints, cleanup host memory, call general purpose
815 * host_stop. 815 * host_stop.
@@ -817,10 +817,10 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
817 * LOCKING: 817 * LOCKING:
818 * Inherited from caller. 818 * Inherited from caller.
819 */ 819 */
820static void mv_host_stop(struct ata_host_set *host_set) 820static void mv_host_stop(struct ata_host *host)
821{ 821{
822 struct mv_host_priv *hpriv = host_set->private_data; 822 struct mv_host_priv *hpriv = host->private_data;
823 struct pci_dev *pdev = to_pci_dev(host_set->dev); 823 struct pci_dev *pdev = to_pci_dev(host->dev);
824 824
825 if (hpriv->hp_flags & MV_HP_FLAG_MSI) { 825 if (hpriv->hp_flags & MV_HP_FLAG_MSI) {
826 pci_disable_msi(pdev); 826 pci_disable_msi(pdev);
@@ -828,7 +828,7 @@ static void mv_host_stop(struct ata_host_set *host_set)
828 pci_intx(pdev, 0); 828 pci_intx(pdev, 0);
829 } 829 }
830 kfree(hpriv); 830 kfree(hpriv);
831 ata_host_stop(host_set); 831 ata_host_stop(host);
832} 832}
833 833
834static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) 834static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev)
@@ -875,8 +875,8 @@ static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio)
875 */ 875 */
876static int mv_port_start(struct ata_port *ap) 876static int mv_port_start(struct ata_port *ap)
877{ 877{
878 struct device *dev = ap->host_set->dev; 878 struct device *dev = ap->host->dev;
879 struct mv_host_priv *hpriv = ap->host_set->private_data; 879 struct mv_host_priv *hpriv = ap->host->private_data;
880 struct mv_port_priv *pp; 880 struct mv_port_priv *pp;
881 void __iomem *port_mmio = mv_ap_base(ap); 881 void __iomem *port_mmio = mv_ap_base(ap);
882 void *mem; 882 void *mem;
@@ -965,17 +965,17 @@ err_out:
965 * Stop DMA, cleanup port memory. 965 * Stop DMA, cleanup port memory.
966 * 966 *
967 * LOCKING: 967 * LOCKING:
968 * This routine uses the host_set lock to protect the DMA stop. 968 * This routine uses the host lock to protect the DMA stop.
969 */ 969 */
970static void mv_port_stop(struct ata_port *ap) 970static void mv_port_stop(struct ata_port *ap)
971{ 971{
972 struct device *dev = ap->host_set->dev; 972 struct device *dev = ap->host->dev;
973 struct mv_port_priv *pp = ap->private_data; 973 struct mv_port_priv *pp = ap->private_data;
974 unsigned long flags; 974 unsigned long flags;
975 975
976 spin_lock_irqsave(&ap->host_set->lock, flags); 976 spin_lock_irqsave(&ap->host->lock, flags);
977 mv_stop_dma(ap); 977 mv_stop_dma(ap);
978 spin_unlock_irqrestore(&ap->host_set->lock, flags); 978 spin_unlock_irqrestore(&ap->host->lock, flags);
979 979
980 ap->private_data = NULL; 980 ap->private_data = NULL;
981 ata_pad_free(ap, dev); 981 ata_pad_free(ap, dev);
@@ -1330,7 +1330,7 @@ static void mv_err_intr(struct ata_port *ap, int reset_allowed)
1330 1330
1331/** 1331/**
1332 * mv_host_intr - Handle all interrupts on the given host controller 1332 * mv_host_intr - Handle all interrupts on the given host controller
1333 * @host_set: host specific structure 1333 * @host: host specific structure
1334 * @relevant: port error bits relevant to this host controller 1334 * @relevant: port error bits relevant to this host controller
1335 * @hc: which host controller we're to look at 1335 * @hc: which host controller we're to look at
1336 * 1336 *
@@ -1344,10 +1344,9 @@ static void mv_err_intr(struct ata_port *ap, int reset_allowed)
1344 * LOCKING: 1344 * LOCKING:
1345 * Inherited from caller. 1345 * Inherited from caller.
1346 */ 1346 */
1347static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, 1347static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
1348 unsigned int hc)
1349{ 1348{
1350 void __iomem *mmio = host_set->mmio_base; 1349 void __iomem *mmio = host->mmio_base;
1351 void __iomem *hc_mmio = mv_hc_base(mmio, hc); 1350 void __iomem *hc_mmio = mv_hc_base(mmio, hc);
1352 struct ata_queued_cmd *qc; 1351 struct ata_queued_cmd *qc;
1353 u32 hc_irq_cause; 1352 u32 hc_irq_cause;
@@ -1371,7 +1370,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1371 1370
1372 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { 1371 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) {
1373 u8 ata_status = 0; 1372 u8 ata_status = 0;
1374 struct ata_port *ap = host_set->ports[port]; 1373 struct ata_port *ap = host->ports[port];
1375 struct mv_port_priv *pp = ap->private_data; 1374 struct mv_port_priv *pp = ap->private_data;
1376 1375
1377 hard_port = mv_hardport_from_port(port); /* range 0..3 */ 1376 hard_port = mv_hardport_from_port(port); /* range 0..3 */
@@ -1444,15 +1443,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1444 * reported here. 1443 * reported here.
1445 * 1444 *
1446 * LOCKING: 1445 * LOCKING:
1447 * This routine holds the host_set lock while processing pending 1446 * This routine holds the host lock while processing pending
1448 * interrupts. 1447 * interrupts.
1449 */ 1448 */
1450static irqreturn_t mv_interrupt(int irq, void *dev_instance, 1449static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1451 struct pt_regs *regs) 1450 struct pt_regs *regs)
1452{ 1451{
1453 struct ata_host_set *host_set = dev_instance; 1452 struct ata_host *host = dev_instance;
1454 unsigned int hc, handled = 0, n_hcs; 1453 unsigned int hc, handled = 0, n_hcs;
1455 void __iomem *mmio = host_set->mmio_base; 1454 void __iomem *mmio = host->mmio_base;
1456 struct mv_host_priv *hpriv; 1455 struct mv_host_priv *hpriv;
1457 u32 irq_stat; 1456 u32 irq_stat;
1458 1457
@@ -1465,18 +1464,18 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1465 return IRQ_NONE; 1464 return IRQ_NONE;
1466 } 1465 }
1467 1466
1468 n_hcs = mv_get_hc_count(host_set->ports[0]->flags); 1467 n_hcs = mv_get_hc_count(host->ports[0]->flags);
1469 spin_lock(&host_set->lock); 1468 spin_lock(&host->lock);
1470 1469
1471 for (hc = 0; hc < n_hcs; hc++) { 1470 for (hc = 0; hc < n_hcs; hc++) {
1472 u32 relevant = irq_stat & (HC0_IRQ_PEND << (hc * HC_SHIFT)); 1471 u32 relevant = irq_stat & (HC0_IRQ_PEND << (hc * HC_SHIFT));
1473 if (relevant) { 1472 if (relevant) {
1474 mv_host_intr(host_set, relevant, hc); 1473 mv_host_intr(host, relevant, hc);
1475 handled++; 1474 handled++;
1476 } 1475 }
1477 } 1476 }
1478 1477
1479 hpriv = host_set->private_data; 1478 hpriv = host->private_data;
1480 if (IS_60XX(hpriv)) { 1479 if (IS_60XX(hpriv)) {
1481 /* deal with the interrupt coalescing bits */ 1480 /* deal with the interrupt coalescing bits */
1482 if (irq_stat & (TRAN_LO_DONE | TRAN_HI_DONE | PORTS_0_7_COAL_DONE)) { 1481 if (irq_stat & (TRAN_LO_DONE | TRAN_HI_DONE | PORTS_0_7_COAL_DONE)) {
@@ -1491,12 +1490,12 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1491 readl(mmio + PCI_IRQ_CAUSE_OFS)); 1490 readl(mmio + PCI_IRQ_CAUSE_OFS));
1492 1491
1493 DPRINTK("All regs @ PCI error\n"); 1492 DPRINTK("All regs @ PCI error\n");
1494 mv_dump_all_regs(mmio, -1, to_pci_dev(host_set->dev)); 1493 mv_dump_all_regs(mmio, -1, to_pci_dev(host->dev));
1495 1494
1496 writelfl(0, mmio + PCI_IRQ_CAUSE_OFS); 1495 writelfl(0, mmio + PCI_IRQ_CAUSE_OFS);
1497 handled++; 1496 handled++;
1498 } 1497 }
1499 spin_unlock(&host_set->lock); 1498 spin_unlock(&host->lock);
1500 1499
1501 return IRQ_RETVAL(handled); 1500 return IRQ_RETVAL(handled);
1502} 1501}
@@ -1528,7 +1527,7 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in)
1528 1527
1529static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in) 1528static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
1530{ 1529{
1531 void __iomem *mmio = mv5_phy_base(ap->host_set->mmio_base, ap->port_no); 1530 void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no);
1532 unsigned int ofs = mv5_scr_offset(sc_reg_in); 1531 unsigned int ofs = mv5_scr_offset(sc_reg_in);
1533 1532
1534 if (ofs != 0xffffffffU) 1533 if (ofs != 0xffffffffU)
@@ -1539,7 +1538,7 @@ static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
1539 1538
1540static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) 1539static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
1541{ 1540{
1542 void __iomem *mmio = mv5_phy_base(ap->host_set->mmio_base, ap->port_no); 1541 void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no);
1543 unsigned int ofs = mv5_scr_offset(sc_reg_in); 1542 unsigned int ofs = mv5_scr_offset(sc_reg_in);
1544 1543
1545 if (ofs != 0xffffffffU) 1544 if (ofs != 0xffffffffU)
@@ -1904,8 +1903,8 @@ static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
1904 1903
1905static void mv_stop_and_reset(struct ata_port *ap) 1904static void mv_stop_and_reset(struct ata_port *ap)
1906{ 1905{
1907 struct mv_host_priv *hpriv = ap->host_set->private_data; 1906 struct mv_host_priv *hpriv = ap->host->private_data;
1908 void __iomem *mmio = ap->host_set->mmio_base; 1907 void __iomem *mmio = ap->host->mmio_base;
1909 1908
1910 mv_stop_dma(ap); 1909 mv_stop_dma(ap);
1911 1910
@@ -1936,7 +1935,7 @@ static inline void __msleep(unsigned int msec, int can_sleep)
1936static void __mv_phy_reset(struct ata_port *ap, int can_sleep) 1935static void __mv_phy_reset(struct ata_port *ap, int can_sleep)
1937{ 1936{
1938 struct mv_port_priv *pp = ap->private_data; 1937 struct mv_port_priv *pp = ap->private_data;
1939 struct mv_host_priv *hpriv = ap->host_set->private_data; 1938 struct mv_host_priv *hpriv = ap->host->private_data;
1940 void __iomem *port_mmio = mv_ap_base(ap); 1939 void __iomem *port_mmio = mv_ap_base(ap);
1941 struct ata_taskfile tf; 1940 struct ata_taskfile tf;
1942 struct ata_device *dev = &ap->device[0]; 1941 struct ata_device *dev = &ap->device[0];
@@ -2035,7 +2034,7 @@ static void mv_phy_reset(struct ata_port *ap)
2035 * chip/bus, fail the command, and move on. 2034 * chip/bus, fail the command, and move on.
2036 * 2035 *
2037 * LOCKING: 2036 * LOCKING:
2038 * This routine holds the host_set lock while failing the command. 2037 * This routine holds the host lock while failing the command.
2039 */ 2038 */
2040static void mv_eng_timeout(struct ata_port *ap) 2039static void mv_eng_timeout(struct ata_port *ap)
2041{ 2040{
@@ -2044,18 +2043,17 @@ static void mv_eng_timeout(struct ata_port *ap)
2044 2043
2045 ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n"); 2044 ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n");
2046 DPRINTK("All regs @ start of eng_timeout\n"); 2045 DPRINTK("All regs @ start of eng_timeout\n");
2047 mv_dump_all_regs(ap->host_set->mmio_base, ap->port_no, 2046 mv_dump_all_regs(ap->host->mmio_base, ap->port_no,
2048 to_pci_dev(ap->host_set->dev)); 2047 to_pci_dev(ap->host->dev));
2049 2048
2050 qc = ata_qc_from_tag(ap, ap->active_tag); 2049 qc = ata_qc_from_tag(ap, ap->active_tag);
2051 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n", 2050 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n",
2052 ap->host_set->mmio_base, ap, qc, qc->scsicmd, 2051 ap->host->mmio_base, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd);
2053 &qc->scsicmd->cmnd);
2054 2052
2055 spin_lock_irqsave(&ap->host_set->lock, flags); 2053 spin_lock_irqsave(&ap->host->lock, flags);
2056 mv_err_intr(ap, 0); 2054 mv_err_intr(ap, 0);
2057 mv_stop_and_reset(ap); 2055 mv_stop_and_reset(ap);
2058 spin_unlock_irqrestore(&ap->host_set->lock, flags); 2056 spin_unlock_irqrestore(&ap->host->lock, flags);
2059 2057
2060 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); 2058 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
2061 if (qc->flags & ATA_QCFLAG_ACTIVE) { 2059 if (qc->flags & ATA_QCFLAG_ACTIVE) {
@@ -2236,7 +2234,7 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent,
2236 if (rc) 2234 if (rc)
2237 goto done; 2235 goto done;
2238 2236
2239 n_hc = mv_get_hc_count(probe_ent->host_flags); 2237 n_hc = mv_get_hc_count(probe_ent->port_flags);
2240 probe_ent->n_ports = MV_PORTS_PER_HC * n_hc; 2238 probe_ent->n_ports = MV_PORTS_PER_HC * n_hc;
2241 2239
2242 for (port = 0; port < probe_ent->n_ports; port++) 2240 for (port = 0; port < probe_ent->n_ports; port++)
@@ -2389,7 +2387,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2389 memset(hpriv, 0, sizeof(*hpriv)); 2387 memset(hpriv, 0, sizeof(*hpriv));
2390 2388
2391 probe_ent->sht = mv_port_info[board_idx].sht; 2389 probe_ent->sht = mv_port_info[board_idx].sht;
2392 probe_ent->host_flags = mv_port_info[board_idx].host_flags; 2390 probe_ent->port_flags = mv_port_info[board_idx].flags;
2393 probe_ent->pio_mask = mv_port_info[board_idx].pio_mask; 2391 probe_ent->pio_mask = mv_port_info[board_idx].pio_mask;
2394 probe_ent->udma_mask = mv_port_info[board_idx].udma_mask; 2392 probe_ent->udma_mask = mv_port_info[board_idx].udma_mask;
2395 probe_ent->port_ops = mv_port_info[board_idx].port_ops; 2393 probe_ent->port_ops = mv_port_info[board_idx].port_ops;
@@ -2447,7 +2445,7 @@ err_out:
2447 2445
2448static int __init mv_init(void) 2446static int __init mv_init(void)
2449{ 2447{
2450 return pci_module_init(&mv_pci_driver); 2448 return pci_register_driver(&mv_pci_driver);
2451} 2449}
2452 2450
2453static void __exit mv_exit(void) 2451static void __exit mv_exit(void)
diff --git a/drivers/scsi/sata_nv.c b/drivers/ata/sata_nv.c
index 56da25581f31..27c22feebf30 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -81,7 +81,7 @@ enum {
81}; 81};
82 82
83static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 83static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
84static void nv_ck804_host_stop(struct ata_host_set *host_set); 84static void nv_ck804_host_stop(struct ata_host *host);
85static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance, 85static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance,
86 struct pt_regs *regs); 86 struct pt_regs *regs);
87static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance, 87static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance,
@@ -257,7 +257,7 @@ static struct ata_port_info nv_port_info[] = {
257 /* generic */ 257 /* generic */
258 { 258 {
259 .sht = &nv_sht, 259 .sht = &nv_sht,
260 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 260 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
261 .pio_mask = NV_PIO_MASK, 261 .pio_mask = NV_PIO_MASK,
262 .mwdma_mask = NV_MWDMA_MASK, 262 .mwdma_mask = NV_MWDMA_MASK,
263 .udma_mask = NV_UDMA_MASK, 263 .udma_mask = NV_UDMA_MASK,
@@ -266,7 +266,7 @@ static struct ata_port_info nv_port_info[] = {
266 /* nforce2/3 */ 266 /* nforce2/3 */
267 { 267 {
268 .sht = &nv_sht, 268 .sht = &nv_sht,
269 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 269 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
270 .pio_mask = NV_PIO_MASK, 270 .pio_mask = NV_PIO_MASK,
271 .mwdma_mask = NV_MWDMA_MASK, 271 .mwdma_mask = NV_MWDMA_MASK,
272 .udma_mask = NV_UDMA_MASK, 272 .udma_mask = NV_UDMA_MASK,
@@ -275,7 +275,7 @@ static struct ata_port_info nv_port_info[] = {
275 /* ck804 */ 275 /* ck804 */
276 { 276 {
277 .sht = &nv_sht, 277 .sht = &nv_sht,
278 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 278 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
279 .pio_mask = NV_PIO_MASK, 279 .pio_mask = NV_PIO_MASK,
280 .mwdma_mask = NV_MWDMA_MASK, 280 .mwdma_mask = NV_MWDMA_MASK,
281 .udma_mask = NV_UDMA_MASK, 281 .udma_mask = NV_UDMA_MASK,
@@ -292,17 +292,17 @@ MODULE_VERSION(DRV_VERSION);
292static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance, 292static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance,
293 struct pt_regs *regs) 293 struct pt_regs *regs)
294{ 294{
295 struct ata_host_set *host_set = dev_instance; 295 struct ata_host *host = dev_instance;
296 unsigned int i; 296 unsigned int i;
297 unsigned int handled = 0; 297 unsigned int handled = 0;
298 unsigned long flags; 298 unsigned long flags;
299 299
300 spin_lock_irqsave(&host_set->lock, flags); 300 spin_lock_irqsave(&host->lock, flags);
301 301
302 for (i = 0; i < host_set->n_ports; i++) { 302 for (i = 0; i < host->n_ports; i++) {
303 struct ata_port *ap; 303 struct ata_port *ap;
304 304
305 ap = host_set->ports[i]; 305 ap = host->ports[i];
306 if (ap && 306 if (ap &&
307 !(ap->flags & ATA_FLAG_DISABLED)) { 307 !(ap->flags & ATA_FLAG_DISABLED)) {
308 struct ata_queued_cmd *qc; 308 struct ata_queued_cmd *qc;
@@ -318,7 +318,7 @@ static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance,
318 318
319 } 319 }
320 320
321 spin_unlock_irqrestore(&host_set->lock, flags); 321 spin_unlock_irqrestore(&host->lock, flags);
322 322
323 return IRQ_RETVAL(handled); 323 return IRQ_RETVAL(handled);
324} 324}
@@ -354,12 +354,12 @@ static int nv_host_intr(struct ata_port *ap, u8 irq_stat)
354 return 1; 354 return 1;
355} 355}
356 356
357static irqreturn_t nv_do_interrupt(struct ata_host_set *host_set, u8 irq_stat) 357static irqreturn_t nv_do_interrupt(struct ata_host *host, u8 irq_stat)
358{ 358{
359 int i, handled = 0; 359 int i, handled = 0;
360 360
361 for (i = 0; i < host_set->n_ports; i++) { 361 for (i = 0; i < host->n_ports; i++) {
362 struct ata_port *ap = host_set->ports[i]; 362 struct ata_port *ap = host->ports[i];
363 363
364 if (ap && !(ap->flags & ATA_FLAG_DISABLED)) 364 if (ap && !(ap->flags & ATA_FLAG_DISABLED))
365 handled += nv_host_intr(ap, irq_stat); 365 handled += nv_host_intr(ap, irq_stat);
@@ -373,14 +373,14 @@ static irqreturn_t nv_do_interrupt(struct ata_host_set *host_set, u8 irq_stat)
373static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance, 373static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance,
374 struct pt_regs *regs) 374 struct pt_regs *regs)
375{ 375{
376 struct ata_host_set *host_set = dev_instance; 376 struct ata_host *host = dev_instance;
377 u8 irq_stat; 377 u8 irq_stat;
378 irqreturn_t ret; 378 irqreturn_t ret;
379 379
380 spin_lock(&host_set->lock); 380 spin_lock(&host->lock);
381 irq_stat = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS); 381 irq_stat = inb(host->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
382 ret = nv_do_interrupt(host_set, irq_stat); 382 ret = nv_do_interrupt(host, irq_stat);
383 spin_unlock(&host_set->lock); 383 spin_unlock(&host->lock);
384 384
385 return ret; 385 return ret;
386} 386}
@@ -388,14 +388,14 @@ static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance,
388static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance, 388static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance,
389 struct pt_regs *regs) 389 struct pt_regs *regs)
390{ 390{
391 struct ata_host_set *host_set = dev_instance; 391 struct ata_host *host = dev_instance;
392 u8 irq_stat; 392 u8 irq_stat;
393 irqreturn_t ret; 393 irqreturn_t ret;
394 394
395 spin_lock(&host_set->lock); 395 spin_lock(&host->lock);
396 irq_stat = readb(host_set->mmio_base + NV_INT_STATUS_CK804); 396 irq_stat = readb(host->mmio_base + NV_INT_STATUS_CK804);
397 ret = nv_do_interrupt(host_set, irq_stat); 397 ret = nv_do_interrupt(host, irq_stat);
398 spin_unlock(&host_set->lock); 398 spin_unlock(&host->lock);
399 399
400 return ret; 400 return ret;
401} 401}
@@ -418,7 +418,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
418 418
419static void nv_nf2_freeze(struct ata_port *ap) 419static void nv_nf2_freeze(struct ata_port *ap)
420{ 420{
421 unsigned long scr_addr = ap->host_set->ports[0]->ioaddr.scr_addr; 421 unsigned long scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
422 int shift = ap->port_no * NV_INT_PORT_SHIFT; 422 int shift = ap->port_no * NV_INT_PORT_SHIFT;
423 u8 mask; 423 u8 mask;
424 424
@@ -429,7 +429,7 @@ static void nv_nf2_freeze(struct ata_port *ap)
429 429
430static void nv_nf2_thaw(struct ata_port *ap) 430static void nv_nf2_thaw(struct ata_port *ap)
431{ 431{
432 unsigned long scr_addr = ap->host_set->ports[0]->ioaddr.scr_addr; 432 unsigned long scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
433 int shift = ap->port_no * NV_INT_PORT_SHIFT; 433 int shift = ap->port_no * NV_INT_PORT_SHIFT;
434 u8 mask; 434 u8 mask;
435 435
@@ -442,7 +442,7 @@ static void nv_nf2_thaw(struct ata_port *ap)
442 442
443static void nv_ck804_freeze(struct ata_port *ap) 443static void nv_ck804_freeze(struct ata_port *ap)
444{ 444{
445 void __iomem *mmio_base = ap->host_set->mmio_base; 445 void __iomem *mmio_base = ap->host->mmio_base;
446 int shift = ap->port_no * NV_INT_PORT_SHIFT; 446 int shift = ap->port_no * NV_INT_PORT_SHIFT;
447 u8 mask; 447 u8 mask;
448 448
@@ -453,7 +453,7 @@ static void nv_ck804_freeze(struct ata_port *ap)
453 453
454static void nv_ck804_thaw(struct ata_port *ap) 454static void nv_ck804_thaw(struct ata_port *ap)
455{ 455{
456 void __iomem *mmio_base = ap->host_set->mmio_base; 456 void __iomem *mmio_base = ap->host->mmio_base;
457 int shift = ap->port_no * NV_INT_PORT_SHIFT; 457 int shift = ap->port_no * NV_INT_PORT_SHIFT;
458 u8 mask; 458 u8 mask;
459 459
@@ -568,9 +568,9 @@ err_out:
568 return rc; 568 return rc;
569} 569}
570 570
571static void nv_ck804_host_stop(struct ata_host_set *host_set) 571static void nv_ck804_host_stop(struct ata_host *host)
572{ 572{
573 struct pci_dev *pdev = to_pci_dev(host_set->dev); 573 struct pci_dev *pdev = to_pci_dev(host->dev);
574 u8 regval; 574 u8 regval;
575 575
576 /* disable SATA space for CK804 */ 576 /* disable SATA space for CK804 */
@@ -578,12 +578,12 @@ static void nv_ck804_host_stop(struct ata_host_set *host_set)
578 regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN; 578 regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
579 pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); 579 pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
580 580
581 ata_pci_host_stop(host_set); 581 ata_pci_host_stop(host);
582} 582}
583 583
584static int __init nv_init(void) 584static int __init nv_init(void)
585{ 585{
586 return pci_module_init(&nv_pci_driver); 586 return pci_register_driver(&nv_pci_driver);
587} 587}
588 588
589static void __exit nv_exit(void) 589static void __exit nv_exit(void)
diff --git a/drivers/scsi/sata_promise.c b/drivers/ata/sata_promise.c
index 4776f4e55839..d627812ea73d 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -104,7 +104,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
104static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 104static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
105static void pdc_irq_clear(struct ata_port *ap); 105static void pdc_irq_clear(struct ata_port *ap);
106static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 106static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
107static void pdc_host_stop(struct ata_host_set *host_set); 107static void pdc_host_stop(struct ata_host *host);
108 108
109 109
110static struct scsi_host_template pdc_ata_sht = { 110static struct scsi_host_template pdc_ata_sht = {
@@ -175,7 +175,7 @@ static const struct ata_port_info pdc_port_info[] = {
175 /* board_2037x */ 175 /* board_2037x */
176 { 176 {
177 .sht = &pdc_ata_sht, 177 .sht = &pdc_ata_sht,
178 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, 178 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
179 .pio_mask = 0x1f, /* pio0-4 */ 179 .pio_mask = 0x1f, /* pio0-4 */
180 .mwdma_mask = 0x07, /* mwdma0-2 */ 180 .mwdma_mask = 0x07, /* mwdma0-2 */
181 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 181 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -185,7 +185,7 @@ static const struct ata_port_info pdc_port_info[] = {
185 /* board_20319 */ 185 /* board_20319 */
186 { 186 {
187 .sht = &pdc_ata_sht, 187 .sht = &pdc_ata_sht,
188 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, 188 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
189 .pio_mask = 0x1f, /* pio0-4 */ 189 .pio_mask = 0x1f, /* pio0-4 */
190 .mwdma_mask = 0x07, /* mwdma0-2 */ 190 .mwdma_mask = 0x07, /* mwdma0-2 */
191 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 191 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -195,7 +195,7 @@ static const struct ata_port_info pdc_port_info[] = {
195 /* board_20619 */ 195 /* board_20619 */
196 { 196 {
197 .sht = &pdc_ata_sht, 197 .sht = &pdc_ata_sht,
198 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, 198 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS,
199 .pio_mask = 0x1f, /* pio0-4 */ 199 .pio_mask = 0x1f, /* pio0-4 */
200 .mwdma_mask = 0x07, /* mwdma0-2 */ 200 .mwdma_mask = 0x07, /* mwdma0-2 */
201 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 201 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -205,7 +205,7 @@ static const struct ata_port_info pdc_port_info[] = {
205 /* board_20771 */ 205 /* board_20771 */
206 { 206 {
207 .sht = &pdc_ata_sht, 207 .sht = &pdc_ata_sht,
208 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, 208 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
209 .pio_mask = 0x1f, /* pio0-4 */ 209 .pio_mask = 0x1f, /* pio0-4 */
210 .mwdma_mask = 0x07, /* mwdma0-2 */ 210 .mwdma_mask = 0x07, /* mwdma0-2 */
211 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 211 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -215,7 +215,7 @@ static const struct ata_port_info pdc_port_info[] = {
215 /* board_2057x */ 215 /* board_2057x */
216 { 216 {
217 .sht = &pdc_ata_sht, 217 .sht = &pdc_ata_sht,
218 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, 218 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
219 .pio_mask = 0x1f, /* pio0-4 */ 219 .pio_mask = 0x1f, /* pio0-4 */
220 .mwdma_mask = 0x07, /* mwdma0-2 */ 220 .mwdma_mask = 0x07, /* mwdma0-2 */
221 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 221 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -225,7 +225,7 @@ static const struct ata_port_info pdc_port_info[] = {
225 /* board_40518 */ 225 /* board_40518 */
226 { 226 {
227 .sht = &pdc_ata_sht, 227 .sht = &pdc_ata_sht,
228 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, 228 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
229 .pio_mask = 0x1f, /* pio0-4 */ 229 .pio_mask = 0x1f, /* pio0-4 */
230 .mwdma_mask = 0x07, /* mwdma0-2 */ 230 .mwdma_mask = 0x07, /* mwdma0-2 */
231 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 231 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -292,7 +292,7 @@ static struct pci_driver pdc_ata_pci_driver = {
292 292
293static int pdc_port_start(struct ata_port *ap) 293static int pdc_port_start(struct ata_port *ap)
294{ 294{
295 struct device *dev = ap->host_set->dev; 295 struct device *dev = ap->host->dev;
296 struct pdc_port_priv *pp; 296 struct pdc_port_priv *pp;
297 int rc; 297 int rc;
298 298
@@ -326,7 +326,7 @@ err_out:
326 326
327static void pdc_port_stop(struct ata_port *ap) 327static void pdc_port_stop(struct ata_port *ap)
328{ 328{
329 struct device *dev = ap->host_set->dev; 329 struct device *dev = ap->host->dev;
330 struct pdc_port_priv *pp = ap->private_data; 330 struct pdc_port_priv *pp = ap->private_data;
331 331
332 ap->private_data = NULL; 332 ap->private_data = NULL;
@@ -336,11 +336,11 @@ static void pdc_port_stop(struct ata_port *ap)
336} 336}
337 337
338 338
339static void pdc_host_stop(struct ata_host_set *host_set) 339static void pdc_host_stop(struct ata_host *host)
340{ 340{
341 struct pdc_host_priv *hp = host_set->private_data; 341 struct pdc_host_priv *hp = host->private_data;
342 342
343 ata_pci_host_stop(host_set); 343 ata_pci_host_stop(host);
344 344
345 kfree(hp); 345 kfree(hp);
346} 346}
@@ -443,14 +443,14 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
443 443
444static void pdc_eng_timeout(struct ata_port *ap) 444static void pdc_eng_timeout(struct ata_port *ap)
445{ 445{
446 struct ata_host_set *host_set = ap->host_set; 446 struct ata_host *host = ap->host;
447 u8 drv_stat; 447 u8 drv_stat;
448 struct ata_queued_cmd *qc; 448 struct ata_queued_cmd *qc;
449 unsigned long flags; 449 unsigned long flags;
450 450
451 DPRINTK("ENTER\n"); 451 DPRINTK("ENTER\n");
452 452
453 spin_lock_irqsave(&host_set->lock, flags); 453 spin_lock_irqsave(&host->lock, flags);
454 454
455 qc = ata_qc_from_tag(ap, ap->active_tag); 455 qc = ata_qc_from_tag(ap, ap->active_tag);
456 456
@@ -473,7 +473,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
473 break; 473 break;
474 } 474 }
475 475
476 spin_unlock_irqrestore(&host_set->lock, flags); 476 spin_unlock_irqrestore(&host->lock, flags);
477 ata_eh_qc_complete(qc); 477 ata_eh_qc_complete(qc);
478 DPRINTK("EXIT\n"); 478 DPRINTK("EXIT\n");
479} 479}
@@ -509,15 +509,15 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
509 509
510static void pdc_irq_clear(struct ata_port *ap) 510static void pdc_irq_clear(struct ata_port *ap)
511{ 511{
512 struct ata_host_set *host_set = ap->host_set; 512 struct ata_host *host = ap->host;
513 void __iomem *mmio = host_set->mmio_base; 513 void __iomem *mmio = host->mmio_base;
514 514
515 readl(mmio + PDC_INT_SEQMASK); 515 readl(mmio + PDC_INT_SEQMASK);
516} 516}
517 517
518static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 518static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
519{ 519{
520 struct ata_host_set *host_set = dev_instance; 520 struct ata_host *host = dev_instance;
521 struct ata_port *ap; 521 struct ata_port *ap;
522 u32 mask = 0; 522 u32 mask = 0;
523 unsigned int i, tmp; 523 unsigned int i, tmp;
@@ -526,12 +526,12 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
526 526
527 VPRINTK("ENTER\n"); 527 VPRINTK("ENTER\n");
528 528
529 if (!host_set || !host_set->mmio_base) { 529 if (!host || !host->mmio_base) {
530 VPRINTK("QUICK EXIT\n"); 530 VPRINTK("QUICK EXIT\n");
531 return IRQ_NONE; 531 return IRQ_NONE;
532 } 532 }
533 533
534 mmio_base = host_set->mmio_base; 534 mmio_base = host->mmio_base;
535 535
536 /* reading should also clear interrupts */ 536 /* reading should also clear interrupts */
537 mask = readl(mmio_base + PDC_INT_SEQMASK); 537 mask = readl(mmio_base + PDC_INT_SEQMASK);
@@ -541,7 +541,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
541 return IRQ_NONE; 541 return IRQ_NONE;
542 } 542 }
543 543
544 spin_lock(&host_set->lock); 544 spin_lock(&host->lock);
545 545
546 mask &= 0xffff; /* only 16 tags possible */ 546 mask &= 0xffff; /* only 16 tags possible */
547 if (!mask) { 547 if (!mask) {
@@ -551,9 +551,9 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
551 551
552 writel(mask, mmio_base + PDC_INT_SEQMASK); 552 writel(mask, mmio_base + PDC_INT_SEQMASK);
553 553
554 for (i = 0; i < host_set->n_ports; i++) { 554 for (i = 0; i < host->n_ports; i++) {
555 VPRINTK("port %u\n", i); 555 VPRINTK("port %u\n", i);
556 ap = host_set->ports[i]; 556 ap = host->ports[i];
557 tmp = mask & (1 << (i + 1)); 557 tmp = mask & (1 << (i + 1));
558 if (tmp && ap && 558 if (tmp && ap &&
559 !(ap->flags & ATA_FLAG_DISABLED)) { 559 !(ap->flags & ATA_FLAG_DISABLED)) {
@@ -568,7 +568,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
568 VPRINTK("EXIT\n"); 568 VPRINTK("EXIT\n");
569 569
570done_irq: 570done_irq:
571 spin_unlock(&host_set->lock); 571 spin_unlock(&host->lock);
572 return IRQ_RETVAL(handled); 572 return IRQ_RETVAL(handled);
573} 573}
574 574
@@ -581,8 +581,8 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc)
581 581
582 VPRINTK("ENTER, ap %p\n", ap); 582 VPRINTK("ENTER, ap %p\n", ap);
583 583
584 writel(0x00000001, ap->host_set->mmio_base + (seq * 4)); 584 writel(0x00000001, ap->host->mmio_base + (seq * 4));
585 readl(ap->host_set->mmio_base + (seq * 4)); /* flush */ 585 readl(ap->host->mmio_base + (seq * 4)); /* flush */
586 586
587 pp->pkt[2] = seq; 587 pp->pkt[2] = seq;
588 wmb(); /* flush PRD, pkt writes */ 588 wmb(); /* flush PRD, pkt writes */
@@ -743,7 +743,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
743 probe_ent->private_data = hp; 743 probe_ent->private_data = hp;
744 744
745 probe_ent->sht = pdc_port_info[board_idx].sht; 745 probe_ent->sht = pdc_port_info[board_idx].sht;
746 probe_ent->host_flags = pdc_port_info[board_idx].host_flags; 746 probe_ent->port_flags = pdc_port_info[board_idx].flags;
747 probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; 747 probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask;
748 probe_ent->mwdma_mask = pdc_port_info[board_idx].mwdma_mask; 748 probe_ent->mwdma_mask = pdc_port_info[board_idx].mwdma_mask;
749 probe_ent->udma_mask = pdc_port_info[board_idx].udma_mask; 749 probe_ent->udma_mask = pdc_port_info[board_idx].udma_mask;
@@ -824,7 +824,7 @@ err_out:
824 824
825static int __init pdc_ata_init(void) 825static int __init pdc_ata_init(void)
826{ 826{
827 return pci_module_init(&pdc_ata_pci_driver); 827 return pci_register_driver(&pdc_ata_pci_driver);
828} 828}
829 829
830 830
diff --git a/drivers/scsi/sata_promise.h b/drivers/ata/sata_promise.h
index 6ee5e190262d..6ee5e190262d 100644
--- a/drivers/scsi/sata_promise.h
+++ b/drivers/ata/sata_promise.h
diff --git a/drivers/scsi/sata_qstor.c b/drivers/ata/sata_qstor.c
index d374c1db0cf3..fa29dfe2a7b5 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -116,7 +116,7 @@ static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
116static int qs_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 116static int qs_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
117static irqreturn_t qs_intr (int irq, void *dev_instance, struct pt_regs *regs); 117static irqreturn_t qs_intr (int irq, void *dev_instance, struct pt_regs *regs);
118static int qs_port_start(struct ata_port *ap); 118static int qs_port_start(struct ata_port *ap);
119static void qs_host_stop(struct ata_host_set *host_set); 119static void qs_host_stop(struct ata_host *host);
120static void qs_port_stop(struct ata_port *ap); 120static void qs_port_stop(struct ata_port *ap);
121static void qs_phy_reset(struct ata_port *ap); 121static void qs_phy_reset(struct ata_port *ap);
122static void qs_qc_prep(struct ata_queued_cmd *qc); 122static void qs_qc_prep(struct ata_queued_cmd *qc);
@@ -174,7 +174,7 @@ static const struct ata_port_info qs_port_info[] = {
174 /* board_2068_idx */ 174 /* board_2068_idx */
175 { 175 {
176 .sht = &qs_ata_sht, 176 .sht = &qs_ata_sht,
177 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 177 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
178 ATA_FLAG_SATA_RESET | 178 ATA_FLAG_SATA_RESET |
179 //FIXME ATA_FLAG_SRST | 179 //FIXME ATA_FLAG_SRST |
180 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING, 180 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
@@ -220,7 +220,7 @@ static void qs_irq_clear(struct ata_port *ap)
220 220
221static inline void qs_enter_reg_mode(struct ata_port *ap) 221static inline void qs_enter_reg_mode(struct ata_port *ap)
222{ 222{
223 u8 __iomem *chan = ap->host_set->mmio_base + (ap->port_no * 0x4000); 223 u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000);
224 224
225 writeb(QS_CTR0_REG, chan + QS_CCT_CTR0); 225 writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
226 readb(chan + QS_CCT_CTR0); /* flush */ 226 readb(chan + QS_CCT_CTR0); /* flush */
@@ -228,7 +228,7 @@ static inline void qs_enter_reg_mode(struct ata_port *ap)
228 228
229static inline void qs_reset_channel_logic(struct ata_port *ap) 229static inline void qs_reset_channel_logic(struct ata_port *ap)
230{ 230{
231 u8 __iomem *chan = ap->host_set->mmio_base + (ap->port_no * 0x4000); 231 u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000);
232 232
233 writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1); 233 writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1);
234 readb(chan + QS_CCT_CTR0); /* flush */ 234 readb(chan + QS_CCT_CTR0); /* flush */
@@ -342,7 +342,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
342static inline void qs_packet_start(struct ata_queued_cmd *qc) 342static inline void qs_packet_start(struct ata_queued_cmd *qc)
343{ 343{
344 struct ata_port *ap = qc->ap; 344 struct ata_port *ap = qc->ap;
345 u8 __iomem *chan = ap->host_set->mmio_base + (ap->port_no * 0x4000); 345 u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000);
346 346
347 VPRINTK("ENTER, ap %p\n", ap); 347 VPRINTK("ENTER, ap %p\n", ap);
348 348
@@ -375,11 +375,11 @@ static unsigned int qs_qc_issue(struct ata_queued_cmd *qc)
375 return ata_qc_issue_prot(qc); 375 return ata_qc_issue_prot(qc);
376} 376}
377 377
378static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) 378static inline unsigned int qs_intr_pkt(struct ata_host *host)
379{ 379{
380 unsigned int handled = 0; 380 unsigned int handled = 0;
381 u8 sFFE; 381 u8 sFFE;
382 u8 __iomem *mmio_base = host_set->mmio_base; 382 u8 __iomem *mmio_base = host->mmio_base;
383 383
384 do { 384 do {
385 u32 sff0 = readl(mmio_base + QS_HST_SFF); 385 u32 sff0 = readl(mmio_base + QS_HST_SFF);
@@ -391,7 +391,7 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
391 u8 sDST = sff0 >> 16; /* dev status */ 391 u8 sDST = sff0 >> 16; /* dev status */
392 u8 sHST = sff1 & 0x3f; /* host status */ 392 u8 sHST = sff1 & 0x3f; /* host status */
393 unsigned int port_no = (sff1 >> 8) & 0x03; 393 unsigned int port_no = (sff1 >> 8) & 0x03;
394 struct ata_port *ap = host_set->ports[port_no]; 394 struct ata_port *ap = host->ports[port_no];
395 395
396 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n", 396 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n",
397 sff1, sff0, port_no, sHST, sDST); 397 sff1, sff0, port_no, sHST, sDST);
@@ -421,13 +421,13 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
421 return handled; 421 return handled;
422} 422}
423 423
424static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) 424static inline unsigned int qs_intr_mmio(struct ata_host *host)
425{ 425{
426 unsigned int handled = 0, port_no; 426 unsigned int handled = 0, port_no;
427 427
428 for (port_no = 0; port_no < host_set->n_ports; ++port_no) { 428 for (port_no = 0; port_no < host->n_ports; ++port_no) {
429 struct ata_port *ap; 429 struct ata_port *ap;
430 ap = host_set->ports[port_no]; 430 ap = host->ports[port_no];
431 if (ap && 431 if (ap &&
432 !(ap->flags & ATA_FLAG_DISABLED)) { 432 !(ap->flags & ATA_FLAG_DISABLED)) {
433 struct ata_queued_cmd *qc; 433 struct ata_queued_cmd *qc;
@@ -457,14 +457,14 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
457 457
458static irqreturn_t qs_intr(int irq, void *dev_instance, struct pt_regs *regs) 458static irqreturn_t qs_intr(int irq, void *dev_instance, struct pt_regs *regs)
459{ 459{
460 struct ata_host_set *host_set = dev_instance; 460 struct ata_host *host = dev_instance;
461 unsigned int handled = 0; 461 unsigned int handled = 0;
462 462
463 VPRINTK("ENTER\n"); 463 VPRINTK("ENTER\n");
464 464
465 spin_lock(&host_set->lock); 465 spin_lock(&host->lock);
466 handled = qs_intr_pkt(host_set) | qs_intr_mmio(host_set); 466 handled = qs_intr_pkt(host) | qs_intr_mmio(host);
467 spin_unlock(&host_set->lock); 467 spin_unlock(&host->lock);
468 468
469 VPRINTK("EXIT\n"); 469 VPRINTK("EXIT\n");
470 470
@@ -491,9 +491,9 @@ static void qs_ata_setup_port(struct ata_ioports *port, unsigned long base)
491 491
492static int qs_port_start(struct ata_port *ap) 492static int qs_port_start(struct ata_port *ap)
493{ 493{
494 struct device *dev = ap->host_set->dev; 494 struct device *dev = ap->host->dev;
495 struct qs_port_priv *pp; 495 struct qs_port_priv *pp;
496 void __iomem *mmio_base = ap->host_set->mmio_base; 496 void __iomem *mmio_base = ap->host->mmio_base;
497 void __iomem *chan = mmio_base + (ap->port_no * 0x4000); 497 void __iomem *chan = mmio_base + (ap->port_no * 0x4000);
498 u64 addr; 498 u64 addr;
499 int rc; 499 int rc;
@@ -530,7 +530,7 @@ err_out:
530 530
531static void qs_port_stop(struct ata_port *ap) 531static void qs_port_stop(struct ata_port *ap)
532{ 532{
533 struct device *dev = ap->host_set->dev; 533 struct device *dev = ap->host->dev;
534 struct qs_port_priv *pp = ap->private_data; 534 struct qs_port_priv *pp = ap->private_data;
535 535
536 if (pp != NULL) { 536 if (pp != NULL) {
@@ -543,10 +543,10 @@ static void qs_port_stop(struct ata_port *ap)
543 ata_port_stop(ap); 543 ata_port_stop(ap);
544} 544}
545 545
546static void qs_host_stop(struct ata_host_set *host_set) 546static void qs_host_stop(struct ata_host *host)
547{ 547{
548 void __iomem *mmio_base = host_set->mmio_base; 548 void __iomem *mmio_base = host->mmio_base;
549 struct pci_dev *pdev = to_pci_dev(host_set->dev); 549 struct pci_dev *pdev = to_pci_dev(host->dev);
550 550
551 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ 551 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
552 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ 552 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
@@ -673,7 +673,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
673 INIT_LIST_HEAD(&probe_ent->node); 673 INIT_LIST_HEAD(&probe_ent->node);
674 674
675 probe_ent->sht = qs_port_info[board_idx].sht; 675 probe_ent->sht = qs_port_info[board_idx].sht;
676 probe_ent->host_flags = qs_port_info[board_idx].host_flags; 676 probe_ent->port_flags = qs_port_info[board_idx].flags;
677 probe_ent->pio_mask = qs_port_info[board_idx].pio_mask; 677 probe_ent->pio_mask = qs_port_info[board_idx].pio_mask;
678 probe_ent->mwdma_mask = qs_port_info[board_idx].mwdma_mask; 678 probe_ent->mwdma_mask = qs_port_info[board_idx].mwdma_mask;
679 probe_ent->udma_mask = qs_port_info[board_idx].udma_mask; 679 probe_ent->udma_mask = qs_port_info[board_idx].udma_mask;
@@ -712,7 +712,7 @@ err_out:
712 712
713static int __init qs_ata_init(void) 713static int __init qs_ata_init(void)
714{ 714{
715 return pci_module_init(&qs_ata_pci_driver); 715 return pci_register_driver(&qs_ata_pci_driver);
716} 716}
717 717
718static void __exit qs_ata_exit(void) 718static void __exit qs_ata_exit(void)
diff --git a/drivers/scsi/sata_sil.c b/drivers/ata/sata_sil.c
index d0a85073ebf7..c63dbabc0cd9 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -56,7 +56,7 @@ enum {
56 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), 56 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29),
57 SIL_FLAG_MOD15WRITE = (1 << 30), 57 SIL_FLAG_MOD15WRITE = (1 << 30),
58 58
59 SIL_DFL_HOST_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 59 SIL_DFL_PORT_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
60 ATA_FLAG_MMIO | ATA_FLAG_HRST_TO_RESUME, 60 ATA_FLAG_MMIO | ATA_FLAG_HRST_TO_RESUME,
61 61
62 /* 62 /*
@@ -109,7 +109,9 @@ enum {
109}; 109};
110 110
111static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 111static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
112#ifdef CONFIG_PM
112static int sil_pci_device_resume(struct pci_dev *pdev); 113static int sil_pci_device_resume(struct pci_dev *pdev);
114#endif
113static void sil_dev_config(struct ata_port *ap, struct ata_device *dev); 115static void sil_dev_config(struct ata_port *ap, struct ata_device *dev);
114static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg); 116static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg);
115static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 117static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
@@ -141,12 +143,8 @@ static const struct sil_drivelist {
141 { "ST330013AS", SIL_QUIRK_MOD15WRITE }, 143 { "ST330013AS", SIL_QUIRK_MOD15WRITE },
142 { "ST340017AS", SIL_QUIRK_MOD15WRITE }, 144 { "ST340017AS", SIL_QUIRK_MOD15WRITE },
143 { "ST360015AS", SIL_QUIRK_MOD15WRITE }, 145 { "ST360015AS", SIL_QUIRK_MOD15WRITE },
144 { "ST380013AS", SIL_QUIRK_MOD15WRITE },
145 { "ST380023AS", SIL_QUIRK_MOD15WRITE }, 146 { "ST380023AS", SIL_QUIRK_MOD15WRITE },
146 { "ST3120023AS", SIL_QUIRK_MOD15WRITE }, 147 { "ST3120023AS", SIL_QUIRK_MOD15WRITE },
147 { "ST3160023AS", SIL_QUIRK_MOD15WRITE },
148 { "ST3120026AS", SIL_QUIRK_MOD15WRITE },
149 { "ST3200822AS", SIL_QUIRK_MOD15WRITE },
150 { "ST340014ASL", SIL_QUIRK_MOD15WRITE }, 148 { "ST340014ASL", SIL_QUIRK_MOD15WRITE },
151 { "ST360014ASL", SIL_QUIRK_MOD15WRITE }, 149 { "ST360014ASL", SIL_QUIRK_MOD15WRITE },
152 { "ST380011ASL", SIL_QUIRK_MOD15WRITE }, 150 { "ST380011ASL", SIL_QUIRK_MOD15WRITE },
@@ -161,8 +159,10 @@ static struct pci_driver sil_pci_driver = {
161 .id_table = sil_pci_tbl, 159 .id_table = sil_pci_tbl,
162 .probe = sil_init_one, 160 .probe = sil_init_one,
163 .remove = ata_pci_remove_one, 161 .remove = ata_pci_remove_one,
162#ifdef CONFIG_PM
164 .suspend = ata_pci_device_suspend, 163 .suspend = ata_pci_device_suspend,
165 .resume = sil_pci_device_resume, 164 .resume = sil_pci_device_resume,
165#endif
166}; 166};
167 167
168static struct scsi_host_template sil_sht = { 168static struct scsi_host_template sil_sht = {
@@ -218,7 +218,7 @@ static const struct ata_port_info sil_port_info[] = {
218 /* sil_3112 */ 218 /* sil_3112 */
219 { 219 {
220 .sht = &sil_sht, 220 .sht = &sil_sht,
221 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE, 221 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE,
222 .pio_mask = 0x1f, /* pio0-4 */ 222 .pio_mask = 0x1f, /* pio0-4 */
223 .mwdma_mask = 0x07, /* mwdma0-2 */ 223 .mwdma_mask = 0x07, /* mwdma0-2 */
224 .udma_mask = 0x3f, /* udma0-5 */ 224 .udma_mask = 0x3f, /* udma0-5 */
@@ -227,7 +227,7 @@ static const struct ata_port_info sil_port_info[] = {
227 /* sil_3112_no_sata_irq */ 227 /* sil_3112_no_sata_irq */
228 { 228 {
229 .sht = &sil_sht, 229 .sht = &sil_sht,
230 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE | 230 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE |
231 SIL_FLAG_NO_SATA_IRQ, 231 SIL_FLAG_NO_SATA_IRQ,
232 .pio_mask = 0x1f, /* pio0-4 */ 232 .pio_mask = 0x1f, /* pio0-4 */
233 .mwdma_mask = 0x07, /* mwdma0-2 */ 233 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -237,7 +237,7 @@ static const struct ata_port_info sil_port_info[] = {
237 /* sil_3512 */ 237 /* sil_3512 */
238 { 238 {
239 .sht = &sil_sht, 239 .sht = &sil_sht,
240 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT, 240 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
241 .pio_mask = 0x1f, /* pio0-4 */ 241 .pio_mask = 0x1f, /* pio0-4 */
242 .mwdma_mask = 0x07, /* mwdma0-2 */ 242 .mwdma_mask = 0x07, /* mwdma0-2 */
243 .udma_mask = 0x3f, /* udma0-5 */ 243 .udma_mask = 0x3f, /* udma0-5 */
@@ -246,7 +246,7 @@ static const struct ata_port_info sil_port_info[] = {
246 /* sil_3114 */ 246 /* sil_3114 */
247 { 247 {
248 .sht = &sil_sht, 248 .sht = &sil_sht,
249 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT, 249 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
250 .pio_mask = 0x1f, /* pio0-4 */ 250 .pio_mask = 0x1f, /* pio0-4 */
251 .mwdma_mask = 0x07, /* mwdma0-2 */ 251 .mwdma_mask = 0x07, /* mwdma0-2 */
252 .udma_mask = 0x3f, /* udma0-5 */ 252 .udma_mask = 0x3f, /* udma0-5 */
@@ -295,10 +295,9 @@ static unsigned char sil_get_device_cache_line(struct pci_dev *pdev)
295 295
296static void sil_post_set_mode (struct ata_port *ap) 296static void sil_post_set_mode (struct ata_port *ap)
297{ 297{
298 struct ata_host_set *host_set = ap->host_set; 298 struct ata_host *host = ap->host;
299 struct ata_device *dev; 299 struct ata_device *dev;
300 void __iomem *addr = 300 void __iomem *addr = host->mmio_base + sil_port[ap->port_no].xfer_mode;
301 host_set->mmio_base + sil_port[ap->port_no].xfer_mode;
302 u32 tmp, dev_mode[2]; 301 u32 tmp, dev_mode[2];
303 unsigned int i; 302 unsigned int i;
304 303
@@ -440,15 +439,15 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
440static irqreturn_t sil_interrupt(int irq, void *dev_instance, 439static irqreturn_t sil_interrupt(int irq, void *dev_instance,
441 struct pt_regs *regs) 440 struct pt_regs *regs)
442{ 441{
443 struct ata_host_set *host_set = dev_instance; 442 struct ata_host *host = dev_instance;
444 void __iomem *mmio_base = host_set->mmio_base; 443 void __iomem *mmio_base = host->mmio_base;
445 int handled = 0; 444 int handled = 0;
446 int i; 445 int i;
447 446
448 spin_lock(&host_set->lock); 447 spin_lock(&host->lock);
449 448
450 for (i = 0; i < host_set->n_ports; i++) { 449 for (i = 0; i < host->n_ports; i++) {
451 struct ata_port *ap = host_set->ports[i]; 450 struct ata_port *ap = host->ports[i];
452 u32 bmdma2 = readl(mmio_base + sil_port[ap->port_no].bmdma2); 451 u32 bmdma2 = readl(mmio_base + sil_port[ap->port_no].bmdma2);
453 452
454 if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED)) 453 if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED))
@@ -466,14 +465,14 @@ static irqreturn_t sil_interrupt(int irq, void *dev_instance,
466 handled = 1; 465 handled = 1;
467 } 466 }
468 467
469 spin_unlock(&host_set->lock); 468 spin_unlock(&host->lock);
470 469
471 return IRQ_RETVAL(handled); 470 return IRQ_RETVAL(handled);
472} 471}
473 472
474static void sil_freeze(struct ata_port *ap) 473static void sil_freeze(struct ata_port *ap)
475{ 474{
476 void __iomem *mmio_base = ap->host_set->mmio_base; 475 void __iomem *mmio_base = ap->host->mmio_base;
477 u32 tmp; 476 u32 tmp;
478 477
479 /* global IRQ mask doesn't block SATA IRQ, turn off explicitly */ 478 /* global IRQ mask doesn't block SATA IRQ, turn off explicitly */
@@ -488,7 +487,7 @@ static void sil_freeze(struct ata_port *ap)
488 487
489static void sil_thaw(struct ata_port *ap) 488static void sil_thaw(struct ata_port *ap)
490{ 489{
491 void __iomem *mmio_base = ap->host_set->mmio_base; 490 void __iomem *mmio_base = ap->host->mmio_base;
492 u32 tmp; 491 u32 tmp;
493 492
494 /* clear IRQ */ 493 /* clear IRQ */
@@ -567,7 +566,7 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
567} 566}
568 567
569static void sil_init_controller(struct pci_dev *pdev, 568static void sil_init_controller(struct pci_dev *pdev,
570 int n_ports, unsigned long host_flags, 569 int n_ports, unsigned long port_flags,
571 void __iomem *mmio_base) 570 void __iomem *mmio_base)
572{ 571{
573 u8 cls; 572 u8 cls;
@@ -587,7 +586,7 @@ static void sil_init_controller(struct pci_dev *pdev,
587 "cache line size not set. Driver may not function\n"); 586 "cache line size not set. Driver may not function\n");
588 587
589 /* Apply R_ERR on DMA activate FIS errata workaround */ 588 /* Apply R_ERR on DMA activate FIS errata workaround */
590 if (host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { 589 if (port_flags & SIL_FLAG_RERR_ON_DMA_ACT) {
591 int cnt; 590 int cnt;
592 591
593 for (i = 0, cnt = 0; i < n_ports; i++) { 592 for (i = 0, cnt = 0; i < n_ports; i++) {
@@ -658,7 +657,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
658 probe_ent->udma_mask = sil_port_info[ent->driver_data].udma_mask; 657 probe_ent->udma_mask = sil_port_info[ent->driver_data].udma_mask;
659 probe_ent->irq = pdev->irq; 658 probe_ent->irq = pdev->irq;
660 probe_ent->irq_flags = IRQF_SHARED; 659 probe_ent->irq_flags = IRQF_SHARED;
661 probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags; 660 probe_ent->port_flags = sil_port_info[ent->driver_data].flags;
662 661
663 mmio_base = pci_iomap(pdev, 5, 0); 662 mmio_base = pci_iomap(pdev, 5, 0);
664 if (mmio_base == NULL) { 663 if (mmio_base == NULL) {
@@ -679,7 +678,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
679 ata_std_ports(&probe_ent->port[i]); 678 ata_std_ports(&probe_ent->port[i]);
680 } 679 }
681 680
682 sil_init_controller(pdev, probe_ent->n_ports, probe_ent->host_flags, 681 sil_init_controller(pdev, probe_ent->n_ports, probe_ent->port_flags,
683 mmio_base); 682 mmio_base);
684 683
685 pci_set_master(pdev); 684 pci_set_master(pdev);
@@ -700,21 +699,23 @@ err_out:
700 return rc; 699 return rc;
701} 700}
702 701
702#ifdef CONFIG_PM
703static int sil_pci_device_resume(struct pci_dev *pdev) 703static int sil_pci_device_resume(struct pci_dev *pdev)
704{ 704{
705 struct ata_host_set *host_set = dev_get_drvdata(&pdev->dev); 705 struct ata_host *host = dev_get_drvdata(&pdev->dev);
706 706
707 ata_pci_device_do_resume(pdev); 707 ata_pci_device_do_resume(pdev);
708 sil_init_controller(pdev, host_set->n_ports, host_set->ports[0]->flags, 708 sil_init_controller(pdev, host->n_ports, host->ports[0]->flags,
709 host_set->mmio_base); 709 host->mmio_base);
710 ata_host_set_resume(host_set); 710 ata_host_resume(host);
711 711
712 return 0; 712 return 0;
713} 713}
714#endif
714 715
715static int __init sil_init(void) 716static int __init sil_init(void)
716{ 717{
717 return pci_module_init(&sil_pci_driver); 718 return pci_register_driver(&sil_pci_driver);
718} 719}
719 720
720static void __exit sil_exit(void) 721static void __exit sil_exit(void)
diff --git a/drivers/scsi/sata_sil24.c b/drivers/ata/sata_sil24.c
index 3f368c7d3ef9..39cb07baebae 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -316,7 +316,7 @@ struct sil24_port_priv {
316 struct ata_taskfile tf; /* Cached taskfile registers */ 316 struct ata_taskfile tf; /* Cached taskfile registers */
317}; 317};
318 318
319/* ap->host_set->private_data */ 319/* ap->host->private_data */
320struct sil24_host_priv { 320struct sil24_host_priv {
321 void __iomem *host_base; /* global controller control (128 bytes @BAR0) */ 321 void __iomem *host_base; /* global controller control (128 bytes @BAR0) */
322 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */ 322 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */
@@ -337,9 +337,11 @@ static void sil24_error_handler(struct ata_port *ap);
337static void sil24_post_internal_cmd(struct ata_queued_cmd *qc); 337static void sil24_post_internal_cmd(struct ata_queued_cmd *qc);
338static int sil24_port_start(struct ata_port *ap); 338static int sil24_port_start(struct ata_port *ap);
339static void sil24_port_stop(struct ata_port *ap); 339static void sil24_port_stop(struct ata_port *ap);
340static void sil24_host_stop(struct ata_host_set *host_set); 340static void sil24_host_stop(struct ata_host *host);
341static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 341static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
342#ifdef CONFIG_PM
342static int sil24_pci_device_resume(struct pci_dev *pdev); 343static int sil24_pci_device_resume(struct pci_dev *pdev);
344#endif
343 345
344static const struct pci_device_id sil24_pci_tbl[] = { 346static const struct pci_device_id sil24_pci_tbl[] = {
345 { 0x1095, 0x3124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3124 }, 347 { 0x1095, 0x3124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3124 },
@@ -355,8 +357,10 @@ static struct pci_driver sil24_pci_driver = {
355 .id_table = sil24_pci_tbl, 357 .id_table = sil24_pci_tbl,
356 .probe = sil24_init_one, 358 .probe = sil24_init_one,
357 .remove = ata_pci_remove_one, /* safe? */ 359 .remove = ata_pci_remove_one, /* safe? */
360#ifdef CONFIG_PM
358 .suspend = ata_pci_device_suspend, 361 .suspend = ata_pci_device_suspend,
359 .resume = sil24_pci_device_resume, 362 .resume = sil24_pci_device_resume,
363#endif
360}; 364};
361 365
362static struct scsi_host_template sil24_sht = { 366static struct scsi_host_template sil24_sht = {
@@ -411,7 +415,7 @@ static const struct ata_port_operations sil24_ops = {
411}; 415};
412 416
413/* 417/*
414 * Use bits 30-31 of host_flags to encode available port numbers. 418 * Use bits 30-31 of port_flags to encode available port numbers.
415 * Current maxium is 4. 419 * Current maxium is 4.
416 */ 420 */
417#define SIL24_NPORTS2FLAG(nports) ((((unsigned)(nports) - 1) & 0x3) << 30) 421#define SIL24_NPORTS2FLAG(nports) ((((unsigned)(nports) - 1) & 0x3) << 30)
@@ -421,7 +425,7 @@ static struct ata_port_info sil24_port_info[] = {
421 /* sil_3124 */ 425 /* sil_3124 */
422 { 426 {
423 .sht = &sil24_sht, 427 .sht = &sil24_sht,
424 .host_flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(4) | 428 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(4) |
425 SIL24_FLAG_PCIX_IRQ_WOC, 429 SIL24_FLAG_PCIX_IRQ_WOC,
426 .pio_mask = 0x1f, /* pio0-4 */ 430 .pio_mask = 0x1f, /* pio0-4 */
427 .mwdma_mask = 0x07, /* mwdma0-2 */ 431 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -431,7 +435,7 @@ static struct ata_port_info sil24_port_info[] = {
431 /* sil_3132 */ 435 /* sil_3132 */
432 { 436 {
433 .sht = &sil24_sht, 437 .sht = &sil24_sht,
434 .host_flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(2), 438 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(2),
435 .pio_mask = 0x1f, /* pio0-4 */ 439 .pio_mask = 0x1f, /* pio0-4 */
436 .mwdma_mask = 0x07, /* mwdma0-2 */ 440 .mwdma_mask = 0x07, /* mwdma0-2 */
437 .udma_mask = 0x3f, /* udma0-5 */ 441 .udma_mask = 0x3f, /* udma0-5 */
@@ -440,7 +444,7 @@ static struct ata_port_info sil24_port_info[] = {
440 /* sil_3131/sil_3531 */ 444 /* sil_3131/sil_3531 */
441 { 445 {
442 .sht = &sil24_sht, 446 .sht = &sil24_sht,
443 .host_flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(1), 447 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(1),
444 .pio_mask = 0x1f, /* pio0-4 */ 448 .pio_mask = 0x1f, /* pio0-4 */
445 .mwdma_mask = 0x07, /* mwdma0-2 */ 449 .mwdma_mask = 0x07, /* mwdma0-2 */
446 .udma_mask = 0x3f, /* udma0-5 */ 450 .udma_mask = 0x3f, /* udma0-5 */
@@ -867,8 +871,8 @@ static inline void sil24_host_intr(struct ata_port *ap)
867 871
868static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 872static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
869{ 873{
870 struct ata_host_set *host_set = dev_instance; 874 struct ata_host *host = dev_instance;
871 struct sil24_host_priv *hpriv = host_set->private_data; 875 struct sil24_host_priv *hpriv = host->private_data;
872 unsigned handled = 0; 876 unsigned handled = 0;
873 u32 status; 877 u32 status;
874 int i; 878 int i;
@@ -884,20 +888,20 @@ static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *
884 if (!(status & IRQ_STAT_4PORTS)) 888 if (!(status & IRQ_STAT_4PORTS))
885 goto out; 889 goto out;
886 890
887 spin_lock(&host_set->lock); 891 spin_lock(&host->lock);
888 892
889 for (i = 0; i < host_set->n_ports; i++) 893 for (i = 0; i < host->n_ports; i++)
890 if (status & (1 << i)) { 894 if (status & (1 << i)) {
891 struct ata_port *ap = host_set->ports[i]; 895 struct ata_port *ap = host->ports[i];
892 if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { 896 if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
893 sil24_host_intr(host_set->ports[i]); 897 sil24_host_intr(host->ports[i]);
894 handled++; 898 handled++;
895 } else 899 } else
896 printk(KERN_ERR DRV_NAME 900 printk(KERN_ERR DRV_NAME
897 ": interrupt from disabled port %d\n", i); 901 ": interrupt from disabled port %d\n", i);
898 } 902 }
899 903
900 spin_unlock(&host_set->lock); 904 spin_unlock(&host->lock);
901 out: 905 out:
902 return IRQ_RETVAL(handled); 906 return IRQ_RETVAL(handled);
903} 907}
@@ -937,7 +941,7 @@ static inline void sil24_cblk_free(struct sil24_port_priv *pp, struct device *de
937 941
938static int sil24_port_start(struct ata_port *ap) 942static int sil24_port_start(struct ata_port *ap)
939{ 943{
940 struct device *dev = ap->host_set->dev; 944 struct device *dev = ap->host->dev;
941 struct sil24_port_priv *pp; 945 struct sil24_port_priv *pp;
942 union sil24_cmd_block *cb; 946 union sil24_cmd_block *cb;
943 size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS; 947 size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS;
@@ -976,7 +980,7 @@ err_out:
976 980
977static void sil24_port_stop(struct ata_port *ap) 981static void sil24_port_stop(struct ata_port *ap)
978{ 982{
979 struct device *dev = ap->host_set->dev; 983 struct device *dev = ap->host->dev;
980 struct sil24_port_priv *pp = ap->private_data; 984 struct sil24_port_priv *pp = ap->private_data;
981 985
982 sil24_cblk_free(pp, dev); 986 sil24_cblk_free(pp, dev);
@@ -984,10 +988,10 @@ static void sil24_port_stop(struct ata_port *ap)
984 kfree(pp); 988 kfree(pp);
985} 989}
986 990
987static void sil24_host_stop(struct ata_host_set *host_set) 991static void sil24_host_stop(struct ata_host *host)
988{ 992{
989 struct sil24_host_priv *hpriv = host_set->private_data; 993 struct sil24_host_priv *hpriv = host->private_data;
990 struct pci_dev *pdev = to_pci_dev(host_set->dev); 994 struct pci_dev *pdev = to_pci_dev(host->dev);
991 995
992 pci_iounmap(pdev, hpriv->host_base); 996 pci_iounmap(pdev, hpriv->host_base);
993 pci_iounmap(pdev, hpriv->port_base); 997 pci_iounmap(pdev, hpriv->port_base);
@@ -995,7 +999,7 @@ static void sil24_host_stop(struct ata_host_set *host_set)
995} 999}
996 1000
997static void sil24_init_controller(struct pci_dev *pdev, int n_ports, 1001static void sil24_init_controller(struct pci_dev *pdev, int n_ports,
998 unsigned long host_flags, 1002 unsigned long port_flags,
999 void __iomem *host_base, 1003 void __iomem *host_base,
1000 void __iomem *port_base) 1004 void __iomem *port_base)
1001{ 1005{
@@ -1028,7 +1032,7 @@ static void sil24_init_controller(struct pci_dev *pdev, int n_ports,
1028 } 1032 }
1029 1033
1030 /* Configure IRQ WoC */ 1034 /* Configure IRQ WoC */
1031 if (host_flags & SIL24_FLAG_PCIX_IRQ_WOC) 1035 if (port_flags & SIL24_FLAG_PCIX_IRQ_WOC)
1032 writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_STAT); 1036 writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_STAT);
1033 else 1037 else
1034 writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_CLR); 1038 writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_CLR);
@@ -1097,12 +1101,12 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1097 INIT_LIST_HEAD(&probe_ent->node); 1101 INIT_LIST_HEAD(&probe_ent->node);
1098 1102
1099 probe_ent->sht = pinfo->sht; 1103 probe_ent->sht = pinfo->sht;
1100 probe_ent->host_flags = pinfo->host_flags; 1104 probe_ent->port_flags = pinfo->flags;
1101 probe_ent->pio_mask = pinfo->pio_mask; 1105 probe_ent->pio_mask = pinfo->pio_mask;
1102 probe_ent->mwdma_mask = pinfo->mwdma_mask; 1106 probe_ent->mwdma_mask = pinfo->mwdma_mask;
1103 probe_ent->udma_mask = pinfo->udma_mask; 1107 probe_ent->udma_mask = pinfo->udma_mask;
1104 probe_ent->port_ops = pinfo->port_ops; 1108 probe_ent->port_ops = pinfo->port_ops;
1105 probe_ent->n_ports = SIL24_FLAG2NPORTS(pinfo->host_flags); 1109 probe_ent->n_ports = SIL24_FLAG2NPORTS(pinfo->flags);
1106 1110
1107 probe_ent->irq = pdev->irq; 1111 probe_ent->irq = pdev->irq;
1108 probe_ent->irq_flags = IRQF_SHARED; 1112 probe_ent->irq_flags = IRQF_SHARED;
@@ -1140,14 +1144,14 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1140 } 1144 }
1141 1145
1142 /* Apply workaround for completion IRQ loss on PCI-X errata */ 1146 /* Apply workaround for completion IRQ loss on PCI-X errata */
1143 if (probe_ent->host_flags & SIL24_FLAG_PCIX_IRQ_WOC) { 1147 if (probe_ent->port_flags & SIL24_FLAG_PCIX_IRQ_WOC) {
1144 tmp = readl(host_base + HOST_CTRL); 1148 tmp = readl(host_base + HOST_CTRL);
1145 if (tmp & (HOST_CTRL_TRDY | HOST_CTRL_STOP | HOST_CTRL_DEVSEL)) 1149 if (tmp & (HOST_CTRL_TRDY | HOST_CTRL_STOP | HOST_CTRL_DEVSEL))
1146 dev_printk(KERN_INFO, &pdev->dev, 1150 dev_printk(KERN_INFO, &pdev->dev,
1147 "Applying completion IRQ loss on PCI-X " 1151 "Applying completion IRQ loss on PCI-X "
1148 "errata fix\n"); 1152 "errata fix\n");
1149 else 1153 else
1150 probe_ent->host_flags &= ~SIL24_FLAG_PCIX_IRQ_WOC; 1154 probe_ent->port_flags &= ~SIL24_FLAG_PCIX_IRQ_WOC;
1151 } 1155 }
1152 1156
1153 for (i = 0; i < probe_ent->n_ports; i++) { 1157 for (i = 0; i < probe_ent->n_ports; i++) {
@@ -1160,7 +1164,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1160 ata_std_ports(&probe_ent->port[i]); 1164 ata_std_ports(&probe_ent->port[i]);
1161 } 1165 }
1162 1166
1163 sil24_init_controller(pdev, probe_ent->n_ports, probe_ent->host_flags, 1167 sil24_init_controller(pdev, probe_ent->n_ports, probe_ent->port_flags,
1164 host_base, port_base); 1168 host_base, port_base);
1165 1169
1166 pci_set_master(pdev); 1170 pci_set_master(pdev);
@@ -1184,28 +1188,29 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1184 return rc; 1188 return rc;
1185} 1189}
1186 1190
1191#ifdef CONFIG_PM
1187static int sil24_pci_device_resume(struct pci_dev *pdev) 1192static int sil24_pci_device_resume(struct pci_dev *pdev)
1188{ 1193{
1189 struct ata_host_set *host_set = dev_get_drvdata(&pdev->dev); 1194 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1190 struct sil24_host_priv *hpriv = host_set->private_data; 1195 struct sil24_host_priv *hpriv = host->private_data;
1191 1196
1192 ata_pci_device_do_resume(pdev); 1197 ata_pci_device_do_resume(pdev);
1193 1198
1194 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) 1199 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND)
1195 writel(HOST_CTRL_GLOBAL_RST, hpriv->host_base + HOST_CTRL); 1200 writel(HOST_CTRL_GLOBAL_RST, hpriv->host_base + HOST_CTRL);
1196 1201
1197 sil24_init_controller(pdev, host_set->n_ports, 1202 sil24_init_controller(pdev, host->n_ports, host->ports[0]->flags,
1198 host_set->ports[0]->flags,
1199 hpriv->host_base, hpriv->port_base); 1203 hpriv->host_base, hpriv->port_base);
1200 1204
1201 ata_host_set_resume(host_set); 1205 ata_host_resume(host);
1202 1206
1203 return 0; 1207 return 0;
1204} 1208}
1209#endif
1205 1210
1206static int __init sil24_init(void) 1211static int __init sil24_init(void)
1207{ 1212{
1208 return pci_module_init(&sil24_pci_driver); 1213 return pci_register_driver(&sil24_pci_driver);
1209} 1214}
1210 1215
1211static void __exit sil24_exit(void) 1216static void __exit sil24_exit(void)
diff --git a/drivers/scsi/sata_sis.c b/drivers/ata/sata_sis.c
index ee6b5df41d30..9b17375d8056 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -128,7 +128,7 @@ static const struct ata_port_operations sis_ops = {
128 128
129static struct ata_port_info sis_port_info = { 129static struct ata_port_info sis_port_info = {
130 .sht = &sis_sht, 130 .sht = &sis_sht,
131 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 131 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
132 .pio_mask = 0x1f, 132 .pio_mask = 0x1f,
133 .mwdma_mask = 0x7, 133 .mwdma_mask = 0x7,
134 .udma_mask = 0x7f, 134 .udma_mask = 0x7f,
@@ -158,7 +158,7 @@ static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg,
158 158
159static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) 159static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
160{ 160{
161 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 161 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
162 unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg, pdev->device); 162 unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg, pdev->device);
163 u32 val, val2 = 0; 163 u32 val, val2 = 0;
164 u8 pmr; 164 u8 pmr;
@@ -178,7 +178,7 @@ static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
178 178
179static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) 179static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
180{ 180{
181 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 181 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
182 unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr, pdev->device); 182 unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr, pdev->device);
183 u8 pmr; 183 u8 pmr;
184 184
@@ -195,7 +195,7 @@ static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
195 195
196static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg) 196static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg)
197{ 197{
198 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 198 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
199 u32 val, val2 = 0; 199 u32 val, val2 = 0;
200 u8 pmr; 200 u8 pmr;
201 201
@@ -217,7 +217,7 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg)
217 217
218static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 218static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
219{ 219{
220 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 220 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
221 u8 pmr; 221 u8 pmr;
222 222
223 if (sc_reg > SCR_CONTROL) 223 if (sc_reg > SCR_CONTROL)
@@ -275,17 +275,17 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
275 /* check and see if the SCRs are in IO space or PCI cfg space */ 275 /* check and see if the SCRs are in IO space or PCI cfg space */
276 pci_read_config_dword(pdev, SIS_GENCTL, &genctl); 276 pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
277 if ((genctl & GENCTL_IOMAPPED_SCR) == 0) 277 if ((genctl & GENCTL_IOMAPPED_SCR) == 0)
278 probe_ent->host_flags |= SIS_FLAG_CFGSCR; 278 probe_ent->port_flags |= SIS_FLAG_CFGSCR;
279 279
280 /* if hardware thinks SCRs are in IO space, but there are 280 /* if hardware thinks SCRs are in IO space, but there are
281 * no IO resources assigned, change to PCI cfg space. 281 * no IO resources assigned, change to PCI cfg space.
282 */ 282 */
283 if ((!(probe_ent->host_flags & SIS_FLAG_CFGSCR)) && 283 if ((!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) &&
284 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) || 284 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) ||
285 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) { 285 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
286 genctl &= ~GENCTL_IOMAPPED_SCR; 286 genctl &= ~GENCTL_IOMAPPED_SCR;
287 pci_write_config_dword(pdev, SIS_GENCTL, genctl); 287 pci_write_config_dword(pdev, SIS_GENCTL, genctl);
288 probe_ent->host_flags |= SIS_FLAG_CFGSCR; 288 probe_ent->port_flags |= SIS_FLAG_CFGSCR;
289 } 289 }
290 290
291 pci_read_config_byte(pdev, SIS_PMR, &pmr); 291 pci_read_config_byte(pdev, SIS_PMR, &pmr);
@@ -306,7 +306,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
306 port2_start = 0x20; 306 port2_start = 0x20;
307 } 307 }
308 308
309 if (!(probe_ent->host_flags & SIS_FLAG_CFGSCR)) { 309 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) {
310 probe_ent->port[0].scr_addr = 310 probe_ent->port[0].scr_addr =
311 pci_resource_start(pdev, SIS_SCR_PCI_BAR); 311 pci_resource_start(pdev, SIS_SCR_PCI_BAR);
312 probe_ent->port[1].scr_addr = 312 probe_ent->port[1].scr_addr =
@@ -334,7 +334,7 @@ err_out:
334 334
335static int __init sis_init(void) 335static int __init sis_init(void)
336{ 336{
337 return pci_module_init(&sis_pci_driver); 337 return pci_register_driver(&sis_pci_driver);
338} 338}
339 339
340static void __exit sis_exit(void) 340static void __exit sis_exit(void)
diff --git a/drivers/scsi/sata_svw.c b/drivers/ata/sata_svw.c
index 7d0858095e1f..2a7e3495cf16 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -169,7 +169,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
169 * @qc: Info associated with this ATA transaction. 169 * @qc: Info associated with this ATA transaction.
170 * 170 *
171 * LOCKING: 171 * LOCKING:
172 * spin_lock_irqsave(host_set lock) 172 * spin_lock_irqsave(host lock)
173 */ 173 */
174 174
175static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc) 175static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc)
@@ -199,7 +199,7 @@ static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc)
199 * @qc: Info associated with this ATA transaction. 199 * @qc: Info associated with this ATA transaction.
200 * 200 *
201 * LOCKING: 201 * LOCKING:
202 * spin_lock_irqsave(host_set lock) 202 * spin_lock_irqsave(host lock)
203 */ 203 */
204 204
205static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc) 205static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc)
@@ -261,12 +261,12 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start,
261 return 0; 261 return 0;
262 262
263 /* Find the OF node for the PCI device proper */ 263 /* Find the OF node for the PCI device proper */
264 np = pci_device_to_OF_node(to_pci_dev(ap->host_set->dev)); 264 np = pci_device_to_OF_node(to_pci_dev(ap->host->dev));
265 if (np == NULL) 265 if (np == NULL)
266 return 0; 266 return 0;
267 267
268 /* Match it to a port node */ 268 /* Match it to a port node */
269 index = (ap == ap->host_set->ports[0]) ? 0 : 1; 269 index = (ap == ap->host->ports[0]) ? 0 : 1;
270 for (np = np->child; np != NULL; np = np->sibling) { 270 for (np = np->child; np != NULL; np = np->sibling) {
271 u32 *reg = (u32 *)get_property(np, "reg", NULL); 271 u32 *reg = (u32 *)get_property(np, "reg", NULL);
272 if (!reg) 272 if (!reg)
@@ -423,7 +423,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
423 writel(0x0, mmio_base + K2_SATA_SIM_OFFSET); 423 writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);
424 424
425 probe_ent->sht = &k2_sata_sht; 425 probe_ent->sht = &k2_sata_sht;
426 probe_ent->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 426 probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
427 ATA_FLAG_MMIO; 427 ATA_FLAG_MMIO;
428 probe_ent->port_ops = &k2_sata_ops; 428 probe_ent->port_ops = &k2_sata_ops;
429 probe_ent->n_ports = 4; 429 probe_ent->n_ports = 4;
@@ -488,7 +488,7 @@ static struct pci_driver k2_sata_pci_driver = {
488 488
489static int __init k2_sata_init(void) 489static int __init k2_sata_init(void)
490{ 490{
491 return pci_module_init(&k2_sata_pci_driver); 491 return pci_register_driver(&k2_sata_pci_driver);
492} 492}
493 493
494 494
diff --git a/drivers/scsi/sata_sx4.c b/drivers/ata/sata_sx4.c
index ccc8cad24f7d..091867e10ea3 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -160,7 +160,7 @@ static void pdc_port_stop(struct ata_port *ap);
160static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 160static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
161static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 161static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
162static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 162static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
163static void pdc20621_host_stop(struct ata_host_set *host_set); 163static void pdc20621_host_stop(struct ata_host *host);
164static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); 164static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
165static int pdc20621_detect_dimm(struct ata_probe_ent *pe); 165static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
166static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, 166static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe,
@@ -218,7 +218,7 @@ static const struct ata_port_info pdc_port_info[] = {
218 /* board_20621 */ 218 /* board_20621 */
219 { 219 {
220 .sht = &pdc_sata_sht, 220 .sht = &pdc_sata_sht,
221 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 221 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
222 ATA_FLAG_SRST | ATA_FLAG_MMIO | 222 ATA_FLAG_SRST | ATA_FLAG_MMIO |
223 ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING, 223 ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING,
224 .pio_mask = 0x1f, /* pio0-4 */ 224 .pio_mask = 0x1f, /* pio0-4 */
@@ -244,21 +244,21 @@ static struct pci_driver pdc_sata_pci_driver = {
244}; 244};
245 245
246 246
247static void pdc20621_host_stop(struct ata_host_set *host_set) 247static void pdc20621_host_stop(struct ata_host *host)
248{ 248{
249 struct pci_dev *pdev = to_pci_dev(host_set->dev); 249 struct pci_dev *pdev = to_pci_dev(host->dev);
250 struct pdc_host_priv *hpriv = host_set->private_data; 250 struct pdc_host_priv *hpriv = host->private_data;
251 void __iomem *dimm_mmio = hpriv->dimm_mmio; 251 void __iomem *dimm_mmio = hpriv->dimm_mmio;
252 252
253 pci_iounmap(pdev, dimm_mmio); 253 pci_iounmap(pdev, dimm_mmio);
254 kfree(hpriv); 254 kfree(hpriv);
255 255
256 pci_iounmap(pdev, host_set->mmio_base); 256 pci_iounmap(pdev, host->mmio_base);
257} 257}
258 258
259static int pdc_port_start(struct ata_port *ap) 259static int pdc_port_start(struct ata_port *ap)
260{ 260{
261 struct device *dev = ap->host_set->dev; 261 struct device *dev = ap->host->dev;
262 struct pdc_port_priv *pp; 262 struct pdc_port_priv *pp;
263 int rc; 263 int rc;
264 264
@@ -293,7 +293,7 @@ err_out:
293 293
294static void pdc_port_stop(struct ata_port *ap) 294static void pdc_port_stop(struct ata_port *ap)
295{ 295{
296 struct device *dev = ap->host_set->dev; 296 struct device *dev = ap->host->dev;
297 struct pdc_port_priv *pp = ap->private_data; 297 struct pdc_port_priv *pp = ap->private_data;
298 298
299 ap->private_data = NULL; 299 ap->private_data = NULL;
@@ -453,8 +453,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
453 struct scatterlist *sg; 453 struct scatterlist *sg;
454 struct ata_port *ap = qc->ap; 454 struct ata_port *ap = qc->ap;
455 struct pdc_port_priv *pp = ap->private_data; 455 struct pdc_port_priv *pp = ap->private_data;
456 void __iomem *mmio = ap->host_set->mmio_base; 456 void __iomem *mmio = ap->host->mmio_base;
457 struct pdc_host_priv *hpriv = ap->host_set->private_data; 457 struct pdc_host_priv *hpriv = ap->host->private_data;
458 void __iomem *dimm_mmio = hpriv->dimm_mmio; 458 void __iomem *dimm_mmio = hpriv->dimm_mmio;
459 unsigned int portno = ap->port_no; 459 unsigned int portno = ap->port_no;
460 unsigned int i, idx, total_len = 0, sgt_len; 460 unsigned int i, idx, total_len = 0, sgt_len;
@@ -514,8 +514,8 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
514{ 514{
515 struct ata_port *ap = qc->ap; 515 struct ata_port *ap = qc->ap;
516 struct pdc_port_priv *pp = ap->private_data; 516 struct pdc_port_priv *pp = ap->private_data;
517 void __iomem *mmio = ap->host_set->mmio_base; 517 void __iomem *mmio = ap->host->mmio_base;
518 struct pdc_host_priv *hpriv = ap->host_set->private_data; 518 struct pdc_host_priv *hpriv = ap->host->private_data;
519 void __iomem *dimm_mmio = hpriv->dimm_mmio; 519 void __iomem *dimm_mmio = hpriv->dimm_mmio;
520 unsigned int portno = ap->port_no; 520 unsigned int portno = ap->port_no;
521 unsigned int i; 521 unsigned int i;
@@ -565,8 +565,8 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
565 u32 pkt_ofs) 565 u32 pkt_ofs)
566{ 566{
567 struct ata_port *ap = qc->ap; 567 struct ata_port *ap = qc->ap;
568 struct ata_host_set *host_set = ap->host_set; 568 struct ata_host *host = ap->host;
569 void __iomem *mmio = host_set->mmio_base; 569 void __iomem *mmio = host->mmio_base;
570 570
571 /* hard-code chip #0 */ 571 /* hard-code chip #0 */
572 mmio += PDC_CHIP0_OFS; 572 mmio += PDC_CHIP0_OFS;
@@ -583,7 +583,7 @@ static void pdc20621_push_hdma(struct ata_queued_cmd *qc,
583 u32 pkt_ofs) 583 u32 pkt_ofs)
584{ 584{
585 struct ata_port *ap = qc->ap; 585 struct ata_port *ap = qc->ap;
586 struct pdc_host_priv *pp = ap->host_set->private_data; 586 struct pdc_host_priv *pp = ap->host->private_data;
587 unsigned int idx = pp->hdma_prod & PDC_HDMA_Q_MASK; 587 unsigned int idx = pp->hdma_prod & PDC_HDMA_Q_MASK;
588 588
589 if (!pp->doing_hdma) { 589 if (!pp->doing_hdma) {
@@ -601,7 +601,7 @@ static void pdc20621_push_hdma(struct ata_queued_cmd *qc,
601static void pdc20621_pop_hdma(struct ata_queued_cmd *qc) 601static void pdc20621_pop_hdma(struct ata_queued_cmd *qc)
602{ 602{
603 struct ata_port *ap = qc->ap; 603 struct ata_port *ap = qc->ap;
604 struct pdc_host_priv *pp = ap->host_set->private_data; 604 struct pdc_host_priv *pp = ap->host->private_data;
605 unsigned int idx = pp->hdma_cons & PDC_HDMA_Q_MASK; 605 unsigned int idx = pp->hdma_cons & PDC_HDMA_Q_MASK;
606 606
607 /* if nothing on queue, we're done */ 607 /* if nothing on queue, we're done */
@@ -620,7 +620,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc)
620{ 620{
621 struct ata_port *ap = qc->ap; 621 struct ata_port *ap = qc->ap;
622 unsigned int port_no = ap->port_no; 622 unsigned int port_no = ap->port_no;
623 struct pdc_host_priv *hpriv = ap->host_set->private_data; 623 struct pdc_host_priv *hpriv = ap->host->private_data;
624 void *dimm_mmio = hpriv->dimm_mmio; 624 void *dimm_mmio = hpriv->dimm_mmio;
625 625
626 dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP); 626 dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP);
@@ -638,9 +638,9 @@ static inline void pdc20621_dump_hdma(struct ata_queued_cmd *qc) { }
638static void pdc20621_packet_start(struct ata_queued_cmd *qc) 638static void pdc20621_packet_start(struct ata_queued_cmd *qc)
639{ 639{
640 struct ata_port *ap = qc->ap; 640 struct ata_port *ap = qc->ap;
641 struct ata_host_set *host_set = ap->host_set; 641 struct ata_host *host = ap->host;
642 unsigned int port_no = ap->port_no; 642 unsigned int port_no = ap->port_no;
643 void __iomem *mmio = host_set->mmio_base; 643 void __iomem *mmio = host->mmio_base;
644 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); 644 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
645 u8 seq = (u8) (port_no + 1); 645 u8 seq = (u8) (port_no + 1);
646 unsigned int port_ofs; 646 unsigned int port_ofs;
@@ -781,8 +781,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
781 781
782static void pdc20621_irq_clear(struct ata_port *ap) 782static void pdc20621_irq_clear(struct ata_port *ap)
783{ 783{
784 struct ata_host_set *host_set = ap->host_set; 784 struct ata_host *host = ap->host;
785 void __iomem *mmio = host_set->mmio_base; 785 void __iomem *mmio = host->mmio_base;
786 786
787 mmio += PDC_CHIP0_OFS; 787 mmio += PDC_CHIP0_OFS;
788 788
@@ -791,7 +791,7 @@ static void pdc20621_irq_clear(struct ata_port *ap)
791 791
792static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 792static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
793{ 793{
794 struct ata_host_set *host_set = dev_instance; 794 struct ata_host *host = dev_instance;
795 struct ata_port *ap; 795 struct ata_port *ap;
796 u32 mask = 0; 796 u32 mask = 0;
797 unsigned int i, tmp, port_no; 797 unsigned int i, tmp, port_no;
@@ -800,12 +800,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
800 800
801 VPRINTK("ENTER\n"); 801 VPRINTK("ENTER\n");
802 802
803 if (!host_set || !host_set->mmio_base) { 803 if (!host || !host->mmio_base) {
804 VPRINTK("QUICK EXIT\n"); 804 VPRINTK("QUICK EXIT\n");
805 return IRQ_NONE; 805 return IRQ_NONE;
806 } 806 }
807 807
808 mmio_base = host_set->mmio_base; 808 mmio_base = host->mmio_base;
809 809
810 /* reading should also clear interrupts */ 810 /* reading should also clear interrupts */
811 mmio_base += PDC_CHIP0_OFS; 811 mmio_base += PDC_CHIP0_OFS;
@@ -822,16 +822,16 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
822 return IRQ_NONE; 822 return IRQ_NONE;
823 } 823 }
824 824
825 spin_lock(&host_set->lock); 825 spin_lock(&host->lock);
826 826
827 for (i = 1; i < 9; i++) { 827 for (i = 1; i < 9; i++) {
828 port_no = i - 1; 828 port_no = i - 1;
829 if (port_no > 3) 829 if (port_no > 3)
830 port_no -= 4; 830 port_no -= 4;
831 if (port_no >= host_set->n_ports) 831 if (port_no >= host->n_ports)
832 ap = NULL; 832 ap = NULL;
833 else 833 else
834 ap = host_set->ports[port_no]; 834 ap = host->ports[port_no];
835 tmp = mask & (1 << i); 835 tmp = mask & (1 << i);
836 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); 836 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
837 if (tmp && ap && 837 if (tmp && ap &&
@@ -845,7 +845,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
845 } 845 }
846 } 846 }
847 847
848 spin_unlock(&host_set->lock); 848 spin_unlock(&host->lock);
849 849
850 VPRINTK("mask == 0x%x\n", mask); 850 VPRINTK("mask == 0x%x\n", mask);
851 851
@@ -857,13 +857,13 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
857static void pdc_eng_timeout(struct ata_port *ap) 857static void pdc_eng_timeout(struct ata_port *ap)
858{ 858{
859 u8 drv_stat; 859 u8 drv_stat;
860 struct ata_host_set *host_set = ap->host_set; 860 struct ata_host *host = ap->host;
861 struct ata_queued_cmd *qc; 861 struct ata_queued_cmd *qc;
862 unsigned long flags; 862 unsigned long flags;
863 863
864 DPRINTK("ENTER\n"); 864 DPRINTK("ENTER\n");
865 865
866 spin_lock_irqsave(&host_set->lock, flags); 866 spin_lock_irqsave(&host->lock, flags);
867 867
868 qc = ata_qc_from_tag(ap, ap->active_tag); 868 qc = ata_qc_from_tag(ap, ap->active_tag);
869 869
@@ -885,7 +885,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
885 break; 885 break;
886 } 886 }
887 887
888 spin_unlock_irqrestore(&host_set->lock, flags); 888 spin_unlock_irqrestore(&host->lock, flags);
889 ata_eh_qc_complete(qc); 889 ata_eh_qc_complete(qc);
890 DPRINTK("EXIT\n"); 890 DPRINTK("EXIT\n");
891} 891}
@@ -1429,7 +1429,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1429 hpriv->dimm_mmio = dimm_mmio; 1429 hpriv->dimm_mmio = dimm_mmio;
1430 1430
1431 probe_ent->sht = pdc_port_info[board_idx].sht; 1431 probe_ent->sht = pdc_port_info[board_idx].sht;
1432 probe_ent->host_flags = pdc_port_info[board_idx].host_flags; 1432 probe_ent->port_flags = pdc_port_info[board_idx].flags;
1433 probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; 1433 probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask;
1434 probe_ent->mwdma_mask = pdc_port_info[board_idx].mwdma_mask; 1434 probe_ent->mwdma_mask = pdc_port_info[board_idx].mwdma_mask;
1435 probe_ent->udma_mask = pdc_port_info[board_idx].udma_mask; 1435 probe_ent->udma_mask = pdc_port_info[board_idx].udma_mask;
@@ -1482,7 +1482,7 @@ err_out:
1482 1482
1483static int __init pdc_sata_init(void) 1483static int __init pdc_sata_init(void)
1484{ 1484{
1485 return pci_module_init(&pdc_sata_pci_driver); 1485 return pci_register_driver(&pdc_sata_pci_driver);
1486} 1486}
1487 1487
1488 1488
diff --git a/drivers/scsi/sata_uli.c b/drivers/ata/sata_uli.c
index 33cdb4867ef1..8fc6e800011a 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -128,7 +128,7 @@ static const struct ata_port_operations uli_ops = {
128 128
129static struct ata_port_info uli_port_info = { 129static struct ata_port_info uli_port_info = {
130 .sht = &uli_sht, 130 .sht = &uli_sht,
131 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 131 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
132 .pio_mask = 0x1f, /* pio0-4 */ 132 .pio_mask = 0x1f, /* pio0-4 */
133 .udma_mask = 0x7f, /* udma0-6 */ 133 .udma_mask = 0x7f, /* udma0-6 */
134 .port_ops = &uli_ops, 134 .port_ops = &uli_ops,
@@ -143,13 +143,13 @@ MODULE_VERSION(DRV_VERSION);
143 143
144static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) 144static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
145{ 145{
146 struct uli_priv *hpriv = ap->host_set->private_data; 146 struct uli_priv *hpriv = ap->host->private_data;
147 return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); 147 return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg);
148} 148}
149 149
150static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) 150static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
151{ 151{
152 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 152 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
153 unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); 153 unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg);
154 u32 val; 154 u32 val;
155 155
@@ -159,7 +159,7 @@ static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
159 159
160static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) 160static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
161{ 161{
162 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 162 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
163 unsigned int cfg_addr = get_scr_cfg_addr(ap, scr); 163 unsigned int cfg_addr = get_scr_cfg_addr(ap, scr);
164 164
165 pci_write_config_dword(pdev, cfg_addr, val); 165 pci_write_config_dword(pdev, cfg_addr, val);
@@ -287,7 +287,7 @@ err_out:
287 287
288static int __init uli_init(void) 288static int __init uli_init(void)
289{ 289{
290 return pci_module_init(&uli_pci_driver); 290 return pci_register_driver(&uli_pci_driver);
291} 291}
292 292
293static void __exit uli_exit(void) 293static void __exit uli_exit(void)
diff --git a/drivers/scsi/sata_via.c b/drivers/ata/sata_via.c
index 01d40369a8a5..7f087aef99de 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -77,6 +77,7 @@ static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
77static void vt6420_error_handler(struct ata_port *ap); 77static void vt6420_error_handler(struct ata_port *ap);
78 78
79static const struct pci_device_id svia_pci_tbl[] = { 79static const struct pci_device_id svia_pci_tbl[] = {
80 { 0x1106, 0x0591, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 },
80 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 }, 81 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 },
81 { 0x1106, 0x3249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6421 }, 82 { 0x1106, 0x3249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6421 },
82 83
@@ -175,7 +176,7 @@ static const struct ata_port_operations vt6421_sata_ops = {
175 176
176static struct ata_port_info vt6420_port_info = { 177static struct ata_port_info vt6420_port_info = {
177 .sht = &svia_sht, 178 .sht = &svia_sht,
178 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 179 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
179 .pio_mask = 0x1f, 180 .pio_mask = 0x1f,
180 .mwdma_mask = 0x07, 181 .mwdma_mask = 0x07,
181 .udma_mask = 0x7f, 182 .udma_mask = 0x7f,
@@ -345,7 +346,7 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev)
345 INIT_LIST_HEAD(&probe_ent->node); 346 INIT_LIST_HEAD(&probe_ent->node);
346 347
347 probe_ent->sht = &svia_sht; 348 probe_ent->sht = &svia_sht;
348 probe_ent->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY; 349 probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY;
349 probe_ent->port_ops = &vt6421_sata_ops; 350 probe_ent->port_ops = &vt6421_sata_ops;
350 probe_ent->n_ports = N_PORTS; 351 probe_ent->n_ports = N_PORTS;
351 probe_ent->irq = pdev->irq; 352 probe_ent->irq = pdev->irq;
@@ -488,7 +489,7 @@ err_out:
488 489
489static int __init svia_init(void) 490static int __init svia_init(void)
490{ 491{
491 return pci_module_init(&svia_pci_driver); 492 return pci_register_driver(&svia_pci_driver);
492} 493}
493 494
494static void __exit svia_exit(void) 495static void __exit svia_exit(void)
diff --git a/drivers/scsi/sata_vsc.c b/drivers/ata/sata_vsc.c
index ad37871594f5..d0d92f33de54 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -123,7 +123,7 @@ static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
123 void __iomem *mask_addr; 123 void __iomem *mask_addr;
124 u8 mask; 124 u8 mask;
125 125
126 mask_addr = ap->host_set->mmio_base + 126 mask_addr = ap->host->mmio_base +
127 VSC_SATA_INT_MASK_OFFSET + ap->port_no; 127 VSC_SATA_INT_MASK_OFFSET + ap->port_no;
128 mask = readb(mask_addr); 128 mask = readb(mask_addr);
129 if (ctl & ATA_NIEN) 129 if (ctl & ATA_NIEN)
@@ -206,20 +206,20 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
206static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance, 206static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
207 struct pt_regs *regs) 207 struct pt_regs *regs)
208{ 208{
209 struct ata_host_set *host_set = dev_instance; 209 struct ata_host *host = dev_instance;
210 unsigned int i; 210 unsigned int i;
211 unsigned int handled = 0; 211 unsigned int handled = 0;
212 u32 int_status; 212 u32 int_status;
213 213
214 spin_lock(&host_set->lock); 214 spin_lock(&host->lock);
215 215
216 int_status = readl(host_set->mmio_base + VSC_SATA_INT_STAT_OFFSET); 216 int_status = readl(host->mmio_base + VSC_SATA_INT_STAT_OFFSET);
217 217
218 for (i = 0; i < host_set->n_ports; i++) { 218 for (i = 0; i < host->n_ports; i++) {
219 if (int_status & ((u32) 0xFF << (8 * i))) { 219 if (int_status & ((u32) 0xFF << (8 * i))) {
220 struct ata_port *ap; 220 struct ata_port *ap;
221 221
222 ap = host_set->ports[i]; 222 ap = host->ports[i];
223 223
224 if (is_vsc_sata_int_err(i, int_status)) { 224 if (is_vsc_sata_int_err(i, int_status)) {
225 u32 err_status; 225 u32 err_status;
@@ -259,7 +259,7 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
259 } 259 }
260 } 260 }
261 261
262 spin_unlock(&host_set->lock); 262 spin_unlock(&host->lock);
263 263
264 return IRQ_RETVAL(handled); 264 return IRQ_RETVAL(handled);
265} 265}
@@ -395,7 +395,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
395 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); 395 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80);
396 396
397 probe_ent->sht = &vsc_sata_sht; 397 probe_ent->sht = &vsc_sata_sht;
398 probe_ent->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 398 probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
399 ATA_FLAG_MMIO; 399 ATA_FLAG_MMIO;
400 probe_ent->port_ops = &vsc_sata_ops; 400 probe_ent->port_ops = &vsc_sata_ops;
401 probe_ent->n_ports = 4; 401 probe_ent->n_ports = 4;
@@ -462,7 +462,7 @@ static struct pci_driver vsc_sata_pci_driver = {
462 462
463static int __init vsc_sata_init(void) 463static int __init vsc_sata_init(void)
464{ 464{
465 return pci_module_init(&vsc_sata_pci_driver); 465 return pci_register_driver(&vsc_sata_pci_driver);
466} 466}
467 467
468 468
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 73177429fe74..b4970387a16f 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1209,7 +1209,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_
1209DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus ); 1209DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus );
1210DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus ); 1210DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus );
1211 1211
1212#if defined(CONFIG_SCSI_SATA) || defined(CONFIG_SCSI_SATA_MODULE) 1212#if defined(CONFIG_ATA) || defined(CONFIG_ATA_MODULE)
1213 1213
1214/* 1214/*
1215 * If we are using libata we can drive this chip properly but must 1215 * If we are using libata we can drive this chip properly but must
@@ -1299,7 +1299,7 @@ static int __init combined_setup(char *str)
1299} 1299}
1300__setup("combined_mode=", combined_setup); 1300__setup("combined_mode=", combined_setup);
1301 1301
1302#ifdef CONFIG_SCSI_SATA_INTEL_COMBINED 1302#ifdef CONFIG_SATA_INTEL_COMBINED
1303static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) 1303static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
1304{ 1304{
1305 u8 prog, comb, tmp; 1305 u8 prog, comb, tmp;
@@ -1392,7 +1392,7 @@ static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
1392 request_region(0x170, 8, "libata"); /* port 1 */ 1392 request_region(0x170, 8, "libata"); /* port 1 */
1393} 1393}
1394DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_intel_ide_combined ); 1394DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_intel_ide_combined );
1395#endif /* CONFIG_SCSI_SATA_INTEL_COMBINED */ 1395#endif /* CONFIG_SATA_INTEL_COMBINED */
1396 1396
1397 1397
1398int pcie_mch_quirk; 1398int pcie_mch_quirk;
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 96a81cd17617..2df4d15c9634 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -471,67 +471,6 @@ config SCSI_IN2000
471 471
472source "drivers/scsi/megaraid/Kconfig.megaraid" 472source "drivers/scsi/megaraid/Kconfig.megaraid"
473 473
474config SCSI_SATA
475 tristate "Serial ATA (SATA) support"
476 depends on SCSI
477 help
478 This driver family supports Serial ATA host controllers
479 and devices.
480
481 If unsure, say N.
482
483config SCSI_SATA_AHCI
484 tristate "AHCI SATA support"
485 depends on SCSI_SATA && PCI
486 help
487 This option enables support for AHCI Serial ATA.
488
489 If unsure, say N.
490
491config SCSI_SATA_SVW
492 tristate "ServerWorks Frodo / Apple K2 SATA support"
493 depends on SCSI_SATA && PCI
494 help
495 This option enables support for Broadcom/Serverworks/Apple K2
496 SATA support.
497
498 If unsure, say N.
499
500config SCSI_ATA_PIIX
501 tristate "Intel PIIX/ICH SATA support"
502 depends on SCSI_SATA && PCI
503 help
504 This option enables support for ICH5/6/7/8 Serial ATA.
505 If PATA support was enabled previously, this enables
506 support for select Intel PIIX/ICH PATA host controllers.
507
508 If unsure, say N.
509
510config SCSI_SATA_MV
511 tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)"
512 depends on SCSI_SATA && PCI && EXPERIMENTAL
513 help
514 This option enables support for the Marvell Serial ATA family.
515 Currently supports 88SX[56]0[48][01] chips.
516
517 If unsure, say N.
518
519config SCSI_SATA_NV
520 tristate "NVIDIA SATA support"
521 depends on SCSI_SATA && PCI && EXPERIMENTAL
522 help
523 This option enables support for NVIDIA Serial ATA.
524
525 If unsure, say N.
526
527config SCSI_PDC_ADMA
528 tristate "Pacific Digital ADMA support"
529 depends on SCSI_SATA && PCI
530 help
531 This option enables support for Pacific Digital ADMA controllers
532
533 If unsure, say N.
534
535config SCSI_HPTIOP 474config SCSI_HPTIOP
536 tristate "HighPoint RocketRAID 3xxx Controller support" 475 tristate "HighPoint RocketRAID 3xxx Controller support"
537 depends on SCSI && PCI 476 depends on SCSI && PCI
@@ -542,83 +481,6 @@ config SCSI_HPTIOP
542 To compile this driver as a module, choose M here; the module 481 To compile this driver as a module, choose M here; the module
543 will be called hptiop. If unsure, say N. 482 will be called hptiop. If unsure, say N.
544 483
545config SCSI_SATA_QSTOR
546 tristate "Pacific Digital SATA QStor support"
547 depends on SCSI_SATA && PCI
548 help
549 This option enables support for Pacific Digital Serial ATA QStor.
550
551 If unsure, say N.
552
553config SCSI_SATA_PROMISE
554 tristate "Promise SATA TX2/TX4 support"
555 depends on SCSI_SATA && PCI
556 help
557 This option enables support for Promise Serial ATA TX2/TX4.
558
559 If unsure, say N.
560
561config SCSI_SATA_SX4
562 tristate "Promise SATA SX4 support"
563 depends on SCSI_SATA && PCI && EXPERIMENTAL
564 help
565 This option enables support for Promise Serial ATA SX4.
566
567 If unsure, say N.
568
569config SCSI_SATA_SIL
570 tristate "Silicon Image SATA support"
571 depends on SCSI_SATA && PCI && EXPERIMENTAL
572 help
573 This option enables support for Silicon Image Serial ATA.
574
575 If unsure, say N.
576
577config SCSI_SATA_SIL24
578 tristate "Silicon Image 3124/3132 SATA support"
579 depends on SCSI_SATA && PCI && EXPERIMENTAL
580 help
581 This option enables support for Silicon Image 3124/3132 Serial ATA.
582
583 If unsure, say N.
584
585config SCSI_SATA_SIS
586 tristate "SiS 964/180 SATA support"
587 depends on SCSI_SATA && PCI && EXPERIMENTAL
588 help
589 This option enables support for SiS Serial ATA 964/180.
590
591 If unsure, say N.
592
593config SCSI_SATA_ULI
594 tristate "ULi Electronics SATA support"
595 depends on SCSI_SATA && PCI && EXPERIMENTAL
596 help
597 This option enables support for ULi Electronics SATA.
598
599 If unsure, say N.
600
601config SCSI_SATA_VIA
602 tristate "VIA SATA support"
603 depends on SCSI_SATA && PCI
604 help
605 This option enables support for VIA Serial ATA.
606
607 If unsure, say N.
608
609config SCSI_SATA_VITESSE
610 tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
611 depends on SCSI_SATA && PCI
612 help
613 This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
614
615 If unsure, say N.
616
617config SCSI_SATA_INTEL_COMBINED
618 bool
619 depends on IDE=y && !BLK_DEV_IDE_SATA && (SCSI_SATA_AHCI || SCSI_ATA_PIIX)
620 default y
621
622config SCSI_BUSLOGIC 484config SCSI_BUSLOGIC
623 tristate "BusLogic SCSI support" 485 tristate "BusLogic SCSI support"
624 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API 486 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index ebd0cf00bf3e..b678f957cfe2 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -122,21 +122,6 @@ obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
122obj-$(CONFIG_SCSI_NSP32) += nsp32.o 122obj-$(CONFIG_SCSI_NSP32) += nsp32.o
123obj-$(CONFIG_SCSI_IPR) += ipr.o 123obj-$(CONFIG_SCSI_IPR) += ipr.o
124obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/ 124obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/
125obj-$(CONFIG_SCSI_SATA_AHCI) += libata.o ahci.o
126obj-$(CONFIG_SCSI_SATA_SVW) += libata.o sata_svw.o
127obj-$(CONFIG_SCSI_ATA_PIIX) += libata.o ata_piix.o
128obj-$(CONFIG_SCSI_SATA_PROMISE) += libata.o sata_promise.o
129obj-$(CONFIG_SCSI_SATA_QSTOR) += libata.o sata_qstor.o
130obj-$(CONFIG_SCSI_SATA_SIL) += libata.o sata_sil.o
131obj-$(CONFIG_SCSI_SATA_SIL24) += libata.o sata_sil24.o
132obj-$(CONFIG_SCSI_SATA_VIA) += libata.o sata_via.o
133obj-$(CONFIG_SCSI_SATA_VITESSE) += libata.o sata_vsc.o
134obj-$(CONFIG_SCSI_SATA_SIS) += libata.o sata_sis.o
135obj-$(CONFIG_SCSI_SATA_SX4) += libata.o sata_sx4.o
136obj-$(CONFIG_SCSI_SATA_NV) += libata.o sata_nv.o
137obj-$(CONFIG_SCSI_SATA_ULI) += libata.o sata_uli.o
138obj-$(CONFIG_SCSI_SATA_MV) += libata.o sata_mv.o
139obj-$(CONFIG_SCSI_PDC_ADMA) += libata.o pdc_adma.o
140obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o 125obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
141 126
142obj-$(CONFIG_ARM) += arm/ 127obj-$(CONFIG_ARM) += arm/
@@ -166,7 +151,6 @@ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
166CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) 151CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m)
167zalon7xx-objs := zalon.o ncr53c8xx.o 152zalon7xx-objs := zalon.o ncr53c8xx.o
168NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o 153NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o
169libata-objs := libata-core.o libata-scsi.o libata-bmdma.o libata-eh.o
170oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o 154oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o
171 155
172# Files generated that shall be removed upon make clean 156# Files generated that shall be removed upon make clean
diff --git a/include/asm-alpha/libata-portmap.h b/include/asm-alpha/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-alpha/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/asm-generic/libata-portmap.h b/include/asm-generic/libata-portmap.h
new file mode 100644
index 000000000000..9202fd02d5be
--- /dev/null
+++ b/include/asm-generic/libata-portmap.h
@@ -0,0 +1,12 @@
1#ifndef __ASM_GENERIC_LIBATA_PORTMAP_H
2#define __ASM_GENERIC_LIBATA_PORTMAP_H
3
4#define ATA_PRIMARY_CMD 0x1F0
5#define ATA_PRIMARY_CTL 0x3F6
6#define ATA_PRIMARY_IRQ 14
7
8#define ATA_SECONDARY_CMD 0x170
9#define ATA_SECONDARY_CTL 0x376
10#define ATA_SECONDARY_IRQ 15
11
12#endif
diff --git a/include/asm-i386/libata-portmap.h b/include/asm-i386/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-i386/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/asm-ia64/libata-portmap.h b/include/asm-ia64/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-ia64/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/asm-powerpc/libata-portmap.h b/include/asm-powerpc/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-powerpc/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/asm-sparc/libata-portmap.h b/include/asm-sparc/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-sparc/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/asm-sparc64/libata-portmap.h b/include/asm-sparc64/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-sparc64/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/asm-x86_64/libata-portmap.h b/include/asm-x86_64/libata-portmap.h
new file mode 100644
index 000000000000..75484ef0c743
--- /dev/null
+++ b/include/asm-x86_64/libata-portmap.h
@@ -0,0 +1 @@
#include <asm-generic/libata-portmap.h>
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 3671af869696..991b858acc30 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -40,6 +40,8 @@ enum {
40 ATA_MAX_DEVICES = 2, /* per bus/port */ 40 ATA_MAX_DEVICES = 2, /* per bus/port */
41 ATA_MAX_PRD = 256, /* we could make these 256/256 */ 41 ATA_MAX_PRD = 256, /* we could make these 256/256 */
42 ATA_SECT_SIZE = 512, 42 ATA_SECT_SIZE = 512,
43 ATA_MAX_SECTORS = 256,
44 ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */
43 45
44 ATA_ID_WORDS = 256, 46 ATA_ID_WORDS = 256,
45 ATA_ID_SERNO_OFS = 10, 47 ATA_ID_SERNO_OFS = 10,
@@ -168,12 +170,16 @@ enum {
168 XFER_UDMA_2 = 0x42, 170 XFER_UDMA_2 = 0x42,
169 XFER_UDMA_1 = 0x41, 171 XFER_UDMA_1 = 0x41,
170 XFER_UDMA_0 = 0x40, 172 XFER_UDMA_0 = 0x40,
173 XFER_MW_DMA_4 = 0x24, /* CFA only */
174 XFER_MW_DMA_3 = 0x23, /* CFA only */
171 XFER_MW_DMA_2 = 0x22, 175 XFER_MW_DMA_2 = 0x22,
172 XFER_MW_DMA_1 = 0x21, 176 XFER_MW_DMA_1 = 0x21,
173 XFER_MW_DMA_0 = 0x20, 177 XFER_MW_DMA_0 = 0x20,
174 XFER_SW_DMA_2 = 0x12, 178 XFER_SW_DMA_2 = 0x12,
175 XFER_SW_DMA_1 = 0x11, 179 XFER_SW_DMA_1 = 0x11,
176 XFER_SW_DMA_0 = 0x10, 180 XFER_SW_DMA_0 = 0x10,
181 XFER_PIO_6 = 0x0E, /* CFA only */
182 XFER_PIO_5 = 0x0D, /* CFA only */
177 XFER_PIO_4 = 0x0C, 183 XFER_PIO_4 = 0x0C,
178 XFER_PIO_3 = 0x0B, 184 XFER_PIO_3 = 0x0B,
179 XFER_PIO_2 = 0x0A, 185 XFER_PIO_2 = 0x0A,
@@ -272,7 +278,6 @@ struct ata_taskfile {
272}; 278};
273 279
274#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 280#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
275#define ata_id_is_cfa(id) ((id)[0] == 0x848A)
276#define ata_id_is_sata(id) ((id)[93] == 0) 281#define ata_id_is_sata(id) ((id)[93] == 0)
277#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) 282#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
278#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) 283#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
@@ -304,6 +309,9 @@ static inline unsigned int ata_id_major_version(const u16 *id)
304{ 309{
305 unsigned int mver; 310 unsigned int mver;
306 311
312 if (id[ATA_ID_MAJOR_VER] == 0xFFFF)
313 return 0;
314
307 for (mver = 14; mver >= 1; mver--) 315 for (mver = 14; mver >= 1; mver--)
308 if (id[ATA_ID_MAJOR_VER] & (1 << mver)) 316 if (id[ATA_ID_MAJOR_VER] & (1 << mver))
309 break; 317 break;
@@ -322,6 +330,18 @@ static inline int ata_id_current_chs_valid(const u16 *id)
322 id[56]; /* sectors in current translation */ 330 id[56]; /* sectors in current translation */
323} 331}
324 332
333static inline int ata_id_is_cfa(const u16 *id)
334{
335 u16 v = id[0];
336 if (v == 0x848A) /* Standard CF */
337 return 1;
338 /* Could be CF hiding as standard ATA */
339 if (ata_id_major_version(id) >= 3 && id[82] != 0xFFFF &&
340 (id[82] & ( 1 << 2)))
341 return 1;
342 return 0;
343}
344
325static inline int atapi_cdb_len(const u16 *dev_id) 345static inline int atapi_cdb_len(const u16 *dev_id)
326{ 346{
327 u16 tmp = dev_id[0] & 0x3; 347 u16 tmp = dev_id[0] & 0x3;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 66c3100c2b94..563885cb0995 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -36,6 +36,8 @@
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
38 38
39#include <asm/libata-portmap.h>
40
39/* 41/*
40 * compile-time options: to be removed as soon as all the drivers are 42 * compile-time options: to be removed as soon as all the drivers are
41 * converted to the new debugging mechanism 43 * converted to the new debugging mechanism
@@ -112,8 +114,6 @@ enum {
112 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */ 114 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
113 ATA_MAX_QUEUE = 32, 115 ATA_MAX_QUEUE = 32,
114 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1, 116 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
115 ATA_MAX_SECTORS = 200, /* FIXME */
116 ATA_MAX_SECTORS_LBA48 = 65535,
117 ATA_MAX_BUS = 2, 117 ATA_MAX_BUS = 2,
118 ATA_DEF_BUSY_WAIT = 10000, 118 ATA_DEF_BUSY_WAIT = 10000,
119 ATA_SHORT_PAUSE = (HZ >> 6) + 1, 119 ATA_SHORT_PAUSE = (HZ >> 6) + 1,
@@ -197,7 +197,7 @@ enum {
197 ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */ 197 ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */
198 198
199 /* host set flags */ 199 /* host set flags */
200 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ 200 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */
201 201
202 /* various lengths of time */ 202 /* various lengths of time */
203 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 203 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */
@@ -225,8 +225,8 @@ enum {
225 /* encoding various smaller bitmaps into a single 225 /* encoding various smaller bitmaps into a single
226 * unsigned int bitmap 226 * unsigned int bitmap
227 */ 227 */
228 ATA_BITS_PIO = 5, 228 ATA_BITS_PIO = 7,
229 ATA_BITS_MWDMA = 3, 229 ATA_BITS_MWDMA = 5,
230 ATA_BITS_UDMA = 8, 230 ATA_BITS_UDMA = 8,
231 231
232 ATA_SHIFT_PIO = 0, 232 ATA_SHIFT_PIO = 0,
@@ -350,23 +350,24 @@ struct ata_probe_ent {
350 struct scsi_host_template *sht; 350 struct scsi_host_template *sht;
351 struct ata_ioports port[ATA_MAX_PORTS]; 351 struct ata_ioports port[ATA_MAX_PORTS];
352 unsigned int n_ports; 352 unsigned int n_ports;
353 unsigned int hard_port_no; 353 unsigned int dummy_port_mask;
354 unsigned int pio_mask; 354 unsigned int pio_mask;
355 unsigned int mwdma_mask; 355 unsigned int mwdma_mask;
356 unsigned int udma_mask; 356 unsigned int udma_mask;
357 unsigned int legacy_mode;
358 unsigned long irq; 357 unsigned long irq;
358 unsigned long irq2;
359 unsigned int irq_flags; 359 unsigned int irq_flags;
360 unsigned long host_flags; 360 unsigned long port_flags;
361 unsigned long host_set_flags; 361 unsigned long _host_flags;
362 void __iomem *mmio_base; 362 void __iomem *mmio_base;
363 void *private_data; 363 void *private_data;
364}; 364};
365 365
366struct ata_host_set { 366struct ata_host {
367 spinlock_t lock; 367 spinlock_t lock;
368 struct device *dev; 368 struct device *dev;
369 unsigned long irq; 369 unsigned long irq;
370 unsigned long irq2;
370 void __iomem *mmio_base; 371 void __iomem *mmio_base;
371 unsigned int n_ports; 372 unsigned int n_ports;
372 void *private_data; 373 void *private_data;
@@ -374,7 +375,6 @@ struct ata_host_set {
374 unsigned long flags; 375 unsigned long flags;
375 int simplex_claimed; /* Keep seperate in case we 376 int simplex_claimed; /* Keep seperate in case we
376 ever need to do this locked */ 377 ever need to do this locked */
377 struct ata_host_set *next; /* for legacy mode */
378 struct ata_port *ports[0]; 378 struct ata_port *ports[0];
379}; 379};
380 380
@@ -420,7 +420,7 @@ struct ata_queued_cmd {
420 void *private_data; 420 void *private_data;
421}; 421};
422 422
423struct ata_host_stats { 423struct ata_port_stats {
424 unsigned long unhandled_irq; 424 unsigned long unhandled_irq;
425 unsigned long idle_irq; 425 unsigned long idle_irq;
426 unsigned long rw_reqbuf; 426 unsigned long rw_reqbuf;
@@ -498,14 +498,13 @@ struct ata_eh_context {
498}; 498};
499 499
500struct ata_port { 500struct ata_port {
501 struct Scsi_Host *host; /* our co-allocated scsi host */ 501 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */
502 const struct ata_port_operations *ops; 502 const struct ata_port_operations *ops;
503 spinlock_t *lock; 503 spinlock_t *lock;
504 unsigned long flags; /* ATA_FLAG_xxx */ 504 unsigned long flags; /* ATA_FLAG_xxx */
505 unsigned int pflags; /* ATA_PFLAG_xxx */ 505 unsigned int pflags; /* ATA_PFLAG_xxx */
506 unsigned int id; /* unique id req'd by scsi midlyr */ 506 unsigned int id; /* unique id req'd by scsi midlyr */
507 unsigned int port_no; /* unique port #; from zero */ 507 unsigned int port_no; /* unique port #; from zero */
508 unsigned int hard_port_no; /* hardware port #; from zero */
509 508
510 struct ata_prd *prd; /* our SG list */ 509 struct ata_prd *prd; /* our SG list */
511 dma_addr_t prd_dma; /* and its DMA mapping */ 510 dma_addr_t prd_dma; /* and its DMA mapping */
@@ -524,7 +523,7 @@ struct ata_port {
524 unsigned int hw_sata_spd_limit; 523 unsigned int hw_sata_spd_limit;
525 unsigned int sata_spd_limit; /* SATA PHY speed limit */ 524 unsigned int sata_spd_limit; /* SATA PHY speed limit */
526 525
527 /* record runtime error info, protected by host_set lock */ 526 /* record runtime error info, protected by host lock */
528 struct ata_eh_info eh_info; 527 struct ata_eh_info eh_info;
529 /* EH context owned by EH */ 528 /* EH context owned by EH */
530 struct ata_eh_context eh_context; 529 struct ata_eh_context eh_context;
@@ -538,8 +537,8 @@ struct ata_port {
538 unsigned int active_tag; 537 unsigned int active_tag;
539 u32 sactive; 538 u32 sactive;
540 539
541 struct ata_host_stats stats; 540 struct ata_port_stats stats;
542 struct ata_host_set *host_set; 541 struct ata_host *host;
543 struct device *dev; 542 struct device *dev;
544 543
545 struct work_struct port_task; 544 struct work_struct port_task;
@@ -615,7 +614,7 @@ struct ata_port_operations {
615 int (*port_start) (struct ata_port *ap); 614 int (*port_start) (struct ata_port *ap);
616 void (*port_stop) (struct ata_port *ap); 615 void (*port_stop) (struct ata_port *ap);
617 616
618 void (*host_stop) (struct ata_host_set *host_set); 617 void (*host_stop) (struct ata_host *host);
619 618
620 void (*bmdma_stop) (struct ata_queued_cmd *qc); 619 void (*bmdma_stop) (struct ata_queued_cmd *qc);
621 u8 (*bmdma_status) (struct ata_port *ap); 620 u8 (*bmdma_status) (struct ata_port *ap);
@@ -623,7 +622,7 @@ struct ata_port_operations {
623 622
624struct ata_port_info { 623struct ata_port_info {
625 struct scsi_host_template *sht; 624 struct scsi_host_template *sht;
626 unsigned long host_flags; 625 unsigned long flags;
627 unsigned long pio_mask; 626 unsigned long pio_mask;
628 unsigned long mwdma_mask; 627 unsigned long mwdma_mask;
629 unsigned long udma_mask; 628 unsigned long udma_mask;
@@ -649,6 +648,8 @@ extern const unsigned long sata_deb_timing_normal[];
649extern const unsigned long sata_deb_timing_hotplug[]; 648extern const unsigned long sata_deb_timing_hotplug[];
650extern const unsigned long sata_deb_timing_long[]; 649extern const unsigned long sata_deb_timing_long[];
651 650
651extern const struct ata_port_operations ata_dummy_port_ops;
652
652static inline const unsigned long * 653static inline const unsigned long *
653sata_ehc_deb_timing(struct ata_eh_context *ehc) 654sata_ehc_deb_timing(struct ata_eh_context *ehc)
654{ 655{
@@ -658,6 +659,11 @@ sata_ehc_deb_timing(struct ata_eh_context *ehc)
658 return sata_deb_timing_normal; 659 return sata_deb_timing_normal;
659} 660}
660 661
662static inline int ata_port_is_dummy(struct ata_port *ap)
663{
664 return ap->ops == &ata_dummy_port_ops;
665}
666
661extern void ata_port_probe(struct ata_port *); 667extern void ata_port_probe(struct ata_port *);
662extern void __sata_phy_reset(struct ata_port *ap); 668extern void __sata_phy_reset(struct ata_port *ap);
663extern void sata_phy_reset(struct ata_port *ap); 669extern void sata_phy_reset(struct ata_port *ap);
@@ -676,19 +682,30 @@ extern void ata_std_ports(struct ata_ioports *ioaddr);
676extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 682extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
677 unsigned int n_ports); 683 unsigned int n_ports);
678extern void ata_pci_remove_one (struct pci_dev *pdev); 684extern void ata_pci_remove_one (struct pci_dev *pdev);
679extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t state); 685extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
680extern void ata_pci_device_do_resume(struct pci_dev *pdev); 686extern void ata_pci_device_do_resume(struct pci_dev *pdev);
681extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); 687extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
682extern int ata_pci_device_resume(struct pci_dev *pdev); 688extern int ata_pci_device_resume(struct pci_dev *pdev);
683extern int ata_pci_clear_simplex(struct pci_dev *pdev); 689extern int ata_pci_clear_simplex(struct pci_dev *pdev);
684#endif /* CONFIG_PCI */ 690#endif /* CONFIG_PCI */
685extern int ata_device_add(const struct ata_probe_ent *ent); 691extern int ata_device_add(const struct ata_probe_ent *ent);
686extern void ata_port_detach(struct ata_port *ap); 692extern void ata_port_detach(struct ata_port *ap);
687extern void ata_host_set_remove(struct ata_host_set *host_set); 693extern void ata_host_init(struct ata_host *, struct device *,
694 unsigned long, const struct ata_port_operations *);
695extern void ata_host_remove(struct ata_host *host);
688extern int ata_scsi_detect(struct scsi_host_template *sht); 696extern int ata_scsi_detect(struct scsi_host_template *sht);
689extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 697extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
690extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 698extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
691extern int ata_scsi_release(struct Scsi_Host *host); 699extern int ata_scsi_release(struct Scsi_Host *host);
700extern void ata_sas_port_destroy(struct ata_port *);
701extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
702 struct ata_port_info *, struct Scsi_Host *);
703extern int ata_sas_port_init(struct ata_port *);
704extern int ata_sas_port_start(struct ata_port *ap);
705extern void ata_sas_port_stop(struct ata_port *ap);
706extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
707extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
708 struct ata_port *ap);
692extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); 709extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
693extern int sata_scr_valid(struct ata_port *ap); 710extern int sata_scr_valid(struct ata_port *ap);
694extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val); 711extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val);
@@ -697,10 +714,9 @@ extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val);
697extern int ata_port_online(struct ata_port *ap); 714extern int ata_port_online(struct ata_port *ap);
698extern int ata_port_offline(struct ata_port *ap); 715extern int ata_port_offline(struct ata_port *ap);
699extern int ata_scsi_device_resume(struct scsi_device *); 716extern int ata_scsi_device_resume(struct scsi_device *);
700extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); 717extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg);
701extern int ata_host_set_suspend(struct ata_host_set *host_set, 718extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
702 pm_message_t mesg); 719extern void ata_host_resume(struct ata_host *host);
703extern void ata_host_set_resume(struct ata_host_set *host_set);
704extern int ata_ratelimit(void); 720extern int ata_ratelimit(void);
705extern unsigned int ata_busy_sleep(struct ata_port *ap, 721extern unsigned int ata_busy_sleep(struct ata_port *ap,
706 unsigned long timeout_pat, 722 unsigned long timeout_pat,
@@ -725,7 +741,7 @@ extern u8 ata_altstatus(struct ata_port *ap);
725extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); 741extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
726extern int ata_port_start (struct ata_port *ap); 742extern int ata_port_start (struct ata_port *ap);
727extern void ata_port_stop (struct ata_port *ap); 743extern void ata_port_stop (struct ata_port *ap);
728extern void ata_host_stop (struct ata_host_set *host_set); 744extern void ata_host_stop (struct ata_host *host);
729extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); 745extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
730extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, 746extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
731 unsigned int buflen, int write_data); 747 unsigned int buflen, int write_data);
@@ -811,7 +827,7 @@ struct pci_bits {
811 unsigned long val; 827 unsigned long val;
812}; 828};
813 829
814extern void ata_pci_host_stop (struct ata_host_set *host_set); 830extern void ata_pci_host_stop (struct ata_host *host);
815extern struct ata_probe_ent * 831extern struct ata_probe_ent *
816ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); 832ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
817extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 833extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);