hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/tty/serial/8250/8250_core.c
....@@ -14,6 +14,7 @@
1414 * serial8250_register_8250_port() ports
1515 */
1616
17
+#include <linux/acpi.h>
1718 #include <linux/module.h>
1819 #include <linux/moduleparam.h>
1920 #include <linux/ioport.h>
....@@ -22,6 +23,7 @@
2223 #include <linux/sysrq.h>
2324 #include <linux/delay.h>
2425 #include <linux/platform_device.h>
26
+#include <linux/pm_runtime.h>
2527 #include <linux/tty.h>
2628 #include <linux/ratelimit.h>
2729 #include <linux/tty_flip.h>
....@@ -130,12 +132,8 @@
130132
131133 l = l->next;
132134
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)
137136 break;
138
- }
139137 } while (l != end);
140138
141139 spin_unlock(&i->lock);
....@@ -334,9 +332,9 @@
334332 * hardware interrupt, we use a timer-based system. The original
335333 * driver used to do this with IRQ0.
336334 */
337
- if (!port->irq) {
335
+ if (!port->irq)
338336 mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
339
- } else
337
+ else
340338 retval = serial_link_irq_chain(up);
341339
342340 return retval;
....@@ -575,6 +573,9 @@
575573
576574 up->port.dev = dev;
577575
576
+ if (uart_console_enabled(&up->port))
577
+ pm_runtime_get_sync(up->port.dev);
578
+
578579 serial8250_apply_quirks(up);
579580 uart_add_one_port(drv, &up->port);
580581 }
....@@ -611,6 +612,14 @@
611612 if (retval != 0)
612613 port->cons = NULL;
613614 return retval;
615
+}
616
+
617
+static int univ8250_console_exit(struct console *co)
618
+{
619
+ struct uart_port *port;
620
+
621
+ port = &serial8250_ports[co->index].port;
622
+ return serial8250_console_exit(port);
614623 }
615624
616625 /**
....@@ -671,6 +680,7 @@
671680 .write = univ8250_console_write,
672681 .device = uart_console_device,
673682 .setup = univ8250_console_setup,
683
+ .exit = univ8250_console_exit,
674684 .match = univ8250_console_match,
675685 .flags = CON_PRINTBUFFER | CON_ANYTIME,
676686 .index = -1,
....@@ -758,6 +768,7 @@
758768 if (!console_suspend_enabled && uart_console(port) &&
759769 port->type != PORT_8250) {
760770 unsigned char canary = 0xa5;
771
+
761772 serial_out(up, UART_SCR, canary);
762773 if (serial_in(up, UART_SCR) == canary)
763774 up->canary = canary;
....@@ -820,6 +831,7 @@
820831 uart.port.flags = p->flags;
821832 uart.port.mapbase = p->mapbase;
822833 uart.port.hub6 = p->hub6;
834
+ uart.port.has_sysrq = p->has_sysrq;
823835 uart.port.private_data = p->private_data;
824836 uart.port.type = p->type;
825837 uart.port.serial_in = p->serial_in;
....@@ -987,6 +999,8 @@
987999
9881000 uart = serial8250_find_match_or_unused(&up->port);
9891001 if (uart && uart->port.type != PORT_8250_CIR) {
1002
+ struct mctrl_gpios *gpios;
1003
+
9901004 if (uart->port.dev)
9911005 uart_remove_one_port(&serial8250_reg, &uart->port);
9921006
....@@ -1009,6 +1023,8 @@
10091023 uart->port.unthrottle = up->port.unthrottle;
10101024 uart->port.rs485_config = up->port.rs485_config;
10111025 uart->port.rs485 = up->port.rs485;
1026
+ uart->rs485_start_tx = up->rs485_start_tx;
1027
+ uart->rs485_stop_tx = up->rs485_stop_tx;
10121028 uart->dma = up->dma;
10131029 #ifdef CONFIG_ARCH_ROCKCHIP
10141030 uart->port.line = up->port.line;
....@@ -1017,11 +1033,29 @@
10171033 if (uart->port.fifosize && !uart->tx_loadsz)
10181034 uart->tx_loadsz = uart->port.fifosize;
10191035
1020
- if (up->port.dev)
1036
+ if (up->port.dev) {
10211037 uart->port.dev = up->port.dev;
1038
+ ret = uart_get_rs485_mode(&uart->port);
1039
+ if (ret)
1040
+ goto err;
1041
+ }
10221042
10231043 if (up->port.flags & UPF_FIXED_TYPE)
10241044 uart->port.type = up->port.type;
1045
+
1046
+ /*
1047
+ * Only call mctrl_gpio_init(), if the device has no ACPI
1048
+ * companion device
1049
+ */
1050
+ if (!has_acpi_companion(uart->port.dev)) {
1051
+ gpios = mctrl_gpio_init(&uart->port, 0);
1052
+ if (IS_ERR(gpios)) {
1053
+ ret = PTR_ERR(gpios);
1054
+ goto err;
1055
+ } else {
1056
+ uart->gpios = gpios;
1057
+ }
1058
+ }
10251059
10261060 serial8250_set_defaults(uart);
10271061
....@@ -1129,6 +1163,7 @@
11291163 uart->port.type = PORT_UNKNOWN;
11301164 uart->port.dev = &serial8250_isa_devs->dev;
11311165 uart->capabilities = 0;
1166
+ serial8250_init_port(uart);
11321167 serial8250_apply_quirks(uart);
11331168 uart_add_one_port(&serial8250_reg, &uart->port);
11341169 } else {