diff options
Diffstat (limited to 'drivers/ide')
55 files changed, 1479 insertions, 1375 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 15b09b89588a..04d9c4d459d0 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -510,6 +510,7 @@ config BLK_DEV_TRIFLEX | |||
510 | 510 | ||
511 | config BLK_DEV_CY82C693 | 511 | config BLK_DEV_CY82C693 |
512 | tristate "CY82C693 chipset support" | 512 | tristate "CY82C693 chipset support" |
513 | depends on ALPHA | ||
513 | select IDE_TIMINGS | 514 | select IDE_TIMINGS |
514 | select BLK_DEV_IDEDMA_PCI | 515 | select BLK_DEV_IDEDMA_PCI |
515 | help | 516 | help |
@@ -548,6 +549,7 @@ config BLK_DEV_CS5535 | |||
548 | 549 | ||
549 | config BLK_DEV_HPT34X | 550 | config BLK_DEV_HPT34X |
550 | tristate "HPT34X chipset support" | 551 | tristate "HPT34X chipset support" |
552 | depends on BROKEN | ||
551 | select BLK_DEV_IDEDMA_PCI | 553 | select BLK_DEV_IDEDMA_PCI |
552 | help | 554 | help |
553 | This driver adds up to 4 more EIDE devices sharing a single | 555 | This driver adds up to 4 more EIDE devices sharing a single |
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 52f58c885783..f575e8341aec 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -72,7 +72,7 @@ struct icside_state { | |||
72 | void __iomem *ioc_base; | 72 | void __iomem *ioc_base; |
73 | unsigned int sel; | 73 | unsigned int sel; |
74 | unsigned int type; | 74 | unsigned int type; |
75 | ide_hwif_t *hwif[2]; | 75 | struct ide_host *host; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | #define ICS_TYPE_A3IN 0 | 78 | #define ICS_TYPE_A3IN 0 |
@@ -375,12 +375,14 @@ static int icside_dma_test_irq(ide_drive_t *drive) | |||
375 | 375 | ||
376 | static void icside_dma_timeout(ide_drive_t *drive) | 376 | static void icside_dma_timeout(ide_drive_t *drive) |
377 | { | 377 | { |
378 | ide_hwif_t *hwif = drive->hwif; | ||
379 | |||
378 | printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); | 380 | printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); |
379 | 381 | ||
380 | if (icside_dma_test_irq(drive)) | 382 | if (icside_dma_test_irq(drive)) |
381 | return; | 383 | return; |
382 | 384 | ||
383 | ide_dump_status(drive, "DMA timeout", ide_read_status(drive)); | 385 | ide_dump_status(drive, "DMA timeout", hwif->tp_ops->read_status(hwif)); |
384 | 386 | ||
385 | icside_dma_end(drive); | 387 | icside_dma_end(drive); |
386 | } | 388 | } |
@@ -440,10 +442,10 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base, | |||
440 | static int __init | 442 | static int __init |
441 | icside_register_v5(struct icside_state *state, struct expansion_card *ec) | 443 | icside_register_v5(struct icside_state *state, struct expansion_card *ec) |
442 | { | 444 | { |
443 | ide_hwif_t *hwif; | ||
444 | void __iomem *base; | 445 | void __iomem *base; |
445 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 446 | struct ide_host *host; |
446 | hw_regs_t hw; | 447 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
448 | int ret; | ||
447 | 449 | ||
448 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); | 450 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
449 | if (!base) | 451 | if (!base) |
@@ -463,22 +465,23 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
463 | 465 | ||
464 | icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); | 466 | icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); |
465 | 467 | ||
466 | hwif = ide_find_port(); | 468 | host = ide_host_alloc(NULL, hws); |
467 | if (!hwif) | 469 | if (host == NULL) |
468 | return -ENODEV; | 470 | return -ENODEV; |
469 | 471 | ||
470 | ide_init_port_hw(hwif, &hw); | 472 | state->host = host; |
471 | default_hwif_mmiops(hwif); | ||
472 | |||
473 | state->hwif[0] = hwif; | ||
474 | 473 | ||
475 | ecard_set_drvdata(ec, state); | 474 | ecard_set_drvdata(ec, state); |
476 | 475 | ||
477 | idx[0] = hwif->index; | 476 | ret = ide_host_register(host, NULL, hws); |
478 | 477 | if (ret) | |
479 | ide_device_add(idx, NULL); | 478 | goto err_free; |
480 | 479 | ||
481 | return 0; | 480 | return 0; |
481 | err_free: | ||
482 | ide_host_free(host); | ||
483 | ecard_set_drvdata(ec, NULL); | ||
484 | return ret; | ||
482 | } | 485 | } |
483 | 486 | ||
484 | static const struct ide_port_info icside_v6_port_info __initdata = { | 487 | static const struct ide_port_info icside_v6_port_info __initdata = { |
@@ -493,13 +496,12 @@ static const struct ide_port_info icside_v6_port_info __initdata = { | |||
493 | static int __init | 496 | static int __init |
494 | icside_register_v6(struct icside_state *state, struct expansion_card *ec) | 497 | icside_register_v6(struct icside_state *state, struct expansion_card *ec) |
495 | { | 498 | { |
496 | ide_hwif_t *hwif, *mate; | ||
497 | void __iomem *ioc_base, *easi_base; | 499 | void __iomem *ioc_base, *easi_base; |
500 | struct ide_host *host; | ||
498 | unsigned int sel = 0; | 501 | unsigned int sel = 0; |
499 | int ret; | 502 | int ret; |
500 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 503 | hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL }; |
501 | struct ide_port_info d = icside_v6_port_info; | 504 | struct ide_port_info d = icside_v6_port_info; |
502 | hw_regs_t hw[2]; | ||
503 | 505 | ||
504 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 506 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
505 | if (!ioc_base) { | 507 | if (!ioc_base) { |
@@ -538,28 +540,11 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
538 | icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); | 540 | icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); |
539 | icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); | 541 | icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); |
540 | 542 | ||
541 | /* | 543 | host = ide_host_alloc(&d, hws); |
542 | * Find and register the interfaces. | 544 | if (host == NULL) |
543 | */ | ||
544 | hwif = ide_find_port(); | ||
545 | if (hwif == NULL) | ||
546 | return -ENODEV; | 545 | return -ENODEV; |
547 | 546 | ||
548 | ide_init_port_hw(hwif, &hw[0]); | 547 | state->host = host; |
549 | default_hwif_mmiops(hwif); | ||
550 | |||
551 | idx[0] = hwif->index; | ||
552 | |||
553 | mate = ide_find_port(); | ||
554 | if (mate) { | ||
555 | ide_init_port_hw(mate, &hw[1]); | ||
556 | default_hwif_mmiops(mate); | ||
557 | |||
558 | idx[1] = mate->index; | ||
559 | } | ||
560 | |||
561 | state->hwif[0] = hwif; | ||
562 | state->hwif[1] = mate; | ||
563 | 548 | ||
564 | ecard_set_drvdata(ec, state); | 549 | ecard_set_drvdata(ec, state); |
565 | 550 | ||
@@ -569,11 +554,17 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
569 | d.dma_ops = NULL; | 554 | d.dma_ops = NULL; |
570 | } | 555 | } |
571 | 556 | ||
572 | ide_device_add(idx, &d); | 557 | ret = ide_host_register(host, NULL, hws); |
558 | if (ret) | ||
559 | goto err_free; | ||
573 | 560 | ||
574 | return 0; | 561 | return 0; |
575 | 562 | err_free: | |
576 | out: | 563 | ide_host_free(host); |
564 | if (d.dma_ops) | ||
565 | free_dma(ec->dma); | ||
566 | ecard_set_drvdata(ec, NULL); | ||
567 | out: | ||
577 | return ret; | 568 | return ret; |
578 | } | 569 | } |
579 | 570 | ||
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index 2f311da4c963..176532ffae0e 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c | |||
@@ -28,10 +28,8 @@ | |||
28 | 28 | ||
29 | static int __init ide_arm_init(void) | 29 | static int __init ide_arm_init(void) |
30 | { | 30 | { |
31 | ide_hwif_t *hwif; | ||
32 | hw_regs_t hw; | ||
33 | unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; | 31 | unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; |
34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 32 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
35 | 33 | ||
36 | if (!request_region(base, 8, DRV_NAME)) { | 34 | if (!request_region(base, 8, DRV_NAME)) { |
37 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | 35 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", |
@@ -51,15 +49,7 @@ static int __init ide_arm_init(void) | |||
51 | hw.irq = IDE_ARM_IRQ; | 49 | hw.irq = IDE_ARM_IRQ; |
52 | hw.chipset = ide_generic; | 50 | hw.chipset = ide_generic; |
53 | 51 | ||
54 | hwif = ide_find_port(); | 52 | return ide_host_add(NULL, hws, NULL); |
55 | if (hwif) { | ||
56 | ide_init_port_hw(hwif, &hw); | ||
57 | idx[0] = hwif->index; | ||
58 | |||
59 | ide_device_add(idx, NULL); | ||
60 | } | ||
61 | |||
62 | return 0; | ||
63 | } | 53 | } |
64 | 54 | ||
65 | module_init(ide_arm_init); | 55 | module_init(ide_arm_init); |
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index c79b85b6e4a3..65bb4b8fd570 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -316,15 +316,14 @@ static u8 __devinit palm_bk3710_cable_detect(ide_hwif_t *hwif) | |||
316 | static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif, | 316 | static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif, |
317 | const struct ide_port_info *d) | 317 | const struct ide_port_info *d) |
318 | { | 318 | { |
319 | unsigned long base = | ||
320 | hwif->io_ports.data_addr - IDE_PALM_ATA_PRI_REG_OFFSET; | ||
321 | |||
322 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); | 319 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
323 | 320 | ||
324 | if (ide_allocate_dma_engine(hwif)) | 321 | if (ide_allocate_dma_engine(hwif)) |
325 | return -1; | 322 | return -1; |
326 | 323 | ||
327 | ide_setup_dma(hwif, base); | 324 | hwif->dma_base = hwif->io_ports.data_addr - IDE_PALM_ATA_PRI_REG_OFFSET; |
325 | |||
326 | hwif->dma_ops = &sff_dma_ops; | ||
328 | 327 | ||
329 | return 0; | 328 | return 0; |
330 | } | 329 | } |
@@ -348,11 +347,10 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
348 | { | 347 | { |
349 | struct clk *clk; | 348 | struct clk *clk; |
350 | struct resource *mem, *irq; | 349 | struct resource *mem, *irq; |
351 | ide_hwif_t *hwif; | 350 | struct ide_host *host; |
352 | unsigned long base, rate; | 351 | unsigned long base, rate; |
353 | int i; | 352 | int i, rc; |
354 | hw_regs_t hw; | 353 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
355 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
356 | 354 | ||
357 | clk = clk_get(NULL, "IDECLK"); | 355 | clk = clk_get(NULL, "IDECLK"); |
358 | if (IS_ERR(clk)) | 356 | if (IS_ERR(clk)) |
@@ -394,24 +392,14 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
394 | hw.irq = irq->start; | 392 | hw.irq = irq->start; |
395 | hw.chipset = ide_palm3710; | 393 | hw.chipset = ide_palm3710; |
396 | 394 | ||
397 | hwif = ide_find_port(); | 395 | rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); |
398 | if (hwif == NULL) | 396 | if (rc) |
399 | goto out; | 397 | goto out; |
400 | 398 | ||
401 | i = hwif->index; | ||
402 | |||
403 | ide_init_port_hw(hwif, &hw); | ||
404 | |||
405 | default_hwif_mmiops(hwif); | ||
406 | |||
407 | idx[0] = i; | ||
408 | |||
409 | ide_device_add(idx, &palm_bk3710_port_info); | ||
410 | |||
411 | return 0; | 399 | return 0; |
412 | out: | 400 | out: |
413 | printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n"); | 401 | printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n"); |
414 | return -ENODEV; | 402 | return rc; |
415 | } | 403 | } |
416 | 404 | ||
417 | /* work with hotplug and coldplug */ | 405 | /* work with hotplug and coldplug */ |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 43057e0303c8..2bdd8b734afb 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -32,11 +32,10 @@ static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, | |||
32 | static int __devinit | 32 | static int __devinit |
33 | rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | 33 | rapide_probe(struct expansion_card *ec, const struct ecard_id *id) |
34 | { | 34 | { |
35 | ide_hwif_t *hwif; | ||
36 | void __iomem *base; | 35 | void __iomem *base; |
36 | struct ide_host *host; | ||
37 | int ret; | 37 | int ret; |
38 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 38 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
39 | hw_regs_t hw; | ||
40 | 39 | ||
41 | ret = ecard_request_resources(ec); | 40 | ret = ecard_request_resources(ec); |
42 | if (ret) | 41 | if (ret) |
@@ -53,20 +52,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
53 | hw.chipset = ide_generic; | 52 | hw.chipset = ide_generic; |
54 | hw.dev = &ec->dev; | 53 | hw.dev = &ec->dev; |
55 | 54 | ||
56 | hwif = ide_find_port(); | 55 | ret = ide_host_add(&rapide_port_info, hws, &host); |
57 | if (hwif == NULL) { | 56 | if (ret) |
58 | ret = -ENOENT; | ||
59 | goto release; | 57 | goto release; |
60 | } | ||
61 | |||
62 | ide_init_port_hw(hwif, &hw); | ||
63 | default_hwif_mmiops(hwif); | ||
64 | |||
65 | idx[0] = hwif->index; | ||
66 | |||
67 | ide_device_add(idx, &rapide_port_info); | ||
68 | 58 | ||
69 | ecard_set_drvdata(ec, hwif); | 59 | ecard_set_drvdata(ec, host); |
70 | goto out; | 60 | goto out; |
71 | 61 | ||
72 | release: | 62 | release: |
@@ -77,11 +67,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
77 | 67 | ||
78 | static void __devexit rapide_remove(struct expansion_card *ec) | 68 | static void __devexit rapide_remove(struct expansion_card *ec) |
79 | { | 69 | { |
80 | ide_hwif_t *hwif = ecard_get_drvdata(ec); | 70 | struct ide_host *host = ecard_get_drvdata(ec); |
81 | 71 | ||
82 | ecard_set_drvdata(ec, NULL); | 72 | ecard_set_drvdata(ec, NULL); |
83 | 73 | ||
84 | ide_unregister(hwif); | 74 | ide_host_remove(host); |
85 | 75 | ||
86 | ecard_release_resources(ec); | 76 | ecard_release_resources(ec); |
87 | } | 77 | } |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index 20fad6d542cc..bde7a585f198 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
@@ -100,6 +100,8 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
100 | /* be sure we're looking at the low order bits */ | 100 | /* be sure we're looking at the low order bits */ |
101 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | 101 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
102 | 102 | ||
103 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
104 | tf->feature = inb(io_ports->feature_addr); | ||
103 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 105 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
104 | tf->nsect = inb(io_ports->nsect_addr); | 106 | tf->nsect = inb(io_ports->nsect_addr); |
105 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | 107 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) |
@@ -153,6 +155,21 @@ static void h8300_output_data(ide_drive_t *drive, struct request *rq, | |||
153 | mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); | 155 | mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); |
154 | } | 156 | } |
155 | 157 | ||
158 | static const struct ide_tp_ops h8300_tp_ops = { | ||
159 | .exec_command = ide_exec_command, | ||
160 | .read_status = ide_read_status, | ||
161 | .read_altstatus = ide_read_altstatus, | ||
162 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
163 | |||
164 | .set_irq = ide_set_irq, | ||
165 | |||
166 | .tf_load = h8300_tf_load, | ||
167 | .tf_read = h8300_tf_read, | ||
168 | |||
169 | .input_data = h8300_input_data, | ||
170 | .output_data = h8300_output_data, | ||
171 | }; | ||
172 | |||
156 | #define H8300_IDE_GAP (2) | 173 | #define H8300_IDE_GAP (2) |
157 | 174 | ||
158 | static inline void hw_setup(hw_regs_t *hw) | 175 | static inline void hw_setup(hw_regs_t *hw) |
@@ -167,27 +184,14 @@ static inline void hw_setup(hw_regs_t *hw) | |||
167 | hw->chipset = ide_generic; | 184 | hw->chipset = ide_generic; |
168 | } | 185 | } |
169 | 186 | ||
170 | static inline void hwif_setup(ide_hwif_t *hwif) | ||
171 | { | ||
172 | default_hwif_iops(hwif); | ||
173 | |||
174 | hwif->tf_load = h8300_tf_load; | ||
175 | hwif->tf_read = h8300_tf_read; | ||
176 | |||
177 | hwif->input_data = h8300_input_data; | ||
178 | hwif->output_data = h8300_output_data; | ||
179 | } | ||
180 | |||
181 | static const struct ide_port_info h8300_port_info = { | 187 | static const struct ide_port_info h8300_port_info = { |
188 | .tp_ops = &h8300_tp_ops, | ||
182 | .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, | 189 | .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, |
183 | }; | 190 | }; |
184 | 191 | ||
185 | static int __init h8300_ide_init(void) | 192 | static int __init h8300_ide_init(void) |
186 | { | 193 | { |
187 | hw_regs_t hw; | 194 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
188 | ide_hwif_t *hwif; | ||
189 | int index; | ||
190 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
191 | 195 | ||
192 | printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); | 196 | printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); |
193 | 197 | ||
@@ -200,19 +204,7 @@ static int __init h8300_ide_init(void) | |||
200 | 204 | ||
201 | hw_setup(&hw); | 205 | hw_setup(&hw); |
202 | 206 | ||
203 | hwif = ide_find_port_slot(&h8300_port_info); | 207 | return ide_host_add(&h8300_port_info, hws, NULL); |
204 | if (hwif == NULL) | ||
205 | return -ENOENT; | ||
206 | |||
207 | index = hwif->index; | ||
208 | ide_init_port_hw(hwif, &hw); | ||
209 | hwif_setup(hwif); | ||
210 | |||
211 | idx[0] = index; | ||
212 | |||
213 | ide_device_add(idx, &h8300_port_info); | ||
214 | |||
215 | return 0; | ||
216 | 208 | ||
217 | out_busy: | 209 | out_busy: |
218 | printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n"); | 210 | printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n"); |
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 2802031de670..adf04f99cdeb 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -22,6 +22,8 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) | 22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) |
23 | { | 23 | { |
24 | ide_hwif_t *hwif = drive->hwif; | 24 | ide_hwif_t *hwif = drive->hwif; |
25 | struct request *rq = hwif->hwgroup->rq; | ||
26 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
25 | xfer_func_t *xferfunc; | 27 | xfer_func_t *xferfunc; |
26 | unsigned int temp; | 28 | unsigned int temp; |
27 | u16 bcount; | 29 | u16 bcount; |
@@ -30,12 +32,12 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
30 | debug_log("Enter %s - interrupt handler\n", __func__); | 32 | debug_log("Enter %s - interrupt handler\n", __func__); |
31 | 33 | ||
32 | if (pc->flags & PC_FLAG_TIMEDOUT) { | 34 | if (pc->flags & PC_FLAG_TIMEDOUT) { |
33 | pc->callback(drive); | 35 | drive->pc_callback(drive); |
34 | return ide_stopped; | 36 | return ide_stopped; |
35 | } | 37 | } |
36 | 38 | ||
37 | /* Clear the interrupt */ | 39 | /* Clear the interrupt */ |
38 | stat = ide_read_status(drive); | 40 | stat = tp_ops->read_status(hwif); |
39 | 41 | ||
40 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 42 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
41 | if (hwif->dma_ops->dma_end(drive) || | 43 | if (hwif->dma_ops->dma_end(drive) || |
@@ -63,8 +65,9 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
63 | local_irq_enable_in_hardirq(); | 65 | local_irq_enable_in_hardirq(); |
64 | 66 | ||
65 | if (drive->media == ide_tape && !scsi && | 67 | if (drive->media == ide_tape && !scsi && |
66 | (stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | 68 | (stat & ERR_STAT) && rq->cmd[0] == REQUEST_SENSE) |
67 | stat &= ~ERR_STAT; | 69 | stat &= ~ERR_STAT; |
70 | |||
68 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | 71 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { |
69 | /* Error detected */ | 72 | /* Error detected */ |
70 | debug_log("%s: I/O error\n", drive->name); | 73 | debug_log("%s: I/O error\n", drive->name); |
@@ -75,16 +78,17 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
75 | goto cmd_finished; | 78 | goto cmd_finished; |
76 | } | 79 | } |
77 | 80 | ||
78 | if (pc->c[0] == REQUEST_SENSE) { | 81 | if (rq->cmd[0] == REQUEST_SENSE) { |
79 | printk(KERN_ERR "%s: I/O error in request sense" | 82 | printk(KERN_ERR "%s: I/O error in request sense" |
80 | " command\n", drive->name); | 83 | " command\n", drive->name); |
81 | return ide_do_reset(drive); | 84 | return ide_do_reset(drive); |
82 | } | 85 | } |
83 | 86 | ||
84 | debug_log("[cmd %x]: check condition\n", pc->c[0]); | 87 | debug_log("[cmd %x]: check condition\n", rq->cmd[0]); |
85 | 88 | ||
86 | /* Retry operation */ | 89 | /* Retry operation */ |
87 | retry_pc(drive); | 90 | retry_pc(drive); |
91 | |||
88 | /* queued, but not started */ | 92 | /* queued, but not started */ |
89 | return ide_stopped; | 93 | return ide_stopped; |
90 | } | 94 | } |
@@ -95,8 +99,10 @@ cmd_finished: | |||
95 | dsc_handle(drive); | 99 | dsc_handle(drive); |
96 | return ide_stopped; | 100 | return ide_stopped; |
97 | } | 101 | } |
102 | |||
98 | /* Command finished - Call the callback function */ | 103 | /* Command finished - Call the callback function */ |
99 | pc->callback(drive); | 104 | drive->pc_callback(drive); |
105 | |||
100 | return ide_stopped; | 106 | return ide_stopped; |
101 | } | 107 | } |
102 | 108 | ||
@@ -107,16 +113,15 @@ cmd_finished: | |||
107 | ide_dma_off(drive); | 113 | ide_dma_off(drive); |
108 | return ide_do_reset(drive); | 114 | return ide_do_reset(drive); |
109 | } | 115 | } |
110 | /* Get the number of bytes to transfer on this interrupt. */ | ||
111 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
112 | hwif->INB(hwif->io_ports.lbam_addr); | ||
113 | 116 | ||
114 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | 117 | /* Get the number of bytes to transfer on this interrupt. */ |
118 | ide_read_bcount_and_ireason(drive, &bcount, &ireason); | ||
115 | 119 | ||
116 | if (ireason & CD) { | 120 | if (ireason & CD) { |
117 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); | 121 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); |
118 | return ide_do_reset(drive); | 122 | return ide_do_reset(drive); |
119 | } | 123 | } |
124 | |||
120 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | 125 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { |
121 | /* Hopefully, we will never get here */ | 126 | /* Hopefully, we will never get here */ |
122 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " | 127 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " |
@@ -125,6 +130,7 @@ cmd_finished: | |||
125 | (ireason & IO) ? "Read" : "Write"); | 130 | (ireason & IO) ? "Read" : "Write"); |
126 | return ide_do_reset(drive); | 131 | return ide_do_reset(drive); |
127 | } | 132 | } |
133 | |||
128 | if (!(pc->flags & PC_FLAG_WRITING)) { | 134 | if (!(pc->flags & PC_FLAG_WRITING)) { |
129 | /* Reading - Check that we have enough space */ | 135 | /* Reading - Check that we have enough space */ |
130 | temp = pc->xferred + bcount; | 136 | temp = pc->xferred + bcount; |
@@ -142,7 +148,7 @@ cmd_finished: | |||
142 | if (pc->sg) | 148 | if (pc->sg) |
143 | io_buffers(drive, pc, temp, 0); | 149 | io_buffers(drive, pc, temp, 0); |
144 | else | 150 | else |
145 | hwif->input_data(drive, NULL, | 151 | tp_ops->input_data(drive, NULL, |
146 | pc->cur_pos, temp); | 152 | pc->cur_pos, temp); |
147 | printk(KERN_ERR "%s: transferred %d of " | 153 | printk(KERN_ERR "%s: transferred %d of " |
148 | "%d bytes\n", | 154 | "%d bytes\n", |
@@ -159,9 +165,9 @@ cmd_finished: | |||
159 | debug_log("The device wants to send us more data than " | 165 | debug_log("The device wants to send us more data than " |
160 | "expected - allowing transfer\n"); | 166 | "expected - allowing transfer\n"); |
161 | } | 167 | } |
162 | xferfunc = hwif->input_data; | 168 | xferfunc = tp_ops->input_data; |
163 | } else | 169 | } else |
164 | xferfunc = hwif->output_data; | 170 | xferfunc = tp_ops->output_data; |
165 | 171 | ||
166 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || | 172 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || |
167 | (drive->media == ide_tape && !scsi && pc->bh) || | 173 | (drive->media == ide_tape && !scsi && pc->bh) || |
@@ -175,7 +181,7 @@ cmd_finished: | |||
175 | pc->cur_pos += bcount; | 181 | pc->cur_pos += bcount; |
176 | 182 | ||
177 | debug_log("[cmd %x] transferred %d bytes on that intr.\n", | 183 | debug_log("[cmd %x] transferred %d bytes on that intr.\n", |
178 | pc->c[0], bcount); | 184 | rq->cmd[0], bcount); |
179 | 185 | ||
180 | /* And set the interrupt handler again */ | 186 | /* And set the interrupt handler again */ |
181 | ide_set_handler(drive, handler, timeout, expiry); | 187 | ide_set_handler(drive, handler, timeout, expiry); |
@@ -183,16 +189,27 @@ cmd_finished: | |||
183 | } | 189 | } |
184 | EXPORT_SYMBOL_GPL(ide_pc_intr); | 190 | EXPORT_SYMBOL_GPL(ide_pc_intr); |
185 | 191 | ||
192 | static u8 ide_read_ireason(ide_drive_t *drive) | ||
193 | { | ||
194 | ide_task_t task; | ||
195 | |||
196 | memset(&task, 0, sizeof(task)); | ||
197 | task.tf_flags = IDE_TFLAG_IN_NSECT; | ||
198 | |||
199 | drive->hwif->tp_ops->tf_read(drive, &task); | ||
200 | |||
201 | return task.tf.nsect & 3; | ||
202 | } | ||
203 | |||
186 | static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | 204 | static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) |
187 | { | 205 | { |
188 | ide_hwif_t *hwif = drive->hwif; | ||
189 | int retries = 100; | 206 | int retries = 100; |
190 | 207 | ||
191 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | 208 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { |
192 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 209 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " |
193 | "a packet command, retrying\n", drive->name); | 210 | "a packet command, retrying\n", drive->name); |
194 | udelay(100); | 211 | udelay(100); |
195 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | 212 | ireason = ide_read_ireason(drive); |
196 | if (retries == 0) { | 213 | if (retries == 0) { |
197 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 214 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " |
198 | "a packet command, ignoring\n", | 215 | "a packet command, ignoring\n", |
@@ -210,6 +227,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
210 | ide_expiry_t *expiry) | 227 | ide_expiry_t *expiry) |
211 | { | 228 | { |
212 | ide_hwif_t *hwif = drive->hwif; | 229 | ide_hwif_t *hwif = drive->hwif; |
230 | struct request *rq = hwif->hwgroup->rq; | ||
213 | ide_startstop_t startstop; | 231 | ide_startstop_t startstop; |
214 | u8 ireason; | 232 | u8 ireason; |
215 | 233 | ||
@@ -219,7 +237,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
219 | return startstop; | 237 | return startstop; |
220 | } | 238 | } |
221 | 239 | ||
222 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | 240 | ireason = ide_read_ireason(drive); |
223 | if (drive->media == ide_tape && !drive->scsi) | 241 | if (drive->media == ide_tape && !drive->scsi) |
224 | ireason = ide_wait_ireason(drive, ireason); | 242 | ireason = ide_wait_ireason(drive, ireason); |
225 | 243 | ||
@@ -239,8 +257,8 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
239 | } | 257 | } |
240 | 258 | ||
241 | /* Send the actual packet */ | 259 | /* Send the actual packet */ |
242 | if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0) | 260 | if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0) |
243 | hwif->output_data(drive, NULL, pc->c, 12); | 261 | hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12); |
244 | 262 | ||
245 | return ide_started; | 263 | return ide_started; |
246 | } | 264 | } |
@@ -284,7 +302,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
284 | bcount, dma); | 302 | bcount, dma); |
285 | 303 | ||
286 | /* Issue the packet command */ | 304 | /* Issue the packet command */ |
287 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | 305 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { |
288 | ide_execute_command(drive, WIN_PACKETCMD, handler, | 306 | ide_execute_command(drive, WIN_PACKETCMD, handler, |
289 | timeout, NULL); | 307 | timeout, NULL); |
290 | return ide_started; | 308 | return ide_started; |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 6e29dd532090..4e73aeee4053 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -85,10 +85,8 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
85 | /* Mark that we've seen a media change and invalidate our internal buffers. */ | 85 | /* Mark that we've seen a media change and invalidate our internal buffers. */ |
86 | static void cdrom_saw_media_change(ide_drive_t *drive) | 86 | static void cdrom_saw_media_change(ide_drive_t *drive) |
87 | { | 87 | { |
88 | struct cdrom_info *cd = drive->driver_data; | 88 | drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; |
89 | 89 | drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID; | |
90 | cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED; | ||
91 | cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; | ||
92 | } | 90 | } |
93 | 91 | ||
94 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | 92 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, |
@@ -280,11 +278,12 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) | |||
280 | */ | 278 | */ |
281 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | 279 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) |
282 | { | 280 | { |
283 | struct request *rq = HWGROUP(drive)->rq; | 281 | ide_hwif_t *hwif = drive->hwif; |
282 | struct request *rq = hwif->hwgroup->rq; | ||
284 | int stat, err, sense_key; | 283 | int stat, err, sense_key; |
285 | 284 | ||
286 | /* check for errors */ | 285 | /* check for errors */ |
287 | stat = ide_read_status(drive); | 286 | stat = hwif->tp_ops->read_status(hwif); |
288 | 287 | ||
289 | if (stat_ret) | 288 | if (stat_ret) |
290 | *stat_ret = stat; | 289 | *stat_ret = stat; |
@@ -528,7 +527,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
528 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, | 527 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, |
529 | xferlen, info->dma); | 528 | xferlen, info->dma); |
530 | 529 | ||
531 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 530 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { |
532 | /* waiting for CDB interrupt, not DMA yet. */ | 531 | /* waiting for CDB interrupt, not DMA yet. */ |
533 | if (info->dma) | 532 | if (info->dma) |
534 | drive->waiting_for_dma = 0; | 533 | drive->waiting_for_dma = 0; |
@@ -560,7 +559,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
560 | struct cdrom_info *info = drive->driver_data; | 559 | struct cdrom_info *info = drive->driver_data; |
561 | ide_startstop_t startstop; | 560 | ide_startstop_t startstop; |
562 | 561 | ||
563 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 562 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { |
564 | /* | 563 | /* |
565 | * Here we should have been called after receiving an interrupt | 564 | * Here we should have been called after receiving an interrupt |
566 | * from the device. DRQ should how be set. | 565 | * from the device. DRQ should how be set. |
@@ -589,7 +588,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
589 | cmd_len = ATAPI_MIN_CDB_BYTES; | 588 | cmd_len = ATAPI_MIN_CDB_BYTES; |
590 | 589 | ||
591 | /* send the command to the device */ | 590 | /* send the command to the device */ |
592 | hwif->output_data(drive, NULL, rq->cmd, cmd_len); | 591 | hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len); |
593 | 592 | ||
594 | /* start the DMA if need be */ | 593 | /* start the DMA if need be */ |
595 | if (info->dma) | 594 | if (info->dma) |
@@ -606,6 +605,8 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
606 | static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | 605 | static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, |
607 | int len, int ireason, int rw) | 606 | int len, int ireason, int rw) |
608 | { | 607 | { |
608 | ide_hwif_t *hwif = drive->hwif; | ||
609 | |||
609 | /* | 610 | /* |
610 | * ireason == 0: the drive wants to receive data from us | 611 | * ireason == 0: the drive wants to receive data from us |
611 | * ireason == 2: the drive is expecting to transfer data to us | 612 | * ireason == 2: the drive is expecting to transfer data to us |
@@ -624,7 +625,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | |||
624 | * Some drives (ASUS) seem to tell us that status info is | 625 | * Some drives (ASUS) seem to tell us that status info is |
625 | * available. Just get it and ignore. | 626 | * available. Just get it and ignore. |
626 | */ | 627 | */ |
627 | (void)ide_read_status(drive); | 628 | (void)hwif->tp_ops->read_status(hwif); |
628 | return 0; | 629 | return 0; |
629 | } else { | 630 | } else { |
630 | /* drive wants a command packet, or invalid ireason... */ | 631 | /* drive wants a command packet, or invalid ireason... */ |
@@ -645,20 +646,18 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | |||
645 | */ | 646 | */ |
646 | static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | 647 | static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) |
647 | { | 648 | { |
648 | struct cdrom_info *cd = drive->driver_data; | ||
649 | |||
650 | if ((len % SECTOR_SIZE) == 0) | 649 | if ((len % SECTOR_SIZE) == 0) |
651 | return 0; | 650 | return 0; |
652 | 651 | ||
653 | printk(KERN_ERR "%s: %s: Bad transfer size %d\n", | 652 | printk(KERN_ERR "%s: %s: Bad transfer size %d\n", |
654 | drive->name, __func__, len); | 653 | drive->name, __func__, len); |
655 | 654 | ||
656 | if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES) | 655 | if (drive->atapi_flags & IDE_AFLAG_LIMIT_NFRAMES) |
657 | printk(KERN_ERR " This drive is not supported by " | 656 | printk(KERN_ERR " This drive is not supported by " |
658 | "this version of the driver\n"); | 657 | "this version of the driver\n"); |
659 | else { | 658 | else { |
660 | printk(KERN_ERR " Trying to limit transfer sizes\n"); | 659 | printk(KERN_ERR " Trying to limit transfer sizes\n"); |
661 | cd->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES; | 660 | drive->atapi_flags |= IDE_AFLAG_LIMIT_NFRAMES; |
662 | } | 661 | } |
663 | 662 | ||
664 | return 1; | 663 | return 1; |
@@ -735,7 +734,7 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive) | |||
735 | if (cdrom_decode_status(drive, 0, &stat)) | 734 | if (cdrom_decode_status(drive, 0, &stat)) |
736 | return ide_stopped; | 735 | return ide_stopped; |
737 | 736 | ||
738 | info->cd_flags |= IDE_CD_FLAG_SEEKING; | 737 | drive->atapi_flags |= IDE_AFLAG_SEEKING; |
739 | 738 | ||
740 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { | 739 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { |
741 | if (--retry == 0) | 740 | if (--retry == 0) |
@@ -892,10 +891,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
892 | struct request *rq = HWGROUP(drive)->rq; | 891 | struct request *rq = HWGROUP(drive)->rq; |
893 | xfer_func_t *xferfunc; | 892 | xfer_func_t *xferfunc; |
894 | ide_expiry_t *expiry = NULL; | 893 | ide_expiry_t *expiry = NULL; |
895 | int dma_error = 0, dma, stat, ireason, len, thislen, uptodate = 0; | 894 | int dma_error = 0, dma, stat, thislen, uptodate = 0; |
896 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0; | 895 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0; |
897 | unsigned int timeout; | 896 | unsigned int timeout; |
898 | u8 lowcyl, highcyl; | 897 | u16 len; |
898 | u8 ireason; | ||
899 | 899 | ||
900 | /* check for errors */ | 900 | /* check for errors */ |
901 | dma = info->dma; | 901 | dma = info->dma; |
@@ -923,12 +923,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
923 | goto end_request; | 923 | goto end_request; |
924 | } | 924 | } |
925 | 925 | ||
926 | /* ok we fall to pio :/ */ | 926 | ide_read_bcount_and_ireason(drive, &len, &ireason); |
927 | ireason = hwif->INB(hwif->io_ports.nsect_addr) & 0x3; | ||
928 | lowcyl = hwif->INB(hwif->io_ports.lbam_addr); | ||
929 | highcyl = hwif->INB(hwif->io_ports.lbah_addr); | ||
930 | |||
931 | len = lowcyl + (256 * highcyl); | ||
932 | 927 | ||
933 | thislen = blk_fs_request(rq) ? len : rq->data_len; | 928 | thislen = blk_fs_request(rq) ? len : rq->data_len; |
934 | if (thislen > len) | 929 | if (thislen > len) |
@@ -991,10 +986,10 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
991 | 986 | ||
992 | if (ireason == 0) { | 987 | if (ireason == 0) { |
993 | write = 1; | 988 | write = 1; |
994 | xferfunc = hwif->output_data; | 989 | xferfunc = hwif->tp_ops->output_data; |
995 | } else { | 990 | } else { |
996 | write = 0; | 991 | write = 0; |
997 | xferfunc = hwif->input_data; | 992 | xferfunc = hwif->tp_ops->input_data; |
998 | } | 993 | } |
999 | 994 | ||
1000 | /* transfer data */ | 995 | /* transfer data */ |
@@ -1198,9 +1193,10 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
1198 | int xferlen; | 1193 | int xferlen; |
1199 | 1194 | ||
1200 | if (blk_fs_request(rq)) { | 1195 | if (blk_fs_request(rq)) { |
1201 | if (info->cd_flags & IDE_CD_FLAG_SEEKING) { | 1196 | if (drive->atapi_flags & IDE_AFLAG_SEEKING) { |
1197 | ide_hwif_t *hwif = drive->hwif; | ||
1202 | unsigned long elapsed = jiffies - info->start_seek; | 1198 | unsigned long elapsed = jiffies - info->start_seek; |
1203 | int stat = ide_read_status(drive); | 1199 | int stat = hwif->tp_ops->read_status(hwif); |
1204 | 1200 | ||
1205 | if ((stat & SEEK_STAT) != SEEK_STAT) { | 1201 | if ((stat & SEEK_STAT) != SEEK_STAT) { |
1206 | if (elapsed < IDECD_SEEK_TIMEOUT) { | 1202 | if (elapsed < IDECD_SEEK_TIMEOUT) { |
@@ -1211,7 +1207,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
1211 | printk(KERN_ERR "%s: DSC timeout\n", | 1207 | printk(KERN_ERR "%s: DSC timeout\n", |
1212 | drive->name); | 1208 | drive->name); |
1213 | } | 1209 | } |
1214 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; | 1210 | drive->atapi_flags &= ~IDE_AFLAG_SEEKING; |
1215 | } | 1211 | } |
1216 | if (rq_data_dir(rq) == READ && | 1212 | if (rq_data_dir(rq) == READ && |
1217 | IDE_LARGE_SEEK(info->last_block, block, | 1213 | IDE_LARGE_SEEK(info->last_block, block, |
@@ -1288,7 +1284,7 @@ int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | |||
1288 | */ | 1284 | */ |
1289 | cmd[7] = cdi->sanyo_slot % 3; | 1285 | cmd[7] = cdi->sanyo_slot % 3; |
1290 | 1286 | ||
1291 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, REQ_QUIET); | 1287 | return ide_cd_queue_pc(drive, cmd, 0, NULL, NULL, sense, 0, REQ_QUIET); |
1292 | } | 1288 | } |
1293 | 1289 | ||
1294 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | 1290 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, |
@@ -1296,8 +1292,8 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
1296 | struct request_sense *sense) | 1292 | struct request_sense *sense) |
1297 | { | 1293 | { |
1298 | struct { | 1294 | struct { |
1299 | __u32 lba; | 1295 | __be32 lba; |
1300 | __u32 blocklen; | 1296 | __be32 blocklen; |
1301 | } capbuf; | 1297 | } capbuf; |
1302 | 1298 | ||
1303 | int stat; | 1299 | int stat; |
@@ -1369,7 +1365,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1369 | */ | 1365 | */ |
1370 | (void) cdrom_check_status(drive, sense); | 1366 | (void) cdrom_check_status(drive, sense); |
1371 | 1367 | ||
1372 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) | 1368 | if (drive->atapi_flags & IDE_AFLAG_TOC_VALID) |
1373 | return 0; | 1369 | return 0; |
1374 | 1370 | ||
1375 | /* try to get the total cdrom capacity and sector size */ | 1371 | /* try to get the total cdrom capacity and sector size */ |
@@ -1391,7 +1387,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1391 | if (stat) | 1387 | if (stat) |
1392 | return stat; | 1388 | return stat; |
1393 | 1389 | ||
1394 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { | 1390 | if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) { |
1395 | toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); | 1391 | toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); |
1396 | toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); | 1392 | toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); |
1397 | } | 1393 | } |
@@ -1432,7 +1428,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1432 | if (stat) | 1428 | if (stat) |
1433 | return stat; | 1429 | return stat; |
1434 | 1430 | ||
1435 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { | 1431 | if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) { |
1436 | toc->hdr.first_track = (u8)BIN2BCD(CDROM_LEADOUT); | 1432 | toc->hdr.first_track = (u8)BIN2BCD(CDROM_LEADOUT); |
1437 | toc->hdr.last_track = (u8)BIN2BCD(CDROM_LEADOUT); | 1433 | toc->hdr.last_track = (u8)BIN2BCD(CDROM_LEADOUT); |
1438 | } else { | 1434 | } else { |
@@ -1446,14 +1442,14 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1446 | 1442 | ||
1447 | toc->hdr.toc_length = be16_to_cpu(toc->hdr.toc_length); | 1443 | toc->hdr.toc_length = be16_to_cpu(toc->hdr.toc_length); |
1448 | 1444 | ||
1449 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { | 1445 | if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) { |
1450 | toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); | 1446 | toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); |
1451 | toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); | 1447 | toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); |
1452 | } | 1448 | } |
1453 | 1449 | ||
1454 | for (i = 0; i <= ntracks; i++) { | 1450 | for (i = 0; i <= ntracks; i++) { |
1455 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { | 1451 | if (drive->atapi_flags & IDE_AFLAG_TOCADDR_AS_BCD) { |
1456 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) | 1452 | if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) |
1457 | toc->ent[i].track = BCD2BIN(toc->ent[i].track); | 1453 | toc->ent[i].track = BCD2BIN(toc->ent[i].track); |
1458 | msf_from_bcd(&toc->ent[i].addr.msf); | 1454 | msf_from_bcd(&toc->ent[i].addr.msf); |
1459 | } | 1455 | } |
@@ -1476,7 +1472,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1476 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ | 1472 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ |
1477 | } | 1473 | } |
1478 | 1474 | ||
1479 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { | 1475 | if (drive->atapi_flags & IDE_AFLAG_TOCADDR_AS_BCD) { |
1480 | /* re-read multisession information using MSF format */ | 1476 | /* re-read multisession information using MSF format */ |
1481 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, | 1477 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, |
1482 | sizeof(ms_tmp), sense); | 1478 | sizeof(ms_tmp), sense); |
@@ -1500,7 +1496,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1500 | } | 1496 | } |
1501 | 1497 | ||
1502 | /* Remember that we've read this stuff. */ | 1498 | /* Remember that we've read this stuff. */ |
1503 | info->cd_flags |= IDE_CD_FLAG_TOC_VALID; | 1499 | drive->atapi_flags |= IDE_AFLAG_TOC_VALID; |
1504 | 1500 | ||
1505 | return 0; | 1501 | return 0; |
1506 | } | 1502 | } |
@@ -1512,7 +1508,7 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) | |||
1512 | struct packet_command cgc; | 1508 | struct packet_command cgc; |
1513 | int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; | 1509 | int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; |
1514 | 1510 | ||
1515 | if ((info->cd_flags & IDE_CD_FLAG_FULL_CAPS_PAGE) == 0) | 1511 | if ((drive->atapi_flags & IDE_AFLAG_FULL_CAPS_PAGE) == 0) |
1516 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; | 1512 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; |
1517 | 1513 | ||
1518 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); | 1514 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); |
@@ -1530,15 +1526,12 @@ void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf) | |||
1530 | struct cdrom_info *cd = drive->driver_data; | 1526 | struct cdrom_info *cd = drive->driver_data; |
1531 | u16 curspeed, maxspeed; | 1527 | u16 curspeed, maxspeed; |
1532 | 1528 | ||
1533 | curspeed = *(u16 *)&buf[8 + 14]; | 1529 | if (drive->atapi_flags & IDE_AFLAG_LE_SPEED_FIELDS) { |
1534 | maxspeed = *(u16 *)&buf[8 + 8]; | 1530 | curspeed = le16_to_cpup((__le16 *)&buf[8 + 14]); |
1535 | 1531 | maxspeed = le16_to_cpup((__le16 *)&buf[8 + 8]); | |
1536 | if (cd->cd_flags & IDE_CD_FLAG_LE_SPEED_FIELDS) { | ||
1537 | curspeed = le16_to_cpu(curspeed); | ||
1538 | maxspeed = le16_to_cpu(maxspeed); | ||
1539 | } else { | 1532 | } else { |
1540 | curspeed = be16_to_cpu(curspeed); | 1533 | curspeed = be16_to_cpup((__be16 *)&buf[8 + 14]); |
1541 | maxspeed = be16_to_cpu(maxspeed); | 1534 | maxspeed = be16_to_cpup((__be16 *)&buf[8 + 8]); |
1542 | } | 1535 | } |
1543 | 1536 | ||
1544 | cd->current_speed = (curspeed + (176/2)) / 176; | 1537 | cd->current_speed = (curspeed + (176/2)) / 176; |
@@ -1579,7 +1572,7 @@ static int ide_cdrom_register(ide_drive_t *drive, int nslots) | |||
1579 | devinfo->handle = drive; | 1572 | devinfo->handle = drive; |
1580 | strcpy(devinfo->name, drive->name); | 1573 | strcpy(devinfo->name, drive->name); |
1581 | 1574 | ||
1582 | if (info->cd_flags & IDE_CD_FLAG_NO_SPEED_SELECT) | 1575 | if (drive->atapi_flags & IDE_AFLAG_NO_SPEED_SELECT) |
1583 | devinfo->mask |= CDC_SELECT_SPEED; | 1576 | devinfo->mask |= CDC_SELECT_SPEED; |
1584 | 1577 | ||
1585 | devinfo->disk = info->disk; | 1578 | devinfo->disk = info->disk; |
@@ -1605,8 +1598,8 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1605 | return nslots; | 1598 | return nslots; |
1606 | } | 1599 | } |
1607 | 1600 | ||
1608 | if (cd->cd_flags & IDE_CD_FLAG_PRE_ATAPI12) { | 1601 | if (drive->atapi_flags & IDE_AFLAG_PRE_ATAPI12) { |
1609 | cd->cd_flags &= ~IDE_CD_FLAG_NO_EJECT; | 1602 | drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT; |
1610 | cdi->mask &= ~CDC_PLAY_AUDIO; | 1603 | cdi->mask &= ~CDC_PLAY_AUDIO; |
1611 | return nslots; | 1604 | return nslots; |
1612 | } | 1605 | } |
@@ -1624,9 +1617,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1624 | return 0; | 1617 | return 0; |
1625 | 1618 | ||
1626 | if ((buf[8 + 6] & 0x01) == 0) | 1619 | if ((buf[8 + 6] & 0x01) == 0) |
1627 | cd->cd_flags |= IDE_CD_FLAG_NO_DOORLOCK; | 1620 | drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; |
1628 | if (buf[8 + 6] & 0x08) | 1621 | if (buf[8 + 6] & 0x08) |
1629 | cd->cd_flags &= ~IDE_CD_FLAG_NO_EJECT; | 1622 | drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT; |
1630 | if (buf[8 + 3] & 0x01) | 1623 | if (buf[8 + 3] & 0x01) |
1631 | cdi->mask &= ~CDC_CD_R; | 1624 | cdi->mask &= ~CDC_CD_R; |
1632 | if (buf[8 + 3] & 0x02) | 1625 | if (buf[8 + 3] & 0x02) |
@@ -1637,7 +1630,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1637 | cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM); | 1630 | cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM); |
1638 | if (buf[8 + 3] & 0x10) | 1631 | if (buf[8 + 3] & 0x10) |
1639 | cdi->mask &= ~CDC_DVD_R; | 1632 | cdi->mask &= ~CDC_DVD_R; |
1640 | if ((buf[8 + 4] & 0x01) || (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK)) | 1633 | if ((buf[8 + 4] & 0x01) || (drive->atapi_flags & IDE_AFLAG_PLAY_AUDIO_OK)) |
1641 | cdi->mask &= ~CDC_PLAY_AUDIO; | 1634 | cdi->mask &= ~CDC_PLAY_AUDIO; |
1642 | 1635 | ||
1643 | mechtype = buf[8 + 6] >> 5; | 1636 | mechtype = buf[8 + 6] >> 5; |
@@ -1679,7 +1672,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1679 | else | 1672 | else |
1680 | printk(KERN_CONT " drive"); | 1673 | printk(KERN_CONT " drive"); |
1681 | 1674 | ||
1682 | printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(*(u16 *)&buf[8 + 12])); | 1675 | printk(KERN_CONT ", %dkB Cache\n", be16_to_cpup((__be16 *)&buf[8 + 12])); |
1683 | 1676 | ||
1684 | return nslots; | 1677 | return nslots; |
1685 | } | 1678 | } |
@@ -1802,43 +1795,43 @@ static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } | |||
1802 | 1795 | ||
1803 | static const struct cd_list_entry ide_cd_quirks_list[] = { | 1796 | static const struct cd_list_entry ide_cd_quirks_list[] = { |
1804 | /* Limit transfer size per interrupt. */ | 1797 | /* Limit transfer size per interrupt. */ |
1805 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, | 1798 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_AFLAG_LIMIT_NFRAMES }, |
1806 | { "SAMSUNG CD-ROM SCR-2432", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, | 1799 | { "SAMSUNG CD-ROM SCR-2432", NULL, IDE_AFLAG_LIMIT_NFRAMES }, |
1807 | /* SCR-3231 doesn't support the SET_CD_SPEED command. */ | 1800 | /* SCR-3231 doesn't support the SET_CD_SPEED command. */ |
1808 | { "SAMSUNG CD-ROM SCR-3231", NULL, IDE_CD_FLAG_NO_SPEED_SELECT }, | 1801 | { "SAMSUNG CD-ROM SCR-3231", NULL, IDE_AFLAG_NO_SPEED_SELECT }, |
1809 | /* Old NEC260 (not R) was released before ATAPI 1.2 spec. */ | 1802 | /* Old NEC260 (not R) was released before ATAPI 1.2 spec. */ |
1810 | { "NEC CD-ROM DRIVE:260", "1.01", IDE_CD_FLAG_TOCADDR_AS_BCD | | 1803 | { "NEC CD-ROM DRIVE:260", "1.01", IDE_AFLAG_TOCADDR_AS_BCD | |
1811 | IDE_CD_FLAG_PRE_ATAPI12, }, | 1804 | IDE_AFLAG_PRE_ATAPI12, }, |
1812 | /* Vertos 300, some versions of this drive like to talk BCD. */ | 1805 | /* Vertos 300, some versions of this drive like to talk BCD. */ |
1813 | { "V003S0DS", NULL, IDE_CD_FLAG_VERTOS_300_SSD, }, | 1806 | { "V003S0DS", NULL, IDE_AFLAG_VERTOS_300_SSD, }, |
1814 | /* Vertos 600 ESD. */ | 1807 | /* Vertos 600 ESD. */ |
1815 | { "V006E0DS", NULL, IDE_CD_FLAG_VERTOS_600_ESD, }, | 1808 | { "V006E0DS", NULL, IDE_AFLAG_VERTOS_600_ESD, }, |
1816 | /* | 1809 | /* |
1817 | * Sanyo 3 CD changer uses a non-standard command for CD changing | 1810 | * Sanyo 3 CD changer uses a non-standard command for CD changing |
1818 | * (by default standard ATAPI support for CD changers is used). | 1811 | * (by default standard ATAPI support for CD changers is used). |
1819 | */ | 1812 | */ |
1820 | { "CD-ROM CDR-C3 G", NULL, IDE_CD_FLAG_SANYO_3CD }, | 1813 | { "CD-ROM CDR-C3 G", NULL, IDE_AFLAG_SANYO_3CD }, |
1821 | { "CD-ROM CDR-C3G", NULL, IDE_CD_FLAG_SANYO_3CD }, | 1814 | { "CD-ROM CDR-C3G", NULL, IDE_AFLAG_SANYO_3CD }, |
1822 | { "CD-ROM CDR_C36", NULL, IDE_CD_FLAG_SANYO_3CD }, | 1815 | { "CD-ROM CDR_C36", NULL, IDE_AFLAG_SANYO_3CD }, |
1823 | /* Stingray 8X CD-ROM. */ | 1816 | /* Stingray 8X CD-ROM. */ |
1824 | { "STINGRAY 8422 IDE 8X CD-ROM 7-27-95", NULL, IDE_CD_FLAG_PRE_ATAPI12}, | 1817 | { "STINGRAY 8422 IDE 8X CD-ROM 7-27-95", NULL, IDE_AFLAG_PRE_ATAPI12 }, |
1825 | /* | 1818 | /* |
1826 | * ACER 50X CD-ROM and WPI 32X CD-ROM require the full spec length | 1819 | * ACER 50X CD-ROM and WPI 32X CD-ROM require the full spec length |
1827 | * mode sense page capabilities size, but older drives break. | 1820 | * mode sense page capabilities size, but older drives break. |
1828 | */ | 1821 | */ |
1829 | { "ATAPI CD ROM DRIVE 50X MAX", NULL, IDE_CD_FLAG_FULL_CAPS_PAGE }, | 1822 | { "ATAPI CD ROM DRIVE 50X MAX", NULL, IDE_AFLAG_FULL_CAPS_PAGE }, |
1830 | { "WPI CDS-32X", NULL, IDE_CD_FLAG_FULL_CAPS_PAGE }, | 1823 | { "WPI CDS-32X", NULL, IDE_AFLAG_FULL_CAPS_PAGE }, |
1831 | /* ACER/AOpen 24X CD-ROM has the speed fields byte-swapped. */ | 1824 | /* ACER/AOpen 24X CD-ROM has the speed fields byte-swapped. */ |
1832 | { "", "241N", IDE_CD_FLAG_LE_SPEED_FIELDS }, | 1825 | { "", "241N", IDE_AFLAG_LE_SPEED_FIELDS }, |
1833 | /* | 1826 | /* |
1834 | * Some drives used by Apple don't advertise audio play | 1827 | * Some drives used by Apple don't advertise audio play |
1835 | * but they do support reading TOC & audio datas. | 1828 | * but they do support reading TOC & audio datas. |
1836 | */ | 1829 | */ |
1837 | { "MATSHITADVD-ROM SR-8187", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | 1830 | { "MATSHITADVD-ROM SR-8187", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, |
1838 | { "MATSHITADVD-ROM SR-8186", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | 1831 | { "MATSHITADVD-ROM SR-8186", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, |
1839 | { "MATSHITADVD-ROM SR-8176", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | 1832 | { "MATSHITADVD-ROM SR-8176", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, |
1840 | { "MATSHITADVD-ROM SR-8174", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | 1833 | { "MATSHITADVD-ROM SR-8174", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, |
1841 | { "Optiarc DVD RW AD-5200A", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | 1834 | { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, |
1842 | { NULL, NULL, 0 } | 1835 | { NULL, NULL, 0 } |
1843 | }; | 1836 | }; |
1844 | 1837 | ||
@@ -1873,20 +1866,20 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
1873 | 1866 | ||
1874 | drive->special.all = 0; | 1867 | drive->special.all = 0; |
1875 | 1868 | ||
1876 | cd->cd_flags = IDE_CD_FLAG_MEDIA_CHANGED | IDE_CD_FLAG_NO_EJECT | | 1869 | drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT | |
1877 | ide_cd_flags(id); | 1870 | ide_cd_flags(id); |
1878 | 1871 | ||
1879 | if ((id->config & 0x0060) == 0x20) | 1872 | if ((id->config & 0x0060) == 0x20) |
1880 | cd->cd_flags |= IDE_CD_FLAG_DRQ_INTERRUPT; | 1873 | drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; |
1881 | 1874 | ||
1882 | if ((cd->cd_flags & IDE_CD_FLAG_VERTOS_300_SSD) && | 1875 | if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) && |
1883 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1876 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
1884 | cd->cd_flags |= (IDE_CD_FLAG_TOCTRACKS_AS_BCD | | 1877 | drive->atapi_flags |= (IDE_AFLAG_TOCTRACKS_AS_BCD | |
1885 | IDE_CD_FLAG_TOCADDR_AS_BCD); | 1878 | IDE_AFLAG_TOCADDR_AS_BCD); |
1886 | else if ((cd->cd_flags & IDE_CD_FLAG_VERTOS_600_ESD) && | 1879 | else if ((drive->atapi_flags & IDE_AFLAG_VERTOS_600_ESD) && |
1887 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1880 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
1888 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; | 1881 | drive->atapi_flags |= IDE_AFLAG_TOCTRACKS_AS_BCD; |
1889 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) | 1882 | else if (drive->atapi_flags & IDE_AFLAG_SANYO_3CD) |
1890 | /* 3 => use CD in slot 0 */ | 1883 | /* 3 => use CD in slot 0 */ |
1891 | cdi->sanyo_slot = 3; | 1884 | cdi->sanyo_slot = 3; |
1892 | 1885 | ||
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index fe0ea36e4124..61a4599b77db 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -27,42 +27,6 @@ | |||
27 | #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) | 27 | #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) |
28 | #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 | 28 | #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 |
29 | 29 | ||
30 | enum { | ||
31 | /* Device sends an interrupt when ready for a packet command. */ | ||
32 | IDE_CD_FLAG_DRQ_INTERRUPT = (1 << 0), | ||
33 | /* Drive cannot lock the door. */ | ||
34 | IDE_CD_FLAG_NO_DOORLOCK = (1 << 1), | ||
35 | /* Drive cannot eject the disc. */ | ||
36 | IDE_CD_FLAG_NO_EJECT = (1 << 2), | ||
37 | /* Drive is a pre ATAPI 1.2 drive. */ | ||
38 | IDE_CD_FLAG_PRE_ATAPI12 = (1 << 3), | ||
39 | /* TOC addresses are in BCD. */ | ||
40 | IDE_CD_FLAG_TOCADDR_AS_BCD = (1 << 4), | ||
41 | /* TOC track numbers are in BCD. */ | ||
42 | IDE_CD_FLAG_TOCTRACKS_AS_BCD = (1 << 5), | ||
43 | /* | ||
44 | * Drive does not provide data in multiples of SECTOR_SIZE | ||
45 | * when more than one interrupt is needed. | ||
46 | */ | ||
47 | IDE_CD_FLAG_LIMIT_NFRAMES = (1 << 6), | ||
48 | /* Seeking in progress. */ | ||
49 | IDE_CD_FLAG_SEEKING = (1 << 7), | ||
50 | /* Driver has noticed a media change. */ | ||
51 | IDE_CD_FLAG_MEDIA_CHANGED = (1 << 8), | ||
52 | /* Saved TOC information is current. */ | ||
53 | IDE_CD_FLAG_TOC_VALID = (1 << 9), | ||
54 | /* We think that the drive door is locked. */ | ||
55 | IDE_CD_FLAG_DOOR_LOCKED = (1 << 10), | ||
56 | /* SET_CD_SPEED command is unsupported. */ | ||
57 | IDE_CD_FLAG_NO_SPEED_SELECT = (1 << 11), | ||
58 | IDE_CD_FLAG_VERTOS_300_SSD = (1 << 12), | ||
59 | IDE_CD_FLAG_VERTOS_600_ESD = (1 << 13), | ||
60 | IDE_CD_FLAG_SANYO_3CD = (1 << 14), | ||
61 | IDE_CD_FLAG_FULL_CAPS_PAGE = (1 << 15), | ||
62 | IDE_CD_FLAG_PLAY_AUDIO_OK = (1 << 16), | ||
63 | IDE_CD_FLAG_LE_SPEED_FIELDS = (1 << 17), | ||
64 | }; | ||
65 | |||
66 | /* Structure of a MSF cdrom address. */ | 30 | /* Structure of a MSF cdrom address. */ |
67 | struct atapi_msf { | 31 | struct atapi_msf { |
68 | byte reserved; | 32 | byte reserved; |
@@ -128,8 +92,6 @@ struct cdrom_info { | |||
128 | unsigned long last_block; | 92 | unsigned long last_block; |
129 | unsigned long start_seek; | 93 | unsigned long start_seek; |
130 | 94 | ||
131 | unsigned int cd_flags; | ||
132 | |||
133 | u8 max_speed; /* Max speed of the drive. */ | 95 | u8 max_speed; /* Max speed of the drive. */ |
134 | u8 current_speed; /* Current speed of the drive. */ | 96 | u8 current_speed; /* Current speed of the drive. */ |
135 | 97 | ||
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c index 24d002addf73..74231b41f611 100644 --- a/drivers/ide/ide-cd_ioctl.c +++ b/drivers/ide/ide-cd_ioctl.c | |||
@@ -27,10 +27,9 @@ int ide_cdrom_open_real(struct cdrom_device_info *cdi, int purpose) | |||
27 | void ide_cdrom_release_real(struct cdrom_device_info *cdi) | 27 | void ide_cdrom_release_real(struct cdrom_device_info *cdi) |
28 | { | 28 | { |
29 | ide_drive_t *drive = cdi->handle; | 29 | ide_drive_t *drive = cdi->handle; |
30 | struct cdrom_info *cd = drive->driver_data; | ||
31 | 30 | ||
32 | if (!cdi->use_count) | 31 | if (!cdi->use_count) |
33 | cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; | 32 | drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID; |
34 | } | 33 | } |
35 | 34 | ||
36 | /* | 35 | /* |
@@ -83,13 +82,12 @@ int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi, | |||
83 | int slot_nr) | 82 | int slot_nr) |
84 | { | 83 | { |
85 | ide_drive_t *drive = cdi->handle; | 84 | ide_drive_t *drive = cdi->handle; |
86 | struct cdrom_info *cd = drive->driver_data; | ||
87 | int retval; | 85 | int retval; |
88 | 86 | ||
89 | if (slot_nr == CDSL_CURRENT) { | 87 | if (slot_nr == CDSL_CURRENT) { |
90 | (void) cdrom_check_status(drive, NULL); | 88 | (void) cdrom_check_status(drive, NULL); |
91 | retval = (cd->cd_flags & IDE_CD_FLAG_MEDIA_CHANGED) ? 1 : 0; | 89 | retval = (drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED) ? 1 : 0; |
92 | cd->cd_flags &= ~IDE_CD_FLAG_MEDIA_CHANGED; | 90 | drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED; |
93 | return retval; | 91 | return retval; |
94 | } else { | 92 | } else { |
95 | return -EINVAL; | 93 | return -EINVAL; |
@@ -107,11 +105,11 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
107 | char loej = 0x02; | 105 | char loej = 0x02; |
108 | unsigned char cmd[BLK_MAX_CDB]; | 106 | unsigned char cmd[BLK_MAX_CDB]; |
109 | 107 | ||
110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) | 108 | if ((drive->atapi_flags & IDE_AFLAG_NO_EJECT) && !ejectflag) |
111 | return -EDRIVE_CANT_DO_THIS; | 109 | return -EDRIVE_CANT_DO_THIS; |
112 | 110 | ||
113 | /* reload fails on some drives, if the tray is locked */ | 111 | /* reload fails on some drives, if the tray is locked */ |
114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) | 112 | if ((drive->atapi_flags & IDE_AFLAG_DOOR_LOCKED) && ejectflag) |
115 | return 0; | 113 | return 0; |
116 | 114 | ||
117 | /* only tell drive to close tray if open, if it can do that */ | 115 | /* only tell drive to close tray if open, if it can do that */ |
@@ -123,7 +121,7 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
123 | cmd[0] = GPCMD_START_STOP_UNIT; | 121 | cmd[0] = GPCMD_START_STOP_UNIT; |
124 | cmd[4] = loej | (ejectflag != 0); | 122 | cmd[4] = loej | (ejectflag != 0); |
125 | 123 | ||
126 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, 0); | 124 | return ide_cd_queue_pc(drive, cmd, 0, NULL, NULL, sense, 0, 0); |
127 | } | 125 | } |
128 | 126 | ||
129 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ | 127 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ |
@@ -131,7 +129,6 @@ static | |||
131 | int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | 129 | int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, |
132 | struct request_sense *sense) | 130 | struct request_sense *sense) |
133 | { | 131 | { |
134 | struct cdrom_info *cd = drive->driver_data; | ||
135 | struct request_sense my_sense; | 132 | struct request_sense my_sense; |
136 | int stat; | 133 | int stat; |
137 | 134 | ||
@@ -139,7 +136,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
139 | sense = &my_sense; | 136 | sense = &my_sense; |
140 | 137 | ||
141 | /* If the drive cannot lock the door, just pretend. */ | 138 | /* If the drive cannot lock the door, just pretend. */ |
142 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { | 139 | if (drive->atapi_flags & IDE_AFLAG_NO_DOORLOCK) { |
143 | stat = 0; | 140 | stat = 0; |
144 | } else { | 141 | } else { |
145 | unsigned char cmd[BLK_MAX_CDB]; | 142 | unsigned char cmd[BLK_MAX_CDB]; |
@@ -149,7 +146,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
149 | cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | 146 | cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; |
150 | cmd[4] = lockflag ? 1 : 0; | 147 | cmd[4] = lockflag ? 1 : 0; |
151 | 148 | ||
152 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, | 149 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, NULL, |
153 | sense, 0, 0); | 150 | sense, 0, 0); |
154 | } | 151 | } |
155 | 152 | ||
@@ -160,7 +157,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
160 | (sense->asc == 0x24 || sense->asc == 0x20)) { | 157 | (sense->asc == 0x24 || sense->asc == 0x20)) { |
161 | printk(KERN_ERR "%s: door locking not supported\n", | 158 | printk(KERN_ERR "%s: door locking not supported\n", |
162 | drive->name); | 159 | drive->name); |
163 | cd->cd_flags |= IDE_CD_FLAG_NO_DOORLOCK; | 160 | drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; |
164 | stat = 0; | 161 | stat = 0; |
165 | } | 162 | } |
166 | 163 | ||
@@ -170,9 +167,9 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
170 | 167 | ||
171 | if (stat == 0) { | 168 | if (stat == 0) { |
172 | if (lockflag) | 169 | if (lockflag) |
173 | cd->cd_flags |= IDE_CD_FLAG_DOOR_LOCKED; | 170 | drive->atapi_flags |= IDE_AFLAG_DOOR_LOCKED; |
174 | else | 171 | else |
175 | cd->cd_flags &= ~IDE_CD_FLAG_DOOR_LOCKED; | 172 | drive->atapi_flags &= ~IDE_AFLAG_DOOR_LOCKED; |
176 | } | 173 | } |
177 | 174 | ||
178 | return stat; | 175 | return stat; |
@@ -231,7 +228,7 @@ int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) | |||
231 | cmd[5] = speed & 0xff; | 228 | cmd[5] = speed & 0xff; |
232 | } | 229 | } |
233 | 230 | ||
234 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); | 231 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, NULL, &sense, 0, 0); |
235 | 232 | ||
236 | if (!ide_cdrom_get_capabilities(drive, buf)) { | 233 | if (!ide_cdrom_get_capabilities(drive, buf)) { |
237 | ide_cdrom_update_speed(drive, buf); | 234 | ide_cdrom_update_speed(drive, buf); |
@@ -250,7 +247,7 @@ int ide_cdrom_get_last_session(struct cdrom_device_info *cdi, | |||
250 | struct request_sense sense; | 247 | struct request_sense sense; |
251 | int ret; | 248 | int ret; |
252 | 249 | ||
253 | if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0 || !info->toc) { | 250 | if ((drive->atapi_flags & IDE_AFLAG_TOC_VALID) == 0 || !info->toc) { |
254 | ret = ide_cd_read_toc(drive, &sense); | 251 | ret = ide_cd_read_toc(drive, &sense); |
255 | if (ret) | 252 | if (ret) |
256 | return ret; | 253 | return ret; |
@@ -308,7 +305,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi) | |||
308 | * A reset will unlock the door. If it was previously locked, | 305 | * A reset will unlock the door. If it was previously locked, |
309 | * lock it again. | 306 | * lock it again. |
310 | */ | 307 | */ |
311 | if (cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) | 308 | if (drive->atapi_flags & IDE_AFLAG_DOOR_LOCKED) |
312 | (void)ide_cd_lockdoor(drive, 1, &sense); | 309 | (void)ide_cd_lockdoor(drive, 1, &sense); |
313 | 310 | ||
314 | return ret; | 311 | return ret; |
@@ -324,7 +321,7 @@ static int ide_cd_get_toc_entry(ide_drive_t *drive, int track, | |||
324 | /* | 321 | /* |
325 | * don't serve cached data, if the toc isn't valid | 322 | * don't serve cached data, if the toc isn't valid |
326 | */ | 323 | */ |
327 | if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0) | 324 | if ((drive->atapi_flags & IDE_AFLAG_TOC_VALID) == 0) |
328 | return -EINVAL; | 325 | return -EINVAL; |
329 | 326 | ||
330 | /* Check validity of requested track number. */ | 327 | /* Check validity of requested track number. */ |
@@ -374,7 +371,7 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
374 | lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]); | 371 | lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]); |
375 | lba_to_msf(lba_end - 1, &cmd[6], &cmd[7], &cmd[8]); | 372 | lba_to_msf(lba_end - 1, &cmd[6], &cmd[7], &cmd[8]); |
376 | 373 | ||
377 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); | 374 | return ide_cd_queue_pc(drive, cmd, 0, NULL, NULL, &sense, 0, 0); |
378 | } | 375 | } |
379 | 376 | ||
380 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) | 377 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 3a2e80237c10..df5fe5756871 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -158,7 +158,7 @@ static void ide_tf_set_cmd(ide_drive_t *drive, ide_task_t *task, u8 dma) | |||
158 | write = (task->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0; | 158 | write = (task->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0; |
159 | 159 | ||
160 | if (dma) | 160 | if (dma) |
161 | index = drive->vdma ? 4 : 8; | 161 | index = 8; |
162 | else | 162 | else |
163 | index = drive->mult_count ? 0 : 4; | 163 | index = drive->mult_count ? 0 : 4; |
164 | 164 | ||
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 7ee44f86bc54..be99d463dcc7 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -100,10 +100,11 @@ static const struct drive_list_entry drive_blacklist [] = { | |||
100 | 100 | ||
101 | ide_startstop_t ide_dma_intr (ide_drive_t *drive) | 101 | ide_startstop_t ide_dma_intr (ide_drive_t *drive) |
102 | { | 102 | { |
103 | ide_hwif_t *hwif = drive->hwif; | ||
103 | u8 stat = 0, dma_stat = 0; | 104 | u8 stat = 0, dma_stat = 0; |
104 | 105 | ||
105 | dma_stat = drive->hwif->dma_ops->dma_end(drive); | 106 | dma_stat = hwif->dma_ops->dma_end(drive); |
106 | stat = ide_read_status(drive); | 107 | stat = hwif->tp_ops->read_status(hwif); |
107 | 108 | ||
108 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { | 109 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { |
109 | if (!dma_stat) { | 110 | if (!dma_stat) { |
@@ -334,7 +335,7 @@ static int config_drive_for_dma (ide_drive_t *drive) | |||
334 | static int dma_timer_expiry (ide_drive_t *drive) | 335 | static int dma_timer_expiry (ide_drive_t *drive) |
335 | { | 336 | { |
336 | ide_hwif_t *hwif = HWIF(drive); | 337 | ide_hwif_t *hwif = HWIF(drive); |
337 | u8 dma_stat = hwif->INB(hwif->dma_status); | 338 | u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
338 | 339 | ||
339 | printk(KERN_WARNING "%s: dma_timer_expiry: dma status == 0x%02x\n", | 340 | printk(KERN_WARNING "%s: dma_timer_expiry: dma status == 0x%02x\n", |
340 | drive->name, dma_stat); | 341 | drive->name, dma_stat); |
@@ -369,14 +370,18 @@ void ide_dma_host_set(ide_drive_t *drive, int on) | |||
369 | { | 370 | { |
370 | ide_hwif_t *hwif = HWIF(drive); | 371 | ide_hwif_t *hwif = HWIF(drive); |
371 | u8 unit = (drive->select.b.unit & 0x01); | 372 | u8 unit = (drive->select.b.unit & 0x01); |
372 | u8 dma_stat = hwif->INB(hwif->dma_status); | 373 | u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
373 | 374 | ||
374 | if (on) | 375 | if (on) |
375 | dma_stat |= (1 << (5 + unit)); | 376 | dma_stat |= (1 << (5 + unit)); |
376 | else | 377 | else |
377 | dma_stat &= ~(1 << (5 + unit)); | 378 | dma_stat &= ~(1 << (5 + unit)); |
378 | 379 | ||
379 | hwif->OUTB(dma_stat, hwif->dma_status); | 380 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
381 | writeb(dma_stat, | ||
382 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
383 | else | ||
384 | outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS); | ||
380 | } | 385 | } |
381 | 386 | ||
382 | EXPORT_SYMBOL_GPL(ide_dma_host_set); | 387 | EXPORT_SYMBOL_GPL(ide_dma_host_set); |
@@ -449,6 +454,7 @@ int ide_dma_setup(ide_drive_t *drive) | |||
449 | ide_hwif_t *hwif = drive->hwif; | 454 | ide_hwif_t *hwif = drive->hwif; |
450 | struct request *rq = HWGROUP(drive)->rq; | 455 | struct request *rq = HWGROUP(drive)->rq; |
451 | unsigned int reading; | 456 | unsigned int reading; |
457 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
452 | u8 dma_stat; | 458 | u8 dma_stat; |
453 | 459 | ||
454 | if (rq_data_dir(rq)) | 460 | if (rq_data_dir(rq)) |
@@ -470,13 +476,21 @@ int ide_dma_setup(ide_drive_t *drive) | |||
470 | outl(hwif->dmatable_dma, hwif->dma_base + ATA_DMA_TABLE_OFS); | 476 | outl(hwif->dmatable_dma, hwif->dma_base + ATA_DMA_TABLE_OFS); |
471 | 477 | ||
472 | /* specify r/w */ | 478 | /* specify r/w */ |
473 | hwif->OUTB(reading, hwif->dma_command); | 479 | if (mmio) |
480 | writeb(reading, (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | ||
481 | else | ||
482 | outb(reading, hwif->dma_base + ATA_DMA_CMD); | ||
474 | 483 | ||
475 | /* read dma_status for INTR & ERROR flags */ | 484 | /* read DMA status for INTR & ERROR flags */ |
476 | dma_stat = hwif->INB(hwif->dma_status); | 485 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
477 | 486 | ||
478 | /* clear INTR & ERROR flags */ | 487 | /* clear INTR & ERROR flags */ |
479 | hwif->OUTB(dma_stat|6, hwif->dma_status); | 488 | if (mmio) |
489 | writeb(dma_stat | 6, | ||
490 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
491 | else | ||
492 | outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); | ||
493 | |||
480 | drive->waiting_for_dma = 1; | 494 | drive->waiting_for_dma = 1; |
481 | return 0; | 495 | return 0; |
482 | } | 496 | } |
@@ -492,16 +506,24 @@ EXPORT_SYMBOL_GPL(ide_dma_exec_cmd); | |||
492 | 506 | ||
493 | void ide_dma_start(ide_drive_t *drive) | 507 | void ide_dma_start(ide_drive_t *drive) |
494 | { | 508 | { |
495 | ide_hwif_t *hwif = HWIF(drive); | 509 | ide_hwif_t *hwif = drive->hwif; |
496 | u8 dma_cmd = hwif->INB(hwif->dma_command); | 510 | u8 dma_cmd; |
497 | 511 | ||
498 | /* Note that this is done *after* the cmd has | 512 | /* Note that this is done *after* the cmd has |
499 | * been issued to the drive, as per the BM-IDE spec. | 513 | * been issued to the drive, as per the BM-IDE spec. |
500 | * The Promise Ultra33 doesn't work correctly when | 514 | * The Promise Ultra33 doesn't work correctly when |
501 | * we do this part before issuing the drive cmd. | 515 | * we do this part before issuing the drive cmd. |
502 | */ | 516 | */ |
503 | /* start DMA */ | 517 | if (hwif->host_flags & IDE_HFLAG_MMIO) { |
504 | hwif->OUTB(dma_cmd|1, hwif->dma_command); | 518 | dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); |
519 | /* start DMA */ | ||
520 | writeb(dma_cmd | 1, | ||
521 | (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | ||
522 | } else { | ||
523 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); | ||
524 | outb(dma_cmd | 1, hwif->dma_base + ATA_DMA_CMD); | ||
525 | } | ||
526 | |||
505 | hwif->dma = 1; | 527 | hwif->dma = 1; |
506 | wmb(); | 528 | wmb(); |
507 | } | 529 | } |
@@ -511,18 +533,33 @@ EXPORT_SYMBOL_GPL(ide_dma_start); | |||
511 | /* returns 1 on error, 0 otherwise */ | 533 | /* returns 1 on error, 0 otherwise */ |
512 | int __ide_dma_end (ide_drive_t *drive) | 534 | int __ide_dma_end (ide_drive_t *drive) |
513 | { | 535 | { |
514 | ide_hwif_t *hwif = HWIF(drive); | 536 | ide_hwif_t *hwif = drive->hwif; |
537 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
515 | u8 dma_stat = 0, dma_cmd = 0; | 538 | u8 dma_stat = 0, dma_cmd = 0; |
516 | 539 | ||
517 | drive->waiting_for_dma = 0; | 540 | drive->waiting_for_dma = 0; |
518 | /* get dma_command mode */ | 541 | |
519 | dma_cmd = hwif->INB(hwif->dma_command); | 542 | if (mmio) { |
520 | /* stop DMA */ | 543 | /* get DMA command mode */ |
521 | hwif->OUTB(dma_cmd&~1, hwif->dma_command); | 544 | dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); |
545 | /* stop DMA */ | ||
546 | writeb(dma_cmd & ~1, | ||
547 | (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | ||
548 | } else { | ||
549 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); | ||
550 | outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); | ||
551 | } | ||
552 | |||
522 | /* get DMA status */ | 553 | /* get DMA status */ |
523 | dma_stat = hwif->INB(hwif->dma_status); | 554 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
524 | /* clear the INTR & ERROR bits */ | 555 | |
525 | hwif->OUTB(dma_stat|6, hwif->dma_status); | 556 | if (mmio) |
557 | /* clear the INTR & ERROR bits */ | ||
558 | writeb(dma_stat | 6, | ||
559 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
560 | else | ||
561 | outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); | ||
562 | |||
526 | /* purge DMA mappings */ | 563 | /* purge DMA mappings */ |
527 | ide_destroy_dmatable(drive); | 564 | ide_destroy_dmatable(drive); |
528 | /* verify good DMA status */ | 565 | /* verify good DMA status */ |
@@ -537,7 +574,7 @@ EXPORT_SYMBOL(__ide_dma_end); | |||
537 | int ide_dma_test_irq(ide_drive_t *drive) | 574 | int ide_dma_test_irq(ide_drive_t *drive) |
538 | { | 575 | { |
539 | ide_hwif_t *hwif = HWIF(drive); | 576 | ide_hwif_t *hwif = HWIF(drive); |
540 | u8 dma_stat = hwif->INB(hwif->dma_status); | 577 | u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
541 | 578 | ||
542 | /* return 1 if INTR asserted */ | 579 | /* return 1 if INTR asserted */ |
543 | if ((dma_stat & 4) == 4) | 580 | if ((dma_stat & 4) == 4) |
@@ -719,9 +756,8 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
719 | static int ide_dma_check(ide_drive_t *drive) | 756 | static int ide_dma_check(ide_drive_t *drive) |
720 | { | 757 | { |
721 | ide_hwif_t *hwif = drive->hwif; | 758 | ide_hwif_t *hwif = drive->hwif; |
722 | int vdma = (hwif->host_flags & IDE_HFLAG_VDMA)? 1 : 0; | ||
723 | 759 | ||
724 | if (!vdma && ide_tune_dma(drive)) | 760 | if (ide_tune_dma(drive)) |
725 | return 0; | 761 | return 0; |
726 | 762 | ||
727 | /* TODO: always do PIO fallback */ | 763 | /* TODO: always do PIO fallback */ |
@@ -730,7 +766,7 @@ static int ide_dma_check(ide_drive_t *drive) | |||
730 | 766 | ||
731 | ide_set_max_pio(drive); | 767 | ide_set_max_pio(drive); |
732 | 768 | ||
733 | return vdma ? 0 : -1; | 769 | return -1; |
734 | } | 770 | } |
735 | 771 | ||
736 | int ide_id_dma_bug(ide_drive_t *drive) | 772 | int ide_id_dma_bug(ide_drive_t *drive) |
@@ -842,7 +878,7 @@ int ide_allocate_dma_engine(ide_hwif_t *hwif) | |||
842 | } | 878 | } |
843 | EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); | 879 | EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); |
844 | 880 | ||
845 | static const struct ide_dma_ops sff_dma_ops = { | 881 | const struct ide_dma_ops sff_dma_ops = { |
846 | .dma_host_set = ide_dma_host_set, | 882 | .dma_host_set = ide_dma_host_set, |
847 | .dma_setup = ide_dma_setup, | 883 | .dma_setup = ide_dma_setup, |
848 | .dma_exec_cmd = ide_dma_exec_cmd, | 884 | .dma_exec_cmd = ide_dma_exec_cmd, |
@@ -852,18 +888,5 @@ static const struct ide_dma_ops sff_dma_ops = { | |||
852 | .dma_timeout = ide_dma_timeout, | 888 | .dma_timeout = ide_dma_timeout, |
853 | .dma_lost_irq = ide_dma_lost_irq, | 889 | .dma_lost_irq = ide_dma_lost_irq, |
854 | }; | 890 | }; |
855 | 891 | EXPORT_SYMBOL_GPL(sff_dma_ops); | |
856 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) | ||
857 | { | ||
858 | hwif->dma_base = base; | ||
859 | |||
860 | if (!hwif->dma_command) | ||
861 | hwif->dma_command = hwif->dma_base + 0; | ||
862 | if (!hwif->dma_status) | ||
863 | hwif->dma_status = hwif->dma_base + 2; | ||
864 | |||
865 | hwif->dma_ops = &sff_dma_ops; | ||
866 | } | ||
867 | |||
868 | EXPORT_SYMBOL_GPL(ide_setup_dma); | ||
869 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 892 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 011d72011cc4..3d8e6dd0f41e 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -125,26 +125,10 @@ typedef struct ide_floppy_obj { | |||
125 | int wp; | 125 | int wp; |
126 | /* Supports format progress report */ | 126 | /* Supports format progress report */ |
127 | int srfp; | 127 | int srfp; |
128 | /* Status/Action flags */ | ||
129 | unsigned long flags; | ||
130 | } idefloppy_floppy_t; | 128 | } idefloppy_floppy_t; |
131 | 129 | ||
132 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ | 130 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ |
133 | 131 | ||
134 | /* Floppy flag bits values. */ | ||
135 | enum { | ||
136 | /* DRQ interrupt device */ | ||
137 | IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0), | ||
138 | /* Media may have changed */ | ||
139 | IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1), | ||
140 | /* Format in progress */ | ||
141 | IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2), | ||
142 | /* Avoid commands not supported in Clik drive */ | ||
143 | IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3), | ||
144 | /* Requires BH algorithm for packets */ | ||
145 | IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), | ||
146 | }; | ||
147 | |||
148 | /* Defines for the MODE SENSE command */ | 132 | /* Defines for the MODE SENSE command */ |
149 | #define MODE_SENSE_CURRENT 0x00 | 133 | #define MODE_SENSE_CURRENT 0x00 |
150 | #define MODE_SENSE_CHANGEABLE 0x01 | 134 | #define MODE_SENSE_CHANGEABLE 0x01 |
@@ -247,9 +231,9 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
247 | 231 | ||
248 | data = bvec_kmap_irq(bvec, &flags); | 232 | data = bvec_kmap_irq(bvec, &flags); |
249 | if (direction) | 233 | if (direction) |
250 | hwif->output_data(drive, NULL, data, count); | 234 | hwif->tp_ops->output_data(drive, NULL, data, count); |
251 | else | 235 | else |
252 | hwif->input_data(drive, NULL, data, count); | 236 | hwif->tp_ops->input_data(drive, NULL, data, count); |
253 | bvec_kunmap_irq(data, &flags); | 237 | bvec_kunmap_irq(data, &flags); |
254 | 238 | ||
255 | bcount -= count; | 239 | bcount -= count; |
@@ -291,6 +275,7 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
291 | rq->cmd_type = REQ_TYPE_SPECIAL; | 275 | rq->cmd_type = REQ_TYPE_SPECIAL; |
292 | rq->cmd_flags |= REQ_PREEMPT; | 276 | rq->cmd_flags |= REQ_PREEMPT; |
293 | rq->rq_disk = floppy->disk; | 277 | rq->rq_disk = floppy->disk; |
278 | memcpy(rq->cmd, pc->c, 12); | ||
294 | ide_do_drive_cmd(drive, rq); | 279 | ide_do_drive_cmd(drive, rq); |
295 | } | 280 | } |
296 | 281 | ||
@@ -354,7 +339,6 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc) | |||
354 | memset(pc, 0, sizeof(*pc)); | 339 | memset(pc, 0, sizeof(*pc)); |
355 | pc->buf = pc->pc_buf; | 340 | pc->buf = pc->pc_buf; |
356 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; | 341 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; |
357 | pc->callback = ide_floppy_callback; | ||
358 | } | 342 | } |
359 | 343 | ||
360 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | 344 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) |
@@ -402,7 +386,7 @@ static int idefloppy_transfer_pc(ide_drive_t *drive) | |||
402 | idefloppy_floppy_t *floppy = drive->driver_data; | 386 | idefloppy_floppy_t *floppy = drive->driver_data; |
403 | 387 | ||
404 | /* Send the actual packet */ | 388 | /* Send the actual packet */ |
405 | drive->hwif->output_data(drive, NULL, floppy->pc->c, 12); | 389 | drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12); |
406 | 390 | ||
407 | /* Timeout for the packet command */ | 391 | /* Timeout for the packet command */ |
408 | return IDEFLOPPY_WAIT_CMD; | 392 | return IDEFLOPPY_WAIT_CMD; |
@@ -429,7 +413,7 @@ static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive) | |||
429 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually | 413 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually |
430 | * used until after the packet is moved in about 50 msec. | 414 | * used until after the packet is moved in about 50 msec. |
431 | */ | 415 | */ |
432 | if (pc->flags & PC_FLAG_ZIP_DRIVE) { | 416 | if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { |
433 | timeout = floppy->ticks; | 417 | timeout = floppy->ticks; |
434 | expiry = &idefloppy_transfer_pc; | 418 | expiry = &idefloppy_transfer_pc; |
435 | } else { | 419 | } else { |
@@ -474,7 +458,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
474 | pc->error = IDEFLOPPY_ERROR_GENERAL; | 458 | pc->error = IDEFLOPPY_ERROR_GENERAL; |
475 | 459 | ||
476 | floppy->failed_pc = NULL; | 460 | floppy->failed_pc = NULL; |
477 | pc->callback(drive); | 461 | drive->pc_callback(drive); |
478 | return ide_stopped; | 462 | return ide_stopped; |
479 | } | 463 | } |
480 | 464 | ||
@@ -574,6 +558,8 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
574 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); | 558 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
575 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); | 559 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
576 | 560 | ||
561 | memcpy(rq->cmd, pc->c, 12); | ||
562 | |||
577 | pc->rq = rq; | 563 | pc->rq = rq; |
578 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 564 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; |
579 | if (rq->cmd_flags & REQ_RW) | 565 | if (rq->cmd_flags & REQ_RW) |
@@ -647,12 +633,6 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
647 | return ide_stopped; | 633 | return ide_stopped; |
648 | } | 634 | } |
649 | 635 | ||
650 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) | ||
651 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
652 | |||
653 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) | ||
654 | pc->flags |= PC_FLAG_ZIP_DRIVE; | ||
655 | |||
656 | pc->rq = rq; | 636 | pc->rq = rq; |
657 | 637 | ||
658 | return idefloppy_issue_pc(drive, pc); | 638 | return idefloppy_issue_pc(drive, pc); |
@@ -671,6 +651,7 @@ static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | |||
671 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 651 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
672 | rq->buffer = (char *) pc; | 652 | rq->buffer = (char *) pc; |
673 | rq->cmd_type = REQ_TYPE_SPECIAL; | 653 | rq->cmd_type = REQ_TYPE_SPECIAL; |
654 | memcpy(rq->cmd, pc->c, 12); | ||
674 | error = blk_execute_rq(drive->queue, floppy->disk, rq, 0); | 655 | error = blk_execute_rq(drive->queue, floppy->disk, rq, 0); |
675 | blk_put_request(rq); | 656 | blk_put_request(rq); |
676 | 657 | ||
@@ -795,7 +776,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
795 | switch (pc.buf[desc_start + 4] & 0x03) { | 776 | switch (pc.buf[desc_start + 4] & 0x03) { |
796 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ | 777 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
797 | case CAPACITY_UNFORMATTED: | 778 | case CAPACITY_UNFORMATTED: |
798 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) | 779 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
799 | /* | 780 | /* |
800 | * If it is not a clik drive, break out | 781 | * If it is not a clik drive, break out |
801 | * (maintains previous driver behaviour) | 782 | * (maintains previous driver behaviour) |
@@ -841,7 +822,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
841 | } | 822 | } |
842 | 823 | ||
843 | /* Clik! disk does not support get_flexible_disk_page */ | 824 | /* Clik! disk does not support get_flexible_disk_page */ |
844 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) | 825 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
845 | (void) ide_floppy_get_flexible_disk_page(drive); | 826 | (void) ide_floppy_get_flexible_disk_page(drive); |
846 | 827 | ||
847 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); | 828 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); |
@@ -949,11 +930,12 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
949 | 930 | ||
950 | /* Else assume format_unit has finished, and we're at 0x10000 */ | 931 | /* Else assume format_unit has finished, and we're at 0x10000 */ |
951 | } else { | 932 | } else { |
933 | ide_hwif_t *hwif = drive->hwif; | ||
952 | unsigned long flags; | 934 | unsigned long flags; |
953 | u8 stat; | 935 | u8 stat; |
954 | 936 | ||
955 | local_irq_save(flags); | 937 | local_irq_save(flags); |
956 | stat = ide_read_status(drive); | 938 | stat = hwif->tp_ops->read_status(hwif); |
957 | local_irq_restore(flags); | 939 | local_irq_restore(flags); |
958 | 940 | ||
959 | progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; | 941 | progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; |
@@ -1039,9 +1021,10 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
1039 | 1021 | ||
1040 | *((u16 *) &gcw) = drive->id->config; | 1022 | *((u16 *) &gcw) = drive->id->config; |
1041 | floppy->pc = floppy->pc_stack; | 1023 | floppy->pc = floppy->pc_stack; |
1024 | drive->pc_callback = ide_floppy_callback; | ||
1042 | 1025 | ||
1043 | if (((gcw[0] & 0x60) >> 5) == 1) | 1026 | if (((gcw[0] & 0x60) >> 5) == 1) |
1044 | floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; | 1027 | drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; |
1045 | /* | 1028 | /* |
1046 | * We used to check revisions here. At this point however I'm giving up. | 1029 | * We used to check revisions here. At this point however I'm giving up. |
1047 | * Just assume they are all broken, its easier. | 1030 | * Just assume they are all broken, its easier. |
@@ -1052,7 +1035,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
1052 | * we'll leave the limitation below for the 2.2.x tree. | 1035 | * we'll leave the limitation below for the 2.2.x tree. |
1053 | */ | 1036 | */ |
1054 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { | 1037 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { |
1055 | floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; | 1038 | drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; |
1056 | /* This value will be visible in the /proc/ide/hdx/settings */ | 1039 | /* This value will be visible in the /proc/ide/hdx/settings */ |
1057 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; | 1040 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; |
1058 | blk_queue_max_sectors(drive->queue, 64); | 1041 | blk_queue_max_sectors(drive->queue, 64); |
@@ -1064,7 +1047,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
1064 | */ | 1047 | */ |
1065 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { | 1048 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { |
1066 | blk_queue_max_sectors(drive->queue, 64); | 1049 | blk_queue_max_sectors(drive->queue, 64); |
1067 | floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; | 1050 | drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; |
1068 | } | 1051 | } |
1069 | 1052 | ||
1070 | (void) ide_floppy_get_capacity(drive); | 1053 | (void) ide_floppy_get_capacity(drive); |
@@ -1153,7 +1136,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1153 | floppy->openers++; | 1136 | floppy->openers++; |
1154 | 1137 | ||
1155 | if (floppy->openers == 1) { | 1138 | if (floppy->openers == 1) { |
1156 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | 1139 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
1157 | /* Just in case */ | 1140 | /* Just in case */ |
1158 | 1141 | ||
1159 | idefloppy_init_pc(&pc); | 1142 | idefloppy_init_pc(&pc); |
@@ -1180,14 +1163,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1180 | ret = -EROFS; | 1163 | ret = -EROFS; |
1181 | goto out_put_floppy; | 1164 | goto out_put_floppy; |
1182 | } | 1165 | } |
1183 | floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; | 1166 | drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; |
1184 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1167 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1185 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | 1168 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { |
1186 | idefloppy_create_prevent_cmd(&pc, 1); | 1169 | idefloppy_create_prevent_cmd(&pc, 1); |
1187 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1170 | (void) idefloppy_queue_pc_tail(drive, &pc); |
1188 | } | 1171 | } |
1189 | check_disk_change(inode->i_bdev); | 1172 | check_disk_change(inode->i_bdev); |
1190 | } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) { | 1173 | } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { |
1191 | ret = -EBUSY; | 1174 | ret = -EBUSY; |
1192 | goto out_put_floppy; | 1175 | goto out_put_floppy; |
1193 | } | 1176 | } |
@@ -1210,12 +1193,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
1210 | 1193 | ||
1211 | if (floppy->openers == 1) { | 1194 | if (floppy->openers == 1) { |
1212 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1195 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1213 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | 1196 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { |
1214 | idefloppy_create_prevent_cmd(&pc, 0); | 1197 | idefloppy_create_prevent_cmd(&pc, 0); |
1215 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1198 | (void) idefloppy_queue_pc_tail(drive, &pc); |
1216 | } | 1199 | } |
1217 | 1200 | ||
1218 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | 1201 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
1219 | } | 1202 | } |
1220 | 1203 | ||
1221 | floppy->openers--; | 1204 | floppy->openers--; |
@@ -1236,15 +1219,17 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
1236 | return 0; | 1219 | return 0; |
1237 | } | 1220 | } |
1238 | 1221 | ||
1239 | static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, | 1222 | static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, |
1240 | struct ide_atapi_pc *pc, unsigned long arg, unsigned int cmd) | 1223 | unsigned long arg, unsigned int cmd) |
1241 | { | 1224 | { |
1225 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
1226 | |||
1242 | if (floppy->openers > 1) | 1227 | if (floppy->openers > 1) |
1243 | return -EBUSY; | 1228 | return -EBUSY; |
1244 | 1229 | ||
1245 | /* The IOMEGA Clik! Drive doesn't support this command - | 1230 | /* The IOMEGA Clik! Drive doesn't support this command - |
1246 | * no room for an eject mechanism */ | 1231 | * no room for an eject mechanism */ |
1247 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | 1232 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { |
1248 | int prevent = arg ? 1 : 0; | 1233 | int prevent = arg ? 1 : 0; |
1249 | 1234 | ||
1250 | if (cmd == CDROMEJECT) | 1235 | if (cmd == CDROMEJECT) |
@@ -1265,16 +1250,17 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, | |||
1265 | static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | 1250 | static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, |
1266 | int __user *arg) | 1251 | int __user *arg) |
1267 | { | 1252 | { |
1268 | int blocks, length, flags, err = 0; | ||
1269 | struct ide_atapi_pc pc; | 1253 | struct ide_atapi_pc pc; |
1254 | ide_drive_t *drive = floppy->drive; | ||
1255 | int blocks, length, flags, err = 0; | ||
1270 | 1256 | ||
1271 | if (floppy->openers > 1) { | 1257 | if (floppy->openers > 1) { |
1272 | /* Don't format if someone is using the disk */ | 1258 | /* Don't format if someone is using the disk */ |
1273 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | 1259 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
1274 | return -EBUSY; | 1260 | return -EBUSY; |
1275 | } | 1261 | } |
1276 | 1262 | ||
1277 | floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | 1263 | drive->atapi_flags |= IDE_AFLAG_FORMAT_IN_PROGRESS; |
1278 | 1264 | ||
1279 | /* | 1265 | /* |
1280 | * Send ATAPI_FORMAT_UNIT to the drive. | 1266 | * Send ATAPI_FORMAT_UNIT to the drive. |
@@ -1298,15 +1284,15 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | |||
1298 | goto out; | 1284 | goto out; |
1299 | } | 1285 | } |
1300 | 1286 | ||
1301 | (void) idefloppy_get_sfrp_bit(floppy->drive); | 1287 | (void) idefloppy_get_sfrp_bit(drive); |
1302 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); | 1288 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); |
1303 | 1289 | ||
1304 | if (idefloppy_queue_pc_tail(floppy->drive, &pc)) | 1290 | if (idefloppy_queue_pc_tail(drive, &pc)) |
1305 | err = -EIO; | 1291 | err = -EIO; |
1306 | 1292 | ||
1307 | out: | 1293 | out: |
1308 | if (err) | 1294 | if (err) |
1309 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | 1295 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
1310 | return err; | 1296 | return err; |
1311 | } | 1297 | } |
1312 | 1298 | ||
@@ -1325,7 +1311,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
1325 | case CDROMEJECT: | 1311 | case CDROMEJECT: |
1326 | /* fall through */ | 1312 | /* fall through */ |
1327 | case CDROM_LOCKDOOR: | 1313 | case CDROM_LOCKDOOR: |
1328 | return ide_floppy_lockdoor(floppy, &pc, arg, cmd); | 1314 | return ide_floppy_lockdoor(drive, &pc, arg, cmd); |
1329 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | 1315 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: |
1330 | return 0; | 1316 | return 0; |
1331 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: | 1317 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: |
@@ -1366,8 +1352,8 @@ static int idefloppy_media_changed(struct gendisk *disk) | |||
1366 | drive->attach = 0; | 1352 | drive->attach = 0; |
1367 | return 0; | 1353 | return 0; |
1368 | } | 1354 | } |
1369 | ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED); | 1355 | ret = !!(drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED); |
1370 | floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; | 1356 | drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED; |
1371 | return ret; | 1357 | return ret; |
1372 | } | 1358 | } |
1373 | 1359 | ||
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 2d92214096ab..31d98fec775f 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -28,29 +28,21 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports"); | |||
28 | 28 | ||
29 | static ssize_t store_add(struct class *cls, const char *buf, size_t n) | 29 | static ssize_t store_add(struct class *cls, const char *buf, size_t n) |
30 | { | 30 | { |
31 | ide_hwif_t *hwif; | ||
32 | unsigned int base, ctl; | 31 | unsigned int base, ctl; |
33 | int irq; | 32 | int irq, rc; |
34 | hw_regs_t hw; | 33 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
35 | u8 idx[] = { 0xff, 0xff, 0xff, 0xff }; | ||
36 | 34 | ||
37 | if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) | 35 | if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) |
38 | return -EINVAL; | 36 | return -EINVAL; |
39 | 37 | ||
40 | hwif = ide_find_port(); | ||
41 | if (hwif == NULL) | ||
42 | return -ENOENT; | ||
43 | |||
44 | memset(&hw, 0, sizeof(hw)); | 38 | memset(&hw, 0, sizeof(hw)); |
45 | ide_std_init_ports(&hw, base, ctl); | 39 | ide_std_init_ports(&hw, base, ctl); |
46 | hw.irq = irq; | 40 | hw.irq = irq; |
47 | hw.chipset = ide_generic; | 41 | hw.chipset = ide_generic; |
48 | 42 | ||
49 | ide_init_port_hw(hwif, &hw); | 43 | rc = ide_host_add(NULL, hws, NULL); |
50 | 44 | if (rc) | |
51 | idx[0] = hwif->index; | 45 | return rc; |
52 | |||
53 | ide_device_add(idx, NULL); | ||
54 | 46 | ||
55 | return n; | 47 | return n; |
56 | }; | 48 | }; |
@@ -90,18 +82,18 @@ static int __init ide_generic_sysfs_init(void) | |||
90 | 82 | ||
91 | static int __init ide_generic_init(void) | 83 | static int __init ide_generic_init(void) |
92 | { | 84 | { |
93 | u8 idx[MAX_HWIFS]; | 85 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; |
94 | int i; | 86 | struct ide_host *host; |
87 | unsigned long io_addr; | ||
88 | int i, rc; | ||
95 | 89 | ||
96 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " | 90 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " |
97 | "parameter for probing all legacy ISA IDE ports\n"); | 91 | "parameter for probing all legacy ISA IDE ports\n"); |
98 | 92 | ||
99 | for (i = 0; i < MAX_HWIFS; i++) { | 93 | for (i = 0; i < MAX_HWIFS; i++) { |
100 | ide_hwif_t *hwif; | 94 | io_addr = ide_default_io_base(i); |
101 | unsigned long io_addr = ide_default_io_base(i); | ||
102 | hw_regs_t hw; | ||
103 | 95 | ||
104 | idx[i] = 0xff; | 96 | hws[i] = NULL; |
105 | 97 | ||
106 | if ((probe_mask & (1 << i)) && io_addr) { | 98 | if ((probe_mask & (1 << i)) && io_addr) { |
107 | if (!request_region(io_addr, 8, DRV_NAME)) { | 99 | if (!request_region(io_addr, 8, DRV_NAME)) { |
@@ -119,33 +111,42 @@ static int __init ide_generic_init(void) | |||
119 | continue; | 111 | continue; |
120 | } | 112 | } |
121 | 113 | ||
122 | /* | 114 | memset(&hw[i], 0, sizeof(hw[i])); |
123 | * Skip probing if the corresponding | 115 | ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); |
124 | * slot is already occupied. | 116 | hw[i].irq = ide_default_irq(io_addr); |
125 | */ | 117 | hw[i].chipset = ide_generic; |
126 | hwif = ide_find_port(); | ||
127 | if (hwif == NULL || hwif->index != i) { | ||
128 | idx[i] = 0xff; | ||
129 | continue; | ||
130 | } | ||
131 | |||
132 | memset(&hw, 0, sizeof(hw)); | ||
133 | ide_std_init_ports(&hw, io_addr, io_addr + 0x206); | ||
134 | hw.irq = ide_default_irq(io_addr); | ||
135 | hw.chipset = ide_generic; | ||
136 | ide_init_port_hw(hwif, &hw); | ||
137 | 118 | ||
138 | idx[i] = i; | 119 | hws[i] = &hw[i]; |
139 | } | 120 | } |
140 | } | 121 | } |
141 | 122 | ||
142 | ide_device_add_all(idx, NULL); | 123 | host = ide_host_alloc_all(NULL, hws); |
124 | if (host == NULL) { | ||
125 | rc = -ENOMEM; | ||
126 | goto err; | ||
127 | } | ||
128 | |||
129 | rc = ide_host_register(host, NULL, hws); | ||
130 | if (rc) | ||
131 | goto err_free; | ||
143 | 132 | ||
144 | if (ide_generic_sysfs_init()) | 133 | if (ide_generic_sysfs_init()) |
145 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " | 134 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " |
146 | "class\n"); | 135 | "class\n"); |
147 | 136 | ||
148 | return 0; | 137 | return 0; |
138 | err_free: | ||
139 | ide_host_free(host); | ||
140 | err: | ||
141 | for (i = 0; i < MAX_HWIFS; i++) { | ||
142 | if (hws[i] == NULL) | ||
143 | continue; | ||
144 | |||
145 | io_addr = hws[i]->io_ports.data_addr; | ||
146 | release_region(io_addr + 0x206, 1); | ||
147 | release_region(io_addr, 8); | ||
148 | } | ||
149 | return rc; | ||
149 | } | 150 | } |
150 | 151 | ||
151 | module_init(ide_generic_init); | 152 | module_init(ide_generic_init); |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 661b75a89d4d..a896a283f27f 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -330,7 +330,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | |||
330 | tf->error = err; | 330 | tf->error = err; |
331 | tf->status = stat; | 331 | tf->status = stat; |
332 | 332 | ||
333 | drive->hwif->tf_read(drive, task); | 333 | drive->hwif->tp_ops->tf_read(drive, task); |
334 | 334 | ||
335 | if (task->tf_flags & IDE_TFLAG_DYN) | 335 | if (task->tf_flags & IDE_TFLAG_DYN) |
336 | kfree(task); | 336 | kfree(task); |
@@ -381,8 +381,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
381 | if (err == ABRT_ERR) { | 381 | if (err == ABRT_ERR) { |
382 | if (drive->select.b.lba && | 382 | if (drive->select.b.lba && |
383 | /* some newer drives don't support WIN_SPECIFY */ | 383 | /* some newer drives don't support WIN_SPECIFY */ |
384 | hwif->INB(hwif->io_ports.command_addr) == | 384 | hwif->tp_ops->read_status(hwif) == WIN_SPECIFY) |
385 | WIN_SPECIFY) | ||
386 | return ide_stopped; | 385 | return ide_stopped; |
387 | } else if ((err & BAD_CRC) == BAD_CRC) { | 386 | } else if ((err & BAD_CRC) == BAD_CRC) { |
388 | /* UDMA crc error, just retry the operation */ | 387 | /* UDMA crc error, just retry the operation */ |
@@ -408,7 +407,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
408 | return ide_stopped; | 407 | return ide_stopped; |
409 | } | 408 | } |
410 | 409 | ||
411 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) | 410 | if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) |
412 | rq->errors |= ERROR_RESET; | 411 | rq->errors |= ERROR_RESET; |
413 | 412 | ||
414 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { | 413 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { |
@@ -435,10 +434,9 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u | |||
435 | /* add decoding error stuff */ | 434 | /* add decoding error stuff */ |
436 | } | 435 | } |
437 | 436 | ||
438 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) | 437 | if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) |
439 | /* force an abort */ | 438 | /* force an abort */ |
440 | hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE, | 439 | hwif->tp_ops->exec_command(hwif, WIN_IDLEIMMEDIATE); |
441 | hwif->io_ports.command_addr); | ||
442 | 440 | ||
443 | if (rq->errors >= ERROR_MAX) { | 441 | if (rq->errors >= ERROR_MAX) { |
444 | ide_kill_rq(drive, rq); | 442 | ide_kill_rq(drive, rq); |
@@ -712,7 +710,8 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, | |||
712 | #ifdef DEBUG | 710 | #ifdef DEBUG |
713 | printk("%s: DRIVE_CMD (null)\n", drive->name); | 711 | printk("%s: DRIVE_CMD (null)\n", drive->name); |
714 | #endif | 712 | #endif |
715 | ide_end_drive_cmd(drive, ide_read_status(drive), ide_read_error(drive)); | 713 | ide_end_drive_cmd(drive, hwif->tp_ops->read_status(hwif), |
714 | ide_read_error(drive)); | ||
716 | 715 | ||
717 | return ide_stopped; | 716 | return ide_stopped; |
718 | } | 717 | } |
@@ -747,16 +746,17 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) | |||
747 | * the bus may be broken enough to walk on our toes at this | 746 | * the bus may be broken enough to walk on our toes at this |
748 | * point. | 747 | * point. |
749 | */ | 748 | */ |
749 | ide_hwif_t *hwif = drive->hwif; | ||
750 | int rc; | 750 | int rc; |
751 | #ifdef DEBUG_PM | 751 | #ifdef DEBUG_PM |
752 | printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name); | 752 | printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name); |
753 | #endif | 753 | #endif |
754 | rc = ide_wait_not_busy(HWIF(drive), 35000); | 754 | rc = ide_wait_not_busy(hwif, 35000); |
755 | if (rc) | 755 | if (rc) |
756 | printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name); | 756 | printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name); |
757 | SELECT_DRIVE(drive); | 757 | SELECT_DRIVE(drive); |
758 | ide_set_irq(drive, 1); | 758 | hwif->tp_ops->set_irq(hwif, 1); |
759 | rc = ide_wait_not_busy(HWIF(drive), 100000); | 759 | rc = ide_wait_not_busy(hwif, 100000); |
760 | if (rc) | 760 | if (rc) |
761 | printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); | 761 | printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); |
762 | } | 762 | } |
@@ -1042,7 +1042,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) | |||
1042 | * quirk_list may not like intr setups/cleanups | 1042 | * quirk_list may not like intr setups/cleanups |
1043 | */ | 1043 | */ |
1044 | if (drive->quirk_list != 1) | 1044 | if (drive->quirk_list != 1) |
1045 | ide_set_irq(drive, 0); | 1045 | hwif->tp_ops->set_irq(hwif, 0); |
1046 | } | 1046 | } |
1047 | hwgroup->hwif = hwif; | 1047 | hwgroup->hwif = hwif; |
1048 | hwgroup->drive = drive; | 1048 | hwgroup->drive = drive; |
@@ -1142,7 +1142,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | |||
1142 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); | 1142 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); |
1143 | (void)hwif->dma_ops->dma_end(drive); | 1143 | (void)hwif->dma_ops->dma_end(drive); |
1144 | ret = ide_error(drive, "dma timeout error", | 1144 | ret = ide_error(drive, "dma timeout error", |
1145 | ide_read_status(drive)); | 1145 | hwif->tp_ops->read_status(hwif)); |
1146 | } else { | 1146 | } else { |
1147 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); | 1147 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); |
1148 | hwif->dma_ops->dma_timeout(drive); | 1148 | hwif->dma_ops->dma_timeout(drive); |
@@ -1267,7 +1267,7 @@ void ide_timer_expiry (unsigned long data) | |||
1267 | } else | 1267 | } else |
1268 | startstop = | 1268 | startstop = |
1269 | ide_error(drive, "irq timeout", | 1269 | ide_error(drive, "irq timeout", |
1270 | ide_read_status(drive)); | 1270 | hwif->tp_ops->read_status(hwif)); |
1271 | } | 1271 | } |
1272 | drive->service_time = jiffies - drive->service_start; | 1272 | drive->service_time = jiffies - drive->service_start; |
1273 | spin_lock_irq(&ide_lock); | 1273 | spin_lock_irq(&ide_lock); |
@@ -1323,7 +1323,8 @@ static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup) | |||
1323 | */ | 1323 | */ |
1324 | do { | 1324 | do { |
1325 | if (hwif->irq == irq) { | 1325 | if (hwif->irq == irq) { |
1326 | stat = hwif->INB(hwif->io_ports.status_addr); | 1326 | stat = hwif->tp_ops->read_status(hwif); |
1327 | |||
1327 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) { | 1328 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) { |
1328 | /* Try to not flood the console with msgs */ | 1329 | /* Try to not flood the console with msgs */ |
1329 | static unsigned long last_msgtime, count; | 1330 | static unsigned long last_msgtime, count; |
@@ -1413,7 +1414,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1413 | * Whack the status register, just in case | 1414 | * Whack the status register, just in case |
1414 | * we have a leftover pending IRQ. | 1415 | * we have a leftover pending IRQ. |
1415 | */ | 1416 | */ |
1416 | (void) hwif->INB(hwif->io_ports.status_addr); | 1417 | (void)hwif->tp_ops->read_status(hwif); |
1417 | #endif /* CONFIG_BLK_DEV_IDEPCI */ | 1418 | #endif /* CONFIG_BLK_DEV_IDEPCI */ |
1418 | } | 1419 | } |
1419 | spin_unlock_irqrestore(&ide_lock, flags); | 1420 | spin_unlock_irqrestore(&ide_lock, flags); |
@@ -1519,6 +1520,7 @@ EXPORT_SYMBOL(ide_do_drive_cmd); | |||
1519 | 1520 | ||
1520 | void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) | 1521 | void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) |
1521 | { | 1522 | { |
1523 | ide_hwif_t *hwif = drive->hwif; | ||
1522 | ide_task_t task; | 1524 | ide_task_t task; |
1523 | 1525 | ||
1524 | memset(&task, 0, sizeof(task)); | 1526 | memset(&task, 0, sizeof(task)); |
@@ -1529,9 +1531,9 @@ void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) | |||
1529 | task.tf.lbah = (bcount >> 8) & 0xff; | 1531 | task.tf.lbah = (bcount >> 8) & 0xff; |
1530 | 1532 | ||
1531 | ide_tf_dump(drive->name, &task.tf); | 1533 | ide_tf_dump(drive->name, &task.tf); |
1532 | ide_set_irq(drive, 1); | 1534 | hwif->tp_ops->set_irq(hwif, 1); |
1533 | SELECT_MASK(drive, 0); | 1535 | SELECT_MASK(drive, 0); |
1534 | drive->hwif->tf_load(drive, &task); | 1536 | hwif->tp_ops->tf_load(drive, &task); |
1535 | } | 1537 | } |
1536 | 1538 | ||
1537 | EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load); | 1539 | EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load); |
@@ -1543,9 +1545,9 @@ void ide_pad_transfer(ide_drive_t *drive, int write, int len) | |||
1543 | 1545 | ||
1544 | while (len > 0) { | 1546 | while (len > 0) { |
1545 | if (write) | 1547 | if (write) |
1546 | hwif->output_data(drive, NULL, buf, min(4, len)); | 1548 | hwif->tp_ops->output_data(drive, NULL, buf, min(4, len)); |
1547 | else | 1549 | else |
1548 | hwif->input_data(drive, NULL, buf, min(4, len)); | 1550 | hwif->tp_ops->input_data(drive, NULL, buf, min(4, len)); |
1549 | len -= 4; | 1551 | len -= 4; |
1550 | } | 1552 | } |
1551 | } | 1553 | } |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 44aaec256a30..07da5fb9eaff 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -42,18 +42,6 @@ static void ide_outb (u8 val, unsigned long port) | |||
42 | outb(val, port); | 42 | outb(val, port); |
43 | } | 43 | } |
44 | 44 | ||
45 | static void ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port) | ||
46 | { | ||
47 | outb(addr, port); | ||
48 | } | ||
49 | |||
50 | void default_hwif_iops (ide_hwif_t *hwif) | ||
51 | { | ||
52 | hwif->OUTB = ide_outb; | ||
53 | hwif->OUTBSYNC = ide_outbsync; | ||
54 | hwif->INB = ide_inb; | ||
55 | } | ||
56 | |||
57 | /* | 45 | /* |
58 | * MMIO operations, typically used for SATA controllers | 46 | * MMIO operations, typically used for SATA controllers |
59 | */ | 47 | */ |
@@ -68,31 +56,19 @@ static void ide_mm_outb (u8 value, unsigned long port) | |||
68 | writeb(value, (void __iomem *) port); | 56 | writeb(value, (void __iomem *) port); |
69 | } | 57 | } |
70 | 58 | ||
71 | static void ide_mm_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) | ||
72 | { | ||
73 | writeb(value, (void __iomem *) port); | ||
74 | } | ||
75 | |||
76 | void default_hwif_mmiops (ide_hwif_t *hwif) | ||
77 | { | ||
78 | hwif->OUTB = ide_mm_outb; | ||
79 | /* Most systems will need to override OUTBSYNC, alas however | ||
80 | this one is controller specific! */ | ||
81 | hwif->OUTBSYNC = ide_mm_outbsync; | ||
82 | hwif->INB = ide_mm_inb; | ||
83 | } | ||
84 | |||
85 | EXPORT_SYMBOL(default_hwif_mmiops); | ||
86 | |||
87 | void SELECT_DRIVE (ide_drive_t *drive) | 59 | void SELECT_DRIVE (ide_drive_t *drive) |
88 | { | 60 | { |
89 | ide_hwif_t *hwif = drive->hwif; | 61 | ide_hwif_t *hwif = drive->hwif; |
90 | const struct ide_port_ops *port_ops = hwif->port_ops; | 62 | const struct ide_port_ops *port_ops = hwif->port_ops; |
63 | ide_task_t task; | ||
91 | 64 | ||
92 | if (port_ops && port_ops->selectproc) | 65 | if (port_ops && port_ops->selectproc) |
93 | port_ops->selectproc(drive); | 66 | port_ops->selectproc(drive); |
94 | 67 | ||
95 | hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); | 68 | memset(&task, 0, sizeof(task)); |
69 | task.tf_flags = IDE_TFLAG_OUT_DEVICE; | ||
70 | |||
71 | drive->hwif->tp_ops->tf_load(drive, &task); | ||
96 | } | 72 | } |
97 | 73 | ||
98 | void SELECT_MASK(ide_drive_t *drive, int mask) | 74 | void SELECT_MASK(ide_drive_t *drive, int mask) |
@@ -103,7 +79,61 @@ void SELECT_MASK(ide_drive_t *drive, int mask) | |||
103 | port_ops->maskproc(drive, mask); | 79 | port_ops->maskproc(drive, mask); |
104 | } | 80 | } |
105 | 81 | ||
106 | static void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | 82 | void ide_exec_command(ide_hwif_t *hwif, u8 cmd) |
83 | { | ||
84 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
85 | writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); | ||
86 | else | ||
87 | outb(cmd, hwif->io_ports.command_addr); | ||
88 | } | ||
89 | EXPORT_SYMBOL_GPL(ide_exec_command); | ||
90 | |||
91 | u8 ide_read_status(ide_hwif_t *hwif) | ||
92 | { | ||
93 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
94 | return readb((void __iomem *)hwif->io_ports.status_addr); | ||
95 | else | ||
96 | return inb(hwif->io_ports.status_addr); | ||
97 | } | ||
98 | EXPORT_SYMBOL_GPL(ide_read_status); | ||
99 | |||
100 | u8 ide_read_altstatus(ide_hwif_t *hwif) | ||
101 | { | ||
102 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
103 | return readb((void __iomem *)hwif->io_ports.ctl_addr); | ||
104 | else | ||
105 | return inb(hwif->io_ports.ctl_addr); | ||
106 | } | ||
107 | EXPORT_SYMBOL_GPL(ide_read_altstatus); | ||
108 | |||
109 | u8 ide_read_sff_dma_status(ide_hwif_t *hwif) | ||
110 | { | ||
111 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
112 | return readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
113 | else | ||
114 | return inb(hwif->dma_base + ATA_DMA_STATUS); | ||
115 | } | ||
116 | EXPORT_SYMBOL_GPL(ide_read_sff_dma_status); | ||
117 | |||
118 | void ide_set_irq(ide_hwif_t *hwif, int on) | ||
119 | { | ||
120 | u8 ctl = ATA_DEVCTL_OBS; | ||
121 | |||
122 | if (on == 4) { /* hack for SRST */ | ||
123 | ctl |= 4; | ||
124 | on &= ~4; | ||
125 | } | ||
126 | |||
127 | ctl |= on ? 0 : 2; | ||
128 | |||
129 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
130 | writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr); | ||
131 | else | ||
132 | outb(ctl, hwif->io_ports.ctl_addr); | ||
133 | } | ||
134 | EXPORT_SYMBOL_GPL(ide_set_irq); | ||
135 | |||
136 | void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | ||
107 | { | 137 | { |
108 | ide_hwif_t *hwif = drive->hwif; | 138 | ide_hwif_t *hwif = drive->hwif; |
109 | struct ide_io_ports *io_ports = &hwif->io_ports; | 139 | struct ide_io_ports *io_ports = &hwif->io_ports; |
@@ -155,8 +185,9 @@ static void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
155 | tf_outb((tf->device & HIHI) | drive->select.all, | 185 | tf_outb((tf->device & HIHI) | drive->select.all, |
156 | io_ports->device_addr); | 186 | io_ports->device_addr); |
157 | } | 187 | } |
188 | EXPORT_SYMBOL_GPL(ide_tf_load); | ||
158 | 189 | ||
159 | static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | 190 | void ide_tf_read(ide_drive_t *drive, ide_task_t *task) |
160 | { | 191 | { |
161 | ide_hwif_t *hwif = drive->hwif; | 192 | ide_hwif_t *hwif = drive->hwif; |
162 | struct ide_io_ports *io_ports = &hwif->io_ports; | 193 | struct ide_io_ports *io_ports = &hwif->io_ports; |
@@ -188,6 +219,8 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
188 | /* be sure we're looking at the low order bits */ | 219 | /* be sure we're looking at the low order bits */ |
189 | tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | 220 | tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
190 | 221 | ||
222 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
223 | tf->feature = tf_inb(io_ports->feature_addr); | ||
191 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 224 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
192 | tf->nsect = tf_inb(io_ports->nsect_addr); | 225 | tf->nsect = tf_inb(io_ports->nsect_addr); |
193 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | 226 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) |
@@ -214,6 +247,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
214 | tf->hob_lbah = tf_inb(io_ports->lbah_addr); | 247 | tf->hob_lbah = tf_inb(io_ports->lbah_addr); |
215 | } | 248 | } |
216 | } | 249 | } |
250 | EXPORT_SYMBOL_GPL(ide_tf_read); | ||
217 | 251 | ||
218 | /* | 252 | /* |
219 | * Some localbus EIDE interfaces require a special access sequence | 253 | * Some localbus EIDE interfaces require a special access sequence |
@@ -236,8 +270,8 @@ static void ata_vlb_sync(unsigned long port) | |||
236 | * so if an odd len is specified, be sure that there's at least one | 270 | * so if an odd len is specified, be sure that there's at least one |
237 | * extra byte allocated for the buffer. | 271 | * extra byte allocated for the buffer. |
238 | */ | 272 | */ |
239 | static void ata_input_data(ide_drive_t *drive, struct request *rq, | 273 | void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf, |
240 | void *buf, unsigned int len) | 274 | unsigned int len) |
241 | { | 275 | { |
242 | ide_hwif_t *hwif = drive->hwif; | 276 | ide_hwif_t *hwif = drive->hwif; |
243 | struct ide_io_ports *io_ports = &hwif->io_ports; | 277 | struct ide_io_ports *io_ports = &hwif->io_ports; |
@@ -277,12 +311,13 @@ static void ata_input_data(ide_drive_t *drive, struct request *rq, | |||
277 | insw(data_addr, buf, len / 2); | 311 | insw(data_addr, buf, len / 2); |
278 | } | 312 | } |
279 | } | 313 | } |
314 | EXPORT_SYMBOL_GPL(ide_input_data); | ||
280 | 315 | ||
281 | /* | 316 | /* |
282 | * This is used for most PIO data transfers *to* the IDE interface | 317 | * This is used for most PIO data transfers *to* the IDE interface |
283 | */ | 318 | */ |
284 | static void ata_output_data(ide_drive_t *drive, struct request *rq, | 319 | void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf, |
285 | void *buf, unsigned int len) | 320 | unsigned int len) |
286 | { | 321 | { |
287 | ide_hwif_t *hwif = drive->hwif; | 322 | ide_hwif_t *hwif = drive->hwif; |
288 | struct ide_io_ports *io_ports = &hwif->io_ports; | 323 | struct ide_io_ports *io_ports = &hwif->io_ports; |
@@ -320,15 +355,50 @@ static void ata_output_data(ide_drive_t *drive, struct request *rq, | |||
320 | outsw(data_addr, buf, len / 2); | 355 | outsw(data_addr, buf, len / 2); |
321 | } | 356 | } |
322 | } | 357 | } |
358 | EXPORT_SYMBOL_GPL(ide_output_data); | ||
359 | |||
360 | u8 ide_read_error(ide_drive_t *drive) | ||
361 | { | ||
362 | ide_task_t task; | ||
363 | |||
364 | memset(&task, 0, sizeof(task)); | ||
365 | task.tf_flags = IDE_TFLAG_IN_FEATURE; | ||
366 | |||
367 | drive->hwif->tp_ops->tf_read(drive, &task); | ||
368 | |||
369 | return task.tf.error; | ||
370 | } | ||
371 | EXPORT_SYMBOL_GPL(ide_read_error); | ||
323 | 372 | ||
324 | void default_hwif_transport(ide_hwif_t *hwif) | 373 | void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason) |
325 | { | 374 | { |
326 | hwif->tf_load = ide_tf_load; | 375 | ide_task_t task; |
327 | hwif->tf_read = ide_tf_read; | 376 | |
377 | memset(&task, 0, sizeof(task)); | ||
378 | task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM | | ||
379 | IDE_TFLAG_IN_NSECT; | ||
328 | 380 | ||
329 | hwif->input_data = ata_input_data; | 381 | drive->hwif->tp_ops->tf_read(drive, &task); |
330 | hwif->output_data = ata_output_data; | 382 | |
383 | *bcount = (task.tf.lbah << 8) | task.tf.lbam; | ||
384 | *ireason = task.tf.nsect & 3; | ||
331 | } | 385 | } |
386 | EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); | ||
387 | |||
388 | const struct ide_tp_ops default_tp_ops = { | ||
389 | .exec_command = ide_exec_command, | ||
390 | .read_status = ide_read_status, | ||
391 | .read_altstatus = ide_read_altstatus, | ||
392 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
393 | |||
394 | .set_irq = ide_set_irq, | ||
395 | |||
396 | .tf_load = ide_tf_load, | ||
397 | .tf_read = ide_tf_read, | ||
398 | |||
399 | .input_data = ide_input_data, | ||
400 | .output_data = ide_output_data, | ||
401 | }; | ||
332 | 402 | ||
333 | void ide_fix_driveid (struct hd_driveid *id) | 403 | void ide_fix_driveid (struct hd_driveid *id) |
334 | { | 404 | { |
@@ -483,10 +553,10 @@ int drive_is_ready (ide_drive_t *drive) | |||
483 | * about possible isa-pnp and pci-pnp issues yet. | 553 | * about possible isa-pnp and pci-pnp issues yet. |
484 | */ | 554 | */ |
485 | if (hwif->io_ports.ctl_addr) | 555 | if (hwif->io_ports.ctl_addr) |
486 | stat = ide_read_altstatus(drive); | 556 | stat = hwif->tp_ops->read_altstatus(hwif); |
487 | else | 557 | else |
488 | /* Note: this may clear a pending IRQ!! */ | 558 | /* Note: this may clear a pending IRQ!! */ |
489 | stat = ide_read_status(drive); | 559 | stat = hwif->tp_ops->read_status(hwif); |
490 | 560 | ||
491 | if (stat & BUSY_STAT) | 561 | if (stat & BUSY_STAT) |
492 | /* drive busy: definitely not interrupting */ | 562 | /* drive busy: definitely not interrupting */ |
@@ -511,24 +581,26 @@ EXPORT_SYMBOL(drive_is_ready); | |||
511 | */ | 581 | */ |
512 | static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) | 582 | static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) |
513 | { | 583 | { |
584 | ide_hwif_t *hwif = drive->hwif; | ||
585 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
514 | unsigned long flags; | 586 | unsigned long flags; |
515 | int i; | 587 | int i; |
516 | u8 stat; | 588 | u8 stat; |
517 | 589 | ||
518 | udelay(1); /* spec allows drive 400ns to assert "BUSY" */ | 590 | udelay(1); /* spec allows drive 400ns to assert "BUSY" */ |
519 | stat = ide_read_status(drive); | 591 | stat = tp_ops->read_status(hwif); |
520 | 592 | ||
521 | if (stat & BUSY_STAT) { | 593 | if (stat & BUSY_STAT) { |
522 | local_irq_set(flags); | 594 | local_irq_set(flags); |
523 | timeout += jiffies; | 595 | timeout += jiffies; |
524 | while ((stat = ide_read_status(drive)) & BUSY_STAT) { | 596 | while ((stat = tp_ops->read_status(hwif)) & BUSY_STAT) { |
525 | if (time_after(jiffies, timeout)) { | 597 | if (time_after(jiffies, timeout)) { |
526 | /* | 598 | /* |
527 | * One last read after the timeout in case | 599 | * One last read after the timeout in case |
528 | * heavy interrupt load made us not make any | 600 | * heavy interrupt load made us not make any |
529 | * progress during the timeout.. | 601 | * progress during the timeout.. |
530 | */ | 602 | */ |
531 | stat = ide_read_status(drive); | 603 | stat = tp_ops->read_status(hwif); |
532 | if (!(stat & BUSY_STAT)) | 604 | if (!(stat & BUSY_STAT)) |
533 | break; | 605 | break; |
534 | 606 | ||
@@ -548,7 +620,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti | |||
548 | */ | 620 | */ |
549 | for (i = 0; i < 10; i++) { | 621 | for (i = 0; i < 10; i++) { |
550 | udelay(1); | 622 | udelay(1); |
551 | stat = ide_read_status(drive); | 623 | stat = tp_ops->read_status(hwif); |
552 | 624 | ||
553 | if (OK_STAT(stat, good, bad)) { | 625 | if (OK_STAT(stat, good, bad)) { |
554 | *rstat = stat; | 626 | *rstat = stat; |
@@ -674,6 +746,7 @@ no_80w: | |||
674 | int ide_driveid_update(ide_drive_t *drive) | 746 | int ide_driveid_update(ide_drive_t *drive) |
675 | { | 747 | { |
676 | ide_hwif_t *hwif = drive->hwif; | 748 | ide_hwif_t *hwif = drive->hwif; |
749 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
677 | struct hd_driveid *id; | 750 | struct hd_driveid *id; |
678 | unsigned long timeout, flags; | 751 | unsigned long timeout, flags; |
679 | u8 stat; | 752 | u8 stat; |
@@ -684,9 +757,9 @@ int ide_driveid_update(ide_drive_t *drive) | |||
684 | */ | 757 | */ |
685 | 758 | ||
686 | SELECT_MASK(drive, 1); | 759 | SELECT_MASK(drive, 1); |
687 | ide_set_irq(drive, 0); | 760 | tp_ops->set_irq(hwif, 0); |
688 | msleep(50); | 761 | msleep(50); |
689 | hwif->OUTBSYNC(hwif, WIN_IDENTIFY, hwif->io_ports.command_addr); | 762 | tp_ops->exec_command(hwif, WIN_IDENTIFY); |
690 | timeout = jiffies + WAIT_WORSTCASE; | 763 | timeout = jiffies + WAIT_WORSTCASE; |
691 | do { | 764 | do { |
692 | if (time_after(jiffies, timeout)) { | 765 | if (time_after(jiffies, timeout)) { |
@@ -695,11 +768,11 @@ int ide_driveid_update(ide_drive_t *drive) | |||
695 | } | 768 | } |
696 | 769 | ||
697 | msleep(50); /* give drive a breather */ | 770 | msleep(50); /* give drive a breather */ |
698 | stat = ide_read_altstatus(drive); | 771 | stat = tp_ops->read_altstatus(hwif); |
699 | } while (stat & BUSY_STAT); | 772 | } while (stat & BUSY_STAT); |
700 | 773 | ||
701 | msleep(50); /* wait for IRQ and DRQ_STAT */ | 774 | msleep(50); /* wait for IRQ and DRQ_STAT */ |
702 | stat = ide_read_status(drive); | 775 | stat = tp_ops->read_status(hwif); |
703 | 776 | ||
704 | if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { | 777 | if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { |
705 | SELECT_MASK(drive, 0); | 778 | SELECT_MASK(drive, 0); |
@@ -713,8 +786,8 @@ int ide_driveid_update(ide_drive_t *drive) | |||
713 | local_irq_restore(flags); | 786 | local_irq_restore(flags); |
714 | return 0; | 787 | return 0; |
715 | } | 788 | } |
716 | hwif->input_data(drive, NULL, id, SECTOR_SIZE); | 789 | tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); |
717 | (void)ide_read_status(drive); /* clear drive IRQ */ | 790 | (void)tp_ops->read_status(hwif); /* clear drive IRQ */ |
718 | local_irq_enable(); | 791 | local_irq_enable(); |
719 | local_irq_restore(flags); | 792 | local_irq_restore(flags); |
720 | ide_fix_driveid(id); | 793 | ide_fix_driveid(id); |
@@ -735,9 +808,10 @@ int ide_driveid_update(ide_drive_t *drive) | |||
735 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | 808 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) |
736 | { | 809 | { |
737 | ide_hwif_t *hwif = drive->hwif; | 810 | ide_hwif_t *hwif = drive->hwif; |
738 | struct ide_io_ports *io_ports = &hwif->io_ports; | 811 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
739 | int error = 0; | 812 | int error = 0; |
740 | u8 stat; | 813 | u8 stat; |
814 | ide_task_t task; | ||
741 | 815 | ||
742 | #ifdef CONFIG_BLK_DEV_IDEDMA | 816 | #ifdef CONFIG_BLK_DEV_IDEDMA |
743 | if (hwif->dma_ops) /* check if host supports DMA */ | 817 | if (hwif->dma_ops) /* check if host supports DMA */ |
@@ -770,12 +844,19 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
770 | SELECT_DRIVE(drive); | 844 | SELECT_DRIVE(drive); |
771 | SELECT_MASK(drive, 0); | 845 | SELECT_MASK(drive, 0); |
772 | udelay(1); | 846 | udelay(1); |
773 | ide_set_irq(drive, 0); | 847 | tp_ops->set_irq(hwif, 0); |
774 | hwif->OUTB(speed, io_ports->nsect_addr); | 848 | |
775 | hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); | 849 | memset(&task, 0, sizeof(task)); |
776 | hwif->OUTBSYNC(hwif, WIN_SETFEATURES, io_ports->command_addr); | 850 | task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT; |
851 | task.tf.feature = SETFEATURES_XFER; | ||
852 | task.tf.nsect = speed; | ||
853 | |||
854 | tp_ops->tf_load(drive, &task); | ||
855 | |||
856 | tp_ops->exec_command(hwif, WIN_SETFEATURES); | ||
857 | |||
777 | if (drive->quirk_list == 2) | 858 | if (drive->quirk_list == 2) |
778 | ide_set_irq(drive, 1); | 859 | tp_ops->set_irq(hwif, 1); |
779 | 860 | ||
780 | error = __ide_wait_stat(drive, drive->ready_stat, | 861 | error = __ide_wait_stat(drive, drive->ready_stat, |
781 | BUSY_STAT|DRQ_STAT|ERR_STAT, | 862 | BUSY_STAT|DRQ_STAT|ERR_STAT, |
@@ -796,8 +877,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
796 | 877 | ||
797 | skip: | 878 | skip: |
798 | #ifdef CONFIG_BLK_DEV_IDEDMA | 879 | #ifdef CONFIG_BLK_DEV_IDEDMA |
799 | if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && | 880 | if (speed >= XFER_SW_DMA_0 && drive->using_dma) |
800 | drive->using_dma) | ||
801 | hwif->dma_ops->dma_host_set(drive, 1); | 881 | hwif->dma_ops->dma_host_set(drive, 1); |
802 | else if (hwif->dma_ops) /* check if host supports DMA */ | 882 | else if (hwif->dma_ops) /* check if host supports DMA */ |
803 | ide_dma_off_quietly(drive); | 883 | ide_dma_off_quietly(drive); |
@@ -881,7 +961,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
881 | 961 | ||
882 | spin_lock_irqsave(&ide_lock, flags); | 962 | spin_lock_irqsave(&ide_lock, flags); |
883 | __ide_set_handler(drive, handler, timeout, expiry); | 963 | __ide_set_handler(drive, handler, timeout, expiry); |
884 | hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr); | 964 | hwif->tp_ops->exec_command(hwif, cmd); |
885 | /* | 965 | /* |
886 | * Drive takes 400nS to respond, we must avoid the IRQ being | 966 | * Drive takes 400nS to respond, we must avoid the IRQ being |
887 | * serviced before that. | 967 | * serviced before that. |
@@ -899,7 +979,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive) | |||
899 | unsigned long flags; | 979 | unsigned long flags; |
900 | 980 | ||
901 | spin_lock_irqsave(&ide_lock, flags); | 981 | spin_lock_irqsave(&ide_lock, flags); |
902 | hwif->OUTBSYNC(hwif, WIN_PACKETCMD, hwif->io_ports.command_addr); | 982 | hwif->tp_ops->exec_command(hwif, WIN_PACKETCMD); |
903 | ndelay(400); | 983 | ndelay(400); |
904 | spin_unlock_irqrestore(&ide_lock, flags); | 984 | spin_unlock_irqrestore(&ide_lock, flags); |
905 | } | 985 | } |
@@ -924,12 +1004,13 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int); | |||
924 | */ | 1004 | */ |
925 | static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | 1005 | static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) |
926 | { | 1006 | { |
927 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 1007 | ide_hwif_t *hwif = drive->hwif; |
1008 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
928 | u8 stat; | 1009 | u8 stat; |
929 | 1010 | ||
930 | SELECT_DRIVE(drive); | 1011 | SELECT_DRIVE(drive); |
931 | udelay (10); | 1012 | udelay (10); |
932 | stat = ide_read_status(drive); | 1013 | stat = hwif->tp_ops->read_status(hwif); |
933 | 1014 | ||
934 | if (OK_STAT(stat, 0, BUSY_STAT)) | 1015 | if (OK_STAT(stat, 0, BUSY_STAT)) |
935 | printk("%s: ATAPI reset complete\n", drive->name); | 1016 | printk("%s: ATAPI reset complete\n", drive->name); |
@@ -975,7 +1056,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
975 | } | 1056 | } |
976 | } | 1057 | } |
977 | 1058 | ||
978 | tmp = ide_read_status(drive); | 1059 | tmp = hwif->tp_ops->read_status(hwif); |
979 | 1060 | ||
980 | if (!OK_STAT(tmp, 0, BUSY_STAT)) { | 1061 | if (!OK_STAT(tmp, 0, BUSY_STAT)) { |
981 | if (time_before(jiffies, hwgroup->poll_timeout)) { | 1062 | if (time_before(jiffies, hwgroup->poll_timeout)) { |
@@ -1089,8 +1170,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1089 | ide_hwif_t *hwif; | 1170 | ide_hwif_t *hwif; |
1090 | ide_hwgroup_t *hwgroup; | 1171 | ide_hwgroup_t *hwgroup; |
1091 | struct ide_io_ports *io_ports; | 1172 | struct ide_io_ports *io_ports; |
1173 | const struct ide_tp_ops *tp_ops; | ||
1092 | const struct ide_port_ops *port_ops; | 1174 | const struct ide_port_ops *port_ops; |
1093 | u8 ctl; | ||
1094 | 1175 | ||
1095 | spin_lock_irqsave(&ide_lock, flags); | 1176 | spin_lock_irqsave(&ide_lock, flags); |
1096 | hwif = HWIF(drive); | 1177 | hwif = HWIF(drive); |
@@ -1098,6 +1179,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1098 | 1179 | ||
1099 | io_ports = &hwif->io_ports; | 1180 | io_ports = &hwif->io_ports; |
1100 | 1181 | ||
1182 | tp_ops = hwif->tp_ops; | ||
1183 | |||
1101 | /* We must not reset with running handlers */ | 1184 | /* We must not reset with running handlers */ |
1102 | BUG_ON(hwgroup->handler != NULL); | 1185 | BUG_ON(hwgroup->handler != NULL); |
1103 | 1186 | ||
@@ -1106,7 +1189,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1106 | pre_reset(drive); | 1189 | pre_reset(drive); |
1107 | SELECT_DRIVE(drive); | 1190 | SELECT_DRIVE(drive); |
1108 | udelay (20); | 1191 | udelay (20); |
1109 | hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr); | 1192 | tp_ops->exec_command(hwif, WIN_SRST); |
1110 | ndelay(400); | 1193 | ndelay(400); |
1111 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1194 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
1112 | hwgroup->polling = 1; | 1195 | hwgroup->polling = 1; |
@@ -1135,16 +1218,15 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1135 | * immediate interrupt due to the edge transition it produces. | 1218 | * immediate interrupt due to the edge transition it produces. |
1136 | * This single interrupt gives us a "fast poll" for drives that | 1219 | * This single interrupt gives us a "fast poll" for drives that |
1137 | * recover from reset very quickly, saving us the first 50ms wait time. | 1220 | * recover from reset very quickly, saving us the first 50ms wait time. |
1221 | * | ||
1222 | * TODO: add ->softreset method and stop abusing ->set_irq | ||
1138 | */ | 1223 | */ |
1139 | /* set SRST and nIEN */ | 1224 | /* set SRST and nIEN */ |
1140 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | 6, io_ports->ctl_addr); | 1225 | tp_ops->set_irq(hwif, 4); |
1141 | /* more than enough time */ | 1226 | /* more than enough time */ |
1142 | udelay(10); | 1227 | udelay(10); |
1143 | if (drive->quirk_list == 2) | 1228 | /* clear SRST, leave nIEN (unless device is on the quirk list) */ |
1144 | ctl = ATA_DEVCTL_OBS; /* clear SRST and nIEN */ | 1229 | tp_ops->set_irq(hwif, drive->quirk_list == 2); |
1145 | else | ||
1146 | ctl = ATA_DEVCTL_OBS | 2; /* clear SRST, leave nIEN */ | ||
1147 | hwif->OUTBSYNC(hwif, ctl, io_ports->ctl_addr); | ||
1148 | /* more than enough time */ | 1230 | /* more than enough time */ |
1149 | udelay(10); | 1231 | udelay(10); |
1150 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1232 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
@@ -1189,7 +1271,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) | |||
1189 | * about locking issues (2.5 work ?). | 1271 | * about locking issues (2.5 work ?). |
1190 | */ | 1272 | */ |
1191 | mdelay(1); | 1273 | mdelay(1); |
1192 | stat = hwif->INB(hwif->io_ports.status_addr); | 1274 | stat = hwif->tp_ops->read_status(hwif); |
1193 | if ((stat & BUSY_STAT) == 0) | 1275 | if ((stat & BUSY_STAT) == 0) |
1194 | return 0; | 1276 | return 0; |
1195 | /* | 1277 | /* |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 13af72f09ec4..97fefabea8b8 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -266,22 +266,11 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) | |||
266 | 266 | ||
267 | rate = ide_rate_filter(drive, rate); | 267 | rate = ide_rate_filter(drive, rate); |
268 | 268 | ||
269 | BUG_ON(rate < XFER_PIO_0); | ||
270 | |||
269 | if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5) | 271 | if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5) |
270 | return ide_set_pio_mode(drive, rate); | 272 | return ide_set_pio_mode(drive, rate); |
271 | 273 | ||
272 | /* | ||
273 | * TODO: transfer modes 0x00-0x07 passed from the user-space are | ||
274 | * currently handled here which needs fixing (please note that such | ||
275 | * case could happen iff the transfer mode has already been set on | ||
276 | * the device by ide-proc.c::set_xfer_rate()). | ||
277 | */ | ||
278 | if (rate < XFER_PIO_0) { | ||
279 | if (hwif->host_flags & IDE_HFLAG_ABUSE_SET_DMA_MODE) | ||
280 | return ide_set_dma_mode(drive, rate); | ||
281 | else | ||
282 | return ide_config_drive_speed(drive, rate); | ||
283 | } | ||
284 | |||
285 | return ide_set_dma_mode(drive, rate); | 274 | return ide_set_dma_mode(drive, rate); |
286 | } | 275 | } |
287 | 276 | ||
@@ -336,7 +325,7 @@ static void ide_dump_sector(ide_drive_t *drive) | |||
336 | else | 325 | else |
337 | task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE; | 326 | task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE; |
338 | 327 | ||
339 | drive->hwif->tf_read(drive, &task); | 328 | drive->hwif->tp_ops->tf_read(drive, &task); |
340 | 329 | ||
341 | if (lba48 || (tf->device & ATA_LBA)) | 330 | if (lba48 || (tf->device & ATA_LBA)) |
342 | printk(", LBAsect=%llu", | 331 | printk(", LBAsect=%llu", |
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index 03f2ef5470a3..bac9b392b689 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
@@ -29,9 +29,10 @@ static struct pnp_device_id idepnp_devices[] = { | |||
29 | 29 | ||
30 | static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | 30 | static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) |
31 | { | 31 | { |
32 | hw_regs_t hw; | 32 | struct ide_host *host; |
33 | ide_hwif_t *hwif; | ||
34 | unsigned long base, ctl; | 33 | unsigned long base, ctl; |
34 | int rc; | ||
35 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | ||
35 | 36 | ||
36 | printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); | 37 | printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); |
37 | 38 | ||
@@ -59,31 +60,25 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
59 | hw.irq = pnp_irq(dev, 0); | 60 | hw.irq = pnp_irq(dev, 0); |
60 | hw.chipset = ide_generic; | 61 | hw.chipset = ide_generic; |
61 | 62 | ||
62 | hwif = ide_find_port(); | 63 | rc = ide_host_add(NULL, hws, &host); |
63 | if (hwif) { | 64 | if (rc) |
64 | u8 index = hwif->index; | 65 | goto out; |
65 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | ||
66 | 66 | ||
67 | ide_init_port_hw(hwif, &hw); | 67 | pnp_set_drvdata(dev, host); |
68 | |||
69 | pnp_set_drvdata(dev, hwif); | ||
70 | |||
71 | ide_device_add(idx, NULL); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | 68 | ||
69 | return 0; | ||
70 | out: | ||
76 | release_region(ctl, 1); | 71 | release_region(ctl, 1); |
77 | release_region(base, 8); | 72 | release_region(base, 8); |
78 | 73 | ||
79 | return -1; | 74 | return rc; |
80 | } | 75 | } |
81 | 76 | ||
82 | static void idepnp_remove(struct pnp_dev *dev) | 77 | static void idepnp_remove(struct pnp_dev *dev) |
83 | { | 78 | { |
84 | ide_hwif_t *hwif = pnp_get_drvdata(dev); | 79 | struct ide_host *host = pnp_get_drvdata(dev); |
85 | 80 | ||
86 | ide_unregister(hwif); | 81 | ide_host_remove(host); |
87 | 82 | ||
88 | release_region(pnp_port_start(dev, 1), 1); | 83 | release_region(pnp_port_start(dev, 1), 1); |
89 | release_region(pnp_port_start(dev, 0), 8); | 84 | release_region(pnp_port_start(dev, 0), 8); |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 235ebdb29b28..4aa76c453755 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -39,8 +39,6 @@ | |||
39 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | 41 | ||
42 | static ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ | ||
43 | |||
44 | /** | 42 | /** |
45 | * generic_id - add a generic drive id | 43 | * generic_id - add a generic drive id |
46 | * @drive: drive to make an ID block for | 44 | * @drive: drive to make an ID block for |
@@ -126,7 +124,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
126 | 124 | ||
127 | id = drive->id; | 125 | id = drive->id; |
128 | /* read 512 bytes of id info */ | 126 | /* read 512 bytes of id info */ |
129 | hwif->input_data(drive, NULL, id, SECTOR_SIZE); | 127 | hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); |
130 | 128 | ||
131 | drive->id_read = 1; | 129 | drive->id_read = 1; |
132 | local_irq_enable(); | 130 | local_irq_enable(); |
@@ -267,6 +265,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
267 | { | 265 | { |
268 | ide_hwif_t *hwif = HWIF(drive); | 266 | ide_hwif_t *hwif = HWIF(drive); |
269 | struct ide_io_ports *io_ports = &hwif->io_ports; | 267 | struct ide_io_ports *io_ports = &hwif->io_ports; |
268 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
270 | int use_altstatus = 0, rc; | 269 | int use_altstatus = 0, rc; |
271 | unsigned long timeout; | 270 | unsigned long timeout; |
272 | u8 s = 0, a = 0; | 271 | u8 s = 0, a = 0; |
@@ -275,8 +274,8 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
275 | msleep(50); | 274 | msleep(50); |
276 | 275 | ||
277 | if (io_ports->ctl_addr) { | 276 | if (io_ports->ctl_addr) { |
278 | a = ide_read_altstatus(drive); | 277 | a = tp_ops->read_altstatus(hwif); |
279 | s = ide_read_status(drive); | 278 | s = tp_ops->read_status(hwif); |
280 | if ((a ^ s) & ~INDEX_STAT) | 279 | if ((a ^ s) & ~INDEX_STAT) |
281 | /* ancient Seagate drives, broken interfaces */ | 280 | /* ancient Seagate drives, broken interfaces */ |
282 | printk(KERN_INFO "%s: probing with STATUS(0x%02x) " | 281 | printk(KERN_INFO "%s: probing with STATUS(0x%02x) " |
@@ -290,12 +289,18 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
290 | /* set features register for atapi | 289 | /* set features register for atapi |
291 | * identify command to be sure of reply | 290 | * identify command to be sure of reply |
292 | */ | 291 | */ |
293 | if ((cmd == WIN_PIDENTIFY)) | 292 | if (cmd == WIN_PIDENTIFY) { |
294 | /* disable dma & overlap */ | 293 | ide_task_t task; |
295 | hwif->OUTB(0, io_ports->feature_addr); | 294 | |
295 | memset(&task, 0, sizeof(task)); | ||
296 | /* disable DMA & overlap */ | ||
297 | task.tf_flags = IDE_TFLAG_OUT_FEATURE; | ||
298 | |||
299 | tp_ops->tf_load(drive, &task); | ||
300 | } | ||
296 | 301 | ||
297 | /* ask drive for ID */ | 302 | /* ask drive for ID */ |
298 | hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr); | 303 | tp_ops->exec_command(hwif, cmd); |
299 | 304 | ||
300 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 305 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
301 | timeout += jiffies; | 306 | timeout += jiffies; |
@@ -306,13 +311,13 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
306 | } | 311 | } |
307 | /* give drive a breather */ | 312 | /* give drive a breather */ |
308 | msleep(50); | 313 | msleep(50); |
309 | s = use_altstatus ? ide_read_altstatus(drive) | 314 | s = use_altstatus ? tp_ops->read_altstatus(hwif) |
310 | : ide_read_status(drive); | 315 | : tp_ops->read_status(hwif); |
311 | } while (s & BUSY_STAT); | 316 | } while (s & BUSY_STAT); |
312 | 317 | ||
313 | /* wait for IRQ and DRQ_STAT */ | 318 | /* wait for IRQ and DRQ_STAT */ |
314 | msleep(50); | 319 | msleep(50); |
315 | s = ide_read_status(drive); | 320 | s = tp_ops->read_status(hwif); |
316 | 321 | ||
317 | if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) { | 322 | if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) { |
318 | unsigned long flags; | 323 | unsigned long flags; |
@@ -324,7 +329,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
324 | /* drive responded with ID */ | 329 | /* drive responded with ID */ |
325 | rc = 0; | 330 | rc = 0; |
326 | /* clear drive IRQ */ | 331 | /* clear drive IRQ */ |
327 | (void)ide_read_status(drive); | 332 | (void)tp_ops->read_status(hwif); |
328 | local_irq_restore(flags); | 333 | local_irq_restore(flags); |
329 | } else { | 334 | } else { |
330 | /* drive refused ID */ | 335 | /* drive refused ID */ |
@@ -346,6 +351,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
346 | static int try_to_identify (ide_drive_t *drive, u8 cmd) | 351 | static int try_to_identify (ide_drive_t *drive, u8 cmd) |
347 | { | 352 | { |
348 | ide_hwif_t *hwif = HWIF(drive); | 353 | ide_hwif_t *hwif = HWIF(drive); |
354 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
349 | int retval; | 355 | int retval; |
350 | int autoprobe = 0; | 356 | int autoprobe = 0; |
351 | unsigned long cookie = 0; | 357 | unsigned long cookie = 0; |
@@ -361,7 +367,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
361 | autoprobe = 1; | 367 | autoprobe = 1; |
362 | cookie = probe_irq_on(); | 368 | cookie = probe_irq_on(); |
363 | } | 369 | } |
364 | ide_set_irq(drive, autoprobe); | 370 | tp_ops->set_irq(hwif, autoprobe); |
365 | } | 371 | } |
366 | 372 | ||
367 | retval = actual_try_to_identify(drive, cmd); | 373 | retval = actual_try_to_identify(drive, cmd); |
@@ -369,9 +375,9 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
369 | if (autoprobe) { | 375 | if (autoprobe) { |
370 | int irq; | 376 | int irq; |
371 | 377 | ||
372 | ide_set_irq(drive, 0); | 378 | tp_ops->set_irq(hwif, 0); |
373 | /* clear drive IRQ */ | 379 | /* clear drive IRQ */ |
374 | (void)ide_read_status(drive); | 380 | (void)tp_ops->read_status(hwif); |
375 | udelay(5); | 381 | udelay(5); |
376 | irq = probe_irq_off(cookie); | 382 | irq = probe_irq_off(cookie); |
377 | if (!hwif->irq) { | 383 | if (!hwif->irq) { |
@@ -396,7 +402,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
396 | 402 | ||
397 | do { | 403 | do { |
398 | msleep(50); | 404 | msleep(50); |
399 | stat = hwif->INB(hwif->io_ports.status_addr); | 405 | stat = hwif->tp_ops->read_status(hwif); |
400 | if ((stat & BUSY_STAT) == 0) | 406 | if ((stat & BUSY_STAT) == 0) |
401 | return 0; | 407 | return 0; |
402 | } while (time_before(jiffies, timeout)); | 408 | } while (time_before(jiffies, timeout)); |
@@ -404,6 +410,18 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
404 | return 1; | 410 | return 1; |
405 | } | 411 | } |
406 | 412 | ||
413 | static u8 ide_read_device(ide_drive_t *drive) | ||
414 | { | ||
415 | ide_task_t task; | ||
416 | |||
417 | memset(&task, 0, sizeof(task)); | ||
418 | task.tf_flags = IDE_TFLAG_IN_DEVICE; | ||
419 | |||
420 | drive->hwif->tp_ops->tf_read(drive, &task); | ||
421 | |||
422 | return task.tf.device; | ||
423 | } | ||
424 | |||
407 | /** | 425 | /** |
408 | * do_probe - probe an IDE device | 426 | * do_probe - probe an IDE device |
409 | * @drive: drive to probe | 427 | * @drive: drive to probe |
@@ -428,7 +446,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
428 | static int do_probe (ide_drive_t *drive, u8 cmd) | 446 | static int do_probe (ide_drive_t *drive, u8 cmd) |
429 | { | 447 | { |
430 | ide_hwif_t *hwif = HWIF(drive); | 448 | ide_hwif_t *hwif = HWIF(drive); |
431 | struct ide_io_ports *io_ports = &hwif->io_ports; | 449 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
432 | int rc; | 450 | int rc; |
433 | u8 stat; | 451 | u8 stat; |
434 | 452 | ||
@@ -449,8 +467,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
449 | msleep(50); | 467 | msleep(50); |
450 | SELECT_DRIVE(drive); | 468 | SELECT_DRIVE(drive); |
451 | msleep(50); | 469 | msleep(50); |
452 | if (hwif->INB(io_ports->device_addr) != drive->select.all && | 470 | |
453 | !drive->present) { | 471 | if (ide_read_device(drive) != drive->select.all && !drive->present) { |
454 | if (drive->select.b.unit != 0) { | 472 | if (drive->select.b.unit != 0) { |
455 | /* exit with drive0 selected */ | 473 | /* exit with drive0 selected */ |
456 | SELECT_DRIVE(&hwif->drives[0]); | 474 | SELECT_DRIVE(&hwif->drives[0]); |
@@ -461,7 +479,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
461 | return 3; | 479 | return 3; |
462 | } | 480 | } |
463 | 481 | ||
464 | stat = ide_read_status(drive); | 482 | stat = tp_ops->read_status(hwif); |
465 | 483 | ||
466 | if (OK_STAT(stat, READY_STAT, BUSY_STAT) || | 484 | if (OK_STAT(stat, READY_STAT, BUSY_STAT) || |
467 | drive->present || cmd == WIN_PIDENTIFY) { | 485 | drive->present || cmd == WIN_PIDENTIFY) { |
@@ -471,7 +489,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
471 | rc = try_to_identify(drive,cmd); | 489 | rc = try_to_identify(drive,cmd); |
472 | } | 490 | } |
473 | 491 | ||
474 | stat = ide_read_status(drive); | 492 | stat = tp_ops->read_status(hwif); |
475 | 493 | ||
476 | if (stat == (BUSY_STAT | READY_STAT)) | 494 | if (stat == (BUSY_STAT | READY_STAT)) |
477 | return 4; | 495 | return 4; |
@@ -482,13 +500,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
482 | msleep(50); | 500 | msleep(50); |
483 | SELECT_DRIVE(drive); | 501 | SELECT_DRIVE(drive); |
484 | msleep(50); | 502 | msleep(50); |
485 | hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr); | 503 | tp_ops->exec_command(hwif, WIN_SRST); |
486 | (void)ide_busy_sleep(hwif); | 504 | (void)ide_busy_sleep(hwif); |
487 | rc = try_to_identify(drive, cmd); | 505 | rc = try_to_identify(drive, cmd); |
488 | } | 506 | } |
489 | 507 | ||
490 | /* ensure drive IRQ is clear */ | 508 | /* ensure drive IRQ is clear */ |
491 | stat = ide_read_status(drive); | 509 | stat = tp_ops->read_status(hwif); |
492 | 510 | ||
493 | if (rc == 1) | 511 | if (rc == 1) |
494 | printk(KERN_ERR "%s: no response (status = 0x%02x)\n", | 512 | printk(KERN_ERR "%s: no response (status = 0x%02x)\n", |
@@ -502,7 +520,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
502 | SELECT_DRIVE(&hwif->drives[0]); | 520 | SELECT_DRIVE(&hwif->drives[0]); |
503 | msleep(50); | 521 | msleep(50); |
504 | /* ensure drive irq is clear */ | 522 | /* ensure drive irq is clear */ |
505 | (void)ide_read_status(drive); | 523 | (void)tp_ops->read_status(hwif); |
506 | } | 524 | } |
507 | return rc; | 525 | return rc; |
508 | } | 526 | } |
@@ -513,12 +531,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
513 | static void enable_nest (ide_drive_t *drive) | 531 | static void enable_nest (ide_drive_t *drive) |
514 | { | 532 | { |
515 | ide_hwif_t *hwif = HWIF(drive); | 533 | ide_hwif_t *hwif = HWIF(drive); |
534 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
516 | u8 stat; | 535 | u8 stat; |
517 | 536 | ||
518 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 537 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); |
519 | SELECT_DRIVE(drive); | 538 | SELECT_DRIVE(drive); |
520 | msleep(50); | 539 | msleep(50); |
521 | hwif->OUTBSYNC(hwif, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); | 540 | tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST); |
522 | 541 | ||
523 | if (ide_busy_sleep(hwif)) { | 542 | if (ide_busy_sleep(hwif)) { |
524 | printk(KERN_CONT "failed (timeout)\n"); | 543 | printk(KERN_CONT "failed (timeout)\n"); |
@@ -527,7 +546,7 @@ static void enable_nest (ide_drive_t *drive) | |||
527 | 546 | ||
528 | msleep(50); | 547 | msleep(50); |
529 | 548 | ||
530 | stat = ide_read_status(drive); | 549 | stat = tp_ops->read_status(hwif); |
531 | 550 | ||
532 | if (!OK_STAT(stat, 0, BAD_STAT)) | 551 | if (!OK_STAT(stat, 0, BAD_STAT)) |
533 | printk(KERN_CONT "failed (status = 0x%02x)\n", stat); | 552 | printk(KERN_CONT "failed (status = 0x%02x)\n", stat); |
@@ -619,7 +638,7 @@ static inline u8 probe_for_drive (ide_drive_t *drive) | |||
619 | return drive->present; | 638 | return drive->present; |
620 | } | 639 | } |
621 | 640 | ||
622 | static void hwif_release_dev (struct device *dev) | 641 | static void hwif_release_dev(struct device *dev) |
623 | { | 642 | { |
624 | ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); | 643 | ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); |
625 | 644 | ||
@@ -709,7 +728,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif) | |||
709 | /* Ignore disks that we will not probe for later. */ | 728 | /* Ignore disks that we will not probe for later. */ |
710 | if (!drive->noprobe || drive->present) { | 729 | if (!drive->noprobe || drive->present) { |
711 | SELECT_DRIVE(drive); | 730 | SELECT_DRIVE(drive); |
712 | ide_set_irq(drive, 1); | 731 | hwif->tp_ops->set_irq(hwif, 1); |
713 | mdelay(2); | 732 | mdelay(2); |
714 | rc = ide_wait_not_busy(hwif, 35000); | 733 | rc = ide_wait_not_busy(hwif, 35000); |
715 | if (rc) | 734 | if (rc) |
@@ -971,6 +990,45 @@ static void ide_port_setup_devices(ide_hwif_t *hwif) | |||
971 | mutex_unlock(&ide_cfg_mtx); | 990 | mutex_unlock(&ide_cfg_mtx); |
972 | } | 991 | } |
973 | 992 | ||
993 | static ide_hwif_t *ide_ports[MAX_HWIFS]; | ||
994 | |||
995 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | ||
996 | { | ||
997 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
998 | |||
999 | ide_ports[hwif->index] = NULL; | ||
1000 | |||
1001 | spin_lock_irq(&ide_lock); | ||
1002 | /* | ||
1003 | * Remove us from the hwgroup, and free | ||
1004 | * the hwgroup if we were the only member | ||
1005 | */ | ||
1006 | if (hwif->next == hwif) { | ||
1007 | BUG_ON(hwgroup->hwif != hwif); | ||
1008 | kfree(hwgroup); | ||
1009 | } else { | ||
1010 | /* There is another interface in hwgroup. | ||
1011 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
1012 | * something sane. | ||
1013 | */ | ||
1014 | ide_hwif_t *g = hwgroup->hwif; | ||
1015 | |||
1016 | while (g->next != hwif) | ||
1017 | g = g->next; | ||
1018 | g->next = hwif->next; | ||
1019 | if (hwgroup->hwif == hwif) { | ||
1020 | /* Chose a random hwif for hwgroup->hwif. | ||
1021 | * It's guaranteed that there are no drives | ||
1022 | * left in the hwgroup. | ||
1023 | */ | ||
1024 | BUG_ON(hwgroup->drive != NULL); | ||
1025 | hwgroup->hwif = g; | ||
1026 | } | ||
1027 | BUG_ON(hwgroup->hwif == hwif); | ||
1028 | } | ||
1029 | spin_unlock_irq(&ide_lock); | ||
1030 | } | ||
1031 | |||
974 | /* | 1032 | /* |
975 | * This routine sets up the irq for an ide interface, and creates a new | 1033 | * This routine sets up the irq for an ide interface, and creates a new |
976 | * hwgroup for the irq/hwif if none was previously assigned. | 1034 | * hwgroup for the irq/hwif if none was previously assigned. |
@@ -998,8 +1056,9 @@ static int init_irq (ide_hwif_t *hwif) | |||
998 | * Group up with any other hwifs that share our irq(s). | 1056 | * Group up with any other hwifs that share our irq(s). |
999 | */ | 1057 | */ |
1000 | for (index = 0; index < MAX_HWIFS; index++) { | 1058 | for (index = 0; index < MAX_HWIFS; index++) { |
1001 | ide_hwif_t *h = &ide_hwifs[index]; | 1059 | ide_hwif_t *h = ide_ports[index]; |
1002 | if (h->hwgroup) { /* scan only initialized hwif's */ | 1060 | |
1061 | if (h && h->hwgroup) { /* scan only initialized ports */ | ||
1003 | if (hwif->irq == h->irq) { | 1062 | if (hwif->irq == h->irq) { |
1004 | hwif->sharing_irq = h->sharing_irq = 1; | 1063 | hwif->sharing_irq = h->sharing_irq = 1; |
1005 | if (hwif->chipset != ide_pci || | 1064 | if (hwif->chipset != ide_pci || |
@@ -1053,6 +1112,8 @@ static int init_irq (ide_hwif_t *hwif) | |||
1053 | hwgroup->timer.data = (unsigned long) hwgroup; | 1112 | hwgroup->timer.data = (unsigned long) hwgroup; |
1054 | } | 1113 | } |
1055 | 1114 | ||
1115 | ide_ports[hwif->index] = hwif; | ||
1116 | |||
1056 | /* | 1117 | /* |
1057 | * Allocate the irq, if not already obtained for another hwif | 1118 | * Allocate the irq, if not already obtained for another hwif |
1058 | */ | 1119 | */ |
@@ -1066,8 +1127,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
1066 | sa = IRQF_SHARED; | 1127 | sa = IRQF_SHARED; |
1067 | 1128 | ||
1068 | if (io_ports->ctl_addr) | 1129 | if (io_ports->ctl_addr) |
1069 | /* clear nIEN */ | 1130 | hwif->tp_ops->set_irq(hwif, 1); |
1070 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS, io_ports->ctl_addr); | ||
1071 | 1131 | ||
1072 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) | 1132 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) |
1073 | goto out_unlink; | 1133 | goto out_unlink; |
@@ -1345,6 +1405,9 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1345 | hwif->host_flags |= d->host_flags; | 1405 | hwif->host_flags |= d->host_flags; |
1346 | hwif->pio_mask = d->pio_mask; | 1406 | hwif->pio_mask = d->pio_mask; |
1347 | 1407 | ||
1408 | if (d->tp_ops) | ||
1409 | hwif->tp_ops = d->tp_ops; | ||
1410 | |||
1348 | /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ | 1411 | /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ |
1349 | if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) | 1412 | if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) |
1350 | hwif->port_ops = d->port_ops; | 1413 | hwif->port_ops = d->port_ops; |
@@ -1363,6 +1426,7 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1363 | 1426 | ||
1364 | if (rc < 0) { | 1427 | if (rc < 0) { |
1365 | printk(KERN_INFO "%s: DMA disabled\n", hwif->name); | 1428 | printk(KERN_INFO "%s: DMA disabled\n", hwif->name); |
1429 | hwif->dma_base = 0; | ||
1366 | hwif->swdma_mask = 0; | 1430 | hwif->swdma_mask = 0; |
1367 | hwif->mwdma_mask = 0; | 1431 | hwif->mwdma_mask = 0; |
1368 | hwif->ultra_mask = 0; | 1432 | hwif->ultra_mask = 0; |
@@ -1446,18 +1510,20 @@ static int ide_sysfs_register_port(ide_hwif_t *hwif) | |||
1446 | return rc; | 1510 | return rc; |
1447 | } | 1511 | } |
1448 | 1512 | ||
1513 | static unsigned int ide_indexes; | ||
1514 | |||
1449 | /** | 1515 | /** |
1450 | * ide_find_port_slot - find free ide_hwifs[] slot | 1516 | * ide_find_port_slot - find free port slot |
1451 | * @d: IDE port info | 1517 | * @d: IDE port info |
1452 | * | 1518 | * |
1453 | * Return the new hwif. If we are out of free slots return NULL. | 1519 | * Return the new port slot index or -ENOENT if we are out of free slots. |
1454 | */ | 1520 | */ |
1455 | 1521 | ||
1456 | ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d) | 1522 | static int ide_find_port_slot(const struct ide_port_info *d) |
1457 | { | 1523 | { |
1458 | ide_hwif_t *hwif; | 1524 | int idx = -ENOENT; |
1459 | int i; | ||
1460 | u8 bootable = (d && (d->host_flags & IDE_HFLAG_NON_BOOTABLE)) ? 0 : 1; | 1525 | u8 bootable = (d && (d->host_flags & IDE_HFLAG_NON_BOOTABLE)) ? 0 : 1; |
1526 | u8 i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0;; | ||
1461 | 1527 | ||
1462 | /* | 1528 | /* |
1463 | * Claim an unassigned slot. | 1529 | * Claim an unassigned slot. |
@@ -1469,51 +1535,106 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d) | |||
1469 | * Unless there is a bootable card that does not use the standard | 1535 | * Unless there is a bootable card that does not use the standard |
1470 | * ports 0x1f0/0x170 (the ide0/ide1 defaults). | 1536 | * ports 0x1f0/0x170 (the ide0/ide1 defaults). |
1471 | */ | 1537 | */ |
1472 | if (bootable) { | 1538 | mutex_lock(&ide_cfg_mtx); |
1473 | i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0; | 1539 | if (MAX_HWIFS == 1) { |
1474 | 1540 | if (ide_indexes == 0 && i == 0) | |
1475 | for (; i < MAX_HWIFS; i++) { | 1541 | idx = 1; |
1476 | hwif = &ide_hwifs[i]; | ||
1477 | if (hwif->chipset == ide_unknown) | ||
1478 | goto out_found; | ||
1479 | } | ||
1480 | } else { | 1542 | } else { |
1481 | for (i = 2; i < MAX_HWIFS; i++) { | 1543 | if (bootable) { |
1482 | hwif = &ide_hwifs[i]; | 1544 | if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1) |
1483 | if (hwif->chipset == ide_unknown) | 1545 | idx = ffz(ide_indexes | i); |
1484 | goto out_found; | 1546 | } else { |
1547 | if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1) | ||
1548 | idx = ffz(ide_indexes | 3); | ||
1549 | else if ((ide_indexes & 3) != 3) | ||
1550 | idx = ffz(ide_indexes); | ||
1485 | } | 1551 | } |
1486 | for (i = 0; i < 2 && i < MAX_HWIFS; i++) { | 1552 | } |
1487 | hwif = &ide_hwifs[i]; | 1553 | if (idx >= 0) |
1488 | if (hwif->chipset == ide_unknown) | 1554 | ide_indexes |= (1 << idx); |
1489 | goto out_found; | 1555 | mutex_unlock(&ide_cfg_mtx); |
1556 | |||
1557 | return idx; | ||
1558 | } | ||
1559 | |||
1560 | static void ide_free_port_slot(int idx) | ||
1561 | { | ||
1562 | mutex_lock(&ide_cfg_mtx); | ||
1563 | ide_indexes &= ~(1 << idx); | ||
1564 | mutex_unlock(&ide_cfg_mtx); | ||
1565 | } | ||
1566 | |||
1567 | struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | ||
1568 | hw_regs_t **hws) | ||
1569 | { | ||
1570 | struct ide_host *host; | ||
1571 | int i; | ||
1572 | |||
1573 | host = kzalloc(sizeof(*host), GFP_KERNEL); | ||
1574 | if (host == NULL) | ||
1575 | return NULL; | ||
1576 | |||
1577 | for (i = 0; i < MAX_HWIFS; i++) { | ||
1578 | ide_hwif_t *hwif; | ||
1579 | int idx; | ||
1580 | |||
1581 | if (hws[i] == NULL) | ||
1582 | continue; | ||
1583 | |||
1584 | hwif = kzalloc(sizeof(*hwif), GFP_KERNEL); | ||
1585 | if (hwif == NULL) | ||
1586 | continue; | ||
1587 | |||
1588 | idx = ide_find_port_slot(d); | ||
1589 | if (idx < 0) { | ||
1590 | printk(KERN_ERR "%s: no free slot for interface\n", | ||
1591 | d ? d->name : "ide"); | ||
1592 | kfree(hwif); | ||
1593 | continue; | ||
1490 | } | 1594 | } |
1595 | |||
1596 | ide_init_port_data(hwif, idx); | ||
1597 | |||
1598 | host->ports[i] = hwif; | ||
1599 | host->n_ports++; | ||
1491 | } | 1600 | } |
1492 | 1601 | ||
1493 | printk(KERN_ERR "%s: no free slot for interface\n", | 1602 | if (host->n_ports == 0) { |
1494 | d ? d->name : "ide"); | 1603 | kfree(host); |
1604 | return NULL; | ||
1605 | } | ||
1495 | 1606 | ||
1496 | return NULL; | 1607 | return host; |
1608 | } | ||
1609 | EXPORT_SYMBOL_GPL(ide_host_alloc_all); | ||
1610 | |||
1611 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | ||
1612 | { | ||
1613 | hw_regs_t *hws_all[MAX_HWIFS]; | ||
1614 | int i; | ||
1497 | 1615 | ||
1498 | out_found: | 1616 | for (i = 0; i < MAX_HWIFS; i++) |
1499 | ide_init_port_data(hwif, i); | 1617 | hws_all[i] = (i < 4) ? hws[i] : NULL; |
1500 | return hwif; | 1618 | |
1619 | return ide_host_alloc_all(d, hws_all); | ||
1501 | } | 1620 | } |
1502 | EXPORT_SYMBOL_GPL(ide_find_port_slot); | 1621 | EXPORT_SYMBOL_GPL(ide_host_alloc); |
1503 | 1622 | ||
1504 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | 1623 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, |
1624 | hw_regs_t **hws) | ||
1505 | { | 1625 | { |
1506 | ide_hwif_t *hwif, *mate = NULL; | 1626 | ide_hwif_t *hwif, *mate = NULL; |
1507 | int i, rc = 0; | 1627 | int i, j = 0; |
1508 | 1628 | ||
1509 | for (i = 0; i < MAX_HWIFS; i++) { | 1629 | for (i = 0; i < MAX_HWIFS; i++) { |
1510 | if (idx[i] == 0xff) { | 1630 | hwif = host->ports[i]; |
1631 | |||
1632 | if (hwif == NULL) { | ||
1511 | mate = NULL; | 1633 | mate = NULL; |
1512 | continue; | 1634 | continue; |
1513 | } | 1635 | } |
1514 | 1636 | ||
1515 | hwif = &ide_hwifs[idx[i]]; | 1637 | ide_init_port_hw(hwif, hws[i]); |
1516 | |||
1517 | ide_port_apply_params(hwif); | 1638 | ide_port_apply_params(hwif); |
1518 | 1639 | ||
1519 | if (d == NULL) { | 1640 | if (d == NULL) { |
@@ -1534,10 +1655,10 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1534 | } | 1655 | } |
1535 | 1656 | ||
1536 | for (i = 0; i < MAX_HWIFS; i++) { | 1657 | for (i = 0; i < MAX_HWIFS; i++) { |
1537 | if (idx[i] == 0xff) | 1658 | hwif = host->ports[i]; |
1538 | continue; | ||
1539 | 1659 | ||
1540 | hwif = &ide_hwifs[idx[i]]; | 1660 | if (hwif == NULL) |
1661 | continue; | ||
1541 | 1662 | ||
1542 | if (ide_probe_port(hwif) == 0) | 1663 | if (ide_probe_port(hwif) == 0) |
1543 | hwif->present = 1; | 1664 | hwif->present = 1; |
@@ -1551,19 +1672,20 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1551 | } | 1672 | } |
1552 | 1673 | ||
1553 | for (i = 0; i < MAX_HWIFS; i++) { | 1674 | for (i = 0; i < MAX_HWIFS; i++) { |
1554 | if (idx[i] == 0xff) | 1675 | hwif = host->ports[i]; |
1555 | continue; | ||
1556 | 1676 | ||
1557 | hwif = &ide_hwifs[idx[i]]; | 1677 | if (hwif == NULL) |
1678 | continue; | ||
1558 | 1679 | ||
1559 | if (hwif_init(hwif) == 0) { | 1680 | if (hwif_init(hwif) == 0) { |
1560 | printk(KERN_INFO "%s: failed to initialize IDE " | 1681 | printk(KERN_INFO "%s: failed to initialize IDE " |
1561 | "interface\n", hwif->name); | 1682 | "interface\n", hwif->name); |
1562 | hwif->present = 0; | 1683 | hwif->present = 0; |
1563 | rc = -1; | ||
1564 | continue; | 1684 | continue; |
1565 | } | 1685 | } |
1566 | 1686 | ||
1687 | j++; | ||
1688 | |||
1567 | if (hwif->present) | 1689 | if (hwif->present) |
1568 | ide_port_setup_devices(hwif); | 1690 | ide_port_setup_devices(hwif); |
1569 | 1691 | ||
@@ -1574,10 +1696,10 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1574 | } | 1696 | } |
1575 | 1697 | ||
1576 | for (i = 0; i < MAX_HWIFS; i++) { | 1698 | for (i = 0; i < MAX_HWIFS; i++) { |
1577 | if (idx[i] == 0xff) | 1699 | hwif = host->ports[i]; |
1578 | continue; | ||
1579 | 1700 | ||
1580 | hwif = &ide_hwifs[idx[i]]; | 1701 | if (hwif == NULL) |
1702 | continue; | ||
1581 | 1703 | ||
1582 | if (hwif->chipset == ide_unknown) | 1704 | if (hwif->chipset == ide_unknown) |
1583 | hwif->chipset = ide_generic; | 1705 | hwif->chipset = ide_generic; |
@@ -1587,10 +1709,10 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1587 | } | 1709 | } |
1588 | 1710 | ||
1589 | for (i = 0; i < MAX_HWIFS; i++) { | 1711 | for (i = 0; i < MAX_HWIFS; i++) { |
1590 | if (idx[i] == 0xff) | 1712 | hwif = host->ports[i]; |
1591 | continue; | ||
1592 | 1713 | ||
1593 | hwif = &ide_hwifs[idx[i]]; | 1714 | if (hwif == NULL) |
1715 | continue; | ||
1594 | 1716 | ||
1595 | ide_sysfs_register_port(hwif); | 1717 | ide_sysfs_register_port(hwif); |
1596 | ide_proc_register_port(hwif); | 1718 | ide_proc_register_port(hwif); |
@@ -1599,21 +1721,64 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1599 | ide_proc_port_register_devices(hwif); | 1721 | ide_proc_port_register_devices(hwif); |
1600 | } | 1722 | } |
1601 | 1723 | ||
1602 | return rc; | 1724 | return j ? 0 : -1; |
1603 | } | 1725 | } |
1604 | EXPORT_SYMBOL_GPL(ide_device_add_all); | 1726 | EXPORT_SYMBOL_GPL(ide_host_register); |
1605 | 1727 | ||
1606 | int ide_device_add(u8 idx[4], const struct ide_port_info *d) | 1728 | int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws, |
1729 | struct ide_host **hostp) | ||
1607 | { | 1730 | { |
1608 | u8 idx_all[MAX_HWIFS]; | 1731 | struct ide_host *host; |
1732 | int rc; | ||
1733 | |||
1734 | host = ide_host_alloc(d, hws); | ||
1735 | if (host == NULL) | ||
1736 | return -ENOMEM; | ||
1737 | |||
1738 | rc = ide_host_register(host, d, hws); | ||
1739 | if (rc) { | ||
1740 | ide_host_free(host); | ||
1741 | return rc; | ||
1742 | } | ||
1743 | |||
1744 | if (hostp) | ||
1745 | *hostp = host; | ||
1746 | |||
1747 | return 0; | ||
1748 | } | ||
1749 | EXPORT_SYMBOL_GPL(ide_host_add); | ||
1750 | |||
1751 | void ide_host_free(struct ide_host *host) | ||
1752 | { | ||
1753 | ide_hwif_t *hwif; | ||
1609 | int i; | 1754 | int i; |
1610 | 1755 | ||
1611 | for (i = 0; i < MAX_HWIFS; i++) | 1756 | for (i = 0; i < MAX_HWIFS; i++) { |
1612 | idx_all[i] = (i < 4) ? idx[i] : 0xff; | 1757 | hwif = host->ports[i]; |
1613 | 1758 | ||
1614 | return ide_device_add_all(idx_all, d); | 1759 | if (hwif == NULL) |
1760 | continue; | ||
1761 | |||
1762 | ide_free_port_slot(hwif->index); | ||
1763 | kfree(hwif); | ||
1764 | } | ||
1765 | |||
1766 | kfree(host); | ||
1615 | } | 1767 | } |
1616 | EXPORT_SYMBOL_GPL(ide_device_add); | 1768 | EXPORT_SYMBOL_GPL(ide_host_free); |
1769 | |||
1770 | void ide_host_remove(struct ide_host *host) | ||
1771 | { | ||
1772 | int i; | ||
1773 | |||
1774 | for (i = 0; i < MAX_HWIFS; i++) { | ||
1775 | if (host->ports[i]) | ||
1776 | ide_unregister(host->ports[i]); | ||
1777 | } | ||
1778 | |||
1779 | ide_host_free(host); | ||
1780 | } | ||
1781 | EXPORT_SYMBOL_GPL(ide_host_remove); | ||
1617 | 1782 | ||
1618 | void ide_port_scan(ide_hwif_t *hwif) | 1783 | void ide_port_scan(ide_hwif_t *hwif) |
1619 | { | 1784 | { |
@@ -1634,11 +1799,10 @@ void ide_port_scan(ide_hwif_t *hwif) | |||
1634 | } | 1799 | } |
1635 | EXPORT_SYMBOL_GPL(ide_port_scan); | 1800 | EXPORT_SYMBOL_GPL(ide_port_scan); |
1636 | 1801 | ||
1637 | static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, | 1802 | static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw, |
1638 | const struct ide_port_info *d, | 1803 | u8 port_no, const struct ide_port_info *d, |
1639 | unsigned long config) | 1804 | unsigned long config) |
1640 | { | 1805 | { |
1641 | ide_hwif_t *hwif; | ||
1642 | unsigned long base, ctl; | 1806 | unsigned long base, ctl; |
1643 | int irq; | 1807 | int irq; |
1644 | 1808 | ||
@@ -1668,33 +1832,25 @@ static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, | |||
1668 | ide_std_init_ports(hw, base, ctl); | 1832 | ide_std_init_ports(hw, base, ctl); |
1669 | hw->irq = irq; | 1833 | hw->irq = irq; |
1670 | hw->chipset = d->chipset; | 1834 | hw->chipset = d->chipset; |
1835 | hw->config = config; | ||
1671 | 1836 | ||
1672 | hwif = ide_find_port_slot(d); | 1837 | hws[port_no] = hw; |
1673 | if (hwif) { | ||
1674 | ide_init_port_hw(hwif, hw); | ||
1675 | if (config) | ||
1676 | hwif->config_data = config; | ||
1677 | idx[port_no] = hwif->index; | ||
1678 | } | ||
1679 | } | 1838 | } |
1680 | 1839 | ||
1681 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) | 1840 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) |
1682 | { | 1841 | { |
1683 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 1842 | hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; |
1684 | hw_regs_t hw[2]; | ||
1685 | 1843 | ||
1686 | memset(&hw, 0, sizeof(hw)); | 1844 | memset(&hw, 0, sizeof(hw)); |
1687 | 1845 | ||
1688 | if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) | 1846 | if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) |
1689 | ide_legacy_init_one(idx, &hw[0], 0, d, config); | 1847 | ide_legacy_init_one(hws, &hw[0], 0, d, config); |
1690 | ide_legacy_init_one(idx, &hw[1], 1, d, config); | 1848 | ide_legacy_init_one(hws, &hw[1], 1, d, config); |
1691 | 1849 | ||
1692 | if (idx[0] == 0xff && idx[1] == 0xff && | 1850 | if (hws[0] == NULL && hws[1] == NULL && |
1693 | (d->host_flags & IDE_HFLAG_SINGLE)) | 1851 | (d->host_flags & IDE_HFLAG_SINGLE)) |
1694 | return -ENOENT; | 1852 | return -ENOENT; |
1695 | 1853 | ||
1696 | ide_device_add(idx, d); | 1854 | return ide_host_add(d, hws, NULL); |
1697 | |||
1698 | return 0; | ||
1699 | } | 1855 | } |
1700 | EXPORT_SYMBOL_GPL(ide_legacy_device_add); | 1856 | EXPORT_SYMBOL_GPL(ide_legacy_device_add); |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 8af88bf0969b..151c91e933da 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -345,7 +345,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg) | |||
345 | ide_task_t task; | 345 | ide_task_t task; |
346 | int err; | 346 | int err; |
347 | 347 | ||
348 | if (arg < 0 || arg > 70) | 348 | if (arg < XFER_PIO_0 || arg > XFER_UDMA_6) |
349 | return -EINVAL; | 349 | return -EINVAL; |
350 | 350 | ||
351 | memset(&task, 0, sizeof(task)); | 351 | memset(&task, 0, sizeof(task)); |
@@ -357,7 +357,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg) | |||
357 | 357 | ||
358 | err = ide_no_data_taskfile(drive, &task); | 358 | err = ide_no_data_taskfile(drive, &task); |
359 | 359 | ||
360 | if (!err && arg) { | 360 | if (!err) { |
361 | ide_set_xfer_rate(drive, (u8) arg); | 361 | ide_set_xfer_rate(drive, (u8) arg); |
362 | ide_driveid_update(drive); | 362 | ide_driveid_update(drive); |
363 | } | 363 | } |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 353dd11b9283..6962ca4891a1 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -195,23 +195,6 @@ enum { | |||
195 | #define IDETAPE_BLOCK_DESCRIPTOR 0 | 195 | #define IDETAPE_BLOCK_DESCRIPTOR 0 |
196 | #define IDETAPE_CAPABILITIES_PAGE 0x2a | 196 | #define IDETAPE_CAPABILITIES_PAGE 0x2a |
197 | 197 | ||
198 | /* Tape flag bits values. */ | ||
199 | enum { | ||
200 | IDETAPE_FLAG_IGNORE_DSC = (1 << 0), | ||
201 | /* 0 When the tape position is unknown */ | ||
202 | IDETAPE_FLAG_ADDRESS_VALID = (1 << 1), | ||
203 | /* Device already opened */ | ||
204 | IDETAPE_FLAG_BUSY = (1 << 2), | ||
205 | /* Attempt to auto-detect the current user block size */ | ||
206 | IDETAPE_FLAG_DETECT_BS = (1 << 3), | ||
207 | /* Currently on a filemark */ | ||
208 | IDETAPE_FLAG_FILEMARK = (1 << 4), | ||
209 | /* DRQ interrupt device */ | ||
210 | IDETAPE_FLAG_DRQ_INTERRUPT = (1 << 5), | ||
211 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | ||
212 | IDETAPE_FLAG_MEDIUM_PRESENT = (1 << 6), | ||
213 | }; | ||
214 | |||
215 | /* | 198 | /* |
216 | * Most of our global data which we need to save even as we leave the driver due | 199 | * Most of our global data which we need to save even as we leave the driver due |
217 | * to an interrupt or a timer event is stored in the struct defined below. | 200 | * to an interrupt or a timer event is stored in the struct defined below. |
@@ -312,8 +295,6 @@ typedef struct ide_tape_obj { | |||
312 | /* Wasted space in each stage */ | 295 | /* Wasted space in each stage */ |
313 | int excess_bh_size; | 296 | int excess_bh_size; |
314 | 297 | ||
315 | /* Status/Action flags: long for set_bit */ | ||
316 | unsigned long flags; | ||
317 | /* protects the ide-tape queue */ | 298 | /* protects the ide-tape queue */ |
318 | spinlock_t lock; | 299 | spinlock_t lock; |
319 | 300 | ||
@@ -398,7 +379,7 @@ static void idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
398 | count = min( | 379 | count = min( |
399 | (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), | 380 | (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), |
400 | bcount); | 381 | bcount); |
401 | drive->hwif->input_data(drive, NULL, bh->b_data + | 382 | drive->hwif->tp_ops->input_data(drive, NULL, bh->b_data + |
402 | atomic_read(&bh->b_count), count); | 383 | atomic_read(&bh->b_count), count); |
403 | bcount -= count; | 384 | bcount -= count; |
404 | atomic_add(count, &bh->b_count); | 385 | atomic_add(count, &bh->b_count); |
@@ -424,7 +405,7 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
424 | return; | 405 | return; |
425 | } | 406 | } |
426 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); | 407 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); |
427 | drive->hwif->output_data(drive, NULL, pc->b_data, count); | 408 | drive->hwif->tp_ops->output_data(drive, NULL, pc->b_data, count); |
428 | bcount -= count; | 409 | bcount -= count; |
429 | pc->b_data += count; | 410 | pc->b_data += count; |
430 | pc->b_count -= count; | 411 | pc->b_count -= count; |
@@ -585,7 +566,6 @@ static void ide_tape_kfree_buffer(idetape_tape_t *tape) | |||
585 | bh = bh->b_reqnext; | 566 | bh = bh->b_reqnext; |
586 | kfree(prev_bh); | 567 | kfree(prev_bh); |
587 | } | 568 | } |
588 | kfree(tape->merge_bh); | ||
589 | } | 569 | } |
590 | 570 | ||
591 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | 571 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) |
@@ -665,7 +645,7 @@ static void ide_tape_callback(ide_drive_t *drive) | |||
665 | if (readpos[0] & 0x4) { | 645 | if (readpos[0] & 0x4) { |
666 | printk(KERN_INFO "ide-tape: Block location is unknown" | 646 | printk(KERN_INFO "ide-tape: Block location is unknown" |
667 | "to the tape\n"); | 647 | "to the tape\n"); |
668 | clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | 648 | clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); |
669 | uptodate = 0; | 649 | uptodate = 0; |
670 | } else { | 650 | } else { |
671 | debug_log(DBG_SENSE, "Block Location - %u\n", | 651 | debug_log(DBG_SENSE, "Block Location - %u\n", |
@@ -673,7 +653,7 @@ static void ide_tape_callback(ide_drive_t *drive) | |||
673 | 653 | ||
674 | tape->partition = readpos[1]; | 654 | tape->partition = readpos[1]; |
675 | tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); | 655 | tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); |
676 | set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | 656 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); |
677 | } | 657 | } |
678 | } | 658 | } |
679 | 659 | ||
@@ -690,7 +670,6 @@ static void idetape_init_pc(struct ide_atapi_pc *pc) | |||
690 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; | 670 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; |
691 | pc->bh = NULL; | 671 | pc->bh = NULL; |
692 | pc->b_data = NULL; | 672 | pc->b_data = NULL; |
693 | pc->callback = ide_tape_callback; | ||
694 | } | 673 | } |
695 | 674 | ||
696 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | 675 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) |
@@ -705,7 +684,7 @@ static void idetape_init_rq(struct request *rq, u8 cmd) | |||
705 | { | 684 | { |
706 | blk_rq_init(NULL, rq); | 685 | blk_rq_init(NULL, rq); |
707 | rq->cmd_type = REQ_TYPE_SPECIAL; | 686 | rq->cmd_type = REQ_TYPE_SPECIAL; |
708 | rq->cmd[0] = cmd; | 687 | rq->cmd[13] = cmd; |
709 | } | 688 | } |
710 | 689 | ||
711 | /* | 690 | /* |
@@ -732,6 +711,7 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
732 | rq->cmd_flags |= REQ_PREEMPT; | 711 | rq->cmd_flags |= REQ_PREEMPT; |
733 | rq->buffer = (char *) pc; | 712 | rq->buffer = (char *) pc; |
734 | rq->rq_disk = tape->disk; | 713 | rq->rq_disk = tape->disk; |
714 | memcpy(rq->cmd, pc->c, 12); | ||
735 | ide_do_drive_cmd(drive, rq); | 715 | ide_do_drive_cmd(drive, rq); |
736 | } | 716 | } |
737 | 717 | ||
@@ -742,7 +722,6 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
742 | */ | 722 | */ |
743 | static void idetape_retry_pc(ide_drive_t *drive) | 723 | static void idetape_retry_pc(ide_drive_t *drive) |
744 | { | 724 | { |
745 | idetape_tape_t *tape = drive->driver_data; | ||
746 | struct ide_atapi_pc *pc; | 725 | struct ide_atapi_pc *pc; |
747 | struct request *rq; | 726 | struct request *rq; |
748 | 727 | ||
@@ -750,7 +729,7 @@ static void idetape_retry_pc(ide_drive_t *drive) | |||
750 | pc = idetape_next_pc_storage(drive); | 729 | pc = idetape_next_pc_storage(drive); |
751 | rq = idetape_next_rq_storage(drive); | 730 | rq = idetape_next_rq_storage(drive); |
752 | idetape_create_request_sense_cmd(pc); | 731 | idetape_create_request_sense_cmd(pc); |
753 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); | 732 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); |
754 | idetape_queue_pc_head(drive, pc, rq); | 733 | idetape_queue_pc_head(drive, pc, rq); |
755 | } | 734 | } |
756 | 735 | ||
@@ -887,7 +866,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
887 | pc->error = IDETAPE_ERROR_GENERAL; | 866 | pc->error = IDETAPE_ERROR_GENERAL; |
888 | } | 867 | } |
889 | tape->failed_pc = NULL; | 868 | tape->failed_pc = NULL; |
890 | pc->callback(drive); | 869 | drive->pc_callback(drive); |
891 | return ide_stopped; | 870 | return ide_stopped; |
892 | } | 871 | } |
893 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 872 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
@@ -927,11 +906,12 @@ static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) | |||
927 | 906 | ||
928 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | 907 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
929 | { | 908 | { |
909 | ide_hwif_t *hwif = drive->hwif; | ||
930 | idetape_tape_t *tape = drive->driver_data; | 910 | idetape_tape_t *tape = drive->driver_data; |
931 | struct ide_atapi_pc *pc = tape->pc; | 911 | struct ide_atapi_pc *pc = tape->pc; |
932 | u8 stat; | 912 | u8 stat; |
933 | 913 | ||
934 | stat = ide_read_status(drive); | 914 | stat = hwif->tp_ops->read_status(hwif); |
935 | 915 | ||
936 | if (stat & SEEK_STAT) { | 916 | if (stat & SEEK_STAT) { |
937 | if (stat & ERR_STAT) { | 917 | if (stat & ERR_STAT) { |
@@ -948,14 +928,17 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | |||
948 | pc->error = IDETAPE_ERROR_GENERAL; | 928 | pc->error = IDETAPE_ERROR_GENERAL; |
949 | tape->failed_pc = NULL; | 929 | tape->failed_pc = NULL; |
950 | } | 930 | } |
951 | pc->callback(drive); | 931 | drive->pc_callback(drive); |
952 | return ide_stopped; | 932 | return ide_stopped; |
953 | } | 933 | } |
954 | 934 | ||
955 | static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | 935 | static void ide_tape_create_rw_cmd(idetape_tape_t *tape, |
956 | struct ide_atapi_pc *pc, unsigned int length, | 936 | struct ide_atapi_pc *pc, struct request *rq, |
957 | struct idetape_bh *bh, u8 opcode) | 937 | u8 opcode) |
958 | { | 938 | { |
939 | struct idetape_bh *bh = (struct idetape_bh *)rq->special; | ||
940 | unsigned int length = rq->current_nr_sectors; | ||
941 | |||
959 | idetape_init_pc(pc); | 942 | idetape_init_pc(pc); |
960 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 943 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
961 | pc->c[1] = 1; | 944 | pc->c[1] = 1; |
@@ -975,11 +958,14 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
975 | pc->b_data = bh->b_data; | 958 | pc->b_data = bh->b_data; |
976 | pc->b_count = atomic_read(&bh->b_count); | 959 | pc->b_count = atomic_read(&bh->b_count); |
977 | } | 960 | } |
961 | |||
962 | memcpy(rq->cmd, pc->c, 12); | ||
978 | } | 963 | } |
979 | 964 | ||
980 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, | 965 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, |
981 | struct request *rq, sector_t block) | 966 | struct request *rq, sector_t block) |
982 | { | 967 | { |
968 | ide_hwif_t *hwif = drive->hwif; | ||
983 | idetape_tape_t *tape = drive->driver_data; | 969 | idetape_tape_t *tape = drive->driver_data; |
984 | struct ide_atapi_pc *pc = NULL; | 970 | struct ide_atapi_pc *pc = NULL; |
985 | struct request *postponed_rq = tape->postponed_rq; | 971 | struct request *postponed_rq = tape->postponed_rq; |
@@ -1017,17 +1003,17 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1017 | * If the tape is still busy, postpone our request and service | 1003 | * If the tape is still busy, postpone our request and service |
1018 | * the other device meanwhile. | 1004 | * the other device meanwhile. |
1019 | */ | 1005 | */ |
1020 | stat = ide_read_status(drive); | 1006 | stat = hwif->tp_ops->read_status(hwif); |
1021 | 1007 | ||
1022 | if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) | 1008 | if (!drive->dsc_overlap && !(rq->cmd[13] & REQ_IDETAPE_PC2)) |
1023 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); | 1009 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); |
1024 | 1010 | ||
1025 | if (drive->post_reset == 1) { | 1011 | if (drive->post_reset == 1) { |
1026 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); | 1012 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); |
1027 | drive->post_reset = 0; | 1013 | drive->post_reset = 0; |
1028 | } | 1014 | } |
1029 | 1015 | ||
1030 | if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) && | 1016 | if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && |
1031 | (stat & SEEK_STAT) == 0) { | 1017 | (stat & SEEK_STAT) == 0) { |
1032 | if (postponed_rq == NULL) { | 1018 | if (postponed_rq == NULL) { |
1033 | tape->dsc_polling_start = jiffies; | 1019 | tape->dsc_polling_start = jiffies; |
@@ -1036,7 +1022,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1036 | } else if (time_after(jiffies, tape->dsc_timeout)) { | 1022 | } else if (time_after(jiffies, tape->dsc_timeout)) { |
1037 | printk(KERN_ERR "ide-tape: %s: DSC timeout\n", | 1023 | printk(KERN_ERR "ide-tape: %s: DSC timeout\n", |
1038 | tape->name); | 1024 | tape->name); |
1039 | if (rq->cmd[0] & REQ_IDETAPE_PC2) { | 1025 | if (rq->cmd[13] & REQ_IDETAPE_PC2) { |
1040 | idetape_media_access_finished(drive); | 1026 | idetape_media_access_finished(drive); |
1041 | return ide_stopped; | 1027 | return ide_stopped; |
1042 | } else { | 1028 | } else { |
@@ -1049,35 +1035,29 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1049 | idetape_postpone_request(drive); | 1035 | idetape_postpone_request(drive); |
1050 | return ide_stopped; | 1036 | return ide_stopped; |
1051 | } | 1037 | } |
1052 | if (rq->cmd[0] & REQ_IDETAPE_READ) { | 1038 | if (rq->cmd[13] & REQ_IDETAPE_READ) { |
1053 | pc = idetape_next_pc_storage(drive); | 1039 | pc = idetape_next_pc_storage(drive); |
1054 | ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors, | 1040 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); |
1055 | (struct idetape_bh *)rq->special, | ||
1056 | READ_6); | ||
1057 | goto out; | 1041 | goto out; |
1058 | } | 1042 | } |
1059 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 1043 | if (rq->cmd[13] & REQ_IDETAPE_WRITE) { |
1060 | pc = idetape_next_pc_storage(drive); | 1044 | pc = idetape_next_pc_storage(drive); |
1061 | ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors, | 1045 | ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); |
1062 | (struct idetape_bh *)rq->special, | ||
1063 | WRITE_6); | ||
1064 | goto out; | 1046 | goto out; |
1065 | } | 1047 | } |
1066 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { | 1048 | if (rq->cmd[13] & REQ_IDETAPE_PC1) { |
1067 | pc = (struct ide_atapi_pc *) rq->buffer; | 1049 | pc = (struct ide_atapi_pc *) rq->buffer; |
1068 | rq->cmd[0] &= ~(REQ_IDETAPE_PC1); | 1050 | rq->cmd[13] &= ~(REQ_IDETAPE_PC1); |
1069 | rq->cmd[0] |= REQ_IDETAPE_PC2; | 1051 | rq->cmd[13] |= REQ_IDETAPE_PC2; |
1070 | goto out; | 1052 | goto out; |
1071 | } | 1053 | } |
1072 | if (rq->cmd[0] & REQ_IDETAPE_PC2) { | 1054 | if (rq->cmd[13] & REQ_IDETAPE_PC2) { |
1073 | idetape_media_access_finished(drive); | 1055 | idetape_media_access_finished(drive); |
1074 | return ide_stopped; | 1056 | return ide_stopped; |
1075 | } | 1057 | } |
1076 | BUG(); | 1058 | BUG(); |
1077 | out: | ||
1078 | if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) | ||
1079 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
1080 | 1059 | ||
1060 | out: | ||
1081 | return idetape_issue_pc(drive, pc); | 1061 | return idetape_issue_pc(drive, pc); |
1082 | } | 1062 | } |
1083 | 1063 | ||
@@ -1281,8 +1261,9 @@ static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | |||
1281 | 1261 | ||
1282 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 1262 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1283 | rq->cmd_type = REQ_TYPE_SPECIAL; | 1263 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1284 | rq->cmd[0] = REQ_IDETAPE_PC1; | 1264 | rq->cmd[13] = REQ_IDETAPE_PC1; |
1285 | rq->buffer = (char *)pc; | 1265 | rq->buffer = (char *)pc; |
1266 | memcpy(rq->cmd, pc->c, 12); | ||
1286 | error = blk_execute_rq(drive->queue, tape->disk, rq, 0); | 1267 | error = blk_execute_rq(drive->queue, tape->disk, rq, 0); |
1287 | blk_put_request(rq); | 1268 | blk_put_request(rq); |
1288 | return error; | 1269 | return error; |
@@ -1304,7 +1285,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1304 | int load_attempted = 0; | 1285 | int load_attempted = 0; |
1305 | 1286 | ||
1306 | /* Wait for the tape to become ready */ | 1287 | /* Wait for the tape to become ready */ |
1307 | set_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags); | 1288 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); |
1308 | timeout += jiffies; | 1289 | timeout += jiffies; |
1309 | while (time_before(jiffies, timeout)) { | 1290 | while (time_before(jiffies, timeout)) { |
1310 | idetape_create_test_unit_ready_cmd(&pc); | 1291 | idetape_create_test_unit_ready_cmd(&pc); |
@@ -1397,7 +1378,7 @@ static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) | |||
1397 | if (tape->chrdev_dir != IDETAPE_DIR_READ) | 1378 | if (tape->chrdev_dir != IDETAPE_DIR_READ) |
1398 | return; | 1379 | return; |
1399 | 1380 | ||
1400 | clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags); | 1381 | clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags); |
1401 | tape->merge_bh_size = 0; | 1382 | tape->merge_bh_size = 0; |
1402 | if (tape->merge_bh != NULL) { | 1383 | if (tape->merge_bh != NULL) { |
1403 | ide_tape_kfree_buffer(tape); | 1384 | ide_tape_kfree_buffer(tape); |
@@ -1465,7 +1446,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
1465 | 1446 | ||
1466 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 1447 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1467 | rq->cmd_type = REQ_TYPE_SPECIAL; | 1448 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1468 | rq->cmd[0] = cmd; | 1449 | rq->cmd[13] = cmd; |
1469 | rq->rq_disk = tape->disk; | 1450 | rq->rq_disk = tape->disk; |
1470 | rq->special = (void *)bh; | 1451 | rq->special = (void *)bh; |
1471 | rq->sector = tape->first_frame; | 1452 | rq->sector = tape->first_frame; |
@@ -1636,7 +1617,7 @@ static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | |||
1636 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); | 1617 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); |
1637 | 1618 | ||
1638 | /* If we are at a filemark, return a read length of 0 */ | 1619 | /* If we are at a filemark, return a read length of 0 */ |
1639 | if (test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) | 1620 | if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) |
1640 | return 0; | 1621 | return 0; |
1641 | 1622 | ||
1642 | idetape_init_read(drive); | 1623 | idetape_init_read(drive); |
@@ -1746,7 +1727,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
1746 | 1727 | ||
1747 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 1728 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
1748 | tape->merge_bh_size = 0; | 1729 | tape->merge_bh_size = 0; |
1749 | if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) | 1730 | if (test_and_clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) |
1750 | ++count; | 1731 | ++count; |
1751 | ide_tape_discard_merge_buffer(drive, 0); | 1732 | ide_tape_discard_merge_buffer(drive, 0); |
1752 | } | 1733 | } |
@@ -1801,7 +1782,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1801 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 1782 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); |
1802 | 1783 | ||
1803 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 1784 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
1804 | if (test_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags)) | 1785 | if (test_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags)) |
1805 | if (count > tape->blk_size && | 1786 | if (count > tape->blk_size && |
1806 | (count % tape->blk_size) == 0) | 1787 | (count % tape->blk_size) == 0) |
1807 | tape->user_bs_factor = count / tape->blk_size; | 1788 | tape->user_bs_factor = count / tape->blk_size; |
@@ -1841,7 +1822,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1841 | tape->merge_bh_size = bytes_read-temp; | 1822 | tape->merge_bh_size = bytes_read-temp; |
1842 | } | 1823 | } |
1843 | finish: | 1824 | finish: |
1844 | if (!actually_read && test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) { | 1825 | if (!actually_read && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) { |
1845 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); | 1826 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); |
1846 | 1827 | ||
1847 | idetape_space_over_filemarks(drive, MTFSF, 1); | 1828 | idetape_space_over_filemarks(drive, MTFSF, 1); |
@@ -2027,7 +2008,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2027 | !IDETAPE_LU_LOAD_MASK); | 2008 | !IDETAPE_LU_LOAD_MASK); |
2028 | retval = idetape_queue_pc_tail(drive, &pc); | 2009 | retval = idetape_queue_pc_tail(drive, &pc); |
2029 | if (!retval) | 2010 | if (!retval) |
2030 | clear_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags); | 2011 | clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); |
2031 | return retval; | 2012 | return retval; |
2032 | case MTNOP: | 2013 | case MTNOP: |
2033 | ide_tape_discard_merge_buffer(drive, 0); | 2014 | ide_tape_discard_merge_buffer(drive, 0); |
@@ -2050,9 +2031,9 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2050 | mt_count % tape->blk_size) | 2031 | mt_count % tape->blk_size) |
2051 | return -EIO; | 2032 | return -EIO; |
2052 | tape->user_bs_factor = mt_count / tape->blk_size; | 2033 | tape->user_bs_factor = mt_count / tape->blk_size; |
2053 | clear_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags); | 2034 | clear_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); |
2054 | } else | 2035 | } else |
2055 | set_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags); | 2036 | set_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); |
2056 | return 0; | 2037 | return 0; |
2057 | case MTSEEK: | 2038 | case MTSEEK: |
2058 | ide_tape_discard_merge_buffer(drive, 0); | 2039 | ide_tape_discard_merge_buffer(drive, 0); |
@@ -2202,20 +2183,20 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
2202 | 2183 | ||
2203 | filp->private_data = tape; | 2184 | filp->private_data = tape; |
2204 | 2185 | ||
2205 | if (test_and_set_bit(IDETAPE_FLAG_BUSY, &tape->flags)) { | 2186 | if (test_and_set_bit(IDE_AFLAG_BUSY, &drive->atapi_flags)) { |
2206 | retval = -EBUSY; | 2187 | retval = -EBUSY; |
2207 | goto out_put_tape; | 2188 | goto out_put_tape; |
2208 | } | 2189 | } |
2209 | 2190 | ||
2210 | retval = idetape_wait_ready(drive, 60 * HZ); | 2191 | retval = idetape_wait_ready(drive, 60 * HZ); |
2211 | if (retval) { | 2192 | if (retval) { |
2212 | clear_bit(IDETAPE_FLAG_BUSY, &tape->flags); | 2193 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); |
2213 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); | 2194 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); |
2214 | goto out_put_tape; | 2195 | goto out_put_tape; |
2215 | } | 2196 | } |
2216 | 2197 | ||
2217 | idetape_read_position(drive); | 2198 | idetape_read_position(drive); |
2218 | if (!test_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags)) | 2199 | if (!test_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags)) |
2219 | (void)idetape_rewind_tape(drive); | 2200 | (void)idetape_rewind_tape(drive); |
2220 | 2201 | ||
2221 | /* Read block size and write protect status from drive. */ | 2202 | /* Read block size and write protect status from drive. */ |
@@ -2231,7 +2212,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
2231 | if (tape->write_prot) { | 2212 | if (tape->write_prot) { |
2232 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || | 2213 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || |
2233 | (filp->f_flags & O_ACCMODE) == O_RDWR) { | 2214 | (filp->f_flags & O_ACCMODE) == O_RDWR) { |
2234 | clear_bit(IDETAPE_FLAG_BUSY, &tape->flags); | 2215 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); |
2235 | retval = -EROFS; | 2216 | retval = -EROFS; |
2236 | goto out_put_tape; | 2217 | goto out_put_tape; |
2237 | } | 2218 | } |
@@ -2291,7 +2272,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
2291 | ide_tape_discard_merge_buffer(drive, 1); | 2272 | ide_tape_discard_merge_buffer(drive, 1); |
2292 | } | 2273 | } |
2293 | 2274 | ||
2294 | if (minor < 128 && test_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags)) | 2275 | if (minor < 128 && test_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags)) |
2295 | (void) idetape_rewind_tape(drive); | 2276 | (void) idetape_rewind_tape(drive); |
2296 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 2277 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
2297 | if (tape->door_locked == DOOR_LOCKED) { | 2278 | if (tape->door_locked == DOOR_LOCKED) { |
@@ -2301,7 +2282,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
2301 | } | 2282 | } |
2302 | } | 2283 | } |
2303 | } | 2284 | } |
2304 | clear_bit(IDETAPE_FLAG_BUSY, &tape->flags); | 2285 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); |
2305 | ide_tape_put(tape); | 2286 | ide_tape_put(tape); |
2306 | unlock_kernel(); | 2287 | unlock_kernel(); |
2307 | return 0; | 2288 | return 0; |
@@ -2464,6 +2445,8 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
2464 | u8 gcw[2]; | 2445 | u8 gcw[2]; |
2465 | u16 *ctl = (u16 *)&tape->caps[12]; | 2446 | u16 *ctl = (u16 *)&tape->caps[12]; |
2466 | 2447 | ||
2448 | drive->pc_callback = ide_tape_callback; | ||
2449 | |||
2467 | spin_lock_init(&tape->lock); | 2450 | spin_lock_init(&tape->lock); |
2468 | drive->dsc_overlap = 1; | 2451 | drive->dsc_overlap = 1; |
2469 | if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { | 2452 | if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { |
@@ -2484,7 +2467,7 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
2484 | 2467 | ||
2485 | /* Command packet DRQ type */ | 2468 | /* Command packet DRQ type */ |
2486 | if (((gcw[0] & 0x60) >> 5) == 1) | 2469 | if (((gcw[0] & 0x60) >> 5) == 1) |
2487 | set_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags); | 2470 | set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags); |
2488 | 2471 | ||
2489 | idetape_get_inquiry_results(drive); | 2472 | idetape_get_inquiry_results(drive); |
2490 | idetape_get_mode_sense_results(drive); | 2473 | idetape_get_mode_sense_results(drive); |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 1fbdb746dc88..aeddbbd69e86 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -64,6 +64,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
64 | ide_hwif_t *hwif = HWIF(drive); | 64 | ide_hwif_t *hwif = HWIF(drive); |
65 | struct ide_taskfile *tf = &task->tf; | 65 | struct ide_taskfile *tf = &task->tf; |
66 | ide_handler_t *handler = NULL; | 66 | ide_handler_t *handler = NULL; |
67 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
67 | const struct ide_dma_ops *dma_ops = hwif->dma_ops; | 68 | const struct ide_dma_ops *dma_ops = hwif->dma_ops; |
68 | 69 | ||
69 | if (task->data_phase == TASKFILE_MULTI_IN || | 70 | if (task->data_phase == TASKFILE_MULTI_IN || |
@@ -80,15 +81,15 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
80 | 81 | ||
81 | if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { | 82 | if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { |
82 | ide_tf_dump(drive->name, tf); | 83 | ide_tf_dump(drive->name, tf); |
83 | ide_set_irq(drive, 1); | 84 | tp_ops->set_irq(hwif, 1); |
84 | SELECT_MASK(drive, 0); | 85 | SELECT_MASK(drive, 0); |
85 | hwif->tf_load(drive, task); | 86 | tp_ops->tf_load(drive, task); |
86 | } | 87 | } |
87 | 88 | ||
88 | switch (task->data_phase) { | 89 | switch (task->data_phase) { |
89 | case TASKFILE_MULTI_OUT: | 90 | case TASKFILE_MULTI_OUT: |
90 | case TASKFILE_OUT: | 91 | case TASKFILE_OUT: |
91 | hwif->OUTBSYNC(hwif, tf->command, hwif->io_ports.command_addr); | 92 | tp_ops->exec_command(hwif, tf->command); |
92 | ndelay(400); /* FIXME */ | 93 | ndelay(400); /* FIXME */ |
93 | return pre_task_out_intr(drive, task->rq); | 94 | return pre_task_out_intr(drive, task->rq); |
94 | case TASKFILE_MULTI_IN: | 95 | case TASKFILE_MULTI_IN: |
@@ -124,7 +125,8 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile); | |||
124 | */ | 125 | */ |
125 | static ide_startstop_t set_multmode_intr(ide_drive_t *drive) | 126 | static ide_startstop_t set_multmode_intr(ide_drive_t *drive) |
126 | { | 127 | { |
127 | u8 stat = ide_read_status(drive); | 128 | ide_hwif_t *hwif = drive->hwif; |
129 | u8 stat = hwif->tp_ops->read_status(hwif); | ||
128 | 130 | ||
129 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) | 131 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) |
130 | drive->mult_count = drive->mult_req; | 132 | drive->mult_count = drive->mult_req; |
@@ -141,11 +143,16 @@ static ide_startstop_t set_multmode_intr(ide_drive_t *drive) | |||
141 | */ | 143 | */ |
142 | static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | 144 | static ide_startstop_t set_geometry_intr(ide_drive_t *drive) |
143 | { | 145 | { |
146 | ide_hwif_t *hwif = drive->hwif; | ||
144 | int retries = 5; | 147 | int retries = 5; |
145 | u8 stat; | 148 | u8 stat; |
146 | 149 | ||
147 | while (((stat = ide_read_status(drive)) & BUSY_STAT) && retries--) | 150 | while (1) { |
151 | stat = hwif->tp_ops->read_status(hwif); | ||
152 | if ((stat & BUSY_STAT) == 0 || retries-- == 0) | ||
153 | break; | ||
148 | udelay(10); | 154 | udelay(10); |
155 | }; | ||
149 | 156 | ||
150 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) | 157 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) |
151 | return ide_stopped; | 158 | return ide_stopped; |
@@ -162,7 +169,8 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | |||
162 | */ | 169 | */ |
163 | static ide_startstop_t recal_intr(ide_drive_t *drive) | 170 | static ide_startstop_t recal_intr(ide_drive_t *drive) |
164 | { | 171 | { |
165 | u8 stat = ide_read_status(drive); | 172 | ide_hwif_t *hwif = drive->hwif; |
173 | u8 stat = hwif->tp_ops->read_status(hwif); | ||
166 | 174 | ||
167 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) | 175 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) |
168 | return ide_error(drive, "recal_intr", stat); | 176 | return ide_error(drive, "recal_intr", stat); |
@@ -174,11 +182,12 @@ static ide_startstop_t recal_intr(ide_drive_t *drive) | |||
174 | */ | 182 | */ |
175 | static ide_startstop_t task_no_data_intr(ide_drive_t *drive) | 183 | static ide_startstop_t task_no_data_intr(ide_drive_t *drive) |
176 | { | 184 | { |
177 | ide_task_t *args = HWGROUP(drive)->rq->special; | 185 | ide_hwif_t *hwif = drive->hwif; |
186 | ide_task_t *args = hwif->hwgroup->rq->special; | ||
178 | u8 stat; | 187 | u8 stat; |
179 | 188 | ||
180 | local_irq_enable_in_hardirq(); | 189 | local_irq_enable_in_hardirq(); |
181 | stat = ide_read_status(drive); | 190 | stat = hwif->tp_ops->read_status(hwif); |
182 | 191 | ||
183 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) | 192 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) |
184 | return ide_error(drive, "task_no_data_intr", stat); | 193 | return ide_error(drive, "task_no_data_intr", stat); |
@@ -192,6 +201,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive) | |||
192 | 201 | ||
193 | static u8 wait_drive_not_busy(ide_drive_t *drive) | 202 | static u8 wait_drive_not_busy(ide_drive_t *drive) |
194 | { | 203 | { |
204 | ide_hwif_t *hwif = drive->hwif; | ||
195 | int retries; | 205 | int retries; |
196 | u8 stat; | 206 | u8 stat; |
197 | 207 | ||
@@ -200,7 +210,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) | |||
200 | * take up to 6 ms on some ATAPI devices, so we will wait max 10 ms. | 210 | * take up to 6 ms on some ATAPI devices, so we will wait max 10 ms. |
201 | */ | 211 | */ |
202 | for (retries = 0; retries < 1000; retries++) { | 212 | for (retries = 0; retries < 1000; retries++) { |
203 | stat = ide_read_status(drive); | 213 | stat = hwif->tp_ops->read_status(hwif); |
204 | 214 | ||
205 | if (stat & BUSY_STAT) | 215 | if (stat & BUSY_STAT) |
206 | udelay(10); | 216 | udelay(10); |
@@ -255,9 +265,9 @@ static void ide_pio_sector(ide_drive_t *drive, struct request *rq, | |||
255 | 265 | ||
256 | /* do the actual data transfer */ | 266 | /* do the actual data transfer */ |
257 | if (write) | 267 | if (write) |
258 | hwif->output_data(drive, rq, buf, SECTOR_SIZE); | 268 | hwif->tp_ops->output_data(drive, rq, buf, SECTOR_SIZE); |
259 | else | 269 | else |
260 | hwif->input_data(drive, rq, buf, SECTOR_SIZE); | 270 | hwif->tp_ops->input_data(drive, rq, buf, SECTOR_SIZE); |
261 | 271 | ||
262 | kunmap_atomic(buf, KM_BIO_SRC_IRQ); | 272 | kunmap_atomic(buf, KM_BIO_SRC_IRQ); |
263 | #ifdef CONFIG_HIGHMEM | 273 | #ifdef CONFIG_HIGHMEM |
@@ -383,8 +393,8 @@ static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq | |||
383 | static ide_startstop_t task_in_intr(ide_drive_t *drive) | 393 | static ide_startstop_t task_in_intr(ide_drive_t *drive) |
384 | { | 394 | { |
385 | ide_hwif_t *hwif = drive->hwif; | 395 | ide_hwif_t *hwif = drive->hwif; |
386 | struct request *rq = HWGROUP(drive)->rq; | 396 | struct request *rq = hwif->hwgroup->rq; |
387 | u8 stat = ide_read_status(drive); | 397 | u8 stat = hwif->tp_ops->read_status(hwif); |
388 | 398 | ||
389 | /* Error? */ | 399 | /* Error? */ |
390 | if (stat & ERR_STAT) | 400 | if (stat & ERR_STAT) |
@@ -418,7 +428,7 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive) | |||
418 | { | 428 | { |
419 | ide_hwif_t *hwif = drive->hwif; | 429 | ide_hwif_t *hwif = drive->hwif; |
420 | struct request *rq = HWGROUP(drive)->rq; | 430 | struct request *rq = HWGROUP(drive)->rq; |
421 | u8 stat = ide_read_status(drive); | 431 | u8 stat = hwif->tp_ops->read_status(hwif); |
422 | 432 | ||
423 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) | 433 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) |
424 | return task_error(drive, rq, __func__, stat); | 434 | return task_error(drive, rq, __func__, stat); |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index d4a6b102a772..60f0ca66aa93 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
3 | * Copyrifht (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz | 3 | * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
@@ -101,8 +101,7 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
101 | 101 | ||
102 | init_completion(&hwif->gendev_rel_comp); | 102 | init_completion(&hwif->gendev_rel_comp); |
103 | 103 | ||
104 | default_hwif_iops(hwif); | 104 | hwif->tp_ops = &default_tp_ops; |
105 | default_hwif_transport(hwif); | ||
106 | 105 | ||
107 | ide_port_init_devices_data(hwif); | 106 | ide_port_init_devices_data(hwif); |
108 | } | 107 | } |
@@ -134,41 +133,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
134 | } | 133 | } |
135 | } | 134 | } |
136 | 135 | ||
137 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | ||
138 | { | ||
139 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
140 | |||
141 | spin_lock_irq(&ide_lock); | ||
142 | /* | ||
143 | * Remove us from the hwgroup, and free | ||
144 | * the hwgroup if we were the only member | ||
145 | */ | ||
146 | if (hwif->next == hwif) { | ||
147 | BUG_ON(hwgroup->hwif != hwif); | ||
148 | kfree(hwgroup); | ||
149 | } else { | ||
150 | /* There is another interface in hwgroup. | ||
151 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
152 | * something sane. | ||
153 | */ | ||
154 | ide_hwif_t *g = hwgroup->hwif; | ||
155 | |||
156 | while (g->next != hwif) | ||
157 | g = g->next; | ||
158 | g->next = hwif->next; | ||
159 | if (hwgroup->hwif == hwif) { | ||
160 | /* Chose a random hwif for hwgroup->hwif. | ||
161 | * It's guaranteed that there are no drives | ||
162 | * left in the hwgroup. | ||
163 | */ | ||
164 | BUG_ON(hwgroup->drive != NULL); | ||
165 | hwgroup->hwif = g; | ||
166 | } | ||
167 | BUG_ON(hwgroup->hwif == hwif); | ||
168 | } | ||
169 | spin_unlock_irq(&ide_lock); | ||
170 | } | ||
171 | |||
172 | /* Called with ide_lock held. */ | 136 | /* Called with ide_lock held. */ |
173 | static void __ide_port_unregister_devices(ide_hwif_t *hwif) | 137 | static void __ide_port_unregister_devices(ide_hwif_t *hwif) |
174 | { | 138 | { |
@@ -269,16 +233,9 @@ void ide_unregister(ide_hwif_t *hwif) | |||
269 | if (hwif->dma_base) | 233 | if (hwif->dma_base) |
270 | ide_release_dma_engine(hwif); | 234 | ide_release_dma_engine(hwif); |
271 | 235 | ||
272 | spin_lock_irq(&ide_lock); | ||
273 | /* restore hwif data to pristine status */ | ||
274 | ide_init_port_data(hwif, hwif->index); | ||
275 | spin_unlock_irq(&ide_lock); | ||
276 | |||
277 | mutex_unlock(&ide_cfg_mtx); | 236 | mutex_unlock(&ide_cfg_mtx); |
278 | } | 237 | } |
279 | 238 | ||
280 | EXPORT_SYMBOL(ide_unregister); | ||
281 | |||
282 | void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | 239 | void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) |
283 | { | 240 | { |
284 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | 241 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); |
@@ -287,8 +244,8 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | |||
287 | hwif->dev = hw->dev; | 244 | hwif->dev = hw->dev; |
288 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | 245 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; |
289 | hwif->ack_intr = hw->ack_intr; | 246 | hwif->ack_intr = hw->ack_intr; |
247 | hwif->config_data = hw->config; | ||
290 | } | 248 | } |
291 | EXPORT_SYMBOL_GPL(ide_init_port_hw); | ||
292 | 249 | ||
293 | /* | 250 | /* |
294 | * Locks for IDE setting functionality | 251 | * Locks for IDE setting functionality |
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index 0497e7f85b09..7c2afa97f417 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
@@ -37,6 +37,8 @@ | |||
37 | #define CATWEASEL_NUM_HWIFS 3 | 37 | #define CATWEASEL_NUM_HWIFS 3 |
38 | #define XSURF_NUM_HWIFS 2 | 38 | #define XSURF_NUM_HWIFS 2 |
39 | 39 | ||
40 | #define MAX_NUM_HWIFS 3 | ||
41 | |||
40 | /* | 42 | /* |
41 | * Bases of the IDE interfaces (relative to the board address) | 43 | * Bases of the IDE interfaces (relative to the board address) |
42 | */ | 44 | */ |
@@ -148,18 +150,14 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, | |||
148 | 150 | ||
149 | static int __init buddha_init(void) | 151 | static int __init buddha_init(void) |
150 | { | 152 | { |
151 | hw_regs_t hw; | ||
152 | ide_hwif_t *hwif; | ||
153 | int i; | ||
154 | |||
155 | struct zorro_dev *z = NULL; | 153 | struct zorro_dev *z = NULL; |
156 | u_long buddha_board = 0; | 154 | u_long buddha_board = 0; |
157 | BuddhaType type; | 155 | BuddhaType type; |
158 | int buddha_num_hwifs; | 156 | int buddha_num_hwifs, i; |
159 | 157 | ||
160 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { | 158 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { |
161 | unsigned long board; | 159 | unsigned long board; |
162 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 160 | hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; |
163 | 161 | ||
164 | if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { | 162 | if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { |
165 | buddha_num_hwifs = BUDDHA_NUM_HWIFS; | 163 | buddha_num_hwifs = BUDDHA_NUM_HWIFS; |
@@ -221,19 +219,13 @@ fail_base2: | |||
221 | ack_intr = xsurf_ack_intr; | 219 | ack_intr = xsurf_ack_intr; |
222 | } | 220 | } |
223 | 221 | ||
224 | buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr); | 222 | buddha_setup_ports(&hw[i], base, ctl, irq_port, |
223 | ack_intr); | ||
225 | 224 | ||
226 | hwif = ide_find_port(); | 225 | hws[i] = &hw[i]; |
227 | if (hwif) { | ||
228 | u8 index = hwif->index; | ||
229 | |||
230 | ide_init_port_hw(hwif, &hw); | ||
231 | |||
232 | idx[i] = index; | ||
233 | } | ||
234 | } | 226 | } |
235 | 227 | ||
236 | ide_device_add(idx, NULL); | 228 | ide_host_add(NULL, hws, NULL); |
237 | } | 229 | } |
238 | 230 | ||
239 | return 0; | 231 | return 0; |
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 129a812bb57f..724f95073d80 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -66,6 +66,27 @@ static void falconide_output_data(ide_drive_t *drive, struct request *rq, | |||
66 | outsw_swapw(data_addr, buf, (len + 1) / 2); | 66 | outsw_swapw(data_addr, buf, (len + 1) / 2); |
67 | } | 67 | } |
68 | 68 | ||
69 | /* Atari has a byte-swapped IDE interface */ | ||
70 | static const struct ide_tp_ops falconide_tp_ops = { | ||
71 | .exec_command = ide_exec_command, | ||
72 | .read_status = ide_read_status, | ||
73 | .read_altstatus = ide_read_altstatus, | ||
74 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
75 | |||
76 | .set_irq = ide_set_irq, | ||
77 | |||
78 | .tf_load = ide_tf_load, | ||
79 | .tf_read = ide_tf_read, | ||
80 | |||
81 | .input_data = falconide_input_data, | ||
82 | .output_data = falconide_output_data, | ||
83 | }; | ||
84 | |||
85 | static const struct ide_port_info falconide_port_info = { | ||
86 | .tp_ops = &falconide_tp_ops, | ||
87 | .host_flags = IDE_HFLAG_NO_DMA, | ||
88 | }; | ||
89 | |||
69 | static void __init falconide_setup_ports(hw_regs_t *hw) | 90 | static void __init falconide_setup_ports(hw_regs_t *hw) |
70 | { | 91 | { |
71 | int i; | 92 | int i; |
@@ -91,11 +112,12 @@ static void __init falconide_setup_ports(hw_regs_t *hw) | |||
91 | 112 | ||
92 | static int __init falconide_init(void) | 113 | static int __init falconide_init(void) |
93 | { | 114 | { |
94 | hw_regs_t hw; | 115 | struct ide_host *host; |
95 | ide_hwif_t *hwif; | 116 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
117 | int rc; | ||
96 | 118 | ||
97 | if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) | 119 | if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) |
98 | return 0; | 120 | return -ENODEV; |
99 | 121 | ||
100 | printk(KERN_INFO "ide: Falcon IDE controller\n"); | 122 | printk(KERN_INFO "ide: Falcon IDE controller\n"); |
101 | 123 | ||
@@ -106,23 +128,25 @@ static int __init falconide_init(void) | |||
106 | 128 | ||
107 | falconide_setup_ports(&hw); | 129 | falconide_setup_ports(&hw); |
108 | 130 | ||
109 | hwif = ide_find_port(); | 131 | host = ide_host_alloc(&falconide_port_info, hws); |
110 | if (hwif) { | 132 | if (host == NULL) { |
111 | u8 index = hwif->index; | 133 | rc = -ENOMEM; |
112 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | 134 | goto err; |
113 | 135 | } | |
114 | ide_init_port_hw(hwif, &hw); | ||
115 | 136 | ||
116 | /* Atari has a byte-swapped IDE interface */ | 137 | ide_get_lock(NULL, NULL); |
117 | hwif->input_data = falconide_input_data; | 138 | rc = ide_host_register(host, &falconide_port_info, hws); |
118 | hwif->output_data = falconide_output_data; | 139 | ide_release_lock(); |
119 | 140 | ||
120 | ide_get_lock(NULL, NULL); | 141 | if (rc) |
121 | ide_device_add(idx, NULL); | 142 | goto err_free; |
122 | ide_release_lock(); | ||
123 | } | ||
124 | 143 | ||
125 | return 0; | 144 | return 0; |
145 | err_free: | ||
146 | ide_host_free(host); | ||
147 | err: | ||
148 | release_mem_region(ATA_HD_BASE, 0x40); | ||
149 | return rc; | ||
126 | } | 150 | } |
127 | 151 | ||
128 | module_init(falconide_init); | 152 | module_init(falconide_init); |
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index 7e74b20202df..dd5c467d8dd0 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #define GAYLE_BASE_4000 0xdd2020 /* A4000/A4000T */ | 31 | #define GAYLE_BASE_4000 0xdd2020 /* A4000/A4000T */ |
32 | #define GAYLE_BASE_1200 0xda0000 /* A1200/A600 and E-Matrix 530 */ | 32 | #define GAYLE_BASE_1200 0xda0000 /* A1200/A600 and E-Matrix 530 */ |
33 | 33 | ||
34 | #define GAYLE_IDEREG_SIZE 0x2000 | ||
35 | |||
34 | /* | 36 | /* |
35 | * Offsets from one of the above bases | 37 | * Offsets from one of the above bases |
36 | */ | 38 | */ |
@@ -56,13 +58,11 @@ | |||
56 | #define GAYLE_NUM_HWIFS 1 | 58 | #define GAYLE_NUM_HWIFS 1 |
57 | #define GAYLE_NUM_PROBE_HWIFS GAYLE_NUM_HWIFS | 59 | #define GAYLE_NUM_PROBE_HWIFS GAYLE_NUM_HWIFS |
58 | #define GAYLE_HAS_CONTROL_REG 1 | 60 | #define GAYLE_HAS_CONTROL_REG 1 |
59 | #define GAYLE_IDEREG_SIZE 0x2000 | ||
60 | #else /* CONFIG_BLK_DEV_IDEDOUBLER */ | 61 | #else /* CONFIG_BLK_DEV_IDEDOUBLER */ |
61 | #define GAYLE_NUM_HWIFS 2 | 62 | #define GAYLE_NUM_HWIFS 2 |
62 | #define GAYLE_NUM_PROBE_HWIFS (ide_doubler ? GAYLE_NUM_HWIFS : \ | 63 | #define GAYLE_NUM_PROBE_HWIFS (ide_doubler ? GAYLE_NUM_HWIFS : \ |
63 | GAYLE_NUM_HWIFS-1) | 64 | GAYLE_NUM_HWIFS-1) |
64 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) | 65 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) |
65 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) | ||
66 | 66 | ||
67 | static int ide_doubler; | 67 | static int ide_doubler; |
68 | module_param_named(doubler, ide_doubler, bool, 0); | 68 | module_param_named(doubler, ide_doubler, bool, 0); |
@@ -124,8 +124,11 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, | |||
124 | 124 | ||
125 | static int __init gayle_init(void) | 125 | static int __init gayle_init(void) |
126 | { | 126 | { |
127 | unsigned long phys_base, res_start, res_n; | ||
128 | unsigned long base, ctrlport, irqport; | ||
129 | ide_ack_intr_t *ack_intr; | ||
127 | int a4000, i; | 130 | int a4000, i; |
128 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 131 | hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; |
129 | 132 | ||
130 | if (!MACH_IS_AMIGA) | 133 | if (!MACH_IS_AMIGA) |
131 | return -ENODEV; | 134 | return -ENODEV; |
@@ -148,13 +151,6 @@ found: | |||
148 | #endif | 151 | #endif |
149 | ""); | 152 | ""); |
150 | 153 | ||
151 | for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) { | ||
152 | unsigned long base, ctrlport, irqport; | ||
153 | ide_ack_intr_t *ack_intr; | ||
154 | hw_regs_t hw; | ||
155 | ide_hwif_t *hwif; | ||
156 | unsigned long phys_base, res_start, res_n; | ||
157 | |||
158 | if (a4000) { | 154 | if (a4000) { |
159 | phys_base = GAYLE_BASE_4000; | 155 | phys_base = GAYLE_BASE_4000; |
160 | irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000); | 156 | irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000); |
@@ -168,33 +164,22 @@ found: | |||
168 | * FIXME: we now have selectable modes between mmio v/s iomio | 164 | * FIXME: we now have selectable modes between mmio v/s iomio |
169 | */ | 165 | */ |
170 | 166 | ||
171 | phys_base += i*GAYLE_NEXT_PORT; | ||
172 | |||
173 | res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1); | 167 | res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1); |
174 | res_n = GAYLE_IDEREG_SIZE; | 168 | res_n = GAYLE_IDEREG_SIZE; |
175 | 169 | ||
176 | if (!request_mem_region(res_start, res_n, "IDE")) | 170 | if (!request_mem_region(res_start, res_n, "IDE")) |
177 | continue; | 171 | return -EBUSY; |
178 | 172 | ||
179 | base = (unsigned long)ZTWO_VADDR(phys_base); | 173 | for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) { |
174 | base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT); | ||
180 | ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; | 175 | ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; |
181 | 176 | ||
182 | gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr); | 177 | gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr); |
183 | |||
184 | hwif = ide_find_port(); | ||
185 | if (hwif) { | ||
186 | u8 index = hwif->index; | ||
187 | 178 | ||
188 | ide_init_port_hw(hwif, &hw); | 179 | hws[i] = &hw[i]; |
189 | |||
190 | idx[i] = index; | ||
191 | } else | ||
192 | release_mem_region(res_start, res_n); | ||
193 | } | 180 | } |
194 | 181 | ||
195 | ide_device_add(idx, NULL); | 182 | return ide_host_add(NULL, hws, NULL); |
196 | |||
197 | return 0; | ||
198 | } | 183 | } |
199 | 184 | ||
200 | module_init(gayle_init); | 185 | module_init(gayle_init); |
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c index 89c8ff0a4d08..c76d55de6996 100644 --- a/drivers/ide/legacy/ide-4drives.c +++ b/drivers/ide/legacy/ide-4drives.c | |||
@@ -28,10 +28,8 @@ static const struct ide_port_info ide_4drives_port_info = { | |||
28 | 28 | ||
29 | static int __init ide_4drives_init(void) | 29 | static int __init ide_4drives_init(void) |
30 | { | 30 | { |
31 | ide_hwif_t *hwif, *mate; | ||
32 | unsigned long base = 0x1f0, ctl = 0x3f6; | 31 | unsigned long base = 0x1f0, ctl = 0x3f6; |
33 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 32 | hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL }; |
34 | hw_regs_t hw; | ||
35 | 33 | ||
36 | if (probe_4drives == 0) | 34 | if (probe_4drives == 0) |
37 | return -ENODEV; | 35 | return -ENODEV; |
@@ -55,21 +53,7 @@ static int __init ide_4drives_init(void) | |||
55 | hw.irq = 14; | 53 | hw.irq = 14; |
56 | hw.chipset = ide_4drives; | 54 | hw.chipset = ide_4drives; |
57 | 55 | ||
58 | hwif = ide_find_port(); | 56 | return ide_host_add(&ide_4drives_port_info, hws, NULL); |
59 | if (hwif) { | ||
60 | ide_init_port_hw(hwif, &hw); | ||
61 | idx[0] = hwif->index; | ||
62 | } | ||
63 | |||
64 | mate = ide_find_port(); | ||
65 | if (mate) { | ||
66 | ide_init_port_hw(mate, &hw); | ||
67 | idx[1] = mate->index; | ||
68 | } | ||
69 | |||
70 | ide_device_add(idx, &ide_4drives_port_info); | ||
71 | |||
72 | return 0; | ||
73 | } | 57 | } |
74 | 58 | ||
75 | module_init(ide_4drives_init); | 59 | module_init(ide_4drives_init); |
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 27b1e0b7ecb4..21bfac137844 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -74,7 +74,7 @@ INT_MODULE_PARM(pc_debug, 0); | |||
74 | 74 | ||
75 | typedef struct ide_info_t { | 75 | typedef struct ide_info_t { |
76 | struct pcmcia_device *p_dev; | 76 | struct pcmcia_device *p_dev; |
77 | ide_hwif_t *hwif; | 77 | struct ide_host *host; |
78 | int ndev; | 78 | int ndev; |
79 | dev_node_t node; | 79 | dev_node_t node; |
80 | } ide_info_t; | 80 | } ide_info_t; |
@@ -132,7 +132,7 @@ static int ide_probe(struct pcmcia_device *link) | |||
132 | static void ide_detach(struct pcmcia_device *link) | 132 | static void ide_detach(struct pcmcia_device *link) |
133 | { | 133 | { |
134 | ide_info_t *info = link->priv; | 134 | ide_info_t *info = link->priv; |
135 | ide_hwif_t *hwif = info->hwif; | 135 | ide_hwif_t *hwif = info->host->ports[0]; |
136 | unsigned long data_addr, ctl_addr; | 136 | unsigned long data_addr, ctl_addr; |
137 | 137 | ||
138 | DEBUG(0, "ide_detach(0x%p)\n", link); | 138 | DEBUG(0, "ide_detach(0x%p)\n", link); |
@@ -157,13 +157,13 @@ static const struct ide_port_info idecs_port_info = { | |||
157 | .host_flags = IDE_HFLAG_NO_DMA, | 157 | .host_flags = IDE_HFLAG_NO_DMA, |
158 | }; | 158 | }; |
159 | 159 | ||
160 | static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, | 160 | static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, |
161 | unsigned long irq, struct pcmcia_device *handle) | 161 | unsigned long irq, struct pcmcia_device *handle) |
162 | { | 162 | { |
163 | struct ide_host *host; | ||
163 | ide_hwif_t *hwif; | 164 | ide_hwif_t *hwif; |
164 | hw_regs_t hw; | 165 | int i, rc; |
165 | int i; | 166 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
166 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
167 | 167 | ||
168 | if (!request_region(io, 8, DRV_NAME)) { | 168 | if (!request_region(io, 8, DRV_NAME)) { |
169 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | 169 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", |
@@ -184,30 +184,24 @@ static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, | |||
184 | hw.chipset = ide_pci; | 184 | hw.chipset = ide_pci; |
185 | hw.dev = &handle->dev; | 185 | hw.dev = &handle->dev; |
186 | 186 | ||
187 | hwif = ide_find_port(); | 187 | rc = ide_host_add(&idecs_port_info, hws, &host); |
188 | if (hwif == NULL) | 188 | if (rc) |
189 | goto out_release; | 189 | goto out_release; |
190 | 190 | ||
191 | i = hwif->index; | 191 | hwif = host->ports[0]; |
192 | |||
193 | ide_init_port_hw(hwif, &hw); | ||
194 | |||
195 | idx[0] = i; | ||
196 | |||
197 | ide_device_add(idx, &idecs_port_info); | ||
198 | 192 | ||
199 | if (hwif->present) | 193 | if (hwif->present) |
200 | return hwif; | 194 | return host; |
201 | 195 | ||
202 | /* retry registration in case device is still spinning up */ | 196 | /* retry registration in case device is still spinning up */ |
203 | for (i = 0; i < 10; i++) { | 197 | for (i = 0; i < 10; i++) { |
204 | msleep(100); | 198 | msleep(100); |
205 | ide_port_scan(hwif); | 199 | ide_port_scan(hwif); |
206 | if (hwif->present) | 200 | if (hwif->present) |
207 | return hwif; | 201 | return host; |
208 | } | 202 | } |
209 | 203 | ||
210 | return hwif; | 204 | return host; |
211 | 205 | ||
212 | out_release: | 206 | out_release: |
213 | release_region(ctl, 1); | 207 | release_region(ctl, 1); |
@@ -239,7 +233,7 @@ static int ide_config(struct pcmcia_device *link) | |||
239 | cistpl_cftable_entry_t *cfg; | 233 | cistpl_cftable_entry_t *cfg; |
240 | int pass, last_ret = 0, last_fn = 0, is_kme = 0; | 234 | int pass, last_ret = 0, last_fn = 0, is_kme = 0; |
241 | unsigned long io_base, ctl_base; | 235 | unsigned long io_base, ctl_base; |
242 | ide_hwif_t *hwif; | 236 | struct ide_host *host; |
243 | 237 | ||
244 | DEBUG(0, "ide_config(0x%p)\n", link); | 238 | DEBUG(0, "ide_config(0x%p)\n", link); |
245 | 239 | ||
@@ -334,21 +328,21 @@ static int ide_config(struct pcmcia_device *link) | |||
334 | if (is_kme) | 328 | if (is_kme) |
335 | outb(0x81, ctl_base+1); | 329 | outb(0x81, ctl_base+1); |
336 | 330 | ||
337 | hwif = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); | 331 | host = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); |
338 | if (hwif == NULL && link->io.NumPorts1 == 0x20) { | 332 | if (host == NULL && link->io.NumPorts1 == 0x20) { |
339 | outb(0x02, ctl_base + 0x10); | 333 | outb(0x02, ctl_base + 0x10); |
340 | hwif = idecs_register(io_base + 0x10, ctl_base + 0x10, | 334 | host = idecs_register(io_base + 0x10, ctl_base + 0x10, |
341 | link->irq.AssignedIRQ, link); | 335 | link->irq.AssignedIRQ, link); |
342 | } | 336 | } |
343 | 337 | ||
344 | if (hwif == NULL) | 338 | if (host == NULL) |
345 | goto failed; | 339 | goto failed; |
346 | 340 | ||
347 | info->ndev = 1; | 341 | info->ndev = 1; |
348 | sprintf(info->node.dev_name, "hd%c", 'a' + hwif->index * 2); | 342 | sprintf(info->node.dev_name, "hd%c", 'a' + host->ports[0]->index * 2); |
349 | info->node.major = hwif->major; | 343 | info->node.major = host->ports[0]->major; |
350 | info->node.minor = 0; | 344 | info->node.minor = 0; |
351 | info->hwif = hwif; | 345 | info->host = host; |
352 | link->dev_node = &info->node; | 346 | link->dev_node = &info->node; |
353 | printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", | 347 | printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", |
354 | info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); | 348 | info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); |
@@ -379,15 +373,15 @@ failed: | |||
379 | static void ide_release(struct pcmcia_device *link) | 373 | static void ide_release(struct pcmcia_device *link) |
380 | { | 374 | { |
381 | ide_info_t *info = link->priv; | 375 | ide_info_t *info = link->priv; |
382 | ide_hwif_t *hwif = info->hwif; | 376 | struct ide_host *host = info->host; |
383 | 377 | ||
384 | DEBUG(0, "ide_release(0x%p)\n", link); | 378 | DEBUG(0, "ide_release(0x%p)\n", link); |
385 | 379 | ||
386 | if (info->ndev) { | 380 | if (info->ndev) |
387 | /* FIXME: if this fails we need to queue the cleanup somehow | 381 | /* FIXME: if this fails we need to queue the cleanup somehow |
388 | -- need to investigate the required PCMCIA magic */ | 382 | -- need to investigate the required PCMCIA magic */ |
389 | ide_unregister(hwif); | 383 | ide_host_remove(host); |
390 | } | 384 | |
391 | info->ndev = 0; | 385 | info->ndev = 0; |
392 | 386 | ||
393 | pcmcia_disable_device(link); | 387 | pcmcia_disable_device(link); |
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index a249562b34b5..051b4ab0f359 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -52,12 +52,10 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
52 | { | 52 | { |
53 | struct resource *res_base, *res_alt, *res_irq; | 53 | struct resource *res_base, *res_alt, *res_irq; |
54 | void __iomem *base, *alt_base; | 54 | void __iomem *base, *alt_base; |
55 | ide_hwif_t *hwif; | ||
56 | struct pata_platform_info *pdata; | 55 | struct pata_platform_info *pdata; |
57 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 56 | struct ide_host *host; |
58 | int ret = 0; | 57 | int ret = 0, mmio = 0; |
59 | int mmio = 0; | 58 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
60 | hw_regs_t hw; | ||
61 | struct ide_port_info d = platform_ide_port_info; | 59 | struct ide_port_info d = platform_ide_port_info; |
62 | 60 | ||
63 | pdata = pdev->dev.platform_data; | 61 | pdata = pdev->dev.platform_data; |
@@ -94,28 +92,18 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
94 | res_alt->start, res_alt->end - res_alt->start + 1); | 92 | res_alt->start, res_alt->end - res_alt->start + 1); |
95 | } | 93 | } |
96 | 94 | ||
97 | hwif = ide_find_port(); | ||
98 | if (!hwif) { | ||
99 | ret = -ENODEV; | ||
100 | goto out; | ||
101 | } | ||
102 | |||
103 | memset(&hw, 0, sizeof(hw)); | 95 | memset(&hw, 0, sizeof(hw)); |
104 | plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); | 96 | plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); |
105 | hw.dev = &pdev->dev; | 97 | hw.dev = &pdev->dev; |
106 | 98 | ||
107 | ide_init_port_hw(hwif, &hw); | 99 | if (mmio) |
108 | |||
109 | if (mmio) { | ||
110 | d.host_flags |= IDE_HFLAG_MMIO; | 100 | d.host_flags |= IDE_HFLAG_MMIO; |
111 | default_hwif_mmiops(hwif); | ||
112 | } | ||
113 | 101 | ||
114 | idx[0] = hwif->index; | 102 | ret = ide_host_add(&d, hws, &host); |
115 | 103 | if (ret) | |
116 | ide_device_add(idx, &d); | 104 | goto out; |
117 | 105 | ||
118 | platform_set_drvdata(pdev, hwif); | 106 | platform_set_drvdata(pdev, host); |
119 | 107 | ||
120 | return 0; | 108 | return 0; |
121 | 109 | ||
@@ -125,9 +113,9 @@ out: | |||
125 | 113 | ||
126 | static int __devexit plat_ide_remove(struct platform_device *pdev) | 114 | static int __devexit plat_ide_remove(struct platform_device *pdev) |
127 | { | 115 | { |
128 | ide_hwif_t *hwif = pdev->dev.driver_data; | 116 | struct ide_host *host = pdev->dev.driver_data; |
129 | 117 | ||
130 | ide_unregister(hwif); | 118 | ide_host_remove(host); |
131 | 119 | ||
132 | return 0; | 120 | return 0; |
133 | } | 121 | } |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index 0a6195bcfeda..a0bb167980e7 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
@@ -91,11 +91,10 @@ static const char *mac_ide_name[] = | |||
91 | 91 | ||
92 | static int __init macide_init(void) | 92 | static int __init macide_init(void) |
93 | { | 93 | { |
94 | ide_hwif_t *hwif; | ||
95 | ide_ack_intr_t *ack_intr; | 94 | ide_ack_intr_t *ack_intr; |
96 | unsigned long base; | 95 | unsigned long base; |
97 | int irq; | 96 | int irq; |
98 | hw_regs_t hw; | 97 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
99 | 98 | ||
100 | if (!MACH_IS_MAC) | 99 | if (!MACH_IS_MAC) |
101 | return -ENODEV; | 100 | return -ENODEV; |
@@ -125,17 +124,7 @@ static int __init macide_init(void) | |||
125 | 124 | ||
126 | macide_setup_ports(&hw, base, irq, ack_intr); | 125 | macide_setup_ports(&hw, base, irq, ack_intr); |
127 | 126 | ||
128 | hwif = ide_find_port(); | 127 | return ide_host_add(NULL, hws, NULL); |
129 | if (hwif) { | ||
130 | u8 index = hwif->index; | ||
131 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | ||
132 | |||
133 | ide_init_port_hw(hwif, &hw); | ||
134 | |||
135 | ide_device_add(idx, NULL); | ||
136 | } | ||
137 | |||
138 | return 0; | ||
139 | } | 128 | } |
140 | 129 | ||
141 | module_init(macide_init); | 130 | module_init(macide_init); |
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index 9c2b9d078f69..4abd8fc78197 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
@@ -96,6 +96,27 @@ static void q40ide_output_data(ide_drive_t *drive, struct request *rq, | |||
96 | outsw_swapw(data_addr, buf, (len + 1) / 2); | 96 | outsw_swapw(data_addr, buf, (len + 1) / 2); |
97 | } | 97 | } |
98 | 98 | ||
99 | /* Q40 has a byte-swapped IDE interface */ | ||
100 | static const struct ide_tp_ops q40ide_tp_ops = { | ||
101 | .exec_command = ide_exec_command, | ||
102 | .read_status = ide_read_status, | ||
103 | .read_altstatus = ide_read_altstatus, | ||
104 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
105 | |||
106 | .set_irq = ide_set_irq, | ||
107 | |||
108 | .tf_load = ide_tf_load, | ||
109 | .tf_read = ide_tf_read, | ||
110 | |||
111 | .input_data = q40ide_input_data, | ||
112 | .output_data = q40ide_output_data, | ||
113 | }; | ||
114 | |||
115 | static const struct ide_port_info q40ide_port_info = { | ||
116 | .tp_ops = &q40ide_tp_ops, | ||
117 | .host_flags = IDE_HFLAG_NO_DMA, | ||
118 | }; | ||
119 | |||
99 | /* | 120 | /* |
100 | * the static array is needed to have the name reported in /proc/ioports, | 121 | * the static array is needed to have the name reported in /proc/ioports, |
101 | * hwif->name unfortunately isn't available yet | 122 | * hwif->name unfortunately isn't available yet |
@@ -111,9 +132,7 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={ | |||
111 | static int __init q40ide_init(void) | 132 | static int __init q40ide_init(void) |
112 | { | 133 | { |
113 | int i; | 134 | int i; |
114 | ide_hwif_t *hwif; | 135 | hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; |
115 | const char *name; | ||
116 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
117 | 136 | ||
118 | if (!MACH_IS_Q40) | 137 | if (!MACH_IS_Q40) |
119 | return -ENODEV; | 138 | return -ENODEV; |
@@ -121,9 +140,8 @@ static int __init q40ide_init(void) | |||
121 | printk(KERN_INFO "ide: Q40 IDE controller\n"); | 140 | printk(KERN_INFO "ide: Q40 IDE controller\n"); |
122 | 141 | ||
123 | for (i = 0; i < Q40IDE_NUM_HWIFS; i++) { | 142 | for (i = 0; i < Q40IDE_NUM_HWIFS; i++) { |
124 | hw_regs_t hw; | 143 | const char *name = q40_ide_names[i]; |
125 | 144 | ||
126 | name = q40_ide_names[i]; | ||
127 | if (!request_region(pcide_bases[i], 8, name)) { | 145 | if (!request_region(pcide_bases[i], 8, name)) { |
128 | printk("could not reserve ports %lx-%lx for %s\n", | 146 | printk("could not reserve ports %lx-%lx for %s\n", |
129 | pcide_bases[i],pcide_bases[i]+8,name); | 147 | pcide_bases[i],pcide_bases[i]+8,name); |
@@ -135,26 +153,13 @@ static int __init q40ide_init(void) | |||
135 | release_region(pcide_bases[i], 8); | 153 | release_region(pcide_bases[i], 8); |
136 | continue; | 154 | continue; |
137 | } | 155 | } |
138 | q40_ide_setup_ports(&hw, pcide_bases[i], | 156 | q40_ide_setup_ports(&hw[i], pcide_bases[i], NULL, |
139 | NULL, | ||
140 | // m68kide_iops, | ||
141 | q40ide_default_irq(pcide_bases[i])); | 157 | q40ide_default_irq(pcide_bases[i])); |
142 | 158 | ||
143 | hwif = ide_find_port(); | 159 | hws[i] = &hw[i]; |
144 | if (hwif) { | ||
145 | ide_init_port_hw(hwif, &hw); | ||
146 | |||
147 | /* Q40 has a byte-swapped IDE interface */ | ||
148 | hwif->input_data = q40ide_input_data; | ||
149 | hwif->output_data = q40ide_output_data; | ||
150 | |||
151 | idx[i] = hwif->index; | ||
152 | } | ||
153 | } | 160 | } |
154 | 161 | ||
155 | ide_device_add(idx, NULL); | 162 | return ide_host_add(&q40ide_port_info, hws, NULL); |
156 | |||
157 | return 0; | ||
158 | } | 163 | } |
159 | 164 | ||
160 | module_init(q40ide_init); | 165 | module_init(q40ide_init); |
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index 48d57cae63c6..11b7f61aae40 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
@@ -519,6 +519,23 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) | |||
519 | *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT); | 519 | *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT); |
520 | } | 520 | } |
521 | 521 | ||
522 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA | ||
523 | static const struct ide_tp_ops au1xxx_tp_ops = { | ||
524 | .exec_command = ide_exec_command, | ||
525 | .read_status = ide_read_status, | ||
526 | .read_altstatus = ide_read_altstatus, | ||
527 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
528 | |||
529 | .set_irq = ide_set_irq, | ||
530 | |||
531 | .tf_load = ide_tf_load, | ||
532 | .tf_read = ide_tf_read, | ||
533 | |||
534 | .input_data = au1xxx_input_data, | ||
535 | .output_data = au1xxx_output_data, | ||
536 | }; | ||
537 | #endif | ||
538 | |||
522 | static const struct ide_port_ops au1xxx_port_ops = { | 539 | static const struct ide_port_ops au1xxx_port_ops = { |
523 | .set_pio_mode = au1xxx_set_pio_mode, | 540 | .set_pio_mode = au1xxx_set_pio_mode, |
524 | .set_dma_mode = auide_set_dma_mode, | 541 | .set_dma_mode = auide_set_dma_mode, |
@@ -526,6 +543,9 @@ static const struct ide_port_ops au1xxx_port_ops = { | |||
526 | 543 | ||
527 | static const struct ide_port_info au1xxx_port_info = { | 544 | static const struct ide_port_info au1xxx_port_info = { |
528 | .init_dma = auide_ddma_init, | 545 | .init_dma = auide_ddma_init, |
546 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA | ||
547 | .tp_ops = &au1xxx_tp_ops, | ||
548 | #endif | ||
529 | .port_ops = &au1xxx_port_ops, | 549 | .port_ops = &au1xxx_port_ops, |
530 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 550 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
531 | .dma_ops = &au1xxx_dma_ops, | 551 | .dma_ops = &au1xxx_dma_ops, |
@@ -543,11 +563,10 @@ static int au_ide_probe(struct device *dev) | |||
543 | { | 563 | { |
544 | struct platform_device *pdev = to_platform_device(dev); | 564 | struct platform_device *pdev = to_platform_device(dev); |
545 | _auide_hwif *ahwif = &auide_hwif; | 565 | _auide_hwif *ahwif = &auide_hwif; |
546 | ide_hwif_t *hwif; | ||
547 | struct resource *res; | 566 | struct resource *res; |
567 | struct ide_host *host; | ||
548 | int ret = 0; | 568 | int ret = 0; |
549 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 569 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
550 | hw_regs_t hw; | ||
551 | 570 | ||
552 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) | 571 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) |
553 | char *mode = "MWDMA2"; | 572 | char *mode = "MWDMA2"; |
@@ -584,36 +603,19 @@ static int au_ide_probe(struct device *dev) | |||
584 | goto out; | 603 | goto out; |
585 | } | 604 | } |
586 | 605 | ||
587 | hwif = ide_find_port(); | ||
588 | if (hwif == NULL) { | ||
589 | ret = -ENOENT; | ||
590 | goto out; | ||
591 | } | ||
592 | |||
593 | memset(&hw, 0, sizeof(hw)); | 606 | memset(&hw, 0, sizeof(hw)); |
594 | auide_setup_ports(&hw, ahwif); | 607 | auide_setup_ports(&hw, ahwif); |
595 | hw.irq = ahwif->irq; | 608 | hw.irq = ahwif->irq; |
596 | hw.dev = dev; | 609 | hw.dev = dev; |
597 | hw.chipset = ide_au1xxx; | 610 | hw.chipset = ide_au1xxx; |
598 | 611 | ||
599 | ide_init_port_hw(hwif, &hw); | 612 | ret = ide_host_add(&au1xxx_port_info, hws, &host); |
600 | 613 | if (ret) | |
601 | /* If the user has selected DDMA assisted copies, | 614 | goto out; |
602 | then set up a few local I/O function entry points | ||
603 | */ | ||
604 | |||
605 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA | ||
606 | hwif->input_data = au1xxx_input_data; | ||
607 | hwif->output_data = au1xxx_output_data; | ||
608 | #endif | ||
609 | |||
610 | auide_hwif.hwif = hwif; | ||
611 | |||
612 | idx[0] = hwif->index; | ||
613 | 615 | ||
614 | ide_device_add(idx, &au1xxx_port_info); | 616 | auide_hwif.hwif = host->ports[0]; |
615 | 617 | ||
616 | dev_set_drvdata(dev, hwif); | 618 | dev_set_drvdata(dev, host); |
617 | 619 | ||
618 | printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); | 620 | printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); |
619 | 621 | ||
@@ -625,10 +627,10 @@ static int au_ide_remove(struct device *dev) | |||
625 | { | 627 | { |
626 | struct platform_device *pdev = to_platform_device(dev); | 628 | struct platform_device *pdev = to_platform_device(dev); |
627 | struct resource *res; | 629 | struct resource *res; |
628 | ide_hwif_t *hwif = dev_get_drvdata(dev); | 630 | struct ide_host *host = dev_get_drvdata(dev); |
629 | _auide_hwif *ahwif = &auide_hwif; | 631 | _auide_hwif *ahwif = &auide_hwif; |
630 | 632 | ||
631 | ide_unregister(hwif); | 633 | ide_host_remove(host); |
632 | 634 | ||
633 | iounmap((void *)ahwif->regbase); | 635 | iounmap((void *)ahwif->regbase); |
634 | 636 | ||
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c index 9f1212cc4aed..badf79fc9e3a 100644 --- a/drivers/ide/mips/swarm.c +++ b/drivers/ide/mips/swarm.c | |||
@@ -72,12 +72,11 @@ static const struct ide_port_info swarm_port_info = { | |||
72 | */ | 72 | */ |
73 | static int __devinit swarm_ide_probe(struct device *dev) | 73 | static int __devinit swarm_ide_probe(struct device *dev) |
74 | { | 74 | { |
75 | ide_hwif_t *hwif; | ||
76 | u8 __iomem *base; | 75 | u8 __iomem *base; |
76 | struct ide_host *host; | ||
77 | phys_t offset, size; | 77 | phys_t offset, size; |
78 | hw_regs_t hw; | 78 | int i, rc; |
79 | int i; | 79 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
80 | u8 idx[] = { 0xff, 0xff, 0xff, 0xff }; | ||
81 | 80 | ||
82 | if (!SIBYTE_HAVE_IDE) | 81 | if (!SIBYTE_HAVE_IDE) |
83 | return -ENODEV; | 82 | return -ENODEV; |
@@ -116,26 +115,17 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
116 | hw.irq = K_INT_GB_IDE; | 115 | hw.irq = K_INT_GB_IDE; |
117 | hw.chipset = ide_generic; | 116 | hw.chipset = ide_generic; |
118 | 117 | ||
119 | hwif = ide_find_port_slot(&swarm_port_info); | 118 | rc = ide_host_add(&swarm_port_info, hws, &host); |
120 | if (hwif == NULL) | 119 | if (rc) |
121 | goto err; | 120 | goto err; |
122 | 121 | ||
123 | ide_init_port_hw(hwif, &hw); | 122 | dev_set_drvdata(dev, host); |
124 | |||
125 | /* Setup MMIO ops. */ | ||
126 | default_hwif_mmiops(hwif); | ||
127 | |||
128 | idx[0] = hwif->index; | ||
129 | |||
130 | ide_device_add(idx, &swarm_port_info); | ||
131 | |||
132 | dev_set_drvdata(dev, hwif); | ||
133 | 123 | ||
134 | return 0; | 124 | return 0; |
135 | err: | 125 | err: |
136 | release_resource(&swarm_ide_resource); | 126 | release_resource(&swarm_ide_resource); |
137 | iounmap(base); | 127 | iounmap(base); |
138 | return -ENOMEM; | 128 | return rc; |
139 | } | 129 | } |
140 | 130 | ||
141 | static struct device_driver swarm_ide_driver = { | 131 | static struct device_driver swarm_ide_driver = { |
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index ae7a4329a581..fbc43e121e6b 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -195,7 +195,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
195 | .host_flags = IDE_HFLAG_SERIALIZE | | 195 | .host_flags = IDE_HFLAG_SERIALIZE | |
196 | IDE_HFLAG_NO_ATAPI_DMA | | 196 | IDE_HFLAG_NO_ATAPI_DMA | |
197 | IDE_HFLAG_NO_DSC | | 197 | IDE_HFLAG_NO_DSC | |
198 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | ||
199 | IDE_HFLAG_OFF_BOARD, | 198 | IDE_HFLAG_OFF_BOARD, |
200 | .pio_mask = ATA_PIO4, | 199 | .pio_mask = ATA_PIO4, |
201 | .mwdma_mask = ATA_MWDMA2, | 200 | .mwdma_mask = ATA_MWDMA2, |
@@ -205,7 +204,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
205 | .init_chipset = init_chipset_aec62xx, | 204 | .init_chipset = init_chipset_aec62xx, |
206 | .port_ops = &atp86x_port_ops, | 205 | .port_ops = &atp86x_port_ops, |
207 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | | 206 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | |
208 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | ||
209 | IDE_HFLAG_OFF_BOARD, | 207 | IDE_HFLAG_OFF_BOARD, |
210 | .pio_mask = ATA_PIO4, | 208 | .pio_mask = ATA_PIO4, |
211 | .mwdma_mask = ATA_MWDMA2, | 209 | .mwdma_mask = ATA_MWDMA2, |
@@ -216,7 +214,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
216 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 214 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
217 | .port_ops = &atp86x_port_ops, | 215 | .port_ops = &atp86x_port_ops, |
218 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 216 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
219 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | ||
220 | IDE_HFLAG_NON_BOOTABLE, | 217 | IDE_HFLAG_NON_BOOTABLE, |
221 | .pio_mask = ATA_PIO4, | 218 | .pio_mask = ATA_PIO4, |
222 | .mwdma_mask = ATA_MWDMA2, | 219 | .mwdma_mask = ATA_MWDMA2, |
@@ -226,7 +223,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
226 | .init_chipset = init_chipset_aec62xx, | 223 | .init_chipset = init_chipset_aec62xx, |
227 | .port_ops = &atp86x_port_ops, | 224 | .port_ops = &atp86x_port_ops, |
228 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 225 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
229 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | ||
230 | IDE_HFLAG_OFF_BOARD, | 226 | IDE_HFLAG_OFF_BOARD, |
231 | .pio_mask = ATA_PIO4, | 227 | .pio_mask = ATA_PIO4, |
232 | .mwdma_mask = ATA_MWDMA2, | 228 | .mwdma_mask = ATA_MWDMA2, |
@@ -237,7 +233,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
237 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 233 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
238 | .port_ops = &atp86x_port_ops, | 234 | .port_ops = &atp86x_port_ops, |
239 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 235 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
240 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | ||
241 | IDE_HFLAG_OFF_BOARD, | 236 | IDE_HFLAG_OFF_BOARD, |
242 | .pio_mask = ATA_PIO4, | 237 | .pio_mask = ATA_PIO4, |
243 | .mwdma_mask = ATA_MWDMA2, | 238 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 80d19c0eb780..5ef7817ac64f 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -471,7 +471,15 @@ static int __devinit init_dma_ali15x3(ide_hwif_t *hwif, | |||
471 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 471 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
472 | unsigned long base = ide_pci_dma_base(hwif, d); | 472 | unsigned long base = ide_pci_dma_base(hwif, d); |
473 | 473 | ||
474 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | 474 | if (base == 0) |
475 | return -1; | ||
476 | |||
477 | hwif->dma_base = base; | ||
478 | |||
479 | if (ide_pci_check_simplex(hwif, d) < 0) | ||
480 | return -1; | ||
481 | |||
482 | if (ide_pci_set_master(dev, d->name) < 0) | ||
475 | return -1; | 483 | return -1; |
476 | 484 | ||
477 | if (!hwif->channel) | 485 | if (!hwif->channel) |
@@ -483,7 +491,7 @@ static int __devinit init_dma_ali15x3(ide_hwif_t *hwif, | |||
483 | if (ide_allocate_dma_engine(hwif)) | 491 | if (ide_allocate_dma_engine(hwif)) |
484 | return -1; | 492 | return -1; |
485 | 493 | ||
486 | ide_setup_dma(hwif, base); | 494 | hwif->dma_ops = &sff_dma_ops; |
487 | 495 | ||
488 | return 0; | 496 | return 0; |
489 | } | 497 | } |
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 0bfcdd0e77b3..ef7d971031ee 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -218,7 +218,6 @@ static const struct ide_port_ops amd_port_ops = { | |||
218 | 218 | ||
219 | #define IDE_HFLAGS_AMD \ | 219 | #define IDE_HFLAGS_AMD \ |
220 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ | 220 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ |
221 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | ||
222 | IDE_HFLAG_POST_SET_MODE | \ | 221 | IDE_HFLAG_POST_SET_MODE | \ |
223 | IDE_HFLAG_IO_32BIT | \ | 222 | IDE_HFLAG_IO_32BIT | \ |
224 | IDE_HFLAG_UNMASK_IRQS) | 223 | IDE_HFLAG_UNMASK_IRQS) |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index 1ad1e23e3105..e6c62006ca1a 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -181,11 +181,6 @@ static u8 recovery_counts[4] = {16, 16, 16, 16}; /* Recovery count (encoded) */ | |||
181 | static DEFINE_SPINLOCK(cmd640_lock); | 181 | static DEFINE_SPINLOCK(cmd640_lock); |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * These are initialized to point at the devices we control | ||
185 | */ | ||
186 | static ide_hwif_t *cmd_hwif0, *cmd_hwif1; | ||
187 | |||
188 | /* | ||
189 | * Interface to access cmd640x registers | 184 | * Interface to access cmd640x registers |
190 | */ | 185 | */ |
191 | static unsigned int cmd640_key; | 186 | static unsigned int cmd640_key; |
@@ -717,8 +712,7 @@ static int __init cmd640x_init(void) | |||
717 | int second_port_cmd640 = 0, rc; | 712 | int second_port_cmd640 = 0, rc; |
718 | const char *bus_type, *port2; | 713 | const char *bus_type, *port2; |
719 | u8 b, cfr; | 714 | u8 b, cfr; |
720 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 715 | hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; |
721 | hw_regs_t hw[2]; | ||
722 | 716 | ||
723 | if (cmd640_vlb && probe_for_cmd640_vlb()) { | 717 | if (cmd640_vlb && probe_for_cmd640_vlb()) { |
724 | bus_type = "VLB"; | 718 | bus_type = "VLB"; |
@@ -781,15 +775,10 @@ static int __init cmd640x_init(void) | |||
781 | printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" | 775 | printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" |
782 | "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); | 776 | "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); |
783 | 777 | ||
784 | cmd_hwif0 = ide_find_port(); | ||
785 | |||
786 | /* | 778 | /* |
787 | * Initialize data for primary port | 779 | * Initialize data for primary port |
788 | */ | 780 | */ |
789 | if (cmd_hwif0) { | 781 | hws[0] = &hw[0]; |
790 | ide_init_port_hw(cmd_hwif0, &hw[0]); | ||
791 | idx[0] = cmd_hwif0->index; | ||
792 | } | ||
793 | 782 | ||
794 | /* | 783 | /* |
795 | * Ensure compatibility by always using the slowest timings | 784 | * Ensure compatibility by always using the slowest timings |
@@ -829,13 +818,9 @@ static int __init cmd640x_init(void) | |||
829 | /* | 818 | /* |
830 | * Initialize data for secondary cmd640 port, if enabled | 819 | * Initialize data for secondary cmd640 port, if enabled |
831 | */ | 820 | */ |
832 | if (second_port_cmd640) { | 821 | if (second_port_cmd640) |
833 | cmd_hwif1 = ide_find_port(); | 822 | hws[1] = &hw[1]; |
834 | if (cmd_hwif1) { | 823 | |
835 | ide_init_port_hw(cmd_hwif1, &hw[1]); | ||
836 | idx[1] = cmd_hwif1->index; | ||
837 | } | ||
838 | } | ||
839 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", | 824 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", |
840 | second_port_cmd640 ? "" : "not ", port2); | 825 | second_port_cmd640 ? "" : "not ", port2); |
841 | 826 | ||
@@ -843,9 +828,7 @@ static int __init cmd640x_init(void) | |||
843 | cmd640_dump_regs(); | 828 | cmd640_dump_regs(); |
844 | #endif | 829 | #endif |
845 | 830 | ||
846 | ide_device_add(idx, &cmd640_port_info); | 831 | return ide_host_add(&cmd640_port_info, hws, NULL); |
847 | |||
848 | return 1; | ||
849 | } | 832 | } |
850 | 833 | ||
851 | module_param_named(probe_vlb, cmd640_vlb, bool, 0); | 834 | module_param_named(probe_vlb, cmd640_vlb, bool, 0); |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index cfa784bacf48..ce58bfcdb3c6 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -262,7 +262,7 @@ static int cmd648_dma_test_irq(ide_drive_t *drive) | |||
262 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 262 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
263 | u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : | 263 | u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : |
264 | MRDMODE_INTR_CH0; | 264 | MRDMODE_INTR_CH0; |
265 | u8 dma_stat = inb(hwif->dma_status); | 265 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
266 | u8 mrdmode = inb(base + 1); | 266 | u8 mrdmode = inb(base + 1); |
267 | 267 | ||
268 | #ifdef DEBUG | 268 | #ifdef DEBUG |
@@ -286,7 +286,7 @@ static int cmd64x_dma_test_irq(ide_drive_t *drive) | |||
286 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; | 286 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; |
287 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : | 287 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : |
288 | CFR_INTR_CH0; | 288 | CFR_INTR_CH0; |
289 | u8 dma_stat = inb(hwif->dma_status); | 289 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
290 | u8 irq_stat = 0; | 290 | u8 irq_stat = 0; |
291 | 291 | ||
292 | (void) pci_read_config_byte(dev, irq_reg, &irq_stat); | 292 | (void) pci_read_config_byte(dev, irq_reg, &irq_stat); |
@@ -317,13 +317,13 @@ static int cmd646_1_dma_end(ide_drive_t *drive) | |||
317 | 317 | ||
318 | drive->waiting_for_dma = 0; | 318 | drive->waiting_for_dma = 0; |
319 | /* get DMA status */ | 319 | /* get DMA status */ |
320 | dma_stat = inb(hwif->dma_status); | 320 | dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
321 | /* read DMA command state */ | 321 | /* read DMA command state */ |
322 | dma_cmd = inb(hwif->dma_command); | 322 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
323 | /* stop DMA */ | 323 | /* stop DMA */ |
324 | outb(dma_cmd & ~1, hwif->dma_command); | 324 | outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); |
325 | /* clear the INTR & ERROR bits */ | 325 | /* clear the INTR & ERROR bits */ |
326 | outb(dma_stat | 6, hwif->dma_status); | 326 | outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); |
327 | /* and free any DMA resources */ | 327 | /* and free any DMA resources */ |
328 | ide_destroy_dmatable(drive); | 328 | ide_destroy_dmatable(drive); |
329 | /* verify good DMA status */ | 329 | /* verify good DMA status */ |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index 992b1cf8db69..b03d8ae947e6 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -62,8 +62,6 @@ static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
62 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 62 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
63 | int controller = drive->dn > 1 ? 1 : 0; | 63 | int controller = drive->dn > 1 ? 1 : 0; |
64 | 64 | ||
65 | /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */ | ||
66 | |||
67 | /* 8bit CAT/CRT - 8bit command timing for channel */ | 65 | /* 8bit CAT/CRT - 8bit command timing for channel */ |
68 | pci_write_config_byte(pdev, 0x62 + controller, | 66 | pci_write_config_byte(pdev, 0x62 + controller, |
69 | (cs5520_pio_clocks[pio].recovery << 4) | | 67 | (cs5520_pio_clocks[pio].recovery << 4) | |
@@ -89,46 +87,17 @@ static void cs5520_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
89 | cs5520_set_pio_mode(drive, 0); | 87 | cs5520_set_pio_mode(drive, 0); |
90 | } | 88 | } |
91 | 89 | ||
92 | /* | ||
93 | * We wrap the DMA activate to set the vdma flag. This is needed | ||
94 | * so that the IDE DMA layer issues PIO not DMA commands over the | ||
95 | * DMA channel | ||
96 | * | ||
97 | * ATAPI is harder so disable it for now using IDE_HFLAG_NO_ATAPI_DMA | ||
98 | */ | ||
99 | |||
100 | static void cs5520_dma_host_set(ide_drive_t *drive, int on) | ||
101 | { | ||
102 | drive->vdma = on; | ||
103 | ide_dma_host_set(drive, on); | ||
104 | } | ||
105 | |||
106 | static const struct ide_port_ops cs5520_port_ops = { | 90 | static const struct ide_port_ops cs5520_port_ops = { |
107 | .set_pio_mode = cs5520_set_pio_mode, | 91 | .set_pio_mode = cs5520_set_pio_mode, |
108 | .set_dma_mode = cs5520_set_dma_mode, | 92 | .set_dma_mode = cs5520_set_dma_mode, |
109 | }; | 93 | }; |
110 | 94 | ||
111 | static const struct ide_dma_ops cs5520_dma_ops = { | ||
112 | .dma_host_set = cs5520_dma_host_set, | ||
113 | .dma_setup = ide_dma_setup, | ||
114 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
115 | .dma_start = ide_dma_start, | ||
116 | .dma_end = __ide_dma_end, | ||
117 | .dma_test_irq = ide_dma_test_irq, | ||
118 | .dma_lost_irq = ide_dma_lost_irq, | ||
119 | .dma_timeout = ide_dma_timeout, | ||
120 | }; | ||
121 | |||
122 | /* FIXME: VDMA is disabled because it caused system hangs */ | ||
123 | #define DECLARE_CS_DEV(name_str) \ | 95 | #define DECLARE_CS_DEV(name_str) \ |
124 | { \ | 96 | { \ |
125 | .name = name_str, \ | 97 | .name = name_str, \ |
126 | .port_ops = &cs5520_port_ops, \ | 98 | .port_ops = &cs5520_port_ops, \ |
127 | .dma_ops = &cs5520_dma_ops, \ | ||
128 | .host_flags = IDE_HFLAG_ISA_PORTS | \ | 99 | .host_flags = IDE_HFLAG_ISA_PORTS | \ |
129 | IDE_HFLAG_CS5520 | \ | 100 | IDE_HFLAG_CS5520, \ |
130 | IDE_HFLAG_NO_ATAPI_DMA | \ | ||
131 | IDE_HFLAG_ABUSE_SET_DMA_MODE, \ | ||
132 | .pio_mask = ATA_PIO4, \ | 101 | .pio_mask = ATA_PIO4, \ |
133 | } | 102 | } |
134 | 103 | ||
@@ -146,7 +115,7 @@ static const struct ide_port_info cyrix_chipsets[] __devinitdata = { | |||
146 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 115 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
147 | { | 116 | { |
148 | const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; | 117 | const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; |
149 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 118 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
150 | 119 | ||
151 | ide_setup_pci_noise(dev, d); | 120 | ide_setup_pci_noise(dev, d); |
152 | 121 | ||
@@ -168,11 +137,9 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic | |||
168 | * do all the device setup for us | 137 | * do all the device setup for us |
169 | */ | 138 | */ |
170 | 139 | ||
171 | ide_pci_setup_ports(dev, d, 14, &idx[0]); | 140 | ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]); |
172 | |||
173 | ide_device_add(idx, d); | ||
174 | 141 | ||
175 | return 0; | 142 | return ide_host_add(d, hws, NULL); |
176 | } | 143 | } |
177 | 144 | ||
178 | static const struct pci_device_id cs5520_pci_tbl[] = { | 145 | static const struct pci_device_id cs5520_pci_tbl[] = { |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index dc97c48623f3..5404fe4f701d 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -171,8 +171,7 @@ static const struct ide_port_ops cs5535_port_ops = { | |||
171 | static const struct ide_port_info cs5535_chipset __devinitdata = { | 171 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
172 | .name = "CS5535", | 172 | .name = "CS5535", |
173 | .port_ops = &cs5535_port_ops, | 173 | .port_ops = &cs5535_port_ops, |
174 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | | 174 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE, |
175 | IDE_HFLAG_ABUSE_SET_DMA_MODE, | ||
176 | .pio_mask = ATA_PIO4, | 175 | .pio_mask = ATA_PIO4, |
177 | .mwdma_mask = ATA_MWDMA2, | 176 | .mwdma_mask = ATA_MWDMA2, |
178 | .udma_mask = ATA_UDMA4, | 177 | .udma_mask = ATA_UDMA4, |
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 0106e2a2df77..f84bfb4f600f 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
@@ -56,11 +56,10 @@ static const struct ide_port_info delkin_cb_port_info = { | |||
56 | static int __devinit | 56 | static int __devinit |
57 | delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | 57 | delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) |
58 | { | 58 | { |
59 | struct ide_host *host; | ||
59 | unsigned long base; | 60 | unsigned long base; |
60 | hw_regs_t hw; | ||
61 | ide_hwif_t *hwif = NULL; | ||
62 | int i, rc; | 61 | int i, rc; |
63 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 62 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
64 | 63 | ||
65 | rc = pci_enable_device(dev); | 64 | rc = pci_enable_device(dev); |
66 | if (rc) { | 65 | if (rc) { |
@@ -87,34 +86,26 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
87 | hw.dev = &dev->dev; | 86 | hw.dev = &dev->dev; |
88 | hw.chipset = ide_pci; /* this enables IRQ sharing */ | 87 | hw.chipset = ide_pci; /* this enables IRQ sharing */ |
89 | 88 | ||
90 | hwif = ide_find_port(); | 89 | rc = ide_host_add(&delkin_cb_port_info, hws, &host); |
91 | if (hwif == NULL) | 90 | if (rc) |
92 | goto out_disable; | 91 | goto out_disable; |
93 | 92 | ||
94 | i = hwif->index; | 93 | pci_set_drvdata(dev, host); |
95 | |||
96 | ide_init_port_hw(hwif, &hw); | ||
97 | |||
98 | idx[0] = i; | ||
99 | |||
100 | ide_device_add(idx, &delkin_cb_port_info); | ||
101 | |||
102 | pci_set_drvdata(dev, hwif); | ||
103 | 94 | ||
104 | return 0; | 95 | return 0; |
105 | 96 | ||
106 | out_disable: | 97 | out_disable: |
107 | pci_release_regions(dev); | 98 | pci_release_regions(dev); |
108 | pci_disable_device(dev); | 99 | pci_disable_device(dev); |
109 | return -ENODEV; | 100 | return rc; |
110 | } | 101 | } |
111 | 102 | ||
112 | static void | 103 | static void |
113 | delkin_cb_remove (struct pci_dev *dev) | 104 | delkin_cb_remove (struct pci_dev *dev) |
114 | { | 105 | { |
115 | ide_hwif_t *hwif = pci_get_drvdata(dev); | 106 | struct ide_host *host = pci_get_drvdata(dev); |
116 | 107 | ||
117 | ide_unregister(hwif); | 108 | ide_host_remove(host); |
118 | 109 | ||
119 | pci_release_regions(dev); | 110 | pci_release_regions(dev); |
120 | pci_disable_device(dev); | 111 | pci_disable_device(dev); |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 84c36c117194..9e1d1c4741da 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -123,7 +123,6 @@ static const struct ide_port_ops hpt34x_port_ops = { | |||
123 | #define IDE_HFLAGS_HPT34X \ | 123 | #define IDE_HFLAGS_HPT34X \ |
124 | (IDE_HFLAG_NO_ATAPI_DMA | \ | 124 | (IDE_HFLAG_NO_ATAPI_DMA | \ |
125 | IDE_HFLAG_NO_DSC | \ | 125 | IDE_HFLAG_NO_DSC | \ |
126 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | ||
127 | IDE_HFLAG_NO_AUTODMA) | 126 | IDE_HFLAG_NO_AUTODMA) |
128 | 127 | ||
129 | static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { | 128 | static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 397c6cbe953c..1f1135ce7cd6 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -801,9 +801,9 @@ static void hpt370_irq_timeout(ide_drive_t *drive) | |||
801 | printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff); | 801 | printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff); |
802 | 802 | ||
803 | /* get DMA command mode */ | 803 | /* get DMA command mode */ |
804 | dma_cmd = inb(hwif->dma_command); | 804 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
805 | /* stop DMA */ | 805 | /* stop DMA */ |
806 | outb(dma_cmd & ~0x1, hwif->dma_command); | 806 | outb(dma_cmd & ~0x1, hwif->dma_base + ATA_DMA_CMD); |
807 | hpt370_clear_engine(drive); | 807 | hpt370_clear_engine(drive); |
808 | } | 808 | } |
809 | 809 | ||
@@ -818,12 +818,12 @@ static void hpt370_dma_start(ide_drive_t *drive) | |||
818 | static int hpt370_dma_end(ide_drive_t *drive) | 818 | static int hpt370_dma_end(ide_drive_t *drive) |
819 | { | 819 | { |
820 | ide_hwif_t *hwif = HWIF(drive); | 820 | ide_hwif_t *hwif = HWIF(drive); |
821 | u8 dma_stat = inb(hwif->dma_status); | 821 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
822 | 822 | ||
823 | if (dma_stat & 0x01) { | 823 | if (dma_stat & 0x01) { |
824 | /* wait a little */ | 824 | /* wait a little */ |
825 | udelay(20); | 825 | udelay(20); |
826 | dma_stat = inb(hwif->dma_status); | 826 | dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
827 | if (dma_stat & 0x01) | 827 | if (dma_stat & 0x01) |
828 | hpt370_irq_timeout(drive); | 828 | hpt370_irq_timeout(drive); |
829 | } | 829 | } |
@@ -850,7 +850,7 @@ static int hpt374_dma_test_irq(ide_drive_t *drive) | |||
850 | return 0; | 850 | return 0; |
851 | } | 851 | } |
852 | 852 | ||
853 | dma_stat = inb(hwif->dma_status); | 853 | dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
854 | /* return 1 if INTR asserted */ | 854 | /* return 1 if INTR asserted */ |
855 | if (dma_stat & 4) | 855 | if (dma_stat & 4) |
856 | return 1; | 856 | return 1; |
@@ -1320,7 +1320,15 @@ static int __devinit init_dma_hpt366(ide_hwif_t *hwif, | |||
1320 | unsigned long flags, base = ide_pci_dma_base(hwif, d); | 1320 | unsigned long flags, base = ide_pci_dma_base(hwif, d); |
1321 | u8 dma_old, dma_new, masterdma = 0, slavedma = 0; | 1321 | u8 dma_old, dma_new, masterdma = 0, slavedma = 0; |
1322 | 1322 | ||
1323 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | 1323 | if (base == 0) |
1324 | return -1; | ||
1325 | |||
1326 | hwif->dma_base = base; | ||
1327 | |||
1328 | if (ide_pci_check_simplex(hwif, d) < 0) | ||
1329 | return -1; | ||
1330 | |||
1331 | if (ide_pci_set_master(dev, d->name) < 0) | ||
1324 | return -1; | 1332 | return -1; |
1325 | 1333 | ||
1326 | dma_old = inb(base + 2); | 1334 | dma_old = inb(base + 2); |
@@ -1346,7 +1354,7 @@ static int __devinit init_dma_hpt366(ide_hwif_t *hwif, | |||
1346 | if (ide_allocate_dma_engine(hwif)) | 1354 | if (ide_allocate_dma_engine(hwif)) |
1347 | return -1; | 1355 | return -1; |
1348 | 1356 | ||
1349 | ide_setup_dma(hwif, base); | 1357 | hwif->dma_ops = &sff_dma_ops; |
1350 | 1358 | ||
1351 | return 0; | 1359 | return 0; |
1352 | } | 1360 | } |
@@ -1401,7 +1409,6 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1401 | 1409 | ||
1402 | #define IDE_HFLAGS_HPT3XX \ | 1410 | #define IDE_HFLAGS_HPT3XX \ |
1403 | (IDE_HFLAG_NO_ATAPI_DMA | \ | 1411 | (IDE_HFLAG_NO_ATAPI_DMA | \ |
1404 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | ||
1405 | IDE_HFLAG_OFF_BOARD) | 1412 | IDE_HFLAG_OFF_BOARD) |
1406 | 1413 | ||
1407 | static const struct ide_port_ops hpt3xx_port_ops = { | 1414 | static const struct ide_port_ops hpt3xx_port_ops = { |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index 45ba71a7182f..5cd2b32ff0ef 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -28,10 +28,6 @@ | |||
28 | */ | 28 | */ |
29 | #include <asm/superio.h> | 29 | #include <asm/superio.h> |
30 | 30 | ||
31 | static unsigned long superio_ide_status[2]; | ||
32 | static unsigned long superio_ide_select[2]; | ||
33 | static unsigned long superio_ide_dma_status[2]; | ||
34 | |||
35 | #define SUPERIO_IDE_MAX_RETRIES 25 | 31 | #define SUPERIO_IDE_MAX_RETRIES 25 |
36 | 32 | ||
37 | /* Because of a defect in Super I/O, all reads of the PCI DMA status | 33 | /* Because of a defect in Super I/O, all reads of the PCI DMA status |
@@ -40,27 +36,28 @@ static unsigned long superio_ide_dma_status[2]; | |||
40 | */ | 36 | */ |
41 | static u8 superio_ide_inb (unsigned long port) | 37 | static u8 superio_ide_inb (unsigned long port) |
42 | { | 38 | { |
43 | if (port == superio_ide_status[0] || | 39 | u8 tmp; |
44 | port == superio_ide_status[1] || | 40 | int retries = SUPERIO_IDE_MAX_RETRIES; |
45 | port == superio_ide_select[0] || | ||
46 | port == superio_ide_select[1] || | ||
47 | port == superio_ide_dma_status[0] || | ||
48 | port == superio_ide_dma_status[1]) { | ||
49 | u8 tmp; | ||
50 | int retries = SUPERIO_IDE_MAX_RETRIES; | ||
51 | 41 | ||
52 | /* printk(" [ reading port 0x%x with retry ] ", port); */ | 42 | /* printk(" [ reading port 0x%x with retry ] ", port); */ |
53 | 43 | ||
54 | do { | 44 | do { |
55 | tmp = inb(port); | 45 | tmp = inb(port); |
56 | if (tmp == 0) | 46 | if (tmp == 0) |
57 | udelay(50); | 47 | udelay(50); |
58 | } while (tmp == 0 && retries-- > 0); | 48 | } while (tmp == 0 && retries-- > 0); |
59 | 49 | ||
60 | return tmp; | 50 | return tmp; |
61 | } | 51 | } |
62 | 52 | ||
63 | return inb(port); | 53 | static u8 superio_read_status(ide_hwif_t *hwif) |
54 | { | ||
55 | return superio_ide_inb(hwif->io_ports.status_addr); | ||
56 | } | ||
57 | |||
58 | static u8 superio_read_sff_dma_status(ide_hwif_t *hwif) | ||
59 | { | ||
60 | return superio_ide_inb(hwif->dma_base + ATA_DMA_STATUS); | ||
64 | } | 61 | } |
65 | 62 | ||
66 | static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | 63 | static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) |
@@ -78,6 +75,8 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
78 | /* be sure we're looking at the low order bits */ | 75 | /* be sure we're looking at the low order bits */ |
79 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | 76 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
80 | 77 | ||
78 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
79 | tf->feature = inb(io_ports->feature_addr); | ||
81 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 80 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
82 | tf->nsect = inb(io_ports->nsect_addr); | 81 | tf->nsect = inb(io_ports->nsect_addr); |
83 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | 82 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) |
@@ -105,36 +104,32 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
105 | } | 104 | } |
106 | } | 105 | } |
107 | 106 | ||
108 | static void __devinit superio_ide_init_iops (struct hwif_s *hwif) | 107 | static const struct ide_tp_ops superio_tp_ops = { |
109 | { | 108 | .exec_command = ide_exec_command, |
110 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 109 | .read_status = superio_read_status, |
111 | u32 base, dmabase; | 110 | .read_altstatus = ide_read_altstatus, |
112 | u8 port = hwif->channel, tmp; | 111 | .read_sff_dma_status = superio_read_sff_dma_status, |
113 | 112 | ||
114 | base = pci_resource_start(pdev, port * 2) & ~3; | 113 | .set_irq = ide_set_irq, |
115 | dmabase = pci_resource_start(pdev, 4) & ~3; | ||
116 | |||
117 | superio_ide_status[port] = base + 7; | ||
118 | superio_ide_select[port] = base + 6; | ||
119 | superio_ide_dma_status[port] = dmabase + (!port ? 2 : 0xa); | ||
120 | |||
121 | /* Clear error/interrupt, enable dma */ | ||
122 | tmp = superio_ide_inb(superio_ide_dma_status[port]); | ||
123 | outb(tmp | 0x66, superio_ide_dma_status[port]); | ||
124 | 114 | ||
125 | hwif->tf_read = superio_tf_read; | 115 | .tf_load = ide_tf_load, |
116 | .tf_read = superio_tf_read, | ||
126 | 117 | ||
127 | /* We need to override inb to workaround a SuperIO errata */ | 118 | .input_data = ide_input_data, |
128 | hwif->INB = superio_ide_inb; | 119 | .output_data = ide_output_data, |
129 | } | 120 | }; |
130 | 121 | ||
131 | static void __devinit init_iops_ns87415(ide_hwif_t *hwif) | 122 | static void __devinit superio_init_iops(struct hwif_s *hwif) |
132 | { | 123 | { |
133 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 124 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
125 | u32 dma_stat; | ||
126 | u8 port = hwif->channel, tmp; | ||
134 | 127 | ||
135 | if (PCI_SLOT(dev->devfn) == 0xE) | 128 | dma_stat = (pci_resource_start(pdev, 4) & ~3) + (!port ? 2 : 0xa); |
136 | /* Built-in - assume it's under superio. */ | 129 | |
137 | superio_ide_init_iops(hwif); | 130 | /* Clear error/interrupt, enable dma */ |
131 | tmp = superio_ide_inb(dma_stat); | ||
132 | outb(tmp | 0x66, dma_stat); | ||
138 | } | 133 | } |
139 | #endif | 134 | #endif |
140 | 135 | ||
@@ -200,14 +195,14 @@ static int ns87415_dma_end(ide_drive_t *drive) | |||
200 | u8 dma_stat = 0, dma_cmd = 0; | 195 | u8 dma_stat = 0, dma_cmd = 0; |
201 | 196 | ||
202 | drive->waiting_for_dma = 0; | 197 | drive->waiting_for_dma = 0; |
203 | dma_stat = hwif->INB(hwif->dma_status); | 198 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
204 | /* get dma command mode */ | 199 | /* get DMA command mode */ |
205 | dma_cmd = hwif->INB(hwif->dma_command); | 200 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
206 | /* stop DMA */ | 201 | /* stop DMA */ |
207 | outb(dma_cmd & ~1, hwif->dma_command); | 202 | outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); |
208 | /* from ERRATA: clear the INTR & ERROR bits */ | 203 | /* from ERRATA: clear the INTR & ERROR bits */ |
209 | dma_cmd = hwif->INB(hwif->dma_command); | 204 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
210 | outb(dma_cmd | 6, hwif->dma_command); | 205 | outb(dma_cmd | 6, hwif->dma_base + ATA_DMA_CMD); |
211 | /* and free any DMA resources */ | 206 | /* and free any DMA resources */ |
212 | ide_destroy_dmatable(drive); | 207 | ide_destroy_dmatable(drive); |
213 | /* verify good DMA status */ | 208 | /* verify good DMA status */ |
@@ -276,7 +271,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
276 | outb(8, hwif->io_ports.ctl_addr); | 271 | outb(8, hwif->io_ports.ctl_addr); |
277 | do { | 272 | do { |
278 | udelay(50); | 273 | udelay(50); |
279 | stat = hwif->INB(hwif->io_ports.status_addr); | 274 | stat = hwif->tp_ops->read_status(hwif); |
280 | if (stat == 0xff) | 275 | if (stat == 0xff) |
281 | break; | 276 | break; |
282 | } while ((stat & BUSY_STAT) && --timeout); | 277 | } while ((stat & BUSY_STAT) && --timeout); |
@@ -291,7 +286,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
291 | if (!hwif->dma_base) | 286 | if (!hwif->dma_base) |
292 | return; | 287 | return; |
293 | 288 | ||
294 | outb(0x60, hwif->dma_status); | 289 | outb(0x60, hwif->dma_base + ATA_DMA_STATUS); |
295 | } | 290 | } |
296 | 291 | ||
297 | static const struct ide_port_ops ns87415_port_ops = { | 292 | static const struct ide_port_ops ns87415_port_ops = { |
@@ -311,9 +306,6 @@ static const struct ide_dma_ops ns87415_dma_ops = { | |||
311 | 306 | ||
312 | static const struct ide_port_info ns87415_chipset __devinitdata = { | 307 | static const struct ide_port_info ns87415_chipset __devinitdata = { |
313 | .name = "NS87415", | 308 | .name = "NS87415", |
314 | #ifdef CONFIG_SUPERIO | ||
315 | .init_iops = init_iops_ns87415, | ||
316 | #endif | ||
317 | .init_hwif = init_hwif_ns87415, | 309 | .init_hwif = init_hwif_ns87415, |
318 | .port_ops = &ns87415_port_ops, | 310 | .port_ops = &ns87415_port_ops, |
319 | .dma_ops = &ns87415_dma_ops, | 311 | .dma_ops = &ns87415_dma_ops, |
@@ -323,7 +315,16 @@ static const struct ide_port_info ns87415_chipset __devinitdata = { | |||
323 | 315 | ||
324 | static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 316 | static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
325 | { | 317 | { |
326 | return ide_setup_pci_device(dev, &ns87415_chipset); | 318 | struct ide_port_info d = ns87415_chipset; |
319 | |||
320 | #ifdef CONFIG_SUPERIO | ||
321 | if (PCI_SLOT(dev->devfn) == 0xE) { | ||
322 | /* Built-in - assume it's under superio. */ | ||
323 | d.init_iops = superio_init_iops; | ||
324 | d.tp_ops = &superio_tp_ops; | ||
325 | } | ||
326 | #endif | ||
327 | return ide_setup_pci_device(dev, &d); | ||
327 | } | 328 | } |
328 | 329 | ||
329 | static const struct pci_device_id ns87415_pci_tbl[] = { | 330 | static const struct pci_device_id ns87415_pci_tbl[] = { |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index fca89eda5c02..e54dc653b8c4 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -206,7 +206,7 @@ static int pdc202xx_dma_test_irq(ide_drive_t *drive) | |||
206 | { | 206 | { |
207 | ide_hwif_t *hwif = HWIF(drive); | 207 | ide_hwif_t *hwif = HWIF(drive); |
208 | unsigned long high_16 = hwif->extra_base - 16; | 208 | unsigned long high_16 = hwif->extra_base - 16; |
209 | u8 dma_stat = inb(hwif->dma_status); | 209 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
210 | u8 sc1d = inb(high_16 + 0x001d); | 210 | u8 sc1d = inb(high_16 + 0x001d); |
211 | 211 | ||
212 | if (hwif->channel) { | 212 | if (hwif->channel) { |
@@ -312,7 +312,6 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
312 | 312 | ||
313 | #define IDE_HFLAGS_PDC202XX \ | 313 | #define IDE_HFLAGS_PDC202XX \ |
314 | (IDE_HFLAG_ERROR_STOPS_FIFO | \ | 314 | (IDE_HFLAG_ERROR_STOPS_FIFO | \ |
315 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | ||
316 | IDE_HFLAG_OFF_BOARD) | 315 | IDE_HFLAG_OFF_BOARD) |
317 | 316 | ||
318 | static const struct ide_port_ops pdc20246_port_ops = { | 317 | static const struct ide_port_ops pdc20246_port_ops = { |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index f04738d14a6f..0ce41b4dddaf 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -227,9 +227,9 @@ static void piix_dma_clear_irq(ide_drive_t *drive) | |||
227 | u8 dma_stat; | 227 | u8 dma_stat; |
228 | 228 | ||
229 | /* clear the INTR & ERROR bits */ | 229 | /* clear the INTR & ERROR bits */ |
230 | dma_stat = inb(hwif->dma_status); | 230 | dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
231 | /* Should we force the bit as well ? */ | 231 | /* Should we force the bit as well ? */ |
232 | outb(dma_stat, hwif->dma_status); | 232 | outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS); |
233 | } | 233 | } |
234 | 234 | ||
235 | struct ich_laptop { | 235 | struct ich_laptop { |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 789c66dfbde5..94a7ab864236 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -65,7 +65,7 @@ | |||
65 | 65 | ||
66 | static struct scc_ports { | 66 | static struct scc_ports { |
67 | unsigned long ctl, dma; | 67 | unsigned long ctl, dma; |
68 | ide_hwif_t *hwif; /* for removing port from system */ | 68 | struct ide_host *host; /* for removing port from system */ |
69 | } scc_ports[MAX_HWIFS]; | 69 | } scc_ports[MAX_HWIFS]; |
70 | 70 | ||
71 | /* PIO transfer mode table */ | 71 | /* PIO transfer mode table */ |
@@ -126,6 +126,46 @@ static u8 scc_ide_inb(unsigned long port) | |||
126 | return (u8)data; | 126 | return (u8)data; |
127 | } | 127 | } |
128 | 128 | ||
129 | static void scc_exec_command(ide_hwif_t *hwif, u8 cmd) | ||
130 | { | ||
131 | out_be32((void *)hwif->io_ports.command_addr, cmd); | ||
132 | eieio(); | ||
133 | in_be32((void *)(hwif->dma_base + 0x01c)); | ||
134 | eieio(); | ||
135 | } | ||
136 | |||
137 | static u8 scc_read_status(ide_hwif_t *hwif) | ||
138 | { | ||
139 | return (u8)in_be32((void *)hwif->io_ports.status_addr); | ||
140 | } | ||
141 | |||
142 | static u8 scc_read_altstatus(ide_hwif_t *hwif) | ||
143 | { | ||
144 | return (u8)in_be32((void *)hwif->io_ports.ctl_addr); | ||
145 | } | ||
146 | |||
147 | static u8 scc_read_sff_dma_status(ide_hwif_t *hwif) | ||
148 | { | ||
149 | return (u8)in_be32((void *)(hwif->dma_base + 4)); | ||
150 | } | ||
151 | |||
152 | static void scc_set_irq(ide_hwif_t *hwif, int on) | ||
153 | { | ||
154 | u8 ctl = ATA_DEVCTL_OBS; | ||
155 | |||
156 | if (on == 4) { /* hack for SRST */ | ||
157 | ctl |= 4; | ||
158 | on &= ~4; | ||
159 | } | ||
160 | |||
161 | ctl |= on ? 0 : 2; | ||
162 | |||
163 | out_be32((void *)hwif->io_ports.ctl_addr, ctl); | ||
164 | eieio(); | ||
165 | in_be32((void *)(hwif->dma_base + 0x01c)); | ||
166 | eieio(); | ||
167 | } | ||
168 | |||
129 | static void scc_ide_insw(unsigned long port, void *addr, u32 count) | 169 | static void scc_ide_insw(unsigned long port, void *addr, u32 count) |
130 | { | 170 | { |
131 | u16 *ptr = (u16 *)addr; | 171 | u16 *ptr = (u16 *)addr; |
@@ -148,14 +188,6 @@ static void scc_ide_outb(u8 addr, unsigned long port) | |||
148 | out_be32((void*)port, addr); | 188 | out_be32((void*)port, addr); |
149 | } | 189 | } |
150 | 190 | ||
151 | static void scc_ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port) | ||
152 | { | ||
153 | out_be32((void*)port, addr); | ||
154 | eieio(); | ||
155 | in_be32((void*)(hwif->dma_base + 0x01c)); | ||
156 | eieio(); | ||
157 | } | ||
158 | |||
159 | static void | 191 | static void |
160 | scc_ide_outsw(unsigned long port, void *addr, u32 count) | 192 | scc_ide_outsw(unsigned long port, void *addr, u32 count) |
161 | { | 193 | { |
@@ -261,14 +293,14 @@ static void scc_dma_host_set(ide_drive_t *drive, int on) | |||
261 | { | 293 | { |
262 | ide_hwif_t *hwif = drive->hwif; | 294 | ide_hwif_t *hwif = drive->hwif; |
263 | u8 unit = (drive->select.b.unit & 0x01); | 295 | u8 unit = (drive->select.b.unit & 0x01); |
264 | u8 dma_stat = scc_ide_inb(hwif->dma_status); | 296 | u8 dma_stat = scc_ide_inb(hwif->dma_base + 4); |
265 | 297 | ||
266 | if (on) | 298 | if (on) |
267 | dma_stat |= (1 << (5 + unit)); | 299 | dma_stat |= (1 << (5 + unit)); |
268 | else | 300 | else |
269 | dma_stat &= ~(1 << (5 + unit)); | 301 | dma_stat &= ~(1 << (5 + unit)); |
270 | 302 | ||
271 | scc_ide_outb(dma_stat, hwif->dma_status); | 303 | scc_ide_outb(dma_stat, hwif->dma_base + 4); |
272 | } | 304 | } |
273 | 305 | ||
274 | /** | 306 | /** |
@@ -304,13 +336,13 @@ static int scc_dma_setup(ide_drive_t *drive) | |||
304 | out_be32((void __iomem *)(hwif->dma_base + 8), hwif->dmatable_dma); | 336 | out_be32((void __iomem *)(hwif->dma_base + 8), hwif->dmatable_dma); |
305 | 337 | ||
306 | /* specify r/w */ | 338 | /* specify r/w */ |
307 | out_be32((void __iomem *)hwif->dma_command, reading); | 339 | out_be32((void __iomem *)hwif->dma_base, reading); |
308 | 340 | ||
309 | /* read dma_status for INTR & ERROR flags */ | 341 | /* read DMA status for INTR & ERROR flags */ |
310 | dma_stat = in_be32((void __iomem *)hwif->dma_status); | 342 | dma_stat = in_be32((void __iomem *)(hwif->dma_base + 4)); |
311 | 343 | ||
312 | /* clear INTR & ERROR flags */ | 344 | /* clear INTR & ERROR flags */ |
313 | out_be32((void __iomem *)hwif->dma_status, dma_stat|6); | 345 | out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6); |
314 | drive->waiting_for_dma = 1; | 346 | drive->waiting_for_dma = 1; |
315 | return 0; | 347 | return 0; |
316 | } | 348 | } |
@@ -318,10 +350,10 @@ static int scc_dma_setup(ide_drive_t *drive) | |||
318 | static void scc_dma_start(ide_drive_t *drive) | 350 | static void scc_dma_start(ide_drive_t *drive) |
319 | { | 351 | { |
320 | ide_hwif_t *hwif = drive->hwif; | 352 | ide_hwif_t *hwif = drive->hwif; |
321 | u8 dma_cmd = scc_ide_inb(hwif->dma_command); | 353 | u8 dma_cmd = scc_ide_inb(hwif->dma_base); |
322 | 354 | ||
323 | /* start DMA */ | 355 | /* start DMA */ |
324 | scc_ide_outb(dma_cmd | 1, hwif->dma_command); | 356 | scc_ide_outb(dma_cmd | 1, hwif->dma_base); |
325 | hwif->dma = 1; | 357 | hwif->dma = 1; |
326 | wmb(); | 358 | wmb(); |
327 | } | 359 | } |
@@ -333,13 +365,13 @@ static int __scc_dma_end(ide_drive_t *drive) | |||
333 | 365 | ||
334 | drive->waiting_for_dma = 0; | 366 | drive->waiting_for_dma = 0; |
335 | /* get DMA command mode */ | 367 | /* get DMA command mode */ |
336 | dma_cmd = scc_ide_inb(hwif->dma_command); | 368 | dma_cmd = scc_ide_inb(hwif->dma_base); |
337 | /* stop DMA */ | 369 | /* stop DMA */ |
338 | scc_ide_outb(dma_cmd & ~1, hwif->dma_command); | 370 | scc_ide_outb(dma_cmd & ~1, hwif->dma_base); |
339 | /* get DMA status */ | 371 | /* get DMA status */ |
340 | dma_stat = scc_ide_inb(hwif->dma_status); | 372 | dma_stat = scc_ide_inb(hwif->dma_base + 4); |
341 | /* clear the INTR & ERROR bits */ | 373 | /* clear the INTR & ERROR bits */ |
342 | scc_ide_outb(dma_stat | 6, hwif->dma_status); | 374 | scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); |
343 | /* purge DMA mappings */ | 375 | /* purge DMA mappings */ |
344 | ide_destroy_dmatable(drive); | 376 | ide_destroy_dmatable(drive); |
345 | /* verify good DMA status */ | 377 | /* verify good DMA status */ |
@@ -359,6 +391,7 @@ static int __scc_dma_end(ide_drive_t *drive) | |||
359 | static int scc_dma_end(ide_drive_t *drive) | 391 | static int scc_dma_end(ide_drive_t *drive) |
360 | { | 392 | { |
361 | ide_hwif_t *hwif = HWIF(drive); | 393 | ide_hwif_t *hwif = HWIF(drive); |
394 | void __iomem *dma_base = (void __iomem *)hwif->dma_base; | ||
362 | unsigned long intsts_port = hwif->dma_base + 0x014; | 395 | unsigned long intsts_port = hwif->dma_base + 0x014; |
363 | u32 reg; | 396 | u32 reg; |
364 | int dma_stat, data_loss = 0; | 397 | int dma_stat, data_loss = 0; |
@@ -397,7 +430,7 @@ static int scc_dma_end(ide_drive_t *drive) | |||
397 | printk(KERN_WARNING "%s: SERROR\n", SCC_PATA_NAME); | 430 | printk(KERN_WARNING "%s: SERROR\n", SCC_PATA_NAME); |
398 | out_be32((void __iomem *)intsts_port, INTSTS_SERROR|INTSTS_BMSINT); | 431 | out_be32((void __iomem *)intsts_port, INTSTS_SERROR|INTSTS_BMSINT); |
399 | 432 | ||
400 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); | 433 | out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); |
401 | continue; | 434 | continue; |
402 | } | 435 | } |
403 | 436 | ||
@@ -412,7 +445,7 @@ static int scc_dma_end(ide_drive_t *drive) | |||
412 | 445 | ||
413 | out_be32((void __iomem *)intsts_port, INTSTS_PRERR|INTSTS_BMSINT); | 446 | out_be32((void __iomem *)intsts_port, INTSTS_PRERR|INTSTS_BMSINT); |
414 | 447 | ||
415 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); | 448 | out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); |
416 | continue; | 449 | continue; |
417 | } | 450 | } |
418 | 451 | ||
@@ -420,12 +453,12 @@ static int scc_dma_end(ide_drive_t *drive) | |||
420 | printk(KERN_WARNING "%s: Response Error\n", SCC_PATA_NAME); | 453 | printk(KERN_WARNING "%s: Response Error\n", SCC_PATA_NAME); |
421 | out_be32((void __iomem *)intsts_port, INTSTS_RERR|INTSTS_BMSINT); | 454 | out_be32((void __iomem *)intsts_port, INTSTS_RERR|INTSTS_BMSINT); |
422 | 455 | ||
423 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); | 456 | out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); |
424 | continue; | 457 | continue; |
425 | } | 458 | } |
426 | 459 | ||
427 | if (reg & INTSTS_ICERR) { | 460 | if (reg & INTSTS_ICERR) { |
428 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); | 461 | out_be32(dma_base, in_be32(dma_base) & ~QCHCD_IOS_SS); |
429 | 462 | ||
430 | printk(KERN_WARNING "%s: Illegal Configuration\n", SCC_PATA_NAME); | 463 | printk(KERN_WARNING "%s: Illegal Configuration\n", SCC_PATA_NAME); |
431 | out_be32((void __iomem *)intsts_port, INTSTS_ICERR|INTSTS_BMSINT); | 464 | out_be32((void __iomem *)intsts_port, INTSTS_ICERR|INTSTS_BMSINT); |
@@ -553,14 +586,9 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
553 | const struct ide_port_info *d) | 586 | const struct ide_port_info *d) |
554 | { | 587 | { |
555 | struct scc_ports *ports = pci_get_drvdata(dev); | 588 | struct scc_ports *ports = pci_get_drvdata(dev); |
556 | ide_hwif_t *hwif = NULL; | 589 | struct ide_host *host; |
557 | hw_regs_t hw; | 590 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
558 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 591 | int i, rc; |
559 | int i; | ||
560 | |||
561 | hwif = ide_find_port_slot(d); | ||
562 | if (hwif == NULL) | ||
563 | return -ENOMEM; | ||
564 | 592 | ||
565 | memset(&hw, 0, sizeof(hw)); | 593 | memset(&hw, 0, sizeof(hw)); |
566 | for (i = 0; i <= 8; i++) | 594 | for (i = 0; i <= 8; i++) |
@@ -568,11 +596,12 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
568 | hw.irq = dev->irq; | 596 | hw.irq = dev->irq; |
569 | hw.dev = &dev->dev; | 597 | hw.dev = &dev->dev; |
570 | hw.chipset = ide_pci; | 598 | hw.chipset = ide_pci; |
571 | ide_init_port_hw(hwif, &hw); | ||
572 | 599 | ||
573 | idx[0] = hwif->index; | 600 | rc = ide_host_add(d, hws, &host); |
601 | if (rc) | ||
602 | return rc; | ||
574 | 603 | ||
575 | ide_device_add(idx, d); | 604 | ports->host = host; |
576 | 605 | ||
577 | return 0; | 606 | return 0; |
578 | } | 607 | } |
@@ -701,6 +730,8 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
701 | /* be sure we're looking at the low order bits */ | 730 | /* be sure we're looking at the low order bits */ |
702 | scc_ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | 731 | scc_ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
703 | 732 | ||
733 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
734 | tf->feature = scc_ide_inb(io_ports->feature_addr); | ||
704 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 735 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
705 | tf->nsect = scc_ide_inb(io_ports->nsect_addr); | 736 | tf->nsect = scc_ide_inb(io_ports->nsect_addr); |
706 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | 737 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) |
@@ -774,16 +805,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
774 | 805 | ||
775 | ide_set_hwifdata(hwif, ports); | 806 | ide_set_hwifdata(hwif, ports); |
776 | 807 | ||
777 | hwif->tf_load = scc_tf_load; | ||
778 | hwif->tf_read = scc_tf_read; | ||
779 | |||
780 | hwif->input_data = scc_input_data; | ||
781 | hwif->output_data = scc_output_data; | ||
782 | |||
783 | hwif->INB = scc_ide_inb; | ||
784 | hwif->OUTB = scc_ide_outb; | ||
785 | hwif->OUTBSYNC = scc_ide_outbsync; | ||
786 | |||
787 | hwif->dma_base = dma_base; | 808 | hwif->dma_base = dma_base; |
788 | hwif->config_data = ports->ctl; | 809 | hwif->config_data = ports->ctl; |
789 | } | 810 | } |
@@ -824,11 +845,6 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
824 | { | 845 | { |
825 | struct scc_ports *ports = ide_get_hwifdata(hwif); | 846 | struct scc_ports *ports = ide_get_hwifdata(hwif); |
826 | 847 | ||
827 | ports->hwif = hwif; | ||
828 | |||
829 | hwif->dma_command = hwif->dma_base; | ||
830 | hwif->dma_status = hwif->dma_base + 0x04; | ||
831 | |||
832 | /* PTERADD */ | 848 | /* PTERADD */ |
833 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); | 849 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); |
834 | 850 | ||
@@ -838,6 +854,21 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
838 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ | 854 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ |
839 | } | 855 | } |
840 | 856 | ||
857 | static const struct ide_tp_ops scc_tp_ops = { | ||
858 | .exec_command = scc_exec_command, | ||
859 | .read_status = scc_read_status, | ||
860 | .read_altstatus = scc_read_altstatus, | ||
861 | .read_sff_dma_status = scc_read_sff_dma_status, | ||
862 | |||
863 | .set_irq = scc_set_irq, | ||
864 | |||
865 | .tf_load = scc_tf_load, | ||
866 | .tf_read = scc_tf_read, | ||
867 | |||
868 | .input_data = scc_input_data, | ||
869 | .output_data = scc_output_data, | ||
870 | }; | ||
871 | |||
841 | static const struct ide_port_ops scc_port_ops = { | 872 | static const struct ide_port_ops scc_port_ops = { |
842 | .set_pio_mode = scc_set_pio_mode, | 873 | .set_pio_mode = scc_set_pio_mode, |
843 | .set_dma_mode = scc_set_dma_mode, | 874 | .set_dma_mode = scc_set_dma_mode, |
@@ -861,6 +892,7 @@ static const struct ide_dma_ops scc_dma_ops = { | |||
861 | .name = name_str, \ | 892 | .name = name_str, \ |
862 | .init_iops = init_iops_scc, \ | 893 | .init_iops = init_iops_scc, \ |
863 | .init_hwif = init_hwif_scc, \ | 894 | .init_hwif = init_hwif_scc, \ |
895 | .tp_ops = &scc_tp_ops, \ | ||
864 | .port_ops = &scc_port_ops, \ | 896 | .port_ops = &scc_port_ops, \ |
865 | .dma_ops = &scc_dma_ops, \ | 897 | .dma_ops = &scc_dma_ops, \ |
866 | .host_flags = IDE_HFLAG_SINGLE, \ | 898 | .host_flags = IDE_HFLAG_SINGLE, \ |
@@ -895,7 +927,8 @@ static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_i | |||
895 | static void __devexit scc_remove(struct pci_dev *dev) | 927 | static void __devexit scc_remove(struct pci_dev *dev) |
896 | { | 928 | { |
897 | struct scc_ports *ports = pci_get_drvdata(dev); | 929 | struct scc_ports *ports = pci_get_drvdata(dev); |
898 | ide_hwif_t *hwif = ports->hwif; | 930 | struct ide_host *host = ports->host; |
931 | ide_hwif_t *hwif = host->ports[0]; | ||
899 | 932 | ||
900 | if (hwif->dmatable_cpu) { | 933 | if (hwif->dmatable_cpu) { |
901 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, | 934 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, |
@@ -903,7 +936,7 @@ static void __devexit scc_remove(struct pci_dev *dev) | |||
903 | hwif->dmatable_cpu = NULL; | 936 | hwif->dmatable_cpu = NULL; |
904 | } | 937 | } |
905 | 938 | ||
906 | ide_unregister(hwif); | 939 | ide_host_remove(host); |
907 | 940 | ||
908 | iounmap((void*)ports->dma); | 941 | iounmap((void*)ports->dma); |
909 | iounmap((void*)ports->ctl); | 942 | iounmap((void*)ports->ctl); |
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index a1fb20826a5b..127ccb45e261 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -349,9 +349,7 @@ static const struct ide_port_ops svwks_port_ops = { | |||
349 | .cable_detect = svwks_cable_detect, | 349 | .cable_detect = svwks_cable_detect, |
350 | }; | 350 | }; |
351 | 351 | ||
352 | #define IDE_HFLAGS_SVWKS \ | 352 | #define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS |
353 | (IDE_HFLAG_LEGACY_IRQS | \ | ||
354 | IDE_HFLAG_ABUSE_SET_DMA_MODE) | ||
355 | 353 | ||
356 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | 354 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { |
357 | { /* 0 */ | 355 | { /* 0 */ |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index c79ff5b41088..42eef19a18f1 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -127,7 +127,7 @@ sgiioc4_checkirq(ide_hwif_t * hwif) | |||
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | 129 | ||
130 | static u8 sgiioc4_INB(unsigned long); | 130 | static u8 sgiioc4_read_status(ide_hwif_t *); |
131 | 131 | ||
132 | static int | 132 | static int |
133 | sgiioc4_clearirq(ide_drive_t * drive) | 133 | sgiioc4_clearirq(ide_drive_t * drive) |
@@ -141,18 +141,19 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
141 | intr_reg = readl((void __iomem *)other_ir); | 141 | intr_reg = readl((void __iomem *)other_ir); |
142 | if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */ | 142 | if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */ |
143 | /* | 143 | /* |
144 | * Using sgiioc4_INB to read the Status register has a side | 144 | * Using sgiioc4_read_status to read the Status register has a |
145 | * effect of clearing the interrupt. The first read should | 145 | * side effect of clearing the interrupt. The first read should |
146 | * clear it if it is set. The second read should return | 146 | * clear it if it is set. The second read should return |
147 | * a "clear" status if it got cleared. If not, then spin | 147 | * a "clear" status if it got cleared. If not, then spin |
148 | * for a bit trying to clear it. | 148 | * for a bit trying to clear it. |
149 | */ | 149 | */ |
150 | u8 stat = sgiioc4_INB(io_ports->status_addr); | 150 | u8 stat = sgiioc4_read_status(hwif); |
151 | int count = 0; | 151 | int count = 0; |
152 | stat = sgiioc4_INB(io_ports->status_addr); | 152 | |
153 | stat = sgiioc4_read_status(hwif); | ||
153 | while ((stat & 0x80) && (count++ < 100)) { | 154 | while ((stat & 0x80) && (count++ < 100)) { |
154 | udelay(1); | 155 | udelay(1); |
155 | stat = sgiioc4_INB(io_ports->status_addr); | 156 | stat = sgiioc4_read_status(hwif); |
156 | } | 157 | } |
157 | 158 | ||
158 | if (intr_reg & 0x02) { | 159 | if (intr_reg & 0x02) { |
@@ -304,9 +305,9 @@ sgiioc4_dma_lost_irq(ide_drive_t * drive) | |||
304 | ide_dma_lost_irq(drive); | 305 | ide_dma_lost_irq(drive); |
305 | } | 306 | } |
306 | 307 | ||
307 | static u8 | 308 | static u8 sgiioc4_read_status(ide_hwif_t *hwif) |
308 | sgiioc4_INB(unsigned long port) | ||
309 | { | 309 | { |
310 | unsigned long port = hwif->io_ports.status_addr; | ||
310 | u8 reg = (u8) readb((void __iomem *) port); | 311 | u8 reg = (u8) readb((void __iomem *) port); |
311 | 312 | ||
312 | if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ | 313 | if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ |
@@ -549,6 +550,21 @@ static int sgiioc4_dma_setup(ide_drive_t *drive) | |||
549 | return 0; | 550 | return 0; |
550 | } | 551 | } |
551 | 552 | ||
553 | static const struct ide_tp_ops sgiioc4_tp_ops = { | ||
554 | .exec_command = ide_exec_command, | ||
555 | .read_status = sgiioc4_read_status, | ||
556 | .read_altstatus = ide_read_altstatus, | ||
557 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
558 | |||
559 | .set_irq = ide_set_irq, | ||
560 | |||
561 | .tf_load = ide_tf_load, | ||
562 | .tf_read = ide_tf_read, | ||
563 | |||
564 | .input_data = ide_input_data, | ||
565 | .output_data = ide_output_data, | ||
566 | }; | ||
567 | |||
552 | static const struct ide_port_ops sgiioc4_port_ops = { | 568 | static const struct ide_port_ops sgiioc4_port_ops = { |
553 | .set_dma_mode = sgiioc4_set_dma_mode, | 569 | .set_dma_mode = sgiioc4_set_dma_mode, |
554 | /* reset DMA engine, clear IRQs */ | 570 | /* reset DMA engine, clear IRQs */ |
@@ -571,6 +587,7 @@ static const struct ide_port_info sgiioc4_port_info __devinitdata = { | |||
571 | .name = DRV_NAME, | 587 | .name = DRV_NAME, |
572 | .chipset = ide_pci, | 588 | .chipset = ide_pci, |
573 | .init_dma = ide_dma_sgiioc4, | 589 | .init_dma = ide_dma_sgiioc4, |
590 | .tp_ops = &sgiioc4_tp_ops, | ||
574 | .port_ops = &sgiioc4_port_ops, | 591 | .port_ops = &sgiioc4_port_ops, |
575 | .dma_ops = &sgiioc4_dma_ops, | 592 | .dma_ops = &sgiioc4_dma_ops, |
576 | .host_flags = IDE_HFLAG_MMIO, | 593 | .host_flags = IDE_HFLAG_MMIO, |
@@ -583,10 +600,10 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
583 | unsigned long cmd_base, irqport; | 600 | unsigned long cmd_base, irqport; |
584 | unsigned long bar0, cmd_phys_base, ctl; | 601 | unsigned long bar0, cmd_phys_base, ctl; |
585 | void __iomem *virt_base; | 602 | void __iomem *virt_base; |
586 | ide_hwif_t *hwif; | 603 | struct ide_host *host; |
587 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 604 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
588 | hw_regs_t hw; | ||
589 | struct ide_port_info d = sgiioc4_port_info; | 605 | struct ide_port_info d = sgiioc4_port_info; |
606 | int rc; | ||
590 | 607 | ||
591 | /* Get the CmdBlk and CtrlBlk Base Registers */ | 608 | /* Get the CmdBlk and CtrlBlk Base Registers */ |
592 | bar0 = pci_resource_start(dev, 0); | 609 | bar0 = pci_resource_start(dev, 0); |
@@ -618,30 +635,26 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
618 | hw.chipset = ide_pci; | 635 | hw.chipset = ide_pci; |
619 | hw.dev = &dev->dev; | 636 | hw.dev = &dev->dev; |
620 | 637 | ||
621 | hwif = ide_find_port_slot(&d); | ||
622 | if (hwif == NULL) | ||
623 | goto err; | ||
624 | |||
625 | ide_init_port_hw(hwif, &hw); | ||
626 | |||
627 | /* The IOC4 uses MMIO rather than Port IO. */ | ||
628 | default_hwif_mmiops(hwif); | ||
629 | |||
630 | /* Initializing chipset IRQ Registers */ | 638 | /* Initializing chipset IRQ Registers */ |
631 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); | 639 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); |
632 | 640 | ||
633 | hwif->INB = &sgiioc4_INB; | 641 | host = ide_host_alloc(&d, hws); |
634 | 642 | if (host == NULL) { | |
635 | idx[0] = hwif->index; | 643 | rc = -ENOMEM; |
644 | goto err; | ||
645 | } | ||
636 | 646 | ||
637 | if (ide_device_add(idx, &d)) | 647 | rc = ide_host_register(host, &d, hws); |
638 | return -EIO; | 648 | if (rc) |
649 | goto err_free; | ||
639 | 650 | ||
640 | return 0; | 651 | return 0; |
652 | err_free: | ||
653 | ide_host_free(host); | ||
641 | err: | 654 | err: |
642 | release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE); | 655 | release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE); |
643 | iounmap(virt_base); | 656 | iounmap(virt_base); |
644 | return -ENOMEM; | 657 | return rc; |
645 | } | 658 | } |
646 | 659 | ||
647 | static unsigned int __devinit | 660 | static unsigned int __devinit |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 6e9d7655d89c..5965a35d94ae 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -334,7 +334,7 @@ static int siimage_io_dma_test_irq(ide_drive_t *drive) | |||
334 | unsigned long addr = siimage_selreg(hwif, 1); | 334 | unsigned long addr = siimage_selreg(hwif, 1); |
335 | 335 | ||
336 | /* return 1 if INTR asserted */ | 336 | /* return 1 if INTR asserted */ |
337 | if (hwif->INB(hwif->dma_status) & 4) | 337 | if (inb(hwif->dma_base + ATA_DMA_STATUS) & 4) |
338 | return 1; | 338 | return 1; |
339 | 339 | ||
340 | /* return 1 if Device INTR asserted */ | 340 | /* return 1 if Device INTR asserted */ |
@@ -382,7 +382,7 @@ static int siimage_mmio_dma_test_irq(ide_drive_t *drive) | |||
382 | } | 382 | } |
383 | 383 | ||
384 | /* return 1 if INTR asserted */ | 384 | /* return 1 if INTR asserted */ |
385 | if (readb((void __iomem *)hwif->dma_status) & 0x04) | 385 | if (readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)) & 4) |
386 | return 1; | 386 | return 1; |
387 | 387 | ||
388 | /* return 1 if Device INTR asserted */ | 388 | /* return 1 if Device INTR asserted */ |
@@ -601,7 +601,7 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
601 | * Fill in the basic hwif bits | 601 | * Fill in the basic hwif bits |
602 | */ | 602 | */ |
603 | hwif->host_flags |= IDE_HFLAG_MMIO; | 603 | hwif->host_flags |= IDE_HFLAG_MMIO; |
604 | default_hwif_mmiops(hwif); | 604 | |
605 | hwif->hwif_data = addr; | 605 | hwif->hwif_data = addr; |
606 | 606 | ||
607 | /* | 607 | /* |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 6efbde297174..f82a6502c1b7 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -157,9 +157,9 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive) | |||
157 | * Was DMA enabled? If so, disable it - we're resetting the | 157 | * Was DMA enabled? If so, disable it - we're resetting the |
158 | * host. The IDE layer will be handling the drive for us. | 158 | * host. The IDE layer will be handling the drive for us. |
159 | */ | 159 | */ |
160 | dma_cmd = inb(hwif->dma_command); | 160 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
161 | if (dma_cmd & 1) { | 161 | if (dma_cmd & 1) { |
162 | outb(dma_cmd & ~1, hwif->dma_command); | 162 | outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); |
163 | printk("sl82c105: DMA was enabled\n"); | 163 | printk("sl82c105: DMA was enabled\n"); |
164 | } | 164 | } |
165 | 165 | ||
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index 9b4b27a4c711..477e19790102 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -63,7 +63,7 @@ static int tc86c001_timer_expiry(ide_drive_t *drive) | |||
63 | ide_hwif_t *hwif = HWIF(drive); | 63 | ide_hwif_t *hwif = HWIF(drive); |
64 | ide_expiry_t *expiry = ide_get_hwifdata(hwif); | 64 | ide_expiry_t *expiry = ide_get_hwifdata(hwif); |
65 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 65 | ide_hwgroup_t *hwgroup = HWGROUP(drive); |
66 | u8 dma_stat = inb(hwif->dma_status); | 66 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
67 | 67 | ||
68 | /* Restore a higher level driver's expiry handler first. */ | 68 | /* Restore a higher level driver's expiry handler first. */ |
69 | hwgroup->expiry = expiry; | 69 | hwgroup->expiry = expiry; |
@@ -71,21 +71,24 @@ static int tc86c001_timer_expiry(ide_drive_t *drive) | |||
71 | if ((dma_stat & 5) == 1) { /* DMA active and no interrupt */ | 71 | if ((dma_stat & 5) == 1) { /* DMA active and no interrupt */ |
72 | unsigned long sc_base = hwif->config_data; | 72 | unsigned long sc_base = hwif->config_data; |
73 | unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); | 73 | unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); |
74 | u8 dma_cmd = inb(hwif->dma_command); | 74 | u8 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
75 | 75 | ||
76 | printk(KERN_WARNING "%s: DMA interrupt possibly stuck, " | 76 | printk(KERN_WARNING "%s: DMA interrupt possibly stuck, " |
77 | "attempting recovery...\n", drive->name); | 77 | "attempting recovery...\n", drive->name); |
78 | 78 | ||
79 | /* Stop DMA */ | 79 | /* Stop DMA */ |
80 | outb(dma_cmd & ~0x01, hwif->dma_command); | 80 | outb(dma_cmd & ~0x01, hwif->dma_base + ATA_DMA_CMD); |
81 | 81 | ||
82 | /* Setup the dummy DMA transfer */ | 82 | /* Setup the dummy DMA transfer */ |
83 | outw(0, sc_base + 0x0a); /* Sector Count */ | 83 | outw(0, sc_base + 0x0a); /* Sector Count */ |
84 | outw(0, twcr_port); /* Transfer Word Count 1 or 2 */ | 84 | outw(0, twcr_port); /* Transfer Word Count 1 or 2 */ |
85 | 85 | ||
86 | /* Start the dummy DMA transfer */ | 86 | /* Start the dummy DMA transfer */ |
87 | outb(0x00, hwif->dma_command); /* clear R_OR_WCTR for write */ | 87 | |
88 | outb(0x01, hwif->dma_command); /* set START_STOPBM */ | 88 | /* clear R_OR_WCTR for write */ |
89 | outb(0x00, hwif->dma_base + ATA_DMA_CMD); | ||
90 | /* set START_STOPBM */ | ||
91 | outb(0x01, hwif->dma_base + ATA_DMA_CMD); | ||
89 | 92 | ||
90 | /* | 93 | /* |
91 | * If an interrupt was pending, it should come thru shortly. | 94 | * If an interrupt was pending, it should come thru shortly. |
@@ -203,8 +206,7 @@ static const struct ide_port_info tc86c001_chipset __devinitdata = { | |||
203 | .init_hwif = init_hwif_tc86c001, | 206 | .init_hwif = init_hwif_tc86c001, |
204 | .port_ops = &tc86c001_port_ops, | 207 | .port_ops = &tc86c001_port_ops, |
205 | .dma_ops = &tc86c001_dma_ops, | 208 | .dma_ops = &tc86c001_dma_ops, |
206 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | | 209 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD, |
207 | IDE_HFLAG_ABUSE_SET_DMA_MODE, | ||
208 | .pio_mask = ATA_PIO4, | 210 | .pio_mask = ATA_PIO4, |
209 | .mwdma_mask = ATA_MWDMA2, | 211 | .mwdma_mask = ATA_MWDMA2, |
210 | .udma_mask = ATA_UDMA4, | 212 | .udma_mask = ATA_UDMA4, |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index e47384c70c40..09dc4803ef9d 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -425,7 +425,6 @@ static const struct ide_port_info via82cxxx_chipset __devinitdata = { | |||
425 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, | 425 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, |
426 | .port_ops = &via_port_ops, | 426 | .port_ops = &via_port_ops, |
427 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | | 427 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | |
428 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | ||
429 | IDE_HFLAG_POST_SET_MODE | | 428 | IDE_HFLAG_POST_SET_MODE | |
430 | IDE_HFLAG_IO_32BIT, | 429 | IDE_HFLAG_IO_32BIT, |
431 | .pio_mask = ATA_PIO5, | 430 | .pio_mask = ATA_PIO5, |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 93fb9067c043..c521bf6e1bf2 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -48,6 +48,8 @@ | |||
48 | #include <asm/mediabay.h> | 48 | #include <asm/mediabay.h> |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #define DRV_NAME "ide-pmac" | ||
52 | |||
51 | #undef IDE_PMAC_DEBUG | 53 | #undef IDE_PMAC_DEBUG |
52 | 54 | ||
53 | #define DMA_WAIT_TIMEOUT 50 | 55 | #define DMA_WAIT_TIMEOUT 50 |
@@ -424,7 +426,9 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | |||
424 | static void | 426 | static void |
425 | pmac_ide_selectproc(ide_drive_t *drive) | 427 | pmac_ide_selectproc(ide_drive_t *drive) |
426 | { | 428 | { |
427 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 429 | ide_hwif_t *hwif = drive->hwif; |
430 | pmac_ide_hwif_t *pmif = | ||
431 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
428 | 432 | ||
429 | if (pmif == NULL) | 433 | if (pmif == NULL) |
430 | return; | 434 | return; |
@@ -444,7 +448,9 @@ pmac_ide_selectproc(ide_drive_t *drive) | |||
444 | static void | 448 | static void |
445 | pmac_ide_kauai_selectproc(ide_drive_t *drive) | 449 | pmac_ide_kauai_selectproc(ide_drive_t *drive) |
446 | { | 450 | { |
447 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 451 | ide_hwif_t *hwif = drive->hwif; |
452 | pmac_ide_hwif_t *pmif = | ||
453 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
448 | 454 | ||
449 | if (pmif == NULL) | 455 | if (pmif == NULL) |
450 | return; | 456 | return; |
@@ -465,7 +471,9 @@ pmac_ide_kauai_selectproc(ide_drive_t *drive) | |||
465 | static void | 471 | static void |
466 | pmac_ide_do_update_timings(ide_drive_t *drive) | 472 | pmac_ide_do_update_timings(ide_drive_t *drive) |
467 | { | 473 | { |
468 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 474 | ide_hwif_t *hwif = drive->hwif; |
475 | pmac_ide_hwif_t *pmif = | ||
476 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
469 | 477 | ||
470 | if (pmif == NULL) | 478 | if (pmif == NULL) |
471 | return; | 479 | return; |
@@ -478,12 +486,26 @@ pmac_ide_do_update_timings(ide_drive_t *drive) | |||
478 | pmac_ide_selectproc(drive); | 486 | pmac_ide_selectproc(drive); |
479 | } | 487 | } |
480 | 488 | ||
481 | static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) | 489 | static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd) |
482 | { | 490 | { |
483 | u32 tmp; | 491 | writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); |
484 | 492 | (void)readl((void __iomem *)(hwif->io_ports.data_addr | |
485 | writeb(value, (void __iomem *) port); | 493 | + IDE_TIMING_CONFIG)); |
486 | tmp = readl((void __iomem *)(hwif->io_ports.data_addr | 494 | } |
495 | |||
496 | static void pmac_set_irq(ide_hwif_t *hwif, int on) | ||
497 | { | ||
498 | u8 ctl = ATA_DEVCTL_OBS; | ||
499 | |||
500 | if (on == 4) { /* hack for SRST */ | ||
501 | ctl |= 4; | ||
502 | on &= ~4; | ||
503 | } | ||
504 | |||
505 | ctl |= on ? 0 : 2; | ||
506 | |||
507 | writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr); | ||
508 | (void)readl((void __iomem *)(hwif->io_ports.data_addr | ||
487 | + IDE_TIMING_CONFIG)); | 509 | + IDE_TIMING_CONFIG)); |
488 | } | 510 | } |
489 | 511 | ||
@@ -493,11 +515,13 @@ static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) | |||
493 | static void | 515 | static void |
494 | pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | 516 | pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) |
495 | { | 517 | { |
518 | ide_hwif_t *hwif = drive->hwif; | ||
519 | pmac_ide_hwif_t *pmif = | ||
520 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
496 | struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio); | 521 | struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio); |
497 | u32 *timings, t; | 522 | u32 *timings, t; |
498 | unsigned accessTicks, recTicks; | 523 | unsigned accessTicks, recTicks; |
499 | unsigned accessTime, recTime; | 524 | unsigned accessTime, recTime; |
500 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | ||
501 | unsigned int cycle_time; | 525 | unsigned int cycle_time; |
502 | 526 | ||
503 | if (pmif == NULL) | 527 | if (pmif == NULL) |
@@ -778,9 +802,11 @@ set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, | |||
778 | 802 | ||
779 | static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) | 803 | static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) |
780 | { | 804 | { |
805 | ide_hwif_t *hwif = drive->hwif; | ||
806 | pmac_ide_hwif_t *pmif = | ||
807 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
781 | int unit = (drive->select.b.unit & 0x01); | 808 | int unit = (drive->select.b.unit & 0x01); |
782 | int ret = 0; | 809 | int ret = 0; |
783 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | ||
784 | u32 *timings, *timings2, tl[2]; | 810 | u32 *timings, *timings2, tl[2]; |
785 | 811 | ||
786 | timings = &pmif->timings[unit]; | 812 | timings = &pmif->timings[unit]; |
@@ -852,11 +878,8 @@ sanitize_timings(pmac_ide_hwif_t *pmif) | |||
852 | /* Suspend call back, should be called after the child devices | 878 | /* Suspend call back, should be called after the child devices |
853 | * have actually been suspended | 879 | * have actually been suspended |
854 | */ | 880 | */ |
855 | static int | 881 | static int pmac_ide_do_suspend(pmac_ide_hwif_t *pmif) |
856 | pmac_ide_do_suspend(ide_hwif_t *hwif) | ||
857 | { | 882 | { |
858 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
859 | |||
860 | /* We clear the timings */ | 883 | /* We clear the timings */ |
861 | pmif->timings[0] = 0; | 884 | pmif->timings[0] = 0; |
862 | pmif->timings[1] = 0; | 885 | pmif->timings[1] = 0; |
@@ -884,11 +907,8 @@ pmac_ide_do_suspend(ide_hwif_t *hwif) | |||
884 | /* Resume call back, should be called before the child devices | 907 | /* Resume call back, should be called before the child devices |
885 | * are resumed | 908 | * are resumed |
886 | */ | 909 | */ |
887 | static int | 910 | static int pmac_ide_do_resume(pmac_ide_hwif_t *pmif) |
888 | pmac_ide_do_resume(ide_hwif_t *hwif) | ||
889 | { | 911 | { |
890 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
891 | |||
892 | /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ | 912 | /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ |
893 | if (!pmif->mediabay) { | 913 | if (!pmif->mediabay) { |
894 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); | 914 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); |
@@ -916,7 +936,8 @@ pmac_ide_do_resume(ide_hwif_t *hwif) | |||
916 | 936 | ||
917 | static u8 pmac_ide_cable_detect(ide_hwif_t *hwif) | 937 | static u8 pmac_ide_cable_detect(ide_hwif_t *hwif) |
918 | { | 938 | { |
919 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)ide_get_hwifdata(hwif); | 939 | pmac_ide_hwif_t *pmif = |
940 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
920 | struct device_node *np = pmif->node; | 941 | struct device_node *np = pmif->node; |
921 | const char *cable = of_get_property(np, "cable-type", NULL); | 942 | const char *cable = of_get_property(np, "cable-type", NULL); |
922 | 943 | ||
@@ -936,7 +957,40 @@ static u8 pmac_ide_cable_detect(ide_hwif_t *hwif) | |||
936 | return ATA_CBL_PATA40; | 957 | return ATA_CBL_PATA40; |
937 | } | 958 | } |
938 | 959 | ||
960 | static void pmac_ide_init_dev(ide_drive_t *drive) | ||
961 | { | ||
962 | ide_hwif_t *hwif = drive->hwif; | ||
963 | pmac_ide_hwif_t *pmif = | ||
964 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
965 | |||
966 | if (pmif->mediabay) { | ||
967 | #ifdef CONFIG_PMAC_MEDIABAY | ||
968 | if (check_media_bay_by_base(pmif->regbase, MB_CD) == 0) { | ||
969 | drive->noprobe = 0; | ||
970 | return; | ||
971 | } | ||
972 | #endif | ||
973 | drive->noprobe = 1; | ||
974 | } | ||
975 | } | ||
976 | |||
977 | static const struct ide_tp_ops pmac_tp_ops = { | ||
978 | .exec_command = pmac_exec_command, | ||
979 | .read_status = ide_read_status, | ||
980 | .read_altstatus = ide_read_altstatus, | ||
981 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
982 | |||
983 | .set_irq = pmac_set_irq, | ||
984 | |||
985 | .tf_load = ide_tf_load, | ||
986 | .tf_read = ide_tf_read, | ||
987 | |||
988 | .input_data = ide_input_data, | ||
989 | .output_data = ide_output_data, | ||
990 | }; | ||
991 | |||
939 | static const struct ide_port_ops pmac_ide_ata6_port_ops = { | 992 | static const struct ide_port_ops pmac_ide_ata6_port_ops = { |
993 | .init_dev = pmac_ide_init_dev, | ||
940 | .set_pio_mode = pmac_ide_set_pio_mode, | 994 | .set_pio_mode = pmac_ide_set_pio_mode, |
941 | .set_dma_mode = pmac_ide_set_dma_mode, | 995 | .set_dma_mode = pmac_ide_set_dma_mode, |
942 | .selectproc = pmac_ide_kauai_selectproc, | 996 | .selectproc = pmac_ide_kauai_selectproc, |
@@ -944,6 +998,7 @@ static const struct ide_port_ops pmac_ide_ata6_port_ops = { | |||
944 | }; | 998 | }; |
945 | 999 | ||
946 | static const struct ide_port_ops pmac_ide_ata4_port_ops = { | 1000 | static const struct ide_port_ops pmac_ide_ata4_port_ops = { |
1001 | .init_dev = pmac_ide_init_dev, | ||
947 | .set_pio_mode = pmac_ide_set_pio_mode, | 1002 | .set_pio_mode = pmac_ide_set_pio_mode, |
948 | .set_dma_mode = pmac_ide_set_dma_mode, | 1003 | .set_dma_mode = pmac_ide_set_dma_mode, |
949 | .selectproc = pmac_ide_selectproc, | 1004 | .selectproc = pmac_ide_selectproc, |
@@ -951,6 +1006,7 @@ static const struct ide_port_ops pmac_ide_ata4_port_ops = { | |||
951 | }; | 1006 | }; |
952 | 1007 | ||
953 | static const struct ide_port_ops pmac_ide_port_ops = { | 1008 | static const struct ide_port_ops pmac_ide_port_ops = { |
1009 | .init_dev = pmac_ide_init_dev, | ||
954 | .set_pio_mode = pmac_ide_set_pio_mode, | 1010 | .set_pio_mode = pmac_ide_set_pio_mode, |
955 | .set_dma_mode = pmac_ide_set_dma_mode, | 1011 | .set_dma_mode = pmac_ide_set_dma_mode, |
956 | .selectproc = pmac_ide_selectproc, | 1012 | .selectproc = pmac_ide_selectproc, |
@@ -959,12 +1015,14 @@ static const struct ide_port_ops pmac_ide_port_ops = { | |||
959 | static const struct ide_dma_ops pmac_dma_ops; | 1015 | static const struct ide_dma_ops pmac_dma_ops; |
960 | 1016 | ||
961 | static const struct ide_port_info pmac_port_info = { | 1017 | static const struct ide_port_info pmac_port_info = { |
1018 | .name = DRV_NAME, | ||
962 | .init_dma = pmac_ide_init_dma, | 1019 | .init_dma = pmac_ide_init_dma, |
963 | .chipset = ide_pmac, | 1020 | .chipset = ide_pmac, |
1021 | .tp_ops = &pmac_tp_ops, | ||
1022 | .port_ops = &pmac_ide_port_ops, | ||
964 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 1023 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
965 | .dma_ops = &pmac_dma_ops, | 1024 | .dma_ops = &pmac_dma_ops, |
966 | #endif | 1025 | #endif |
967 | .port_ops = &pmac_ide_port_ops, | ||
968 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | 1026 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | |
969 | IDE_HFLAG_POST_SET_MODE | | 1027 | IDE_HFLAG_POST_SET_MODE | |
970 | IDE_HFLAG_MMIO | | 1028 | IDE_HFLAG_MMIO | |
@@ -977,13 +1035,15 @@ static const struct ide_port_info pmac_port_info = { | |||
977 | * Setup, register & probe an IDE channel driven by this driver, this is | 1035 | * Setup, register & probe an IDE channel driven by this driver, this is |
978 | * called by one of the 2 probe functions (macio or PCI). | 1036 | * called by one of the 2 probe functions (macio or PCI). |
979 | */ | 1037 | */ |
980 | static int __devinit | 1038 | static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) |
981 | pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | ||
982 | { | 1039 | { |
983 | struct device_node *np = pmif->node; | 1040 | struct device_node *np = pmif->node; |
984 | const int *bidp; | 1041 | const int *bidp; |
985 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 1042 | struct ide_host *host; |
1043 | ide_hwif_t *hwif; | ||
1044 | hw_regs_t *hws[] = { hw, NULL, NULL, NULL }; | ||
986 | struct ide_port_info d = pmac_port_info; | 1045 | struct ide_port_info d = pmac_port_info; |
1046 | int rc; | ||
987 | 1047 | ||
988 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 1048 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
989 | if (of_device_is_compatible(np, "shasta-ata")) { | 1049 | if (of_device_is_compatible(np, "shasta-ata")) { |
@@ -1054,31 +1114,16 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
1054 | msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY)); | 1114 | msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY)); |
1055 | } | 1115 | } |
1056 | 1116 | ||
1057 | /* Setup MMIO ops */ | 1117 | printk(KERN_INFO DRV_NAME ": Found Apple %s controller (%s), " |
1058 | default_hwif_mmiops(hwif); | 1118 | "bus ID %d%s, irq %d\n", model_name[pmif->kind], |
1059 | hwif->OUTBSYNC = pmac_outbsync; | 1119 | pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, |
1120 | pmif->mediabay ? " (mediabay)" : "", hw->irq); | ||
1060 | 1121 | ||
1061 | hwif->hwif_data = pmif; | 1122 | rc = ide_host_add(&d, hws, &host); |
1062 | ide_init_port_hw(hwif, hw); | 1123 | if (rc) |
1124 | return rc; | ||
1063 | 1125 | ||
1064 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", | 1126 | hwif = host->ports[0]; |
1065 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, | ||
1066 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); | ||
1067 | |||
1068 | if (pmif->mediabay) { | ||
1069 | #ifdef CONFIG_PMAC_MEDIABAY | ||
1070 | if (check_media_bay_by_base(pmif->regbase, MB_CD)) { | ||
1071 | #else | ||
1072 | if (1) { | ||
1073 | #endif | ||
1074 | hwif->drives[0].noprobe = 1; | ||
1075 | hwif->drives[1].noprobe = 1; | ||
1076 | } | ||
1077 | } | ||
1078 | |||
1079 | idx[0] = hwif->index; | ||
1080 | |||
1081 | ide_device_add(idx, &d); | ||
1082 | 1127 | ||
1083 | return 0; | 1128 | return 0; |
1084 | } | 1129 | } |
@@ -1101,7 +1146,6 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1101 | { | 1146 | { |
1102 | void __iomem *base; | 1147 | void __iomem *base; |
1103 | unsigned long regbase; | 1148 | unsigned long regbase; |
1104 | ide_hwif_t *hwif; | ||
1105 | pmac_ide_hwif_t *pmif; | 1149 | pmac_ide_hwif_t *pmif; |
1106 | int irq, rc; | 1150 | int irq, rc; |
1107 | hw_regs_t hw; | 1151 | hw_regs_t hw; |
@@ -1110,14 +1154,6 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1110 | if (pmif == NULL) | 1154 | if (pmif == NULL) |
1111 | return -ENOMEM; | 1155 | return -ENOMEM; |
1112 | 1156 | ||
1113 | hwif = ide_find_port(); | ||
1114 | if (hwif == NULL) { | ||
1115 | printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n"); | ||
1116 | printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name); | ||
1117 | rc = -ENODEV; | ||
1118 | goto out_free_pmif; | ||
1119 | } | ||
1120 | |||
1121 | if (macio_resource_count(mdev) == 0) { | 1157 | if (macio_resource_count(mdev) == 0) { |
1122 | printk(KERN_WARNING "ide-pmac: no address for %s\n", | 1158 | printk(KERN_WARNING "ide-pmac: no address for %s\n", |
1123 | mdev->ofdev.node->full_name); | 1159 | mdev->ofdev.node->full_name); |
@@ -1164,7 +1200,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1164 | } else | 1200 | } else |
1165 | pmif->dma_regs = NULL; | 1201 | pmif->dma_regs = NULL; |
1166 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1202 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
1167 | dev_set_drvdata(&mdev->ofdev.dev, hwif); | 1203 | dev_set_drvdata(&mdev->ofdev.dev, pmif); |
1168 | 1204 | ||
1169 | memset(&hw, 0, sizeof(hw)); | 1205 | memset(&hw, 0, sizeof(hw)); |
1170 | pmac_ide_init_ports(&hw, pmif->regbase); | 1206 | pmac_ide_init_ports(&hw, pmif->regbase); |
@@ -1172,7 +1208,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1172 | hw.dev = &mdev->bus->pdev->dev; | 1208 | hw.dev = &mdev->bus->pdev->dev; |
1173 | hw.parent = &mdev->ofdev.dev; | 1209 | hw.parent = &mdev->ofdev.dev; |
1174 | 1210 | ||
1175 | rc = pmac_ide_setup_device(pmif, hwif, &hw); | 1211 | rc = pmac_ide_setup_device(pmif, &hw); |
1176 | if (rc != 0) { | 1212 | if (rc != 0) { |
1177 | /* The inteface is released to the common IDE layer */ | 1213 | /* The inteface is released to the common IDE layer */ |
1178 | dev_set_drvdata(&mdev->ofdev.dev, NULL); | 1214 | dev_set_drvdata(&mdev->ofdev.dev, NULL); |
@@ -1195,12 +1231,13 @@ out_free_pmif: | |||
1195 | static int | 1231 | static int |
1196 | pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) | 1232 | pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) |
1197 | { | 1233 | { |
1198 | ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); | 1234 | pmac_ide_hwif_t *pmif = |
1199 | int rc = 0; | 1235 | (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); |
1236 | int rc = 0; | ||
1200 | 1237 | ||
1201 | if (mesg.event != mdev->ofdev.dev.power.power_state.event | 1238 | if (mesg.event != mdev->ofdev.dev.power.power_state.event |
1202 | && (mesg.event & PM_EVENT_SLEEP)) { | 1239 | && (mesg.event & PM_EVENT_SLEEP)) { |
1203 | rc = pmac_ide_do_suspend(hwif); | 1240 | rc = pmac_ide_do_suspend(pmif); |
1204 | if (rc == 0) | 1241 | if (rc == 0) |
1205 | mdev->ofdev.dev.power.power_state = mesg; | 1242 | mdev->ofdev.dev.power.power_state = mesg; |
1206 | } | 1243 | } |
@@ -1211,11 +1248,12 @@ pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) | |||
1211 | static int | 1248 | static int |
1212 | pmac_ide_macio_resume(struct macio_dev *mdev) | 1249 | pmac_ide_macio_resume(struct macio_dev *mdev) |
1213 | { | 1250 | { |
1214 | ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); | 1251 | pmac_ide_hwif_t *pmif = |
1215 | int rc = 0; | 1252 | (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); |
1216 | 1253 | int rc = 0; | |
1254 | |||
1217 | if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) { | 1255 | if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) { |
1218 | rc = pmac_ide_do_resume(hwif); | 1256 | rc = pmac_ide_do_resume(pmif); |
1219 | if (rc == 0) | 1257 | if (rc == 0) |
1220 | mdev->ofdev.dev.power.power_state = PMSG_ON; | 1258 | mdev->ofdev.dev.power.power_state = PMSG_ON; |
1221 | } | 1259 | } |
@@ -1229,7 +1267,6 @@ pmac_ide_macio_resume(struct macio_dev *mdev) | |||
1229 | static int __devinit | 1267 | static int __devinit |
1230 | pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | 1268 | pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) |
1231 | { | 1269 | { |
1232 | ide_hwif_t *hwif; | ||
1233 | struct device_node *np; | 1270 | struct device_node *np; |
1234 | pmac_ide_hwif_t *pmif; | 1271 | pmac_ide_hwif_t *pmif; |
1235 | void __iomem *base; | 1272 | void __iomem *base; |
@@ -1247,14 +1284,6 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1247 | if (pmif == NULL) | 1284 | if (pmif == NULL) |
1248 | return -ENOMEM; | 1285 | return -ENOMEM; |
1249 | 1286 | ||
1250 | hwif = ide_find_port(); | ||
1251 | if (hwif == NULL) { | ||
1252 | printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n"); | ||
1253 | printk(KERN_ERR " %s\n", np->full_name); | ||
1254 | rc = -ENODEV; | ||
1255 | goto out_free_pmif; | ||
1256 | } | ||
1257 | |||
1258 | if (pci_enable_device(pdev)) { | 1287 | if (pci_enable_device(pdev)) { |
1259 | printk(KERN_WARNING "ide-pmac: Can't enable PCI device for " | 1288 | printk(KERN_WARNING "ide-pmac: Can't enable PCI device for " |
1260 | "%s\n", np->full_name); | 1289 | "%s\n", np->full_name); |
@@ -1284,14 +1313,14 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1284 | pmif->kauai_fcr = base; | 1313 | pmif->kauai_fcr = base; |
1285 | pmif->irq = pdev->irq; | 1314 | pmif->irq = pdev->irq; |
1286 | 1315 | ||
1287 | pci_set_drvdata(pdev, hwif); | 1316 | pci_set_drvdata(pdev, pmif); |
1288 | 1317 | ||
1289 | memset(&hw, 0, sizeof(hw)); | 1318 | memset(&hw, 0, sizeof(hw)); |
1290 | pmac_ide_init_ports(&hw, pmif->regbase); | 1319 | pmac_ide_init_ports(&hw, pmif->regbase); |
1291 | hw.irq = pdev->irq; | 1320 | hw.irq = pdev->irq; |
1292 | hw.dev = &pdev->dev; | 1321 | hw.dev = &pdev->dev; |
1293 | 1322 | ||
1294 | rc = pmac_ide_setup_device(pmif, hwif, &hw); | 1323 | rc = pmac_ide_setup_device(pmif, &hw); |
1295 | if (rc != 0) { | 1324 | if (rc != 0) { |
1296 | /* The inteface is released to the common IDE layer */ | 1325 | /* The inteface is released to the common IDE layer */ |
1297 | pci_set_drvdata(pdev, NULL); | 1326 | pci_set_drvdata(pdev, NULL); |
@@ -1310,12 +1339,12 @@ out_free_pmif: | |||
1310 | static int | 1339 | static int |
1311 | pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | 1340 | pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) |
1312 | { | 1341 | { |
1313 | ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); | 1342 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev); |
1314 | int rc = 0; | 1343 | int rc = 0; |
1315 | 1344 | ||
1316 | if (mesg.event != pdev->dev.power.power_state.event | 1345 | if (mesg.event != pdev->dev.power.power_state.event |
1317 | && (mesg.event & PM_EVENT_SLEEP)) { | 1346 | && (mesg.event & PM_EVENT_SLEEP)) { |
1318 | rc = pmac_ide_do_suspend(hwif); | 1347 | rc = pmac_ide_do_suspend(pmif); |
1319 | if (rc == 0) | 1348 | if (rc == 0) |
1320 | pdev->dev.power.power_state = mesg; | 1349 | pdev->dev.power.power_state = mesg; |
1321 | } | 1350 | } |
@@ -1326,11 +1355,11 @@ pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
1326 | static int | 1355 | static int |
1327 | pmac_ide_pci_resume(struct pci_dev *pdev) | 1356 | pmac_ide_pci_resume(struct pci_dev *pdev) |
1328 | { | 1357 | { |
1329 | ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); | 1358 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev); |
1330 | int rc = 0; | 1359 | int rc = 0; |
1331 | 1360 | ||
1332 | if (pdev->dev.power.power_state.event != PM_EVENT_ON) { | 1361 | if (pdev->dev.power.power_state.event != PM_EVENT_ON) { |
1333 | rc = pmac_ide_do_resume(hwif); | 1362 | rc = pmac_ide_do_resume(pmif); |
1334 | if (rc == 0) | 1363 | if (rc == 0) |
1335 | pdev->dev.power.power_state = PMSG_ON; | 1364 | pdev->dev.power.power_state = PMSG_ON; |
1336 | } | 1365 | } |
@@ -1421,10 +1450,11 @@ out: | |||
1421 | static int | 1450 | static int |
1422 | pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) | 1451 | pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) |
1423 | { | 1452 | { |
1453 | ide_hwif_t *hwif = drive->hwif; | ||
1454 | pmac_ide_hwif_t *pmif = | ||
1455 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1424 | struct dbdma_cmd *table; | 1456 | struct dbdma_cmd *table; |
1425 | int i, count = 0; | 1457 | int i, count = 0; |
1426 | ide_hwif_t *hwif = HWIF(drive); | ||
1427 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
1428 | volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; | 1458 | volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; |
1429 | struct scatterlist *sg; | 1459 | struct scatterlist *sg; |
1430 | int wr = (rq_data_dir(rq) == WRITE); | 1460 | int wr = (rq_data_dir(rq) == WRITE); |
@@ -1520,7 +1550,8 @@ static int | |||
1520 | pmac_ide_dma_setup(ide_drive_t *drive) | 1550 | pmac_ide_dma_setup(ide_drive_t *drive) |
1521 | { | 1551 | { |
1522 | ide_hwif_t *hwif = HWIF(drive); | 1552 | ide_hwif_t *hwif = HWIF(drive); |
1523 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | 1553 | pmac_ide_hwif_t *pmif = |
1554 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1524 | struct request *rq = HWGROUP(drive)->rq; | 1555 | struct request *rq = HWGROUP(drive)->rq; |
1525 | u8 unit = (drive->select.b.unit & 0x01); | 1556 | u8 unit = (drive->select.b.unit & 0x01); |
1526 | u8 ata4; | 1557 | u8 ata4; |
@@ -1560,7 +1591,9 @@ pmac_ide_dma_exec_cmd(ide_drive_t *drive, u8 command) | |||
1560 | static void | 1591 | static void |
1561 | pmac_ide_dma_start(ide_drive_t *drive) | 1592 | pmac_ide_dma_start(ide_drive_t *drive) |
1562 | { | 1593 | { |
1563 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 1594 | ide_hwif_t *hwif = drive->hwif; |
1595 | pmac_ide_hwif_t *pmif = | ||
1596 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1564 | volatile struct dbdma_regs __iomem *dma; | 1597 | volatile struct dbdma_regs __iomem *dma; |
1565 | 1598 | ||
1566 | dma = pmif->dma_regs; | 1599 | dma = pmif->dma_regs; |
@@ -1576,7 +1609,9 @@ pmac_ide_dma_start(ide_drive_t *drive) | |||
1576 | static int | 1609 | static int |
1577 | pmac_ide_dma_end (ide_drive_t *drive) | 1610 | pmac_ide_dma_end (ide_drive_t *drive) |
1578 | { | 1611 | { |
1579 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 1612 | ide_hwif_t *hwif = drive->hwif; |
1613 | pmac_ide_hwif_t *pmif = | ||
1614 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1580 | volatile struct dbdma_regs __iomem *dma; | 1615 | volatile struct dbdma_regs __iomem *dma; |
1581 | u32 dstat; | 1616 | u32 dstat; |
1582 | 1617 | ||
@@ -1604,7 +1639,9 @@ pmac_ide_dma_end (ide_drive_t *drive) | |||
1604 | static int | 1639 | static int |
1605 | pmac_ide_dma_test_irq (ide_drive_t *drive) | 1640 | pmac_ide_dma_test_irq (ide_drive_t *drive) |
1606 | { | 1641 | { |
1607 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 1642 | ide_hwif_t *hwif = drive->hwif; |
1643 | pmac_ide_hwif_t *pmif = | ||
1644 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1608 | volatile struct dbdma_regs __iomem *dma; | 1645 | volatile struct dbdma_regs __iomem *dma; |
1609 | unsigned long status, timeout; | 1646 | unsigned long status, timeout; |
1610 | 1647 | ||
@@ -1664,7 +1701,9 @@ static void pmac_ide_dma_host_set(ide_drive_t *drive, int on) | |||
1664 | static void | 1701 | static void |
1665 | pmac_ide_dma_lost_irq (ide_drive_t *drive) | 1702 | pmac_ide_dma_lost_irq (ide_drive_t *drive) |
1666 | { | 1703 | { |
1667 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; | 1704 | ide_hwif_t *hwif = drive->hwif; |
1705 | pmac_ide_hwif_t *pmif = | ||
1706 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1668 | volatile struct dbdma_regs __iomem *dma; | 1707 | volatile struct dbdma_regs __iomem *dma; |
1669 | unsigned long status; | 1708 | unsigned long status; |
1670 | 1709 | ||
@@ -1694,7 +1733,8 @@ static const struct ide_dma_ops pmac_dma_ops = { | |||
1694 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, | 1733 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, |
1695 | const struct ide_port_info *d) | 1734 | const struct ide_port_info *d) |
1696 | { | 1735 | { |
1697 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | 1736 | pmac_ide_hwif_t *pmif = |
1737 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | ||
1698 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1738 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1699 | 1739 | ||
1700 | /* We won't need pci_dev if we switch to generic consistent | 1740 | /* We won't need pci_dev if we switch to generic consistent |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 65fc08b6b6d0..b15cad58dc81 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -73,15 +73,12 @@ static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | |||
73 | * @d: IDE port info | 73 | * @d: IDE port info |
74 | * | 74 | * |
75 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. | 75 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
76 | * Where a device has a partner that is already in DMA mode we check | ||
77 | * and enforce IDE simplex rules. | ||
78 | */ | 76 | */ |
79 | 77 | ||
80 | unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) | 78 | unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) |
81 | { | 79 | { |
82 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 80 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
83 | unsigned long dma_base = 0; | 81 | unsigned long dma_base = 0; |
84 | u8 dma_stat = 0; | ||
85 | 82 | ||
86 | if (hwif->host_flags & IDE_HFLAG_MMIO) | 83 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
87 | return hwif->dma_base; | 84 | return hwif->dma_base; |
@@ -102,11 +99,19 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
102 | if (hwif->channel) | 99 | if (hwif->channel) |
103 | dma_base += 8; | 100 | dma_base += 8; |
104 | 101 | ||
105 | if (d->host_flags & IDE_HFLAG_CS5520) | 102 | return dma_base; |
103 | } | ||
104 | EXPORT_SYMBOL_GPL(ide_pci_dma_base); | ||
105 | |||
106 | int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d) | ||
107 | { | ||
108 | u8 dma_stat; | ||
109 | |||
110 | if (d->host_flags & (IDE_HFLAG_MMIO | IDE_HFLAG_CS5520)) | ||
106 | goto out; | 111 | goto out; |
107 | 112 | ||
108 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { | 113 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { |
109 | ide_pci_clear_simplex(dma_base, d->name); | 114 | ide_pci_clear_simplex(hwif->dma_base, d->name); |
110 | goto out; | 115 | goto out; |
111 | } | 116 | } |
112 | 117 | ||
@@ -120,15 +125,15 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
120 | * we tune the drive then try to grab DMA ownership if we want to be | 125 | * we tune the drive then try to grab DMA ownership if we want to be |
121 | * the DMA end. This has to be become dynamic to handle hot-plug. | 126 | * the DMA end. This has to be become dynamic to handle hot-plug. |
122 | */ | 127 | */ |
123 | dma_stat = hwif->INB(dma_base + 2); | 128 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
124 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { | 129 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { |
125 | printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); | 130 | printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); |
126 | dma_base = 0; | 131 | return -1; |
127 | } | 132 | } |
128 | out: | 133 | out: |
129 | return dma_base; | 134 | return 0; |
130 | } | 135 | } |
131 | EXPORT_SYMBOL_GPL(ide_pci_dma_base); | 136 | EXPORT_SYMBOL_GPL(ide_pci_check_simplex); |
132 | 137 | ||
133 | /* | 138 | /* |
134 | * Set up BM-DMA capability (PnP BIOS should have done this) | 139 | * Set up BM-DMA capability (PnP BIOS should have done this) |
@@ -284,33 +289,31 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
284 | } | 289 | } |
285 | 290 | ||
286 | /** | 291 | /** |
287 | * ide_hwif_configure - configure an IDE interface | 292 | * ide_hw_configure - configure a hw_regs_t instance |
288 | * @dev: PCI device holding interface | 293 | * @dev: PCI device holding interface |
289 | * @d: IDE port info | 294 | * @d: IDE port info |
290 | * @port: port number | 295 | * @port: port number |
291 | * @irq: PCI IRQ | 296 | * @irq: PCI IRQ |
297 | * @hw: hw_regs_t instance corresponding to this port | ||
292 | * | 298 | * |
293 | * Perform the initial set up for the hardware interface structure. This | 299 | * Perform the initial set up for the hardware interface structure. This |
294 | * is done per interface port rather than per PCI device. There may be | 300 | * is done per interface port rather than per PCI device. There may be |
295 | * more than one port per device. | 301 | * more than one port per device. |
296 | * | 302 | * |
297 | * Returns the new hardware interface structure, or NULL on a failure | 303 | * Returns zero on success or an error code. |
298 | */ | 304 | */ |
299 | 305 | ||
300 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | 306 | static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, |
301 | const struct ide_port_info *d, | 307 | unsigned int port, int irq, hw_regs_t *hw) |
302 | unsigned int port, int irq) | ||
303 | { | 308 | { |
304 | unsigned long ctl = 0, base = 0; | 309 | unsigned long ctl = 0, base = 0; |
305 | ide_hwif_t *hwif; | ||
306 | struct hw_regs_s hw; | ||
307 | 310 | ||
308 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { | 311 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
309 | if (ide_pci_check_iomem(dev, d, 2 * port) || | 312 | if (ide_pci_check_iomem(dev, d, 2 * port) || |
310 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { | 313 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { |
311 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " | 314 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " |
312 | "as MEM for port %d!\n", d->name, port); | 315 | "as MEM for port %d!\n", d->name, port); |
313 | return NULL; | 316 | return -EINVAL; |
314 | } | 317 | } |
315 | 318 | ||
316 | ctl = pci_resource_start(dev, 2*port+1); | 319 | ctl = pci_resource_start(dev, 2*port+1); |
@@ -324,22 +327,16 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
324 | if (!base || !ctl) { | 327 | if (!base || !ctl) { |
325 | printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n", | 328 | printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n", |
326 | d->name, port); | 329 | d->name, port); |
327 | return NULL; | 330 | return -EINVAL; |
328 | } | 331 | } |
329 | 332 | ||
330 | hwif = ide_find_port_slot(d); | 333 | memset(hw, 0, sizeof(*hw)); |
331 | if (hwif == NULL) | 334 | hw->irq = irq; |
332 | return NULL; | 335 | hw->dev = &dev->dev; |
333 | 336 | hw->chipset = d->chipset ? d->chipset : ide_pci; | |
334 | memset(&hw, 0, sizeof(hw)); | 337 | ide_std_init_ports(hw, base, ctl | 2); |
335 | hw.irq = irq; | ||
336 | hw.dev = &dev->dev; | ||
337 | hw.chipset = d->chipset ? d->chipset : ide_pci; | ||
338 | ide_std_init_ports(&hw, base, ctl | 2); | ||
339 | |||
340 | ide_init_port_hw(hwif, &hw); | ||
341 | 338 | ||
342 | return hwif; | 339 | return 0; |
343 | } | 340 | } |
344 | 341 | ||
345 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 342 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
@@ -362,7 +359,15 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
362 | (dev->class & 0x80))) { | 359 | (dev->class & 0x80))) { |
363 | unsigned long base = ide_pci_dma_base(hwif, d); | 360 | unsigned long base = ide_pci_dma_base(hwif, d); |
364 | 361 | ||
365 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | 362 | if (base == 0) |
363 | return -1; | ||
364 | |||
365 | hwif->dma_base = base; | ||
366 | |||
367 | if (ide_pci_check_simplex(hwif, d) < 0) | ||
368 | return -1; | ||
369 | |||
370 | if (ide_pci_set_master(dev, d->name) < 0) | ||
366 | return -1; | 371 | return -1; |
367 | 372 | ||
368 | if (hwif->host_flags & IDE_HFLAG_MMIO) | 373 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
@@ -376,7 +381,7 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
376 | if (ide_allocate_dma_engine(hwif)) | 381 | if (ide_allocate_dma_engine(hwif)) |
377 | return -1; | 382 | return -1; |
378 | 383 | ||
379 | ide_setup_dma(hwif, base); | 384 | hwif->dma_ops = &sff_dma_ops; |
380 | } | 385 | } |
381 | 386 | ||
382 | return 0; | 387 | return 0; |
@@ -429,7 +434,8 @@ out: | |||
429 | * @dev: PCI device | 434 | * @dev: PCI device |
430 | * @d: IDE port info | 435 | * @d: IDE port info |
431 | * @pciirq: IRQ line | 436 | * @pciirq: IRQ line |
432 | * @idx: ATA index table to update | 437 | * @hw: hw_regs_t instances corresponding to this PCI IDE device |
438 | * @hws: hw_regs_t pointers table to update | ||
433 | * | 439 | * |
434 | * Scan the interfaces attached to this device and do any | 440 | * Scan the interfaces attached to this device and do any |
435 | * necessary per port setup. Attach the devices and ask the | 441 | * necessary per port setup. Attach the devices and ask the |
@@ -440,10 +446,10 @@ out: | |||
440 | * where the chipset setup is not the default PCI IDE one. | 446 | * where the chipset setup is not the default PCI IDE one. |
441 | */ | 447 | */ |
442 | 448 | ||
443 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) | 449 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, |
450 | int pciirq, hw_regs_t *hw, hw_regs_t **hws) | ||
444 | { | 451 | { |
445 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 452 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
446 | ide_hwif_t *hwif; | ||
447 | u8 tmp; | 453 | u8 tmp; |
448 | 454 | ||
449 | /* | 455 | /* |
@@ -459,11 +465,10 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int | |||
459 | continue; /* port not enabled */ | 465 | continue; /* port not enabled */ |
460 | } | 466 | } |
461 | 467 | ||
462 | hwif = ide_hwif_configure(dev, d, port, pciirq); | 468 | if (ide_hw_configure(dev, d, port, pciirq, hw + port)) |
463 | if (hwif == NULL) | ||
464 | continue; | 469 | continue; |
465 | 470 | ||
466 | *(idx + port) = hwif->index; | 471 | *(hws + port) = hw + port; |
467 | } | 472 | } |
468 | } | 473 | } |
469 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); | 474 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); |
@@ -480,7 +485,7 @@ EXPORT_SYMBOL_GPL(ide_pci_setup_ports); | |||
480 | */ | 485 | */ |
481 | static int do_ide_setup_pci_device(struct pci_dev *dev, | 486 | static int do_ide_setup_pci_device(struct pci_dev *dev, |
482 | const struct ide_port_info *d, | 487 | const struct ide_port_info *d, |
483 | u8 *idx, u8 noisy) | 488 | u8 noisy) |
484 | { | 489 | { |
485 | int tried_config = 0; | 490 | int tried_config = 0; |
486 | int pciirq, ret; | 491 | int pciirq, ret; |
@@ -529,22 +534,24 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, | |||
529 | d->name, pciirq); | 534 | d->name, pciirq); |
530 | } | 535 | } |
531 | 536 | ||
532 | /* FIXME: silent failure can happen */ | 537 | ret = pciirq; |
533 | |||
534 | ide_pci_setup_ports(dev, d, pciirq, idx); | ||
535 | out: | 538 | out: |
536 | return ret; | 539 | return ret; |
537 | } | 540 | } |
538 | 541 | ||
539 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | 542 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) |
540 | { | 543 | { |
541 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 544 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
542 | int ret; | 545 | int ret; |
543 | 546 | ||
544 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); | 547 | ret = do_ide_setup_pci_device(dev, d, 1); |
548 | |||
549 | if (ret >= 0) { | ||
550 | /* FIXME: silent failure can happen */ | ||
551 | ide_pci_setup_ports(dev, d, ret, &hw[0], &hws[0]); | ||
545 | 552 | ||
546 | if (ret >= 0) | 553 | ret = ide_host_add(d, hws, NULL); |
547 | ide_device_add(idx, d); | 554 | } |
548 | 555 | ||
549 | return ret; | 556 | return ret; |
550 | } | 557 | } |
@@ -555,19 +562,23 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
555 | { | 562 | { |
556 | struct pci_dev *pdev[] = { dev1, dev2 }; | 563 | struct pci_dev *pdev[] = { dev1, dev2 }; |
557 | int ret, i; | 564 | int ret, i; |
558 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 565 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
559 | 566 | ||
560 | for (i = 0; i < 2; i++) { | 567 | for (i = 0; i < 2; i++) { |
561 | ret = do_ide_setup_pci_device(pdev[i], d, &idx[i*2], !i); | 568 | ret = do_ide_setup_pci_device(pdev[i], d, !i); |
569 | |||
562 | /* | 570 | /* |
563 | * FIXME: Mom, mom, they stole me the helper function to undo | 571 | * FIXME: Mom, mom, they stole me the helper function to undo |
564 | * do_ide_setup_pci_device() on the first device! | 572 | * do_ide_setup_pci_device() on the first device! |
565 | */ | 573 | */ |
566 | if (ret < 0) | 574 | if (ret < 0) |
567 | goto out; | 575 | goto out; |
576 | |||
577 | /* FIXME: silent failure can happen */ | ||
578 | ide_pci_setup_ports(pdev[i], d, ret, &hw[i*2], &hws[i*2]); | ||
568 | } | 579 | } |
569 | 580 | ||
570 | ide_device_add(idx, d); | 581 | ret = ide_host_add(d, hws, NULL); |
571 | out: | 582 | out: |
572 | return ret; | 583 | return ret; |
573 | } | 584 | } |