aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/8250/8250_early.c42
-rw-r--r--include/linux/serial_8250.h2
2 files changed, 23 insertions, 21 deletions
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 843a150ba105..f53a7db4350d 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -48,7 +48,7 @@ struct early_serial8250_device {
48 48
49static struct early_serial8250_device early_device; 49static struct early_serial8250_device early_device;
50 50
51static unsigned int __init serial_in(struct uart_port *port, int offset) 51unsigned int __weak __init serial8250_early_in(struct uart_port *port, int offset)
52{ 52{
53 switch (port->iotype) { 53 switch (port->iotype) {
54 case UPIO_MEM: 54 case UPIO_MEM:
@@ -62,7 +62,7 @@ static unsigned int __init serial_in(struct uart_port *port, int offset)
62 } 62 }
63} 63}
64 64
65static void __init serial_out(struct uart_port *port, int offset, int value) 65void __weak __init serial8250_early_out(struct uart_port *port, int offset, int value)
66{ 66{
67 switch (port->iotype) { 67 switch (port->iotype) {
68 case UPIO_MEM: 68 case UPIO_MEM:
@@ -84,7 +84,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
84 unsigned int status; 84 unsigned int status;
85 85
86 for (;;) { 86 for (;;) {
87 status = serial_in(port, UART_LSR); 87 status = serial8250_early_in(port, UART_LSR);
88 if ((status & BOTH_EMPTY) == BOTH_EMPTY) 88 if ((status & BOTH_EMPTY) == BOTH_EMPTY)
89 return; 89 return;
90 cpu_relax(); 90 cpu_relax();
@@ -94,7 +94,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
94static void __init serial_putc(struct uart_port *port, int c) 94static void __init serial_putc(struct uart_port *port, int c)
95{ 95{
96 wait_for_xmitr(port); 96 wait_for_xmitr(port);
97 serial_out(port, UART_TX, c); 97 serial8250_early_out(port, UART_TX, c);
98} 98}
99 99
100static void __init early_serial8250_write(struct console *console, 100static void __init early_serial8250_write(struct console *console,
@@ -104,14 +104,14 @@ static void __init early_serial8250_write(struct console *console,
104 unsigned int ier; 104 unsigned int ier;
105 105
106 /* Save the IER and disable interrupts */ 106 /* Save the IER and disable interrupts */
107 ier = serial_in(port, UART_IER); 107 ier = serial8250_early_in(port, UART_IER);
108 serial_out(port, UART_IER, 0); 108 serial8250_early_out(port, UART_IER, 0);
109 109
110 uart_console_write(port, s, count, serial_putc); 110 uart_console_write(port, s, count, serial_putc);
111 111
112 /* Wait for transmitter to become empty and restore the IER */ 112 /* Wait for transmitter to become empty and restore the IER */
113 wait_for_xmitr(port); 113 wait_for_xmitr(port);
114 serial_out(port, UART_IER, ier); 114 serial8250_early_out(port, UART_IER, ier);
115} 115}
116 116
117static unsigned int __init probe_baud(struct uart_port *port) 117static unsigned int __init probe_baud(struct uart_port *port)
@@ -119,11 +119,11 @@ static unsigned int __init probe_baud(struct uart_port *port)
119 unsigned char lcr, dll, dlm; 119 unsigned char lcr, dll, dlm;
120 unsigned int quot; 120 unsigned int quot;
121 121
122 lcr = serial_in(port, UART_LCR); 122 lcr = serial8250_early_in(port, UART_LCR);
123 serial_out(port, UART_LCR, lcr | UART_LCR_DLAB); 123 serial8250_early_out(port, UART_LCR, lcr | UART_LCR_DLAB);
124 dll = serial_in(port, UART_DLL); 124 dll = serial8250_early_in(port, UART_DLL);
125 dlm = serial_in(port, UART_DLM); 125 dlm = serial8250_early_in(port, UART_DLM);
126 serial_out(port, UART_LCR, lcr); 126 serial8250_early_out(port, UART_LCR, lcr);
127 127
128 quot = (dlm << 8) | dll; 128 quot = (dlm << 8) | dll;
129 return (port->uartclk / 16) / quot; 129 return (port->uartclk / 16) / quot;
@@ -135,17 +135,17 @@ static void __init init_port(struct early_serial8250_device *device)
135 unsigned int divisor; 135 unsigned int divisor;
136 unsigned char c; 136 unsigned char c;
137 137
138 serial_out(port, UART_LCR, 0x3); /* 8n1 */ 138 serial8250_early_out(port, UART_LCR, 0x3); /* 8n1 */
139 serial_out(port, UART_IER, 0); /* no interrupt */ 139 serial8250_early_out(port, UART_IER, 0); /* no interrupt */
140 serial_out(port, UART_FCR, 0); /* no fifo */ 140 serial8250_early_out(port, UART_FCR, 0); /* no fifo */
141 serial_out(port, UART_MCR, 0x3); /* DTR + RTS */ 141 serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */
142 142
143 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud); 143 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
144 c = serial_in(port, UART_LCR); 144 c = serial8250_early_in(port, UART_LCR);
145 serial_out(port, UART_LCR, c | UART_LCR_DLAB); 145 serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB);
146 serial_out(port, UART_DLL, divisor & 0xff); 146 serial8250_early_out(port, UART_DLL, divisor & 0xff);
147 serial_out(port, UART_DLM, (divisor >> 8) & 0xff); 147 serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff);
148 serial_out(port, UART_LCR, c & ~UART_LCR_DLAB); 148 serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB);
149} 149}
150 150
151static int __init parse_options(struct early_serial8250_device *device, 151static int __init parse_options(struct early_serial8250_device *device,
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index c174c90fb3fb..c490d20b3fb8 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -105,6 +105,8 @@ extern int early_serial_setup(struct uart_port *port);
105 105
106extern int serial8250_find_port(struct uart_port *p); 106extern int serial8250_find_port(struct uart_port *p);
107extern int serial8250_find_port_for_earlycon(void); 107extern int serial8250_find_port_for_earlycon(void);
108extern unsigned int serial8250_early_in(struct uart_port *port, int offset);
109extern void serial8250_early_out(struct uart_port *port, int offset, int value);
108extern int setup_early_serial8250_console(char *cmdline); 110extern int setup_early_serial8250_console(char *cmdline);
109extern void serial8250_do_set_termios(struct uart_port *port, 111extern void serial8250_do_set_termios(struct uart_port *port,
110 struct ktermios *termios, struct ktermios *old); 112 struct ktermios *termios, struct ktermios *old);