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
127 uart_port_tx_limited(port, ch, port->fifosize >> 1, in apbuart_tx_chars()
129 UART_PUT_CHAR(port, ch), in apbuart_tx_chars()
135 struct uart_port *port = dev_id; in apbuart_int() local
138 spin_lock(&port->lock); in apbuart_int()
140 status = UART_GET_STATUS(port); in apbuart_int()
142 apbuart_rx_chars(port); in apbuart_int()
144 apbuart_tx_chars(port); in apbuart_int()
146 spin_unlock(&port->lock); in apbuart_int()
151 static unsigned int apbuart_tx_empty(struct uart_port *port) in apbuart_tx_empty() argument
153 unsigned int status = UART_GET_STATUS(port); in apbuart_tx_empty()
157 static unsigned int apbuart_get_mctrl(struct uart_port *port) in apbuart_get_mctrl() argument
163 static void apbuart_set_mctrl(struct uart_port *port, unsigned int mctrl) in apbuart_set_mctrl() argument
168 static void apbuart_break_ctl(struct uart_port *port, int break_state) in apbuart_break_ctl() argument
173 static int apbuart_startup(struct uart_port *port) in apbuart_startup() argument
179 retval = request_irq(port->irq, apbuart_int, 0, "apbuart", port); in apbuart_startup()
184 cr = UART_GET_CTRL(port); in apbuart_startup()
185 UART_PUT_CTRL(port, in apbuart_startup()
192 static void apbuart_shutdown(struct uart_port *port) in apbuart_shutdown() argument
197 cr = UART_GET_CTRL(port); in apbuart_shutdown()
198 UART_PUT_CTRL(port, in apbuart_shutdown()
203 free_irq(port->irq, port); in apbuart_shutdown()
206 static void apbuart_set_termios(struct uart_port *port, in apbuart_set_termios() argument
214 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in apbuart_set_termios()
216 panic("invalid baudrate %i\n", port->uartclk / 16); in apbuart_set_termios()
219 quot = (uart_get_divisor(port, baud)) * 2; in apbuart_set_termios()
220 cr = UART_GET_CTRL(port); in apbuart_set_termios()
233 spin_lock_irqsave(&port->lock, flags); in apbuart_set_termios()
236 uart_update_timeout(port, termios->c_cflag, baud); in apbuart_set_termios()
238 port->read_status_mask = UART_STATUS_OE; in apbuart_set_termios()
240 port->read_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
243 port->ignore_status_mask = 0; in apbuart_set_termios()
245 port->ignore_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
249 port->ignore_status_mask |= UART_DUMMY_RSR_RX; in apbuart_set_termios()
253 UART_PUT_SCAL(port, quot); in apbuart_set_termios()
254 UART_PUT_CTRL(port, cr); in apbuart_set_termios()
256 spin_unlock_irqrestore(&port->lock, flags); in apbuart_set_termios()
259 static const char *apbuart_type(struct uart_port *port) in apbuart_type() argument
261 return port->type == PORT_APBUART ? "GRLIB/APBUART" : NULL; in apbuart_type()
264 static void apbuart_release_port(struct uart_port *port) in apbuart_release_port() argument
266 release_mem_region(port->mapbase, 0x100); in apbuart_release_port()
269 static int apbuart_request_port(struct uart_port *port) in apbuart_request_port() argument
271 return request_mem_region(port->mapbase, 0x100, "grlib-apbuart") in apbuart_request_port()
277 static void apbuart_config_port(struct uart_port *port, int flags) in apbuart_config_port() argument
280 port->type = PORT_APBUART; in apbuart_config_port()
281 apbuart_request_port(port); in apbuart_config_port()
286 static int apbuart_verify_port(struct uart_port *port, in apbuart_verify_port() argument
320 static int apbuart_scan_fifo_size(struct uart_port *port, int portnumber) in apbuart_scan_fifo_size() argument
327 ctrl = UART_GET_CTRL(port); in apbuart_scan_fifo_size()
338 UART_PUT_CTRL(port, ctrl | UART_CTRL_TE); in apbuart_scan_fifo_size()
340 while (!UART_TX_READY(UART_GET_STATUS(port))) in apbuart_scan_fifo_size()
348 UART_PUT_CTRL(port, ctrl & ~(UART_CTRL_TE)); in apbuart_scan_fifo_size()
351 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
359 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
362 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
363 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
368 UART_PUT_CTRL(port, ctrl); in apbuart_scan_fifo_size()
377 static void apbuart_flush_fifo(struct uart_port *port) in apbuart_flush_fifo() argument
381 for (i = 0; i < port->fifosize; i++) in apbuart_flush_fifo()
382 UART_GET_CHAR(port); in apbuart_flush_fifo()
392 static void apbuart_console_putchar(struct uart_port *port, unsigned char ch) in apbuart_console_putchar() argument
396 status = UART_GET_STATUS(port); in apbuart_console_putchar()
398 UART_PUT_CHAR(port, ch); in apbuart_console_putchar()
404 struct uart_port *port = &grlib_apbuart_ports[co->index]; in apbuart_console_write() local
408 old_cr = UART_GET_CTRL(port); in apbuart_console_write()
410 UART_PUT_CTRL(port, new_cr); in apbuart_console_write()
412 uart_console_write(port, s, count, apbuart_console_putchar); in apbuart_console_write()
419 status = UART_GET_STATUS(port); in apbuart_console_write()
421 UART_PUT_CTRL(port, old_cr); in apbuart_console_write()
425 apbuart_console_get_options(struct uart_port *port, int *baud, in apbuart_console_get_options() argument
428 if (UART_GET_CTRL(port) & (UART_CTRL_RE | UART_CTRL_TE)) { in apbuart_console_get_options()
431 status = UART_GET_STATUS(port); in apbuart_console_get_options()
442 quot = UART_GET_SCAL(port) / 8; in apbuart_console_get_options()
443 *baud = port->uartclk / (16 * (quot + 1)); in apbuart_console_get_options()
449 struct uart_port *port; in apbuart_console_setup() local
466 port = &grlib_apbuart_ports[co->index]; in apbuart_console_setup()
468 spin_lock_init(&port->lock); in apbuart_console_setup()
473 apbuart_console_get_options(port, &baud, &parity, &bits); in apbuart_console_setup()
475 return uart_set_options(port, co, baud, parity, bits, flow); in apbuart_console_setup()
526 struct uart_port *port = NULL; in apbuart_probe() local
533 port = &grlib_apbuart_ports[i]; in apbuart_probe()
534 port->dev = &op->dev; in apbuart_probe()
535 port->irq = op->archdata.irqs[0]; in apbuart_probe()
537 uart_add_one_port(&grlib_apbuart_driver, (struct uart_port *) port); in apbuart_probe()
539 apbuart_flush_fifo((struct uart_port *) port); in apbuart_probe()
542 (unsigned long long) port->mapbase, port->irq); in apbuart_probe()
575 struct uart_port *port; in grlib_apbuart_configure() local
592 port = &grlib_apbuart_ports[line]; in grlib_apbuart_configure()
594 port->mapbase = addr; in grlib_apbuart_configure()
595 port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); in grlib_apbuart_configure()
596 port->irq = 0; in grlib_apbuart_configure()
597 port->iotype = UPIO_MEM; in grlib_apbuart_configure()
598 port->ops = &grlib_apbuart_ops; in grlib_apbuart_configure()
599 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE); in grlib_apbuart_configure()
600 port->flags = UPF_BOOT_AUTOCONF; in grlib_apbuart_configure()
601 port->line = line; in grlib_apbuart_configure()
602 port->uartclk = *freq_hz; in grlib_apbuart_configure()
603 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); in grlib_apbuart_configure()