Lines Matching refs:port
39 static void apbuart_tx_chars(struct uart_port *port);
41 static void apbuart_stop_tx(struct uart_port *port) in apbuart_stop_tx() argument
45 cr = UART_GET_CTRL(port); in apbuart_stop_tx()
47 UART_PUT_CTRL(port, cr); in apbuart_stop_tx()
50 static void apbuart_start_tx(struct uart_port *port) in apbuart_start_tx() argument
54 cr = UART_GET_CTRL(port); in apbuart_start_tx()
56 UART_PUT_CTRL(port, cr); in apbuart_start_tx()
58 if (UART_GET_STATUS(port) & UART_STATUS_THE) in apbuart_start_tx()
59 apbuart_tx_chars(port); in apbuart_start_tx()
62 static void apbuart_stop_rx(struct uart_port *port) in apbuart_stop_rx() argument
66 cr = UART_GET_CTRL(port); in apbuart_stop_rx()
68 UART_PUT_CTRL(port, cr); in apbuart_stop_rx()
71 static void apbuart_rx_chars(struct uart_port *port) in apbuart_rx_chars() argument
74 unsigned int max_chars = port->fifosize; in apbuart_rx_chars()
76 status = UART_GET_STATUS(port); in apbuart_rx_chars()
80 ch = UART_GET_CHAR(port); in apbuart_rx_chars()
83 port->icount.rx++; in apbuart_rx_chars()
85 rsr = UART_GET_STATUS(port) | UART_DUMMY_RSR_RX; in apbuart_rx_chars()
86 UART_PUT_STATUS(port, 0); in apbuart_rx_chars()
91 port->icount.brk++; in apbuart_rx_chars()
92 if (uart_handle_break(port)) in apbuart_rx_chars()
95 port->icount.parity++; in apbuart_rx_chars()
97 port->icount.frame++; in apbuart_rx_chars()
100 port->icount.overrun++; in apbuart_rx_chars()
102 rsr &= port->read_status_mask; in apbuart_rx_chars()
110 if (uart_handle_sysrq_char(port, ch)) in apbuart_rx_chars()
113 uart_insert_char(port, rsr, UART_STATUS_OE, ch, flag); in apbuart_rx_chars()
117 status = UART_GET_STATUS(port); in apbuart_rx_chars()
120 tty_flip_buffer_push(&port->state->port); in apbuart_rx_chars()
123 static void apbuart_tx_chars(struct uart_port *port) in apbuart_tx_chars() argument
125 struct circ_buf *xmit = &port->state->xmit; in apbuart_tx_chars()
128 if (port->x_char) { in apbuart_tx_chars()
129 UART_PUT_CHAR(port, port->x_char); in apbuart_tx_chars()
130 port->icount.tx++; in apbuart_tx_chars()
131 port->x_char = 0; in apbuart_tx_chars()
135 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { in apbuart_tx_chars()
136 apbuart_stop_tx(port); in apbuart_tx_chars()
141 count = port->fifosize >> 1; in apbuart_tx_chars()
143 UART_PUT_CHAR(port, xmit->buf[xmit->tail]); in apbuart_tx_chars()
145 port->icount.tx++; in apbuart_tx_chars()
151 uart_write_wakeup(port); in apbuart_tx_chars()
154 apbuart_stop_tx(port); in apbuart_tx_chars()
159 struct uart_port *port = dev_id; in apbuart_int() local
162 spin_lock(&port->lock); in apbuart_int()
164 status = UART_GET_STATUS(port); in apbuart_int()
166 apbuart_rx_chars(port); in apbuart_int()
168 apbuart_tx_chars(port); in apbuart_int()
170 spin_unlock(&port->lock); in apbuart_int()
175 static unsigned int apbuart_tx_empty(struct uart_port *port) in apbuart_tx_empty() argument
177 unsigned int status = UART_GET_STATUS(port); in apbuart_tx_empty()
181 static unsigned int apbuart_get_mctrl(struct uart_port *port) in apbuart_get_mctrl() argument
187 static void apbuart_set_mctrl(struct uart_port *port, unsigned int mctrl) in apbuart_set_mctrl() argument
192 static void apbuart_break_ctl(struct uart_port *port, int break_state) in apbuart_break_ctl() argument
197 static int apbuart_startup(struct uart_port *port) in apbuart_startup() argument
203 retval = request_irq(port->irq, apbuart_int, 0, "apbuart", port); in apbuart_startup()
208 cr = UART_GET_CTRL(port); in apbuart_startup()
209 UART_PUT_CTRL(port, in apbuart_startup()
216 static void apbuart_shutdown(struct uart_port *port) in apbuart_shutdown() argument
221 cr = UART_GET_CTRL(port); in apbuart_shutdown()
222 UART_PUT_CTRL(port, in apbuart_shutdown()
227 free_irq(port->irq, port); in apbuart_shutdown()
230 static void apbuart_set_termios(struct uart_port *port, in apbuart_set_termios() argument
238 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in apbuart_set_termios()
240 panic("invalid baudrate %i\n", port->uartclk / 16); in apbuart_set_termios()
243 quot = (uart_get_divisor(port, baud)) * 2; in apbuart_set_termios()
244 cr = UART_GET_CTRL(port); in apbuart_set_termios()
257 spin_lock_irqsave(&port->lock, flags); in apbuart_set_termios()
260 uart_update_timeout(port, termios->c_cflag, baud); in apbuart_set_termios()
262 port->read_status_mask = UART_STATUS_OE; in apbuart_set_termios()
264 port->read_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
267 port->ignore_status_mask = 0; in apbuart_set_termios()
269 port->ignore_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
273 port->ignore_status_mask |= UART_DUMMY_RSR_RX; in apbuart_set_termios()
277 UART_PUT_SCAL(port, quot); in apbuart_set_termios()
278 UART_PUT_CTRL(port, cr); in apbuart_set_termios()
280 spin_unlock_irqrestore(&port->lock, flags); in apbuart_set_termios()
283 static const char *apbuart_type(struct uart_port *port) in apbuart_type() argument
285 return port->type == PORT_APBUART ? "GRLIB/APBUART" : NULL; in apbuart_type()
288 static void apbuart_release_port(struct uart_port *port) in apbuart_release_port() argument
290 release_mem_region(port->mapbase, 0x100); in apbuart_release_port()
293 static int apbuart_request_port(struct uart_port *port) in apbuart_request_port() argument
295 return request_mem_region(port->mapbase, 0x100, "grlib-apbuart") in apbuart_request_port()
301 static void apbuart_config_port(struct uart_port *port, int flags) in apbuart_config_port() argument
304 port->type = PORT_APBUART; in apbuart_config_port()
305 apbuart_request_port(port); in apbuart_config_port()
310 static int apbuart_verify_port(struct uart_port *port, in apbuart_verify_port() argument
344 static int apbuart_scan_fifo_size(struct uart_port *port, int portnumber) in apbuart_scan_fifo_size() argument
351 ctrl = UART_GET_CTRL(port); in apbuart_scan_fifo_size()
362 UART_PUT_CTRL(port, ctrl | UART_CTRL_TE); in apbuart_scan_fifo_size()
364 while (!UART_TX_READY(UART_GET_STATUS(port))) in apbuart_scan_fifo_size()
372 UART_PUT_CTRL(port, ctrl & ~(UART_CTRL_TE)); in apbuart_scan_fifo_size()
375 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
383 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
386 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
387 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
392 UART_PUT_CTRL(port, ctrl); in apbuart_scan_fifo_size()
401 static void apbuart_flush_fifo(struct uart_port *port) in apbuart_flush_fifo() argument
405 for (i = 0; i < port->fifosize; i++) in apbuart_flush_fifo()
406 UART_GET_CHAR(port); in apbuart_flush_fifo()
416 static void apbuart_console_putchar(struct uart_port *port, unsigned char ch) in apbuart_console_putchar() argument
420 status = UART_GET_STATUS(port); in apbuart_console_putchar()
422 UART_PUT_CHAR(port, ch); in apbuart_console_putchar()
428 struct uart_port *port = &grlib_apbuart_ports[co->index]; in apbuart_console_write() local
432 old_cr = UART_GET_CTRL(port); in apbuart_console_write()
434 UART_PUT_CTRL(port, new_cr); in apbuart_console_write()
436 uart_console_write(port, s, count, apbuart_console_putchar); in apbuart_console_write()
443 status = UART_GET_STATUS(port); in apbuart_console_write()
445 UART_PUT_CTRL(port, old_cr); in apbuart_console_write()
449 apbuart_console_get_options(struct uart_port *port, int *baud, in apbuart_console_get_options() argument
452 if (UART_GET_CTRL(port) & (UART_CTRL_RE | UART_CTRL_TE)) { in apbuart_console_get_options()
455 status = UART_GET_STATUS(port); in apbuart_console_get_options()
466 quot = UART_GET_SCAL(port) / 8; in apbuart_console_get_options()
467 *baud = port->uartclk / (16 * (quot + 1)); in apbuart_console_get_options()
473 struct uart_port *port; in apbuart_console_setup() local
490 port = &grlib_apbuart_ports[co->index]; in apbuart_console_setup()
492 spin_lock_init(&port->lock); in apbuart_console_setup()
497 apbuart_console_get_options(port, &baud, &parity, &bits); in apbuart_console_setup()
499 return uart_set_options(port, co, baud, parity, bits, flow); in apbuart_console_setup()
550 struct uart_port *port = NULL; in apbuart_probe() local
557 port = &grlib_apbuart_ports[i]; in apbuart_probe()
558 port->dev = &op->dev; in apbuart_probe()
559 port->irq = op->archdata.irqs[0]; in apbuart_probe()
561 uart_add_one_port(&grlib_apbuart_driver, (struct uart_port *) port); in apbuart_probe()
563 apbuart_flush_fifo((struct uart_port *) port); in apbuart_probe()
566 (unsigned long long) port->mapbase, port->irq); in apbuart_probe()
599 struct uart_port *port; in grlib_apbuart_configure() local
616 port = &grlib_apbuart_ports[line]; in grlib_apbuart_configure()
618 port->mapbase = addr; in grlib_apbuart_configure()
619 port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); in grlib_apbuart_configure()
620 port->irq = 0; in grlib_apbuart_configure()
621 port->iotype = UPIO_MEM; in grlib_apbuart_configure()
622 port->ops = &grlib_apbuart_ops; in grlib_apbuart_configure()
623 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE); in grlib_apbuart_configure()
624 port->flags = UPF_BOOT_AUTOCONF; in grlib_apbuart_configure()
625 port->line = line; in grlib_apbuart_configure()
626 port->uartclk = *freq_hz; in grlib_apbuart_configure()
627 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); in grlib_apbuart_configure()