Lines Matching refs:port

78 	struct uart_port port;  member
84 static u32 altera_uart_readl(struct uart_port *port, int reg) in altera_uart_readl() argument
86 return readl(port->membase + (reg << port->regshift)); in altera_uart_readl()
89 static void altera_uart_writel(struct uart_port *port, u32 dat, int reg) in altera_uart_writel() argument
91 writel(dat, port->membase + (reg << port->regshift)); in altera_uart_writel()
94 static unsigned int altera_uart_tx_empty(struct uart_port *port) in altera_uart_tx_empty() argument
96 return (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_tx_empty()
100 static unsigned int altera_uart_get_mctrl(struct uart_port *port) in altera_uart_get_mctrl() argument
102 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_get_mctrl()
105 sigs = (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_get_mctrl()
120 if (!pp->port.irq) in altera_uart_update_ctrl_reg()
123 altera_uart_writel(&pp->port, imr, ALTERA_UART_CONTROL_REG); in altera_uart_update_ctrl_reg()
126 static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs) in altera_uart_set_mctrl() argument
128 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_set_mctrl()
138 static void altera_uart_start_tx(struct uart_port *port) in altera_uart_start_tx() argument
140 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_start_tx()
146 static void altera_uart_stop_tx(struct uart_port *port) in altera_uart_stop_tx() argument
148 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_stop_tx()
154 static void altera_uart_stop_rx(struct uart_port *port) in altera_uart_stop_rx() argument
156 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_stop_rx()
162 static void altera_uart_break_ctl(struct uart_port *port, int break_state) in altera_uart_break_ctl() argument
164 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_break_ctl()
167 spin_lock_irqsave(&port->lock, flags); in altera_uart_break_ctl()
173 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_break_ctl()
176 static void altera_uart_set_termios(struct uart_port *port, in altera_uart_set_termios() argument
183 baud = uart_get_baud_rate(port, termios, old, 0, 4000000); in altera_uart_set_termios()
184 baudclk = port->uartclk / baud; in altera_uart_set_termios()
190 spin_lock_irqsave(&port->lock, flags); in altera_uart_set_termios()
191 uart_update_timeout(port, termios->c_cflag, baud); in altera_uart_set_termios()
192 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); in altera_uart_set_termios()
193 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_set_termios()
202 static void altera_uart_rx_chars(struct uart_port *port) in altera_uart_rx_chars() argument
207 while ((status = altera_uart_readl(port, ALTERA_UART_STATUS_REG)) & in altera_uart_rx_chars()
209 ch = altera_uart_readl(port, ALTERA_UART_RXDATA_REG); in altera_uart_rx_chars()
211 port->icount.rx++; in altera_uart_rx_chars()
214 altera_uart_writel(port, status, in altera_uart_rx_chars()
218 port->icount.brk++; in altera_uart_rx_chars()
219 if (uart_handle_break(port)) in altera_uart_rx_chars()
222 port->icount.parity++; in altera_uart_rx_chars()
224 port->icount.overrun++; in altera_uart_rx_chars()
226 port->icount.frame++; in altera_uart_rx_chars()
229 status &= port->read_status_mask; in altera_uart_rx_chars()
239 if (uart_handle_sysrq_char(port, ch)) in altera_uart_rx_chars()
241 uart_insert_char(port, status, ALTERA_UART_STATUS_ROE_MSK, ch, in altera_uart_rx_chars()
245 tty_flip_buffer_push(&port->state->port); in altera_uart_rx_chars()
248 static void altera_uart_tx_chars(struct uart_port *port) in altera_uart_tx_chars() argument
250 struct circ_buf *xmit = &port->state->xmit; in altera_uart_tx_chars()
252 if (port->x_char) { in altera_uart_tx_chars()
254 altera_uart_writel(port, port->x_char, ALTERA_UART_TXDATA_REG); in altera_uart_tx_chars()
255 port->x_char = 0; in altera_uart_tx_chars()
256 port->icount.tx++; in altera_uart_tx_chars()
260 while (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_tx_chars()
264 altera_uart_writel(port, xmit->buf[xmit->tail], in altera_uart_tx_chars()
267 port->icount.tx++; in altera_uart_tx_chars()
271 uart_write_wakeup(port); in altera_uart_tx_chars()
274 altera_uart_stop_tx(port); in altera_uart_tx_chars()
279 struct uart_port *port = data; in altera_uart_interrupt() local
280 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_interrupt()
284 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; in altera_uart_interrupt()
286 spin_lock_irqsave(&port->lock, flags); in altera_uart_interrupt()
288 altera_uart_rx_chars(port); in altera_uart_interrupt()
290 altera_uart_tx_chars(port); in altera_uart_interrupt()
291 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_interrupt()
299 struct uart_port *port = &pp->port; in altera_uart_timer() local
301 altera_uart_interrupt(0, port); in altera_uart_timer()
302 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_timer()
305 static void altera_uart_config_port(struct uart_port *port, int flags) in altera_uart_config_port() argument
307 port->type = PORT_ALTERA_UART; in altera_uart_config_port()
310 altera_uart_writel(port, 0, ALTERA_UART_CONTROL_REG); in altera_uart_config_port()
312 altera_uart_writel(port, 0, ALTERA_UART_STATUS_REG); in altera_uart_config_port()
315 static int altera_uart_startup(struct uart_port *port) in altera_uart_startup() argument
317 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_startup()
320 if (!port->irq) { in altera_uart_startup()
322 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_startup()
326 ret = request_irq(port->irq, altera_uart_interrupt, 0, in altera_uart_startup()
327 DRV_NAME, port); in altera_uart_startup()
330 "interrupt vector=%d\n", port->line, port->irq); in altera_uart_startup()
335 spin_lock_irqsave(&port->lock, flags); in altera_uart_startup()
341 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_startup()
346 static void altera_uart_shutdown(struct uart_port *port) in altera_uart_shutdown() argument
348 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_shutdown()
351 spin_lock_irqsave(&port->lock, flags); in altera_uart_shutdown()
357 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_shutdown()
359 if (port->irq) in altera_uart_shutdown()
360 free_irq(port->irq, port); in altera_uart_shutdown()
365 static const char *altera_uart_type(struct uart_port *port) in altera_uart_type() argument
367 return (port->type == PORT_ALTERA_UART) ? "Altera UART" : NULL; in altera_uart_type()
370 static int altera_uart_request_port(struct uart_port *port) in altera_uart_request_port() argument
376 static void altera_uart_release_port(struct uart_port *port) in altera_uart_release_port() argument
381 static int altera_uart_verify_port(struct uart_port *port, in altera_uart_verify_port() argument
390 static int altera_uart_poll_get_char(struct uart_port *port) in altera_uart_poll_get_char() argument
392 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_poll_get_char()
396 return altera_uart_readl(port, ALTERA_UART_RXDATA_REG); in altera_uart_poll_get_char()
399 static void altera_uart_poll_put_char(struct uart_port *port, unsigned char c) in altera_uart_poll_put_char() argument
401 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_poll_put_char()
405 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); in altera_uart_poll_put_char()
438 static void altera_uart_console_putc(struct uart_port *port, unsigned char c) in altera_uart_console_putc() argument
440 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_console_putc()
444 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); in altera_uart_console_putc()
450 struct uart_port *port = &(altera_uart_ports + co->index)->port; in altera_uart_console_write() local
452 uart_console_write(port, s, count, altera_uart_console_putc); in altera_uart_console_write()
457 struct uart_port *port; in altera_uart_console_setup() local
465 port = &altera_uart_ports[co->index].port; in altera_uart_console_setup()
466 if (!port->membase) in altera_uart_console_setup()
472 return uart_set_options(port, co, baud, parity, bits, flow); in altera_uart_console_setup()
502 uart_console_write(&dev->port, s, count, altera_uart_console_putc); in altera_uart_earlycon_write()
508 struct uart_port *port = &dev->port; in altera_uart_earlycon_setup() local
510 if (!port->membase) in altera_uart_earlycon_setup()
514 altera_uart_writel(port, ALTERA_UART_CONTROL_RRDY_MSK, in altera_uart_earlycon_setup()
518 unsigned int baudclk = port->uartclk / dev->baud; in altera_uart_earlycon_setup()
520 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); in altera_uart_earlycon_setup()
551 struct uart_port *port; in altera_uart_probe() local
559 if (altera_uart_ports[i].port.mapbase == 0) in altera_uart_probe()
566 port = &altera_uart_ports[i].port; in altera_uart_probe()
570 port->mapbase = res_mem->start; in altera_uart_probe()
572 port->mapbase = platp->mapbase; in altera_uart_probe()
580 port->irq = ret; in altera_uart_probe()
582 port->irq = platp->irq; in altera_uart_probe()
586 port->uartclk = platp->uartclk; in altera_uart_probe()
589 &port->uartclk); in altera_uart_probe()
594 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in altera_uart_probe()
595 if (!port->membase) in altera_uart_probe()
599 port->regshift = platp->bus_shift; in altera_uart_probe()
601 port->regshift = 0; in altera_uart_probe()
603 port->line = i; in altera_uart_probe()
604 port->type = PORT_ALTERA_UART; in altera_uart_probe()
605 port->iotype = SERIAL_IO_MEM; in altera_uart_probe()
606 port->ops = &altera_uart_ops; in altera_uart_probe()
607 port->flags = UPF_BOOT_AUTOCONF; in altera_uart_probe()
608 port->dev = &pdev->dev; in altera_uart_probe()
610 platform_set_drvdata(pdev, port); in altera_uart_probe()
612 uart_add_one_port(&altera_uart_driver, port); in altera_uart_probe()
619 struct uart_port *port = platform_get_drvdata(pdev); in altera_uart_remove() local
621 if (port) { in altera_uart_remove()
622 uart_remove_one_port(&altera_uart_driver, port); in altera_uart_remove()
623 port->mapbase = 0; in altera_uart_remove()
624 iounmap(port->membase); in altera_uart_remove()