Lines Matching refs:port
39 static void apbuart_tx_chars(struct uart_port *port);
41 static void apbuart_stop_tx(struct uart_port *port)
45 cr = UART_GET_CTRL(port);
47 UART_PUT_CTRL(port, cr);
50 static void apbuart_start_tx(struct uart_port *port)
54 cr = UART_GET_CTRL(port);
56 UART_PUT_CTRL(port, cr);
58 if (UART_GET_STATUS(port) & UART_STATUS_THE)
59 apbuart_tx_chars(port);
62 static void apbuart_stop_rx(struct uart_port *port)
66 cr = UART_GET_CTRL(port);
68 UART_PUT_CTRL(port, cr);
71 static void apbuart_rx_chars(struct uart_port *port)
74 unsigned int max_chars = port->fifosize;
76 status = UART_GET_STATUS(port);
80 ch = UART_GET_CHAR(port);
83 port->icount.rx++;
85 rsr = UART_GET_STATUS(port) | UART_DUMMY_RSR_RX;
86 UART_PUT_STATUS(port, 0);
91 port->icount.brk++;
92 if (uart_handle_break(port))
95 port->icount.parity++;
97 port->icount.frame++;
100 port->icount.overrun++;
102 rsr &= port->read_status_mask;
110 if (uart_handle_sysrq_char(port, ch))
113 uart_insert_char(port, rsr, UART_STATUS_OE, ch, flag);
117 status = UART_GET_STATUS(port);
120 spin_unlock(&port->lock);
121 tty_flip_buffer_push(&port->state->port);
122 spin_lock(&port->lock);
125 static void apbuart_tx_chars(struct uart_port *port)
127 struct circ_buf *xmit = &port->state->xmit;
130 if (port->x_char) {
131 UART_PUT_CHAR(port, port->x_char);
132 port->icount.tx++;
133 port->x_char = 0;
137 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
138 apbuart_stop_tx(port);
143 count = port->fifosize >> 1;
145 UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
147 port->icount.tx++;
153 uart_write_wakeup(port);
156 apbuart_stop_tx(port);
161 struct uart_port *port = dev_id;
164 spin_lock(&port->lock);
166 status = UART_GET_STATUS(port);
168 apbuart_rx_chars(port);
170 apbuart_tx_chars(port);
172 spin_unlock(&port->lock);
177 static unsigned int apbuart_tx_empty(struct uart_port *port)
179 unsigned int status = UART_GET_STATUS(port);
183 static unsigned int apbuart_get_mctrl(struct uart_port *port)
189 static void apbuart_set_mctrl(struct uart_port *port, unsigned int mctrl)
194 static void apbuart_break_ctl(struct uart_port *port, int break_state)
199 static int apbuart_startup(struct uart_port *port)
205 retval = request_irq(port->irq, apbuart_int, 0, "apbuart", port);
210 cr = UART_GET_CTRL(port);
211 UART_PUT_CTRL(port,
218 static void apbuart_shutdown(struct uart_port *port)
222 /* disable all interrupts, disable the port */
223 cr = UART_GET_CTRL(port);
224 UART_PUT_CTRL(port,
229 free_irq(port->irq, port);
232 static void apbuart_set_termios(struct uart_port *port,
240 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16);
242 panic("invalid baudrate %i\n", port->uartclk / 16);
245 quot = (uart_get_divisor(port, baud)) * 2;
246 cr = UART_GET_CTRL(port);
259 spin_lock_irqsave(&port->lock, flags);
261 /* Update the per-port timeout. */
262 uart_update_timeout(port, termios->c_cflag, baud);
264 port->read_status_mask = UART_STATUS_OE;
266 port->read_status_mask |= UART_STATUS_FE | UART_STATUS_PE;
269 port->ignore_status_mask = 0;
271 port->ignore_status_mask |= UART_STATUS_FE | UART_STATUS_PE;
275 port->ignore_status_mask |= UART_DUMMY_RSR_RX;
279 UART_PUT_SCAL(port, quot);
280 UART_PUT_CTRL(port, cr);
282 spin_unlock_irqrestore(&port->lock, flags);
285 static const char *apbuart_type(struct uart_port *port)
287 return port->type == PORT_APBUART ? "GRLIB/APBUART" : NULL;
290 static void apbuart_release_port(struct uart_port *port)
292 release_mem_region(port->mapbase, 0x100);
295 static int apbuart_request_port(struct uart_port *port)
297 return request_mem_region(port->mapbase, 0x100, "grlib-apbuart")
302 /* Configure/autoconfigure the port */
303 static void apbuart_config_port(struct uart_port *port, int flags)
306 port->type = PORT_APBUART;
307 apbuart_request_port(port);
312 static int apbuart_verify_port(struct uart_port *port,
346 static int apbuart_scan_fifo_size(struct uart_port *port, int portnumber)
353 ctrl = UART_GET_CTRL(port);
364 UART_PUT_CTRL(port, ctrl | UART_CTRL_TE);
366 while (!UART_TX_READY(UART_GET_STATUS(port)))
374 UART_PUT_CTRL(port, ctrl & ~(UART_CTRL_TE));
377 UART_PUT_CHAR(port, 0);
385 status = UART_GET_STATUS(port);
388 UART_PUT_CHAR(port, 0);
389 status = UART_GET_STATUS(port);
394 UART_PUT_CTRL(port, ctrl);
403 static void apbuart_flush_fifo(struct uart_port *port)
407 for (i = 0; i < port->fifosize; i++)
408 UART_GET_CHAR(port);
418 static void apbuart_console_putchar(struct uart_port *port, int ch)
422 status = UART_GET_STATUS(port);
424 UART_PUT_CHAR(port, ch);
430 struct uart_port *port = &grlib_apbuart_ports[co->index];
434 old_cr = UART_GET_CTRL(port);
436 UART_PUT_CTRL(port, new_cr);
438 uart_console_write(port, s, count, apbuart_console_putchar);
445 status = UART_GET_STATUS(port);
447 UART_PUT_CTRL(port, old_cr);
451 apbuart_console_get_options(struct uart_port *port, int *baud,
454 if (UART_GET_CTRL(port) & (UART_CTRL_RE | UART_CTRL_TE)) {
457 status = UART_GET_STATUS(port);
468 quot = UART_GET_SCAL(port) / 8;
469 *baud = port->uartclk / (16 * (quot + 1));
475 struct uart_port *port;
486 * if so, search for the first available port that does have
492 port = &grlib_apbuart_ports[co->index];
494 spin_lock_init(&port->lock);
499 apbuart_console_get_options(port, &baud, &parity, &bits);
501 return uart_set_options(port, co, baud, parity, bits, flow);
552 struct uart_port *port = NULL;
559 port = &grlib_apbuart_ports[i];
560 port->dev = &op->dev;
561 port->irq = op->archdata.irqs[0];
563 uart_add_one_port(&grlib_apbuart_driver, (struct uart_port *) port);
565 apbuart_flush_fifo((struct uart_port *) port);
568 (unsigned long long) port->mapbase, port->irq);
601 struct uart_port *port;
618 port = &grlib_apbuart_ports[line];
620 port->mapbase = addr;
621 port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map));
622 port->irq = 0;
623 port->iotype = UPIO_MEM;
624 port->ops = &grlib_apbuart_ops;
625 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE);
626 port->flags = UPF_BOOT_AUTOCONF;
627 port->line = line;
628 port->uartclk = *freq_hz;
629 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line);