diff options
Diffstat (limited to 'drivers/tty/serial/bcm63xx_uart.c')
-rw-r--r-- | drivers/tty/serial/bcm63xx_uart.c | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index 231519022b73..e04e5805ae6e 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c | |||
@@ -588,20 +588,7 @@ static void bcm_uart_set_termios(struct uart_port *port, | |||
588 | */ | 588 | */ |
589 | static int bcm_uart_request_port(struct uart_port *port) | 589 | static int bcm_uart_request_port(struct uart_port *port) |
590 | { | 590 | { |
591 | unsigned int size; | 591 | /* UARTs always present */ |
592 | |||
593 | size = UART_REG_SIZE; | ||
594 | if (!request_mem_region(port->mapbase, size, "bcm63xx")) { | ||
595 | dev_err(port->dev, "Memory region busy\n"); | ||
596 | return -EBUSY; | ||
597 | } | ||
598 | |||
599 | port->membase = ioremap(port->mapbase, size); | ||
600 | if (!port->membase) { | ||
601 | dev_err(port->dev, "Unable to map registers\n"); | ||
602 | release_mem_region(port->mapbase, size); | ||
603 | return -EBUSY; | ||
604 | } | ||
605 | return 0; | 592 | return 0; |
606 | } | 593 | } |
607 | 594 | ||
@@ -610,8 +597,7 @@ static int bcm_uart_request_port(struct uart_port *port) | |||
610 | */ | 597 | */ |
611 | static void bcm_uart_release_port(struct uart_port *port) | 598 | static void bcm_uart_release_port(struct uart_port *port) |
612 | { | 599 | { |
613 | release_mem_region(port->mapbase, UART_REG_SIZE); | 600 | /* Nothing to release ... */ |
614 | iounmap(port->membase); | ||
615 | } | 601 | } |
616 | 602 | ||
617 | /* | 603 | /* |
@@ -782,6 +768,26 @@ static int __init bcm63xx_console_init(void) | |||
782 | 768 | ||
783 | console_initcall(bcm63xx_console_init); | 769 | console_initcall(bcm63xx_console_init); |
784 | 770 | ||
771 | static void bcm_early_write(struct console *con, const char *s, unsigned n) | ||
772 | { | ||
773 | struct earlycon_device *dev = con->data; | ||
774 | |||
775 | uart_console_write(&dev->port, s, n, bcm_console_putchar); | ||
776 | wait_for_xmitr(&dev->port); | ||
777 | } | ||
778 | |||
779 | static int __init bcm_early_console_setup(struct earlycon_device *device, | ||
780 | const char *opt) | ||
781 | { | ||
782 | if (!device->port.membase) | ||
783 | return -ENODEV; | ||
784 | |||
785 | device->con->write = bcm_early_write; | ||
786 | return 0; | ||
787 | } | ||
788 | |||
789 | OF_EARLYCON_DECLARE(bcm63xx_uart, "brcm,bcm6345-uart", bcm_early_console_setup); | ||
790 | |||
785 | #define BCM63XX_CONSOLE (&bcm63xx_console) | 791 | #define BCM63XX_CONSOLE (&bcm63xx_console) |
786 | #else | 792 | #else |
787 | #define BCM63XX_CONSOLE NULL | 793 | #define BCM63XX_CONSOLE NULL |
@@ -813,25 +819,30 @@ static int bcm_uart_probe(struct platform_device *pdev) | |||
813 | if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS) | 819 | if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS) |
814 | return -EINVAL; | 820 | return -EINVAL; |
815 | 821 | ||
816 | if (ports[pdev->id].membase) | 822 | port = &ports[pdev->id]; |
823 | if (port->membase) | ||
817 | return -EBUSY; | 824 | return -EBUSY; |
825 | memset(port, 0, sizeof(*port)); | ||
818 | 826 | ||
819 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 827 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
820 | if (!res_mem) | 828 | if (!res_mem) |
821 | return -ENODEV; | 829 | return -ENODEV; |
822 | 830 | ||
831 | port->mapbase = res_mem->start; | ||
832 | port->membase = devm_ioremap_resource(&pdev->dev, res_mem); | ||
833 | if (IS_ERR(port->membase)) | ||
834 | return PTR_ERR(port->membase); | ||
835 | |||
823 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 836 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
824 | if (!res_irq) | 837 | if (!res_irq) |
825 | return -ENODEV; | 838 | return -ENODEV; |
826 | 839 | ||
827 | clk = clk_get(&pdev->dev, "periph"); | 840 | clk = pdev->dev.of_node ? of_clk_get(pdev->dev.of_node, 0) : |
841 | clk_get(&pdev->dev, "periph"); | ||
828 | if (IS_ERR(clk)) | 842 | if (IS_ERR(clk)) |
829 | return -ENODEV; | 843 | return -ENODEV; |
830 | 844 | ||
831 | port = &ports[pdev->id]; | ||
832 | memset(port, 0, sizeof(*port)); | ||
833 | port->iotype = UPIO_MEM; | 845 | port->iotype = UPIO_MEM; |
834 | port->mapbase = res_mem->start; | ||
835 | port->irq = res_irq->start; | 846 | port->irq = res_irq->start; |
836 | port->ops = &bcm_uart_ops; | 847 | port->ops = &bcm_uart_ops; |
837 | port->flags = UPF_BOOT_AUTOCONF; | 848 | port->flags = UPF_BOOT_AUTOCONF; |
@@ -905,5 +916,5 @@ module_init(bcm_uart_init); | |||
905 | module_exit(bcm_uart_exit); | 916 | module_exit(bcm_uart_exit); |
906 | 917 | ||
907 | MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); | 918 | MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); |
908 | MODULE_DESCRIPTION("Broadcom 63<xx integrated uart driver"); | 919 | MODULE_DESCRIPTION("Broadcom 63xx integrated uart driver"); |
909 | MODULE_LICENSE("GPL"); | 920 | MODULE_LICENSE("GPL"); |