| .. | .. |
|---|
| 109 | 109 | uart_console_write(port, s, count, serial_putc); |
|---|
| 110 | 110 | } |
|---|
| 111 | 111 | |
|---|
| 112 | +#ifdef CONFIG_CONSOLE_POLL |
|---|
| 113 | +static int early_serial8250_read(struct console *console, |
|---|
| 114 | + char *s, unsigned int count) |
|---|
| 115 | +{ |
|---|
| 116 | + struct earlycon_device *device = console->data; |
|---|
| 117 | + struct uart_port *port = &device->port; |
|---|
| 118 | + unsigned int status; |
|---|
| 119 | + int num_read = 0; |
|---|
| 120 | + |
|---|
| 121 | + while (num_read < count) { |
|---|
| 122 | + status = serial8250_early_in(port, UART_LSR); |
|---|
| 123 | + if (!(status & UART_LSR_DR)) |
|---|
| 124 | + break; |
|---|
| 125 | + s[num_read++] = serial8250_early_in(port, UART_RX); |
|---|
| 126 | + } |
|---|
| 127 | + |
|---|
| 128 | + return num_read; |
|---|
| 129 | +} |
|---|
| 130 | +#else |
|---|
| 131 | +#define early_serial8250_read NULL |
|---|
| 132 | +#endif |
|---|
| 133 | + |
|---|
| 112 | 134 | static void __init init_port(struct earlycon_device *device) |
|---|
| 113 | 135 | { |
|---|
| 114 | 136 | struct uart_port *port = &device->port; |
|---|
| .. | .. |
|---|
| 149 | 171 | init_port(device); |
|---|
| 150 | 172 | |
|---|
| 151 | 173 | device->con->write = early_serial8250_write; |
|---|
| 174 | + device->con->read = early_serial8250_read; |
|---|
| 152 | 175 | return 0; |
|---|
| 153 | 176 | } |
|---|
| 154 | 177 | EARLYCON_DECLARE(uart8250, early_serial8250_setup); |
|---|