diff options
Diffstat (limited to 'drivers/ide/arm/icside.c')
-rw-r--r-- | drivers/ide/arm/icside.c | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 3af33fbf1f8..410a0d13e35 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -316,27 +316,29 @@ static int icside_dma_end(ide_drive_t *drive) | |||
316 | 316 | ||
317 | drive->waiting_for_dma = 0; | 317 | drive->waiting_for_dma = 0; |
318 | 318 | ||
319 | disable_dma(hwif->hw.dma); | 319 | disable_dma(state->dev->dma); |
320 | 320 | ||
321 | /* Teardown mappings after DMA has completed. */ | 321 | /* Teardown mappings after DMA has completed. */ |
322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, | 322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, |
323 | hwif->sg_dma_direction); | 323 | hwif->sg_dma_direction); |
324 | 324 | ||
325 | return get_dma_residue(hwif->hw.dma) != 0; | 325 | return get_dma_residue(state->dev->dma) != 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | static void icside_dma_start(ide_drive_t *drive) | 328 | static void icside_dma_start(ide_drive_t *drive) |
329 | { | 329 | { |
330 | ide_hwif_t *hwif = HWIF(drive); | 330 | ide_hwif_t *hwif = HWIF(drive); |
331 | struct icside_state *state = hwif->hwif_data; | ||
331 | 332 | ||
332 | /* We can not enable DMA on both channels simultaneously. */ | 333 | /* We can not enable DMA on both channels simultaneously. */ |
333 | BUG_ON(dma_channel_active(hwif->hw.dma)); | 334 | BUG_ON(dma_channel_active(state->dev->dma)); |
334 | enable_dma(hwif->hw.dma); | 335 | enable_dma(state->dev->dma); |
335 | } | 336 | } |
336 | 337 | ||
337 | static int icside_dma_setup(ide_drive_t *drive) | 338 | static int icside_dma_setup(ide_drive_t *drive) |
338 | { | 339 | { |
339 | ide_hwif_t *hwif = HWIF(drive); | 340 | ide_hwif_t *hwif = HWIF(drive); |
341 | struct icside_state *state = hwif->hwif_data; | ||
340 | struct request *rq = hwif->hwgroup->rq; | 342 | struct request *rq = hwif->hwgroup->rq; |
341 | unsigned int dma_mode; | 343 | unsigned int dma_mode; |
342 | 344 | ||
@@ -348,7 +350,7 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
348 | /* | 350 | /* |
349 | * We can not enable DMA on both channels. | 351 | * We can not enable DMA on both channels. |
350 | */ | 352 | */ |
351 | BUG_ON(dma_channel_active(hwif->hw.dma)); | 353 | BUG_ON(dma_channel_active(state->dev->dma)); |
352 | 354 | ||
353 | icside_build_sglist(drive, rq); | 355 | icside_build_sglist(drive, rq); |
354 | 356 | ||
@@ -365,14 +367,14 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
365 | /* | 367 | /* |
366 | * Select the correct timing for this drive. | 368 | * Select the correct timing for this drive. |
367 | */ | 369 | */ |
368 | set_dma_speed(hwif->hw.dma, drive->drive_data); | 370 | set_dma_speed(state->dev->dma, drive->drive_data); |
369 | 371 | ||
370 | /* | 372 | /* |
371 | * Tell the DMA engine about the SG table and | 373 | * Tell the DMA engine about the SG table and |
372 | * data direction. | 374 | * data direction. |
373 | */ | 375 | */ |
374 | set_dma_sg(hwif->hw.dma, hwif->sg_table, hwif->sg_nents); | 376 | set_dma_sg(state->dev->dma, hwif->sg_table, hwif->sg_nents); |
375 | set_dma_mode(hwif->hw.dma, dma_mode); | 377 | set_dma_mode(state->dev->dma, dma_mode); |
376 | 378 | ||
377 | drive->waiting_for_dma = 1; | 379 | drive->waiting_for_dma = 1; |
378 | 380 | ||
@@ -438,40 +440,16 @@ static void icside_dma_init(ide_hwif_t *hwif) | |||
438 | #define icside_dma_init(hwif) (0) | 440 | #define icside_dma_init(hwif) (0) |
439 | #endif | 441 | #endif |
440 | 442 | ||
441 | static ide_hwif_t *icside_find_hwif(unsigned long dataport) | ||
442 | { | ||
443 | ide_hwif_t *hwif; | ||
444 | int index; | ||
445 | |||
446 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
447 | hwif = &ide_hwifs[index]; | ||
448 | if (hwif->io_ports[IDE_DATA_OFFSET] == dataport) | ||
449 | goto found; | ||
450 | } | ||
451 | |||
452 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
453 | hwif = &ide_hwifs[index]; | ||
454 | if (!hwif->io_ports[IDE_DATA_OFFSET]) | ||
455 | goto found; | ||
456 | } | ||
457 | |||
458 | hwif = NULL; | ||
459 | found: | ||
460 | return hwif; | ||
461 | } | ||
462 | |||
463 | static ide_hwif_t * | 443 | static ide_hwif_t * |
464 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) | 444 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) |
465 | { | 445 | { |
466 | unsigned long port = (unsigned long)base + info->dataoffset; | 446 | unsigned long port = (unsigned long)base + info->dataoffset; |
467 | ide_hwif_t *hwif; | 447 | ide_hwif_t *hwif; |
468 | 448 | ||
469 | hwif = icside_find_hwif(port); | 449 | hwif = ide_find_port(port); |
470 | if (hwif) { | 450 | if (hwif) { |
471 | int i; | 451 | int i; |
472 | 452 | ||
473 | memset(&hwif->hw, 0, sizeof(hw_regs_t)); | ||
474 | |||
475 | /* | 453 | /* |
476 | * Ensure we're using MMIO | 454 | * Ensure we're using MMIO |
477 | */ | 455 | */ |
@@ -479,13 +457,10 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e | |||
479 | hwif->mmio = 1; | 457 | hwif->mmio = 1; |
480 | 458 | ||
481 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 459 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
482 | hwif->hw.io_ports[i] = port; | ||
483 | hwif->io_ports[i] = port; | 460 | hwif->io_ports[i] = port; |
484 | port += 1 << info->stepping; | 461 | port += 1 << info->stepping; |
485 | } | 462 | } |
486 | hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; | ||
487 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; | 463 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; |
488 | hwif->hw.irq = ec->irq; | ||
489 | hwif->irq = ec->irq; | 464 | hwif->irq = ec->irq; |
490 | hwif->noprobe = 0; | 465 | hwif->noprobe = 0; |
491 | hwif->chipset = ide_acorn; | 466 | hwif->chipset = ide_acorn; |
@@ -500,6 +475,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
500 | { | 475 | { |
501 | ide_hwif_t *hwif; | 476 | ide_hwif_t *hwif; |
502 | void __iomem *base; | 477 | void __iomem *base; |
478 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
503 | 479 | ||
504 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); | 480 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
505 | if (!base) | 481 | if (!base) |
@@ -523,9 +499,9 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
523 | 499 | ||
524 | state->hwif[0] = hwif; | 500 | state->hwif[0] = hwif; |
525 | 501 | ||
526 | probe_hwif_init(hwif); | 502 | idx[0] = hwif->index; |
527 | 503 | ||
528 | ide_proc_register_port(hwif); | 504 | ide_device_add(idx); |
529 | 505 | ||
530 | return 0; | 506 | return 0; |
531 | } | 507 | } |
@@ -537,6 +513,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
537 | void __iomem *ioc_base, *easi_base; | 513 | void __iomem *ioc_base, *easi_base; |
538 | unsigned int sel = 0; | 514 | unsigned int sel = 0; |
539 | int ret; | 515 | int ret; |
516 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
540 | 517 | ||
541 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 518 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
542 | if (!ioc_base) { | 519 | if (!ioc_base) { |
@@ -592,7 +569,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
592 | hwif->serialized = 1; | 569 | hwif->serialized = 1; |
593 | hwif->config_data = (unsigned long)ioc_base; | 570 | hwif->config_data = (unsigned long)ioc_base; |
594 | hwif->select_data = sel; | 571 | hwif->select_data = sel; |
595 | hwif->hw.dma = ec->dma; | ||
596 | 572 | ||
597 | mate->maskproc = icside_maskproc; | 573 | mate->maskproc = icside_maskproc; |
598 | mate->channel = 1; | 574 | mate->channel = 1; |
@@ -601,18 +577,16 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
601 | mate->serialized = 1; | 577 | mate->serialized = 1; |
602 | mate->config_data = (unsigned long)ioc_base; | 578 | mate->config_data = (unsigned long)ioc_base; |
603 | mate->select_data = sel | 1; | 579 | mate->select_data = sel | 1; |
604 | mate->hw.dma = ec->dma; | ||
605 | 580 | ||
606 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { | 581 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { |
607 | icside_dma_init(hwif); | 582 | icside_dma_init(hwif); |
608 | icside_dma_init(mate); | 583 | icside_dma_init(mate); |
609 | } | 584 | } |
610 | 585 | ||
611 | probe_hwif_init(hwif); | 586 | idx[0] = hwif->index; |
612 | probe_hwif_init(mate); | 587 | idx[1] = mate->index; |
613 | 588 | ||
614 | ide_proc_register_port(hwif); | 589 | ide_device_add(idx); |
615 | ide_proc_register_port(mate); | ||
616 | 590 | ||
617 | return 0; | 591 | return 0; |
618 | 592 | ||