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>
....@@ -54,16 +56,7 @@
5456
5557 static unsigned int skip_txen_test; /* force skip of txen test at init time */
5658
57
-/*
58
- * On -rt we can have a more delays, and legitimately
59
- * so - so don't drop work spuriously and spam the
60
- * syslog:
61
- */
62
-#ifdef CONFIG_PREEMPT_RT_FULL
63
-# define PASS_LIMIT 1000000
64
-#else
65
-# define PASS_LIMIT 512
66
-#endif
59
+#define PASS_LIMIT 512
6760
6861 #include <asm/serial.h>
6962 /*
....@@ -139,12 +132,8 @@
139132
140133 l = l->next;
141134
142
- if (l == i->head && pass_counter++ > PASS_LIMIT) {
143
- /* If we hit this, we're dead. */
144
- printk_ratelimited(KERN_ERR
145
- "serial8250: too much work for irq%d\n", irq);
135
+ if (l == i->head && pass_counter++ > PASS_LIMIT)
146136 break;
147
- }
148137 } while (l != end);
149138
150139 spin_unlock(&i->lock);
....@@ -343,9 +332,9 @@
343332 * hardware interrupt, we use a timer-based system. The original
344333 * driver used to do this with IRQ0.
345334 */
346
- if (!port->irq) {
335
+ if (!port->irq)
347336 mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
348
- } else
337
+ else
349338 retval = serial_link_irq_chain(up);
350339
351340 return retval;
....@@ -584,6 +573,9 @@
584573
585574 up->port.dev = dev;
586575
576
+ if (uart_console_enabled(&up->port))
577
+ pm_runtime_get_sync(up->port.dev);
578
+
587579 serial8250_apply_quirks(up);
588580 uart_add_one_port(drv, &up->port);
589581 }
....@@ -620,6 +612,14 @@
620612 if (retval != 0)
621613 port->cons = NULL;
622614 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);
623623 }
624624
625625 /**
....@@ -680,6 +680,7 @@
680680 .write = univ8250_console_write,
681681 .device = uart_console_device,
682682 .setup = univ8250_console_setup,
683
+ .exit = univ8250_console_exit,
683684 .match = univ8250_console_match,
684685 .flags = CON_PRINTBUFFER | CON_ANYTIME,
685686 .index = -1,
....@@ -767,6 +768,7 @@
767768 if (!console_suspend_enabled && uart_console(port) &&
768769 port->type != PORT_8250) {
769770 unsigned char canary = 0xa5;
771
+
770772 serial_out(up, UART_SCR, canary);
771773 if (serial_in(up, UART_SCR) == canary)
772774 up->canary = canary;
....@@ -829,6 +831,7 @@
829831 uart.port.flags = p->flags;
830832 uart.port.mapbase = p->mapbase;
831833 uart.port.hub6 = p->hub6;
834
+ uart.port.has_sysrq = p->has_sysrq;
832835 uart.port.private_data = p->private_data;
833836 uart.port.type = p->type;
834837 uart.port.serial_in = p->serial_in;
....@@ -996,6 +999,8 @@
996999
9971000 uart = serial8250_find_match_or_unused(&up->port);
9981001 if (uart && uart->port.type != PORT_8250_CIR) {
1002
+ struct mctrl_gpios *gpios;
1003
+
9991004 if (uart->port.dev)
10001005 uart_remove_one_port(&serial8250_reg, &uart->port);
10011006
....@@ -1018,6 +1023,8 @@
10181023 uart->port.unthrottle = up->port.unthrottle;
10191024 uart->port.rs485_config = up->port.rs485_config;
10201025 uart->port.rs485 = up->port.rs485;
1026
+ uart->rs485_start_tx = up->rs485_start_tx;
1027
+ uart->rs485_stop_tx = up->rs485_stop_tx;
10211028 uart->dma = up->dma;
10221029 #ifdef CONFIG_ARCH_ROCKCHIP
10231030 uart->port.line = up->port.line;
....@@ -1026,11 +1033,29 @@
10261033 if (uart->port.fifosize && !uart->tx_loadsz)
10271034 uart->tx_loadsz = uart->port.fifosize;
10281035
1029
- if (up->port.dev)
1036
+ if (up->port.dev) {
10301037 uart->port.dev = up->port.dev;
1038
+ ret = uart_get_rs485_mode(&uart->port);
1039
+ if (ret)
1040
+ goto err;
1041
+ }
10311042
10321043 if (up->port.flags & UPF_FIXED_TYPE)
10331044 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
+ }
10341059
10351060 serial8250_set_defaults(uart);
10361061
....@@ -1138,6 +1163,7 @@
11381163 uart->port.type = PORT_UNKNOWN;
11391164 uart->port.dev = &serial8250_isa_devs->dev;
11401165 uart->capabilities = 0;
1166
+ serial8250_init_port(uart);
11411167 serial8250_apply_quirks(uart);
11421168 uart_add_one_port(&serial8250_reg, &uart->port);
11431169 } else {