aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/pata_cs5520.c130
-rw-r--r--drivers/ata/pata_isapnp.c43
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c39
-rw-r--r--drivers/ata/pata_legacy.c38
-rw-r--r--drivers/ata/pata_mpc52xx.c46
-rw-r--r--drivers/ata/pata_mpiix.c36
-rw-r--r--drivers/ata/pata_pcmcia.c40
-rw-r--r--drivers/ata/pata_pdc2027x.c98
-rw-r--r--drivers/ata/pata_platform.c43
-rw-r--r--drivers/ata/pata_qdi.c45
-rw-r--r--drivers/ata/pata_scc.c51
-rw-r--r--drivers/ata/pata_winbond.c97
-rw-r--r--drivers/ata/pdc_adma.c85
13 files changed, 362 insertions, 429 deletions
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index b5b27baa0be1..79bef0d1fad3 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -186,7 +186,6 @@ static struct ata_port_operations cs5520_port_ops = {
186 .qc_issue = ata_qc_issue_prot, 186 .qc_issue = ata_qc_issue_prot,
187 .data_xfer = ata_data_xfer, 187 .data_xfer = ata_data_xfer,
188 188
189 .irq_handler = ata_interrupt,
190 .irq_clear = ata_bmdma_irq_clear, 189 .irq_clear = ata_bmdma_irq_clear,
191 .irq_on = ata_irq_on, 190 .irq_on = ata_irq_on,
192 .irq_ack = ata_irq_ack, 191 .irq_ack = ata_irq_ack,
@@ -194,91 +193,104 @@ static struct ata_port_operations cs5520_port_ops = {
194 .port_start = ata_port_start, 193 .port_start = ata_port_start,
195}; 194};
196 195
197static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) 196static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
198{ 197{
198 struct ata_port_info pi = {
199 .flags = ATA_FLAG_SLAVE_POSS,
200 .pio_mask = 0x1f,
201 .port_ops = &cs5520_port_ops,
202 };
203 const struct ata_port_info *ppi[2];
199 u8 pcicfg; 204 u8 pcicfg;
200 void __iomem *iomap[5]; 205 void *iomap[5];
201 static struct ata_probe_ent probe[2]; 206 struct ata_host *host;
202 int ports = 0; 207 struct ata_ioports *ioaddr;
208 int i, rc;
203 209
204 /* IDE port enable bits */ 210 /* IDE port enable bits */
205 pci_read_config_byte(dev, 0x60, &pcicfg); 211 pci_read_config_byte(pdev, 0x60, &pcicfg);
206 212
207 /* Check if the ATA ports are enabled */ 213 /* Check if the ATA ports are enabled */
208 if ((pcicfg & 3) == 0) 214 if ((pcicfg & 3) == 0)
209 return -ENODEV; 215 return -ENODEV;
210 216
217 ppi[0] = ppi[1] = &ata_dummy_port_info;
218 if (pcicfg & 1)
219 ppi[0] = π
220 if (pcicfg & 2)
221 ppi[1] = π
222
211 if ((pcicfg & 0x40) == 0) { 223 if ((pcicfg & 0x40) == 0) {
212 printk(KERN_WARNING DRV_NAME ": DMA mode disabled. Enabling.\n"); 224 dev_printk(KERN_WARNING, &pdev->dev,
213 pci_write_config_byte(dev, 0x60, pcicfg | 0x40); 225 "DMA mode disabled. Enabling.\n");
226 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
214 } 227 }
215 228
229 pi.mwdma_mask = id->driver_data;
230
231 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
232 if (!host)
233 return -ENOMEM;
234
216 /* Perform set up for DMA */ 235 /* Perform set up for DMA */
217 if (pci_enable_device_bars(dev, 1<<2)) { 236 if (pci_enable_device_bars(pdev, 1<<2)) {
218 printk(KERN_ERR DRV_NAME ": unable to configure BAR2.\n"); 237 printk(KERN_ERR DRV_NAME ": unable to configure BAR2.\n");
219 return -ENODEV; 238 return -ENODEV;
220 } 239 }
221 pci_set_master(dev); 240
222 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { 241 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
223 printk(KERN_ERR DRV_NAME ": unable to configure DMA mask.\n"); 242 printk(KERN_ERR DRV_NAME ": unable to configure DMA mask.\n");
224 return -ENODEV; 243 return -ENODEV;
225 } 244 }
226 if (pci_set_consistent_dma_mask(dev, DMA_32BIT_MASK)) { 245 if (pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
227 printk(KERN_ERR DRV_NAME ": unable to configure consistent DMA mask.\n"); 246 printk(KERN_ERR DRV_NAME ": unable to configure consistent DMA mask.\n");
228 return -ENODEV; 247 return -ENODEV;
229 } 248 }
230 249
231 /* Map IO ports */ 250 /* Map IO ports and initialize host accordingly */
232 iomap[0] = devm_ioport_map(&dev->dev, 0x1F0, 8); 251 iomap[0] = devm_ioport_map(&pdev->dev, 0x1F0, 8);
233 iomap[1] = devm_ioport_map(&dev->dev, 0x3F6, 1); 252 iomap[1] = devm_ioport_map(&pdev->dev, 0x3F6, 1);
234 iomap[2] = devm_ioport_map(&dev->dev, 0x170, 8); 253 iomap[2] = devm_ioport_map(&pdev->dev, 0x170, 8);
235 iomap[3] = devm_ioport_map(&dev->dev, 0x376, 1); 254 iomap[3] = devm_ioport_map(&pdev->dev, 0x376, 1);
236 iomap[4] = pcim_iomap(dev, 2, 0); 255 iomap[4] = pcim_iomap(pdev, 2, 0);
237 256
238 if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4]) 257 if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4])
239 return -ENOMEM; 258 return -ENOMEM;
240 259
241 /* We have to do our own plumbing as the PCI setup for this 260 ioaddr = &host->ports[0]->ioaddr;
242 chipset is non-standard so we can't punt to the libata code */ 261 ioaddr->cmd_addr = iomap[0];
243 262 ioaddr->ctl_addr = iomap[1];
244 INIT_LIST_HEAD(&probe[0].node); 263 ioaddr->altstatus_addr = iomap[1];
245 probe[0].dev = pci_dev_to_dev(dev); 264 ioaddr->bmdma_addr = iomap[4];
246 probe[0].port_ops = &cs5520_port_ops; 265 ata_std_ports(ioaddr);
247 probe[0].sht = &cs5520_sht; 266
248 probe[0].pio_mask = 0x1F; 267 ioaddr = &host->ports[1]->ioaddr;
249 probe[0].mwdma_mask = id->driver_data; 268 ioaddr->cmd_addr = iomap[2];
250 probe[0].irq = 14; 269 ioaddr->ctl_addr = iomap[3];
251 probe[0].irq_flags = 0; 270 ioaddr->altstatus_addr = iomap[3];
252 probe[0].port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST; 271 ioaddr->bmdma_addr = iomap[4] + 8;
253 probe[0].n_ports = 1; 272 ata_std_ports(ioaddr);
254 probe[0].port[0].cmd_addr = iomap[0]; 273
255 probe[0].port[0].ctl_addr = iomap[1]; 274 /* activate the host */
256 probe[0].port[0].altstatus_addr = iomap[1]; 275 pci_set_master(pdev);
257 probe[0].port[0].bmdma_addr = iomap[4]; 276 rc = ata_host_start(host);
258 277 if (rc)
259 /* The secondary lurks at different addresses but is otherwise 278 return rc;
260 the same beastie */ 279
261 280 for (i = 0; i < 2; i++) {
262 probe[1] = probe[0]; 281 static const int irq[] = { 14, 15 };
263 INIT_LIST_HEAD(&probe[1].node); 282 struct ata_port *ap = host->ports[0];
264 probe[1].irq = 15; 283
265 probe[1].port[0].cmd_addr = iomap[2]; 284 if (ata_port_is_dummy(ap))
266 probe[1].port[0].ctl_addr = iomap[3]; 285 continue;
267 probe[1].port[0].altstatus_addr = iomap[3]; 286
268 probe[1].port[0].bmdma_addr = iomap[4] + 8; 287 rc = devm_request_irq(&pdev->dev, irq[ap->port_no],
269 288 ata_interrupt, 0, DRV_NAME, host);
270 /* Let libata fill in the port details */ 289 if (rc)
271 ata_std_ports(&probe[0].port[0]); 290 return rc;
272 ata_std_ports(&probe[1].port[0]); 291 }
273 292
274 /* Now add the ports that are active */ 293 return ata_host_register(host, &cs5520_sht);
275 if (pcicfg & 1)
276 ports += ata_device_add(&probe[0]);
277 if (pcicfg & 2)
278 ports += ata_device_add(&probe[1]);
279 if (ports)
280 return 0;
281 return -ENODEV;
282} 294}
283 295
284/** 296/**
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 2580ab3146bf..d042efdfbac4 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -56,7 +56,6 @@ static struct ata_port_operations isapnp_port_ops = {
56 56
57 .data_xfer = ata_data_xfer, 57 .data_xfer = ata_data_xfer,
58 58
59 .irq_handler = ata_interrupt,
60 .irq_clear = ata_bmdma_irq_clear, 59 .irq_clear = ata_bmdma_irq_clear,
61 .irq_on = ata_irq_on, 60 .irq_on = ata_irq_on,
62 .irq_ack = ata_irq_ack, 61 .irq_ack = ata_irq_ack,
@@ -75,8 +74,10 @@ static struct ata_port_operations isapnp_port_ops = {
75 74
76static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id) 75static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
77{ 76{
78 struct ata_probe_ent ae; 77 struct ata_host *host;
78 struct ata_port *ap;
79 void __iomem *cmd_addr, *ctl_addr; 79 void __iomem *cmd_addr, *ctl_addr;
80 int rc;
80 81
81 if (pnp_port_valid(idev, 0) == 0) 82 if (pnp_port_valid(idev, 0) == 0)
82 return -ENODEV; 83 return -ENODEV;
@@ -85,34 +86,36 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
85 if (pnp_irq_valid(idev, 0) == 0) 86 if (pnp_irq_valid(idev, 0) == 0)
86 return -ENODEV; 87 return -ENODEV;
87 88
89 /* allocate host */
90 host = ata_host_alloc(&idev->dev, 1);
91 if (!host)
92 return -ENOMEM;
93
94 /* acquire resources and fill host */
88 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8); 95 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
89 if (!cmd_addr) 96 if (!cmd_addr)
90 return -ENOMEM; 97 return -ENOMEM;
91 98
92 memset(&ae, 0, sizeof(struct ata_probe_ent)); 99 ap = host->ports[0];
93 INIT_LIST_HEAD(&ae.node); 100
94 ae.dev = &idev->dev; 101 ap->ops = &isapnp_port_ops;
95 ae.port_ops = &isapnp_port_ops; 102 ap->pio_mask = 1;
96 ae.sht = &isapnp_sht; 103 ap->flags |= ATA_FLAG_SLAVE_POSS;
97 ae.n_ports = 1; 104
98 ae.pio_mask = 1; /* ISA so PIO 0 cycles */ 105 ap->ioaddr.cmd_addr = cmd_addr;
99 ae.irq = pnp_irq(idev, 0);
100 ae.irq_flags = 0;
101 ae.port_flags = ATA_FLAG_SLAVE_POSS;
102 ae.port[0].cmd_addr = cmd_addr;
103 106
104 if (pnp_port_valid(idev, 1) == 0) { 107 if (pnp_port_valid(idev, 1) == 0) {
105 ctl_addr = devm_ioport_map(&idev->dev, 108 ctl_addr = devm_ioport_map(&idev->dev,
106 pnp_port_start(idev, 1), 1); 109 pnp_port_start(idev, 1), 1);
107 ae.port[0].altstatus_addr = ctl_addr; 110 ap->ioaddr.altstatus_addr = ctl_addr;
108 ae.port[0].ctl_addr = ctl_addr; 111 ap->ioaddr.ctl_addr = ctl_addr;
109 ae.port_flags |= ATA_FLAG_SRST;
110 } 112 }
111 ata_std_ports(&ae.port[0]);
112 113
113 if (ata_device_add(&ae) == 0) 114 ata_std_ports(&ap->ioaddr);
114 return -ENODEV; 115
115 return 0; 116 /* activate */
117 return ata_host_activate(host, pnp_irq(idev, 0), ata_interrupt, 0,
118 &isapnp_sht);
116} 119}
117 120
118/** 121/**
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 8257af84ff7c..420c343e5711 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -131,7 +131,6 @@ static struct ata_port_operations ixp4xx_port_ops = {
131 .data_xfer = ixp4xx_mmio_data_xfer, 131 .data_xfer = ixp4xx_mmio_data_xfer,
132 .cable_detect = ata_cable_40wire, 132 .cable_detect = ata_cable_40wire,
133 133
134 .irq_handler = ata_interrupt,
135 .irq_clear = ixp4xx_irq_clear, 134 .irq_clear = ixp4xx_irq_clear,
136 .irq_on = ata_irq_on, 135 .irq_on = ata_irq_on,
137 .irq_ack = ata_irq_ack, 136 .irq_ack = ata_irq_ack,
@@ -174,12 +173,12 @@ static void ixp4xx_setup_port(struct ata_ioports *ioaddr,
174 173
175static __devinit int ixp4xx_pata_probe(struct platform_device *pdev) 174static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
176{ 175{
177 int ret;
178 unsigned int irq; 176 unsigned int irq;
179 struct resource *cs0, *cs1; 177 struct resource *cs0, *cs1;
180 struct ata_probe_ent ae; 178 struct ata_host *host;
181 179 struct ata_port *ap;
182 struct ixp4xx_pata_data *data = pdev->dev.platform_data; 180 struct ixp4xx_pata_data *data = pdev->dev.platform_data;
181 int rc;
183 182
184 cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 183 cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
185 cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 184 cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -187,6 +186,12 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
187 if (!cs0 || !cs1) 186 if (!cs0 || !cs1)
188 return -EINVAL; 187 return -EINVAL;
189 188
189 /* allocate host */
190 host = ata_host_alloc(&pdev->dev, 1);
191 if (!host)
192 return -ENOMEM;
193
194 /* acquire resources and fill host */
190 pdev->dev.coherent_dma_mask = DMA_32BIT_MASK; 195 pdev->dev.coherent_dma_mask = DMA_32BIT_MASK;
191 196
192 data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000); 197 data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000);
@@ -200,32 +205,22 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
200 *data->cs0_cfg = data->cs0_bits; 205 *data->cs0_cfg = data->cs0_bits;
201 *data->cs1_cfg = data->cs1_bits; 206 *data->cs1_cfg = data->cs1_bits;
202 207
203 memset(&ae, 0, sizeof(struct ata_probe_ent)); 208 ap = host->ports[0];
204 INIT_LIST_HEAD(&ae.node);
205 209
206 ae.dev = &pdev->dev; 210 ap->ops = &ixp4xx_port_ops;
207 ae.port_ops = &ixp4xx_port_ops; 211 ap->pio_mask = 0x1f; /* PIO4 */
208 ae.sht = &ixp4xx_sht; 212 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_NO_ATAPI;
209 ae.n_ports = 1;
210 ae.pio_mask = 0x1f; /* PIO4 */
211 ae.irq = irq;
212 ae.irq_flags = 0;
213 ae.port_flags = ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY
214 | ATA_FLAG_NO_ATAPI | ATA_FLAG_SRST;
215 213
216 /* run in polling mode if no irq has been assigned */ 214 /* run in polling mode if no irq has been assigned */
217 if (!irq) 215 if (!irq)
218 ae.port_flags |= ATA_FLAG_PIO_POLLING; 216 ap->flags |= ATA_FLAG_PIO_POLLING;
219 217
220 ixp4xx_setup_port(&ae.port[0], data); 218 ixp4xx_setup_port(&ap->ioaddr, data);
221 219
222 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 220 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
223 221
224 ret = ata_device_add(&ae); 222 /* activate host */
225 if (ret == 0) 223 return ata_host_activate(host, irq, ata_interrupt, 0, &ixp4xx_sht);
226 return -ENODEV;
227
228 return 0;
229} 224}
230 225
231static __devexit int ixp4xx_pata_remove(struct platform_device *dev) 226static __devexit int ixp4xx_pata_remove(struct platform_device *dev)
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 0b1749a84df2..707099291e01 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -716,7 +716,8 @@ static struct ata_port_operations opti82c46x_port_ops = {
716static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl, int irq) 716static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl, int irq)
717{ 717{
718 struct legacy_data *ld = &legacy_data[nr_legacy_host]; 718 struct legacy_data *ld = &legacy_data[nr_legacy_host];
719 struct ata_probe_ent ae; 719 struct ata_host *host;
720 struct ata_port *ap;
720 struct platform_device *pdev; 721 struct platform_device *pdev;
721 struct ata_port_operations *ops = &legacy_port_ops; 722 struct ata_port_operations *ops = &legacy_port_ops;
722 void __iomem *io_addr, *ctrl_addr; 723 void __iomem *io_addr, *ctrl_addr;
@@ -798,24 +799,23 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
798 if (ops == &legacy_port_ops && (autospeed & mask)) 799 if (ops == &legacy_port_ops && (autospeed & mask))
799 ops = &simple_port_ops; 800 ops = &simple_port_ops;
800 801
801 memset(&ae, 0, sizeof(struct ata_probe_ent)); 802 ret = -ENOMEM;
802 INIT_LIST_HEAD(&ae.node); 803 host = ata_host_alloc(&pdev->dev, 1);
803 ae.dev = &pdev->dev; 804 if (!host)
804 ae.port_ops = ops; 805 goto fail;
805 ae.sht = &legacy_sht; 806 ap = host->ports[0];
806 ae.n_ports = 1; 807
807 ae.pio_mask = pio_modes; 808 ap->ops = ops;
808 ae.irq = irq; 809 ap->pio_mask = pio_modes;
809 ae.irq_flags = 0; 810 ap->flags |= ATA_FLAG_SLAVE_POSS | iordy;
810 ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST|iordy; 811 ap->ioaddr.cmd_addr = io_addr;
811 ae.port[0].cmd_addr = io_addr; 812 ap->ioaddr.altstatus_addr = ctrl_addr;
812 ae.port[0].altstatus_addr = ctrl_addr; 813 ap->ioaddr.ctl_addr = ctrl_addr;
813 ae.port[0].ctl_addr = ctrl_addr; 814 ata_std_ports(&ap->ioaddr);
814 ata_std_ports(&ae.port[0]); 815 ap->private_data = ld;
815 ae.private_data = ld; 816
816 817 ret = ata_host_activate(host, irq, ata_interrupt, 0, &legacy_sht);
817 ret = -ENODEV; 818 if (ret)
818 if (!ata_device_add(&ae))
819 goto fail; 819 goto fail;
820 820
821 legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev); 821 legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev);
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 77b57321ff52..9587a89f9683 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -301,35 +301,33 @@ static struct ata_port_operations mpc52xx_ata_port_ops = {
301 .qc_prep = ata_qc_prep, 301 .qc_prep = ata_qc_prep,
302 .qc_issue = ata_qc_issue_prot, 302 .qc_issue = ata_qc_issue_prot,
303 .data_xfer = ata_data_xfer, 303 .data_xfer = ata_data_xfer,
304 .irq_handler = ata_interrupt,
305 .irq_clear = ata_bmdma_irq_clear, 304 .irq_clear = ata_bmdma_irq_clear,
306 .irq_on = ata_irq_on, 305 .irq_on = ata_irq_on,
307 .irq_ack = ata_irq_ack, 306 .irq_ack = ata_irq_ack,
308 .port_start = ata_port_start, 307 .port_start = ata_port_start,
309}; 308};
310 309
311static struct ata_probe_ent mpc52xx_ata_probe_ent = {
312 .port_ops = &mpc52xx_ata_port_ops,
313 .sht = &mpc52xx_ata_sht,
314 .n_ports = 1,
315 .pio_mask = 0x1f, /* Up to PIO4 */
316 .mwdma_mask = 0x00, /* No MWDMA */
317 .udma_mask = 0x00, /* No UDMA */
318 .port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
319 .irq_flags = 0,
320};
321
322static int __devinit 310static int __devinit
323mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv) 311mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv)
324{ 312{
325 struct ata_probe_ent *ae = &mpc52xx_ata_probe_ent; 313 struct ata_host *host;
326 struct ata_ioports *aio = &ae->port[0]; 314 struct ata_port *ap;
327 int rv; 315 struct ata_ioports *aio;
328 316 int rc;
329 INIT_LIST_HEAD(&ae->node); 317
330 ae->dev = dev; 318 host = ata_host_alloc(dev, 1);
331 ae->irq = priv->ata_irq; 319 if (!host)
332 320 return -ENOMEM;
321
322 ap = host->ports[0];
323 ap->flags |= ATA_FLAG_SLAVE_POSS;
324 ap->pio_mask = 0x1f; /* Up to PIO4 */
325 ap->mwdma_mask = 0x00; /* No MWDMA */
326 ap->udma_mask = 0x00; /* No UDMA */
327 ap->ops = &mpc52xx_ata_port_ops;
328 host->private_data = priv;
329
330 aio = &ap->ioaddr;
333 aio->cmd_addr = NULL; /* Don't have a classic reg block */ 331 aio->cmd_addr = NULL; /* Don't have a classic reg block */
334 aio->altstatus_addr = &priv->ata_regs->tf_control; 332 aio->altstatus_addr = &priv->ata_regs->tf_control;
335 aio->ctl_addr = &priv->ata_regs->tf_control; 333 aio->ctl_addr = &priv->ata_regs->tf_control;
@@ -344,11 +342,9 @@ mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv)
344 aio->status_addr = &priv->ata_regs->tf_command; 342 aio->status_addr = &priv->ata_regs->tf_command;
345 aio->command_addr = &priv->ata_regs->tf_command; 343 aio->command_addr = &priv->ata_regs->tf_command;
346 344
347 ae->private_data = priv; 345 /* activate host */
348 346 return ata_host_activate(host, priv->ata_irq, ata_interrupt, 0,
349 rv = ata_device_add(ae); 347 &mpc52xx_ata_sht);
350
351 return rv ? 0 : -EINVAL;
352} 348}
353 349
354static struct mpc52xx_ata_priv * 350static struct mpc52xx_ata_priv *
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 1718eaca731f..987c5fafab08 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -190,7 +190,6 @@ static struct ata_port_operations mpiix_port_ops = {
190 .qc_issue = mpiix_qc_issue_prot, 190 .qc_issue = mpiix_qc_issue_prot,
191 .data_xfer = ata_data_xfer, 191 .data_xfer = ata_data_xfer,
192 192
193 .irq_handler = ata_interrupt,
194 .irq_clear = ata_bmdma_irq_clear, 193 .irq_clear = ata_bmdma_irq_clear,
195 .irq_on = ata_irq_on, 194 .irq_on = ata_irq_on,
196 .irq_ack = ata_irq_ack, 195 .irq_ack = ata_irq_ack,
@@ -201,8 +200,9 @@ static struct ata_port_operations mpiix_port_ops = {
201static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) 200static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
202{ 201{
203 /* Single threaded by the PCI probe logic */ 202 /* Single threaded by the PCI probe logic */
204 static struct ata_probe_ent probe;
205 static int printed_version; 203 static int printed_version;
204 struct ata_host *host;
205 struct ata_port *ap;
206 void __iomem *cmd_addr, *ctl_addr; 206 void __iomem *cmd_addr, *ctl_addr;
207 u16 idetim; 207 u16 idetim;
208 int irq; 208 int irq;
@@ -210,6 +210,10 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
210 if (!printed_version++) 210 if (!printed_version++)
211 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 211 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
212 212
213 host = ata_host_alloc(&dev->dev, 1);
214 if (!host)
215 return -ENOMEM;
216
213 /* MPIIX has many functions which can be turned on or off according 217 /* MPIIX has many functions which can be turned on or off according
214 to other devices present. Make sure IDE is enabled before we try 218 to other devices present. Make sure IDE is enabled before we try
215 and use it */ 219 and use it */
@@ -238,27 +242,21 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
238 without BARs set fools the setup. #2 If you pci_disable_device 242 without BARs set fools the setup. #2 If you pci_disable_device
239 the MPIIX your box goes castors up */ 243 the MPIIX your box goes castors up */
240 244
241 INIT_LIST_HEAD(&probe.node); 245 ap = host->ports[0];
242 probe.dev = pci_dev_to_dev(dev); 246 ap->ops = &mpiix_port_ops;
243 probe.port_ops = &mpiix_port_ops; 247 ap->pio_mask = 0x1F;
244 probe.sht = &mpiix_sht; 248 ap->flags |= ATA_FLAG_SLAVE_POSS;
245 probe.pio_mask = 0x1F;
246 probe.irq_flags = IRQF_SHARED;
247 probe.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
248 probe.n_ports = 1;
249 249
250 probe.irq = irq; 250 ap->ioaddr.cmd_addr = cmd_addr;
251 probe.port[0].cmd_addr = cmd_addr; 251 ap->ioaddr.ctl_addr = ctl_addr;
252 probe.port[0].ctl_addr = ctl_addr; 252 ap->ioaddr.altstatus_addr = ctl_addr;
253 probe.port[0].altstatus_addr = ctl_addr;
254 253
255 /* Let libata fill in the port details */ 254 /* Let libata fill in the port details */
256 ata_std_ports(&probe.port[0]); 255 ata_std_ports(&ap->ioaddr);
257 256
258 /* Now add the port that is active */ 257 /* activate host */
259 if (ata_device_add(&probe)) 258 return ata_host_activate(host, irq, ata_interrupt, IRQF_SHARED,
260 return 0; 259 &mpiix_sht);
261 return -ENODEV;
262} 260}
263 261
264static const struct pci_device_id mpiix[] = { 262static const struct pci_device_id mpiix[] = {
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 171da0aeb65f..75dc84797ff3 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -125,7 +125,6 @@ static struct ata_port_operations pcmcia_port_ops = {
125 125
126 .data_xfer = ata_data_xfer_noirq, 126 .data_xfer = ata_data_xfer_noirq,
127 127
128 .irq_handler = ata_interrupt,
129 .irq_clear = ata_bmdma_irq_clear, 128 .irq_clear = ata_bmdma_irq_clear,
130 .irq_on = ata_irq_on, 129 .irq_on = ata_irq_on,
131 .irq_ack = ata_irq_ack, 130 .irq_ack = ata_irq_ack,
@@ -146,7 +145,8 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
146 145
147static int pcmcia_init_one(struct pcmcia_device *pdev) 146static int pcmcia_init_one(struct pcmcia_device *pdev)
148{ 147{
149 struct ata_probe_ent ae; 148 struct ata_host *host;
149 struct ata_port *ap;
150 struct ata_pcmcia_info *info; 150 struct ata_pcmcia_info *info;
151 tuple_t tuple; 151 tuple_t tuple;
152 struct { 152 struct {
@@ -290,24 +290,24 @@ next_entry:
290 * Having done the PCMCIA plumbing the ATA side is relatively 290 * Having done the PCMCIA plumbing the ATA side is relatively
291 * sane. 291 * sane.
292 */ 292 */
293 293 ret = -ENOMEM;
294 memset(&ae, 0, sizeof(struct ata_probe_ent)); 294 host = ata_host_alloc(&pdev->dev, 1);
295 INIT_LIST_HEAD(&ae.node); 295 if (!host)
296 ae.dev = &pdev->dev; 296 goto failed;
297 ae.port_ops = &pcmcia_port_ops; 297 ap = host->ports[0];
298 ae.sht = &pcmcia_sht; 298
299 ae.n_ports = 1; 299 ap->ops = &pcmcia_port_ops;
300 ae.pio_mask = 1; /* ISA so PIO 0 cycles */ 300 ap->pio_mask = 1; /* ISA so PIO 0 cycles */
301 ae.irq = pdev->irq.AssignedIRQ; 301 ap->flags |= ATA_FLAG_SLAVE_POSS;
302 ae.irq_flags = IRQF_SHARED; 302 ap->ioaddr.cmd_addr = io_addr;
303 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; 303 ap->ioaddr.altstatus_addr = ctl_addr;
304 ae.port[0].cmd_addr = io_addr; 304 ap->ioaddr.ctl_addr = ctl_addr;
305 ae.port[0].altstatus_addr = ctl_addr; 305 ata_std_ports(&ap->ioaddr);
306 ae.port[0].ctl_addr = ctl_addr; 306
307 ata_std_ports(&ae.port[0]); 307 /* activate */
308 308 ret = ata_host_activate(host, pdev->irq.AssignedIRQ, ata_interrupt,
309 ret = -ENODEV; 309 IRQF_SHARED, &pcmcia_sht);
310 if (ata_device_add(&ae) == 0) 310 if (ret)
311 goto failed; 311 goto failed;
312 312
313 info->ndev = 1; 313 info->ndev = 1;
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 8261f4f8c1dc..a61cbc110688 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -171,7 +171,6 @@ static struct ata_port_operations pdc2027x_pata100_ops = {
171 .post_internal_cmd = ata_bmdma_post_internal_cmd, 171 .post_internal_cmd = ata_bmdma_post_internal_cmd,
172 .cable_detect = pdc2027x_cable_detect, 172 .cable_detect = pdc2027x_cable_detect,
173 173
174 .irq_handler = ata_interrupt,
175 .irq_clear = ata_bmdma_irq_clear, 174 .irq_clear = ata_bmdma_irq_clear,
176 .irq_on = ata_irq_on, 175 .irq_on = ata_irq_on,
177 .irq_ack = ata_irq_ack, 176 .irq_ack = ata_irq_ack,
@@ -207,7 +206,6 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
207 .post_internal_cmd = ata_bmdma_post_internal_cmd, 206 .post_internal_cmd = ata_bmdma_post_internal_cmd,
208 .cable_detect = pdc2027x_cable_detect, 207 .cable_detect = pdc2027x_cable_detect,
209 208
210 .irq_handler = ata_interrupt,
211 .irq_clear = ata_bmdma_irq_clear, 209 .irq_clear = ata_bmdma_irq_clear,
212 .irq_on = ata_irq_on, 210 .irq_on = ata_irq_on,
213 .irq_ack = ata_irq_ack, 211 .irq_ack = ata_irq_ack,
@@ -218,7 +216,6 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
218static struct ata_port_info pdc2027x_port_info[] = { 216static struct ata_port_info pdc2027x_port_info[] = {
219 /* PDC_UDMA_100 */ 217 /* PDC_UDMA_100 */
220 { 218 {
221 .sht = &pdc2027x_sht,
222 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS | 219 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS |
223 ATA_FLAG_MMIO, 220 ATA_FLAG_MMIO,
224 .pio_mask = 0x1f, /* pio0-4 */ 221 .pio_mask = 0x1f, /* pio0-4 */
@@ -228,7 +225,6 @@ static struct ata_port_info pdc2027x_port_info[] = {
228 }, 225 },
229 /* PDC_UDMA_133 */ 226 /* PDC_UDMA_133 */
230 { 227 {
231 .sht = &pdc2027x_sht,
232 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS | 228 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS |
233 ATA_FLAG_MMIO, 229 ATA_FLAG_MMIO,
234 .pio_mask = 0x1f, /* pio0-4 */ 230 .pio_mask = 0x1f, /* pio0-4 */
@@ -555,12 +551,12 @@ static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc)
555 551
556/** 552/**
557 * pdc_read_counter - Read the ctr counter 553 * pdc_read_counter - Read the ctr counter
558 * @probe_ent: for the port address 554 * @host: target ATA host
559 */ 555 */
560 556
561static long pdc_read_counter(struct ata_probe_ent *probe_ent) 557static long pdc_read_counter(struct ata_host *host)
562{ 558{
563 void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR]; 559 void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR];
564 long counter; 560 long counter;
565 int retry = 1; 561 int retry = 1;
566 u32 bccrl, bccrh, bccrlv, bccrhv; 562 u32 bccrl, bccrh, bccrlv, bccrhv;
@@ -598,12 +594,12 @@ retry:
598 * adjust_pll - Adjust the PLL input clock in Hz. 594 * adjust_pll - Adjust the PLL input clock in Hz.
599 * 595 *
600 * @pdc_controller: controller specific information 596 * @pdc_controller: controller specific information
601 * @probe_ent: For the port address 597 * @host: target ATA host
602 * @pll_clock: The input of PLL in HZ 598 * @pll_clock: The input of PLL in HZ
603 */ 599 */
604static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsigned int board_idx) 600static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int board_idx)
605{ 601{
606 void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR]; 602 void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR];
607 u16 pll_ctl; 603 u16 pll_ctl;
608 long pll_clock_khz = pll_clock / 1000; 604 long pll_clock_khz = pll_clock / 1000;
609 long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ; 605 long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ;
@@ -683,19 +679,19 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
683 679
684/** 680/**
685 * detect_pll_input_clock - Detect the PLL input clock in Hz. 681 * detect_pll_input_clock - Detect the PLL input clock in Hz.
686 * @probe_ent: for the port address 682 * @host: target ATA host
687 * Ex. 16949000 on 33MHz PCI bus for pdc20275. 683 * Ex. 16949000 on 33MHz PCI bus for pdc20275.
688 * Half of the PCI clock. 684 * Half of the PCI clock.
689 */ 685 */
690static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent) 686static long pdc_detect_pll_input_clock(struct ata_host *host)
691{ 687{
692 void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR]; 688 void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR];
693 u32 scr; 689 u32 scr;
694 long start_count, end_count; 690 long start_count, end_count;
695 long pll_clock; 691 long pll_clock;
696 692
697 /* Read current counter value */ 693 /* Read current counter value */
698 start_count = pdc_read_counter(probe_ent); 694 start_count = pdc_read_counter(host);
699 695
700 /* Start the test mode */ 696 /* Start the test mode */
701 scr = readl(mmio_base + PDC_SYS_CTL); 697 scr = readl(mmio_base + PDC_SYS_CTL);
@@ -707,7 +703,7 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
707 mdelay(100); 703 mdelay(100);
708 704
709 /* Read the counter values again */ 705 /* Read the counter values again */
710 end_count = pdc_read_counter(probe_ent); 706 end_count = pdc_read_counter(host);
711 707
712 /* Stop the test mode */ 708 /* Stop the test mode */
713 scr = readl(mmio_base + PDC_SYS_CTL); 709 scr = readl(mmio_base + PDC_SYS_CTL);
@@ -726,11 +722,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
726 722
727/** 723/**
728 * pdc_hardware_init - Initialize the hardware. 724 * pdc_hardware_init - Initialize the hardware.
729 * @pdev: instance of pci_dev found 725 * @host: target ATA host
730 * @pdc_controller: controller specific information 726 * @board_idx: board identifier
731 * @pe: for the port address
732 */ 727 */
733static int pdc_hardware_init(struct pci_dev *pdev, struct ata_probe_ent *pe, unsigned int board_idx) 728static int pdc_hardware_init(struct ata_host *host, unsigned int board_idx)
734{ 729{
735 long pll_clock; 730 long pll_clock;
736 731
@@ -740,15 +735,15 @@ static int pdc_hardware_init(struct pci_dev *pdev, struct ata_probe_ent *pe, uns
740 * Ex. 25MHz or 40MHz, we have to adjust the cycle_time. 735 * Ex. 25MHz or 40MHz, we have to adjust the cycle_time.
741 * The pdc20275 controller employs PLL circuit to help correct timing registers setting. 736 * The pdc20275 controller employs PLL circuit to help correct timing registers setting.
742 */ 737 */
743 pll_clock = pdc_detect_pll_input_clock(pe); 738 pll_clock = pdc_detect_pll_input_clock(host);
744 739
745 if (pll_clock < 0) /* counter overflow? Try again. */ 740 if (pll_clock < 0) /* counter overflow? Try again. */
746 pll_clock = pdc_detect_pll_input_clock(pe); 741 pll_clock = pdc_detect_pll_input_clock(host);
747 742
748 dev_printk(KERN_INFO, &pdev->dev, "PLL input clock %ld kHz\n", pll_clock/1000); 743 dev_printk(KERN_INFO, host->dev, "PLL input clock %ld kHz\n", pll_clock/1000);
749 744
750 /* Adjust PLL control register */ 745 /* Adjust PLL control register */
751 pdc_adjust_pll(pe, pll_clock, board_idx); 746 pdc_adjust_pll(host, pll_clock, board_idx);
752 747
753 return 0; 748 return 0;
754} 749}
@@ -780,8 +775,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
780 * Called when an instance of PCI adapter is inserted. 775 * Called when an instance of PCI adapter is inserted.
781 * This function checks whether the hardware is supported, 776 * This function checks whether the hardware is supported,
782 * initialize hardware and register an instance of ata_host to 777 * initialize hardware and register an instance of ata_host to
783 * libata by providing struct ata_probe_ent and ata_device_add(). 778 * libata. (implements struct pci_driver.probe() )
784 * (implements struct pci_driver.probe() )
785 * 779 *
786 * @pdev: instance of pci_dev found 780 * @pdev: instance of pci_dev found
787 * @ent: matching entry in the id_tbl[] 781 * @ent: matching entry in the id_tbl[]
@@ -790,14 +784,21 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
790{ 784{
791 static int printed_version; 785 static int printed_version;
792 unsigned int board_idx = (unsigned int) ent->driver_data; 786 unsigned int board_idx = (unsigned int) ent->driver_data;
793 787 const struct ata_port_info *ppi[] =
794 struct ata_probe_ent *probe_ent; 788 { &pdc2027x_port_info[board_idx], NULL };
789 struct ata_host *host;
795 void __iomem *mmio_base; 790 void __iomem *mmio_base;
796 int rc; 791 int rc;
797 792
798 if (!printed_version++) 793 if (!printed_version++)
799 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 794 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
800 795
796 /* alloc host */
797 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
798 if (!host)
799 return -ENOMEM;
800
801 /* acquire resources and fill host */
801 rc = pcim_enable_device(pdev); 802 rc = pcim_enable_device(pdev);
802 if (rc) 803 if (rc)
803 return rc; 804 return rc;
@@ -805,6 +806,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
805 rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME); 806 rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME);
806 if (rc) 807 if (rc)
807 return rc; 808 return rc;
809 host->iomap = pcim_iomap_table(pdev);
808 810
809 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 811 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
810 if (rc) 812 if (rc)
@@ -814,46 +816,22 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
814 if (rc) 816 if (rc)
815 return rc; 817 return rc;
816 818
817 /* Prepare the probe entry */ 819 mmio_base = host->iomap[PDC_MMIO_BAR];
818 probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
819 if (probe_ent == NULL)
820 return -ENOMEM;
821
822 probe_ent->dev = pci_dev_to_dev(pdev);
823 INIT_LIST_HEAD(&probe_ent->node);
824
825 probe_ent->sht = pdc2027x_port_info[board_idx].sht;
826 probe_ent->port_flags = pdc2027x_port_info[board_idx].flags;
827 probe_ent->pio_mask = pdc2027x_port_info[board_idx].pio_mask;
828 probe_ent->mwdma_mask = pdc2027x_port_info[board_idx].mwdma_mask;
829 probe_ent->udma_mask = pdc2027x_port_info[board_idx].udma_mask;
830 probe_ent->port_ops = pdc2027x_port_info[board_idx].port_ops;
831 820
832 probe_ent->irq = pdev->irq; 821 pdc_ata_setup_port(&host->ports[0]->ioaddr, mmio_base + 0x17c0);
833 probe_ent->irq_flags = IRQF_SHARED; 822 host->ports[0]->ioaddr.bmdma_addr = mmio_base + 0x1000;
834 probe_ent->iomap = pcim_iomap_table(pdev); 823 pdc_ata_setup_port(&host->ports[1]->ioaddr, mmio_base + 0x15c0);
824 host->ports[1]->ioaddr.bmdma_addr = mmio_base + 0x1008;
835 825
836 mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
837
838 pdc_ata_setup_port(&probe_ent->port[0], mmio_base + 0x17c0);
839 probe_ent->port[0].bmdma_addr = mmio_base + 0x1000;
840 pdc_ata_setup_port(&probe_ent->port[1], mmio_base + 0x15c0);
841 probe_ent->port[1].bmdma_addr = mmio_base + 0x1008;
842
843 probe_ent->n_ports = 2;
844
845 pci_set_master(pdev);
846 //pci_enable_intx(pdev); 826 //pci_enable_intx(pdev);
847 827
848 /* initialize adapter */ 828 /* initialize adapter */
849 if (pdc_hardware_init(pdev, probe_ent, board_idx) != 0) 829 if (pdc_hardware_init(host, board_idx) != 0)
850 return -EIO; 830 return -EIO;
851 831
852 if (!ata_device_add(probe_ent)) 832 pci_set_master(pdev);
853 return -ENODEV; 833 return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED,
854 834 &pdc2027x_sht);
855 devm_kfree(&pdev->dev, probe_ent);
856 return 0;
857} 835}
858 836
859/** 837/**
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 507eb1ee05f8..a0a650c7f272 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -87,7 +87,6 @@ static struct ata_port_operations pata_platform_port_ops = {
87 87
88 .data_xfer = ata_data_xfer_noirq, 88 .data_xfer = ata_data_xfer_noirq,
89 89
90 .irq_handler = ata_interrupt,
91 .irq_clear = ata_bmdma_irq_clear, 90 .irq_clear = ata_bmdma_irq_clear,
92 .irq_on = ata_irq_on, 91 .irq_on = ata_irq_on,
93 .irq_ack = ata_irq_ack, 92 .irq_ack = ata_irq_ack,
@@ -136,7 +135,8 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr,
136static int __devinit pata_platform_probe(struct platform_device *pdev) 135static int __devinit pata_platform_probe(struct platform_device *pdev)
137{ 136{
138 struct resource *io_res, *ctl_res; 137 struct resource *io_res, *ctl_res;
139 struct ata_probe_ent ae; 138 struct ata_host *host;
139 struct ata_port *ap;
140 unsigned int mmio; 140 unsigned int mmio;
141 141
142 /* 142 /*
@@ -176,44 +176,41 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
176 /* 176 /*
177 * Now that that's out of the way, wire up the port.. 177 * Now that that's out of the way, wire up the port..
178 */ 178 */
179 memset(&ae, 0, sizeof(struct ata_probe_ent)); 179 host = ata_host_alloc(&pdev->dev, 1);
180 INIT_LIST_HEAD(&ae.node); 180 if (!host)
181 ae.dev = &pdev->dev; 181 return -ENOMEM;
182 ae.port_ops = &pata_platform_port_ops; 182 ap = host->ports[0];
183 ae.sht = &pata_platform_sht; 183
184 ae.n_ports = 1; 184 ap->ops = &pata_platform_port_ops;
185 ae.pio_mask = pio_mask; 185 ap->pio_mask = pio_mask;
186 ae.irq = platform_get_irq(pdev, 0); 186 ap->flags |= ATA_FLAG_SLAVE_POSS;
187 ae.irq_flags = 0;
188 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
189 187
190 /* 188 /*
191 * Handle the MMIO case 189 * Handle the MMIO case
192 */ 190 */
193 if (mmio) { 191 if (mmio) {
194 ae.port[0].cmd_addr = devm_ioremap(&pdev->dev, io_res->start, 192 ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, io_res->start,
195 io_res->end - io_res->start + 1); 193 io_res->end - io_res->start + 1);
196 ae.port[0].ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start, 194 ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start,
197 ctl_res->end - ctl_res->start + 1); 195 ctl_res->end - ctl_res->start + 1);
198 } else { 196 } else {
199 ae.port[0].cmd_addr = devm_ioport_map(&pdev->dev, io_res->start, 197 ap->ioaddr.cmd_addr = devm_ioport_map(&pdev->dev, io_res->start,
200 io_res->end - io_res->start + 1); 198 io_res->end - io_res->start + 1);
201 ae.port[0].ctl_addr = devm_ioport_map(&pdev->dev, ctl_res->start, 199 ap->ioaddr.ctl_addr = devm_ioport_map(&pdev->dev, ctl_res->start,
202 ctl_res->end - ctl_res->start + 1); 200 ctl_res->end - ctl_res->start + 1);
203 } 201 }
204 if (!ae.port[0].cmd_addr || !ae.port[0].ctl_addr) { 202 if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) {
205 dev_err(&pdev->dev, "failed to map IO/CTL base\n"); 203 dev_err(&pdev->dev, "failed to map IO/CTL base\n");
206 return -ENOMEM; 204 return -ENOMEM;
207 } 205 }
208 206
209 ae.port[0].altstatus_addr = ae.port[0].ctl_addr; 207 ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr;
210 208
211 pata_platform_setup_port(&ae.port[0], pdev->dev.platform_data); 209 pata_platform_setup_port(&ap->ioaddr, pdev->dev.platform_data);
212 210
213 if (unlikely(ata_device_add(&ae) == 0)) 211 /* activate */
214 return -ENODEV; 212 return ata_host_activate(host, platform_get_irq(pdev, 0), ata_interrupt,
215 213 0, &pata_platform_sht);
216 return 0;
217} 214}
218 215
219/** 216/**
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 44472641db28..27685ce63ceb 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -190,7 +190,6 @@ static struct ata_port_operations qdi6500_port_ops = {
190 190
191 .data_xfer = qdi_data_xfer, 191 .data_xfer = qdi_data_xfer,
192 192
193 .irq_handler = ata_interrupt,
194 .irq_clear = ata_bmdma_irq_clear, 193 .irq_clear = ata_bmdma_irq_clear,
195 .irq_on = ata_irq_on, 194 .irq_on = ata_irq_on,
196 .irq_ack = ata_irq_ack, 195 .irq_ack = ata_irq_ack,
@@ -219,7 +218,6 @@ static struct ata_port_operations qdi6580_port_ops = {
219 218
220 .data_xfer = qdi_data_xfer, 219 .data_xfer = qdi_data_xfer,
221 220
222 .irq_handler = ata_interrupt,
223 .irq_clear = ata_bmdma_irq_clear, 221 .irq_clear = ata_bmdma_irq_clear,
224 .irq_on = ata_irq_on, 222 .irq_on = ata_irq_on,
225 .irq_ack = ata_irq_ack, 223 .irq_ack = ata_irq_ack,
@@ -240,8 +238,9 @@ static struct ata_port_operations qdi6580_port_ops = {
240 238
241static __init int qdi_init_one(unsigned long port, int type, unsigned long io, int irq, int fast) 239static __init int qdi_init_one(unsigned long port, int type, unsigned long io, int irq, int fast)
242{ 240{
243 struct ata_probe_ent ae;
244 struct platform_device *pdev; 241 struct platform_device *pdev;
242 struct ata_host *host;
243 struct ata_port *ap;
245 void __iomem *io_addr, *ctl_addr; 244 void __iomem *io_addr, *ctl_addr;
246 int ret; 245 int ret;
247 246
@@ -259,34 +258,31 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
259 if (!io_addr || !ctl_addr) 258 if (!io_addr || !ctl_addr)
260 goto fail; 259 goto fail;
261 260
262 memset(&ae, 0, sizeof(struct ata_probe_ent)); 261 ret = -ENOMEM;
263 INIT_LIST_HEAD(&ae.node); 262 host = ata_host_alloc(&pdev->dev, 1);
264 ae.dev = &pdev->dev; 263 if (!host)
264 goto fail;
265 ap = host->ports[0];
265 266
266 if (type == 6580) { 267 if (type == 6580) {
267 ae.port_ops = &qdi6580_port_ops; 268 ap->ops = &qdi6580_port_ops;
268 ae.pio_mask = 0x1F; 269 ap->pio_mask = 0x1F;
269 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; 270 ap->flags |= ATA_FLAG_SLAVE_POSS;
270 } else { 271 } else {
271 ae.port_ops = &qdi6500_port_ops; 272 ap->ops = &qdi6500_port_ops;
272 ae.pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */ 273 ap->pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */
273 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | 274 ap->flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY;
274 ATA_FLAG_NO_IORDY;
275 } 275 }
276 276
277 ae.sht = &qdi_sht; 277 ap->ioaddr.cmd_addr = io_addr;
278 ae.n_ports = 1; 278 ap->ioaddr.altstatus_addr = ctl_addr;
279 ae.irq = irq; 279 ap->ioaddr.ctl_addr = ctl_addr;
280 ae.irq_flags = 0; 280 ata_std_ports(&ap->ioaddr);
281 ae.port[0].cmd_addr = io_addr;
282 ae.port[0].altstatus_addr = ctl_addr;
283 ae.port[0].ctl_addr = ctl_addr;
284 ata_std_ports(&ae.port[0]);
285 281
286 /* 282 /*
287 * Hook in a private data structure per channel 283 * Hook in a private data structure per channel
288 */ 284 */
289 ae.private_data = &qdi_data[nr_qdi_host]; 285 ap->private_data = &qdi_data[nr_qdi_host];
290 286
291 qdi_data[nr_qdi_host].timing = port; 287 qdi_data[nr_qdi_host].timing = port;
292 qdi_data[nr_qdi_host].fast = fast; 288 qdi_data[nr_qdi_host].fast = fast;
@@ -294,8 +290,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
294 290
295 printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io); 291 printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io);
296 292
297 ret = -ENODEV; 293 /* activate */
298 if (!ata_device_add(&ae)) 294 ret = ata_host_activate(host, irq, ata_interrupt, 0, &qdi_sht);
295 if (ret)
299 goto fail; 296 goto fail;
300 297
301 qdi_host[nr_qdi_host++] = dev_get_drvdata(&pdev->dev); 298 qdi_host[nr_qdi_host++] = dev_get_drvdata(&pdev->dev);
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index f3ed141fdc0e..5df354d573e8 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -1016,7 +1016,6 @@ static const struct ata_port_operations scc_pata_ops = {
1016 .error_handler = scc_error_handler, 1016 .error_handler = scc_error_handler,
1017 .post_internal_cmd = scc_bmdma_stop, 1017 .post_internal_cmd = scc_bmdma_stop,
1018 1018
1019 .irq_handler = ata_interrupt,
1020 .irq_clear = scc_bmdma_irq_clear, 1019 .irq_clear = scc_bmdma_irq_clear,
1021 .irq_on = scc_irq_on, 1020 .irq_on = scc_irq_on,
1022 .irq_ack = scc_irq_ack, 1021 .irq_ack = scc_irq_ack,
@@ -1027,7 +1026,6 @@ static const struct ata_port_operations scc_pata_ops = {
1027 1026
1028static struct ata_port_info scc_port_info[] = { 1027static struct ata_port_info scc_port_info[] = {
1029 { 1028 {
1030 .sht = &scc_sht,
1031 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY, 1029 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY,
1032 .pio_mask = 0x1f, /* pio0-4 */ 1030 .pio_mask = 0x1f, /* pio0-4 */
1033 .mwdma_mask = 0x00, 1031 .mwdma_mask = 0x00,
@@ -1040,10 +1038,10 @@ static struct ata_port_info scc_port_info[] = {
1040 * scc_reset_controller - initialize SCC PATA controller. 1038 * scc_reset_controller - initialize SCC PATA controller.
1041 */ 1039 */
1042 1040
1043static int scc_reset_controller(struct ata_probe_ent *probe_ent) 1041static int scc_reset_controller(struct ata_host *host)
1044{ 1042{
1045 void __iomem *ctrl_base = probe_ent->iomap[SCC_CTRL_BAR]; 1043 void __iomem *ctrl_base = host->iomap[SCC_CTRL_BAR];
1046 void __iomem *bmid_base = probe_ent->iomap[SCC_BMID_BAR]; 1044 void __iomem *bmid_base = host->iomap[SCC_BMID_BAR];
1047 void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL; 1045 void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL;
1048 void __iomem *mode_port = ctrl_base + SCC_CTL_MODEREG; 1046 void __iomem *mode_port = ctrl_base + SCC_CTL_MODEREG;
1049 void __iomem *ecmode_port = ctrl_base + SCC_CTL_ECMODE; 1047 void __iomem *ecmode_port = ctrl_base + SCC_CTL_ECMODE;
@@ -1104,17 +1102,15 @@ static void scc_setup_ports (struct ata_ioports *ioaddr, void __iomem *base)
1104 ioaddr->command_addr = ioaddr->cmd_addr + SCC_REG_CMD; 1102 ioaddr->command_addr = ioaddr->cmd_addr + SCC_REG_CMD;
1105} 1103}
1106 1104
1107static int scc_host_init(struct ata_probe_ent *probe_ent) 1105static int scc_host_init(struct ata_host *host)
1108{ 1106{
1109 struct pci_dev *pdev = to_pci_dev(probe_ent->dev); 1107 struct pci_dev *pdev = to_pci_dev(host->dev);
1110 int rc; 1108 int rc;
1111 1109
1112 rc = scc_reset_controller(probe_ent); 1110 rc = scc_reset_controller(host);
1113 if (rc) 1111 if (rc)
1114 return rc; 1112 return rc;
1115 1113
1116 probe_ent->n_ports = 1;
1117
1118 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 1114 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
1119 if (rc) 1115 if (rc)
1120 return rc; 1116 return rc;
@@ -1122,7 +1118,7 @@ static int scc_host_init(struct ata_probe_ent *probe_ent)
1122 if (rc) 1118 if (rc)
1123 return rc; 1119 return rc;
1124 1120
1125 scc_setup_ports(&probe_ent->port[0], probe_ent->iomap[SCC_BMID_BAR]); 1121 scc_setup_ports(&host->ports[0]->ioaddr, host->iomap[SCC_BMID_BAR]);
1126 1122
1127 pci_set_master(pdev); 1123 pci_set_master(pdev);
1128 1124
@@ -1145,14 +1141,18 @@ static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1145{ 1141{
1146 static int printed_version; 1142 static int printed_version;
1147 unsigned int board_idx = (unsigned int) ent->driver_data; 1143 unsigned int board_idx = (unsigned int) ent->driver_data;
1144 const struct ata_port_info *ppi[] = { &scc_port_info[board_idx], NULL };
1148 struct device *dev = &pdev->dev; 1145 struct device *dev = &pdev->dev;
1149 struct ata_probe_ent *probe_ent;
1150 int rc; 1146 int rc;
1151 1147
1152 if (!printed_version++) 1148 if (!printed_version++)
1153 dev_printk(KERN_DEBUG, &pdev->dev, 1149 dev_printk(KERN_DEBUG, &pdev->dev,
1154 "version " DRV_VERSION "\n"); 1150 "version " DRV_VERSION "\n");
1155 1151
1152 host = ata_port_alloc_pinfo(&pdev->dev, ppi, 1);
1153 if (!host)
1154 return -ENOMEM;
1155
1156 rc = pcim_enable_device(pdev); 1156 rc = pcim_enable_device(pdev);
1157 if (rc) 1157 if (rc)
1158 return rc; 1158 return rc;
@@ -1162,33 +1162,14 @@ static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1162 pcim_pin_device(pdev); 1162 pcim_pin_device(pdev);
1163 if (rc) 1163 if (rc)
1164 return rc; 1164 return rc;
1165 host->iomap = pcim_iomap_table(pdev);
1165 1166
1166 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); 1167 rc = scc_host_init(host);
1167 if (!probe_ent)
1168 return -ENOMEM;
1169
1170 probe_ent->dev = dev;
1171 INIT_LIST_HEAD(&probe_ent->node);
1172
1173 probe_ent->sht = scc_port_info[board_idx].sht;
1174 probe_ent->port_flags = scc_port_info[board_idx].flags;
1175 probe_ent->pio_mask = scc_port_info[board_idx].pio_mask;
1176 probe_ent->udma_mask = scc_port_info[board_idx].udma_mask;
1177 probe_ent->port_ops = scc_port_info[board_idx].port_ops;
1178
1179 probe_ent->irq = pdev->irq;
1180 probe_ent->irq_flags = IRQF_SHARED;
1181 probe_ent->iomap = pcim_iomap_table(pdev);
1182
1183 rc = scc_host_init(probe_ent);
1184 if (rc) 1168 if (rc)
1185 return rc; 1169 return rc;
1186 1170
1187 if (!ata_device_add(probe_ent)) 1171 return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED,
1188 return -ENODEV; 1172 &scc_sht);
1189
1190 devm_kfree(dev, probe_ent);
1191 return 0;
1192} 1173}
1193 1174
1194static struct pci_driver scc_pci_driver = { 1175static struct pci_driver scc_pci_driver = {
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
index 434f14f6f869..aa6d4bca2ea3 100644
--- a/drivers/ata/pata_winbond.c
+++ b/drivers/ata/pata_winbond.c
@@ -158,7 +158,6 @@ static struct ata_port_operations winbond_port_ops = {
158 158
159 .data_xfer = winbond_data_xfer, 159 .data_xfer = winbond_data_xfer,
160 160
161 .irq_handler = ata_interrupt,
162 .irq_clear = ata_bmdma_irq_clear, 161 .irq_clear = ata_bmdma_irq_clear,
163 .irq_on = ata_irq_on, 162 .irq_on = ata_irq_on,
164 .irq_ack = ata_irq_ack, 163 .irq_ack = ata_irq_ack,
@@ -179,11 +178,9 @@ static struct ata_port_operations winbond_port_ops = {
179 178
180static __init int winbond_init_one(unsigned long port) 179static __init int winbond_init_one(unsigned long port)
181{ 180{
182 struct ata_probe_ent ae;
183 struct platform_device *pdev; 181 struct platform_device *pdev;
184 int ret;
185 u8 reg; 182 u8 reg;
186 int i; 183 int i, rc;
187 184
188 reg = winbond_readcfg(port, 0x81); 185 reg = winbond_readcfg(port, 0x81);
189 reg |= 0x80; /* jumpered mode off */ 186 reg |= 0x80; /* jumpered mode off */
@@ -202,58 +199,56 @@ static __init int winbond_init_one(unsigned long port)
202 199
203 for (i = 0; i < 2 ; i ++) { 200 for (i = 0; i < 2 ; i ++) {
204 unsigned long cmd_port = 0x1F0 - (0x80 * i); 201 unsigned long cmd_port = 0x1F0 - (0x80 * i);
202 struct ata_host *host;
203 struct ata_port *ap;
205 void __iomem *cmd_addr, *ctl_addr; 204 void __iomem *cmd_addr, *ctl_addr;
206 205
207 if (reg & (1 << i)) { 206 if (!(reg & (1 << i)))
208 /* 207 continue;
209 * Fill in a probe structure first of all 208
210 */ 209 pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0);
211 210 if (IS_ERR(pdev))
212 pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0); 211 return PTR_ERR(pdev);
213 if (IS_ERR(pdev)) 212
214 return PTR_ERR(pdev); 213 rc = -ENOMEM;
215 214 host = ata_host_alloc(&pdev->dev, 1);
216 cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8); 215 if (!host)
217 ctl_addr = devm_ioport_map(&pdev->dev, cmd_port + 0x0206, 1); 216 goto err_unregister;
218 if (!cmd_addr || !ctl_addr) { 217
219 platform_device_unregister(pdev); 218 rc = -ENOMEM;
220 return -ENOMEM; 219 cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8);
221 } 220 ctl_addr = devm_ioport_map(&pdev->dev, cmd_port + 0x0206, 1);
222 221 if (!cmd_addr || !ctl_addr)
223 memset(&ae, 0, sizeof(struct ata_probe_ent)); 222 goto err_unregister;
224 INIT_LIST_HEAD(&ae.node); 223
225 ae.dev = &pdev->dev; 224 ap = host->ports[0];
226 225 ap->ops = &winbond_port_ops;
227 ae.port_ops = &winbond_port_ops; 226 ap->pio_mask = 0x1F;
228 ae.pio_mask = 0x1F; 227 ap->flags |= ATA_FLAG_SLAVE_POSS;
229 228 ap->ioaddr.cmd_addr = cmd_addr;
230 ae.sht = &winbond_sht; 229 ap->ioaddr.altstatus_addr = ctl_addr;
231 230 ap->ioaddr.ctl_addr = ctl_addr;
232 ae.n_ports = 1; 231 ata_std_ports(&ap->ioaddr);
233 ae.irq = 14 + i; 232
234 ae.irq_flags = 0; 233 /* hook in a private data structure per channel */
235 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; 234 host->private_data = &winbond_data[nr_winbond_host];
236 ae.port[0].cmd_addr = cmd_addr; 235 winbond_data[nr_winbond_host].config = port;
237 ae.port[0].altstatus_addr = ctl_addr; 236 winbond_data[nr_winbond_host].platform_dev = pdev;
238 ae.port[0].ctl_addr = ctl_addr; 237
239 ata_std_ports(&ae.port[0]); 238 /* activate */
240 /* 239 rc = ata_host_activate(host, 14 + i, ata_interrupt, 0,
241 * Hook in a private data structure per channel 240 &winbond_sht);
242 */ 241 if (rc)
243 ae.private_data = &winbond_data[nr_winbond_host]; 242 goto err_unregister;
244 winbond_data[nr_winbond_host].config = port; 243
245 winbond_data[nr_winbond_host].platform_dev = pdev; 244 winbond_host[nr_winbond_host++] = dev_get_drvdata(&pdev->dev);
246
247 ret = ata_device_add(&ae);
248 if (ret == 0) {
249 platform_device_unregister(pdev);
250 return -ENODEV;
251 }
252 winbond_host[nr_winbond_host++] = dev_get_drvdata(&pdev->dev);
253 }
254 } 245 }
255 246
256 return 0; 247 return 0;
248
249 err_unregister:
250 platform_device_unregister(pdev);
251 return rc;
257} 252}
258 253
259/** 254/**
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index 5dd3ca8b5f29..52b69530ab29 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -52,9 +52,9 @@
52/* macro to calculate base address for ADMA regs */ 52/* macro to calculate base address for ADMA regs */
53#define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20)) 53#define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20))
54 54
55/* macro to obtain addresses from ata_host */ 55/* macro to obtain addresses from ata_port */
56#define ADMA_HOST_REGS(host,port_no) \ 56#define ADMA_PORT_REGS(ap) \
57 ADMA_REGS((host)->iomap[ADMA_MMIO_BAR], port_no) 57 ADMA_REGS((ap)->host->iomap[ADMA_MMIO_BAR], ap->port_no)
58 58
59enum { 59enum {
60 ADMA_MMIO_BAR = 4, 60 ADMA_MMIO_BAR = 4,
@@ -128,7 +128,6 @@ struct adma_port_priv {
128 128
129static int adma_ata_init_one (struct pci_dev *pdev, 129static int adma_ata_init_one (struct pci_dev *pdev,
130 const struct pci_device_id *ent); 130 const struct pci_device_id *ent);
131static irqreturn_t adma_intr (int irq, void *dev_instance);
132static int adma_port_start(struct ata_port *ap); 131static int adma_port_start(struct ata_port *ap);
133static void adma_host_stop(struct ata_host *host); 132static void adma_host_stop(struct ata_host *host);
134static void adma_port_stop(struct ata_port *ap); 133static void adma_port_stop(struct ata_port *ap);
@@ -172,7 +171,6 @@ static const struct ata_port_operations adma_ata_ops = {
172 .qc_issue = adma_qc_issue, 171 .qc_issue = adma_qc_issue,
173 .eng_timeout = adma_eng_timeout, 172 .eng_timeout = adma_eng_timeout,
174 .data_xfer = ata_data_xfer, 173 .data_xfer = ata_data_xfer,
175 .irq_handler = adma_intr,
176 .irq_clear = adma_irq_clear, 174 .irq_clear = adma_irq_clear,
177 .irq_on = ata_irq_on, 175 .irq_on = ata_irq_on,
178 .irq_ack = ata_irq_ack, 176 .irq_ack = ata_irq_ack,
@@ -186,7 +184,6 @@ static const struct ata_port_operations adma_ata_ops = {
186static struct ata_port_info adma_port_info[] = { 184static struct ata_port_info adma_port_info[] = {
187 /* board_1841_idx */ 185 /* board_1841_idx */
188 { 186 {
189 .sht = &adma_ata_sht,
190 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | 187 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST |
191 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO | 188 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO |
192 ATA_FLAG_PIO_POLLING, 189 ATA_FLAG_PIO_POLLING,
@@ -229,8 +226,10 @@ static void adma_irq_clear(struct ata_port *ap)
229 /* nothing */ 226 /* nothing */
230} 227}
231 228
232static void adma_reset_engine(void __iomem *chan) 229static void adma_reset_engine(struct ata_port *ap)
233{ 230{
231 void __iomem *chan = ADMA_PORT_REGS(ap);
232
234 /* reset ADMA to idle state */ 233 /* reset ADMA to idle state */
235 writew(aPIOMD4 | aNIEN | aRSTADM, chan + ADMA_CONTROL); 234 writew(aPIOMD4 | aNIEN | aRSTADM, chan + ADMA_CONTROL);
236 udelay(2); 235 udelay(2);
@@ -241,14 +240,14 @@ static void adma_reset_engine(void __iomem *chan)
241static void adma_reinit_engine(struct ata_port *ap) 240static void adma_reinit_engine(struct ata_port *ap)
242{ 241{
243 struct adma_port_priv *pp = ap->private_data; 242 struct adma_port_priv *pp = ap->private_data;
244 void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no); 243 void __iomem *chan = ADMA_PORT_REGS(ap);
245 244
246 /* mask/clear ATA interrupts */ 245 /* mask/clear ATA interrupts */
247 writeb(ATA_NIEN, ap->ioaddr.ctl_addr); 246 writeb(ATA_NIEN, ap->ioaddr.ctl_addr);
248 ata_check_status(ap); 247 ata_check_status(ap);
249 248
250 /* reset the ADMA engine */ 249 /* reset the ADMA engine */
251 adma_reset_engine(chan); 250 adma_reset_engine(ap);
252 251
253 /* set in-FIFO threshold to 0x100 */ 252 /* set in-FIFO threshold to 0x100 */
254 writew(0x100, chan + ADMA_FIFO_IN); 253 writew(0x100, chan + ADMA_FIFO_IN);
@@ -268,7 +267,7 @@ static void adma_reinit_engine(struct ata_port *ap)
268 267
269static inline void adma_enter_reg_mode(struct ata_port *ap) 268static inline void adma_enter_reg_mode(struct ata_port *ap)
270{ 269{
271 void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no); 270 void __iomem *chan = ADMA_PORT_REGS(ap);
272 271
273 writew(aPIOMD4, chan + ADMA_CONTROL); 272 writew(aPIOMD4, chan + ADMA_CONTROL);
274 readb(chan + ADMA_STATUS); /* flush */ 273 readb(chan + ADMA_STATUS); /* flush */
@@ -415,7 +414,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc)
415static inline void adma_packet_start(struct ata_queued_cmd *qc) 414static inline void adma_packet_start(struct ata_queued_cmd *qc)
416{ 415{
417 struct ata_port *ap = qc->ap; 416 struct ata_port *ap = qc->ap;
418 void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no); 417 void __iomem *chan = ADMA_PORT_REGS(ap);
419 418
420 VPRINTK("ENTER, ap %p\n", ap); 419 VPRINTK("ENTER, ap %p\n", ap);
421 420
@@ -453,7 +452,7 @@ static inline unsigned int adma_intr_pkt(struct ata_host *host)
453 struct ata_port *ap = host->ports[port_no]; 452 struct ata_port *ap = host->ports[port_no];
454 struct adma_port_priv *pp; 453 struct adma_port_priv *pp;
455 struct ata_queued_cmd *qc; 454 struct ata_queued_cmd *qc;
456 void __iomem *chan = ADMA_HOST_REGS(host, port_no); 455 void __iomem *chan = ADMA_PORT_REGS(ap);
457 u8 status = readb(chan + ADMA_STATUS); 456 u8 status = readb(chan + ADMA_STATUS);
458 457
459 if (status == 0) 458 if (status == 0)
@@ -575,7 +574,7 @@ static int adma_port_start(struct ata_port *ap)
575 574
576static void adma_port_stop(struct ata_port *ap) 575static void adma_port_stop(struct ata_port *ap)
577{ 576{
578 adma_reset_engine(ADMA_HOST_REGS(ap->host, ap->port_no)); 577 adma_reset_engine(ap);
579} 578}
580 579
581static void adma_host_stop(struct ata_host *host) 580static void adma_host_stop(struct ata_host *host)
@@ -583,21 +582,19 @@ static void adma_host_stop(struct ata_host *host)
583 unsigned int port_no; 582 unsigned int port_no;
584 583
585 for (port_no = 0; port_no < ADMA_PORTS; ++port_no) 584 for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
586 adma_reset_engine(ADMA_HOST_REGS(host, port_no)); 585 adma_reset_engine(host->ports[port_no]);
587} 586}
588 587
589static void adma_host_init(unsigned int chip_id, 588static void adma_host_init(struct ata_host *host, unsigned int chip_id)
590 struct ata_probe_ent *probe_ent)
591{ 589{
592 unsigned int port_no; 590 unsigned int port_no;
593 void __iomem *mmio_base = probe_ent->iomap[ADMA_MMIO_BAR];
594 591
595 /* enable/lock aGO operation */ 592 /* enable/lock aGO operation */
596 writeb(7, mmio_base + ADMA_MODE_LOCK); 593 writeb(7, host->iomap[ADMA_MMIO_BAR] + ADMA_MODE_LOCK);
597 594
598 /* reset the ADMA logic */ 595 /* reset the ADMA logic */
599 for (port_no = 0; port_no < ADMA_PORTS; ++port_no) 596 for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
600 adma_reset_engine(ADMA_REGS(mmio_base, port_no)); 597 adma_reset_engine(host->ports[port_no]);
601} 598}
602 599
603static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base) 600static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
@@ -623,14 +620,21 @@ static int adma_ata_init_one(struct pci_dev *pdev,
623 const struct pci_device_id *ent) 620 const struct pci_device_id *ent)
624{ 621{
625 static int printed_version; 622 static int printed_version;
626 struct ata_probe_ent *probe_ent = NULL;
627 void __iomem *mmio_base;
628 unsigned int board_idx = (unsigned int) ent->driver_data; 623 unsigned int board_idx = (unsigned int) ent->driver_data;
624 const struct ata_port_info *ppi[] = { &adma_port_info[board_idx], NULL };
625 struct ata_host *host;
626 void __iomem *mmio_base;
629 int rc, port_no; 627 int rc, port_no;
630 628
631 if (!printed_version++) 629 if (!printed_version++)
632 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 630 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
633 631
632 /* alloc host */
633 host = ata_host_alloc_pinfo(&pdev->dev, ppi, ADMA_PORTS);
634 if (!host)
635 return -ENOMEM;
636
637 /* acquire resources and fill host */
634 rc = pcim_enable_device(pdev); 638 rc = pcim_enable_device(pdev);
635 if (rc) 639 if (rc)
636 return rc; 640 return rc;
@@ -641,46 +645,23 @@ static int adma_ata_init_one(struct pci_dev *pdev,
641 rc = pcim_iomap_regions(pdev, 1 << ADMA_MMIO_BAR, DRV_NAME); 645 rc = pcim_iomap_regions(pdev, 1 << ADMA_MMIO_BAR, DRV_NAME);
642 if (rc) 646 if (rc)
643 return rc; 647 return rc;
644 mmio_base = pcim_iomap_table(pdev)[ADMA_MMIO_BAR]; 648 host->iomap = pcim_iomap_table(pdev);
649 mmio_base = host->iomap[ADMA_MMIO_BAR];
645 650
646 rc = adma_set_dma_masks(pdev, mmio_base); 651 rc = adma_set_dma_masks(pdev, mmio_base);
647 if (rc) 652 if (rc)
648 return rc; 653 return rc;
649 654
650 probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); 655 for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
651 if (probe_ent == NULL) 656 adma_ata_setup_port(&host->ports[port_no]->ioaddr,
652 return -ENOMEM;
653
654 probe_ent->dev = pci_dev_to_dev(pdev);
655 INIT_LIST_HEAD(&probe_ent->node);
656
657 probe_ent->sht = adma_port_info[board_idx].sht;
658 probe_ent->port_flags = adma_port_info[board_idx].flags;
659 probe_ent->pio_mask = adma_port_info[board_idx].pio_mask;
660 probe_ent->mwdma_mask = adma_port_info[board_idx].mwdma_mask;
661 probe_ent->udma_mask = adma_port_info[board_idx].udma_mask;
662 probe_ent->port_ops = adma_port_info[board_idx].port_ops;
663
664 probe_ent->irq = pdev->irq;
665 probe_ent->irq_flags = IRQF_SHARED;
666 probe_ent->n_ports = ADMA_PORTS;
667 probe_ent->iomap = pcim_iomap_table(pdev);
668
669 for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
670 adma_ata_setup_port(&probe_ent->port[port_no],
671 ADMA_ATA_REGS(mmio_base, port_no)); 657 ADMA_ATA_REGS(mmio_base, port_no));
672 }
673
674 pci_set_master(pdev);
675 658
676 /* initialize adapter */ 659 /* initialize adapter */
677 adma_host_init(board_idx, probe_ent); 660 adma_host_init(host, board_idx);
678 661
679 if (!ata_device_add(probe_ent)) 662 pci_set_master(pdev);
680 return -ENODEV; 663 return ata_host_activate(host, pdev->irq, adma_intr, IRQF_SHARED,
681 664 &adma_ata_sht);
682 devm_kfree(&pdev->dev, probe_ent);
683 return 0;
684} 665}
685 666
686static int __init adma_ata_init(void) 667static int __init adma_ata_init(void)