Lines Matching refs:port
36 static void apbuart_tx_chars(struct uart_port *port);
38 static void apbuart_stop_tx(struct uart_port *port) in apbuart_stop_tx() argument
42 cr = UART_GET_CTRL(port); in apbuart_stop_tx()
44 UART_PUT_CTRL(port, cr); in apbuart_stop_tx()
47 static void apbuart_start_tx(struct uart_port *port) in apbuart_start_tx() argument
51 cr = UART_GET_CTRL(port); in apbuart_start_tx()
53 UART_PUT_CTRL(port, cr); in apbuart_start_tx()
55 if (UART_GET_STATUS(port) & UART_STATUS_THE) in apbuart_start_tx()
56 apbuart_tx_chars(port); in apbuart_start_tx()
59 static void apbuart_stop_rx(struct uart_port *port) in apbuart_stop_rx() argument
63 cr = UART_GET_CTRL(port); in apbuart_stop_rx()
65 UART_PUT_CTRL(port, cr); in apbuart_stop_rx()
68 static void apbuart_rx_chars(struct uart_port *port) in apbuart_rx_chars() argument
71 unsigned int max_chars = port->fifosize; in apbuart_rx_chars()
74 status = UART_GET_STATUS(port); in apbuart_rx_chars()
78 ch = UART_GET_CHAR(port); in apbuart_rx_chars()
81 port->icount.rx++; in apbuart_rx_chars()
83 rsr = UART_GET_STATUS(port) | UART_DUMMY_RSR_RX; in apbuart_rx_chars()
84 UART_PUT_STATUS(port, 0); in apbuart_rx_chars()
89 port->icount.brk++; in apbuart_rx_chars()
90 if (uart_handle_break(port)) in apbuart_rx_chars()
93 port->icount.parity++; in apbuart_rx_chars()
95 port->icount.frame++; in apbuart_rx_chars()
98 port->icount.overrun++; in apbuart_rx_chars()
100 rsr &= port->read_status_mask; in apbuart_rx_chars()
108 if (uart_handle_sysrq_char(port, ch)) in apbuart_rx_chars()
111 uart_insert_char(port, rsr, UART_STATUS_OE, ch, flag); in apbuart_rx_chars()
115 status = UART_GET_STATUS(port); in apbuart_rx_chars()
118 tty_flip_buffer_push(&port->state->port); in apbuart_rx_chars()
121 static void apbuart_tx_chars(struct uart_port *port) in apbuart_tx_chars() argument
125 uart_port_tx_limited(port, ch, port->fifosize, in apbuart_tx_chars()
127 UART_PUT_CHAR(port, ch), in apbuart_tx_chars()
133 struct uart_port *port = dev_id; in apbuart_int() local
136 spin_lock(&port->lock); in apbuart_int()
138 status = UART_GET_STATUS(port); in apbuart_int()
140 apbuart_rx_chars(port); in apbuart_int()
142 apbuart_tx_chars(port); in apbuart_int()
144 spin_unlock(&port->lock); in apbuart_int()
149 static unsigned int apbuart_tx_empty(struct uart_port *port) in apbuart_tx_empty() argument
151 unsigned int status = UART_GET_STATUS(port); in apbuart_tx_empty()
155 static unsigned int apbuart_get_mctrl(struct uart_port *port) in apbuart_get_mctrl() argument
161 static void apbuart_set_mctrl(struct uart_port *port, unsigned int mctrl) in apbuart_set_mctrl() argument
166 static void apbuart_break_ctl(struct uart_port *port, int break_state) in apbuart_break_ctl() argument
171 static int apbuart_startup(struct uart_port *port) in apbuart_startup() argument
177 retval = request_irq(port->irq, apbuart_int, 0, "apbuart", port); in apbuart_startup()
182 cr = UART_GET_CTRL(port); in apbuart_startup()
183 UART_PUT_CTRL(port, in apbuart_startup()
190 static void apbuart_shutdown(struct uart_port *port) in apbuart_shutdown() argument
195 cr = UART_GET_CTRL(port); in apbuart_shutdown()
196 UART_PUT_CTRL(port, in apbuart_shutdown()
201 free_irq(port->irq, port); in apbuart_shutdown()
204 static void apbuart_set_termios(struct uart_port *port, in apbuart_set_termios() argument
212 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in apbuart_set_termios()
214 panic("invalid baudrate %i\n", port->uartclk / 16); in apbuart_set_termios()
217 quot = (uart_get_divisor(port, baud)) * 2; in apbuart_set_termios()
218 cr = UART_GET_CTRL(port); in apbuart_set_termios()
231 spin_lock_irqsave(&port->lock, flags); in apbuart_set_termios()
234 uart_update_timeout(port, termios->c_cflag, baud); in apbuart_set_termios()
236 port->read_status_mask = UART_STATUS_OE; in apbuart_set_termios()
238 port->read_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
241 port->ignore_status_mask = 0; in apbuart_set_termios()
243 port->ignore_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
247 port->ignore_status_mask |= UART_DUMMY_RSR_RX; in apbuart_set_termios()
251 UART_PUT_SCAL(port, quot); in apbuart_set_termios()
252 UART_PUT_CTRL(port, cr); in apbuart_set_termios()
254 spin_unlock_irqrestore(&port->lock, flags); in apbuart_set_termios()
257 static const char *apbuart_type(struct uart_port *port) in apbuart_type() argument
259 return port->type == PORT_APBUART ? "GRLIB/APBUART" : NULL; in apbuart_type()
262 static void apbuart_release_port(struct uart_port *port) in apbuart_release_port() argument
264 release_mem_region(port->mapbase, 0x100); in apbuart_release_port()
267 static int apbuart_request_port(struct uart_port *port) in apbuart_request_port() argument
269 return request_mem_region(port->mapbase, 0x100, "grlib-apbuart") in apbuart_request_port()
275 static void apbuart_config_port(struct uart_port *port, int flags) in apbuart_config_port() argument
278 port->type = PORT_APBUART; in apbuart_config_port()
279 apbuart_request_port(port); in apbuart_config_port()
284 static int apbuart_verify_port(struct uart_port *port, in apbuart_verify_port() argument
318 static int apbuart_scan_fifo_size(struct uart_port *port, int portnumber) in apbuart_scan_fifo_size() argument
325 ctrl = UART_GET_CTRL(port); in apbuart_scan_fifo_size()
336 UART_PUT_CTRL(port, ctrl | UART_CTRL_TE); in apbuart_scan_fifo_size()
338 while (!UART_TX_READY(UART_GET_STATUS(port))) in apbuart_scan_fifo_size()
346 UART_PUT_CTRL(port, ctrl & ~(UART_CTRL_TE)); in apbuart_scan_fifo_size()
349 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
357 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
360 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
361 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
366 UART_PUT_CTRL(port, ctrl); in apbuart_scan_fifo_size()
375 static void apbuart_flush_fifo(struct uart_port *port) in apbuart_flush_fifo() argument
379 for (i = 0; i < port->fifosize; i++) in apbuart_flush_fifo()
380 UART_GET_CHAR(port); in apbuart_flush_fifo()
390 static void apbuart_console_putchar(struct uart_port *port, unsigned char ch) in apbuart_console_putchar() argument
394 status = UART_GET_STATUS(port); in apbuart_console_putchar()
396 UART_PUT_CHAR(port, ch); in apbuart_console_putchar()
402 struct uart_port *port = &grlib_apbuart_ports[co->index]; in apbuart_console_write() local
406 old_cr = UART_GET_CTRL(port); in apbuart_console_write()
408 UART_PUT_CTRL(port, new_cr); in apbuart_console_write()
410 uart_console_write(port, s, count, apbuart_console_putchar); in apbuart_console_write()
417 status = UART_GET_STATUS(port); in apbuart_console_write()
419 UART_PUT_CTRL(port, old_cr); in apbuart_console_write()
423 apbuart_console_get_options(struct uart_port *port, int *baud, in apbuart_console_get_options() argument
426 if (UART_GET_CTRL(port) & (UART_CTRL_RE | UART_CTRL_TE)) { in apbuart_console_get_options()
429 status = UART_GET_STATUS(port); in apbuart_console_get_options()
440 quot = UART_GET_SCAL(port) / 8; in apbuart_console_get_options()
441 *baud = port->uartclk / (16 * (quot + 1)); in apbuart_console_get_options()
447 struct uart_port *port; in apbuart_console_setup() local
464 port = &grlib_apbuart_ports[co->index]; in apbuart_console_setup()
466 spin_lock_init(&port->lock); in apbuart_console_setup()
471 apbuart_console_get_options(port, &baud, &parity, &bits); in apbuart_console_setup()
473 return uart_set_options(port, co, baud, parity, bits, flow); in apbuart_console_setup()
524 struct uart_port *port = NULL; in apbuart_probe() local
531 port = &grlib_apbuart_ports[i]; in apbuart_probe()
532 port->dev = &op->dev; in apbuart_probe()
533 port->irq = op->archdata.irqs[0]; in apbuart_probe()
535 uart_add_one_port(&grlib_apbuart_driver, (struct uart_port *) port); in apbuart_probe()
537 apbuart_flush_fifo((struct uart_port *) port); in apbuart_probe()
540 (unsigned long long) port->mapbase, port->irq); in apbuart_probe()
573 struct uart_port *port; in grlib_apbuart_configure() local
590 port = &grlib_apbuart_ports[line]; in grlib_apbuart_configure()
592 port->mapbase = addr; in grlib_apbuart_configure()
593 port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); in grlib_apbuart_configure()
594 port->irq = 0; in grlib_apbuart_configure()
595 port->iotype = UPIO_MEM; in grlib_apbuart_configure()
596 port->ops = &grlib_apbuart_ops; in grlib_apbuart_configure()
597 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE); in grlib_apbuart_configure()
598 port->flags = UPF_BOOT_AUTOCONF; in grlib_apbuart_configure()
599 port->line = line; in grlib_apbuart_configure()
600 port->uartclk = *freq_hz; in grlib_apbuart_configure()
601 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); in grlib_apbuart_configure()