| .. | .. |
|---|
| 14 | 14 | * serial8250_register_8250_port() ports |
|---|
| 15 | 15 | */ |
|---|
| 16 | 16 | |
|---|
| 17 | +#include <linux/acpi.h> |
|---|
| 17 | 18 | #include <linux/module.h> |
|---|
| 18 | 19 | #include <linux/moduleparam.h> |
|---|
| 19 | 20 | #include <linux/ioport.h> |
|---|
| .. | .. |
|---|
| 22 | 23 | #include <linux/sysrq.h> |
|---|
| 23 | 24 | #include <linux/delay.h> |
|---|
| 24 | 25 | #include <linux/platform_device.h> |
|---|
| 26 | +#include <linux/pm_runtime.h> |
|---|
| 25 | 27 | #include <linux/tty.h> |
|---|
| 26 | 28 | #include <linux/ratelimit.h> |
|---|
| 27 | 29 | #include <linux/tty_flip.h> |
|---|
| .. | .. |
|---|
| 130 | 132 | |
|---|
| 131 | 133 | l = l->next; |
|---|
| 132 | 134 | |
|---|
| 133 | | - if (l == i->head && pass_counter++ > PASS_LIMIT) { |
|---|
| 134 | | - /* If we hit this, we're dead. */ |
|---|
| 135 | | - printk_ratelimited(KERN_ERR |
|---|
| 136 | | - "serial8250: too much work for irq%d\n", irq); |
|---|
| 135 | + if (l == i->head && pass_counter++ > PASS_LIMIT) |
|---|
| 137 | 136 | break; |
|---|
| 138 | | - } |
|---|
| 139 | 137 | } while (l != end); |
|---|
| 140 | 138 | |
|---|
| 141 | 139 | spin_unlock(&i->lock); |
|---|
| .. | .. |
|---|
| 277 | 275 | * Must disable interrupts or else we risk racing with the interrupt |
|---|
| 278 | 276 | * based handler. |
|---|
| 279 | 277 | */ |
|---|
| 280 | | - if (up->port.irq) { |
|---|
| 281 | | - ier = serial_in(up, UART_IER); |
|---|
| 282 | | - serial_out(up, UART_IER, 0); |
|---|
| 283 | | - } |
|---|
| 278 | + if (up->port.irq) |
|---|
| 279 | + ier = serial8250_clear_IER(up); |
|---|
| 284 | 280 | |
|---|
| 285 | 281 | iir = serial_in(up, UART_IIR); |
|---|
| 286 | 282 | |
|---|
| .. | .. |
|---|
| 303 | 299 | serial8250_tx_chars(up); |
|---|
| 304 | 300 | |
|---|
| 305 | 301 | if (up->port.irq) |
|---|
| 306 | | - serial_out(up, UART_IER, ier); |
|---|
| 302 | + serial8250_set_IER(up, ier); |
|---|
| 307 | 303 | |
|---|
| 308 | 304 | spin_unlock_irqrestore(&up->port.lock, flags); |
|---|
| 309 | 305 | |
|---|
| .. | .. |
|---|
| 334 | 330 | * hardware interrupt, we use a timer-based system. The original |
|---|
| 335 | 331 | * driver used to do this with IRQ0. |
|---|
| 336 | 332 | */ |
|---|
| 337 | | - if (!port->irq) { |
|---|
| 333 | + if (!port->irq) |
|---|
| 338 | 334 | mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); |
|---|
| 339 | | - } else |
|---|
| 335 | + else |
|---|
| 340 | 336 | retval = serial_link_irq_chain(up); |
|---|
| 341 | 337 | |
|---|
| 342 | 338 | return retval; |
|---|
| .. | .. |
|---|
| 575 | 571 | |
|---|
| 576 | 572 | up->port.dev = dev; |
|---|
| 577 | 573 | |
|---|
| 574 | + if (uart_console_enabled(&up->port)) |
|---|
| 575 | + pm_runtime_get_sync(up->port.dev); |
|---|
| 576 | + |
|---|
| 578 | 577 | serial8250_apply_quirks(up); |
|---|
| 579 | 578 | uart_add_one_port(drv, &up->port); |
|---|
| 580 | 579 | } |
|---|
| .. | .. |
|---|
| 582 | 581 | } |
|---|
| 583 | 582 | |
|---|
| 584 | 583 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
|---|
| 584 | + |
|---|
| 585 | +static void univ8250_console_write_atomic(struct console *co, const char *s, |
|---|
| 586 | + unsigned int count) |
|---|
| 587 | +{ |
|---|
| 588 | + struct uart_8250_port *up = &serial8250_ports[co->index]; |
|---|
| 589 | + |
|---|
| 590 | + serial8250_console_write_atomic(up, s, count); |
|---|
| 591 | +} |
|---|
| 585 | 592 | |
|---|
| 586 | 593 | static void univ8250_console_write(struct console *co, const char *s, |
|---|
| 587 | 594 | unsigned int count) |
|---|
| .. | .. |
|---|
| 611 | 618 | if (retval != 0) |
|---|
| 612 | 619 | port->cons = NULL; |
|---|
| 613 | 620 | return retval; |
|---|
| 621 | +} |
|---|
| 622 | + |
|---|
| 623 | +static int univ8250_console_exit(struct console *co) |
|---|
| 624 | +{ |
|---|
| 625 | + struct uart_port *port; |
|---|
| 626 | + |
|---|
| 627 | + port = &serial8250_ports[co->index].port; |
|---|
| 628 | + return serial8250_console_exit(port); |
|---|
| 614 | 629 | } |
|---|
| 615 | 630 | |
|---|
| 616 | 631 | /** |
|---|
| .. | .. |
|---|
| 668 | 683 | |
|---|
| 669 | 684 | static struct console univ8250_console = { |
|---|
| 670 | 685 | .name = "ttyS", |
|---|
| 686 | + .write_atomic = univ8250_console_write_atomic, |
|---|
| 671 | 687 | .write = univ8250_console_write, |
|---|
| 672 | 688 | .device = uart_console_device, |
|---|
| 673 | 689 | .setup = univ8250_console_setup, |
|---|
| 690 | + .exit = univ8250_console_exit, |
|---|
| 674 | 691 | .match = univ8250_console_match, |
|---|
| 675 | 692 | .flags = CON_PRINTBUFFER | CON_ANYTIME, |
|---|
| 676 | 693 | .index = -1, |
|---|
| .. | .. |
|---|
| 758 | 775 | if (!console_suspend_enabled && uart_console(port) && |
|---|
| 759 | 776 | port->type != PORT_8250) { |
|---|
| 760 | 777 | unsigned char canary = 0xa5; |
|---|
| 778 | + |
|---|
| 761 | 779 | serial_out(up, UART_SCR, canary); |
|---|
| 762 | 780 | if (serial_in(up, UART_SCR) == canary) |
|---|
| 763 | 781 | up->canary = canary; |
|---|
| .. | .. |
|---|
| 820 | 838 | uart.port.flags = p->flags; |
|---|
| 821 | 839 | uart.port.mapbase = p->mapbase; |
|---|
| 822 | 840 | uart.port.hub6 = p->hub6; |
|---|
| 841 | + uart.port.has_sysrq = p->has_sysrq; |
|---|
| 823 | 842 | uart.port.private_data = p->private_data; |
|---|
| 824 | 843 | uart.port.type = p->type; |
|---|
| 825 | 844 | uart.port.serial_in = p->serial_in; |
|---|
| .. | .. |
|---|
| 987 | 1006 | |
|---|
| 988 | 1007 | uart = serial8250_find_match_or_unused(&up->port); |
|---|
| 989 | 1008 | if (uart && uart->port.type != PORT_8250_CIR) { |
|---|
| 1009 | + struct mctrl_gpios *gpios; |
|---|
| 1010 | + |
|---|
| 990 | 1011 | if (uart->port.dev) |
|---|
| 991 | 1012 | uart_remove_one_port(&serial8250_reg, &uart->port); |
|---|
| 992 | 1013 | |
|---|
| .. | .. |
|---|
| 1009 | 1030 | uart->port.unthrottle = up->port.unthrottle; |
|---|
| 1010 | 1031 | uart->port.rs485_config = up->port.rs485_config; |
|---|
| 1011 | 1032 | uart->port.rs485 = up->port.rs485; |
|---|
| 1033 | + uart->rs485_start_tx = up->rs485_start_tx; |
|---|
| 1034 | + uart->rs485_stop_tx = up->rs485_stop_tx; |
|---|
| 1012 | 1035 | uart->dma = up->dma; |
|---|
| 1013 | 1036 | #ifdef CONFIG_ARCH_ROCKCHIP |
|---|
| 1014 | 1037 | uart->port.line = up->port.line; |
|---|
| .. | .. |
|---|
| 1017 | 1040 | if (uart->port.fifosize && !uart->tx_loadsz) |
|---|
| 1018 | 1041 | uart->tx_loadsz = uart->port.fifosize; |
|---|
| 1019 | 1042 | |
|---|
| 1020 | | - if (up->port.dev) |
|---|
| 1043 | + if (up->port.dev) { |
|---|
| 1021 | 1044 | uart->port.dev = up->port.dev; |
|---|
| 1045 | + ret = uart_get_rs485_mode(&uart->port); |
|---|
| 1046 | + if (ret) |
|---|
| 1047 | + goto err; |
|---|
| 1048 | + } |
|---|
| 1022 | 1049 | |
|---|
| 1023 | 1050 | if (up->port.flags & UPF_FIXED_TYPE) |
|---|
| 1024 | 1051 | uart->port.type = up->port.type; |
|---|
| 1025 | 1052 | |
|---|
| 1053 | + /* |
|---|
| 1054 | + * Only call mctrl_gpio_init(), if the device has no ACPI |
|---|
| 1055 | + * companion device |
|---|
| 1056 | + */ |
|---|
| 1057 | + if (!has_acpi_companion(uart->port.dev)) { |
|---|
| 1058 | + gpios = mctrl_gpio_init(&uart->port, 0); |
|---|
| 1059 | + if (IS_ERR(gpios)) { |
|---|
| 1060 | + ret = PTR_ERR(gpios); |
|---|
| 1061 | + goto err; |
|---|
| 1062 | + } else { |
|---|
| 1063 | + uart->gpios = gpios; |
|---|
| 1064 | + } |
|---|
| 1065 | + } |
|---|
| 1066 | + |
|---|
| 1026 | 1067 | serial8250_set_defaults(uart); |
|---|
| 1027 | 1068 | |
|---|
| 1028 | 1069 | /* Possibly override default I/O functions. */ |
|---|