Lines Matching refs:port

43 static void apbuart_tx_chars(struct uart_port *port);
45 static void apbuart_stop_tx(struct uart_port *port) in apbuart_stop_tx() argument
49 cr = UART_GET_CTRL(port); in apbuart_stop_tx()
51 UART_PUT_CTRL(port, cr); in apbuart_stop_tx()
54 static void apbuart_start_tx(struct uart_port *port) in apbuart_start_tx() argument
58 cr = UART_GET_CTRL(port); in apbuart_start_tx()
60 UART_PUT_CTRL(port, cr); in apbuart_start_tx()
62 if (UART_GET_STATUS(port) & UART_STATUS_THE) in apbuart_start_tx()
63 apbuart_tx_chars(port); in apbuart_start_tx()
66 static void apbuart_stop_rx(struct uart_port *port) in apbuart_stop_rx() argument
70 cr = UART_GET_CTRL(port); in apbuart_stop_rx()
72 UART_PUT_CTRL(port, cr); in apbuart_stop_rx()
75 static void apbuart_rx_chars(struct uart_port *port) in apbuart_rx_chars() argument
78 unsigned int max_chars = port->fifosize; in apbuart_rx_chars()
80 status = UART_GET_STATUS(port); in apbuart_rx_chars()
84 ch = UART_GET_CHAR(port); in apbuart_rx_chars()
87 port->icount.rx++; in apbuart_rx_chars()
89 rsr = UART_GET_STATUS(port) | UART_DUMMY_RSR_RX; in apbuart_rx_chars()
90 UART_PUT_STATUS(port, 0); in apbuart_rx_chars()
95 port->icount.brk++; in apbuart_rx_chars()
96 if (uart_handle_break(port)) in apbuart_rx_chars()
99 port->icount.parity++; in apbuart_rx_chars()
101 port->icount.frame++; in apbuart_rx_chars()
104 port->icount.overrun++; in apbuart_rx_chars()
106 rsr &= port->read_status_mask; in apbuart_rx_chars()
114 if (uart_handle_sysrq_char(port, ch)) in apbuart_rx_chars()
117 uart_insert_char(port, rsr, UART_STATUS_OE, ch, flag); in apbuart_rx_chars()
121 status = UART_GET_STATUS(port); in apbuart_rx_chars()
124 spin_unlock(&port->lock); in apbuart_rx_chars()
125 tty_flip_buffer_push(&port->state->port); in apbuart_rx_chars()
126 spin_lock(&port->lock); in apbuart_rx_chars()
129 static void apbuart_tx_chars(struct uart_port *port) in apbuart_tx_chars() argument
131 struct circ_buf *xmit = &port->state->xmit; in apbuart_tx_chars()
134 if (port->x_char) { in apbuart_tx_chars()
135 UART_PUT_CHAR(port, port->x_char); in apbuart_tx_chars()
136 port->icount.tx++; in apbuart_tx_chars()
137 port->x_char = 0; in apbuart_tx_chars()
141 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { in apbuart_tx_chars()
142 apbuart_stop_tx(port); in apbuart_tx_chars()
147 count = port->fifosize >> 1; in apbuart_tx_chars()
149 UART_PUT_CHAR(port, xmit->buf[xmit->tail]); in apbuart_tx_chars()
151 port->icount.tx++; in apbuart_tx_chars()
157 uart_write_wakeup(port); in apbuart_tx_chars()
160 apbuart_stop_tx(port); in apbuart_tx_chars()
165 struct uart_port *port = dev_id; in apbuart_int() local
168 spin_lock(&port->lock); in apbuart_int()
170 status = UART_GET_STATUS(port); in apbuart_int()
172 apbuart_rx_chars(port); in apbuart_int()
174 apbuart_tx_chars(port); in apbuart_int()
176 spin_unlock(&port->lock); in apbuart_int()
181 static unsigned int apbuart_tx_empty(struct uart_port *port) in apbuart_tx_empty() argument
183 unsigned int status = UART_GET_STATUS(port); in apbuart_tx_empty()
187 static unsigned int apbuart_get_mctrl(struct uart_port *port) in apbuart_get_mctrl() argument
193 static void apbuart_set_mctrl(struct uart_port *port, unsigned int mctrl) in apbuart_set_mctrl() argument
198 static void apbuart_break_ctl(struct uart_port *port, int break_state) in apbuart_break_ctl() argument
203 static int apbuart_startup(struct uart_port *port) in apbuart_startup() argument
209 retval = request_irq(port->irq, apbuart_int, 0, "apbuart", port); in apbuart_startup()
214 cr = UART_GET_CTRL(port); in apbuart_startup()
215 UART_PUT_CTRL(port, in apbuart_startup()
222 static void apbuart_shutdown(struct uart_port *port) in apbuart_shutdown() argument
227 cr = UART_GET_CTRL(port); in apbuart_shutdown()
228 UART_PUT_CTRL(port, in apbuart_shutdown()
233 free_irq(port->irq, port); in apbuart_shutdown()
236 static void apbuart_set_termios(struct uart_port *port, in apbuart_set_termios() argument
244 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in apbuart_set_termios()
246 panic("invalid baudrate %i\n", port->uartclk / 16); in apbuart_set_termios()
249 quot = (uart_get_divisor(port, baud)) * 2; in apbuart_set_termios()
250 cr = UART_GET_CTRL(port); in apbuart_set_termios()
263 spin_lock_irqsave(&port->lock, flags); in apbuart_set_termios()
266 uart_update_timeout(port, termios->c_cflag, baud); in apbuart_set_termios()
268 port->read_status_mask = UART_STATUS_OE; in apbuart_set_termios()
270 port->read_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
273 port->ignore_status_mask = 0; in apbuart_set_termios()
275 port->ignore_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
279 port->ignore_status_mask |= UART_DUMMY_RSR_RX; in apbuart_set_termios()
283 UART_PUT_SCAL(port, quot); in apbuart_set_termios()
284 UART_PUT_CTRL(port, cr); in apbuart_set_termios()
286 spin_unlock_irqrestore(&port->lock, flags); in apbuart_set_termios()
289 static const char *apbuart_type(struct uart_port *port) in apbuart_type() argument
291 return port->type == PORT_APBUART ? "GRLIB/APBUART" : NULL; in apbuart_type()
294 static void apbuart_release_port(struct uart_port *port) in apbuart_release_port() argument
296 release_mem_region(port->mapbase, 0x100); in apbuart_release_port()
299 static int apbuart_request_port(struct uart_port *port) in apbuart_request_port() argument
301 return request_mem_region(port->mapbase, 0x100, "grlib-apbuart") in apbuart_request_port()
307 static void apbuart_config_port(struct uart_port *port, int flags) in apbuart_config_port() argument
310 port->type = PORT_APBUART; in apbuart_config_port()
311 apbuart_request_port(port); in apbuart_config_port()
316 static int apbuart_verify_port(struct uart_port *port, in apbuart_verify_port() argument
350 static int apbuart_scan_fifo_size(struct uart_port *port, int portnumber) in apbuart_scan_fifo_size() argument
357 ctrl = UART_GET_CTRL(port); in apbuart_scan_fifo_size()
368 UART_PUT_CTRL(port, ctrl | UART_CTRL_TE); in apbuart_scan_fifo_size()
370 while (!UART_TX_READY(UART_GET_STATUS(port))) in apbuart_scan_fifo_size()
378 UART_PUT_CTRL(port, ctrl & ~(UART_CTRL_TE)); in apbuart_scan_fifo_size()
381 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
389 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
392 UART_PUT_CHAR(port, 0); in apbuart_scan_fifo_size()
393 status = UART_GET_STATUS(port); in apbuart_scan_fifo_size()
398 UART_PUT_CTRL(port, ctrl); in apbuart_scan_fifo_size()
407 static void apbuart_flush_fifo(struct uart_port *port) in apbuart_flush_fifo() argument
411 for (i = 0; i < port->fifosize; i++) in apbuart_flush_fifo()
412 UART_GET_CHAR(port); in apbuart_flush_fifo()
422 static void apbuart_console_putchar(struct uart_port *port, int ch) in apbuart_console_putchar() argument
426 status = UART_GET_STATUS(port); in apbuart_console_putchar()
428 UART_PUT_CHAR(port, ch); in apbuart_console_putchar()
434 struct uart_port *port = &grlib_apbuart_ports[co->index]; in apbuart_console_write() local
438 old_cr = UART_GET_CTRL(port); in apbuart_console_write()
440 UART_PUT_CTRL(port, new_cr); in apbuart_console_write()
442 uart_console_write(port, s, count, apbuart_console_putchar); in apbuart_console_write()
449 status = UART_GET_STATUS(port); in apbuart_console_write()
451 UART_PUT_CTRL(port, old_cr); in apbuart_console_write()
455 apbuart_console_get_options(struct uart_port *port, int *baud, in apbuart_console_get_options() argument
458 if (UART_GET_CTRL(port) & (UART_CTRL_RE | UART_CTRL_TE)) { in apbuart_console_get_options()
461 status = UART_GET_STATUS(port); in apbuart_console_get_options()
472 quot = UART_GET_SCAL(port) / 8; in apbuart_console_get_options()
473 *baud = port->uartclk / (16 * (quot + 1)); in apbuart_console_get_options()
479 struct uart_port *port; in apbuart_console_setup() local
496 port = &grlib_apbuart_ports[co->index]; in apbuart_console_setup()
498 spin_lock_init(&port->lock); in apbuart_console_setup()
503 apbuart_console_get_options(port, &baud, &parity, &bits); in apbuart_console_setup()
505 return uart_set_options(port, co, baud, parity, bits, flow); in apbuart_console_setup()
556 struct uart_port *port = NULL; in apbuart_probe() local
563 port = &grlib_apbuart_ports[i]; in apbuart_probe()
564 port->dev = &op->dev; in apbuart_probe()
565 port->irq = op->archdata.irqs[0]; in apbuart_probe()
567 uart_add_one_port(&grlib_apbuart_driver, (struct uart_port *) port); in apbuart_probe()
569 apbuart_flush_fifo((struct uart_port *) port); in apbuart_probe()
572 (unsigned long long) port->mapbase, port->irq); in apbuart_probe()
605 struct uart_port *port; in grlib_apbuart_configure() local
622 port = &grlib_apbuart_ports[line]; in grlib_apbuart_configure()
624 port->mapbase = addr; in grlib_apbuart_configure()
625 port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); in grlib_apbuart_configure()
626 port->irq = 0; in grlib_apbuart_configure()
627 port->iotype = UPIO_MEM; in grlib_apbuart_configure()
628 port->ops = &grlib_apbuart_ops; in grlib_apbuart_configure()
629 port->flags = UPF_BOOT_AUTOCONF; in grlib_apbuart_configure()
630 port->line = line; in grlib_apbuart_configure()
631 port->uartclk = *freq_hz; in grlib_apbuart_configure()
632 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); in grlib_apbuart_configure()