diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 17:39:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 17:39:20 -0500 |
commit | 56b85f32d530d09d6805488ad00775d4e0e3baab (patch) | |
tree | e7fbe69e338ef775d3b2dd822aa915d259b4bc94 /drivers/serial/apbuart.c | |
parent | 3e5b08cbbf78bedd316904ab0cf3b27119433ee5 (diff) | |
parent | 568389c257fa7d74ce36c2f78bad31965fded4cf (diff) |
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (36 commits)
serial: apbuart: Fixup apbuart_console_init()
TTY: Add tty ioctl to figure device node of the system console.
tty: add 'active' sysfs attribute to tty0 and console device
drivers: serial: apbuart: Handle OF failures gracefully
Serial: Avoid unbalanced IRQ wake disable during resume
tty: fix typos/errors in tty_driver.h comments
pch_uart : fix warnings for 64bit compile
8250: fix uninitialized FIFOs
ip2: fix compiler warning on ip2main_pci_tbl
specialix: fix compiler warning on specialix_pci_tbl
rocket: fix compiler warning on rocket_pci_ids
8250: add a UPIO_DWAPB32 for 32 bit accesses
8250: use container_of() instead of casting
serial: omap-serial: Add support for kernel debugger
serial: fix pch_uart kconfig & build
drivers: char: hvc: add arm JTAG DCC console support
RS485 documentation: add 16C950 UART description
serial: ifx6x60: fix memory leak
serial: ifx6x60: free IRQ on error
Serial: EG20T: add PCH_UART driver
...
Fixed up conflicts in drivers/serial/apbuart.c with evil merge that
makes the code look fairly sane (unlike either side).
Diffstat (limited to 'drivers/serial/apbuart.c')
-rw-r--r-- | drivers/serial/apbuart.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/drivers/serial/apbuart.c b/drivers/serial/apbuart.c index 767ce9e396c5..095a5d562618 100644 --- a/drivers/serial/apbuart.c +++ b/drivers/serial/apbuart.c | |||
@@ -521,11 +521,12 @@ static struct console grlib_apbuart_console = { | |||
521 | }; | 521 | }; |
522 | 522 | ||
523 | 523 | ||
524 | static void grlib_apbuart_configure(void); | 524 | static int grlib_apbuart_configure(void); |
525 | 525 | ||
526 | static int __init apbuart_console_init(void) | 526 | static int __init apbuart_console_init(void) |
527 | { | 527 | { |
528 | grlib_apbuart_configure(); | 528 | if (grlib_apbuart_configure()) |
529 | return -ENODEV; | ||
529 | register_console(&grlib_apbuart_console); | 530 | register_console(&grlib_apbuart_console); |
530 | return 0; | 531 | return 0; |
531 | } | 532 | } |
@@ -596,57 +597,49 @@ static struct of_platform_driver grlib_apbuart_of_driver = { | |||
596 | }; | 597 | }; |
597 | 598 | ||
598 | 599 | ||
599 | static void grlib_apbuart_configure(void) | 600 | static int grlib_apbuart_configure(void) |
600 | { | 601 | { |
601 | static int enum_done; | ||
602 | struct device_node *np, *rp; | 602 | struct device_node *np, *rp; |
603 | struct uart_port *port = NULL; | ||
604 | const u32 *prop; | 603 | const u32 *prop; |
605 | int freq_khz; | 604 | int freq_khz, line = 0; |
606 | int v = 0, d = 0; | ||
607 | unsigned int addr; | ||
608 | int irq, line; | ||
609 | struct amba_prom_registers *regs; | ||
610 | |||
611 | if (enum_done) | ||
612 | return; | ||
613 | 605 | ||
614 | /* Get bus frequency */ | 606 | /* Get bus frequency */ |
615 | rp = of_find_node_by_path("/"); | 607 | rp = of_find_node_by_path("/"); |
608 | if (!rp) | ||
609 | return -ENODEV; | ||
616 | rp = of_get_next_child(rp, NULL); | 610 | rp = of_get_next_child(rp, NULL); |
611 | if (!rp) | ||
612 | return -ENODEV; | ||
617 | prop = of_get_property(rp, "clock-frequency", NULL); | 613 | prop = of_get_property(rp, "clock-frequency", NULL); |
614 | if (!prop) | ||
615 | return -ENODEV; | ||
618 | freq_khz = *prop; | 616 | freq_khz = *prop; |
619 | 617 | ||
620 | line = 0; | ||
621 | for_each_matching_node(np, apbuart_match) { | 618 | for_each_matching_node(np, apbuart_match) { |
619 | const int *irqs, *ampopts; | ||
620 | const struct amba_prom_registers *regs; | ||
621 | struct uart_port *port; | ||
622 | unsigned long addr; | ||
622 | 623 | ||
623 | int *vendor = (int *) of_get_property(np, "vendor", NULL); | 624 | ampopts = of_get_property(np, "ampopts", NULL); |
624 | int *device = (int *) of_get_property(np, "device", NULL); | ||
625 | int *irqs = (int *) of_get_property(np, "interrupts", NULL); | ||
626 | int *ampopts = (int *) of_get_property(np, "ampopts", NULL); | ||
627 | regs = (struct amba_prom_registers *) | ||
628 | of_get_property(np, "reg", NULL); | ||
629 | |||
630 | if (ampopts && (*ampopts == 0)) | 625 | if (ampopts && (*ampopts == 0)) |
631 | continue; /* Ignore if used by another OS instance */ | 626 | continue; /* Ignore if used by another OS instance */ |
632 | if (vendor) | 627 | |
633 | v = *vendor; | 628 | irqs = of_get_property(np, "interrupts", NULL); |
634 | if (device) | 629 | regs = of_get_property(np, "reg", NULL); |
635 | d = *device; | ||
636 | 630 | ||
637 | if (!irqs || !regs) | 631 | if (!irqs || !regs) |
638 | return; | 632 | continue; |
639 | 633 | ||
640 | grlib_apbuart_nodes[line] = np; | 634 | grlib_apbuart_nodes[line] = np; |
641 | 635 | ||
642 | addr = regs->phys_addr; | 636 | addr = regs->phys_addr; |
643 | irq = *irqs; | ||
644 | 637 | ||
645 | port = &grlib_apbuart_ports[line]; | 638 | port = &grlib_apbuart_ports[line]; |
646 | 639 | ||
647 | port->mapbase = addr; | 640 | port->mapbase = addr; |
648 | port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); | 641 | port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); |
649 | port->irq = irq; | 642 | port->irq = *irqs; |
650 | port->iotype = UPIO_MEM; | 643 | port->iotype = UPIO_MEM; |
651 | port->ops = &grlib_apbuart_ops; | 644 | port->ops = &grlib_apbuart_ops; |
652 | port->flags = UPF_BOOT_AUTOCONF; | 645 | port->flags = UPF_BOOT_AUTOCONF; |
@@ -658,12 +651,10 @@ static void grlib_apbuart_configure(void) | |||
658 | /* We support maximum UART_NR uarts ... */ | 651 | /* We support maximum UART_NR uarts ... */ |
659 | if (line == UART_NR) | 652 | if (line == UART_NR) |
660 | break; | 653 | break; |
661 | |||
662 | } | 654 | } |
663 | 655 | ||
664 | enum_done = 1; | ||
665 | |||
666 | grlib_apbuart_driver.nr = grlib_apbuart_port_nr = line; | 656 | grlib_apbuart_driver.nr = grlib_apbuart_port_nr = line; |
657 | return line ? 0 : -ENODEV; | ||
667 | } | 658 | } |
668 | 659 | ||
669 | static int __init grlib_apbuart_init(void) | 660 | static int __init grlib_apbuart_init(void) |
@@ -671,7 +662,9 @@ static int __init grlib_apbuart_init(void) | |||
671 | int ret; | 662 | int ret; |
672 | 663 | ||
673 | /* Find all APBUARTS in device the tree and initialize their ports */ | 664 | /* Find all APBUARTS in device the tree and initialize their ports */ |
674 | grlib_apbuart_configure(); | 665 | ret = grlib_apbuart_configure(); |
666 | if (ret) | ||
667 | return ret; | ||
675 | 668 | ||
676 | printk(KERN_INFO "Serial: GRLIB APBUART driver\n"); | 669 | printk(KERN_INFO "Serial: GRLIB APBUART driver\n"); |
677 | 670 | ||