Lines Matching refs:port

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