diff options
author | Steve French <sfrench@us.ibm.com> | 2008-04-28 00:01:34 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-04-28 00:01:34 -0400 |
commit | 1dbbb6077426f8ce63d6a59c5ac6613e1689cbde (patch) | |
tree | 6141d4d7a8eb7c557705bdfa764137d4fd2e4924 /drivers/ide | |
parent | d09e860cf07e7c9ee12920a09f5080e30a12a23a (diff) | |
parent | 064922a805ec7aadfafdd27aa6b4908d737c3c1d (diff) |
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/ide')
80 files changed, 3399 insertions, 4608 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 87532034d105..3f9e10001e19 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -1031,7 +1031,7 @@ comment "Other IDE chipsets support" | |||
1031 | comment "Note: most of these also require special kernel boot parameters" | 1031 | comment "Note: most of these also require special kernel boot parameters" |
1032 | 1032 | ||
1033 | config BLK_DEV_4DRIVES | 1033 | config BLK_DEV_4DRIVES |
1034 | bool "Generic 4 drives/port support" | 1034 | tristate "Generic 4 drives/port support" |
1035 | help | 1035 | help |
1036 | Certain older chipsets, including the Tekram 690CD, use a single set | 1036 | Certain older chipsets, including the Tekram 690CD, use a single set |
1037 | of I/O ports at 0x1f0 to control up to four drives, instead of the | 1037 | of I/O ports at 0x1f0 to control up to four drives, instead of the |
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c index ec46c44b061c..713cef20622e 100644 --- a/drivers/ide/arm/bast-ide.c +++ b/drivers/ide/arm/bast-ide.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <asm/arch/bast-map.h> | 21 | #include <asm/arch/bast-map.h> |
22 | #include <asm/arch/bast-irq.h> | 22 | #include <asm/arch/bast-irq.h> |
23 | 23 | ||
24 | #define DRV_NAME "bast-ide" | ||
25 | |||
24 | static int __init bastide_register(unsigned int base, unsigned int aux, int irq) | 26 | static int __init bastide_register(unsigned int base, unsigned int aux, int irq) |
25 | { | 27 | { |
26 | ide_hwif_t *hwif; | 28 | ide_hwif_t *hwif; |
@@ -33,27 +35,23 @@ static int __init bastide_register(unsigned int base, unsigned int aux, int irq) | |||
33 | base += BAST_IDE_CS; | 35 | base += BAST_IDE_CS; |
34 | aux += BAST_IDE_CS; | 36 | aux += BAST_IDE_CS; |
35 | 37 | ||
36 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 38 | for (i = 0; i <= 7; i++) { |
37 | hw.io_ports[i] = (unsigned long)base; | 39 | hw.io_ports_array[i] = (unsigned long)base; |
38 | base += 0x20; | 40 | base += 0x20; |
39 | } | 41 | } |
40 | 42 | ||
41 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); | 43 | hw.io_ports.ctl_addr = aux + (6 * 0x20); |
42 | hw.irq = irq; | 44 | hw.irq = irq; |
43 | 45 | ||
44 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 46 | hwif = ide_find_port(); |
45 | if (hwif == NULL) | 47 | if (hwif == NULL) |
46 | goto out; | 48 | goto out; |
47 | 49 | ||
48 | i = hwif->index; | 50 | i = hwif->index; |
49 | 51 | ||
50 | if (hwif->present) | 52 | ide_init_port_data(hwif, i); |
51 | ide_unregister(i); | ||
52 | else | ||
53 | ide_init_port_data(hwif, i); | ||
54 | |||
55 | ide_init_port_hw(hwif, &hw); | 53 | ide_init_port_hw(hwif, &hw); |
56 | hwif->quirkproc = NULL; | 54 | hwif->port_ops = NULL; |
57 | 55 | ||
58 | idx[0] = i; | 56 | idx[0] = i; |
59 | 57 | ||
@@ -64,6 +62,8 @@ out: | |||
64 | 62 | ||
65 | static int __init bastide_init(void) | 63 | static int __init bastide_init(void) |
66 | { | 64 | { |
65 | unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS; | ||
66 | |||
67 | /* we can treat the VR1000 and the BAST the same */ | 67 | /* we can treat the VR1000 and the BAST the same */ |
68 | 68 | ||
69 | if (!(machine_is_bast() || machine_is_vr1000())) | 69 | if (!(machine_is_bast() || machine_is_vr1000())) |
@@ -71,6 +71,11 @@ static int __init bastide_init(void) | |||
71 | 71 | ||
72 | printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n"); | 72 | printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n"); |
73 | 73 | ||
74 | if (!request_mem_region(base, 0x400000, DRV_NAME)) { | ||
75 | printk(KERN_ERR "%s: resources busy\n", DRV_NAME); | ||
76 | return -EBUSY; | ||
77 | } | ||
78 | |||
74 | bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0); | 79 | bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0); |
75 | bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1); | 80 | bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1); |
76 | 81 | ||
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index e816b0ffcfe6..124445c20921 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -191,6 +191,10 @@ static void icside_maskproc(ide_drive_t *drive, int mask) | |||
191 | local_irq_restore(flags); | 191 | local_irq_restore(flags); |
192 | } | 192 | } |
193 | 193 | ||
194 | static const struct ide_port_ops icside_v6_no_dma_port_ops = { | ||
195 | .maskproc = icside_maskproc, | ||
196 | }; | ||
197 | |||
194 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS | 198 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS |
195 | /* | 199 | /* |
196 | * SG-DMA support. | 200 | * SG-DMA support. |
@@ -266,6 +270,11 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) | |||
266 | ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); | 270 | ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); |
267 | } | 271 | } |
268 | 272 | ||
273 | static const struct ide_port_ops icside_v6_port_ops = { | ||
274 | .set_dma_mode = icside_set_dma_mode, | ||
275 | .maskproc = icside_maskproc, | ||
276 | }; | ||
277 | |||
269 | static void icside_dma_host_set(ide_drive_t *drive, int on) | 278 | static void icside_dma_host_set(ide_drive_t *drive, int on) |
270 | { | 279 | { |
271 | } | 280 | } |
@@ -375,32 +384,40 @@ static void icside_dma_lost_irq(ide_drive_t *drive) | |||
375 | printk(KERN_ERR "%s: IRQ lost\n", drive->name); | 384 | printk(KERN_ERR "%s: IRQ lost\n", drive->name); |
376 | } | 385 | } |
377 | 386 | ||
378 | static void icside_dma_init(ide_hwif_t *hwif) | 387 | static int icside_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d) |
379 | { | 388 | { |
380 | hwif->dmatable_cpu = NULL; | 389 | hwif->dmatable_cpu = NULL; |
381 | hwif->dmatable_dma = 0; | 390 | hwif->dmatable_dma = 0; |
382 | hwif->set_dma_mode = icside_set_dma_mode; | 391 | |
383 | 392 | return 0; | |
384 | hwif->dma_host_set = icside_dma_host_set; | ||
385 | hwif->dma_setup = icside_dma_setup; | ||
386 | hwif->dma_exec_cmd = icside_dma_exec_cmd; | ||
387 | hwif->dma_start = icside_dma_start; | ||
388 | hwif->ide_dma_end = icside_dma_end; | ||
389 | hwif->ide_dma_test_irq = icside_dma_test_irq; | ||
390 | hwif->dma_timeout = icside_dma_timeout; | ||
391 | hwif->dma_lost_irq = icside_dma_lost_irq; | ||
392 | } | 393 | } |
394 | |||
395 | static const struct ide_dma_ops icside_v6_dma_ops = { | ||
396 | .dma_host_set = icside_dma_host_set, | ||
397 | .dma_setup = icside_dma_setup, | ||
398 | .dma_exec_cmd = icside_dma_exec_cmd, | ||
399 | .dma_start = icside_dma_start, | ||
400 | .dma_end = icside_dma_end, | ||
401 | .dma_test_irq = icside_dma_test_irq, | ||
402 | .dma_timeout = icside_dma_timeout, | ||
403 | .dma_lost_irq = icside_dma_lost_irq, | ||
404 | }; | ||
393 | #else | 405 | #else |
394 | #define icside_dma_init(hwif) (0) | 406 | #define icside_v6_dma_ops NULL |
395 | #endif | 407 | #endif |
396 | 408 | ||
409 | static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d) | ||
410 | { | ||
411 | return -EOPNOTSUPP; | ||
412 | } | ||
413 | |||
397 | static ide_hwif_t * | 414 | static ide_hwif_t * |
398 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) | 415 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) |
399 | { | 416 | { |
400 | unsigned long port = (unsigned long)base + info->dataoffset; | 417 | unsigned long port = (unsigned long)base + info->dataoffset; |
401 | ide_hwif_t *hwif; | 418 | ide_hwif_t *hwif; |
402 | 419 | ||
403 | hwif = ide_find_port(port); | 420 | hwif = ide_find_port(); |
404 | if (hwif) { | 421 | if (hwif) { |
405 | int i; | 422 | int i; |
406 | 423 | ||
@@ -408,15 +425,14 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e | |||
408 | * Ensure we're using MMIO | 425 | * Ensure we're using MMIO |
409 | */ | 426 | */ |
410 | default_hwif_mmiops(hwif); | 427 | default_hwif_mmiops(hwif); |
411 | hwif->mmio = 1; | ||
412 | 428 | ||
413 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 429 | for (i = 0; i <= 7; i++) { |
414 | hwif->io_ports[i] = port; | 430 | hwif->io_ports_array[i] = port; |
415 | port += 1 << info->stepping; | 431 | port += 1 << info->stepping; |
416 | } | 432 | } |
417 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; | 433 | hwif->io_ports.ctl_addr = |
434 | (unsigned long)base + info->ctrloffset; | ||
418 | hwif->irq = ec->irq; | 435 | hwif->irq = ec->irq; |
419 | hwif->noprobe = 0; | ||
420 | hwif->chipset = ide_acorn; | 436 | hwif->chipset = ide_acorn; |
421 | hwif->gendev.parent = &ec->dev; | 437 | hwif->gendev.parent = &ec->dev; |
422 | hwif->dev = &ec->dev; | 438 | hwif->dev = &ec->dev; |
@@ -462,9 +478,10 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
462 | } | 478 | } |
463 | 479 | ||
464 | static const struct ide_port_info icside_v6_port_info __initdata = { | 480 | static const struct ide_port_info icside_v6_port_info __initdata = { |
465 | .host_flags = IDE_HFLAG_SERIALIZE | | 481 | .init_dma = icside_dma_off_init, |
466 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | 482 | .port_ops = &icside_v6_no_dma_port_ops, |
467 | IDE_HFLAG_NO_AUTOTUNE, | 483 | .dma_ops = &icside_v6_dma_ops, |
484 | .host_flags = IDE_HFLAG_SERIALIZE, | ||
468 | .mwdma_mask = ATA_MWDMA2, | 485 | .mwdma_mask = ATA_MWDMA2, |
469 | .swdma_mask = ATA_SWDMA2, | 486 | .swdma_mask = ATA_SWDMA2, |
470 | }; | 487 | }; |
@@ -526,21 +543,19 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
526 | state->hwif[0] = hwif; | 543 | state->hwif[0] = hwif; |
527 | state->hwif[1] = mate; | 544 | state->hwif[1] = mate; |
528 | 545 | ||
529 | hwif->maskproc = icside_maskproc; | ||
530 | hwif->hwif_data = state; | 546 | hwif->hwif_data = state; |
531 | hwif->config_data = (unsigned long)ioc_base; | 547 | hwif->config_data = (unsigned long)ioc_base; |
532 | hwif->select_data = sel; | 548 | hwif->select_data = sel; |
533 | 549 | ||
534 | mate->maskproc = icside_maskproc; | ||
535 | mate->hwif_data = state; | 550 | mate->hwif_data = state; |
536 | mate->config_data = (unsigned long)ioc_base; | 551 | mate->config_data = (unsigned long)ioc_base; |
537 | mate->select_data = sel | 1; | 552 | mate->select_data = sel | 1; |
538 | 553 | ||
539 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { | 554 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { |
540 | icside_dma_init(hwif); | 555 | d.init_dma = icside_dma_init; |
541 | icside_dma_init(mate); | 556 | d.port_ops = &icside_v6_port_ops; |
542 | } else | 557 | d.dma_ops = NULL; |
543 | d.mwdma_mask = d.swdma_mask = 0; | 558 | } |
544 | 559 | ||
545 | idx[0] = hwif->index; | 560 | idx[0] = hwif->index; |
546 | idx[1] = mate->index; | 561 | idx[1] = mate->index; |
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index be9ff7334c52..4263ffd4ab20 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <asm/mach-types.h> | 14 | #include <asm/mach-types.h> |
15 | #include <asm/irq.h> | 15 | #include <asm/irq.h> |
16 | 16 | ||
17 | #define DRV_NAME "ide_arm" | ||
18 | |||
17 | #ifdef CONFIG_ARCH_CLPS7500 | 19 | #ifdef CONFIG_ARCH_CLPS7500 |
18 | # include <asm/arch/hardware.h> | 20 | # include <asm/arch/hardware.h> |
19 | # | 21 | # |
@@ -28,13 +30,27 @@ static int __init ide_arm_init(void) | |||
28 | { | 30 | { |
29 | ide_hwif_t *hwif; | 31 | ide_hwif_t *hwif; |
30 | hw_regs_t hw; | 32 | hw_regs_t hw; |
33 | unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; | ||
31 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
32 | 35 | ||
36 | if (!request_region(base, 8, DRV_NAME)) { | ||
37 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
38 | DRV_NAME, base, base + 7); | ||
39 | return -EBUSY; | ||
40 | } | ||
41 | |||
42 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
43 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
44 | DRV_NAME, ctl); | ||
45 | release_region(base, 8); | ||
46 | return -EBUSY; | ||
47 | } | ||
48 | |||
33 | memset(&hw, 0, sizeof(hw)); | 49 | memset(&hw, 0, sizeof(hw)); |
34 | ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); | 50 | ide_std_init_ports(&hw, base, ctl); |
35 | hw.irq = IDE_ARM_IRQ; | 51 | hw.irq = IDE_ARM_IRQ; |
36 | 52 | ||
37 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 53 | hwif = ide_find_port(); |
38 | if (hwif) { | 54 | if (hwif) { |
39 | ide_init_port_hw(hwif, &hw); | 55 | ide_init_port_hw(hwif, &hw); |
40 | idx[0] = hwif->index; | 56 | idx[0] = hwif->index; |
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 420fcb78a7cd..aaf32541622d 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -96,11 +96,11 @@ static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | |||
96 | u16 val16; | 96 | u16 val16; |
97 | 97 | ||
98 | /* DMA Data Setup */ | 98 | /* DMA Data Setup */ |
99 | t0 = (palm_bk3710_udmatimings[mode].cycletime + ide_palm_clk - 1) | 99 | t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime, |
100 | / ide_palm_clk - 1; | 100 | ide_palm_clk) - 1; |
101 | tenv = (20 + ide_palm_clk - 1) / ide_palm_clk - 1; | 101 | tenv = DIV_ROUND_UP(20, ide_palm_clk) - 1; |
102 | trp = (palm_bk3710_udmatimings[mode].rptime + ide_palm_clk - 1) | 102 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, |
103 | / ide_palm_clk - 1; | 103 | ide_palm_clk) - 1; |
104 | 104 | ||
105 | /* udmatim Register */ | 105 | /* udmatim Register */ |
106 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); | 106 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); |
@@ -141,8 +141,8 @@ static void palm_bk3710_setdmamode(void __iomem *base, unsigned int dev, | |||
141 | cycletime = max_t(int, t->cycle, min_cycle); | 141 | cycletime = max_t(int, t->cycle, min_cycle); |
142 | 142 | ||
143 | /* DMA Data Setup */ | 143 | /* DMA Data Setup */ |
144 | t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk; | 144 | t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); |
145 | td = (t->active + ide_palm_clk - 1) / ide_palm_clk; | 145 | td = DIV_ROUND_UP(t->active, ide_palm_clk); |
146 | tkw = t0 - td - 1; | 146 | tkw = t0 - td - 1; |
147 | td -= 1; | 147 | td -= 1; |
148 | 148 | ||
@@ -168,9 +168,9 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
168 | struct ide_timing *t; | 168 | struct ide_timing *t; |
169 | 169 | ||
170 | /* PIO Data Setup */ | 170 | /* PIO Data Setup */ |
171 | t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk; | 171 | t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); |
172 | t2 = (ide_timing_find_mode(XFER_PIO_0 + mode)->active + | 172 | t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, |
173 | ide_palm_clk - 1) / ide_palm_clk; | 173 | ide_palm_clk); |
174 | 174 | ||
175 | t2i = t0 - t2 - 1; | 175 | t2i = t0 - t2 - 1; |
176 | t2 -= 1; | 176 | t2 -= 1; |
@@ -192,8 +192,8 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
192 | 192 | ||
193 | /* TASKFILE Setup */ | 193 | /* TASKFILE Setup */ |
194 | t = ide_timing_find_mode(XFER_PIO_0 + mode); | 194 | t = ide_timing_find_mode(XFER_PIO_0 + mode); |
195 | t0 = (t->cyc8b + ide_palm_clk - 1) / ide_palm_clk; | 195 | t0 = DIV_ROUND_UP(t->cyc8b, ide_palm_clk); |
196 | t2 = (t->act8b + ide_palm_clk - 1) / ide_palm_clk; | 196 | t2 = DIV_ROUND_UP(t->act8b, ide_palm_clk); |
197 | 197 | ||
198 | t2i = t0 - t2 - 1; | 198 | t2i = t0 - t2 - 1; |
199 | t2 -= 1; | 199 | t2 -= 1; |
@@ -317,17 +317,31 @@ static u8 __devinit palm_bk3710_cable_detect(ide_hwif_t *hwif) | |||
317 | return ATA_CBL_PATA80; | 317 | return ATA_CBL_PATA80; |
318 | } | 318 | } |
319 | 319 | ||
320 | static void __devinit palm_bk3710_init_hwif(ide_hwif_t *hwif) | 320 | static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif, |
321 | const struct ide_port_info *d) | ||
321 | { | 322 | { |
322 | hwif->set_pio_mode = palm_bk3710_set_pio_mode; | 323 | unsigned long base = |
323 | hwif->set_dma_mode = palm_bk3710_set_dma_mode; | 324 | hwif->io_ports.data_addr - IDE_PALM_ATA_PRI_REG_OFFSET; |
324 | 325 | ||
325 | hwif->cable_detect = palm_bk3710_cable_detect; | 326 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
327 | |||
328 | if (ide_allocate_dma_engine(hwif)) | ||
329 | return -1; | ||
330 | |||
331 | ide_setup_dma(hwif, base); | ||
332 | |||
333 | return 0; | ||
326 | } | 334 | } |
327 | 335 | ||
336 | static const struct ide_port_ops palm_bk3710_ports_ops = { | ||
337 | .set_pio_mode = palm_bk3710_set_pio_mode, | ||
338 | .set_dma_mode = palm_bk3710_set_dma_mode, | ||
339 | .cable_detect = palm_bk3710_cable_detect, | ||
340 | }; | ||
341 | |||
328 | static const struct ide_port_info __devinitdata palm_bk3710_port_info = { | 342 | static const struct ide_port_info __devinitdata palm_bk3710_port_info = { |
329 | .init_hwif = palm_bk3710_init_hwif, | 343 | .init_dma = palm_bk3710_init_dma, |
330 | .host_flags = IDE_HFLAG_NO_DMA, /* hack (no PCI) */ | 344 | .port_ops = &palm_bk3710_ports_ops, |
331 | .pio_mask = ATA_PIO4, | 345 | .pio_mask = ATA_PIO4, |
332 | .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ | 346 | .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ |
333 | .mwdma_mask = ATA_MWDMA2, | 347 | .mwdma_mask = ATA_MWDMA2, |
@@ -372,30 +386,24 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
372 | 386 | ||
373 | pribase = mem->start + IDE_PALM_ATA_PRI_REG_OFFSET; | 387 | pribase = mem->start + IDE_PALM_ATA_PRI_REG_OFFSET; |
374 | for (i = 0; i < IDE_NR_PORTS - 2; i++) | 388 | for (i = 0; i < IDE_NR_PORTS - 2; i++) |
375 | hw.io_ports[i] = pribase + i; | 389 | hw.io_ports_array[i] = pribase + i; |
376 | hw.io_ports[IDE_CONTROL_OFFSET] = mem->start + | 390 | hw.io_ports.ctl_addr = mem->start + |
377 | IDE_PALM_ATA_PRI_CTL_OFFSET; | 391 | IDE_PALM_ATA_PRI_CTL_OFFSET; |
378 | hw.irq = irq->start; | 392 | hw.irq = irq->start; |
379 | hw.chipset = ide_palm3710; | 393 | hw.chipset = ide_palm3710; |
380 | 394 | ||
381 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 395 | hwif = ide_find_port(); |
382 | if (hwif == NULL) | 396 | if (hwif == NULL) |
383 | goto out; | 397 | goto out; |
384 | 398 | ||
385 | i = hwif->index; | 399 | i = hwif->index; |
386 | 400 | ||
387 | if (hwif->present) | 401 | ide_init_port_data(hwif, i); |
388 | ide_unregister(i); | ||
389 | else | ||
390 | ide_init_port_data(hwif, i); | ||
391 | |||
392 | ide_init_port_hw(hwif, &hw); | 402 | ide_init_port_hw(hwif, &hw); |
393 | 403 | ||
394 | hwif->mmio = 1; | 404 | hwif->mmio = 1; |
395 | default_hwif_mmiops(hwif); | 405 | default_hwif_mmiops(hwif); |
396 | 406 | ||
397 | ide_setup_dma(hwif, mem->start); | ||
398 | |||
399 | idx[0] = i; | 407 | idx[0] = i; |
400 | 408 | ||
401 | ide_device_add(idx, &palm_bk3710_port_info); | 409 | ide_device_add(idx, &palm_bk3710_port_info); |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index b30adcf321c3..babc1a5e128d 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -17,11 +17,11 @@ static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, | |||
17 | unsigned long port = (unsigned long)base; | 17 | unsigned long port = (unsigned long)base; |
18 | int i; | 18 | int i; |
19 | 19 | ||
20 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 20 | for (i = 0; i <= 7; i++) { |
21 | hw->io_ports[i] = port; | 21 | hw->io_ports_array[i] = port; |
22 | port += sz; | 22 | port += sz; |
23 | } | 23 | } |
24 | hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; | 24 | hw->io_ports.ctl_addr = (unsigned long)ctrl; |
25 | hw->irq = irq; | 25 | hw->irq = irq; |
26 | } | 26 | } |
27 | 27 | ||
@@ -44,7 +44,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
44 | goto release; | 44 | goto release; |
45 | } | 45 | } |
46 | 46 | ||
47 | hwif = ide_find_port((unsigned long)base); | 47 | hwif = ide_find_port(); |
48 | if (hwif) { | 48 | if (hwif) { |
49 | memset(&hw, 0, sizeof(hw)); | 49 | memset(&hw, 0, sizeof(hw)); |
50 | rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); | 50 | rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); |
@@ -53,7 +53,6 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
53 | 53 | ||
54 | ide_init_port_hw(hwif, &hw); | 54 | ide_init_port_hw(hwif, &hw); |
55 | 55 | ||
56 | hwif->mmio = 1; | ||
57 | default_hwif_mmiops(hwif); | 56 | default_hwif_mmiops(hwif); |
58 | 57 | ||
59 | idx[0] = hwif->index; | 58 | idx[0] = hwif->index; |
@@ -76,7 +75,7 @@ static void __devexit rapide_remove(struct expansion_card *ec) | |||
76 | 75 | ||
77 | ecard_set_drvdata(ec, NULL); | 76 | ecard_set_drvdata(ec, NULL); |
78 | 77 | ||
79 | ide_unregister(hwif->index); | 78 | ide_unregister(hwif); |
80 | 79 | ||
81 | ecard_release_resources(ec); | 80 | ecard_release_resources(ec); |
82 | } | 81 | } |
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 31266d278095..9df26855bc05 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
@@ -88,8 +88,8 @@ enum /* Transfer types */ | |||
88 | int | 88 | int |
89 | cris_ide_ack_intr(ide_hwif_t* hwif) | 89 | cris_ide_ack_intr(ide_hwif_t* hwif) |
90 | { | 90 | { |
91 | reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, | 91 | reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, |
92 | int, hwif->io_ports[0]); | 92 | hwif->io_ports.data_addr); |
93 | REG_WR_INT(ata, regi_ata, rw_ack_intr, 1 << ctrl2.sel); | 93 | REG_WR_INT(ata, regi_ata, rw_ack_intr, 1 << ctrl2.sel); |
94 | return 1; | 94 | return 1; |
95 | } | 95 | } |
@@ -231,7 +231,7 @@ cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int dir,int type, | |||
231 | ide_hwif_t *hwif = drive->hwif; | 231 | ide_hwif_t *hwif = drive->hwif; |
232 | 232 | ||
233 | reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, | 233 | reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, |
234 | hwif->io_ports[IDE_DATA_OFFSET]); | 234 | hwif->io_ports.data_addr); |
235 | reg_ata_rw_trf_cnt trf_cnt = {0}; | 235 | reg_ata_rw_trf_cnt trf_cnt = {0}; |
236 | 236 | ||
237 | mycontext.saved_data = (dma_descr_data*)virt_to_phys(d); | 237 | mycontext.saved_data = (dma_descr_data*)virt_to_phys(d); |
@@ -271,7 +271,7 @@ static int cris_dma_test_irq(ide_drive_t *drive) | |||
271 | int intr = REG_RD_INT(ata, regi_ata, r_intr); | 271 | int intr = REG_RD_INT(ata, regi_ata, r_intr); |
272 | 272 | ||
273 | reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, | 273 | reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, |
274 | hwif->io_ports[IDE_DATA_OFFSET]); | 274 | hwif->io_ports.data_addr); |
275 | 275 | ||
276 | return intr & (1 << ctrl2.sel) ? 1 : 0; | 276 | return intr & (1 << ctrl2.sel) ? 1 : 0; |
277 | } | 277 | } |
@@ -531,7 +531,7 @@ static void cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int d | |||
531 | *R_ATA_CTRL_DATA = | 531 | *R_ATA_CTRL_DATA = |
532 | cmd | | 532 | cmd | |
533 | IO_FIELD(R_ATA_CTRL_DATA, data, | 533 | IO_FIELD(R_ATA_CTRL_DATA, data, |
534 | drive->hwif->io_ports[IDE_DATA_OFFSET]) | | 534 | drive->hwif->io_ports.data_addr) | |
535 | IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) | | 535 | IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) | |
536 | IO_STATE(R_ATA_CTRL_DATA, multi, on) | | 536 | IO_STATE(R_ATA_CTRL_DATA, multi, on) | |
537 | IO_STATE(R_ATA_CTRL_DATA, dma_size, word); | 537 | IO_STATE(R_ATA_CTRL_DATA, dma_size, word); |
@@ -550,7 +550,7 @@ static int cris_dma_test_irq(ide_drive_t *drive) | |||
550 | { | 550 | { |
551 | int intr = *R_IRQ_MASK0_RD; | 551 | int intr = *R_IRQ_MASK0_RD; |
552 | int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel, | 552 | int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel, |
553 | drive->hwif->io_ports[IDE_DATA_OFFSET]); | 553 | drive->hwif->io_ports.data_addr); |
554 | 554 | ||
555 | return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0; | 555 | return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0; |
556 | } | 556 | } |
@@ -644,7 +644,7 @@ cris_ide_inw(unsigned long reg) { | |||
644 | * call will also timeout on busy, but as long as the | 644 | * call will also timeout on busy, but as long as the |
645 | * write is still performed, everything will be fine. | 645 | * write is still performed, everything will be fine. |
646 | */ | 646 | */ |
647 | if (cris_ide_get_reg(reg) == IDE_STATUS_OFFSET) | 647 | if (cris_ide_get_reg(reg) == 7) |
648 | return BUSY_STAT; | 648 | return BUSY_STAT; |
649 | else | 649 | else |
650 | /* For other rare cases we assume 0 is good enough. */ | 650 | /* For other rare cases we assume 0 is good enough. */ |
@@ -673,11 +673,6 @@ cris_ide_inb(unsigned long reg) | |||
673 | return (unsigned char)cris_ide_inw(reg); | 673 | return (unsigned char)cris_ide_inw(reg); |
674 | } | 674 | } |
675 | 675 | ||
676 | static int cris_dma_end (ide_drive_t *drive); | ||
677 | static int cris_dma_setup (ide_drive_t *drive); | ||
678 | static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command); | ||
679 | static int cris_dma_test_irq(ide_drive_t *drive); | ||
680 | static void cris_dma_start(ide_drive_t *drive); | ||
681 | static void cris_ide_input_data (ide_drive_t *drive, void *, unsigned int); | 676 | static void cris_ide_input_data (ide_drive_t *drive, void *, unsigned int); |
682 | static void cris_ide_output_data (ide_drive_t *drive, void *, unsigned int); | 677 | static void cris_ide_output_data (ide_drive_t *drive, void *, unsigned int); |
683 | static void cris_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int); | 678 | static void cris_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int); |
@@ -770,20 +765,29 @@ static void __init cris_setup_ports(hw_regs_t *hw, unsigned long base) | |||
770 | memset(hw, 0, sizeof(*hw)); | 765 | memset(hw, 0, sizeof(*hw)); |
771 | 766 | ||
772 | for (i = 0; i <= 7; i++) | 767 | for (i = 0; i <= 7; i++) |
773 | hw->io_ports[i] = base + cris_ide_reg_addr(i, 0, 1); | 768 | hw->io_ports_array[i] = base + cris_ide_reg_addr(i, 0, 1); |
774 | 769 | ||
775 | /* | 770 | /* |
776 | * the IDE control register is at ATA address 6, | 771 | * the IDE control register is at ATA address 6, |
777 | * with CS1 active instead of CS0 | 772 | * with CS1 active instead of CS0 |
778 | */ | 773 | */ |
779 | hw->io_ports[IDE_CONTROL_OFFSET] = base + cris_ide_reg_addr(6, 1, 0); | 774 | hw->io_ports.ctl_addr = base + cris_ide_reg_addr(6, 1, 0); |
780 | 775 | ||
781 | hw->irq = ide_default_irq(0); | 776 | hw->irq = ide_default_irq(0); |
782 | hw->ack_intr = cris_ide_ack_intr; | 777 | hw->ack_intr = cris_ide_ack_intr; |
783 | } | 778 | } |
784 | 779 | ||
780 | static const struct ide_port_ops cris_port_ops = { | ||
781 | .set_pio_mode = cris_set_pio_mode, | ||
782 | .set_dma_mode = cris_set_dma_mode, | ||
783 | }; | ||
784 | |||
785 | static const struct ide_dma_ops cris_dma_ops; | ||
786 | |||
785 | static const struct ide_port_info cris_port_info __initdata = { | 787 | static const struct ide_port_info cris_port_info __initdata = { |
786 | .chipset = ide_etrax100, | 788 | .chipset = ide_etrax100, |
789 | .port_ops = &cris_port_ops, | ||
790 | .dma_ops = &cris_dma_ops, | ||
787 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 791 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
788 | IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ | 792 | IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ |
789 | .pio_mask = ATA_PIO4, | 793 | .pio_mask = ATA_PIO4, |
@@ -804,24 +808,16 @@ static int __init init_e100_ide(void) | |||
804 | 808 | ||
805 | cris_setup_ports(&hw, cris_ide_base_address(h)); | 809 | cris_setup_ports(&hw, cris_ide_base_address(h)); |
806 | 810 | ||
807 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 811 | hwif = ide_find_port(); |
808 | if (hwif == NULL) | 812 | if (hwif == NULL) |
809 | continue; | 813 | continue; |
810 | ide_init_port_data(hwif, hwif->index); | 814 | ide_init_port_data(hwif, hwif->index); |
811 | ide_init_port_hw(hwif, &hw); | 815 | ide_init_port_hw(hwif, &hw); |
812 | hwif->mmio = 1; | 816 | |
813 | hwif->set_pio_mode = &cris_set_pio_mode; | ||
814 | hwif->set_dma_mode = &cris_set_dma_mode; | ||
815 | hwif->ata_input_data = &cris_ide_input_data; | 817 | hwif->ata_input_data = &cris_ide_input_data; |
816 | hwif->ata_output_data = &cris_ide_output_data; | 818 | hwif->ata_output_data = &cris_ide_output_data; |
817 | hwif->atapi_input_bytes = &cris_atapi_input_bytes; | 819 | hwif->atapi_input_bytes = &cris_atapi_input_bytes; |
818 | hwif->atapi_output_bytes = &cris_atapi_output_bytes; | 820 | hwif->atapi_output_bytes = &cris_atapi_output_bytes; |
819 | hwif->dma_host_set = &cris_dma_host_set; | ||
820 | hwif->ide_dma_end = &cris_dma_end; | ||
821 | hwif->dma_setup = &cris_dma_setup; | ||
822 | hwif->dma_exec_cmd = &cris_dma_exec_cmd; | ||
823 | hwif->ide_dma_test_irq = &cris_dma_test_irq; | ||
824 | hwif->dma_start = &cris_dma_start; | ||
825 | hwif->OUTB = &cris_ide_outb; | 821 | hwif->OUTB = &cris_ide_outb; |
826 | hwif->OUTW = &cris_ide_outw; | 822 | hwif->OUTW = &cris_ide_outw; |
827 | hwif->OUTBSYNC = &cris_ide_outbsync; | 823 | hwif->OUTBSYNC = &cris_ide_outbsync; |
@@ -1076,6 +1072,15 @@ static void cris_dma_start(ide_drive_t *drive) | |||
1076 | } | 1072 | } |
1077 | } | 1073 | } |
1078 | 1074 | ||
1075 | static const struct ide_dma_ops cris_dma_ops = { | ||
1076 | .dma_host_set = cris_dma_host_set, | ||
1077 | .dma_setup = cris_dma_setup, | ||
1078 | .dma_exec_cmd = cris_dma_exec_cmd, | ||
1079 | .dma_start = cris_dma_start, | ||
1080 | .dma_end = cris_dma_end, | ||
1081 | .dma_test_irq = cris_dma_test_irq, | ||
1082 | }; | ||
1083 | |||
1079 | module_init(init_e100_ide); | 1084 | module_init(init_e100_ide); |
1080 | 1085 | ||
1081 | MODULE_LICENSE("GPL"); | 1086 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index 4108ec4ffa7f..fd23f12e17aa 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
@@ -63,9 +63,9 @@ static inline void hw_setup(hw_regs_t *hw) | |||
63 | int i; | 63 | int i; |
64 | 64 | ||
65 | memset(hw, 0, sizeof(hw_regs_t)); | 65 | memset(hw, 0, sizeof(hw_regs_t)); |
66 | for (i = 0; i <= IDE_STATUS_OFFSET; i++) | 66 | for (i = 0; i <= 7; i++) |
67 | hw->io_ports[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; | 67 | hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; |
68 | hw->io_ports[IDE_CONTROL_OFFSET] = CONFIG_H8300_IDE_ALT; | 68 | hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT; |
69 | hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; | 69 | hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; |
70 | hw->chipset = ide_generic; | 70 | hw->chipset = ide_generic; |
71 | } | 71 | } |
@@ -74,7 +74,6 @@ static inline void hwif_setup(ide_hwif_t *hwif) | |||
74 | { | 74 | { |
75 | default_hwif_iops(hwif); | 75 | default_hwif_iops(hwif); |
76 | 76 | ||
77 | hwif->mmio = 1; | ||
78 | hwif->OUTW = mm_outw; | 77 | hwif->OUTW = mm_outw; |
79 | hwif->OUTSW = mm_outsw; | 78 | hwif->OUTSW = mm_outsw; |
80 | hwif->INW = mm_inw; | 79 | hwif->INW = mm_inw; |
@@ -99,8 +98,7 @@ static int __init h8300_ide_init(void) | |||
99 | 98 | ||
100 | hw_setup(&hw); | 99 | hw_setup(&hw); |
101 | 100 | ||
102 | /* register if */ | 101 | hwif = ide_find_port(); |
103 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | ||
104 | if (hwif == NULL) { | 102 | if (hwif == NULL) { |
105 | printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); | 103 | printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); |
106 | return -ENOENT; | 104 | return -ENOENT; |
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 0f6fb6b72dd9..9d3601fa5680 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -55,14 +55,22 @@ struct ide_acpi_hwif_link { | |||
55 | /* note: adds function name and KERN_DEBUG */ | 55 | /* note: adds function name and KERN_DEBUG */ |
56 | #ifdef DEBUGGING | 56 | #ifdef DEBUGGING |
57 | #define DEBPRINT(fmt, args...) \ | 57 | #define DEBPRINT(fmt, args...) \ |
58 | printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ## args) | 58 | printk(KERN_DEBUG "%s: " fmt, __func__, ## args) |
59 | #else | 59 | #else |
60 | #define DEBPRINT(fmt, args...) do {} while (0) | 60 | #define DEBPRINT(fmt, args...) do {} while (0) |
61 | #endif /* DEBUGGING */ | 61 | #endif /* DEBUGGING */ |
62 | 62 | ||
63 | extern int ide_noacpi; | 63 | int ide_noacpi; |
64 | extern int ide_noacpitfs; | 64 | module_param_named(noacpi, ide_noacpi, bool, 0); |
65 | extern int ide_noacpionboot; | 65 | MODULE_PARM_DESC(noacpi, "disable IDE ACPI support"); |
66 | |||
67 | int ide_acpigtf; | ||
68 | module_param_named(acpigtf, ide_acpigtf, bool, 0); | ||
69 | MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support"); | ||
70 | |||
71 | int ide_acpionboot; | ||
72 | module_param_named(acpionboot, ide_acpionboot, bool, 0); | ||
73 | MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot"); | ||
66 | 74 | ||
67 | static bool ide_noacpi_psx; | 75 | static bool ide_noacpi_psx; |
68 | static int no_acpi_psx(const struct dmi_system_id *id) | 76 | static int no_acpi_psx(const struct dmi_system_id *id) |
@@ -309,7 +317,7 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
309 | if (ACPI_FAILURE(status)) { | 317 | if (ACPI_FAILURE(status)) { |
310 | printk(KERN_DEBUG | 318 | printk(KERN_DEBUG |
311 | "%s: Run _GTF error: status = 0x%x\n", | 319 | "%s: Run _GTF error: status = 0x%x\n", |
312 | __FUNCTION__, status); | 320 | __func__, status); |
313 | goto out; | 321 | goto out; |
314 | } | 322 | } |
315 | 323 | ||
@@ -335,7 +343,7 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
335 | out_obj->buffer.length % REGS_PER_GTF) { | 343 | out_obj->buffer.length % REGS_PER_GTF) { |
336 | printk(KERN_ERR | 344 | printk(KERN_ERR |
337 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", | 345 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", |
338 | __FUNCTION__, out_obj->buffer.length, | 346 | __func__, out_obj->buffer.length, |
339 | out_obj->buffer.pointer); | 347 | out_obj->buffer.pointer); |
340 | err = -ENOENT; | 348 | err = -ENOENT; |
341 | kfree(output.pointer); | 349 | kfree(output.pointer); |
@@ -376,7 +384,7 @@ static int taskfile_load_raw(ide_drive_t *drive, | |||
376 | memcpy(&args.tf_array[7], >f->tfa, 7); | 384 | memcpy(&args.tf_array[7], >f->tfa, 7); |
377 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 385 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
378 | 386 | ||
379 | if (ide_noacpitfs) { | 387 | if (!ide_acpigtf) { |
380 | DEBPRINT("_GTF execution disabled\n"); | 388 | DEBPRINT("_GTF execution disabled\n"); |
381 | return err; | 389 | return err; |
382 | } | 390 | } |
@@ -384,7 +392,7 @@ static int taskfile_load_raw(ide_drive_t *drive, | |||
384 | err = ide_no_data_taskfile(drive, &args); | 392 | err = ide_no_data_taskfile(drive, &args); |
385 | if (err) | 393 | if (err) |
386 | printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", | 394 | printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", |
387 | __FUNCTION__, err); | 395 | __func__, err); |
388 | 396 | ||
389 | return err; | 397 | return err; |
390 | } | 398 | } |
@@ -422,7 +430,7 @@ static int do_drive_set_taskfiles(ide_drive_t *drive, | |||
422 | 430 | ||
423 | if (gtf_length % REGS_PER_GTF) { | 431 | if (gtf_length % REGS_PER_GTF) { |
424 | printk(KERN_ERR "%s: unexpected GTF length (%d)\n", | 432 | printk(KERN_ERR "%s: unexpected GTF length (%d)\n", |
425 | __FUNCTION__, gtf_length); | 433 | __func__, gtf_length); |
426 | goto out; | 434 | goto out; |
427 | } | 435 | } |
428 | 436 | ||
@@ -547,7 +555,7 @@ void ide_acpi_get_timing(ide_hwif_t *hwif) | |||
547 | printk(KERN_ERR | 555 | printk(KERN_ERR |
548 | "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " | 556 | "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " |
549 | "addr (0x%p)\n", | 557 | "addr (0x%p)\n", |
550 | __FUNCTION__, out_obj->buffer.length, | 558 | __func__, out_obj->buffer.length, |
551 | sizeof(struct GTM_buffer), out_obj->buffer.pointer); | 559 | sizeof(struct GTM_buffer), out_obj->buffer.pointer); |
552 | return; | 560 | return; |
553 | } | 561 | } |
@@ -721,7 +729,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) | |||
721 | drive->name, err); | 729 | drive->name, err); |
722 | } | 730 | } |
723 | 731 | ||
724 | if (ide_noacpionboot) { | 732 | if (!ide_acpionboot) { |
725 | DEBPRINT("ACPI methods disabled on boot\n"); | 733 | DEBPRINT("ACPI methods disabled on boot\n"); |
726 | return; | 734 | return; |
727 | } | 735 | } |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index fe5aefbf8339..b34fd2bde96f 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -13,8 +13,8 @@ | |||
13 | * | 13 | * |
14 | * Suggestions are welcome. Patches that work are more welcome though. ;-) | 14 | * Suggestions are welcome. Patches that work are more welcome though. ;-) |
15 | * For those wishing to work on this driver, please be sure you download | 15 | * For those wishing to work on this driver, please be sure you download |
16 | * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI | 16 | * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI |
17 | * (SFF-8020i rev 2.6) standards. These documents can be obtained by | 17 | * (SFF-8020i rev 2.6) standards. These documents can be obtained by |
18 | * anonymous ftp from: | 18 | * anonymous ftp from: |
19 | * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps | 19 | * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps |
20 | * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf | 20 | * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf |
@@ -39,19 +39,20 @@ | |||
39 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
40 | #include <linux/bcd.h> | 40 | #include <linux/bcd.h> |
41 | 41 | ||
42 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ | 42 | /* For SCSI -> ATAPI command conversion */ |
43 | #include <scsi/scsi.h> | ||
43 | 44 | ||
44 | #include <asm/irq.h> | 45 | #include <linux/irq.h> |
45 | #include <asm/io.h> | 46 | #include <linux/io.h> |
46 | #include <asm/byteorder.h> | 47 | #include <asm/byteorder.h> |
47 | #include <asm/uaccess.h> | 48 | #include <linux/uaccess.h> |
48 | #include <asm/unaligned.h> | 49 | #include <asm/unaligned.h> |
49 | 50 | ||
50 | #include "ide-cd.h" | 51 | #include "ide-cd.h" |
51 | 52 | ||
52 | static DEFINE_MUTEX(idecd_ref_mutex); | 53 | static DEFINE_MUTEX(idecd_ref_mutex); |
53 | 54 | ||
54 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) | 55 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) |
55 | 56 | ||
56 | #define ide_cd_g(disk) \ | 57 | #define ide_cd_g(disk) \ |
57 | container_of((disk)->private_data, struct cdrom_info, driver) | 58 | container_of((disk)->private_data, struct cdrom_info, driver) |
@@ -77,19 +78,17 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
77 | mutex_unlock(&idecd_ref_mutex); | 78 | mutex_unlock(&idecd_ref_mutex); |
78 | } | 79 | } |
79 | 80 | ||
80 | /**************************************************************************** | 81 | /* |
81 | * Generic packet command support and error handling routines. | 82 | * Generic packet command support and error handling routines. |
82 | */ | 83 | */ |
83 | 84 | ||
84 | /* Mark that we've seen a media change, and invalidate our internal | 85 | /* Mark that we've seen a media change and invalidate our internal buffers. */ |
85 | 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 | struct cdrom_info *cd = drive->driver_data; |
89 | 89 | ||
90 | cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED; | 90 | cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED; |
91 | cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; | 91 | cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; |
92 | cd->nsectors_buffered = 0; | ||
93 | } | 92 | } |
94 | 93 | ||
95 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | 94 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, |
@@ -101,44 +100,43 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
101 | return 0; | 100 | return 0; |
102 | 101 | ||
103 | switch (sense->sense_key) { | 102 | switch (sense->sense_key) { |
104 | case NO_SENSE: case RECOVERED_ERROR: | 103 | case NO_SENSE: |
105 | break; | 104 | case RECOVERED_ERROR: |
106 | case NOT_READY: | 105 | break; |
107 | /* | 106 | case NOT_READY: |
108 | * don't care about tray state messages for | 107 | /* |
109 | * e.g. capacity commands or in-progress or | 108 | * don't care about tray state messages for e.g. capacity |
110 | * becoming ready | 109 | * commands or in-progress or becoming ready |
111 | */ | 110 | */ |
112 | if (sense->asc == 0x3a || sense->asc == 0x04) | 111 | if (sense->asc == 0x3a || sense->asc == 0x04) |
113 | break; | ||
114 | log = 1; | ||
115 | break; | ||
116 | case ILLEGAL_REQUEST: | ||
117 | /* | ||
118 | * don't log START_STOP unit with LoEj set, since | ||
119 | * we cannot reliably check if drive can auto-close | ||
120 | */ | ||
121 | if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) | ||
122 | break; | ||
123 | log = 1; | ||
124 | break; | ||
125 | case UNIT_ATTENTION: | ||
126 | /* | ||
127 | * Make good and sure we've seen this potential media | ||
128 | * change. Some drives (i.e. Creative) fail to present | ||
129 | * the correct sense key in the error register. | ||
130 | */ | ||
131 | cdrom_saw_media_change(drive); | ||
132 | break; | 112 | break; |
133 | default: | 113 | log = 1; |
134 | log = 1; | 114 | break; |
115 | case ILLEGAL_REQUEST: | ||
116 | /* | ||
117 | * don't log START_STOP unit with LoEj set, since we cannot | ||
118 | * reliably check if drive can auto-close | ||
119 | */ | ||
120 | if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) | ||
135 | break; | 121 | break; |
122 | log = 1; | ||
123 | break; | ||
124 | case UNIT_ATTENTION: | ||
125 | /* | ||
126 | * Make good and sure we've seen this potential media change. | ||
127 | * Some drives (i.e. Creative) fail to present the correct sense | ||
128 | * key in the error register. | ||
129 | */ | ||
130 | cdrom_saw_media_change(drive); | ||
131 | break; | ||
132 | default: | ||
133 | log = 1; | ||
134 | break; | ||
136 | } | 135 | } |
137 | return log; | 136 | return log; |
138 | } | 137 | } |
139 | 138 | ||
140 | static | 139 | static void cdrom_analyze_sense_data(ide_drive_t *drive, |
141 | void cdrom_analyze_sense_data(ide_drive_t *drive, | ||
142 | struct request *failed_command, | 140 | struct request *failed_command, |
143 | struct request_sense *sense) | 141 | struct request_sense *sense) |
144 | { | 142 | { |
@@ -151,16 +149,17 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
151 | return; | 149 | return; |
152 | 150 | ||
153 | /* | 151 | /* |
154 | * If a read toc is executed for a CD-R or CD-RW medium where | 152 | * If a read toc is executed for a CD-R or CD-RW medium where the first |
155 | * the first toc has not been recorded yet, it will fail with | 153 | * toc has not been recorded yet, it will fail with 05/24/00 (which is a |
156 | * 05/24/00 (which is a confusing error) | 154 | * confusing error) |
157 | */ | 155 | */ |
158 | if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) | 156 | if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) |
159 | if (sense->sense_key == 0x05 && sense->asc == 0x24) | 157 | if (sense->sense_key == 0x05 && sense->asc == 0x24) |
160 | return; | 158 | return; |
161 | 159 | ||
162 | if (sense->error_code == 0x70) { /* Current Error */ | 160 | /* current error */ |
163 | switch(sense->sense_key) { | 161 | if (sense->error_code == 0x70) { |
162 | switch (sense->sense_key) { | ||
164 | case MEDIUM_ERROR: | 163 | case MEDIUM_ERROR: |
165 | case VOLUME_OVERFLOW: | 164 | case VOLUME_OVERFLOW: |
166 | case ILLEGAL_REQUEST: | 165 | case ILLEGAL_REQUEST: |
@@ -178,25 +177,23 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
178 | if (bio_sectors < 4) | 177 | if (bio_sectors < 4) |
179 | bio_sectors = 4; | 178 | bio_sectors = 4; |
180 | if (drive->queue->hardsect_size == 2048) | 179 | if (drive->queue->hardsect_size == 2048) |
181 | sector <<= 2; /* Device sector size is 2K */ | 180 | /* device sector size is 2K */ |
182 | sector &= ~(bio_sectors -1); | 181 | sector <<= 2; |
182 | sector &= ~(bio_sectors - 1); | ||
183 | valid = (sector - failed_command->sector) << 9; | 183 | valid = (sector - failed_command->sector) << 9; |
184 | 184 | ||
185 | if (valid < 0) | 185 | if (valid < 0) |
186 | valid = 0; | 186 | valid = 0; |
187 | if (sector < get_capacity(info->disk) && | 187 | if (sector < get_capacity(info->disk) && |
188 | drive->probed_capacity - sector < 4 * 75) { | 188 | drive->probed_capacity - sector < 4 * 75) |
189 | set_capacity(info->disk, sector); | 189 | set_capacity(info->disk, sector); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | ||
193 | 192 | ||
194 | ide_cd_log_error(drive->name, failed_command, sense); | 193 | ide_cd_log_error(drive->name, failed_command, sense); |
195 | } | 194 | } |
196 | 195 | ||
197 | /* | 196 | /* Initialize a ide-cd packet command request */ |
198 | * Initialize a ide-cd packet command request | ||
199 | */ | ||
200 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) | 197 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) |
201 | { | 198 | { |
202 | struct cdrom_info *cd = drive->driver_data; | 199 | struct cdrom_info *cd = drive->driver_data; |
@@ -220,7 +217,8 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
220 | 217 | ||
221 | rq->data = sense; | 218 | rq->data = sense; |
222 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | 219 | rq->cmd[0] = GPCMD_REQUEST_SENSE; |
223 | rq->cmd[4] = rq->data_len = 18; | 220 | rq->cmd[4] = 18; |
221 | rq->data_len = 18; | ||
224 | 222 | ||
225 | rq->cmd_type = REQ_TYPE_SENSE; | 223 | rq->cmd_type = REQ_TYPE_SENSE; |
226 | 224 | ||
@@ -230,7 +228,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
230 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 228 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); |
231 | } | 229 | } |
232 | 230 | ||
233 | static void cdrom_end_request (ide_drive_t *drive, int uptodate) | 231 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) |
234 | { | 232 | { |
235 | struct request *rq = HWGROUP(drive)->rq; | 233 | struct request *rq = HWGROUP(drive)->rq; |
236 | int nsectors = rq->hard_cur_sectors; | 234 | int nsectors = rq->hard_cur_sectors; |
@@ -252,7 +250,7 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) | |||
252 | } | 250 | } |
253 | cdrom_analyze_sense_data(drive, failed, sense); | 251 | cdrom_analyze_sense_data(drive, failed, sense); |
254 | /* | 252 | /* |
255 | * now end failed request | 253 | * now end the failed request |
256 | */ | 254 | */ |
257 | if (blk_fs_request(failed)) { | 255 | if (blk_fs_request(failed)) { |
258 | if (ide_end_dequeued_request(drive, failed, 0, | 256 | if (ide_end_dequeued_request(drive, failed, 0, |
@@ -280,21 +278,24 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) | |||
280 | ide_end_request(drive, uptodate, nsectors); | 278 | ide_end_request(drive, uptodate, nsectors); |
281 | } | 279 | } |
282 | 280 | ||
283 | static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 stat) | 281 | static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) |
284 | { | 282 | { |
285 | if (stat & 0x80) | 283 | if (st & 0x80) |
286 | return; | 284 | return; |
287 | ide_dump_status(drive, msg, stat); | 285 | ide_dump_status(drive, msg, st); |
288 | } | 286 | } |
289 | 287 | ||
290 | /* Returns 0 if the request should be continued. | 288 | /* |
291 | Returns 1 if the request was ended. */ | 289 | * Returns: |
290 | * 0: if the request should be continued. | ||
291 | * 1: if the request was ended. | ||
292 | */ | ||
292 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | 293 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) |
293 | { | 294 | { |
294 | struct request *rq = HWGROUP(drive)->rq; | 295 | struct request *rq = HWGROUP(drive)->rq; |
295 | int stat, err, sense_key; | 296 | int stat, err, sense_key; |
296 | 297 | ||
297 | /* Check for errors. */ | 298 | /* check for errors */ |
298 | stat = ide_read_status(drive); | 299 | stat = ide_read_status(drive); |
299 | 300 | ||
300 | if (stat_ret) | 301 | if (stat_ret) |
@@ -303,20 +304,22 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
303 | if (OK_STAT(stat, good_stat, BAD_R_STAT)) | 304 | if (OK_STAT(stat, good_stat, BAD_R_STAT)) |
304 | return 0; | 305 | return 0; |
305 | 306 | ||
306 | /* Get the IDE error register. */ | 307 | /* get the IDE error register */ |
307 | err = ide_read_error(drive); | 308 | err = ide_read_error(drive); |
308 | sense_key = err >> 4; | 309 | sense_key = err >> 4; |
309 | 310 | ||
310 | if (rq == NULL) { | 311 | if (rq == NULL) { |
311 | printk("%s: missing rq in cdrom_decode_status\n", drive->name); | 312 | printk(KERN_ERR "%s: missing rq in %s\n", |
313 | drive->name, __func__); | ||
312 | return 1; | 314 | return 1; |
313 | } | 315 | } |
314 | 316 | ||
315 | if (blk_sense_request(rq)) { | 317 | if (blk_sense_request(rq)) { |
316 | /* We got an error trying to get sense info | 318 | /* |
317 | from the drive (probably while trying | 319 | * We got an error trying to get sense info from the drive |
318 | to recover from a former error). Just give up. */ | 320 | * (probably while trying to recover from a former error). |
319 | 321 | * Just give up. | |
322 | */ | ||
320 | rq->cmd_flags |= REQ_FAILED; | 323 | rq->cmd_flags |= REQ_FAILED; |
321 | cdrom_end_request(drive, 0); | 324 | cdrom_end_request(drive, 0); |
322 | ide_error(drive, "request sense failure", stat); | 325 | ide_error(drive, "request sense failure", stat); |
@@ -332,28 +335,27 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
332 | if (blk_pc_request(rq) && !rq->errors) | 335 | if (blk_pc_request(rq) && !rq->errors) |
333 | rq->errors = SAM_STAT_CHECK_CONDITION; | 336 | rq->errors = SAM_STAT_CHECK_CONDITION; |
334 | 337 | ||
335 | /* Check for tray open. */ | 338 | /* check for tray open */ |
336 | if (sense_key == NOT_READY) { | 339 | if (sense_key == NOT_READY) { |
337 | cdrom_saw_media_change (drive); | 340 | cdrom_saw_media_change(drive); |
338 | } else if (sense_key == UNIT_ATTENTION) { | 341 | } else if (sense_key == UNIT_ATTENTION) { |
339 | /* Check for media change. */ | 342 | /* check for media change */ |
340 | cdrom_saw_media_change (drive); | 343 | cdrom_saw_media_change(drive); |
341 | /*printk("%s: media changed\n",drive->name);*/ | ||
342 | return 0; | 344 | return 0; |
343 | } else if ((sense_key == ILLEGAL_REQUEST) && | 345 | } else if (sense_key == ILLEGAL_REQUEST && |
344 | (rq->cmd[0] == GPCMD_START_STOP_UNIT)) { | 346 | rq->cmd[0] == GPCMD_START_STOP_UNIT) { |
345 | /* | 347 | /* |
346 | * Don't print error message for this condition-- | 348 | * Don't print error message for this condition-- |
347 | * SFF8090i indicates that 5/24/00 is the correct | 349 | * SFF8090i indicates that 5/24/00 is the correct |
348 | * response to a request to close the tray if the | 350 | * response to a request to close the tray if the |
349 | * drive doesn't have that capability. | 351 | * drive doesn't have that capability. |
350 | * cdrom_log_sense() knows this! | 352 | * cdrom_log_sense() knows this! |
351 | */ | 353 | */ |
352 | } else if (!(rq->cmd_flags & REQ_QUIET)) { | 354 | } else if (!(rq->cmd_flags & REQ_QUIET)) { |
353 | /* Otherwise, print an error. */ | 355 | /* otherwise, print an error */ |
354 | ide_dump_status(drive, "packet command error", stat); | 356 | ide_dump_status(drive, "packet command error", stat); |
355 | } | 357 | } |
356 | 358 | ||
357 | rq->cmd_flags |= REQ_FAILED; | 359 | rq->cmd_flags |= REQ_FAILED; |
358 | 360 | ||
359 | /* | 361 | /* |
@@ -366,27 +368,30 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
366 | } else if (blk_fs_request(rq)) { | 368 | } else if (blk_fs_request(rq)) { |
367 | int do_end_request = 0; | 369 | int do_end_request = 0; |
368 | 370 | ||
369 | /* Handle errors from READ and WRITE requests. */ | 371 | /* handle errors from READ and WRITE requests */ |
370 | 372 | ||
371 | if (blk_noretry_request(rq)) | 373 | if (blk_noretry_request(rq)) |
372 | do_end_request = 1; | 374 | do_end_request = 1; |
373 | 375 | ||
374 | if (sense_key == NOT_READY) { | 376 | if (sense_key == NOT_READY) { |
375 | /* Tray open. */ | 377 | /* tray open */ |
376 | if (rq_data_dir(rq) == READ) { | 378 | if (rq_data_dir(rq) == READ) { |
377 | cdrom_saw_media_change (drive); | 379 | cdrom_saw_media_change(drive); |
378 | 380 | ||
379 | /* Fail the request. */ | 381 | /* fail the request */ |
380 | printk ("%s: tray open\n", drive->name); | 382 | printk(KERN_ERR "%s: tray open\n", drive->name); |
381 | do_end_request = 1; | 383 | do_end_request = 1; |
382 | } else { | 384 | } else { |
383 | struct cdrom_info *info = drive->driver_data; | 385 | struct cdrom_info *info = drive->driver_data; |
384 | 386 | ||
385 | /* allow the drive 5 seconds to recover, some | 387 | /* |
388 | * Allow the drive 5 seconds to recover, some | ||
386 | * devices will return this error while flushing | 389 | * devices will return this error while flushing |
387 | * data from cache */ | 390 | * data from cache. |
391 | */ | ||
388 | if (!rq->errors) | 392 | if (!rq->errors) |
389 | info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; | 393 | info->write_timeout = jiffies + |
394 | ATAPI_WAIT_WRITE_BUSY; | ||
390 | rq->errors = 1; | 395 | rq->errors = 1; |
391 | if (time_after(jiffies, info->write_timeout)) | 396 | if (time_after(jiffies, info->write_timeout)) |
392 | do_end_request = 1; | 397 | do_end_request = 1; |
@@ -394,59 +399,68 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
394 | unsigned long flags; | 399 | unsigned long flags; |
395 | 400 | ||
396 | /* | 401 | /* |
397 | * take a breather relying on the | 402 | * take a breather relying on the unplug |
398 | * unplug timer to kick us again | 403 | * timer to kick us again |
399 | */ | 404 | */ |
400 | spin_lock_irqsave(&ide_lock, flags); | 405 | spin_lock_irqsave(&ide_lock, flags); |
401 | blk_plug_device(drive->queue); | 406 | blk_plug_device(drive->queue); |
402 | spin_unlock_irqrestore(&ide_lock,flags); | 407 | spin_unlock_irqrestore(&ide_lock, |
408 | flags); | ||
403 | return 1; | 409 | return 1; |
404 | } | 410 | } |
405 | } | 411 | } |
406 | } else if (sense_key == UNIT_ATTENTION) { | 412 | } else if (sense_key == UNIT_ATTENTION) { |
407 | /* Media change. */ | 413 | /* media change */ |
408 | cdrom_saw_media_change (drive); | 414 | cdrom_saw_media_change(drive); |
409 | 415 | ||
410 | /* Arrange to retry the request. | 416 | /* |
411 | But be sure to give up if we've retried | 417 | * Arrange to retry the request but be sure to give up |
412 | too many times. */ | 418 | * if we've retried too many times. |
419 | */ | ||
413 | if (++rq->errors > ERROR_MAX) | 420 | if (++rq->errors > ERROR_MAX) |
414 | do_end_request = 1; | 421 | do_end_request = 1; |
415 | } else if (sense_key == ILLEGAL_REQUEST || | 422 | } else if (sense_key == ILLEGAL_REQUEST || |
416 | sense_key == DATA_PROTECT) { | 423 | sense_key == DATA_PROTECT) { |
417 | /* No point in retrying after an illegal | 424 | /* |
418 | request or data protect error.*/ | 425 | * No point in retrying after an illegal request or data |
419 | ide_dump_status_no_sense (drive, "command error", stat); | 426 | * protect error. |
427 | */ | ||
428 | ide_dump_status_no_sense(drive, "command error", stat); | ||
420 | do_end_request = 1; | 429 | do_end_request = 1; |
421 | } else if (sense_key == MEDIUM_ERROR) { | 430 | } else if (sense_key == MEDIUM_ERROR) { |
422 | /* No point in re-trying a zillion times on a bad | 431 | /* |
423 | * sector... If we got here the error is not correctable */ | 432 | * No point in re-trying a zillion times on a bad |
424 | ide_dump_status_no_sense (drive, "media error (bad sector)", stat); | 433 | * sector. If we got here the error is not correctable. |
434 | */ | ||
435 | ide_dump_status_no_sense(drive, | ||
436 | "media error (bad sector)", | ||
437 | stat); | ||
425 | do_end_request = 1; | 438 | do_end_request = 1; |
426 | } else if (sense_key == BLANK_CHECK) { | 439 | } else if (sense_key == BLANK_CHECK) { |
427 | /* Disk appears blank ?? */ | 440 | /* disk appears blank ?? */ |
428 | ide_dump_status_no_sense (drive, "media error (blank)", stat); | 441 | ide_dump_status_no_sense(drive, "media error (blank)", |
442 | stat); | ||
429 | do_end_request = 1; | 443 | do_end_request = 1; |
430 | } else if ((err & ~ABRT_ERR) != 0) { | 444 | } else if ((err & ~ABRT_ERR) != 0) { |
431 | /* Go to the default handler | 445 | /* go to the default handler for other errors */ |
432 | for other errors. */ | ||
433 | ide_error(drive, "cdrom_decode_status", stat); | 446 | ide_error(drive, "cdrom_decode_status", stat); |
434 | return 1; | 447 | return 1; |
435 | } else if ((++rq->errors > ERROR_MAX)) { | 448 | } else if ((++rq->errors > ERROR_MAX)) { |
436 | /* We've racked up too many retries. Abort. */ | 449 | /* we've racked up too many retries, abort */ |
437 | do_end_request = 1; | 450 | do_end_request = 1; |
438 | } | 451 | } |
439 | 452 | ||
440 | /* End a request through request sense analysis when we have | 453 | /* |
441 | sense data. We need this in order to perform end of media | 454 | * End a request through request sense analysis when we have |
442 | processing */ | 455 | * sense data. We need this in order to perform end of media |
443 | 456 | * processing. | |
457 | */ | ||
444 | if (do_end_request) | 458 | if (do_end_request) |
445 | goto end_request; | 459 | goto end_request; |
446 | 460 | ||
447 | /* | 461 | /* |
448 | * If we got a CHECK_CONDITION status, | 462 | * If we got a CHECK_CONDITION status, queue |
449 | * queue a request sense command. | 463 | * a request sense command. |
450 | */ | 464 | */ |
451 | if (stat & ERR_STAT) | 465 | if (stat & ERR_STAT) |
452 | cdrom_queue_request_sense(drive, NULL, NULL); | 466 | cdrom_queue_request_sense(drive, NULL, NULL); |
@@ -455,7 +469,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
455 | cdrom_end_request(drive, 0); | 469 | cdrom_end_request(drive, 0); |
456 | } | 470 | } |
457 | 471 | ||
458 | /* Retry, or handle the next request. */ | 472 | /* retry, or handle the next request */ |
459 | return 1; | 473 | return 1; |
460 | 474 | ||
461 | end_request: | 475 | end_request: |
@@ -480,35 +494,37 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
480 | unsigned long wait = 0; | 494 | unsigned long wait = 0; |
481 | 495 | ||
482 | /* | 496 | /* |
483 | * Some commands are *slow* and normally take a long time to | 497 | * Some commands are *slow* and normally take a long time to complete. |
484 | * complete. Usually we can use the ATAPI "disconnect" to bypass | 498 | * Usually we can use the ATAPI "disconnect" to bypass this, but not all |
485 | * this, but not all commands/drives support that. Let | 499 | * commands/drives support that. Let ide_timer_expiry keep polling us |
486 | * ide_timer_expiry keep polling us for these. | 500 | * for these. |
487 | */ | 501 | */ |
488 | switch (rq->cmd[0]) { | 502 | switch (rq->cmd[0]) { |
489 | case GPCMD_BLANK: | 503 | case GPCMD_BLANK: |
490 | case GPCMD_FORMAT_UNIT: | 504 | case GPCMD_FORMAT_UNIT: |
491 | case GPCMD_RESERVE_RZONE_TRACK: | 505 | case GPCMD_RESERVE_RZONE_TRACK: |
492 | case GPCMD_CLOSE_TRACK: | 506 | case GPCMD_CLOSE_TRACK: |
493 | case GPCMD_FLUSH_CACHE: | 507 | case GPCMD_FLUSH_CACHE: |
494 | wait = ATAPI_WAIT_PC; | 508 | wait = ATAPI_WAIT_PC; |
495 | break; | 509 | break; |
496 | default: | 510 | default: |
497 | if (!(rq->cmd_flags & REQ_QUIET)) | 511 | if (!(rq->cmd_flags & REQ_QUIET)) |
498 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); | 512 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", |
499 | wait = 0; | 513 | rq->cmd[0]); |
500 | break; | 514 | wait = 0; |
515 | break; | ||
501 | } | 516 | } |
502 | return wait; | 517 | return wait; |
503 | } | 518 | } |
504 | 519 | ||
505 | /* Set up the device registers for transferring a packet command on DEV, | 520 | /* |
506 | expecting to later transfer XFERLEN bytes. HANDLER is the routine | 521 | * Set up the device registers for transferring a packet command on DEV, |
507 | which actually transfers the command to the drive. If this is a | 522 | * expecting to later transfer XFERLEN bytes. HANDLER is the routine |
508 | drq_interrupt device, this routine will arrange for HANDLER to be | 523 | * which actually transfers the command to the drive. If this is a |
509 | called when the interrupt from the drive arrives. Otherwise, HANDLER | 524 | * drq_interrupt device, this routine will arrange for HANDLER to be |
510 | will be called immediately after the drive is prepared for the transfer. */ | 525 | * called when the interrupt from the drive arrives. Otherwise, HANDLER |
511 | 526 | * will be called immediately after the drive is prepared for the transfer. | |
527 | */ | ||
512 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | 528 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, |
513 | int xferlen, | 529 | int xferlen, |
514 | ide_handler_t *handler) | 530 | ide_handler_t *handler) |
@@ -517,15 +533,15 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
517 | struct cdrom_info *info = drive->driver_data; | 533 | struct cdrom_info *info = drive->driver_data; |
518 | ide_hwif_t *hwif = drive->hwif; | 534 | ide_hwif_t *hwif = drive->hwif; |
519 | 535 | ||
520 | /* Wait for the controller to be idle. */ | 536 | /* wait for the controller to be idle */ |
521 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) | 537 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) |
522 | return startstop; | 538 | return startstop; |
523 | 539 | ||
524 | /* FIXME: for Virtual DMA we must check harder */ | 540 | /* FIXME: for Virtual DMA we must check harder */ |
525 | if (info->dma) | 541 | if (info->dma) |
526 | info->dma = !hwif->dma_setup(drive); | 542 | info->dma = !hwif->dma_ops->dma_setup(drive); |
527 | 543 | ||
528 | /* Set up the controller registers. */ | 544 | /* set up the controller registers */ |
529 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | | 545 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | |
530 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); | 546 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); |
531 | 547 | ||
@@ -535,7 +551,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
535 | drive->waiting_for_dma = 0; | 551 | drive->waiting_for_dma = 0; |
536 | 552 | ||
537 | /* packet command */ | 553 | /* packet command */ |
538 | ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); | 554 | ide_execute_command(drive, WIN_PACKETCMD, handler, |
555 | ATAPI_WAIT_PC, cdrom_timer_expiry); | ||
539 | return ide_started; | 556 | return ide_started; |
540 | } else { | 557 | } else { |
541 | unsigned long flags; | 558 | unsigned long flags; |
@@ -543,7 +560,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
543 | /* packet command */ | 560 | /* packet command */ |
544 | spin_lock_irqsave(&ide_lock, flags); | 561 | spin_lock_irqsave(&ide_lock, flags); |
545 | hwif->OUTBSYNC(drive, WIN_PACKETCMD, | 562 | hwif->OUTBSYNC(drive, WIN_PACKETCMD, |
546 | hwif->io_ports[IDE_COMMAND_OFFSET]); | 563 | hwif->io_ports.command_addr); |
547 | ndelay(400); | 564 | ndelay(400); |
548 | spin_unlock_irqrestore(&ide_lock, flags); | 565 | spin_unlock_irqrestore(&ide_lock, flags); |
549 | 566 | ||
@@ -551,13 +568,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
551 | } | 568 | } |
552 | } | 569 | } |
553 | 570 | ||
554 | /* Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. | 571 | /* |
555 | The device registers must have already been prepared | 572 | * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device |
556 | by cdrom_start_packet_command. | 573 | * registers must have already been prepared by cdrom_start_packet_command. |
557 | HANDLER is the interrupt handler to call when the command completes | 574 | * HANDLER is the interrupt handler to call when the command completes or |
558 | or there's data ready. */ | 575 | * there's data ready. |
576 | */ | ||
559 | #define ATAPI_MIN_CDB_BYTES 12 | 577 | #define ATAPI_MIN_CDB_BYTES 12 |
560 | static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | 578 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, |
561 | struct request *rq, | 579 | struct request *rq, |
562 | ide_handler_t *handler) | 580 | ide_handler_t *handler) |
563 | { | 581 | { |
@@ -567,24 +585,26 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
567 | ide_startstop_t startstop; | 585 | ide_startstop_t startstop; |
568 | 586 | ||
569 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 587 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
570 | /* Here we should have been called after receiving an interrupt | 588 | /* |
571 | from the device. DRQ should how be set. */ | 589 | * Here we should have been called after receiving an interrupt |
590 | * from the device. DRQ should how be set. | ||
591 | */ | ||
572 | 592 | ||
573 | /* Check for errors. */ | 593 | /* check for errors */ |
574 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) | 594 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) |
575 | return ide_stopped; | 595 | return ide_stopped; |
576 | 596 | ||
577 | /* Ok, next interrupt will be DMA interrupt. */ | 597 | /* ok, next interrupt will be DMA interrupt */ |
578 | if (info->dma) | 598 | if (info->dma) |
579 | drive->waiting_for_dma = 1; | 599 | drive->waiting_for_dma = 1; |
580 | } else { | 600 | } else { |
581 | /* Otherwise, we must wait for DRQ to get set. */ | 601 | /* otherwise, we must wait for DRQ to get set */ |
582 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, | 602 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, |
583 | BUSY_STAT, WAIT_READY)) | 603 | BUSY_STAT, WAIT_READY)) |
584 | return startstop; | 604 | return startstop; |
585 | } | 605 | } |
586 | 606 | ||
587 | /* Arm the interrupt handler. */ | 607 | /* arm the interrupt handler */ |
588 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); | 608 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); |
589 | 609 | ||
590 | /* ATAPI commands get padded out to 12 bytes minimum */ | 610 | /* ATAPI commands get padded out to 12 bytes minimum */ |
@@ -592,20 +612,19 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
592 | if (cmd_len < ATAPI_MIN_CDB_BYTES) | 612 | if (cmd_len < ATAPI_MIN_CDB_BYTES) |
593 | cmd_len = ATAPI_MIN_CDB_BYTES; | 613 | cmd_len = ATAPI_MIN_CDB_BYTES; |
594 | 614 | ||
595 | /* Send the command to the device. */ | 615 | /* send the command to the device */ |
596 | HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); | 616 | HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); |
597 | 617 | ||
598 | /* Start the DMA if need be */ | 618 | /* start the DMA if need be */ |
599 | if (info->dma) | 619 | if (info->dma) |
600 | hwif->dma_start(drive); | 620 | hwif->dma_ops->dma_start(drive); |
601 | 621 | ||
602 | return ide_started; | 622 | return ide_started; |
603 | } | 623 | } |
604 | 624 | ||
605 | /**************************************************************************** | 625 | /* |
606 | * Block read functions. | 626 | * Block read functions. |
607 | */ | 627 | */ |
608 | |||
609 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | 628 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) |
610 | { | 629 | { |
611 | while (len > 0) { | 630 | while (len > 0) { |
@@ -626,47 +645,6 @@ static void ide_cd_drain_data(ide_drive_t *drive, int nsects) | |||
626 | } | 645 | } |
627 | 646 | ||
628 | /* | 647 | /* |
629 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector | ||
630 | * buffer. Once the first sector is added, any subsequent sectors are | ||
631 | * assumed to be continuous (until the buffer is cleared). For the first | ||
632 | * sector added, SECTOR is its sector number. (SECTOR is then ignored until | ||
633 | * the buffer is cleared.) | ||
634 | */ | ||
635 | static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector, | ||
636 | int sectors_to_transfer) | ||
637 | { | ||
638 | struct cdrom_info *info = drive->driver_data; | ||
639 | |||
640 | /* Number of sectors to read into the buffer. */ | ||
641 | int sectors_to_buffer = min_t(int, sectors_to_transfer, | ||
642 | (SECTOR_BUFFER_SIZE >> SECTOR_BITS) - | ||
643 | info->nsectors_buffered); | ||
644 | |||
645 | char *dest; | ||
646 | |||
647 | /* If we couldn't get a buffer, don't try to buffer anything... */ | ||
648 | if (info->buffer == NULL) | ||
649 | sectors_to_buffer = 0; | ||
650 | |||
651 | /* If this is the first sector in the buffer, remember its number. */ | ||
652 | if (info->nsectors_buffered == 0) | ||
653 | info->sector_buffered = sector; | ||
654 | |||
655 | /* Read the data into the buffer. */ | ||
656 | dest = info->buffer + info->nsectors_buffered * SECTOR_SIZE; | ||
657 | while (sectors_to_buffer > 0) { | ||
658 | HWIF(drive)->atapi_input_bytes(drive, dest, SECTOR_SIZE); | ||
659 | --sectors_to_buffer; | ||
660 | --sectors_to_transfer; | ||
661 | ++info->nsectors_buffered; | ||
662 | dest += SECTOR_SIZE; | ||
663 | } | ||
664 | |||
665 | /* Throw away any remaining data. */ | ||
666 | ide_cd_drain_data(drive, sectors_to_transfer); | ||
667 | } | ||
668 | |||
669 | /* | ||
670 | * Check the contents of the interrupt reason register from the cdrom | 648 | * Check the contents of the interrupt reason register from the cdrom |
671 | * and attempt to recover if there are problems. Returns 0 if everything's | 649 | * and attempt to recover if there are problems. Returns 0 if everything's |
672 | * ok; nonzero if the request has been terminated. | 650 | * ok; nonzero if the request has been terminated. |
@@ -684,22 +662,23 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | |||
684 | ide_hwif_t *hwif = drive->hwif; | 662 | ide_hwif_t *hwif = drive->hwif; |
685 | xfer_func_t *xf; | 663 | xfer_func_t *xf; |
686 | 664 | ||
687 | /* Whoops... */ | 665 | /* whoops... */ |
688 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 666 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
689 | drive->name, __FUNCTION__); | 667 | drive->name, __func__); |
690 | 668 | ||
691 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; | 669 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; |
692 | ide_cd_pad_transfer(drive, xf, len); | 670 | ide_cd_pad_transfer(drive, xf, len); |
693 | } else if (rw == 0 && ireason == 1) { | 671 | } else if (rw == 0 && ireason == 1) { |
694 | /* Some drives (ASUS) seem to tell us that status | 672 | /* |
695 | * info is available. just get it and ignore. | 673 | * Some drives (ASUS) seem to tell us that status info is |
674 | * available. Just get it and ignore. | ||
696 | */ | 675 | */ |
697 | (void)ide_read_status(drive); | 676 | (void)ide_read_status(drive); |
698 | return 0; | 677 | return 0; |
699 | } else { | 678 | } else { |
700 | /* Drive wants a command packet, or invalid ireason... */ | 679 | /* drive wants a command packet, or invalid ireason... */ |
701 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", | 680 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", |
702 | drive->name, __FUNCTION__, ireason); | 681 | drive->name, __func__, ireason); |
703 | } | 682 | } |
704 | 683 | ||
705 | if (rq->cmd_type == REQ_TYPE_ATA_PC) | 684 | if (rq->cmd_type == REQ_TYPE_ATA_PC) |
@@ -721,7 +700,7 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | |||
721 | return 0; | 700 | return 0; |
722 | 701 | ||
723 | printk(KERN_ERR "%s: %s: Bad transfer size %d\n", | 702 | printk(KERN_ERR "%s: %s: Bad transfer size %d\n", |
724 | drive->name, __FUNCTION__, len); | 703 | drive->name, __func__, len); |
725 | 704 | ||
726 | if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES) | 705 | if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES) |
727 | printk(KERN_ERR " This drive is not supported by " | 706 | printk(KERN_ERR " This drive is not supported by " |
@@ -734,72 +713,13 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | |||
734 | return 1; | 713 | return 1; |
735 | } | 714 | } |
736 | 715 | ||
737 | /* | ||
738 | * Try to satisfy some of the current read request from our cached data. | ||
739 | * Returns nonzero if the request has been completed, zero otherwise. | ||
740 | */ | ||
741 | static int cdrom_read_from_buffer (ide_drive_t *drive) | ||
742 | { | ||
743 | struct cdrom_info *info = drive->driver_data; | ||
744 | struct request *rq = HWGROUP(drive)->rq; | ||
745 | unsigned short sectors_per_frame; | ||
746 | |||
747 | sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; | ||
748 | |||
749 | /* Can't do anything if there's no buffer. */ | ||
750 | if (info->buffer == NULL) return 0; | ||
751 | |||
752 | /* Loop while this request needs data and the next block is present | ||
753 | in our cache. */ | ||
754 | while (rq->nr_sectors > 0 && | ||
755 | rq->sector >= info->sector_buffered && | ||
756 | rq->sector < info->sector_buffered + info->nsectors_buffered) { | ||
757 | if (rq->current_nr_sectors == 0) | ||
758 | cdrom_end_request(drive, 1); | ||
759 | |||
760 | memcpy (rq->buffer, | ||
761 | info->buffer + | ||
762 | (rq->sector - info->sector_buffered) * SECTOR_SIZE, | ||
763 | SECTOR_SIZE); | ||
764 | rq->buffer += SECTOR_SIZE; | ||
765 | --rq->current_nr_sectors; | ||
766 | --rq->nr_sectors; | ||
767 | ++rq->sector; | ||
768 | } | ||
769 | |||
770 | /* If we've satisfied the current request, | ||
771 | terminate it successfully. */ | ||
772 | if (rq->nr_sectors == 0) { | ||
773 | cdrom_end_request(drive, 1); | ||
774 | return -1; | ||
775 | } | ||
776 | |||
777 | /* Move on to the next buffer if needed. */ | ||
778 | if (rq->current_nr_sectors == 0) | ||
779 | cdrom_end_request(drive, 1); | ||
780 | |||
781 | /* If this condition does not hold, then the kluge i use to | ||
782 | represent the number of sectors to skip at the start of a transfer | ||
783 | will fail. I think that this will never happen, but let's be | ||
784 | paranoid and check. */ | ||
785 | if (rq->current_nr_sectors < bio_cur_sectors(rq->bio) && | ||
786 | (rq->sector & (sectors_per_frame - 1))) { | ||
787 | printk(KERN_ERR "%s: cdrom_read_from_buffer: buffer botch (%ld)\n", | ||
788 | drive->name, (long)rq->sector); | ||
789 | cdrom_end_request(drive, 0); | ||
790 | return -1; | ||
791 | } | ||
792 | |||
793 | return 0; | ||
794 | } | ||
795 | |||
796 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | 716 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); |
797 | 717 | ||
798 | /* | 718 | /* |
799 | * Routine to send a read/write packet command to the drive. | 719 | * Routine to send a read/write packet command to the drive. This is usually |
800 | * This is usually called directly from cdrom_start_{read,write}(). | 720 | * called directly from cdrom_start_{read,write}(). However, for drq_interrupt |
801 | * However, for drq_interrupt devices, it is called from an interrupt | 721 | * devices, it is called from an interrupt when the drive is ready to accept |
802 | * when the drive is ready to accept the command. | 722 | * the command. |
803 | */ | 723 | */ |
804 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | 724 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) |
805 | { | 725 | { |
@@ -821,11 +741,11 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
821 | * is larger than the buffer size. | 741 | * is larger than the buffer size. |
822 | */ | 742 | */ |
823 | if (nskip > 0) { | 743 | if (nskip > 0) { |
824 | /* Sanity check... */ | 744 | /* sanity check... */ |
825 | if (rq->current_nr_sectors != | 745 | if (rq->current_nr_sectors != |
826 | bio_cur_sectors(rq->bio)) { | 746 | bio_cur_sectors(rq->bio)) { |
827 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", | 747 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", |
828 | drive->name, __FUNCTION__, | 748 | drive->name, __func__, |
829 | rq->current_nr_sectors); | 749 | rq->current_nr_sectors); |
830 | cdrom_end_request(drive, 0); | 750 | cdrom_end_request(drive, 0); |
831 | return ide_stopped; | 751 | return ide_stopped; |
@@ -838,10 +758,10 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
838 | /* the immediate bit */ | 758 | /* the immediate bit */ |
839 | rq->cmd[1] = 1 << 3; | 759 | rq->cmd[1] = 1 << 3; |
840 | #endif | 760 | #endif |
841 | /* Set up the command */ | 761 | /* set up the command */ |
842 | rq->timeout = ATAPI_WAIT_PC; | 762 | rq->timeout = ATAPI_WAIT_PC; |
843 | 763 | ||
844 | /* Send the command to the drive and return. */ | 764 | /* send the command to the drive and return */ |
845 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | 765 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); |
846 | } | 766 | } |
847 | 767 | ||
@@ -849,7 +769,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
849 | #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ | 769 | #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ |
850 | #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ | 770 | #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ |
851 | 771 | ||
852 | static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive) | 772 | static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive) |
853 | { | 773 | { |
854 | struct cdrom_info *info = drive->driver_data; | 774 | struct cdrom_info *info = drive->driver_data; |
855 | int stat; | 775 | int stat; |
@@ -861,19 +781,13 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive) | |||
861 | info->cd_flags |= IDE_CD_FLAG_SEEKING; | 781 | info->cd_flags |= IDE_CD_FLAG_SEEKING; |
862 | 782 | ||
863 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { | 783 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { |
864 | if (--retry == 0) { | 784 | if (--retry == 0) |
865 | /* | ||
866 | * this condition is far too common, to bother | ||
867 | * users about it | ||
868 | */ | ||
869 | /* printk("%s: disabled DSC seek overlap\n", drive->name);*/ | ||
870 | drive->dsc_overlap = 0; | 785 | drive->dsc_overlap = 0; |
871 | } | ||
872 | } | 786 | } |
873 | return ide_stopped; | 787 | return ide_stopped; |
874 | } | 788 | } |
875 | 789 | ||
876 | static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive) | 790 | static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive) |
877 | { | 791 | { |
878 | struct request *rq = HWGROUP(drive)->rq; | 792 | struct request *rq = HWGROUP(drive)->rq; |
879 | sector_t frame = rq->sector; | 793 | sector_t frame = rq->sector; |
@@ -888,36 +802,40 @@ static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive) | |||
888 | return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr); | 802 | return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr); |
889 | } | 803 | } |
890 | 804 | ||
891 | static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block) | 805 | static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) |
892 | { | 806 | { |
893 | struct cdrom_info *info = drive->driver_data; | 807 | struct cdrom_info *info = drive->driver_data; |
894 | 808 | ||
895 | info->dma = 0; | 809 | info->dma = 0; |
896 | info->start_seek = jiffies; | 810 | info->start_seek = jiffies; |
897 | return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); | 811 | return cdrom_start_packet_command(drive, 0, |
812 | cdrom_start_seek_continuation); | ||
898 | } | 813 | } |
899 | 814 | ||
900 | /* Fix up a possibly partially-processed request so that we can | 815 | /* |
901 | start it over entirely, or even put it back on the request queue. */ | 816 | * Fix up a possibly partially-processed request so that we can start it over |
902 | static void restore_request (struct request *rq) | 817 | * entirely, or even put it back on the request queue. |
818 | */ | ||
819 | static void restore_request(struct request *rq) | ||
903 | { | 820 | { |
904 | if (rq->buffer != bio_data(rq->bio)) { | 821 | if (rq->buffer != bio_data(rq->bio)) { |
905 | sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; | 822 | sector_t n = |
823 | (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; | ||
906 | 824 | ||
907 | rq->buffer = bio_data(rq->bio); | 825 | rq->buffer = bio_data(rq->bio); |
908 | rq->nr_sectors += n; | 826 | rq->nr_sectors += n; |
909 | rq->sector -= n; | 827 | rq->sector -= n; |
910 | } | 828 | } |
911 | rq->hard_cur_sectors = rq->current_nr_sectors = bio_cur_sectors(rq->bio); | 829 | rq->current_nr_sectors = bio_cur_sectors(rq->bio); |
830 | rq->hard_cur_sectors = rq->current_nr_sectors; | ||
912 | rq->hard_nr_sectors = rq->nr_sectors; | 831 | rq->hard_nr_sectors = rq->nr_sectors; |
913 | rq->hard_sector = rq->sector; | 832 | rq->hard_sector = rq->sector; |
914 | rq->q->prep_rq_fn(rq->q, rq); | 833 | rq->q->prep_rq_fn(rq->q, rq); |
915 | } | 834 | } |
916 | 835 | ||
917 | /**************************************************************************** | 836 | /* |
918 | * Execute all other packet commands. | 837 | * All other packet commands. |
919 | */ | 838 | */ |
920 | |||
921 | static void ide_cd_request_sense_fixup(struct request *rq) | 839 | static void ide_cd_request_sense_fixup(struct request *rq) |
922 | { | 840 | { |
923 | /* | 841 | /* |
@@ -941,7 +859,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
941 | if (rq->sense == NULL) | 859 | if (rq->sense == NULL) |
942 | rq->sense = &sense; | 860 | rq->sense = &sense; |
943 | 861 | ||
944 | /* Start of retry loop. */ | 862 | /* start of retry loop */ |
945 | do { | 863 | do { |
946 | int error; | 864 | int error; |
947 | unsigned long time = jiffies; | 865 | unsigned long time = jiffies; |
@@ -950,41 +868,45 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
950 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 868 | error = ide_do_drive_cmd(drive, rq, ide_wait); |
951 | time = jiffies - time; | 869 | time = jiffies - time; |
952 | 870 | ||
953 | /* FIXME: we should probably abort/retry or something | 871 | /* |
954 | * in case of failure */ | 872 | * FIXME: we should probably abort/retry or something in case of |
873 | * failure. | ||
874 | */ | ||
955 | if (rq->cmd_flags & REQ_FAILED) { | 875 | if (rq->cmd_flags & REQ_FAILED) { |
956 | /* The request failed. Retry if it was due to a unit | 876 | /* |
957 | attention status | 877 | * The request failed. Retry if it was due to a unit |
958 | (usually means media was changed). */ | 878 | * attention status (usually means media was changed). |
879 | */ | ||
959 | struct request_sense *reqbuf = rq->sense; | 880 | struct request_sense *reqbuf = rq->sense; |
960 | 881 | ||
961 | if (reqbuf->sense_key == UNIT_ATTENTION) | 882 | if (reqbuf->sense_key == UNIT_ATTENTION) |
962 | cdrom_saw_media_change(drive); | 883 | cdrom_saw_media_change(drive); |
963 | else if (reqbuf->sense_key == NOT_READY && | 884 | else if (reqbuf->sense_key == NOT_READY && |
964 | reqbuf->asc == 4 && reqbuf->ascq != 4) { | 885 | reqbuf->asc == 4 && reqbuf->ascq != 4) { |
965 | /* The drive is in the process of loading | 886 | /* |
966 | a disk. Retry, but wait a little to give | 887 | * The drive is in the process of loading |
967 | the drive time to complete the load. */ | 888 | * a disk. Retry, but wait a little to give |
889 | * the drive time to complete the load. | ||
890 | */ | ||
968 | ssleep(2); | 891 | ssleep(2); |
969 | } else { | 892 | } else { |
970 | /* Otherwise, don't retry. */ | 893 | /* otherwise, don't retry */ |
971 | retries = 0; | 894 | retries = 0; |
972 | } | 895 | } |
973 | --retries; | 896 | --retries; |
974 | } | 897 | } |
975 | 898 | ||
976 | /* End of retry loop. */ | 899 | /* end of retry loop */ |
977 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); | 900 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); |
978 | 901 | ||
979 | /* Return an error if the command failed. */ | 902 | /* return an error if the command failed */ |
980 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; | 903 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; |
981 | } | 904 | } |
982 | 905 | ||
983 | /* | 906 | /* |
984 | * Called from blk_end_request_callback() after the data of the request | 907 | * Called from blk_end_request_callback() after the data of the request is |
985 | * is completed and before the request is completed. | 908 | * completed and before the request itself is completed. By returning value '1', |
986 | * By returning value '1', blk_end_request_callback() returns immediately | 909 | * blk_end_request_callback() returns immediately without completing it. |
987 | * without completing the request. | ||
988 | */ | 910 | */ |
989 | static int cdrom_newpc_intr_dummy_cb(struct request *rq) | 911 | static int cdrom_newpc_intr_dummy_cb(struct request *rq) |
990 | { | 912 | { |
@@ -1003,11 +925,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1003 | unsigned int timeout; | 925 | unsigned int timeout; |
1004 | u8 lowcyl, highcyl; | 926 | u8 lowcyl, highcyl; |
1005 | 927 | ||
1006 | /* Check for errors. */ | 928 | /* check for errors */ |
1007 | dma = info->dma; | 929 | dma = info->dma; |
1008 | if (dma) { | 930 | if (dma) { |
1009 | info->dma = 0; | 931 | info->dma = 0; |
1010 | dma_error = HWIF(drive)->ide_dma_end(drive); | 932 | dma_error = hwif->dma_ops->dma_end(drive); |
1011 | if (dma_error) { | 933 | if (dma_error) { |
1012 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | 934 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, |
1013 | write ? "write" : "read"); | 935 | write ? "write" : "read"); |
@@ -1018,9 +940,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1018 | if (cdrom_decode_status(drive, 0, &stat)) | 940 | if (cdrom_decode_status(drive, 0, &stat)) |
1019 | return ide_stopped; | 941 | return ide_stopped; |
1020 | 942 | ||
1021 | /* | 943 | /* using dma, transfer is complete now */ |
1022 | * using dma, transfer is complete now | ||
1023 | */ | ||
1024 | if (dma) { | 944 | if (dma) { |
1025 | if (dma_error) | 945 | if (dma_error) |
1026 | return ide_error(drive, "dma error", stat); | 946 | return ide_error(drive, "dma error", stat); |
@@ -1031,12 +951,10 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1031 | goto end_request; | 951 | goto end_request; |
1032 | } | 952 | } |
1033 | 953 | ||
1034 | /* | 954 | /* ok we fall to pio :/ */ |
1035 | * ok we fall to pio :/ | 955 | ireason = hwif->INB(hwif->io_ports.nsect_addr) & 0x3; |
1036 | */ | 956 | lowcyl = hwif->INB(hwif->io_ports.lbam_addr); |
1037 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3; | 957 | highcyl = hwif->INB(hwif->io_ports.lbah_addr); |
1038 | lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); | ||
1039 | highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]); | ||
1040 | 958 | ||
1041 | len = lowcyl + (256 * highcyl); | 959 | len = lowcyl + (256 * highcyl); |
1042 | 960 | ||
@@ -1044,9 +962,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1044 | if (thislen > len) | 962 | if (thislen > len) |
1045 | thislen = len; | 963 | thislen = len; |
1046 | 964 | ||
1047 | /* | 965 | /* If DRQ is clear, the command has completed. */ |
1048 | * If DRQ is clear, the command has completed. | ||
1049 | */ | ||
1050 | if ((stat & DRQ_STAT) == 0) { | 966 | if ((stat & DRQ_STAT) == 0) { |
1051 | if (blk_fs_request(rq)) { | 967 | if (blk_fs_request(rq)) { |
1052 | /* | 968 | /* |
@@ -1057,7 +973,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1057 | if (rq->current_nr_sectors > 0) { | 973 | if (rq->current_nr_sectors > 0) { |
1058 | printk(KERN_ERR "%s: %s: data underrun " | 974 | printk(KERN_ERR "%s: %s: data underrun " |
1059 | "(%d blocks)\n", | 975 | "(%d blocks)\n", |
1060 | drive->name, __FUNCTION__, | 976 | drive->name, __func__, |
1061 | rq->current_nr_sectors); | 977 | rq->current_nr_sectors); |
1062 | if (!write) | 978 | if (!write) |
1063 | rq->cmd_flags |= REQ_FAILED; | 979 | rq->cmd_flags |= REQ_FAILED; |
@@ -1067,15 +983,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1067 | return ide_stopped; | 983 | return ide_stopped; |
1068 | } else if (!blk_pc_request(rq)) { | 984 | } else if (!blk_pc_request(rq)) { |
1069 | ide_cd_request_sense_fixup(rq); | 985 | ide_cd_request_sense_fixup(rq); |
1070 | /* Complain if we still have data left to transfer. */ | 986 | /* complain if we still have data left to transfer */ |
1071 | uptodate = rq->data_len ? 0 : 1; | 987 | uptodate = rq->data_len ? 0 : 1; |
1072 | } | 988 | } |
1073 | goto end_request; | 989 | goto end_request; |
1074 | } | 990 | } |
1075 | 991 | ||
1076 | /* | 992 | /* check which way to transfer data */ |
1077 | * check which way to transfer data | ||
1078 | */ | ||
1079 | if (ide_cd_check_ireason(drive, rq, len, ireason, write)) | 993 | if (ide_cd_check_ireason(drive, rq, len, ireason, write)) |
1080 | return ide_stopped; | 994 | return ide_stopped; |
1081 | 995 | ||
@@ -1111,16 +1025,12 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1111 | xferfunc = HWIF(drive)->atapi_input_bytes; | 1025 | xferfunc = HWIF(drive)->atapi_input_bytes; |
1112 | } | 1026 | } |
1113 | 1027 | ||
1114 | /* | 1028 | /* transfer data */ |
1115 | * transfer data | ||
1116 | */ | ||
1117 | while (thislen > 0) { | 1029 | while (thislen > 0) { |
1118 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; | 1030 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; |
1119 | int blen = rq->data_len; | 1031 | int blen = rq->data_len; |
1120 | 1032 | ||
1121 | /* | 1033 | /* bio backed? */ |
1122 | * bio backed? | ||
1123 | */ | ||
1124 | if (rq->bio) { | 1034 | if (rq->bio) { |
1125 | if (blk_fs_request(rq)) { | 1035 | if (blk_fs_request(rq)) { |
1126 | ptr = rq->buffer; | 1036 | ptr = rq->buffer; |
@@ -1134,11 +1044,10 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1134 | if (!ptr) { | 1044 | if (!ptr) { |
1135 | if (blk_fs_request(rq) && !write) | 1045 | if (blk_fs_request(rq) && !write) |
1136 | /* | 1046 | /* |
1137 | * If the buffers are full, cache the rest | 1047 | * If the buffers are full, pipe the rest into |
1138 | * of the data in our internal buffer. | 1048 | * oblivion. |
1139 | */ | 1049 | */ |
1140 | cdrom_buffer_sectors(drive, rq->sector, | 1050 | ide_cd_drain_data(drive, thislen >> 9); |
1141 | thislen >> 9); | ||
1142 | else { | 1051 | else { |
1143 | printk(KERN_ERR "%s: confused, missing data\n", | 1052 | printk(KERN_ERR "%s: confused, missing data\n", |
1144 | drive->name); | 1053 | drive->name); |
@@ -1184,9 +1093,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1184 | rq->sense_len += blen; | 1093 | rq->sense_len += blen; |
1185 | } | 1094 | } |
1186 | 1095 | ||
1187 | /* | 1096 | /* pad, if necessary */ |
1188 | * pad, if necessary | ||
1189 | */ | ||
1190 | if (!blk_fs_request(rq) && len > 0) | 1097 | if (!blk_fs_request(rq) && len > 0) |
1191 | ide_cd_pad_transfer(drive, xferfunc, len); | 1098 | ide_cd_pad_transfer(drive, xferfunc, len); |
1192 | 1099 | ||
@@ -1230,9 +1137,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1230 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | 1137 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; |
1231 | 1138 | ||
1232 | if (write) { | 1139 | if (write) { |
1233 | /* | 1140 | /* disk has become write protected */ |
1234 | * disk has become write protected | ||
1235 | */ | ||
1236 | if (cd->disk->policy) { | 1141 | if (cd->disk->policy) { |
1237 | cdrom_end_request(drive, 0); | 1142 | cdrom_end_request(drive, 0); |
1238 | return ide_stopped; | 1143 | return ide_stopped; |
@@ -1243,15 +1148,9 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1243 | * weirdness which might be present in the request packet. | 1148 | * weirdness which might be present in the request packet. |
1244 | */ | 1149 | */ |
1245 | restore_request(rq); | 1150 | restore_request(rq); |
1246 | |||
1247 | /* Satisfy whatever we can of this request from our cache. */ | ||
1248 | if (cdrom_read_from_buffer(drive)) | ||
1249 | return ide_stopped; | ||
1250 | } | 1151 | } |
1251 | 1152 | ||
1252 | /* | 1153 | /* use DMA, if possible / writes *must* be hardware frame aligned */ |
1253 | * use DMA, if possible / writes *must* be hardware frame aligned | ||
1254 | */ | ||
1255 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || | 1154 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || |
1256 | (rq->sector & (sectors_per_frame - 1))) { | 1155 | (rq->sector & (sectors_per_frame - 1))) { |
1257 | if (write) { | 1156 | if (write) { |
@@ -1262,13 +1161,10 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1262 | } else | 1161 | } else |
1263 | cd->dma = drive->using_dma; | 1162 | cd->dma = drive->using_dma; |
1264 | 1163 | ||
1265 | /* Clear the local sector buffer. */ | ||
1266 | cd->nsectors_buffered = 0; | ||
1267 | |||
1268 | if (write) | 1164 | if (write) |
1269 | cd->devinfo.media_written = 1; | 1165 | cd->devinfo.media_written = 1; |
1270 | 1166 | ||
1271 | /* Start sending the read/write request to the drive. */ | 1167 | /* start sending the read/write request to the drive */ |
1272 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); | 1168 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); |
1273 | } | 1169 | } |
1274 | 1170 | ||
@@ -1293,12 +1189,11 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1293 | 1189 | ||
1294 | info->dma = 0; | 1190 | info->dma = 0; |
1295 | 1191 | ||
1296 | /* | 1192 | /* sg request */ |
1297 | * sg request | ||
1298 | */ | ||
1299 | if (rq->bio) { | 1193 | if (rq->bio) { |
1300 | int mask = drive->queue->dma_alignment; | 1194 | int mask = drive->queue->dma_alignment; |
1301 | unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); | 1195 | unsigned long addr = |
1196 | (unsigned long)page_address(bio_page(rq->bio)); | ||
1302 | 1197 | ||
1303 | info->dma = drive->using_dma; | 1198 | info->dma = drive->using_dma; |
1304 | 1199 | ||
@@ -1312,15 +1207,16 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1312 | info->dma = 0; | 1207 | info->dma = 0; |
1313 | } | 1208 | } |
1314 | 1209 | ||
1315 | /* Start sending the command to the drive. */ | 1210 | /* start sending the command to the drive */ |
1316 | return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); | 1211 | return cdrom_start_packet_command(drive, rq->data_len, |
1212 | cdrom_do_newpc_cont); | ||
1317 | } | 1213 | } |
1318 | 1214 | ||
1319 | /**************************************************************************** | 1215 | /* |
1320 | * cdrom driver request routine. | 1216 | * cdrom driver request routine. |
1321 | */ | 1217 | */ |
1322 | static ide_startstop_t | 1218 | static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, |
1323 | ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | 1219 | sector_t block) |
1324 | { | 1220 | { |
1325 | ide_startstop_t action; | 1221 | ide_startstop_t action; |
1326 | struct cdrom_info *info = drive->driver_data; | 1222 | struct cdrom_info *info = drive->driver_data; |
@@ -1332,16 +1228,21 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
1332 | 1228 | ||
1333 | if ((stat & SEEK_STAT) != SEEK_STAT) { | 1229 | if ((stat & SEEK_STAT) != SEEK_STAT) { |
1334 | if (elapsed < IDECD_SEEK_TIMEOUT) { | 1230 | if (elapsed < IDECD_SEEK_TIMEOUT) { |
1335 | ide_stall_queue(drive, IDECD_SEEK_TIMER); | 1231 | ide_stall_queue(drive, |
1232 | IDECD_SEEK_TIMER); | ||
1336 | return ide_stopped; | 1233 | return ide_stopped; |
1337 | } | 1234 | } |
1338 | printk (KERN_ERR "%s: DSC timeout\n", drive->name); | 1235 | printk(KERN_ERR "%s: DSC timeout\n", |
1236 | drive->name); | ||
1339 | } | 1237 | } |
1340 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; | 1238 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; |
1341 | } | 1239 | } |
1342 | if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { | 1240 | if (rq_data_dir(rq) == READ && |
1241 | IDE_LARGE_SEEK(info->last_block, block, | ||
1242 | IDECD_SEEK_THRESHOLD) && | ||
1243 | drive->dsc_overlap) | ||
1343 | action = cdrom_start_seek(drive, block); | 1244 | action = cdrom_start_seek(drive, block); |
1344 | } else | 1245 | else |
1345 | action = cdrom_start_rw(drive, rq); | 1246 | action = cdrom_start_rw(drive, rq); |
1346 | info->last_block = block; | 1247 | info->last_block = block; |
1347 | return action; | 1248 | return action; |
@@ -1349,9 +1250,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
1349 | rq->cmd_type == REQ_TYPE_ATA_PC) { | 1250 | rq->cmd_type == REQ_TYPE_ATA_PC) { |
1350 | return cdrom_do_block_pc(drive, rq); | 1251 | return cdrom_do_block_pc(drive, rq); |
1351 | } else if (blk_special_request(rq)) { | 1252 | } else if (blk_special_request(rq)) { |
1352 | /* | 1253 | /* right now this can only be a reset... */ |
1353 | * right now this can only be a reset... | ||
1354 | */ | ||
1355 | cdrom_end_request(drive, 1); | 1254 | cdrom_end_request(drive, 1); |
1356 | return ide_stopped; | 1255 | return ide_stopped; |
1357 | } | 1256 | } |
@@ -1363,18 +1262,16 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
1363 | 1262 | ||
1364 | 1263 | ||
1365 | 1264 | ||
1366 | /**************************************************************************** | 1265 | /* |
1367 | * Ioctl handling. | 1266 | * Ioctl handling. |
1368 | * | 1267 | * |
1369 | * Routines which queue packet commands take as a final argument a pointer | 1268 | * Routines which queue packet commands take as a final argument a pointer to a |
1370 | * to a request_sense struct. If execution of the command results | 1269 | * request_sense struct. If execution of the command results in an error with a |
1371 | * in an error with a CHECK CONDITION status, this structure will be filled | 1270 | * CHECK CONDITION status, this structure will be filled with the results of the |
1372 | * with the results of the subsequent request sense command. The pointer | 1271 | * subsequent request sense command. The pointer can also be NULL, in which case |
1373 | * can also be NULL, in which case no sense information is returned. | 1272 | * no sense information is returned. |
1374 | */ | 1273 | */ |
1375 | 1274 | static void msf_from_bcd(struct atapi_msf *msf) | |
1376 | static | ||
1377 | void msf_from_bcd (struct atapi_msf *msf) | ||
1378 | { | 1275 | { |
1379 | msf->minute = BCD2BIN(msf->minute); | 1276 | msf->minute = BCD2BIN(msf->minute); |
1380 | msf->second = BCD2BIN(msf->second); | 1277 | msf->second = BCD2BIN(msf->second); |
@@ -1394,8 +1291,8 @@ int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | |||
1394 | req.cmd_flags |= REQ_QUIET; | 1291 | req.cmd_flags |= REQ_QUIET; |
1395 | 1292 | ||
1396 | /* | 1293 | /* |
1397 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to | 1294 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs |
1398 | * switch CDs instead of supporting the LOAD_UNLOAD opcode. | 1295 | * instead of supporting the LOAD_UNLOAD opcode. |
1399 | */ | 1296 | */ |
1400 | req.cmd[7] = cdi->sanyo_slot % 3; | 1297 | req.cmd[7] = cdi->sanyo_slot % 3; |
1401 | 1298 | ||
@@ -1471,36 +1368,39 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1471 | unsigned long sectors_per_frame = SECTORS_PER_FRAME; | 1368 | unsigned long sectors_per_frame = SECTORS_PER_FRAME; |
1472 | 1369 | ||
1473 | if (toc == NULL) { | 1370 | if (toc == NULL) { |
1474 | /* Try to allocate space. */ | 1371 | /* try to allocate space */ |
1475 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); | 1372 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); |
1476 | if (toc == NULL) { | 1373 | if (toc == NULL) { |
1477 | printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); | 1374 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", |
1375 | drive->name); | ||
1478 | return -ENOMEM; | 1376 | return -ENOMEM; |
1479 | } | 1377 | } |
1480 | info->toc = toc; | 1378 | info->toc = toc; |
1481 | } | 1379 | } |
1482 | 1380 | ||
1483 | /* Check to see if the existing data is still valid. | 1381 | /* |
1484 | If it is, just return. */ | 1382 | * Check to see if the existing data is still valid. If it is, |
1383 | * just return. | ||
1384 | */ | ||
1485 | (void) cdrom_check_status(drive, sense); | 1385 | (void) cdrom_check_status(drive, sense); |
1486 | 1386 | ||
1487 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) | 1387 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) |
1488 | return 0; | 1388 | return 0; |
1489 | 1389 | ||
1490 | /* Try to get the total cdrom capacity and sector size. */ | 1390 | /* try to get the total cdrom capacity and sector size */ |
1491 | stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, | 1391 | stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, |
1492 | sense); | 1392 | sense); |
1493 | if (stat) | 1393 | if (stat) |
1494 | toc->capacity = 0x1fffff; | 1394 | toc->capacity = 0x1fffff; |
1495 | 1395 | ||
1496 | set_capacity(info->disk, toc->capacity * sectors_per_frame); | 1396 | set_capacity(info->disk, toc->capacity * sectors_per_frame); |
1497 | /* Save a private copy of te TOC capacity for error handling */ | 1397 | /* save a private copy of the TOC capacity for error handling */ |
1498 | drive->probed_capacity = toc->capacity * sectors_per_frame; | 1398 | drive->probed_capacity = toc->capacity * sectors_per_frame; |
1499 | 1399 | ||
1500 | blk_queue_hardsect_size(drive->queue, | 1400 | blk_queue_hardsect_size(drive->queue, |
1501 | sectors_per_frame << SECTOR_BITS); | 1401 | sectors_per_frame << SECTOR_BITS); |
1502 | 1402 | ||
1503 | /* First read just the header, so we know how long the TOC is. */ | 1403 | /* first read just the header, so we know how long the TOC is */ |
1504 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, | 1404 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, |
1505 | sizeof(struct atapi_toc_header), sense); | 1405 | sizeof(struct atapi_toc_header), sense); |
1506 | if (stat) | 1406 | if (stat) |
@@ -1517,7 +1417,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1517 | if (ntracks > MAX_TRACKS) | 1417 | if (ntracks > MAX_TRACKS) |
1518 | ntracks = MAX_TRACKS; | 1418 | ntracks = MAX_TRACKS; |
1519 | 1419 | ||
1520 | /* Now read the whole schmeer. */ | 1420 | /* now read the whole schmeer */ |
1521 | stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, | 1421 | stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, |
1522 | (char *)&toc->hdr, | 1422 | (char *)&toc->hdr, |
1523 | sizeof(struct atapi_toc_header) + | 1423 | sizeof(struct atapi_toc_header) + |
@@ -1525,15 +1425,18 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1525 | sizeof(struct atapi_toc_entry), sense); | 1425 | sizeof(struct atapi_toc_entry), sense); |
1526 | 1426 | ||
1527 | if (stat && toc->hdr.first_track > 1) { | 1427 | if (stat && toc->hdr.first_track > 1) { |
1528 | /* Cds with CDI tracks only don't have any TOC entries, | 1428 | /* |
1529 | despite of this the returned values are | 1429 | * Cds with CDI tracks only don't have any TOC entries, despite |
1530 | first_track == last_track = number of CDI tracks + 1, | 1430 | * of this the returned values are |
1531 | so that this case is indistinguishable from the same | 1431 | * first_track == last_track = number of CDI tracks + 1, |
1532 | layout plus an additional audio track. | 1432 | * so that this case is indistinguishable from the same layout |
1533 | If we get an error for the regular case, we assume | 1433 | * plus an additional audio track. If we get an error for the |
1534 | a CDI without additional audio tracks. In this case | 1434 | * regular case, we assume a CDI without additional audio |
1535 | the readable TOC is empty (CDI tracks are not included) | 1435 | * tracks. In this case the readable TOC is empty (CDI tracks |
1536 | and only holds the Leadout entry. Heiko Eißfeldt */ | 1436 | * are not included) and only holds the Leadout entry. |
1437 | * | ||
1438 | * Heiko Eißfeldt. | ||
1439 | */ | ||
1537 | ntracks = 0; | 1440 | ntracks = 0; |
1538 | stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, | 1441 | stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, |
1539 | (char *)&toc->hdr, | 1442 | (char *)&toc->hdr, |
@@ -1569,14 +1472,13 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1569 | toc->ent[i].track = BCD2BIN(toc->ent[i].track); | 1472 | toc->ent[i].track = BCD2BIN(toc->ent[i].track); |
1570 | msf_from_bcd(&toc->ent[i].addr.msf); | 1473 | msf_from_bcd(&toc->ent[i].addr.msf); |
1571 | } | 1474 | } |
1572 | toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, | 1475 | toc->ent[i].addr.lba = msf_to_lba(toc->ent[i].addr.msf.minute, |
1573 | toc->ent[i].addr.msf.second, | 1476 | toc->ent[i].addr.msf.second, |
1574 | toc->ent[i].addr.msf.frame); | 1477 | toc->ent[i].addr.msf.frame); |
1575 | } | 1478 | } |
1576 | 1479 | ||
1577 | /* Read the multisession information. */ | ||
1578 | if (toc->hdr.first_track != CDROM_LEADOUT) { | 1480 | if (toc->hdr.first_track != CDROM_LEADOUT) { |
1579 | /* Read the multisession information. */ | 1481 | /* read the multisession information */ |
1580 | stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, | 1482 | stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, |
1581 | sizeof(ms_tmp), sense); | 1483 | sizeof(ms_tmp), sense); |
1582 | if (stat) | 1484 | if (stat) |
@@ -1584,26 +1486,27 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1584 | 1486 | ||
1585 | toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba); | 1487 | toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba); |
1586 | } else { | 1488 | } else { |
1587 | ms_tmp.hdr.first_track = ms_tmp.hdr.last_track = CDROM_LEADOUT; | 1489 | ms_tmp.hdr.last_track = CDROM_LEADOUT; |
1490 | ms_tmp.hdr.first_track = ms_tmp.hdr.last_track; | ||
1588 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ | 1491 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ |
1589 | } | 1492 | } |
1590 | 1493 | ||
1591 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { | 1494 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { |
1592 | /* Re-read multisession information using MSF format */ | 1495 | /* re-read multisession information using MSF format */ |
1593 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, | 1496 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, |
1594 | sizeof(ms_tmp), sense); | 1497 | sizeof(ms_tmp), sense); |
1595 | if (stat) | 1498 | if (stat) |
1596 | return stat; | 1499 | return stat; |
1597 | 1500 | ||
1598 | msf_from_bcd (&ms_tmp.ent.addr.msf); | 1501 | msf_from_bcd(&ms_tmp.ent.addr.msf); |
1599 | toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute, | 1502 | toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute, |
1600 | ms_tmp.ent.addr.msf.second, | 1503 | ms_tmp.ent.addr.msf.second, |
1601 | ms_tmp.ent.addr.msf.frame); | 1504 | ms_tmp.ent.addr.msf.frame); |
1602 | } | 1505 | } |
1603 | 1506 | ||
1604 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); | 1507 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); |
1605 | 1508 | ||
1606 | /* Now try to get the total cdrom capacity. */ | 1509 | /* now try to get the total cdrom capacity */ |
1607 | stat = cdrom_get_last_written(cdi, &last_written); | 1510 | stat = cdrom_get_last_written(cdi, &last_written); |
1608 | if (!stat && (last_written > toc->capacity)) { | 1511 | if (!stat && (last_written > toc->capacity)) { |
1609 | toc->capacity = last_written; | 1512 | toc->capacity = last_written; |
@@ -1628,7 +1531,8 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) | |||
1628 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; | 1531 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; |
1629 | 1532 | ||
1630 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); | 1533 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); |
1631 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ | 1534 | do { |
1535 | /* we seem to get stat=0x01,err=0x00 the first time (??) */ | ||
1632 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); | 1536 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); |
1633 | if (!stat) | 1537 | if (!stat) |
1634 | break; | 1538 | break; |
@@ -1679,7 +1583,7 @@ static struct cdrom_device_ops ide_cdrom_dops = { | |||
1679 | .generic_packet = ide_cdrom_packet, | 1583 | .generic_packet = ide_cdrom_packet, |
1680 | }; | 1584 | }; |
1681 | 1585 | ||
1682 | static int ide_cdrom_register (ide_drive_t *drive, int nslots) | 1586 | static int ide_cdrom_register(ide_drive_t *drive, int nslots) |
1683 | { | 1587 | { |
1684 | struct cdrom_info *info = drive->driver_data; | 1588 | struct cdrom_info *info = drive->driver_data; |
1685 | struct cdrom_device_info *devinfo = &info->devinfo; | 1589 | struct cdrom_device_info *devinfo = &info->devinfo; |
@@ -1697,8 +1601,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) | |||
1697 | return register_cdrom(devinfo); | 1601 | return register_cdrom(devinfo); |
1698 | } | 1602 | } |
1699 | 1603 | ||
1700 | static | 1604 | static int ide_cdrom_probe_capabilities(ide_drive_t *drive) |
1701 | int ide_cdrom_probe_capabilities (ide_drive_t *drive) | ||
1702 | { | 1605 | { |
1703 | struct cdrom_info *cd = drive->driver_data; | 1606 | struct cdrom_info *cd = drive->driver_data; |
1704 | struct cdrom_device_info *cdi = &cd->devinfo; | 1607 | struct cdrom_device_info *cdi = &cd->devinfo; |
@@ -1712,7 +1615,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
1712 | 1615 | ||
1713 | if (drive->media == ide_optical) { | 1616 | if (drive->media == ide_optical) { |
1714 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); | 1617 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); |
1715 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); | 1618 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", |
1619 | drive->name); | ||
1716 | return nslots; | 1620 | return nslots; |
1717 | } | 1621 | } |
1718 | 1622 | ||
@@ -1723,11 +1627,10 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
1723 | } | 1627 | } |
1724 | 1628 | ||
1725 | /* | 1629 | /* |
1726 | * we have to cheat a little here. the packet will eventually | 1630 | * We have to cheat a little here. the packet will eventually be queued |
1727 | * be queued with ide_cdrom_packet(), which extracts the | 1631 | * with ide_cdrom_packet(), which extracts the drive from cdi->handle. |
1728 | * drive from cdi->handle. Since this device hasn't been | 1632 | * Since this device hasn't been registered with the Uniform layer yet, |
1729 | * registered with the Uniform layer yet, it can't do this. | 1633 | * it can't do this. Same goes for cdi->ops. |
1730 | * Same goes for cdi->ops. | ||
1731 | */ | 1634 | */ |
1732 | cdi->handle = drive; | 1635 | cdi->handle = drive; |
1733 | cdi->ops = &ide_cdrom_dops; | 1636 | cdi->ops = &ide_cdrom_dops; |
@@ -1796,18 +1699,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
1796 | return nslots; | 1699 | return nslots; |
1797 | } | 1700 | } |
1798 | 1701 | ||
1799 | #ifdef CONFIG_IDE_PROC_FS | 1702 | /* standard prep_rq_fn that builds 10 byte cmds */ |
1800 | static void ide_cdrom_add_settings(ide_drive_t *drive) | ||
1801 | { | ||
1802 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); | ||
1803 | } | ||
1804 | #else | ||
1805 | static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } | ||
1806 | #endif | ||
1807 | |||
1808 | /* | ||
1809 | * standard prep_rq_fn that builds 10 byte cmds | ||
1810 | */ | ||
1811 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) | 1703 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) |
1812 | { | 1704 | { |
1813 | int hard_sect = queue_hardsect_size(q); | 1705 | int hard_sect = queue_hardsect_size(q); |
@@ -1846,9 +1738,7 @@ static int ide_cdrom_prep_pc(struct request *rq) | |||
1846 | { | 1738 | { |
1847 | u8 *c = rq->cmd; | 1739 | u8 *c = rq->cmd; |
1848 | 1740 | ||
1849 | /* | 1741 | /* transform 6-byte read/write commands to the 10-byte version */ |
1850 | * Transform 6-byte read/write commands to the 10-byte version | ||
1851 | */ | ||
1852 | if (c[0] == READ_6 || c[0] == WRITE_6) { | 1742 | if (c[0] == READ_6 || c[0] == WRITE_6) { |
1853 | c[8] = c[4]; | 1743 | c[8] = c[4]; |
1854 | c[5] = c[3]; | 1744 | c[5] = c[3]; |
@@ -1870,7 +1760,7 @@ static int ide_cdrom_prep_pc(struct request *rq) | |||
1870 | rq->errors = ILLEGAL_REQUEST; | 1760 | rq->errors = ILLEGAL_REQUEST; |
1871 | return BLKPREP_KILL; | 1761 | return BLKPREP_KILL; |
1872 | } | 1762 | } |
1873 | 1763 | ||
1874 | return BLKPREP_OK; | 1764 | return BLKPREP_OK; |
1875 | } | 1765 | } |
1876 | 1766 | ||
@@ -1890,6 +1780,41 @@ struct cd_list_entry { | |||
1890 | unsigned int cd_flags; | 1780 | unsigned int cd_flags; |
1891 | }; | 1781 | }; |
1892 | 1782 | ||
1783 | #ifdef CONFIG_IDE_PROC_FS | ||
1784 | static sector_t ide_cdrom_capacity(ide_drive_t *drive) | ||
1785 | { | ||
1786 | unsigned long capacity, sectors_per_frame; | ||
1787 | |||
1788 | if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL)) | ||
1789 | return 0; | ||
1790 | |||
1791 | return capacity * sectors_per_frame; | ||
1792 | } | ||
1793 | |||
1794 | static int proc_idecd_read_capacity(char *page, char **start, off_t off, | ||
1795 | int count, int *eof, void *data) | ||
1796 | { | ||
1797 | ide_drive_t *drive = data; | ||
1798 | int len; | ||
1799 | |||
1800 | len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); | ||
1801 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
1802 | } | ||
1803 | |||
1804 | static ide_proc_entry_t idecd_proc[] = { | ||
1805 | { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, | ||
1806 | { NULL, 0, NULL, NULL } | ||
1807 | }; | ||
1808 | |||
1809 | static void ide_cdrom_add_settings(ide_drive_t *drive) | ||
1810 | { | ||
1811 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | ||
1812 | &drive->dsc_overlap, NULL); | ||
1813 | } | ||
1814 | #else | ||
1815 | static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } | ||
1816 | #endif | ||
1817 | |||
1893 | static const struct cd_list_entry ide_cd_quirks_list[] = { | 1818 | static const struct cd_list_entry ide_cd_quirks_list[] = { |
1894 | /* Limit transfer size per interrupt. */ | 1819 | /* Limit transfer size per interrupt. */ |
1895 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, | 1820 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, |
@@ -1947,8 +1872,7 @@ static unsigned int ide_cd_flags(struct hd_driveid *id) | |||
1947 | return 0; | 1872 | return 0; |
1948 | } | 1873 | } |
1949 | 1874 | ||
1950 | static | 1875 | static int ide_cdrom_setup(ide_drive_t *drive) |
1951 | int ide_cdrom_setup (ide_drive_t *drive) | ||
1952 | { | 1876 | { |
1953 | struct cdrom_info *cd = drive->driver_data; | 1877 | struct cdrom_info *cd = drive->driver_data; |
1954 | struct cdrom_device_info *cdi = &cd->devinfo; | 1878 | struct cdrom_device_info *cdi = &cd->devinfo; |
@@ -1977,21 +1901,19 @@ int ide_cdrom_setup (ide_drive_t *drive) | |||
1977 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1901 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
1978 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; | 1902 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; |
1979 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) | 1903 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) |
1980 | cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ | 1904 | /* 3 => use CD in slot 0 */ |
1905 | cdi->sanyo_slot = 3; | ||
1981 | 1906 | ||
1982 | nslots = ide_cdrom_probe_capabilities (drive); | 1907 | nslots = ide_cdrom_probe_capabilities(drive); |
1983 | 1908 | ||
1984 | /* | 1909 | /* set correct block size */ |
1985 | * set correct block size | ||
1986 | */ | ||
1987 | blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); | 1910 | blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); |
1988 | 1911 | ||
1989 | if (drive->autotune == IDE_TUNE_DEFAULT || | 1912 | drive->dsc_overlap = (drive->next != drive); |
1990 | drive->autotune == IDE_TUNE_AUTO) | ||
1991 | drive->dsc_overlap = (drive->next != drive); | ||
1992 | 1913 | ||
1993 | if (ide_cdrom_register(drive, nslots)) { | 1914 | if (ide_cdrom_register(drive, nslots)) { |
1994 | printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); | 1915 | printk(KERN_ERR "%s: %s failed to register device with the" |
1916 | " cdrom driver.\n", drive->name, __func__); | ||
1995 | cd->devinfo.handle = NULL; | 1917 | cd->devinfo.handle = NULL; |
1996 | return 1; | 1918 | return 1; |
1997 | } | 1919 | } |
@@ -1999,19 +1921,6 @@ int ide_cdrom_setup (ide_drive_t *drive) | |||
1999 | return 0; | 1921 | return 0; |
2000 | } | 1922 | } |
2001 | 1923 | ||
2002 | #ifdef CONFIG_IDE_PROC_FS | ||
2003 | static | ||
2004 | sector_t ide_cdrom_capacity (ide_drive_t *drive) | ||
2005 | { | ||
2006 | unsigned long capacity, sectors_per_frame; | ||
2007 | |||
2008 | if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL)) | ||
2009 | return 0; | ||
2010 | |||
2011 | return capacity * sectors_per_frame; | ||
2012 | } | ||
2013 | #endif | ||
2014 | |||
2015 | static void ide_cd_remove(ide_drive_t *drive) | 1924 | static void ide_cd_remove(ide_drive_t *drive) |
2016 | { | 1925 | { |
2017 | struct cdrom_info *info = drive->driver_data; | 1926 | struct cdrom_info *info = drive->driver_data; |
@@ -2030,7 +1939,6 @@ static void ide_cd_release(struct kref *kref) | |||
2030 | ide_drive_t *drive = info->drive; | 1939 | ide_drive_t *drive = info->drive; |
2031 | struct gendisk *g = info->disk; | 1940 | struct gendisk *g = info->disk; |
2032 | 1941 | ||
2033 | kfree(info->buffer); | ||
2034 | kfree(info->toc); | 1942 | kfree(info->toc); |
2035 | if (devinfo->handle == drive) | 1943 | if (devinfo->handle == drive) |
2036 | unregister_cdrom(devinfo); | 1944 | unregister_cdrom(devinfo); |
@@ -2044,23 +1952,6 @@ static void ide_cd_release(struct kref *kref) | |||
2044 | 1952 | ||
2045 | static int ide_cd_probe(ide_drive_t *); | 1953 | static int ide_cd_probe(ide_drive_t *); |
2046 | 1954 | ||
2047 | #ifdef CONFIG_IDE_PROC_FS | ||
2048 | static int proc_idecd_read_capacity | ||
2049 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
2050 | { | ||
2051 | ide_drive_t *drive = data; | ||
2052 | int len; | ||
2053 | |||
2054 | len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive)); | ||
2055 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | ||
2056 | } | ||
2057 | |||
2058 | static ide_proc_entry_t idecd_proc[] = { | ||
2059 | { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, | ||
2060 | { NULL, 0, NULL, NULL } | ||
2061 | }; | ||
2062 | #endif | ||
2063 | |||
2064 | static ide_driver_t ide_cdrom_driver = { | 1955 | static ide_driver_t ide_cdrom_driver = { |
2065 | .gen_driver = { | 1956 | .gen_driver = { |
2066 | .owner = THIS_MODULE, | 1957 | .owner = THIS_MODULE, |
@@ -2081,20 +1972,17 @@ static ide_driver_t ide_cdrom_driver = { | |||
2081 | #endif | 1972 | #endif |
2082 | }; | 1973 | }; |
2083 | 1974 | ||
2084 | static int idecd_open(struct inode * inode, struct file * file) | 1975 | static int idecd_open(struct inode *inode, struct file *file) |
2085 | { | 1976 | { |
2086 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1977 | struct gendisk *disk = inode->i_bdev->bd_disk; |
2087 | struct cdrom_info *info; | 1978 | struct cdrom_info *info; |
2088 | int rc = -ENOMEM; | 1979 | int rc = -ENOMEM; |
2089 | 1980 | ||
2090 | if (!(info = ide_cd_get(disk))) | 1981 | info = ide_cd_get(disk); |
1982 | if (!info) | ||
2091 | return -ENXIO; | 1983 | return -ENXIO; |
2092 | 1984 | ||
2093 | if (!info->buffer) | 1985 | rc = cdrom_open(&info->devinfo, inode, file); |
2094 | info->buffer = kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL|__GFP_REPEAT); | ||
2095 | |||
2096 | if (info->buffer) | ||
2097 | rc = cdrom_open(&info->devinfo, inode, file); | ||
2098 | 1986 | ||
2099 | if (rc < 0) | 1987 | if (rc < 0) |
2100 | ide_cd_put(info); | 1988 | ide_cd_put(info); |
@@ -2102,12 +1990,12 @@ static int idecd_open(struct inode * inode, struct file * file) | |||
2102 | return rc; | 1990 | return rc; |
2103 | } | 1991 | } |
2104 | 1992 | ||
2105 | static int idecd_release(struct inode * inode, struct file * file) | 1993 | static int idecd_release(struct inode *inode, struct file *file) |
2106 | { | 1994 | { |
2107 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1995 | struct gendisk *disk = inode->i_bdev->bd_disk; |
2108 | struct cdrom_info *info = ide_cd_g(disk); | 1996 | struct cdrom_info *info = ide_cd_g(disk); |
2109 | 1997 | ||
2110 | cdrom_release (&info->devinfo, file); | 1998 | cdrom_release(&info->devinfo, file); |
2111 | 1999 | ||
2112 | ide_cd_put(info); | 2000 | ide_cd_put(info); |
2113 | 2001 | ||
@@ -2139,7 +2027,7 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg) | |||
2139 | struct packet_command cgc; | 2027 | struct packet_command cgc; |
2140 | char buffer[16]; | 2028 | char buffer[16]; |
2141 | int stat; | 2029 | int stat; |
2142 | char spindown; | 2030 | char spindown; |
2143 | 2031 | ||
2144 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | 2032 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); |
2145 | 2033 | ||
@@ -2148,12 +2036,12 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg) | |||
2148 | return stat; | 2036 | return stat; |
2149 | 2037 | ||
2150 | spindown = buffer[11] & 0x0f; | 2038 | spindown = buffer[11] & 0x0f; |
2151 | if (copy_to_user((void __user *)arg, &spindown, sizeof (char))) | 2039 | if (copy_to_user((void __user *)arg, &spindown, sizeof(char))) |
2152 | return -EFAULT; | 2040 | return -EFAULT; |
2153 | return 0; | 2041 | return 0; |
2154 | } | 2042 | } |
2155 | 2043 | ||
2156 | static int idecd_ioctl (struct inode *inode, struct file *file, | 2044 | static int idecd_ioctl(struct inode *inode, struct file *file, |
2157 | unsigned int cmd, unsigned long arg) | 2045 | unsigned int cmd, unsigned long arg) |
2158 | { | 2046 | { |
2159 | struct block_device *bdev = inode->i_bdev; | 2047 | struct block_device *bdev = inode->i_bdev; |
@@ -2161,13 +2049,13 @@ static int idecd_ioctl (struct inode *inode, struct file *file, | |||
2161 | int err; | 2049 | int err; |
2162 | 2050 | ||
2163 | switch (cmd) { | 2051 | switch (cmd) { |
2164 | case CDROMSETSPINDOWN: | 2052 | case CDROMSETSPINDOWN: |
2165 | return idecd_set_spindown(&info->devinfo, arg); | 2053 | return idecd_set_spindown(&info->devinfo, arg); |
2166 | case CDROMGETSPINDOWN: | 2054 | case CDROMGETSPINDOWN: |
2167 | return idecd_get_spindown(&info->devinfo, arg); | 2055 | return idecd_get_spindown(&info->devinfo, arg); |
2168 | default: | 2056 | default: |
2169 | break; | 2057 | break; |
2170 | } | 2058 | } |
2171 | 2059 | ||
2172 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | 2060 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); |
2173 | if (err == -EINVAL) | 2061 | if (err == -EINVAL) |
@@ -2193,16 +2081,16 @@ static int idecd_revalidate_disk(struct gendisk *disk) | |||
2193 | } | 2081 | } |
2194 | 2082 | ||
2195 | static struct block_device_operations idecd_ops = { | 2083 | static struct block_device_operations idecd_ops = { |
2196 | .owner = THIS_MODULE, | 2084 | .owner = THIS_MODULE, |
2197 | .open = idecd_open, | 2085 | .open = idecd_open, |
2198 | .release = idecd_release, | 2086 | .release = idecd_release, |
2199 | .ioctl = idecd_ioctl, | 2087 | .ioctl = idecd_ioctl, |
2200 | .media_changed = idecd_media_changed, | 2088 | .media_changed = idecd_media_changed, |
2201 | .revalidate_disk= idecd_revalidate_disk | 2089 | .revalidate_disk = idecd_revalidate_disk |
2202 | }; | 2090 | }; |
2203 | 2091 | ||
2204 | /* options */ | 2092 | /* module options */ |
2205 | static char *ignore = NULL; | 2093 | static char *ignore; |
2206 | 2094 | ||
2207 | module_param(ignore, charp, 0400); | 2095 | module_param(ignore, charp, 0400); |
2208 | MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); | 2096 | MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); |
@@ -2222,17 +2110,20 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2222 | /* skip drives that we were told to ignore */ | 2110 | /* skip drives that we were told to ignore */ |
2223 | if (ignore != NULL) { | 2111 | if (ignore != NULL) { |
2224 | if (strstr(ignore, drive->name)) { | 2112 | if (strstr(ignore, drive->name)) { |
2225 | printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); | 2113 | printk(KERN_INFO "ide-cd: ignoring drive %s\n", |
2114 | drive->name); | ||
2226 | goto failed; | 2115 | goto failed; |
2227 | } | 2116 | } |
2228 | } | 2117 | } |
2229 | if (drive->scsi) { | 2118 | if (drive->scsi) { |
2230 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); | 2119 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " |
2120 | "emulation.\n", drive->name); | ||
2231 | goto failed; | 2121 | goto failed; |
2232 | } | 2122 | } |
2233 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 2123 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2234 | if (info == NULL) { | 2124 | if (info == NULL) { |
2235 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); | 2125 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", |
2126 | drive->name); | ||
2236 | goto failed; | 2127 | goto failed; |
2237 | } | 2128 | } |
2238 | 2129 | ||
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index 22e3751a681e..a58801c4484d 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -119,10 +119,6 @@ struct cdrom_info { | |||
119 | 119 | ||
120 | struct atapi_toc *toc; | 120 | struct atapi_toc *toc; |
121 | 121 | ||
122 | unsigned long sector_buffered; | ||
123 | unsigned long nsectors_buffered; | ||
124 | unsigned char *buffer; | ||
125 | |||
126 | /* The result of the last successful request sense command | 122 | /* The result of the last successful request sense command |
127 | on this device. */ | 123 | on this device. */ |
128 | struct request_sense sense_data; | 124 | struct request_sense sense_data; |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 39501d130256..8e08d083fce9 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -16,8 +16,6 @@ | |||
16 | 16 | ||
17 | #define IDEDISK_VERSION "1.18" | 17 | #define IDEDISK_VERSION "1.18" |
18 | 18 | ||
19 | //#define DEBUG | ||
20 | |||
21 | #include <linux/module.h> | 19 | #include <linux/module.h> |
22 | #include <linux/types.h> | 20 | #include <linux/types.h> |
23 | #include <linux/string.h> | 21 | #include <linux/string.h> |
@@ -88,7 +86,7 @@ static void ide_disk_put(struct ide_disk_obj *idkp) | |||
88 | * | 86 | * |
89 | * It is called only once for each drive. | 87 | * It is called only once for each drive. |
90 | */ | 88 | */ |
91 | static int lba_capacity_is_ok (struct hd_driveid *id) | 89 | static int lba_capacity_is_ok(struct hd_driveid *id) |
92 | { | 90 | { |
93 | unsigned long lba_sects, chs_sects, head, tail; | 91 | unsigned long lba_sects, chs_sects, head, tail; |
94 | 92 | ||
@@ -176,7 +174,8 @@ static void ide_tf_set_cmd(ide_drive_t *drive, ide_task_t *task, u8 dma) | |||
176 | * __ide_do_rw_disk() issues READ and WRITE commands to a disk, | 174 | * __ide_do_rw_disk() issues READ and WRITE commands to a disk, |
177 | * using LBA if supported, or CHS otherwise, to address sectors. | 175 | * using LBA if supported, or CHS otherwise, to address sectors. |
178 | */ | 176 | */ |
179 | static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, sector_t block) | 177 | static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, |
178 | sector_t block) | ||
180 | { | 179 | { |
181 | ide_hwif_t *hwif = HWIF(drive); | 180 | ide_hwif_t *hwif = HWIF(drive); |
182 | unsigned int dma = drive->using_dma; | 181 | unsigned int dma = drive->using_dma; |
@@ -228,7 +227,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
228 | tf->device = (block >> 8) & 0xf; | 227 | tf->device = (block >> 8) & 0xf; |
229 | } | 228 | } |
230 | } else { | 229 | } else { |
231 | unsigned int sect,head,cyl,track; | 230 | unsigned int sect, head, cyl, track; |
231 | |||
232 | track = (int)block / drive->sect; | 232 | track = (int)block / drive->sect; |
233 | sect = (int)block % drive->sect + 1; | 233 | sect = (int)block % drive->sect + 1; |
234 | head = track % drive->head; | 234 | head = track % drive->head; |
@@ -271,7 +271,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
271 | * 1073741822 == 549756 MB or 48bit addressing fake drive | 271 | * 1073741822 == 549756 MB or 48bit addressing fake drive |
272 | */ | 272 | */ |
273 | 273 | ||
274 | static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector_t block) | 274 | static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, |
275 | sector_t block) | ||
275 | { | 276 | { |
276 | ide_hwif_t *hwif = HWIF(drive); | 277 | ide_hwif_t *hwif = HWIF(drive); |
277 | 278 | ||
@@ -452,7 +453,7 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
452 | * in above order (i.e., if value of higher priority is available, | 453 | * in above order (i.e., if value of higher priority is available, |
453 | * reset will be ignored). | 454 | * reset will be ignored). |
454 | */ | 455 | */ |
455 | static void init_idedisk_capacity (ide_drive_t *drive) | 456 | static void init_idedisk_capacity(ide_drive_t *drive) |
456 | { | 457 | { |
457 | struct hd_driveid *id = drive->id; | 458 | struct hd_driveid *id = drive->id; |
458 | /* | 459 | /* |
@@ -479,7 +480,7 @@ static void init_idedisk_capacity (ide_drive_t *drive) | |||
479 | } | 480 | } |
480 | } | 481 | } |
481 | 482 | ||
482 | static sector_t idedisk_capacity (ide_drive_t *drive) | 483 | static sector_t idedisk_capacity(ide_drive_t *drive) |
483 | { | 484 | { |
484 | return drive->capacity64 - drive->sect0; | 485 | return drive->capacity64 - drive->sect0; |
485 | } | 486 | } |
@@ -524,10 +525,11 @@ static int proc_idedisk_read_cache | |||
524 | int len; | 525 | int len; |
525 | 526 | ||
526 | if (drive->id_read) | 527 | if (drive->id_read) |
527 | len = sprintf(out,"%i\n", drive->id->buf_size / 2); | 528 | len = sprintf(out, "%i\n", drive->id->buf_size / 2); |
528 | else | 529 | else |
529 | len = sprintf(out,"(none)\n"); | 530 | len = sprintf(out, "(none)\n"); |
530 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 531 | |
532 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
531 | } | 533 | } |
532 | 534 | ||
533 | static int proc_idedisk_read_capacity | 535 | static int proc_idedisk_read_capacity |
@@ -536,54 +538,52 @@ static int proc_idedisk_read_capacity | |||
536 | ide_drive_t*drive = (ide_drive_t *)data; | 538 | ide_drive_t*drive = (ide_drive_t *)data; |
537 | int len; | 539 | int len; |
538 | 540 | ||
539 | len = sprintf(page,"%llu\n", (long long)idedisk_capacity(drive)); | 541 | len = sprintf(page, "%llu\n", (long long)idedisk_capacity(drive)); |
540 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 542 | |
543 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
541 | } | 544 | } |
542 | 545 | ||
543 | static int proc_idedisk_read_smart_thresholds | 546 | static int proc_idedisk_read_smart(char *page, char **start, off_t off, |
544 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 547 | int count, int *eof, void *data, u8 sub_cmd) |
545 | { | 548 | { |
546 | ide_drive_t *drive = (ide_drive_t *)data; | 549 | ide_drive_t *drive = (ide_drive_t *)data; |
547 | int len = 0, i = 0; | 550 | int len = 0, i = 0; |
548 | 551 | ||
549 | if (get_smart_data(drive, page, SMART_READ_THRESHOLDS) == 0) { | 552 | if (get_smart_data(drive, page, sub_cmd) == 0) { |
550 | unsigned short *val = (unsigned short *) page; | 553 | unsigned short *val = (unsigned short *) page; |
551 | char *out = ((char *)val) + (SECTOR_WORDS * 4); | 554 | char *out = ((char *)val) + (SECTOR_WORDS * 4); |
552 | page = out; | 555 | page = out; |
553 | do { | 556 | do { |
554 | out += sprintf(out, "%04x%c", le16_to_cpu(*val), (++i & 7) ? ' ' : '\n'); | 557 | out += sprintf(out, "%04x%c", le16_to_cpu(*val), |
558 | (++i & 7) ? ' ' : '\n'); | ||
555 | val += 1; | 559 | val += 1; |
556 | } while (i < (SECTOR_WORDS * 2)); | 560 | } while (i < (SECTOR_WORDS * 2)); |
557 | len = out - page; | 561 | len = out - page; |
558 | } | 562 | } |
559 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 563 | |
564 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
560 | } | 565 | } |
561 | 566 | ||
562 | static int proc_idedisk_read_smart_values | 567 | static int proc_idedisk_read_sv |
563 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 568 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
564 | { | 569 | { |
565 | ide_drive_t *drive = (ide_drive_t *)data; | 570 | return proc_idedisk_read_smart(page, start, off, count, eof, data, |
566 | int len = 0, i = 0; | 571 | SMART_READ_VALUES); |
572 | } | ||
567 | 573 | ||
568 | if (get_smart_data(drive, page, SMART_READ_VALUES) == 0) { | 574 | static int proc_idedisk_read_st |
569 | unsigned short *val = (unsigned short *) page; | 575 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
570 | char *out = ((char *)val) + (SECTOR_WORDS * 4); | 576 | { |
571 | page = out; | 577 | return proc_idedisk_read_smart(page, start, off, count, eof, data, |
572 | do { | 578 | SMART_READ_THRESHOLDS); |
573 | out += sprintf(out, "%04x%c", le16_to_cpu(*val), (++i & 7) ? ' ' : '\n'); | ||
574 | val += 1; | ||
575 | } while (i < (SECTOR_WORDS * 2)); | ||
576 | len = out - page; | ||
577 | } | ||
578 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | ||
579 | } | 579 | } |
580 | 580 | ||
581 | static ide_proc_entry_t idedisk_proc[] = { | 581 | static ide_proc_entry_t idedisk_proc[] = { |
582 | { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, | 582 | { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, |
583 | { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, | 583 | { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, |
584 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, | 584 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, |
585 | { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_smart_values, NULL }, | 585 | { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL }, |
586 | { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL }, | 586 | { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL }, |
587 | { NULL, 0, NULL, NULL } | 587 | { NULL, 0, NULL, NULL } |
588 | }; | 588 | }; |
589 | #endif /* CONFIG_IDE_PROC_FS */ | 589 | #endif /* CONFIG_IDE_PROC_FS */ |
@@ -625,12 +625,13 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
625 | if (drive->special.b.set_multmode) | 625 | if (drive->special.b.set_multmode) |
626 | return -EBUSY; | 626 | return -EBUSY; |
627 | 627 | ||
628 | ide_init_drive_cmd (&rq); | 628 | ide_init_drive_cmd(&rq); |
629 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 629 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; |
630 | 630 | ||
631 | drive->mult_req = arg; | 631 | drive->mult_req = arg; |
632 | drive->special.b.set_multmode = 1; | 632 | drive->special.b.set_multmode = 1; |
633 | (void) ide_do_drive_cmd (drive, &rq, ide_wait); | 633 | (void)ide_do_drive_cmd(drive, &rq, ide_wait); |
634 | |||
634 | return (drive->mult_count == arg) ? 0 : -EIO; | 635 | return (drive->mult_count == arg) ? 0 : -EIO; |
635 | } | 636 | } |
636 | 637 | ||
@@ -706,7 +707,7 @@ static int write_cache(ide_drive_t *drive, int arg) | |||
706 | return err; | 707 | return err; |
707 | } | 708 | } |
708 | 709 | ||
709 | static int do_idedisk_flushcache (ide_drive_t *drive) | 710 | static int do_idedisk_flushcache(ide_drive_t *drive) |
710 | { | 711 | { |
711 | ide_task_t args; | 712 | ide_task_t args; |
712 | 713 | ||
@@ -719,7 +720,7 @@ static int do_idedisk_flushcache (ide_drive_t *drive) | |||
719 | return ide_no_data_taskfile(drive, &args); | 720 | return ide_no_data_taskfile(drive, &args); |
720 | } | 721 | } |
721 | 722 | ||
722 | static int set_acoustic (ide_drive_t *drive, int arg) | 723 | static int set_acoustic(ide_drive_t *drive, int arg) |
723 | { | 724 | { |
724 | ide_task_t args; | 725 | ide_task_t args; |
725 | 726 | ||
@@ -753,7 +754,7 @@ static int set_lba_addressing(ide_drive_t *drive, int arg) | |||
753 | return 0; | 754 | return 0; |
754 | 755 | ||
755 | if (!idedisk_supports_lba48(drive->id)) | 756 | if (!idedisk_supports_lba48(drive->id)) |
756 | return -EIO; | 757 | return -EIO; |
757 | drive->addressing = arg; | 758 | drive->addressing = arg; |
758 | return 0; | 759 | return 0; |
759 | } | 760 | } |
@@ -763,23 +764,35 @@ static void idedisk_add_settings(ide_drive_t *drive) | |||
763 | { | 764 | { |
764 | struct hd_driveid *id = drive->id; | 765 | struct hd_driveid *id = drive->id; |
765 | 766 | ||
766 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->bios_cyl, NULL); | 767 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, |
767 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); | 768 | &drive->bios_cyl, NULL); |
768 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); | 769 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, |
769 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, &drive->addressing, set_lba_addressing); | 770 | &drive->bios_head, NULL); |
770 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, id->max_multsect, 1, 1, &drive->mult_count, set_multcount); | 771 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, |
771 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->nowerr, set_nowerr); | 772 | &drive->bios_sect, NULL); |
772 | ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, &drive->lun, NULL); | 773 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, |
773 | ide_add_setting(drive, "wcache", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->wcache, write_cache); | 774 | &drive->addressing, set_lba_addressing); |
774 | ide_add_setting(drive, "acoustic", SETTING_RW, TYPE_BYTE, 0, 254, 1, 1, &drive->acoustic, set_acoustic); | 775 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, |
775 | ide_add_setting(drive, "failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->failures, NULL); | 776 | id->max_multsect, 1, 1, &drive->mult_count, |
776 | ide_add_setting(drive, "max_failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->max_failures, NULL); | 777 | set_multcount); |
778 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | ||
779 | &drive->nowerr, set_nowerr); | ||
780 | ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, | ||
781 | &drive->lun, NULL); | ||
782 | ide_add_setting(drive, "wcache", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | ||
783 | &drive->wcache, write_cache); | ||
784 | ide_add_setting(drive, "acoustic", SETTING_RW, TYPE_BYTE, 0, 254, 1, 1, | ||
785 | &drive->acoustic, set_acoustic); | ||
786 | ide_add_setting(drive, "failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, | ||
787 | &drive->failures, NULL); | ||
788 | ide_add_setting(drive, "max_failures", SETTING_RW, TYPE_INT, 0, 65535, | ||
789 | 1, 1, &drive->max_failures, NULL); | ||
777 | } | 790 | } |
778 | #else | 791 | #else |
779 | static inline void idedisk_add_settings(ide_drive_t *drive) { ; } | 792 | static inline void idedisk_add_settings(ide_drive_t *drive) { ; } |
780 | #endif | 793 | #endif |
781 | 794 | ||
782 | static void idedisk_setup (ide_drive_t *drive) | 795 | static void idedisk_setup(ide_drive_t *drive) |
783 | { | 796 | { |
784 | ide_hwif_t *hwif = drive->hwif; | 797 | ide_hwif_t *hwif = drive->hwif; |
785 | struct hd_driveid *id = drive->id; | 798 | struct hd_driveid *id = drive->id; |
@@ -792,11 +805,10 @@ static void idedisk_setup (ide_drive_t *drive) | |||
792 | 805 | ||
793 | if (drive->removable) { | 806 | if (drive->removable) { |
794 | /* | 807 | /* |
795 | * Removable disks (eg. SYQUEST); ignore 'WD' drives | 808 | * Removable disks (eg. SYQUEST); ignore 'WD' drives |
796 | */ | 809 | */ |
797 | if (id->model[0] != 'W' || id->model[1] != 'D') { | 810 | if (id->model[0] != 'W' || id->model[1] != 'D') |
798 | drive->doorlocking = 1; | 811 | drive->doorlocking = 1; |
799 | } | ||
800 | } | 812 | } |
801 | 813 | ||
802 | (void)set_lba_addressing(drive, 1); | 814 | (void)set_lba_addressing(drive, 1); |
@@ -810,10 +822,11 @@ static void idedisk_setup (ide_drive_t *drive) | |||
810 | blk_queue_max_sectors(drive->queue, max_s); | 822 | blk_queue_max_sectors(drive->queue, max_s); |
811 | } | 823 | } |
812 | 824 | ||
813 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, drive->queue->max_sectors / 2); | 825 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, |
826 | drive->queue->max_sectors / 2); | ||
814 | 827 | ||
815 | /* calculate drive capacity, and select LBA if possible */ | 828 | /* calculate drive capacity, and select LBA if possible */ |
816 | init_idedisk_capacity (drive); | 829 | init_idedisk_capacity(drive); |
817 | 830 | ||
818 | /* limit drive capacity to 137GB if LBA48 cannot be used */ | 831 | /* limit drive capacity to 137GB if LBA48 cannot be used */ |
819 | if (drive->addressing == 0 && drive->capacity64 > 1ULL << 28) { | 832 | if (drive->addressing == 0 && drive->capacity64 > 1ULL << 28) { |
@@ -826,9 +839,9 @@ static void idedisk_setup (ide_drive_t *drive) | |||
826 | 839 | ||
827 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && drive->addressing) { | 840 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && drive->addressing) { |
828 | if (drive->capacity64 > 1ULL << 28) { | 841 | if (drive->capacity64 > 1ULL << 28) { |
829 | printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode will" | 842 | printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode" |
830 | " be used for accessing sectors > %u\n", | 843 | " will be used for accessing sectors " |
831 | drive->name, 1 << 28); | 844 | "> %u\n", drive->name, 1 << 28); |
832 | } else | 845 | } else |
833 | drive->addressing = 0; | 846 | drive->addressing = 0; |
834 | } | 847 | } |
@@ -837,7 +850,8 @@ static void idedisk_setup (ide_drive_t *drive) | |||
837 | * if possible, give fdisk access to more of the drive, | 850 | * if possible, give fdisk access to more of the drive, |
838 | * by correcting bios_cyls: | 851 | * by correcting bios_cyls: |
839 | */ | 852 | */ |
840 | capacity = idedisk_capacity (drive); | 853 | capacity = idedisk_capacity(drive); |
854 | |||
841 | if (!drive->forced_geom) { | 855 | if (!drive->forced_geom) { |
842 | 856 | ||
843 | if (idedisk_supports_lba48(drive->id)) { | 857 | if (idedisk_supports_lba48(drive->id)) { |
@@ -993,7 +1007,8 @@ static int idedisk_open(struct inode *inode, struct file *filp) | |||
993 | struct ide_disk_obj *idkp; | 1007 | struct ide_disk_obj *idkp; |
994 | ide_drive_t *drive; | 1008 | ide_drive_t *drive; |
995 | 1009 | ||
996 | if (!(idkp = ide_disk_get(disk))) | 1010 | idkp = ide_disk_get(disk); |
1011 | if (idkp == NULL) | ||
997 | return -ENXIO; | 1012 | return -ENXIO; |
998 | 1013 | ||
999 | drive = idkp->drive; | 1014 | drive = idkp->drive; |
@@ -1115,13 +1130,13 @@ static int idedisk_revalidate_disk(struct gendisk *disk) | |||
1115 | } | 1130 | } |
1116 | 1131 | ||
1117 | static struct block_device_operations idedisk_ops = { | 1132 | static struct block_device_operations idedisk_ops = { |
1118 | .owner = THIS_MODULE, | 1133 | .owner = THIS_MODULE, |
1119 | .open = idedisk_open, | 1134 | .open = idedisk_open, |
1120 | .release = idedisk_release, | 1135 | .release = idedisk_release, |
1121 | .ioctl = idedisk_ioctl, | 1136 | .ioctl = idedisk_ioctl, |
1122 | .getgeo = idedisk_getgeo, | 1137 | .getgeo = idedisk_getgeo, |
1123 | .media_changed = idedisk_media_changed, | 1138 | .media_changed = idedisk_media_changed, |
1124 | .revalidate_disk= idedisk_revalidate_disk | 1139 | .revalidate_disk = idedisk_revalidate_disk |
1125 | }; | 1140 | }; |
1126 | 1141 | ||
1127 | MODULE_DESCRIPTION("ATA DISK Driver"); | 1142 | MODULE_DESCRIPTION("ATA DISK Driver"); |
@@ -1184,7 +1199,7 @@ failed: | |||
1184 | return -ENODEV; | 1199 | return -ENODEV; |
1185 | } | 1200 | } |
1186 | 1201 | ||
1187 | static void __exit idedisk_exit (void) | 1202 | static void __exit idedisk_exit(void) |
1188 | { | 1203 | { |
1189 | driver_unregister(&idedisk_driver.gen_driver); | 1204 | driver_unregister(&idedisk_driver.gen_driver); |
1190 | } | 1205 | } |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index d61e5788d310..c352cf27b6e7 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -102,7 +102,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) | |||
102 | { | 102 | { |
103 | u8 stat = 0, dma_stat = 0; | 103 | u8 stat = 0, dma_stat = 0; |
104 | 104 | ||
105 | dma_stat = HWIF(drive)->ide_dma_end(drive); | 105 | dma_stat = drive->hwif->dma_ops->dma_end(drive); |
106 | stat = ide_read_status(drive); | 106 | stat = ide_read_status(drive); |
107 | 107 | ||
108 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { | 108 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { |
@@ -394,7 +394,7 @@ void ide_dma_off_quietly(ide_drive_t *drive) | |||
394 | drive->using_dma = 0; | 394 | drive->using_dma = 0; |
395 | ide_toggle_bounce(drive, 0); | 395 | ide_toggle_bounce(drive, 0); |
396 | 396 | ||
397 | drive->hwif->dma_host_set(drive, 0); | 397 | drive->hwif->dma_ops->dma_host_set(drive, 0); |
398 | } | 398 | } |
399 | 399 | ||
400 | EXPORT_SYMBOL(ide_dma_off_quietly); | 400 | EXPORT_SYMBOL(ide_dma_off_quietly); |
@@ -427,7 +427,7 @@ void ide_dma_on(ide_drive_t *drive) | |||
427 | drive->using_dma = 1; | 427 | drive->using_dma = 1; |
428 | ide_toggle_bounce(drive, 1); | 428 | ide_toggle_bounce(drive, 1); |
429 | 429 | ||
430 | drive->hwif->dma_host_set(drive, 1); | 430 | drive->hwif->dma_ops->dma_host_set(drive, 1); |
431 | } | 431 | } |
432 | 432 | ||
433 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 433 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
@@ -482,11 +482,12 @@ int ide_dma_setup(ide_drive_t *drive) | |||
482 | 482 | ||
483 | EXPORT_SYMBOL_GPL(ide_dma_setup); | 483 | EXPORT_SYMBOL_GPL(ide_dma_setup); |
484 | 484 | ||
485 | static void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) | 485 | void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) |
486 | { | 486 | { |
487 | /* issue cmd to drive */ | 487 | /* issue cmd to drive */ |
488 | ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); | 488 | ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); |
489 | } | 489 | } |
490 | EXPORT_SYMBOL_GPL(ide_dma_exec_cmd); | ||
490 | 491 | ||
491 | void ide_dma_start(ide_drive_t *drive) | 492 | void ide_dma_start(ide_drive_t *drive) |
492 | { | 493 | { |
@@ -532,7 +533,7 @@ int __ide_dma_end (ide_drive_t *drive) | |||
532 | EXPORT_SYMBOL(__ide_dma_end); | 533 | EXPORT_SYMBOL(__ide_dma_end); |
533 | 534 | ||
534 | /* returns 1 if dma irq issued, 0 otherwise */ | 535 | /* returns 1 if dma irq issued, 0 otherwise */ |
535 | static int __ide_dma_test_irq(ide_drive_t *drive) | 536 | int ide_dma_test_irq(ide_drive_t *drive) |
536 | { | 537 | { |
537 | ide_hwif_t *hwif = HWIF(drive); | 538 | ide_hwif_t *hwif = HWIF(drive); |
538 | u8 dma_stat = hwif->INB(hwif->dma_status); | 539 | u8 dma_stat = hwif->INB(hwif->dma_status); |
@@ -542,9 +543,10 @@ static int __ide_dma_test_irq(ide_drive_t *drive) | |||
542 | return 1; | 543 | return 1; |
543 | if (!drive->waiting_for_dma) | 544 | if (!drive->waiting_for_dma) |
544 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", | 545 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", |
545 | drive->name, __FUNCTION__); | 546 | drive->name, __func__); |
546 | return 0; | 547 | return 0; |
547 | } | 548 | } |
549 | EXPORT_SYMBOL_GPL(ide_dma_test_irq); | ||
548 | #else | 550 | #else |
549 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | 551 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } |
550 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 552 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
@@ -574,6 +576,7 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
574 | { | 576 | { |
575 | struct hd_driveid *id = drive->id; | 577 | struct hd_driveid *id = drive->id; |
576 | ide_hwif_t *hwif = drive->hwif; | 578 | ide_hwif_t *hwif = drive->hwif; |
579 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
577 | unsigned int mask = 0; | 580 | unsigned int mask = 0; |
578 | 581 | ||
579 | switch(base) { | 582 | switch(base) { |
@@ -581,8 +584,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
581 | if ((id->field_valid & 4) == 0) | 584 | if ((id->field_valid & 4) == 0) |
582 | break; | 585 | break; |
583 | 586 | ||
584 | if (hwif->udma_filter) | 587 | if (port_ops && port_ops->udma_filter) |
585 | mask = hwif->udma_filter(drive); | 588 | mask = port_ops->udma_filter(drive); |
586 | else | 589 | else |
587 | mask = hwif->ultra_mask; | 590 | mask = hwif->ultra_mask; |
588 | mask &= id->dma_ultra; | 591 | mask &= id->dma_ultra; |
@@ -598,8 +601,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
598 | case XFER_MW_DMA_0: | 601 | case XFER_MW_DMA_0: |
599 | if ((id->field_valid & 2) == 0) | 602 | if ((id->field_valid & 2) == 0) |
600 | break; | 603 | break; |
601 | if (hwif->mdma_filter) | 604 | if (port_ops && port_ops->mdma_filter) |
602 | mask = hwif->mdma_filter(drive); | 605 | mask = port_ops->mdma_filter(drive); |
603 | else | 606 | else |
604 | mask = hwif->mwdma_mask; | 607 | mask = hwif->mwdma_mask; |
605 | mask &= id->dma_mword; | 608 | mask &= id->dma_mword; |
@@ -703,17 +706,8 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
703 | 706 | ||
704 | speed = ide_max_dma_mode(drive); | 707 | speed = ide_max_dma_mode(drive); |
705 | 708 | ||
706 | if (!speed) { | 709 | if (!speed) |
707 | /* is this really correct/needed? */ | 710 | return 0; |
708 | if ((hwif->host_flags & IDE_HFLAG_CY82C693) && | ||
709 | ide_dma_good_drive(drive)) | ||
710 | return 1; | ||
711 | else | ||
712 | return 0; | ||
713 | } | ||
714 | |||
715 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
716 | return 1; | ||
717 | 711 | ||
718 | if (ide_set_dma_mode(drive, speed)) | 712 | if (ide_set_dma_mode(drive, speed)) |
719 | return 0; | 713 | return 0; |
@@ -810,15 +804,15 @@ void ide_dma_timeout (ide_drive_t *drive) | |||
810 | 804 | ||
811 | printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name); | 805 | printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name); |
812 | 806 | ||
813 | if (hwif->ide_dma_test_irq(drive)) | 807 | if (hwif->dma_ops->dma_test_irq(drive)) |
814 | return; | 808 | return; |
815 | 809 | ||
816 | hwif->ide_dma_end(drive); | 810 | hwif->dma_ops->dma_end(drive); |
817 | } | 811 | } |
818 | 812 | ||
819 | EXPORT_SYMBOL(ide_dma_timeout); | 813 | EXPORT_SYMBOL(ide_dma_timeout); |
820 | 814 | ||
821 | static void ide_release_dma_engine(ide_hwif_t *hwif) | 815 | void ide_release_dma_engine(ide_hwif_t *hwif) |
822 | { | 816 | { |
823 | if (hwif->dmatable_cpu) { | 817 | if (hwif->dmatable_cpu) { |
824 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 818 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
@@ -829,28 +823,7 @@ static void ide_release_dma_engine(ide_hwif_t *hwif) | |||
829 | } | 823 | } |
830 | } | 824 | } |
831 | 825 | ||
832 | static int ide_release_iomio_dma(ide_hwif_t *hwif) | 826 | int ide_allocate_dma_engine(ide_hwif_t *hwif) |
833 | { | ||
834 | release_region(hwif->dma_base, 8); | ||
835 | if (hwif->extra_ports) | ||
836 | release_region(hwif->extra_base, hwif->extra_ports); | ||
837 | return 1; | ||
838 | } | ||
839 | |||
840 | /* | ||
841 | * Needed for allowing full modular support of ide-driver | ||
842 | */ | ||
843 | int ide_release_dma(ide_hwif_t *hwif) | ||
844 | { | ||
845 | ide_release_dma_engine(hwif); | ||
846 | |||
847 | if (hwif->mmio) | ||
848 | return 1; | ||
849 | else | ||
850 | return ide_release_iomio_dma(hwif); | ||
851 | } | ||
852 | |||
853 | static int ide_allocate_dma_engine(ide_hwif_t *hwif) | ||
854 | { | 827 | { |
855 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 828 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
856 | 829 | ||
@@ -862,65 +835,25 @@ static int ide_allocate_dma_engine(ide_hwif_t *hwif) | |||
862 | return 0; | 835 | return 0; |
863 | 836 | ||
864 | printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", | 837 | printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", |
865 | hwif->cds->name); | 838 | hwif->name); |
866 | 839 | ||
867 | return 1; | 840 | return 1; |
868 | } | 841 | } |
869 | 842 | EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); | |
870 | static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base) | 843 | |
871 | { | 844 | static const struct ide_dma_ops sff_dma_ops = { |
872 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); | 845 | .dma_host_set = ide_dma_host_set, |
873 | 846 | .dma_setup = ide_dma_setup, | |
874 | return 0; | 847 | .dma_exec_cmd = ide_dma_exec_cmd, |
875 | } | 848 | .dma_start = ide_dma_start, |
876 | 849 | .dma_end = __ide_dma_end, | |
877 | static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base) | 850 | .dma_test_irq = ide_dma_test_irq, |
878 | { | 851 | .dma_timeout = ide_dma_timeout, |
879 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | 852 | .dma_lost_irq = ide_dma_lost_irq, |
880 | hwif->name, base, base + 7); | 853 | }; |
881 | |||
882 | if (!request_region(base, 8, hwif->name)) { | ||
883 | printk(" -- Error, ports in use.\n"); | ||
884 | return 1; | ||
885 | } | ||
886 | |||
887 | if (hwif->cds->extra) { | ||
888 | hwif->extra_base = base + (hwif->channel ? 8 : 16); | ||
889 | |||
890 | if (!hwif->mate || !hwif->mate->extra_ports) { | ||
891 | if (!request_region(hwif->extra_base, | ||
892 | hwif->cds->extra, hwif->cds->name)) { | ||
893 | printk(" -- Error, extra ports in use.\n"); | ||
894 | release_region(base, 8); | ||
895 | return 1; | ||
896 | } | ||
897 | hwif->extra_ports = hwif->cds->extra; | ||
898 | } | ||
899 | } | ||
900 | |||
901 | return 0; | ||
902 | } | ||
903 | |||
904 | static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base) | ||
905 | { | ||
906 | if (hwif->mmio) | ||
907 | return ide_mapped_mmio_dma(hwif, base); | ||
908 | |||
909 | return ide_iomio_dma(hwif, base); | ||
910 | } | ||
911 | 854 | ||
912 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) | 855 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) |
913 | { | 856 | { |
914 | u8 dma_stat; | ||
915 | |||
916 | if (ide_dma_iobase(hwif, base)) | ||
917 | return; | ||
918 | |||
919 | if (ide_allocate_dma_engine(hwif)) { | ||
920 | ide_release_dma(hwif); | ||
921 | return; | ||
922 | } | ||
923 | |||
924 | hwif->dma_base = base; | 857 | hwif->dma_base = base; |
925 | 858 | ||
926 | if (!hwif->dma_command) | 859 | if (!hwif->dma_command) |
@@ -934,27 +867,7 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) | |||
934 | if (!hwif->dma_prdtable) | 867 | if (!hwif->dma_prdtable) |
935 | hwif->dma_prdtable = hwif->dma_base + 4; | 868 | hwif->dma_prdtable = hwif->dma_base + 4; |
936 | 869 | ||
937 | if (!hwif->dma_host_set) | 870 | hwif->dma_ops = &sff_dma_ops; |
938 | hwif->dma_host_set = &ide_dma_host_set; | ||
939 | if (!hwif->dma_setup) | ||
940 | hwif->dma_setup = &ide_dma_setup; | ||
941 | if (!hwif->dma_exec_cmd) | ||
942 | hwif->dma_exec_cmd = &ide_dma_exec_cmd; | ||
943 | if (!hwif->dma_start) | ||
944 | hwif->dma_start = &ide_dma_start; | ||
945 | if (!hwif->ide_dma_end) | ||
946 | hwif->ide_dma_end = &__ide_dma_end; | ||
947 | if (!hwif->ide_dma_test_irq) | ||
948 | hwif->ide_dma_test_irq = &__ide_dma_test_irq; | ||
949 | if (!hwif->dma_timeout) | ||
950 | hwif->dma_timeout = &ide_dma_timeout; | ||
951 | if (!hwif->dma_lost_irq) | ||
952 | hwif->dma_lost_irq = &ide_dma_lost_irq; | ||
953 | |||
954 | dma_stat = hwif->INB(hwif->dma_status); | ||
955 | printk(KERN_CONT ", BIOS settings: %s:%s, %s:%s\n", | ||
956 | hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "PIO", | ||
957 | hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "PIO"); | ||
958 | } | 871 | } |
959 | 872 | ||
960 | EXPORT_SYMBOL_GPL(ide_setup_dma); | 873 | EXPORT_SYMBOL_GPL(ide_setup_dma); |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 5f133dfb541c..489079b8ed03 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -396,7 +396,7 @@ static void idefloppy_retry_pc(ide_drive_t *drive) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | /* The usual interrupt handler called during a packet command. */ | 398 | /* The usual interrupt handler called during a packet command. */ |
399 | static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | 399 | static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) |
400 | { | 400 | { |
401 | idefloppy_floppy_t *floppy = drive->driver_data; | 401 | idefloppy_floppy_t *floppy = drive->driver_data; |
402 | ide_hwif_t *hwif = drive->hwif; | 402 | ide_hwif_t *hwif = drive->hwif; |
@@ -411,7 +411,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
411 | debug_log("Reached %s interrupt handler\n", __func__); | 411 | debug_log("Reached %s interrupt handler\n", __func__); |
412 | 412 | ||
413 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 413 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
414 | dma_error = hwif->ide_dma_end(drive); | 414 | dma_error = hwif->dma_ops->dma_end(drive); |
415 | if (dma_error) { | 415 | if (dma_error) { |
416 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | 416 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, |
417 | rq_data_dir(rq) ? "write" : "read"); | 417 | rq_data_dir(rq) ? "write" : "read"); |
@@ -465,10 +465,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
465 | } | 465 | } |
466 | 466 | ||
467 | /* Get the number of bytes to transfer */ | 467 | /* Get the number of bytes to transfer */ |
468 | bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) | | 468 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | |
469 | hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); | 469 | hwif->INB(hwif->io_ports.lbam_addr); |
470 | /* on this interrupt */ | 470 | /* on this interrupt */ |
471 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); | 471 | ireason = hwif->INB(hwif->io_ports.nsect_addr); |
472 | 472 | ||
473 | if (ireason & CD) { | 473 | if (ireason & CD) { |
474 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); | 474 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); |
@@ -539,7 +539,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) | |||
539 | "initiated yet DRQ isn't asserted\n"); | 539 | "initiated yet DRQ isn't asserted\n"); |
540 | return startstop; | 540 | return startstop; |
541 | } | 541 | } |
542 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); | 542 | ireason = hwif->INB(hwif->io_ports.nsect_addr); |
543 | if ((ireason & CD) == 0 || (ireason & IO)) { | 543 | if ((ireason & CD) == 0 || (ireason & IO)) { |
544 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " | 544 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " |
545 | "issuing a packet command\n"); | 545 | "issuing a packet command\n"); |
@@ -586,7 +586,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) | |||
586 | "initiated yet DRQ isn't asserted\n"); | 586 | "initiated yet DRQ isn't asserted\n"); |
587 | return startstop; | 587 | return startstop; |
588 | } | 588 | } |
589 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); | 589 | ireason = hwif->INB(hwif->io_ports.nsect_addr); |
590 | if ((ireason & CD) == 0 || (ireason & IO)) { | 590 | if ((ireason & CD) == 0 || (ireason & IO)) { |
591 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " | 591 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " |
592 | "while issuing a packet command\n"); | 592 | "while issuing a packet command\n"); |
@@ -663,7 +663,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
663 | dma = 0; | 663 | dma = 0; |
664 | 664 | ||
665 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | 665 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
666 | dma = !hwif->dma_setup(drive); | 666 | dma = !hwif->dma_ops->dma_setup(drive); |
667 | 667 | ||
668 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 668 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
669 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | 669 | IDE_TFLAG_OUT_DEVICE, bcount, dma); |
@@ -671,7 +671,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
671 | if (dma) { | 671 | if (dma) { |
672 | /* Begin DMA, if necessary */ | 672 | /* Begin DMA, if necessary */ |
673 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | 673 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; |
674 | hwif->dma_start(drive); | 674 | hwif->dma_ops->dma_start(drive); |
675 | } | 675 | } |
676 | 676 | ||
677 | /* Can we transfer the packet when we get the interrupt or wait? */ | 677 | /* Can we transfer the packet when we get the interrupt or wait? */ |
@@ -692,7 +692,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
692 | return ide_started; | 692 | return ide_started; |
693 | } else { | 693 | } else { |
694 | /* Issue the packet command */ | 694 | /* Issue the packet command */ |
695 | hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]); | 695 | hwif->OUTB(WIN_PACKETCMD, hwif->io_ports.command_addr); |
696 | return (*pkt_xfer_routine) (drive); | 696 | return (*pkt_xfer_routine) (drive); |
697 | } | 697 | } |
698 | } | 698 | } |
@@ -1596,13 +1596,13 @@ static int idefloppy_revalidate_disk(struct gendisk *disk) | |||
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | static struct block_device_operations idefloppy_ops = { | 1598 | static struct block_device_operations idefloppy_ops = { |
1599 | .owner = THIS_MODULE, | 1599 | .owner = THIS_MODULE, |
1600 | .open = idefloppy_open, | 1600 | .open = idefloppy_open, |
1601 | .release = idefloppy_release, | 1601 | .release = idefloppy_release, |
1602 | .ioctl = idefloppy_ioctl, | 1602 | .ioctl = idefloppy_ioctl, |
1603 | .getgeo = idefloppy_getgeo, | 1603 | .getgeo = idefloppy_getgeo, |
1604 | .media_changed = idefloppy_media_changed, | 1604 | .media_changed = idefloppy_media_changed, |
1605 | .revalidate_disk= idefloppy_revalidate_disk | 1605 | .revalidate_disk = idefloppy_revalidate_disk |
1606 | }; | 1606 | }; |
1607 | 1607 | ||
1608 | static int ide_floppy_probe(ide_drive_t *drive) | 1608 | static int ide_floppy_probe(ide_drive_t *drive) |
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 25fda0a3263f..a6073e248f45 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -33,7 +33,7 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n) | |||
33 | if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) | 33 | if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) |
34 | return -EINVAL; | 34 | return -EINVAL; |
35 | 35 | ||
36 | hwif = ide_find_port(base); | 36 | hwif = ide_find_port(); |
37 | if (hwif == NULL) | 37 | if (hwif == NULL) |
38 | return -ENOENT; | 38 | return -ENOENT; |
39 | 39 | ||
@@ -90,19 +90,45 @@ static int __init ide_generic_init(void) | |||
90 | int i; | 90 | int i; |
91 | 91 | ||
92 | for (i = 0; i < MAX_HWIFS; i++) { | 92 | for (i = 0; i < MAX_HWIFS; i++) { |
93 | ide_hwif_t *hwif = &ide_hwifs[i]; | 93 | ide_hwif_t *hwif; |
94 | unsigned long io_addr = ide_default_io_base(i); | 94 | unsigned long io_addr = ide_default_io_base(i); |
95 | hw_regs_t hw; | 95 | hw_regs_t hw; |
96 | 96 | ||
97 | if (hwif->chipset == ide_unknown && io_addr) { | 97 | idx[i] = 0xff; |
98 | |||
99 | if (io_addr) { | ||
100 | if (!request_region(io_addr, 8, DRV_NAME)) { | ||
101 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " | ||
102 | "not free.\n", | ||
103 | DRV_NAME, io_addr, io_addr + 7); | ||
104 | continue; | ||
105 | } | ||
106 | |||
107 | if (!request_region(io_addr + 0x206, 1, DRV_NAME)) { | ||
108 | printk(KERN_ERR "%s: I/O resource 0x%lX " | ||
109 | "not free.\n", | ||
110 | DRV_NAME, io_addr + 0x206); | ||
111 | release_region(io_addr, 8); | ||
112 | continue; | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * Skip probing if the corresponding | ||
117 | * slot is already occupied. | ||
118 | */ | ||
119 | hwif = ide_find_port(); | ||
120 | if (hwif == NULL || hwif->index != i) { | ||
121 | idx[i] = 0xff; | ||
122 | continue; | ||
123 | } | ||
124 | |||
98 | memset(&hw, 0, sizeof(hw)); | 125 | memset(&hw, 0, sizeof(hw)); |
99 | ide_std_init_ports(&hw, io_addr, io_addr + 0x206); | 126 | ide_std_init_ports(&hw, io_addr, io_addr + 0x206); |
100 | hw.irq = ide_default_irq(io_addr); | 127 | hw.irq = ide_default_irq(io_addr); |
101 | ide_init_port_hw(hwif, &hw); | 128 | ide_init_port_hw(hwif, &hw); |
102 | 129 | ||
103 | idx[i] = i; | 130 | idx[i] = i; |
104 | } else | 131 | } |
105 | idx[i] = 0xff; | ||
106 | } | 132 | } |
107 | 133 | ||
108 | ide_device_add_all(idx, NULL); | 134 | ide_device_add_all(idx, NULL); |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 31e5afadb7e9..3a2d8930d17f 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -218,7 +218,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * | |||
218 | * we could be smarter and check for current xfer_speed | 218 | * we could be smarter and check for current xfer_speed |
219 | * in struct drive etc... | 219 | * in struct drive etc... |
220 | */ | 220 | */ |
221 | if (drive->hwif->dma_host_set == NULL) | 221 | if (drive->hwif->dma_ops == NULL) |
222 | break; | 222 | break; |
223 | /* | 223 | /* |
224 | * TODO: respect ->using_dma setting | 224 | * TODO: respect ->using_dma setting |
@@ -298,48 +298,43 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq) | |||
298 | void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | 298 | void ide_tf_read(ide_drive_t *drive, ide_task_t *task) |
299 | { | 299 | { |
300 | ide_hwif_t *hwif = drive->hwif; | 300 | ide_hwif_t *hwif = drive->hwif; |
301 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
301 | struct ide_taskfile *tf = &task->tf; | 302 | struct ide_taskfile *tf = &task->tf; |
302 | 303 | ||
303 | if (task->tf_flags & IDE_TFLAG_IN_DATA) { | 304 | if (task->tf_flags & IDE_TFLAG_IN_DATA) { |
304 | u16 data = hwif->INW(hwif->io_ports[IDE_DATA_OFFSET]); | 305 | u16 data = hwif->INW(io_ports->data_addr); |
305 | 306 | ||
306 | tf->data = data & 0xff; | 307 | tf->data = data & 0xff; |
307 | tf->hob_data = (data >> 8) & 0xff; | 308 | tf->hob_data = (data >> 8) & 0xff; |
308 | } | 309 | } |
309 | 310 | ||
310 | /* be sure we're looking at the low order bits */ | 311 | /* be sure we're looking at the low order bits */ |
311 | hwif->OUTB(drive->ctl & ~0x80, hwif->io_ports[IDE_CONTROL_OFFSET]); | 312 | hwif->OUTB(drive->ctl & ~0x80, io_ports->ctl_addr); |
312 | 313 | ||
313 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 314 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
314 | tf->nsect = hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]); | 315 | tf->nsect = hwif->INB(io_ports->nsect_addr); |
315 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | 316 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) |
316 | tf->lbal = hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]); | 317 | tf->lbal = hwif->INB(io_ports->lbal_addr); |
317 | if (task->tf_flags & IDE_TFLAG_IN_LBAM) | 318 | if (task->tf_flags & IDE_TFLAG_IN_LBAM) |
318 | tf->lbam = hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]); | 319 | tf->lbam = hwif->INB(io_ports->lbam_addr); |
319 | if (task->tf_flags & IDE_TFLAG_IN_LBAH) | 320 | if (task->tf_flags & IDE_TFLAG_IN_LBAH) |
320 | tf->lbah = hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]); | 321 | tf->lbah = hwif->INB(io_ports->lbah_addr); |
321 | if (task->tf_flags & IDE_TFLAG_IN_DEVICE) | 322 | if (task->tf_flags & IDE_TFLAG_IN_DEVICE) |
322 | tf->device = hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]); | 323 | tf->device = hwif->INB(io_ports->device_addr); |
323 | 324 | ||
324 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 325 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
325 | hwif->OUTB(drive->ctl | 0x80, | 326 | hwif->OUTB(drive->ctl | 0x80, io_ports->ctl_addr); |
326 | hwif->io_ports[IDE_CONTROL_OFFSET]); | ||
327 | 327 | ||
328 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 328 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
329 | tf->hob_feature = | 329 | tf->hob_feature = hwif->INB(io_ports->feature_addr); |
330 | hwif->INB(hwif->io_ports[IDE_FEATURE_OFFSET]); | ||
331 | if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) | 330 | if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) |
332 | tf->hob_nsect = | 331 | tf->hob_nsect = hwif->INB(io_ports->nsect_addr); |
333 | hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]); | ||
334 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) | 332 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) |
335 | tf->hob_lbal = | 333 | tf->hob_lbal = hwif->INB(io_ports->lbal_addr); |
336 | hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]); | ||
337 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) | 334 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) |
338 | tf->hob_lbam = | 335 | tf->hob_lbam = hwif->INB(io_ports->lbam_addr); |
339 | hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]); | ||
340 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) | 336 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) |
341 | tf->hob_lbah = | 337 | tf->hob_lbah = hwif->INB(io_ports->lbah_addr); |
342 | hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]); | ||
343 | } | 338 | } |
344 | } | 339 | } |
345 | 340 | ||
@@ -454,7 +449,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
454 | if (err == ABRT_ERR) { | 449 | if (err == ABRT_ERR) { |
455 | if (drive->select.b.lba && | 450 | if (drive->select.b.lba && |
456 | /* some newer drives don't support WIN_SPECIFY */ | 451 | /* some newer drives don't support WIN_SPECIFY */ |
457 | hwif->INB(hwif->io_ports[IDE_COMMAND_OFFSET]) == | 452 | hwif->INB(hwif->io_ports.command_addr) == |
458 | WIN_SPECIFY) | 453 | WIN_SPECIFY) |
459 | return ide_stopped; | 454 | return ide_stopped; |
460 | } else if ((err & BAD_CRC) == BAD_CRC) { | 455 | } else if ((err & BAD_CRC) == BAD_CRC) { |
@@ -507,8 +502,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u | |||
507 | 502 | ||
508 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) | 503 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) |
509 | /* force an abort */ | 504 | /* force an abort */ |
510 | hwif->OUTB(WIN_IDLEIMMEDIATE, | 505 | hwif->OUTB(WIN_IDLEIMMEDIATE, hwif->io_ports.command_addr); |
511 | hwif->io_ports[IDE_COMMAND_OFFSET]); | ||
512 | 506 | ||
513 | if (rq->errors >= ERROR_MAX) { | 507 | if (rq->errors >= ERROR_MAX) { |
514 | ide_kill_rq(drive, rq); | 508 | ide_kill_rq(drive, rq); |
@@ -721,15 +715,12 @@ static ide_startstop_t do_special (ide_drive_t *drive) | |||
721 | #endif | 715 | #endif |
722 | if (s->b.set_tune) { | 716 | if (s->b.set_tune) { |
723 | ide_hwif_t *hwif = drive->hwif; | 717 | ide_hwif_t *hwif = drive->hwif; |
718 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
724 | u8 req_pio = drive->tune_req; | 719 | u8 req_pio = drive->tune_req; |
725 | 720 | ||
726 | s->b.set_tune = 0; | 721 | s->b.set_tune = 0; |
727 | 722 | ||
728 | if (set_pio_mode_abuse(drive->hwif, req_pio)) { | 723 | if (set_pio_mode_abuse(drive->hwif, req_pio)) { |
729 | |||
730 | if (hwif->set_pio_mode == NULL) | ||
731 | return ide_stopped; | ||
732 | |||
733 | /* | 724 | /* |
734 | * take ide_lock for drive->[no_]unmask/[no_]io_32bit | 725 | * take ide_lock for drive->[no_]unmask/[no_]io_32bit |
735 | */ | 726 | */ |
@@ -737,10 +728,10 @@ static ide_startstop_t do_special (ide_drive_t *drive) | |||
737 | unsigned long flags; | 728 | unsigned long flags; |
738 | 729 | ||
739 | spin_lock_irqsave(&ide_lock, flags); | 730 | spin_lock_irqsave(&ide_lock, flags); |
740 | hwif->set_pio_mode(drive, req_pio); | 731 | port_ops->set_pio_mode(drive, req_pio); |
741 | spin_unlock_irqrestore(&ide_lock, flags); | 732 | spin_unlock_irqrestore(&ide_lock, flags); |
742 | } else | 733 | } else |
743 | hwif->set_pio_mode(drive, req_pio); | 734 | port_ops->set_pio_mode(drive, req_pio); |
744 | } else { | 735 | } else { |
745 | int keep_dma = drive->using_dma; | 736 | int keep_dma = drive->using_dma; |
746 | 737 | ||
@@ -1241,12 +1232,12 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | |||
1241 | 1232 | ||
1242 | if (error < 0) { | 1233 | if (error < 0) { |
1243 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); | 1234 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); |
1244 | (void)HWIF(drive)->ide_dma_end(drive); | 1235 | (void)hwif->dma_ops->dma_end(drive); |
1245 | ret = ide_error(drive, "dma timeout error", | 1236 | ret = ide_error(drive, "dma timeout error", |
1246 | ide_read_status(drive)); | 1237 | ide_read_status(drive)); |
1247 | } else { | 1238 | } else { |
1248 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); | 1239 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); |
1249 | hwif->dma_timeout(drive); | 1240 | hwif->dma_ops->dma_timeout(drive); |
1250 | } | 1241 | } |
1251 | 1242 | ||
1252 | /* | 1243 | /* |
@@ -1358,7 +1349,7 @@ void ide_timer_expiry (unsigned long data) | |||
1358 | startstop = handler(drive); | 1349 | startstop = handler(drive); |
1359 | } else if (drive_is_ready(drive)) { | 1350 | } else if (drive_is_ready(drive)) { |
1360 | if (drive->waiting_for_dma) | 1351 | if (drive->waiting_for_dma) |
1361 | hwgroup->hwif->dma_lost_irq(drive); | 1352 | hwif->dma_ops->dma_lost_irq(drive); |
1362 | (void)ide_ack_intr(hwif); | 1353 | (void)ide_ack_intr(hwif); |
1363 | printk(KERN_WARNING "%s: lost interrupt\n", drive->name); | 1354 | printk(KERN_WARNING "%s: lost interrupt\n", drive->name); |
1364 | startstop = handler(drive); | 1355 | startstop = handler(drive); |
@@ -1424,7 +1415,7 @@ static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup) | |||
1424 | */ | 1415 | */ |
1425 | do { | 1416 | do { |
1426 | if (hwif->irq == irq) { | 1417 | if (hwif->irq == irq) { |
1427 | stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 1418 | stat = hwif->INB(hwif->io_ports.status_addr); |
1428 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) { | 1419 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) { |
1429 | /* Try to not flood the console with msgs */ | 1420 | /* Try to not flood the console with msgs */ |
1430 | static unsigned long last_msgtime, count; | 1421 | static unsigned long last_msgtime, count; |
@@ -1514,7 +1505,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1514 | * Whack the status register, just in case | 1505 | * Whack the status register, just in case |
1515 | * we have a leftover pending IRQ. | 1506 | * we have a leftover pending IRQ. |
1516 | */ | 1507 | */ |
1517 | (void) hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 1508 | (void) hwif->INB(hwif->io_ports.status_addr); |
1518 | #endif /* CONFIG_BLK_DEV_IDEPCI */ | 1509 | #endif /* CONFIG_BLK_DEV_IDEPCI */ |
1519 | } | 1510 | } |
1520 | spin_unlock_irqrestore(&ide_lock, flags); | 1511 | spin_unlock_irqrestore(&ide_lock, flags); |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 45944219eea0..5425d3038ec2 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -159,17 +159,20 @@ EXPORT_SYMBOL(default_hwif_mmiops); | |||
159 | void SELECT_DRIVE (ide_drive_t *drive) | 159 | void SELECT_DRIVE (ide_drive_t *drive) |
160 | { | 160 | { |
161 | ide_hwif_t *hwif = drive->hwif; | 161 | ide_hwif_t *hwif = drive->hwif; |
162 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
162 | 163 | ||
163 | if (hwif->selectproc) | 164 | if (port_ops && port_ops->selectproc) |
164 | hwif->selectproc(drive); | 165 | port_ops->selectproc(drive); |
165 | 166 | ||
166 | hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); | 167 | hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); |
167 | } | 168 | } |
168 | 169 | ||
169 | void SELECT_MASK (ide_drive_t *drive, int mask) | 170 | void SELECT_MASK (ide_drive_t *drive, int mask) |
170 | { | 171 | { |
171 | if (HWIF(drive)->maskproc) | 172 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; |
172 | HWIF(drive)->maskproc(drive, mask); | 173 | |
174 | if (port_ops && port_ops->maskproc) | ||
175 | port_ops->maskproc(drive, mask); | ||
173 | } | 176 | } |
174 | 177 | ||
175 | /* | 178 | /* |
@@ -191,24 +194,22 @@ static void ata_vlb_sync(ide_drive_t *drive, unsigned long port) | |||
191 | */ | 194 | */ |
192 | static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount) | 195 | static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount) |
193 | { | 196 | { |
194 | ide_hwif_t *hwif = HWIF(drive); | 197 | ide_hwif_t *hwif = drive->hwif; |
195 | u8 io_32bit = drive->io_32bit; | 198 | struct ide_io_ports *io_ports = &hwif->io_ports; |
199 | u8 io_32bit = drive->io_32bit; | ||
196 | 200 | ||
197 | if (io_32bit) { | 201 | if (io_32bit) { |
198 | if (io_32bit & 2) { | 202 | if (io_32bit & 2) { |
199 | unsigned long flags; | 203 | unsigned long flags; |
200 | 204 | ||
201 | local_irq_save(flags); | 205 | local_irq_save(flags); |
202 | ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]); | 206 | ata_vlb_sync(drive, io_ports->nsect_addr); |
203 | hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 207 | hwif->INSL(io_ports->data_addr, buffer, wcount); |
204 | wcount); | ||
205 | local_irq_restore(flags); | 208 | local_irq_restore(flags); |
206 | } else | 209 | } else |
207 | hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 210 | hwif->INSL(io_ports->data_addr, buffer, wcount); |
208 | wcount); | ||
209 | } else | 211 | } else |
210 | hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 212 | hwif->INSW(io_ports->data_addr, buffer, wcount << 1); |
211 | wcount << 1); | ||
212 | } | 213 | } |
213 | 214 | ||
214 | /* | 215 | /* |
@@ -216,24 +217,22 @@ static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount) | |||
216 | */ | 217 | */ |
217 | static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount) | 218 | static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount) |
218 | { | 219 | { |
219 | ide_hwif_t *hwif = HWIF(drive); | 220 | ide_hwif_t *hwif = drive->hwif; |
220 | u8 io_32bit = drive->io_32bit; | 221 | struct ide_io_ports *io_ports = &hwif->io_ports; |
222 | u8 io_32bit = drive->io_32bit; | ||
221 | 223 | ||
222 | if (io_32bit) { | 224 | if (io_32bit) { |
223 | if (io_32bit & 2) { | 225 | if (io_32bit & 2) { |
224 | unsigned long flags; | 226 | unsigned long flags; |
225 | 227 | ||
226 | local_irq_save(flags); | 228 | local_irq_save(flags); |
227 | ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]); | 229 | ata_vlb_sync(drive, io_ports->nsect_addr); |
228 | hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 230 | hwif->OUTSL(io_ports->data_addr, buffer, wcount); |
229 | wcount); | ||
230 | local_irq_restore(flags); | 231 | local_irq_restore(flags); |
231 | } else | 232 | } else |
232 | hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 233 | hwif->OUTSL(io_ports->data_addr, buffer, wcount); |
233 | wcount); | ||
234 | } else | 234 | } else |
235 | hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 235 | hwif->OUTSW(io_ports->data_addr, buffer, wcount << 1); |
236 | wcount << 1); | ||
237 | } | 236 | } |
238 | 237 | ||
239 | /* | 238 | /* |
@@ -252,14 +251,13 @@ static void atapi_input_bytes(ide_drive_t *drive, void *buffer, u32 bytecount) | |||
252 | #if defined(CONFIG_ATARI) || defined(CONFIG_Q40) | 251 | #if defined(CONFIG_ATARI) || defined(CONFIG_Q40) |
253 | if (MACH_IS_ATARI || MACH_IS_Q40) { | 252 | if (MACH_IS_ATARI || MACH_IS_Q40) { |
254 | /* Atari has a byte-swapped IDE interface */ | 253 | /* Atari has a byte-swapped IDE interface */ |
255 | insw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 254 | insw_swapw(hwif->io_ports.data_addr, buffer, bytecount / 2); |
256 | bytecount / 2); | ||
257 | return; | 255 | return; |
258 | } | 256 | } |
259 | #endif /* CONFIG_ATARI || CONFIG_Q40 */ | 257 | #endif /* CONFIG_ATARI || CONFIG_Q40 */ |
260 | hwif->ata_input_data(drive, buffer, bytecount / 4); | 258 | hwif->ata_input_data(drive, buffer, bytecount / 4); |
261 | if ((bytecount & 0x03) >= 2) | 259 | if ((bytecount & 0x03) >= 2) |
262 | hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], | 260 | hwif->INSW(hwif->io_ports.data_addr, |
263 | (u8 *)buffer + (bytecount & ~0x03), 1); | 261 | (u8 *)buffer + (bytecount & ~0x03), 1); |
264 | } | 262 | } |
265 | 263 | ||
@@ -271,14 +269,13 @@ static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount) | |||
271 | #if defined(CONFIG_ATARI) || defined(CONFIG_Q40) | 269 | #if defined(CONFIG_ATARI) || defined(CONFIG_Q40) |
272 | if (MACH_IS_ATARI || MACH_IS_Q40) { | 270 | if (MACH_IS_ATARI || MACH_IS_Q40) { |
273 | /* Atari has a byte-swapped IDE interface */ | 271 | /* Atari has a byte-swapped IDE interface */ |
274 | outsw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer, | 272 | outsw_swapw(hwif->io_ports.data_addr, buffer, bytecount / 2); |
275 | bytecount / 2); | ||
276 | return; | 273 | return; |
277 | } | 274 | } |
278 | #endif /* CONFIG_ATARI || CONFIG_Q40 */ | 275 | #endif /* CONFIG_ATARI || CONFIG_Q40 */ |
279 | hwif->ata_output_data(drive, buffer, bytecount / 4); | 276 | hwif->ata_output_data(drive, buffer, bytecount / 4); |
280 | if ((bytecount & 0x03) >= 2) | 277 | if ((bytecount & 0x03) >= 2) |
281 | hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], | 278 | hwif->OUTSW(hwif->io_ports.data_addr, |
282 | (u8 *)buffer + (bytecount & ~0x03), 1); | 279 | (u8 *)buffer + (bytecount & ~0x03), 1); |
283 | } | 280 | } |
284 | 281 | ||
@@ -429,7 +426,7 @@ int drive_is_ready (ide_drive_t *drive) | |||
429 | u8 stat = 0; | 426 | u8 stat = 0; |
430 | 427 | ||
431 | if (drive->waiting_for_dma) | 428 | if (drive->waiting_for_dma) |
432 | return hwif->ide_dma_test_irq(drive); | 429 | return hwif->dma_ops->dma_test_irq(drive); |
433 | 430 | ||
434 | #if 0 | 431 | #if 0 |
435 | /* need to guarantee 400ns since last command was issued */ | 432 | /* need to guarantee 400ns since last command was issued */ |
@@ -442,7 +439,7 @@ int drive_is_ready (ide_drive_t *drive) | |||
442 | * an interrupt with another pci card/device. We make no assumptions | 439 | * an interrupt with another pci card/device. We make no assumptions |
443 | * about possible isa-pnp and pci-pnp issues yet. | 440 | * about possible isa-pnp and pci-pnp issues yet. |
444 | */ | 441 | */ |
445 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) | 442 | if (hwif->io_ports.ctl_addr) |
446 | stat = ide_read_altstatus(drive); | 443 | stat = ide_read_altstatus(drive); |
447 | else | 444 | else |
448 | /* Note: this may clear a pending IRQ!! */ | 445 | /* Note: this may clear a pending IRQ!! */ |
@@ -644,7 +641,7 @@ int ide_driveid_update(ide_drive_t *drive) | |||
644 | SELECT_MASK(drive, 1); | 641 | SELECT_MASK(drive, 1); |
645 | ide_set_irq(drive, 1); | 642 | ide_set_irq(drive, 1); |
646 | msleep(50); | 643 | msleep(50); |
647 | hwif->OUTB(WIN_IDENTIFY, hwif->io_ports[IDE_COMMAND_OFFSET]); | 644 | hwif->OUTB(WIN_IDENTIFY, hwif->io_ports.command_addr); |
648 | timeout = jiffies + WAIT_WORSTCASE; | 645 | timeout = jiffies + WAIT_WORSTCASE; |
649 | do { | 646 | do { |
650 | if (time_after(jiffies, timeout)) { | 647 | if (time_after(jiffies, timeout)) { |
@@ -693,6 +690,7 @@ int ide_driveid_update(ide_drive_t *drive) | |||
693 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | 690 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) |
694 | { | 691 | { |
695 | ide_hwif_t *hwif = drive->hwif; | 692 | ide_hwif_t *hwif = drive->hwif; |
693 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
696 | int error = 0; | 694 | int error = 0; |
697 | u8 stat; | 695 | u8 stat; |
698 | 696 | ||
@@ -700,8 +698,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
700 | // msleep(50); | 698 | // msleep(50); |
701 | 699 | ||
702 | #ifdef CONFIG_BLK_DEV_IDEDMA | 700 | #ifdef CONFIG_BLK_DEV_IDEDMA |
703 | if (hwif->dma_host_set) /* check if host supports DMA */ | 701 | if (hwif->dma_ops) /* check if host supports DMA */ |
704 | hwif->dma_host_set(drive, 0); | 702 | hwif->dma_ops->dma_host_set(drive, 0); |
705 | #endif | 703 | #endif |
706 | 704 | ||
707 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ | 705 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ |
@@ -731,10 +729,9 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
731 | SELECT_MASK(drive, 0); | 729 | SELECT_MASK(drive, 0); |
732 | udelay(1); | 730 | udelay(1); |
733 | ide_set_irq(drive, 0); | 731 | ide_set_irq(drive, 0); |
734 | hwif->OUTB(speed, hwif->io_ports[IDE_NSECTOR_OFFSET]); | 732 | hwif->OUTB(speed, io_ports->nsect_addr); |
735 | hwif->OUTB(SETFEATURES_XFER, hwif->io_ports[IDE_FEATURE_OFFSET]); | 733 | hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); |
736 | hwif->OUTBSYNC(drive, WIN_SETFEATURES, | 734 | hwif->OUTBSYNC(drive, WIN_SETFEATURES, io_ports->command_addr); |
737 | hwif->io_ports[IDE_COMMAND_OFFSET]); | ||
738 | if (drive->quirk_list == 2) | 735 | if (drive->quirk_list == 2) |
739 | ide_set_irq(drive, 1); | 736 | ide_set_irq(drive, 1); |
740 | 737 | ||
@@ -759,8 +756,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
759 | #ifdef CONFIG_BLK_DEV_IDEDMA | 756 | #ifdef CONFIG_BLK_DEV_IDEDMA |
760 | if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && | 757 | if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && |
761 | drive->using_dma) | 758 | drive->using_dma) |
762 | hwif->dma_host_set(drive, 1); | 759 | hwif->dma_ops->dma_host_set(drive, 1); |
763 | else if (hwif->dma_host_set) /* check if host supports DMA */ | 760 | else if (hwif->dma_ops) /* check if host supports DMA */ |
764 | ide_dma_off_quietly(drive); | 761 | ide_dma_off_quietly(drive); |
765 | #endif | 762 | #endif |
766 | 763 | ||
@@ -842,7 +839,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
842 | 839 | ||
843 | spin_lock_irqsave(&ide_lock, flags); | 840 | spin_lock_irqsave(&ide_lock, flags); |
844 | __ide_set_handler(drive, handler, timeout, expiry); | 841 | __ide_set_handler(drive, handler, timeout, expiry); |
845 | hwif->OUTBSYNC(drive, cmd, hwif->io_ports[IDE_COMMAND_OFFSET]); | 842 | hwif->OUTBSYNC(drive, cmd, hwif->io_ports.command_addr); |
846 | /* | 843 | /* |
847 | * Drive takes 400nS to respond, we must avoid the IRQ being | 844 | * Drive takes 400nS to respond, we must avoid the IRQ being |
848 | * serviced before that. | 845 | * serviced before that. |
@@ -905,10 +902,11 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
905 | { | 902 | { |
906 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 903 | ide_hwgroup_t *hwgroup = HWGROUP(drive); |
907 | ide_hwif_t *hwif = HWIF(drive); | 904 | ide_hwif_t *hwif = HWIF(drive); |
905 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
908 | u8 tmp; | 906 | u8 tmp; |
909 | 907 | ||
910 | if (hwif->reset_poll != NULL) { | 908 | if (port_ops && port_ops->reset_poll) { |
911 | if (hwif->reset_poll(drive)) { | 909 | if (port_ops->reset_poll(drive)) { |
912 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", | 910 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", |
913 | hwif->name, drive->name); | 911 | hwif->name, drive->name); |
914 | return ide_stopped; | 912 | return ide_stopped; |
@@ -974,6 +972,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive) | |||
974 | 972 | ||
975 | static void pre_reset(ide_drive_t *drive) | 973 | static void pre_reset(ide_drive_t *drive) |
976 | { | 974 | { |
975 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; | ||
976 | |||
977 | if (drive->media == ide_disk) | 977 | if (drive->media == ide_disk) |
978 | ide_disk_pre_reset(drive); | 978 | ide_disk_pre_reset(drive); |
979 | else | 979 | else |
@@ -994,8 +994,8 @@ static void pre_reset(ide_drive_t *drive) | |||
994 | return; | 994 | return; |
995 | } | 995 | } |
996 | 996 | ||
997 | if (HWIF(drive)->pre_reset != NULL) | 997 | if (port_ops && port_ops->pre_reset) |
998 | HWIF(drive)->pre_reset(drive); | 998 | port_ops->pre_reset(drive); |
999 | 999 | ||
1000 | if (drive->current_speed != 0xff) | 1000 | if (drive->current_speed != 0xff) |
1001 | drive->desired_speed = drive->current_speed; | 1001 | drive->desired_speed = drive->current_speed; |
@@ -1023,12 +1023,16 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1023 | unsigned long flags; | 1023 | unsigned long flags; |
1024 | ide_hwif_t *hwif; | 1024 | ide_hwif_t *hwif; |
1025 | ide_hwgroup_t *hwgroup; | 1025 | ide_hwgroup_t *hwgroup; |
1026 | struct ide_io_ports *io_ports; | ||
1027 | const struct ide_port_ops *port_ops; | ||
1026 | u8 ctl; | 1028 | u8 ctl; |
1027 | 1029 | ||
1028 | spin_lock_irqsave(&ide_lock, flags); | 1030 | spin_lock_irqsave(&ide_lock, flags); |
1029 | hwif = HWIF(drive); | 1031 | hwif = HWIF(drive); |
1030 | hwgroup = HWGROUP(drive); | 1032 | hwgroup = HWGROUP(drive); |
1031 | 1033 | ||
1034 | io_ports = &hwif->io_ports; | ||
1035 | |||
1032 | /* We must not reset with running handlers */ | 1036 | /* We must not reset with running handlers */ |
1033 | BUG_ON(hwgroup->handler != NULL); | 1037 | BUG_ON(hwgroup->handler != NULL); |
1034 | 1038 | ||
@@ -1038,8 +1042,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1038 | pre_reset(drive); | 1042 | pre_reset(drive); |
1039 | SELECT_DRIVE(drive); | 1043 | SELECT_DRIVE(drive); |
1040 | udelay (20); | 1044 | udelay (20); |
1041 | hwif->OUTBSYNC(drive, WIN_SRST, | 1045 | hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); |
1042 | hwif->io_ports[IDE_COMMAND_OFFSET]); | ||
1043 | ndelay(400); | 1046 | ndelay(400); |
1044 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1047 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
1045 | hwgroup->polling = 1; | 1048 | hwgroup->polling = 1; |
@@ -1055,7 +1058,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1055 | for (unit = 0; unit < MAX_DRIVES; ++unit) | 1058 | for (unit = 0; unit < MAX_DRIVES; ++unit) |
1056 | pre_reset(&hwif->drives[unit]); | 1059 | pre_reset(&hwif->drives[unit]); |
1057 | 1060 | ||
1058 | if (hwif->io_ports[IDE_CONTROL_OFFSET] == 0) { | 1061 | if (io_ports->ctl_addr == 0) { |
1059 | spin_unlock_irqrestore(&ide_lock, flags); | 1062 | spin_unlock_irqrestore(&ide_lock, flags); |
1060 | return ide_stopped; | 1063 | return ide_stopped; |
1061 | } | 1064 | } |
@@ -1070,14 +1073,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1070 | * recover from reset very quickly, saving us the first 50ms wait time. | 1073 | * recover from reset very quickly, saving us the first 50ms wait time. |
1071 | */ | 1074 | */ |
1072 | /* set SRST and nIEN */ | 1075 | /* set SRST and nIEN */ |
1073 | hwif->OUTBSYNC(drive, drive->ctl|6, hwif->io_ports[IDE_CONTROL_OFFSET]); | 1076 | hwif->OUTBSYNC(drive, drive->ctl|6, io_ports->ctl_addr); |
1074 | /* more than enough time */ | 1077 | /* more than enough time */ |
1075 | udelay(10); | 1078 | udelay(10); |
1076 | if (drive->quirk_list == 2) | 1079 | if (drive->quirk_list == 2) |
1077 | ctl = drive->ctl; /* clear SRST and nIEN */ | 1080 | ctl = drive->ctl; /* clear SRST and nIEN */ |
1078 | else | 1081 | else |
1079 | ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ | 1082 | ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ |
1080 | hwif->OUTBSYNC(drive, ctl, hwif->io_ports[IDE_CONTROL_OFFSET]); | 1083 | hwif->OUTBSYNC(drive, ctl, io_ports->ctl_addr); |
1081 | /* more than enough time */ | 1084 | /* more than enough time */ |
1082 | udelay(10); | 1085 | udelay(10); |
1083 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1086 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
@@ -1089,8 +1092,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1089 | * state when the disks are reset this way. At least, the Winbond | 1092 | * state when the disks are reset this way. At least, the Winbond |
1090 | * 553 documentation says that | 1093 | * 553 documentation says that |
1091 | */ | 1094 | */ |
1092 | if (hwif->resetproc) | 1095 | port_ops = hwif->port_ops; |
1093 | hwif->resetproc(drive); | 1096 | if (port_ops && port_ops->resetproc) |
1097 | port_ops->resetproc(drive); | ||
1094 | 1098 | ||
1095 | spin_unlock_irqrestore(&ide_lock, flags); | 1099 | spin_unlock_irqrestore(&ide_lock, flags); |
1096 | return ide_started; | 1100 | return ide_started; |
@@ -1121,7 +1125,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) | |||
1121 | * about locking issues (2.5 work ?). | 1125 | * about locking issues (2.5 work ?). |
1122 | */ | 1126 | */ |
1123 | mdelay(1); | 1127 | mdelay(1); |
1124 | stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 1128 | stat = hwif->INB(hwif->io_ports.status_addr); |
1125 | if ((stat & BUSY_STAT) == 0) | 1129 | if ((stat & BUSY_STAT) == 0) |
1126 | return 0; | 1130 | return 0; |
1127 | /* | 1131 | /* |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 7031a8dcf692..6f04ea3e93a8 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -85,7 +85,7 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed) | |||
85 | mode = XFER_PIO_4; | 85 | mode = XFER_PIO_4; |
86 | } | 86 | } |
87 | 87 | ||
88 | // printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); | 88 | /* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */ |
89 | 89 | ||
90 | return min(speed, mode); | 90 | return min(speed, mode); |
91 | } | 91 | } |
@@ -274,16 +274,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode) | |||
274 | if (overridden) | 274 | if (overridden) |
275 | printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n", | 275 | printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n", |
276 | drive->name); | 276 | drive->name); |
277 | |||
278 | /* | ||
279 | * Conservative "downgrade" for all pre-ATA2 drives | ||
280 | */ | ||
281 | if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 && | ||
282 | pio_mode && pio_mode < 4) { | ||
283 | pio_mode--; | ||
284 | printk(KERN_INFO "%s: applying conservative " | ||
285 | "PIO \"downgrade\"\n", drive->name); | ||
286 | } | ||
287 | } | 277 | } |
288 | 278 | ||
289 | if (pio_mode > max_mode) | 279 | if (pio_mode > max_mode) |
@@ -298,9 +288,11 @@ EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); | |||
298 | void ide_set_pio(ide_drive_t *drive, u8 req_pio) | 288 | void ide_set_pio(ide_drive_t *drive, u8 req_pio) |
299 | { | 289 | { |
300 | ide_hwif_t *hwif = drive->hwif; | 290 | ide_hwif_t *hwif = drive->hwif; |
291 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
301 | u8 host_pio, pio; | 292 | u8 host_pio, pio; |
302 | 293 | ||
303 | if (hwif->set_pio_mode == NULL) | 294 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || |
295 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
304 | return; | 296 | return; |
305 | 297 | ||
306 | BUG_ON(hwif->pio_mask == 0x00); | 298 | BUG_ON(hwif->pio_mask == 0x00); |
@@ -352,26 +344,30 @@ void ide_toggle_bounce(ide_drive_t *drive, int on) | |||
352 | int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | 344 | int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) |
353 | { | 345 | { |
354 | ide_hwif_t *hwif = drive->hwif; | 346 | ide_hwif_t *hwif = drive->hwif; |
347 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
348 | |||
349 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
350 | return 0; | ||
355 | 351 | ||
356 | if (hwif->set_pio_mode == NULL) | 352 | if (port_ops == NULL || port_ops->set_pio_mode == NULL) |
357 | return -1; | 353 | return -1; |
358 | 354 | ||
359 | /* | 355 | /* |
360 | * TODO: temporary hack for some legacy host drivers that didn't | 356 | * TODO: temporary hack for some legacy host drivers that didn't |
361 | * set transfer mode on the device in ->set_pio_mode method... | 357 | * set transfer mode on the device in ->set_pio_mode method... |
362 | */ | 358 | */ |
363 | if (hwif->set_dma_mode == NULL) { | 359 | if (port_ops->set_dma_mode == NULL) { |
364 | hwif->set_pio_mode(drive, mode - XFER_PIO_0); | 360 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); |
365 | return 0; | 361 | return 0; |
366 | } | 362 | } |
367 | 363 | ||
368 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | 364 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { |
369 | if (ide_config_drive_speed(drive, mode)) | 365 | if (ide_config_drive_speed(drive, mode)) |
370 | return -1; | 366 | return -1; |
371 | hwif->set_pio_mode(drive, mode - XFER_PIO_0); | 367 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); |
372 | return 0; | 368 | return 0; |
373 | } else { | 369 | } else { |
374 | hwif->set_pio_mode(drive, mode - XFER_PIO_0); | 370 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); |
375 | return ide_config_drive_speed(drive, mode); | 371 | return ide_config_drive_speed(drive, mode); |
376 | } | 372 | } |
377 | } | 373 | } |
@@ -379,17 +375,21 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | |||
379 | int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) | 375 | int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) |
380 | { | 376 | { |
381 | ide_hwif_t *hwif = drive->hwif; | 377 | ide_hwif_t *hwif = drive->hwif; |
378 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
379 | |||
380 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
381 | return 0; | ||
382 | 382 | ||
383 | if (hwif->set_dma_mode == NULL) | 383 | if (port_ops == NULL || port_ops->set_dma_mode == NULL) |
384 | return -1; | 384 | return -1; |
385 | 385 | ||
386 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | 386 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { |
387 | if (ide_config_drive_speed(drive, mode)) | 387 | if (ide_config_drive_speed(drive, mode)) |
388 | return -1; | 388 | return -1; |
389 | hwif->set_dma_mode(drive, mode); | 389 | port_ops->set_dma_mode(drive, mode); |
390 | return 0; | 390 | return 0; |
391 | } else { | 391 | } else { |
392 | hwif->set_dma_mode(drive, mode); | 392 | port_ops->set_dma_mode(drive, mode); |
393 | return ide_config_drive_speed(drive, mode); | 393 | return ide_config_drive_speed(drive, mode); |
394 | } | 394 | } |
395 | } | 395 | } |
@@ -409,8 +409,10 @@ EXPORT_SYMBOL_GPL(ide_set_dma_mode); | |||
409 | int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) | 409 | int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) |
410 | { | 410 | { |
411 | ide_hwif_t *hwif = drive->hwif; | 411 | ide_hwif_t *hwif = drive->hwif; |
412 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
412 | 413 | ||
413 | if (hwif->set_dma_mode == NULL) | 414 | if (port_ops == NULL || port_ops->set_dma_mode == NULL || |
415 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
414 | return -1; | 416 | return -1; |
415 | 417 | ||
416 | rate = ide_rate_filter(drive, rate); | 418 | rate = ide_rate_filter(drive, rate); |
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index 34c2ad36ce54..6a8953f68e9f 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
@@ -11,34 +11,52 @@ | |||
11 | * | 11 | * |
12 | * You should have received a copy of the GNU General Public License | 12 | * You should have received a copy of the GNU General Public License |
13 | * (for example /usr/src/linux/COPYING); if not, write to the Free | 13 | * (for example /usr/src/linux/COPYING); if not, write to the Free |
14 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 14 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/pnp.h> | 18 | #include <linux/pnp.h> |
19 | #include <linux/ide.h> | 19 | #include <linux/ide.h> |
20 | 20 | ||
21 | #define DRV_NAME "ide-pnp" | ||
22 | |||
21 | /* Add your devices here :)) */ | 23 | /* Add your devices here :)) */ |
22 | static struct pnp_device_id idepnp_devices[] = { | 24 | static struct pnp_device_id idepnp_devices[] = { |
23 | /* Generic ESDI/IDE/ATA compatible hard disk controller */ | 25 | /* Generic ESDI/IDE/ATA compatible hard disk controller */ |
24 | {.id = "PNP0600", .driver_data = 0}, | 26 | {.id = "PNP0600", .driver_data = 0}, |
25 | {.id = ""} | 27 | {.id = ""} |
26 | }; | 28 | }; |
27 | 29 | ||
28 | 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) |
29 | { | 31 | { |
30 | hw_regs_t hw; | 32 | hw_regs_t hw; |
31 | ide_hwif_t *hwif; | 33 | ide_hwif_t *hwif; |
34 | unsigned long base, ctl; | ||
32 | 35 | ||
33 | if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) | 36 | if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) |
34 | return -1; | 37 | return -1; |
35 | 38 | ||
39 | base = pnp_port_start(dev, 0); | ||
40 | ctl = pnp_port_start(dev, 1); | ||
41 | |||
42 | if (!request_region(base, 8, DRV_NAME)) { | ||
43 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
44 | DRV_NAME, base, base + 7); | ||
45 | return -EBUSY; | ||
46 | } | ||
47 | |||
48 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
49 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
50 | DRV_NAME, ctl); | ||
51 | release_region(base, 8); | ||
52 | return -EBUSY; | ||
53 | } | ||
54 | |||
36 | memset(&hw, 0, sizeof(hw)); | 55 | memset(&hw, 0, sizeof(hw)); |
37 | ide_std_init_ports(&hw, pnp_port_start(dev, 0), | 56 | ide_std_init_ports(&hw, base, ctl); |
38 | pnp_port_start(dev, 1)); | ||
39 | hw.irq = pnp_irq(dev, 0); | 57 | hw.irq = pnp_irq(dev, 0); |
40 | 58 | ||
41 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 59 | hwif = ide_find_port(); |
42 | if (hwif) { | 60 | if (hwif) { |
43 | u8 index = hwif->index; | 61 | u8 index = hwif->index; |
44 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | 62 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; |
@@ -47,24 +65,27 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id | |||
47 | ide_init_port_hw(hwif, &hw); | 65 | ide_init_port_hw(hwif, &hw); |
48 | 66 | ||
49 | printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); | 67 | printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); |
50 | pnp_set_drvdata(dev,hwif); | 68 | pnp_set_drvdata(dev, hwif); |
51 | 69 | ||
52 | ide_device_add(idx, NULL); | 70 | ide_device_add(idx, NULL); |
53 | 71 | ||
54 | return 0; | 72 | return 0; |
55 | } | 73 | } |
56 | 74 | ||
75 | release_region(ctl, 1); | ||
76 | release_region(base, 8); | ||
77 | |||
57 | return -1; | 78 | return -1; |
58 | } | 79 | } |
59 | 80 | ||
60 | static void idepnp_remove(struct pnp_dev * dev) | 81 | static void idepnp_remove(struct pnp_dev *dev) |
61 | { | 82 | { |
62 | ide_hwif_t *hwif = pnp_get_drvdata(dev); | 83 | ide_hwif_t *hwif = pnp_get_drvdata(dev); |
63 | 84 | ||
64 | if (hwif) | 85 | ide_unregister(hwif); |
65 | ide_unregister(hwif->index); | 86 | |
66 | else | 87 | release_region(pnp_port_start(dev, 1), 1); |
67 | printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); | 88 | release_region(pnp_port_start(dev, 0), 8); |
68 | } | 89 | } |
69 | 90 | ||
70 | static struct pnp_driver idepnp_driver = { | 91 | static struct pnp_driver idepnp_driver = { |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 6a196c27b0aa..862f02603f9b 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -264,6 +264,7 @@ err_misc: | |||
264 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | 264 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) |
265 | { | 265 | { |
266 | ide_hwif_t *hwif = HWIF(drive); | 266 | ide_hwif_t *hwif = HWIF(drive); |
267 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
267 | int use_altstatus = 0, rc; | 268 | int use_altstatus = 0, rc; |
268 | unsigned long timeout; | 269 | unsigned long timeout; |
269 | u8 s = 0, a = 0; | 270 | u8 s = 0, a = 0; |
@@ -271,7 +272,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
271 | /* take a deep breath */ | 272 | /* take a deep breath */ |
272 | msleep(50); | 273 | msleep(50); |
273 | 274 | ||
274 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) { | 275 | if (io_ports->ctl_addr) { |
275 | a = ide_read_altstatus(drive); | 276 | a = ide_read_altstatus(drive); |
276 | s = ide_read_status(drive); | 277 | s = ide_read_status(drive); |
277 | if ((a ^ s) & ~INDEX_STAT) | 278 | if ((a ^ s) & ~INDEX_STAT) |
@@ -289,10 +290,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
289 | */ | 290 | */ |
290 | if ((cmd == WIN_PIDENTIFY)) | 291 | if ((cmd == WIN_PIDENTIFY)) |
291 | /* disable dma & overlap */ | 292 | /* disable dma & overlap */ |
292 | hwif->OUTB(0, hwif->io_ports[IDE_FEATURE_OFFSET]); | 293 | hwif->OUTB(0, io_ports->feature_addr); |
293 | 294 | ||
294 | /* ask drive for ID */ | 295 | /* ask drive for ID */ |
295 | hwif->OUTB(cmd, hwif->io_ports[IDE_COMMAND_OFFSET]); | 296 | hwif->OUTB(cmd, io_ports->command_addr); |
296 | 297 | ||
297 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 298 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
298 | timeout += jiffies; | 299 | timeout += jiffies; |
@@ -353,7 +354,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
353 | * interrupts during the identify-phase that | 354 | * interrupts during the identify-phase that |
354 | * the irq handler isn't expecting. | 355 | * the irq handler isn't expecting. |
355 | */ | 356 | */ |
356 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) { | 357 | if (hwif->io_ports.ctl_addr) { |
357 | if (!hwif->irq) { | 358 | if (!hwif->irq) { |
358 | autoprobe = 1; | 359 | autoprobe = 1; |
359 | cookie = probe_irq_on(); | 360 | cookie = probe_irq_on(); |
@@ -393,7 +394,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
393 | 394 | ||
394 | do { | 395 | do { |
395 | msleep(50); | 396 | msleep(50); |
396 | stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 397 | stat = hwif->INB(hwif->io_ports.status_addr); |
397 | if ((stat & BUSY_STAT) == 0) | 398 | if ((stat & BUSY_STAT) == 0) |
398 | return 0; | 399 | return 0; |
399 | } while (time_before(jiffies, timeout)); | 400 | } while (time_before(jiffies, timeout)); |
@@ -425,6 +426,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
425 | static int do_probe (ide_drive_t *drive, u8 cmd) | 426 | static int do_probe (ide_drive_t *drive, u8 cmd) |
426 | { | 427 | { |
427 | ide_hwif_t *hwif = HWIF(drive); | 428 | ide_hwif_t *hwif = HWIF(drive); |
429 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
428 | int rc; | 430 | int rc; |
429 | u8 stat; | 431 | u8 stat; |
430 | 432 | ||
@@ -445,7 +447,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
445 | msleep(50); | 447 | msleep(50); |
446 | SELECT_DRIVE(drive); | 448 | SELECT_DRIVE(drive); |
447 | msleep(50); | 449 | msleep(50); |
448 | if (hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]) != drive->select.all && | 450 | if (hwif->INB(io_ports->device_addr) != drive->select.all && |
449 | !drive->present) { | 451 | !drive->present) { |
450 | if (drive->select.b.unit != 0) { | 452 | if (drive->select.b.unit != 0) { |
451 | /* exit with drive0 selected */ | 453 | /* exit with drive0 selected */ |
@@ -472,17 +474,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
472 | if (stat == (BUSY_STAT | READY_STAT)) | 474 | if (stat == (BUSY_STAT | READY_STAT)) |
473 | return 4; | 475 | return 4; |
474 | 476 | ||
475 | if ((rc == 1 && cmd == WIN_PIDENTIFY) && | 477 | if (rc == 1 && cmd == WIN_PIDENTIFY) { |
476 | ((drive->autotune == IDE_TUNE_DEFAULT) || | ||
477 | (drive->autotune == IDE_TUNE_AUTO))) { | ||
478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " | 478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " |
479 | "resetting drive\n", drive->name, stat); | 479 | "resetting drive\n", drive->name, stat); |
480 | msleep(50); | 480 | msleep(50); |
481 | hwif->OUTB(drive->select.all, | 481 | hwif->OUTB(drive->select.all, io_ports->device_addr); |
482 | hwif->io_ports[IDE_SELECT_OFFSET]); | ||
483 | msleep(50); | 482 | msleep(50); |
484 | hwif->OUTB(WIN_SRST, | 483 | hwif->OUTB(WIN_SRST, io_ports->command_addr); |
485 | hwif->io_ports[IDE_COMMAND_OFFSET]); | ||
486 | (void)ide_busy_sleep(hwif); | 484 | (void)ide_busy_sleep(hwif); |
487 | rc = try_to_identify(drive, cmd); | 485 | rc = try_to_identify(drive, cmd); |
488 | } | 486 | } |
@@ -518,7 +516,7 @@ static void enable_nest (ide_drive_t *drive) | |||
518 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 516 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); |
519 | SELECT_DRIVE(drive); | 517 | SELECT_DRIVE(drive); |
520 | msleep(50); | 518 | msleep(50); |
521 | hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports[IDE_COMMAND_OFFSET]); | 519 | hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); |
522 | 520 | ||
523 | if (ide_busy_sleep(hwif)) { | 521 | if (ide_busy_sleep(hwif)) { |
524 | printk(KERN_CONT "failed (timeout)\n"); | 522 | printk(KERN_CONT "failed (timeout)\n"); |
@@ -644,7 +642,7 @@ static int ide_register_port(ide_hwif_t *hwif) | |||
644 | ret = device_register(&hwif->gendev); | 642 | ret = device_register(&hwif->gendev); |
645 | if (ret < 0) { | 643 | if (ret < 0) { |
646 | printk(KERN_WARNING "IDE: %s: device_register error: %d\n", | 644 | printk(KERN_WARNING "IDE: %s: device_register error: %d\n", |
647 | __FUNCTION__, ret); | 645 | __func__, ret); |
648 | goto out; | 646 | goto out; |
649 | } | 647 | } |
650 | 648 | ||
@@ -773,8 +771,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
773 | 771 | ||
774 | BUG_ON(hwif->present); | 772 | BUG_ON(hwif->present); |
775 | 773 | ||
776 | if (hwif->noprobe || | 774 | if (hwif->drives[0].noprobe && hwif->drives[1].noprobe) |
777 | (hwif->drives[0].noprobe && hwif->drives[1].noprobe)) | ||
778 | return -EACCES; | 775 | return -EACCES; |
779 | 776 | ||
780 | /* | 777 | /* |
@@ -801,14 +798,9 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
801 | if (drive->present) | 798 | if (drive->present) |
802 | rc = 0; | 799 | rc = 0; |
803 | } | 800 | } |
804 | if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { | 801 | |
805 | printk(KERN_WARNING "%s: reset\n", hwif->name); | ||
806 | hwif->OUTB(12, hwif->io_ports[IDE_CONTROL_OFFSET]); | ||
807 | udelay(10); | ||
808 | hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); | ||
809 | (void)ide_busy_sleep(hwif); | ||
810 | } | ||
811 | local_irq_restore(flags); | 802 | local_irq_restore(flags); |
803 | |||
812 | /* | 804 | /* |
813 | * Use cached IRQ number. It might be (and is...) changed by probe | 805 | * Use cached IRQ number. It might be (and is...) changed by probe |
814 | * code above | 806 | * code above |
@@ -821,29 +813,25 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
821 | 813 | ||
822 | static void ide_port_tune_devices(ide_hwif_t *hwif) | 814 | static void ide_port_tune_devices(ide_hwif_t *hwif) |
823 | { | 815 | { |
816 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
824 | int unit; | 817 | int unit; |
825 | 818 | ||
826 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 819 | for (unit = 0; unit < MAX_DRIVES; unit++) { |
827 | ide_drive_t *drive = &hwif->drives[unit]; | 820 | ide_drive_t *drive = &hwif->drives[unit]; |
828 | 821 | ||
829 | if (drive->present && hwif->quirkproc) | 822 | if (drive->present && port_ops && port_ops->quirkproc) |
830 | hwif->quirkproc(drive); | 823 | port_ops->quirkproc(drive); |
831 | } | 824 | } |
832 | 825 | ||
833 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 826 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
834 | ide_drive_t *drive = &hwif->drives[unit]; | 827 | ide_drive_t *drive = &hwif->drives[unit]; |
835 | 828 | ||
836 | if (drive->present) { | 829 | if (drive->present) { |
837 | if (drive->autotune == IDE_TUNE_AUTO) | 830 | ide_set_max_pio(drive); |
838 | ide_set_max_pio(drive); | ||
839 | |||
840 | if (drive->autotune != IDE_TUNE_DEFAULT && | ||
841 | drive->autotune != IDE_TUNE_AUTO) | ||
842 | continue; | ||
843 | 831 | ||
844 | drive->nice1 = 1; | 832 | drive->nice1 = 1; |
845 | 833 | ||
846 | if (hwif->dma_host_set) | 834 | if (hwif->dma_ops) |
847 | ide_set_dma(drive); | 835 | ide_set_dma(drive); |
848 | } | 836 | } |
849 | } | 837 | } |
@@ -994,6 +982,7 @@ static void ide_port_setup_devices(ide_hwif_t *hwif) | |||
994 | */ | 982 | */ |
995 | static int init_irq (ide_hwif_t *hwif) | 983 | static int init_irq (ide_hwif_t *hwif) |
996 | { | 984 | { |
985 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
997 | unsigned int index; | 986 | unsigned int index; |
998 | ide_hwgroup_t *hwgroup; | 987 | ide_hwgroup_t *hwgroup; |
999 | ide_hwif_t *match = NULL; | 988 | ide_hwif_t *match = NULL; |
@@ -1077,9 +1066,9 @@ static int init_irq (ide_hwif_t *hwif) | |||
1077 | if (IDE_CHIPSET_IS_PCI(hwif->chipset)) | 1066 | if (IDE_CHIPSET_IS_PCI(hwif->chipset)) |
1078 | sa = IRQF_SHARED; | 1067 | sa = IRQF_SHARED; |
1079 | 1068 | ||
1080 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) | 1069 | if (io_ports->ctl_addr) |
1081 | /* clear nIEN */ | 1070 | /* clear nIEN */ |
1082 | hwif->OUTB(0x08, hwif->io_ports[IDE_CONTROL_OFFSET]); | 1071 | hwif->OUTB(0x08, io_ports->ctl_addr); |
1083 | 1072 | ||
1084 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) | 1073 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) |
1085 | goto out_unlink; | 1074 | goto out_unlink; |
@@ -1095,12 +1084,11 @@ static int init_irq (ide_hwif_t *hwif) | |||
1095 | 1084 | ||
1096 | #if !defined(__mc68000__) | 1085 | #if !defined(__mc68000__) |
1097 | printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, | 1086 | printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, |
1098 | hwif->io_ports[IDE_DATA_OFFSET], | 1087 | io_ports->data_addr, io_ports->status_addr, |
1099 | hwif->io_ports[IDE_DATA_OFFSET]+7, | 1088 | io_ports->ctl_addr, hwif->irq); |
1100 | hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq); | ||
1101 | #else | 1089 | #else |
1102 | printk("%s at 0x%08lx on irq %d", hwif->name, | 1090 | printk("%s at 0x%08lx on irq %d", hwif->name, |
1103 | hwif->io_ports[IDE_DATA_OFFSET], hwif->irq); | 1091 | io_ports->data_addr, hwif->irq); |
1104 | #endif /* __mc68000__ */ | 1092 | #endif /* __mc68000__ */ |
1105 | if (match) | 1093 | if (match) |
1106 | printk(" (%sed with %s)", | 1094 | printk(" (%sed with %s)", |
@@ -1242,8 +1230,8 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1242 | int old_irq; | 1230 | int old_irq; |
1243 | 1231 | ||
1244 | if (!hwif->irq) { | 1232 | if (!hwif->irq) { |
1245 | if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) | 1233 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); |
1246 | { | 1234 | if (!hwif->irq) { |
1247 | printk("%s: DISABLED, NO IRQ\n", hwif->name); | 1235 | printk("%s: DISABLED, NO IRQ\n", hwif->name); |
1248 | return 0; | 1236 | return 0; |
1249 | } | 1237 | } |
@@ -1272,7 +1260,8 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1272 | * It failed to initialise. Find the default IRQ for | 1260 | * It failed to initialise. Find the default IRQ for |
1273 | * this port and try that. | 1261 | * this port and try that. |
1274 | */ | 1262 | */ |
1275 | if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) { | 1263 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); |
1264 | if (!hwif->irq) { | ||
1276 | printk("%s: Disabled unable to get IRQ %d.\n", | 1265 | printk("%s: Disabled unable to get IRQ %d.\n", |
1277 | hwif->name, old_irq); | 1266 | hwif->name, old_irq); |
1278 | goto out; | 1267 | goto out; |
@@ -1324,6 +1313,7 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
1324 | 1313 | ||
1325 | static void ide_port_init_devices(ide_hwif_t *hwif) | 1314 | static void ide_port_init_devices(ide_hwif_t *hwif) |
1326 | { | 1315 | { |
1316 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
1327 | int i; | 1317 | int i; |
1328 | 1318 | ||
1329 | for (i = 0; i < MAX_DRIVES; i++) { | 1319 | for (i = 0; i < MAX_DRIVES; i++) { |
@@ -1335,12 +1325,10 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1335 | drive->unmask = 1; | 1325 | drive->unmask = 1; |
1336 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | 1326 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) |
1337 | drive->no_unmask = 1; | 1327 | drive->no_unmask = 1; |
1338 | if ((hwif->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) | ||
1339 | drive->autotune = 1; | ||
1340 | } | 1328 | } |
1341 | 1329 | ||
1342 | if (hwif->port_init_devs) | 1330 | if (port_ops && port_ops->port_init_devs) |
1343 | hwif->port_init_devs(hwif); | 1331 | port_ops->port_init_devs(hwif); |
1344 | } | 1332 | } |
1345 | 1333 | ||
1346 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | 1334 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, |
@@ -1355,9 +1343,6 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1355 | if (d->init_iops) | 1343 | if (d->init_iops) |
1356 | d->init_iops(hwif); | 1344 | d->init_iops(hwif); |
1357 | 1345 | ||
1358 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) | ||
1359 | ide_hwif_setup_dma(hwif, d); | ||
1360 | |||
1361 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || | 1346 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || |
1362 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | 1347 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) |
1363 | hwif->irq = port ? 15 : 14; | 1348 | hwif->irq = port ? 15 : 14; |
@@ -1365,16 +1350,36 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1365 | hwif->host_flags = d->host_flags; | 1350 | hwif->host_flags = d->host_flags; |
1366 | hwif->pio_mask = d->pio_mask; | 1351 | hwif->pio_mask = d->pio_mask; |
1367 | 1352 | ||
1368 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | 1353 | /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ |
1369 | hwif->mate->serialized = hwif->serialized = 1; | 1354 | if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) |
1355 | hwif->port_ops = d->port_ops; | ||
1356 | |||
1357 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) || | ||
1358 | ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) { | ||
1359 | if (hwif->mate) | ||
1360 | hwif->mate->serialized = hwif->serialized = 1; | ||
1361 | } | ||
1370 | 1362 | ||
1371 | hwif->swdma_mask = d->swdma_mask; | 1363 | hwif->swdma_mask = d->swdma_mask; |
1372 | hwif->mwdma_mask = d->mwdma_mask; | 1364 | hwif->mwdma_mask = d->mwdma_mask; |
1373 | hwif->ultra_mask = d->udma_mask; | 1365 | hwif->ultra_mask = d->udma_mask; |
1374 | 1366 | ||
1375 | /* reset DMA masks only for SFF-style DMA controllers */ | 1367 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { |
1376 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0) | 1368 | int rc; |
1377 | hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0; | 1369 | |
1370 | if (d->init_dma) | ||
1371 | rc = d->init_dma(hwif, d); | ||
1372 | else | ||
1373 | rc = ide_hwif_setup_dma(hwif, d); | ||
1374 | |||
1375 | if (rc < 0) { | ||
1376 | printk(KERN_INFO "%s: DMA disabled\n", hwif->name); | ||
1377 | hwif->swdma_mask = 0; | ||
1378 | hwif->mwdma_mask = 0; | ||
1379 | hwif->ultra_mask = 0; | ||
1380 | } else if (d->dma_ops) | ||
1381 | hwif->dma_ops = d->dma_ops; | ||
1382 | } | ||
1378 | 1383 | ||
1379 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | 1384 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) |
1380 | hwif->rqsize = 256; | 1385 | hwif->rqsize = 256; |
@@ -1386,9 +1391,11 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1386 | 1391 | ||
1387 | static void ide_port_cable_detect(ide_hwif_t *hwif) | 1392 | static void ide_port_cable_detect(ide_hwif_t *hwif) |
1388 | { | 1393 | { |
1389 | if (hwif->cable_detect && (hwif->ultra_mask & 0x78)) { | 1394 | const struct ide_port_ops *port_ops = hwif->port_ops; |
1395 | |||
1396 | if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { | ||
1390 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 1397 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
1391 | hwif->cbl = hwif->cable_detect(hwif); | 1398 | hwif->cbl = port_ops->cable_detect(hwif); |
1392 | } | 1399 | } |
1393 | } | 1400 | } |
1394 | 1401 | ||
@@ -1444,19 +1451,74 @@ static int ide_sysfs_register_port(ide_hwif_t *hwif) | |||
1444 | return rc; | 1451 | return rc; |
1445 | } | 1452 | } |
1446 | 1453 | ||
1454 | /** | ||
1455 | * ide_find_port_slot - find free ide_hwifs[] slot | ||
1456 | * @d: IDE port info | ||
1457 | * | ||
1458 | * Return the new hwif. If we are out of free slots return NULL. | ||
1459 | */ | ||
1460 | |||
1461 | ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d) | ||
1462 | { | ||
1463 | ide_hwif_t *hwif; | ||
1464 | int i; | ||
1465 | u8 bootable = (d && (d->host_flags & IDE_HFLAG_NON_BOOTABLE)) ? 0 : 1; | ||
1466 | |||
1467 | /* | ||
1468 | * Claim an unassigned slot. | ||
1469 | * | ||
1470 | * Give preference to claiming other slots before claiming ide0/ide1, | ||
1471 | * just in case there's another interface yet-to-be-scanned | ||
1472 | * which uses ports 0x1f0/0x170 (the ide0/ide1 defaults). | ||
1473 | * | ||
1474 | * Unless there is a bootable card that does not use the standard | ||
1475 | * ports 0x1f0/0x170 (the ide0/ide1 defaults). | ||
1476 | */ | ||
1477 | if (bootable) { | ||
1478 | i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0; | ||
1479 | |||
1480 | for (; i < MAX_HWIFS; i++) { | ||
1481 | hwif = &ide_hwifs[i]; | ||
1482 | if (hwif->chipset == ide_unknown) | ||
1483 | return hwif; | ||
1484 | } | ||
1485 | } else { | ||
1486 | for (i = 2; i < MAX_HWIFS; i++) { | ||
1487 | hwif = &ide_hwifs[i]; | ||
1488 | if (hwif->chipset == ide_unknown) | ||
1489 | return hwif; | ||
1490 | } | ||
1491 | for (i = 0; i < 2 && i < MAX_HWIFS; i++) { | ||
1492 | hwif = &ide_hwifs[i]; | ||
1493 | if (hwif->chipset == ide_unknown) | ||
1494 | return hwif; | ||
1495 | } | ||
1496 | } | ||
1497 | |||
1498 | return NULL; | ||
1499 | } | ||
1500 | EXPORT_SYMBOL_GPL(ide_find_port_slot); | ||
1501 | |||
1447 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | 1502 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) |
1448 | { | 1503 | { |
1449 | ide_hwif_t *hwif, *mate = NULL; | 1504 | ide_hwif_t *hwif, *mate = NULL; |
1450 | int i, rc = 0; | 1505 | int i, rc = 0; |
1451 | 1506 | ||
1452 | for (i = 0; i < MAX_HWIFS; i++) { | 1507 | for (i = 0; i < MAX_HWIFS; i++) { |
1453 | if (d == NULL || idx[i] == 0xff) { | 1508 | if (idx[i] == 0xff) { |
1454 | mate = NULL; | 1509 | mate = NULL; |
1455 | continue; | 1510 | continue; |
1456 | } | 1511 | } |
1457 | 1512 | ||
1458 | hwif = &ide_hwifs[idx[i]]; | 1513 | hwif = &ide_hwifs[idx[i]]; |
1459 | 1514 | ||
1515 | ide_port_apply_params(hwif); | ||
1516 | |||
1517 | if (d == NULL) { | ||
1518 | mate = NULL; | ||
1519 | continue; | ||
1520 | } | ||
1521 | |||
1460 | if (d->chipset != ide_etrax100 && (i & 1) && mate) { | 1522 | if (d->chipset != ide_etrax100 && (i & 1) && mate) { |
1461 | hwif->mate = mate; | 1523 | hwif->mate = mate; |
1462 | mate->mate = hwif; | 1524 | mate->mate = hwif; |
@@ -1475,25 +1537,15 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1475 | 1537 | ||
1476 | hwif = &ide_hwifs[idx[i]]; | 1538 | hwif = &ide_hwifs[idx[i]]; |
1477 | 1539 | ||
1478 | if ((hwif->chipset != ide_4drives || !hwif->mate || | 1540 | if (ide_probe_port(hwif) == 0) |
1479 | !hwif->mate->present) && ide_hwif_request_regions(hwif)) { | 1541 | hwif->present = 1; |
1480 | printk(KERN_ERR "%s: ports already in use, " | ||
1481 | "skipping probe\n", hwif->name); | ||
1482 | continue; | ||
1483 | } | ||
1484 | |||
1485 | if (ide_probe_port(hwif) < 0) { | ||
1486 | ide_hwif_release_regions(hwif); | ||
1487 | continue; | ||
1488 | } | ||
1489 | |||
1490 | hwif->present = 1; | ||
1491 | 1542 | ||
1492 | if (hwif->chipset != ide_4drives || !hwif->mate || | 1543 | if (hwif->chipset != ide_4drives || !hwif->mate || |
1493 | !hwif->mate->present) | 1544 | !hwif->mate->present) |
1494 | ide_register_port(hwif); | 1545 | ide_register_port(hwif); |
1495 | 1546 | ||
1496 | ide_port_tune_devices(hwif); | 1547 | if (hwif->present) |
1548 | ide_port_tune_devices(hwif); | ||
1497 | } | 1549 | } |
1498 | 1550 | ||
1499 | for (i = 0; i < MAX_HWIFS; i++) { | 1551 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1502,9 +1554,6 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1502 | 1554 | ||
1503 | hwif = &ide_hwifs[idx[i]]; | 1555 | hwif = &ide_hwifs[idx[i]]; |
1504 | 1556 | ||
1505 | if (!hwif->present) | ||
1506 | continue; | ||
1507 | |||
1508 | if (hwif_init(hwif) == 0) { | 1557 | if (hwif_init(hwif) == 0) { |
1509 | printk(KERN_INFO "%s: failed to initialize IDE " | 1558 | printk(KERN_INFO "%s: failed to initialize IDE " |
1510 | "interface\n", hwif->name); | 1559 | "interface\n", hwif->name); |
@@ -1513,10 +1562,13 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1513 | continue; | 1562 | continue; |
1514 | } | 1563 | } |
1515 | 1564 | ||
1516 | ide_port_setup_devices(hwif); | 1565 | if (hwif->present) |
1566 | ide_port_setup_devices(hwif); | ||
1517 | 1567 | ||
1518 | ide_acpi_init(hwif); | 1568 | ide_acpi_init(hwif); |
1519 | ide_acpi_port_init_devices(hwif); | 1569 | |
1570 | if (hwif->present) | ||
1571 | ide_acpi_port_init_devices(hwif); | ||
1520 | } | 1572 | } |
1521 | 1573 | ||
1522 | for (i = 0; i < MAX_HWIFS; i++) { | 1574 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1525,11 +1577,11 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1525 | 1577 | ||
1526 | hwif = &ide_hwifs[idx[i]]; | 1578 | hwif = &ide_hwifs[idx[i]]; |
1527 | 1579 | ||
1528 | if (hwif->present) { | 1580 | if (hwif->chipset == ide_unknown) |
1529 | if (hwif->chipset == ide_unknown) | 1581 | hwif->chipset = ide_generic; |
1530 | hwif->chipset = ide_generic; | 1582 | |
1583 | if (hwif->present) | ||
1531 | hwif_register_devices(hwif); | 1584 | hwif_register_devices(hwif); |
1532 | } | ||
1533 | } | 1585 | } |
1534 | 1586 | ||
1535 | for (i = 0; i < MAX_HWIFS; i++) { | 1587 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1538,11 +1590,11 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1538 | 1590 | ||
1539 | hwif = &ide_hwifs[idx[i]]; | 1591 | hwif = &ide_hwifs[idx[i]]; |
1540 | 1592 | ||
1541 | if (hwif->present) { | 1593 | ide_sysfs_register_port(hwif); |
1542 | ide_sysfs_register_port(hwif); | 1594 | ide_proc_register_port(hwif); |
1543 | ide_proc_register_port(hwif); | 1595 | |
1596 | if (hwif->present) | ||
1544 | ide_proc_port_register_devices(hwif); | 1597 | ide_proc_port_register_devices(hwif); |
1545 | } | ||
1546 | } | 1598 | } |
1547 | 1599 | ||
1548 | return rc; | 1600 | return rc; |
@@ -1563,6 +1615,7 @@ EXPORT_SYMBOL_GPL(ide_device_add); | |||
1563 | 1615 | ||
1564 | void ide_port_scan(ide_hwif_t *hwif) | 1616 | void ide_port_scan(ide_hwif_t *hwif) |
1565 | { | 1617 | { |
1618 | ide_port_apply_params(hwif); | ||
1566 | ide_port_cable_detect(hwif); | 1619 | ide_port_cable_detect(hwif); |
1567 | ide_port_init_devices(hwif); | 1620 | ide_port_init_devices(hwif); |
1568 | 1621 | ||
@@ -1578,3 +1631,67 @@ void ide_port_scan(ide_hwif_t *hwif) | |||
1578 | ide_proc_port_register_devices(hwif); | 1631 | ide_proc_port_register_devices(hwif); |
1579 | } | 1632 | } |
1580 | EXPORT_SYMBOL_GPL(ide_port_scan); | 1633 | EXPORT_SYMBOL_GPL(ide_port_scan); |
1634 | |||
1635 | static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, | ||
1636 | const struct ide_port_info *d, | ||
1637 | unsigned long config) | ||
1638 | { | ||
1639 | ide_hwif_t *hwif; | ||
1640 | unsigned long base, ctl; | ||
1641 | int irq; | ||
1642 | |||
1643 | if (port_no == 0) { | ||
1644 | base = 0x1f0; | ||
1645 | ctl = 0x3f6; | ||
1646 | irq = 14; | ||
1647 | } else { | ||
1648 | base = 0x170; | ||
1649 | ctl = 0x376; | ||
1650 | irq = 15; | ||
1651 | } | ||
1652 | |||
1653 | if (!request_region(base, 8, d->name)) { | ||
1654 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
1655 | d->name, base, base + 7); | ||
1656 | return; | ||
1657 | } | ||
1658 | |||
1659 | if (!request_region(ctl, 1, d->name)) { | ||
1660 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
1661 | d->name, ctl); | ||
1662 | release_region(base, 8); | ||
1663 | return; | ||
1664 | } | ||
1665 | |||
1666 | ide_std_init_ports(hw, base, ctl); | ||
1667 | hw->irq = irq; | ||
1668 | |||
1669 | hwif = ide_find_port_slot(d); | ||
1670 | if (hwif) { | ||
1671 | ide_init_port_hw(hwif, hw); | ||
1672 | if (config) | ||
1673 | hwif->config_data = config; | ||
1674 | idx[port_no] = hwif->index; | ||
1675 | } | ||
1676 | } | ||
1677 | |||
1678 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) | ||
1679 | { | ||
1680 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
1681 | hw_regs_t hw[2]; | ||
1682 | |||
1683 | memset(&hw, 0, sizeof(hw)); | ||
1684 | |||
1685 | if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) | ||
1686 | ide_legacy_init_one(idx, &hw[0], 0, d, config); | ||
1687 | ide_legacy_init_one(idx, &hw[1], 1, d, config); | ||
1688 | |||
1689 | if (idx[0] == 0xff && idx[1] == 0xff && | ||
1690 | (d->host_flags & IDE_HFLAG_SINGLE)) | ||
1691 | return -ENOENT; | ||
1692 | |||
1693 | ide_device_add(idx, d); | ||
1694 | |||
1695 | return 0; | ||
1696 | } | ||
1697 | EXPORT_SYMBOL_GPL(ide_legacy_device_add); | ||
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index edd7f186dc4d..7b2f3815a838 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -47,28 +47,28 @@ static int proc_ide_read_imodel | |||
47 | const char *name; | 47 | const char *name; |
48 | 48 | ||
49 | switch (hwif->chipset) { | 49 | switch (hwif->chipset) { |
50 | case ide_generic: name = "generic"; break; | 50 | case ide_generic: name = "generic"; break; |
51 | case ide_pci: name = "pci"; break; | 51 | case ide_pci: name = "pci"; break; |
52 | case ide_cmd640: name = "cmd640"; break; | 52 | case ide_cmd640: name = "cmd640"; break; |
53 | case ide_dtc2278: name = "dtc2278"; break; | 53 | case ide_dtc2278: name = "dtc2278"; break; |
54 | case ide_ali14xx: name = "ali14xx"; break; | 54 | case ide_ali14xx: name = "ali14xx"; break; |
55 | case ide_qd65xx: name = "qd65xx"; break; | 55 | case ide_qd65xx: name = "qd65xx"; break; |
56 | case ide_umc8672: name = "umc8672"; break; | 56 | case ide_umc8672: name = "umc8672"; break; |
57 | case ide_ht6560b: name = "ht6560b"; break; | 57 | case ide_ht6560b: name = "ht6560b"; break; |
58 | case ide_rz1000: name = "rz1000"; break; | 58 | case ide_rz1000: name = "rz1000"; break; |
59 | case ide_trm290: name = "trm290"; break; | 59 | case ide_trm290: name = "trm290"; break; |
60 | case ide_cmd646: name = "cmd646"; break; | 60 | case ide_cmd646: name = "cmd646"; break; |
61 | case ide_cy82c693: name = "cy82c693"; break; | 61 | case ide_cy82c693: name = "cy82c693"; break; |
62 | case ide_4drives: name = "4drives"; break; | 62 | case ide_4drives: name = "4drives"; break; |
63 | case ide_pmac: name = "mac-io"; break; | 63 | case ide_pmac: name = "mac-io"; break; |
64 | case ide_au1xxx: name = "au1xxx"; break; | 64 | case ide_au1xxx: name = "au1xxx"; break; |
65 | case ide_palm3710: name = "palm3710"; break; | 65 | case ide_palm3710: name = "palm3710"; break; |
66 | case ide_etrax100: name = "etrax100"; break; | 66 | case ide_etrax100: name = "etrax100"; break; |
67 | case ide_acorn: name = "acorn"; break; | 67 | case ide_acorn: name = "acorn"; break; |
68 | default: name = "(unknown)"; break; | 68 | default: name = "(unknown)"; break; |
69 | } | 69 | } |
70 | len = sprintf(page, "%s\n", name); | 70 | len = sprintf(page, "%s\n", name); |
71 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 71 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
72 | } | 72 | } |
73 | 73 | ||
74 | static int proc_ide_read_mate | 74 | static int proc_ide_read_mate |
@@ -81,7 +81,7 @@ static int proc_ide_read_mate | |||
81 | len = sprintf(page, "%s\n", hwif->mate->name); | 81 | len = sprintf(page, "%s\n", hwif->mate->name); |
82 | else | 82 | else |
83 | len = sprintf(page, "(none)\n"); | 83 | len = sprintf(page, "(none)\n"); |
84 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 84 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
85 | } | 85 | } |
86 | 86 | ||
87 | static int proc_ide_read_channel | 87 | static int proc_ide_read_channel |
@@ -93,7 +93,7 @@ static int proc_ide_read_channel | |||
93 | page[0] = hwif->channel ? '1' : '0'; | 93 | page[0] = hwif->channel ? '1' : '0'; |
94 | page[1] = '\n'; | 94 | page[1] = '\n'; |
95 | len = 2; | 95 | len = 2; |
96 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 96 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
97 | } | 97 | } |
98 | 98 | ||
99 | static int proc_ide_read_identify | 99 | static int proc_ide_read_identify |
@@ -120,7 +120,7 @@ static int proc_ide_read_identify | |||
120 | len = out - page; | 120 | len = out - page; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 123 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
@@ -197,7 +197,7 @@ EXPORT_SYMBOL(ide_add_setting); | |||
197 | * The caller must hold the setting semaphore. | 197 | * The caller must hold the setting semaphore. |
198 | */ | 198 | */ |
199 | 199 | ||
200 | static void __ide_remove_setting (ide_drive_t *drive, char *name) | 200 | static void __ide_remove_setting(ide_drive_t *drive, char *name) |
201 | { | 201 | { |
202 | ide_settings_t **p, *setting; | 202 | ide_settings_t **p, *setting; |
203 | 203 | ||
@@ -205,7 +205,8 @@ static void __ide_remove_setting (ide_drive_t *drive, char *name) | |||
205 | 205 | ||
206 | while ((*p) && strcmp((*p)->name, name)) | 206 | while ((*p) && strcmp((*p)->name, name)) |
207 | p = &((*p)->next); | 207 | p = &((*p)->next); |
208 | if ((setting = (*p)) == NULL) | 208 | setting = (*p); |
209 | if (setting == NULL) | ||
209 | return; | 210 | return; |
210 | 211 | ||
211 | (*p) = setting->next; | 212 | (*p) = setting->next; |
@@ -223,7 +224,7 @@ static void __ide_remove_setting (ide_drive_t *drive, char *name) | |||
223 | * caller must hold ide_setting_mtx. | 224 | * caller must hold ide_setting_mtx. |
224 | */ | 225 | */ |
225 | 226 | ||
226 | static void auto_remove_settings (ide_drive_t *drive) | 227 | static void auto_remove_settings(ide_drive_t *drive) |
227 | { | 228 | { |
228 | ide_settings_t *setting; | 229 | ide_settings_t *setting; |
229 | repeat: | 230 | repeat: |
@@ -279,16 +280,16 @@ static int ide_read_setting(ide_drive_t *drive, ide_settings_t *setting) | |||
279 | 280 | ||
280 | if ((setting->rw & SETTING_READ)) { | 281 | if ((setting->rw & SETTING_READ)) { |
281 | spin_lock_irqsave(&ide_lock, flags); | 282 | spin_lock_irqsave(&ide_lock, flags); |
282 | switch(setting->data_type) { | 283 | switch (setting->data_type) { |
283 | case TYPE_BYTE: | 284 | case TYPE_BYTE: |
284 | val = *((u8 *) setting->data); | 285 | val = *((u8 *) setting->data); |
285 | break; | 286 | break; |
286 | case TYPE_SHORT: | 287 | case TYPE_SHORT: |
287 | val = *((u16 *) setting->data); | 288 | val = *((u16 *) setting->data); |
288 | break; | 289 | break; |
289 | case TYPE_INT: | 290 | case TYPE_INT: |
290 | val = *((u32 *) setting->data); | 291 | val = *((u32 *) setting->data); |
291 | break; | 292 | break; |
292 | } | 293 | } |
293 | spin_unlock_irqrestore(&ide_lock, flags); | 294 | spin_unlock_irqrestore(&ide_lock, flags); |
294 | } | 295 | } |
@@ -326,15 +327,15 @@ static int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int va | |||
326 | if (ide_spin_wait_hwgroup(drive)) | 327 | if (ide_spin_wait_hwgroup(drive)) |
327 | return -EBUSY; | 328 | return -EBUSY; |
328 | switch (setting->data_type) { | 329 | switch (setting->data_type) { |
329 | case TYPE_BYTE: | 330 | case TYPE_BYTE: |
330 | *((u8 *) setting->data) = val; | 331 | *((u8 *) setting->data) = val; |
331 | break; | 332 | break; |
332 | case TYPE_SHORT: | 333 | case TYPE_SHORT: |
333 | *((u16 *) setting->data) = val; | 334 | *((u16 *) setting->data) = val; |
334 | break; | 335 | break; |
335 | case TYPE_INT: | 336 | case TYPE_INT: |
336 | *((u32 *) setting->data) = val; | 337 | *((u32 *) setting->data) = val; |
337 | break; | 338 | break; |
338 | } | 339 | } |
339 | spin_unlock_irq(&ide_lock); | 340 | spin_unlock_irq(&ide_lock); |
340 | return 0; | 341 | return 0; |
@@ -390,7 +391,7 @@ void ide_add_generic_settings (ide_drive_t *drive) | |||
390 | 391 | ||
391 | static void proc_ide_settings_warn(void) | 392 | static void proc_ide_settings_warn(void) |
392 | { | 393 | { |
393 | static int warned = 0; | 394 | static int warned; |
394 | 395 | ||
395 | if (warned) | 396 | if (warned) |
396 | return; | 397 | return; |
@@ -413,11 +414,12 @@ static int proc_ide_read_settings | |||
413 | mutex_lock(&ide_setting_mtx); | 414 | mutex_lock(&ide_setting_mtx); |
414 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); | 415 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); |
415 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); | 416 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); |
416 | while(setting) { | 417 | while (setting) { |
417 | mul_factor = setting->mul_factor; | 418 | mul_factor = setting->mul_factor; |
418 | div_factor = setting->div_factor; | 419 | div_factor = setting->div_factor; |
419 | out += sprintf(out, "%-24s", setting->name); | 420 | out += sprintf(out, "%-24s", setting->name); |
420 | if ((rc = ide_read_setting(drive, setting)) >= 0) | 421 | rc = ide_read_setting(drive, setting); |
422 | if (rc >= 0) | ||
421 | out += sprintf(out, "%-16d", rc * mul_factor / div_factor); | 423 | out += sprintf(out, "%-16d", rc * mul_factor / div_factor); |
422 | else | 424 | else |
423 | out += sprintf(out, "%-16s", "write-only"); | 425 | out += sprintf(out, "%-16s", "write-only"); |
@@ -431,7 +433,7 @@ static int proc_ide_read_settings | |||
431 | } | 433 | } |
432 | len = out - page; | 434 | len = out - page; |
433 | mutex_unlock(&ide_setting_mtx); | 435 | mutex_unlock(&ide_setting_mtx); |
434 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 436 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
435 | } | 437 | } |
436 | 438 | ||
437 | #define MAX_LEN 30 | 439 | #define MAX_LEN 30 |
@@ -512,8 +514,7 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, | |||
512 | 514 | ||
513 | mutex_lock(&ide_setting_mtx); | 515 | mutex_lock(&ide_setting_mtx); |
514 | setting = ide_find_setting_by_name(drive, name); | 516 | setting = ide_find_setting_by_name(drive, name); |
515 | if (!setting) | 517 | if (!setting) { |
516 | { | ||
517 | mutex_unlock(&ide_setting_mtx); | 518 | mutex_unlock(&ide_setting_mtx); |
518 | goto parse_error; | 519 | goto parse_error; |
519 | } | 520 | } |
@@ -533,8 +534,8 @@ parse_error: | |||
533 | int proc_ide_read_capacity | 534 | int proc_ide_read_capacity |
534 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 535 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
535 | { | 536 | { |
536 | int len = sprintf(page,"%llu\n", (long long)0x7fffffff); | 537 | int len = sprintf(page, "%llu\n", (long long)0x7fffffff); |
537 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 538 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
538 | } | 539 | } |
539 | 540 | ||
540 | EXPORT_SYMBOL_GPL(proc_ide_read_capacity); | 541 | EXPORT_SYMBOL_GPL(proc_ide_read_capacity); |
@@ -546,13 +547,13 @@ int proc_ide_read_geometry | |||
546 | char *out = page; | 547 | char *out = page; |
547 | int len; | 548 | int len; |
548 | 549 | ||
549 | out += sprintf(out,"physical %d/%d/%d\n", | 550 | out += sprintf(out, "physical %d/%d/%d\n", |
550 | drive->cyl, drive->head, drive->sect); | 551 | drive->cyl, drive->head, drive->sect); |
551 | out += sprintf(out,"logical %d/%d/%d\n", | 552 | out += sprintf(out, "logical %d/%d/%d\n", |
552 | drive->bios_cyl, drive->bios_head, drive->bios_sect); | 553 | drive->bios_cyl, drive->bios_head, drive->bios_sect); |
553 | 554 | ||
554 | len = out - page; | 555 | len = out - page; |
555 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 556 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
556 | } | 557 | } |
557 | 558 | ||
558 | EXPORT_SYMBOL(proc_ide_read_geometry); | 559 | EXPORT_SYMBOL(proc_ide_read_geometry); |
@@ -566,7 +567,7 @@ static int proc_ide_read_dmodel | |||
566 | 567 | ||
567 | len = sprintf(page, "%.40s\n", | 568 | len = sprintf(page, "%.40s\n", |
568 | (id && id->model[0]) ? (char *)id->model : "(none)"); | 569 | (id && id->model[0]) ? (char *)id->model : "(none)"); |
569 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 570 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
570 | } | 571 | } |
571 | 572 | ||
572 | static int proc_ide_read_driver | 573 | static int proc_ide_read_driver |
@@ -583,7 +584,7 @@ static int proc_ide_read_driver | |||
583 | dev->driver->name, ide_drv->version); | 584 | dev->driver->name, ide_drv->version); |
584 | } else | 585 | } else |
585 | len = sprintf(page, "ide-default version 0.9.newide\n"); | 586 | len = sprintf(page, "ide-default version 0.9.newide\n"); |
586 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 587 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
587 | } | 588 | } |
588 | 589 | ||
589 | static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) | 590 | static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) |
@@ -598,14 +599,14 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) | |||
598 | err = device_attach(dev); | 599 | err = device_attach(dev); |
599 | if (err < 0) | 600 | if (err < 0) |
600 | printk(KERN_WARNING "IDE: %s: device_attach error: %d\n", | 601 | printk(KERN_WARNING "IDE: %s: device_attach error: %d\n", |
601 | __FUNCTION__, err); | 602 | __func__, err); |
602 | drive->driver_req[0] = 0; | 603 | drive->driver_req[0] = 0; |
603 | if (dev->driver == NULL) { | 604 | if (dev->driver == NULL) { |
604 | err = device_attach(dev); | 605 | err = device_attach(dev); |
605 | if (err < 0) | 606 | if (err < 0) |
606 | printk(KERN_WARNING | 607 | printk(KERN_WARNING |
607 | "IDE: %s: device_attach(2) error: %d\n", | 608 | "IDE: %s: device_attach(2) error: %d\n", |
608 | __FUNCTION__, err); | 609 | __func__, err); |
609 | } | 610 | } |
610 | if (dev->driver && !strcmp(dev->driver->name, driver)) | 611 | if (dev->driver && !strcmp(dev->driver->name, driver)) |
611 | ret = 0; | 612 | ret = 0; |
@@ -639,30 +640,26 @@ static int proc_ide_read_media | |||
639 | int len; | 640 | int len; |
640 | 641 | ||
641 | switch (drive->media) { | 642 | switch (drive->media) { |
642 | case ide_disk: media = "disk\n"; | 643 | case ide_disk: media = "disk\n"; break; |
643 | break; | 644 | case ide_cdrom: media = "cdrom\n"; break; |
644 | case ide_cdrom: media = "cdrom\n"; | 645 | case ide_tape: media = "tape\n"; break; |
645 | break; | 646 | case ide_floppy: media = "floppy\n"; break; |
646 | case ide_tape: media = "tape\n"; | 647 | case ide_optical: media = "optical\n"; break; |
647 | break; | 648 | default: media = "UNKNOWN\n"; break; |
648 | case ide_floppy:media = "floppy\n"; | ||
649 | break; | ||
650 | case ide_optical:media = "optical\n"; | ||
651 | break; | ||
652 | default: media = "UNKNOWN\n"; | ||
653 | break; | ||
654 | } | 649 | } |
655 | strcpy(page,media); | 650 | strcpy(page, media); |
656 | len = strlen(media); | 651 | len = strlen(media); |
657 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 652 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
658 | } | 653 | } |
659 | 654 | ||
660 | static ide_proc_entry_t generic_drive_entries[] = { | 655 | static ide_proc_entry_t generic_drive_entries[] = { |
661 | { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, proc_ide_write_driver }, | 656 | { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, |
662 | { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL }, | 657 | proc_ide_write_driver }, |
663 | { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL }, | 658 | { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL }, |
664 | { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL }, | 659 | { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL }, |
665 | { "settings", S_IFREG|S_IRUSR|S_IWUSR,proc_ide_read_settings, proc_ide_write_settings }, | 660 | { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL }, |
661 | { "settings", S_IFREG|S_IRUSR|S_IWUSR, proc_ide_read_settings, | ||
662 | proc_ide_write_settings }, | ||
666 | { NULL, 0, NULL, NULL } | 663 | { NULL, 0, NULL, NULL } |
667 | }; | 664 | }; |
668 | 665 | ||
@@ -734,7 +731,6 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) | |||
734 | spin_unlock_irqrestore(&ide_lock, flags); | 731 | spin_unlock_irqrestore(&ide_lock, flags); |
735 | mutex_unlock(&ide_setting_mtx); | 732 | mutex_unlock(&ide_setting_mtx); |
736 | } | 733 | } |
737 | |||
738 | EXPORT_SYMBOL(ide_proc_unregister_driver); | 734 | EXPORT_SYMBOL(ide_proc_unregister_driver); |
739 | 735 | ||
740 | void ide_proc_port_register_devices(ide_hwif_t *hwif) | 736 | void ide_proc_port_register_devices(ide_hwif_t *hwif) |
@@ -755,7 +751,7 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif) | |||
755 | drive->proc = proc_mkdir(drive->name, parent); | 751 | drive->proc = proc_mkdir(drive->name, parent); |
756 | if (drive->proc) | 752 | if (drive->proc) |
757 | ide_add_proc_entries(drive->proc, generic_drive_entries, drive); | 753 | ide_add_proc_entries(drive->proc, generic_drive_entries, drive); |
758 | sprintf(name,"ide%d/%s", (drive->name[2]-'a')/2, drive->name); | 754 | sprintf(name, "ide%d/%s", (drive->name[2]-'a')/2, drive->name); |
759 | ent = proc_symlink(drive->name, proc_ide_root, name); | 755 | ent = proc_symlink(drive->name, proc_ide_root, name); |
760 | if (!ent) return; | 756 | if (!ent) return; |
761 | } | 757 | } |
@@ -790,15 +786,6 @@ void ide_proc_register_port(ide_hwif_t *hwif) | |||
790 | } | 786 | } |
791 | } | 787 | } |
792 | 788 | ||
793 | #ifdef CONFIG_BLK_DEV_IDEPCI | ||
794 | void ide_pci_create_host_proc(const char *name, get_info_t *get_info) | ||
795 | { | ||
796 | create_proc_info_entry(name, 0, proc_ide_root, get_info); | ||
797 | } | ||
798 | |||
799 | EXPORT_SYMBOL_GPL(ide_pci_create_host_proc); | ||
800 | #endif | ||
801 | |||
802 | void ide_proc_unregister_port(ide_hwif_t *hwif) | 789 | void ide_proc_unregister_port(ide_hwif_t *hwif) |
803 | { | 790 | { |
804 | if (hwif->proc) { | 791 | if (hwif->proc) { |
@@ -825,7 +812,7 @@ static int ide_drivers_show(struct seq_file *s, void *p) | |||
825 | err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); | 812 | err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); |
826 | if (err < 0) | 813 | if (err < 0) |
827 | printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n", | 814 | printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n", |
828 | __FUNCTION__, err); | 815 | __func__, err); |
829 | return 0; | 816 | return 0; |
830 | } | 817 | } |
831 | 818 | ||
diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c index 98888da1b600..0e79efff1deb 100644 --- a/drivers/ide/ide-scan-pci.c +++ b/drivers/ide/ide-scan-pci.c | |||
@@ -102,7 +102,7 @@ static int __init ide_scan_pcibus(void) | |||
102 | if (__pci_register_driver(d, d->driver.owner, | 102 | if (__pci_register_driver(d, d->driver.owner, |
103 | d->driver.mod_name)) | 103 | d->driver.mod_name)) |
104 | printk(KERN_ERR "%s: failed to register %s driver\n", | 104 | printk(KERN_ERR "%s: failed to register %s driver\n", |
105 | __FUNCTION__, d->driver.mod_name); | 105 | __func__, d->driver.mod_name); |
106 | } | 106 | } |
107 | 107 | ||
108 | return 0; | 108 | return 0; |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index f43fd070f1b6..29870c415110 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -72,26 +72,6 @@ enum { | |||
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | /**************************** Tunable parameters *****************************/ | 74 | /**************************** Tunable parameters *****************************/ |
75 | |||
76 | |||
77 | /* | ||
78 | * Pipelined mode parameters. | ||
79 | * | ||
80 | * We try to use the minimum number of stages which is enough to keep the tape | ||
81 | * constantly streaming. To accomplish that, we implement a feedback loop around | ||
82 | * the maximum number of stages: | ||
83 | * | ||
84 | * We start from MIN maximum stages (we will not even use MIN stages if we don't | ||
85 | * need them), increment it by RATE*(MAX-MIN) whenever we sense that the | ||
86 | * pipeline is empty, until we reach the optimum value or until we reach MAX. | ||
87 | * | ||
88 | * Setting the following parameter to 0 is illegal: the pipelined mode cannot be | ||
89 | * disabled (idetape_calculate_speeds() divides by tape->max_stages.) | ||
90 | */ | ||
91 | #define IDETAPE_MIN_PIPELINE_STAGES 1 | ||
92 | #define IDETAPE_MAX_PIPELINE_STAGES 400 | ||
93 | #define IDETAPE_INCREASE_STAGES_RATE 20 | ||
94 | |||
95 | /* | 75 | /* |
96 | * After each failed packet command we issue a request sense command and retry | 76 | * After each failed packet command we issue a request sense command and retry |
97 | * the packet command IDETAPE_MAX_PC_RETRIES times. | 77 | * the packet command IDETAPE_MAX_PC_RETRIES times. |
@@ -224,28 +204,17 @@ enum { | |||
224 | /* 0 When the tape position is unknown */ | 204 | /* 0 When the tape position is unknown */ |
225 | IDETAPE_FLAG_ADDRESS_VALID = (1 << 1), | 205 | IDETAPE_FLAG_ADDRESS_VALID = (1 << 1), |
226 | /* Device already opened */ | 206 | /* Device already opened */ |
227 | IDETAPE_FLAG_BUSY = (1 << 2), | 207 | IDETAPE_FLAG_BUSY = (1 << 2), |
228 | /* Error detected in a pipeline stage */ | ||
229 | IDETAPE_FLAG_PIPELINE_ERR = (1 << 3), | ||
230 | /* Attempt to auto-detect the current user block size */ | 208 | /* Attempt to auto-detect the current user block size */ |
231 | IDETAPE_FLAG_DETECT_BS = (1 << 4), | 209 | IDETAPE_FLAG_DETECT_BS = (1 << 3), |
232 | /* Currently on a filemark */ | 210 | /* Currently on a filemark */ |
233 | IDETAPE_FLAG_FILEMARK = (1 << 5), | 211 | IDETAPE_FLAG_FILEMARK = (1 << 4), |
234 | /* DRQ interrupt device */ | 212 | /* DRQ interrupt device */ |
235 | IDETAPE_FLAG_DRQ_INTERRUPT = (1 << 6), | 213 | IDETAPE_FLAG_DRQ_INTERRUPT = (1 << 5), |
236 | /* pipeline active */ | ||
237 | IDETAPE_FLAG_PIPELINE_ACTIVE = (1 << 7), | ||
238 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | 214 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ |
239 | IDETAPE_FLAG_MEDIUM_PRESENT = (1 << 8), | 215 | IDETAPE_FLAG_MEDIUM_PRESENT = (1 << 6), |
240 | }; | 216 | }; |
241 | 217 | ||
242 | /* A pipeline stage. */ | ||
243 | typedef struct idetape_stage_s { | ||
244 | struct request rq; /* The corresponding request */ | ||
245 | struct idetape_bh *bh; /* The data buffers */ | ||
246 | struct idetape_stage_s *next; /* Pointer to the next stage */ | ||
247 | } idetape_stage_t; | ||
248 | |||
249 | /* | 218 | /* |
250 | * Most of our global data which we need to save even as we leave the driver due | 219 | * Most of our global data which we need to save even as we leave the driver due |
251 | * to an interrupt or a timer event is stored in the struct defined below. | 220 | * to an interrupt or a timer event is stored in the struct defined below. |
@@ -289,9 +258,7 @@ typedef struct ide_tape_obj { | |||
289 | * While polling for DSC we use postponed_rq to postpone the current | 258 | * While polling for DSC we use postponed_rq to postpone the current |
290 | * request so that ide.c will be able to service pending requests on the | 259 | * request so that ide.c will be able to service pending requests on the |
291 | * other device. Note that at most we will have only one DSC (usually | 260 | * other device. Note that at most we will have only one DSC (usually |
292 | * data transfer) request in the device request queue. Additional | 261 | * data transfer) request in the device request queue. |
293 | * requests can be queued in our internal pipeline, but they will be | ||
294 | * visible to ide.c only one at a time. | ||
295 | */ | 262 | */ |
296 | struct request *postponed_rq; | 263 | struct request *postponed_rq; |
297 | /* The time in which we started polling for DSC */ | 264 | /* The time in which we started polling for DSC */ |
@@ -331,43 +298,20 @@ typedef struct ide_tape_obj { | |||
331 | * At most, there is only one ide-tape originated data transfer request | 298 | * At most, there is only one ide-tape originated data transfer request |
332 | * in the device request queue. This allows ide.c to easily service | 299 | * in the device request queue. This allows ide.c to easily service |
333 | * requests from the other device when we postpone our active request. | 300 | * requests from the other device when we postpone our active request. |
334 | * In the pipelined operation mode, we use our internal pipeline | ||
335 | * structure to hold more data requests. The data buffer size is chosen | ||
336 | * based on the tape's recommendation. | ||
337 | */ | 301 | */ |
338 | /* ptr to the request which is waiting in the device request queue */ | 302 | |
339 | struct request *active_data_rq; | ||
340 | /* Data buffer size chosen based on the tape's recommendation */ | 303 | /* Data buffer size chosen based on the tape's recommendation */ |
341 | int stage_size; | 304 | int buffer_size; |
342 | idetape_stage_t *merge_stage; | 305 | /* merge buffer */ |
343 | int merge_stage_size; | 306 | struct idetape_bh *merge_bh; |
307 | /* size of the merge buffer */ | ||
308 | int merge_bh_size; | ||
309 | /* pointer to current buffer head within the merge buffer */ | ||
344 | struct idetape_bh *bh; | 310 | struct idetape_bh *bh; |
345 | char *b_data; | 311 | char *b_data; |
346 | int b_count; | 312 | int b_count; |
347 | 313 | ||
348 | /* | 314 | int pages_per_buffer; |
349 | * Pipeline parameters. | ||
350 | * | ||
351 | * To accomplish non-pipelined mode, we simply set the following | ||
352 | * variables to zero (or NULL, where appropriate). | ||
353 | */ | ||
354 | /* Number of currently used stages */ | ||
355 | int nr_stages; | ||
356 | /* Number of pending stages */ | ||
357 | int nr_pending_stages; | ||
358 | /* We will not allocate more than this number of stages */ | ||
359 | int max_stages, min_pipeline, max_pipeline; | ||
360 | /* The first stage which will be removed from the pipeline */ | ||
361 | idetape_stage_t *first_stage; | ||
362 | /* The currently active stage */ | ||
363 | idetape_stage_t *active_stage; | ||
364 | /* Will be serviced after the currently active request */ | ||
365 | idetape_stage_t *next_stage; | ||
366 | /* New requests will be added to the pipeline here */ | ||
367 | idetape_stage_t *last_stage; | ||
368 | /* Optional free stage which we can use */ | ||
369 | idetape_stage_t *cache_stage; | ||
370 | int pages_per_stage; | ||
371 | /* Wasted space in each stage */ | 315 | /* Wasted space in each stage */ |
372 | int excess_bh_size; | 316 | int excess_bh_size; |
373 | 317 | ||
@@ -388,45 +332,6 @@ typedef struct ide_tape_obj { | |||
388 | /* the tape is write protected (hardware or opened as read-only) */ | 332 | /* the tape is write protected (hardware or opened as read-only) */ |
389 | char write_prot; | 333 | char write_prot; |
390 | 334 | ||
391 | /* | ||
392 | * Limit the number of times a request can be postponed, to avoid an | ||
393 | * infinite postpone deadlock. | ||
394 | */ | ||
395 | int postpone_cnt; | ||
396 | |||
397 | /* | ||
398 | * Measures number of frames: | ||
399 | * | ||
400 | * 1. written/read to/from the driver pipeline (pipeline_head). | ||
401 | * 2. written/read to/from the tape buffers (idetape_bh). | ||
402 | * 3. written/read by the tape to/from the media (tape_head). | ||
403 | */ | ||
404 | int pipeline_head; | ||
405 | int buffer_head; | ||
406 | int tape_head; | ||
407 | int last_tape_head; | ||
408 | |||
409 | /* Speed control at the tape buffers input/output */ | ||
410 | unsigned long insert_time; | ||
411 | int insert_size; | ||
412 | int insert_speed; | ||
413 | int max_insert_speed; | ||
414 | int measure_insert_time; | ||
415 | |||
416 | /* Speed regulation negative feedback loop */ | ||
417 | int speed_control; | ||
418 | int pipeline_head_speed; | ||
419 | int controlled_pipeline_head_speed; | ||
420 | int uncontrolled_pipeline_head_speed; | ||
421 | int controlled_last_pipeline_head; | ||
422 | unsigned long uncontrolled_pipeline_head_time; | ||
423 | unsigned long controlled_pipeline_head_time; | ||
424 | int controlled_previous_pipeline_head; | ||
425 | int uncontrolled_previous_pipeline_head; | ||
426 | unsigned long controlled_previous_head_time; | ||
427 | unsigned long uncontrolled_previous_head_time; | ||
428 | int restart_speed_control_req; | ||
429 | |||
430 | u32 debug_mask; | 335 | u32 debug_mask; |
431 | } idetape_tape_t; | 336 | } idetape_tape_t; |
432 | 337 | ||
@@ -674,128 +579,36 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
674 | } | 579 | } |
675 | } | 580 | } |
676 | 581 | ||
677 | static void idetape_activate_next_stage(ide_drive_t *drive) | 582 | /* Free data buffers completely. */ |
583 | static void ide_tape_kfree_buffer(idetape_tape_t *tape) | ||
678 | { | 584 | { |
679 | idetape_tape_t *tape = drive->driver_data; | 585 | struct idetape_bh *prev_bh, *bh = tape->merge_bh; |
680 | idetape_stage_t *stage = tape->next_stage; | ||
681 | struct request *rq = &stage->rq; | ||
682 | 586 | ||
683 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 587 | while (bh) { |
588 | u32 size = bh->b_size; | ||
684 | 589 | ||
685 | if (stage == NULL) { | 590 | while (size) { |
686 | printk(KERN_ERR "ide-tape: bug: Trying to activate a non" | 591 | unsigned int order = fls(size >> PAGE_SHIFT)-1; |
687 | " existing stage\n"); | ||
688 | return; | ||
689 | } | ||
690 | 592 | ||
691 | rq->rq_disk = tape->disk; | 593 | if (bh->b_data) |
692 | rq->buffer = NULL; | 594 | free_pages((unsigned long)bh->b_data, order); |
693 | rq->special = (void *)stage->bh; | 595 | |
694 | tape->active_data_rq = rq; | 596 | size &= (order-1); |
695 | tape->active_stage = stage; | 597 | bh->b_data += (1 << order) * PAGE_SIZE; |
696 | tape->next_stage = stage->next; | ||
697 | } | ||
698 | |||
699 | /* Free a stage along with its related buffers completely. */ | ||
700 | static void __idetape_kfree_stage(idetape_stage_t *stage) | ||
701 | { | ||
702 | struct idetape_bh *prev_bh, *bh = stage->bh; | ||
703 | int size; | ||
704 | |||
705 | while (bh != NULL) { | ||
706 | if (bh->b_data != NULL) { | ||
707 | size = (int) bh->b_size; | ||
708 | while (size > 0) { | ||
709 | free_page((unsigned long) bh->b_data); | ||
710 | size -= PAGE_SIZE; | ||
711 | bh->b_data += PAGE_SIZE; | ||
712 | } | ||
713 | } | 598 | } |
714 | prev_bh = bh; | 599 | prev_bh = bh; |
715 | bh = bh->b_reqnext; | 600 | bh = bh->b_reqnext; |
716 | kfree(prev_bh); | 601 | kfree(prev_bh); |
717 | } | 602 | } |
718 | kfree(stage); | 603 | kfree(tape->merge_bh); |
719 | } | ||
720 | |||
721 | static void idetape_kfree_stage(idetape_tape_t *tape, idetape_stage_t *stage) | ||
722 | { | ||
723 | __idetape_kfree_stage(stage); | ||
724 | } | 604 | } |
725 | 605 | ||
726 | /* | ||
727 | * Remove tape->first_stage from the pipeline. The caller should avoid race | ||
728 | * conditions. | ||
729 | */ | ||
730 | static void idetape_remove_stage_head(ide_drive_t *drive) | ||
731 | { | ||
732 | idetape_tape_t *tape = drive->driver_data; | ||
733 | idetape_stage_t *stage; | ||
734 | |||
735 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
736 | |||
737 | if (tape->first_stage == NULL) { | ||
738 | printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); | ||
739 | return; | ||
740 | } | ||
741 | if (tape->active_stage == tape->first_stage) { | ||
742 | printk(KERN_ERR "ide-tape: bug: Trying to free our active " | ||
743 | "pipeline stage\n"); | ||
744 | return; | ||
745 | } | ||
746 | stage = tape->first_stage; | ||
747 | tape->first_stage = stage->next; | ||
748 | idetape_kfree_stage(tape, stage); | ||
749 | tape->nr_stages--; | ||
750 | if (tape->first_stage == NULL) { | ||
751 | tape->last_stage = NULL; | ||
752 | if (tape->next_stage != NULL) | ||
753 | printk(KERN_ERR "ide-tape: bug: tape->next_stage !=" | ||
754 | " NULL\n"); | ||
755 | if (tape->nr_stages) | ||
756 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 " | ||
757 | "now\n"); | ||
758 | } | ||
759 | } | ||
760 | |||
761 | /* | ||
762 | * This will free all the pipeline stages starting from new_last_stage->next | ||
763 | * to the end of the list, and point tape->last_stage to new_last_stage. | ||
764 | */ | ||
765 | static void idetape_abort_pipeline(ide_drive_t *drive, | ||
766 | idetape_stage_t *new_last_stage) | ||
767 | { | ||
768 | idetape_tape_t *tape = drive->driver_data; | ||
769 | idetape_stage_t *stage = new_last_stage->next; | ||
770 | idetape_stage_t *nstage; | ||
771 | |||
772 | debug_log(DBG_PROCS, "%s: Enter %s\n", tape->name, __func__); | ||
773 | |||
774 | while (stage) { | ||
775 | nstage = stage->next; | ||
776 | idetape_kfree_stage(tape, stage); | ||
777 | --tape->nr_stages; | ||
778 | --tape->nr_pending_stages; | ||
779 | stage = nstage; | ||
780 | } | ||
781 | if (new_last_stage) | ||
782 | new_last_stage->next = NULL; | ||
783 | tape->last_stage = new_last_stage; | ||
784 | tape->next_stage = NULL; | ||
785 | } | ||
786 | |||
787 | /* | ||
788 | * Finish servicing a request and insert a pending pipeline request into the | ||
789 | * main device queue. | ||
790 | */ | ||
791 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | 606 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) |
792 | { | 607 | { |
793 | struct request *rq = HWGROUP(drive)->rq; | 608 | struct request *rq = HWGROUP(drive)->rq; |
794 | idetape_tape_t *tape = drive->driver_data; | 609 | idetape_tape_t *tape = drive->driver_data; |
795 | unsigned long flags; | 610 | unsigned long flags; |
796 | int error; | 611 | int error; |
797 | int remove_stage = 0; | ||
798 | idetape_stage_t *active_stage; | ||
799 | 612 | ||
800 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 613 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
801 | 614 | ||
@@ -815,58 +628,8 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
815 | 628 | ||
816 | spin_lock_irqsave(&tape->lock, flags); | 629 | spin_lock_irqsave(&tape->lock, flags); |
817 | 630 | ||
818 | /* The request was a pipelined data transfer request */ | ||
819 | if (tape->active_data_rq == rq) { | ||
820 | active_stage = tape->active_stage; | ||
821 | tape->active_stage = NULL; | ||
822 | tape->active_data_rq = NULL; | ||
823 | tape->nr_pending_stages--; | ||
824 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | ||
825 | remove_stage = 1; | ||
826 | if (error) { | ||
827 | set_bit(IDETAPE_FLAG_PIPELINE_ERR, | ||
828 | &tape->flags); | ||
829 | if (error == IDETAPE_ERROR_EOD) | ||
830 | idetape_abort_pipeline(drive, | ||
831 | active_stage); | ||
832 | } | ||
833 | } else if (rq->cmd[0] & REQ_IDETAPE_READ) { | ||
834 | if (error == IDETAPE_ERROR_EOD) { | ||
835 | set_bit(IDETAPE_FLAG_PIPELINE_ERR, | ||
836 | &tape->flags); | ||
837 | idetape_abort_pipeline(drive, active_stage); | ||
838 | } | ||
839 | } | ||
840 | if (tape->next_stage != NULL) { | ||
841 | idetape_activate_next_stage(drive); | ||
842 | |||
843 | /* Insert the next request into the request queue. */ | ||
844 | (void)ide_do_drive_cmd(drive, tape->active_data_rq, | ||
845 | ide_end); | ||
846 | } else if (!error) { | ||
847 | /* | ||
848 | * This is a part of the feedback loop which tries to | ||
849 | * find the optimum number of stages. We are starting | ||
850 | * from a minimum maximum number of stages, and if we | ||
851 | * sense that the pipeline is empty, we try to increase | ||
852 | * it, until we reach the user compile time memory | ||
853 | * limit. | ||
854 | */ | ||
855 | int i = (tape->max_pipeline - tape->min_pipeline) / 10; | ||
856 | |||
857 | tape->max_stages += max(i, 1); | ||
858 | tape->max_stages = max(tape->max_stages, | ||
859 | tape->min_pipeline); | ||
860 | tape->max_stages = min(tape->max_stages, | ||
861 | tape->max_pipeline); | ||
862 | } | ||
863 | } | ||
864 | ide_end_drive_cmd(drive, 0, 0); | 631 | ide_end_drive_cmd(drive, 0, 0); |
865 | 632 | ||
866 | if (remove_stage) | ||
867 | idetape_remove_stage_head(drive); | ||
868 | if (tape->active_data_rq == NULL) | ||
869 | clear_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); | ||
870 | spin_unlock_irqrestore(&tape->lock, flags); | 633 | spin_unlock_irqrestore(&tape->lock, flags); |
871 | return 0; | 634 | return 0; |
872 | } | 635 | } |
@@ -993,7 +756,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
993 | stat = ide_read_status(drive); | 756 | stat = ide_read_status(drive); |
994 | 757 | ||
995 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 758 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
996 | if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { | 759 | if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) { |
997 | /* | 760 | /* |
998 | * A DMA error is sometimes expected. For example, | 761 | * A DMA error is sometimes expected. For example, |
999 | * if the tape is crossing a filemark during a | 762 | * if the tape is crossing a filemark during a |
@@ -1083,10 +846,10 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
1083 | return ide_do_reset(drive); | 846 | return ide_do_reset(drive); |
1084 | } | 847 | } |
1085 | /* Get the number of bytes to transfer on this interrupt. */ | 848 | /* Get the number of bytes to transfer on this interrupt. */ |
1086 | bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) | | 849 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | |
1087 | hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); | 850 | hwif->INB(hwif->io_ports.lbam_addr); |
1088 | 851 | ||
1089 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); | 852 | ireason = hwif->INB(hwif->io_ports.nsect_addr); |
1090 | 853 | ||
1091 | if (ireason & CD) { | 854 | if (ireason & CD) { |
1092 | printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); | 855 | printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); |
@@ -1190,12 +953,12 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
1190 | "yet DRQ isn't asserted\n"); | 953 | "yet DRQ isn't asserted\n"); |
1191 | return startstop; | 954 | return startstop; |
1192 | } | 955 | } |
1193 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); | 956 | ireason = hwif->INB(hwif->io_ports.nsect_addr); |
1194 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | 957 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { |
1195 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " | 958 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " |
1196 | "a packet command, retrying\n"); | 959 | "a packet command, retrying\n"); |
1197 | udelay(100); | 960 | udelay(100); |
1198 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); | 961 | ireason = hwif->INB(hwif->io_ports.nsect_addr); |
1199 | if (retries == 0) { | 962 | if (retries == 0) { |
1200 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " | 963 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " |
1201 | "issuing a packet command, ignoring\n"); | 964 | "issuing a packet command, ignoring\n"); |
@@ -1213,7 +976,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
1213 | #ifdef CONFIG_BLK_DEV_IDEDMA | 976 | #ifdef CONFIG_BLK_DEV_IDEDMA |
1214 | /* Begin DMA, if necessary */ | 977 | /* Begin DMA, if necessary */ |
1215 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) | 978 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) |
1216 | hwif->dma_start(drive); | 979 | hwif->dma_ops->dma_start(drive); |
1217 | #endif | 980 | #endif |
1218 | /* Send the actual packet */ | 981 | /* Send the actual packet */ |
1219 | HWIF(drive)->atapi_output_bytes(drive, pc->c, 12); | 982 | HWIF(drive)->atapi_output_bytes(drive, pc->c, 12); |
@@ -1279,7 +1042,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
1279 | ide_dma_off(drive); | 1042 | ide_dma_off(drive); |
1280 | } | 1043 | } |
1281 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | 1044 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
1282 | dma_ok = !hwif->dma_setup(drive); | 1045 | dma_ok = !hwif->dma_ops->dma_setup(drive); |
1283 | 1046 | ||
1284 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 1047 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
1285 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); | 1048 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); |
@@ -1292,7 +1055,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
1292 | IDETAPE_WAIT_CMD, NULL); | 1055 | IDETAPE_WAIT_CMD, NULL); |
1293 | return ide_started; | 1056 | return ide_started; |
1294 | } else { | 1057 | } else { |
1295 | hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]); | 1058 | hwif->OUTB(WIN_PACKETCMD, hwif->io_ports.command_addr); |
1296 | return idetape_transfer_pc(drive); | 1059 | return idetape_transfer_pc(drive); |
1297 | } | 1060 | } |
1298 | } | 1061 | } |
@@ -1335,69 +1098,6 @@ static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) | |||
1335 | pc->idetape_callback = &idetape_pc_callback; | 1098 | pc->idetape_callback = &idetape_pc_callback; |
1336 | } | 1099 | } |
1337 | 1100 | ||
1338 | static void idetape_calculate_speeds(ide_drive_t *drive) | ||
1339 | { | ||
1340 | idetape_tape_t *tape = drive->driver_data; | ||
1341 | |||
1342 | if (time_after(jiffies, | ||
1343 | tape->controlled_pipeline_head_time + 120 * HZ)) { | ||
1344 | tape->controlled_previous_pipeline_head = | ||
1345 | tape->controlled_last_pipeline_head; | ||
1346 | tape->controlled_previous_head_time = | ||
1347 | tape->controlled_pipeline_head_time; | ||
1348 | tape->controlled_last_pipeline_head = tape->pipeline_head; | ||
1349 | tape->controlled_pipeline_head_time = jiffies; | ||
1350 | } | ||
1351 | if (time_after(jiffies, tape->controlled_pipeline_head_time + 60 * HZ)) | ||
1352 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - | ||
1353 | tape->controlled_last_pipeline_head) * 32 * HZ / | ||
1354 | (jiffies - tape->controlled_pipeline_head_time); | ||
1355 | else if (time_after(jiffies, tape->controlled_previous_head_time)) | ||
1356 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - | ||
1357 | tape->controlled_previous_pipeline_head) * 32 * | ||
1358 | HZ / (jiffies - tape->controlled_previous_head_time); | ||
1359 | |||
1360 | if (tape->nr_pending_stages < tape->max_stages/*- 1 */) { | ||
1361 | /* -1 for read mode error recovery */ | ||
1362 | if (time_after(jiffies, tape->uncontrolled_previous_head_time + | ||
1363 | 10 * HZ)) { | ||
1364 | tape->uncontrolled_pipeline_head_time = jiffies; | ||
1365 | tape->uncontrolled_pipeline_head_speed = | ||
1366 | (tape->pipeline_head - | ||
1367 | tape->uncontrolled_previous_pipeline_head) * | ||
1368 | 32 * HZ / (jiffies - | ||
1369 | tape->uncontrolled_previous_head_time); | ||
1370 | } | ||
1371 | } else { | ||
1372 | tape->uncontrolled_previous_head_time = jiffies; | ||
1373 | tape->uncontrolled_previous_pipeline_head = tape->pipeline_head; | ||
1374 | if (time_after(jiffies, tape->uncontrolled_pipeline_head_time + | ||
1375 | 30 * HZ)) | ||
1376 | tape->uncontrolled_pipeline_head_time = jiffies; | ||
1377 | |||
1378 | } | ||
1379 | tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, | ||
1380 | tape->controlled_pipeline_head_speed); | ||
1381 | |||
1382 | if (tape->speed_control == 1) { | ||
1383 | if (tape->nr_pending_stages >= tape->max_stages / 2) | ||
1384 | tape->max_insert_speed = tape->pipeline_head_speed + | ||
1385 | (1100 - tape->pipeline_head_speed) * 2 * | ||
1386 | (tape->nr_pending_stages - tape->max_stages / 2) | ||
1387 | / tape->max_stages; | ||
1388 | else | ||
1389 | tape->max_insert_speed = 500 + | ||
1390 | (tape->pipeline_head_speed - 500) * 2 * | ||
1391 | tape->nr_pending_stages / tape->max_stages; | ||
1392 | |||
1393 | if (tape->nr_pending_stages >= tape->max_stages * 99 / 100) | ||
1394 | tape->max_insert_speed = 5000; | ||
1395 | } else | ||
1396 | tape->max_insert_speed = tape->speed_control; | ||
1397 | |||
1398 | tape->max_insert_speed = max(tape->max_insert_speed, 500); | ||
1399 | } | ||
1400 | |||
1401 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | 1101 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
1402 | { | 1102 | { |
1403 | idetape_tape_t *tape = drive->driver_data; | 1103 | idetape_tape_t *tape = drive->driver_data; |
@@ -1432,17 +1132,7 @@ static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) | |||
1432 | int blocks = tape->pc->xferred / tape->blk_size; | 1132 | int blocks = tape->pc->xferred / tape->blk_size; |
1433 | 1133 | ||
1434 | tape->avg_size += blocks * tape->blk_size; | 1134 | tape->avg_size += blocks * tape->blk_size; |
1435 | tape->insert_size += blocks * tape->blk_size; | 1135 | |
1436 | if (tape->insert_size > 1024 * 1024) | ||
1437 | tape->measure_insert_time = 1; | ||
1438 | if (tape->measure_insert_time) { | ||
1439 | tape->measure_insert_time = 0; | ||
1440 | tape->insert_time = jiffies; | ||
1441 | tape->insert_size = 0; | ||
1442 | } | ||
1443 | if (time_after(jiffies, tape->insert_time)) | ||
1444 | tape->insert_speed = tape->insert_size / 1024 * HZ / | ||
1445 | (jiffies - tape->insert_time); | ||
1446 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { | 1136 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { |
1447 | tape->avg_speed = tape->avg_size * HZ / | 1137 | tape->avg_speed = tape->avg_size * HZ / |
1448 | (jiffies - tape->avg_time) / 1024; | 1138 | (jiffies - tape->avg_time) / 1024; |
@@ -1475,7 +1165,7 @@ static void idetape_create_read_cmd(idetape_tape_t *tape, | |||
1475 | pc->buf = NULL; | 1165 | pc->buf = NULL; |
1476 | pc->buf_size = length * tape->blk_size; | 1166 | pc->buf_size = length * tape->blk_size; |
1477 | pc->req_xfer = pc->buf_size; | 1167 | pc->req_xfer = pc->buf_size; |
1478 | if (pc->req_xfer == tape->stage_size) | 1168 | if (pc->req_xfer == tape->buffer_size) |
1479 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 1169 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
1480 | } | 1170 | } |
1481 | 1171 | ||
@@ -1495,7 +1185,7 @@ static void idetape_create_write_cmd(idetape_tape_t *tape, | |||
1495 | pc->buf = NULL; | 1185 | pc->buf = NULL; |
1496 | pc->buf_size = length * tape->blk_size; | 1186 | pc->buf_size = length * tape->blk_size; |
1497 | pc->req_xfer = pc->buf_size; | 1187 | pc->req_xfer = pc->buf_size; |
1498 | if (pc->req_xfer == tape->stage_size) | 1188 | if (pc->req_xfer == tape->buffer_size) |
1499 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 1189 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
1500 | } | 1190 | } |
1501 | 1191 | ||
@@ -1547,10 +1237,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1547 | drive->post_reset = 0; | 1237 | drive->post_reset = 0; |
1548 | } | 1238 | } |
1549 | 1239 | ||
1550 | if (time_after(jiffies, tape->insert_time)) | ||
1551 | tape->insert_speed = tape->insert_size / 1024 * HZ / | ||
1552 | (jiffies - tape->insert_time); | ||
1553 | idetape_calculate_speeds(drive); | ||
1554 | if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) && | 1240 | if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) && |
1555 | (stat & SEEK_STAT) == 0) { | 1241 | (stat & SEEK_STAT) == 0) { |
1556 | if (postponed_rq == NULL) { | 1242 | if (postponed_rq == NULL) { |
@@ -1574,16 +1260,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1574 | return ide_stopped; | 1260 | return ide_stopped; |
1575 | } | 1261 | } |
1576 | if (rq->cmd[0] & REQ_IDETAPE_READ) { | 1262 | if (rq->cmd[0] & REQ_IDETAPE_READ) { |
1577 | tape->buffer_head++; | ||
1578 | tape->postpone_cnt = 0; | ||
1579 | pc = idetape_next_pc_storage(drive); | 1263 | pc = idetape_next_pc_storage(drive); |
1580 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, | 1264 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, |
1581 | (struct idetape_bh *)rq->special); | 1265 | (struct idetape_bh *)rq->special); |
1582 | goto out; | 1266 | goto out; |
1583 | } | 1267 | } |
1584 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 1268 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
1585 | tape->buffer_head++; | ||
1586 | tape->postpone_cnt = 0; | ||
1587 | pc = idetape_next_pc_storage(drive); | 1269 | pc = idetape_next_pc_storage(drive); |
1588 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, | 1270 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, |
1589 | (struct idetape_bh *)rq->special); | 1271 | (struct idetape_bh *)rq->special); |
@@ -1604,111 +1286,91 @@ out: | |||
1604 | return idetape_issue_pc(drive, pc); | 1286 | return idetape_issue_pc(drive, pc); |
1605 | } | 1287 | } |
1606 | 1288 | ||
1607 | /* Pipeline related functions */ | ||
1608 | static inline int idetape_pipeline_active(idetape_tape_t *tape) | ||
1609 | { | ||
1610 | int rc1, rc2; | ||
1611 | |||
1612 | rc1 = test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); | ||
1613 | rc2 = (tape->active_data_rq != NULL); | ||
1614 | return rc1; | ||
1615 | } | ||
1616 | |||
1617 | /* | 1289 | /* |
1618 | * The function below uses __get_free_page to allocate a pipeline stage, along | 1290 | * The function below uses __get_free_pages to allocate a data buffer of size |
1619 | * with all the necessary small buffers which together make a buffer of size | 1291 | * tape->buffer_size (or a bit more). We attempt to combine sequential pages as |
1620 | * tape->stage_size (or a bit more). We attempt to combine sequential pages as | ||
1621 | * much as possible. | 1292 | * much as possible. |
1622 | * | 1293 | * |
1623 | * It returns a pointer to the new allocated stage, or NULL if we can't (or | 1294 | * It returns a pointer to the newly allocated buffer, or NULL in case of |
1624 | * don't want to) allocate a stage. | 1295 | * failure. |
1625 | * | ||
1626 | * Pipeline stages are optional and are used to increase performance. If we | ||
1627 | * can't allocate them, we'll manage without them. | ||
1628 | */ | 1296 | */ |
1629 | static idetape_stage_t *__idetape_kmalloc_stage(idetape_tape_t *tape, int full, | 1297 | static struct idetape_bh *ide_tape_kmalloc_buffer(idetape_tape_t *tape, |
1630 | int clear) | 1298 | int full, int clear) |
1631 | { | 1299 | { |
1632 | idetape_stage_t *stage; | 1300 | struct idetape_bh *prev_bh, *bh, *merge_bh; |
1633 | struct idetape_bh *prev_bh, *bh; | 1301 | int pages = tape->pages_per_buffer; |
1634 | int pages = tape->pages_per_stage; | 1302 | unsigned int order, b_allocd; |
1635 | char *b_data = NULL; | 1303 | char *b_data = NULL; |
1636 | 1304 | ||
1637 | stage = kmalloc(sizeof(idetape_stage_t), GFP_KERNEL); | 1305 | merge_bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); |
1638 | if (!stage) | 1306 | bh = merge_bh; |
1639 | return NULL; | ||
1640 | stage->next = NULL; | ||
1641 | |||
1642 | stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); | ||
1643 | bh = stage->bh; | ||
1644 | if (bh == NULL) | 1307 | if (bh == NULL) |
1645 | goto abort; | 1308 | goto abort; |
1646 | bh->b_reqnext = NULL; | 1309 | |
1647 | bh->b_data = (char *) __get_free_page(GFP_KERNEL); | 1310 | order = fls(pages) - 1; |
1311 | bh->b_data = (char *) __get_free_pages(GFP_KERNEL, order); | ||
1648 | if (!bh->b_data) | 1312 | if (!bh->b_data) |
1649 | goto abort; | 1313 | goto abort; |
1314 | b_allocd = (1 << order) * PAGE_SIZE; | ||
1315 | pages &= (order-1); | ||
1316 | |||
1650 | if (clear) | 1317 | if (clear) |
1651 | memset(bh->b_data, 0, PAGE_SIZE); | 1318 | memset(bh->b_data, 0, b_allocd); |
1652 | bh->b_size = PAGE_SIZE; | 1319 | bh->b_reqnext = NULL; |
1320 | bh->b_size = b_allocd; | ||
1653 | atomic_set(&bh->b_count, full ? bh->b_size : 0); | 1321 | atomic_set(&bh->b_count, full ? bh->b_size : 0); |
1654 | 1322 | ||
1655 | while (--pages) { | 1323 | while (pages) { |
1656 | b_data = (char *) __get_free_page(GFP_KERNEL); | 1324 | order = fls(pages) - 1; |
1325 | b_data = (char *) __get_free_pages(GFP_KERNEL, order); | ||
1657 | if (!b_data) | 1326 | if (!b_data) |
1658 | goto abort; | 1327 | goto abort; |
1328 | b_allocd = (1 << order) * PAGE_SIZE; | ||
1329 | |||
1659 | if (clear) | 1330 | if (clear) |
1660 | memset(b_data, 0, PAGE_SIZE); | 1331 | memset(b_data, 0, b_allocd); |
1661 | if (bh->b_data == b_data + PAGE_SIZE) { | 1332 | |
1662 | bh->b_size += PAGE_SIZE; | 1333 | /* newly allocated page frames below buffer header or ...*/ |
1663 | bh->b_data -= PAGE_SIZE; | 1334 | if (bh->b_data == b_data + b_allocd) { |
1335 | bh->b_size += b_allocd; | ||
1336 | bh->b_data -= b_allocd; | ||
1664 | if (full) | 1337 | if (full) |
1665 | atomic_add(PAGE_SIZE, &bh->b_count); | 1338 | atomic_add(b_allocd, &bh->b_count); |
1666 | continue; | 1339 | continue; |
1667 | } | 1340 | } |
1341 | /* they are above the header */ | ||
1668 | if (b_data == bh->b_data + bh->b_size) { | 1342 | if (b_data == bh->b_data + bh->b_size) { |
1669 | bh->b_size += PAGE_SIZE; | 1343 | bh->b_size += b_allocd; |
1670 | if (full) | 1344 | if (full) |
1671 | atomic_add(PAGE_SIZE, &bh->b_count); | 1345 | atomic_add(b_allocd, &bh->b_count); |
1672 | continue; | 1346 | continue; |
1673 | } | 1347 | } |
1674 | prev_bh = bh; | 1348 | prev_bh = bh; |
1675 | bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); | 1349 | bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); |
1676 | if (!bh) { | 1350 | if (!bh) { |
1677 | free_page((unsigned long) b_data); | 1351 | free_pages((unsigned long) b_data, order); |
1678 | goto abort; | 1352 | goto abort; |
1679 | } | 1353 | } |
1680 | bh->b_reqnext = NULL; | 1354 | bh->b_reqnext = NULL; |
1681 | bh->b_data = b_data; | 1355 | bh->b_data = b_data; |
1682 | bh->b_size = PAGE_SIZE; | 1356 | bh->b_size = b_allocd; |
1683 | atomic_set(&bh->b_count, full ? bh->b_size : 0); | 1357 | atomic_set(&bh->b_count, full ? bh->b_size : 0); |
1684 | prev_bh->b_reqnext = bh; | 1358 | prev_bh->b_reqnext = bh; |
1359 | |||
1360 | pages &= (order-1); | ||
1685 | } | 1361 | } |
1362 | |||
1686 | bh->b_size -= tape->excess_bh_size; | 1363 | bh->b_size -= tape->excess_bh_size; |
1687 | if (full) | 1364 | if (full) |
1688 | atomic_sub(tape->excess_bh_size, &bh->b_count); | 1365 | atomic_sub(tape->excess_bh_size, &bh->b_count); |
1689 | return stage; | 1366 | return merge_bh; |
1690 | abort: | 1367 | abort: |
1691 | __idetape_kfree_stage(stage); | 1368 | ide_tape_kfree_buffer(tape); |
1692 | return NULL; | 1369 | return NULL; |
1693 | } | 1370 | } |
1694 | 1371 | ||
1695 | static idetape_stage_t *idetape_kmalloc_stage(idetape_tape_t *tape) | ||
1696 | { | ||
1697 | idetape_stage_t *cache_stage = tape->cache_stage; | ||
1698 | |||
1699 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1700 | |||
1701 | if (tape->nr_stages >= tape->max_stages) | ||
1702 | return NULL; | ||
1703 | if (cache_stage != NULL) { | ||
1704 | tape->cache_stage = NULL; | ||
1705 | return cache_stage; | ||
1706 | } | ||
1707 | return __idetape_kmalloc_stage(tape, 0, 0); | ||
1708 | } | ||
1709 | |||
1710 | static int idetape_copy_stage_from_user(idetape_tape_t *tape, | 1372 | static int idetape_copy_stage_from_user(idetape_tape_t *tape, |
1711 | idetape_stage_t *stage, const char __user *buf, int n) | 1373 | const char __user *buf, int n) |
1712 | { | 1374 | { |
1713 | struct idetape_bh *bh = tape->bh; | 1375 | struct idetape_bh *bh = tape->bh; |
1714 | int count; | 1376 | int count; |
@@ -1740,7 +1402,7 @@ static int idetape_copy_stage_from_user(idetape_tape_t *tape, | |||
1740 | } | 1402 | } |
1741 | 1403 | ||
1742 | static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf, | 1404 | static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf, |
1743 | idetape_stage_t *stage, int n) | 1405 | int n) |
1744 | { | 1406 | { |
1745 | struct idetape_bh *bh = tape->bh; | 1407 | struct idetape_bh *bh = tape->bh; |
1746 | int count; | 1408 | int count; |
@@ -1771,11 +1433,11 @@ static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf, | |||
1771 | return ret; | 1433 | return ret; |
1772 | } | 1434 | } |
1773 | 1435 | ||
1774 | static void idetape_init_merge_stage(idetape_tape_t *tape) | 1436 | static void idetape_init_merge_buffer(idetape_tape_t *tape) |
1775 | { | 1437 | { |
1776 | struct idetape_bh *bh = tape->merge_stage->bh; | 1438 | struct idetape_bh *bh = tape->merge_bh; |
1439 | tape->bh = tape->merge_bh; | ||
1777 | 1440 | ||
1778 | tape->bh = bh; | ||
1779 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) | 1441 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) |
1780 | atomic_set(&bh->b_count, 0); | 1442 | atomic_set(&bh->b_count, 0); |
1781 | else { | 1443 | else { |
@@ -1784,61 +1446,6 @@ static void idetape_init_merge_stage(idetape_tape_t *tape) | |||
1784 | } | 1446 | } |
1785 | } | 1447 | } |
1786 | 1448 | ||
1787 | static void idetape_switch_buffers(idetape_tape_t *tape, idetape_stage_t *stage) | ||
1788 | { | ||
1789 | struct idetape_bh *tmp; | ||
1790 | |||
1791 | tmp = stage->bh; | ||
1792 | stage->bh = tape->merge_stage->bh; | ||
1793 | tape->merge_stage->bh = tmp; | ||
1794 | idetape_init_merge_stage(tape); | ||
1795 | } | ||
1796 | |||
1797 | /* Add a new stage at the end of the pipeline. */ | ||
1798 | static void idetape_add_stage_tail(ide_drive_t *drive, idetape_stage_t *stage) | ||
1799 | { | ||
1800 | idetape_tape_t *tape = drive->driver_data; | ||
1801 | unsigned long flags; | ||
1802 | |||
1803 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1804 | |||
1805 | spin_lock_irqsave(&tape->lock, flags); | ||
1806 | stage->next = NULL; | ||
1807 | if (tape->last_stage != NULL) | ||
1808 | tape->last_stage->next = stage; | ||
1809 | else | ||
1810 | tape->first_stage = stage; | ||
1811 | tape->next_stage = stage; | ||
1812 | tape->last_stage = stage; | ||
1813 | if (tape->next_stage == NULL) | ||
1814 | tape->next_stage = tape->last_stage; | ||
1815 | tape->nr_stages++; | ||
1816 | tape->nr_pending_stages++; | ||
1817 | spin_unlock_irqrestore(&tape->lock, flags); | ||
1818 | } | ||
1819 | |||
1820 | /* Install a completion in a pending request and sleep until it is serviced. The | ||
1821 | * caller should ensure that the request will not be serviced before we install | ||
1822 | * the completion (usually by disabling interrupts). | ||
1823 | */ | ||
1824 | static void idetape_wait_for_request(ide_drive_t *drive, struct request *rq) | ||
1825 | { | ||
1826 | DECLARE_COMPLETION_ONSTACK(wait); | ||
1827 | idetape_tape_t *tape = drive->driver_data; | ||
1828 | |||
1829 | if (rq == NULL || !blk_special_request(rq)) { | ||
1830 | printk(KERN_ERR "ide-tape: bug: Trying to sleep on non-valid" | ||
1831 | " request\n"); | ||
1832 | return; | ||
1833 | } | ||
1834 | rq->end_io_data = &wait; | ||
1835 | rq->end_io = blk_end_sync_rq; | ||
1836 | spin_unlock_irq(&tape->lock); | ||
1837 | wait_for_completion(&wait); | ||
1838 | /* The stage and its struct request have been deallocated */ | ||
1839 | spin_lock_irq(&tape->lock); | ||
1840 | } | ||
1841 | |||
1842 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | 1449 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) |
1843 | { | 1450 | { |
1844 | idetape_tape_t *tape = drive->driver_data; | 1451 | idetape_tape_t *tape = drive->driver_data; |
@@ -1907,7 +1514,7 @@ static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | |||
1907 | * to the request list without waiting for it to be serviced! In that case, we | 1514 | * to the request list without waiting for it to be serviced! In that case, we |
1908 | * usually use idetape_queue_pc_head(). | 1515 | * usually use idetape_queue_pc_head(). |
1909 | */ | 1516 | */ |
1910 | static int __idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | 1517 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
1911 | { | 1518 | { |
1912 | struct ide_tape_obj *tape = drive->driver_data; | 1519 | struct ide_tape_obj *tape = drive->driver_data; |
1913 | struct request rq; | 1520 | struct request rq; |
@@ -1939,7 +1546,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1939 | timeout += jiffies; | 1546 | timeout += jiffies; |
1940 | while (time_before(jiffies, timeout)) { | 1547 | while (time_before(jiffies, timeout)) { |
1941 | idetape_create_test_unit_ready_cmd(&pc); | 1548 | idetape_create_test_unit_ready_cmd(&pc); |
1942 | if (!__idetape_queue_pc_tail(drive, &pc)) | 1549 | if (!idetape_queue_pc_tail(drive, &pc)) |
1943 | return 0; | 1550 | return 0; |
1944 | if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) | 1551 | if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) |
1945 | || (tape->asc == 0x3A)) { | 1552 | || (tape->asc == 0x3A)) { |
@@ -1948,7 +1555,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1948 | return -ENOMEDIUM; | 1555 | return -ENOMEDIUM; |
1949 | idetape_create_load_unload_cmd(drive, &pc, | 1556 | idetape_create_load_unload_cmd(drive, &pc, |
1950 | IDETAPE_LU_LOAD_MASK); | 1557 | IDETAPE_LU_LOAD_MASK); |
1951 | __idetape_queue_pc_tail(drive, &pc); | 1558 | idetape_queue_pc_tail(drive, &pc); |
1952 | load_attempted = 1; | 1559 | load_attempted = 1; |
1953 | /* not about to be ready */ | 1560 | /* not about to be ready */ |
1954 | } else if (!(tape->sense_key == 2 && tape->asc == 4 && | 1561 | } else if (!(tape->sense_key == 2 && tape->asc == 4 && |
@@ -1959,11 +1566,6 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1959 | return -EIO; | 1566 | return -EIO; |
1960 | } | 1567 | } |
1961 | 1568 | ||
1962 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | ||
1963 | { | ||
1964 | return __idetape_queue_pc_tail(drive, pc); | ||
1965 | } | ||
1966 | |||
1967 | static int idetape_flush_tape_buffers(ide_drive_t *drive) | 1569 | static int idetape_flush_tape_buffers(ide_drive_t *drive) |
1968 | { | 1570 | { |
1969 | struct ide_atapi_pc pc; | 1571 | struct ide_atapi_pc pc; |
@@ -2029,50 +1631,21 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive, | |||
2029 | return 1; | 1631 | return 1; |
2030 | } | 1632 | } |
2031 | 1633 | ||
2032 | static int __idetape_discard_read_pipeline(ide_drive_t *drive) | 1634 | static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) |
2033 | { | 1635 | { |
2034 | idetape_tape_t *tape = drive->driver_data; | 1636 | idetape_tape_t *tape = drive->driver_data; |
2035 | unsigned long flags; | ||
2036 | int cnt; | ||
2037 | 1637 | ||
2038 | if (tape->chrdev_dir != IDETAPE_DIR_READ) | 1638 | if (tape->chrdev_dir != IDETAPE_DIR_READ) |
2039 | return 0; | 1639 | return; |
2040 | 1640 | ||
2041 | /* Remove merge stage. */ | 1641 | clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags); |
2042 | cnt = tape->merge_stage_size / tape->blk_size; | 1642 | tape->merge_bh_size = 0; |
2043 | if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) | 1643 | if (tape->merge_bh != NULL) { |
2044 | ++cnt; /* Filemarks count as 1 sector */ | 1644 | ide_tape_kfree_buffer(tape); |
2045 | tape->merge_stage_size = 0; | 1645 | tape->merge_bh = NULL; |
2046 | if (tape->merge_stage != NULL) { | ||
2047 | __idetape_kfree_stage(tape->merge_stage); | ||
2048 | tape->merge_stage = NULL; | ||
2049 | } | 1646 | } |
2050 | 1647 | ||
2051 | /* Clear pipeline flags. */ | ||
2052 | clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags); | ||
2053 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 1648 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
2054 | |||
2055 | /* Remove pipeline stages. */ | ||
2056 | if (tape->first_stage == NULL) | ||
2057 | return 0; | ||
2058 | |||
2059 | spin_lock_irqsave(&tape->lock, flags); | ||
2060 | tape->next_stage = NULL; | ||
2061 | if (idetape_pipeline_active(tape)) | ||
2062 | idetape_wait_for_request(drive, tape->active_data_rq); | ||
2063 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2064 | |||
2065 | while (tape->first_stage != NULL) { | ||
2066 | struct request *rq_ptr = &tape->first_stage->rq; | ||
2067 | |||
2068 | cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors; | ||
2069 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) | ||
2070 | ++cnt; | ||
2071 | idetape_remove_stage_head(drive); | ||
2072 | } | ||
2073 | tape->nr_pending_stages = 0; | ||
2074 | tape->max_stages = tape->min_pipeline; | ||
2075 | return cnt; | ||
2076 | } | 1649 | } |
2077 | 1650 | ||
2078 | /* | 1651 | /* |
@@ -2089,7 +1662,7 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
2089 | struct ide_atapi_pc pc; | 1662 | struct ide_atapi_pc pc; |
2090 | 1663 | ||
2091 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 1664 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
2092 | __idetape_discard_read_pipeline(drive); | 1665 | __ide_tape_discard_merge_buffer(drive); |
2093 | idetape_wait_ready(drive, 60 * 5 * HZ); | 1666 | idetape_wait_ready(drive, 60 * 5 * HZ); |
2094 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); | 1667 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); |
2095 | retval = idetape_queue_pc_tail(drive, &pc); | 1668 | retval = idetape_queue_pc_tail(drive, &pc); |
@@ -2100,20 +1673,19 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
2100 | return (idetape_queue_pc_tail(drive, &pc)); | 1673 | return (idetape_queue_pc_tail(drive, &pc)); |
2101 | } | 1674 | } |
2102 | 1675 | ||
2103 | static void idetape_discard_read_pipeline(ide_drive_t *drive, | 1676 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, |
2104 | int restore_position) | 1677 | int restore_position) |
2105 | { | 1678 | { |
2106 | idetape_tape_t *tape = drive->driver_data; | 1679 | idetape_tape_t *tape = drive->driver_data; |
2107 | int cnt; | ||
2108 | int seek, position; | 1680 | int seek, position; |
2109 | 1681 | ||
2110 | cnt = __idetape_discard_read_pipeline(drive); | 1682 | __ide_tape_discard_merge_buffer(drive); |
2111 | if (restore_position) { | 1683 | if (restore_position) { |
2112 | position = idetape_read_position(drive); | 1684 | position = idetape_read_position(drive); |
2113 | seek = position > cnt ? position - cnt : 0; | 1685 | seek = position > 0 ? position : 0; |
2114 | if (idetape_position_tape(drive, seek, 0, 0)) { | 1686 | if (idetape_position_tape(drive, seek, 0, 0)) { |
2115 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" | 1687 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" |
2116 | " discard_pipeline()\n", tape->name); | 1688 | " %s\n", tape->name, __func__); |
2117 | return; | 1689 | return; |
2118 | } | 1690 | } |
2119 | } | 1691 | } |
@@ -2131,12 +1703,6 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
2131 | 1703 | ||
2132 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); | 1704 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); |
2133 | 1705 | ||
2134 | if (idetape_pipeline_active(tape)) { | ||
2135 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n", | ||
2136 | __func__); | ||
2137 | return (0); | ||
2138 | } | ||
2139 | |||
2140 | idetape_init_rq(&rq, cmd); | 1706 | idetape_init_rq(&rq, cmd); |
2141 | rq.rq_disk = tape->disk; | 1707 | rq.rq_disk = tape->disk; |
2142 | rq.special = (void *)bh; | 1708 | rq.special = (void *)bh; |
@@ -2148,27 +1714,13 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
2148 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) | 1714 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) |
2149 | return 0; | 1715 | return 0; |
2150 | 1716 | ||
2151 | if (tape->merge_stage) | 1717 | if (tape->merge_bh) |
2152 | idetape_init_merge_stage(tape); | 1718 | idetape_init_merge_buffer(tape); |
2153 | if (rq.errors == IDETAPE_ERROR_GENERAL) | 1719 | if (rq.errors == IDETAPE_ERROR_GENERAL) |
2154 | return -EIO; | 1720 | return -EIO; |
2155 | return (tape->blk_size * (blocks-rq.current_nr_sectors)); | 1721 | return (tape->blk_size * (blocks-rq.current_nr_sectors)); |
2156 | } | 1722 | } |
2157 | 1723 | ||
2158 | /* start servicing the pipeline stages, starting from tape->next_stage. */ | ||
2159 | static void idetape_plug_pipeline(ide_drive_t *drive) | ||
2160 | { | ||
2161 | idetape_tape_t *tape = drive->driver_data; | ||
2162 | |||
2163 | if (tape->next_stage == NULL) | ||
2164 | return; | ||
2165 | if (!idetape_pipeline_active(tape)) { | ||
2166 | set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); | ||
2167 | idetape_activate_next_stage(drive); | ||
2168 | (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); | ||
2169 | } | ||
2170 | } | ||
2171 | |||
2172 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | 1724 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) |
2173 | { | 1725 | { |
2174 | idetape_init_pc(pc); | 1726 | idetape_init_pc(pc); |
@@ -2206,135 +1758,39 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | |||
2206 | pc->idetape_callback = &idetape_pc_callback; | 1758 | pc->idetape_callback = &idetape_pc_callback; |
2207 | } | 1759 | } |
2208 | 1760 | ||
2209 | static void idetape_wait_first_stage(ide_drive_t *drive) | 1761 | /* Queue up a character device originated write request. */ |
2210 | { | ||
2211 | idetape_tape_t *tape = drive->driver_data; | ||
2212 | unsigned long flags; | ||
2213 | |||
2214 | if (tape->first_stage == NULL) | ||
2215 | return; | ||
2216 | spin_lock_irqsave(&tape->lock, flags); | ||
2217 | if (tape->active_stage == tape->first_stage) | ||
2218 | idetape_wait_for_request(drive, tape->active_data_rq); | ||
2219 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2220 | } | ||
2221 | |||
2222 | /* | ||
2223 | * Try to add a character device originated write request to our pipeline. In | ||
2224 | * case we don't succeed, we revert to non-pipelined operation mode for this | ||
2225 | * request. In order to accomplish that, we | ||
2226 | * | ||
2227 | * 1. Try to allocate a new pipeline stage. | ||
2228 | * 2. If we can't, wait for more and more requests to be serviced and try again | ||
2229 | * each time. | ||
2230 | * 3. If we still can't allocate a stage, fallback to non-pipelined operation | ||
2231 | * mode for this request. | ||
2232 | */ | ||
2233 | static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) | 1762 | static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) |
2234 | { | 1763 | { |
2235 | idetape_tape_t *tape = drive->driver_data; | 1764 | idetape_tape_t *tape = drive->driver_data; |
2236 | idetape_stage_t *new_stage; | ||
2237 | unsigned long flags; | ||
2238 | struct request *rq; | ||
2239 | 1765 | ||
2240 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); | 1766 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); |
2241 | 1767 | ||
2242 | /* Attempt to allocate a new stage. Beware possible race conditions. */ | 1768 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, |
2243 | while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { | 1769 | blocks, tape->merge_bh); |
2244 | spin_lock_irqsave(&tape->lock, flags); | ||
2245 | if (idetape_pipeline_active(tape)) { | ||
2246 | idetape_wait_for_request(drive, tape->active_data_rq); | ||
2247 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2248 | } else { | ||
2249 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2250 | idetape_plug_pipeline(drive); | ||
2251 | if (idetape_pipeline_active(tape)) | ||
2252 | continue; | ||
2253 | /* | ||
2254 | * The machine is short on memory. Fallback to non- | ||
2255 | * pipelined operation mode for this request. | ||
2256 | */ | ||
2257 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, | ||
2258 | blocks, tape->merge_stage->bh); | ||
2259 | } | ||
2260 | } | ||
2261 | rq = &new_stage->rq; | ||
2262 | idetape_init_rq(rq, REQ_IDETAPE_WRITE); | ||
2263 | /* Doesn't actually matter - We always assume sequential access */ | ||
2264 | rq->sector = tape->first_frame; | ||
2265 | rq->current_nr_sectors = blocks; | ||
2266 | rq->nr_sectors = blocks; | ||
2267 | |||
2268 | idetape_switch_buffers(tape, new_stage); | ||
2269 | idetape_add_stage_tail(drive, new_stage); | ||
2270 | tape->pipeline_head++; | ||
2271 | idetape_calculate_speeds(drive); | ||
2272 | |||
2273 | /* | ||
2274 | * Estimate whether the tape has stopped writing by checking if our | ||
2275 | * write pipeline is currently empty. If we are not writing anymore, | ||
2276 | * wait for the pipeline to be almost completely full (90%) before | ||
2277 | * starting to service requests, so that we will be able to keep up with | ||
2278 | * the higher speeds of the tape. | ||
2279 | */ | ||
2280 | if (!idetape_pipeline_active(tape)) { | ||
2281 | if (tape->nr_stages >= tape->max_stages * 9 / 10 || | ||
2282 | tape->nr_stages >= tape->max_stages - | ||
2283 | tape->uncontrolled_pipeline_head_speed * 3 * 1024 / | ||
2284 | tape->blk_size) { | ||
2285 | tape->measure_insert_time = 1; | ||
2286 | tape->insert_time = jiffies; | ||
2287 | tape->insert_size = 0; | ||
2288 | tape->insert_speed = 0; | ||
2289 | idetape_plug_pipeline(drive); | ||
2290 | } | ||
2291 | } | ||
2292 | if (test_and_clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags)) | ||
2293 | /* Return a deferred error */ | ||
2294 | return -EIO; | ||
2295 | return blocks; | ||
2296 | } | ||
2297 | |||
2298 | /* | ||
2299 | * Wait until all pending pipeline requests are serviced. Typically called on | ||
2300 | * device close. | ||
2301 | */ | ||
2302 | static void idetape_wait_for_pipeline(ide_drive_t *drive) | ||
2303 | { | ||
2304 | idetape_tape_t *tape = drive->driver_data; | ||
2305 | unsigned long flags; | ||
2306 | |||
2307 | while (tape->next_stage || idetape_pipeline_active(tape)) { | ||
2308 | idetape_plug_pipeline(drive); | ||
2309 | spin_lock_irqsave(&tape->lock, flags); | ||
2310 | if (idetape_pipeline_active(tape)) | ||
2311 | idetape_wait_for_request(drive, tape->active_data_rq); | ||
2312 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2313 | } | ||
2314 | } | 1770 | } |
2315 | 1771 | ||
2316 | static void idetape_empty_write_pipeline(ide_drive_t *drive) | 1772 | static void ide_tape_flush_merge_buffer(ide_drive_t *drive) |
2317 | { | 1773 | { |
2318 | idetape_tape_t *tape = drive->driver_data; | 1774 | idetape_tape_t *tape = drive->driver_data; |
2319 | int blocks, min; | 1775 | int blocks, min; |
2320 | struct idetape_bh *bh; | 1776 | struct idetape_bh *bh; |
2321 | 1777 | ||
2322 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { | 1778 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { |
2323 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline," | 1779 | printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer" |
2324 | " but we are not writing.\n"); | 1780 | " but we are not writing.\n"); |
2325 | return; | 1781 | return; |
2326 | } | 1782 | } |
2327 | if (tape->merge_stage_size > tape->stage_size) { | 1783 | if (tape->merge_bh_size > tape->buffer_size) { |
2328 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); | 1784 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); |
2329 | tape->merge_stage_size = tape->stage_size; | 1785 | tape->merge_bh_size = tape->buffer_size; |
2330 | } | 1786 | } |
2331 | if (tape->merge_stage_size) { | 1787 | if (tape->merge_bh_size) { |
2332 | blocks = tape->merge_stage_size / tape->blk_size; | 1788 | blocks = tape->merge_bh_size / tape->blk_size; |
2333 | if (tape->merge_stage_size % tape->blk_size) { | 1789 | if (tape->merge_bh_size % tape->blk_size) { |
2334 | unsigned int i; | 1790 | unsigned int i; |
2335 | 1791 | ||
2336 | blocks++; | 1792 | blocks++; |
2337 | i = tape->blk_size - tape->merge_stage_size % | 1793 | i = tape->blk_size - tape->merge_bh_size % |
2338 | tape->blk_size; | 1794 | tape->blk_size; |
2339 | bh = tape->bh->b_reqnext; | 1795 | bh = tape->bh->b_reqnext; |
2340 | while (bh) { | 1796 | while (bh) { |
@@ -2358,74 +1814,33 @@ static void idetape_empty_write_pipeline(ide_drive_t *drive) | |||
2358 | } | 1814 | } |
2359 | } | 1815 | } |
2360 | (void) idetape_add_chrdev_write_request(drive, blocks); | 1816 | (void) idetape_add_chrdev_write_request(drive, blocks); |
2361 | tape->merge_stage_size = 0; | 1817 | tape->merge_bh_size = 0; |
2362 | } | 1818 | } |
2363 | idetape_wait_for_pipeline(drive); | 1819 | if (tape->merge_bh != NULL) { |
2364 | if (tape->merge_stage != NULL) { | 1820 | ide_tape_kfree_buffer(tape); |
2365 | __idetape_kfree_stage(tape->merge_stage); | 1821 | tape->merge_bh = NULL; |
2366 | tape->merge_stage = NULL; | ||
2367 | } | 1822 | } |
2368 | clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags); | ||
2369 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 1823 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
2370 | |||
2371 | /* | ||
2372 | * On the next backup, perform the feedback loop again. (I don't want to | ||
2373 | * keep sense information between backups, as some systems are | ||
2374 | * constantly on, and the system load can be totally different on the | ||
2375 | * next backup). | ||
2376 | */ | ||
2377 | tape->max_stages = tape->min_pipeline; | ||
2378 | if (tape->first_stage != NULL || | ||
2379 | tape->next_stage != NULL || | ||
2380 | tape->last_stage != NULL || | ||
2381 | tape->nr_stages != 0) { | ||
2382 | printk(KERN_ERR "ide-tape: ide-tape pipeline bug, " | ||
2383 | "first_stage %p, next_stage %p, " | ||
2384 | "last_stage %p, nr_stages %d\n", | ||
2385 | tape->first_stage, tape->next_stage, | ||
2386 | tape->last_stage, tape->nr_stages); | ||
2387 | } | ||
2388 | } | 1824 | } |
2389 | 1825 | ||
2390 | static void idetape_restart_speed_control(ide_drive_t *drive) | 1826 | static int idetape_init_read(ide_drive_t *drive) |
2391 | { | 1827 | { |
2392 | idetape_tape_t *tape = drive->driver_data; | 1828 | idetape_tape_t *tape = drive->driver_data; |
2393 | |||
2394 | tape->restart_speed_control_req = 0; | ||
2395 | tape->pipeline_head = 0; | ||
2396 | tape->controlled_last_pipeline_head = 0; | ||
2397 | tape->controlled_previous_pipeline_head = 0; | ||
2398 | tape->uncontrolled_previous_pipeline_head = 0; | ||
2399 | tape->controlled_pipeline_head_speed = 5000; | ||
2400 | tape->pipeline_head_speed = 5000; | ||
2401 | tape->uncontrolled_pipeline_head_speed = 0; | ||
2402 | tape->controlled_pipeline_head_time = | ||
2403 | tape->uncontrolled_pipeline_head_time = jiffies; | ||
2404 | tape->controlled_previous_head_time = | ||
2405 | tape->uncontrolled_previous_head_time = jiffies; | ||
2406 | } | ||
2407 | |||
2408 | static int idetape_init_read(ide_drive_t *drive, int max_stages) | ||
2409 | { | ||
2410 | idetape_tape_t *tape = drive->driver_data; | ||
2411 | idetape_stage_t *new_stage; | ||
2412 | struct request rq; | ||
2413 | int bytes_read; | 1829 | int bytes_read; |
2414 | u16 blocks = *(u16 *)&tape->caps[12]; | ||
2415 | 1830 | ||
2416 | /* Initialize read operation */ | 1831 | /* Initialize read operation */ |
2417 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 1832 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
2418 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { | 1833 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { |
2419 | idetape_empty_write_pipeline(drive); | 1834 | ide_tape_flush_merge_buffer(drive); |
2420 | idetape_flush_tape_buffers(drive); | 1835 | idetape_flush_tape_buffers(drive); |
2421 | } | 1836 | } |
2422 | if (tape->merge_stage || tape->merge_stage_size) { | 1837 | if (tape->merge_bh || tape->merge_bh_size) { |
2423 | printk(KERN_ERR "ide-tape: merge_stage_size should be" | 1838 | printk(KERN_ERR "ide-tape: merge_bh_size should be" |
2424 | " 0 now\n"); | 1839 | " 0 now\n"); |
2425 | tape->merge_stage_size = 0; | 1840 | tape->merge_bh_size = 0; |
2426 | } | 1841 | } |
2427 | tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0); | 1842 | tape->merge_bh = ide_tape_kmalloc_buffer(tape, 0, 0); |
2428 | if (!tape->merge_stage) | 1843 | if (!tape->merge_bh) |
2429 | return -ENOMEM; | 1844 | return -ENOMEM; |
2430 | tape->chrdev_dir = IDETAPE_DIR_READ; | 1845 | tape->chrdev_dir = IDETAPE_DIR_READ; |
2431 | 1846 | ||
@@ -2438,54 +1853,23 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2438 | if (drive->dsc_overlap) { | 1853 | if (drive->dsc_overlap) { |
2439 | bytes_read = idetape_queue_rw_tail(drive, | 1854 | bytes_read = idetape_queue_rw_tail(drive, |
2440 | REQ_IDETAPE_READ, 0, | 1855 | REQ_IDETAPE_READ, 0, |
2441 | tape->merge_stage->bh); | 1856 | tape->merge_bh); |
2442 | if (bytes_read < 0) { | 1857 | if (bytes_read < 0) { |
2443 | __idetape_kfree_stage(tape->merge_stage); | 1858 | ide_tape_kfree_buffer(tape); |
2444 | tape->merge_stage = NULL; | 1859 | tape->merge_bh = NULL; |
2445 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 1860 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
2446 | return bytes_read; | 1861 | return bytes_read; |
2447 | } | 1862 | } |
2448 | } | 1863 | } |
2449 | } | 1864 | } |
2450 | if (tape->restart_speed_control_req) | 1865 | |
2451 | idetape_restart_speed_control(drive); | ||
2452 | idetape_init_rq(&rq, REQ_IDETAPE_READ); | ||
2453 | rq.sector = tape->first_frame; | ||
2454 | rq.nr_sectors = blocks; | ||
2455 | rq.current_nr_sectors = blocks; | ||
2456 | if (!test_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags) && | ||
2457 | tape->nr_stages < max_stages) { | ||
2458 | new_stage = idetape_kmalloc_stage(tape); | ||
2459 | while (new_stage != NULL) { | ||
2460 | new_stage->rq = rq; | ||
2461 | idetape_add_stage_tail(drive, new_stage); | ||
2462 | if (tape->nr_stages >= max_stages) | ||
2463 | break; | ||
2464 | new_stage = idetape_kmalloc_stage(tape); | ||
2465 | } | ||
2466 | } | ||
2467 | if (!idetape_pipeline_active(tape)) { | ||
2468 | if (tape->nr_pending_stages >= 3 * max_stages / 4) { | ||
2469 | tape->measure_insert_time = 1; | ||
2470 | tape->insert_time = jiffies; | ||
2471 | tape->insert_size = 0; | ||
2472 | tape->insert_speed = 0; | ||
2473 | idetape_plug_pipeline(drive); | ||
2474 | } | ||
2475 | } | ||
2476 | return 0; | 1866 | return 0; |
2477 | } | 1867 | } |
2478 | 1868 | ||
2479 | /* | 1869 | /* called from idetape_chrdev_read() to service a chrdev read request. */ |
2480 | * Called from idetape_chrdev_read() to service a character device read request | ||
2481 | * and add read-ahead requests to our pipeline. | ||
2482 | */ | ||
2483 | static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | 1870 | static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) |
2484 | { | 1871 | { |
2485 | idetape_tape_t *tape = drive->driver_data; | 1872 | idetape_tape_t *tape = drive->driver_data; |
2486 | unsigned long flags; | ||
2487 | struct request *rq_ptr; | ||
2488 | int bytes_read; | ||
2489 | 1873 | ||
2490 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); | 1874 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); |
2491 | 1875 | ||
@@ -2493,39 +1877,10 @@ static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | |||
2493 | if (test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) | 1877 | if (test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) |
2494 | return 0; | 1878 | return 0; |
2495 | 1879 | ||
2496 | /* Wait for the next block to reach the head of the pipeline. */ | 1880 | idetape_init_read(drive); |
2497 | idetape_init_read(drive, tape->max_stages); | ||
2498 | if (tape->first_stage == NULL) { | ||
2499 | if (test_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags)) | ||
2500 | return 0; | ||
2501 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, | ||
2502 | tape->merge_stage->bh); | ||
2503 | } | ||
2504 | idetape_wait_first_stage(drive); | ||
2505 | rq_ptr = &tape->first_stage->rq; | ||
2506 | bytes_read = tape->blk_size * (rq_ptr->nr_sectors - | ||
2507 | rq_ptr->current_nr_sectors); | ||
2508 | rq_ptr->nr_sectors = 0; | ||
2509 | rq_ptr->current_nr_sectors = 0; | ||
2510 | 1881 | ||
2511 | if (rq_ptr->errors == IDETAPE_ERROR_EOD) | 1882 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, |
2512 | return 0; | 1883 | tape->merge_bh); |
2513 | else { | ||
2514 | idetape_switch_buffers(tape, tape->first_stage); | ||
2515 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) | ||
2516 | set_bit(IDETAPE_FLAG_FILEMARK, &tape->flags); | ||
2517 | spin_lock_irqsave(&tape->lock, flags); | ||
2518 | idetape_remove_stage_head(drive); | ||
2519 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2520 | tape->pipeline_head++; | ||
2521 | idetape_calculate_speeds(drive); | ||
2522 | } | ||
2523 | if (bytes_read > blocks * tape->blk_size) { | ||
2524 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes" | ||
2525 | " than requested\n"); | ||
2526 | bytes_read = blocks * tape->blk_size; | ||
2527 | } | ||
2528 | return (bytes_read); | ||
2529 | } | 1884 | } |
2530 | 1885 | ||
2531 | static void idetape_pad_zeros(ide_drive_t *drive, int bcount) | 1886 | static void idetape_pad_zeros(ide_drive_t *drive, int bcount) |
@@ -2537,8 +1892,8 @@ static void idetape_pad_zeros(ide_drive_t *drive, int bcount) | |||
2537 | while (bcount) { | 1892 | while (bcount) { |
2538 | unsigned int count; | 1893 | unsigned int count; |
2539 | 1894 | ||
2540 | bh = tape->merge_stage->bh; | 1895 | bh = tape->merge_bh; |
2541 | count = min(tape->stage_size, bcount); | 1896 | count = min(tape->buffer_size, bcount); |
2542 | bcount -= count; | 1897 | bcount -= count; |
2543 | blocks = count / tape->blk_size; | 1898 | blocks = count / tape->blk_size; |
2544 | while (count) { | 1899 | while (count) { |
@@ -2549,31 +1904,10 @@ static void idetape_pad_zeros(ide_drive_t *drive, int bcount) | |||
2549 | bh = bh->b_reqnext; | 1904 | bh = bh->b_reqnext; |
2550 | } | 1905 | } |
2551 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, | 1906 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, |
2552 | tape->merge_stage->bh); | 1907 | tape->merge_bh); |
2553 | } | 1908 | } |
2554 | } | 1909 | } |
2555 | 1910 | ||
2556 | static int idetape_pipeline_size(ide_drive_t *drive) | ||
2557 | { | ||
2558 | idetape_tape_t *tape = drive->driver_data; | ||
2559 | idetape_stage_t *stage; | ||
2560 | struct request *rq; | ||
2561 | int size = 0; | ||
2562 | |||
2563 | idetape_wait_for_pipeline(drive); | ||
2564 | stage = tape->first_stage; | ||
2565 | while (stage != NULL) { | ||
2566 | rq = &stage->rq; | ||
2567 | size += tape->blk_size * (rq->nr_sectors - | ||
2568 | rq->current_nr_sectors); | ||
2569 | if (rq->errors == IDETAPE_ERROR_FILEMARK) | ||
2570 | size += tape->blk_size; | ||
2571 | stage = stage->next; | ||
2572 | } | ||
2573 | size += tape->merge_stage_size; | ||
2574 | return size; | ||
2575 | } | ||
2576 | |||
2577 | /* | 1911 | /* |
2578 | * Rewinds the tape to the Beginning Of the current Partition (BOP). We | 1912 | * Rewinds the tape to the Beginning Of the current Partition (BOP). We |
2579 | * currently support only one partition. | 1913 | * currently support only one partition. |
@@ -2619,11 +1953,10 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, | |||
2619 | if (copy_from_user(&config, argp, sizeof(config))) | 1953 | if (copy_from_user(&config, argp, sizeof(config))) |
2620 | return -EFAULT; | 1954 | return -EFAULT; |
2621 | tape->best_dsc_rw_freq = config.dsc_rw_frequency; | 1955 | tape->best_dsc_rw_freq = config.dsc_rw_frequency; |
2622 | tape->max_stages = config.nr_stages; | ||
2623 | break; | 1956 | break; |
2624 | case 0x0350: | 1957 | case 0x0350: |
2625 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; | 1958 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; |
2626 | config.nr_stages = tape->max_stages; | 1959 | config.nr_stages = 1; |
2627 | if (copy_to_user(argp, &config, sizeof(config))) | 1960 | if (copy_to_user(argp, &config, sizeof(config))) |
2628 | return -EFAULT; | 1961 | return -EFAULT; |
2629 | break; | 1962 | break; |
@@ -2633,19 +1966,11 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, | |||
2633 | return 0; | 1966 | return 0; |
2634 | } | 1967 | } |
2635 | 1968 | ||
2636 | /* | ||
2637 | * The function below is now a bit more complicated than just passing the | ||
2638 | * command to the tape since we may have crossed some filemarks during our | ||
2639 | * pipelined read-ahead mode. As a minor side effect, the pipeline enables us to | ||
2640 | * support MTFSFM when the filemark is in our internal pipeline even if the tape | ||
2641 | * doesn't support spacing over filemarks in the reverse direction. | ||
2642 | */ | ||
2643 | static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | 1969 | static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, |
2644 | int mt_count) | 1970 | int mt_count) |
2645 | { | 1971 | { |
2646 | idetape_tape_t *tape = drive->driver_data; | 1972 | idetape_tape_t *tape = drive->driver_data; |
2647 | struct ide_atapi_pc pc; | 1973 | struct ide_atapi_pc pc; |
2648 | unsigned long flags; | ||
2649 | int retval, count = 0; | 1974 | int retval, count = 0; |
2650 | int sprev = !!(tape->caps[4] & 0x20); | 1975 | int sprev = !!(tape->caps[4] & 0x20); |
2651 | 1976 | ||
@@ -2658,48 +1983,12 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
2658 | } | 1983 | } |
2659 | 1984 | ||
2660 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 1985 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
2661 | /* its a read-ahead buffer, scan it for crossed filemarks. */ | 1986 | tape->merge_bh_size = 0; |
2662 | tape->merge_stage_size = 0; | ||
2663 | if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) | 1987 | if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) |
2664 | ++count; | 1988 | ++count; |
2665 | while (tape->first_stage != NULL) { | 1989 | ide_tape_discard_merge_buffer(drive, 0); |
2666 | if (count == mt_count) { | ||
2667 | if (mt_op == MTFSFM) | ||
2668 | set_bit(IDETAPE_FLAG_FILEMARK, | ||
2669 | &tape->flags); | ||
2670 | return 0; | ||
2671 | } | ||
2672 | spin_lock_irqsave(&tape->lock, flags); | ||
2673 | if (tape->first_stage == tape->active_stage) { | ||
2674 | /* | ||
2675 | * We have reached the active stage in the read | ||
2676 | * pipeline. There is no point in allowing the | ||
2677 | * drive to continue reading any farther, so we | ||
2678 | * stop the pipeline. | ||
2679 | * | ||
2680 | * This section should be moved to a separate | ||
2681 | * subroutine because similar operations are | ||
2682 | * done in __idetape_discard_read_pipeline(), | ||
2683 | * for example. | ||
2684 | */ | ||
2685 | tape->next_stage = NULL; | ||
2686 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2687 | idetape_wait_first_stage(drive); | ||
2688 | tape->next_stage = tape->first_stage->next; | ||
2689 | } else | ||
2690 | spin_unlock_irqrestore(&tape->lock, flags); | ||
2691 | if (tape->first_stage->rq.errors == | ||
2692 | IDETAPE_ERROR_FILEMARK) | ||
2693 | ++count; | ||
2694 | idetape_remove_stage_head(drive); | ||
2695 | } | ||
2696 | idetape_discard_read_pipeline(drive, 0); | ||
2697 | } | 1990 | } |
2698 | 1991 | ||
2699 | /* | ||
2700 | * The filemark was not found in our internal pipeline; now we can issue | ||
2701 | * the space command. | ||
2702 | */ | ||
2703 | switch (mt_op) { | 1992 | switch (mt_op) { |
2704 | case MTFSF: | 1993 | case MTFSF: |
2705 | case MTBSF: | 1994 | case MTBSF: |
@@ -2755,27 +2044,25 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
2755 | (count % tape->blk_size) == 0) | 2044 | (count % tape->blk_size) == 0) |
2756 | tape->user_bs_factor = count / tape->blk_size; | 2045 | tape->user_bs_factor = count / tape->blk_size; |
2757 | } | 2046 | } |
2758 | rc = idetape_init_read(drive, tape->max_stages); | 2047 | rc = idetape_init_read(drive); |
2759 | if (rc < 0) | 2048 | if (rc < 0) |
2760 | return rc; | 2049 | return rc; |
2761 | if (count == 0) | 2050 | if (count == 0) |
2762 | return (0); | 2051 | return (0); |
2763 | if (tape->merge_stage_size) { | 2052 | if (tape->merge_bh_size) { |
2764 | actually_read = min((unsigned int)(tape->merge_stage_size), | 2053 | actually_read = min((unsigned int)(tape->merge_bh_size), |
2765 | (unsigned int)count); | 2054 | (unsigned int)count); |
2766 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, | 2055 | if (idetape_copy_stage_to_user(tape, buf, actually_read)) |
2767 | actually_read)) | ||
2768 | ret = -EFAULT; | 2056 | ret = -EFAULT; |
2769 | buf += actually_read; | 2057 | buf += actually_read; |
2770 | tape->merge_stage_size -= actually_read; | 2058 | tape->merge_bh_size -= actually_read; |
2771 | count -= actually_read; | 2059 | count -= actually_read; |
2772 | } | 2060 | } |
2773 | while (count >= tape->stage_size) { | 2061 | while (count >= tape->buffer_size) { |
2774 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); | 2062 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); |
2775 | if (bytes_read <= 0) | 2063 | if (bytes_read <= 0) |
2776 | goto finish; | 2064 | goto finish; |
2777 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, | 2065 | if (idetape_copy_stage_to_user(tape, buf, bytes_read)) |
2778 | bytes_read)) | ||
2779 | ret = -EFAULT; | 2066 | ret = -EFAULT; |
2780 | buf += bytes_read; | 2067 | buf += bytes_read; |
2781 | count -= bytes_read; | 2068 | count -= bytes_read; |
@@ -2786,11 +2073,10 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
2786 | if (bytes_read <= 0) | 2073 | if (bytes_read <= 0) |
2787 | goto finish; | 2074 | goto finish; |
2788 | temp = min((unsigned long)count, (unsigned long)bytes_read); | 2075 | temp = min((unsigned long)count, (unsigned long)bytes_read); |
2789 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, | 2076 | if (idetape_copy_stage_to_user(tape, buf, temp)) |
2790 | temp)) | ||
2791 | ret = -EFAULT; | 2077 | ret = -EFAULT; |
2792 | actually_read += temp; | 2078 | actually_read += temp; |
2793 | tape->merge_stage_size = bytes_read-temp; | 2079 | tape->merge_bh_size = bytes_read-temp; |
2794 | } | 2080 | } |
2795 | finish: | 2081 | finish: |
2796 | if (!actually_read && test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) { | 2082 | if (!actually_read && test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) { |
@@ -2821,17 +2107,17 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
2821 | /* Initialize write operation */ | 2107 | /* Initialize write operation */ |
2822 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { | 2108 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { |
2823 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 2109 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
2824 | idetape_discard_read_pipeline(drive, 1); | 2110 | ide_tape_discard_merge_buffer(drive, 1); |
2825 | if (tape->merge_stage || tape->merge_stage_size) { | 2111 | if (tape->merge_bh || tape->merge_bh_size) { |
2826 | printk(KERN_ERR "ide-tape: merge_stage_size " | 2112 | printk(KERN_ERR "ide-tape: merge_bh_size " |
2827 | "should be 0 now\n"); | 2113 | "should be 0 now\n"); |
2828 | tape->merge_stage_size = 0; | 2114 | tape->merge_bh_size = 0; |
2829 | } | 2115 | } |
2830 | tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0); | 2116 | tape->merge_bh = ide_tape_kmalloc_buffer(tape, 0, 0); |
2831 | if (!tape->merge_stage) | 2117 | if (!tape->merge_bh) |
2832 | return -ENOMEM; | 2118 | return -ENOMEM; |
2833 | tape->chrdev_dir = IDETAPE_DIR_WRITE; | 2119 | tape->chrdev_dir = IDETAPE_DIR_WRITE; |
2834 | idetape_init_merge_stage(tape); | 2120 | idetape_init_merge_buffer(tape); |
2835 | 2121 | ||
2836 | /* | 2122 | /* |
2837 | * Issue a write 0 command to ensure that DSC handshake is | 2123 | * Issue a write 0 command to ensure that DSC handshake is |
@@ -2842,10 +2128,10 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
2842 | if (drive->dsc_overlap) { | 2128 | if (drive->dsc_overlap) { |
2843 | ssize_t retval = idetape_queue_rw_tail(drive, | 2129 | ssize_t retval = idetape_queue_rw_tail(drive, |
2844 | REQ_IDETAPE_WRITE, 0, | 2130 | REQ_IDETAPE_WRITE, 0, |
2845 | tape->merge_stage->bh); | 2131 | tape->merge_bh); |
2846 | if (retval < 0) { | 2132 | if (retval < 0) { |
2847 | __idetape_kfree_stage(tape->merge_stage); | 2133 | ide_tape_kfree_buffer(tape); |
2848 | tape->merge_stage = NULL; | 2134 | tape->merge_bh = NULL; |
2849 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 2135 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
2850 | return retval; | 2136 | return retval; |
2851 | } | 2137 | } |
@@ -2853,49 +2139,44 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
2853 | } | 2139 | } |
2854 | if (count == 0) | 2140 | if (count == 0) |
2855 | return (0); | 2141 | return (0); |
2856 | if (tape->restart_speed_control_req) | 2142 | if (tape->merge_bh_size) { |
2857 | idetape_restart_speed_control(drive); | 2143 | if (tape->merge_bh_size >= tape->buffer_size) { |
2858 | if (tape->merge_stage_size) { | ||
2859 | if (tape->merge_stage_size >= tape->stage_size) { | ||
2860 | printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); | 2144 | printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); |
2861 | tape->merge_stage_size = 0; | 2145 | tape->merge_bh_size = 0; |
2862 | } | 2146 | } |
2863 | actually_written = min((unsigned int) | 2147 | actually_written = min((unsigned int) |
2864 | (tape->stage_size - tape->merge_stage_size), | 2148 | (tape->buffer_size - tape->merge_bh_size), |
2865 | (unsigned int)count); | 2149 | (unsigned int)count); |
2866 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, | 2150 | if (idetape_copy_stage_from_user(tape, buf, actually_written)) |
2867 | actually_written)) | ||
2868 | ret = -EFAULT; | 2151 | ret = -EFAULT; |
2869 | buf += actually_written; | 2152 | buf += actually_written; |
2870 | tape->merge_stage_size += actually_written; | 2153 | tape->merge_bh_size += actually_written; |
2871 | count -= actually_written; | 2154 | count -= actually_written; |
2872 | 2155 | ||
2873 | if (tape->merge_stage_size == tape->stage_size) { | 2156 | if (tape->merge_bh_size == tape->buffer_size) { |
2874 | ssize_t retval; | 2157 | ssize_t retval; |
2875 | tape->merge_stage_size = 0; | 2158 | tape->merge_bh_size = 0; |
2876 | retval = idetape_add_chrdev_write_request(drive, ctl); | 2159 | retval = idetape_add_chrdev_write_request(drive, ctl); |
2877 | if (retval <= 0) | 2160 | if (retval <= 0) |
2878 | return (retval); | 2161 | return (retval); |
2879 | } | 2162 | } |
2880 | } | 2163 | } |
2881 | while (count >= tape->stage_size) { | 2164 | while (count >= tape->buffer_size) { |
2882 | ssize_t retval; | 2165 | ssize_t retval; |
2883 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, | 2166 | if (idetape_copy_stage_from_user(tape, buf, tape->buffer_size)) |
2884 | tape->stage_size)) | ||
2885 | ret = -EFAULT; | 2167 | ret = -EFAULT; |
2886 | buf += tape->stage_size; | 2168 | buf += tape->buffer_size; |
2887 | count -= tape->stage_size; | 2169 | count -= tape->buffer_size; |
2888 | retval = idetape_add_chrdev_write_request(drive, ctl); | 2170 | retval = idetape_add_chrdev_write_request(drive, ctl); |
2889 | actually_written += tape->stage_size; | 2171 | actually_written += tape->buffer_size; |
2890 | if (retval <= 0) | 2172 | if (retval <= 0) |
2891 | return (retval); | 2173 | return (retval); |
2892 | } | 2174 | } |
2893 | if (count) { | 2175 | if (count) { |
2894 | actually_written += count; | 2176 | actually_written += count; |
2895 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, | 2177 | if (idetape_copy_stage_from_user(tape, buf, count)) |
2896 | count)) | ||
2897 | ret = -EFAULT; | 2178 | ret = -EFAULT; |
2898 | tape->merge_stage_size += count; | 2179 | tape->merge_bh_size += count; |
2899 | } | 2180 | } |
2900 | return ret ? ret : actually_written; | 2181 | return ret ? ret : actually_written; |
2901 | } | 2182 | } |
@@ -2919,8 +2200,7 @@ static int idetape_write_filemark(ide_drive_t *drive) | |||
2919 | * | 2200 | * |
2920 | * Note: MTBSF and MTBSFM are not supported when the tape doesn't support | 2201 | * Note: MTBSF and MTBSFM are not supported when the tape doesn't support |
2921 | * spacing over filemarks in the reverse direction. In this case, MTFSFM is also | 2202 | * spacing over filemarks in the reverse direction. In this case, MTFSFM is also |
2922 | * usually not supported (it is supported in the rare case in which we crossed | 2203 | * usually not supported. |
2923 | * the filemark during our read-ahead pipelined operation mode). | ||
2924 | * | 2204 | * |
2925 | * The following commands are currently not supported: | 2205 | * The following commands are currently not supported: |
2926 | * | 2206 | * |
@@ -2936,7 +2216,6 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2936 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", | 2216 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", |
2937 | mt_op, mt_count); | 2217 | mt_op, mt_count); |
2938 | 2218 | ||
2939 | /* Commands which need our pipelined read-ahead stages. */ | ||
2940 | switch (mt_op) { | 2219 | switch (mt_op) { |
2941 | case MTFSF: | 2220 | case MTFSF: |
2942 | case MTFSFM: | 2221 | case MTFSFM: |
@@ -2953,7 +2232,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2953 | case MTWEOF: | 2232 | case MTWEOF: |
2954 | if (tape->write_prot) | 2233 | if (tape->write_prot) |
2955 | return -EACCES; | 2234 | return -EACCES; |
2956 | idetape_discard_read_pipeline(drive, 1); | 2235 | ide_tape_discard_merge_buffer(drive, 1); |
2957 | for (i = 0; i < mt_count; i++) { | 2236 | for (i = 0; i < mt_count; i++) { |
2958 | retval = idetape_write_filemark(drive); | 2237 | retval = idetape_write_filemark(drive); |
2959 | if (retval) | 2238 | if (retval) |
@@ -2961,12 +2240,12 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2961 | } | 2240 | } |
2962 | return 0; | 2241 | return 0; |
2963 | case MTREW: | 2242 | case MTREW: |
2964 | idetape_discard_read_pipeline(drive, 0); | 2243 | ide_tape_discard_merge_buffer(drive, 0); |
2965 | if (idetape_rewind_tape(drive)) | 2244 | if (idetape_rewind_tape(drive)) |
2966 | return -EIO; | 2245 | return -EIO; |
2967 | return 0; | 2246 | return 0; |
2968 | case MTLOAD: | 2247 | case MTLOAD: |
2969 | idetape_discard_read_pipeline(drive, 0); | 2248 | ide_tape_discard_merge_buffer(drive, 0); |
2970 | idetape_create_load_unload_cmd(drive, &pc, | 2249 | idetape_create_load_unload_cmd(drive, &pc, |
2971 | IDETAPE_LU_LOAD_MASK); | 2250 | IDETAPE_LU_LOAD_MASK); |
2972 | return idetape_queue_pc_tail(drive, &pc); | 2251 | return idetape_queue_pc_tail(drive, &pc); |
@@ -2981,7 +2260,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2981 | if (!idetape_queue_pc_tail(drive, &pc)) | 2260 | if (!idetape_queue_pc_tail(drive, &pc)) |
2982 | tape->door_locked = DOOR_UNLOCKED; | 2261 | tape->door_locked = DOOR_UNLOCKED; |
2983 | } | 2262 | } |
2984 | idetape_discard_read_pipeline(drive, 0); | 2263 | ide_tape_discard_merge_buffer(drive, 0); |
2985 | idetape_create_load_unload_cmd(drive, &pc, | 2264 | idetape_create_load_unload_cmd(drive, &pc, |
2986 | !IDETAPE_LU_LOAD_MASK); | 2265 | !IDETAPE_LU_LOAD_MASK); |
2987 | retval = idetape_queue_pc_tail(drive, &pc); | 2266 | retval = idetape_queue_pc_tail(drive, &pc); |
@@ -2989,10 +2268,10 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2989 | clear_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags); | 2268 | clear_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags); |
2990 | return retval; | 2269 | return retval; |
2991 | case MTNOP: | 2270 | case MTNOP: |
2992 | idetape_discard_read_pipeline(drive, 0); | 2271 | ide_tape_discard_merge_buffer(drive, 0); |
2993 | return idetape_flush_tape_buffers(drive); | 2272 | return idetape_flush_tape_buffers(drive); |
2994 | case MTRETEN: | 2273 | case MTRETEN: |
2995 | idetape_discard_read_pipeline(drive, 0); | 2274 | ide_tape_discard_merge_buffer(drive, 0); |
2996 | idetape_create_load_unload_cmd(drive, &pc, | 2275 | idetape_create_load_unload_cmd(drive, &pc, |
2997 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); | 2276 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); |
2998 | return idetape_queue_pc_tail(drive, &pc); | 2277 | return idetape_queue_pc_tail(drive, &pc); |
@@ -3014,11 +2293,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
3014 | set_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags); | 2293 | set_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags); |
3015 | return 0; | 2294 | return 0; |
3016 | case MTSEEK: | 2295 | case MTSEEK: |
3017 | idetape_discard_read_pipeline(drive, 0); | 2296 | ide_tape_discard_merge_buffer(drive, 0); |
3018 | return idetape_position_tape(drive, | 2297 | return idetape_position_tape(drive, |
3019 | mt_count * tape->user_bs_factor, tape->partition, 0); | 2298 | mt_count * tape->user_bs_factor, tape->partition, 0); |
3020 | case MTSETPART: | 2299 | case MTSETPART: |
3021 | idetape_discard_read_pipeline(drive, 0); | 2300 | ide_tape_discard_merge_buffer(drive, 0); |
3022 | return idetape_position_tape(drive, 0, mt_count, 0); | 2301 | return idetape_position_tape(drive, 0, mt_count, 0); |
3023 | case MTFSR: | 2302 | case MTFSR: |
3024 | case MTBSR: | 2303 | case MTBSR: |
@@ -3063,13 +2342,12 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
3063 | 2342 | ||
3064 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); | 2343 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); |
3065 | 2344 | ||
3066 | tape->restart_speed_control_req = 1; | ||
3067 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { | 2345 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { |
3068 | idetape_empty_write_pipeline(drive); | 2346 | ide_tape_flush_merge_buffer(drive); |
3069 | idetape_flush_tape_buffers(drive); | 2347 | idetape_flush_tape_buffers(drive); |
3070 | } | 2348 | } |
3071 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { | 2349 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { |
3072 | block_offset = idetape_pipeline_size(drive) / | 2350 | block_offset = tape->merge_bh_size / |
3073 | (tape->blk_size * tape->user_bs_factor); | 2351 | (tape->blk_size * tape->user_bs_factor); |
3074 | position = idetape_read_position(drive); | 2352 | position = idetape_read_position(drive); |
3075 | if (position < 0) | 2353 | if (position < 0) |
@@ -3101,7 +2379,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
3101 | return 0; | 2379 | return 0; |
3102 | default: | 2380 | default: |
3103 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 2381 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
3104 | idetape_discard_read_pipeline(drive, 1); | 2382 | ide_tape_discard_merge_buffer(drive, 1); |
3105 | return idetape_blkdev_ioctl(drive, cmd, arg); | 2383 | return idetape_blkdev_ioctl(drive, cmd, arg); |
3106 | } | 2384 | } |
3107 | } | 2385 | } |
@@ -3175,9 +2453,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
3175 | if (!test_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags)) | 2453 | if (!test_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags)) |
3176 | (void)idetape_rewind_tape(drive); | 2454 | (void)idetape_rewind_tape(drive); |
3177 | 2455 | ||
3178 | if (tape->chrdev_dir != IDETAPE_DIR_READ) | ||
3179 | clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags); | ||
3180 | |||
3181 | /* Read block size and write protect status from drive. */ | 2456 | /* Read block size and write protect status from drive. */ |
3182 | ide_tape_get_bsize_from_bdesc(drive); | 2457 | ide_tape_get_bsize_from_bdesc(drive); |
3183 | 2458 | ||
@@ -3206,8 +2481,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
3206 | } | 2481 | } |
3207 | } | 2482 | } |
3208 | } | 2483 | } |
3209 | idetape_restart_speed_control(drive); | ||
3210 | tape->restart_speed_control_req = 0; | ||
3211 | return 0; | 2484 | return 0; |
3212 | 2485 | ||
3213 | out_put_tape: | 2486 | out_put_tape: |
@@ -3219,13 +2492,13 @@ static void idetape_write_release(ide_drive_t *drive, unsigned int minor) | |||
3219 | { | 2492 | { |
3220 | idetape_tape_t *tape = drive->driver_data; | 2493 | idetape_tape_t *tape = drive->driver_data; |
3221 | 2494 | ||
3222 | idetape_empty_write_pipeline(drive); | 2495 | ide_tape_flush_merge_buffer(drive); |
3223 | tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0); | 2496 | tape->merge_bh = ide_tape_kmalloc_buffer(tape, 1, 0); |
3224 | if (tape->merge_stage != NULL) { | 2497 | if (tape->merge_bh != NULL) { |
3225 | idetape_pad_zeros(drive, tape->blk_size * | 2498 | idetape_pad_zeros(drive, tape->blk_size * |
3226 | (tape->user_bs_factor - 1)); | 2499 | (tape->user_bs_factor - 1)); |
3227 | __idetape_kfree_stage(tape->merge_stage); | 2500 | ide_tape_kfree_buffer(tape); |
3228 | tape->merge_stage = NULL; | 2501 | tape->merge_bh = NULL; |
3229 | } | 2502 | } |
3230 | idetape_write_filemark(drive); | 2503 | idetape_write_filemark(drive); |
3231 | idetape_flush_tape_buffers(drive); | 2504 | idetape_flush_tape_buffers(drive); |
@@ -3248,14 +2521,9 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
3248 | idetape_write_release(drive, minor); | 2521 | idetape_write_release(drive, minor); |
3249 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 2522 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
3250 | if (minor < 128) | 2523 | if (minor < 128) |
3251 | idetape_discard_read_pipeline(drive, 1); | 2524 | ide_tape_discard_merge_buffer(drive, 1); |
3252 | else | ||
3253 | idetape_wait_for_pipeline(drive); | ||
3254 | } | ||
3255 | if (tape->cache_stage != NULL) { | ||
3256 | __idetape_kfree_stage(tape->cache_stage); | ||
3257 | tape->cache_stage = NULL; | ||
3258 | } | 2525 | } |
2526 | |||
3259 | if (minor < 128 && test_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags)) | 2527 | if (minor < 128 && test_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags)) |
3260 | (void) idetape_rewind_tape(drive); | 2528 | (void) idetape_rewind_tape(drive); |
3261 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 2529 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
@@ -3392,33 +2660,15 @@ static void idetape_add_settings(ide_drive_t *drive) | |||
3392 | 2660 | ||
3393 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 2661 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3394 | 1, 2, (u16 *)&tape->caps[16], NULL); | 2662 | 1, 2, (u16 *)&tape->caps[16], NULL); |
3395 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, | ||
3396 | tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); | ||
3397 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, | ||
3398 | tape->stage_size / 1024, 1, &tape->max_stages, NULL); | ||
3399 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, | ||
3400 | tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); | ||
3401 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, | ||
3402 | 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, | ||
3403 | NULL); | ||
3404 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, | ||
3405 | 0xffff, tape->stage_size / 1024, 1, | ||
3406 | &tape->nr_pending_stages, NULL); | ||
3407 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 2663 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3408 | 1, 1, (u16 *)&tape->caps[14], NULL); | 2664 | 1, 1, (u16 *)&tape->caps[14], NULL); |
3409 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, | 2665 | ide_add_setting(drive, "buffer_size", SETTING_READ, TYPE_INT, 0, 0xffff, |
3410 | 1024, &tape->stage_size, NULL); | 2666 | 1, 1024, &tape->buffer_size, NULL); |
3411 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, | 2667 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, |
3412 | IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, | 2668 | IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, |
3413 | NULL); | 2669 | NULL); |
3414 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, | 2670 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, |
3415 | 1, &drive->dsc_overlap, NULL); | 2671 | 1, &drive->dsc_overlap, NULL); |
3416 | ide_add_setting(drive, "pipeline_head_speed_c", SETTING_READ, TYPE_INT, | ||
3417 | 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, | ||
3418 | NULL); | ||
3419 | ide_add_setting(drive, "pipeline_head_speed_u", SETTING_READ, TYPE_INT, | ||
3420 | 0, 0xffff, 1, 1, | ||
3421 | &tape->uncontrolled_pipeline_head_speed, NULL); | ||
3422 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, | 2672 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, |
3423 | 1, 1, &tape->avg_speed, NULL); | 2673 | 1, 1, &tape->avg_speed, NULL); |
3424 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, | 2674 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, |
@@ -3441,11 +2691,10 @@ static inline void idetape_add_settings(ide_drive_t *drive) { ; } | |||
3441 | */ | 2691 | */ |
3442 | static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | 2692 | static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) |
3443 | { | 2693 | { |
3444 | unsigned long t1, tmid, tn, t; | 2694 | unsigned long t; |
3445 | int speed; | 2695 | int speed; |
3446 | int stage_size; | 2696 | int buffer_size; |
3447 | u8 gcw[2]; | 2697 | u8 gcw[2]; |
3448 | struct sysinfo si; | ||
3449 | u16 *ctl = (u16 *)&tape->caps[12]; | 2698 | u16 *ctl = (u16 *)&tape->caps[12]; |
3450 | 2699 | ||
3451 | spin_lock_init(&tape->lock); | 2700 | spin_lock_init(&tape->lock); |
@@ -3464,65 +2713,33 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3464 | tape->name[2] = '0' + minor; | 2713 | tape->name[2] = '0' + minor; |
3465 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 2714 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
3466 | tape->pc = tape->pc_stack; | 2715 | tape->pc = tape->pc_stack; |
3467 | tape->max_insert_speed = 10000; | ||
3468 | tape->speed_control = 1; | ||
3469 | *((unsigned short *) &gcw) = drive->id->config; | 2716 | *((unsigned short *) &gcw) = drive->id->config; |
3470 | 2717 | ||
3471 | /* Command packet DRQ type */ | 2718 | /* Command packet DRQ type */ |
3472 | if (((gcw[0] & 0x60) >> 5) == 1) | 2719 | if (((gcw[0] & 0x60) >> 5) == 1) |
3473 | set_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags); | 2720 | set_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags); |
3474 | 2721 | ||
3475 | tape->min_pipeline = 10; | ||
3476 | tape->max_pipeline = 10; | ||
3477 | tape->max_stages = 10; | ||
3478 | |||
3479 | idetape_get_inquiry_results(drive); | 2722 | idetape_get_inquiry_results(drive); |
3480 | idetape_get_mode_sense_results(drive); | 2723 | idetape_get_mode_sense_results(drive); |
3481 | ide_tape_get_bsize_from_bdesc(drive); | 2724 | ide_tape_get_bsize_from_bdesc(drive); |
3482 | tape->user_bs_factor = 1; | 2725 | tape->user_bs_factor = 1; |
3483 | tape->stage_size = *ctl * tape->blk_size; | 2726 | tape->buffer_size = *ctl * tape->blk_size; |
3484 | while (tape->stage_size > 0xffff) { | 2727 | while (tape->buffer_size > 0xffff) { |
3485 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); | 2728 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); |
3486 | *ctl /= 2; | 2729 | *ctl /= 2; |
3487 | tape->stage_size = *ctl * tape->blk_size; | 2730 | tape->buffer_size = *ctl * tape->blk_size; |
3488 | } | 2731 | } |
3489 | stage_size = tape->stage_size; | 2732 | buffer_size = tape->buffer_size; |
3490 | tape->pages_per_stage = stage_size / PAGE_SIZE; | 2733 | tape->pages_per_buffer = buffer_size / PAGE_SIZE; |
3491 | if (stage_size % PAGE_SIZE) { | 2734 | if (buffer_size % PAGE_SIZE) { |
3492 | tape->pages_per_stage++; | 2735 | tape->pages_per_buffer++; |
3493 | tape->excess_bh_size = PAGE_SIZE - stage_size % PAGE_SIZE; | 2736 | tape->excess_bh_size = PAGE_SIZE - buffer_size % PAGE_SIZE; |
3494 | } | 2737 | } |
3495 | 2738 | ||
3496 | /* Select the "best" DSC read/write polling freq and pipeline size. */ | 2739 | /* select the "best" DSC read/write polling freq */ |
3497 | speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); | 2740 | speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); |
3498 | 2741 | ||
3499 | tape->max_stages = speed * 1000 * 10 / tape->stage_size; | 2742 | t = (IDETAPE_FIFO_THRESHOLD * tape->buffer_size * HZ) / (speed * 1000); |
3500 | |||
3501 | /* Limit memory use for pipeline to 10% of physical memory */ | ||
3502 | si_meminfo(&si); | ||
3503 | if (tape->max_stages * tape->stage_size > | ||
3504 | si.totalram * si.mem_unit / 10) | ||
3505 | tape->max_stages = | ||
3506 | si.totalram * si.mem_unit / (10 * tape->stage_size); | ||
3507 | |||
3508 | tape->max_stages = min(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES); | ||
3509 | tape->min_pipeline = min(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES); | ||
3510 | tape->max_pipeline = | ||
3511 | min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES); | ||
3512 | if (tape->max_stages == 0) { | ||
3513 | tape->max_stages = 1; | ||
3514 | tape->min_pipeline = 1; | ||
3515 | tape->max_pipeline = 1; | ||
3516 | } | ||
3517 | |||
3518 | t1 = (tape->stage_size * HZ) / (speed * 1000); | ||
3519 | tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125); | ||
3520 | tn = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000); | ||
3521 | |||
3522 | if (tape->max_stages) | ||
3523 | t = tn; | ||
3524 | else | ||
3525 | t = t1; | ||
3526 | 2743 | ||
3527 | /* | 2744 | /* |
3528 | * Ensure that the number we got makes sense; limit it within | 2745 | * Ensure that the number we got makes sense; limit it within |
@@ -3532,11 +2749,10 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3532 | min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), | 2749 | min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), |
3533 | IDETAPE_DSC_RW_MIN); | 2750 | IDETAPE_DSC_RW_MIN); |
3534 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " | 2751 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " |
3535 | "%dkB pipeline, %lums tDSC%s\n", | 2752 | "%lums tDSC%s\n", |
3536 | drive->name, tape->name, *(u16 *)&tape->caps[14], | 2753 | drive->name, tape->name, *(u16 *)&tape->caps[14], |
3537 | (*(u16 *)&tape->caps[16] * 512) / tape->stage_size, | 2754 | (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size, |
3538 | tape->stage_size / 1024, | 2755 | tape->buffer_size / 1024, |
3539 | tape->max_stages * tape->stage_size / 1024, | ||
3540 | tape->best_dsc_rw_freq * 1000 / HZ, | 2756 | tape->best_dsc_rw_freq * 1000 / HZ, |
3541 | drive->using_dma ? ", DMA":""); | 2757 | drive->using_dma ? ", DMA":""); |
3542 | 2758 | ||
@@ -3560,7 +2776,7 @@ static void ide_tape_release(struct kref *kref) | |||
3560 | ide_drive_t *drive = tape->drive; | 2776 | ide_drive_t *drive = tape->drive; |
3561 | struct gendisk *g = tape->disk; | 2777 | struct gendisk *g = tape->disk; |
3562 | 2778 | ||
3563 | BUG_ON(tape->first_stage != NULL || tape->merge_stage_size); | 2779 | BUG_ON(tape->merge_bh_size); |
3564 | 2780 | ||
3565 | drive->dsc_overlap = 0; | 2781 | drive->dsc_overlap = 0; |
3566 | drive->driver_data = NULL; | 2782 | drive->driver_data = NULL; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 155cc904f4eb..9f9ad9fb6b89 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -36,6 +36,7 @@ | |||
36 | void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | 36 | void ide_tf_load(ide_drive_t *drive, ide_task_t *task) |
37 | { | 37 | { |
38 | ide_hwif_t *hwif = drive->hwif; | 38 | ide_hwif_t *hwif = drive->hwif; |
39 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
39 | struct ide_taskfile *tf = &task->tf; | 40 | struct ide_taskfile *tf = &task->tf; |
40 | u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; | 41 | u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; |
41 | 42 | ||
@@ -59,34 +60,33 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
59 | SELECT_MASK(drive, 0); | 60 | SELECT_MASK(drive, 0); |
60 | 61 | ||
61 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) | 62 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) |
62 | hwif->OUTW((tf->hob_data << 8) | tf->data, | 63 | hwif->OUTW((tf->hob_data << 8) | tf->data, io_ports->data_addr); |
63 | hwif->io_ports[IDE_DATA_OFFSET]); | ||
64 | 64 | ||
65 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) | 65 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) |
66 | hwif->OUTB(tf->hob_feature, hwif->io_ports[IDE_FEATURE_OFFSET]); | 66 | hwif->OUTB(tf->hob_feature, io_ports->feature_addr); |
67 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) | 67 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) |
68 | hwif->OUTB(tf->hob_nsect, hwif->io_ports[IDE_NSECTOR_OFFSET]); | 68 | hwif->OUTB(tf->hob_nsect, io_ports->nsect_addr); |
69 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) | 69 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) |
70 | hwif->OUTB(tf->hob_lbal, hwif->io_ports[IDE_SECTOR_OFFSET]); | 70 | hwif->OUTB(tf->hob_lbal, io_ports->lbal_addr); |
71 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) | 71 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) |
72 | hwif->OUTB(tf->hob_lbam, hwif->io_ports[IDE_LCYL_OFFSET]); | 72 | hwif->OUTB(tf->hob_lbam, io_ports->lbam_addr); |
73 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) | 73 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) |
74 | hwif->OUTB(tf->hob_lbah, hwif->io_ports[IDE_HCYL_OFFSET]); | 74 | hwif->OUTB(tf->hob_lbah, io_ports->lbah_addr); |
75 | 75 | ||
76 | if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) | 76 | if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) |
77 | hwif->OUTB(tf->feature, hwif->io_ports[IDE_FEATURE_OFFSET]); | 77 | hwif->OUTB(tf->feature, io_ports->feature_addr); |
78 | if (task->tf_flags & IDE_TFLAG_OUT_NSECT) | 78 | if (task->tf_flags & IDE_TFLAG_OUT_NSECT) |
79 | hwif->OUTB(tf->nsect, hwif->io_ports[IDE_NSECTOR_OFFSET]); | 79 | hwif->OUTB(tf->nsect, io_ports->nsect_addr); |
80 | if (task->tf_flags & IDE_TFLAG_OUT_LBAL) | 80 | if (task->tf_flags & IDE_TFLAG_OUT_LBAL) |
81 | hwif->OUTB(tf->lbal, hwif->io_ports[IDE_SECTOR_OFFSET]); | 81 | hwif->OUTB(tf->lbal, io_ports->lbal_addr); |
82 | if (task->tf_flags & IDE_TFLAG_OUT_LBAM) | 82 | if (task->tf_flags & IDE_TFLAG_OUT_LBAM) |
83 | hwif->OUTB(tf->lbam, hwif->io_ports[IDE_LCYL_OFFSET]); | 83 | hwif->OUTB(tf->lbam, io_ports->lbam_addr); |
84 | if (task->tf_flags & IDE_TFLAG_OUT_LBAH) | 84 | if (task->tf_flags & IDE_TFLAG_OUT_LBAH) |
85 | hwif->OUTB(tf->lbah, hwif->io_ports[IDE_HCYL_OFFSET]); | 85 | hwif->OUTB(tf->lbah, io_ports->lbah_addr); |
86 | 86 | ||
87 | if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) | 87 | if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) |
88 | hwif->OUTB((tf->device & HIHI) | drive->select.all, | 88 | hwif->OUTB((tf->device & HIHI) | drive->select.all, |
89 | hwif->io_ports[IDE_SELECT_OFFSET]); | 89 | io_ports->device_addr); |
90 | } | 90 | } |
91 | 91 | ||
92 | int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) | 92 | int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) |
@@ -135,6 +135,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
135 | ide_hwif_t *hwif = HWIF(drive); | 135 | ide_hwif_t *hwif = HWIF(drive); |
136 | struct ide_taskfile *tf = &task->tf; | 136 | struct ide_taskfile *tf = &task->tf; |
137 | ide_handler_t *handler = NULL; | 137 | ide_handler_t *handler = NULL; |
138 | const struct ide_dma_ops *dma_ops = hwif->dma_ops; | ||
138 | 139 | ||
139 | if (task->data_phase == TASKFILE_MULTI_IN || | 140 | if (task->data_phase == TASKFILE_MULTI_IN || |
140 | task->data_phase == TASKFILE_MULTI_OUT) { | 141 | task->data_phase == TASKFILE_MULTI_OUT) { |
@@ -154,8 +155,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
154 | switch (task->data_phase) { | 155 | switch (task->data_phase) { |
155 | case TASKFILE_MULTI_OUT: | 156 | case TASKFILE_MULTI_OUT: |
156 | case TASKFILE_OUT: | 157 | case TASKFILE_OUT: |
157 | hwif->OUTBSYNC(drive, tf->command, | 158 | hwif->OUTBSYNC(drive, tf->command, hwif->io_ports.command_addr); |
158 | hwif->io_ports[IDE_COMMAND_OFFSET]); | ||
159 | ndelay(400); /* FIXME */ | 159 | ndelay(400); /* FIXME */ |
160 | return pre_task_out_intr(drive, task->rq); | 160 | return pre_task_out_intr(drive, task->rq); |
161 | case TASKFILE_MULTI_IN: | 161 | case TASKFILE_MULTI_IN: |
@@ -178,10 +178,10 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
178 | return ide_started; | 178 | return ide_started; |
179 | default: | 179 | default: |
180 | if (task_dma_ok(task) == 0 || drive->using_dma == 0 || | 180 | if (task_dma_ok(task) == 0 || drive->using_dma == 0 || |
181 | hwif->dma_setup(drive)) | 181 | dma_ops->dma_setup(drive)) |
182 | return ide_stopped; | 182 | return ide_stopped; |
183 | hwif->dma_exec_cmd(drive, tf->command); | 183 | dma_ops->dma_exec_cmd(drive, tf->command); |
184 | hwif->dma_start(drive); | 184 | dma_ops->dma_start(drive); |
185 | return ide_started; | 185 | return ide_started; |
186 | } | 186 | } |
187 | } | 187 | } |
@@ -455,7 +455,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) | |||
455 | 455 | ||
456 | /* Error? */ | 456 | /* Error? */ |
457 | if (stat & ERR_STAT) | 457 | if (stat & ERR_STAT) |
458 | return task_error(drive, rq, __FUNCTION__, stat); | 458 | return task_error(drive, rq, __func__, stat); |
459 | 459 | ||
460 | /* Didn't want any data? Odd. */ | 460 | /* Didn't want any data? Odd. */ |
461 | if (!(stat & DRQ_STAT)) | 461 | if (!(stat & DRQ_STAT)) |
@@ -467,7 +467,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) | |||
467 | if (!hwif->nleft) { | 467 | if (!hwif->nleft) { |
468 | stat = wait_drive_not_busy(drive); | 468 | stat = wait_drive_not_busy(drive); |
469 | if (!OK_STAT(stat, 0, BAD_STAT)) | 469 | if (!OK_STAT(stat, 0, BAD_STAT)) |
470 | return task_error(drive, rq, __FUNCTION__, stat); | 470 | return task_error(drive, rq, __func__, stat); |
471 | task_end_request(drive, rq, stat); | 471 | task_end_request(drive, rq, stat); |
472 | return ide_stopped; | 472 | return ide_stopped; |
473 | } | 473 | } |
@@ -488,11 +488,11 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive) | |||
488 | u8 stat = ide_read_status(drive); | 488 | u8 stat = ide_read_status(drive); |
489 | 489 | ||
490 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) | 490 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) |
491 | return task_error(drive, rq, __FUNCTION__, stat); | 491 | return task_error(drive, rq, __func__, stat); |
492 | 492 | ||
493 | /* Deal with unexpected ATA data phase. */ | 493 | /* Deal with unexpected ATA data phase. */ |
494 | if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft) | 494 | if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft) |
495 | return task_error(drive, rq, __FUNCTION__, stat); | 495 | return task_error(drive, rq, __func__, stat); |
496 | 496 | ||
497 | if (!hwif->nleft) { | 497 | if (!hwif->nleft) { |
498 | task_end_request(drive, rq, stat); | 498 | task_end_request(drive, rq, stat); |
@@ -675,7 +675,7 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
675 | /* (hs): give up if multcount is not set */ | 675 | /* (hs): give up if multcount is not set */ |
676 | printk(KERN_ERR "%s: %s Multimode Write " \ | 676 | printk(KERN_ERR "%s: %s Multimode Write " \ |
677 | "multcount is not set\n", | 677 | "multcount is not set\n", |
678 | drive->name, __FUNCTION__); | 678 | drive->name, __func__); |
679 | err = -EPERM; | 679 | err = -EPERM; |
680 | goto abort; | 680 | goto abort; |
681 | } | 681 | } |
@@ -692,7 +692,7 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
692 | /* (hs): give up if multcount is not set */ | 692 | /* (hs): give up if multcount is not set */ |
693 | printk(KERN_ERR "%s: %s Multimode Read failure " \ | 693 | printk(KERN_ERR "%s: %s Multimode Read failure " \ |
694 | "multcount is not set\n", | 694 | "multcount is not set\n", |
695 | drive->name, __FUNCTION__); | 695 | drive->name, __func__); |
696 | err = -EPERM; | 696 | err = -EPERM; |
697 | goto abort; | 697 | goto abort; |
698 | } | 698 | } |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 917c72dcd33d..999584c03d97 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -94,19 +94,8 @@ DEFINE_MUTEX(ide_cfg_mtx); | |||
94 | 94 | ||
95 | int noautodma = 0; | 95 | int noautodma = 0; |
96 | 96 | ||
97 | #ifdef CONFIG_BLK_DEV_IDEACPI | ||
98 | int ide_noacpi = 0; | ||
99 | int ide_noacpitfs = 1; | ||
100 | int ide_noacpionboot = 1; | ||
101 | #endif | ||
102 | |||
103 | /* | ||
104 | * This is declared extern in ide.h, for access by other IDE modules: | ||
105 | */ | ||
106 | ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ | 97 | ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ |
107 | 98 | ||
108 | EXPORT_SYMBOL(ide_hwifs); | ||
109 | |||
110 | static void ide_port_init_devices_data(ide_hwif_t *); | 99 | static void ide_port_init_devices_data(ide_hwif_t *); |
111 | 100 | ||
112 | /* | 101 | /* |
@@ -232,117 +221,6 @@ static int ide_system_bus_speed(void) | |||
232 | return pci_dev_present(pci_default) ? 33 : 50; | 221 | return pci_dev_present(pci_default) ? 33 : 50; |
233 | } | 222 | } |
234 | 223 | ||
235 | ide_hwif_t * ide_find_port(unsigned long base) | ||
236 | { | ||
237 | ide_hwif_t *hwif; | ||
238 | int i; | ||
239 | |||
240 | for (i = 0; i < MAX_HWIFS; i++) { | ||
241 | hwif = &ide_hwifs[i]; | ||
242 | if (hwif->io_ports[IDE_DATA_OFFSET] == base) | ||
243 | goto found; | ||
244 | } | ||
245 | |||
246 | for (i = 0; i < MAX_HWIFS; i++) { | ||
247 | hwif = &ide_hwifs[i]; | ||
248 | if (hwif->chipset == ide_unknown) | ||
249 | goto found; | ||
250 | } | ||
251 | |||
252 | hwif = NULL; | ||
253 | found: | ||
254 | return hwif; | ||
255 | } | ||
256 | |||
257 | EXPORT_SYMBOL_GPL(ide_find_port); | ||
258 | |||
259 | static struct resource* hwif_request_region(ide_hwif_t *hwif, | ||
260 | unsigned long addr, int num) | ||
261 | { | ||
262 | struct resource *res = request_region(addr, num, hwif->name); | ||
263 | |||
264 | if (!res) | ||
265 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
266 | hwif->name, addr, addr+num-1); | ||
267 | return res; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * ide_hwif_request_regions - request resources for IDE | ||
272 | * @hwif: interface to use | ||
273 | * | ||
274 | * Requests all the needed resources for an interface. | ||
275 | * Right now core IDE code does this work which is deeply wrong. | ||
276 | * MMIO leaves it to the controller driver, | ||
277 | * PIO will migrate this way over time. | ||
278 | */ | ||
279 | |||
280 | int ide_hwif_request_regions(ide_hwif_t *hwif) | ||
281 | { | ||
282 | unsigned long addr; | ||
283 | unsigned int i; | ||
284 | |||
285 | if (hwif->mmio) | ||
286 | return 0; | ||
287 | addr = hwif->io_ports[IDE_CONTROL_OFFSET]; | ||
288 | if (addr && !hwif_request_region(hwif, addr, 1)) | ||
289 | goto control_region_busy; | ||
290 | hwif->straight8 = 0; | ||
291 | addr = hwif->io_ports[IDE_DATA_OFFSET]; | ||
292 | if ((addr | 7) == hwif->io_ports[IDE_STATUS_OFFSET]) { | ||
293 | if (!hwif_request_region(hwif, addr, 8)) | ||
294 | goto data_region_busy; | ||
295 | hwif->straight8 = 1; | ||
296 | return 0; | ||
297 | } | ||
298 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | ||
299 | addr = hwif->io_ports[i]; | ||
300 | if (!hwif_request_region(hwif, addr, 1)) { | ||
301 | while (--i) | ||
302 | release_region(addr, 1); | ||
303 | goto data_region_busy; | ||
304 | } | ||
305 | } | ||
306 | return 0; | ||
307 | |||
308 | data_region_busy: | ||
309 | addr = hwif->io_ports[IDE_CONTROL_OFFSET]; | ||
310 | if (addr) | ||
311 | release_region(addr, 1); | ||
312 | control_region_busy: | ||
313 | /* If any errors are return, we drop the hwif interface. */ | ||
314 | return -EBUSY; | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * ide_hwif_release_regions - free IDE resources | ||
319 | * | ||
320 | * Note that we only release the standard ports, | ||
321 | * and do not even try to handle any extra ports | ||
322 | * allocated for weird IDE interface chipsets. | ||
323 | * | ||
324 | * Note also that we don't yet handle mmio resources here. More | ||
325 | * importantly our caller should be doing this so we need to | ||
326 | * restructure this as a helper function for drivers. | ||
327 | */ | ||
328 | |||
329 | void ide_hwif_release_regions(ide_hwif_t *hwif) | ||
330 | { | ||
331 | u32 i = 0; | ||
332 | |||
333 | if (hwif->mmio) | ||
334 | return; | ||
335 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) | ||
336 | release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1); | ||
337 | if (hwif->straight8) { | ||
338 | release_region(hwif->io_ports[IDE_DATA_OFFSET], 8); | ||
339 | return; | ||
340 | } | ||
341 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) | ||
342 | if (hwif->io_ports[i]) | ||
343 | release_region(hwif->io_ports[i], 1); | ||
344 | } | ||
345 | |||
346 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | 224 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) |
347 | { | 225 | { |
348 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 226 | ide_hwgroup_t *hwgroup = hwif->hwgroup; |
@@ -409,7 +287,7 @@ EXPORT_SYMBOL_GPL(ide_port_unregister_devices); | |||
409 | 287 | ||
410 | /** | 288 | /** |
411 | * ide_unregister - free an IDE interface | 289 | * ide_unregister - free an IDE interface |
412 | * @index: index of interface (will change soon to a pointer) | 290 | * @hwif: IDE interface |
413 | * | 291 | * |
414 | * Perform the final unregister of an IDE interface. At the moment | 292 | * Perform the final unregister of an IDE interface. At the moment |
415 | * we don't refcount interfaces so this will also get split up. | 293 | * we don't refcount interfaces so this will also get split up. |
@@ -429,19 +307,16 @@ EXPORT_SYMBOL_GPL(ide_port_unregister_devices); | |||
429 | * This is raving bonkers. | 307 | * This is raving bonkers. |
430 | */ | 308 | */ |
431 | 309 | ||
432 | void ide_unregister(unsigned int index) | 310 | void ide_unregister(ide_hwif_t *hwif) |
433 | { | 311 | { |
434 | ide_hwif_t *hwif, *g; | 312 | ide_hwif_t *g; |
435 | ide_hwgroup_t *hwgroup; | 313 | ide_hwgroup_t *hwgroup; |
436 | int irq_count = 0; | 314 | int irq_count = 0; |
437 | 315 | ||
438 | BUG_ON(index >= MAX_HWIFS); | ||
439 | |||
440 | BUG_ON(in_interrupt()); | 316 | BUG_ON(in_interrupt()); |
441 | BUG_ON(irqs_disabled()); | 317 | BUG_ON(irqs_disabled()); |
442 | mutex_lock(&ide_cfg_mtx); | 318 | mutex_lock(&ide_cfg_mtx); |
443 | spin_lock_irq(&ide_lock); | 319 | spin_lock_irq(&ide_lock); |
444 | hwif = &ide_hwifs[index]; | ||
445 | if (!hwif->present) | 320 | if (!hwif->present) |
446 | goto abort; | 321 | goto abort; |
447 | __ide_port_unregister_devices(hwif); | 322 | __ide_port_unregister_devices(hwif); |
@@ -479,12 +354,10 @@ void ide_unregister(unsigned int index) | |||
479 | spin_lock_irq(&ide_lock); | 354 | spin_lock_irq(&ide_lock); |
480 | 355 | ||
481 | if (hwif->dma_base) | 356 | if (hwif->dma_base) |
482 | (void)ide_release_dma(hwif); | 357 | ide_release_dma_engine(hwif); |
483 | |||
484 | ide_hwif_release_regions(hwif); | ||
485 | 358 | ||
486 | /* restore hwif data to pristine status */ | 359 | /* restore hwif data to pristine status */ |
487 | ide_init_port_data(hwif, index); | 360 | ide_init_port_data(hwif, hwif->index); |
488 | 361 | ||
489 | abort: | 362 | abort: |
490 | spin_unlock_irq(&ide_lock); | 363 | spin_unlock_irq(&ide_lock); |
@@ -495,9 +368,8 @@ EXPORT_SYMBOL(ide_unregister); | |||
495 | 368 | ||
496 | void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | 369 | void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) |
497 | { | 370 | { |
498 | memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); | 371 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); |
499 | hwif->irq = hw->irq; | 372 | hwif->irq = hw->irq; |
500 | hwif->noprobe = 0; | ||
501 | hwif->chipset = hw->chipset; | 373 | hwif->chipset = hw->chipset; |
502 | hwif->gendev.parent = hw->dev; | 374 | hwif->gendev.parent = hw->dev; |
503 | hwif->ack_intr = hw->ack_intr; | 375 | hwif->ack_intr = hw->ack_intr; |
@@ -588,7 +460,7 @@ int set_using_dma(ide_drive_t *drive, int arg) | |||
588 | if (!drive->id || !(drive->id->capability & 1)) | 460 | if (!drive->id || !(drive->id->capability & 1)) |
589 | goto out; | 461 | goto out; |
590 | 462 | ||
591 | if (hwif->dma_host_set == NULL) | 463 | if (hwif->dma_ops == NULL) |
592 | goto out; | 464 | goto out; |
593 | 465 | ||
594 | err = -EBUSY; | 466 | err = -EBUSY; |
@@ -627,11 +499,14 @@ out: | |||
627 | int set_pio_mode(ide_drive_t *drive, int arg) | 499 | int set_pio_mode(ide_drive_t *drive, int arg) |
628 | { | 500 | { |
629 | struct request rq; | 501 | struct request rq; |
502 | ide_hwif_t *hwif = drive->hwif; | ||
503 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
630 | 504 | ||
631 | if (arg < 0 || arg > 255) | 505 | if (arg < 0 || arg > 255) |
632 | return -EINVAL; | 506 | return -EINVAL; |
633 | 507 | ||
634 | if (drive->hwif->set_pio_mode == NULL) | 508 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || |
509 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
635 | return -ENOSYS; | 510 | return -ENOSYS; |
636 | 511 | ||
637 | if (drive->special.b.set_tune) | 512 | if (drive->special.b.set_tune) |
@@ -953,16 +828,6 @@ static int __init match_parm (char *s, const char *keywords[], int vals[], int m | |||
953 | return 0; /* zero = nothing matched */ | 828 | return 0; /* zero = nothing matched */ |
954 | } | 829 | } |
955 | 830 | ||
956 | extern int probe_ali14xx; | ||
957 | extern int probe_umc8672; | ||
958 | extern int probe_dtc2278; | ||
959 | extern int probe_ht6560b; | ||
960 | extern int probe_qd65xx; | ||
961 | extern int cmd640_vlb; | ||
962 | extern int probe_4drives; | ||
963 | |||
964 | static int __initdata is_chipset_set; | ||
965 | |||
966 | /* | 831 | /* |
967 | * ide_setup() gets called VERY EARLY during initialization, | 832 | * ide_setup() gets called VERY EARLY during initialization, |
968 | * to handle kernel "command line" strings beginning with "hdx=" or "ide". | 833 | * to handle kernel "command line" strings beginning with "hdx=" or "ide". |
@@ -971,14 +836,12 @@ static int __initdata is_chipset_set; | |||
971 | */ | 836 | */ |
972 | static int __init ide_setup(char *s) | 837 | static int __init ide_setup(char *s) |
973 | { | 838 | { |
974 | int i, vals[3]; | ||
975 | ide_hwif_t *hwif; | 839 | ide_hwif_t *hwif; |
976 | ide_drive_t *drive; | 840 | ide_drive_t *drive; |
977 | unsigned int hw, unit; | 841 | unsigned int hw, unit; |
842 | int vals[3]; | ||
978 | const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1); | 843 | const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1); |
979 | const char max_hwif = '0' + (MAX_HWIFS - 1); | ||
980 | 844 | ||
981 | |||
982 | if (strncmp(s,"hd",2) == 0 && s[2] == '=') /* hd= is for hd.c */ | 845 | if (strncmp(s,"hd",2) == 0 && s[2] == '=') /* hd= is for hd.c */ |
983 | return 0; /* driver and not us */ | 846 | return 0; /* driver and not us */ |
984 | 847 | ||
@@ -994,7 +857,7 @@ static int __init ide_setup(char *s) | |||
994 | 857 | ||
995 | printk(" : Enabled support for IDE doublers\n"); | 858 | printk(" : Enabled support for IDE doublers\n"); |
996 | ide_doubler = 1; | 859 | ide_doubler = 1; |
997 | return 1; | 860 | goto obsolete_option; |
998 | } | 861 | } |
999 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ | 862 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ |
1000 | 863 | ||
@@ -1008,17 +871,17 @@ static int __init ide_setup(char *s) | |||
1008 | if (!strcmp(s, "ide=noacpi")) { | 871 | if (!strcmp(s, "ide=noacpi")) { |
1009 | //printk(" : Disable IDE ACPI support.\n"); | 872 | //printk(" : Disable IDE ACPI support.\n"); |
1010 | ide_noacpi = 1; | 873 | ide_noacpi = 1; |
1011 | return 1; | 874 | goto obsolete_option; |
1012 | } | 875 | } |
1013 | if (!strcmp(s, "ide=acpigtf")) { | 876 | if (!strcmp(s, "ide=acpigtf")) { |
1014 | //printk(" : Enable IDE ACPI _GTF support.\n"); | 877 | //printk(" : Enable IDE ACPI _GTF support.\n"); |
1015 | ide_noacpitfs = 0; | 878 | ide_acpigtf = 1; |
1016 | return 1; | 879 | goto obsolete_option; |
1017 | } | 880 | } |
1018 | if (!strcmp(s, "ide=acpionboot")) { | 881 | if (!strcmp(s, "ide=acpionboot")) { |
1019 | //printk(" : Call IDE ACPI methods on boot.\n"); | 882 | //printk(" : Call IDE ACPI methods on boot.\n"); |
1020 | ide_noacpionboot = 0; | 883 | ide_acpionboot = 1; |
1021 | return 1; | 884 | goto obsolete_option; |
1022 | } | 885 | } |
1023 | #endif /* CONFIG_BLK_DEV_IDEACPI */ | 886 | #endif /* CONFIG_BLK_DEV_IDEACPI */ |
1024 | 887 | ||
@@ -1028,7 +891,7 @@ static int __init ide_setup(char *s) | |||
1028 | if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { | 891 | if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { |
1029 | const char *hd_words[] = { | 892 | const char *hd_words[] = { |
1030 | "none", "noprobe", "nowerr", "cdrom", "nodma", | 893 | "none", "noprobe", "nowerr", "cdrom", "nodma", |
1031 | "autotune", "noautotune", "-8", "-9", "-10", | 894 | "-6", "-7", "-8", "-9", "-10", |
1032 | "noflush", "remap", "remap63", "scsi", NULL }; | 895 | "noflush", "remap", "remap63", "scsi", NULL }; |
1033 | unit = s[2] - 'a'; | 896 | unit = s[2] - 'a'; |
1034 | hw = unit / MAX_DRIVES; | 897 | hw = unit / MAX_DRIVES; |
@@ -1043,30 +906,22 @@ static int __init ide_setup(char *s) | |||
1043 | case -1: /* "none" */ | 906 | case -1: /* "none" */ |
1044 | case -2: /* "noprobe" */ | 907 | case -2: /* "noprobe" */ |
1045 | drive->noprobe = 1; | 908 | drive->noprobe = 1; |
1046 | goto done; | 909 | goto obsolete_option; |
1047 | case -3: /* "nowerr" */ | 910 | case -3: /* "nowerr" */ |
1048 | drive->bad_wstat = BAD_R_STAT; | 911 | drive->bad_wstat = BAD_R_STAT; |
1049 | hwif->noprobe = 0; | 912 | goto obsolete_option; |
1050 | goto done; | ||
1051 | case -4: /* "cdrom" */ | 913 | case -4: /* "cdrom" */ |
1052 | drive->present = 1; | 914 | drive->present = 1; |
1053 | drive->media = ide_cdrom; | 915 | drive->media = ide_cdrom; |
1054 | /* an ATAPI device ignores DRDY */ | 916 | /* an ATAPI device ignores DRDY */ |
1055 | drive->ready_stat = 0; | 917 | drive->ready_stat = 0; |
1056 | hwif->noprobe = 0; | 918 | goto obsolete_option; |
1057 | goto done; | ||
1058 | case -5: /* nodma */ | 919 | case -5: /* nodma */ |
1059 | drive->nodma = 1; | 920 | drive->nodma = 1; |
1060 | goto done; | ||
1061 | case -6: /* "autotune" */ | ||
1062 | drive->autotune = IDE_TUNE_AUTO; | ||
1063 | goto obsolete_option; | ||
1064 | case -7: /* "noautotune" */ | ||
1065 | drive->autotune = IDE_TUNE_NOAUTO; | ||
1066 | goto obsolete_option; | 921 | goto obsolete_option; |
1067 | case -11: /* noflush */ | 922 | case -11: /* noflush */ |
1068 | drive->noflush = 1; | 923 | drive->noflush = 1; |
1069 | goto done; | 924 | goto obsolete_option; |
1070 | case -12: /* "remap" */ | 925 | case -12: /* "remap" */ |
1071 | drive->remap_0_to_1 = 1; | 926 | drive->remap_0_to_1 = 1; |
1072 | goto obsolete_option; | 927 | goto obsolete_option; |
@@ -1084,8 +939,7 @@ static int __init ide_setup(char *s) | |||
1084 | drive->sect = drive->bios_sect = vals[2]; | 939 | drive->sect = drive->bios_sect = vals[2]; |
1085 | drive->present = 1; | 940 | drive->present = 1; |
1086 | drive->forced_geom = 1; | 941 | drive->forced_geom = 1; |
1087 | hwif->noprobe = 0; | 942 | goto obsolete_option; |
1088 | goto done; | ||
1089 | default: | 943 | default: |
1090 | goto bad_option; | 944 | goto bad_option; |
1091 | } | 945 | } |
@@ -1103,126 +957,15 @@ static int __init ide_setup(char *s) | |||
1103 | idebus_parameter = vals[0]; | 957 | idebus_parameter = vals[0]; |
1104 | } else | 958 | } else |
1105 | printk(" -- BAD BUS SPEED! Expected value from 20 to 66"); | 959 | printk(" -- BAD BUS SPEED! Expected value from 20 to 66"); |
1106 | goto done; | 960 | goto obsolete_option; |
1107 | } | 961 | } |
1108 | /* | ||
1109 | * Look for interface options: "idex=" | ||
1110 | */ | ||
1111 | if (s[3] >= '0' && s[3] <= max_hwif) { | ||
1112 | /* | ||
1113 | * Be VERY CAREFUL changing this: note hardcoded indexes below | ||
1114 | * (-8, -9, -10) are reserved to ease the hardcoding. | ||
1115 | */ | ||
1116 | static const char *ide_words[] = { | ||
1117 | "minus1", "serialize", "minus3", "minus4", | ||
1118 | "reset", "minus6", "ata66", "minus8", "minus9", | ||
1119 | "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb", | ||
1120 | "dtc2278", "umc8672", "ali14xx", NULL }; | ||
1121 | |||
1122 | hw = s[3] - '0'; | ||
1123 | hwif = &ide_hwifs[hw]; | ||
1124 | i = match_parm(&s[4], ide_words, vals, 3); | ||
1125 | 962 | ||
1126 | /* | ||
1127 | * Cryptic check to ensure chipset not already set for hwif. | ||
1128 | * Note: we can't depend on hwif->chipset here. | ||
1129 | */ | ||
1130 | if (i >= -18 && i <= -11) { | ||
1131 | /* chipset already specified */ | ||
1132 | if (is_chipset_set) | ||
1133 | goto bad_option; | ||
1134 | /* these drivers are for "ide0=" only */ | ||
1135 | if (hw != 0) | ||
1136 | goto bad_hwif; | ||
1137 | is_chipset_set = 1; | ||
1138 | printk("\n"); | ||
1139 | } | ||
1140 | |||
1141 | switch (i) { | ||
1142 | #ifdef CONFIG_BLK_DEV_ALI14XX | ||
1143 | case -17: /* "ali14xx" */ | ||
1144 | probe_ali14xx = 1; | ||
1145 | goto obsolete_option; | ||
1146 | #endif | ||
1147 | #ifdef CONFIG_BLK_DEV_UMC8672 | ||
1148 | case -16: /* "umc8672" */ | ||
1149 | probe_umc8672 = 1; | ||
1150 | goto obsolete_option; | ||
1151 | #endif | ||
1152 | #ifdef CONFIG_BLK_DEV_DTC2278 | ||
1153 | case -15: /* "dtc2278" */ | ||
1154 | probe_dtc2278 = 1; | ||
1155 | goto obsolete_option; | ||
1156 | #endif | ||
1157 | #ifdef CONFIG_BLK_DEV_CMD640 | ||
1158 | case -14: /* "cmd640_vlb" */ | ||
1159 | cmd640_vlb = 1; | ||
1160 | goto obsolete_option; | ||
1161 | #endif | ||
1162 | #ifdef CONFIG_BLK_DEV_HT6560B | ||
1163 | case -13: /* "ht6560b" */ | ||
1164 | probe_ht6560b = 1; | ||
1165 | goto obsolete_option; | ||
1166 | #endif | ||
1167 | #ifdef CONFIG_BLK_DEV_QD65XX | ||
1168 | case -12: /* "qd65xx" */ | ||
1169 | probe_qd65xx = 1; | ||
1170 | goto obsolete_option; | ||
1171 | #endif | ||
1172 | #ifdef CONFIG_BLK_DEV_4DRIVES | ||
1173 | case -11: /* "four" drives on one set of ports */ | ||
1174 | probe_4drives = 1; | ||
1175 | goto obsolete_option; | ||
1176 | #endif | ||
1177 | case -10: /* minus10 */ | ||
1178 | case -9: /* minus9 */ | ||
1179 | case -8: /* minus8 */ | ||
1180 | case -6: | ||
1181 | case -4: | ||
1182 | case -3: | ||
1183 | goto bad_option; | ||
1184 | case -7: /* ata66 */ | ||
1185 | #ifdef CONFIG_BLK_DEV_IDEPCI | ||
1186 | /* | ||
1187 | * Use ATA_CBL_PATA40_SHORT so drive side | ||
1188 | * cable detection is also overriden. | ||
1189 | */ | ||
1190 | hwif->cbl = ATA_CBL_PATA40_SHORT; | ||
1191 | goto obsolete_option; | ||
1192 | #else | ||
1193 | goto bad_hwif; | ||
1194 | #endif | ||
1195 | case -5: /* "reset" */ | ||
1196 | hwif->reset = 1; | ||
1197 | goto obsolete_option; | ||
1198 | case -2: /* "serialize" */ | ||
1199 | hwif->mate = &ide_hwifs[hw^1]; | ||
1200 | hwif->mate->mate = hwif; | ||
1201 | hwif->serialized = hwif->mate->serialized = 1; | ||
1202 | goto obsolete_option; | ||
1203 | |||
1204 | case -1: | ||
1205 | case 0: | ||
1206 | case 1: | ||
1207 | case 2: | ||
1208 | case 3: | ||
1209 | goto bad_option; | ||
1210 | default: | ||
1211 | printk(" -- SUPPORT NOT CONFIGURED IN THIS KERNEL\n"); | ||
1212 | return 1; | ||
1213 | } | ||
1214 | } | ||
1215 | bad_option: | 963 | bad_option: |
1216 | printk(" -- BAD OPTION\n"); | 964 | printk(" -- BAD OPTION\n"); |
1217 | return 1; | 965 | return 1; |
1218 | obsolete_option: | 966 | obsolete_option: |
1219 | printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n"); | 967 | printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n"); |
1220 | return 1; | 968 | return 1; |
1221 | bad_hwif: | ||
1222 | printk("-- NOT SUPPORTED ON ide%d", hw); | ||
1223 | done: | ||
1224 | printk("\n"); | ||
1225 | return 1; | ||
1226 | } | 969 | } |
1227 | 970 | ||
1228 | EXPORT_SYMBOL(ide_lock); | 971 | EXPORT_SYMBOL(ide_lock); |
@@ -1358,6 +1101,185 @@ static void ide_port_class_release(struct device *portdev) | |||
1358 | put_device(&hwif->gendev); | 1101 | put_device(&hwif->gendev); |
1359 | } | 1102 | } |
1360 | 1103 | ||
1104 | int ide_vlb_clk; | ||
1105 | EXPORT_SYMBOL_GPL(ide_vlb_clk); | ||
1106 | |||
1107 | module_param_named(vlb_clock, ide_vlb_clk, int, 0); | ||
1108 | MODULE_PARM_DESC(vlb_clock, "VLB clock frequency (in MHz)"); | ||
1109 | |||
1110 | int ide_pci_clk; | ||
1111 | EXPORT_SYMBOL_GPL(ide_pci_clk); | ||
1112 | |||
1113 | module_param_named(pci_clock, ide_pci_clk, int, 0); | ||
1114 | MODULE_PARM_DESC(pci_clock, "PCI bus clock frequency (in MHz)"); | ||
1115 | |||
1116 | static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp) | ||
1117 | { | ||
1118 | int a, b, i, j = 1; | ||
1119 | unsigned int *dev_param_mask = (unsigned int *)kp->arg; | ||
1120 | |||
1121 | if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 && | ||
1122 | sscanf(s, "%d.%d", &a, &b) != 2) | ||
1123 | return -EINVAL; | ||
1124 | |||
1125 | i = a * MAX_DRIVES + b; | ||
1126 | |||
1127 | if (i >= MAX_HWIFS * MAX_DRIVES || j < 0 || j > 1) | ||
1128 | return -EINVAL; | ||
1129 | |||
1130 | if (j) | ||
1131 | *dev_param_mask |= (1 << i); | ||
1132 | else | ||
1133 | *dev_param_mask &= (1 << i); | ||
1134 | |||
1135 | return 0; | ||
1136 | } | ||
1137 | |||
1138 | static unsigned int ide_nodma; | ||
1139 | |||
1140 | module_param_call(nodma, ide_set_dev_param_mask, NULL, &ide_nodma, 0); | ||
1141 | MODULE_PARM_DESC(nodma, "disallow DMA for a device"); | ||
1142 | |||
1143 | static unsigned int ide_noflush; | ||
1144 | |||
1145 | module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); | ||
1146 | MODULE_PARM_DESC(noflush, "disable flush requests for a device"); | ||
1147 | |||
1148 | static unsigned int ide_noprobe; | ||
1149 | |||
1150 | module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); | ||
1151 | MODULE_PARM_DESC(noprobe, "skip probing for a device"); | ||
1152 | |||
1153 | static unsigned int ide_nowerr; | ||
1154 | |||
1155 | module_param_call(nowerr, ide_set_dev_param_mask, NULL, &ide_nowerr, 0); | ||
1156 | MODULE_PARM_DESC(nowerr, "ignore the WRERR_STAT bit for a device"); | ||
1157 | |||
1158 | static unsigned int ide_cdroms; | ||
1159 | |||
1160 | module_param_call(cdrom, ide_set_dev_param_mask, NULL, &ide_cdroms, 0); | ||
1161 | MODULE_PARM_DESC(cdrom, "force device as a CD-ROM"); | ||
1162 | |||
1163 | struct chs_geom { | ||
1164 | unsigned int cyl; | ||
1165 | u8 head; | ||
1166 | u8 sect; | ||
1167 | }; | ||
1168 | |||
1169 | static unsigned int ide_disks; | ||
1170 | static struct chs_geom ide_disks_chs[MAX_HWIFS * MAX_DRIVES]; | ||
1171 | |||
1172 | static int ide_set_disk_chs(const char *str, struct kernel_param *kp) | ||
1173 | { | ||
1174 | int a, b, c = 0, h = 0, s = 0, i, j = 1; | ||
1175 | |||
1176 | if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 && | ||
1177 | sscanf(str, "%d.%d:%d", &a, &b, &j) != 3) | ||
1178 | return -EINVAL; | ||
1179 | |||
1180 | i = a * MAX_DRIVES + b; | ||
1181 | |||
1182 | if (i >= MAX_HWIFS * MAX_DRIVES || j < 0 || j > 1) | ||
1183 | return -EINVAL; | ||
1184 | |||
1185 | if (c > INT_MAX || h > 255 || s > 255) | ||
1186 | return -EINVAL; | ||
1187 | |||
1188 | if (j) | ||
1189 | ide_disks |= (1 << i); | ||
1190 | else | ||
1191 | ide_disks &= (1 << i); | ||
1192 | |||
1193 | ide_disks_chs[i].cyl = c; | ||
1194 | ide_disks_chs[i].head = h; | ||
1195 | ide_disks_chs[i].sect = s; | ||
1196 | |||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0); | ||
1201 | MODULE_PARM_DESC(chs, "force device as a disk (using CHS)"); | ||
1202 | |||
1203 | static void ide_dev_apply_params(ide_drive_t *drive) | ||
1204 | { | ||
1205 | int i = drive->hwif->index * MAX_DRIVES + drive->select.b.unit; | ||
1206 | |||
1207 | if (ide_nodma & (1 << i)) { | ||
1208 | printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name); | ||
1209 | drive->nodma = 1; | ||
1210 | } | ||
1211 | if (ide_noflush & (1 << i)) { | ||
1212 | printk(KERN_INFO "ide: disabling flush requests for %s\n", | ||
1213 | drive->name); | ||
1214 | drive->noflush = 1; | ||
1215 | } | ||
1216 | if (ide_noprobe & (1 << i)) { | ||
1217 | printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); | ||
1218 | drive->noprobe = 1; | ||
1219 | } | ||
1220 | if (ide_nowerr & (1 << i)) { | ||
1221 | printk(KERN_INFO "ide: ignoring the WRERR_STAT bit for %s\n", | ||
1222 | drive->name); | ||
1223 | drive->bad_wstat = BAD_R_STAT; | ||
1224 | } | ||
1225 | if (ide_cdroms & (1 << i)) { | ||
1226 | printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name); | ||
1227 | drive->present = 1; | ||
1228 | drive->media = ide_cdrom; | ||
1229 | /* an ATAPI device ignores DRDY */ | ||
1230 | drive->ready_stat = 0; | ||
1231 | } | ||
1232 | if (ide_disks & (1 << i)) { | ||
1233 | drive->cyl = drive->bios_cyl = ide_disks_chs[i].cyl; | ||
1234 | drive->head = drive->bios_head = ide_disks_chs[i].head; | ||
1235 | drive->sect = drive->bios_sect = ide_disks_chs[i].sect; | ||
1236 | drive->forced_geom = 1; | ||
1237 | printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n", | ||
1238 | drive->name, | ||
1239 | drive->cyl, drive->head, drive->sect); | ||
1240 | drive->present = 1; | ||
1241 | drive->media = ide_disk; | ||
1242 | drive->ready_stat = READY_STAT; | ||
1243 | } | ||
1244 | } | ||
1245 | |||
1246 | static unsigned int ide_ignore_cable; | ||
1247 | |||
1248 | static int ide_set_ignore_cable(const char *s, struct kernel_param *kp) | ||
1249 | { | ||
1250 | int i, j = 1; | ||
1251 | |||
1252 | if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1) | ||
1253 | return -EINVAL; | ||
1254 | |||
1255 | if (i >= MAX_HWIFS || j < 0 || j > 1) | ||
1256 | return -EINVAL; | ||
1257 | |||
1258 | if (j) | ||
1259 | ide_ignore_cable |= (1 << i); | ||
1260 | else | ||
1261 | ide_ignore_cable &= (1 << i); | ||
1262 | |||
1263 | return 0; | ||
1264 | } | ||
1265 | |||
1266 | module_param_call(ignore_cable, ide_set_ignore_cable, NULL, NULL, 0); | ||
1267 | MODULE_PARM_DESC(ignore_cable, "ignore cable detection"); | ||
1268 | |||
1269 | void ide_port_apply_params(ide_hwif_t *hwif) | ||
1270 | { | ||
1271 | int i; | ||
1272 | |||
1273 | if (ide_ignore_cable & (1 << hwif->index)) { | ||
1274 | printk(KERN_INFO "ide: ignoring cable detection for %s\n", | ||
1275 | hwif->name); | ||
1276 | hwif->cbl = ATA_CBL_PATA40_SHORT; | ||
1277 | } | ||
1278 | |||
1279 | for (i = 0; i < MAX_DRIVES; i++) | ||
1280 | ide_dev_apply_params(&hwif->drives[i]); | ||
1281 | } | ||
1282 | |||
1361 | /* | 1283 | /* |
1362 | * This is gets invoked once during initialization, to set *everything* up | 1284 | * This is gets invoked once during initialization, to set *everything* up |
1363 | */ | 1285 | */ |
@@ -1424,11 +1346,6 @@ int __init init_module (void) | |||
1424 | 1346 | ||
1425 | void __exit cleanup_module (void) | 1347 | void __exit cleanup_module (void) |
1426 | { | 1348 | { |
1427 | int index; | ||
1428 | |||
1429 | for (index = 0; index < MAX_HWIFS; ++index) | ||
1430 | ide_unregister(index); | ||
1431 | |||
1432 | proc_ide_destroy(); | 1349 | proc_ide_destroy(); |
1433 | 1350 | ||
1434 | class_destroy(ide_port_class); | 1351 | class_destroy(ide_port_class); |
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index bc8b1f8de614..90c65cf97448 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -49,6 +49,8 @@ | |||
49 | 49 | ||
50 | #include <asm/io.h> | 50 | #include <asm/io.h> |
51 | 51 | ||
52 | #define DRV_NAME "ali14xx" | ||
53 | |||
52 | /* port addresses for auto-detection */ | 54 | /* port addresses for auto-detection */ |
53 | #define ALI_NUM_PORTS 4 | 55 | #define ALI_NUM_PORTS 4 |
54 | static const int ports[ALI_NUM_PORTS] __initdata = | 56 | static const int ports[ALI_NUM_PORTS] __initdata = |
@@ -86,7 +88,7 @@ static u8 regOff; /* output to base port to close registers */ | |||
86 | /* | 88 | /* |
87 | * Read a controller register. | 89 | * Read a controller register. |
88 | */ | 90 | */ |
89 | static inline u8 inReg (u8 reg) | 91 | static inline u8 inReg(u8 reg) |
90 | { | 92 | { |
91 | outb_p(reg, regPort); | 93 | outb_p(reg, regPort); |
92 | return inb(dataPort); | 94 | return inb(dataPort); |
@@ -95,7 +97,7 @@ static inline u8 inReg (u8 reg) | |||
95 | /* | 97 | /* |
96 | * Write a controller register. | 98 | * Write a controller register. |
97 | */ | 99 | */ |
98 | static void outReg (u8 data, u8 reg) | 100 | static void outReg(u8 data, u8 reg) |
99 | { | 101 | { |
100 | outb_p(reg, regPort); | 102 | outb_p(reg, regPort); |
101 | outb_p(data, dataPort); | 103 | outb_p(data, dataPort); |
@@ -114,7 +116,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
114 | int time1, time2; | 116 | int time1, time2; |
115 | u8 param1, param2, param3, param4; | 117 | u8 param1, param2, param3, param4; |
116 | unsigned long flags; | 118 | unsigned long flags; |
117 | int bus_speed = system_bus_clock(); | 119 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); |
118 | 120 | ||
119 | /* calculate timing, according to PIO mode */ | 121 | /* calculate timing, according to PIO mode */ |
120 | time1 = ide_pio_cycle_time(drive, pio); | 122 | time1 = ide_pio_cycle_time(drive, pio); |
@@ -143,7 +145,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
143 | /* | 145 | /* |
144 | * Auto-detect the IDE controller port. | 146 | * Auto-detect the IDE controller port. |
145 | */ | 147 | */ |
146 | static int __init findPort (void) | 148 | static int __init findPort(void) |
147 | { | 149 | { |
148 | int i; | 150 | int i; |
149 | u8 t; | 151 | u8 t; |
@@ -175,7 +177,8 @@ static int __init findPort (void) | |||
175 | /* | 177 | /* |
176 | * Initialize controller registers with default values. | 178 | * Initialize controller registers with default values. |
177 | */ | 179 | */ |
178 | static int __init initRegisters (void) { | 180 | static int __init initRegisters(void) |
181 | { | ||
179 | const RegInitializer *p; | 182 | const RegInitializer *p; |
180 | u8 t; | 183 | u8 t; |
181 | unsigned long flags; | 184 | unsigned long flags; |
@@ -191,17 +194,20 @@ static int __init initRegisters (void) { | |||
191 | return t; | 194 | return t; |
192 | } | 195 | } |
193 | 196 | ||
197 | static const struct ide_port_ops ali14xx_port_ops = { | ||
198 | .set_pio_mode = ali14xx_set_pio_mode, | ||
199 | }; | ||
200 | |||
194 | static const struct ide_port_info ali14xx_port_info = { | 201 | static const struct ide_port_info ali14xx_port_info = { |
202 | .name = DRV_NAME, | ||
195 | .chipset = ide_ali14xx, | 203 | .chipset = ide_ali14xx, |
196 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, | 204 | .port_ops = &ali14xx_port_ops, |
205 | .host_flags = IDE_HFLAG_NO_DMA, | ||
197 | .pio_mask = ATA_PIO4, | 206 | .pio_mask = ATA_PIO4, |
198 | }; | 207 | }; |
199 | 208 | ||
200 | static int __init ali14xx_probe(void) | 209 | static int __init ali14xx_probe(void) |
201 | { | 210 | { |
202 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
203 | hw_regs_t hw[2]; | ||
204 | |||
205 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", | 211 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", |
206 | basePort, regOn); | 212 | basePort, regOn); |
207 | 213 | ||
@@ -211,26 +217,10 @@ static int __init ali14xx_probe(void) | |||
211 | return 1; | 217 | return 1; |
212 | } | 218 | } |
213 | 219 | ||
214 | memset(&hw, 0, sizeof(hw)); | 220 | return ide_legacy_device_add(&ali14xx_port_info, 0); |
215 | |||
216 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
217 | hw[0].irq = 14; | ||
218 | |||
219 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
220 | hw[1].irq = 15; | ||
221 | |||
222 | ide_init_port_hw(&ide_hwifs[0], &hw[0]); | ||
223 | ide_init_port_hw(&ide_hwifs[1], &hw[1]); | ||
224 | |||
225 | ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode; | ||
226 | ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode; | ||
227 | |||
228 | ide_device_add(idx, &ali14xx_port_info); | ||
229 | |||
230 | return 0; | ||
231 | } | 221 | } |
232 | 222 | ||
233 | int probe_ali14xx = 0; | 223 | static int probe_ali14xx; |
234 | 224 | ||
235 | module_param_named(probe, probe_ali14xx, bool, 0); | 225 | module_param_named(probe, probe_ali14xx, bool, 0); |
236 | MODULE_PARM_DESC(probe, "probe for ALI M14xx chipsets"); | 226 | MODULE_PARM_DESC(probe, "probe for ALI M14xx chipsets"); |
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index fdd3791e465f..5c730e4dd735 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
@@ -102,7 +102,7 @@ static int buddha_ack_intr(ide_hwif_t *hwif) | |||
102 | { | 102 | { |
103 | unsigned char ch; | 103 | unsigned char ch; |
104 | 104 | ||
105 | ch = z_readb(hwif->io_ports[IDE_IRQ_OFFSET]); | 105 | ch = z_readb(hwif->io_ports.irq_addr); |
106 | if (!(ch & 0x80)) | 106 | if (!(ch & 0x80)) |
107 | return 0; | 107 | return 0; |
108 | return 1; | 108 | return 1; |
@@ -112,9 +112,9 @@ static int xsurf_ack_intr(ide_hwif_t *hwif) | |||
112 | { | 112 | { |
113 | unsigned char ch; | 113 | unsigned char ch; |
114 | 114 | ||
115 | ch = z_readb(hwif->io_ports[IDE_IRQ_OFFSET]); | 115 | ch = z_readb(hwif->io_ports.irq_addr); |
116 | /* X-Surf needs a 0 written to IRQ register to ensure ISA bit A11 stays at 0 */ | 116 | /* X-Surf needs a 0 written to IRQ register to ensure ISA bit A11 stays at 0 */ |
117 | z_writeb(0, hwif->io_ports[IDE_IRQ_OFFSET]); | 117 | z_writeb(0, hwif->io_ports.irq_addr); |
118 | if (!(ch & 0x80)) | 118 | if (!(ch & 0x80)) |
119 | return 0; | 119 | return 0; |
120 | return 1; | 120 | return 1; |
@@ -128,13 +128,13 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, | |||
128 | 128 | ||
129 | memset(hw, 0, sizeof(*hw)); | 129 | memset(hw, 0, sizeof(*hw)); |
130 | 130 | ||
131 | hw->io_ports[IDE_DATA_OFFSET] = base; | 131 | hw->io_ports.data_addr = base; |
132 | 132 | ||
133 | for (i = 1; i < 8; i++) | 133 | for (i = 1; i < 8; i++) |
134 | hw->io_ports[i] = base + 2 + i * 4; | 134 | hw->io_ports_array[i] = base + 2 + i * 4; |
135 | 135 | ||
136 | hw->io_ports[IDE_CONTROL_OFFSET] = ctl; | 136 | hw->io_ports.ctl_addr = ctl; |
137 | hw->io_ports[IDE_IRQ_OFFSET] = irq_port; | 137 | hw->io_ports.irq_addr = irq_port; |
138 | 138 | ||
139 | hw->irq = IRQ_AMIGA_PORTS; | 139 | hw->irq = IRQ_AMIGA_PORTS; |
140 | hw->ack_intr = ack_intr; | 140 | hw->ack_intr = ack_intr; |
@@ -221,15 +221,13 @@ fail_base2: | |||
221 | 221 | ||
222 | buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr); | 222 | buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr); |
223 | 223 | ||
224 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 224 | hwif = ide_find_port(); |
225 | if (hwif) { | 225 | if (hwif) { |
226 | u8 index = hwif->index; | 226 | u8 index = hwif->index; |
227 | 227 | ||
228 | ide_init_port_data(hwif, index); | 228 | ide_init_port_data(hwif, index); |
229 | ide_init_port_hw(hwif, &hw); | 229 | ide_init_port_hw(hwif, &hw); |
230 | 230 | ||
231 | hwif->mmio = 1; | ||
232 | |||
233 | idx[i] = index; | 231 | idx[i] = index; |
234 | } | 232 | } |
235 | } | 233 | } |
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 5f69cd2ea6f7..af791a02a120 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
18 | 18 | ||
19 | #define DRV_NAME "dtc2278" | ||
20 | |||
19 | /* | 21 | /* |
20 | * Changing this #undef to #define may solve start up problems in some systems. | 22 | * Changing this #undef to #define may solve start up problems in some systems. |
21 | */ | 23 | */ |
@@ -86,30 +88,26 @@ static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
86 | } | 88 | } |
87 | } | 89 | } |
88 | 90 | ||
91 | static const struct ide_port_ops dtc2278_port_ops = { | ||
92 | .set_pio_mode = dtc2278_set_pio_mode, | ||
93 | }; | ||
94 | |||
89 | static const struct ide_port_info dtc2278_port_info __initdata = { | 95 | static const struct ide_port_info dtc2278_port_info __initdata = { |
96 | .name = DRV_NAME, | ||
90 | .chipset = ide_dtc2278, | 97 | .chipset = ide_dtc2278, |
98 | .port_ops = &dtc2278_port_ops, | ||
91 | .host_flags = IDE_HFLAG_SERIALIZE | | 99 | .host_flags = IDE_HFLAG_SERIALIZE | |
92 | IDE_HFLAG_NO_UNMASK_IRQS | | 100 | IDE_HFLAG_NO_UNMASK_IRQS | |
93 | IDE_HFLAG_IO_32BIT | | 101 | IDE_HFLAG_IO_32BIT | |
94 | /* disallow ->io_32bit changes */ | 102 | /* disallow ->io_32bit changes */ |
95 | IDE_HFLAG_NO_IO_32BIT | | 103 | IDE_HFLAG_NO_IO_32BIT | |
96 | IDE_HFLAG_NO_DMA | | 104 | IDE_HFLAG_NO_DMA, |
97 | IDE_HFLAG_NO_AUTOTUNE, | ||
98 | .pio_mask = ATA_PIO4, | 105 | .pio_mask = ATA_PIO4, |
99 | }; | 106 | }; |
100 | 107 | ||
101 | static int __init dtc2278_probe(void) | 108 | static int __init dtc2278_probe(void) |
102 | { | 109 | { |
103 | unsigned long flags; | 110 | unsigned long flags; |
104 | ide_hwif_t *hwif, *mate; | ||
105 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
106 | hw_regs_t hw[2]; | ||
107 | |||
108 | hwif = &ide_hwifs[0]; | ||
109 | mate = &ide_hwifs[1]; | ||
110 | |||
111 | if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown) | ||
112 | return 1; | ||
113 | 111 | ||
114 | local_irq_save(flags); | 112 | local_irq_save(flags); |
115 | /* | 113 | /* |
@@ -129,25 +127,10 @@ static int __init dtc2278_probe(void) | |||
129 | #endif | 127 | #endif |
130 | local_irq_restore(flags); | 128 | local_irq_restore(flags); |
131 | 129 | ||
132 | memset(&hw, 0, sizeof(hw)); | 130 | return ide_legacy_device_add(&dtc2278_port_info, 0); |
133 | |||
134 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
135 | hw[0].irq = 14; | ||
136 | |||
137 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
138 | hw[1].irq = 15; | ||
139 | |||
140 | ide_init_port_hw(hwif, &hw[0]); | ||
141 | ide_init_port_hw(mate, &hw[1]); | ||
142 | |||
143 | hwif->set_pio_mode = &dtc2278_set_pio_mode; | ||
144 | |||
145 | ide_device_add(idx, &dtc2278_port_info); | ||
146 | |||
147 | return 0; | ||
148 | } | 131 | } |
149 | 132 | ||
150 | int probe_dtc2278 = 0; | 133 | static int probe_dtc2278; |
151 | 134 | ||
152 | module_param_named(probe, probe_dtc2278, bool, 0); | 135 | module_param_named(probe, probe_dtc2278, bool, 0); |
153 | MODULE_PARM_DESC(probe, "probe for DTC2278xx chipsets"); | 136 | MODULE_PARM_DESC(probe, "probe for DTC2278xx chipsets"); |
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index e950afa5939c..56cdaa0eeea5 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <asm/atariints.h> | 22 | #include <asm/atariints.h> |
23 | #include <asm/atari_stdma.h> | 23 | #include <asm/atari_stdma.h> |
24 | 24 | ||
25 | #define DRV_NAME "falconide" | ||
25 | 26 | ||
26 | /* | 27 | /* |
27 | * Base of the IDE interface | 28 | * Base of the IDE interface |
@@ -49,12 +50,12 @@ static void __init falconide_setup_ports(hw_regs_t *hw) | |||
49 | 50 | ||
50 | memset(hw, 0, sizeof(*hw)); | 51 | memset(hw, 0, sizeof(*hw)); |
51 | 52 | ||
52 | hw->io_ports[IDE_DATA_OFFSET] = ATA_HD_BASE; | 53 | hw->io_ports.data_addr = ATA_HD_BASE; |
53 | 54 | ||
54 | for (i = 1; i < 8; i++) | 55 | for (i = 1; i < 8; i++) |
55 | hw->io_ports[i] = ATA_HD_BASE + 1 + i * 4; | 56 | hw->io_ports_array[i] = ATA_HD_BASE + 1 + i * 4; |
56 | 57 | ||
57 | hw->io_ports[IDE_CONTROL_OFFSET] = ATA_HD_BASE + ATA_HD_CONTROL; | 58 | hw->io_ports.ctl_addr = ATA_HD_BASE + ATA_HD_CONTROL; |
58 | 59 | ||
59 | hw->irq = IRQ_MFP_IDE; | 60 | hw->irq = IRQ_MFP_IDE; |
60 | hw->ack_intr = NULL; | 61 | hw->ack_intr = NULL; |
@@ -74,9 +75,14 @@ static int __init falconide_init(void) | |||
74 | 75 | ||
75 | printk(KERN_INFO "ide: Falcon IDE controller\n"); | 76 | printk(KERN_INFO "ide: Falcon IDE controller\n"); |
76 | 77 | ||
78 | if (!request_mem_region(ATA_HD_BASE, 0x40, DRV_NAME)) { | ||
79 | printk(KERN_ERR "%s: resources busy\n", DRV_NAME); | ||
80 | return -EBUSY; | ||
81 | } | ||
82 | |||
77 | falconide_setup_ports(&hw); | 83 | falconide_setup_ports(&hw); |
78 | 84 | ||
79 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 85 | hwif = ide_find_port(); |
80 | if (hwif) { | 86 | if (hwif) { |
81 | u8 index = hwif->index; | 87 | u8 index = hwif->index; |
82 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | 88 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; |
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index e3b4638cc883..a9c2593a898c 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -63,6 +63,8 @@ | |||
63 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) | 63 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) |
64 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) | 64 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) |
65 | int ide_doubler = 0; /* support IDE doublers? */ | 65 | int ide_doubler = 0; /* support IDE doublers? */ |
66 | module_param_named(doubler, ide_doubler, bool, 0); | ||
67 | MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); | ||
66 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ | 68 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ |
67 | 69 | ||
68 | 70 | ||
@@ -74,7 +76,7 @@ static int gayle_ack_intr_a4000(ide_hwif_t *hwif) | |||
74 | { | 76 | { |
75 | unsigned char ch; | 77 | unsigned char ch; |
76 | 78 | ||
77 | ch = z_readb(hwif->io_ports[IDE_IRQ_OFFSET]); | 79 | ch = z_readb(hwif->io_ports.irq_addr); |
78 | if (!(ch & GAYLE_IRQ_IDE)) | 80 | if (!(ch & GAYLE_IRQ_IDE)) |
79 | return 0; | 81 | return 0; |
80 | return 1; | 82 | return 1; |
@@ -84,11 +86,11 @@ static int gayle_ack_intr_a1200(ide_hwif_t *hwif) | |||
84 | { | 86 | { |
85 | unsigned char ch; | 87 | unsigned char ch; |
86 | 88 | ||
87 | ch = z_readb(hwif->io_ports[IDE_IRQ_OFFSET]); | 89 | ch = z_readb(hwif->io_ports.irq_addr); |
88 | if (!(ch & GAYLE_IRQ_IDE)) | 90 | if (!(ch & GAYLE_IRQ_IDE)) |
89 | return 0; | 91 | return 0; |
90 | (void)z_readb(hwif->io_ports[IDE_STATUS_OFFSET]); | 92 | (void)z_readb(hwif->io_ports.status_addr); |
91 | z_writeb(0x7c, hwif->io_ports[IDE_IRQ_OFFSET]); | 93 | z_writeb(0x7c, hwif->io_ports.irq_addr); |
92 | return 1; | 94 | return 1; |
93 | } | 95 | } |
94 | 96 | ||
@@ -100,13 +102,13 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, | |||
100 | 102 | ||
101 | memset(hw, 0, sizeof(*hw)); | 103 | memset(hw, 0, sizeof(*hw)); |
102 | 104 | ||
103 | hw->io_ports[IDE_DATA_OFFSET] = base; | 105 | hw->io_ports.data_addr = base; |
104 | 106 | ||
105 | for (i = 1; i < 8; i++) | 107 | for (i = 1; i < 8; i++) |
106 | hw->io_ports[i] = base + 2 + i * 4; | 108 | hw->io_ports_array[i] = base + 2 + i * 4; |
107 | 109 | ||
108 | hw->io_ports[IDE_CONTROL_OFFSET] = ctl; | 110 | hw->io_ports.ctl_addr = ctl; |
109 | hw->io_ports[IDE_IRQ_OFFSET] = irq_port; | 111 | hw->io_ports.irq_addr = irq_port; |
110 | 112 | ||
111 | hw->irq = IRQ_AMIGA_PORTS; | 113 | hw->irq = IRQ_AMIGA_PORTS; |
112 | hw->ack_intr = ack_intr; | 114 | hw->ack_intr = ack_intr; |
@@ -175,15 +177,13 @@ found: | |||
175 | 177 | ||
176 | gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr); | 178 | gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr); |
177 | 179 | ||
178 | hwif = ide_find_port(base); | 180 | hwif = ide_find_port(); |
179 | if (hwif) { | 181 | if (hwif) { |
180 | u8 index = hwif->index; | 182 | u8 index = hwif->index; |
181 | 183 | ||
182 | ide_init_port_data(hwif, index); | 184 | ide_init_port_data(hwif, index); |
183 | ide_init_port_hw(hwif, &hw); | 185 | ide_init_port_hw(hwif, &hw); |
184 | 186 | ||
185 | hwif->mmio = 1; | ||
186 | |||
187 | idx[i] = index; | 187 | idx[i] = index; |
188 | } else | 188 | } else |
189 | release_mem_region(res_start, res_n); | 189 | release_mem_region(res_start, res_n); |
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c index 0b0d86731927..abdedf56643e 100644 --- a/drivers/ide/legacy/hd.c +++ b/drivers/ide/legacy/hd.c | |||
@@ -122,12 +122,12 @@ static int hd_error; | |||
122 | * This struct defines the HD's and their types. | 122 | * This struct defines the HD's and their types. |
123 | */ | 123 | */ |
124 | struct hd_i_struct { | 124 | struct hd_i_struct { |
125 | unsigned int head,sect,cyl,wpcom,lzone,ctl; | 125 | unsigned int head, sect, cyl, wpcom, lzone, ctl; |
126 | int unit; | 126 | int unit; |
127 | int recalibrate; | 127 | int recalibrate; |
128 | int special_op; | 128 | int special_op; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #ifdef HD_TYPE | 131 | #ifdef HD_TYPE |
132 | static struct hd_i_struct hd_info[] = { HD_TYPE }; | 132 | static struct hd_i_struct hd_info[] = { HD_TYPE }; |
133 | static int NR_HD = ARRAY_SIZE(hd_info); | 133 | static int NR_HD = ARRAY_SIZE(hd_info); |
@@ -168,7 +168,7 @@ unsigned long read_timer(void) | |||
168 | 168 | ||
169 | spin_lock_irqsave(&i8253_lock, flags); | 169 | spin_lock_irqsave(&i8253_lock, flags); |
170 | t = jiffies * 11932; | 170 | t = jiffies * 11932; |
171 | outb_p(0, 0x43); | 171 | outb_p(0, 0x43); |
172 | i = inb_p(0x40); | 172 | i = inb_p(0x40); |
173 | i |= inb(0x40) << 8; | 173 | i |= inb(0x40) << 8; |
174 | spin_unlock_irqrestore(&i8253_lock, flags); | 174 | spin_unlock_irqrestore(&i8253_lock, flags); |
@@ -183,7 +183,7 @@ static void __init hd_setup(char *str, int *ints) | |||
183 | if (ints[0] != 3) | 183 | if (ints[0] != 3) |
184 | return; | 184 | return; |
185 | if (hd_info[0].head != 0) | 185 | if (hd_info[0].head != 0) |
186 | hdind=1; | 186 | hdind = 1; |
187 | hd_info[hdind].head = ints[2]; | 187 | hd_info[hdind].head = ints[2]; |
188 | hd_info[hdind].sect = ints[3]; | 188 | hd_info[hdind].sect = ints[3]; |
189 | hd_info[hdind].cyl = ints[1]; | 189 | hd_info[hdind].cyl = ints[1]; |
@@ -193,7 +193,7 @@ static void __init hd_setup(char *str, int *ints) | |||
193 | NR_HD = hdind+1; | 193 | NR_HD = hdind+1; |
194 | } | 194 | } |
195 | 195 | ||
196 | static void dump_status (const char *msg, unsigned int stat) | 196 | static void dump_status(const char *msg, unsigned int stat) |
197 | { | 197 | { |
198 | char *name = "hd?"; | 198 | char *name = "hd?"; |
199 | if (CURRENT) | 199 | if (CURRENT) |
@@ -291,7 +291,6 @@ static int controller_ready(unsigned int drive, unsigned int head) | |||
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | |||
295 | static void hd_out(struct hd_i_struct *disk, | 294 | static void hd_out(struct hd_i_struct *disk, |
296 | unsigned int nsect, | 295 | unsigned int nsect, |
297 | unsigned int sect, | 296 | unsigned int sect, |
@@ -313,15 +312,15 @@ static void hd_out(struct hd_i_struct *disk, | |||
313 | return; | 312 | return; |
314 | } | 313 | } |
315 | SET_HANDLER(intr_addr); | 314 | SET_HANDLER(intr_addr); |
316 | outb_p(disk->ctl,HD_CMD); | 315 | outb_p(disk->ctl, HD_CMD); |
317 | port=HD_DATA; | 316 | port = HD_DATA; |
318 | outb_p(disk->wpcom>>2,++port); | 317 | outb_p(disk->wpcom >> 2, ++port); |
319 | outb_p(nsect,++port); | 318 | outb_p(nsect, ++port); |
320 | outb_p(sect,++port); | 319 | outb_p(sect, ++port); |
321 | outb_p(cyl,++port); | 320 | outb_p(cyl, ++port); |
322 | outb_p(cyl>>8,++port); | 321 | outb_p(cyl >> 8, ++port); |
323 | outb_p(0xA0|(disk->unit<<4)|head,++port); | 322 | outb_p(0xA0 | (disk->unit << 4) | head, ++port); |
324 | outb_p(cmd,++port); | 323 | outb_p(cmd, ++port); |
325 | } | 324 | } |
326 | 325 | ||
327 | static void hd_request (void); | 326 | static void hd_request (void); |
@@ -344,14 +343,14 @@ static void reset_controller(void) | |||
344 | { | 343 | { |
345 | int i; | 344 | int i; |
346 | 345 | ||
347 | outb_p(4,HD_CMD); | 346 | outb_p(4, HD_CMD); |
348 | for(i = 0; i < 1000; i++) barrier(); | 347 | for (i = 0; i < 1000; i++) barrier(); |
349 | outb_p(hd_info[0].ctl & 0x0f,HD_CMD); | 348 | outb_p(hd_info[0].ctl & 0x0f, HD_CMD); |
350 | for(i = 0; i < 1000; i++) barrier(); | 349 | for (i = 0; i < 1000; i++) barrier(); |
351 | if (drive_busy()) | 350 | if (drive_busy()) |
352 | printk("hd: controller still busy\n"); | 351 | printk("hd: controller still busy\n"); |
353 | else if ((hd_error = inb(HD_ERROR)) != 1) | 352 | else if ((hd_error = inb(HD_ERROR)) != 1) |
354 | printk("hd: controller reset failed: %02x\n",hd_error); | 353 | printk("hd: controller reset failed: %02x\n", hd_error); |
355 | } | 354 | } |
356 | 355 | ||
357 | static void reset_hd(void) | 356 | static void reset_hd(void) |
@@ -371,8 +370,8 @@ repeat: | |||
371 | if (++i < NR_HD) { | 370 | if (++i < NR_HD) { |
372 | struct hd_i_struct *disk = &hd_info[i]; | 371 | struct hd_i_struct *disk = &hd_info[i]; |
373 | disk->special_op = disk->recalibrate = 1; | 372 | disk->special_op = disk->recalibrate = 1; |
374 | hd_out(disk,disk->sect,disk->sect,disk->head-1, | 373 | hd_out(disk, disk->sect, disk->sect, disk->head-1, |
375 | disk->cyl,WIN_SPECIFY,&reset_hd); | 374 | disk->cyl, WIN_SPECIFY, &reset_hd); |
376 | if (reset) | 375 | if (reset) |
377 | goto repeat; | 376 | goto repeat; |
378 | } else | 377 | } else |
@@ -393,7 +392,7 @@ static void unexpected_hd_interrupt(void) | |||
393 | unsigned int stat = inb_p(HD_STATUS); | 392 | unsigned int stat = inb_p(HD_STATUS); |
394 | 393 | ||
395 | if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) { | 394 | if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) { |
396 | dump_status ("unexpected interrupt", stat); | 395 | dump_status("unexpected interrupt", stat); |
397 | SET_TIMER; | 396 | SET_TIMER; |
398 | } | 397 | } |
399 | } | 398 | } |
@@ -453,7 +452,7 @@ static void read_intr(void) | |||
453 | return; | 452 | return; |
454 | ok_to_read: | 453 | ok_to_read: |
455 | req = CURRENT; | 454 | req = CURRENT; |
456 | insw(HD_DATA,req->buffer,256); | 455 | insw(HD_DATA, req->buffer, 256); |
457 | req->sector++; | 456 | req->sector++; |
458 | req->buffer += 512; | 457 | req->buffer += 512; |
459 | req->errors = 0; | 458 | req->errors = 0; |
@@ -507,7 +506,7 @@ ok_to_write: | |||
507 | end_request(req, 1); | 506 | end_request(req, 1); |
508 | if (i > 0) { | 507 | if (i > 0) { |
509 | SET_HANDLER(&write_intr); | 508 | SET_HANDLER(&write_intr); |
510 | outsw(HD_DATA,req->buffer,256); | 509 | outsw(HD_DATA, req->buffer, 256); |
511 | local_irq_enable(); | 510 | local_irq_enable(); |
512 | } else { | 511 | } else { |
513 | #if (HD_DELAY > 0) | 512 | #if (HD_DELAY > 0) |
@@ -560,11 +559,11 @@ static int do_special_op(struct hd_i_struct *disk, struct request *req) | |||
560 | { | 559 | { |
561 | if (disk->recalibrate) { | 560 | if (disk->recalibrate) { |
562 | disk->recalibrate = 0; | 561 | disk->recalibrate = 0; |
563 | hd_out(disk,disk->sect,0,0,0,WIN_RESTORE,&recal_intr); | 562 | hd_out(disk, disk->sect, 0, 0, 0, WIN_RESTORE, &recal_intr); |
564 | return reset; | 563 | return reset; |
565 | } | 564 | } |
566 | if (disk->head > 16) { | 565 | if (disk->head > 16) { |
567 | printk ("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name); | 566 | printk("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name); |
568 | end_request(req, 0); | 567 | end_request(req, 0); |
569 | } | 568 | } |
570 | disk->special_op = 0; | 569 | disk->special_op = 0; |
@@ -633,19 +632,21 @@ repeat: | |||
633 | if (blk_fs_request(req)) { | 632 | if (blk_fs_request(req)) { |
634 | switch (rq_data_dir(req)) { | 633 | switch (rq_data_dir(req)) { |
635 | case READ: | 634 | case READ: |
636 | hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr); | 635 | hd_out(disk, nsect, sec, head, cyl, WIN_READ, |
636 | &read_intr); | ||
637 | if (reset) | 637 | if (reset) |
638 | goto repeat; | 638 | goto repeat; |
639 | break; | 639 | break; |
640 | case WRITE: | 640 | case WRITE: |
641 | hd_out(disk,nsect,sec,head,cyl,WIN_WRITE,&write_intr); | 641 | hd_out(disk, nsect, sec, head, cyl, WIN_WRITE, |
642 | &write_intr); | ||
642 | if (reset) | 643 | if (reset) |
643 | goto repeat; | 644 | goto repeat; |
644 | if (wait_DRQ()) { | 645 | if (wait_DRQ()) { |
645 | bad_rw_intr(); | 646 | bad_rw_intr(); |
646 | goto repeat; | 647 | goto repeat; |
647 | } | 648 | } |
648 | outsw(HD_DATA,req->buffer,256); | 649 | outsw(HD_DATA, req->buffer, 256); |
649 | break; | 650 | break; |
650 | default: | 651 | default: |
651 | printk("unknown hd-command\n"); | 652 | printk("unknown hd-command\n"); |
@@ -655,7 +656,7 @@ repeat: | |||
655 | } | 656 | } |
656 | } | 657 | } |
657 | 658 | ||
658 | static void do_hd_request (struct request_queue * q) | 659 | static void do_hd_request(struct request_queue *q) |
659 | { | 660 | { |
660 | disable_irq(HD_IRQ); | 661 | disable_irq(HD_IRQ); |
661 | hd_request(); | 662 | hd_request(); |
@@ -708,12 +709,12 @@ static int __init hd_init(void) | |||
708 | { | 709 | { |
709 | int drive; | 710 | int drive; |
710 | 711 | ||
711 | if (register_blkdev(MAJOR_NR,"hd")) | 712 | if (register_blkdev(MAJOR_NR, "hd")) |
712 | return -1; | 713 | return -1; |
713 | 714 | ||
714 | hd_queue = blk_init_queue(do_hd_request, &hd_lock); | 715 | hd_queue = blk_init_queue(do_hd_request, &hd_lock); |
715 | if (!hd_queue) { | 716 | if (!hd_queue) { |
716 | unregister_blkdev(MAJOR_NR,"hd"); | 717 | unregister_blkdev(MAJOR_NR, "hd"); |
717 | return -ENOMEM; | 718 | return -ENOMEM; |
718 | } | 719 | } |
719 | 720 | ||
@@ -742,7 +743,7 @@ static int __init hd_init(void) | |||
742 | goto out; | 743 | goto out; |
743 | } | 744 | } |
744 | 745 | ||
745 | for (drive=0 ; drive < NR_HD ; drive++) { | 746 | for (drive = 0 ; drive < NR_HD ; drive++) { |
746 | struct gendisk *disk = alloc_disk(64); | 747 | struct gendisk *disk = alloc_disk(64); |
747 | struct hd_i_struct *p = &hd_info[drive]; | 748 | struct hd_i_struct *p = &hd_info[drive]; |
748 | if (!disk) | 749 | if (!disk) |
@@ -756,7 +757,7 @@ static int __init hd_init(void) | |||
756 | disk->queue = hd_queue; | 757 | disk->queue = hd_queue; |
757 | p->unit = drive; | 758 | p->unit = drive; |
758 | hd_gendisk[drive] = disk; | 759 | hd_gendisk[drive] = disk; |
759 | printk ("%s: %luMB, CHS=%d/%d/%d\n", | 760 | printk("%s: %luMB, CHS=%d/%d/%d\n", |
760 | disk->disk_name, (unsigned long)get_capacity(disk)/2048, | 761 | disk->disk_name, (unsigned long)get_capacity(disk)/2048, |
761 | p->cyl, p->head, p->sect); | 762 | p->cyl, p->head, p->sect); |
762 | } | 763 | } |
@@ -776,7 +777,7 @@ static int __init hd_init(void) | |||
776 | } | 777 | } |
777 | 778 | ||
778 | /* Let them fly */ | 779 | /* Let them fly */ |
779 | for(drive=0; drive < NR_HD; drive++) | 780 | for (drive = 0; drive < NR_HD; drive++) |
780 | add_disk(hd_gendisk[drive]); | 781 | add_disk(hd_gendisk[drive]); |
781 | 782 | ||
782 | return 0; | 783 | return 0; |
@@ -791,7 +792,7 @@ out1: | |||
791 | NR_HD = 0; | 792 | NR_HD = 0; |
792 | out: | 793 | out: |
793 | del_timer(&device_timer); | 794 | del_timer(&device_timer); |
794 | unregister_blkdev(MAJOR_NR,"hd"); | 795 | unregister_blkdev(MAJOR_NR, "hd"); |
795 | blk_cleanup_queue(hd_queue); | 796 | blk_cleanup_queue(hd_queue); |
796 | return -1; | 797 | return -1; |
797 | Enomem: | 798 | Enomem: |
@@ -800,7 +801,8 @@ Enomem: | |||
800 | goto out; | 801 | goto out; |
801 | } | 802 | } |
802 | 803 | ||
803 | static int __init parse_hd_setup (char *line) { | 804 | static int __init parse_hd_setup(char *line) |
805 | { | ||
804 | int ints[6]; | 806 | int ints[6]; |
805 | 807 | ||
806 | (void) get_options(line, ARRAY_SIZE(ints), ints); | 808 | (void) get_options(line, ARRAY_SIZE(ints), ints); |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 88fe9070c9c3..4fe516df9f74 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -35,6 +35,7 @@ | |||
35 | * Try: http://www.maf.iki.fi/~maf/ht6560b/ | 35 | * Try: http://www.maf.iki.fi/~maf/ht6560b/ |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #define DRV_NAME "ht6560b" | ||
38 | #define HT6560B_VERSION "v0.08" | 39 | #define HT6560B_VERSION "v0.08" |
39 | 40 | ||
40 | #include <linux/module.h> | 41 | #include <linux/module.h> |
@@ -156,8 +157,8 @@ static void ht6560b_selectproc (ide_drive_t *drive) | |||
156 | /* | 157 | /* |
157 | * Set timing for this drive: | 158 | * Set timing for this drive: |
158 | */ | 159 | */ |
159 | outb(timing, hwif->io_ports[IDE_SELECT_OFFSET]); | 160 | outb(timing, hwif->io_ports.device_addr); |
160 | (void)inb(hwif->io_ports[IDE_STATUS_OFFSET]); | 161 | (void)inb(hwif->io_ports.status_addr); |
161 | #ifdef DEBUG | 162 | #ifdef DEBUG |
162 | printk("ht6560b: %s: select=%#x timing=%#x\n", | 163 | printk("ht6560b: %s: select=%#x timing=%#x\n", |
163 | drive->name, select, timing); | 164 | drive->name, select, timing); |
@@ -211,8 +212,8 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) | |||
211 | { | 212 | { |
212 | int active_time, recovery_time; | 213 | int active_time, recovery_time; |
213 | int active_cycles, recovery_cycles; | 214 | int active_cycles, recovery_cycles; |
214 | int bus_speed = system_bus_clock(); | 215 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); |
215 | 216 | ||
216 | if (pio) { | 217 | if (pio) { |
217 | unsigned int cycle_time; | 218 | unsigned int cycle_time; |
218 | 219 | ||
@@ -322,66 +323,44 @@ static void __init ht6560b_port_init_devs(ide_hwif_t *hwif) | |||
322 | hwif->drives[1].drive_data = t; | 323 | hwif->drives[1].drive_data = t; |
323 | } | 324 | } |
324 | 325 | ||
325 | int probe_ht6560b = 0; | 326 | static int probe_ht6560b; |
326 | 327 | ||
327 | module_param_named(probe, probe_ht6560b, bool, 0); | 328 | module_param_named(probe, probe_ht6560b, bool, 0); |
328 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); | 329 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); |
329 | 330 | ||
331 | static const struct ide_port_ops ht6560b_port_ops = { | ||
332 | .port_init_devs = ht6560b_port_init_devs, | ||
333 | .set_pio_mode = ht6560b_set_pio_mode, | ||
334 | .selectproc = ht6560b_selectproc, | ||
335 | }; | ||
336 | |||
330 | static const struct ide_port_info ht6560b_port_info __initdata = { | 337 | static const struct ide_port_info ht6560b_port_info __initdata = { |
338 | .name = DRV_NAME, | ||
331 | .chipset = ide_ht6560b, | 339 | .chipset = ide_ht6560b, |
340 | .port_ops = &ht6560b_port_ops, | ||
332 | .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ | 341 | .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ |
333 | IDE_HFLAG_NO_DMA | | 342 | IDE_HFLAG_NO_DMA | |
334 | IDE_HFLAG_NO_AUTOTUNE | | ||
335 | IDE_HFLAG_ABUSE_PREFETCH, | 343 | IDE_HFLAG_ABUSE_PREFETCH, |
336 | .pio_mask = ATA_PIO4, | 344 | .pio_mask = ATA_PIO4, |
337 | }; | 345 | }; |
338 | 346 | ||
339 | static int __init ht6560b_init(void) | 347 | static int __init ht6560b_init(void) |
340 | { | 348 | { |
341 | ide_hwif_t *hwif, *mate; | ||
342 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
343 | hw_regs_t hw[2]; | ||
344 | |||
345 | if (probe_ht6560b == 0) | 349 | if (probe_ht6560b == 0) |
346 | return -ENODEV; | 350 | return -ENODEV; |
347 | 351 | ||
348 | hwif = &ide_hwifs[0]; | 352 | if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { |
349 | mate = &ide_hwifs[1]; | ||
350 | |||
351 | if (!request_region(HT_CONFIG_PORT, 1, hwif->name)) { | ||
352 | printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", | 353 | printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", |
353 | __FUNCTION__); | 354 | __func__); |
354 | return -ENODEV; | 355 | return -ENODEV; |
355 | } | 356 | } |
356 | 357 | ||
357 | if (!try_to_init_ht6560b()) { | 358 | if (!try_to_init_ht6560b()) { |
358 | printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); | 359 | printk(KERN_NOTICE "%s: HBA not found\n", __func__); |
359 | goto release_region; | 360 | goto release_region; |
360 | } | 361 | } |
361 | 362 | ||
362 | memset(&hw, 0, sizeof(hw)); | 363 | return ide_legacy_device_add(&ht6560b_port_info, 0); |
363 | |||
364 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
365 | hw[0].irq = 14; | ||
366 | |||
367 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
368 | hw[1].irq = 15; | ||
369 | |||
370 | ide_init_port_hw(hwif, &hw[0]); | ||
371 | ide_init_port_hw(mate, &hw[1]); | ||
372 | |||
373 | hwif->selectproc = &ht6560b_selectproc; | ||
374 | hwif->set_pio_mode = &ht6560b_set_pio_mode; | ||
375 | |||
376 | mate->selectproc = &ht6560b_selectproc; | ||
377 | mate->set_pio_mode = &ht6560b_set_pio_mode; | ||
378 | |||
379 | hwif->port_init_devs = ht6560b_port_init_devs; | ||
380 | mate->port_init_devs = ht6560b_port_init_devs; | ||
381 | |||
382 | ide_device_add(idx, &ht6560b_port_info); | ||
383 | |||
384 | return 0; | ||
385 | 364 | ||
386 | release_region: | 365 | release_region: |
387 | release_region(HT_CONFIG_PORT, 1); | 366 | release_region(HT_CONFIG_PORT, 1); |
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c index ecd7f3553554..ecae916a3385 100644 --- a/drivers/ide/legacy/ide-4drives.c +++ b/drivers/ide/legacy/ide-4drives.c | |||
@@ -4,7 +4,9 @@ | |||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/ide.h> | 5 | #include <linux/ide.h> |
6 | 6 | ||
7 | int probe_4drives = 0; | 7 | #define DRV_NAME "ide-4drives" |
8 | |||
9 | static int probe_4drives; | ||
8 | 10 | ||
9 | module_param_named(probe, probe_4drives, bool, 0); | 11 | module_param_named(probe, probe_4drives, bool, 0); |
10 | MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); | 12 | MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); |
@@ -12,31 +14,51 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); | |||
12 | static int __init ide_4drives_init(void) | 14 | static int __init ide_4drives_init(void) |
13 | { | 15 | { |
14 | ide_hwif_t *hwif, *mate; | 16 | ide_hwif_t *hwif, *mate; |
15 | u8 idx[4] = { 0, 1, 0xff, 0xff }; | 17 | unsigned long base = 0x1f0, ctl = 0x3f6; |
18 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
16 | hw_regs_t hw; | 19 | hw_regs_t hw; |
17 | 20 | ||
18 | if (probe_4drives == 0) | 21 | if (probe_4drives == 0) |
19 | return -ENODEV; | 22 | return -ENODEV; |
20 | 23 | ||
21 | hwif = &ide_hwifs[0]; | 24 | if (!request_region(base, 8, DRV_NAME)) { |
22 | mate = &ide_hwifs[1]; | 25 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", |
26 | DRV_NAME, base, base + 7); | ||
27 | return -EBUSY; | ||
28 | } | ||
29 | |||
30 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
31 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
32 | DRV_NAME, ctl); | ||
33 | release_region(base, 8); | ||
34 | return -EBUSY; | ||
35 | } | ||
23 | 36 | ||
24 | memset(&hw, 0, sizeof(hw)); | 37 | memset(&hw, 0, sizeof(hw)); |
25 | 38 | ||
26 | ide_std_init_ports(&hw, 0x1f0, 0x3f6); | 39 | ide_std_init_ports(&hw, base, ctl); |
27 | hw.irq = 14; | 40 | hw.irq = 14; |
28 | hw.chipset = ide_4drives; | 41 | hw.chipset = ide_4drives; |
29 | 42 | ||
30 | ide_init_port_hw(hwif, &hw); | 43 | hwif = ide_find_port(); |
31 | ide_init_port_hw(mate, &hw); | 44 | if (hwif) { |
32 | 45 | ide_init_port_hw(hwif, &hw); | |
33 | mate->drives[0].select.all ^= 0x20; | 46 | idx[0] = hwif->index; |
34 | mate->drives[1].select.all ^= 0x20; | 47 | } |
35 | 48 | ||
36 | hwif->mate = mate; | 49 | mate = ide_find_port(); |
37 | mate->mate = hwif; | 50 | if (mate) { |
38 | 51 | ide_init_port_hw(mate, &hw); | |
39 | hwif->serialized = mate->serialized = 1; | 52 | mate->drives[0].select.all ^= 0x20; |
53 | mate->drives[1].select.all ^= 0x20; | ||
54 | idx[1] = mate->index; | ||
55 | |||
56 | if (hwif) { | ||
57 | hwif->mate = mate; | ||
58 | mate->mate = hwif; | ||
59 | hwif->serialized = mate->serialized = 1; | ||
60 | } | ||
61 | } | ||
40 | 62 | ||
41 | ide_device_add(idx, NULL); | 63 | ide_device_add(idx, NULL); |
42 | 64 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 9a23b94f2939..aa2ea3deac85 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -51,6 +51,8 @@ | |||
51 | #include <pcmcia/cisreg.h> | 51 | #include <pcmcia/cisreg.h> |
52 | #include <pcmcia/ciscode.h> | 52 | #include <pcmcia/ciscode.h> |
53 | 53 | ||
54 | #define DRV_NAME "ide-cs" | ||
55 | |||
54 | /*====================================================================*/ | 56 | /*====================================================================*/ |
55 | 57 | ||
56 | /* Module parameters */ | 58 | /* Module parameters */ |
@@ -72,16 +74,11 @@ static char *version = | |||
72 | 74 | ||
73 | /*====================================================================*/ | 75 | /*====================================================================*/ |
74 | 76 | ||
75 | static const char ide_major[] = { | ||
76 | IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, | ||
77 | IDE4_MAJOR, IDE5_MAJOR | ||
78 | }; | ||
79 | |||
80 | typedef struct ide_info_t { | 77 | typedef struct ide_info_t { |
81 | struct pcmcia_device *p_dev; | 78 | struct pcmcia_device *p_dev; |
79 | ide_hwif_t *hwif; | ||
82 | int ndev; | 80 | int ndev; |
83 | dev_node_t node; | 81 | dev_node_t node; |
84 | int hd; | ||
85 | } ide_info_t; | 82 | } ide_info_t; |
86 | 83 | ||
87 | static void ide_release(struct pcmcia_device *); | 84 | static void ide_release(struct pcmcia_device *); |
@@ -136,45 +133,71 @@ static int ide_probe(struct pcmcia_device *link) | |||
136 | 133 | ||
137 | static void ide_detach(struct pcmcia_device *link) | 134 | static void ide_detach(struct pcmcia_device *link) |
138 | { | 135 | { |
136 | ide_info_t *info = link->priv; | ||
137 | ide_hwif_t *hwif = info->hwif; | ||
138 | |||
139 | DEBUG(0, "ide_detach(0x%p)\n", link); | 139 | DEBUG(0, "ide_detach(0x%p)\n", link); |
140 | 140 | ||
141 | ide_release(link); | 141 | ide_release(link); |
142 | 142 | ||
143 | kfree(link->priv); | 143 | release_region(hwif->io_ports.ctl_addr, 1); |
144 | release_region(hwif->io_ports.data_addr, 8); | ||
145 | |||
146 | kfree(info); | ||
144 | } /* ide_detach */ | 147 | } /* ide_detach */ |
145 | 148 | ||
146 | static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) | 149 | static const struct ide_port_ops idecs_port_ops = { |
150 | .quirkproc = ide_undecoded_slave, | ||
151 | }; | ||
152 | |||
153 | static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, | ||
154 | unsigned long irq, struct pcmcia_device *handle) | ||
147 | { | 155 | { |
148 | ide_hwif_t *hwif; | 156 | ide_hwif_t *hwif; |
149 | hw_regs_t hw; | 157 | hw_regs_t hw; |
150 | int i; | 158 | int i; |
151 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 159 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
152 | 160 | ||
161 | if (!request_region(io, 8, DRV_NAME)) { | ||
162 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
163 | DRV_NAME, io, io + 7); | ||
164 | return NULL; | ||
165 | } | ||
166 | |||
167 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
168 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
169 | DRV_NAME, ctl); | ||
170 | release_region(io, 8); | ||
171 | return NULL; | ||
172 | } | ||
173 | |||
153 | memset(&hw, 0, sizeof(hw)); | 174 | memset(&hw, 0, sizeof(hw)); |
154 | ide_std_init_ports(&hw, io, ctl); | 175 | ide_std_init_ports(&hw, io, ctl); |
155 | hw.irq = irq; | 176 | hw.irq = irq; |
156 | hw.chipset = ide_pci; | 177 | hw.chipset = ide_pci; |
157 | hw.dev = &handle->dev; | 178 | hw.dev = &handle->dev; |
158 | 179 | ||
159 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 180 | hwif = ide_find_port(); |
160 | if (hwif == NULL) | 181 | if (hwif == NULL) |
161 | return -1; | 182 | goto out_release; |
162 | 183 | ||
163 | i = hwif->index; | 184 | i = hwif->index; |
164 | 185 | ||
165 | if (hwif->present) | 186 | ide_init_port_data(hwif, i); |
166 | ide_unregister(i); | ||
167 | else | ||
168 | ide_init_port_data(hwif, i); | ||
169 | |||
170 | ide_init_port_hw(hwif, &hw); | 187 | ide_init_port_hw(hwif, &hw); |
171 | hwif->quirkproc = &ide_undecoded_slave; | 188 | hwif->port_ops = &idecs_port_ops; |
172 | 189 | ||
173 | idx[0] = i; | 190 | idx[0] = i; |
174 | 191 | ||
175 | ide_device_add(idx, NULL); | 192 | ide_device_add(idx, NULL); |
176 | 193 | ||
177 | return hwif->present ? i : -1; | 194 | if (hwif->present) |
195 | return hwif; | ||
196 | |||
197 | out_release: | ||
198 | release_region(ctl, 1); | ||
199 | release_region(io, 8); | ||
200 | return NULL; | ||
178 | } | 201 | } |
179 | 202 | ||
180 | /*====================================================================== | 203 | /*====================================================================== |
@@ -199,8 +222,9 @@ static int ide_config(struct pcmcia_device *link) | |||
199 | cistpl_cftable_entry_t dflt; | 222 | cistpl_cftable_entry_t dflt; |
200 | } *stk = NULL; | 223 | } *stk = NULL; |
201 | cistpl_cftable_entry_t *cfg; | 224 | cistpl_cftable_entry_t *cfg; |
202 | int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0; | 225 | int i, pass, last_ret = 0, last_fn = 0, is_kme = 0; |
203 | unsigned long io_base, ctl_base; | 226 | unsigned long io_base, ctl_base; |
227 | ide_hwif_t *hwif; | ||
204 | 228 | ||
205 | DEBUG(0, "ide_config(0x%p)\n", link); | 229 | DEBUG(0, "ide_config(0x%p)\n", link); |
206 | 230 | ||
@@ -296,14 +320,15 @@ static int ide_config(struct pcmcia_device *link) | |||
296 | outb(0x81, ctl_base+1); | 320 | outb(0x81, ctl_base+1); |
297 | 321 | ||
298 | /* retry registration in case device is still spinning up */ | 322 | /* retry registration in case device is still spinning up */ |
299 | for (hd = -1, i = 0; i < 10; i++) { | 323 | for (i = 0; i < 10; i++) { |
300 | hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); | 324 | hwif = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); |
301 | if (hd >= 0) break; | 325 | if (hwif) |
326 | break; | ||
302 | if (link->io.NumPorts1 == 0x20) { | 327 | if (link->io.NumPorts1 == 0x20) { |
303 | outb(0x02, ctl_base + 0x10); | 328 | outb(0x02, ctl_base + 0x10); |
304 | hd = idecs_register(io_base + 0x10, ctl_base + 0x10, | 329 | hwif = idecs_register(io_base + 0x10, ctl_base + 0x10, |
305 | link->irq.AssignedIRQ, link); | 330 | link->irq.AssignedIRQ, link); |
306 | if (hd >= 0) { | 331 | if (hwif) { |
307 | io_base += 0x10; | 332 | io_base += 0x10; |
308 | ctl_base += 0x10; | 333 | ctl_base += 0x10; |
309 | break; | 334 | break; |
@@ -312,7 +337,7 @@ static int ide_config(struct pcmcia_device *link) | |||
312 | msleep(100); | 337 | msleep(100); |
313 | } | 338 | } |
314 | 339 | ||
315 | if (hd < 0) { | 340 | if (hwif == NULL) { |
316 | printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx" | 341 | printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx" |
317 | ", irq %u failed\n", io_base, ctl_base, | 342 | ", irq %u failed\n", io_base, ctl_base, |
318 | link->irq.AssignedIRQ); | 343 | link->irq.AssignedIRQ); |
@@ -320,10 +345,10 @@ static int ide_config(struct pcmcia_device *link) | |||
320 | } | 345 | } |
321 | 346 | ||
322 | info->ndev = 1; | 347 | info->ndev = 1; |
323 | sprintf(info->node.dev_name, "hd%c", 'a' + (hd * 2)); | 348 | sprintf(info->node.dev_name, "hd%c", 'a' + hwif->index * 2); |
324 | info->node.major = ide_major[hd]; | 349 | info->node.major = hwif->major; |
325 | info->node.minor = 0; | 350 | info->node.minor = 0; |
326 | info->hd = hd; | 351 | info->hwif = hwif; |
327 | link->dev_node = &info->node; | 352 | link->dev_node = &info->node; |
328 | printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", | 353 | printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", |
329 | info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); | 354 | info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); |
@@ -354,13 +379,14 @@ failed: | |||
354 | void ide_release(struct pcmcia_device *link) | 379 | void ide_release(struct pcmcia_device *link) |
355 | { | 380 | { |
356 | ide_info_t *info = link->priv; | 381 | ide_info_t *info = link->priv; |
382 | ide_hwif_t *hwif = info->hwif; | ||
357 | 383 | ||
358 | DEBUG(0, "ide_release(0x%p)\n", link); | 384 | DEBUG(0, "ide_release(0x%p)\n", link); |
359 | 385 | ||
360 | if (info->ndev) { | 386 | if (info->ndev) { |
361 | /* FIXME: if this fails we need to queue the cleanup somehow | 387 | /* FIXME: if this fails we need to queue the cleanup somehow |
362 | -- need to investigate the required PCMCIA magic */ | 388 | -- need to investigate the required PCMCIA magic */ |
363 | ide_unregister(info->hd); | 389 | ide_unregister(hwif); |
364 | } | 390 | } |
365 | info->ndev = 0; | 391 | info->ndev = 0; |
366 | 392 | ||
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index 361b1bb544bf..8279dc7ca4c0 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -30,14 +30,14 @@ static void __devinit plat_ide_setup_ports(hw_regs_t *hw, | |||
30 | unsigned long port = (unsigned long)base; | 30 | unsigned long port = (unsigned long)base; |
31 | int i; | 31 | int i; |
32 | 32 | ||
33 | hw->io_ports[IDE_DATA_OFFSET] = port; | 33 | hw->io_ports.data_addr = port; |
34 | 34 | ||
35 | port += (1 << pdata->ioport_shift); | 35 | port += (1 << pdata->ioport_shift); |
36 | for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; | 36 | for (i = 1; i <= 7; |
37 | i++, port += (1 << pdata->ioport_shift)) | 37 | i++, port += (1 << pdata->ioport_shift)) |
38 | hw->io_ports[i] = port; | 38 | hw->io_ports_array[i] = port; |
39 | 39 | ||
40 | hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; | 40 | hw->io_ports.ctl_addr = (unsigned long)ctrl; |
41 | 41 | ||
42 | hw->irq = irq; | 42 | hw->irq = irq; |
43 | 43 | ||
@@ -89,7 +89,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
89 | res_alt->start, res_alt->end - res_alt->start + 1); | 89 | res_alt->start, res_alt->end - res_alt->start + 1); |
90 | } | 90 | } |
91 | 91 | ||
92 | hwif = ide_find_port((unsigned long)base); | 92 | hwif = ide_find_port(); |
93 | if (!hwif) { | 93 | if (!hwif) { |
94 | ret = -ENODEV; | 94 | ret = -ENODEV; |
95 | goto out; | 95 | goto out; |
@@ -101,10 +101,8 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
101 | 101 | ||
102 | ide_init_port_hw(hwif, &hw); | 102 | ide_init_port_hw(hwif, &hw); |
103 | 103 | ||
104 | if (mmio) { | 104 | if (mmio) |
105 | hwif->mmio = 1; | ||
106 | default_hwif_mmiops(hwif); | 105 | default_hwif_mmiops(hwif); |
107 | } | ||
108 | 106 | ||
109 | idx[0] = hwif->index; | 107 | idx[0] = hwif->index; |
110 | 108 | ||
@@ -122,7 +120,7 @@ static int __devexit plat_ide_remove(struct platform_device *pdev) | |||
122 | { | 120 | { |
123 | ide_hwif_t *hwif = pdev->dev.driver_data; | 121 | ide_hwif_t *hwif = pdev->dev.driver_data; |
124 | 122 | ||
125 | ide_unregister(hwif->index); | 123 | ide_unregister(hwif); |
126 | 124 | ||
127 | return 0; | 125 | return 0; |
128 | } | 126 | } |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index eaf5dbe58bc2..1f527bbf8d96 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
@@ -72,9 +72,9 @@ static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base, | |||
72 | memset(hw, 0, sizeof(*hw)); | 72 | memset(hw, 0, sizeof(*hw)); |
73 | 73 | ||
74 | for (i = 0; i < 8; i++) | 74 | for (i = 0; i < 8; i++) |
75 | hw->io_ports[i] = base + i * 4; | 75 | hw->io_ports_array[i] = base + i * 4; |
76 | 76 | ||
77 | hw->io_ports[IDE_CONTROL_OFFSET] = base + IDE_CONTROL; | 77 | hw->io_ports.ctl_addr = base + IDE_CONTROL; |
78 | 78 | ||
79 | hw->irq = irq; | 79 | hw->irq = irq; |
80 | hw->ack_intr = ack_intr; | 80 | hw->ack_intr = ack_intr; |
@@ -120,7 +120,7 @@ static int __init macide_init(void) | |||
120 | 120 | ||
121 | macide_setup_ports(&hw, base, irq, ack_intr); | 121 | macide_setup_ports(&hw, base, irq, ack_intr); |
122 | 122 | ||
123 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 123 | hwif = ide_find_port(); |
124 | if (hwif) { | 124 | if (hwif) { |
125 | u8 index = hwif->index; | 125 | u8 index = hwif->index; |
126 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | 126 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; |
@@ -128,8 +128,6 @@ static int __init macide_init(void) | |||
128 | ide_init_port_data(hwif, index); | 128 | ide_init_port_data(hwif, index); |
129 | ide_init_port_hw(hwif, &hw); | 129 | ide_init_port_hw(hwif, &hw); |
130 | 130 | ||
131 | hwif->mmio = 1; | ||
132 | |||
133 | ide_device_add(idx, NULL); | 131 | ide_device_add(idx, NULL); |
134 | } | 132 | } |
135 | 133 | ||
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index 2da28759686e..a3573d40b4b7 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
@@ -80,10 +80,10 @@ void q40_ide_setup_ports ( hw_regs_t *hw, | |||
80 | for (i = 0; i < IDE_NR_PORTS; i++) { | 80 | for (i = 0; i < IDE_NR_PORTS; i++) { |
81 | /* BIG FAT WARNING: | 81 | /* BIG FAT WARNING: |
82 | assumption: only DATA port is ever used in 16 bit mode */ | 82 | assumption: only DATA port is ever used in 16 bit mode */ |
83 | if ( i==0 ) | 83 | if (i == 0) |
84 | hw->io_ports[i] = Q40_ISA_IO_W(base + offsets[i]); | 84 | hw->io_ports_array[i] = Q40_ISA_IO_W(base + offsets[i]); |
85 | else | 85 | else |
86 | hw->io_ports[i] = Q40_ISA_IO_B(base + offsets[i]); | 86 | hw->io_ports_array[i] = Q40_ISA_IO_B(base + offsets[i]); |
87 | } | 87 | } |
88 | 88 | ||
89 | hw->irq = irq; | 89 | hw->irq = irq; |
@@ -137,11 +137,10 @@ static int __init q40ide_init(void) | |||
137 | // m68kide_iops, | 137 | // m68kide_iops, |
138 | q40ide_default_irq(pcide_bases[i])); | 138 | q40ide_default_irq(pcide_bases[i])); |
139 | 139 | ||
140 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 140 | hwif = ide_find_port(); |
141 | if (hwif) { | 141 | if (hwif) { |
142 | ide_init_port_data(hwif, hwif->index); | 142 | ide_init_port_data(hwif, hwif->index); |
143 | ide_init_port_hw(hwif, &hw); | 143 | ide_init_port_hw(hwif, &hw); |
144 | hwif->mmio = 1; | ||
145 | 144 | ||
146 | idx[i] = hwif->index; | 145 | idx[i] = hwif->index; |
147 | } | 146 | } |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 7016bdf4fcc1..6424af154325 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -11,11 +11,7 @@ | |||
11 | * | 11 | * |
12 | * QDI QD6500/QD6580 EIDE controller fast support | 12 | * QDI QD6500/QD6580 EIDE controller fast support |
13 | * | 13 | * |
14 | * Please set local bus speed using kernel parameter idebus | ||
15 | * for example, "idebus=33" stands for 33Mhz VLbus | ||
16 | * To activate controller support, use "ide0=qd65xx" | 14 | * To activate controller support, use "ide0=qd65xx" |
17 | * To enable tuning, use "hda=autotune hdb=autotune" | ||
18 | * To enable 2nd channel tuning (qd6580 only), use "hdc=autotune hdd=autotune" | ||
19 | */ | 15 | */ |
20 | 16 | ||
21 | /* | 17 | /* |
@@ -37,6 +33,8 @@ | |||
37 | #include <asm/system.h> | 33 | #include <asm/system.h> |
38 | #include <asm/io.h> | 34 | #include <asm/io.h> |
39 | 35 | ||
36 | #define DRV_NAME "qd65xx" | ||
37 | |||
40 | #include "qd65xx.h" | 38 | #include "qd65xx.h" |
41 | 39 | ||
42 | /* | 40 | /* |
@@ -88,12 +86,12 @@ | |||
88 | static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ | 86 | static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ |
89 | 87 | ||
90 | /* | 88 | /* |
91 | * qd_select: | 89 | * qd65xx_select: |
92 | * | 90 | * |
93 | * This routine is invoked from ide.c to prepare for access to a given drive. | 91 | * This routine is invoked to prepare for access to a given drive. |
94 | */ | 92 | */ |
95 | 93 | ||
96 | static void qd_select (ide_drive_t *drive) | 94 | static void qd65xx_select(ide_drive_t *drive) |
97 | { | 95 | { |
98 | u8 index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) | | 96 | u8 index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) | |
99 | (QD_TIMREG(drive) & 0x02); | 97 | (QD_TIMREG(drive) & 0x02); |
@@ -112,17 +110,18 @@ static void qd_select (ide_drive_t *drive) | |||
112 | 110 | ||
113 | static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) | 111 | static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) |
114 | { | 112 | { |
115 | u8 active_cycle,recovery_cycle; | 113 | int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); |
114 | u8 act_cyc, rec_cyc; | ||
116 | 115 | ||
117 | if (system_bus_clock()<=33) { | 116 | if (clk <= 33) { |
118 | active_cycle = 9 - IDE_IN(active_time * system_bus_clock() / 1000 + 1, 2, 9); | 117 | act_cyc = 9 - IDE_IN(active_time * clk / 1000 + 1, 2, 9); |
119 | recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 0, 15); | 118 | rec_cyc = 15 - IDE_IN(recovery_time * clk / 1000 + 1, 0, 15); |
120 | } else { | 119 | } else { |
121 | active_cycle = 8 - IDE_IN(active_time * system_bus_clock() / 1000 + 1, 1, 8); | 120 | act_cyc = 8 - IDE_IN(active_time * clk / 1000 + 1, 1, 8); |
122 | recovery_cycle = 18 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 3, 18); | 121 | rec_cyc = 18 - IDE_IN(recovery_time * clk / 1000 + 1, 3, 18); |
123 | } | 122 | } |
124 | 123 | ||
125 | return((recovery_cycle<<4) | 0x08 | active_cycle); | 124 | return (rec_cyc << 4) | 0x08 | act_cyc; |
126 | } | 125 | } |
127 | 126 | ||
128 | /* | 127 | /* |
@@ -133,10 +132,13 @@ static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery | |||
133 | 132 | ||
134 | static u8 qd6580_compute_timing (int active_time, int recovery_time) | 133 | static u8 qd6580_compute_timing (int active_time, int recovery_time) |
135 | { | 134 | { |
136 | u8 active_cycle = 17 - IDE_IN(active_time * system_bus_clock() / 1000 + 1, 2, 17); | 135 | int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); |
137 | u8 recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 2, 15); | 136 | u8 act_cyc, rec_cyc; |
137 | |||
138 | act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17); | ||
139 | rec_cyc = 15 - IDE_IN(recovery_time * clk / 1000 + 1, 2, 15); | ||
138 | 140 | ||
139 | return((recovery_cycle<<4) | active_cycle); | 141 | return (rec_cyc << 4) | act_cyc; |
140 | } | 142 | } |
141 | 143 | ||
142 | /* | 144 | /* |
@@ -168,36 +170,15 @@ static int qd_find_disk_type (ide_drive_t *drive, | |||
168 | } | 170 | } |
169 | 171 | ||
170 | /* | 172 | /* |
171 | * qd_timing_ok: | ||
172 | * | ||
173 | * check whether timings don't conflict | ||
174 | */ | ||
175 | |||
176 | static int qd_timing_ok (ide_drive_t drives[]) | ||
177 | { | ||
178 | return (IDE_IMPLY(drives[0].present && drives[1].present, | ||
179 | IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1), | ||
180 | QD_TIMING(drives) == QD_TIMING(drives+1)))); | ||
181 | /* if same timing register, must be same timing */ | ||
182 | } | ||
183 | |||
184 | /* | ||
185 | * qd_set_timing: | 173 | * qd_set_timing: |
186 | * | 174 | * |
187 | * records the timing, and enables selectproc as needed | 175 | * records the timing |
188 | */ | 176 | */ |
189 | 177 | ||
190 | static void qd_set_timing (ide_drive_t *drive, u8 timing) | 178 | static void qd_set_timing (ide_drive_t *drive, u8 timing) |
191 | { | 179 | { |
192 | ide_hwif_t *hwif = HWIF(drive); | ||
193 | |||
194 | drive->drive_data &= 0xff00; | 180 | drive->drive_data &= 0xff00; |
195 | drive->drive_data |= timing; | 181 | drive->drive_data |= timing; |
196 | if (qd_timing_ok(hwif->drives)) { | ||
197 | qd_select(drive); /* selects once */ | ||
198 | hwif->selectproc = NULL; | ||
199 | } else | ||
200 | hwif->selectproc = &qd_select; | ||
201 | 182 | ||
202 | printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); | 183 | printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); |
203 | } | 184 | } |
@@ -225,10 +206,11 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
225 | 206 | ||
226 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | 207 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) |
227 | { | 208 | { |
228 | int base = HWIF(drive)->select_data; | 209 | ide_hwif_t *hwif = drive->hwif; |
229 | unsigned int cycle_time; | 210 | unsigned int cycle_time; |
230 | int active_time = 175; | 211 | int active_time = 175; |
231 | int recovery_time = 415; /* worst case values from the dos driver */ | 212 | int recovery_time = 415; /* worst case values from the dos driver */ |
213 | u8 base = (hwif->config_data & 0xff00) >> 8; | ||
232 | 214 | ||
233 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time)) { | 215 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time)) { |
234 | cycle_time = ide_pio_cycle_time(drive, pio); | 216 | cycle_time = ide_pio_cycle_time(drive, pio); |
@@ -299,21 +281,10 @@ static int __init qd_testreg(int port) | |||
299 | return (readreg != QD_TESTVAL); | 281 | return (readreg != QD_TESTVAL); |
300 | } | 282 | } |
301 | 283 | ||
302 | /* | ||
303 | * qd_setup: | ||
304 | * | ||
305 | * called to setup an ata channel : adjusts attributes & links for tuning | ||
306 | */ | ||
307 | |||
308 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config) | ||
309 | { | ||
310 | hwif->select_data = base; | ||
311 | hwif->config_data = config; | ||
312 | } | ||
313 | |||
314 | static void __init qd6500_port_init_devs(ide_hwif_t *hwif) | 284 | static void __init qd6500_port_init_devs(ide_hwif_t *hwif) |
315 | { | 285 | { |
316 | u8 base = hwif->select_data, config = QD_CONFIG(hwif); | 286 | u8 base = (hwif->config_data & 0xff00) >> 8; |
287 | u8 config = QD_CONFIG(hwif); | ||
317 | 288 | ||
318 | hwif->drives[0].drive_data = QD6500_DEF_DATA; | 289 | hwif->drives[0].drive_data = QD6500_DEF_DATA; |
319 | hwif->drives[1].drive_data = QD6500_DEF_DATA; | 290 | hwif->drives[1].drive_data = QD6500_DEF_DATA; |
@@ -322,9 +293,10 @@ static void __init qd6500_port_init_devs(ide_hwif_t *hwif) | |||
322 | static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | 293 | static void __init qd6580_port_init_devs(ide_hwif_t *hwif) |
323 | { | 294 | { |
324 | u16 t1, t2; | 295 | u16 t1, t2; |
325 | u8 base = hwif->select_data, config = QD_CONFIG(hwif); | 296 | u8 base = (hwif->config_data & 0xff00) >> 8; |
297 | u8 config = QD_CONFIG(hwif); | ||
326 | 298 | ||
327 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { | 299 | if (hwif->host_flags & IDE_HFLAG_SINGLE) { |
328 | t1 = QD6580_DEF_DATA; | 300 | t1 = QD6580_DEF_DATA; |
329 | t2 = QD6580_DEF_DATA2; | 301 | t2 = QD6580_DEF_DATA2; |
330 | } else | 302 | } else |
@@ -334,11 +306,23 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | |||
334 | hwif->drives[1].drive_data = t2; | 306 | hwif->drives[1].drive_data = t2; |
335 | } | 307 | } |
336 | 308 | ||
309 | static const struct ide_port_ops qd6500_port_ops = { | ||
310 | .port_init_devs = qd6500_port_init_devs, | ||
311 | .set_pio_mode = qd6500_set_pio_mode, | ||
312 | .selectproc = qd65xx_select, | ||
313 | }; | ||
314 | |||
315 | static const struct ide_port_ops qd6580_port_ops = { | ||
316 | .port_init_devs = qd6580_port_init_devs, | ||
317 | .set_pio_mode = qd6580_set_pio_mode, | ||
318 | .selectproc = qd65xx_select, | ||
319 | }; | ||
320 | |||
337 | static const struct ide_port_info qd65xx_port_info __initdata = { | 321 | static const struct ide_port_info qd65xx_port_info __initdata = { |
322 | .name = DRV_NAME, | ||
338 | .chipset = ide_qd65xx, | 323 | .chipset = ide_qd65xx, |
339 | .host_flags = IDE_HFLAG_IO_32BIT | | 324 | .host_flags = IDE_HFLAG_IO_32BIT | |
340 | IDE_HFLAG_NO_DMA | | 325 | IDE_HFLAG_NO_DMA, |
341 | IDE_HFLAG_NO_AUTOTUNE, | ||
342 | .pio_mask = ATA_PIO4, | 326 | .pio_mask = ATA_PIO4, |
343 | }; | 327 | }; |
344 | 328 | ||
@@ -351,65 +335,41 @@ static const struct ide_port_info qd65xx_port_info __initdata = { | |||
351 | 335 | ||
352 | static int __init qd_probe(int base) | 336 | static int __init qd_probe(int base) |
353 | { | 337 | { |
354 | ide_hwif_t *hwif; | 338 | int rc; |
355 | u8 config, unit; | 339 | u8 config, unit, control; |
356 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 340 | struct ide_port_info d = qd65xx_port_info; |
357 | hw_regs_t hw[2]; | ||
358 | 341 | ||
359 | config = inb(QD_CONFIG_PORT); | 342 | config = inb(QD_CONFIG_PORT); |
360 | 343 | ||
361 | if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) | 344 | if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) |
362 | return 1; | 345 | return -ENODEV; |
363 | 346 | ||
364 | unit = ! (config & QD_CONFIG_IDE_BASEPORT); | 347 | unit = ! (config & QD_CONFIG_IDE_BASEPORT); |
365 | 348 | ||
366 | memset(&hw, 0, sizeof(hw)); | 349 | if (unit) |
350 | d.host_flags |= IDE_HFLAG_QD_2ND_PORT; | ||
367 | 351 | ||
368 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | 352 | switch (config & 0xf0) { |
369 | hw[0].irq = 14; | 353 | case QD_CONFIG_QD6500: |
354 | if (qd_testreg(base)) | ||
355 | return -ENODEV; /* bad register */ | ||
370 | 356 | ||
371 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
372 | hw[1].irq = 15; | ||
373 | |||
374 | if ((config & 0xf0) == QD_CONFIG_QD6500) { | ||
375 | |||
376 | if (qd_testreg(base)) return 1; /* bad register */ | ||
377 | |||
378 | /* qd6500 found */ | ||
379 | |||
380 | hwif = &ide_hwifs[unit]; | ||
381 | printk(KERN_NOTICE "%s: qd6500 at %#x\n", hwif->name, base); | ||
382 | printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", | ||
383 | config, QD_ID3); | ||
384 | |||
385 | if (config & QD_CONFIG_DISABLED) { | 357 | if (config & QD_CONFIG_DISABLED) { |
386 | printk(KERN_WARNING "qd6500 is disabled !\n"); | 358 | printk(KERN_WARNING "qd6500 is disabled !\n"); |
387 | return 1; | 359 | return -ENODEV; |
388 | } | 360 | } |
389 | 361 | ||
390 | ide_init_port_hw(hwif, &hw[unit]); | 362 | printk(KERN_NOTICE "qd6500 at %#x\n", base); |
391 | 363 | printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", | |
392 | qd_setup(hwif, base, config); | 364 | config, QD_ID3); |
393 | |||
394 | hwif->port_init_devs = qd6500_port_init_devs; | ||
395 | hwif->set_pio_mode = &qd6500_set_pio_mode; | ||
396 | |||
397 | idx[unit] = unit; | ||
398 | |||
399 | ide_device_add(idx, &qd65xx_port_info); | ||
400 | |||
401 | return 1; | ||
402 | } | ||
403 | |||
404 | if (((config & 0xf0) == QD_CONFIG_QD6580_A) || | ||
405 | ((config & 0xf0) == QD_CONFIG_QD6580_B)) { | ||
406 | |||
407 | u8 control; | ||
408 | |||
409 | if (qd_testreg(base) || qd_testreg(base+0x02)) return 1; | ||
410 | /* bad registers */ | ||
411 | 365 | ||
412 | /* qd6580 found */ | 366 | d.port_ops = &qd6500_port_ops; |
367 | d.host_flags |= IDE_HFLAG_SINGLE; | ||
368 | break; | ||
369 | case QD_CONFIG_QD6580_A: | ||
370 | case QD_CONFIG_QD6580_B: | ||
371 | if (qd_testreg(base) || qd_testreg(base + 0x02)) | ||
372 | return -ENODEV; /* bad registers */ | ||
413 | 373 | ||
414 | control = inb(QD_CONTROL_PORT); | 374 | control = inb(QD_CONTROL_PORT); |
415 | 375 | ||
@@ -419,74 +379,44 @@ static int __init qd_probe(int base) | |||
419 | 379 | ||
420 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); | 380 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
421 | 381 | ||
422 | if (control & QD_CONTR_SEC_DISABLED) { | 382 | d.port_ops = &qd6580_port_ops; |
423 | /* secondary disabled */ | 383 | if (control & QD_CONTR_SEC_DISABLED) |
424 | 384 | d.host_flags |= IDE_HFLAG_SINGLE; | |
425 | hwif = &ide_hwifs[unit]; | ||
426 | printk(KERN_INFO "%s: qd6580: single IDE board\n", | ||
427 | hwif->name); | ||
428 | |||
429 | ide_init_port_hw(hwif, &hw[unit]); | ||
430 | |||
431 | qd_setup(hwif, base, config | (control << 8)); | ||
432 | |||
433 | hwif->port_init_devs = qd6580_port_init_devs; | ||
434 | hwif->set_pio_mode = &qd6580_set_pio_mode; | ||
435 | |||
436 | idx[unit] = unit; | ||
437 | 385 | ||
438 | ide_device_add(idx, &qd65xx_port_info); | 386 | printk(KERN_INFO "qd6580: %s IDE board\n", |
439 | 387 | (control & QD_CONTR_SEC_DISABLED) ? "single" : "dual"); | |
440 | return 1; | 388 | break; |
441 | } else { | 389 | default: |
442 | ide_hwif_t *mate; | 390 | return -ENODEV; |
443 | 391 | } | |
444 | hwif = &ide_hwifs[0]; | ||
445 | mate = &ide_hwifs[1]; | ||
446 | /* secondary enabled */ | ||
447 | printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", | ||
448 | hwif->name, mate->name); | ||
449 | |||
450 | ide_init_port_hw(hwif, &hw[0]); | ||
451 | ide_init_port_hw(mate, &hw[1]); | ||
452 | |||
453 | qd_setup(hwif, base, config | (control << 8)); | ||
454 | |||
455 | hwif->port_init_devs = qd6580_port_init_devs; | ||
456 | hwif->set_pio_mode = &qd6580_set_pio_mode; | ||
457 | |||
458 | qd_setup(mate, base, config | (control << 8)); | ||
459 | |||
460 | mate->port_init_devs = qd6580_port_init_devs; | ||
461 | mate->set_pio_mode = &qd6580_set_pio_mode; | ||
462 | 392 | ||
463 | idx[0] = 0; | 393 | rc = ide_legacy_device_add(&d, (base << 8) | config); |
464 | idx[1] = 1; | ||
465 | 394 | ||
466 | ide_device_add(idx, &qd65xx_port_info); | 395 | if (d.host_flags & IDE_HFLAG_SINGLE) |
396 | return (rc == 0) ? 1 : rc; | ||
467 | 397 | ||
468 | return 0; /* no other qd65xx possible */ | 398 | return rc; |
469 | } | ||
470 | } | ||
471 | /* no qd65xx found */ | ||
472 | return 1; | ||
473 | } | 399 | } |
474 | 400 | ||
475 | int probe_qd65xx = 0; | 401 | static int probe_qd65xx; |
476 | 402 | ||
477 | module_param_named(probe, probe_qd65xx, bool, 0); | 403 | module_param_named(probe, probe_qd65xx, bool, 0); |
478 | MODULE_PARM_DESC(probe, "probe for QD65xx chipsets"); | 404 | MODULE_PARM_DESC(probe, "probe for QD65xx chipsets"); |
479 | 405 | ||
480 | static int __init qd65xx_init(void) | 406 | static int __init qd65xx_init(void) |
481 | { | 407 | { |
408 | int rc1, rc2 = -ENODEV; | ||
409 | |||
482 | if (probe_qd65xx == 0) | 410 | if (probe_qd65xx == 0) |
483 | return -ENODEV; | 411 | return -ENODEV; |
484 | 412 | ||
485 | if (qd_probe(0x30)) | 413 | rc1 = qd_probe(0x30); |
486 | qd_probe(0xb0); | 414 | if (rc1) |
487 | if (ide_hwifs[0].chipset != ide_qd65xx && | 415 | rc2 = qd_probe(0xb0); |
488 | ide_hwifs[1].chipset != ide_qd65xx) | 416 | |
417 | if (rc1 < 0 && rc2 < 0) | ||
489 | return -ENODEV; | 418 | return -ENODEV; |
419 | |||
490 | return 0; | 420 | return 0; |
491 | } | 421 | } |
492 | 422 | ||
diff --git a/drivers/ide/legacy/qd65xx.h b/drivers/ide/legacy/qd65xx.h index 28dd50a15d55..c83dea85e621 100644 --- a/drivers/ide/legacy/qd65xx.h +++ b/drivers/ide/legacy/qd65xx.h | |||
@@ -30,7 +30,6 @@ | |||
30 | #define QD_ID3 ((config & QD_CONFIG_ID3)!=0) | 30 | #define QD_ID3 ((config & QD_CONFIG_ID3)!=0) |
31 | 31 | ||
32 | #define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) | 32 | #define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) |
33 | #define QD_CONTROL(hwif) (((hwif)->config_data & 0xff00) >> 8) | ||
34 | 33 | ||
35 | #define QD_TIMING(drive) (byte)(((drive)->drive_data) & 0x00ff) | 34 | #define QD_TIMING(drive) (byte)(((drive)->drive_data) & 0x00ff) |
36 | #define QD_TIMREG(drive) (byte)((((drive)->drive_data) & 0xff00) >> 8) | 35 | #define QD_TIMREG(drive) (byte)((((drive)->drive_data) & 0xff00) >> 8) |
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index bc1944811b99..b54a14a57755 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * VLB Controller Support from | 22 | * VLB Controller Support from |
23 | * Wolfram Podien | 23 | * Wolfram Podien |
24 | * Rohoefe 3 | 24 | * Rohoefe 3 |
25 | * D28832 Achim | 25 | * D28832 Achim |
@@ -32,7 +32,7 @@ | |||
32 | * #define UMC_DRIVE0 11 | 32 | * #define UMC_DRIVE0 11 |
33 | * in the beginning of the driver, which sets the speed of drive 0 to 11 (there | 33 | * in the beginning of the driver, which sets the speed of drive 0 to 11 (there |
34 | * are some lines present). 0 - 11 are allowed speed values. These values are | 34 | * are some lines present). 0 - 11 are allowed speed values. These values are |
35 | * the results from the DOS speed test program supplied from UMC. 11 is the | 35 | * the results from the DOS speed test program supplied from UMC. 11 is the |
36 | * highest speed (about PIO mode 3) | 36 | * highest speed (about PIO mode 3) |
37 | */ | 37 | */ |
38 | #define REALLY_SLOW_IO /* some systems can safely undef this */ | 38 | #define REALLY_SLOW_IO /* some systems can safely undef this */ |
@@ -51,6 +51,8 @@ | |||
51 | 51 | ||
52 | #include <asm/io.h> | 52 | #include <asm/io.h> |
53 | 53 | ||
54 | #define DRV_NAME "umc8672" | ||
55 | |||
54 | /* | 56 | /* |
55 | * Default speeds. These can be changed with "auto-tune" and/or hdparm. | 57 | * Default speeds. These can be changed with "auto-tune" and/or hdparm. |
56 | */ | 58 | */ |
@@ -60,115 +62,103 @@ | |||
60 | #define UMC_DRIVE3 1 /* In case of crash reduce speed */ | 62 | #define UMC_DRIVE3 1 /* In case of crash reduce speed */ |
61 | 63 | ||
62 | static u8 current_speeds[4] = {UMC_DRIVE0, UMC_DRIVE1, UMC_DRIVE2, UMC_DRIVE3}; | 64 | static u8 current_speeds[4] = {UMC_DRIVE0, UMC_DRIVE1, UMC_DRIVE2, UMC_DRIVE3}; |
63 | static const u8 pio_to_umc [5] = {0,3,7,10,11}; /* rough guesses */ | 65 | static const u8 pio_to_umc [5] = {0, 3, 7, 10, 11}; /* rough guesses */ |
64 | 66 | ||
65 | /* 0 1 2 3 4 5 6 7 8 9 10 11 */ | 67 | /* 0 1 2 3 4 5 6 7 8 9 10 11 */ |
66 | static const u8 speedtab [3][12] = { | 68 | static const u8 speedtab [3][12] = { |
67 | {0xf, 0xb, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 }, | 69 | {0x0f, 0x0b, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1}, |
68 | {0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 }, | 70 | {0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1}, |
69 | {0xff,0xcb,0xc0,0x58,0x36,0x33,0x23,0x22,0x21,0x11,0x10,0x0}}; | 71 | {0xff, 0xcb, 0xc0, 0x58, 0x36, 0x33, 0x23, 0x22, 0x21, 0x11, 0x10, 0x0} |
72 | }; | ||
70 | 73 | ||
71 | static void out_umc (char port,char wert) | 74 | static void out_umc(char port, char wert) |
72 | { | 75 | { |
73 | outb_p(port,0x108); | 76 | outb_p(port, 0x108); |
74 | outb_p(wert,0x109); | 77 | outb_p(wert, 0x109); |
75 | } | 78 | } |
76 | 79 | ||
77 | static inline u8 in_umc (char port) | 80 | static inline u8 in_umc(char port) |
78 | { | 81 | { |
79 | outb_p(port,0x108); | 82 | outb_p(port, 0x108); |
80 | return inb_p(0x109); | 83 | return inb_p(0x109); |
81 | } | 84 | } |
82 | 85 | ||
83 | static void umc_set_speeds (u8 speeds[]) | 86 | static void umc_set_speeds(u8 speeds[]) |
84 | { | 87 | { |
85 | int i, tmp; | 88 | int i, tmp; |
86 | 89 | ||
87 | outb_p(0x5A,0x108); /* enable umc */ | 90 | outb_p(0x5A, 0x108); /* enable umc */ |
88 | 91 | ||
89 | out_umc (0xd7,(speedtab[0][speeds[2]] | (speedtab[0][speeds[3]]<<4))); | 92 | out_umc(0xd7, (speedtab[0][speeds[2]] | (speedtab[0][speeds[3]]<<4))); |
90 | out_umc (0xd6,(speedtab[0][speeds[0]] | (speedtab[0][speeds[1]]<<4))); | 93 | out_umc(0xd6, (speedtab[0][speeds[0]] | (speedtab[0][speeds[1]]<<4))); |
91 | tmp = 0; | 94 | tmp = 0; |
92 | for (i = 3; i >= 0; i--) { | 95 | for (i = 3; i >= 0; i--) |
93 | tmp = (tmp << 2) | speedtab[1][speeds[i]]; | 96 | tmp = (tmp << 2) | speedtab[1][speeds[i]]; |
97 | out_umc(0xdc, tmp); | ||
98 | for (i = 0; i < 4; i++) { | ||
99 | out_umc(0xd0 + i, speedtab[2][speeds[i]]); | ||
100 | out_umc(0xd8 + i, speedtab[2][speeds[i]]); | ||
94 | } | 101 | } |
95 | out_umc (0xdc,tmp); | 102 | outb_p(0xa5, 0x108); /* disable umc */ |
96 | for (i = 0;i < 4; i++) { | ||
97 | out_umc (0xd0+i,speedtab[2][speeds[i]]); | ||
98 | out_umc (0xd8+i,speedtab[2][speeds[i]]); | ||
99 | } | ||
100 | outb_p(0xa5,0x108); /* disable umc */ | ||
101 | 103 | ||
102 | printk ("umc8672: drive speeds [0 to 11]: %d %d %d %d\n", | 104 | printk("umc8672: drive speeds [0 to 11]: %d %d %d %d\n", |
103 | speeds[0], speeds[1], speeds[2], speeds[3]); | 105 | speeds[0], speeds[1], speeds[2], speeds[3]); |
104 | } | 106 | } |
105 | 107 | ||
106 | static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) | 108 | static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) |
107 | { | 109 | { |
110 | ide_hwif_t *hwif = drive->hwif; | ||
108 | unsigned long flags; | 111 | unsigned long flags; |
109 | ide_hwgroup_t *hwgroup = ide_hwifs[HWIF(drive)->index^1].hwgroup; | ||
110 | 112 | ||
111 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", | 113 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", |
112 | drive->name, pio, pio_to_umc[pio]); | 114 | drive->name, pio, pio_to_umc[pio]); |
113 | spin_lock_irqsave(&ide_lock, flags); | 115 | spin_lock_irqsave(&ide_lock, flags); |
114 | if (hwgroup && hwgroup->handler != NULL) { | 116 | if (hwif->mate && hwif->mate->hwgroup->handler) { |
115 | printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n"); | 117 | printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n"); |
116 | } else { | 118 | } else { |
117 | current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio]; | 119 | current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio]; |
118 | umc_set_speeds (current_speeds); | 120 | umc_set_speeds(current_speeds); |
119 | } | 121 | } |
120 | spin_unlock_irqrestore(&ide_lock, flags); | 122 | spin_unlock_irqrestore(&ide_lock, flags); |
121 | } | 123 | } |
122 | 124 | ||
125 | static const struct ide_port_ops umc8672_port_ops = { | ||
126 | .set_pio_mode = umc_set_pio_mode, | ||
127 | }; | ||
128 | |||
123 | static const struct ide_port_info umc8672_port_info __initdata = { | 129 | static const struct ide_port_info umc8672_port_info __initdata = { |
130 | .name = DRV_NAME, | ||
124 | .chipset = ide_umc8672, | 131 | .chipset = ide_umc8672, |
125 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, | 132 | .port_ops = &umc8672_port_ops, |
133 | .host_flags = IDE_HFLAG_NO_DMA, | ||
126 | .pio_mask = ATA_PIO4, | 134 | .pio_mask = ATA_PIO4, |
127 | }; | 135 | }; |
128 | 136 | ||
129 | static int __init umc8672_probe(void) | 137 | static int __init umc8672_probe(void) |
130 | { | 138 | { |
131 | unsigned long flags; | 139 | unsigned long flags; |
132 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
133 | hw_regs_t hw[2]; | ||
134 | 140 | ||
135 | if (!request_region(0x108, 2, "umc8672")) { | 141 | if (!request_region(0x108, 2, "umc8672")) { |
136 | printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); | 142 | printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); |
137 | return 1; | 143 | return 1; |
138 | } | 144 | } |
139 | local_irq_save(flags); | 145 | local_irq_save(flags); |
140 | outb_p(0x5A,0x108); /* enable umc */ | 146 | outb_p(0x5A, 0x108); /* enable umc */ |
141 | if (in_umc (0xd5) != 0xa0) { | 147 | if (in_umc (0xd5) != 0xa0) { |
142 | local_irq_restore(flags); | 148 | local_irq_restore(flags); |
143 | printk(KERN_ERR "umc8672: not found\n"); | 149 | printk(KERN_ERR "umc8672: not found\n"); |
144 | release_region(0x108, 2); | 150 | release_region(0x108, 2); |
145 | return 1; | 151 | return 1; |
146 | } | 152 | } |
147 | outb_p(0xa5,0x108); /* disable umc */ | 153 | outb_p(0xa5, 0x108); /* disable umc */ |
148 | 154 | ||
149 | umc_set_speeds (current_speeds); | 155 | umc_set_speeds(current_speeds); |
150 | local_irq_restore(flags); | 156 | local_irq_restore(flags); |
151 | 157 | ||
152 | memset(&hw, 0, sizeof(hw)); | 158 | return ide_legacy_device_add(&umc8672_port_info, 0); |
153 | |||
154 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
155 | hw[0].irq = 14; | ||
156 | |||
157 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
158 | hw[1].irq = 15; | ||
159 | |||
160 | ide_init_port_hw(&ide_hwifs[0], &hw[0]); | ||
161 | ide_init_port_hw(&ide_hwifs[1], &hw[1]); | ||
162 | |||
163 | ide_hwifs[0].set_pio_mode = &umc_set_pio_mode; | ||
164 | ide_hwifs[1].set_pio_mode = &umc_set_pio_mode; | ||
165 | |||
166 | ide_device_add(idx, &umc8672_port_info); | ||
167 | |||
168 | return 0; | ||
169 | } | 159 | } |
170 | 160 | ||
171 | int probe_umc8672 = 0; | 161 | static int probe_umc8672; |
172 | 162 | ||
173 | module_param_named(probe, probe_umc8672, bool, 0); | 163 | module_param_named(probe, probe_umc8672, bool, 0); |
174 | MODULE_PARM_DESC(probe, "probe for UMC8672 chipset"); | 164 | MODULE_PARM_DESC(probe, "probe for UMC8672 chipset"); |
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index 9b628248f2f4..296b9c674bae 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #define IDE_AU1XXX_BURSTMODE 1 | 47 | #define IDE_AU1XXX_BURSTMODE 1 |
48 | 48 | ||
49 | static _auide_hwif auide_hwif; | 49 | static _auide_hwif auide_hwif; |
50 | static int dbdma_init_done; | ||
51 | 50 | ||
52 | static int auide_ddma_init(_auide_hwif *auide); | 51 | static int auide_ddma_init(_auide_hwif *auide); |
53 | 52 | ||
@@ -61,7 +60,7 @@ void auide_insw(unsigned long port, void *addr, u32 count) | |||
61 | 60 | ||
62 | if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1, | 61 | if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1, |
63 | DDMA_FLAGS_NOIE)) { | 62 | DDMA_FLAGS_NOIE)) { |
64 | printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__); | 63 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
65 | return; | 64 | return; |
66 | } | 65 | } |
67 | ctp = *((chan_tab_t **)ahwif->rx_chan); | 66 | ctp = *((chan_tab_t **)ahwif->rx_chan); |
@@ -79,7 +78,7 @@ void auide_outsw(unsigned long port, void *addr, u32 count) | |||
79 | 78 | ||
80 | if(!put_source_flags(ahwif->tx_chan, (void*)addr, | 79 | if(!put_source_flags(ahwif->tx_chan, (void*)addr, |
81 | count << 1, DDMA_FLAGS_NOIE)) { | 80 | count << 1, DDMA_FLAGS_NOIE)) { |
82 | printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__); | 81 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
83 | return; | 82 | return; |
84 | } | 83 | } |
85 | ctp = *((chan_tab_t **)ahwif->tx_chan); | 84 | ctp = *((chan_tab_t **)ahwif->tx_chan); |
@@ -250,7 +249,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
250 | (void*) sg_virt(sg), | 249 | (void*) sg_virt(sg), |
251 | tc, flags)) { | 250 | tc, flags)) { |
252 | printk(KERN_ERR "%s failed %d\n", | 251 | printk(KERN_ERR "%s failed %d\n", |
253 | __FUNCTION__, __LINE__); | 252 | __func__, __LINE__); |
254 | } | 253 | } |
255 | } else | 254 | } else |
256 | { | 255 | { |
@@ -258,7 +257,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
258 | (void*) sg_virt(sg), | 257 | (void*) sg_virt(sg), |
259 | tc, flags)) { | 258 | tc, flags)) { |
260 | printk(KERN_ERR "%s failed %d\n", | 259 | printk(KERN_ERR "%s failed %d\n", |
261 | __FUNCTION__, __LINE__); | 260 | __func__, __LINE__); |
262 | } | 261 | } |
263 | } | 262 | } |
264 | 263 | ||
@@ -315,35 +314,6 @@ static int auide_dma_setup(ide_drive_t *drive) | |||
315 | return 0; | 314 | return 0; |
316 | } | 315 | } |
317 | 316 | ||
318 | static u8 auide_mdma_filter(ide_drive_t *drive) | ||
319 | { | ||
320 | /* | ||
321 | * FIXME: ->white_list and ->black_list are based on completely bogus | ||
322 | * ->ide_dma_check implementation which didn't set neither the host | ||
323 | * controller timings nor the device for the desired transfer mode. | ||
324 | * | ||
325 | * They should be either removed or 0x00 MWDMA mask should be | ||
326 | * returned for devices on the ->black_list. | ||
327 | */ | ||
328 | |||
329 | if (dbdma_init_done == 0) { | ||
330 | auide_hwif.white_list = ide_in_drive_list(drive->id, | ||
331 | dma_white_list); | ||
332 | auide_hwif.black_list = ide_in_drive_list(drive->id, | ||
333 | dma_black_list); | ||
334 | auide_hwif.drive = drive; | ||
335 | auide_ddma_init(&auide_hwif); | ||
336 | dbdma_init_done = 1; | ||
337 | } | ||
338 | |||
339 | /* Is the drive in our DMA black list? */ | ||
340 | if (auide_hwif.black_list) | ||
341 | printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n", | ||
342 | drive->name, drive->id->model); | ||
343 | |||
344 | return drive->hwif->mwdma_mask; | ||
345 | } | ||
346 | |||
347 | static int auide_dma_test_irq(ide_drive_t *drive) | 317 | static int auide_dma_test_irq(ide_drive_t *drive) |
348 | { | 318 | { |
349 | if (drive->waiting_for_dma == 0) | 319 | if (drive->waiting_for_dma == 0) |
@@ -396,41 +366,41 @@ static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 de | |||
396 | dev->dev_devwidth = devwidth; | 366 | dev->dev_devwidth = devwidth; |
397 | dev->dev_flags = flags; | 367 | dev->dev_flags = flags; |
398 | } | 368 | } |
399 | |||
400 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) | ||
401 | 369 | ||
370 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
402 | static void auide_dma_timeout(ide_drive_t *drive) | 371 | static void auide_dma_timeout(ide_drive_t *drive) |
403 | { | 372 | { |
404 | ide_hwif_t *hwif = HWIF(drive); | 373 | ide_hwif_t *hwif = HWIF(drive); |
405 | 374 | ||
406 | printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); | 375 | printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); |
407 | 376 | ||
408 | if (hwif->ide_dma_test_irq(drive)) | 377 | if (auide_dma_test_irq(drive)) |
409 | return; | 378 | return; |
410 | 379 | ||
411 | hwif->ide_dma_end(drive); | 380 | auide_dma_end(drive); |
412 | } | 381 | } |
413 | |||
414 | 382 | ||
415 | static int auide_ddma_init(_auide_hwif *auide) { | 383 | static const struct ide_dma_ops au1xxx_dma_ops = { |
416 | 384 | .dma_host_set = auide_dma_host_set, | |
385 | .dma_setup = auide_dma_setup, | ||
386 | .dma_exec_cmd = auide_dma_exec_cmd, | ||
387 | .dma_start = auide_dma_start, | ||
388 | .dma_end = auide_dma_end, | ||
389 | .dma_test_irq = auide_dma_test_irq, | ||
390 | .dma_lost_irq = auide_dma_lost_irq, | ||
391 | .dma_timeout = auide_dma_timeout, | ||
392 | }; | ||
393 | |||
394 | static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | ||
395 | { | ||
396 | _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; | ||
417 | dbdev_tab_t source_dev_tab, target_dev_tab; | 397 | dbdev_tab_t source_dev_tab, target_dev_tab; |
418 | u32 dev_id, tsize, devwidth, flags; | 398 | u32 dev_id, tsize, devwidth, flags; |
419 | ide_hwif_t *hwif = auide->hwif; | ||
420 | 399 | ||
421 | dev_id = AU1XXX_ATA_DDMA_REQ; | 400 | dev_id = AU1XXX_ATA_DDMA_REQ; |
422 | 401 | ||
423 | if (auide->white_list || auide->black_list) { | 402 | tsize = 8; /* 1 */ |
424 | tsize = 8; | 403 | devwidth = 32; /* 16 */ |
425 | devwidth = 32; | ||
426 | } | ||
427 | else { | ||
428 | tsize = 1; | ||
429 | devwidth = 16; | ||
430 | |||
431 | printk(KERN_ERR "au1xxx-ide: %s is not on ide driver whitelist.\n",auide_hwif.drive->id->model); | ||
432 | printk(KERN_ERR " please read 'Documentation/mips/AU1xxx_IDE.README'"); | ||
433 | } | ||
434 | 404 | ||
435 | #ifdef IDE_AU1XXX_BURSTMODE | 405 | #ifdef IDE_AU1XXX_BURSTMODE |
436 | flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE; | 406 | flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE; |
@@ -482,9 +452,9 @@ static int auide_ddma_init(_auide_hwif *auide) { | |||
482 | return 0; | 452 | return 0; |
483 | } | 453 | } |
484 | #else | 454 | #else |
485 | 455 | static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | |
486 | static int auide_ddma_init( _auide_hwif *auide ) | ||
487 | { | 456 | { |
457 | _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; | ||
488 | dbdev_tab_t source_dev_tab; | 458 | dbdev_tab_t source_dev_tab; |
489 | int flags; | 459 | int flags; |
490 | 460 | ||
@@ -532,20 +502,28 @@ static int auide_ddma_init( _auide_hwif *auide ) | |||
532 | static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) | 502 | static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) |
533 | { | 503 | { |
534 | int i; | 504 | int i; |
535 | unsigned long *ata_regs = hw->io_ports; | 505 | unsigned long *ata_regs = hw->io_ports_array; |
536 | 506 | ||
537 | /* FIXME? */ | 507 | /* FIXME? */ |
538 | for (i = 0; i < IDE_CONTROL_OFFSET; i++) { | 508 | for (i = 0; i < 8; i++) |
539 | *ata_regs++ = ahwif->regbase + (i << AU1XXX_ATA_REG_OFFSET); | 509 | *ata_regs++ = ahwif->regbase + (i << AU1XXX_ATA_REG_OFFSET); |
540 | } | ||
541 | 510 | ||
542 | /* set the Alternative Status register */ | 511 | /* set the Alternative Status register */ |
543 | *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); | 512 | *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); |
544 | } | 513 | } |
545 | 514 | ||
515 | static const struct ide_port_ops au1xxx_port_ops = { | ||
516 | .set_pio_mode = au1xxx_set_pio_mode, | ||
517 | .set_dma_mode = auide_set_dma_mode, | ||
518 | }; | ||
519 | |||
546 | static const struct ide_port_info au1xxx_port_info = { | 520 | static const struct ide_port_info au1xxx_port_info = { |
521 | .init_dma = auide_ddma_init, | ||
522 | .port_ops = &au1xxx_port_ops, | ||
523 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
524 | .dma_ops = &au1xxx_dma_ops, | ||
525 | #endif | ||
547 | .host_flags = IDE_HFLAG_POST_SET_MODE | | 526 | .host_flags = IDE_HFLAG_POST_SET_MODE | |
548 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
549 | IDE_HFLAG_NO_IO_32BIT | | 527 | IDE_HFLAG_NO_IO_32BIT | |
550 | IDE_HFLAG_UNMASK_IRQS, | 528 | IDE_HFLAG_UNMASK_IRQS, |
551 | .pio_mask = ATA_PIO4, | 529 | .pio_mask = ATA_PIO4, |
@@ -599,9 +577,11 @@ static int au_ide_probe(struct device *dev) | |||
599 | goto out; | 577 | goto out; |
600 | } | 578 | } |
601 | 579 | ||
602 | /* FIXME: This might possibly break PCMCIA IDE devices */ | 580 | hwif = ide_find_port(); |
603 | 581 | if (hwif == NULL) { | |
604 | hwif = &ide_hwifs[pdev->id]; | 582 | ret = -ENOENT; |
583 | goto out; | ||
584 | } | ||
605 | 585 | ||
606 | memset(&hw, 0, sizeof(hw)); | 586 | memset(&hw, 0, sizeof(hw)); |
607 | auide_setup_ports(&hw, ahwif); | 587 | auide_setup_ports(&hw, ahwif); |
@@ -613,8 +593,6 @@ static int au_ide_probe(struct device *dev) | |||
613 | 593 | ||
614 | hwif->dev = dev; | 594 | hwif->dev = dev; |
615 | 595 | ||
616 | hwif->mmio = 1; | ||
617 | |||
618 | /* If the user has selected DDMA assisted copies, | 596 | /* If the user has selected DDMA assisted copies, |
619 | then set up a few local I/O function entry points | 597 | then set up a few local I/O function entry points |
620 | */ | 598 | */ |
@@ -623,34 +601,12 @@ static int au_ide_probe(struct device *dev) | |||
623 | hwif->INSW = auide_insw; | 601 | hwif->INSW = auide_insw; |
624 | hwif->OUTSW = auide_outsw; | 602 | hwif->OUTSW = auide_outsw; |
625 | #endif | 603 | #endif |
626 | |||
627 | hwif->set_pio_mode = &au1xxx_set_pio_mode; | ||
628 | hwif->set_dma_mode = &auide_set_dma_mode; | ||
629 | |||
630 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
631 | hwif->dma_timeout = &auide_dma_timeout; | ||
632 | |||
633 | hwif->mdma_filter = &auide_mdma_filter; | ||
634 | |||
635 | hwif->dma_host_set = &auide_dma_host_set; | ||
636 | hwif->dma_exec_cmd = &auide_dma_exec_cmd; | ||
637 | hwif->dma_start = &auide_dma_start; | ||
638 | hwif->ide_dma_end = &auide_dma_end; | ||
639 | hwif->dma_setup = &auide_dma_setup; | ||
640 | hwif->ide_dma_test_irq = &auide_dma_test_irq; | ||
641 | hwif->dma_lost_irq = &auide_dma_lost_irq; | ||
642 | #endif | ||
643 | hwif->select_data = 0; /* no chipset-specific code */ | 604 | hwif->select_data = 0; /* no chipset-specific code */ |
644 | hwif->config_data = 0; /* no chipset-specific code */ | 605 | hwif->config_data = 0; /* no chipset-specific code */ |
645 | 606 | ||
646 | auide_hwif.hwif = hwif; | 607 | auide_hwif.hwif = hwif; |
647 | hwif->hwif_data = &auide_hwif; | 608 | hwif->hwif_data = &auide_hwif; |
648 | 609 | ||
649 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA | ||
650 | auide_ddma_init(&auide_hwif); | ||
651 | dbdma_init_done = 1; | ||
652 | #endif | ||
653 | |||
654 | idx[0] = hwif->index; | 610 | idx[0] = hwif->index; |
655 | 611 | ||
656 | ide_device_add(idx, &au1xxx_port_info); | 612 | ide_device_add(idx, &au1xxx_port_info); |
@@ -670,7 +626,7 @@ static int au_ide_remove(struct device *dev) | |||
670 | ide_hwif_t *hwif = dev_get_drvdata(dev); | 626 | ide_hwif_t *hwif = dev_get_drvdata(dev); |
671 | _auide_hwif *ahwif = &auide_hwif; | 627 | _auide_hwif *ahwif = &auide_hwif; |
672 | 628 | ||
673 | ide_unregister(hwif->index); | 629 | ide_unregister(hwif); |
674 | 630 | ||
675 | iounmap((void *)ahwif->regbase); | 631 | iounmap((void *)ahwif->regbase); |
676 | 632 | ||
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c index 956259fc09ba..68947626e4aa 100644 --- a/drivers/ide/mips/swarm.c +++ b/drivers/ide/mips/swarm.c | |||
@@ -76,17 +76,12 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
76 | if (!SIBYTE_HAVE_IDE) | 76 | if (!SIBYTE_HAVE_IDE) |
77 | return -ENODEV; | 77 | return -ENODEV; |
78 | 78 | ||
79 | /* Find an empty slot. */ | 79 | hwif = ide_find_port(); |
80 | for (i = 0; i < MAX_HWIFS; i++) | 80 | if (hwif == NULL) { |
81 | if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET]) | ||
82 | break; | ||
83 | if (i >= MAX_HWIFS) { | ||
84 | printk(KERN_ERR DRV_NAME ": no free slot for interface\n"); | 81 | printk(KERN_ERR DRV_NAME ": no free slot for interface\n"); |
85 | return -ENOMEM; | 82 | return -ENOMEM; |
86 | } | 83 | } |
87 | 84 | ||
88 | hwif = ide_hwifs + i; | ||
89 | |||
90 | base = ioremap(A_IO_EXT_BASE, 0x800); | 85 | base = ioremap(A_IO_EXT_BASE, 0x800); |
91 | offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS)); | 86 | offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS)); |
92 | size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS)); | 87 | size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS)); |
@@ -115,15 +110,13 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
115 | 110 | ||
116 | /* Setup MMIO ops. */ | 111 | /* Setup MMIO ops. */ |
117 | default_hwif_mmiops(hwif); | 112 | default_hwif_mmiops(hwif); |
118 | /* Prevent resource map manipulation. */ | 113 | |
119 | hwif->mmio = 1; | ||
120 | hwif->chipset = ide_generic; | 114 | hwif->chipset = ide_generic; |
121 | hwif->noprobe = 0; | ||
122 | 115 | ||
123 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) | 116 | for (i = 0; i <= 7; i++) |
124 | hwif->io_ports[i] = | 117 | hwif->io_ports_array[i] = |
125 | (unsigned long)(base + ((0x1f0 + i) << 5)); | 118 | (unsigned long)(base + ((0x1f0 + i) << 5)); |
126 | hwif->io_ports[IDE_CONTROL_OFFSET] = | 119 | hwif->io_ports.ctl_addr = |
127 | (unsigned long)(base + (0x3f6 << 5)); | 120 | (unsigned long)(base + (0x3f6 << 5)); |
128 | hwif->irq = K_INT_GB_IDE; | 121 | hwif->irq = K_INT_GB_IDE; |
129 | 122 | ||
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index cfb3265bc1a8..7f46c224b7c4 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -135,12 +135,12 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | |||
135 | 135 | ||
136 | static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | 136 | static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) |
137 | { | 137 | { |
138 | drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); | 138 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); |
139 | } | 139 | } |
140 | 140 | ||
141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) | 141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) |
142 | { | 142 | { |
143 | int bus_speed = system_bus_clock(); | 143 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); |
144 | 144 | ||
145 | if (bus_speed <= 33) | 145 | if (bus_speed <= 33) |
146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); | 146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); |
@@ -175,27 +175,23 @@ static u8 __devinit atp86x_cable_detect(ide_hwif_t *hwif) | |||
175 | return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 175 | return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
176 | } | 176 | } |
177 | 177 | ||
178 | static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | 178 | static const struct ide_port_ops atp850_port_ops = { |
179 | { | 179 | .set_pio_mode = aec_set_pio_mode, |
180 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 180 | .set_dma_mode = aec6210_set_mode, |
181 | 181 | }; | |
182 | hwif->set_pio_mode = &aec_set_pio_mode; | ||
183 | |||
184 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) | ||
185 | hwif->set_dma_mode = &aec6210_set_mode; | ||
186 | else { | ||
187 | hwif->set_dma_mode = &aec6260_set_mode; | ||
188 | 182 | ||
189 | hwif->cable_detect = atp86x_cable_detect; | 183 | static const struct ide_port_ops atp86x_port_ops = { |
190 | } | 184 | .set_pio_mode = aec_set_pio_mode, |
191 | } | 185 | .set_dma_mode = aec6260_set_mode, |
186 | .cable_detect = atp86x_cable_detect, | ||
187 | }; | ||
192 | 188 | ||
193 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | 189 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { |
194 | { /* 0 */ | 190 | { /* 0 */ |
195 | .name = "AEC6210", | 191 | .name = "AEC6210", |
196 | .init_chipset = init_chipset_aec62xx, | 192 | .init_chipset = init_chipset_aec62xx, |
197 | .init_hwif = init_hwif_aec62xx, | ||
198 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 193 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
194 | .port_ops = &atp850_port_ops, | ||
199 | .host_flags = IDE_HFLAG_SERIALIZE | | 195 | .host_flags = IDE_HFLAG_SERIALIZE | |
200 | IDE_HFLAG_NO_ATAPI_DMA | | 196 | IDE_HFLAG_NO_ATAPI_DMA | |
201 | IDE_HFLAG_NO_DSC | | 197 | IDE_HFLAG_NO_DSC | |
@@ -207,7 +203,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
207 | },{ /* 1 */ | 203 | },{ /* 1 */ |
208 | .name = "AEC6260", | 204 | .name = "AEC6260", |
209 | .init_chipset = init_chipset_aec62xx, | 205 | .init_chipset = init_chipset_aec62xx, |
210 | .init_hwif = init_hwif_aec62xx, | 206 | .port_ops = &atp86x_port_ops, |
211 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | | 207 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | |
212 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 208 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
213 | IDE_HFLAG_OFF_BOARD, | 209 | IDE_HFLAG_OFF_BOARD, |
@@ -217,17 +213,18 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
217 | },{ /* 2 */ | 213 | },{ /* 2 */ |
218 | .name = "AEC6260R", | 214 | .name = "AEC6260R", |
219 | .init_chipset = init_chipset_aec62xx, | 215 | .init_chipset = init_chipset_aec62xx, |
220 | .init_hwif = init_hwif_aec62xx, | ||
221 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 216 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
217 | .port_ops = &atp86x_port_ops, | ||
222 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 218 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
223 | IDE_HFLAG_ABUSE_SET_DMA_MODE, | 219 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
220 | IDE_HFLAG_NON_BOOTABLE, | ||
224 | .pio_mask = ATA_PIO4, | 221 | .pio_mask = ATA_PIO4, |
225 | .mwdma_mask = ATA_MWDMA2, | 222 | .mwdma_mask = ATA_MWDMA2, |
226 | .udma_mask = ATA_UDMA4, | 223 | .udma_mask = ATA_UDMA4, |
227 | },{ /* 3 */ | 224 | },{ /* 3 */ |
228 | .name = "AEC6280", | 225 | .name = "AEC6280", |
229 | .init_chipset = init_chipset_aec62xx, | 226 | .init_chipset = init_chipset_aec62xx, |
230 | .init_hwif = init_hwif_aec62xx, | 227 | .port_ops = &atp86x_port_ops, |
231 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 228 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
232 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 229 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
233 | IDE_HFLAG_OFF_BOARD, | 230 | IDE_HFLAG_OFF_BOARD, |
@@ -237,8 +234,8 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
237 | },{ /* 4 */ | 234 | },{ /* 4 */ |
238 | .name = "AEC6280R", | 235 | .name = "AEC6280R", |
239 | .init_chipset = init_chipset_aec62xx, | 236 | .init_chipset = init_chipset_aec62xx, |
240 | .init_hwif = init_hwif_aec62xx, | ||
241 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 237 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
238 | .port_ops = &atp86x_port_ops, | ||
242 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 239 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
243 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 240 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
244 | IDE_HFLAG_OFF_BOARD, | 241 | IDE_HFLAG_OFF_BOARD, |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index b3b6f514ce2d..b36a22b8c213 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -38,8 +38,6 @@ | |||
38 | 38 | ||
39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
40 | 40 | ||
41 | #define DISPLAY_ALI_TIMINGS | ||
42 | |||
43 | /* | 41 | /* |
44 | * ALi devices are not plug in. Otherwise these static values would | 42 | * ALi devices are not plug in. Otherwise these static values would |
45 | * need to go. They ought to go away anyway | 43 | * need to go. They ought to go away anyway |
@@ -49,236 +47,6 @@ static u8 m5229_revision; | |||
49 | static u8 chip_is_1543c_e; | 47 | static u8 chip_is_1543c_e; |
50 | static struct pci_dev *isa_dev; | 48 | static struct pci_dev *isa_dev; |
51 | 49 | ||
52 | #if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) | ||
53 | #include <linux/stat.h> | ||
54 | #include <linux/proc_fs.h> | ||
55 | |||
56 | static u8 ali_proc = 0; | ||
57 | |||
58 | static struct pci_dev *bmide_dev; | ||
59 | |||
60 | static char *fifo[4] = { | ||
61 | "FIFO Off", | ||
62 | "FIFO On ", | ||
63 | "DMA mode", | ||
64 | "PIO mode" }; | ||
65 | |||
66 | static char *udmaT[8] = { | ||
67 | "1.5T", | ||
68 | " 2T", | ||
69 | "2.5T", | ||
70 | " 3T", | ||
71 | "3.5T", | ||
72 | " 4T", | ||
73 | " 6T", | ||
74 | " 8T" | ||
75 | }; | ||
76 | |||
77 | static char *channel_status[8] = { | ||
78 | "OK ", | ||
79 | "busy ", | ||
80 | "DRQ ", | ||
81 | "DRQ busy ", | ||
82 | "error ", | ||
83 | "error busy ", | ||
84 | "error DRQ ", | ||
85 | "error DRQ busy" | ||
86 | }; | ||
87 | |||
88 | /** | ||
89 | * ali_get_info - generate proc file for ALi IDE | ||
90 | * @buffer: buffer to fill | ||
91 | * @addr: address of user start in buffer | ||
92 | * @offset: offset into 'file' | ||
93 | * @count: buffer count | ||
94 | * | ||
95 | * Walks the Ali devices and outputs summary data on the tuning and | ||
96 | * anything else that will help with debugging | ||
97 | */ | ||
98 | |||
99 | static int ali_get_info (char *buffer, char **addr, off_t offset, int count) | ||
100 | { | ||
101 | unsigned long bibma; | ||
102 | u8 reg53h, reg5xh, reg5yh, reg5xh1, reg5yh1, c0, c1, rev, tmp; | ||
103 | char *q, *p = buffer; | ||
104 | |||
105 | /* fetch rev. */ | ||
106 | pci_read_config_byte(bmide_dev, 0x08, &rev); | ||
107 | if (rev >= 0xc1) /* M1543C or newer */ | ||
108 | udmaT[7] = " ???"; | ||
109 | else | ||
110 | fifo[3] = " ??? "; | ||
111 | |||
112 | /* first fetch bibma: */ | ||
113 | |||
114 | bibma = pci_resource_start(bmide_dev, 4); | ||
115 | |||
116 | /* | ||
117 | * at that point bibma+0x2 et bibma+0xa are byte | ||
118 | * registers to investigate: | ||
119 | */ | ||
120 | c0 = inb(bibma + 0x02); | ||
121 | c1 = inb(bibma + 0x0a); | ||
122 | |||
123 | p += sprintf(p, | ||
124 | "\n Ali M15x3 Chipset.\n"); | ||
125 | p += sprintf(p, | ||
126 | " ------------------\n"); | ||
127 | pci_read_config_byte(bmide_dev, 0x78, ®53h); | ||
128 | p += sprintf(p, "PCI Clock: %d.\n", reg53h); | ||
129 | |||
130 | pci_read_config_byte(bmide_dev, 0x53, ®53h); | ||
131 | p += sprintf(p, | ||
132 | "CD_ROM FIFO:%s, CD_ROM DMA:%s\n", | ||
133 | (reg53h & 0x02) ? "Yes" : "No ", | ||
134 | (reg53h & 0x01) ? "Yes" : "No " ); | ||
135 | pci_read_config_byte(bmide_dev, 0x74, ®53h); | ||
136 | p += sprintf(p, | ||
137 | "FIFO Status: contains %d Words, runs%s%s\n\n", | ||
138 | (reg53h & 0x3f), | ||
139 | (reg53h & 0x40) ? " OVERWR" : "", | ||
140 | (reg53h & 0x80) ? " OVERRD." : "." ); | ||
141 | |||
142 | p += sprintf(p, | ||
143 | "-------------------primary channel" | ||
144 | "-------------------secondary channel" | ||
145 | "---------\n\n"); | ||
146 | |||
147 | pci_read_config_byte(bmide_dev, 0x09, ®53h); | ||
148 | p += sprintf(p, | ||
149 | "channel status: %s" | ||
150 | " %s\n", | ||
151 | (reg53h & 0x20) ? "On " : "Off", | ||
152 | (reg53h & 0x10) ? "On " : "Off" ); | ||
153 | |||
154 | p += sprintf(p, | ||
155 | "both channels togth: %s" | ||
156 | " %s\n", | ||
157 | (c0&0x80) ? "No " : "Yes", | ||
158 | (c1&0x80) ? "No " : "Yes" ); | ||
159 | |||
160 | pci_read_config_byte(bmide_dev, 0x76, ®53h); | ||
161 | p += sprintf(p, | ||
162 | "Channel state: %s %s\n", | ||
163 | channel_status[reg53h & 0x07], | ||
164 | channel_status[(reg53h & 0x70) >> 4] ); | ||
165 | |||
166 | pci_read_config_byte(bmide_dev, 0x58, ®5xh); | ||
167 | pci_read_config_byte(bmide_dev, 0x5c, ®5yh); | ||
168 | p += sprintf(p, | ||
169 | "Add. Setup Timing: %dT" | ||
170 | " %dT\n", | ||
171 | (reg5xh & 0x07) ? (reg5xh & 0x07) : 8, | ||
172 | (reg5yh & 0x07) ? (reg5yh & 0x07) : 8 ); | ||
173 | |||
174 | pci_read_config_byte(bmide_dev, 0x59, ®5xh); | ||
175 | pci_read_config_byte(bmide_dev, 0x5d, ®5yh); | ||
176 | p += sprintf(p, | ||
177 | "Command Act. Count: %dT" | ||
178 | " %dT\n" | ||
179 | "Command Rec. Count: %dT" | ||
180 | " %dT\n\n", | ||
181 | (reg5xh & 0x70) ? ((reg5xh & 0x70) >> 4) : 8, | ||
182 | (reg5yh & 0x70) ? ((reg5yh & 0x70) >> 4) : 8, | ||
183 | (reg5xh & 0x0f) ? (reg5xh & 0x0f) : 16, | ||
184 | (reg5yh & 0x0f) ? (reg5yh & 0x0f) : 16 ); | ||
185 | |||
186 | p += sprintf(p, | ||
187 | "----------------drive0-----------drive1" | ||
188 | "------------drive0-----------drive1------\n\n"); | ||
189 | p += sprintf(p, | ||
190 | "DMA enabled: %s %s" | ||
191 | " %s %s\n", | ||
192 | (c0&0x20) ? "Yes" : "No ", | ||
193 | (c0&0x40) ? "Yes" : "No ", | ||
194 | (c1&0x20) ? "Yes" : "No ", | ||
195 | (c1&0x40) ? "Yes" : "No " ); | ||
196 | |||
197 | pci_read_config_byte(bmide_dev, 0x54, ®5xh); | ||
198 | pci_read_config_byte(bmide_dev, 0x55, ®5yh); | ||
199 | q = "FIFO threshold: %2d Words %2d Words" | ||
200 | " %2d Words %2d Words\n"; | ||
201 | if (rev < 0xc1) { | ||
202 | if ((rev == 0x20) && | ||
203 | (pci_read_config_byte(bmide_dev, 0x4f, &tmp), (tmp &= 0x20))) { | ||
204 | p += sprintf(p, q, 8, 8, 8, 8); | ||
205 | } else { | ||
206 | p += sprintf(p, q, | ||
207 | (reg5xh & 0x03) + 12, | ||
208 | ((reg5xh & 0x30)>>4) + 12, | ||
209 | (reg5yh & 0x03) + 12, | ||
210 | ((reg5yh & 0x30)>>4) + 12 ); | ||
211 | } | ||
212 | } else { | ||
213 | int t1 = (tmp = (reg5xh & 0x03)) ? (tmp << 3) : 4; | ||
214 | int t2 = (tmp = ((reg5xh & 0x30)>>4)) ? (tmp << 3) : 4; | ||
215 | int t3 = (tmp = (reg5yh & 0x03)) ? (tmp << 3) : 4; | ||
216 | int t4 = (tmp = ((reg5yh & 0x30)>>4)) ? (tmp << 3) : 4; | ||
217 | p += sprintf(p, q, t1, t2, t3, t4); | ||
218 | } | ||
219 | |||
220 | #if 0 | ||
221 | p += sprintf(p, | ||
222 | "FIFO threshold: %2d Words %2d Words" | ||
223 | " %2d Words %2d Words\n", | ||
224 | (reg5xh & 0x03) + 12, | ||
225 | ((reg5xh & 0x30)>>4) + 12, | ||
226 | (reg5yh & 0x03) + 12, | ||
227 | ((reg5yh & 0x30)>>4) + 12 ); | ||
228 | #endif | ||
229 | |||
230 | p += sprintf(p, | ||
231 | "FIFO mode: %s %s %s %s\n", | ||
232 | fifo[((reg5xh & 0x0c) >> 2)], | ||
233 | fifo[((reg5xh & 0xc0) >> 6)], | ||
234 | fifo[((reg5yh & 0x0c) >> 2)], | ||
235 | fifo[((reg5yh & 0xc0) >> 6)] ); | ||
236 | |||
237 | pci_read_config_byte(bmide_dev, 0x5a, ®5xh); | ||
238 | pci_read_config_byte(bmide_dev, 0x5b, ®5xh1); | ||
239 | pci_read_config_byte(bmide_dev, 0x5e, ®5yh); | ||
240 | pci_read_config_byte(bmide_dev, 0x5f, ®5yh1); | ||
241 | |||
242 | p += sprintf(p,/* | ||
243 | "------------------drive0-----------drive1" | ||
244 | "------------drive0-----------drive1------\n")*/ | ||
245 | "Dt RW act. Cnt %2dT %2dT" | ||
246 | " %2dT %2dT\n" | ||
247 | "Dt RW rec. Cnt %2dT %2dT" | ||
248 | " %2dT %2dT\n\n", | ||
249 | (reg5xh & 0x70) ? ((reg5xh & 0x70) >> 4) : 8, | ||
250 | (reg5xh1 & 0x70) ? ((reg5xh1 & 0x70) >> 4) : 8, | ||
251 | (reg5yh & 0x70) ? ((reg5yh & 0x70) >> 4) : 8, | ||
252 | (reg5yh1 & 0x70) ? ((reg5yh1 & 0x70) >> 4) : 8, | ||
253 | (reg5xh & 0x0f) ? (reg5xh & 0x0f) : 16, | ||
254 | (reg5xh1 & 0x0f) ? (reg5xh1 & 0x0f) : 16, | ||
255 | (reg5yh & 0x0f) ? (reg5yh & 0x0f) : 16, | ||
256 | (reg5yh1 & 0x0f) ? (reg5yh1 & 0x0f) : 16 ); | ||
257 | |||
258 | p += sprintf(p, | ||
259 | "-----------------------------------UDMA Timings" | ||
260 | "--------------------------------\n\n"); | ||
261 | |||
262 | pci_read_config_byte(bmide_dev, 0x56, ®5xh); | ||
263 | pci_read_config_byte(bmide_dev, 0x57, ®5yh); | ||
264 | p += sprintf(p, | ||
265 | "UDMA: %s %s" | ||
266 | " %s %s\n" | ||
267 | "UDMA timings: %s %s" | ||
268 | " %s %s\n\n", | ||
269 | (reg5xh & 0x08) ? "OK" : "No", | ||
270 | (reg5xh & 0x80) ? "OK" : "No", | ||
271 | (reg5yh & 0x08) ? "OK" : "No", | ||
272 | (reg5yh & 0x80) ? "OK" : "No", | ||
273 | udmaT[(reg5xh & 0x07)], | ||
274 | udmaT[(reg5xh & 0x70) >> 4], | ||
275 | udmaT[reg5yh & 0x07], | ||
276 | udmaT[(reg5yh & 0x70) >> 4] ); | ||
277 | |||
278 | return p-buffer; /* => must be less than 4k! */ | ||
279 | } | ||
280 | #endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */ | ||
281 | |||
282 | /** | 50 | /** |
283 | * ali_set_pio_mode - set host controller for PIO mode | 51 | * ali_set_pio_mode - set host controller for PIO mode |
284 | * @drive: drive | 52 | * @drive: drive |
@@ -294,7 +62,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
294 | int s_time, a_time, c_time; | 62 | int s_time, a_time, c_time; |
295 | u8 s_clc, a_clc, r_clc; | 63 | u8 s_clc, a_clc, r_clc; |
296 | unsigned long flags; | 64 | unsigned long flags; |
297 | int bus_speed = system_bus_clock(); | 65 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); |
298 | int port = hwif->channel ? 0x5c : 0x58; | 66 | int port = hwif->channel ? 0x5c : 0x58; |
299 | int portFIFO = hwif->channel ? 0x55 : 0x54; | 67 | int portFIFO = hwif->channel ? 0x55 : 0x54; |
300 | u8 cd_dma_fifo = 0; | 68 | u8 cd_dma_fifo = 0; |
@@ -465,14 +233,6 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c | |||
465 | 233 | ||
466 | isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | 234 | isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); |
467 | 235 | ||
468 | #if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) | ||
469 | if (!ali_proc) { | ||
470 | ali_proc = 1; | ||
471 | bmide_dev = dev; | ||
472 | ide_pci_create_host_proc("ali", ali_get_info); | ||
473 | } | ||
474 | #endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */ | ||
475 | |||
476 | local_irq_save(flags); | 236 | local_irq_save(flags); |
477 | 237 | ||
478 | if (m5229_revision < 0xC2) { | 238 | if (m5229_revision < 0xC2) { |
@@ -610,7 +370,7 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
610 | } | 370 | } |
611 | 371 | ||
612 | /** | 372 | /** |
613 | * ata66_ali15x3 - check for UDMA 66 support | 373 | * ali_cable_detect - cable detection |
614 | * @hwif: IDE interface | 374 | * @hwif: IDE interface |
615 | * | 375 | * |
616 | * This checks if the controller and the cable are capable | 376 | * This checks if the controller and the cable are capable |
@@ -620,7 +380,7 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
620 | * FIXME: frobs bits that are not defined on newer ALi devicea | 380 | * FIXME: frobs bits that are not defined on newer ALi devicea |
621 | */ | 381 | */ |
622 | 382 | ||
623 | static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) | 383 | static u8 __devinit ali_cable_detect(ide_hwif_t *hwif) |
624 | { | 384 | { |
625 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 385 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
626 | unsigned long flags; | 386 | unsigned long flags; |
@@ -652,27 +412,7 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) | |||
652 | return cbl; | 412 | return cbl; |
653 | } | 413 | } |
654 | 414 | ||
655 | /** | 415 | #ifndef CONFIG_SPARC64 |
656 | * init_hwif_common_ali15x3 - Set up ALI IDE hardware | ||
657 | * @hwif: IDE interface | ||
658 | * | ||
659 | * Initialize the IDE structure side of the ALi 15x3 driver. | ||
660 | */ | ||
661 | |||
662 | static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) | ||
663 | { | ||
664 | hwif->set_pio_mode = &ali_set_pio_mode; | ||
665 | hwif->set_dma_mode = &ali_set_dma_mode; | ||
666 | hwif->udma_filter = &ali_udma_filter; | ||
667 | |||
668 | hwif->cable_detect = ata66_ali15x3; | ||
669 | |||
670 | if (hwif->dma_base == 0) | ||
671 | return; | ||
672 | |||
673 | hwif->dma_setup = &ali15x3_dma_setup; | ||
674 | } | ||
675 | |||
676 | /** | 416 | /** |
677 | * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff | 417 | * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff |
678 | * @hwif: interface to configure | 418 | * @hwif: interface to configure |
@@ -722,35 +462,66 @@ static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) | |||
722 | if(irq >= 0) | 462 | if(irq >= 0) |
723 | hwif->irq = irq; | 463 | hwif->irq = irq; |
724 | } | 464 | } |
725 | |||
726 | init_hwif_common_ali15x3(hwif); | ||
727 | } | 465 | } |
466 | #endif | ||
728 | 467 | ||
729 | /** | 468 | /** |
730 | * init_dma_ali15x3 - set up DMA on ALi15x3 | 469 | * init_dma_ali15x3 - set up DMA on ALi15x3 |
731 | * @hwif: IDE interface | 470 | * @hwif: IDE interface |
732 | * @dmabase: DMA interface base PCI address | 471 | * @d: IDE port info |
733 | * | 472 | * |
734 | * Set up the DMA functionality on the ALi 15x3. For the ALi | 473 | * Set up the DMA functionality on the ALi 15x3. |
735 | * controllers this is generic so we can let the generic code do | ||
736 | * the actual work. | ||
737 | */ | 474 | */ |
738 | 475 | ||
739 | static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase) | 476 | static int __devinit init_dma_ali15x3(ide_hwif_t *hwif, |
477 | const struct ide_port_info *d) | ||
740 | { | 478 | { |
741 | if (m5229_revision < 0x20) | 479 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
742 | return; | 480 | unsigned long base = ide_pci_dma_base(hwif, d); |
481 | |||
482 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | ||
483 | return -1; | ||
484 | |||
743 | if (!hwif->channel) | 485 | if (!hwif->channel) |
744 | outb(inb(dmabase + 2) & 0x60, dmabase + 2); | 486 | outb(inb(base + 2) & 0x60, base + 2); |
745 | ide_setup_dma(hwif, dmabase); | 487 | |
488 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", | ||
489 | hwif->name, base, base + 7); | ||
490 | |||
491 | if (ide_allocate_dma_engine(hwif)) | ||
492 | return -1; | ||
493 | |||
494 | ide_setup_dma(hwif, base); | ||
495 | |||
496 | return 0; | ||
746 | } | 497 | } |
747 | 498 | ||
499 | static const struct ide_port_ops ali_port_ops = { | ||
500 | .set_pio_mode = ali_set_pio_mode, | ||
501 | .set_dma_mode = ali_set_dma_mode, | ||
502 | .udma_filter = ali_udma_filter, | ||
503 | .cable_detect = ali_cable_detect, | ||
504 | }; | ||
505 | |||
506 | static const struct ide_dma_ops ali_dma_ops = { | ||
507 | .dma_host_set = ide_dma_host_set, | ||
508 | .dma_setup = ali15x3_dma_setup, | ||
509 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
510 | .dma_start = ide_dma_start, | ||
511 | .dma_end = __ide_dma_end, | ||
512 | .dma_test_irq = ide_dma_test_irq, | ||
513 | .dma_lost_irq = ide_dma_lost_irq, | ||
514 | .dma_timeout = ide_dma_timeout, | ||
515 | }; | ||
516 | |||
748 | static const struct ide_port_info ali15x3_chipset __devinitdata = { | 517 | static const struct ide_port_info ali15x3_chipset __devinitdata = { |
749 | .name = "ALI15X3", | 518 | .name = "ALI15X3", |
750 | .init_chipset = init_chipset_ali15x3, | 519 | .init_chipset = init_chipset_ali15x3, |
520 | #ifndef CONFIG_SPARC64 | ||
751 | .init_hwif = init_hwif_ali15x3, | 521 | .init_hwif = init_hwif_ali15x3, |
522 | #endif | ||
752 | .init_dma = init_dma_ali15x3, | 523 | .init_dma = init_dma_ali15x3, |
753 | .host_flags = IDE_HFLAG_BOOTABLE, | 524 | .port_ops = &ali_port_ops, |
754 | .pio_mask = ATA_PIO5, | 525 | .pio_mask = ATA_PIO5, |
755 | .swdma_mask = ATA_SWDMA2, | 526 | .swdma_mask = ATA_SWDMA2, |
756 | .mwdma_mask = ATA_MWDMA2, | 527 | .mwdma_mask = ATA_MWDMA2, |
@@ -793,14 +564,17 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
793 | d.udma_mask = ATA_UDMA5; | 564 | d.udma_mask = ATA_UDMA5; |
794 | else | 565 | else |
795 | d.udma_mask = ATA_UDMA6; | 566 | d.udma_mask = ATA_UDMA6; |
567 | |||
568 | d.dma_ops = &ali_dma_ops; | ||
569 | } else { | ||
570 | d.host_flags |= IDE_HFLAG_NO_DMA; | ||
571 | |||
572 | d.mwdma_mask = d.swdma_mask = 0; | ||
796 | } | 573 | } |
797 | 574 | ||
798 | if (idx == 0) | 575 | if (idx == 0) |
799 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | 576 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; |
800 | 577 | ||
801 | #if defined(CONFIG_SPARC64) | ||
802 | d.init_hwif = init_hwif_common_ali15x3; | ||
803 | #endif /* CONFIG_SPARC64 */ | ||
804 | return ide_setup_pci_device(dev, &d); | 578 | return ide_setup_pci_device(dev, &d); |
805 | } | 579 | } |
806 | 580 | ||
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 2ef890ce8097..efcf54338be7 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -179,7 +179,7 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
179 | * Determine the system bus clock. | 179 | * Determine the system bus clock. |
180 | */ | 180 | */ |
181 | 181 | ||
182 | amd_clock = system_bus_clock() * 1000; | 182 | amd_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; |
183 | 183 | ||
184 | switch (amd_clock) { | 184 | switch (amd_clock) { |
185 | case 33000: amd_clock = 33333; break; | 185 | case 33000: amd_clock = 33333; break; |
@@ -210,21 +210,20 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
210 | 210 | ||
211 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ | 211 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ |
212 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); | 212 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); |
213 | |||
214 | hwif->set_pio_mode = &amd_set_pio_mode; | ||
215 | hwif->set_dma_mode = &amd_set_drive; | ||
216 | |||
217 | hwif->cable_detect = amd_cable_detect; | ||
218 | } | 213 | } |
219 | 214 | ||
215 | static const struct ide_port_ops amd_port_ops = { | ||
216 | .set_pio_mode = amd_set_pio_mode, | ||
217 | .set_dma_mode = amd_set_drive, | ||
218 | .cable_detect = amd_cable_detect, | ||
219 | }; | ||
220 | |||
220 | #define IDE_HFLAGS_AMD \ | 221 | #define IDE_HFLAGS_AMD \ |
221 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ | 222 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ |
222 | IDE_HFLAG_PIO_NO_DOWNGRADE | \ | ||
223 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 223 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
224 | IDE_HFLAG_POST_SET_MODE | \ | 224 | IDE_HFLAG_POST_SET_MODE | \ |
225 | IDE_HFLAG_IO_32BIT | \ | 225 | IDE_HFLAG_IO_32BIT | \ |
226 | IDE_HFLAG_UNMASK_IRQS | \ | 226 | IDE_HFLAG_UNMASK_IRQS) |
227 | IDE_HFLAG_BOOTABLE) | ||
228 | 227 | ||
229 | #define DECLARE_AMD_DEV(name_str, swdma, udma) \ | 228 | #define DECLARE_AMD_DEV(name_str, swdma, udma) \ |
230 | { \ | 229 | { \ |
@@ -232,6 +231,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
232 | .init_chipset = init_chipset_amd74xx, \ | 231 | .init_chipset = init_chipset_amd74xx, \ |
233 | .init_hwif = init_hwif_amd74xx, \ | 232 | .init_hwif = init_hwif_amd74xx, \ |
234 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 233 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
234 | .port_ops = &amd_port_ops, \ | ||
235 | .host_flags = IDE_HFLAGS_AMD, \ | 235 | .host_flags = IDE_HFLAGS_AMD, \ |
236 | .pio_mask = ATA_PIO5, \ | 236 | .pio_mask = ATA_PIO5, \ |
237 | .swdma_mask = swdma, \ | 237 | .swdma_mask = swdma, \ |
@@ -245,6 +245,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
245 | .init_chipset = init_chipset_amd74xx, \ | 245 | .init_chipset = init_chipset_amd74xx, \ |
246 | .init_hwif = init_hwif_amd74xx, \ | 246 | .init_hwif = init_hwif_amd74xx, \ |
247 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ | 247 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ |
248 | .port_ops = &amd_port_ops, \ | ||
248 | .host_flags = IDE_HFLAGS_AMD, \ | 249 | .host_flags = IDE_HFLAGS_AMD, \ |
249 | .pio_mask = ATA_PIO5, \ | 250 | .pio_mask = ATA_PIO5, \ |
250 | .swdma_mask = ATA_SWDMA2, \ | 251 | .swdma_mask = ATA_SWDMA2, \ |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 7e037c880cb0..8b637181681a 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -130,37 +130,26 @@ static u8 __devinit atiixp_cable_detect(ide_hwif_t *hwif) | |||
130 | return ATA_CBL_PATA40; | 130 | return ATA_CBL_PATA40; |
131 | } | 131 | } |
132 | 132 | ||
133 | /** | 133 | static const struct ide_port_ops atiixp_port_ops = { |
134 | * init_hwif_atiixp - fill in the hwif for the ATIIXP | 134 | .set_pio_mode = atiixp_set_pio_mode, |
135 | * @hwif: IDE interface | 135 | .set_dma_mode = atiixp_set_dma_mode, |
136 | * | 136 | .cable_detect = atiixp_cable_detect, |
137 | * Set up the ide_hwif_t for the ATIIXP interface according to the | 137 | }; |
138 | * capabilities of the hardware. | ||
139 | */ | ||
140 | |||
141 | static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) | ||
142 | { | ||
143 | hwif->set_pio_mode = &atiixp_set_pio_mode; | ||
144 | hwif->set_dma_mode = &atiixp_set_dma_mode; | ||
145 | |||
146 | hwif->cable_detect = atiixp_cable_detect; | ||
147 | } | ||
148 | 138 | ||
149 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | 139 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { |
150 | { /* 0 */ | 140 | { /* 0 */ |
151 | .name = "ATIIXP", | 141 | .name = "ATIIXP", |
152 | .init_hwif = init_hwif_atiixp, | ||
153 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, | 142 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, |
154 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_BOOTABLE, | 143 | .port_ops = &atiixp_port_ops, |
144 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | ||
155 | .pio_mask = ATA_PIO4, | 145 | .pio_mask = ATA_PIO4, |
156 | .mwdma_mask = ATA_MWDMA2, | 146 | .mwdma_mask = ATA_MWDMA2, |
157 | .udma_mask = ATA_UDMA5, | 147 | .udma_mask = ATA_UDMA5, |
158 | },{ /* 1 */ | 148 | },{ /* 1 */ |
159 | .name = "SB600_PATA", | 149 | .name = "SB600_PATA", |
160 | .init_hwif = init_hwif_atiixp, | ||
161 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, | 150 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, |
162 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS | | 151 | .port_ops = &atiixp_port_ops, |
163 | IDE_HFLAG_BOOTABLE, | 152 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, |
164 | .pio_mask = ATA_PIO4, | 153 | .pio_mask = ATA_PIO4, |
165 | .mwdma_mask = ATA_MWDMA2, | 154 | .mwdma_mask = ATA_MWDMA2, |
166 | .udma_mask = ATA_UDMA5, | 155 | .udma_mask = ATA_UDMA5, |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index a1cfe033a55f..aaf38109eaec 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | /* | 5 | /* |
6 | * Original authors: abramov@cecmow.enet.dec.com (Igor Abramov) | 6 | * Original authors: abramov@cecmow.enet.dec.com (Igor Abramov) |
7 | * mlord@pobox.com (Mark Lord) | 7 | * mlord@pobox.com (Mark Lord) |
8 | * | 8 | * |
9 | * See linux/MAINTAINERS for address of current maintainer. | 9 | * See linux/MAINTAINERS for address of current maintainer. |
10 | * | 10 | * |
@@ -98,7 +98,7 @@ | |||
98 | 98 | ||
99 | #define CMD640_PREFETCH_MASKS 1 | 99 | #define CMD640_PREFETCH_MASKS 1 |
100 | 100 | ||
101 | //#define CMD640_DUMP_REGS | 101 | /*#define CMD640_DUMP_REGS */ |
102 | 102 | ||
103 | #include <linux/types.h> | 103 | #include <linux/types.h> |
104 | #include <linux/kernel.h> | 104 | #include <linux/kernel.h> |
@@ -109,10 +109,9 @@ | |||
109 | 109 | ||
110 | #include <asm/io.h> | 110 | #include <asm/io.h> |
111 | 111 | ||
112 | /* | 112 | #define DRV_NAME "cmd640" |
113 | * This flag is set in ide.c by the parameter: ide0=cmd640_vlb | 113 | |
114 | */ | 114 | static int cmd640_vlb; |
115 | int cmd640_vlb = 0; | ||
116 | 115 | ||
117 | /* | 116 | /* |
118 | * CMD640 specific registers definition. | 117 | * CMD640 specific registers definition. |
@@ -185,7 +184,6 @@ static DEFINE_SPINLOCK(cmd640_lock); | |||
185 | * These are initialized to point at the devices we control | 184 | * These are initialized to point at the devices we control |
186 | */ | 185 | */ |
187 | static ide_hwif_t *cmd_hwif0, *cmd_hwif1; | 186 | static ide_hwif_t *cmd_hwif0, *cmd_hwif1; |
188 | static ide_drive_t *cmd_drives[4]; | ||
189 | 187 | ||
190 | /* | 188 | /* |
191 | * Interface to access cmd640x registers | 189 | * Interface to access cmd640x registers |
@@ -207,13 +205,13 @@ static unsigned int cmd640_chip_version; | |||
207 | 205 | ||
208 | /* PCI method 1 access */ | 206 | /* PCI method 1 access */ |
209 | 207 | ||
210 | static void put_cmd640_reg_pci1 (u16 reg, u8 val) | 208 | static void put_cmd640_reg_pci1(u16 reg, u8 val) |
211 | { | 209 | { |
212 | outl_p((reg & 0xfc) | cmd640_key, 0xcf8); | 210 | outl_p((reg & 0xfc) | cmd640_key, 0xcf8); |
213 | outb_p(val, (reg & 3) | 0xcfc); | 211 | outb_p(val, (reg & 3) | 0xcfc); |
214 | } | 212 | } |
215 | 213 | ||
216 | static u8 get_cmd640_reg_pci1 (u16 reg) | 214 | static u8 get_cmd640_reg_pci1(u16 reg) |
217 | { | 215 | { |
218 | outl_p((reg & 0xfc) | cmd640_key, 0xcf8); | 216 | outl_p((reg & 0xfc) | cmd640_key, 0xcf8); |
219 | return inb_p((reg & 3) | 0xcfc); | 217 | return inb_p((reg & 3) | 0xcfc); |
@@ -221,14 +219,14 @@ static u8 get_cmd640_reg_pci1 (u16 reg) | |||
221 | 219 | ||
222 | /* PCI method 2 access (from CMD datasheet) */ | 220 | /* PCI method 2 access (from CMD datasheet) */ |
223 | 221 | ||
224 | static void put_cmd640_reg_pci2 (u16 reg, u8 val) | 222 | static void put_cmd640_reg_pci2(u16 reg, u8 val) |
225 | { | 223 | { |
226 | outb_p(0x10, 0xcf8); | 224 | outb_p(0x10, 0xcf8); |
227 | outb_p(val, cmd640_key + reg); | 225 | outb_p(val, cmd640_key + reg); |
228 | outb_p(0, 0xcf8); | 226 | outb_p(0, 0xcf8); |
229 | } | 227 | } |
230 | 228 | ||
231 | static u8 get_cmd640_reg_pci2 (u16 reg) | 229 | static u8 get_cmd640_reg_pci2(u16 reg) |
232 | { | 230 | { |
233 | u8 b; | 231 | u8 b; |
234 | 232 | ||
@@ -240,13 +238,13 @@ static u8 get_cmd640_reg_pci2 (u16 reg) | |||
240 | 238 | ||
241 | /* VLB access */ | 239 | /* VLB access */ |
242 | 240 | ||
243 | static void put_cmd640_reg_vlb (u16 reg, u8 val) | 241 | static void put_cmd640_reg_vlb(u16 reg, u8 val) |
244 | { | 242 | { |
245 | outb_p(reg, cmd640_key); | 243 | outb_p(reg, cmd640_key); |
246 | outb_p(val, cmd640_key + 4); | 244 | outb_p(val, cmd640_key + 4); |
247 | } | 245 | } |
248 | 246 | ||
249 | static u8 get_cmd640_reg_vlb (u16 reg) | 247 | static u8 get_cmd640_reg_vlb(u16 reg) |
250 | { | 248 | { |
251 | outb_p(reg, cmd640_key); | 249 | outb_p(reg, cmd640_key); |
252 | return inb_p(cmd640_key + 4); | 250 | return inb_p(cmd640_key + 4); |
@@ -268,11 +266,11 @@ static void put_cmd640_reg(u16 reg, u8 val) | |||
268 | unsigned long flags; | 266 | unsigned long flags; |
269 | 267 | ||
270 | spin_lock_irqsave(&cmd640_lock, flags); | 268 | spin_lock_irqsave(&cmd640_lock, flags); |
271 | __put_cmd640_reg(reg,val); | 269 | __put_cmd640_reg(reg, val); |
272 | spin_unlock_irqrestore(&cmd640_lock, flags); | 270 | spin_unlock_irqrestore(&cmd640_lock, flags); |
273 | } | 271 | } |
274 | 272 | ||
275 | static int __init match_pci_cmd640_device (void) | 273 | static int __init match_pci_cmd640_device(void) |
276 | { | 274 | { |
277 | const u8 ven_dev[4] = {0x95, 0x10, 0x40, 0x06}; | 275 | const u8 ven_dev[4] = {0x95, 0x10, 0x40, 0x06}; |
278 | unsigned int i; | 276 | unsigned int i; |
@@ -292,7 +290,7 @@ static int __init match_pci_cmd640_device (void) | |||
292 | /* | 290 | /* |
293 | * Probe for CMD640x -- pci method 1 | 291 | * Probe for CMD640x -- pci method 1 |
294 | */ | 292 | */ |
295 | static int __init probe_for_cmd640_pci1 (void) | 293 | static int __init probe_for_cmd640_pci1(void) |
296 | { | 294 | { |
297 | __get_cmd640_reg = get_cmd640_reg_pci1; | 295 | __get_cmd640_reg = get_cmd640_reg_pci1; |
298 | __put_cmd640_reg = put_cmd640_reg_pci1; | 296 | __put_cmd640_reg = put_cmd640_reg_pci1; |
@@ -308,7 +306,7 @@ static int __init probe_for_cmd640_pci1 (void) | |||
308 | /* | 306 | /* |
309 | * Probe for CMD640x -- pci method 2 | 307 | * Probe for CMD640x -- pci method 2 |
310 | */ | 308 | */ |
311 | static int __init probe_for_cmd640_pci2 (void) | 309 | static int __init probe_for_cmd640_pci2(void) |
312 | { | 310 | { |
313 | __get_cmd640_reg = get_cmd640_reg_pci2; | 311 | __get_cmd640_reg = get_cmd640_reg_pci2; |
314 | __put_cmd640_reg = put_cmd640_reg_pci2; | 312 | __put_cmd640_reg = put_cmd640_reg_pci2; |
@@ -322,7 +320,7 @@ static int __init probe_for_cmd640_pci2 (void) | |||
322 | /* | 320 | /* |
323 | * Probe for CMD640x -- vlb | 321 | * Probe for CMD640x -- vlb |
324 | */ | 322 | */ |
325 | static int __init probe_for_cmd640_vlb (void) | 323 | static int __init probe_for_cmd640_vlb(void) |
326 | { | 324 | { |
327 | u8 b; | 325 | u8 b; |
328 | 326 | ||
@@ -343,18 +341,18 @@ static int __init probe_for_cmd640_vlb (void) | |||
343 | * Returns 1 if an IDE interface/drive exists at 0x170, | 341 | * Returns 1 if an IDE interface/drive exists at 0x170, |
344 | * Returns 0 otherwise. | 342 | * Returns 0 otherwise. |
345 | */ | 343 | */ |
346 | static int __init secondary_port_responding (void) | 344 | static int __init secondary_port_responding(void) |
347 | { | 345 | { |
348 | unsigned long flags; | 346 | unsigned long flags; |
349 | 347 | ||
350 | spin_lock_irqsave(&cmd640_lock, flags); | 348 | spin_lock_irqsave(&cmd640_lock, flags); |
351 | 349 | ||
352 | outb_p(0x0a, 0x170 + IDE_SELECT_OFFSET); /* select drive0 */ | 350 | outb_p(0x0a, 0x176); /* select drive0 */ |
353 | udelay(100); | 351 | udelay(100); |
354 | if ((inb_p(0x170 + IDE_SELECT_OFFSET) & 0x1f) != 0x0a) { | 352 | if ((inb_p(0x176) & 0x1f) != 0x0a) { |
355 | outb_p(0x1a, 0x170 + IDE_SELECT_OFFSET); /* select drive1 */ | 353 | outb_p(0x1a, 0x176); /* select drive1 */ |
356 | udelay(100); | 354 | udelay(100); |
357 | if ((inb_p(0x170 + IDE_SELECT_OFFSET) & 0x1f) != 0x1a) { | 355 | if ((inb_p(0x176) & 0x1f) != 0x1a) { |
358 | spin_unlock_irqrestore(&cmd640_lock, flags); | 356 | spin_unlock_irqrestore(&cmd640_lock, flags); |
359 | return 0; /* nothing responded */ | 357 | return 0; /* nothing responded */ |
360 | } | 358 | } |
@@ -367,7 +365,7 @@ static int __init secondary_port_responding (void) | |||
367 | /* | 365 | /* |
368 | * Dump out all cmd640 registers. May be called from ide.c | 366 | * Dump out all cmd640 registers. May be called from ide.c |
369 | */ | 367 | */ |
370 | static void cmd640_dump_regs (void) | 368 | static void cmd640_dump_regs(void) |
371 | { | 369 | { |
372 | unsigned int reg = cmd640_vlb ? 0x50 : 0x00; | 370 | unsigned int reg = cmd640_vlb ? 0x50 : 0x00; |
373 | 371 | ||
@@ -382,13 +380,13 @@ static void cmd640_dump_regs (void) | |||
382 | } | 380 | } |
383 | #endif | 381 | #endif |
384 | 382 | ||
383 | #ifndef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
385 | /* | 384 | /* |
386 | * Check whether prefetch is on for a drive, | 385 | * Check whether prefetch is on for a drive, |
387 | * and initialize the unmask flags for safe operation. | 386 | * and initialize the unmask flags for safe operation. |
388 | */ | 387 | */ |
389 | static void __init check_prefetch (unsigned int index) | 388 | static void __init check_prefetch(ide_drive_t *drive, unsigned int index) |
390 | { | 389 | { |
391 | ide_drive_t *drive = cmd_drives[index]; | ||
392 | u8 b = get_cmd640_reg(prefetch_regs[index]); | 390 | u8 b = get_cmd640_reg(prefetch_regs[index]); |
393 | 391 | ||
394 | if (b & prefetch_masks[index]) { /* is prefetch off? */ | 392 | if (b & prefetch_masks[index]) { /* is prefetch off? */ |
@@ -403,29 +401,12 @@ static void __init check_prefetch (unsigned int index) | |||
403 | drive->no_io_32bit = 0; | 401 | drive->no_io_32bit = 0; |
404 | } | 402 | } |
405 | } | 403 | } |
406 | 404 | #else | |
407 | /* | ||
408 | * Figure out which devices we control | ||
409 | */ | ||
410 | static void __init setup_device_ptrs (void) | ||
411 | { | ||
412 | cmd_hwif0 = &ide_hwifs[0]; | ||
413 | cmd_hwif1 = &ide_hwifs[1]; | ||
414 | |||
415 | cmd_drives[0] = &cmd_hwif0->drives[0]; | ||
416 | cmd_drives[1] = &cmd_hwif0->drives[1]; | ||
417 | cmd_drives[2] = &cmd_hwif1->drives[0]; | ||
418 | cmd_drives[3] = &cmd_hwif1->drives[1]; | ||
419 | } | ||
420 | |||
421 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
422 | |||
423 | /* | 405 | /* |
424 | * Sets prefetch mode for a drive. | 406 | * Sets prefetch mode for a drive. |
425 | */ | 407 | */ |
426 | static void set_prefetch_mode (unsigned int index, int mode) | 408 | static void set_prefetch_mode(ide_drive_t *drive, unsigned int index, int mode) |
427 | { | 409 | { |
428 | ide_drive_t *drive = cmd_drives[index]; | ||
429 | unsigned long flags; | 410 | unsigned long flags; |
430 | int reg = prefetch_regs[index]; | 411 | int reg = prefetch_regs[index]; |
431 | u8 b; | 412 | u8 b; |
@@ -452,7 +433,7 @@ static void set_prefetch_mode (unsigned int index, int mode) | |||
452 | /* | 433 | /* |
453 | * Dump out current drive clocks settings | 434 | * Dump out current drive clocks settings |
454 | */ | 435 | */ |
455 | static void display_clocks (unsigned int index) | 436 | static void display_clocks(unsigned int index) |
456 | { | 437 | { |
457 | u8 active_count, recovery_count; | 438 | u8 active_count, recovery_count; |
458 | 439 | ||
@@ -471,44 +452,16 @@ static void display_clocks (unsigned int index) | |||
471 | * Pack active and recovery counts into single byte representation | 452 | * Pack active and recovery counts into single byte representation |
472 | * used by controller | 453 | * used by controller |
473 | */ | 454 | */ |
474 | static inline u8 pack_nibbles (u8 upper, u8 lower) | 455 | static inline u8 pack_nibbles(u8 upper, u8 lower) |
475 | { | 456 | { |
476 | return ((upper & 0x0f) << 4) | (lower & 0x0f); | 457 | return ((upper & 0x0f) << 4) | (lower & 0x0f); |
477 | } | 458 | } |
478 | 459 | ||
479 | /* | 460 | /* |
480 | * This routine retrieves the initial drive timings from the chipset. | ||
481 | */ | ||
482 | static void __init retrieve_drive_counts (unsigned int index) | ||
483 | { | ||
484 | u8 b; | ||
485 | |||
486 | /* | ||
487 | * Get the internal setup timing, and convert to clock count | ||
488 | */ | ||
489 | b = get_cmd640_reg(arttim_regs[index]) & ~0x3f; | ||
490 | switch (b) { | ||
491 | case 0x00: b = 4; break; | ||
492 | case 0x80: b = 3; break; | ||
493 | case 0x40: b = 2; break; | ||
494 | default: b = 5; break; | ||
495 | } | ||
496 | setup_counts[index] = b; | ||
497 | |||
498 | /* | ||
499 | * Get the active/recovery counts | ||
500 | */ | ||
501 | b = get_cmd640_reg(drwtim_regs[index]); | ||
502 | active_counts[index] = (b >> 4) ? (b >> 4) : 0x10; | ||
503 | recovery_counts[index] = (b & 0x0f) ? (b & 0x0f) : 0x10; | ||
504 | } | ||
505 | |||
506 | |||
507 | /* | ||
508 | * This routine writes the prepared setup/active/recovery counts | 461 | * This routine writes the prepared setup/active/recovery counts |
509 | * for a drive into the cmd640 chipset registers to active them. | 462 | * for a drive into the cmd640 chipset registers to active them. |
510 | */ | 463 | */ |
511 | static void program_drive_counts (unsigned int index) | 464 | static void program_drive_counts(ide_drive_t *drive, unsigned int index) |
512 | { | 465 | { |
513 | unsigned long flags; | 466 | unsigned long flags; |
514 | u8 setup_count = setup_counts[index]; | 467 | u8 setup_count = setup_counts[index]; |
@@ -522,8 +475,11 @@ static void program_drive_counts (unsigned int index) | |||
522 | * so we merge the timings, using the slowest value for each timing. | 475 | * so we merge the timings, using the slowest value for each timing. |
523 | */ | 476 | */ |
524 | if (index > 1) { | 477 | if (index > 1) { |
525 | unsigned int mate; | 478 | ide_hwif_t *hwif = drive->hwif; |
526 | if (cmd_drives[mate = index ^ 1]->present) { | 479 | ide_drive_t *peer = &hwif->drives[!drive->select.b.unit]; |
480 | unsigned int mate = index ^ 1; | ||
481 | |||
482 | if (peer->present) { | ||
527 | if (setup_count < setup_counts[mate]) | 483 | if (setup_count < setup_counts[mate]) |
528 | setup_count = setup_counts[mate]; | 484 | setup_count = setup_counts[mate]; |
529 | if (active_count < active_counts[mate]) | 485 | if (active_count < active_counts[mate]) |
@@ -537,11 +493,11 @@ static void program_drive_counts (unsigned int index) | |||
537 | * Convert setup_count to internal chipset representation | 493 | * Convert setup_count to internal chipset representation |
538 | */ | 494 | */ |
539 | switch (setup_count) { | 495 | switch (setup_count) { |
540 | case 4: setup_count = 0x00; break; | 496 | case 4: setup_count = 0x00; break; |
541 | case 3: setup_count = 0x80; break; | 497 | case 3: setup_count = 0x80; break; |
542 | case 1: | 498 | case 1: |
543 | case 2: setup_count = 0x40; break; | 499 | case 2: setup_count = 0x40; break; |
544 | default: setup_count = 0xc0; /* case 5 */ | 500 | default: setup_count = 0xc0; /* case 5 */ |
545 | } | 501 | } |
546 | 502 | ||
547 | /* | 503 | /* |
@@ -562,11 +518,19 @@ static void program_drive_counts (unsigned int index) | |||
562 | /* | 518 | /* |
563 | * Set a specific pio_mode for a drive | 519 | * Set a specific pio_mode for a drive |
564 | */ | 520 | */ |
565 | static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle_time) | 521 | static void cmd640_set_mode(ide_drive_t *drive, unsigned int index, |
522 | u8 pio_mode, unsigned int cycle_time) | ||
566 | { | 523 | { |
567 | int setup_time, active_time, recovery_time, clock_time; | 524 | int setup_time, active_time, recovery_time, clock_time; |
568 | u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count; | 525 | u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count; |
569 | int bus_speed = system_bus_clock(); | 526 | int bus_speed; |
527 | |||
528 | if (cmd640_vlb && ide_vlb_clk) | ||
529 | bus_speed = ide_vlb_clk; | ||
530 | else if (!cmd640_vlb && ide_pci_clk) | ||
531 | bus_speed = ide_pci_clk; | ||
532 | else | ||
533 | bus_speed = system_bus_clock(); | ||
570 | 534 | ||
571 | if (pio_mode > 5) | 535 | if (pio_mode > 5) |
572 | pio_mode = 5; | 536 | pio_mode = 5; |
@@ -574,15 +538,15 @@ static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle | |||
574 | active_time = ide_pio_timings[pio_mode].active_time; | 538 | active_time = ide_pio_timings[pio_mode].active_time; |
575 | recovery_time = cycle_time - (setup_time + active_time); | 539 | recovery_time = cycle_time - (setup_time + active_time); |
576 | clock_time = 1000 / bus_speed; | 540 | clock_time = 1000 / bus_speed; |
577 | cycle_count = (cycle_time + clock_time - 1) / clock_time; | 541 | cycle_count = DIV_ROUND_UP(cycle_time, clock_time); |
578 | 542 | ||
579 | setup_count = (setup_time + clock_time - 1) / clock_time; | 543 | setup_count = DIV_ROUND_UP(setup_time, clock_time); |
580 | 544 | ||
581 | active_count = (active_time + clock_time - 1) / clock_time; | 545 | active_count = DIV_ROUND_UP(active_time, clock_time); |
582 | if (active_count < 2) | 546 | if (active_count < 2) |
583 | active_count = 2; /* minimum allowed by cmd640 */ | 547 | active_count = 2; /* minimum allowed by cmd640 */ |
584 | 548 | ||
585 | recovery_count = (recovery_time + clock_time - 1) / clock_time; | 549 | recovery_count = DIV_ROUND_UP(recovery_time, clock_time); |
586 | recovery_count2 = cycle_count - (setup_count + active_count); | 550 | recovery_count2 = cycle_count - (setup_count + active_count); |
587 | if (recovery_count2 > recovery_count) | 551 | if (recovery_count2 > recovery_count) |
588 | recovery_count = recovery_count2; | 552 | recovery_count = recovery_count2; |
@@ -611,7 +575,7 @@ static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle | |||
611 | * 1) this is the wrong place to do it (proper is do_special() in ide.c) | 575 | * 1) this is the wrong place to do it (proper is do_special() in ide.c) |
612 | * 2) in practice this is rarely, if ever, necessary | 576 | * 2) in practice this is rarely, if ever, necessary |
613 | */ | 577 | */ |
614 | program_drive_counts (index); | 578 | program_drive_counts(drive, index); |
615 | } | 579 | } |
616 | 580 | ||
617 | static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | 581 | static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) |
@@ -619,32 +583,26 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
619 | unsigned int index = 0, cycle_time; | 583 | unsigned int index = 0, cycle_time; |
620 | u8 b; | 584 | u8 b; |
621 | 585 | ||
622 | while (drive != cmd_drives[index]) { | ||
623 | if (++index > 3) { | ||
624 | printk(KERN_ERR "%s: bad news in %s\n", | ||
625 | drive->name, __FUNCTION__); | ||
626 | return; | ||
627 | } | ||
628 | } | ||
629 | switch (pio) { | 586 | switch (pio) { |
630 | case 6: /* set fast-devsel off */ | 587 | case 6: /* set fast-devsel off */ |
631 | case 7: /* set fast-devsel on */ | 588 | case 7: /* set fast-devsel on */ |
632 | b = get_cmd640_reg(CNTRL) & ~0x27; | 589 | b = get_cmd640_reg(CNTRL) & ~0x27; |
633 | if (pio & 1) | 590 | if (pio & 1) |
634 | b |= 0x27; | 591 | b |= 0x27; |
635 | put_cmd640_reg(CNTRL, b); | 592 | put_cmd640_reg(CNTRL, b); |
636 | printk("%s: %sabled cmd640 fast host timing (devsel)\n", drive->name, (pio & 1) ? "en" : "dis"); | 593 | printk("%s: %sabled cmd640 fast host timing (devsel)\n", |
637 | return; | 594 | drive->name, (pio & 1) ? "en" : "dis"); |
638 | 595 | return; | |
639 | case 8: /* set prefetch off */ | 596 | case 8: /* set prefetch off */ |
640 | case 9: /* set prefetch on */ | 597 | case 9: /* set prefetch on */ |
641 | set_prefetch_mode(index, pio & 1); | 598 | set_prefetch_mode(drive, index, pio & 1); |
642 | printk("%s: %sabled cmd640 prefetch\n", drive->name, (pio & 1) ? "en" : "dis"); | 599 | printk("%s: %sabled cmd640 prefetch\n", |
643 | return; | 600 | drive->name, (pio & 1) ? "en" : "dis"); |
601 | return; | ||
644 | } | 602 | } |
645 | 603 | ||
646 | cycle_time = ide_pio_cycle_time(drive, pio); | 604 | cycle_time = ide_pio_cycle_time(drive, pio); |
647 | cmd640_set_mode(index, pio, cycle_time); | 605 | cmd640_set_mode(drive, index, pio, cycle_time); |
648 | 606 | ||
649 | printk("%s: selected cmd640 PIO mode%d (%dns)", | 607 | printk("%s: selected cmd640 PIO mode%d (%dns)", |
650 | drive->name, pio, cycle_time); | 608 | drive->name, pio, cycle_time); |
@@ -652,6 +610,9 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
652 | display_clocks(index); | 610 | display_clocks(index); |
653 | } | 611 | } |
654 | 612 | ||
613 | static const struct ide_port_ops cmd640_port_ops = { | ||
614 | .set_pio_mode = cmd640_set_pio_mode, | ||
615 | }; | ||
655 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 616 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
656 | 617 | ||
657 | static int pci_conf1(void) | 618 | static int pci_conf1(void) |
@@ -693,14 +654,32 @@ static const struct ide_port_info cmd640_port_info __initdata = { | |||
693 | .chipset = ide_cmd640, | 654 | .chipset = ide_cmd640, |
694 | .host_flags = IDE_HFLAG_SERIALIZE | | 655 | .host_flags = IDE_HFLAG_SERIALIZE | |
695 | IDE_HFLAG_NO_DMA | | 656 | IDE_HFLAG_NO_DMA | |
696 | IDE_HFLAG_NO_AUTOTUNE | | ||
697 | IDE_HFLAG_ABUSE_PREFETCH | | 657 | IDE_HFLAG_ABUSE_PREFETCH | |
698 | IDE_HFLAG_ABUSE_FAST_DEVSEL, | 658 | IDE_HFLAG_ABUSE_FAST_DEVSEL, |
699 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 659 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
660 | .port_ops = &cmd640_port_ops, | ||
700 | .pio_mask = ATA_PIO5, | 661 | .pio_mask = ATA_PIO5, |
701 | #endif | 662 | #endif |
702 | }; | 663 | }; |
703 | 664 | ||
665 | static int cmd640x_init_one(unsigned long base, unsigned long ctl) | ||
666 | { | ||
667 | if (!request_region(base, 8, DRV_NAME)) { | ||
668 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
669 | DRV_NAME, base, base + 7); | ||
670 | return -EBUSY; | ||
671 | } | ||
672 | |||
673 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
674 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
675 | DRV_NAME, ctl); | ||
676 | release_region(base, 8); | ||
677 | return -EBUSY; | ||
678 | } | ||
679 | |||
680 | return 0; | ||
681 | } | ||
682 | |||
704 | /* | 683 | /* |
705 | * Probe for a cmd640 chipset, and initialize it if found. | 684 | * Probe for a cmd640 chipset, and initialize it if found. |
706 | */ | 685 | */ |
@@ -709,7 +688,7 @@ static int __init cmd640x_init(void) | |||
709 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 688 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
710 | int second_port_toggled = 0; | 689 | int second_port_toggled = 0; |
711 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 690 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
712 | int second_port_cmd640 = 0; | 691 | int second_port_cmd640 = 0, rc; |
713 | const char *bus_type, *port2; | 692 | const char *bus_type, *port2; |
714 | unsigned int index; | 693 | unsigned int index; |
715 | u8 b, cfr; | 694 | u8 b, cfr; |
@@ -749,10 +728,21 @@ static int __init cmd640x_init(void) | |||
749 | cfr = get_cmd640_reg(CFR); | 728 | cfr = get_cmd640_reg(CFR); |
750 | cmd640_chip_version = cfr & CFR_DEVREV; | 729 | cmd640_chip_version = cfr & CFR_DEVREV; |
751 | if (cmd640_chip_version == 0) { | 730 | if (cmd640_chip_version == 0) { |
752 | printk ("ide: bad cmd640 revision: %d\n", cmd640_chip_version); | 731 | printk("ide: bad cmd640 revision: %d\n", cmd640_chip_version); |
753 | return 0; | 732 | return 0; |
754 | } | 733 | } |
755 | 734 | ||
735 | rc = cmd640x_init_one(0x1f0, 0x3f6); | ||
736 | if (rc) | ||
737 | return rc; | ||
738 | |||
739 | rc = cmd640x_init_one(0x170, 0x376); | ||
740 | if (rc) { | ||
741 | release_region(0x3f6, 1); | ||
742 | release_region(0x1f0, 8); | ||
743 | return rc; | ||
744 | } | ||
745 | |||
756 | memset(&hw, 0, sizeof(hw)); | 746 | memset(&hw, 0, sizeof(hw)); |
757 | 747 | ||
758 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | 748 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); |
@@ -764,17 +754,15 @@ static int __init cmd640x_init(void) | |||
764 | printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" | 754 | printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" |
765 | "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); | 755 | "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); |
766 | 756 | ||
757 | cmd_hwif0 = ide_find_port(); | ||
758 | |||
767 | /* | 759 | /* |
768 | * Initialize data for primary port | 760 | * Initialize data for primary port |
769 | */ | 761 | */ |
770 | setup_device_ptrs (); | 762 | if (cmd_hwif0) { |
771 | 763 | ide_init_port_hw(cmd_hwif0, &hw[0]); | |
772 | ide_init_port_hw(cmd_hwif0, &hw[0]); | 764 | idx[0] = cmd_hwif0->index; |
773 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 765 | } |
774 | cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; | ||
775 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
776 | |||
777 | idx[0] = cmd_hwif0->index; | ||
778 | 766 | ||
779 | /* | 767 | /* |
780 | * Ensure compatibility by always using the slowest timings | 768 | * Ensure compatibility by always using the slowest timings |
@@ -786,10 +774,13 @@ static int __init cmd640x_init(void) | |||
786 | put_cmd640_reg(CMDTIM, 0); | 774 | put_cmd640_reg(CMDTIM, 0); |
787 | put_cmd640_reg(BRST, 0x40); | 775 | put_cmd640_reg(BRST, 0x40); |
788 | 776 | ||
777 | cmd_hwif1 = ide_find_port(); | ||
778 | |||
789 | /* | 779 | /* |
790 | * Try to enable the secondary interface, if not already enabled | 780 | * Try to enable the secondary interface, if not already enabled |
791 | */ | 781 | */ |
792 | if (cmd_hwif1->drives[0].noprobe && cmd_hwif1->drives[1].noprobe) { | 782 | if (cmd_hwif1 && |
783 | cmd_hwif1->drives[0].noprobe && cmd_hwif1->drives[1].noprobe) { | ||
793 | port2 = "not probed"; | 784 | port2 = "not probed"; |
794 | } else { | 785 | } else { |
795 | b = get_cmd640_reg(CNTRL); | 786 | b = get_cmd640_reg(CNTRL); |
@@ -820,15 +811,11 @@ static int __init cmd640x_init(void) | |||
820 | /* | 811 | /* |
821 | * Initialize data for secondary cmd640 port, if enabled | 812 | * Initialize data for secondary cmd640 port, if enabled |
822 | */ | 813 | */ |
823 | if (second_port_cmd640) { | 814 | if (second_port_cmd640 && cmd_hwif1) { |
824 | ide_init_port_hw(cmd_hwif1, &hw[1]); | 815 | ide_init_port_hw(cmd_hwif1, &hw[1]); |
825 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
826 | cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; | ||
827 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
828 | |||
829 | idx[1] = cmd_hwif1->index; | 816 | idx[1] = cmd_hwif1->index; |
830 | } | 817 | } |
831 | printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name, | 818 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", |
832 | second_port_cmd640 ? "" : "not ", port2); | 819 | second_port_cmd640 ? "" : "not ", port2); |
833 | 820 | ||
834 | /* | 821 | /* |
@@ -836,35 +823,34 @@ static int __init cmd640x_init(void) | |||
836 | * Do not unnecessarily disturb any prior BIOS setup of these. | 823 | * Do not unnecessarily disturb any prior BIOS setup of these. |
837 | */ | 824 | */ |
838 | for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) { | 825 | for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) { |
839 | ide_drive_t *drive = cmd_drives[index]; | 826 | ide_drive_t *drive; |
840 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 827 | |
841 | if (drive->autotune || ((index > 1) && second_port_toggled)) { | 828 | if (index > 1) { |
842 | /* | 829 | if (cmd_hwif1 == NULL) |
843 | * Reset timing to the slowest speed and turn off prefetch. | 830 | continue; |
844 | * This way, the drive identify code has a better chance. | 831 | drive = &cmd_hwif1->drives[index & 1]; |
845 | */ | 832 | } else { |
846 | setup_counts [index] = 4; /* max possible */ | 833 | if (cmd_hwif0 == NULL) |
847 | active_counts [index] = 16; /* max possible */ | 834 | continue; |
848 | recovery_counts [index] = 16; /* max possible */ | 835 | drive = &cmd_hwif0->drives[index & 1]; |
849 | program_drive_counts (index); | ||
850 | set_prefetch_mode (index, 0); | ||
851 | printk("cmd640: drive%d timings/prefetch cleared\n", index); | ||
852 | } else { | ||
853 | /* | ||
854 | * Record timings/prefetch without changing them. | ||
855 | * This preserves any prior BIOS setup. | ||
856 | */ | ||
857 | retrieve_drive_counts (index); | ||
858 | check_prefetch (index); | ||
859 | printk("cmd640: drive%d timings/prefetch(%s) preserved", | ||
860 | index, drive->no_io_32bit ? "off" : "on"); | ||
861 | display_clocks(index); | ||
862 | } | 836 | } |
837 | |||
838 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
839 | /* | ||
840 | * Reset timing to the slowest speed and turn off prefetch. | ||
841 | * This way, the drive identify code has a better chance. | ||
842 | */ | ||
843 | setup_counts [index] = 4; /* max possible */ | ||
844 | active_counts [index] = 16; /* max possible */ | ||
845 | recovery_counts [index] = 16; /* max possible */ | ||
846 | program_drive_counts(drive, index); | ||
847 | set_prefetch_mode(drive, index, 0); | ||
848 | printk("cmd640: drive%d timings/prefetch cleared\n", index); | ||
863 | #else | 849 | #else |
864 | /* | 850 | /* |
865 | * Set the drive unmask flags to match the prefetch setting | 851 | * Set the drive unmask flags to match the prefetch setting |
866 | */ | 852 | */ |
867 | check_prefetch (index); | 853 | check_prefetch(drive, index); |
868 | printk("cmd640: drive%d timings/prefetch(%s) preserved\n", | 854 | printk("cmd640: drive%d timings/prefetch(%s) preserved\n", |
869 | index, drive->no_io_32bit ? "off" : "on"); | 855 | index, drive->no_io_32bit ? "off" : "on"); |
870 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 856 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index edabe6299efd..08674711d089 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -68,8 +68,8 @@ static u8 quantize_timing(int timing, int quant) | |||
68 | */ | 68 | */ |
69 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) | 69 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) |
70 | { | 70 | { |
71 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 71 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
72 | int clock_time = 1000 / system_bus_clock(); | 72 | int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock()); |
73 | u8 cycle_count, active_count, recovery_count, drwtim; | 73 | u8 cycle_count, active_count, recovery_count, drwtim; |
74 | static const u8 recovery_values[] = | 74 | static const u8 recovery_values[] = |
75 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; | 75 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; |
@@ -128,7 +128,7 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | |||
128 | ide_pio_timings[pio].active_time); | 128 | ide_pio_timings[pio].active_time); |
129 | 129 | ||
130 | setup_count = quantize_timing(ide_pio_timings[pio].setup_time, | 130 | setup_count = quantize_timing(ide_pio_timings[pio].setup_time, |
131 | 1000 / system_bus_clock()); | 131 | 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock())); |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * The primary channel has individual address setup timing registers | 134 | * The primary channel has individual address setup timing registers |
@@ -223,7 +223,7 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
223 | (void) pci_write_config_byte(dev, pciU, regU); | 223 | (void) pci_write_config_byte(dev, pciU, regU); |
224 | } | 224 | } |
225 | 225 | ||
226 | static int cmd648_ide_dma_end (ide_drive_t *drive) | 226 | static int cmd648_dma_end(ide_drive_t *drive) |
227 | { | 227 | { |
228 | ide_hwif_t *hwif = HWIF(drive); | 228 | ide_hwif_t *hwif = HWIF(drive); |
229 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 229 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
@@ -239,7 +239,7 @@ static int cmd648_ide_dma_end (ide_drive_t *drive) | |||
239 | return err; | 239 | return err; |
240 | } | 240 | } |
241 | 241 | ||
242 | static int cmd64x_ide_dma_end (ide_drive_t *drive) | 242 | static int cmd64x_dma_end(ide_drive_t *drive) |
243 | { | 243 | { |
244 | ide_hwif_t *hwif = HWIF(drive); | 244 | ide_hwif_t *hwif = HWIF(drive); |
245 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 245 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -256,7 +256,7 @@ static int cmd64x_ide_dma_end (ide_drive_t *drive) | |||
256 | return err; | 256 | return err; |
257 | } | 257 | } |
258 | 258 | ||
259 | static int cmd648_ide_dma_test_irq (ide_drive_t *drive) | 259 | static int cmd648_dma_test_irq(ide_drive_t *drive) |
260 | { | 260 | { |
261 | ide_hwif_t *hwif = HWIF(drive); | 261 | ide_hwif_t *hwif = HWIF(drive); |
262 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 262 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
@@ -279,7 +279,7 @@ static int cmd648_ide_dma_test_irq (ide_drive_t *drive) | |||
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) | 282 | static int cmd64x_dma_test_irq(ide_drive_t *drive) |
283 | { | 283 | { |
284 | ide_hwif_t *hwif = HWIF(drive); | 284 | ide_hwif_t *hwif = HWIF(drive); |
285 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 285 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -310,7 +310,7 @@ static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) | |||
310 | * event order for DMA transfers. | 310 | * event order for DMA transfers. |
311 | */ | 311 | */ |
312 | 312 | ||
313 | static int cmd646_1_ide_dma_end (ide_drive_t *drive) | 313 | static int cmd646_1_dma_end(ide_drive_t *drive) |
314 | { | 314 | { |
315 | ide_hwif_t *hwif = HWIF(drive); | 315 | ide_hwif_t *hwif = HWIF(drive); |
316 | u8 dma_stat = 0, dma_cmd = 0; | 316 | u8 dma_stat = 0, dma_cmd = 0; |
@@ -370,7 +370,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha | |||
370 | return 0; | 370 | return 0; |
371 | } | 371 | } |
372 | 372 | ||
373 | static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) | 373 | static u8 __devinit cmd64x_cable_detect(ide_hwif_t *hwif) |
374 | { | 374 | { |
375 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 375 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
376 | u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; | 376 | u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; |
@@ -385,91 +385,85 @@ static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) | |||
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | 388 | static const struct ide_port_ops cmd64x_port_ops = { |
389 | { | 389 | .set_pio_mode = cmd64x_set_pio_mode, |
390 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 390 | .set_dma_mode = cmd64x_set_dma_mode, |
391 | 391 | .cable_detect = cmd64x_cable_detect, | |
392 | hwif->set_pio_mode = &cmd64x_set_pio_mode; | 392 | }; |
393 | hwif->set_dma_mode = &cmd64x_set_dma_mode; | ||
394 | |||
395 | hwif->cable_detect = ata66_cmd64x; | ||
396 | 393 | ||
397 | if (!hwif->dma_base) | 394 | static const struct ide_dma_ops cmd64x_dma_ops = { |
398 | return; | 395 | .dma_host_set = ide_dma_host_set, |
396 | .dma_setup = ide_dma_setup, | ||
397 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
398 | .dma_start = ide_dma_start, | ||
399 | .dma_end = cmd64x_dma_end, | ||
400 | .dma_test_irq = cmd64x_dma_test_irq, | ||
401 | .dma_lost_irq = ide_dma_lost_irq, | ||
402 | .dma_timeout = ide_dma_timeout, | ||
403 | }; | ||
399 | 404 | ||
400 | /* | 405 | static const struct ide_dma_ops cmd646_rev1_dma_ops = { |
401 | * UltraDMA only supported on PCI646U and PCI646U2, which | 406 | .dma_host_set = ide_dma_host_set, |
402 | * correspond to revisions 0x03, 0x05 and 0x07 respectively. | 407 | .dma_setup = ide_dma_setup, |
403 | * Actually, although the CMD tech support people won't | 408 | .dma_exec_cmd = ide_dma_exec_cmd, |
404 | * tell me the details, the 0x03 revision cannot support | 409 | .dma_start = ide_dma_start, |
405 | * UDMA correctly without hardware modifications, and even | 410 | .dma_end = cmd646_1_dma_end, |
406 | * then it only works with Quantum disks due to some | 411 | .dma_test_irq = ide_dma_test_irq, |
407 | * hold time assumptions in the 646U part which are fixed | 412 | .dma_lost_irq = ide_dma_lost_irq, |
408 | * in the 646U2. | 413 | .dma_timeout = ide_dma_timeout, |
409 | * | 414 | }; |
410 | * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. | ||
411 | */ | ||
412 | if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5) | ||
413 | hwif->ultra_mask = 0x00; | ||
414 | 415 | ||
415 | switch (dev->device) { | 416 | static const struct ide_dma_ops cmd648_dma_ops = { |
416 | case PCI_DEVICE_ID_CMD_648: | 417 | .dma_host_set = ide_dma_host_set, |
417 | case PCI_DEVICE_ID_CMD_649: | 418 | .dma_setup = ide_dma_setup, |
418 | alt_irq_bits: | 419 | .dma_exec_cmd = ide_dma_exec_cmd, |
419 | hwif->ide_dma_end = &cmd648_ide_dma_end; | 420 | .dma_start = ide_dma_start, |
420 | hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq; | 421 | .dma_end = cmd648_dma_end, |
421 | break; | 422 | .dma_test_irq = cmd648_dma_test_irq, |
422 | case PCI_DEVICE_ID_CMD_646: | 423 | .dma_lost_irq = ide_dma_lost_irq, |
423 | if (dev->revision == 0x01) { | 424 | .dma_timeout = ide_dma_timeout, |
424 | hwif->ide_dma_end = &cmd646_1_ide_dma_end; | 425 | }; |
425 | break; | ||
426 | } else if (dev->revision >= 0x03) | ||
427 | goto alt_irq_bits; | ||
428 | /* fall thru */ | ||
429 | default: | ||
430 | hwif->ide_dma_end = &cmd64x_ide_dma_end; | ||
431 | hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq; | ||
432 | break; | ||
433 | } | ||
434 | } | ||
435 | 426 | ||
436 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | 427 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { |
437 | { /* 0 */ | 428 | { /* 0 */ |
438 | .name = "CMD643", | 429 | .name = "CMD643", |
439 | .init_chipset = init_chipset_cmd64x, | 430 | .init_chipset = init_chipset_cmd64x, |
440 | .init_hwif = init_hwif_cmd64x, | ||
441 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, | 431 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
432 | .port_ops = &cmd64x_port_ops, | ||
433 | .dma_ops = &cmd64x_dma_ops, | ||
442 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | | 434 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | |
443 | IDE_HFLAG_ABUSE_PREFETCH | | 435 | IDE_HFLAG_ABUSE_PREFETCH, |
444 | IDE_HFLAG_BOOTABLE, | ||
445 | .pio_mask = ATA_PIO5, | 436 | .pio_mask = ATA_PIO5, |
446 | .mwdma_mask = ATA_MWDMA2, | 437 | .mwdma_mask = ATA_MWDMA2, |
447 | .udma_mask = 0x00, /* no udma */ | 438 | .udma_mask = 0x00, /* no udma */ |
448 | },{ /* 1 */ | 439 | },{ /* 1 */ |
449 | .name = "CMD646", | 440 | .name = "CMD646", |
450 | .init_chipset = init_chipset_cmd64x, | 441 | .init_chipset = init_chipset_cmd64x, |
451 | .init_hwif = init_hwif_cmd64x, | ||
452 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 442 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
453 | .chipset = ide_cmd646, | 443 | .chipset = ide_cmd646, |
454 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, | 444 | .port_ops = &cmd64x_port_ops, |
445 | .dma_ops = &cmd648_dma_ops, | ||
446 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
455 | .pio_mask = ATA_PIO5, | 447 | .pio_mask = ATA_PIO5, |
456 | .mwdma_mask = ATA_MWDMA2, | 448 | .mwdma_mask = ATA_MWDMA2, |
457 | .udma_mask = ATA_UDMA2, | 449 | .udma_mask = ATA_UDMA2, |
458 | },{ /* 2 */ | 450 | },{ /* 2 */ |
459 | .name = "CMD648", | 451 | .name = "CMD648", |
460 | .init_chipset = init_chipset_cmd64x, | 452 | .init_chipset = init_chipset_cmd64x, |
461 | .init_hwif = init_hwif_cmd64x, | ||
462 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 453 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
463 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, | 454 | .port_ops = &cmd64x_port_ops, |
455 | .dma_ops = &cmd648_dma_ops, | ||
456 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
464 | .pio_mask = ATA_PIO5, | 457 | .pio_mask = ATA_PIO5, |
465 | .mwdma_mask = ATA_MWDMA2, | 458 | .mwdma_mask = ATA_MWDMA2, |
466 | .udma_mask = ATA_UDMA4, | 459 | .udma_mask = ATA_UDMA4, |
467 | },{ /* 3 */ | 460 | },{ /* 3 */ |
468 | .name = "CMD649", | 461 | .name = "CMD649", |
469 | .init_chipset = init_chipset_cmd64x, | 462 | .init_chipset = init_chipset_cmd64x, |
470 | .init_hwif = init_hwif_cmd64x, | ||
471 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 463 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
472 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, | 464 | .port_ops = &cmd64x_port_ops, |
465 | .dma_ops = &cmd648_dma_ops, | ||
466 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
473 | .pio_mask = ATA_PIO5, | 467 | .pio_mask = ATA_PIO5, |
474 | .mwdma_mask = ATA_MWDMA2, | 468 | .mwdma_mask = ATA_MWDMA2, |
475 | .udma_mask = ATA_UDMA5, | 469 | .udma_mask = ATA_UDMA5, |
@@ -483,12 +477,35 @@ static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_devic | |||
483 | 477 | ||
484 | d = cmd64x_chipsets[idx]; | 478 | d = cmd64x_chipsets[idx]; |
485 | 479 | ||
486 | /* | 480 | if (idx == 1) { |
487 | * The original PCI0646 didn't have the primary channel enable bit, | 481 | /* |
488 | * it appeared starting with PCI0646U (i.e. revision ID 3). | 482 | * UltraDMA only supported on PCI646U and PCI646U2, which |
489 | */ | 483 | * correspond to revisions 0x03, 0x05 and 0x07 respectively. |
490 | if (idx == 1 && dev->revision < 3) | 484 | * Actually, although the CMD tech support people won't |
491 | d.enablebits[0].reg = 0; | 485 | * tell me the details, the 0x03 revision cannot support |
486 | * UDMA correctly without hardware modifications, and even | ||
487 | * then it only works with Quantum disks due to some | ||
488 | * hold time assumptions in the 646U part which are fixed | ||
489 | * in the 646U2. | ||
490 | * | ||
491 | * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. | ||
492 | */ | ||
493 | if (dev->revision < 5) { | ||
494 | d.udma_mask = 0x00; | ||
495 | /* | ||
496 | * The original PCI0646 didn't have the primary | ||
497 | * channel enable bit, it appeared starting with | ||
498 | * PCI0646U (i.e. revision ID 3). | ||
499 | */ | ||
500 | if (dev->revision < 3) { | ||
501 | d.enablebits[0].reg = 0; | ||
502 | if (dev->revision == 1) | ||
503 | d.dma_ops = &cmd646_rev1_dma_ops; | ||
504 | else | ||
505 | d.dma_ops = &cmd64x_dma_ops; | ||
506 | } | ||
507 | } | ||
508 | } | ||
492 | 509 | ||
493 | return ide_setup_pci_device(dev, &d); | 510 | return ide_setup_pci_device(dev, &d); |
494 | } | 511 | } |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index 1c163e4ef03f..17669a434438 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -103,27 +103,32 @@ static void cs5520_dma_host_set(ide_drive_t *drive, int on) | |||
103 | ide_dma_host_set(drive, on); | 103 | ide_dma_host_set(drive, on); |
104 | } | 104 | } |
105 | 105 | ||
106 | static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) | 106 | static const struct ide_port_ops cs5520_port_ops = { |
107 | { | 107 | .set_pio_mode = cs5520_set_pio_mode, |
108 | hwif->set_pio_mode = &cs5520_set_pio_mode; | 108 | .set_dma_mode = cs5520_set_dma_mode, |
109 | hwif->set_dma_mode = &cs5520_set_dma_mode; | 109 | }; |
110 | |||
111 | if (hwif->dma_base == 0) | ||
112 | return; | ||
113 | 110 | ||
114 | hwif->dma_host_set = &cs5520_dma_host_set; | 111 | static const struct ide_dma_ops cs5520_dma_ops = { |
115 | } | 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 | }; | ||
116 | 121 | ||
117 | #define DECLARE_CS_DEV(name_str) \ | 122 | #define DECLARE_CS_DEV(name_str) \ |
118 | { \ | 123 | { \ |
119 | .name = name_str, \ | 124 | .name = name_str, \ |
120 | .init_hwif = init_hwif_cs5520, \ | 125 | .port_ops = &cs5520_port_ops, \ |
126 | .dma_ops = &cs5520_dma_ops, \ | ||
121 | .host_flags = IDE_HFLAG_ISA_PORTS | \ | 127 | .host_flags = IDE_HFLAG_ISA_PORTS | \ |
122 | IDE_HFLAG_CS5520 | \ | 128 | IDE_HFLAG_CS5520 | \ |
123 | IDE_HFLAG_VDMA | \ | 129 | IDE_HFLAG_VDMA | \ |
124 | IDE_HFLAG_NO_ATAPI_DMA | \ | 130 | IDE_HFLAG_NO_ATAPI_DMA | \ |
125 | IDE_HFLAG_ABUSE_SET_DMA_MODE |\ | 131 | IDE_HFLAG_ABUSE_SET_DMA_MODE, \ |
126 | IDE_HFLAG_BOOTABLE, \ | ||
127 | .pio_mask = ATA_PIO4, \ | 132 | .pio_mask = ATA_PIO4, \ |
128 | } | 133 | } |
129 | 134 | ||
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index 941a1344820b..f5534c1ff349 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
@@ -228,29 +228,27 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif) | |||
228 | unsigned long basereg; | 228 | unsigned long basereg; |
229 | u32 d0_timings; | 229 | u32 d0_timings; |
230 | 230 | ||
231 | hwif->set_pio_mode = &cs5530_set_pio_mode; | ||
232 | hwif->set_dma_mode = &cs5530_set_dma_mode; | ||
233 | |||
234 | basereg = CS5530_BASEREG(hwif); | 231 | basereg = CS5530_BASEREG(hwif); |
235 | d0_timings = inl(basereg + 0); | 232 | d0_timings = inl(basereg + 0); |
236 | if (CS5530_BAD_PIO(d0_timings)) | 233 | if (CS5530_BAD_PIO(d0_timings)) |
237 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); | 234 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); |
238 | if (CS5530_BAD_PIO(inl(basereg + 8))) | 235 | if (CS5530_BAD_PIO(inl(basereg + 8))) |
239 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); | 236 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); |
240 | |||
241 | if (hwif->dma_base == 0) | ||
242 | return; | ||
243 | |||
244 | hwif->udma_filter = cs5530_udma_filter; | ||
245 | } | 237 | } |
246 | 238 | ||
239 | static const struct ide_port_ops cs5530_port_ops = { | ||
240 | .set_pio_mode = cs5530_set_pio_mode, | ||
241 | .set_dma_mode = cs5530_set_dma_mode, | ||
242 | .udma_filter = cs5530_udma_filter, | ||
243 | }; | ||
244 | |||
247 | static const struct ide_port_info cs5530_chipset __devinitdata = { | 245 | static const struct ide_port_info cs5530_chipset __devinitdata = { |
248 | .name = "CS5530", | 246 | .name = "CS5530", |
249 | .init_chipset = init_chipset_cs5530, | 247 | .init_chipset = init_chipset_cs5530, |
250 | .init_hwif = init_hwif_cs5530, | 248 | .init_hwif = init_hwif_cs5530, |
249 | .port_ops = &cs5530_port_ops, | ||
251 | .host_flags = IDE_HFLAG_SERIALIZE | | 250 | .host_flags = IDE_HFLAG_SERIALIZE | |
252 | IDE_HFLAG_POST_SET_MODE | | 251 | IDE_HFLAG_POST_SET_MODE, |
253 | IDE_HFLAG_BOOTABLE, | ||
254 | .pio_mask = ATA_PIO4, | 252 | .pio_mask = ATA_PIO4, |
255 | .mwdma_mask = ATA_MWDMA2, | 253 | .mwdma_mask = ATA_MWDMA2, |
256 | .udma_mask = ATA_UDMA2, | 254 | .udma_mask = ATA_UDMA2, |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index d7b5ea992e94..99fe91a191b8 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -166,27 +166,17 @@ static u8 __devinit cs5535_cable_detect(ide_hwif_t *hwif) | |||
166 | return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 166 | return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
167 | } | 167 | } |
168 | 168 | ||
169 | /**** | 169 | static const struct ide_port_ops cs5535_port_ops = { |
170 | * init_hwif_cs5535 - Initialize one ide cannel | 170 | .set_pio_mode = cs5535_set_pio_mode, |
171 | * @hwif: Channel descriptor | 171 | .set_dma_mode = cs5535_set_dma_mode, |
172 | * | 172 | .cable_detect = cs5535_cable_detect, |
173 | * This gets invoked by the IDE driver once for each channel. It | 173 | }; |
174 | * performs channel-specific pre-initialization before drive probing. | ||
175 | * | ||
176 | */ | ||
177 | static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) | ||
178 | { | ||
179 | hwif->set_pio_mode = &cs5535_set_pio_mode; | ||
180 | hwif->set_dma_mode = &cs5535_set_dma_mode; | ||
181 | |||
182 | hwif->cable_detect = cs5535_cable_detect; | ||
183 | } | ||
184 | 174 | ||
185 | static const struct ide_port_info cs5535_chipset __devinitdata = { | 175 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
186 | .name = "CS5535", | 176 | .name = "CS5535", |
187 | .init_hwif = init_hwif_cs5535, | 177 | .port_ops = &cs5535_port_ops, |
188 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | | 178 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | |
189 | IDE_HFLAG_ABUSE_SET_DMA_MODE | IDE_HFLAG_BOOTABLE, | 179 | IDE_HFLAG_ABUSE_SET_DMA_MODE, |
190 | .pio_mask = ATA_PIO4, | 180 | .pio_mask = ATA_PIO4, |
191 | .mwdma_mask = ATA_MWDMA2, | 181 | .mwdma_mask = ATA_MWDMA2, |
192 | .udma_mask = ATA_UDMA4, | 182 | .udma_mask = ATA_UDMA4, |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 724cbacf4e5b..77cc22c2ad45 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * | 6 | * |
7 | * The CY82C693 chipset is used on Digital's PC-Alpha 164SX boards. | 7 | * The CY82C693 chipset is used on Digital's PC-Alpha 164SX boards. |
8 | * Writing the driver was quite simple, since most of the job is | 8 | * Writing the driver was quite simple, since most of the job is |
9 | * done by the generic pci-ide support. | 9 | * done by the generic pci-ide support. |
10 | * The hard part was finding the CY82C693's datasheet on Cypress's | 10 | * The hard part was finding the CY82C693's datasheet on Cypress's |
11 | * web page :-(. But Altavista solved this problem :-). | 11 | * web page :-(. But Altavista solved this problem :-). |
12 | * | 12 | * |
@@ -15,12 +15,10 @@ | |||
15 | * - I recently got a 16.8G IBM DTTA, so I was able to test it with | 15 | * - I recently got a 16.8G IBM DTTA, so I was able to test it with |
16 | * a large and fast disk - the results look great, so I'd say the | 16 | * a large and fast disk - the results look great, so I'd say the |
17 | * driver is working fine :-) | 17 | * driver is working fine :-) |
18 | * hdparm -t reports 8.17 MB/sec at about 6% CPU usage for the DTTA | 18 | * hdparm -t reports 8.17 MB/sec at about 6% CPU usage for the DTTA |
19 | * - this is my first linux driver, so there's probably a lot of room | 19 | * - this is my first linux driver, so there's probably a lot of room |
20 | * for optimizations and bug fixing, so feel free to do it. | 20 | * for optimizations and bug fixing, so feel free to do it. |
21 | * - use idebus=xx parameter to set PCI bus speed - needed to calc | 21 | * - if using PIO mode it's a good idea to set the PIO mode and |
22 | * timings for PIO modes (default will be 40) | ||
23 | * - if using PIO mode it's a good idea to set the PIO mode and | ||
24 | * 32-bit I/O support (if possible), e.g. hdparm -p2 -c1 /dev/hda | 22 | * 32-bit I/O support (if possible), e.g. hdparm -p2 -c1 /dev/hda |
25 | * - I had some problems with my IBM DHEA with PIO modes < 2 | 23 | * - I had some problems with my IBM DHEA with PIO modes < 2 |
26 | * (lost interrupts) ????? | 24 | * (lost interrupts) ????? |
@@ -110,11 +108,11 @@ typedef struct pio_clocks_s { | |||
110 | * calc clocks using bus_speed | 108 | * calc clocks using bus_speed |
111 | * returns (rounded up) time in bus clocks for time in ns | 109 | * returns (rounded up) time in bus clocks for time in ns |
112 | */ | 110 | */ |
113 | static int calc_clk (int time, int bus_speed) | 111 | static int calc_clk(int time, int bus_speed) |
114 | { | 112 | { |
115 | int clocks; | 113 | int clocks; |
116 | 114 | ||
117 | clocks = (time*bus_speed+999)/1000 -1; | 115 | clocks = (time*bus_speed+999)/1000 - 1; |
118 | 116 | ||
119 | if (clocks < 0) | 117 | if (clocks < 0) |
120 | clocks = 0; | 118 | clocks = 0; |
@@ -132,11 +130,11 @@ static int calc_clk (int time, int bus_speed) | |||
132 | * NOTE: for mode 0,1 and 2 drives 8-bit IDE command control registers are used | 130 | * NOTE: for mode 0,1 and 2 drives 8-bit IDE command control registers are used |
133 | * for mode 3 and 4 drives 8 and 16-bit timings are the same | 131 | * for mode 3 and 4 drives 8 and 16-bit timings are the same |
134 | * | 132 | * |
135 | */ | 133 | */ |
136 | static void compute_clocks (u8 pio, pio_clocks_t *p_pclk) | 134 | static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) |
137 | { | 135 | { |
138 | int clk1, clk2; | 136 | int clk1, clk2; |
139 | int bus_speed = system_bus_clock(); /* get speed of PCI bus */ | 137 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); |
140 | 138 | ||
141 | /* we don't check against CY82C693's min and max speed, | 139 | /* we don't check against CY82C693's min and max speed, |
142 | * so you can play with the idebus=xx parameter | 140 | * so you can play with the idebus=xx parameter |
@@ -158,7 +156,7 @@ static void compute_clocks (u8 pio, pio_clocks_t *p_pclk) | |||
158 | clk1 = (clk1<<4)|clk2; /* combine active and recovery clocks */ | 156 | clk1 = (clk1<<4)|clk2; /* combine active and recovery clocks */ |
159 | 157 | ||
160 | /* note: we use the same values for 16bit IOR and IOW | 158 | /* note: we use the same values for 16bit IOR and IOW |
161 | * those are all the same, since I don't have other | 159 | * those are all the same, since I don't have other |
162 | * timings than those from ide-lib.c | 160 | * timings than those from ide-lib.c |
163 | */ | 161 | */ |
164 | 162 | ||
@@ -186,7 +184,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
186 | outb(index, CY82_INDEX_PORT); | 184 | outb(index, CY82_INDEX_PORT); |
187 | data = inb(CY82_DATA_PORT); | 185 | data = inb(CY82_DATA_PORT); |
188 | 186 | ||
189 | printk (KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n", | 187 | printk(KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n", |
190 | drive->name, HWIF(drive)->channel, drive->select.b.unit, | 188 | drive->name, HWIF(drive)->channel, drive->select.b.unit, |
191 | (data&0x3), ((data>>2)&1)); | 189 | (data&0x3), ((data>>2)&1)); |
192 | #endif /* CY82C693_DEBUG_LOGS */ | 190 | #endif /* CY82C693_DEBUG_LOGS */ |
@@ -202,7 +200,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
202 | mode & 3, single); | 200 | mode & 3, single); |
203 | #endif /* CY82C693_DEBUG_INFO */ | 201 | #endif /* CY82C693_DEBUG_INFO */ |
204 | 202 | ||
205 | /* | 203 | /* |
206 | * note: below we set the value for Bus Master IDE TimeOut Register | 204 | * note: below we set the value for Bus Master IDE TimeOut Register |
207 | * I'm not absolutly sure what this does, but it solved my problem | 205 | * I'm not absolutly sure what this does, but it solved my problem |
208 | * with IDE DMA and sound, so I now can play sound and work with | 206 | * with IDE DMA and sound, so I now can play sound and work with |
@@ -216,8 +214,8 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
216 | outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT); | 214 | outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT); |
217 | outb(data, CY82_DATA_PORT); | 215 | outb(data, CY82_DATA_PORT); |
218 | 216 | ||
219 | #if CY82C693_DEBUG_INFO | 217 | #if CY82C693_DEBUG_INFO |
220 | printk (KERN_INFO "%s: Set IDE Bus Master TimeOut Register to 0x%X\n", | 218 | printk(KERN_INFO "%s: Set IDE Bus Master TimeOut Register to 0x%X\n", |
221 | drive->name, data); | 219 | drive->name, data); |
222 | #endif /* CY82C693_DEBUG_INFO */ | 220 | #endif /* CY82C693_DEBUG_INFO */ |
223 | } | 221 | } |
@@ -242,14 +240,14 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
242 | 240 | ||
243 | #if CY82C693_DEBUG_LOGS | 241 | #if CY82C693_DEBUG_LOGS |
244 | /* for debug let's show the register values */ | 242 | /* for debug let's show the register values */ |
245 | 243 | ||
246 | if (drive->select.b.unit == 0) { | 244 | if (drive->select.b.unit == 0) { |
247 | /* | 245 | /* |
248 | * get master drive registers | 246 | * get master drive registers |
249 | * address setup control register | 247 | * address setup control register |
250 | * is 32 bit !!! | 248 | * is 32 bit !!! |
251 | */ | 249 | */ |
252 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); | 250 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
253 | addrCtrl &= 0x0F; | 251 | addrCtrl &= 0x0F; |
254 | 252 | ||
255 | /* now let's get the remaining registers */ | 253 | /* now let's get the remaining registers */ |
@@ -261,7 +259,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
261 | * set slave drive registers | 259 | * set slave drive registers |
262 | * address setup control register | 260 | * address setup control register |
263 | * is 32 bit !!! | 261 | * is 32 bit !!! |
264 | */ | 262 | */ |
265 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); | 263 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
266 | 264 | ||
267 | addrCtrl &= 0xF0; | 265 | addrCtrl &= 0xF0; |
@@ -288,9 +286,9 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
288 | * set master drive | 286 | * set master drive |
289 | * address setup control register | 287 | * address setup control register |
290 | * is 32 bit !!! | 288 | * is 32 bit !!! |
291 | */ | 289 | */ |
292 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); | 290 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
293 | 291 | ||
294 | addrCtrl &= (~0xF); | 292 | addrCtrl &= (~0xF); |
295 | addrCtrl |= (unsigned int)pclk.address_time; | 293 | addrCtrl |= (unsigned int)pclk.address_time; |
296 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); | 294 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); |
@@ -299,14 +297,14 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
299 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, pclk.time_16r); | 297 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, pclk.time_16r); |
300 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, pclk.time_16w); | 298 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, pclk.time_16w); |
301 | pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, pclk.time_8); | 299 | pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, pclk.time_8); |
302 | 300 | ||
303 | addrCtrl &= 0xF; | 301 | addrCtrl &= 0xF; |
304 | } else { | 302 | } else { |
305 | /* | 303 | /* |
306 | * set slave drive | 304 | * set slave drive |
307 | * address setup control register | 305 | * address setup control register |
308 | * is 32 bit !!! | 306 | * is 32 bit !!! |
309 | */ | 307 | */ |
310 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); | 308 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
311 | 309 | ||
312 | addrCtrl &= (~0xF0); | 310 | addrCtrl &= (~0xF0); |
@@ -320,7 +318,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
320 | 318 | ||
321 | addrCtrl >>= 4; | 319 | addrCtrl >>= 4; |
322 | addrCtrl &= 0xF; | 320 | addrCtrl &= 0xF; |
323 | } | 321 | } |
324 | 322 | ||
325 | #if CY82C693_DEBUG_INFO | 323 | #if CY82C693_DEBUG_INFO |
326 | printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " | 324 | printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " |
@@ -340,41 +338,41 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c | |||
340 | 338 | ||
341 | #ifdef CY82C693_SETDMA_CLOCK | 339 | #ifdef CY82C693_SETDMA_CLOCK |
342 | u8 data = 0; | 340 | u8 data = 0; |
343 | #endif /* CY82C693_SETDMA_CLOCK */ | 341 | #endif /* CY82C693_SETDMA_CLOCK */ |
344 | 342 | ||
345 | /* write info about this verion of the driver */ | 343 | /* write info about this verion of the driver */ |
346 | printk(KERN_INFO CY82_VERSION "\n"); | 344 | printk(KERN_INFO CY82_VERSION "\n"); |
347 | 345 | ||
348 | #ifdef CY82C693_SETDMA_CLOCK | 346 | #ifdef CY82C693_SETDMA_CLOCK |
349 | /* okay let's set the DMA clock speed */ | 347 | /* okay let's set the DMA clock speed */ |
350 | 348 | ||
351 | outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT); | 349 | outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT); |
352 | data = inb(CY82_DATA_PORT); | 350 | data = inb(CY82_DATA_PORT); |
353 | 351 | ||
354 | #if CY82C693_DEBUG_INFO | 352 | #if CY82C693_DEBUG_INFO |
355 | printk(KERN_INFO "%s: Peripheral Configuration Register: 0x%X\n", | 353 | printk(KERN_INFO "%s: Peripheral Configuration Register: 0x%X\n", |
356 | name, data); | 354 | name, data); |
357 | #endif /* CY82C693_DEBUG_INFO */ | 355 | #endif /* CY82C693_DEBUG_INFO */ |
358 | 356 | ||
359 | /* | 357 | /* |
360 | * for some reason sometimes the DMA controller | 358 | * for some reason sometimes the DMA controller |
361 | * speed is set to ATCLK/2 ???? - we fix this here | 359 | * speed is set to ATCLK/2 ???? - we fix this here |
362 | * | 360 | * |
363 | * note: i don't know what causes this strange behaviour, | 361 | * note: i don't know what causes this strange behaviour, |
364 | * but even changing the dma speed doesn't solve it :-( | 362 | * but even changing the dma speed doesn't solve it :-( |
365 | * the ide performance is still only half the normal speed | 363 | * the ide performance is still only half the normal speed |
366 | * | 364 | * |
367 | * if anybody knows what goes wrong with my machine, please | 365 | * if anybody knows what goes wrong with my machine, please |
368 | * let me know - ASK | 366 | * let me know - ASK |
369 | */ | 367 | */ |
370 | 368 | ||
371 | data |= 0x03; | 369 | data |= 0x03; |
372 | 370 | ||
373 | outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT); | 371 | outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT); |
374 | outb(data, CY82_DATA_PORT); | 372 | outb(data, CY82_DATA_PORT); |
375 | 373 | ||
376 | #if CY82C693_DEBUG_INFO | 374 | #if CY82C693_DEBUG_INFO |
377 | printk (KERN_INFO "%s: New Peripheral Configuration Register: 0x%X\n", | 375 | printk(KERN_INFO "%s: New Peripheral Configuration Register: 0x%X\n", |
378 | name, data); | 376 | name, data); |
379 | #endif /* CY82C693_DEBUG_INFO */ | 377 | #endif /* CY82C693_DEBUG_INFO */ |
380 | 378 | ||
@@ -382,15 +380,6 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c | |||
382 | return 0; | 380 | return 0; |
383 | } | 381 | } |
384 | 382 | ||
385 | /* | ||
386 | * the init function - called for each ide channel once | ||
387 | */ | ||
388 | static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | ||
389 | { | ||
390 | hwif->set_pio_mode = &cy82c693_set_pio_mode; | ||
391 | hwif->set_dma_mode = &cy82c693_set_dma_mode; | ||
392 | } | ||
393 | |||
394 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | 383 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
395 | { | 384 | { |
396 | static ide_hwif_t *primary; | 385 | static ide_hwif_t *primary; |
@@ -404,14 +393,18 @@ static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | |||
404 | } | 393 | } |
405 | } | 394 | } |
406 | 395 | ||
396 | static const struct ide_port_ops cy82c693_port_ops = { | ||
397 | .set_pio_mode = cy82c693_set_pio_mode, | ||
398 | .set_dma_mode = cy82c693_set_dma_mode, | ||
399 | }; | ||
400 | |||
407 | static const struct ide_port_info cy82c693_chipset __devinitdata = { | 401 | static const struct ide_port_info cy82c693_chipset __devinitdata = { |
408 | .name = "CY82C693", | 402 | .name = "CY82C693", |
409 | .init_chipset = init_chipset_cy82c693, | 403 | .init_chipset = init_chipset_cy82c693, |
410 | .init_iops = init_iops_cy82c693, | 404 | .init_iops = init_iops_cy82c693, |
411 | .init_hwif = init_hwif_cy82c693, | 405 | .port_ops = &cy82c693_port_ops, |
412 | .chipset = ide_cy82c693, | 406 | .chipset = ide_cy82c693, |
413 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_CY82C693 | | 407 | .host_flags = IDE_HFLAG_SINGLE, |
414 | IDE_HFLAG_BOOTABLE, | ||
415 | .pio_mask = ATA_PIO4, | 408 | .pio_mask = ATA_PIO4, |
416 | .swdma_mask = ATA_SWDMA2, | 409 | .swdma_mask = ATA_SWDMA2, |
417 | .mwdma_mask = ATA_MWDMA2, | 410 | .mwdma_mask = ATA_MWDMA2, |
@@ -424,7 +417,7 @@ static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_dev | |||
424 | 417 | ||
425 | /* CY82C693 is more than only a IDE controller. | 418 | /* CY82C693 is more than only a IDE controller. |
426 | Function 1 is primary IDE channel, function 2 - secondary. */ | 419 | Function 1 is primary IDE channel, function 2 - secondary. */ |
427 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 420 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
428 | PCI_FUNC(dev->devfn) == 1) { | 421 | PCI_FUNC(dev->devfn) == 1) { |
429 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | 422 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
430 | ret = ide_setup_pci_devices(dev, dev2, &cy82c693_chipset); | 423 | ret = ide_setup_pci_devices(dev, dev2, &cy82c693_chipset); |
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 961698d655eb..b9e457996d0e 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
@@ -43,6 +43,10 @@ static const u8 setup[] = { | |||
43 | 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13, | 43 | 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static const struct ide_port_ops delkin_cb_port_ops = { | ||
47 | .quirkproc = ide_undecoded_slave, | ||
48 | }; | ||
49 | |||
46 | static int __devinit | 50 | static int __devinit |
47 | delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | 51 | delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) |
48 | { | 52 | { |
@@ -71,26 +75,21 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
71 | if (setup[i]) | 75 | if (setup[i]) |
72 | outb(setup[i], base + i); | 76 | outb(setup[i], base + i); |
73 | } | 77 | } |
74 | pci_release_regions(dev); /* IDE layer handles regions itself */ | ||
75 | 78 | ||
76 | memset(&hw, 0, sizeof(hw)); | 79 | memset(&hw, 0, sizeof(hw)); |
77 | ide_std_init_ports(&hw, base + 0x10, base + 0x1e); | 80 | ide_std_init_ports(&hw, base + 0x10, base + 0x1e); |
78 | hw.irq = dev->irq; | 81 | hw.irq = dev->irq; |
79 | hw.chipset = ide_pci; /* this enables IRQ sharing */ | 82 | hw.chipset = ide_pci; /* this enables IRQ sharing */ |
80 | 83 | ||
81 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); | 84 | hwif = ide_find_port(); |
82 | if (hwif == NULL) | 85 | if (hwif == NULL) |
83 | goto out_disable; | 86 | goto out_disable; |
84 | 87 | ||
85 | i = hwif->index; | 88 | i = hwif->index; |
86 | 89 | ||
87 | if (hwif->present) | 90 | ide_init_port_data(hwif, i); |
88 | ide_unregister(i); | ||
89 | else | ||
90 | ide_init_port_data(hwif, i); | ||
91 | |||
92 | ide_init_port_hw(hwif, &hw); | 91 | ide_init_port_hw(hwif, &hw); |
93 | hwif->quirkproc = &ide_undecoded_slave; | 92 | hwif->port_ops = &delkin_cb_port_ops; |
94 | 93 | ||
95 | idx[0] = i; | 94 | idx[0] = i; |
96 | 95 | ||
@@ -110,6 +109,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
110 | 109 | ||
111 | out_disable: | 110 | out_disable: |
112 | printk(KERN_ERR "delkin_cb: no IDE devices found\n"); | 111 | printk(KERN_ERR "delkin_cb: no IDE devices found\n"); |
112 | pci_release_regions(dev); | ||
113 | pci_disable_device(dev); | 113 | pci_disable_device(dev); |
114 | return -ENODEV; | 114 | return -ENODEV; |
115 | } | 115 | } |
@@ -119,9 +119,9 @@ delkin_cb_remove (struct pci_dev *dev) | |||
119 | { | 119 | { |
120 | ide_hwif_t *hwif = pci_get_drvdata(dev); | 120 | ide_hwif_t *hwif = pci_get_drvdata(dev); |
121 | 121 | ||
122 | if (hwif) | 122 | ide_unregister(hwif); |
123 | ide_unregister(hwif->index); | ||
124 | 123 | ||
124 | pci_release_regions(dev); | ||
125 | pci_disable_device(dev); | 125 | pci_disable_device(dev); |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index 7fd83a9d4dee..041720e22762 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
@@ -38,8 +38,7 @@ MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE st | |||
38 | { \ | 38 | { \ |
39 | .name = name_str, \ | 39 | .name = name_str, \ |
40 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ | 40 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ |
41 | extra_flags | \ | 41 | extra_flags, \ |
42 | IDE_HFLAG_BOOTABLE, \ | ||
43 | .swdma_mask = ATA_SWDMA2, \ | 42 | .swdma_mask = ATA_SWDMA2, \ |
44 | .mwdma_mask = ATA_MWDMA2, \ | 43 | .mwdma_mask = ATA_MWDMA2, \ |
45 | .udma_mask = ATA_UDMA6, \ | 44 | .udma_mask = ATA_UDMA6, \ |
@@ -50,9 +49,8 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
50 | 49 | ||
51 | { /* 1 */ | 50 | { /* 1 */ |
52 | .name = "NS87410", | 51 | .name = "NS87410", |
53 | .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, | 52 | .enablebits = { {0x43, 0x08, 0x08}, {0x47, 0x08, 0x08} }, |
54 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 53 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, |
55 | IDE_HFLAG_BOOTABLE, | ||
56 | .swdma_mask = ATA_SWDMA2, | 54 | .swdma_mask = ATA_SWDMA2, |
57 | .mwdma_mask = ATA_MWDMA2, | 55 | .mwdma_mask = ATA_MWDMA2, |
58 | .udma_mask = ATA_UDMA6, | 56 | .udma_mask = ATA_UDMA6, |
@@ -99,7 +97,7 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
99 | * Called when the PCI registration layer (or the IDE initialization) | 97 | * Called when the PCI registration layer (or the IDE initialization) |
100 | * finds a device matching our IDE device tables. | 98 | * finds a device matching our IDE device tables. |
101 | */ | 99 | */ |
102 | 100 | ||
103 | static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 101 | static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
104 | { | 102 | { |
105 | const struct ide_port_info *d = &generic_chipsets[id->driver_data]; | 103 | const struct ide_port_info *d = &generic_chipsets[id->driver_data]; |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 9f01da46b016..84c36c117194 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -115,11 +115,10 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha | |||
115 | return dev->irq; | 115 | return dev->irq; |
116 | } | 116 | } |
117 | 117 | ||
118 | static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) | 118 | static const struct ide_port_ops hpt34x_port_ops = { |
119 | { | 119 | .set_pio_mode = hpt34x_set_pio_mode, |
120 | hwif->set_pio_mode = &hpt34x_set_pio_mode; | 120 | .set_dma_mode = hpt34x_set_mode, |
121 | hwif->set_dma_mode = &hpt34x_set_mode; | 121 | }; |
122 | } | ||
123 | 122 | ||
124 | #define IDE_HFLAGS_HPT34X \ | 123 | #define IDE_HFLAGS_HPT34X \ |
125 | (IDE_HFLAG_NO_ATAPI_DMA | \ | 124 | (IDE_HFLAG_NO_ATAPI_DMA | \ |
@@ -131,16 +130,14 @@ static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { | |||
131 | { /* 0 */ | 130 | { /* 0 */ |
132 | .name = "HPT343", | 131 | .name = "HPT343", |
133 | .init_chipset = init_chipset_hpt34x, | 132 | .init_chipset = init_chipset_hpt34x, |
134 | .init_hwif = init_hwif_hpt34x, | 133 | .port_ops = &hpt34x_port_ops, |
135 | .extra = 16, | 134 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, |
136 | .host_flags = IDE_HFLAGS_HPT34X, | ||
137 | .pio_mask = ATA_PIO5, | 135 | .pio_mask = ATA_PIO5, |
138 | }, | 136 | }, |
139 | { /* 1 */ | 137 | { /* 1 */ |
140 | .name = "HPT345", | 138 | .name = "HPT345", |
141 | .init_chipset = init_chipset_hpt34x, | 139 | .init_chipset = init_chipset_hpt34x, |
142 | .init_hwif = init_hwif_hpt34x, | 140 | .port_ops = &hpt34x_port_ops, |
143 | .extra = 16, | ||
144 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, | 141 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, |
145 | .pio_mask = ATA_PIO5, | 142 | .pio_mask = ATA_PIO5, |
146 | #ifdef CONFIG_HPT34X_AUTODMA | 143 | #ifdef CONFIG_HPT34X_AUTODMA |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 82d0e318a1fe..c929dadaaaff 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -760,7 +760,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | |||
760 | } | 760 | } |
761 | } else | 761 | } else |
762 | outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), | 762 | outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), |
763 | hwif->io_ports[IDE_CONTROL_OFFSET]); | 763 | hwif->io_ports.ctl_addr); |
764 | } | 764 | } |
765 | 765 | ||
766 | /* | 766 | /* |
@@ -776,7 +776,7 @@ static void hpt366_dma_lost_irq(ide_drive_t *drive) | |||
776 | pci_read_config_byte(dev, 0x52, &mcr3); | 776 | pci_read_config_byte(dev, 0x52, &mcr3); |
777 | pci_read_config_byte(dev, 0x5a, &scr1); | 777 | pci_read_config_byte(dev, 0x5a, &scr1); |
778 | printk("%s: (%s) mcr1=0x%02x, mcr3=0x%02x, scr1=0x%02x\n", | 778 | printk("%s: (%s) mcr1=0x%02x, mcr3=0x%02x, scr1=0x%02x\n", |
779 | drive->name, __FUNCTION__, mcr1, mcr3, scr1); | 779 | drive->name, __func__, mcr1, mcr3, scr1); |
780 | if (scr1 & 0x10) | 780 | if (scr1 & 0x10) |
781 | pci_write_config_byte(dev, 0x5a, scr1 & ~0x10); | 781 | pci_write_config_byte(dev, 0x5a, scr1 & ~0x10); |
782 | ide_dma_lost_irq(drive); | 782 | ide_dma_lost_irq(drive); |
@@ -808,7 +808,7 @@ static void hpt370_irq_timeout(ide_drive_t *drive) | |||
808 | hpt370_clear_engine(drive); | 808 | hpt370_clear_engine(drive); |
809 | } | 809 | } |
810 | 810 | ||
811 | static void hpt370_ide_dma_start(ide_drive_t *drive) | 811 | static void hpt370_dma_start(ide_drive_t *drive) |
812 | { | 812 | { |
813 | #ifdef HPT_RESET_STATE_ENGINE | 813 | #ifdef HPT_RESET_STATE_ENGINE |
814 | hpt370_clear_engine(drive); | 814 | hpt370_clear_engine(drive); |
@@ -816,7 +816,7 @@ static void hpt370_ide_dma_start(ide_drive_t *drive) | |||
816 | ide_dma_start(drive); | 816 | ide_dma_start(drive); |
817 | } | 817 | } |
818 | 818 | ||
819 | static int hpt370_ide_dma_end(ide_drive_t *drive) | 819 | static int hpt370_dma_end(ide_drive_t *drive) |
820 | { | 820 | { |
821 | ide_hwif_t *hwif = HWIF(drive); | 821 | ide_hwif_t *hwif = HWIF(drive); |
822 | u8 dma_stat = inb(hwif->dma_status); | 822 | u8 dma_stat = inb(hwif->dma_status); |
@@ -838,7 +838,7 @@ static void hpt370_dma_timeout(ide_drive_t *drive) | |||
838 | } | 838 | } |
839 | 839 | ||
840 | /* returns 1 if DMA IRQ issued, 0 otherwise */ | 840 | /* returns 1 if DMA IRQ issued, 0 otherwise */ |
841 | static int hpt374_ide_dma_test_irq(ide_drive_t *drive) | 841 | static int hpt374_dma_test_irq(ide_drive_t *drive) |
842 | { | 842 | { |
843 | ide_hwif_t *hwif = HWIF(drive); | 843 | ide_hwif_t *hwif = HWIF(drive); |
844 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 844 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -858,11 +858,11 @@ static int hpt374_ide_dma_test_irq(ide_drive_t *drive) | |||
858 | 858 | ||
859 | if (!drive->waiting_for_dma) | 859 | if (!drive->waiting_for_dma) |
860 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", | 860 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", |
861 | drive->name, __FUNCTION__); | 861 | drive->name, __func__); |
862 | return 0; | 862 | return 0; |
863 | } | 863 | } |
864 | 864 | ||
865 | static int hpt374_ide_dma_end(ide_drive_t *drive) | 865 | static int hpt374_dma_end(ide_drive_t *drive) |
866 | { | 866 | { |
867 | ide_hwif_t *hwif = HWIF(drive); | 867 | ide_hwif_t *hwif = HWIF(drive); |
868 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 868 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -1271,17 +1271,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1271 | /* Cache the channel's MISC. control registers' offset */ | 1271 | /* Cache the channel's MISC. control registers' offset */ |
1272 | hwif->select_data = hwif->channel ? 0x54 : 0x50; | 1272 | hwif->select_data = hwif->channel ? 0x54 : 0x50; |
1273 | 1273 | ||
1274 | hwif->set_pio_mode = &hpt3xx_set_pio_mode; | ||
1275 | hwif->set_dma_mode = &hpt3xx_set_mode; | ||
1276 | |||
1277 | hwif->quirkproc = &hpt3xx_quirkproc; | ||
1278 | hwif->maskproc = &hpt3xx_maskproc; | ||
1279 | |||
1280 | hwif->udma_filter = &hpt3xx_udma_filter; | ||
1281 | hwif->mdma_filter = &hpt3xx_mdma_filter; | ||
1282 | |||
1283 | hwif->cable_detect = hpt3xx_cable_detect; | ||
1284 | |||
1285 | /* | 1274 | /* |
1286 | * HPT3xxN chips have some complications: | 1275 | * HPT3xxN chips have some complications: |
1287 | * | 1276 | * |
@@ -1323,29 +1312,19 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1323 | 1312 | ||
1324 | if (new_mcr != old_mcr) | 1313 | if (new_mcr != old_mcr) |
1325 | pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); | 1314 | pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); |
1326 | |||
1327 | if (hwif->dma_base == 0) | ||
1328 | return; | ||
1329 | |||
1330 | if (chip_type >= HPT374) { | ||
1331 | hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; | ||
1332 | hwif->ide_dma_end = &hpt374_ide_dma_end; | ||
1333 | } else if (chip_type >= HPT370) { | ||
1334 | hwif->dma_start = &hpt370_ide_dma_start; | ||
1335 | hwif->ide_dma_end = &hpt370_ide_dma_end; | ||
1336 | hwif->dma_timeout = &hpt370_dma_timeout; | ||
1337 | } else | ||
1338 | hwif->dma_lost_irq = &hpt366_dma_lost_irq; | ||
1339 | } | 1315 | } |
1340 | 1316 | ||
1341 | static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | 1317 | static int __devinit init_dma_hpt366(ide_hwif_t *hwif, |
1318 | const struct ide_port_info *d) | ||
1342 | { | 1319 | { |
1343 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1320 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1344 | u8 masterdma = 0, slavedma = 0; | 1321 | unsigned long flags, base = ide_pci_dma_base(hwif, d); |
1345 | u8 dma_new = 0, dma_old = 0; | 1322 | u8 dma_old, dma_new, masterdma = 0, slavedma = 0; |
1346 | unsigned long flags; | ||
1347 | 1323 | ||
1348 | dma_old = inb(dmabase + 2); | 1324 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
1325 | return -1; | ||
1326 | |||
1327 | dma_old = inb(base + 2); | ||
1349 | 1328 | ||
1350 | local_irq_save(flags); | 1329 | local_irq_save(flags); |
1351 | 1330 | ||
@@ -1356,11 +1335,21 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | |||
1356 | if (masterdma & 0x30) dma_new |= 0x20; | 1335 | if (masterdma & 0x30) dma_new |= 0x20; |
1357 | if ( slavedma & 0x30) dma_new |= 0x40; | 1336 | if ( slavedma & 0x30) dma_new |= 0x40; |
1358 | if (dma_new != dma_old) | 1337 | if (dma_new != dma_old) |
1359 | outb(dma_new, dmabase + 2); | 1338 | outb(dma_new, base + 2); |
1360 | 1339 | ||
1361 | local_irq_restore(flags); | 1340 | local_irq_restore(flags); |
1362 | 1341 | ||
1363 | ide_setup_dma(hwif, dmabase); | 1342 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
1343 | hwif->name, base, base + 7); | ||
1344 | |||
1345 | hwif->extra_base = base + (hwif->channel ? 8 : 16); | ||
1346 | |||
1347 | if (ide_allocate_dma_engine(hwif)) | ||
1348 | return -1; | ||
1349 | |||
1350 | ide_setup_dma(hwif, base); | ||
1351 | |||
1352 | return 0; | ||
1364 | } | 1353 | } |
1365 | 1354 | ||
1366 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) | 1355 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) |
@@ -1416,6 +1405,49 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1416 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 1405 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
1417 | IDE_HFLAG_OFF_BOARD) | 1406 | IDE_HFLAG_OFF_BOARD) |
1418 | 1407 | ||
1408 | static const struct ide_port_ops hpt3xx_port_ops = { | ||
1409 | .set_pio_mode = hpt3xx_set_pio_mode, | ||
1410 | .set_dma_mode = hpt3xx_set_mode, | ||
1411 | .quirkproc = hpt3xx_quirkproc, | ||
1412 | .maskproc = hpt3xx_maskproc, | ||
1413 | .mdma_filter = hpt3xx_mdma_filter, | ||
1414 | .udma_filter = hpt3xx_udma_filter, | ||
1415 | .cable_detect = hpt3xx_cable_detect, | ||
1416 | }; | ||
1417 | |||
1418 | static const struct ide_dma_ops hpt37x_dma_ops = { | ||
1419 | .dma_host_set = ide_dma_host_set, | ||
1420 | .dma_setup = ide_dma_setup, | ||
1421 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
1422 | .dma_start = ide_dma_start, | ||
1423 | .dma_end = hpt374_dma_end, | ||
1424 | .dma_test_irq = hpt374_dma_test_irq, | ||
1425 | .dma_lost_irq = ide_dma_lost_irq, | ||
1426 | .dma_timeout = ide_dma_timeout, | ||
1427 | }; | ||
1428 | |||
1429 | static const struct ide_dma_ops hpt370_dma_ops = { | ||
1430 | .dma_host_set = ide_dma_host_set, | ||
1431 | .dma_setup = ide_dma_setup, | ||
1432 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
1433 | .dma_start = hpt370_dma_start, | ||
1434 | .dma_end = hpt370_dma_end, | ||
1435 | .dma_test_irq = ide_dma_test_irq, | ||
1436 | .dma_lost_irq = ide_dma_lost_irq, | ||
1437 | .dma_timeout = hpt370_dma_timeout, | ||
1438 | }; | ||
1439 | |||
1440 | static const struct ide_dma_ops hpt36x_dma_ops = { | ||
1441 | .dma_host_set = ide_dma_host_set, | ||
1442 | .dma_setup = ide_dma_setup, | ||
1443 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
1444 | .dma_start = ide_dma_start, | ||
1445 | .dma_end = __ide_dma_end, | ||
1446 | .dma_test_irq = ide_dma_test_irq, | ||
1447 | .dma_lost_irq = hpt366_dma_lost_irq, | ||
1448 | .dma_timeout = ide_dma_timeout, | ||
1449 | }; | ||
1450 | |||
1419 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | 1451 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { |
1420 | { /* 0 */ | 1452 | { /* 0 */ |
1421 | .name = "HPT36x", | 1453 | .name = "HPT36x", |
@@ -1429,7 +1461,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1429 | * Bit 4 is for the primary channel, bit 5 for the secondary. | 1461 | * Bit 4 is for the primary channel, bit 5 for the secondary. |
1430 | */ | 1462 | */ |
1431 | .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, | 1463 | .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, |
1432 | .extra = 240, | 1464 | .port_ops = &hpt3xx_port_ops, |
1465 | .dma_ops = &hpt36x_dma_ops, | ||
1433 | .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, | 1466 | .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, |
1434 | .pio_mask = ATA_PIO4, | 1467 | .pio_mask = ATA_PIO4, |
1435 | .mwdma_mask = ATA_MWDMA2, | 1468 | .mwdma_mask = ATA_MWDMA2, |
@@ -1439,7 +1472,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1439 | .init_hwif = init_hwif_hpt366, | 1472 | .init_hwif = init_hwif_hpt366, |
1440 | .init_dma = init_dma_hpt366, | 1473 | .init_dma = init_dma_hpt366, |
1441 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1474 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1442 | .extra = 240, | 1475 | .port_ops = &hpt3xx_port_ops, |
1476 | .dma_ops = &hpt37x_dma_ops, | ||
1443 | .host_flags = IDE_HFLAGS_HPT3XX, | 1477 | .host_flags = IDE_HFLAGS_HPT3XX, |
1444 | .pio_mask = ATA_PIO4, | 1478 | .pio_mask = ATA_PIO4, |
1445 | .mwdma_mask = ATA_MWDMA2, | 1479 | .mwdma_mask = ATA_MWDMA2, |
@@ -1449,7 +1483,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1449 | .init_hwif = init_hwif_hpt366, | 1483 | .init_hwif = init_hwif_hpt366, |
1450 | .init_dma = init_dma_hpt366, | 1484 | .init_dma = init_dma_hpt366, |
1451 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1485 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1452 | .extra = 240, | 1486 | .port_ops = &hpt3xx_port_ops, |
1487 | .dma_ops = &hpt37x_dma_ops, | ||
1453 | .host_flags = IDE_HFLAGS_HPT3XX, | 1488 | .host_flags = IDE_HFLAGS_HPT3XX, |
1454 | .pio_mask = ATA_PIO4, | 1489 | .pio_mask = ATA_PIO4, |
1455 | .mwdma_mask = ATA_MWDMA2, | 1490 | .mwdma_mask = ATA_MWDMA2, |
@@ -1459,7 +1494,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1459 | .init_hwif = init_hwif_hpt366, | 1494 | .init_hwif = init_hwif_hpt366, |
1460 | .init_dma = init_dma_hpt366, | 1495 | .init_dma = init_dma_hpt366, |
1461 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1496 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1462 | .extra = 240, | 1497 | .port_ops = &hpt3xx_port_ops, |
1498 | .dma_ops = &hpt37x_dma_ops, | ||
1463 | .host_flags = IDE_HFLAGS_HPT3XX, | 1499 | .host_flags = IDE_HFLAGS_HPT3XX, |
1464 | .pio_mask = ATA_PIO4, | 1500 | .pio_mask = ATA_PIO4, |
1465 | .mwdma_mask = ATA_MWDMA2, | 1501 | .mwdma_mask = ATA_MWDMA2, |
@@ -1470,7 +1506,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1470 | .init_dma = init_dma_hpt366, | 1506 | .init_dma = init_dma_hpt366, |
1471 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1507 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1472 | .udma_mask = ATA_UDMA5, | 1508 | .udma_mask = ATA_UDMA5, |
1473 | .extra = 240, | 1509 | .port_ops = &hpt3xx_port_ops, |
1510 | .dma_ops = &hpt37x_dma_ops, | ||
1474 | .host_flags = IDE_HFLAGS_HPT3XX, | 1511 | .host_flags = IDE_HFLAGS_HPT3XX, |
1475 | .pio_mask = ATA_PIO4, | 1512 | .pio_mask = ATA_PIO4, |
1476 | .mwdma_mask = ATA_MWDMA2, | 1513 | .mwdma_mask = ATA_MWDMA2, |
@@ -1480,7 +1517,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1480 | .init_hwif = init_hwif_hpt366, | 1517 | .init_hwif = init_hwif_hpt366, |
1481 | .init_dma = init_dma_hpt366, | 1518 | .init_dma = init_dma_hpt366, |
1482 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1519 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1483 | .extra = 240, | 1520 | .port_ops = &hpt3xx_port_ops, |
1521 | .dma_ops = &hpt37x_dma_ops, | ||
1484 | .host_flags = IDE_HFLAGS_HPT3XX, | 1522 | .host_flags = IDE_HFLAGS_HPT3XX, |
1485 | .pio_mask = ATA_PIO4, | 1523 | .pio_mask = ATA_PIO4, |
1486 | .mwdma_mask = ATA_MWDMA2, | 1524 | .mwdma_mask = ATA_MWDMA2, |
@@ -1543,6 +1581,10 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1543 | d.name = info->chip_name; | 1581 | d.name = info->chip_name; |
1544 | d.udma_mask = info->udma_mask; | 1582 | d.udma_mask = info->udma_mask; |
1545 | 1583 | ||
1584 | /* fixup ->dma_ops for HPT370/HPT370A */ | ||
1585 | if (info == &hpt370 || info == &hpt370a) | ||
1586 | d.dma_ops = &hpt370_dma_ops; | ||
1587 | |||
1546 | pci_set_drvdata(dev, (void *)info); | 1588 | pci_set_drvdata(dev, (void *)info); |
1547 | 1589 | ||
1548 | if (info == &hpt36x || info == &hpt374) | 1590 | if (info == &hpt36x || info == &hpt374) |
@@ -1557,7 +1599,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1557 | hpt374_init(dev, dev2); | 1599 | hpt374_init(dev, dev2); |
1558 | else { | 1600 | else { |
1559 | if (hpt36x_init(dev, dev2)) | 1601 | if (hpt36x_init(dev, dev2)) |
1560 | d.host_flags |= IDE_HFLAG_BOOTABLE; | 1602 | d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE; |
1561 | } | 1603 | } |
1562 | 1604 | ||
1563 | ret = ide_setup_pci_devices(dev, dev2, &d); | 1605 | ret = ide_setup_pci_devices(dev, dev2, &d); |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index e3427eaab430..9053c8771e6e 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -35,7 +35,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
35 | static DEFINE_SPINLOCK(tune_lock); | 35 | static DEFINE_SPINLOCK(tune_lock); |
36 | int control = 0; | 36 | int control = 0; |
37 | 37 | ||
38 | static const u8 timings[][2]= { | 38 | static const u8 timings[][2] = { |
39 | { 0, 0 }, | 39 | { 0, 0 }, |
40 | { 0, 0 }, | 40 | { 0, 0 }, |
41 | { 1, 0 }, | 41 | { 1, 0 }, |
@@ -105,11 +105,10 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
105 | 105 | ||
106 | if (!(reg48 & u_flag)) | 106 | if (!(reg48 & u_flag)) |
107 | pci_write_config_byte(dev, 0x48, reg48 | u_flag); | 107 | pci_write_config_byte(dev, 0x48, reg48 | u_flag); |
108 | if (speed >= XFER_UDMA_5) { | 108 | if (speed >= XFER_UDMA_5) |
109 | pci_write_config_byte(dev, 0x55, (u8) reg55|w_flag); | 109 | pci_write_config_byte(dev, 0x55, (u8) reg55|w_flag); |
110 | } else { | 110 | else |
111 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); | 111 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); |
112 | } | ||
113 | 112 | ||
114 | if ((reg4a & a_speed) != u_speed) | 113 | if ((reg4a & a_speed) != u_speed) |
115 | pci_write_config_word(dev, 0x4a, (reg4a & ~a_speed) | u_speed); | 114 | pci_write_config_word(dev, 0x4a, (reg4a & ~a_speed) | u_speed); |
@@ -150,29 +149,18 @@ static u8 __devinit it8213_cable_detect(ide_hwif_t *hwif) | |||
150 | return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 149 | return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
151 | } | 150 | } |
152 | 151 | ||
153 | /** | 152 | static const struct ide_port_ops it8213_port_ops = { |
154 | * init_hwif_it8213 - set up hwif structs | 153 | .set_pio_mode = it8213_set_pio_mode, |
155 | * @hwif: interface to set up | 154 | .set_dma_mode = it8213_set_dma_mode, |
156 | * | 155 | .cable_detect = it8213_cable_detect, |
157 | * We do the basic set up of the interface structure. | 156 | }; |
158 | */ | ||
159 | |||
160 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | ||
161 | { | ||
162 | hwif->set_dma_mode = &it8213_set_dma_mode; | ||
163 | hwif->set_pio_mode = &it8213_set_pio_mode; | ||
164 | |||
165 | hwif->cable_detect = it8213_cable_detect; | ||
166 | } | ||
167 | |||
168 | 157 | ||
169 | #define DECLARE_ITE_DEV(name_str) \ | 158 | #define DECLARE_ITE_DEV(name_str) \ |
170 | { \ | 159 | { \ |
171 | .name = name_str, \ | 160 | .name = name_str, \ |
172 | .init_hwif = init_hwif_it8213, \ | 161 | .enablebits = { {0x41, 0x80, 0x80} }, \ |
173 | .enablebits = {{0x41,0x80,0x80}}, \ | 162 | .port_ops = &it8213_port_ops, \ |
174 | .host_flags = IDE_HFLAG_SINGLE | \ | 163 | .host_flags = IDE_HFLAG_SINGLE, \ |
175 | IDE_HFLAG_BOOTABLE, \ | ||
176 | .pio_mask = ATA_PIO4, \ | 164 | .pio_mask = ATA_PIO4, \ |
177 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 165 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
178 | .mwdma_mask = ATA_MWDMA12_ONLY, \ | 166 | .mwdma_mask = ATA_MWDMA12_ONLY, \ |
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index d8a167451fd6..6ab04115286b 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -418,7 +418,7 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * ata66_it821x - check for 80 pin cable | 421 | * it821x_cable_detect - cable detection |
422 | * @hwif: interface to check | 422 | * @hwif: interface to check |
423 | * | 423 | * |
424 | * Check for the presence of an ATA66 capable cable on the | 424 | * Check for the presence of an ATA66 capable cable on the |
@@ -426,7 +426,7 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
426 | * the needed logic onboard. | 426 | * the needed logic onboard. |
427 | */ | 427 | */ |
428 | 428 | ||
429 | static u8 __devinit ata66_it821x(ide_hwif_t *hwif) | 429 | static u8 __devinit it821x_cable_detect(ide_hwif_t *hwif) |
430 | { | 430 | { |
431 | /* The reference driver also only does disk side */ | 431 | /* The reference driver also only does disk side */ |
432 | return ATA_CBL_PATA80; | 432 | return ATA_CBL_PATA80; |
@@ -511,6 +511,11 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive) | |||
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | static struct ide_dma_ops it821x_pass_through_dma_ops = { | ||
515 | .dma_start = it821x_dma_start, | ||
516 | .dma_end = it821x_dma_end, | ||
517 | }; | ||
518 | |||
514 | /** | 519 | /** |
515 | * init_hwif_it821x - set up hwif structs | 520 | * init_hwif_it821x - set up hwif structs |
516 | * @hwif: interface to set up | 521 | * @hwif: interface to set up |
@@ -523,16 +528,10 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive) | |||
523 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 528 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
524 | { | 529 | { |
525 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 530 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
526 | struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); | 531 | struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); |
532 | struct it821x_dev *idev = itdevs[hwif->channel]; | ||
527 | u8 conf; | 533 | u8 conf; |
528 | 534 | ||
529 | hwif->quirkproc = &it821x_quirkproc; | ||
530 | |||
531 | if (idev == NULL) { | ||
532 | printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | ide_set_hwifdata(hwif, idev); | 535 | ide_set_hwifdata(hwif, idev); |
537 | 536 | ||
538 | pci_read_config_byte(dev, 0x50, &conf); | 537 | pci_read_config_byte(dev, 0x50, &conf); |
@@ -567,17 +566,11 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
567 | } | 566 | } |
568 | 567 | ||
569 | if (idev->smart == 0) { | 568 | if (idev->smart == 0) { |
570 | hwif->set_pio_mode = &it821x_set_pio_mode; | ||
571 | hwif->set_dma_mode = &it821x_set_dma_mode; | ||
572 | |||
573 | /* MWDMA/PIO clock switching for pass through mode */ | 569 | /* MWDMA/PIO clock switching for pass through mode */ |
574 | hwif->dma_start = &it821x_dma_start; | 570 | hwif->dma_ops = &it821x_pass_through_dma_ops; |
575 | hwif->ide_dma_end = &it821x_dma_end; | ||
576 | } else | 571 | } else |
577 | hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; | 572 | hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; |
578 | 573 | ||
579 | hwif->cable_detect = ata66_it821x; | ||
580 | |||
581 | if (hwif->dma_base == 0) | 574 | if (hwif->dma_base == 0) |
582 | return; | 575 | return; |
583 | 576 | ||
@@ -617,13 +610,20 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha | |||
617 | return 0; | 610 | return 0; |
618 | } | 611 | } |
619 | 612 | ||
613 | static const struct ide_port_ops it821x_port_ops = { | ||
614 | /* it821x_set_{pio,dma}_mode() are only used in pass-through mode */ | ||
615 | .set_pio_mode = it821x_set_pio_mode, | ||
616 | .set_dma_mode = it821x_set_dma_mode, | ||
617 | .quirkproc = it821x_quirkproc, | ||
618 | .cable_detect = it821x_cable_detect, | ||
619 | }; | ||
620 | 620 | ||
621 | #define DECLARE_ITE_DEV(name_str) \ | 621 | #define DECLARE_ITE_DEV(name_str) \ |
622 | { \ | 622 | { \ |
623 | .name = name_str, \ | 623 | .name = name_str, \ |
624 | .init_chipset = init_chipset_it821x, \ | 624 | .init_chipset = init_chipset_it821x, \ |
625 | .init_hwif = init_hwif_it821x, \ | 625 | .init_hwif = init_hwif_it821x, \ |
626 | .host_flags = IDE_HFLAG_BOOTABLE, \ | 626 | .port_ops = &it821x_port_ops, \ |
627 | .pio_mask = ATA_PIO4, \ | 627 | .pio_mask = ATA_PIO4, \ |
628 | } | 628 | } |
629 | 629 | ||
@@ -642,6 +642,22 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = { | |||
642 | 642 | ||
643 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 643 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
644 | { | 644 | { |
645 | struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev; | ||
646 | unsigned int i; | ||
647 | |||
648 | for (i = 0; i < 2; i++) { | ||
649 | itdev = kzalloc(sizeof(*itdev), GFP_KERNEL); | ||
650 | if (itdev == NULL) { | ||
651 | kfree(itdevs[0]); | ||
652 | printk(KERN_ERR "it821x: out of memory\n"); | ||
653 | return -ENOMEM; | ||
654 | } | ||
655 | |||
656 | itdevs[i] = itdev; | ||
657 | } | ||
658 | |||
659 | pci_set_drvdata(dev, itdevs); | ||
660 | |||
645 | return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); | 661 | return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); |
646 | } | 662 | } |
647 | 663 | ||
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index a56bcb4f22f4..96ef7394f283 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
@@ -19,13 +19,13 @@ typedef enum { | |||
19 | } port_type; | 19 | } port_type; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * ata66_jmicron - Cable check | 22 | * jmicron_cable_detect - cable detection |
23 | * @hwif: IDE port | 23 | * @hwif: IDE port |
24 | * | 24 | * |
25 | * Returns the cable type. | 25 | * Returns the cable type. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) | 28 | static u8 __devinit jmicron_cable_detect(ide_hwif_t *hwif) |
29 | { | 29 | { |
30 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 30 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
31 | 31 | ||
@@ -63,8 +63,7 @@ static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) | |||
63 | * actually do our cable checking etc. Thankfully we don't need | 63 | * actually do our cable checking etc. Thankfully we don't need |
64 | * to do the plumbing for other cases. | 64 | * to do the plumbing for other cases. |
65 | */ | 65 | */ |
66 | switch (port_map[port]) | 66 | switch (port_map[port]) { |
67 | { | ||
68 | case PORT_PATA0: | 67 | case PORT_PATA0: |
69 | if (control & (1 << 3)) /* 40/80 pin primary */ | 68 | if (control & (1 << 3)) /* 40/80 pin primary */ |
70 | return ATA_CBL_PATA40; | 69 | return ATA_CBL_PATA40; |
@@ -96,26 +95,16 @@ static void jmicron_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
96 | { | 95 | { |
97 | } | 96 | } |
98 | 97 | ||
99 | /** | 98 | static const struct ide_port_ops jmicron_port_ops = { |
100 | * init_hwif_jmicron - set up hwif structs | 99 | .set_pio_mode = jmicron_set_pio_mode, |
101 | * @hwif: interface to set up | 100 | .set_dma_mode = jmicron_set_dma_mode, |
102 | * | 101 | .cable_detect = jmicron_cable_detect, |
103 | * Minimal set up is required for the Jmicron hardware. | 102 | }; |
104 | */ | ||
105 | |||
106 | static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) | ||
107 | { | ||
108 | hwif->set_pio_mode = &jmicron_set_pio_mode; | ||
109 | hwif->set_dma_mode = &jmicron_set_dma_mode; | ||
110 | |||
111 | hwif->cable_detect = ata66_jmicron; | ||
112 | } | ||
113 | 103 | ||
114 | static const struct ide_port_info jmicron_chipset __devinitdata = { | 104 | static const struct ide_port_info jmicron_chipset __devinitdata = { |
115 | .name = "JMB", | 105 | .name = "JMB", |
116 | .init_hwif = init_hwif_jmicron, | ||
117 | .host_flags = IDE_HFLAG_BOOTABLE, | ||
118 | .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, | 106 | .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, |
107 | .port_ops = &jmicron_port_ops, | ||
119 | .pio_mask = ATA_PIO5, | 108 | .pio_mask = ATA_PIO5, |
120 | .mwdma_mask = ATA_MWDMA2, | 109 | .mwdma_mask = ATA_MWDMA2, |
121 | .udma_mask = ATA_UDMA6, | 110 | .udma_mask = ATA_UDMA6, |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index 75513320aad9..c13e299077ec 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -72,8 +72,8 @@ static void __devinit superio_ide_init_iops (struct hwif_s *hwif) | |||
72 | base = pci_resource_start(pdev, port * 2) & ~3; | 72 | base = pci_resource_start(pdev, port * 2) & ~3; |
73 | dmabase = pci_resource_start(pdev, 4) & ~3; | 73 | dmabase = pci_resource_start(pdev, 4) & ~3; |
74 | 74 | ||
75 | superio_ide_status[port] = base + IDE_STATUS_OFFSET; | 75 | superio_ide_status[port] = base + 7; |
76 | superio_ide_select[port] = base + IDE_SELECT_OFFSET; | 76 | superio_ide_select[port] = base + 6; |
77 | superio_ide_dma_status[port] = dmabase + (!port ? 2 : 0xa); | 77 | superio_ide_dma_status[port] = dmabase + (!port ? 2 : 0xa); |
78 | 78 | ||
79 | /* Clear error/interrupt, enable dma */ | 79 | /* Clear error/interrupt, enable dma */ |
@@ -150,7 +150,7 @@ static void ns87415_selectproc (ide_drive_t *drive) | |||
150 | ns87415_prepare_drive (drive, drive->using_dma); | 150 | ns87415_prepare_drive (drive, drive->using_dma); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int ns87415_ide_dma_end (ide_drive_t *drive) | 153 | static int ns87415_dma_end(ide_drive_t *drive) |
154 | { | 154 | { |
155 | ide_hwif_t *hwif = HWIF(drive); | 155 | ide_hwif_t *hwif = HWIF(drive); |
156 | u8 dma_stat = 0, dma_cmd = 0; | 156 | u8 dma_stat = 0, dma_cmd = 0; |
@@ -170,7 +170,7 @@ static int ns87415_ide_dma_end (ide_drive_t *drive) | |||
170 | return (dma_stat & 7) != 4; | 170 | return (dma_stat & 7) != 4; |
171 | } | 171 | } |
172 | 172 | ||
173 | static int ns87415_ide_dma_setup(ide_drive_t *drive) | 173 | static int ns87415_dma_setup(ide_drive_t *drive) |
174 | { | 174 | { |
175 | /* select DMA xfer */ | 175 | /* select DMA xfer */ |
176 | ns87415_prepare_drive(drive, 1); | 176 | ns87415_prepare_drive(drive, 1); |
@@ -195,8 +195,6 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
195 | u8 stat; | 195 | u8 stat; |
196 | #endif | 196 | #endif |
197 | 197 | ||
198 | hwif->selectproc = &ns87415_selectproc; | ||
199 | |||
200 | /* | 198 | /* |
201 | * We cannot probe for IRQ: both ports share common IRQ on INTA. | 199 | * We cannot probe for IRQ: both ports share common IRQ on INTA. |
202 | * Also, leave IRQ masked during drive probing, to prevent infinite | 200 | * Also, leave IRQ masked during drive probing, to prevent infinite |
@@ -233,12 +231,12 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
233 | * SELECT_DRIVE() properly during first ide_probe_port(). | 231 | * SELECT_DRIVE() properly during first ide_probe_port(). |
234 | */ | 232 | */ |
235 | timeout = 10000; | 233 | timeout = 10000; |
236 | outb(12, hwif->io_ports[IDE_CONTROL_OFFSET]); | 234 | outb(12, hwif->io_ports.ctl_addr); |
237 | udelay(10); | 235 | udelay(10); |
238 | outb(8, hwif->io_ports[IDE_CONTROL_OFFSET]); | 236 | outb(8, hwif->io_ports.ctl_addr); |
239 | do { | 237 | do { |
240 | udelay(50); | 238 | udelay(50); |
241 | stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 239 | stat = hwif->INB(hwif->io_ports.status_addr); |
242 | if (stat == 0xff) | 240 | if (stat == 0xff) |
243 | break; | 241 | break; |
244 | } while ((stat & BUSY_STAT) && --timeout); | 242 | } while ((stat & BUSY_STAT) && --timeout); |
@@ -246,7 +244,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
246 | } | 244 | } |
247 | 245 | ||
248 | if (!using_inta) | 246 | if (!using_inta) |
249 | hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]); | 247 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); |
250 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | 248 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) |
251 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ | 249 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ |
252 | 250 | ||
@@ -254,19 +252,33 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
254 | return; | 252 | return; |
255 | 253 | ||
256 | outb(0x60, hwif->dma_status); | 254 | outb(0x60, hwif->dma_status); |
257 | hwif->dma_setup = &ns87415_ide_dma_setup; | ||
258 | hwif->ide_dma_end = &ns87415_ide_dma_end; | ||
259 | } | 255 | } |
260 | 256 | ||
257 | static const struct ide_port_ops ns87415_port_ops = { | ||
258 | .selectproc = ns87415_selectproc, | ||
259 | }; | ||
260 | |||
261 | static const struct ide_dma_ops ns87415_dma_ops = { | ||
262 | .dma_host_set = ide_dma_host_set, | ||
263 | .dma_setup = ns87415_dma_setup, | ||
264 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
265 | .dma_start = ide_dma_start, | ||
266 | .dma_end = ns87415_dma_end, | ||
267 | .dma_test_irq = ide_dma_test_irq, | ||
268 | .dma_lost_irq = ide_dma_lost_irq, | ||
269 | .dma_timeout = ide_dma_timeout, | ||
270 | }; | ||
271 | |||
261 | static const struct ide_port_info ns87415_chipset __devinitdata = { | 272 | static const struct ide_port_info ns87415_chipset __devinitdata = { |
262 | .name = "NS87415", | 273 | .name = "NS87415", |
263 | #ifdef CONFIG_SUPERIO | 274 | #ifdef CONFIG_SUPERIO |
264 | .init_iops = init_iops_ns87415, | 275 | .init_iops = init_iops_ns87415, |
265 | #endif | 276 | #endif |
266 | .init_hwif = init_hwif_ns87415, | 277 | .init_hwif = init_hwif_ns87415, |
278 | .port_ops = &ns87415_port_ops, | ||
279 | .dma_ops = &ns87415_dma_ops, | ||
267 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 280 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
268 | IDE_HFLAG_NO_ATAPI_DMA | | 281 | IDE_HFLAG_NO_ATAPI_DMA, |
269 | IDE_HFLAG_BOOTABLE, | ||
270 | }; | 282 | }; |
271 | 283 | ||
272 | static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 284 | static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 46e8748f507e..6e99080497bf 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -53,13 +53,12 @@ | |||
53 | * If you then set the second drive to another PIO, the old value | 53 | * If you then set the second drive to another PIO, the old value |
54 | * (automatically selected) will be overrided by yours. | 54 | * (automatically selected) will be overrided by yours. |
55 | * There is a 25/33MHz switch in configuration | 55 | * There is a 25/33MHz switch in configuration |
56 | * register, but driver is written for use at any frequency which get | 56 | * register, but driver is written for use at any frequency. |
57 | * (use idebus=xx to select PCI bus speed). | ||
58 | * | 57 | * |
59 | * Version 0.1, Nov 8, 1996 | 58 | * Version 0.1, Nov 8, 1996 |
60 | * by Jaromir Koutek, for 2.1.8. | 59 | * by Jaromir Koutek, for 2.1.8. |
61 | * Initial version of driver. | 60 | * Initial version of driver. |
62 | * | 61 | * |
63 | * Version 0.2 | 62 | * Version 0.2 |
64 | * Number 0.2 skipped. | 63 | * Number 0.2 skipped. |
65 | * | 64 | * |
@@ -75,7 +74,7 @@ | |||
75 | * by Jaromir Koutek | 74 | * by Jaromir Koutek |
76 | * Updates for use with (again) new IDE block driver. | 75 | * Updates for use with (again) new IDE block driver. |
77 | * Update of documentation. | 76 | * Update of documentation. |
78 | * | 77 | * |
79 | * Version 0.6, Jan 2, 1999 | 78 | * Version 0.6, Jan 2, 1999 |
80 | * by Jaromir Koutek | 79 | * by Jaromir Koutek |
81 | * Reversed to version 0.3 of the driver, because | 80 | * Reversed to version 0.3 of the driver, because |
@@ -208,29 +207,34 @@ typedef struct pio_clocks_s { | |||
208 | 207 | ||
209 | static void compute_clocks(int pio, pio_clocks_t *clks) | 208 | static void compute_clocks(int pio, pio_clocks_t *clks) |
210 | { | 209 | { |
211 | if (pio != PIO_NOT_EXIST) { | 210 | if (pio != PIO_NOT_EXIST) { |
212 | int adr_setup, data_pls; | 211 | int adr_setup, data_pls; |
213 | int bus_speed = system_bus_clock(); | 212 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); |
214 | 213 | ||
215 | adr_setup = ide_pio_timings[pio].setup_time; | 214 | adr_setup = ide_pio_timings[pio].setup_time; |
216 | data_pls = ide_pio_timings[pio].active_time; | 215 | data_pls = ide_pio_timings[pio].active_time; |
217 | clks->address_time = cmpt_clk(adr_setup, bus_speed); | 216 | clks->address_time = cmpt_clk(adr_setup, bus_speed); |
218 | clks->data_time = cmpt_clk(data_pls, bus_speed); | 217 | clks->data_time = cmpt_clk(data_pls, bus_speed); |
219 | clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time | 218 | clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time |
220 | - adr_setup-data_pls, bus_speed); | 219 | - adr_setup-data_pls, bus_speed); |
221 | if (clks->address_time<1) clks->address_time = 1; | 220 | if (clks->address_time < 1) |
222 | if (clks->address_time>4) clks->address_time = 4; | 221 | clks->address_time = 1; |
223 | if (clks->data_time<1) clks->data_time = 1; | 222 | if (clks->address_time > 4) |
224 | if (clks->data_time>16) clks->data_time = 16; | 223 | clks->address_time = 4; |
225 | if (clks->recovery_time<2) clks->recovery_time = 2; | 224 | if (clks->data_time < 1) |
226 | if (clks->recovery_time>17) clks->recovery_time = 17; | 225 | clks->data_time = 1; |
226 | if (clks->data_time > 16) | ||
227 | clks->data_time = 16; | ||
228 | if (clks->recovery_time < 2) | ||
229 | clks->recovery_time = 2; | ||
230 | if (clks->recovery_time > 17) | ||
231 | clks->recovery_time = 17; | ||
227 | } else { | 232 | } else { |
228 | clks->address_time = 1; | 233 | clks->address_time = 1; |
229 | clks->data_time = 1; | 234 | clks->data_time = 1; |
230 | clks->recovery_time = 2; | 235 | clks->recovery_time = 2; |
231 | /* minimal values */ | 236 | /* minimal values */ |
232 | } | 237 | } |
233 | |||
234 | } | 238 | } |
235 | 239 | ||
236 | static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | 240 | static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) |
@@ -247,8 +251,8 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
247 | 251 | ||
248 | /* sets drive->drive_data for both drives */ | 252 | /* sets drive->drive_data for both drives */ |
249 | compute_pios(drive, pio); | 253 | compute_pios(drive, pio); |
250 | pio1 = hwif->drives[0].drive_data; | 254 | pio1 = hwif->drives[0].drive_data; |
251 | pio2 = hwif->drives[1].drive_data; | 255 | pio2 = hwif->drives[1].drive_data; |
252 | 256 | ||
253 | compute_clocks(pio1, &first); | 257 | compute_clocks(pio1, &first); |
254 | compute_clocks(pio2, &second); | 258 | compute_clocks(pio2, &second); |
@@ -275,7 +279,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
275 | 279 | ||
276 | spin_lock_irqsave(&opti621_lock, flags); | 280 | spin_lock_irqsave(&opti621_lock, flags); |
277 | 281 | ||
278 | reg_base = hwif->io_ports[IDE_DATA_OFFSET]; | 282 | reg_base = hwif->io_ports.data_addr; |
279 | 283 | ||
280 | /* allow Register-B */ | 284 | /* allow Register-B */ |
281 | outb(0xc0, reg_base + CNTRL_REG); | 285 | outb(0xc0, reg_base + CNTRL_REG); |
@@ -321,31 +325,25 @@ static void __devinit opti621_port_init_devs(ide_hwif_t *hwif) | |||
321 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | 325 | hwif->drives[1].drive_data = PIO_DONT_KNOW; |
322 | } | 326 | } |
323 | 327 | ||
324 | /* | 328 | static const struct ide_port_ops opti621_port_ops = { |
325 | * init_hwif_opti621() is called once for each hwif found at boot. | 329 | .port_init_devs = opti621_port_init_devs, |
326 | */ | 330 | .set_pio_mode = opti621_set_pio_mode, |
327 | static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) | 331 | }; |
328 | { | ||
329 | hwif->port_init_devs = opti621_port_init_devs; | ||
330 | hwif->set_pio_mode = &opti621_set_pio_mode; | ||
331 | } | ||
332 | 332 | ||
333 | static const struct ide_port_info opti621_chipsets[] __devinitdata = { | 333 | static const struct ide_port_info opti621_chipsets[] __devinitdata = { |
334 | { /* 0 */ | 334 | { /* 0 */ |
335 | .name = "OPTI621", | 335 | .name = "OPTI621", |
336 | .init_hwif = init_hwif_opti621, | 336 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, |
337 | .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, | 337 | .port_ops = &opti621_port_ops, |
338 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 338 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, |
339 | IDE_HFLAG_BOOTABLE, | ||
340 | .pio_mask = ATA_PIO3, | 339 | .pio_mask = ATA_PIO3, |
341 | .swdma_mask = ATA_SWDMA2, | 340 | .swdma_mask = ATA_SWDMA2, |
342 | .mwdma_mask = ATA_MWDMA2, | 341 | .mwdma_mask = ATA_MWDMA2, |
343 | },{ /* 1 */ | 342 | }, { /* 1 */ |
344 | .name = "OPTI621X", | 343 | .name = "OPTI621X", |
345 | .init_hwif = init_hwif_opti621, | 344 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, |
346 | .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, | 345 | .port_ops = &opti621_port_ops, |
347 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 346 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, |
348 | IDE_HFLAG_BOOTABLE, | ||
349 | .pio_mask = ATA_PIO3, | 347 | .pio_mask = ATA_PIO3, |
350 | .swdma_mask = ATA_SWDMA2, | 348 | .swdma_mask = ATA_SWDMA2, |
351 | .mwdma_mask = ATA_MWDMA2, | 349 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 1c8cb7797a4a..ec9bd7b352fc 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #undef DEBUG | 34 | #undef DEBUG |
35 | 35 | ||
36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
37 | #define DBG(fmt, args...) printk("%s: " fmt, __FUNCTION__, ## args) | 37 | #define DBG(fmt, args...) printk("%s: " fmt, __func__, ## args) |
38 | #else | 38 | #else |
39 | #define DBG(fmt, args...) | 39 | #define DBG(fmt, args...) |
40 | #endif | 40 | #endif |
@@ -442,17 +442,6 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
442 | return dev->irq; | 442 | return dev->irq; |
443 | } | 443 | } |
444 | 444 | ||
445 | static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) | ||
446 | { | ||
447 | hwif->set_pio_mode = &pdcnew_set_pio_mode; | ||
448 | hwif->set_dma_mode = &pdcnew_set_dma_mode; | ||
449 | |||
450 | hwif->quirkproc = &pdcnew_quirkproc; | ||
451 | hwif->resetproc = &pdcnew_reset; | ||
452 | |||
453 | hwif->cable_detect = pdcnew_cable_detect; | ||
454 | } | ||
455 | |||
456 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | 445 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) |
457 | { | 446 | { |
458 | struct pci_dev *dev2; | 447 | struct pci_dev *dev2; |
@@ -476,11 +465,19 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | |||
476 | return NULL; | 465 | return NULL; |
477 | } | 466 | } |
478 | 467 | ||
468 | static const struct ide_port_ops pdcnew_port_ops = { | ||
469 | .set_pio_mode = pdcnew_set_pio_mode, | ||
470 | .set_dma_mode = pdcnew_set_dma_mode, | ||
471 | .quirkproc = pdcnew_quirkproc, | ||
472 | .resetproc = pdcnew_reset, | ||
473 | .cable_detect = pdcnew_cable_detect, | ||
474 | }; | ||
475 | |||
479 | #define DECLARE_PDCNEW_DEV(name_str, udma) \ | 476 | #define DECLARE_PDCNEW_DEV(name_str, udma) \ |
480 | { \ | 477 | { \ |
481 | .name = name_str, \ | 478 | .name = name_str, \ |
482 | .init_chipset = init_chipset_pdcnew, \ | 479 | .init_chipset = init_chipset_pdcnew, \ |
483 | .init_hwif = init_hwif_pdc202new, \ | 480 | .port_ops = &pdcnew_port_ops, \ |
484 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ | 481 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ |
485 | IDE_HFLAG_ERROR_STOPS_FIFO | \ | 482 | IDE_HFLAG_ERROR_STOPS_FIFO | \ |
486 | IDE_HFLAG_OFF_BOARD, \ | 483 | IDE_HFLAG_OFF_BOARD, \ |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 150422ec3cfa..fca89eda5c02 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -115,7 +115,7 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
115 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); | 115 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); |
116 | } | 116 | } |
117 | 117 | ||
118 | static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif) | 118 | static u8 __devinit pdc2026x_cable_detect(ide_hwif_t *hwif) |
119 | { | 119 | { |
120 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 120 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
121 | u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); | 121 | u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); |
@@ -163,7 +163,7 @@ static void pdc202xx_quirkproc(ide_drive_t *drive) | |||
163 | drive->quirk_list = 0; | 163 | drive->quirk_list = 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) | 166 | static void pdc202xx_dma_start(ide_drive_t *drive) |
167 | { | 167 | { |
168 | if (drive->current_speed > XFER_UDMA_2) | 168 | if (drive->current_speed > XFER_UDMA_2) |
169 | pdc_old_enable_66MHz_clock(drive->hwif); | 169 | pdc_old_enable_66MHz_clock(drive->hwif); |
@@ -185,7 +185,7 @@ static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) | |||
185 | ide_dma_start(drive); | 185 | ide_dma_start(drive); |
186 | } | 186 | } |
187 | 187 | ||
188 | static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) | 188 | static int pdc202xx_dma_end(ide_drive_t *drive) |
189 | { | 189 | { |
190 | if (drive->media != ide_disk || drive->addressing == 1) { | 190 | if (drive->media != ide_disk || drive->addressing == 1) { |
191 | ide_hwif_t *hwif = HWIF(drive); | 191 | ide_hwif_t *hwif = HWIF(drive); |
@@ -202,7 +202,7 @@ static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) | |||
202 | return __ide_dma_end(drive); | 202 | return __ide_dma_end(drive); |
203 | } | 203 | } |
204 | 204 | ||
205 | static int pdc202xx_old_ide_dma_test_irq(ide_drive_t *drive) | 205 | 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; |
@@ -226,26 +226,6 @@ somebody_else: | |||
226 | return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ | 226 | return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ |
227 | } | 227 | } |
228 | 228 | ||
229 | static void pdc202xx_dma_lost_irq(ide_drive_t *drive) | ||
230 | { | ||
231 | ide_hwif_t *hwif = HWIF(drive); | ||
232 | |||
233 | if (hwif->resetproc != NULL) | ||
234 | hwif->resetproc(drive); | ||
235 | |||
236 | ide_dma_lost_irq(drive); | ||
237 | } | ||
238 | |||
239 | static void pdc202xx_dma_timeout(ide_drive_t *drive) | ||
240 | { | ||
241 | ide_hwif_t *hwif = HWIF(drive); | ||
242 | |||
243 | if (hwif->resetproc != NULL) | ||
244 | hwif->resetproc(drive); | ||
245 | |||
246 | ide_dma_timeout(drive); | ||
247 | } | ||
248 | |||
249 | static void pdc202xx_reset_host (ide_hwif_t *hwif) | 229 | static void pdc202xx_reset_host (ide_hwif_t *hwif) |
250 | { | 230 | { |
251 | unsigned long high_16 = hwif->extra_base - 16; | 231 | unsigned long high_16 = hwif->extra_base - 16; |
@@ -271,68 +251,46 @@ static void pdc202xx_reset (ide_drive_t *drive) | |||
271 | ide_set_max_pio(drive); | 251 | ide_set_max_pio(drive); |
272 | } | 252 | } |
273 | 253 | ||
274 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, | 254 | static void pdc202xx_dma_lost_irq(ide_drive_t *drive) |
275 | const char *name) | ||
276 | { | 255 | { |
277 | return dev->irq; | 256 | pdc202xx_reset(drive); |
257 | ide_dma_lost_irq(drive); | ||
278 | } | 258 | } |
279 | 259 | ||
280 | static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | 260 | static void pdc202xx_dma_timeout(ide_drive_t *drive) |
281 | { | 261 | { |
282 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 262 | pdc202xx_reset(drive); |
283 | 263 | ide_dma_timeout(drive); | |
284 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; | ||
285 | hwif->set_dma_mode = &pdc202xx_set_mode; | ||
286 | |||
287 | hwif->quirkproc = &pdc202xx_quirkproc; | ||
288 | |||
289 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { | ||
290 | hwif->resetproc = &pdc202xx_reset; | ||
291 | |||
292 | hwif->cable_detect = pdc2026x_old_cable_detect; | ||
293 | } | ||
294 | |||
295 | if (hwif->dma_base == 0) | ||
296 | return; | ||
297 | |||
298 | hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; | ||
299 | hwif->dma_timeout = &pdc202xx_dma_timeout; | ||
300 | |||
301 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { | ||
302 | hwif->dma_start = &pdc202xx_old_ide_dma_start; | ||
303 | hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; | ||
304 | } | ||
305 | hwif->ide_dma_test_irq = &pdc202xx_old_ide_dma_test_irq; | ||
306 | } | 264 | } |
307 | 265 | ||
308 | static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) | 266 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, |
267 | const char *name) | ||
309 | { | 268 | { |
269 | unsigned long dmabase = pci_resource_start(dev, 4); | ||
310 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; | 270 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; |
311 | 271 | ||
312 | if (hwif->channel) { | 272 | if (dmabase == 0) |
313 | ide_setup_dma(hwif, dmabase); | 273 | goto out; |
314 | return; | ||
315 | } | ||
316 | 274 | ||
317 | udma_speed_flag = inb(dmabase | 0x1f); | 275 | udma_speed_flag = inb(dmabase | 0x1f); |
318 | primary_mode = inb(dmabase | 0x1a); | 276 | primary_mode = inb(dmabase | 0x1a); |
319 | secondary_mode = inb(dmabase | 0x1b); | 277 | secondary_mode = inb(dmabase | 0x1b); |
320 | printk(KERN_INFO "%s: (U)DMA Burst Bit %sABLED " \ | 278 | printk(KERN_INFO "%s: (U)DMA Burst Bit %sABLED " \ |
321 | "Primary %s Mode " \ | 279 | "Primary %s Mode " \ |
322 | "Secondary %s Mode.\n", hwif->cds->name, | 280 | "Secondary %s Mode.\n", pci_name(dev), |
323 | (udma_speed_flag & 1) ? "EN" : "DIS", | 281 | (udma_speed_flag & 1) ? "EN" : "DIS", |
324 | (primary_mode & 1) ? "MASTER" : "PCI", | 282 | (primary_mode & 1) ? "MASTER" : "PCI", |
325 | (secondary_mode & 1) ? "MASTER" : "PCI" ); | 283 | (secondary_mode & 1) ? "MASTER" : "PCI" ); |
326 | 284 | ||
327 | if (!(udma_speed_flag & 1)) { | 285 | if (!(udma_speed_flag & 1)) { |
328 | printk(KERN_INFO "%s: FORCING BURST BIT 0x%02x->0x%02x ", | 286 | printk(KERN_INFO "%s: FORCING BURST BIT 0x%02x->0x%02x ", |
329 | hwif->cds->name, udma_speed_flag, | 287 | pci_name(dev), udma_speed_flag, |
330 | (udma_speed_flag|1)); | 288 | (udma_speed_flag|1)); |
331 | outb(udma_speed_flag | 1, dmabase | 0x1f); | 289 | outb(udma_speed_flag | 1, dmabase | 0x1f); |
332 | printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); | 290 | printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); |
333 | } | 291 | } |
334 | 292 | out: | |
335 | ide_setup_dma(hwif, dmabase); | 293 | return dev->irq; |
336 | } | 294 | } |
337 | 295 | ||
338 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | 296 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, |
@@ -357,13 +315,48 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
357 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 315 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
358 | IDE_HFLAG_OFF_BOARD) | 316 | IDE_HFLAG_OFF_BOARD) |
359 | 317 | ||
318 | static const struct ide_port_ops pdc20246_port_ops = { | ||
319 | .set_pio_mode = pdc202xx_set_pio_mode, | ||
320 | .set_dma_mode = pdc202xx_set_mode, | ||
321 | .quirkproc = pdc202xx_quirkproc, | ||
322 | }; | ||
323 | |||
324 | static const struct ide_port_ops pdc2026x_port_ops = { | ||
325 | .set_pio_mode = pdc202xx_set_pio_mode, | ||
326 | .set_dma_mode = pdc202xx_set_mode, | ||
327 | .quirkproc = pdc202xx_quirkproc, | ||
328 | .resetproc = pdc202xx_reset, | ||
329 | .cable_detect = pdc2026x_cable_detect, | ||
330 | }; | ||
331 | |||
332 | static const struct ide_dma_ops pdc20246_dma_ops = { | ||
333 | .dma_host_set = ide_dma_host_set, | ||
334 | .dma_setup = ide_dma_setup, | ||
335 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
336 | .dma_start = ide_dma_start, | ||
337 | .dma_end = __ide_dma_end, | ||
338 | .dma_test_irq = pdc202xx_dma_test_irq, | ||
339 | .dma_lost_irq = pdc202xx_dma_lost_irq, | ||
340 | .dma_timeout = pdc202xx_dma_timeout, | ||
341 | }; | ||
342 | |||
343 | static const struct ide_dma_ops pdc2026x_dma_ops = { | ||
344 | .dma_host_set = ide_dma_host_set, | ||
345 | .dma_setup = ide_dma_setup, | ||
346 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
347 | .dma_start = pdc202xx_dma_start, | ||
348 | .dma_end = pdc202xx_dma_end, | ||
349 | .dma_test_irq = pdc202xx_dma_test_irq, | ||
350 | .dma_lost_irq = pdc202xx_dma_lost_irq, | ||
351 | .dma_timeout = pdc202xx_dma_timeout, | ||
352 | }; | ||
353 | |||
360 | #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ | 354 | #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ |
361 | { \ | 355 | { \ |
362 | .name = name_str, \ | 356 | .name = name_str, \ |
363 | .init_chipset = init_chipset_pdc202xx, \ | 357 | .init_chipset = init_chipset_pdc202xx, \ |
364 | .init_hwif = init_hwif_pdc202xx, \ | 358 | .port_ops = &pdc2026x_port_ops, \ |
365 | .init_dma = init_dma_pdc202xx, \ | 359 | .dma_ops = &pdc2026x_dma_ops, \ |
366 | .extra = 48, \ | ||
367 | .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ | 360 | .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ |
368 | .pio_mask = ATA_PIO4, \ | 361 | .pio_mask = ATA_PIO4, \ |
369 | .mwdma_mask = ATA_MWDMA2, \ | 362 | .mwdma_mask = ATA_MWDMA2, \ |
@@ -374,9 +367,8 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { | |||
374 | { /* 0 */ | 367 | { /* 0 */ |
375 | .name = "PDC20246", | 368 | .name = "PDC20246", |
376 | .init_chipset = init_chipset_pdc202xx, | 369 | .init_chipset = init_chipset_pdc202xx, |
377 | .init_hwif = init_hwif_pdc202xx, | 370 | .port_ops = &pdc20246_port_ops, |
378 | .init_dma = init_dma_pdc202xx, | 371 | .dma_ops = &pdc20246_dma_ops, |
379 | .extra = 16, | ||
380 | .host_flags = IDE_HFLAGS_PDC202XX, | 372 | .host_flags = IDE_HFLAGS_PDC202XX, |
381 | .pio_mask = ATA_PIO4, | 373 | .pio_mask = ATA_PIO4, |
382 | .mwdma_mask = ATA_MWDMA2, | 374 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index decef0f47674..21c5dd23f928 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -285,11 +285,6 @@ static u8 __devinit piix_cable_detect(ide_hwif_t *hwif) | |||
285 | 285 | ||
286 | static void __devinit init_hwif_piix(ide_hwif_t *hwif) | 286 | static void __devinit init_hwif_piix(ide_hwif_t *hwif) |
287 | { | 287 | { |
288 | hwif->set_pio_mode = &piix_set_pio_mode; | ||
289 | hwif->set_dma_mode = &piix_set_dma_mode; | ||
290 | |||
291 | hwif->cable_detect = piix_cable_detect; | ||
292 | |||
293 | if (!hwif->dma_base) | 288 | if (!hwif->dma_base) |
294 | return; | 289 | return; |
295 | 290 | ||
@@ -306,10 +301,16 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
306 | hwif->ide_dma_clear_irq = &piix_dma_clear_irq; | 301 | hwif->ide_dma_clear_irq = &piix_dma_clear_irq; |
307 | } | 302 | } |
308 | 303 | ||
304 | static const struct ide_port_ops piix_port_ops = { | ||
305 | .set_pio_mode = piix_set_pio_mode, | ||
306 | .set_dma_mode = piix_set_dma_mode, | ||
307 | .cable_detect = piix_cable_detect, | ||
308 | }; | ||
309 | |||
309 | #ifndef CONFIG_IA64 | 310 | #ifndef CONFIG_IA64 |
310 | #define IDE_HFLAGS_PIIX (IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_BOOTABLE) | 311 | #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS |
311 | #else | 312 | #else |
312 | #define IDE_HFLAGS_PIIX IDE_HFLAG_BOOTABLE | 313 | #define IDE_HFLAGS_PIIX 0 |
313 | #endif | 314 | #endif |
314 | 315 | ||
315 | #define DECLARE_PIIX_DEV(name_str, udma) \ | 316 | #define DECLARE_PIIX_DEV(name_str, udma) \ |
@@ -317,6 +318,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
317 | .name = name_str, \ | 318 | .name = name_str, \ |
318 | .init_hwif = init_hwif_piix, \ | 319 | .init_hwif = init_hwif_piix, \ |
319 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 320 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
321 | .port_ops = &piix_port_ops, \ | ||
320 | .host_flags = IDE_HFLAGS_PIIX, \ | 322 | .host_flags = IDE_HFLAGS_PIIX, \ |
321 | .pio_mask = ATA_PIO4, \ | 323 | .pio_mask = ATA_PIO4, \ |
322 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 324 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
@@ -330,6 +332,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
330 | .init_chipset = init_chipset_ich, \ | 332 | .init_chipset = init_chipset_ich, \ |
331 | .init_hwif = init_hwif_ich, \ | 333 | .init_hwif = init_hwif_ich, \ |
332 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 334 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
335 | .port_ops = &piix_port_ops, \ | ||
333 | .host_flags = IDE_HFLAGS_PIIX, \ | 336 | .host_flags = IDE_HFLAGS_PIIX, \ |
334 | .pio_mask = ATA_PIO4, \ | 337 | .pio_mask = ATA_PIO4, \ |
335 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 338 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c index 51676612f78f..532154adba29 100644 --- a/drivers/ide/pci/rz1000.c +++ b/drivers/ide/pci/rz1000.c | |||
@@ -43,7 +43,7 @@ static const struct ide_port_info rz1000_chipset __devinitdata = { | |||
43 | .name = "RZ100x", | 43 | .name = "RZ100x", |
44 | .init_hwif = init_hwif_rz1000, | 44 | .init_hwif = init_hwif_rz1000, |
45 | .chipset = ide_rz1000, | 45 | .chipset = ide_rz1000, |
46 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_BOOTABLE, | 46 | .host_flags = IDE_HFLAG_NO_DMA, |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 49 | static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 561aa47c7720..14c787b5d95f 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -165,7 +165,7 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
165 | * | 165 | * |
166 | * returns 1 on error, 0 otherwise | 166 | * returns 1 on error, 0 otherwise |
167 | */ | 167 | */ |
168 | static int sc1200_ide_dma_end (ide_drive_t *drive) | 168 | static int sc1200_dma_end(ide_drive_t *drive) |
169 | { | 169 | { |
170 | ide_hwif_t *hwif = HWIF(drive); | 170 | ide_hwif_t *hwif = HWIF(drive); |
171 | unsigned long dma_base = hwif->dma_base; | 171 | unsigned long dma_base = hwif->dma_base; |
@@ -214,7 +214,7 @@ static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
214 | printk("SC1200: %s: changing (U)DMA mode\n", drive->name); | 214 | printk("SC1200: %s: changing (U)DMA mode\n", drive->name); |
215 | ide_dma_off_quietly(drive); | 215 | ide_dma_off_quietly(drive); |
216 | if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) | 216 | if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) |
217 | hwif->dma_host_set(drive, 1); | 217 | hwif->dma_ops->dma_host_set(drive, 1); |
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | 220 | ||
@@ -286,29 +286,30 @@ static int sc1200_resume (struct pci_dev *dev) | |||
286 | } | 286 | } |
287 | #endif | 287 | #endif |
288 | 288 | ||
289 | /* | 289 | static const struct ide_port_ops sc1200_port_ops = { |
290 | * This gets invoked by the IDE driver once for each channel, | 290 | .set_pio_mode = sc1200_set_pio_mode, |
291 | * and performs channel-specific pre-initialization before drive probing. | 291 | .set_dma_mode = sc1200_set_dma_mode, |
292 | */ | 292 | .udma_filter = sc1200_udma_filter, |
293 | static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) | 293 | }; |
294 | { | ||
295 | hwif->set_pio_mode = &sc1200_set_pio_mode; | ||
296 | hwif->set_dma_mode = &sc1200_set_dma_mode; | ||
297 | |||
298 | if (hwif->dma_base == 0) | ||
299 | return; | ||
300 | 294 | ||
301 | hwif->udma_filter = sc1200_udma_filter; | 295 | static const struct ide_dma_ops sc1200_dma_ops = { |
302 | hwif->ide_dma_end = &sc1200_ide_dma_end; | 296 | .dma_host_set = ide_dma_host_set, |
303 | } | 297 | .dma_setup = ide_dma_setup, |
298 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
299 | .dma_start = ide_dma_start, | ||
300 | .dma_end = sc1200_dma_end, | ||
301 | .dma_test_irq = ide_dma_test_irq, | ||
302 | .dma_lost_irq = ide_dma_lost_irq, | ||
303 | .dma_timeout = ide_dma_timeout, | ||
304 | }; | ||
304 | 305 | ||
305 | static const struct ide_port_info sc1200_chipset __devinitdata = { | 306 | static const struct ide_port_info sc1200_chipset __devinitdata = { |
306 | .name = "SC1200", | 307 | .name = "SC1200", |
307 | .init_hwif = init_hwif_sc1200, | 308 | .port_ops = &sc1200_port_ops, |
309 | .dma_ops = &sc1200_dma_ops, | ||
308 | .host_flags = IDE_HFLAG_SERIALIZE | | 310 | .host_flags = IDE_HFLAG_SERIALIZE | |
309 | IDE_HFLAG_POST_SET_MODE | | 311 | IDE_HFLAG_POST_SET_MODE | |
310 | IDE_HFLAG_ABUSE_DMA_MODES | | 312 | IDE_HFLAG_ABUSE_DMA_MODES, |
311 | IDE_HFLAG_BOOTABLE, | ||
312 | .pio_mask = ATA_PIO4, | 313 | .pio_mask = ATA_PIO4, |
313 | .mwdma_mask = ATA_MWDMA2, | 314 | .mwdma_mask = ATA_MWDMA2, |
314 | .udma_mask = ATA_UDMA2, | 315 | .udma_mask = ATA_UDMA2, |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index ef07c7a8b97a..ad7cdf9060ca 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 | unsigned char hwif_id; /* for removing hwif from system */ | 68 | ide_hwif_t *hwif; /* 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 */ |
@@ -317,14 +317,14 @@ static int scc_dma_setup(ide_drive_t *drive) | |||
317 | 317 | ||
318 | 318 | ||
319 | /** | 319 | /** |
320 | * scc_ide_dma_end - Stop DMA | 320 | * scc_dma_end - Stop DMA |
321 | * @drive: IDE drive | 321 | * @drive: IDE drive |
322 | * | 322 | * |
323 | * Check and clear INT Status register. | 323 | * Check and clear INT Status register. |
324 | * Then call __ide_dma_end(). | 324 | * Then call __ide_dma_end(). |
325 | */ | 325 | */ |
326 | 326 | ||
327 | static int scc_ide_dma_end(ide_drive_t * drive) | 327 | static int scc_dma_end(ide_drive_t *drive) |
328 | { | 328 | { |
329 | ide_hwif_t *hwif = HWIF(drive); | 329 | ide_hwif_t *hwif = HWIF(drive); |
330 | unsigned long intsts_port = hwif->dma_base + 0x014; | 330 | unsigned long intsts_port = hwif->dma_base + 0x014; |
@@ -334,7 +334,7 @@ static int scc_ide_dma_end(ide_drive_t * drive) | |||
334 | 334 | ||
335 | /* errata A308 workaround: Step5 (check data loss) */ | 335 | /* errata A308 workaround: Step5 (check data loss) */ |
336 | /* We don't check non ide_disk because it is limited to UDMA4 */ | 336 | /* We don't check non ide_disk because it is limited to UDMA4 */ |
337 | if (!(in_be32((void __iomem *)hwif->io_ports[IDE_ALTSTATUS_OFFSET]) | 337 | if (!(in_be32((void __iomem *)hwif->io_ports.ctl_addr) |
338 | & ERR_STAT) && | 338 | & ERR_STAT) && |
339 | drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) { | 339 | drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) { |
340 | reg = in_be32((void __iomem *)intsts_port); | 340 | reg = in_be32((void __iomem *)intsts_port); |
@@ -438,7 +438,7 @@ static int scc_dma_test_irq(ide_drive_t *drive) | |||
438 | u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); | 438 | u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); |
439 | 439 | ||
440 | /* SCC errata A252,A308 workaround: Step4 */ | 440 | /* SCC errata A252,A308 workaround: Step4 */ |
441 | if ((in_be32((void __iomem *)hwif->io_ports[IDE_ALTSTATUS_OFFSET]) | 441 | if ((in_be32((void __iomem *)hwif->io_ports.ctl_addr) |
442 | & ERR_STAT) && | 442 | & ERR_STAT) && |
443 | (int_stat & INTSTS_INTRQ)) | 443 | (int_stat & INTSTS_INTRQ)) |
444 | return 1; | 444 | return 1; |
@@ -449,7 +449,7 @@ static int scc_dma_test_irq(ide_drive_t *drive) | |||
449 | 449 | ||
450 | if (!drive->waiting_for_dma) | 450 | if (!drive->waiting_for_dma) |
451 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", | 451 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", |
452 | drive->name, __FUNCTION__); | 452 | drive->name, __func__); |
453 | return 0; | 453 | return 0; |
454 | } | 454 | } |
455 | 455 | ||
@@ -483,7 +483,7 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
483 | unsigned long dma_size = pci_resource_len(dev, 1); | 483 | unsigned long dma_size = pci_resource_len(dev, 1); |
484 | void __iomem *ctl_addr; | 484 | void __iomem *ctl_addr; |
485 | void __iomem *dma_addr; | 485 | void __iomem *dma_addr; |
486 | int i; | 486 | int i, ret; |
487 | 487 | ||
488 | for (i = 0; i < MAX_HWIFS; i++) { | 488 | for (i = 0; i < MAX_HWIFS; i++) { |
489 | if (scc_ports[i].ctl == 0) | 489 | if (scc_ports[i].ctl == 0) |
@@ -492,21 +492,17 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
492 | if (i >= MAX_HWIFS) | 492 | if (i >= MAX_HWIFS) |
493 | return -ENOMEM; | 493 | return -ENOMEM; |
494 | 494 | ||
495 | if (!request_mem_region(ctl_base, ctl_size, name)) { | 495 | ret = pci_request_selected_regions(dev, (1 << 2) - 1, name); |
496 | printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); | 496 | if (ret < 0) { |
497 | goto fail_0; | 497 | printk(KERN_ERR "%s: can't reserve resources\n", name); |
498 | } | 498 | return ret; |
499 | |||
500 | if (!request_mem_region(dma_base, dma_size, name)) { | ||
501 | printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); | ||
502 | goto fail_1; | ||
503 | } | 499 | } |
504 | 500 | ||
505 | if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) | 501 | if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) |
506 | goto fail_2; | 502 | goto fail_0; |
507 | 503 | ||
508 | if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) | 504 | if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) |
509 | goto fail_3; | 505 | goto fail_1; |
510 | 506 | ||
511 | pci_set_master(dev); | 507 | pci_set_master(dev); |
512 | scc_ports[i].ctl = (unsigned long)ctl_addr; | 508 | scc_ports[i].ctl = (unsigned long)ctl_addr; |
@@ -515,12 +511,8 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
515 | 511 | ||
516 | return 1; | 512 | return 1; |
517 | 513 | ||
518 | fail_3: | ||
519 | iounmap(ctl_addr); | ||
520 | fail_2: | ||
521 | release_mem_region(dma_base, dma_size); | ||
522 | fail_1: | 514 | fail_1: |
523 | release_mem_region(ctl_base, ctl_size); | 515 | iounmap(ctl_addr); |
524 | fail_0: | 516 | fail_0: |
525 | return -ENOMEM; | 517 | return -ENOMEM; |
526 | } | 518 | } |
@@ -534,26 +526,21 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
534 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 526 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
535 | int i; | 527 | int i; |
536 | 528 | ||
537 | for (i = 0; i < MAX_HWIFS; i++) { | 529 | hwif = ide_find_port(); |
538 | hwif = &ide_hwifs[i]; | 530 | if (hwif == NULL) { |
539 | if (hwif->chipset == ide_unknown) | ||
540 | break; /* pick an unused entry */ | ||
541 | } | ||
542 | if (i == MAX_HWIFS) { | ||
543 | printk(KERN_ERR "%s: too many IDE interfaces, " | 531 | printk(KERN_ERR "%s: too many IDE interfaces, " |
544 | "no room in table\n", SCC_PATA_NAME); | 532 | "no room in table\n", SCC_PATA_NAME); |
545 | return -ENOMEM; | 533 | return -ENOMEM; |
546 | } | 534 | } |
547 | 535 | ||
548 | memset(&hw, 0, sizeof(hw)); | 536 | memset(&hw, 0, sizeof(hw)); |
549 | for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; i++) | 537 | for (i = 0; i <= 8; i++) |
550 | hw.io_ports[i] = ports->dma + 0x20 + i * 4; | 538 | hw.io_ports_array[i] = ports->dma + 0x20 + i * 4; |
551 | hw.irq = dev->irq; | 539 | hw.irq = dev->irq; |
552 | hw.dev = &dev->dev; | 540 | hw.dev = &dev->dev; |
553 | hw.chipset = ide_pci; | 541 | hw.chipset = ide_pci; |
554 | ide_init_port_hw(hwif, &hw); | 542 | ide_init_port_hw(hwif, &hw); |
555 | hwif->dev = &dev->dev; | 543 | hwif->dev = &dev->dev; |
556 | hwif->cds = d; | ||
557 | 544 | ||
558 | idx[0] = hwif->index; | 545 | idx[0] = hwif->index; |
559 | 546 | ||
@@ -696,7 +683,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
696 | { | 683 | { |
697 | struct scc_ports *ports = ide_get_hwifdata(hwif); | 684 | struct scc_ports *ports = ide_get_hwifdata(hwif); |
698 | 685 | ||
699 | ports->hwif_id = hwif->index; | 686 | ports->hwif = hwif; |
700 | 687 | ||
701 | hwif->dma_command = hwif->dma_base; | 688 | hwif->dma_command = hwif->dma_base; |
702 | hwif->dma_status = hwif->dma_base + 0x04; | 689 | hwif->dma_status = hwif->dma_base + 0x04; |
@@ -705,28 +692,38 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
705 | /* PTERADD */ | 692 | /* PTERADD */ |
706 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); | 693 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); |
707 | 694 | ||
708 | hwif->dma_setup = scc_dma_setup; | ||
709 | hwif->ide_dma_end = scc_ide_dma_end; | ||
710 | hwif->set_pio_mode = scc_set_pio_mode; | ||
711 | hwif->set_dma_mode = scc_set_dma_mode; | ||
712 | hwif->ide_dma_test_irq = scc_dma_test_irq; | ||
713 | hwif->udma_filter = scc_udma_filter; | ||
714 | |||
715 | if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) | 695 | if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) |
716 | hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ | 696 | hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ |
717 | else | 697 | else |
718 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ | 698 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ |
719 | |||
720 | hwif->cable_detect = scc_cable_detect; | ||
721 | } | 699 | } |
722 | 700 | ||
701 | static const struct ide_port_ops scc_port_ops = { | ||
702 | .set_pio_mode = scc_set_pio_mode, | ||
703 | .set_dma_mode = scc_set_dma_mode, | ||
704 | .udma_filter = scc_udma_filter, | ||
705 | .cable_detect = scc_cable_detect, | ||
706 | }; | ||
707 | |||
708 | static const struct ide_dma_ops scc_dma_ops = { | ||
709 | .dma_host_set = ide_dma_host_set, | ||
710 | .dma_setup = scc_dma_setup, | ||
711 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
712 | .dma_start = ide_dma_start, | ||
713 | .dma_end = scc_dma_end, | ||
714 | .dma_test_irq = scc_dma_test_irq, | ||
715 | .dma_lost_irq = ide_dma_lost_irq, | ||
716 | .dma_timeout = ide_dma_timeout, | ||
717 | }; | ||
718 | |||
723 | #define DECLARE_SCC_DEV(name_str) \ | 719 | #define DECLARE_SCC_DEV(name_str) \ |
724 | { \ | 720 | { \ |
725 | .name = name_str, \ | 721 | .name = name_str, \ |
726 | .init_iops = init_iops_scc, \ | 722 | .init_iops = init_iops_scc, \ |
727 | .init_hwif = init_hwif_scc, \ | 723 | .init_hwif = init_hwif_scc, \ |
728 | .host_flags = IDE_HFLAG_SINGLE | \ | 724 | .port_ops = &scc_port_ops, \ |
729 | IDE_HFLAG_BOOTABLE, \ | 725 | .dma_ops = &scc_dma_ops, \ |
726 | .host_flags = IDE_HFLAG_SINGLE, \ | ||
730 | .pio_mask = ATA_PIO4, \ | 727 | .pio_mask = ATA_PIO4, \ |
731 | } | 728 | } |
732 | 729 | ||
@@ -758,11 +755,7 @@ static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_i | |||
758 | static void __devexit scc_remove(struct pci_dev *dev) | 755 | static void __devexit scc_remove(struct pci_dev *dev) |
759 | { | 756 | { |
760 | struct scc_ports *ports = pci_get_drvdata(dev); | 757 | struct scc_ports *ports = pci_get_drvdata(dev); |
761 | ide_hwif_t *hwif = &ide_hwifs[ports->hwif_id]; | 758 | ide_hwif_t *hwif = ports->hwif; |
762 | unsigned long ctl_base = pci_resource_start(dev, 0); | ||
763 | unsigned long dma_base = pci_resource_start(dev, 1); | ||
764 | unsigned long ctl_size = pci_resource_len(dev, 0); | ||
765 | unsigned long dma_size = pci_resource_len(dev, 1); | ||
766 | 759 | ||
767 | if (hwif->dmatable_cpu) { | 760 | if (hwif->dmatable_cpu) { |
768 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, | 761 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, |
@@ -770,13 +763,11 @@ static void __devexit scc_remove(struct pci_dev *dev) | |||
770 | hwif->dmatable_cpu = NULL; | 763 | hwif->dmatable_cpu = NULL; |
771 | } | 764 | } |
772 | 765 | ||
773 | ide_unregister(hwif->index); | 766 | ide_unregister(hwif); |
774 | 767 | ||
775 | hwif->chipset = ide_unknown; | ||
776 | iounmap((void*)ports->dma); | 768 | iounmap((void*)ports->dma); |
777 | iounmap((void*)ports->ctl); | 769 | iounmap((void*)ports->ctl); |
778 | release_mem_region(dma_base, dma_size); | 770 | pci_release_selected_regions(dev, (1 << 2) - 1); |
779 | release_mem_region(ctl_base, ctl_size); | ||
780 | memset(ports, 0, sizeof(*ports)); | 771 | memset(ports, 0, sizeof(*ports)); |
781 | } | 772 | } |
782 | 773 | ||
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index c11880b0709f..a1fb20826a5b 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -312,7 +312,7 @@ static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) | |||
312 | return ATA_CBL_PATA40; | 312 | return ATA_CBL_PATA40; |
313 | } | 313 | } |
314 | 314 | ||
315 | static u8 __devinit ata66_svwks(ide_hwif_t *hwif) | 315 | static u8 __devinit svwks_cable_detect(ide_hwif_t *hwif) |
316 | { | 316 | { |
317 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 317 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
318 | 318 | ||
@@ -336,28 +336,28 @@ static u8 __devinit ata66_svwks(ide_hwif_t *hwif) | |||
336 | return ATA_CBL_PATA40; | 336 | return ATA_CBL_PATA40; |
337 | } | 337 | } |
338 | 338 | ||
339 | static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | 339 | static const struct ide_port_ops osb4_port_ops = { |
340 | { | 340 | .set_pio_mode = svwks_set_pio_mode, |
341 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 341 | .set_dma_mode = svwks_set_dma_mode, |
342 | 342 | .udma_filter = svwks_udma_filter, | |
343 | hwif->set_pio_mode = &svwks_set_pio_mode; | 343 | }; |
344 | hwif->set_dma_mode = &svwks_set_dma_mode; | ||
345 | hwif->udma_filter = &svwks_udma_filter; | ||
346 | 344 | ||
347 | if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) | 345 | static const struct ide_port_ops svwks_port_ops = { |
348 | hwif->cable_detect = ata66_svwks; | 346 | .set_pio_mode = svwks_set_pio_mode, |
349 | } | 347 | .set_dma_mode = svwks_set_dma_mode, |
348 | .udma_filter = svwks_udma_filter, | ||
349 | .cable_detect = svwks_cable_detect, | ||
350 | }; | ||
350 | 351 | ||
351 | #define IDE_HFLAGS_SVWKS \ | 352 | #define IDE_HFLAGS_SVWKS \ |
352 | (IDE_HFLAG_LEGACY_IRQS | \ | 353 | (IDE_HFLAG_LEGACY_IRQS | \ |
353 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 354 | IDE_HFLAG_ABUSE_SET_DMA_MODE) |
354 | IDE_HFLAG_BOOTABLE) | ||
355 | 355 | ||
356 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | 356 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { |
357 | { /* 0 */ | 357 | { /* 0 */ |
358 | .name = "SvrWks OSB4", | 358 | .name = "SvrWks OSB4", |
359 | .init_chipset = init_chipset_svwks, | 359 | .init_chipset = init_chipset_svwks, |
360 | .init_hwif = init_hwif_svwks, | 360 | .port_ops = &osb4_port_ops, |
361 | .host_flags = IDE_HFLAGS_SVWKS, | 361 | .host_flags = IDE_HFLAGS_SVWKS, |
362 | .pio_mask = ATA_PIO4, | 362 | .pio_mask = ATA_PIO4, |
363 | .mwdma_mask = ATA_MWDMA2, | 363 | .mwdma_mask = ATA_MWDMA2, |
@@ -365,7 +365,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
365 | },{ /* 1 */ | 365 | },{ /* 1 */ |
366 | .name = "SvrWks CSB5", | 366 | .name = "SvrWks CSB5", |
367 | .init_chipset = init_chipset_svwks, | 367 | .init_chipset = init_chipset_svwks, |
368 | .init_hwif = init_hwif_svwks, | 368 | .port_ops = &svwks_port_ops, |
369 | .host_flags = IDE_HFLAGS_SVWKS, | 369 | .host_flags = IDE_HFLAGS_SVWKS, |
370 | .pio_mask = ATA_PIO4, | 370 | .pio_mask = ATA_PIO4, |
371 | .mwdma_mask = ATA_MWDMA2, | 371 | .mwdma_mask = ATA_MWDMA2, |
@@ -373,7 +373,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
373 | },{ /* 2 */ | 373 | },{ /* 2 */ |
374 | .name = "SvrWks CSB6", | 374 | .name = "SvrWks CSB6", |
375 | .init_chipset = init_chipset_svwks, | 375 | .init_chipset = init_chipset_svwks, |
376 | .init_hwif = init_hwif_svwks, | 376 | .port_ops = &svwks_port_ops, |
377 | .host_flags = IDE_HFLAGS_SVWKS, | 377 | .host_flags = IDE_HFLAGS_SVWKS, |
378 | .pio_mask = ATA_PIO4, | 378 | .pio_mask = ATA_PIO4, |
379 | .mwdma_mask = ATA_MWDMA2, | 379 | .mwdma_mask = ATA_MWDMA2, |
@@ -381,7 +381,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
381 | },{ /* 3 */ | 381 | },{ /* 3 */ |
382 | .name = "SvrWks CSB6", | 382 | .name = "SvrWks CSB6", |
383 | .init_chipset = init_chipset_svwks, | 383 | .init_chipset = init_chipset_svwks, |
384 | .init_hwif = init_hwif_svwks, | 384 | .port_ops = &svwks_port_ops, |
385 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 385 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, |
386 | .pio_mask = ATA_PIO4, | 386 | .pio_mask = ATA_PIO4, |
387 | .mwdma_mask = ATA_MWDMA2, | 387 | .mwdma_mask = ATA_MWDMA2, |
@@ -389,7 +389,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
389 | },{ /* 4 */ | 389 | },{ /* 4 */ |
390 | .name = "SvrWks HT1000", | 390 | .name = "SvrWks HT1000", |
391 | .init_chipset = init_chipset_svwks, | 391 | .init_chipset = init_chipset_svwks, |
392 | .init_hwif = init_hwif_svwks, | 392 | .port_ops = &svwks_port_ops, |
393 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 393 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, |
394 | .pio_mask = ATA_PIO4, | 394 | .pio_mask = ATA_PIO4, |
395 | .mwdma_mask = ATA_MWDMA2, | 395 | .mwdma_mask = ATA_MWDMA2, |
@@ -418,7 +418,7 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device | |||
418 | else if (idx == 2 || idx == 3) { | 418 | else if (idx == 2 || idx == 3) { |
419 | if ((PCI_FUNC(dev->devfn) & 1) == 0) { | 419 | if ((PCI_FUNC(dev->devfn) & 1) == 0) { |
420 | if (pci_resource_start(dev, 0) != 0x01f1) | 420 | if (pci_resource_start(dev, 0) != 0x01f1) |
421 | d.host_flags &= ~IDE_HFLAG_BOOTABLE; | 421 | d.host_flags |= IDE_HFLAG_NON_BOOTABLE; |
422 | d.host_flags |= IDE_HFLAG_SINGLE; | 422 | d.host_flags |= IDE_HFLAG_SINGLE; |
423 | } else | 423 | } else |
424 | d.host_flags &= ~IDE_HFLAG_SINGLE; | 424 | d.host_flags &= ~IDE_HFLAG_SINGLE; |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 9d1a3038af9b..63e28f4e6d3b 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -98,28 +98,28 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port, | |||
98 | int i; | 98 | int i; |
99 | 99 | ||
100 | /* Registers are word (32 bit) aligned */ | 100 | /* Registers are word (32 bit) aligned */ |
101 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) | 101 | for (i = 0; i <= 7; i++) |
102 | hw->io_ports[i] = reg + i * 4; | 102 | hw->io_ports_array[i] = reg + i * 4; |
103 | 103 | ||
104 | if (ctrl_port) | 104 | if (ctrl_port) |
105 | hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; | 105 | hw->io_ports.ctl_addr = ctrl_port; |
106 | 106 | ||
107 | if (irq_port) | 107 | if (irq_port) |
108 | hw->io_ports[IDE_IRQ_OFFSET] = irq_port; | 108 | hw->io_ports.irq_addr = irq_port; |
109 | } | 109 | } |
110 | 110 | ||
111 | static void | 111 | static void |
112 | sgiioc4_maskproc(ide_drive_t * drive, int mask) | 112 | sgiioc4_maskproc(ide_drive_t * drive, int mask) |
113 | { | 113 | { |
114 | writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), | 114 | writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), |
115 | (void __iomem *)drive->hwif->io_ports[IDE_CONTROL_OFFSET]); | 115 | (void __iomem *)drive->hwif->io_ports.ctl_addr); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int | 118 | static int |
119 | sgiioc4_checkirq(ide_hwif_t * hwif) | 119 | sgiioc4_checkirq(ide_hwif_t * hwif) |
120 | { | 120 | { |
121 | unsigned long intr_addr = | 121 | unsigned long intr_addr = |
122 | hwif->io_ports[IDE_IRQ_OFFSET] + IOC4_INTR_REG * 4; | 122 | hwif->io_ports.irq_addr + IOC4_INTR_REG * 4; |
123 | 123 | ||
124 | if ((u8)readl((void __iomem *)intr_addr) & 0x03) | 124 | if ((u8)readl((void __iomem *)intr_addr) & 0x03) |
125 | return 1; | 125 | return 1; |
@@ -134,8 +134,8 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
134 | { | 134 | { |
135 | u32 intr_reg; | 135 | u32 intr_reg; |
136 | ide_hwif_t *hwif = HWIF(drive); | 136 | ide_hwif_t *hwif = HWIF(drive); |
137 | unsigned long other_ir = | 137 | struct ide_io_ports *io_ports = &hwif->io_ports; |
138 | hwif->io_ports[IDE_IRQ_OFFSET] + (IOC4_INTR_REG << 2); | 138 | unsigned long other_ir = io_ports->irq_addr + (IOC4_INTR_REG << 2); |
139 | 139 | ||
140 | /* Code to check for PCI error conditions */ | 140 | /* Code to check for PCI error conditions */ |
141 | intr_reg = readl((void __iomem *)other_ir); | 141 | intr_reg = readl((void __iomem *)other_ir); |
@@ -147,12 +147,12 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
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(hwif->io_ports[IDE_STATUS_OFFSET]); | 150 | u8 stat = sgiioc4_INB(io_ports->status_addr); |
151 | int count = 0; | 151 | int count = 0; |
152 | stat = sgiioc4_INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 152 | stat = sgiioc4_INB(io_ports->status_addr); |
153 | while ((stat & 0x80) && (count++ < 100)) { | 153 | while ((stat & 0x80) && (count++ < 100)) { |
154 | udelay(1); | 154 | udelay(1); |
155 | stat = sgiioc4_INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 155 | stat = sgiioc4_INB(io_ports->status_addr); |
156 | } | 156 | } |
157 | 157 | ||
158 | if (intr_reg & 0x02) { | 158 | if (intr_reg & 0x02) { |
@@ -162,18 +162,18 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
162 | pci_stat_cmd_reg; | 162 | pci_stat_cmd_reg; |
163 | 163 | ||
164 | pci_err_addr_low = | 164 | pci_err_addr_low = |
165 | readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]); | 165 | readl((void __iomem *)io_ports->irq_addr); |
166 | pci_err_addr_high = | 166 | pci_err_addr_high = |
167 | readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4)); | 167 | readl((void __iomem *)(io_ports->irq_addr + 4)); |
168 | pci_read_config_dword(dev, PCI_COMMAND, | 168 | pci_read_config_dword(dev, PCI_COMMAND, |
169 | &pci_stat_cmd_reg); | 169 | &pci_stat_cmd_reg); |
170 | printk(KERN_ERR | 170 | printk(KERN_ERR |
171 | "%s(%s) : PCI Bus Error when doing DMA:" | 171 | "%s(%s) : PCI Bus Error when doing DMA:" |
172 | " status-cmd reg is 0x%x\n", | 172 | " status-cmd reg is 0x%x\n", |
173 | __FUNCTION__, drive->name, pci_stat_cmd_reg); | 173 | __func__, drive->name, pci_stat_cmd_reg); |
174 | printk(KERN_ERR | 174 | printk(KERN_ERR |
175 | "%s(%s) : PCI Error Address is 0x%x%x\n", | 175 | "%s(%s) : PCI Error Address is 0x%x%x\n", |
176 | __FUNCTION__, drive->name, | 176 | __func__, drive->name, |
177 | pci_err_addr_high, pci_err_addr_low); | 177 | pci_err_addr_high, pci_err_addr_low); |
178 | /* Clear the PCI Error indicator */ | 178 | /* Clear the PCI Error indicator */ |
179 | pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); | 179 | pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); |
@@ -188,7 +188,7 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
188 | return intr_reg & 3; | 188 | return intr_reg & 3; |
189 | } | 189 | } |
190 | 190 | ||
191 | static void sgiioc4_ide_dma_start(ide_drive_t * drive) | 191 | static void sgiioc4_dma_start(ide_drive_t *drive) |
192 | { | 192 | { |
193 | ide_hwif_t *hwif = HWIF(drive); | 193 | ide_hwif_t *hwif = HWIF(drive); |
194 | unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; | 194 | unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; |
@@ -215,8 +215,7 @@ sgiioc4_ide_dma_stop(ide_hwif_t *hwif, u64 dma_base) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | /* Stops the IOC4 DMA Engine */ | 217 | /* Stops the IOC4 DMA Engine */ |
218 | static int | 218 | static int sgiioc4_dma_end(ide_drive_t *drive) |
219 | sgiioc4_ide_dma_end(ide_drive_t * drive) | ||
220 | { | 219 | { |
221 | u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; | 220 | u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; |
222 | ide_hwif_t *hwif = HWIF(drive); | 221 | ide_hwif_t *hwif = HWIF(drive); |
@@ -232,7 +231,7 @@ sgiioc4_ide_dma_end(ide_drive_t * drive) | |||
232 | printk(KERN_ERR | 231 | printk(KERN_ERR |
233 | "%s(%s): IOC4 DMA STOP bit is still 1 :" | 232 | "%s(%s): IOC4 DMA STOP bit is still 1 :" |
234 | "ioc4_dma_reg 0x%x\n", | 233 | "ioc4_dma_reg 0x%x\n", |
235 | __FUNCTION__, drive->name, ioc4_dma); | 234 | __func__, drive->name, ioc4_dma); |
236 | dma_stat = 1; | 235 | dma_stat = 1; |
237 | } | 236 | } |
238 | 237 | ||
@@ -251,7 +250,7 @@ sgiioc4_ide_dma_end(ide_drive_t * drive) | |||
251 | udelay(1); | 250 | udelay(1); |
252 | } | 251 | } |
253 | if (!valid) { | 252 | if (!valid) { |
254 | printk(KERN_ERR "%s(%s) : DMA incomplete\n", __FUNCTION__, | 253 | printk(KERN_ERR "%s(%s) : DMA incomplete\n", __func__, |
255 | drive->name); | 254 | drive->name); |
256 | dma_stat = 1; | 255 | dma_stat = 1; |
257 | } | 256 | } |
@@ -264,7 +263,7 @@ sgiioc4_ide_dma_end(ide_drive_t * drive) | |||
264 | printk(KERN_ERR | 263 | printk(KERN_ERR |
265 | "%s(%s): WARNING!! byte_count_dev %d " | 264 | "%s(%s): WARNING!! byte_count_dev %d " |
266 | "!= byte_count_mem %d\n", | 265 | "!= byte_count_mem %d\n", |
267 | __FUNCTION__, drive->name, bc_dev, bc_mem); | 266 | __func__, drive->name, bc_dev, bc_mem); |
268 | } | 267 | } |
269 | } | 268 | } |
270 | 269 | ||
@@ -279,8 +278,7 @@ static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
279 | } | 278 | } |
280 | 279 | ||
281 | /* returns 1 if dma irq issued, 0 otherwise */ | 280 | /* returns 1 if dma irq issued, 0 otherwise */ |
282 | static int | 281 | static int sgiioc4_dma_test_irq(ide_drive_t *drive) |
283 | sgiioc4_ide_dma_test_irq(ide_drive_t * drive) | ||
284 | { | 282 | { |
285 | return sgiioc4_checkirq(HWIF(drive)); | 283 | return sgiioc4_checkirq(HWIF(drive)); |
286 | } | 284 | } |
@@ -294,7 +292,7 @@ static void sgiioc4_dma_host_set(ide_drive_t *drive, int on) | |||
294 | static void | 292 | static void |
295 | sgiioc4_resetproc(ide_drive_t * drive) | 293 | sgiioc4_resetproc(ide_drive_t * drive) |
296 | { | 294 | { |
297 | sgiioc4_ide_dma_end(drive); | 295 | sgiioc4_dma_end(drive); |
298 | sgiioc4_clearirq(drive); | 296 | sgiioc4_clearirq(drive); |
299 | } | 297 | } |
300 | 298 | ||
@@ -329,13 +327,17 @@ sgiioc4_INB(unsigned long port) | |||
329 | 327 | ||
330 | /* Creates a dma map for the scatter-gather list entries */ | 328 | /* Creates a dma map for the scatter-gather list entries */ |
331 | static int __devinit | 329 | static int __devinit |
332 | ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | 330 | ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d) |
333 | { | 331 | { |
334 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 332 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
333 | unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; | ||
335 | void __iomem *virt_dma_base; | 334 | void __iomem *virt_dma_base; |
336 | int num_ports = sizeof (ioc4_dma_regs_t); | 335 | int num_ports = sizeof (ioc4_dma_regs_t); |
337 | void *pad; | 336 | void *pad; |
338 | 337 | ||
338 | if (dma_base == 0) | ||
339 | return -1; | ||
340 | |||
339 | printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, | 341 | printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, |
340 | dma_base, dma_base + num_ports - 1); | 342 | dma_base, dma_base + num_ports - 1); |
341 | 343 | ||
@@ -343,7 +345,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
343 | printk(KERN_ERR | 345 | printk(KERN_ERR |
344 | "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " | 346 | "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " |
345 | "ALREADY in use\n", | 347 | "ALREADY in use\n", |
346 | __FUNCTION__, hwif->name, (void *) dma_base, | 348 | __func__, hwif->name, (void *) dma_base, |
347 | (void *) dma_base + num_ports - 1); | 349 | (void *) dma_base + num_ports - 1); |
348 | return -1; | 350 | return -1; |
349 | } | 351 | } |
@@ -352,7 +354,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
352 | if (virt_dma_base == NULL) { | 354 | if (virt_dma_base == NULL) { |
353 | printk(KERN_ERR | 355 | printk(KERN_ERR |
354 | "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", | 356 | "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", |
355 | __FUNCTION__, hwif->name, dma_base, dma_base + num_ports - 1); | 357 | __func__, hwif->name, dma_base, dma_base + num_ports - 1); |
356 | goto dma_remap_failure; | 358 | goto dma_remap_failure; |
357 | } | 359 | } |
358 | hwif->dma_base = (unsigned long) virt_dma_base; | 360 | hwif->dma_base = (unsigned long) virt_dma_base; |
@@ -378,7 +380,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
378 | hwif->dmatable_cpu, hwif->dmatable_dma); | 380 | hwif->dmatable_cpu, hwif->dmatable_dma); |
379 | printk(KERN_INFO | 381 | printk(KERN_INFO |
380 | "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", | 382 | "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", |
381 | __FUNCTION__, hwif->name); | 383 | __func__, hwif->name); |
382 | printk(KERN_INFO | 384 | printk(KERN_INFO |
383 | "Changing from DMA to PIO mode for Drive %s\n", hwif->name); | 385 | "Changing from DMA to PIO mode for Drive %s\n", hwif->name); |
384 | 386 | ||
@@ -406,14 +408,14 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
406 | if (ioc4_dma & IOC4_S_DMA_ACTIVE) { | 408 | if (ioc4_dma & IOC4_S_DMA_ACTIVE) { |
407 | printk(KERN_WARNING | 409 | printk(KERN_WARNING |
408 | "%s(%s):Warning!! DMA from previous transfer was still active\n", | 410 | "%s(%s):Warning!! DMA from previous transfer was still active\n", |
409 | __FUNCTION__, drive->name); | 411 | __func__, drive->name); |
410 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); | 412 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); |
411 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); | 413 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); |
412 | 414 | ||
413 | if (ioc4_dma & IOC4_S_DMA_STOP) | 415 | if (ioc4_dma & IOC4_S_DMA_STOP) |
414 | printk(KERN_ERR | 416 | printk(KERN_ERR |
415 | "%s(%s) : IOC4 Dma STOP bit is still 1\n", | 417 | "%s(%s) : IOC4 Dma STOP bit is still 1\n", |
416 | __FUNCTION__, drive->name); | 418 | __func__, drive->name); |
417 | } | 419 | } |
418 | 420 | ||
419 | ioc4_dma = readl((void __iomem *)ioc4_dma_addr); | 421 | ioc4_dma = readl((void __iomem *)ioc4_dma_addr); |
@@ -421,14 +423,14 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
421 | printk(KERN_WARNING | 423 | printk(KERN_WARNING |
422 | "%s(%s) : Warning!! - DMA Error during Previous" | 424 | "%s(%s) : Warning!! - DMA Error during Previous" |
423 | " transfer | status 0x%x\n", | 425 | " transfer | status 0x%x\n", |
424 | __FUNCTION__, drive->name, ioc4_dma); | 426 | __func__, drive->name, ioc4_dma); |
425 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); | 427 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); |
426 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); | 428 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); |
427 | 429 | ||
428 | if (ioc4_dma & IOC4_S_DMA_STOP) | 430 | if (ioc4_dma & IOC4_S_DMA_STOP) |
429 | printk(KERN_ERR | 431 | printk(KERN_ERR |
430 | "%s(%s) : IOC4 DMA STOP bit is still 1\n", | 432 | "%s(%s) : IOC4 DMA STOP bit is still 1\n", |
431 | __FUNCTION__, drive->name); | 433 | __func__, drive->name); |
432 | } | 434 | } |
433 | 435 | ||
434 | /* Address of the Scatter Gather List */ | 436 | /* Address of the Scatter Gather List */ |
@@ -519,7 +521,7 @@ use_pio_instead: | |||
519 | return 0; /* revert to PIO for this request */ | 521 | return 0; /* revert to PIO for this request */ |
520 | } | 522 | } |
521 | 523 | ||
522 | static int sgiioc4_ide_dma_setup(ide_drive_t *drive) | 524 | static int sgiioc4_dma_setup(ide_drive_t *drive) |
523 | { | 525 | { |
524 | struct request *rq = HWGROUP(drive)->rq; | 526 | struct request *rq = HWGROUP(drive)->rq; |
525 | unsigned int count = 0; | 527 | unsigned int count = 0; |
@@ -548,62 +550,45 @@ static int sgiioc4_ide_dma_setup(ide_drive_t *drive) | |||
548 | return 0; | 550 | return 0; |
549 | } | 551 | } |
550 | 552 | ||
551 | static void __devinit | 553 | static const struct ide_port_ops sgiioc4_port_ops = { |
552 | ide_init_sgiioc4(ide_hwif_t * hwif) | 554 | .set_dma_mode = sgiioc4_set_dma_mode, |
553 | { | 555 | /* reset DMA engine, clear IRQs */ |
554 | hwif->mmio = 1; | 556 | .resetproc = sgiioc4_resetproc, |
555 | hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ | 557 | /* mask on/off NIEN register */ |
556 | hwif->set_dma_mode = &sgiioc4_set_dma_mode; | 558 | .maskproc = sgiioc4_maskproc, |
557 | hwif->selectproc = NULL;/* Use the default routine to select drive */ | 559 | }; |
558 | hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */ | ||
559 | hwif->pre_reset = NULL; /* No HBA specific pre_set needed */ | ||
560 | hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine, | ||
561 | clear interrupts */ | ||
562 | hwif->maskproc = &sgiioc4_maskproc; /* Mask on/off NIEN register */ | ||
563 | hwif->quirkproc = NULL; | ||
564 | |||
565 | hwif->INB = &sgiioc4_INB; | ||
566 | |||
567 | if (hwif->dma_base == 0) | ||
568 | return; | ||
569 | 560 | ||
570 | hwif->dma_host_set = &sgiioc4_dma_host_set; | 561 | static const struct ide_dma_ops sgiioc4_dma_ops = { |
571 | hwif->dma_setup = &sgiioc4_ide_dma_setup; | 562 | .dma_host_set = sgiioc4_dma_host_set, |
572 | hwif->dma_start = &sgiioc4_ide_dma_start; | 563 | .dma_setup = sgiioc4_dma_setup, |
573 | hwif->ide_dma_end = &sgiioc4_ide_dma_end; | 564 | .dma_start = sgiioc4_dma_start, |
574 | hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq; | 565 | .dma_end = sgiioc4_dma_end, |
575 | hwif->dma_lost_irq = &sgiioc4_dma_lost_irq; | 566 | .dma_test_irq = sgiioc4_dma_test_irq, |
576 | hwif->dma_timeout = &ide_dma_timeout; | 567 | .dma_lost_irq = sgiioc4_dma_lost_irq, |
577 | } | 568 | .dma_timeout = ide_dma_timeout, |
569 | }; | ||
578 | 570 | ||
579 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { | 571 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { |
580 | .chipset = ide_pci, | 572 | .chipset = ide_pci, |
581 | .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | 573 | .init_dma = ide_dma_sgiioc4, |
582 | IDE_HFLAG_NO_AUTOTUNE, | 574 | .port_ops = &sgiioc4_port_ops, |
575 | .dma_ops = &sgiioc4_dma_ops, | ||
583 | .mwdma_mask = ATA_MWDMA2_ONLY, | 576 | .mwdma_mask = ATA_MWDMA2_ONLY, |
584 | }; | 577 | }; |
585 | 578 | ||
586 | static int __devinit | 579 | static int __devinit |
587 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | 580 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev) |
588 | { | 581 | { |
589 | unsigned long cmd_base, dma_base, irqport; | 582 | unsigned long cmd_base, irqport; |
590 | unsigned long bar0, cmd_phys_base, ctl; | 583 | unsigned long bar0, cmd_phys_base, ctl; |
591 | void __iomem *virt_base; | 584 | void __iomem *virt_base; |
592 | ide_hwif_t *hwif; | 585 | ide_hwif_t *hwif; |
593 | int h; | ||
594 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 586 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
595 | hw_regs_t hw; | 587 | hw_regs_t hw; |
596 | struct ide_port_info d = sgiioc4_port_info; | 588 | struct ide_port_info d = sgiioc4_port_info; |
597 | 589 | ||
598 | /* | 590 | hwif = ide_find_port(); |
599 | * Find an empty HWIF; if none available, return -ENOMEM. | 591 | if (hwif == NULL) { |
600 | */ | ||
601 | for (h = 0; h < MAX_HWIFS; ++h) { | ||
602 | hwif = &ide_hwifs[h]; | ||
603 | if (hwif->chipset == ide_unknown) | ||
604 | break; | ||
605 | } | ||
606 | if (h == MAX_HWIFS) { | ||
607 | printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", | 592 | printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", |
608 | DRV_NAME); | 593 | DRV_NAME); |
609 | return -ENOMEM; | 594 | return -ENOMEM; |
@@ -620,7 +605,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
620 | cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET; | 605 | cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET; |
621 | ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET; | 606 | ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET; |
622 | irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; | 607 | irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; |
623 | dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; | ||
624 | 608 | ||
625 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; | 609 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; |
626 | if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, | 610 | if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, |
@@ -628,7 +612,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
628 | printk(KERN_ERR | 612 | printk(KERN_ERR |
629 | "%s : %s -- ERROR, Addresses " | 613 | "%s : %s -- ERROR, Addresses " |
630 | "0x%p to 0x%p ALREADY in use\n", | 614 | "0x%p to 0x%p ALREADY in use\n", |
631 | __FUNCTION__, hwif->name, (void *) cmd_phys_base, | 615 | __func__, hwif->name, (void *) cmd_phys_base, |
632 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); | 616 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); |
633 | return -ENOMEM; | 617 | return -ENOMEM; |
634 | } | 618 | } |
@@ -649,13 +633,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
649 | /* Initializing chipset IRQ Registers */ | 633 | /* Initializing chipset IRQ Registers */ |
650 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); | 634 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); |
651 | 635 | ||
652 | if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) { | 636 | hwif->INB = &sgiioc4_INB; |
653 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", | ||
654 | hwif->name, DRV_NAME); | ||
655 | d.mwdma_mask = 0; | ||
656 | } | ||
657 | |||
658 | ide_init_sgiioc4(hwif); | ||
659 | 637 | ||
660 | idx[0] = hwif->index; | 638 | idx[0] = hwif->index; |
661 | 639 | ||
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index b6be1b45f329..c2040a017f47 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -301,7 +301,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
301 | } | 301 | } |
302 | 302 | ||
303 | /* returns 1 if dma irq issued, 0 otherwise */ | 303 | /* returns 1 if dma irq issued, 0 otherwise */ |
304 | static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | 304 | static int siimage_io_dma_test_irq(ide_drive_t *drive) |
305 | { | 305 | { |
306 | ide_hwif_t *hwif = HWIF(drive); | 306 | ide_hwif_t *hwif = HWIF(drive); |
307 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 307 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -320,14 +320,14 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | |||
320 | } | 320 | } |
321 | 321 | ||
322 | /** | 322 | /** |
323 | * siimage_mmio_ide_dma_test_irq - check we caused an IRQ | 323 | * siimage_mmio_dma_test_irq - check we caused an IRQ |
324 | * @drive: drive we are testing | 324 | * @drive: drive we are testing |
325 | * | 325 | * |
326 | * Check if we caused an IDE DMA interrupt. We may also have caused | 326 | * Check if we caused an IDE DMA interrupt. We may also have caused |
327 | * SATA status interrupts, if so we clean them up and continue. | 327 | * SATA status interrupts, if so we clean them up and continue. |
328 | */ | 328 | */ |
329 | 329 | ||
330 | static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | 330 | static int siimage_mmio_dma_test_irq(ide_drive_t *drive) |
331 | { | 331 | { |
332 | ide_hwif_t *hwif = HWIF(drive); | 332 | ide_hwif_t *hwif = HWIF(drive); |
333 | unsigned long addr = siimage_selreg(hwif, 0x1); | 333 | unsigned long addr = siimage_selreg(hwif, 0x1); |
@@ -347,7 +347,7 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
347 | printk(KERN_WARNING "%s: sata_error = 0x%08x, " | 347 | printk(KERN_WARNING "%s: sata_error = 0x%08x, " |
348 | "watchdog = %d, %s\n", | 348 | "watchdog = %d, %s\n", |
349 | drive->name, sata_error, watchdog, | 349 | drive->name, sata_error, watchdog, |
350 | __FUNCTION__); | 350 | __func__); |
351 | 351 | ||
352 | } else { | 352 | } else { |
353 | watchdog = (ext_stat & 0x8000) ? 1 : 0; | 353 | watchdog = (ext_stat & 0x8000) ? 1 : 0; |
@@ -369,6 +369,14 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
369 | return 0; | 369 | return 0; |
370 | } | 370 | } |
371 | 371 | ||
372 | static int siimage_dma_test_irq(ide_drive_t *drive) | ||
373 | { | ||
374 | if (drive->hwif->mmio) | ||
375 | return siimage_mmio_dma_test_irq(drive); | ||
376 | else | ||
377 | return siimage_io_dma_test_irq(drive); | ||
378 | } | ||
379 | |||
372 | /** | 380 | /** |
373 | * sil_sata_reset_poll - wait for SATA reset | 381 | * sil_sata_reset_poll - wait for SATA reset |
374 | * @drive: drive we are resetting | 382 | * @drive: drive we are resetting |
@@ -614,9 +622,10 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
614 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 622 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
615 | void *addr = pci_get_drvdata(dev); | 623 | void *addr = pci_get_drvdata(dev); |
616 | u8 ch = hwif->channel; | 624 | u8 ch = hwif->channel; |
617 | hw_regs_t hw; | ||
618 | unsigned long base; | 625 | unsigned long base; |
619 | 626 | ||
627 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
628 | |||
620 | /* | 629 | /* |
621 | * Fill in the basic HWIF bits | 630 | * Fill in the basic HWIF bits |
622 | */ | 631 | */ |
@@ -630,7 +639,7 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
630 | * based I/O | 639 | * based I/O |
631 | */ | 640 | */ |
632 | 641 | ||
633 | memset(&hw, 0, sizeof(hw_regs_t)); | 642 | memset(io_ports, 0, sizeof(*io_ports)); |
634 | 643 | ||
635 | base = (unsigned long)addr; | 644 | base = (unsigned long)addr; |
636 | if (ch) | 645 | if (ch) |
@@ -643,17 +652,15 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
643 | * so we can't currently use it sanely since we want to | 652 | * so we can't currently use it sanely since we want to |
644 | * use LBA48 mode. | 653 | * use LBA48 mode. |
645 | */ | 654 | */ |
646 | hw.io_ports[IDE_DATA_OFFSET] = base; | 655 | io_ports->data_addr = base; |
647 | hw.io_ports[IDE_ERROR_OFFSET] = base + 1; | 656 | io_ports->error_addr = base + 1; |
648 | hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2; | 657 | io_ports->nsect_addr = base + 2; |
649 | hw.io_ports[IDE_SECTOR_OFFSET] = base + 3; | 658 | io_ports->lbal_addr = base + 3; |
650 | hw.io_ports[IDE_LCYL_OFFSET] = base + 4; | 659 | io_ports->lbam_addr = base + 4; |
651 | hw.io_ports[IDE_HCYL_OFFSET] = base + 5; | 660 | io_ports->lbah_addr = base + 5; |
652 | hw.io_ports[IDE_SELECT_OFFSET] = base + 6; | 661 | io_ports->device_addr = base + 6; |
653 | hw.io_ports[IDE_STATUS_OFFSET] = base + 7; | 662 | io_ports->status_addr = base + 7; |
654 | hw.io_ports[IDE_CONTROL_OFFSET] = base + 10; | 663 | io_ports->ctl_addr = base + 10; |
655 | |||
656 | hw.io_ports[IDE_IRQ_OFFSET] = 0; | ||
657 | 664 | ||
658 | if (pdev_is_sata(dev)) { | 665 | if (pdev_is_sata(dev)) { |
659 | base = (unsigned long)addr; | 666 | base = (unsigned long)addr; |
@@ -664,8 +671,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
664 | hwif->sata_scr[SATA_CONTROL_OFFSET] = base + 0x100; | 671 | hwif->sata_scr[SATA_CONTROL_OFFSET] = base + 0x100; |
665 | } | 672 | } |
666 | 673 | ||
667 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); | ||
668 | |||
669 | hwif->irq = dev->irq; | 674 | hwif->irq = dev->irq; |
670 | 675 | ||
671 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); | 676 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); |
@@ -735,14 +740,14 @@ static void __devinit init_iops_siimage(ide_hwif_t *hwif) | |||
735 | } | 740 | } |
736 | 741 | ||
737 | /** | 742 | /** |
738 | * ata66_siimage - check for 80 pin cable | 743 | * sil_cable_detect - cable detection |
739 | * @hwif: interface to check | 744 | * @hwif: interface to check |
740 | * | 745 | * |
741 | * Check for the presence of an ATA66 capable cable on the | 746 | * Check for the presence of an ATA66 capable cable on the |
742 | * interface. | 747 | * interface. |
743 | */ | 748 | */ |
744 | 749 | ||
745 | static u8 __devinit ata66_siimage(ide_hwif_t *hwif) | 750 | static u8 __devinit sil_cable_detect(ide_hwif_t *hwif) |
746 | { | 751 | { |
747 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 752 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
748 | unsigned long addr = siimage_selreg(hwif, 0); | 753 | unsigned long addr = siimage_selreg(hwif, 0); |
@@ -756,68 +761,44 @@ static u8 __devinit ata66_siimage(ide_hwif_t *hwif) | |||
756 | return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 761 | return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
757 | } | 762 | } |
758 | 763 | ||
759 | /** | 764 | static const struct ide_port_ops sil_pata_port_ops = { |
760 | * init_hwif_siimage - set up hwif structs | 765 | .set_pio_mode = sil_set_pio_mode, |
761 | * @hwif: interface to set up | 766 | .set_dma_mode = sil_set_dma_mode, |
762 | * | 767 | .quirkproc = sil_quirkproc, |
763 | * We do the basic set up of the interface structure. The SIIMAGE | 768 | .udma_filter = sil_pata_udma_filter, |
764 | * requires several custom handlers so we override the default | 769 | .cable_detect = sil_cable_detect, |
765 | * ide DMA handlers appropriately | 770 | }; |
766 | */ | ||
767 | |||
768 | static void __devinit init_hwif_siimage(ide_hwif_t *hwif) | ||
769 | { | ||
770 | u8 sata = is_sata(hwif); | ||
771 | |||
772 | hwif->set_pio_mode = &sil_set_pio_mode; | ||
773 | hwif->set_dma_mode = &sil_set_dma_mode; | ||
774 | hwif->quirkproc = &sil_quirkproc; | ||
775 | |||
776 | if (sata) { | ||
777 | static int first = 1; | ||
778 | |||
779 | hwif->reset_poll = &sil_sata_reset_poll; | ||
780 | hwif->pre_reset = &sil_sata_pre_reset; | ||
781 | hwif->udma_filter = &sil_sata_udma_filter; | ||
782 | |||
783 | if (first) { | ||
784 | printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); | ||
785 | first = 0; | ||
786 | } | ||
787 | } else | ||
788 | hwif->udma_filter = &sil_pata_udma_filter; | ||
789 | |||
790 | hwif->cable_detect = ata66_siimage; | ||
791 | |||
792 | if (hwif->dma_base == 0) | ||
793 | return; | ||
794 | 771 | ||
795 | if (sata) | 772 | static const struct ide_port_ops sil_sata_port_ops = { |
796 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 773 | .set_pio_mode = sil_set_pio_mode, |
774 | .set_dma_mode = sil_set_dma_mode, | ||
775 | .reset_poll = sil_sata_reset_poll, | ||
776 | .pre_reset = sil_sata_pre_reset, | ||
777 | .quirkproc = sil_quirkproc, | ||
778 | .udma_filter = sil_sata_udma_filter, | ||
779 | .cable_detect = sil_cable_detect, | ||
780 | }; | ||
797 | 781 | ||
798 | if (hwif->mmio) { | 782 | static struct ide_dma_ops sil_dma_ops = { |
799 | hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; | 783 | .dma_test_irq = siimage_dma_test_irq, |
800 | } else { | 784 | }; |
801 | hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq; | ||
802 | } | ||
803 | } | ||
804 | 785 | ||
805 | #define DECLARE_SII_DEV(name_str) \ | 786 | #define DECLARE_SII_DEV(name_str, p_ops) \ |
806 | { \ | 787 | { \ |
807 | .name = name_str, \ | 788 | .name = name_str, \ |
808 | .init_chipset = init_chipset_siimage, \ | 789 | .init_chipset = init_chipset_siimage, \ |
809 | .init_iops = init_iops_siimage, \ | 790 | .init_iops = init_iops_siimage, \ |
810 | .init_hwif = init_hwif_siimage, \ | 791 | .port_ops = p_ops, \ |
811 | .host_flags = IDE_HFLAG_BOOTABLE, \ | 792 | .dma_ops = &sil_dma_ops, \ |
812 | .pio_mask = ATA_PIO4, \ | 793 | .pio_mask = ATA_PIO4, \ |
813 | .mwdma_mask = ATA_MWDMA2, \ | 794 | .mwdma_mask = ATA_MWDMA2, \ |
814 | .udma_mask = ATA_UDMA6, \ | 795 | .udma_mask = ATA_UDMA6, \ |
815 | } | 796 | } |
816 | 797 | ||
817 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { | 798 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { |
818 | /* 0 */ DECLARE_SII_DEV("SiI680"), | 799 | /* 0 */ DECLARE_SII_DEV("SiI680", &sil_pata_port_ops), |
819 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), | 800 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA", &sil_sata_port_ops), |
820 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") | 801 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA", &sil_sata_port_ops) |
821 | }; | 802 | }; |
822 | 803 | ||
823 | /** | 804 | /** |
@@ -831,7 +812,24 @@ static const struct ide_port_info siimage_chipsets[] __devinitdata = { | |||
831 | 812 | ||
832 | static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 813 | static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
833 | { | 814 | { |
834 | return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]); | 815 | struct ide_port_info d; |
816 | u8 idx = id->driver_data; | ||
817 | |||
818 | d = siimage_chipsets[idx]; | ||
819 | |||
820 | if (idx) { | ||
821 | static int first = 1; | ||
822 | |||
823 | if (first) { | ||
824 | printk(KERN_INFO "siimage: For full SATA support you " | ||
825 | "should use the libata sata_sil module.\n"); | ||
826 | first = 0; | ||
827 | } | ||
828 | |||
829 | d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | ||
830 | } | ||
831 | |||
832 | return ide_setup_pci_device(dev, &d); | ||
835 | } | 833 | } |
836 | 834 | ||
837 | static const struct pci_device_id siimage_pci_tbl[] = { | 835 | static const struct pci_device_id siimage_pci_tbl[] = { |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 512bb4c1fd5c..4b0b85d8faf5 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -59,10 +59,10 @@ | |||
59 | #define ATA_16 0x01 | 59 | #define ATA_16 0x01 |
60 | #define ATA_33 0x02 | 60 | #define ATA_33 0x02 |
61 | #define ATA_66 0x03 | 61 | #define ATA_66 0x03 |
62 | #define ATA_100a 0x04 // SiS730/SiS550 is ATA100 with ATA66 layout | 62 | #define ATA_100a 0x04 /* SiS730/SiS550 is ATA100 with ATA66 layout */ |
63 | #define ATA_100 0x05 | 63 | #define ATA_100 0x05 |
64 | #define ATA_133a 0x06 // SiS961b with 133 support | 64 | #define ATA_133a 0x06 /* SiS961b with 133 support */ |
65 | #define ATA_133 0x07 // SiS962/963 | 65 | #define ATA_133 0x07 /* SiS962/963 */ |
66 | 66 | ||
67 | static u8 chipset_family; | 67 | static u8 chipset_family; |
68 | 68 | ||
@@ -111,69 +111,70 @@ static const struct { | |||
111 | Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ | 111 | Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ |
112 | 112 | ||
113 | /* {0, ATA_16, ATA_33, ATA_66, ATA_100a, ATA_100, ATA_133} */ | 113 | /* {0, ATA_16, ATA_33, ATA_66, ATA_100a, ATA_100, ATA_133} */ |
114 | static u8 cycle_time_offset[] = {0,0,5,4,4,0,0}; | 114 | static u8 cycle_time_offset[] = { 0, 0, 5, 4, 4, 0, 0 }; |
115 | static u8 cycle_time_range[] = {0,0,2,3,3,4,4}; | 115 | static u8 cycle_time_range[] = { 0, 0, 2, 3, 3, 4, 4 }; |
116 | static u8 cycle_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { | 116 | static u8 cycle_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { |
117 | {0,0,0,0,0,0,0}, /* no udma */ | 117 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
118 | {0,0,0,0,0,0,0}, /* no udma */ | 118 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
119 | {3,2,1,0,0,0,0}, /* ATA_33 */ | 119 | { 3, 2, 1, 0, 0, 0, 0 }, /* ATA_33 */ |
120 | {7,5,3,2,1,0,0}, /* ATA_66 */ | 120 | { 7, 5, 3, 2, 1, 0, 0 }, /* ATA_66 */ |
121 | {7,5,3,2,1,0,0}, /* ATA_100a (730 specific), differences are on cycle_time range and offset */ | 121 | { 7, 5, 3, 2, 1, 0, 0 }, /* ATA_100a (730 specific), |
122 | {11,7,5,4,2,1,0}, /* ATA_100 */ | 122 | different cycle_time range and offset */ |
123 | {15,10,7,5,3,2,1}, /* ATA_133a (earliest 691 southbridges) */ | 123 | { 11, 7, 5, 4, 2, 1, 0 }, /* ATA_100 */ |
124 | {15,10,7,5,3,2,1}, /* ATA_133 */ | 124 | { 15, 10, 7, 5, 3, 2, 1 }, /* ATA_133a (earliest 691 southbridges) */ |
125 | { 15, 10, 7, 5, 3, 2, 1 }, /* ATA_133 */ | ||
125 | }; | 126 | }; |
126 | /* CRC Valid Setup Time vary across IDE clock setting 33/66/100/133 | 127 | /* CRC Valid Setup Time vary across IDE clock setting 33/66/100/133 |
127 | See SiS962 data sheet for more detail */ | 128 | See SiS962 data sheet for more detail */ |
128 | static u8 cvs_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { | 129 | static u8 cvs_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { |
129 | {0,0,0,0,0,0,0}, /* no udma */ | 130 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
130 | {0,0,0,0,0,0,0}, /* no udma */ | 131 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
131 | {2,1,1,0,0,0,0}, | 132 | { 2, 1, 1, 0, 0, 0, 0 }, |
132 | {4,3,2,1,0,0,0}, | 133 | { 4, 3, 2, 1, 0, 0, 0 }, |
133 | {4,3,2,1,0,0,0}, | 134 | { 4, 3, 2, 1, 0, 0, 0 }, |
134 | {6,4,3,1,1,1,0}, | 135 | { 6, 4, 3, 1, 1, 1, 0 }, |
135 | {9,6,4,2,2,2,2}, | 136 | { 9, 6, 4, 2, 2, 2, 2 }, |
136 | {9,6,4,2,2,2,2}, | 137 | { 9, 6, 4, 2, 2, 2, 2 }, |
137 | }; | 138 | }; |
138 | /* Initialize time, Active time, Recovery time vary across | 139 | /* Initialize time, Active time, Recovery time vary across |
139 | IDE clock settings. These 3 arrays hold the register value | 140 | IDE clock settings. These 3 arrays hold the register value |
140 | for PIO0/1/2/3/4 and DMA0/1/2 mode in order */ | 141 | for PIO0/1/2/3/4 and DMA0/1/2 mode in order */ |
141 | static u8 ini_time_value[][8] = { | 142 | static u8 ini_time_value[][8] = { |
142 | {0,0,0,0,0,0,0,0}, | 143 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
143 | {0,0,0,0,0,0,0,0}, | 144 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
144 | {2,1,0,0,0,1,0,0}, | 145 | { 2, 1, 0, 0, 0, 1, 0, 0 }, |
145 | {4,3,1,1,1,3,1,1}, | 146 | { 4, 3, 1, 1, 1, 3, 1, 1 }, |
146 | {4,3,1,1,1,3,1,1}, | 147 | { 4, 3, 1, 1, 1, 3, 1, 1 }, |
147 | {6,4,2,2,2,4,2,2}, | 148 | { 6, 4, 2, 2, 2, 4, 2, 2 }, |
148 | {9,6,3,3,3,6,3,3}, | 149 | { 9, 6, 3, 3, 3, 6, 3, 3 }, |
149 | {9,6,3,3,3,6,3,3}, | 150 | { 9, 6, 3, 3, 3, 6, 3, 3 }, |
150 | }; | 151 | }; |
151 | static u8 act_time_value[][8] = { | 152 | static u8 act_time_value[][8] = { |
152 | {0,0,0,0,0,0,0,0}, | 153 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
153 | {0,0,0,0,0,0,0,0}, | 154 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
154 | {9,9,9,2,2,7,2,2}, | 155 | { 9, 9, 9, 2, 2, 7, 2, 2 }, |
155 | {19,19,19,5,4,14,5,4}, | 156 | { 19, 19, 19, 5, 4, 14, 5, 4 }, |
156 | {19,19,19,5,4,14,5,4}, | 157 | { 19, 19, 19, 5, 4, 14, 5, 4 }, |
157 | {28,28,28,7,6,21,7,6}, | 158 | { 28, 28, 28, 7, 6, 21, 7, 6 }, |
158 | {38,38,38,10,9,28,10,9}, | 159 | { 38, 38, 38, 10, 9, 28, 10, 9 }, |
159 | {38,38,38,10,9,28,10,9}, | 160 | { 38, 38, 38, 10, 9, 28, 10, 9 }, |
160 | }; | 161 | }; |
161 | static u8 rco_time_value[][8] = { | 162 | static u8 rco_time_value[][8] = { |
162 | {0,0,0,0,0,0,0,0}, | 163 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
163 | {0,0,0,0,0,0,0,0}, | 164 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
164 | {9,2,0,2,0,7,1,1}, | 165 | { 9, 2, 0, 2, 0, 7, 1, 1 }, |
165 | {19,5,1,5,2,16,3,2}, | 166 | { 19, 5, 1, 5, 2, 16, 3, 2 }, |
166 | {19,5,1,5,2,16,3,2}, | 167 | { 19, 5, 1, 5, 2, 16, 3, 2 }, |
167 | {30,9,3,9,4,25,6,4}, | 168 | { 30, 9, 3, 9, 4, 25, 6, 4 }, |
168 | {40,12,4,12,5,34,12,5}, | 169 | { 40, 12, 4, 12, 5, 34, 12, 5 }, |
169 | {40,12,4,12,5,34,12,5}, | 170 | { 40, 12, 4, 12, 5, 34, 12, 5 }, |
170 | }; | 171 | }; |
171 | 172 | ||
172 | /* | 173 | /* |
173 | * Printing configuration | 174 | * Printing configuration |
174 | */ | 175 | */ |
175 | /* Used for chipset type printing at boot time */ | 176 | /* Used for chipset type printing at boot time */ |
176 | static char* chipset_capability[] = { | 177 | static char *chipset_capability[] = { |
177 | "ATA", "ATA 16", | 178 | "ATA", "ATA 16", |
178 | "ATA 33", "ATA 66", | 179 | "ATA 33", "ATA 66", |
179 | "ATA 100 (1st gen)", "ATA 100 (2nd gen)", | 180 | "ATA 100 (1st gen)", "ATA 100 (2nd gen)", |
@@ -272,7 +273,7 @@ static void sis_program_timings(ide_drive_t *drive, const u8 mode) | |||
272 | sis_ata133_program_timings(drive, mode); | 273 | sis_ata133_program_timings(drive, mode); |
273 | } | 274 | } |
274 | 275 | ||
275 | static void config_drive_art_rwp (ide_drive_t *drive) | 276 | static void config_drive_art_rwp(ide_drive_t *drive) |
276 | { | 277 | { |
277 | ide_hwif_t *hwif = HWIF(drive); | 278 | ide_hwif_t *hwif = HWIF(drive); |
278 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 279 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -346,7 +347,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
346 | sis_program_timings(drive, speed); | 347 | sis_program_timings(drive, speed); |
347 | } | 348 | } |
348 | 349 | ||
349 | static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | 350 | static u8 sis_ata133_udma_filter(ide_drive_t *drive) |
350 | { | 351 | { |
351 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 352 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
352 | u32 regdw = 0; | 353 | u32 regdw = 0; |
@@ -358,8 +359,7 @@ static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | |||
358 | return (regdw & 0x08) ? ATA_UDMA6 : ATA_UDMA5; | 359 | return (regdw & 0x08) ? ATA_UDMA6 : ATA_UDMA5; |
359 | } | 360 | } |
360 | 361 | ||
361 | /* Chip detection and general config */ | 362 | static int __devinit sis_find_family(struct pci_dev *dev) |
362 | static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name) | ||
363 | { | 363 | { |
364 | struct pci_dev *host; | 364 | struct pci_dev *host; |
365 | int i = 0; | 365 | int i = 0; |
@@ -381,7 +381,7 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c | |||
381 | chipset_family = ATA_100a; | 381 | chipset_family = ATA_100a; |
382 | } | 382 | } |
383 | pci_dev_put(host); | 383 | pci_dev_put(host); |
384 | 384 | ||
385 | printk(KERN_INFO "SIS5513: %s %s controller\n", | 385 | printk(KERN_INFO "SIS5513: %s %s controller\n", |
386 | SiSHostChipInfo[i].name, chipset_capability[chipset_family]); | 386 | SiSHostChipInfo[i].name, chipset_capability[chipset_family]); |
387 | } | 387 | } |
@@ -440,63 +440,60 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c | |||
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | if (!chipset_family) | 443 | return chipset_family; |
444 | return -1; | 444 | } |
445 | 445 | ||
446 | static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev, | ||
447 | const char *name) | ||
448 | { | ||
446 | /* Make general config ops here | 449 | /* Make general config ops here |
447 | 1/ tell IDE channels to operate in Compatibility mode only | 450 | 1/ tell IDE channels to operate in Compatibility mode only |
448 | 2/ tell old chips to allow per drive IDE timings */ | 451 | 2/ tell old chips to allow per drive IDE timings */ |
449 | 452 | ||
450 | { | 453 | u8 reg; |
451 | u8 reg; | 454 | u16 regw; |
452 | u16 regw; | 455 | |
453 | 456 | switch (chipset_family) { | |
454 | switch(chipset_family) { | 457 | case ATA_133: |
455 | case ATA_133: | 458 | /* SiS962 operation mode */ |
456 | /* SiS962 operation mode */ | 459 | pci_read_config_word(dev, 0x50, ®w); |
457 | pci_read_config_word(dev, 0x50, ®w); | 460 | if (regw & 0x08) |
458 | if (regw & 0x08) | 461 | pci_write_config_word(dev, 0x50, regw&0xfff7); |
459 | pci_write_config_word(dev, 0x50, regw&0xfff7); | 462 | pci_read_config_word(dev, 0x52, ®w); |
460 | pci_read_config_word(dev, 0x52, ®w); | 463 | if (regw & 0x08) |
461 | if (regw & 0x08) | 464 | pci_write_config_word(dev, 0x52, regw&0xfff7); |
462 | pci_write_config_word(dev, 0x52, regw&0xfff7); | 465 | break; |
463 | break; | 466 | case ATA_133a: |
464 | case ATA_133a: | 467 | case ATA_100: |
465 | case ATA_100: | 468 | /* Fixup latency */ |
466 | /* Fixup latency */ | 469 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x80); |
467 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x80); | 470 | /* Set compatibility bit */ |
468 | /* Set compatibility bit */ | 471 | pci_read_config_byte(dev, 0x49, ®); |
469 | pci_read_config_byte(dev, 0x49, ®); | 472 | if (!(reg & 0x01)) |
470 | if (!(reg & 0x01)) { | 473 | pci_write_config_byte(dev, 0x49, reg|0x01); |
471 | pci_write_config_byte(dev, 0x49, reg|0x01); | 474 | break; |
472 | } | 475 | case ATA_100a: |
473 | break; | 476 | case ATA_66: |
474 | case ATA_100a: | 477 | /* Fixup latency */ |
475 | case ATA_66: | 478 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x10); |
476 | /* Fixup latency */ | 479 | |
477 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x10); | 480 | /* On ATA_66 chips the bit was elsewhere */ |
478 | 481 | pci_read_config_byte(dev, 0x52, ®); | |
479 | /* On ATA_66 chips the bit was elsewhere */ | 482 | if (!(reg & 0x04)) |
480 | pci_read_config_byte(dev, 0x52, ®); | 483 | pci_write_config_byte(dev, 0x52, reg|0x04); |
481 | if (!(reg & 0x04)) { | 484 | break; |
482 | pci_write_config_byte(dev, 0x52, reg|0x04); | 485 | case ATA_33: |
483 | } | 486 | /* On ATA_33 we didn't have a single bit to set */ |
484 | break; | 487 | pci_read_config_byte(dev, 0x09, ®); |
485 | case ATA_33: | 488 | if ((reg & 0x0f) != 0x00) |
486 | /* On ATA_33 we didn't have a single bit to set */ | 489 | pci_write_config_byte(dev, 0x09, reg&0xf0); |
487 | pci_read_config_byte(dev, 0x09, ®); | 490 | case ATA_16: |
488 | if ((reg & 0x0f) != 0x00) { | 491 | /* force per drive recovery and active timings |
489 | pci_write_config_byte(dev, 0x09, reg&0xf0); | 492 | needed on ATA_33 and below chips */ |
490 | } | 493 | pci_read_config_byte(dev, 0x52, ®); |
491 | case ATA_16: | 494 | if (!(reg & 0x08)) |
492 | /* force per drive recovery and active timings | 495 | pci_write_config_byte(dev, 0x52, reg|0x08); |
493 | needed on ATA_33 and below chips */ | 496 | break; |
494 | pci_read_config_byte(dev, 0x52, ®); | ||
495 | if (!(reg & 0x08)) { | ||
496 | pci_write_config_byte(dev, 0x52, reg|0x08); | ||
497 | } | ||
498 | break; | ||
499 | } | ||
500 | } | 497 | } |
501 | 498 | ||
502 | return 0; | 499 | return 0; |
@@ -517,7 +514,7 @@ static const struct sis_laptop sis_laptop[] = { | |||
517 | { 0, } | 514 | { 0, } |
518 | }; | 515 | }; |
519 | 516 | ||
520 | static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | 517 | static u8 __devinit sis_cable_detect(ide_hwif_t *hwif) |
521 | { | 518 | { |
522 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 519 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
523 | const struct sis_laptop *lap = &sis_laptop[0]; | 520 | const struct sis_laptop *lap = &sis_laptop[0]; |
@@ -546,38 +543,44 @@ static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | |||
546 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 543 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
547 | } | 544 | } |
548 | 545 | ||
549 | static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) | 546 | static const struct ide_port_ops sis_port_ops = { |
550 | { | 547 | .set_pio_mode = sis_set_pio_mode, |
551 | u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f }; | 548 | .set_dma_mode = sis_set_dma_mode, |
552 | 549 | .cable_detect = sis_cable_detect, | |
553 | hwif->set_pio_mode = &sis_set_pio_mode; | 550 | }; |
554 | hwif->set_dma_mode = &sis_set_dma_mode; | ||
555 | |||
556 | if (chipset_family >= ATA_133) | ||
557 | hwif->udma_filter = sis5513_ata133_udma_filter; | ||
558 | |||
559 | hwif->cable_detect = ata66_sis5513; | ||
560 | |||
561 | if (hwif->dma_base == 0) | ||
562 | return; | ||
563 | 551 | ||
564 | hwif->ultra_mask = udma_rates[chipset_family]; | 552 | static const struct ide_port_ops sis_ata133_port_ops = { |
565 | } | 553 | .set_pio_mode = sis_set_pio_mode, |
554 | .set_dma_mode = sis_set_dma_mode, | ||
555 | .udma_filter = sis_ata133_udma_filter, | ||
556 | .cable_detect = sis_cable_detect, | ||
557 | }; | ||
566 | 558 | ||
567 | static const struct ide_port_info sis5513_chipset __devinitdata = { | 559 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
568 | .name = "SIS5513", | 560 | .name = "SIS5513", |
569 | .init_chipset = init_chipset_sis5513, | 561 | .init_chipset = init_chipset_sis5513, |
570 | .init_hwif = init_hwif_sis5513, | 562 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, |
571 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 563 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, |
572 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA | | ||
573 | IDE_HFLAG_BOOTABLE, | ||
574 | .pio_mask = ATA_PIO4, | 564 | .pio_mask = ATA_PIO4, |
575 | .mwdma_mask = ATA_MWDMA2, | 565 | .mwdma_mask = ATA_MWDMA2, |
576 | }; | 566 | }; |
577 | 567 | ||
578 | static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 568 | static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
579 | { | 569 | { |
580 | return ide_setup_pci_device(dev, &sis5513_chipset); | 570 | struct ide_port_info d = sis5513_chipset; |
571 | u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f }; | ||
572 | |||
573 | if (sis_find_family(dev) == 0) | ||
574 | return -ENOTSUPP; | ||
575 | |||
576 | if (chipset_family >= ATA_133) | ||
577 | d.port_ops = &sis_ata133_port_ops; | ||
578 | else | ||
579 | d.port_ops = &sis_port_ops; | ||
580 | |||
581 | d.udma_mask = udma_rates[chipset_family]; | ||
582 | |||
583 | return ide_setup_pci_device(dev, &d); | ||
581 | } | 584 | } |
582 | 585 | ||
583 | static const struct pci_device_id sis5513_pci_tbl[] = { | 586 | static const struct pci_device_id sis5513_pci_tbl[] = { |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 1f00251a4a87..ce84fa045d39 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -179,7 +179,7 @@ static void sl82c105_dma_start(ide_drive_t *drive) | |||
179 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 179 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
180 | int reg = 0x44 + drive->dn * 4; | 180 | int reg = 0x44 + drive->dn * 4; |
181 | 181 | ||
182 | DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); | 182 | DBG(("%s(drive:%s)\n", __func__, drive->name)); |
183 | 183 | ||
184 | pci_write_config_word(dev, reg, drive->drive_data >> 16); | 184 | pci_write_config_word(dev, reg, drive->drive_data >> 16); |
185 | 185 | ||
@@ -203,7 +203,7 @@ static int sl82c105_dma_end(ide_drive_t *drive) | |||
203 | int reg = 0x44 + drive->dn * 4; | 203 | int reg = 0x44 + drive->dn * 4; |
204 | int ret; | 204 | int ret; |
205 | 205 | ||
206 | DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); | 206 | DBG(("%s(drive:%s)\n", __func__, drive->name)); |
207 | 207 | ||
208 | ret = __ide_dma_end(drive); | 208 | ret = __ide_dma_end(drive); |
209 | 209 | ||
@@ -232,7 +232,7 @@ static void sl82c105_resetproc(ide_drive_t *drive) | |||
232 | * Return the revision of the Winbond bridge | 232 | * Return the revision of the Winbond bridge |
233 | * which this function is part of. | 233 | * which this function is part of. |
234 | */ | 234 | */ |
235 | static unsigned int sl82c105_bridge_revision(struct pci_dev *dev) | 235 | static u8 sl82c105_bridge_revision(struct pci_dev *dev) |
236 | { | 236 | { |
237 | struct pci_dev *bridge; | 237 | struct pci_dev *bridge; |
238 | 238 | ||
@@ -282,64 +282,59 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c | |||
282 | return dev->irq; | 282 | return dev->irq; |
283 | } | 283 | } |
284 | 284 | ||
285 | /* | 285 | static const struct ide_port_ops sl82c105_port_ops = { |
286 | * Initialise IDE channel | 286 | .set_pio_mode = sl82c105_set_pio_mode, |
287 | */ | 287 | .set_dma_mode = sl82c105_set_dma_mode, |
288 | static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | 288 | .resetproc = sl82c105_resetproc, |
289 | { | 289 | }; |
290 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
291 | unsigned int rev; | ||
292 | |||
293 | DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); | ||
294 | |||
295 | hwif->set_pio_mode = &sl82c105_set_pio_mode; | ||
296 | hwif->set_dma_mode = &sl82c105_set_dma_mode; | ||
297 | hwif->resetproc = &sl82c105_resetproc; | ||
298 | |||
299 | if (!hwif->dma_base) | ||
300 | return; | ||
301 | |||
302 | rev = sl82c105_bridge_revision(dev); | ||
303 | if (rev <= 5) { | ||
304 | /* | ||
305 | * Never ever EVER under any circumstances enable | ||
306 | * DMA when the bridge is this old. | ||
307 | */ | ||
308 | printk(" %s: Winbond W83C553 bridge revision %d, " | ||
309 | "BM-DMA disabled\n", hwif->name, rev); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | hwif->mwdma_mask = ATA_MWDMA2; | ||
314 | |||
315 | hwif->dma_lost_irq = &sl82c105_dma_lost_irq; | ||
316 | hwif->dma_start = &sl82c105_dma_start; | ||
317 | hwif->ide_dma_end = &sl82c105_dma_end; | ||
318 | hwif->dma_timeout = &sl82c105_dma_timeout; | ||
319 | 290 | ||
320 | if (hwif->mate) | 291 | static const struct ide_dma_ops sl82c105_dma_ops = { |
321 | hwif->serialized = hwif->mate->serialized = 1; | 292 | .dma_host_set = ide_dma_host_set, |
322 | } | 293 | .dma_setup = ide_dma_setup, |
294 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
295 | .dma_start = sl82c105_dma_start, | ||
296 | .dma_end = sl82c105_dma_end, | ||
297 | .dma_test_irq = ide_dma_test_irq, | ||
298 | .dma_lost_irq = sl82c105_dma_lost_irq, | ||
299 | .dma_timeout = sl82c105_dma_timeout, | ||
300 | }; | ||
323 | 301 | ||
324 | static const struct ide_port_info sl82c105_chipset __devinitdata = { | 302 | static const struct ide_port_info sl82c105_chipset __devinitdata = { |
325 | .name = "W82C105", | 303 | .name = "W82C105", |
326 | .init_chipset = init_chipset_sl82c105, | 304 | .init_chipset = init_chipset_sl82c105, |
327 | .init_hwif = init_hwif_sl82c105, | ||
328 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, | 305 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, |
306 | .port_ops = &sl82c105_port_ops, | ||
307 | .dma_ops = &sl82c105_dma_ops, | ||
329 | .host_flags = IDE_HFLAG_IO_32BIT | | 308 | .host_flags = IDE_HFLAG_IO_32BIT | |
330 | IDE_HFLAG_UNMASK_IRQS | | 309 | IDE_HFLAG_UNMASK_IRQS | |
331 | /* FIXME: check for Compatibility mode in generic IDE PCI code */ | 310 | /* FIXME: check for Compatibility mode in generic IDE PCI code */ |
332 | #if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT) | 311 | #if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT) |
333 | IDE_HFLAG_FORCE_LEGACY_IRQS | | 312 | IDE_HFLAG_FORCE_LEGACY_IRQS | |
334 | #endif | 313 | #endif |
335 | IDE_HFLAG_NO_AUTODMA | | 314 | IDE_HFLAG_SERIALIZE_DMA | |
336 | IDE_HFLAG_BOOTABLE, | 315 | IDE_HFLAG_NO_AUTODMA, |
337 | .pio_mask = ATA_PIO5, | 316 | .pio_mask = ATA_PIO5, |
317 | .mwdma_mask = ATA_MWDMA2, | ||
338 | }; | 318 | }; |
339 | 319 | ||
340 | static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 320 | static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
341 | { | 321 | { |
342 | return ide_setup_pci_device(dev, &sl82c105_chipset); | 322 | struct ide_port_info d = sl82c105_chipset; |
323 | u8 rev = sl82c105_bridge_revision(dev); | ||
324 | |||
325 | if (rev <= 5) { | ||
326 | /* | ||
327 | * Never ever EVER under any circumstances enable | ||
328 | * DMA when the bridge is this old. | ||
329 | */ | ||
330 | printk(KERN_INFO "W82C105_IDE: Winbond W83C553 bridge " | ||
331 | "revision %d, BM-DMA disabled\n", rev); | ||
332 | d.dma_ops = NULL; | ||
333 | d.mwdma_mask = 0; | ||
334 | d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA; | ||
335 | } | ||
336 | |||
337 | return ide_setup_pci_device(dev, &d); | ||
343 | } | 338 | } |
344 | 339 | ||
345 | static const struct pci_device_id sl82c105_pci_tbl[] = { | 340 | static const struct pci_device_id sl82c105_pci_tbl[] = { |
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index 65f4c2ffaa59..dae6e2c94d86 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
@@ -27,9 +27,9 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
27 | unsigned long flags; | 27 | unsigned long flags; |
28 | u16 master_data; | 28 | u16 master_data; |
29 | u8 slave_data; | 29 | u8 slave_data; |
30 | int control = 0; | 30 | int control = 0; |
31 | /* ISP RTC */ | 31 | /* ISP RTC */ |
32 | static const u8 timings[][2]= { | 32 | static const u8 timings[][2] = { |
33 | { 0, 0 }, | 33 | { 0, 0 }, |
34 | { 0, 0 }, | 34 | { 0, 0 }, |
35 | { 1, 0 }, | 35 | { 1, 0 }, |
@@ -125,19 +125,17 @@ static u8 __devinit slc90e66_cable_detect(ide_hwif_t *hwif) | |||
125 | return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 125 | return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
126 | } | 126 | } |
127 | 127 | ||
128 | static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif) | 128 | static const struct ide_port_ops slc90e66_port_ops = { |
129 | { | 129 | .set_pio_mode = slc90e66_set_pio_mode, |
130 | hwif->set_pio_mode = &slc90e66_set_pio_mode; | 130 | .set_dma_mode = slc90e66_set_dma_mode, |
131 | hwif->set_dma_mode = &slc90e66_set_dma_mode; | 131 | .cable_detect = slc90e66_cable_detect, |
132 | 132 | }; | |
133 | hwif->cable_detect = slc90e66_cable_detect; | ||
134 | } | ||
135 | 133 | ||
136 | static const struct ide_port_info slc90e66_chipset __devinitdata = { | 134 | static const struct ide_port_info slc90e66_chipset __devinitdata = { |
137 | .name = "SLC90E66", | 135 | .name = "SLC90E66", |
138 | .init_hwif = init_hwif_slc90e66, | 136 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, |
139 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, | 137 | .port_ops = &slc90e66_port_ops, |
140 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_BOOTABLE, | 138 | .host_flags = IDE_HFLAG_LEGACY_IRQS, |
141 | .pio_mask = ATA_PIO4, | 139 | .pio_mask = ATA_PIO4, |
142 | .swdma_mask = ATA_SWDMA2_ONLY, | 140 | .swdma_mask = ATA_SWDMA2_ONLY, |
143 | .mwdma_mask = ATA_MWDMA12_ONLY, | 141 | .mwdma_mask = ATA_MWDMA12_ONLY, |
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index 1e4a6262bcef..9b4b27a4c711 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -18,20 +18,20 @@ static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) | |||
18 | u16 mode, scr = inw(scr_port); | 18 | u16 mode, scr = inw(scr_port); |
19 | 19 | ||
20 | switch (speed) { | 20 | switch (speed) { |
21 | case XFER_UDMA_4: mode = 0x00c0; break; | 21 | case XFER_UDMA_4: mode = 0x00c0; break; |
22 | case XFER_UDMA_3: mode = 0x00b0; break; | 22 | case XFER_UDMA_3: mode = 0x00b0; break; |
23 | case XFER_UDMA_2: mode = 0x00a0; break; | 23 | case XFER_UDMA_2: mode = 0x00a0; break; |
24 | case XFER_UDMA_1: mode = 0x0090; break; | 24 | case XFER_UDMA_1: mode = 0x0090; break; |
25 | case XFER_UDMA_0: mode = 0x0080; break; | 25 | case XFER_UDMA_0: mode = 0x0080; break; |
26 | case XFER_MW_DMA_2: mode = 0x0070; break; | 26 | case XFER_MW_DMA_2: mode = 0x0070; break; |
27 | case XFER_MW_DMA_1: mode = 0x0060; break; | 27 | case XFER_MW_DMA_1: mode = 0x0060; break; |
28 | case XFER_MW_DMA_0: mode = 0x0050; break; | 28 | case XFER_MW_DMA_0: mode = 0x0050; break; |
29 | case XFER_PIO_4: mode = 0x0400; break; | 29 | case XFER_PIO_4: mode = 0x0400; break; |
30 | case XFER_PIO_3: mode = 0x0300; break; | 30 | case XFER_PIO_3: mode = 0x0300; break; |
31 | case XFER_PIO_2: mode = 0x0200; break; | 31 | case XFER_PIO_2: mode = 0x0200; break; |
32 | case XFER_PIO_1: mode = 0x0100; break; | 32 | case XFER_PIO_1: mode = 0x0100; break; |
33 | case XFER_PIO_0: | 33 | case XFER_PIO_0: |
34 | default: mode = 0x0000; break; | 34 | default: mode = 0x0000; break; |
35 | } | 35 | } |
36 | 36 | ||
37 | scr &= (speed < XFER_MW_DMA_0) ? 0xf8ff : 0xff0f; | 37 | scr &= (speed < XFER_MW_DMA_0) ? 0xf8ff : 0xff0f; |
@@ -157,11 +157,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
157 | /* Store the system control register base for convenience... */ | 157 | /* Store the system control register base for convenience... */ |
158 | hwif->config_data = sc_base; | 158 | hwif->config_data = sc_base; |
159 | 159 | ||
160 | hwif->set_pio_mode = &tc86c001_set_pio_mode; | ||
161 | hwif->set_dma_mode = &tc86c001_set_mode; | ||
162 | |||
163 | hwif->cable_detect = tc86c001_cable_detect; | ||
164 | |||
165 | if (!hwif->dma_base) | 160 | if (!hwif->dma_base) |
166 | return; | 161 | return; |
167 | 162 | ||
@@ -173,8 +168,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
173 | 168 | ||
174 | /* Sector Count Register limit */ | 169 | /* Sector Count Register limit */ |
175 | hwif->rqsize = 0xffff; | 170 | hwif->rqsize = 0xffff; |
176 | |||
177 | hwif->dma_start = &tc86c001_dma_start; | ||
178 | } | 171 | } |
179 | 172 | ||
180 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | 173 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, |
@@ -187,10 +180,29 @@ static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | |||
187 | return err; | 180 | return err; |
188 | } | 181 | } |
189 | 182 | ||
183 | static const struct ide_port_ops tc86c001_port_ops = { | ||
184 | .set_pio_mode = tc86c001_set_pio_mode, | ||
185 | .set_dma_mode = tc86c001_set_mode, | ||
186 | .cable_detect = tc86c001_cable_detect, | ||
187 | }; | ||
188 | |||
189 | static const struct ide_dma_ops tc86c001_dma_ops = { | ||
190 | .dma_host_set = ide_dma_host_set, | ||
191 | .dma_setup = ide_dma_setup, | ||
192 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
193 | .dma_start = tc86c001_dma_start, | ||
194 | .dma_end = __ide_dma_end, | ||
195 | .dma_test_irq = ide_dma_test_irq, | ||
196 | .dma_lost_irq = ide_dma_lost_irq, | ||
197 | .dma_timeout = ide_dma_timeout, | ||
198 | }; | ||
199 | |||
190 | static const struct ide_port_info tc86c001_chipset __devinitdata = { | 200 | static const struct ide_port_info tc86c001_chipset __devinitdata = { |
191 | .name = "TC86C001", | 201 | .name = "TC86C001", |
192 | .init_chipset = init_chipset_tc86c001, | 202 | .init_chipset = init_chipset_tc86c001, |
193 | .init_hwif = init_hwif_tc86c001, | 203 | .init_hwif = init_hwif_tc86c001, |
204 | .port_ops = &tc86c001_port_ops, | ||
205 | .dma_ops = &tc86c001_dma_ops, | ||
194 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | | 206 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | |
195 | IDE_HFLAG_ABUSE_SET_DMA_MODE, | 207 | IDE_HFLAG_ABUSE_SET_DMA_MODE, |
196 | .pio_mask = ATA_PIO4, | 208 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index a67d02a3f96e..db65a558d4ec 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
@@ -87,17 +87,15 @@ static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
87 | triflex_set_mode(drive, XFER_PIO_0 + pio); | 87 | triflex_set_mode(drive, XFER_PIO_0 + pio); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void __devinit init_hwif_triflex(ide_hwif_t *hwif) | 90 | static const struct ide_port_ops triflex_port_ops = { |
91 | { | 91 | .set_pio_mode = triflex_set_pio_mode, |
92 | hwif->set_pio_mode = &triflex_set_pio_mode; | 92 | .set_dma_mode = triflex_set_mode, |
93 | hwif->set_dma_mode = &triflex_set_mode; | 93 | }; |
94 | } | ||
95 | 94 | ||
96 | static const struct ide_port_info triflex_device __devinitdata = { | 95 | static const struct ide_port_info triflex_device __devinitdata = { |
97 | .name = "TRIFLEX", | 96 | .name = "TRIFLEX", |
98 | .init_hwif = init_hwif_triflex, | ||
99 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, | 97 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, |
100 | .host_flags = IDE_HFLAG_BOOTABLE, | 98 | .port_ops = &triflex_port_ops, |
101 | .pio_mask = ATA_PIO4, | 99 | .pio_mask = ATA_PIO4, |
102 | .swdma_mask = ATA_SWDMA2, | 100 | .swdma_mask = ATA_SWDMA2, |
103 | .mwdma_mask = ATA_MWDMA2, | 101 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index de750f7a43e9..a8a3138682ef 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
@@ -214,7 +214,7 @@ static void trm290_dma_start(ide_drive_t *drive) | |||
214 | { | 214 | { |
215 | } | 215 | } |
216 | 216 | ||
217 | static int trm290_ide_dma_end (ide_drive_t *drive) | 217 | static int trm290_dma_end(ide_drive_t *drive) |
218 | { | 218 | { |
219 | u16 status; | 219 | u16 status; |
220 | 220 | ||
@@ -225,7 +225,7 @@ static int trm290_ide_dma_end (ide_drive_t *drive) | |||
225 | return status != 0x00ff; | 225 | return status != 0x00ff; |
226 | } | 226 | } |
227 | 227 | ||
228 | static int trm290_ide_dma_test_irq (ide_drive_t *drive) | 228 | static int trm290_dma_test_irq(ide_drive_t *drive) |
229 | { | 229 | { |
230 | u16 status; | 230 | u16 status; |
231 | 231 | ||
@@ -254,22 +254,11 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
254 | hwif->config_data = cfg_base; | 254 | hwif->config_data = cfg_base; |
255 | hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); | 255 | hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); |
256 | 256 | ||
257 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | 257 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
258 | hwif->name, hwif->dma_base, hwif->dma_base + 3); | 258 | hwif->name, hwif->dma_base, hwif->dma_base + 3); |
259 | 259 | ||
260 | if (!request_region(hwif->dma_base, 4, hwif->name)) { | 260 | if (ide_allocate_dma_engine(hwif)) |
261 | printk(KERN_CONT " -- Error, ports in use.\n"); | ||
262 | return; | 261 | return; |
263 | } | ||
264 | |||
265 | hwif->dmatable_cpu = pci_alloc_consistent(dev, PRD_ENTRIES * PRD_BYTES, | ||
266 | &hwif->dmatable_dma); | ||
267 | if (!hwif->dmatable_cpu) { | ||
268 | printk(KERN_CONT " -- Error, unable to allocate DMA table.\n"); | ||
269 | release_region(hwif->dma_base, 4); | ||
270 | return; | ||
271 | } | ||
272 | printk(KERN_CONT "\n"); | ||
273 | 262 | ||
274 | local_irq_save(flags); | 263 | local_irq_save(flags); |
275 | /* put config reg into first byte of hwif->select_data */ | 264 | /* put config reg into first byte of hwif->select_data */ |
@@ -291,14 +280,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
291 | /* sharing IRQ with mate */ | 280 | /* sharing IRQ with mate */ |
292 | hwif->irq = hwif->mate->irq; | 281 | hwif->irq = hwif->mate->irq; |
293 | 282 | ||
294 | hwif->dma_host_set = &trm290_dma_host_set; | ||
295 | hwif->dma_setup = &trm290_dma_setup; | ||
296 | hwif->dma_exec_cmd = &trm290_dma_exec_cmd; | ||
297 | hwif->dma_start = &trm290_dma_start; | ||
298 | hwif->ide_dma_end = &trm290_ide_dma_end; | ||
299 | hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq; | ||
300 | |||
301 | hwif->selectproc = &trm290_selectproc; | ||
302 | #if 1 | 283 | #if 1 |
303 | { | 284 | { |
304 | /* | 285 | /* |
@@ -317,7 +298,7 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
317 | if (old != compat && old_mask == 0xff) { | 298 | if (old != compat && old_mask == 0xff) { |
318 | /* leave lower 10 bits untouched */ | 299 | /* leave lower 10 bits untouched */ |
319 | compat += (next_offset += 0x400); | 300 | compat += (next_offset += 0x400); |
320 | hwif->io_ports[IDE_CONTROL_OFFSET] = compat + 2; | 301 | hwif->io_ports.ctl_addr = compat + 2; |
321 | outw(compat | 1, hwif->config_data); | 302 | outw(compat | 1, hwif->config_data); |
322 | new = inw(hwif->config_data); | 303 | new = inw(hwif->config_data); |
323 | printk(KERN_INFO "%s: control basereg workaround: " | 304 | printk(KERN_INFO "%s: control basereg workaround: " |
@@ -328,16 +309,32 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
328 | #endif | 309 | #endif |
329 | } | 310 | } |
330 | 311 | ||
312 | static const struct ide_port_ops trm290_port_ops = { | ||
313 | .selectproc = trm290_selectproc, | ||
314 | }; | ||
315 | |||
316 | static struct ide_dma_ops trm290_dma_ops = { | ||
317 | .dma_host_set = trm290_dma_host_set, | ||
318 | .dma_setup = trm290_dma_setup, | ||
319 | .dma_exec_cmd = trm290_dma_exec_cmd, | ||
320 | .dma_start = trm290_dma_start, | ||
321 | .dma_end = trm290_dma_end, | ||
322 | .dma_test_irq = trm290_dma_test_irq, | ||
323 | .dma_lost_irq = ide_dma_lost_irq, | ||
324 | .dma_timeout = ide_dma_timeout, | ||
325 | }; | ||
326 | |||
331 | static const struct ide_port_info trm290_chipset __devinitdata = { | 327 | static const struct ide_port_info trm290_chipset __devinitdata = { |
332 | .name = "TRM290", | 328 | .name = "TRM290", |
333 | .init_hwif = init_hwif_trm290, | 329 | .init_hwif = init_hwif_trm290, |
334 | .chipset = ide_trm290, | 330 | .chipset = ide_trm290, |
331 | .port_ops = &trm290_port_ops, | ||
332 | .dma_ops = &trm290_dma_ops, | ||
335 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 333 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
336 | #if 0 /* play it safe for now */ | 334 | #if 0 /* play it safe for now */ |
337 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 335 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
338 | #endif | 336 | #endif |
339 | IDE_HFLAG_NO_AUTODMA | | 337 | IDE_HFLAG_NO_AUTODMA | |
340 | IDE_HFLAG_BOOTABLE | | ||
341 | IDE_HFLAG_NO_LBA48, | 338 | IDE_HFLAG_NO_LBA48, |
342 | }; | 339 | }; |
343 | 340 | ||
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 9004e7521889..566e0ecb8db1 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -340,7 +340,7 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const | |||
340 | * Determine system bus clock. | 340 | * Determine system bus clock. |
341 | */ | 341 | */ |
342 | 342 | ||
343 | via_clock = system_bus_clock() * 1000; | 343 | via_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; |
344 | 344 | ||
345 | switch (via_clock) { | 345 | switch (via_clock) { |
346 | case 33000: via_clock = 33333; break; | 346 | case 33000: via_clock = 33333; break; |
@@ -415,25 +415,21 @@ static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) | |||
415 | return ATA_CBL_PATA40; | 415 | return ATA_CBL_PATA40; |
416 | } | 416 | } |
417 | 417 | ||
418 | static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) | 418 | static const struct ide_port_ops via_port_ops = { |
419 | { | 419 | .set_pio_mode = via_set_pio_mode, |
420 | hwif->set_pio_mode = &via_set_pio_mode; | 420 | .set_dma_mode = via_set_drive, |
421 | hwif->set_dma_mode = &via_set_drive; | 421 | .cable_detect = via82cxxx_cable_detect, |
422 | 422 | }; | |
423 | hwif->cable_detect = via82cxxx_cable_detect; | ||
424 | } | ||
425 | 423 | ||
426 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { | 424 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { |
427 | .name = "VP_IDE", | 425 | .name = "VP_IDE", |
428 | .init_chipset = init_chipset_via82cxxx, | 426 | .init_chipset = init_chipset_via82cxxx, |
429 | .init_hwif = init_hwif_via82cxxx, | ||
430 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, | 427 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, |
428 | .port_ops = &via_port_ops, | ||
431 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | | 429 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | |
432 | IDE_HFLAG_PIO_NO_DOWNGRADE | | ||
433 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 430 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
434 | IDE_HFLAG_POST_SET_MODE | | 431 | IDE_HFLAG_POST_SET_MODE | |
435 | IDE_HFLAG_IO_32BIT | | 432 | IDE_HFLAG_IO_32BIT, |
436 | IDE_HFLAG_BOOTABLE, | ||
437 | .pio_mask = ATA_PIO5, | 433 | .pio_mask = ATA_PIO5, |
438 | .swdma_mask = ATA_SWDMA2, | 434 | .swdma_mask = ATA_SWDMA2, |
439 | .mwdma_mask = ATA_MWDMA2, | 435 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c index a784a97ca7ec..f0e638dcc3ab 100644 --- a/drivers/ide/ppc/mpc8xx.c +++ b/drivers/ide/ppc/mpc8xx.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <asm/machdep.h> | 36 | #include <asm/machdep.h> |
37 | #include <asm/irq.h> | 37 | #include <asm/irq.h> |
38 | 38 | ||
39 | #define DRV_NAME "ide-mpc8xx" | ||
40 | |||
39 | static int identify (volatile u8 *p); | 41 | static int identify (volatile u8 *p); |
40 | static void print_fixed (volatile u8 *p); | 42 | static void print_fixed (volatile u8 *p); |
41 | static void print_funcid (int func); | 43 | static void print_funcid (int func); |
@@ -127,9 +129,9 @@ static int pcmcia_schlvl = PCMCIA_SCHLVL; | |||
127 | * MPC8xx's internal PCMCIA interface | 129 | * MPC8xx's internal PCMCIA interface |
128 | */ | 130 | */ |
129 | #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT) | 131 | #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT) |
130 | static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | 132 | static int __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) |
131 | { | 133 | { |
132 | unsigned long *p = hw->io_ports; | 134 | unsigned long *p = hw->io_ports_array; |
133 | int i; | 135 | int i; |
134 | 136 | ||
135 | typedef struct { | 137 | typedef struct { |
@@ -182,6 +184,13 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
182 | pcmcia_phy_base, pcmcia_phy_end, | 184 | pcmcia_phy_base, pcmcia_phy_end, |
183 | pcmcia_phy_end - pcmcia_phy_base); | 185 | pcmcia_phy_end - pcmcia_phy_base); |
184 | 186 | ||
187 | if (!request_mem_region(pcmcia_phy_base, | ||
188 | pcmcia_phy_end - pcmcia_phy_base, | ||
189 | DRV_NAME)) { | ||
190 | printk(KERN_ERR "%s: resources busy\n", DRV_NAME); | ||
191 | return -EBUSY; | ||
192 | } | ||
193 | |||
185 | pcmcia_base=(unsigned long)ioremap(pcmcia_phy_base, | 194 | pcmcia_base=(unsigned long)ioremap(pcmcia_phy_base, |
186 | pcmcia_phy_end-pcmcia_phy_base); | 195 | pcmcia_phy_end-pcmcia_phy_base); |
187 | 196 | ||
@@ -236,7 +245,7 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
236 | if (pcmp->pcmc_pipr & (M8XX_PCMCIA_CD1(_slot_)|M8XX_PCMCIA_CD2(_slot_))) { | 245 | if (pcmp->pcmc_pipr & (M8XX_PCMCIA_CD1(_slot_)|M8XX_PCMCIA_CD2(_slot_))) { |
237 | printk ("No card in slot %c: PIPR=%08x\n", | 246 | printk ("No card in slot %c: PIPR=%08x\n", |
238 | 'A' + _slot_, (u32) pcmp->pcmc_pipr); | 247 | 'A' + _slot_, (u32) pcmp->pcmc_pipr); |
239 | return; /* No card in slot */ | 248 | return -ENODEV; /* No card in slot */ |
240 | } | 249 | } |
241 | 250 | ||
242 | check_ide_device (pcmcia_base); | 251 | check_ide_device (pcmcia_base); |
@@ -279,9 +288,6 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
279 | } | 288 | } |
280 | #endif /* CONFIG_IDE_8xx_PCCARD */ | 289 | #endif /* CONFIG_IDE_8xx_PCCARD */ |
281 | 290 | ||
282 | ide_hwifs[data_port].pio_mask = ATA_PIO4; | ||
283 | ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode; | ||
284 | |||
285 | /* Enable Harddisk Interrupt, | 291 | /* Enable Harddisk Interrupt, |
286 | * and make it edge sensitive | 292 | * and make it edge sensitive |
287 | */ | 293 | */ |
@@ -296,6 +302,8 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
296 | /* Enable falling edge irq */ | 302 | /* Enable falling edge irq */ |
297 | pcmp->pcmc_per = 0x100000 >> (16 * _slot_); | 303 | pcmp->pcmc_per = 0x100000 >> (16 * _slot_); |
298 | #endif /* CONFIG_IDE_8xx_PCCARD */ | 304 | #endif /* CONFIG_IDE_8xx_PCCARD */ |
305 | |||
306 | return 0; | ||
299 | } | 307 | } |
300 | #endif /* CONFIG_IDE_8xx_PCCARD || CONFIG_IDE_8xx_DIRECT */ | 308 | #endif /* CONFIG_IDE_8xx_PCCARD || CONFIG_IDE_8xx_DIRECT */ |
301 | 309 | ||
@@ -304,9 +312,9 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
304 | * MPC8xx's internal PCMCIA interface | 312 | * MPC8xx's internal PCMCIA interface |
305 | */ | 313 | */ |
306 | #if defined(CONFIG_IDE_EXT_DIRECT) | 314 | #if defined(CONFIG_IDE_EXT_DIRECT) |
307 | static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | 315 | static int __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) |
308 | { | 316 | { |
309 | unsigned long *p = hw->io_ports; | 317 | unsigned long *p = hw->io_ports_array; |
310 | int i; | 318 | int i; |
311 | 319 | ||
312 | u32 ide_phy_base; | 320 | u32 ide_phy_base; |
@@ -327,7 +335,12 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
327 | printk ("IDE phys mem : %08x...%08x (size %08x)\n", | 335 | printk ("IDE phys mem : %08x...%08x (size %08x)\n", |
328 | ide_phy_base, ide_phy_end, | 336 | ide_phy_base, ide_phy_end, |
329 | ide_phy_end - ide_phy_base); | 337 | ide_phy_end - ide_phy_base); |
330 | 338 | ||
339 | if (!request_mem_region(ide_phy_base, 0x200, DRV_NAME)) { | ||
340 | printk(KERN_ERR "%s: resources busy\n", DRV_NAME); | ||
341 | return -EBUSY; | ||
342 | } | ||
343 | |||
331 | ide_base=(unsigned long)ioremap(ide_phy_base, | 344 | ide_base=(unsigned long)ioremap(ide_phy_base, |
332 | ide_phy_end-ide_phy_base); | 345 | ide_phy_end-ide_phy_base); |
333 | 346 | ||
@@ -357,15 +370,14 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port) | |||
357 | hw->irq = ioport_dsc[data_port].irq; | 370 | hw->irq = ioport_dsc[data_port].irq; |
358 | hw->ack_intr = (ide_ack_intr_t *)ide_interrupt_ack; | 371 | hw->ack_intr = (ide_ack_intr_t *)ide_interrupt_ack; |
359 | 372 | ||
360 | ide_hwifs[data_port].pio_mask = ATA_PIO4; | ||
361 | ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode; | ||
362 | |||
363 | /* Enable Harddisk Interrupt, | 373 | /* Enable Harddisk Interrupt, |
364 | * and make it edge sensitive | 374 | * and make it edge sensitive |
365 | */ | 375 | */ |
366 | /* (11-18) Set edge detect for irq, no wakeup from low power mode */ | 376 | /* (11-18) Set edge detect for irq, no wakeup from low power mode */ |
367 | ((immap_t *) IMAP_ADDR)->im_siu_conf.sc_siel |= | 377 | ((immap_t *) IMAP_ADDR)->im_siu_conf.sc_siel |= |
368 | (0x80000000 >> ioport_dsc[data_port].irq); | 378 | (0x80000000 >> ioport_dsc[data_port].irq); |
379 | |||
380 | return 0; | ||
369 | } | 381 | } |
370 | #endif /* CONFIG_IDE_8xx_DIRECT */ | 382 | #endif /* CONFIG_IDE_8xx_DIRECT */ |
371 | 383 | ||
@@ -426,10 +438,14 @@ static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
426 | #elif defined(CONFIG_IDE_EXT_DIRECT) | 438 | #elif defined(CONFIG_IDE_EXT_DIRECT) |
427 | 439 | ||
428 | printk("%s[%d] %s: not implemented yet!\n", | 440 | printk("%s[%d] %s: not implemented yet!\n", |
429 | __FILE__,__LINE__,__FUNCTION__); | 441 | __FILE__, __LINE__, __func__); |
430 | #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */ | 442 | #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */ |
431 | } | 443 | } |
432 | 444 | ||
445 | static const struct ide_port_ops m8xx_port_ops = { | ||
446 | .set_pio_mode = m8xx_ide_set_pio_mode, | ||
447 | }; | ||
448 | |||
433 | static void | 449 | static void |
434 | ide_interrupt_ack (void *dev) | 450 | ide_interrupt_ack (void *dev) |
435 | { | 451 | { |
@@ -794,14 +810,30 @@ static int __init mpc8xx_ide_probe(void) | |||
794 | 810 | ||
795 | #ifdef IDE0_BASE_OFFSET | 811 | #ifdef IDE0_BASE_OFFSET |
796 | memset(&hw, 0, sizeof(hw)); | 812 | memset(&hw, 0, sizeof(hw)); |
797 | m8xx_ide_init_ports(&hw, 0); | 813 | if (!m8xx_ide_init_ports(&hw, 0)) { |
798 | ide_init_port_hw(&ide_hwifs[0], &hw); | 814 | ide_hwif_t *hwif = ide_find_port(); |
799 | idx[0] = 0; | 815 | |
816 | if (hwif) { | ||
817 | ide_init_port_hw(hwif, &hw); | ||
818 | hwif->pio_mask = ATA_PIO4; | ||
819 | hwif->port_ops = &m8xx_port_ops; | ||
820 | |||
821 | idx[0] = hwif->index; | ||
822 | } | ||
823 | } | ||
800 | #ifdef IDE1_BASE_OFFSET | 824 | #ifdef IDE1_BASE_OFFSET |
801 | memset(&hw, 0, sizeof(hw)); | 825 | memset(&hw, 0, sizeof(hw)); |
802 | m8xx_ide_init_ports(&hw, 1); | 826 | if (!m8xx_ide_init_ports(&hw, 1)) { |
803 | ide_init_port_hw(&ide_hwifs[1], &hw); | 827 | ide_hwif_t *mate = ide_find_port(); |
804 | idx[1] = 1; | 828 | |
829 | if (mate) { | ||
830 | ide_init_port_hw(mate, &hw); | ||
831 | mate->pio_mask = ATA_PIO4; | ||
832 | mate->port_ops = &m8xx_port_ops; | ||
833 | |||
834 | idx[1] = mate->index; | ||
835 | } | ||
836 | } | ||
805 | #endif | 837 | #endif |
806 | #endif | 838 | #endif |
807 | 839 | ||
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 88619b50d9ef..3cac6b2790dd 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -79,8 +79,6 @@ typedef struct pmac_ide_hwif { | |||
79 | 79 | ||
80 | } pmac_ide_hwif_t; | 80 | } pmac_ide_hwif_t; |
81 | 81 | ||
82 | static pmac_ide_hwif_t pmac_ide[MAX_HWIFS]; | ||
83 | |||
84 | enum { | 82 | enum { |
85 | controller_ohare, /* OHare based */ | 83 | controller_ohare, /* OHare based */ |
86 | controller_heathrow, /* Heathrow/Paddington */ | 84 | controller_heathrow, /* Heathrow/Paddington */ |
@@ -411,7 +409,7 @@ kauai_lookup_timing(struct kauai_timing* table, int cycle_time) | |||
411 | */ | 409 | */ |
412 | #define IDE_WAKEUP_DELAY (1*HZ) | 410 | #define IDE_WAKEUP_DELAY (1*HZ) |
413 | 411 | ||
414 | static int pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); | 412 | static int pmac_ide_init_dma(ide_hwif_t *, const struct ide_port_info *); |
415 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); | 413 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); |
416 | static void pmac_ide_selectproc(ide_drive_t *drive); | 414 | static void pmac_ide_selectproc(ide_drive_t *drive); |
417 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | 415 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); |
@@ -419,7 +417,7 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | |||
419 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 417 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
420 | 418 | ||
421 | #define PMAC_IDE_REG(x) \ | 419 | #define PMAC_IDE_REG(x) \ |
422 | ((void __iomem *)((drive)->hwif->io_ports[IDE_DATA_OFFSET] + (x))) | 420 | ((void __iomem *)((drive)->hwif->io_ports.data_addr + (x))) |
423 | 421 | ||
424 | /* | 422 | /* |
425 | * Apply the timings of the proper unit (master/slave) to the shared | 423 | * Apply the timings of the proper unit (master/slave) to the shared |
@@ -920,12 +918,29 @@ pmac_ide_do_resume(ide_hwif_t *hwif) | |||
920 | return 0; | 918 | return 0; |
921 | } | 919 | } |
922 | 920 | ||
921 | static const struct ide_port_ops pmac_ide_ata6_port_ops = { | ||
922 | .set_pio_mode = pmac_ide_set_pio_mode, | ||
923 | .set_dma_mode = pmac_ide_set_dma_mode, | ||
924 | .selectproc = pmac_ide_kauai_selectproc, | ||
925 | }; | ||
926 | |||
927 | static const struct ide_port_ops pmac_ide_port_ops = { | ||
928 | .set_pio_mode = pmac_ide_set_pio_mode, | ||
929 | .set_dma_mode = pmac_ide_set_dma_mode, | ||
930 | .selectproc = pmac_ide_selectproc, | ||
931 | }; | ||
932 | |||
933 | static const struct ide_dma_ops pmac_dma_ops; | ||
934 | |||
923 | static const struct ide_port_info pmac_port_info = { | 935 | static const struct ide_port_info pmac_port_info = { |
936 | .init_dma = pmac_ide_init_dma, | ||
924 | .chipset = ide_pmac, | 937 | .chipset = ide_pmac, |
938 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | ||
939 | .dma_ops = &pmac_dma_ops, | ||
940 | #endif | ||
941 | .port_ops = &pmac_ide_port_ops, | ||
925 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | 942 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | |
926 | IDE_HFLAG_PIO_NO_DOWNGRADE | | ||
927 | IDE_HFLAG_POST_SET_MODE | | 943 | IDE_HFLAG_POST_SET_MODE | |
928 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
929 | IDE_HFLAG_UNMASK_IRQS, | 944 | IDE_HFLAG_UNMASK_IRQS, |
930 | .pio_mask = ATA_PIO4, | 945 | .pio_mask = ATA_PIO4, |
931 | .mwdma_mask = ATA_MWDMA2, | 946 | .mwdma_mask = ATA_MWDMA2, |
@@ -950,12 +965,15 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
950 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 965 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
951 | if (of_device_is_compatible(np, "shasta-ata")) { | 966 | if (of_device_is_compatible(np, "shasta-ata")) { |
952 | pmif->kind = controller_sh_ata6; | 967 | pmif->kind = controller_sh_ata6; |
968 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
953 | d.udma_mask = ATA_UDMA6; | 969 | d.udma_mask = ATA_UDMA6; |
954 | } else if (of_device_is_compatible(np, "kauai-ata")) { | 970 | } else if (of_device_is_compatible(np, "kauai-ata")) { |
955 | pmif->kind = controller_un_ata6; | 971 | pmif->kind = controller_un_ata6; |
972 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
956 | d.udma_mask = ATA_UDMA5; | 973 | d.udma_mask = ATA_UDMA5; |
957 | } else if (of_device_is_compatible(np, "K2-UATA")) { | 974 | } else if (of_device_is_compatible(np, "K2-UATA")) { |
958 | pmif->kind = controller_k2_ata6; | 975 | pmif->kind = controller_k2_ata6; |
976 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
959 | d.udma_mask = ATA_UDMA5; | 977 | d.udma_mask = ATA_UDMA5; |
960 | } else if (of_device_is_compatible(np, "keylargo-ata")) { | 978 | } else if (of_device_is_compatible(np, "keylargo-ata")) { |
961 | if (strcmp(np->name, "ata-4") == 0) { | 979 | if (strcmp(np->name, "ata-4") == 0) { |
@@ -1032,37 +1050,29 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
1032 | default_hwif_mmiops(hwif); | 1050 | default_hwif_mmiops(hwif); |
1033 | hwif->OUTBSYNC = pmac_outbsync; | 1051 | hwif->OUTBSYNC = pmac_outbsync; |
1034 | 1052 | ||
1035 | /* Tell common code _not_ to mess with resources */ | ||
1036 | hwif->mmio = 1; | ||
1037 | hwif->hwif_data = pmif; | 1053 | hwif->hwif_data = pmif; |
1038 | ide_init_port_hw(hwif, hw); | 1054 | ide_init_port_hw(hwif, hw); |
1039 | hwif->noprobe = pmif->mediabay; | ||
1040 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 1055 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
1041 | hwif->set_pio_mode = pmac_ide_set_pio_mode; | ||
1042 | if (pmif->kind == controller_un_ata6 | ||
1043 | || pmif->kind == controller_k2_ata6 | ||
1044 | || pmif->kind == controller_sh_ata6) | ||
1045 | hwif->selectproc = pmac_ide_kauai_selectproc; | ||
1046 | else | ||
1047 | hwif->selectproc = pmac_ide_selectproc; | ||
1048 | hwif->set_dma_mode = pmac_ide_set_dma_mode; | ||
1049 | 1056 | ||
1050 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", | 1057 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", |
1051 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, | 1058 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, |
1052 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); | 1059 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); |
1053 | 1060 | ||
1061 | if (pmif->mediabay) { | ||
1054 | #ifdef CONFIG_PMAC_MEDIABAY | 1062 | #ifdef CONFIG_PMAC_MEDIABAY |
1055 | if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0) | 1063 | if (check_media_bay_by_base(pmif->regbase, MB_CD)) { |
1056 | hwif->noprobe = 0; | 1064 | #else |
1057 | #endif /* CONFIG_PMAC_MEDIABAY */ | 1065 | if (1) { |
1066 | #endif | ||
1067 | hwif->drives[0].noprobe = 1; | ||
1068 | hwif->drives[1].noprobe = 1; | ||
1069 | } | ||
1070 | } | ||
1058 | 1071 | ||
1059 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 1072 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
1060 | if (pmif->cable_80 == 0) | 1073 | if (pmif->cable_80 == 0) |
1061 | d.udma_mask &= ATA_UDMA2; | 1074 | d.udma_mask &= ATA_UDMA2; |
1062 | /* has a DBDMA controller channel */ | ||
1063 | if (pmif->dma_regs == 0 || pmac_ide_setup_dma(pmif, hwif) < 0) | ||
1064 | #endif | 1075 | #endif |
1065 | d.udma_mask = d.mwdma_mask = 0; | ||
1066 | 1076 | ||
1067 | idx[0] = hwif->index; | 1077 | idx[0] = hwif->index; |
1068 | 1078 | ||
@@ -1076,8 +1086,9 @@ static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base) | |||
1076 | int i; | 1086 | int i; |
1077 | 1087 | ||
1078 | for (i = 0; i < 8; ++i) | 1088 | for (i = 0; i < 8; ++i) |
1079 | hw->io_ports[i] = base + i * 0x10; | 1089 | hw->io_ports_array[i] = base + i * 0x10; |
1080 | hw->io_ports[8] = base + 0x160; | 1090 | |
1091 | hw->io_ports.ctl_addr = base + 0x160; | ||
1081 | } | 1092 | } |
1082 | 1093 | ||
1083 | /* | 1094 | /* |
@@ -1088,35 +1099,36 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1088 | { | 1099 | { |
1089 | void __iomem *base; | 1100 | void __iomem *base; |
1090 | unsigned long regbase; | 1101 | unsigned long regbase; |
1091 | int irq; | ||
1092 | ide_hwif_t *hwif; | 1102 | ide_hwif_t *hwif; |
1093 | pmac_ide_hwif_t *pmif; | 1103 | pmac_ide_hwif_t *pmif; |
1094 | int i, rc; | 1104 | int irq, rc; |
1095 | hw_regs_t hw; | 1105 | hw_regs_t hw; |
1096 | 1106 | ||
1097 | i = 0; | 1107 | pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); |
1098 | while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0 | 1108 | if (pmif == NULL) |
1099 | || pmac_ide[i].node != NULL)) | 1109 | return -ENOMEM; |
1100 | ++i; | 1110 | |
1101 | if (i >= MAX_HWIFS) { | 1111 | hwif = ide_find_port(); |
1112 | if (hwif == NULL) { | ||
1102 | printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n"); | 1113 | printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n"); |
1103 | printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name); | 1114 | printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name); |
1104 | return -ENODEV; | 1115 | rc = -ENODEV; |
1116 | goto out_free_pmif; | ||
1105 | } | 1117 | } |
1106 | 1118 | ||
1107 | pmif = &pmac_ide[i]; | ||
1108 | hwif = &ide_hwifs[i]; | ||
1109 | |||
1110 | if (macio_resource_count(mdev) == 0) { | 1119 | if (macio_resource_count(mdev) == 0) { |
1111 | printk(KERN_WARNING "ide%d: no address for %s\n", | 1120 | printk(KERN_WARNING "ide-pmac: no address for %s\n", |
1112 | i, mdev->ofdev.node->full_name); | 1121 | mdev->ofdev.node->full_name); |
1113 | return -ENXIO; | 1122 | rc = -ENXIO; |
1123 | goto out_free_pmif; | ||
1114 | } | 1124 | } |
1115 | 1125 | ||
1116 | /* Request memory resource for IO ports */ | 1126 | /* Request memory resource for IO ports */ |
1117 | if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) { | 1127 | if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) { |
1118 | printk(KERN_ERR "ide%d: can't request mmio resource !\n", i); | 1128 | printk(KERN_ERR "ide-pmac: can't request MMIO resource for " |
1119 | return -EBUSY; | 1129 | "%s!\n", mdev->ofdev.node->full_name); |
1130 | rc = -EBUSY; | ||
1131 | goto out_free_pmif; | ||
1120 | } | 1132 | } |
1121 | 1133 | ||
1122 | /* XXX This is bogus. Should be fixed in the registry by checking | 1134 | /* XXX This is bogus. Should be fixed in the registry by checking |
@@ -1125,8 +1137,8 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1125 | * where that happens though... | 1137 | * where that happens though... |
1126 | */ | 1138 | */ |
1127 | if (macio_irq_count(mdev) == 0) { | 1139 | if (macio_irq_count(mdev) == 0) { |
1128 | printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n", | 1140 | printk(KERN_WARNING "ide-pmac: no intrs for device %s, using " |
1129 | i, mdev->ofdev.node->full_name); | 1141 | "13\n", mdev->ofdev.node->full_name); |
1130 | irq = irq_create_mapping(NULL, 13); | 1142 | irq = irq_create_mapping(NULL, 13); |
1131 | } else | 1143 | } else |
1132 | irq = macio_irq(mdev, 0); | 1144 | irq = macio_irq(mdev, 0); |
@@ -1144,7 +1156,9 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1144 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 1156 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
1145 | if (macio_resource_count(mdev) >= 2) { | 1157 | if (macio_resource_count(mdev) >= 2) { |
1146 | if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) | 1158 | if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) |
1147 | printk(KERN_WARNING "ide%d: can't request DMA resource !\n", i); | 1159 | printk(KERN_WARNING "ide-pmac: can't request DMA " |
1160 | "resource for %s!\n", | ||
1161 | mdev->ofdev.node->full_name); | ||
1148 | else | 1162 | else |
1149 | pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); | 1163 | pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); |
1150 | } else | 1164 | } else |
@@ -1166,11 +1180,15 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1166 | iounmap(pmif->dma_regs); | 1180 | iounmap(pmif->dma_regs); |
1167 | macio_release_resource(mdev, 1); | 1181 | macio_release_resource(mdev, 1); |
1168 | } | 1182 | } |
1169 | memset(pmif, 0, sizeof(*pmif)); | ||
1170 | macio_release_resource(mdev, 0); | 1183 | macio_release_resource(mdev, 0); |
1184 | kfree(pmif); | ||
1171 | } | 1185 | } |
1172 | 1186 | ||
1173 | return rc; | 1187 | return rc; |
1188 | |||
1189 | out_free_pmif: | ||
1190 | kfree(pmif); | ||
1191 | return rc; | ||
1174 | } | 1192 | } |
1175 | 1193 | ||
1176 | static int | 1194 | static int |
@@ -1215,7 +1233,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1215 | pmac_ide_hwif_t *pmif; | 1233 | pmac_ide_hwif_t *pmif; |
1216 | void __iomem *base; | 1234 | void __iomem *base; |
1217 | unsigned long rbase, rlen; | 1235 | unsigned long rbase, rlen; |
1218 | int i, rc; | 1236 | int rc; |
1219 | hw_regs_t hw; | 1237 | hw_regs_t hw; |
1220 | 1238 | ||
1221 | np = pci_device_to_OF_node(pdev); | 1239 | np = pci_device_to_OF_node(pdev); |
@@ -1223,30 +1241,32 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1223 | printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n"); | 1241 | printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n"); |
1224 | return -ENODEV; | 1242 | return -ENODEV; |
1225 | } | 1243 | } |
1226 | i = 0; | 1244 | |
1227 | while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0 | 1245 | pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); |
1228 | || pmac_ide[i].node != NULL)) | 1246 | if (pmif == NULL) |
1229 | ++i; | 1247 | return -ENOMEM; |
1230 | if (i >= MAX_HWIFS) { | 1248 | |
1249 | hwif = ide_find_port(); | ||
1250 | if (hwif == NULL) { | ||
1231 | printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n"); | 1251 | printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n"); |
1232 | printk(KERN_ERR " %s\n", np->full_name); | 1252 | printk(KERN_ERR " %s\n", np->full_name); |
1233 | return -ENODEV; | 1253 | rc = -ENODEV; |
1254 | goto out_free_pmif; | ||
1234 | } | 1255 | } |
1235 | 1256 | ||
1236 | pmif = &pmac_ide[i]; | ||
1237 | hwif = &ide_hwifs[i]; | ||
1238 | |||
1239 | if (pci_enable_device(pdev)) { | 1257 | if (pci_enable_device(pdev)) { |
1240 | printk(KERN_WARNING "ide%i: Can't enable PCI device for %s\n", | 1258 | printk(KERN_WARNING "ide-pmac: Can't enable PCI device for " |
1241 | i, np->full_name); | 1259 | "%s\n", np->full_name); |
1242 | return -ENXIO; | 1260 | rc = -ENXIO; |
1261 | goto out_free_pmif; | ||
1243 | } | 1262 | } |
1244 | pci_set_master(pdev); | 1263 | pci_set_master(pdev); |
1245 | 1264 | ||
1246 | if (pci_request_regions(pdev, "Kauai ATA")) { | 1265 | if (pci_request_regions(pdev, "Kauai ATA")) { |
1247 | printk(KERN_ERR "ide%d: Cannot obtain PCI resources for %s\n", | 1266 | printk(KERN_ERR "ide-pmac: Cannot obtain PCI resources for " |
1248 | i, np->full_name); | 1267 | "%s\n", np->full_name); |
1249 | return -ENXIO; | 1268 | rc = -ENXIO; |
1269 | goto out_free_pmif; | ||
1250 | } | 1270 | } |
1251 | 1271 | ||
1252 | hwif->dev = &pdev->dev; | 1272 | hwif->dev = &pdev->dev; |
@@ -1276,11 +1296,15 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1276 | /* The inteface is released to the common IDE layer */ | 1296 | /* The inteface is released to the common IDE layer */ |
1277 | pci_set_drvdata(pdev, NULL); | 1297 | pci_set_drvdata(pdev, NULL); |
1278 | iounmap(base); | 1298 | iounmap(base); |
1279 | memset(pmif, 0, sizeof(*pmif)); | ||
1280 | pci_release_regions(pdev); | 1299 | pci_release_regions(pdev); |
1300 | kfree(pmif); | ||
1281 | } | 1301 | } |
1282 | 1302 | ||
1283 | return rc; | 1303 | return rc; |
1304 | |||
1305 | out_free_pmif: | ||
1306 | kfree(pmif); | ||
1307 | return rc; | ||
1284 | } | 1308 | } |
1285 | 1309 | ||
1286 | static int | 1310 | static int |
@@ -1652,18 +1676,31 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive) | |||
1652 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); | 1676 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); |
1653 | } | 1677 | } |
1654 | 1678 | ||
1679 | static const struct ide_dma_ops pmac_dma_ops = { | ||
1680 | .dma_host_set = pmac_ide_dma_host_set, | ||
1681 | .dma_setup = pmac_ide_dma_setup, | ||
1682 | .dma_exec_cmd = pmac_ide_dma_exec_cmd, | ||
1683 | .dma_start = pmac_ide_dma_start, | ||
1684 | .dma_end = pmac_ide_dma_end, | ||
1685 | .dma_test_irq = pmac_ide_dma_test_irq, | ||
1686 | .dma_timeout = ide_dma_timeout, | ||
1687 | .dma_lost_irq = pmac_ide_dma_lost_irq, | ||
1688 | }; | ||
1689 | |||
1655 | /* | 1690 | /* |
1656 | * Allocate the data structures needed for using DMA with an interface | 1691 | * Allocate the data structures needed for using DMA with an interface |
1657 | * and fill the proper list of functions pointers | 1692 | * and fill the proper list of functions pointers |
1658 | */ | 1693 | */ |
1659 | static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | 1694 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, |
1695 | const struct ide_port_info *d) | ||
1660 | { | 1696 | { |
1697 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
1661 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1698 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1662 | 1699 | ||
1663 | /* We won't need pci_dev if we switch to generic consistent | 1700 | /* We won't need pci_dev if we switch to generic consistent |
1664 | * DMA routines ... | 1701 | * DMA routines ... |
1665 | */ | 1702 | */ |
1666 | if (dev == NULL) | 1703 | if (dev == NULL || pmif->dma_regs == 0) |
1667 | return -ENODEV; | 1704 | return -ENODEV; |
1668 | /* | 1705 | /* |
1669 | * Allocate space for the DBDMA commands. | 1706 | * Allocate space for the DBDMA commands. |
@@ -1682,18 +1719,14 @@ static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1682 | 1719 | ||
1683 | hwif->sg_max_nents = MAX_DCMDS; | 1720 | hwif->sg_max_nents = MAX_DCMDS; |
1684 | 1721 | ||
1685 | hwif->dma_host_set = &pmac_ide_dma_host_set; | ||
1686 | hwif->dma_setup = &pmac_ide_dma_setup; | ||
1687 | hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd; | ||
1688 | hwif->dma_start = &pmac_ide_dma_start; | ||
1689 | hwif->ide_dma_end = &pmac_ide_dma_end; | ||
1690 | hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq; | ||
1691 | hwif->dma_timeout = &ide_dma_timeout; | ||
1692 | hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; | ||
1693 | |||
1694 | return 0; | 1722 | return 0; |
1695 | } | 1723 | } |
1696 | 1724 | #else | |
1725 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, | ||
1726 | const struct ide_port_info *d) | ||
1727 | { | ||
1728 | return -EOPNOTSUPP; | ||
1729 | } | ||
1697 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1730 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
1698 | 1731 | ||
1699 | module_init(pmac_ide_probe); | 1732 | module_init(pmac_ide_probe); |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index f7ede0e42881..5171601fb255 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -20,73 +20,6 @@ | |||
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
22 | 22 | ||
23 | |||
24 | /** | ||
25 | * ide_match_hwif - match a PCI IDE against an ide_hwif | ||
26 | * @io_base: I/O base of device | ||
27 | * @bootable: set if its bootable | ||
28 | * @name: name of device | ||
29 | * | ||
30 | * Match a PCI IDE port against an entry in ide_hwifs[], | ||
31 | * based on io_base port if possible. Return the matching hwif, | ||
32 | * or a new hwif. If we find an error (clashing, out of devices, etc) | ||
33 | * return NULL | ||
34 | * | ||
35 | * FIXME: we need to handle mmio matches here too | ||
36 | */ | ||
37 | |||
38 | static ide_hwif_t *ide_match_hwif(unsigned long io_base, u8 bootable, const char *name) | ||
39 | { | ||
40 | int h; | ||
41 | ide_hwif_t *hwif; | ||
42 | |||
43 | /* | ||
44 | * Look for a hwif with matching io_base default value. | ||
45 | * If chipset is "ide_unknown", then claim that hwif slot. | ||
46 | * Otherwise, some other chipset has already claimed it.. :( | ||
47 | */ | ||
48 | for (h = 0; h < MAX_HWIFS; ++h) { | ||
49 | hwif = &ide_hwifs[h]; | ||
50 | if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) { | ||
51 | if (hwif->chipset == ide_unknown) | ||
52 | return hwif; /* match */ | ||
53 | printk(KERN_ERR "%s: port 0x%04lx already claimed by %s\n", | ||
54 | name, io_base, hwif->name); | ||
55 | return NULL; /* already claimed */ | ||
56 | } | ||
57 | } | ||
58 | /* | ||
59 | * Okay, there is no hwif matching our io_base, | ||
60 | * so we'll just claim an unassigned slot. | ||
61 | * Give preference to claiming other slots before claiming ide0/ide1, | ||
62 | * just in case there's another interface yet-to-be-scanned | ||
63 | * which uses ports 1f0/170 (the ide0/ide1 defaults). | ||
64 | * | ||
65 | * Unless there is a bootable card that does not use the standard | ||
66 | * ports 1f0/170 (the ide0/ide1 defaults). The (bootable) flag. | ||
67 | */ | ||
68 | if (bootable) { | ||
69 | for (h = 0; h < MAX_HWIFS; ++h) { | ||
70 | hwif = &ide_hwifs[h]; | ||
71 | if (hwif->chipset == ide_unknown) | ||
72 | return hwif; /* pick an unused entry */ | ||
73 | } | ||
74 | } else { | ||
75 | for (h = 2; h < MAX_HWIFS; ++h) { | ||
76 | hwif = ide_hwifs + h; | ||
77 | if (hwif->chipset == ide_unknown) | ||
78 | return hwif; /* pick an unused entry */ | ||
79 | } | ||
80 | } | ||
81 | for (h = 0; h < 2 && h < MAX_HWIFS; ++h) { | ||
82 | hwif = ide_hwifs + h; | ||
83 | if (hwif->chipset == ide_unknown) | ||
84 | return hwif; /* pick an unused entry */ | ||
85 | } | ||
86 | printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", name); | ||
87 | return NULL; | ||
88 | } | ||
89 | |||
90 | /** | 23 | /** |
91 | * ide_setup_pci_baseregs - place a PCI IDE controller native | 24 | * ide_setup_pci_baseregs - place a PCI IDE controller native |
92 | * @dev: PCI device of interface to switch native | 25 | * @dev: PCI device of interface to switch native |
@@ -94,13 +27,13 @@ static ide_hwif_t *ide_match_hwif(unsigned long io_base, u8 bootable, const char | |||
94 | * | 27 | * |
95 | * We attempt to place the PCI interface into PCI native mode. If | 28 | * We attempt to place the PCI interface into PCI native mode. If |
96 | * we succeed the BARs are ok and the controller is in PCI mode. | 29 | * we succeed the BARs are ok and the controller is in PCI mode. |
97 | * Returns 0 on success or an errno code. | 30 | * Returns 0 on success or an errno code. |
98 | * | 31 | * |
99 | * FIXME: if we program the interface and then fail to set the BARS | 32 | * FIXME: if we program the interface and then fail to set the BARS |
100 | * we don't switch it back to legacy mode. Do we actually care ?? | 33 | * we don't switch it back to legacy mode. Do we actually care ?? |
101 | */ | 34 | */ |
102 | 35 | ||
103 | static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | 36 | static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name) |
104 | { | 37 | { |
105 | u8 progif = 0; | 38 | u8 progif = 0; |
106 | 39 | ||
@@ -139,16 +72,16 @@ static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | |||
139 | } | 72 | } |
140 | 73 | ||
141 | /** | 74 | /** |
142 | * ide_get_or_set_dma_base - setup BMIBA | 75 | * ide_pci_dma_base - setup BMIBA |
143 | * @d: IDE port info | ||
144 | * @hwif: IDE interface | 76 | * @hwif: IDE interface |
77 | * @d: IDE port info | ||
145 | * | 78 | * |
146 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. | 79 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
147 | * Where a device has a partner that is already in DMA mode we check | 80 | * Where a device has a partner that is already in DMA mode we check |
148 | * and enforce IDE simplex rules. | 81 | * and enforce IDE simplex rules. |
149 | */ | 82 | */ |
150 | 83 | ||
151 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) | 84 | unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) |
152 | { | 85 | { |
153 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 86 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
154 | unsigned long dma_base = 0; | 87 | unsigned long dma_base = 0; |
@@ -199,6 +132,31 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
199 | out: | 132 | out: |
200 | return dma_base; | 133 | return dma_base; |
201 | } | 134 | } |
135 | EXPORT_SYMBOL_GPL(ide_pci_dma_base); | ||
136 | |||
137 | /* | ||
138 | * Set up BM-DMA capability (PnP BIOS should have done this) | ||
139 | */ | ||
140 | int ide_pci_set_master(struct pci_dev *dev, const char *name) | ||
141 | { | ||
142 | u16 pcicmd; | ||
143 | |||
144 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
145 | |||
146 | if ((pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
147 | pci_set_master(dev); | ||
148 | |||
149 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || | ||
150 | (pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
151 | printk(KERN_ERR "%s: error updating PCICMD on %s\n", | ||
152 | name, pci_name(dev)); | ||
153 | return -EIO; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(ide_pci_set_master); | ||
202 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 160 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
203 | 161 | ||
204 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) | 162 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
@@ -207,7 +165,6 @@ void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) | |||
207 | " PCI slot %s\n", d->name, dev->vendor, dev->device, | 165 | " PCI slot %s\n", d->name, dev->vendor, dev->device, |
208 | dev->revision, pci_name(dev)); | 166 | dev->revision, pci_name(dev)); |
209 | } | 167 | } |
210 | |||
211 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | 168 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); |
212 | 169 | ||
213 | 170 | ||
@@ -220,13 +177,13 @@ EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | |||
220 | * but if that fails then we only need IO space. The PCI code should | 177 | * but if that fails then we only need IO space. The PCI code should |
221 | * have setup the proper resources for us already for controllers in | 178 | * have setup the proper resources for us already for controllers in |
222 | * legacy mode. | 179 | * legacy mode. |
223 | * | 180 | * |
224 | * Returns zero on success or an error code | 181 | * Returns zero on success or an error code |
225 | */ | 182 | */ |
226 | 183 | ||
227 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | 184 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) |
228 | { | 185 | { |
229 | int ret; | 186 | int ret, bars; |
230 | 187 | ||
231 | if (pci_enable_device(dev)) { | 188 | if (pci_enable_device(dev)) { |
232 | ret = pci_enable_device_io(dev); | 189 | ret = pci_enable_device_io(dev); |
@@ -249,13 +206,21 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | |||
249 | goto out; | 206 | goto out; |
250 | } | 207 | } |
251 | 208 | ||
252 | /* FIXME: Temporary - until we put in the hotplug interface logic | 209 | if (d->host_flags & IDE_HFLAG_SINGLE) |
253 | Check that the bits we want are not in use by someone else. */ | 210 | bars = (1 << 2) - 1; |
254 | ret = pci_request_region(dev, 4, "ide_tmp"); | 211 | else |
255 | if (ret < 0) | 212 | bars = (1 << 4) - 1; |
256 | goto out; | 213 | |
214 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { | ||
215 | if (d->host_flags & IDE_HFLAG_CS5520) | ||
216 | bars |= (1 << 2); | ||
217 | else | ||
218 | bars |= (1 << 4); | ||
219 | } | ||
257 | 220 | ||
258 | pci_release_region(dev, 4); | 221 | ret = pci_request_selected_regions(dev, bars, d->name); |
222 | if (ret < 0) | ||
223 | printk(KERN_ERR "%s: can't reserve resources\n", d->name); | ||
259 | out: | 224 | out: |
260 | return ret; | 225 | return ret; |
261 | } | 226 | } |
@@ -279,8 +244,8 @@ static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) | |||
279 | * Maybe the user deliberately *disabled* the device, | 244 | * Maybe the user deliberately *disabled* the device, |
280 | * but we'll eventually ignore it again if no drives respond. | 245 | * but we'll eventually ignore it again if no drives respond. |
281 | */ | 246 | */ |
282 | if (ide_setup_pci_baseregs(dev, d->name) || pci_write_config_word(dev, PCI_COMMAND, pcicmd|PCI_COMMAND_IO)) | 247 | if (ide_setup_pci_baseregs(dev, d->name) || |
283 | { | 248 | pci_write_config_word(dev, PCI_COMMAND, pcicmd | PCI_COMMAND_IO)) { |
284 | printk(KERN_INFO "%s: device disabled (BIOS)\n", d->name); | 249 | printk(KERN_INFO "%s: device disabled (BIOS)\n", d->name); |
285 | return -ENODEV; | 250 | return -ENODEV; |
286 | } | 251 | } |
@@ -301,26 +266,24 @@ static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) | |||
301 | * @d: IDE port info | 266 | * @d: IDE port info |
302 | * @bar: BAR number | 267 | * @bar: BAR number |
303 | * | 268 | * |
304 | * Checks if a BAR is configured and points to MMIO space. If so | 269 | * Checks if a BAR is configured and points to MMIO space. If so, |
305 | * print an error and return an error code. Otherwise return 0 | 270 | * return an error code. Otherwise return 0 |
306 | */ | 271 | */ |
307 | 272 | ||
308 | static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, int bar) | 273 | static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, |
274 | int bar) | ||
309 | { | 275 | { |
310 | ulong flags = pci_resource_flags(dev, bar); | 276 | ulong flags = pci_resource_flags(dev, bar); |
311 | 277 | ||
312 | /* Unconfigured ? */ | 278 | /* Unconfigured ? */ |
313 | if (!flags || pci_resource_len(dev, bar) == 0) | 279 | if (!flags || pci_resource_len(dev, bar) == 0) |
314 | return 0; | 280 | return 0; |
315 | 281 | ||
316 | /* I/O space */ | 282 | /* I/O space */ |
317 | if(flags & PCI_BASE_ADDRESS_IO_MASK) | 283 | if (flags & IORESOURCE_IO) |
318 | return 0; | 284 | return 0; |
319 | 285 | ||
320 | /* Bad */ | 286 | /* Bad */ |
321 | printk(KERN_ERR "%s: IO baseregs (BIOS) are reported " | ||
322 | "as MEM, report to " | ||
323 | "<andre@linux-ide.org>.\n", d->name); | ||
324 | return -EINVAL; | 287 | return -EINVAL; |
325 | } | 288 | } |
326 | 289 | ||
@@ -344,14 +307,16 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
344 | { | 307 | { |
345 | unsigned long ctl = 0, base = 0; | 308 | unsigned long ctl = 0, base = 0; |
346 | ide_hwif_t *hwif; | 309 | ide_hwif_t *hwif; |
347 | u8 bootable = (d->host_flags & IDE_HFLAG_BOOTABLE) ? 1 : 0; | ||
348 | struct hw_regs_s hw; | 310 | struct hw_regs_s hw; |
349 | 311 | ||
350 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { | 312 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
351 | /* Possibly we should fail if these checks report true */ | 313 | if (ide_pci_check_iomem(dev, d, 2 * port) || |
352 | ide_pci_check_iomem(dev, d, 2*port); | 314 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { |
353 | ide_pci_check_iomem(dev, d, 2*port+1); | 315 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " |
354 | 316 | "as MEM for port %d!\n", d->name, port); | |
317 | return NULL; | ||
318 | } | ||
319 | |||
355 | ctl = pci_resource_start(dev, 2*port+1); | 320 | ctl = pci_resource_start(dev, 2*port+1); |
356 | base = pci_resource_start(dev, 2*port); | 321 | base = pci_resource_start(dev, 2*port); |
357 | if ((ctl && !base) || (base && !ctl)) { | 322 | if ((ctl && !base) || (base && !ctl)) { |
@@ -360,14 +325,18 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
360 | return NULL; | 325 | return NULL; |
361 | } | 326 | } |
362 | } | 327 | } |
363 | if (!ctl) | 328 | if (!ctl) { |
364 | { | ||
365 | /* Use default values */ | 329 | /* Use default values */ |
366 | ctl = port ? 0x374 : 0x3f4; | 330 | ctl = port ? 0x374 : 0x3f4; |
367 | base = port ? 0x170 : 0x1f0; | 331 | base = port ? 0x170 : 0x1f0; |
368 | } | 332 | } |
369 | if ((hwif = ide_match_hwif(base, bootable, d->name)) == NULL) | 333 | |
370 | return NULL; /* no room in ide_hwifs[] */ | 334 | hwif = ide_find_port_slot(d); |
335 | if (hwif == NULL) { | ||
336 | printk(KERN_ERR "%s: too many IDE interfaces, no room in " | ||
337 | "table\n", d->name); | ||
338 | return NULL; | ||
339 | } | ||
371 | 340 | ||
372 | memset(&hw, 0, sizeof(hw)); | 341 | memset(&hw, 0, sizeof(hw)); |
373 | hw.irq = irq; | 342 | hw.irq = irq; |
@@ -378,7 +347,6 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
378 | ide_init_port_hw(hwif, &hw); | 347 | ide_init_port_hw(hwif, &hw); |
379 | 348 | ||
380 | hwif->dev = &dev->dev; | 349 | hwif->dev = &dev->dev; |
381 | hwif->cds = d; | ||
382 | 350 | ||
383 | return hwif; | 351 | return hwif; |
384 | } | 352 | } |
@@ -394,40 +362,33 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
394 | * state | 362 | * state |
395 | */ | 363 | */ |
396 | 364 | ||
397 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | 365 | int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) |
398 | { | 366 | { |
399 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 367 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
400 | u16 pcicmd; | ||
401 | |||
402 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
403 | 368 | ||
404 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || | 369 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
405 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 370 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
406 | (dev->class & 0x80))) { | 371 | (dev->class & 0x80))) { |
407 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); | 372 | unsigned long base = ide_pci_dma_base(hwif, d); |
408 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { | 373 | |
409 | /* | 374 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
410 | * Set up BM-DMA capability | 375 | return -1; |
411 | * (PnP BIOS should have done this) | 376 | |
412 | */ | 377 | if (hwif->mmio) |
413 | pci_set_master(dev); | 378 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
414 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { | 379 | else |
415 | printk(KERN_ERR "%s: %s error updating PCICMD\n", | 380 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
416 | hwif->name, d->name); | 381 | hwif->name, base, base + 7); |
417 | dma_base = 0; | 382 | |
418 | } | 383 | hwif->extra_base = base + (hwif->channel ? 8 : 16); |
419 | } | 384 | |
420 | if (dma_base) { | 385 | if (ide_allocate_dma_engine(hwif)) |
421 | if (d->init_dma) { | 386 | return -1; |
422 | d->init_dma(hwif, dma_base); | 387 | |
423 | } else { | 388 | ide_setup_dma(hwif, base); |
424 | ide_setup_dma(hwif, dma_base); | ||
425 | } | ||
426 | } else { | ||
427 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " | ||
428 | "(BIOS)\n", hwif->name, d->name); | ||
429 | } | ||
430 | } | 389 | } |
390 | |||
391 | return 0; | ||
431 | } | 392 | } |
432 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 393 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
433 | 394 | ||
@@ -514,7 +475,6 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int | |||
514 | *(idx + port) = hwif->index; | 475 | *(idx + port) = hwif->index; |
515 | } | 476 | } |
516 | } | 477 | } |
517 | |||
518 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); | 478 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); |
519 | 479 | ||
520 | /* | 480 | /* |
@@ -597,7 +557,6 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | |||
597 | 557 | ||
598 | return ret; | 558 | return ret; |
599 | } | 559 | } |
600 | |||
601 | EXPORT_SYMBOL_GPL(ide_setup_pci_device); | 560 | EXPORT_SYMBOL_GPL(ide_setup_pci_device); |
602 | 561 | ||
603 | int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | 562 | int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, |
@@ -621,5 +580,4 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
621 | out: | 580 | out: |
622 | return ret; | 581 | return ret; |
623 | } | 582 | } |
624 | |||
625 | EXPORT_SYMBOL_GPL(ide_setup_pci_devices); | 583 | EXPORT_SYMBOL_GPL(ide_setup_pci_devices); |