diff options
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/floppy_64.h | 86 |
1 files changed, 36 insertions, 50 deletions
diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h index 8c7a06e88249..36439d67ad71 100644 --- a/arch/sparc/include/asm/floppy_64.h +++ b/arch/sparc/include/asm/floppy_64.h | |||
@@ -9,19 +9,11 @@ | |||
9 | #ifndef __ASM_SPARC64_FLOPPY_H | 9 | #ifndef __ASM_SPARC64_FLOPPY_H |
10 | #define __ASM_SPARC64_FLOPPY_H | 10 | #define __ASM_SPARC64_FLOPPY_H |
11 | 11 | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/pci.h> | ||
14 | #include <linux/of.h> | 12 | #include <linux/of.h> |
15 | #include <linux/of_device.h> | 13 | #include <linux/of_device.h> |
14 | #include <linux/dma-mapping.h> | ||
16 | 15 | ||
17 | #include <asm/page.h> | ||
18 | #include <asm/pgtable.h> | ||
19 | #include <asm/system.h> | ||
20 | #include <asm/idprom.h> | ||
21 | #include <asm/oplib.h> | ||
22 | #include <asm/auxio.h> | 16 | #include <asm/auxio.h> |
23 | #include <asm/irq.h> | ||
24 | |||
25 | 17 | ||
26 | /* | 18 | /* |
27 | * Define this to enable exchanging drive 0 and 1 if only drive 1 is | 19 | * Define this to enable exchanging drive 0 and 1 if only drive 1 is |
@@ -292,13 +284,11 @@ static int sun_fd_eject(int drive) | |||
292 | return 0; | 284 | return 0; |
293 | } | 285 | } |
294 | 286 | ||
295 | #ifdef CONFIG_PCI | ||
296 | #include <asm/ebus.h> | ||
297 | #include <asm/ebus_dma.h> | 287 | #include <asm/ebus_dma.h> |
298 | #include <asm/ns87303.h> | 288 | #include <asm/ns87303.h> |
299 | 289 | ||
300 | static struct ebus_dma_info sun_pci_fd_ebus_dma; | 290 | static struct ebus_dma_info sun_pci_fd_ebus_dma; |
301 | static struct pci_dev *sun_pci_ebus_dev; | 291 | static struct device *sun_floppy_dev; |
302 | static int sun_pci_broken_drive = -1; | 292 | static int sun_pci_broken_drive = -1; |
303 | 293 | ||
304 | struct sun_pci_dma_op { | 294 | struct sun_pci_dma_op { |
@@ -379,7 +369,7 @@ static void sun_pci_fd_enable_dma(void) | |||
379 | sun_pci_dma_pending.addr = -1U; | 369 | sun_pci_dma_pending.addr = -1U; |
380 | 370 | ||
381 | sun_pci_dma_current.addr = | 371 | sun_pci_dma_current.addr = |
382 | pci_map_single(sun_pci_ebus_dev, | 372 | dma_map_single(sun_floppy_dev, |
383 | sun_pci_dma_current.buf, | 373 | sun_pci_dma_current.buf, |
384 | sun_pci_dma_current.len, | 374 | sun_pci_dma_current.len, |
385 | sun_pci_dma_current.direction); | 375 | sun_pci_dma_current.direction); |
@@ -396,7 +386,7 @@ static void sun_pci_fd_disable_dma(void) | |||
396 | { | 386 | { |
397 | ebus_dma_enable(&sun_pci_fd_ebus_dma, 0); | 387 | ebus_dma_enable(&sun_pci_fd_ebus_dma, 0); |
398 | if (sun_pci_dma_current.addr != -1U) | 388 | if (sun_pci_dma_current.addr != -1U) |
399 | pci_unmap_single(sun_pci_ebus_dev, | 389 | dma_unmap_single(sun_floppy_dev, |
400 | sun_pci_dma_current.addr, | 390 | sun_pci_dma_current.addr, |
401 | sun_pci_dma_current.len, | 391 | sun_pci_dma_current.len, |
402 | sun_pci_dma_current.direction); | 392 | sun_pci_dma_current.direction); |
@@ -406,9 +396,9 @@ static void sun_pci_fd_disable_dma(void) | |||
406 | static void sun_pci_fd_set_dma_mode(int mode) | 396 | static void sun_pci_fd_set_dma_mode(int mode) |
407 | { | 397 | { |
408 | if (mode == DMA_MODE_WRITE) | 398 | if (mode == DMA_MODE_WRITE) |
409 | sun_pci_dma_pending.direction = PCI_DMA_TODEVICE; | 399 | sun_pci_dma_pending.direction = DMA_TO_DEVICE; |
410 | else | 400 | else |
411 | sun_pci_dma_pending.direction = PCI_DMA_FROMDEVICE; | 401 | sun_pci_dma_pending.direction = DMA_FROM_DEVICE; |
412 | 402 | ||
413 | ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE); | 403 | ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE); |
414 | } | 404 | } |
@@ -540,24 +530,19 @@ static int sun_pci_fd_test_drive(unsigned long port, int drive) | |||
540 | #undef MSR | 530 | #undef MSR |
541 | #undef DOR | 531 | #undef DOR |
542 | 532 | ||
543 | #endif /* CONFIG_PCI */ | 533 | static int __init ebus_fdthree_p(struct device_node *dp) |
544 | |||
545 | #ifdef CONFIG_PCI | ||
546 | static int __init ebus_fdthree_p(struct linux_ebus_device *edev) | ||
547 | { | 534 | { |
548 | if (!strcmp(edev->prom_node->name, "fdthree")) | 535 | if (!strcmp(dp->name, "fdthree")) |
549 | return 1; | 536 | return 1; |
550 | if (!strcmp(edev->prom_node->name, "floppy")) { | 537 | if (!strcmp(dp->name, "floppy")) { |
551 | const char *compat; | 538 | const char *compat; |
552 | 539 | ||
553 | compat = of_get_property(edev->prom_node, | 540 | compat = of_get_property(dp, "compatible", NULL); |
554 | "compatible", NULL); | ||
555 | if (compat && !strcmp(compat, "fdthree")) | 541 | if (compat && !strcmp(compat, "fdthree")) |
556 | return 1; | 542 | return 1; |
557 | } | 543 | } |
558 | return 0; | 544 | return 0; |
559 | } | 545 | } |
560 | #endif | ||
561 | 546 | ||
562 | static unsigned long __init sun_floppy_init(void) | 547 | static unsigned long __init sun_floppy_init(void) |
563 | { | 548 | { |
@@ -584,44 +569,45 @@ static unsigned long __init sun_floppy_init(void) | |||
584 | floppy_op = op; | 569 | floppy_op = op; |
585 | FLOPPY_IRQ = op->irqs[0]; | 570 | FLOPPY_IRQ = op->irqs[0]; |
586 | } else { | 571 | } else { |
587 | #ifdef CONFIG_PCI | 572 | struct device_node *ebus_dp; |
588 | struct linux_ebus *ebus; | ||
589 | struct linux_ebus_device *edev = NULL; | ||
590 | unsigned long config = 0; | ||
591 | void __iomem *auxio_reg; | 573 | void __iomem *auxio_reg; |
592 | const char *state_prop; | 574 | const char *state_prop; |
575 | unsigned long config; | ||
593 | 576 | ||
594 | for_each_ebus(ebus) { | 577 | dp = NULL; |
595 | for_each_ebusdev(edev, ebus) { | 578 | for_each_node_by_name(ebus_dp, "ebus") { |
596 | if (ebus_fdthree_p(edev)) | 579 | for (dp = ebus_dp->child; dp; dp = dp->sibling) { |
597 | goto ebus_done; | 580 | if (ebus_fdthree_p(dp)) |
581 | goto found_fdthree; | ||
598 | } | 582 | } |
599 | } | 583 | } |
600 | ebus_done: | 584 | found_fdthree: |
601 | if (!edev) | 585 | if (!dp) |
602 | return 0; | 586 | return 0; |
603 | 587 | ||
604 | op = &edev->ofdev; | 588 | op = of_find_device_by_node(dp); |
589 | if (!op) | ||
590 | return 0; | ||
605 | 591 | ||
606 | state_prop = of_get_property(op->node, "status", NULL); | 592 | state_prop = of_get_property(op->node, "status", NULL); |
607 | if (state_prop && !strncmp(state_prop, "disabled", 8)) | 593 | if (state_prop && !strncmp(state_prop, "disabled", 8)) |
608 | return 0; | 594 | return 0; |
609 | 595 | ||
610 | FLOPPY_IRQ = edev->irqs[0]; | 596 | FLOPPY_IRQ = op->irqs[0]; |
611 | 597 | ||
612 | /* Make sure the high density bit is set, some systems | 598 | /* Make sure the high density bit is set, some systems |
613 | * (most notably Ultra5/Ultra10) come up with it clear. | 599 | * (most notably Ultra5/Ultra10) come up with it clear. |
614 | */ | 600 | */ |
615 | auxio_reg = (void __iomem *) edev->resource[2].start; | 601 | auxio_reg = (void __iomem *) op->resource[2].start; |
616 | writel(readl(auxio_reg)|0x2, auxio_reg); | 602 | writel(readl(auxio_reg)|0x2, auxio_reg); |
617 | 603 | ||
618 | sun_pci_ebus_dev = ebus->self; | 604 | sun_floppy_dev = &op->dev; |
619 | 605 | ||
620 | spin_lock_init(&sun_pci_fd_ebus_dma.lock); | 606 | spin_lock_init(&sun_pci_fd_ebus_dma.lock); |
621 | 607 | ||
622 | /* XXX ioremap */ | 608 | /* XXX ioremap */ |
623 | sun_pci_fd_ebus_dma.regs = (void __iomem *) | 609 | sun_pci_fd_ebus_dma.regs = (void __iomem *) |
624 | edev->resource[1].start; | 610 | op->resource[1].start; |
625 | if (!sun_pci_fd_ebus_dma.regs) | 611 | if (!sun_pci_fd_ebus_dma.regs) |
626 | return 0; | 612 | return 0; |
627 | 613 | ||
@@ -635,7 +621,7 @@ static unsigned long __init sun_floppy_init(void) | |||
635 | return 0; | 621 | return 0; |
636 | 622 | ||
637 | /* XXX ioremap */ | 623 | /* XXX ioremap */ |
638 | sun_fdc = (struct sun_flpy_controller *)edev->resource[0].start; | 624 | sun_fdc = (struct sun_flpy_controller *) op->resource[0].start; |
639 | 625 | ||
640 | sun_fdops.fd_inb = sun_pci_fd_inb; | 626 | sun_fdops.fd_inb = sun_pci_fd_inb; |
641 | sun_fdops.fd_outb = sun_pci_fd_outb; | 627 | sun_fdops.fd_outb = sun_pci_fd_outb; |
@@ -672,12 +658,15 @@ static unsigned long __init sun_floppy_init(void) | |||
672 | /* | 658 | /* |
673 | * Find NS87303 SuperIO config registers (through ecpp). | 659 | * Find NS87303 SuperIO config registers (through ecpp). |
674 | */ | 660 | */ |
675 | for_each_ebus(ebus) { | 661 | config = 0; |
676 | for_each_ebusdev(edev, ebus) { | 662 | for (dp = ebus_dp->child; dp; dp = dp->sibling) { |
677 | if (!strcmp(edev->prom_node->name, "ecpp")) { | 663 | if (!strcmp(dp->name, "ecpp")) { |
678 | config = edev->resource[1].start; | 664 | struct of_device *ecpp_op; |
679 | goto config_done; | 665 | |
680 | } | 666 | ecpp_op = of_find_device_by_node(dp); |
667 | if (ecpp_op) | ||
668 | config = ecpp_op->resource[1].start; | ||
669 | goto config_done; | ||
681 | } | 670 | } |
682 | } | 671 | } |
683 | config_done: | 672 | config_done: |
@@ -726,9 +715,6 @@ static unsigned long __init sun_floppy_init(void) | |||
726 | #endif /* PCI_FDC_SWAP_DRIVES */ | 715 | #endif /* PCI_FDC_SWAP_DRIVES */ |
727 | 716 | ||
728 | return sun_floppy_types[0]; | 717 | return sun_floppy_types[0]; |
729 | #else | ||
730 | return 0; | ||
731 | #endif | ||
732 | } | 718 | } |
733 | prop = of_get_property(op->node, "status", NULL); | 719 | prop = of_get_property(op->node, "status", NULL); |
734 | if (prop && !strncmp(state, "disabled", 8)) | 720 | if (prop && !strncmp(state, "disabled", 8)) |