diff options
author | Tejun Heo <htejun@gmail.com> | 2007-04-17 10:44:07 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 14:16:03 -0400 |
commit | eca25dca17630ae354f4b1df559ed90578b794fe (patch) | |
tree | e1c0864264a227bf3302480c8a5290d542acbf71 /drivers | |
parent | 21b0ad4fb8306ac2bf5a249ffc978b1b8924c7d0 (diff) |
libata: convert drivers with combined SATA/PATA ports to new init model
Convert sata_via and sata_promise to new init model. Both controllers
can have combined configuration (SATA + PATA) and used twisted
initialization method (modifying port in ->port_start) to overcome
probe_ent limitations.
This patch converts both drivers to new init model in which such
configuration is natively supported.
* promise: Combined pata port now uses separate port_info entry right
after the sata counterpart entry.
* promise: Controller configuration is discerned using ap->flags.
This simplifies init path and makes it look more like other LLDs.
* via: Both SATA and PATA ports in vt6421 are represented in their
own port_info structure.
Tested on PDC20375 (SATA150 TX2plus) [105a:3375] and PDC40775 (SATA
300 TX2plus) [105a:3d73]. Couldn't test via cuz my c3 won't boot the
current kernel.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/sata_promise.c | 255 | ||||
-rw-r--r-- | drivers/ata/sata_via.c | 182 |
2 files changed, 187 insertions, 250 deletions
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 8afde4a9ca7e..f56549b90aa6 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -49,6 +49,7 @@ | |||
49 | 49 | ||
50 | 50 | ||
51 | enum { | 51 | enum { |
52 | PDC_MAX_PORTS = 4, | ||
52 | PDC_MMIO_BAR = 3, | 53 | PDC_MMIO_BAR = 3, |
53 | 54 | ||
54 | /* register offsets */ | 55 | /* register offsets */ |
@@ -89,10 +90,12 @@ enum { | |||
89 | | PDC1_ERR_MASK | PDC2_ERR_MASK), | 90 | | PDC1_ERR_MASK | PDC2_ERR_MASK), |
90 | 91 | ||
91 | board_2037x = 0, /* FastTrak S150 TX2plus */ | 92 | board_2037x = 0, /* FastTrak S150 TX2plus */ |
92 | board_20319 = 1, /* FastTrak S150 TX4 */ | 93 | board_2037x_pata = 1, /* FastTrak S150 TX2plus PATA port */ |
93 | board_20619 = 2, /* FastTrak TX4000 */ | 94 | board_20319 = 2, /* FastTrak S150 TX4 */ |
94 | board_2057x = 3, /* SATAII150 Tx2plus */ | 95 | board_20619 = 3, /* FastTrak TX4000 */ |
95 | board_40518 = 4, /* SATAII150 Tx4 */ | 96 | board_2057x = 4, /* SATAII150 Tx2plus */ |
97 | board_2057x_pata = 5, /* SATAII150 Tx2plus */ | ||
98 | board_40518 = 6, /* SATAII150 Tx4 */ | ||
96 | 99 | ||
97 | PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */ | 100 | PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */ |
98 | 101 | ||
@@ -115,8 +118,10 @@ enum { | |||
115 | ATA_FLAG_MMIO | | 118 | ATA_FLAG_MMIO | |
116 | ATA_FLAG_PIO_POLLING, | 119 | ATA_FLAG_PIO_POLLING, |
117 | 120 | ||
118 | /* hp->flags bits */ | 121 | /* ap->flags bits */ |
119 | PDC_FLAG_GEN_II = (1 << 0), | 122 | PDC_FLAG_GEN_II = (1 << 24), |
123 | PDC_FLAG_SATA_PATA = (1 << 25), /* supports SATA + PATA */ | ||
124 | PDC_FLAG_4_PORTS = (1 << 26), /* 4 ports */ | ||
120 | }; | 125 | }; |
121 | 126 | ||
122 | 127 | ||
@@ -125,16 +130,11 @@ struct pdc_port_priv { | |||
125 | dma_addr_t pkt_dma; | 130 | dma_addr_t pkt_dma; |
126 | }; | 131 | }; |
127 | 132 | ||
128 | struct pdc_host_priv { | ||
129 | unsigned long flags; | ||
130 | unsigned long port_flags[ATA_MAX_PORTS]; | ||
131 | }; | ||
132 | |||
133 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); | 133 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); |
134 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 134 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); |
135 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 135 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
136 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); | 136 | static int pdc_common_port_start(struct ata_port *ap); |
137 | static int pdc_port_start(struct ata_port *ap); | 137 | static int pdc_sata_port_start(struct ata_port *ap); |
138 | static void pdc_qc_prep(struct ata_queued_cmd *qc); | 138 | static void pdc_qc_prep(struct ata_queued_cmd *qc); |
139 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 139 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
140 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 140 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
@@ -185,14 +185,13 @@ static const struct ata_port_operations pdc_sata_ops = { | |||
185 | .post_internal_cmd = pdc_post_internal_cmd, | 185 | .post_internal_cmd = pdc_post_internal_cmd, |
186 | .cable_detect = pdc_sata_cable_detect, | 186 | .cable_detect = pdc_sata_cable_detect, |
187 | .data_xfer = ata_data_xfer, | 187 | .data_xfer = ata_data_xfer, |
188 | .irq_handler = pdc_interrupt, | ||
189 | .irq_clear = pdc_irq_clear, | 188 | .irq_clear = pdc_irq_clear, |
190 | .irq_on = ata_irq_on, | 189 | .irq_on = ata_irq_on, |
191 | .irq_ack = ata_irq_ack, | 190 | .irq_ack = ata_irq_ack, |
192 | 191 | ||
193 | .scr_read = pdc_sata_scr_read, | 192 | .scr_read = pdc_sata_scr_read, |
194 | .scr_write = pdc_sata_scr_write, | 193 | .scr_write = pdc_sata_scr_write, |
195 | .port_start = pdc_port_start, | 194 | .port_start = pdc_sata_port_start, |
196 | }; | 195 | }; |
197 | 196 | ||
198 | /* First-generation chips need a more restrictive ->check_atapi_dma op */ | 197 | /* First-generation chips need a more restrictive ->check_atapi_dma op */ |
@@ -213,14 +212,13 @@ static const struct ata_port_operations pdc_old_sata_ops = { | |||
213 | .post_internal_cmd = pdc_post_internal_cmd, | 212 | .post_internal_cmd = pdc_post_internal_cmd, |
214 | .cable_detect = pdc_sata_cable_detect, | 213 | .cable_detect = pdc_sata_cable_detect, |
215 | .data_xfer = ata_data_xfer, | 214 | .data_xfer = ata_data_xfer, |
216 | .irq_handler = pdc_interrupt, | ||
217 | .irq_clear = pdc_irq_clear, | 215 | .irq_clear = pdc_irq_clear, |
218 | .irq_on = ata_irq_on, | 216 | .irq_on = ata_irq_on, |
219 | .irq_ack = ata_irq_ack, | 217 | .irq_ack = ata_irq_ack, |
220 | 218 | ||
221 | .scr_read = pdc_sata_scr_read, | 219 | .scr_read = pdc_sata_scr_read, |
222 | .scr_write = pdc_sata_scr_write, | 220 | .scr_write = pdc_sata_scr_write, |
223 | .port_start = pdc_port_start, | 221 | .port_start = pdc_sata_port_start, |
224 | }; | 222 | }; |
225 | 223 | ||
226 | static const struct ata_port_operations pdc_pata_ops = { | 224 | static const struct ata_port_operations pdc_pata_ops = { |
@@ -240,29 +238,37 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
240 | .post_internal_cmd = pdc_post_internal_cmd, | 238 | .post_internal_cmd = pdc_post_internal_cmd, |
241 | .cable_detect = pdc_pata_cable_detect, | 239 | .cable_detect = pdc_pata_cable_detect, |
242 | .data_xfer = ata_data_xfer, | 240 | .data_xfer = ata_data_xfer, |
243 | .irq_handler = pdc_interrupt, | ||
244 | .irq_clear = pdc_irq_clear, | 241 | .irq_clear = pdc_irq_clear, |
245 | .irq_on = ata_irq_on, | 242 | .irq_on = ata_irq_on, |
246 | .irq_ack = ata_irq_ack, | 243 | .irq_ack = ata_irq_ack, |
247 | 244 | ||
248 | .port_start = pdc_port_start, | 245 | .port_start = pdc_common_port_start, |
249 | }; | 246 | }; |
250 | 247 | ||
251 | static const struct ata_port_info pdc_port_info[] = { | 248 | static const struct ata_port_info pdc_port_info[] = { |
252 | /* board_2037x */ | 249 | /* board_2037x */ |
253 | { | 250 | { |
254 | .sht = &pdc_ata_sht, | 251 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
255 | .flags = PDC_COMMON_FLAGS, | 252 | PDC_FLAG_SATA_PATA, |
256 | .pio_mask = 0x1f, /* pio0-4 */ | 253 | .pio_mask = 0x1f, /* pio0-4 */ |
257 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 254 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
258 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 255 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
259 | .port_ops = &pdc_old_sata_ops, | 256 | .port_ops = &pdc_old_sata_ops, |
260 | }, | 257 | }, |
261 | 258 | ||
259 | /* board_2037x_pata */ | ||
260 | { | ||
261 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, | ||
262 | .pio_mask = 0x1f, /* pio0-4 */ | ||
263 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
264 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | ||
265 | .port_ops = &pdc_pata_ops, | ||
266 | }, | ||
267 | |||
262 | /* board_20319 */ | 268 | /* board_20319 */ |
263 | { | 269 | { |
264 | .sht = &pdc_ata_sht, | 270 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
265 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, | 271 | PDC_FLAG_4_PORTS, |
266 | .pio_mask = 0x1f, /* pio0-4 */ | 272 | .pio_mask = 0x1f, /* pio0-4 */ |
267 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 273 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
268 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 274 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
@@ -271,8 +277,8 @@ static const struct ata_port_info pdc_port_info[] = { | |||
271 | 277 | ||
272 | /* board_20619 */ | 278 | /* board_20619 */ |
273 | { | 279 | { |
274 | .sht = &pdc_ata_sht, | 280 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | |
275 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, | 281 | PDC_FLAG_4_PORTS, |
276 | .pio_mask = 0x1f, /* pio0-4 */ | 282 | .pio_mask = 0x1f, /* pio0-4 */ |
277 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 283 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
278 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 284 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
@@ -281,18 +287,28 @@ static const struct ata_port_info pdc_port_info[] = { | |||
281 | 287 | ||
282 | /* board_2057x */ | 288 | /* board_2057x */ |
283 | { | 289 | { |
284 | .sht = &pdc_ata_sht, | 290 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
285 | .flags = PDC_COMMON_FLAGS, | 291 | PDC_FLAG_GEN_II | PDC_FLAG_SATA_PATA, |
286 | .pio_mask = 0x1f, /* pio0-4 */ | 292 | .pio_mask = 0x1f, /* pio0-4 */ |
287 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 293 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
288 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 294 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
289 | .port_ops = &pdc_sata_ops, | 295 | .port_ops = &pdc_sata_ops, |
290 | }, | 296 | }, |
291 | 297 | ||
298 | /* board_2057x_pata */ | ||
299 | { | ||
300 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, | ||
301 | PDC_FLAG_GEN_II, | ||
302 | .pio_mask = 0x1f, /* pio0-4 */ | ||
303 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
304 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | ||
305 | .port_ops = &pdc_pata_ops, | ||
306 | }, | ||
307 | |||
292 | /* board_40518 */ | 308 | /* board_40518 */ |
293 | { | 309 | { |
294 | .sht = &pdc_ata_sht, | 310 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
295 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, | 311 | PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS, |
296 | .pio_mask = 0x1f, /* pio0-4 */ | 312 | .pio_mask = 0x1f, /* pio0-4 */ |
297 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 313 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
298 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 314 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
@@ -358,7 +374,6 @@ static int pdc_common_port_start(struct ata_port *ap) | |||
358 | 374 | ||
359 | static int pdc_sata_port_start(struct ata_port *ap) | 375 | static int pdc_sata_port_start(struct ata_port *ap) |
360 | { | 376 | { |
361 | struct pdc_host_priv *hp = ap->host->private_data; | ||
362 | int rc; | 377 | int rc; |
363 | 378 | ||
364 | rc = pdc_common_port_start(ap); | 379 | rc = pdc_common_port_start(ap); |
@@ -366,7 +381,7 @@ static int pdc_sata_port_start(struct ata_port *ap) | |||
366 | return rc; | 381 | return rc; |
367 | 382 | ||
368 | /* fix up PHYMODE4 align timing */ | 383 | /* fix up PHYMODE4 align timing */ |
369 | if (hp->flags & PDC_FLAG_GEN_II) { | 384 | if (ap->flags & PDC_FLAG_GEN_II) { |
370 | void __iomem *mmio = (void __iomem *) ap->ioaddr.scr_addr; | 385 | void __iomem *mmio = (void __iomem *) ap->ioaddr.scr_addr; |
371 | unsigned int tmp; | 386 | unsigned int tmp; |
372 | 387 | ||
@@ -378,21 +393,6 @@ static int pdc_sata_port_start(struct ata_port *ap) | |||
378 | return 0; | 393 | return 0; |
379 | } | 394 | } |
380 | 395 | ||
381 | static int pdc_port_start(struct ata_port *ap) | ||
382 | { | ||
383 | struct pdc_host_priv *hp = ap->host->private_data; | ||
384 | |||
385 | /* fix up port flags and cable type for SATA+PATA chips */ | ||
386 | ap->flags |= hp->port_flags[ap->port_no]; | ||
387 | if (ap->flags & ATA_FLAG_SATA) { | ||
388 | ap->cbl = ATA_CBL_SATA; | ||
389 | return pdc_sata_port_start(ap); | ||
390 | } else { | ||
391 | ap->ops = &pdc_pata_ops; | ||
392 | return pdc_common_port_start(ap); | ||
393 | } | ||
394 | } | ||
395 | |||
396 | static void pdc_reset_port(struct ata_port *ap) | 396 | static void pdc_reset_port(struct ata_port *ap) |
397 | { | 397 | { |
398 | void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT; | 398 | void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT; |
@@ -660,11 +660,10 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, | |||
660 | { | 660 | { |
661 | unsigned int handled = 0; | 661 | unsigned int handled = 0; |
662 | void __iomem *port_mmio = ap->ioaddr.cmd_addr; | 662 | void __iomem *port_mmio = ap->ioaddr.cmd_addr; |
663 | struct pdc_host_priv *hp = ap->host->private_data; | ||
664 | u32 port_status, err_mask; | 663 | u32 port_status, err_mask; |
665 | 664 | ||
666 | err_mask = PDC_ERR_MASK; | 665 | err_mask = PDC_ERR_MASK; |
667 | if (hp->flags & PDC_FLAG_GEN_II) | 666 | if (ap->flags & PDC_FLAG_GEN_II) |
668 | err_mask &= ~PDC1_ERR_MASK; | 667 | err_mask &= ~PDC1_ERR_MASK; |
669 | else | 668 | else |
670 | err_mask &= ~PDC2_ERR_MASK; | 669 | err_mask &= ~PDC2_ERR_MASK; |
@@ -844,34 +843,34 @@ static int pdc_old_sata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
844 | return 1; | 843 | return 1; |
845 | } | 844 | } |
846 | 845 | ||
847 | static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base, | 846 | static void pdc_ata_setup_port(struct ata_port *ap, |
848 | void __iomem *scr_addr) | 847 | void __iomem *base, void __iomem *scr_addr) |
849 | { | 848 | { |
850 | port->cmd_addr = base; | 849 | ap->ioaddr.cmd_addr = base; |
851 | port->data_addr = base; | 850 | ap->ioaddr.data_addr = base; |
852 | port->feature_addr = | 851 | ap->ioaddr.feature_addr = |
853 | port->error_addr = base + 0x4; | 852 | ap->ioaddr.error_addr = base + 0x4; |
854 | port->nsect_addr = base + 0x8; | 853 | ap->ioaddr.nsect_addr = base + 0x8; |
855 | port->lbal_addr = base + 0xc; | 854 | ap->ioaddr.lbal_addr = base + 0xc; |
856 | port->lbam_addr = base + 0x10; | 855 | ap->ioaddr.lbam_addr = base + 0x10; |
857 | port->lbah_addr = base + 0x14; | 856 | ap->ioaddr.lbah_addr = base + 0x14; |
858 | port->device_addr = base + 0x18; | 857 | ap->ioaddr.device_addr = base + 0x18; |
859 | port->command_addr = | 858 | ap->ioaddr.command_addr = |
860 | port->status_addr = base + 0x1c; | 859 | ap->ioaddr.status_addr = base + 0x1c; |
861 | port->altstatus_addr = | 860 | ap->ioaddr.altstatus_addr = |
862 | port->ctl_addr = base + 0x38; | 861 | ap->ioaddr.ctl_addr = base + 0x38; |
863 | port->scr_addr = scr_addr; | 862 | ap->ioaddr.scr_addr = scr_addr; |
864 | } | 863 | } |
865 | 864 | ||
866 | 865 | ||
867 | static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | 866 | static void pdc_host_init(struct ata_host *host) |
868 | { | 867 | { |
869 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; | 868 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
870 | struct pdc_host_priv *hp = pe->private_data; | 869 | int is_gen2 = host->ports[0]->flags & PDC_FLAG_GEN_II; |
871 | int hotplug_offset; | 870 | int hotplug_offset; |
872 | u32 tmp; | 871 | u32 tmp; |
873 | 872 | ||
874 | if (hp->flags & PDC_FLAG_GEN_II) | 873 | if (is_gen2) |
875 | hotplug_offset = PDC2_SATA_PLUG_CSR; | 874 | hotplug_offset = PDC2_SATA_PLUG_CSR; |
876 | else | 875 | else |
877 | hotplug_offset = PDC_SATA_PLUG_CSR; | 876 | hotplug_offset = PDC_SATA_PLUG_CSR; |
@@ -885,7 +884,7 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | |||
885 | /* enable BMR_BURST, maybe change FIFO_SHD to 8 dwords */ | 884 | /* enable BMR_BURST, maybe change FIFO_SHD to 8 dwords */ |
886 | tmp = readl(mmio + PDC_FLASH_CTL); | 885 | tmp = readl(mmio + PDC_FLASH_CTL); |
887 | tmp |= 0x02000; /* bit 13 (enable bmr burst) */ | 886 | tmp |= 0x02000; /* bit 13 (enable bmr burst) */ |
888 | if (!(hp->flags & PDC_FLAG_GEN_II)) | 887 | if (!is_gen2) |
889 | tmp |= 0x10000; /* bit 16 (fifo threshold at 8 dw) */ | 888 | tmp |= 0x10000; /* bit 16 (fifo threshold at 8 dw) */ |
890 | writel(tmp, mmio + PDC_FLASH_CTL); | 889 | writel(tmp, mmio + PDC_FLASH_CTL); |
891 | 890 | ||
@@ -898,7 +897,7 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | |||
898 | writel(tmp | 0xff0000, mmio + hotplug_offset); | 897 | writel(tmp | 0xff0000, mmio + hotplug_offset); |
899 | 898 | ||
900 | /* don't initialise TBG or SLEW on 2nd generation chips */ | 899 | /* don't initialise TBG or SLEW on 2nd generation chips */ |
901 | if (hp->flags & PDC_FLAG_GEN_II) | 900 | if (is_gen2) |
902 | return; | 901 | return; |
903 | 902 | ||
904 | /* reduce TBG clock to 133 Mhz. */ | 903 | /* reduce TBG clock to 133 Mhz. */ |
@@ -920,16 +919,16 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | |||
920 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 919 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
921 | { | 920 | { |
922 | static int printed_version; | 921 | static int printed_version; |
923 | struct ata_probe_ent *probe_ent; | 922 | const struct ata_port_info *pi = &pdc_port_info[ent->driver_data]; |
924 | struct pdc_host_priv *hp; | 923 | const struct ata_port_info *ppi[PDC_MAX_PORTS]; |
924 | struct ata_host *host; | ||
925 | void __iomem *base; | 925 | void __iomem *base; |
926 | unsigned int board_idx = (unsigned int) ent->driver_data; | 926 | int n_ports, i, rc; |
927 | int rc; | ||
928 | u8 tmp; | ||
929 | 927 | ||
930 | if (!printed_version++) | 928 | if (!printed_version++) |
931 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 929 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
932 | 930 | ||
931 | /* enable and acquire resources */ | ||
933 | rc = pcim_enable_device(pdev); | 932 | rc = pcim_enable_device(pdev); |
934 | if (rc) | 933 | if (rc) |
935 | return rc; | 934 | return rc; |
@@ -939,89 +938,49 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
939 | pcim_pin_device(pdev); | 938 | pcim_pin_device(pdev); |
940 | if (rc) | 939 | if (rc) |
941 | return rc; | 940 | return rc; |
941 | base = pcim_iomap_table(pdev)[PDC_MMIO_BAR]; | ||
942 | 942 | ||
943 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 943 | /* determine port configuration and setup host */ |
944 | if (rc) | 944 | n_ports = 2; |
945 | return rc; | 945 | if (pi->flags & PDC_FLAG_4_PORTS) |
946 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 946 | n_ports = 4; |
947 | if (rc) | 947 | for (i = 0; i < n_ports; i++) |
948 | return rc; | 948 | ppi[i] = pi; |
949 | |||
950 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); | ||
951 | if (probe_ent == NULL) | ||
952 | return -ENOMEM; | ||
953 | 949 | ||
954 | probe_ent->dev = pci_dev_to_dev(pdev); | 950 | if (pi->flags & PDC_FLAG_SATA_PATA) { |
955 | INIT_LIST_HEAD(&probe_ent->node); | 951 | u8 tmp = readb(base + PDC_FLASH_CTL+1); |
952 | if (!(tmp & 0x80)) { | ||
953 | ppi[n_ports++] = pi + 1; | ||
954 | dev_printk(KERN_INFO, &pdev->dev, "PATA port found\n"); | ||
955 | } | ||
956 | } | ||
956 | 957 | ||
957 | hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL); | 958 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); |
958 | if (hp == NULL) | 959 | if (!host) { |
960 | dev_printk(KERN_ERR, &pdev->dev, "failed to allocate host\n"); | ||
959 | return -ENOMEM; | 961 | return -ENOMEM; |
960 | |||
961 | probe_ent->private_data = hp; | ||
962 | |||
963 | probe_ent->sht = pdc_port_info[board_idx].sht; | ||
964 | probe_ent->port_flags = pdc_port_info[board_idx].flags; | ||
965 | probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; | ||
966 | probe_ent->mwdma_mask = pdc_port_info[board_idx].mwdma_mask; | ||
967 | probe_ent->udma_mask = pdc_port_info[board_idx].udma_mask; | ||
968 | probe_ent->port_ops = pdc_port_info[board_idx].port_ops; | ||
969 | |||
970 | probe_ent->irq = pdev->irq; | ||
971 | probe_ent->irq_flags = IRQF_SHARED; | ||
972 | probe_ent->iomap = pcim_iomap_table(pdev); | ||
973 | |||
974 | base = probe_ent->iomap[PDC_MMIO_BAR]; | ||
975 | |||
976 | pdc_ata_setup_port(&probe_ent->port[0], base + 0x200, base + 0x400); | ||
977 | pdc_ata_setup_port(&probe_ent->port[1], base + 0x280, base + 0x500); | ||
978 | |||
979 | /* notice 4-port boards */ | ||
980 | switch (board_idx) { | ||
981 | case board_40518: | ||
982 | hp->flags |= PDC_FLAG_GEN_II; | ||
983 | /* Fall through */ | ||
984 | case board_20319: | ||
985 | probe_ent->n_ports = 4; | ||
986 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300, base + 0x600); | ||
987 | pdc_ata_setup_port(&probe_ent->port[3], base + 0x380, base + 0x700); | ||
988 | break; | ||
989 | case board_2057x: | ||
990 | hp->flags |= PDC_FLAG_GEN_II; | ||
991 | /* Fall through */ | ||
992 | case board_2037x: | ||
993 | /* TX2plus boards also have a PATA port */ | ||
994 | tmp = readb(base + PDC_FLASH_CTL+1); | ||
995 | if (!(tmp & 0x80)) { | ||
996 | probe_ent->n_ports = 3; | ||
997 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300, NULL); | ||
998 | hp->port_flags[2] = ATA_FLAG_SLAVE_POSS; | ||
999 | printk(KERN_INFO DRV_NAME " PATA port found\n"); | ||
1000 | } else | ||
1001 | probe_ent->n_ports = 2; | ||
1002 | hp->port_flags[0] = ATA_FLAG_SATA; | ||
1003 | hp->port_flags[1] = ATA_FLAG_SATA; | ||
1004 | break; | ||
1005 | case board_20619: | ||
1006 | probe_ent->n_ports = 4; | ||
1007 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300, NULL); | ||
1008 | pdc_ata_setup_port(&probe_ent->port[3], base + 0x380, NULL); | ||
1009 | break; | ||
1010 | default: | ||
1011 | BUG(); | ||
1012 | break; | ||
1013 | } | 962 | } |
963 | host->iomap = pcim_iomap_table(pdev); | ||
1014 | 964 | ||
1015 | pci_set_master(pdev); | 965 | for (i = 0; i < host->n_ports; i++) |
966 | pdc_ata_setup_port(host->ports[i], | ||
967 | base + 0x200 + i * 0x80, | ||
968 | base + 0x400 + i * 0x100); | ||
1016 | 969 | ||
1017 | /* initialize adapter */ | 970 | /* initialize adapter */ |
1018 | pdc_host_init(board_idx, probe_ent); | 971 | pdc_host_init(host); |
1019 | 972 | ||
1020 | if (!ata_device_add(probe_ent)) | 973 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
1021 | return -ENODEV; | 974 | if (rc) |
975 | return rc; | ||
976 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | ||
977 | if (rc) | ||
978 | return rc; | ||
1022 | 979 | ||
1023 | devm_kfree(&pdev->dev, probe_ent); | 980 | /* start host, request IRQ and attach */ |
1024 | return 0; | 981 | pci_set_master(pdev); |
982 | return ata_host_activate(host, pdev->irq, pdc_interrupt, IRQF_SHARED, | ||
983 | &pdc_ata_sht); | ||
1025 | } | 984 | } |
1026 | 985 | ||
1027 | 986 | ||
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 842ccf601224..1d855f55f5f7 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -64,8 +64,6 @@ enum { | |||
64 | PORT0 = (1 << 1), | 64 | PORT0 = (1 << 1), |
65 | PORT1 = (1 << 0), | 65 | PORT1 = (1 << 0), |
66 | ALL_PORTS = PORT0 | PORT1, | 66 | ALL_PORTS = PORT0 | PORT1, |
67 | PATA_PORT = 2, /* PATA is port 2 */ | ||
68 | N_PORTS = 3, | ||
69 | 67 | ||
70 | NATIVE_MODE_ALL = (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4), | 68 | NATIVE_MODE_ALL = (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4), |
71 | 69 | ||
@@ -81,7 +79,6 @@ static void vt6420_error_handler(struct ata_port *ap); | |||
81 | static int vt6421_pata_cable_detect(struct ata_port *ap); | 79 | static int vt6421_pata_cable_detect(struct ata_port *ap); |
82 | static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev); | 80 | static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev); |
83 | static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev); | 81 | static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev); |
84 | static int vt6421_port_start(struct ata_port *ap); | ||
85 | 82 | ||
86 | static const struct pci_device_id svia_pci_tbl[] = { | 83 | static const struct pci_device_id svia_pci_tbl[] = { |
87 | { PCI_VDEVICE(VIA, 0x5337), vt6420 }, | 84 | { PCI_VDEVICE(VIA, 0x5337), vt6420 }, |
@@ -140,7 +137,6 @@ static const struct ata_port_operations vt6420_sata_ops = { | |||
140 | .error_handler = vt6420_error_handler, | 137 | .error_handler = vt6420_error_handler, |
141 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 138 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
142 | 139 | ||
143 | .irq_handler = ata_interrupt, | ||
144 | .irq_clear = ata_bmdma_irq_clear, | 140 | .irq_clear = ata_bmdma_irq_clear, |
145 | .irq_on = ata_irq_on, | 141 | .irq_on = ata_irq_on, |
146 | .irq_ack = ata_irq_ack, | 142 | .irq_ack = ata_irq_ack, |
@@ -175,12 +171,11 @@ static const struct ata_port_operations vt6421_pata_ops = { | |||
175 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 171 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
176 | .cable_detect = vt6421_pata_cable_detect, | 172 | .cable_detect = vt6421_pata_cable_detect, |
177 | 173 | ||
178 | .irq_handler = ata_interrupt, | ||
179 | .irq_clear = ata_bmdma_irq_clear, | 174 | .irq_clear = ata_bmdma_irq_clear, |
180 | .irq_on = ata_irq_on, | 175 | .irq_on = ata_irq_on, |
181 | .irq_ack = ata_irq_ack, | 176 | .irq_ack = ata_irq_ack, |
182 | 177 | ||
183 | .port_start = vt6421_port_start, | 178 | .port_start = ata_port_start, |
184 | }; | 179 | }; |
185 | 180 | ||
186 | static const struct ata_port_operations vt6421_sata_ops = { | 181 | static const struct ata_port_operations vt6421_sata_ops = { |
@@ -207,7 +202,6 @@ static const struct ata_port_operations vt6421_sata_ops = { | |||
207 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 202 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
208 | .cable_detect = ata_cable_sata, | 203 | .cable_detect = ata_cable_sata, |
209 | 204 | ||
210 | .irq_handler = ata_interrupt, | ||
211 | .irq_clear = ata_bmdma_irq_clear, | 205 | .irq_clear = ata_bmdma_irq_clear, |
212 | .irq_on = ata_irq_on, | 206 | .irq_on = ata_irq_on, |
213 | .irq_ack = ata_irq_ack, | 207 | .irq_ack = ata_irq_ack, |
@@ -215,11 +209,10 @@ static const struct ata_port_operations vt6421_sata_ops = { | |||
215 | .scr_read = svia_scr_read, | 209 | .scr_read = svia_scr_read, |
216 | .scr_write = svia_scr_write, | 210 | .scr_write = svia_scr_write, |
217 | 211 | ||
218 | .port_start = vt6421_port_start, | 212 | .port_start = ata_port_start, |
219 | }; | 213 | }; |
220 | 214 | ||
221 | static struct ata_port_info vt6420_port_info = { | 215 | static const struct ata_port_info vt6420_port_info = { |
222 | .sht = &svia_sht, | ||
223 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, | 216 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, |
224 | .pio_mask = 0x1f, | 217 | .pio_mask = 0x1f, |
225 | .mwdma_mask = 0x07, | 218 | .mwdma_mask = 0x07, |
@@ -227,6 +220,22 @@ static struct ata_port_info vt6420_port_info = { | |||
227 | .port_ops = &vt6420_sata_ops, | 220 | .port_ops = &vt6420_sata_ops, |
228 | }; | 221 | }; |
229 | 222 | ||
223 | static struct ata_port_info vt6421_sport_info = { | ||
224 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, | ||
225 | .pio_mask = 0x1f, | ||
226 | .mwdma_mask = 0x07, | ||
227 | .udma_mask = 0x7f, | ||
228 | .port_ops = &vt6421_sata_ops, | ||
229 | }; | ||
230 | |||
231 | static struct ata_port_info vt6421_pport_info = { | ||
232 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_LEGACY, | ||
233 | .pio_mask = 0x1f, | ||
234 | .mwdma_mask = 0, | ||
235 | .udma_mask = 0x7f, | ||
236 | .port_ops = &vt6421_pata_ops, | ||
237 | }; | ||
238 | |||
230 | MODULE_AUTHOR("Jeff Garzik"); | 239 | MODULE_AUTHOR("Jeff Garzik"); |
231 | MODULE_DESCRIPTION("SCSI low-level driver for VIA SATA controllers"); | 240 | MODULE_DESCRIPTION("SCSI low-level driver for VIA SATA controllers"); |
232 | MODULE_LICENSE("GPL"); | 241 | MODULE_LICENSE("GPL"); |
@@ -356,16 +365,6 @@ static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev) | |||
356 | pci_write_config_byte(pdev, PATA_UDMA_TIMING, udma_bits[adev->pio_mode - XFER_UDMA_0]); | 365 | pci_write_config_byte(pdev, PATA_UDMA_TIMING, udma_bits[adev->pio_mode - XFER_UDMA_0]); |
357 | } | 366 | } |
358 | 367 | ||
359 | static int vt6421_port_start(struct ata_port *ap) | ||
360 | { | ||
361 | if (ap->port_no == PATA_PORT) { | ||
362 | ap->ops = &vt6421_pata_ops; | ||
363 | ap->mwdma_mask = 0; | ||
364 | ap->flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST; | ||
365 | } | ||
366 | return ata_port_start(ap); | ||
367 | } | ||
368 | |||
369 | static const unsigned int svia_bar_sizes[] = { | 368 | static const unsigned int svia_bar_sizes[] = { |
370 | 8, 4, 8, 4, 16, 256 | 369 | 8, 4, 8, 4, 16, 256 |
371 | }; | 370 | }; |
@@ -384,79 +383,78 @@ static void __iomem * vt6421_scr_addr(void __iomem *addr, unsigned int port) | |||
384 | return addr + (port * 64); | 383 | return addr + (port * 64); |
385 | } | 384 | } |
386 | 385 | ||
387 | static void vt6421_init_addrs(struct ata_probe_ent *probe_ent, | 386 | static void vt6421_init_addrs(struct ata_port *ap) |
388 | void __iomem * const *iomap, unsigned int port) | ||
389 | { | 387 | { |
390 | void __iomem *reg_addr = iomap[port]; | 388 | void __iomem * const * iomap = ap->host->iomap; |
391 | void __iomem *bmdma_addr = iomap[4] + (port * 8); | 389 | void __iomem *reg_addr = iomap[ap->port_no]; |
392 | 390 | void __iomem *bmdma_addr = iomap[4] + (ap->port_no * 8); | |
393 | probe_ent->port[port].cmd_addr = reg_addr; | 391 | struct ata_ioports *ioaddr = &ap->ioaddr; |
394 | probe_ent->port[port].altstatus_addr = | 392 | |
395 | probe_ent->port[port].ctl_addr = (void __iomem *) | 393 | ioaddr->cmd_addr = reg_addr; |
394 | ioaddr->altstatus_addr = | ||
395 | ioaddr->ctl_addr = (void __iomem *) | ||
396 | ((unsigned long)(reg_addr + 8) | ATA_PCI_CTL_OFS); | 396 | ((unsigned long)(reg_addr + 8) | ATA_PCI_CTL_OFS); |
397 | probe_ent->port[port].bmdma_addr = bmdma_addr; | 397 | ioaddr->bmdma_addr = bmdma_addr; |
398 | probe_ent->port[port].scr_addr = vt6421_scr_addr(iomap[5], port); | 398 | ioaddr->scr_addr = vt6421_scr_addr(iomap[5], ap->port_no); |
399 | 399 | ||
400 | ata_std_ports(&probe_ent->port[port]); | 400 | ata_std_ports(ioaddr); |
401 | } | 401 | } |
402 | 402 | ||
403 | static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev) | 403 | static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) |
404 | { | 404 | { |
405 | struct ata_probe_ent *probe_ent; | 405 | const struct ata_port_info *ppi[] = { &vt6420_port_info, NULL }; |
406 | struct ata_port_info *ppi[2]; | 406 | struct ata_host *host; |
407 | void __iomem *bar5; | 407 | int rc; |
408 | 408 | ||
409 | ppi[0] = ppi[1] = &vt6420_port_info; | 409 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); |
410 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 410 | if (rc) |
411 | if (!probe_ent) | 411 | return rc; |
412 | return NULL; | 412 | *r_host = host; |
413 | 413 | ||
414 | bar5 = pcim_iomap(pdev, 5, 0); | 414 | rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME); |
415 | if (!bar5) { | 415 | if (rc) { |
416 | dev_printk(KERN_ERR, &pdev->dev, "failed to iomap PCI BAR 5\n"); | 416 | dev_printk(KERN_ERR, &pdev->dev, "failed to iomap PCI BAR 5\n"); |
417 | return NULL; | 417 | return rc; |
418 | } | 418 | } |
419 | 419 | ||
420 | probe_ent->port[0].scr_addr = svia_scr_addr(bar5, 0); | 420 | host->ports[0]->ioaddr.scr_addr = svia_scr_addr(host->iomap[5], 0); |
421 | probe_ent->port[1].scr_addr = svia_scr_addr(bar5, 1); | 421 | host->ports[1]->ioaddr.scr_addr = svia_scr_addr(host->iomap[5], 1); |
422 | 422 | ||
423 | return probe_ent; | 423 | return 0; |
424 | } | 424 | } |
425 | 425 | ||
426 | static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev) | 426 | static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) |
427 | { | 427 | { |
428 | struct ata_probe_ent *probe_ent; | 428 | const struct ata_port_info *ppi[] = |
429 | unsigned int i; | 429 | { &vt6421_sport_info, &vt6421_sport_info, &vt6421_pport_info }; |
430 | struct ata_host *host; | ||
431 | int i, rc; | ||
432 | |||
433 | *r_host = host = ata_host_alloc_pinfo(&pdev->dev, ppi, ARRAY_SIZE(ppi)); | ||
434 | if (!host) { | ||
435 | dev_printk(KERN_ERR, &pdev->dev, "failed to allocate host\n"); | ||
436 | return -ENOMEM; | ||
437 | } | ||
430 | 438 | ||
431 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); | 439 | rc = pcim_iomap_regions(pdev, 0x1f, DRV_NAME); |
432 | if (!probe_ent) | 440 | if (rc) { |
433 | return NULL; | 441 | dev_printk(KERN_ERR, &pdev->dev, "failed to request/iomap " |
434 | 442 | "PCI BARs (errno=%d)\n", rc); | |
435 | memset(probe_ent, 0, sizeof(*probe_ent)); | 443 | return rc; |
436 | probe_ent->dev = pci_dev_to_dev(pdev); | 444 | } |
437 | INIT_LIST_HEAD(&probe_ent->node); | 445 | host->iomap = pcim_iomap_table(pdev); |
438 | |||
439 | probe_ent->sht = &svia_sht; | ||
440 | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY; | ||
441 | probe_ent->port_ops = &vt6421_sata_ops; | ||
442 | probe_ent->n_ports = N_PORTS; | ||
443 | probe_ent->irq = pdev->irq; | ||
444 | probe_ent->irq_flags = IRQF_SHARED; | ||
445 | probe_ent->pio_mask = 0x1f; | ||
446 | probe_ent->mwdma_mask = 0x07; | ||
447 | probe_ent->udma_mask = 0x7f; | ||
448 | |||
449 | for (i = 0; i < 6; i++) | ||
450 | if (!pcim_iomap(pdev, i, 0)) { | ||
451 | dev_printk(KERN_ERR, &pdev->dev, | ||
452 | "failed to iomap PCI BAR %d\n", i); | ||
453 | return NULL; | ||
454 | } | ||
455 | 446 | ||
456 | for (i = 0; i < N_PORTS; i++) | 447 | for (i = 0; i < host->n_ports; i++) |
457 | vt6421_init_addrs(probe_ent, pcim_iomap_table(pdev), i); | 448 | vt6421_init_addrs(host->ports[i]); |
458 | 449 | ||
459 | return probe_ent; | 450 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
451 | if (rc) | ||
452 | return rc; | ||
453 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | ||
454 | if (rc) | ||
455 | return rc; | ||
456 | |||
457 | return 0; | ||
460 | } | 458 | } |
461 | 459 | ||
462 | static void svia_configure(struct pci_dev *pdev) | 460 | static void svia_configure(struct pci_dev *pdev) |
@@ -503,7 +501,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
503 | static int printed_version; | 501 | static int printed_version; |
504 | unsigned int i; | 502 | unsigned int i; |
505 | int rc; | 503 | int rc; |
506 | struct ata_probe_ent *probe_ent; | 504 | struct ata_host *host; |
507 | int board_id = (int) ent->driver_data; | 505 | int board_id = (int) ent->driver_data; |
508 | const int *bar_sizes; | 506 | const int *bar_sizes; |
509 | u8 tmp8; | 507 | u8 tmp8; |
@@ -515,12 +513,6 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
515 | if (rc) | 513 | if (rc) |
516 | return rc; | 514 | return rc; |
517 | 515 | ||
518 | rc = pci_request_regions(pdev, DRV_NAME); | ||
519 | if (rc) { | ||
520 | pcim_pin_device(pdev); | ||
521 | return rc; | ||
522 | } | ||
523 | |||
524 | if (board_id == vt6420) { | 516 | if (board_id == vt6420) { |
525 | pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); | 517 | pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); |
526 | if (tmp8 & SATA_2DEV) { | 518 | if (tmp8 & SATA_2DEV) { |
@@ -546,32 +538,18 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
546 | return -ENODEV; | 538 | return -ENODEV; |
547 | } | 539 | } |
548 | 540 | ||
549 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | ||
550 | if (rc) | ||
551 | return rc; | ||
552 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | ||
553 | if (rc) | ||
554 | return rc; | ||
555 | |||
556 | if (board_id == vt6420) | 541 | if (board_id == vt6420) |
557 | probe_ent = vt6420_init_probe_ent(pdev); | 542 | rc = vt6420_prepare_host(pdev, &host); |
558 | else | 543 | else |
559 | probe_ent = vt6421_init_probe_ent(pdev); | 544 | rc = vt6421_prepare_host(pdev, &host); |
560 | 545 | if (rc) | |
561 | if (!probe_ent) { | 546 | return rc; |
562 | dev_printk(KERN_ERR, &pdev->dev, "out of memory\n"); | ||
563 | return -ENOMEM; | ||
564 | } | ||
565 | 547 | ||
566 | svia_configure(pdev); | 548 | svia_configure(pdev); |
567 | 549 | ||
568 | pci_set_master(pdev); | 550 | pci_set_master(pdev); |
569 | 551 | return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED, | |
570 | if (!ata_device_add(probe_ent)) | 552 | &svia_sht); |
571 | return -ENODEV; | ||
572 | |||
573 | devm_kfree(&pdev->dev, probe_ent); | ||
574 | return 0; | ||
575 | } | 553 | } |
576 | 554 | ||
577 | static int __init svia_init(void) | 555 | static int __init svia_init(void) |