Lines Matching full: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()
196 * FIXME: port->read_status_mask and port->ignore_status_mask 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()
283 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; in altera_uart_interrupt()
285 spin_lock(&port->lock); in altera_uart_interrupt()
287 altera_uart_rx_chars(port); in altera_uart_interrupt()
289 altera_uart_tx_chars(port); in altera_uart_interrupt()
290 spin_unlock(&port->lock); in altera_uart_interrupt()
298 struct uart_port *port = &pp->port; in altera_uart_timer() local
300 altera_uart_interrupt(0, port); in altera_uart_timer()
301 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_timer()
304 static void altera_uart_config_port(struct uart_port *port, int flags) in altera_uart_config_port() argument
306 port->type = PORT_ALTERA_UART; in altera_uart_config_port()
309 altera_uart_writel(port, 0, ALTERA_UART_CONTROL_REG); in altera_uart_config_port()
311 altera_uart_writel(port, 0, ALTERA_UART_STATUS_REG); in altera_uart_config_port()
314 static int altera_uart_startup(struct uart_port *port) in altera_uart_startup() argument
316 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_startup()
319 if (!port->irq) { in altera_uart_startup()
321 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_startup()
325 ret = request_irq(port->irq, altera_uart_interrupt, 0, in altera_uart_startup()
326 DRV_NAME, port); in altera_uart_startup()
329 "interrupt vector=%d\n", port->line, port->irq); in altera_uart_startup()
334 spin_lock_irqsave(&port->lock, flags); in altera_uart_startup()
340 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_startup()
345 static void altera_uart_shutdown(struct uart_port *port) in altera_uart_shutdown() argument
347 struct altera_uart *pp = container_of(port, struct altera_uart, port); in altera_uart_shutdown()
350 spin_lock_irqsave(&port->lock, flags); in altera_uart_shutdown()
356 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_shutdown()
358 if (port->irq) in altera_uart_shutdown()
359 free_irq(port->irq, port); in altera_uart_shutdown()
364 static const char *altera_uart_type(struct uart_port *port) in altera_uart_type() argument
366 return (port->type == PORT_ALTERA_UART) ? "Altera UART" : NULL; in altera_uart_type()
369 static int altera_uart_request_port(struct uart_port *port) in altera_uart_request_port() argument
375 static void altera_uart_release_port(struct uart_port *port) in altera_uart_release_port() argument
380 static int altera_uart_verify_port(struct uart_port *port, in altera_uart_verify_port() argument
389 static int altera_uart_poll_get_char(struct uart_port *port) in altera_uart_poll_get_char() argument
391 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_poll_get_char()
395 return altera_uart_readl(port, ALTERA_UART_RXDATA_REG); in altera_uart_poll_get_char()
398 static void altera_uart_poll_put_char(struct uart_port *port, unsigned char c) in altera_uart_poll_put_char() argument
400 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_poll_put_char()
404 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); in altera_uart_poll_put_char()
437 static void altera_uart_console_putc(struct uart_port *port, unsigned char c) in altera_uart_console_putc() argument
439 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & in altera_uart_console_putc()
443 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); in altera_uart_console_putc()
449 struct uart_port *port = &(altera_uart_ports + co->index)->port; in altera_uart_console_write() local
451 uart_console_write(port, s, count, altera_uart_console_putc); in altera_uart_console_write()
456 struct uart_port *port; in altera_uart_console_setup() local
464 port = &altera_uart_ports[co->index].port; in altera_uart_console_setup()
465 if (!port->membase) in altera_uart_console_setup()
471 return uart_set_options(port, co, baud, parity, bits, flow); in altera_uart_console_setup()
501 uart_console_write(&dev->port, s, count, altera_uart_console_putc); in altera_uart_earlycon_write()
507 struct uart_port *port = &dev->port; in altera_uart_earlycon_setup() local
509 if (!port->membase) in altera_uart_earlycon_setup()
513 altera_uart_writel(port, ALTERA_UART_CONTROL_RRDY_MSK, in altera_uart_earlycon_setup()
517 unsigned int baudclk = port->uartclk / dev->baud; in altera_uart_earlycon_setup()
519 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); in altera_uart_earlycon_setup()
550 struct uart_port *port; in altera_uart_probe() local
558 if (altera_uart_ports[i].port.mapbase == 0) in altera_uart_probe()
565 port = &altera_uart_ports[i].port; in altera_uart_probe()
569 port->mapbase = res_mem->start; in altera_uart_probe()
571 port->mapbase = platp->mapbase; in altera_uart_probe()
579 port->irq = ret; in altera_uart_probe()
581 port->irq = platp->irq; in altera_uart_probe()
585 port->uartclk = platp->uartclk; in altera_uart_probe()
588 &port->uartclk); in altera_uart_probe()
593 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in altera_uart_probe()
594 if (!port->membase) in altera_uart_probe()
598 port->regshift = platp->bus_shift; in altera_uart_probe()
600 port->regshift = 0; in altera_uart_probe()
602 port->line = i; in altera_uart_probe()
603 port->type = PORT_ALTERA_UART; in altera_uart_probe()
604 port->iotype = SERIAL_IO_MEM; in altera_uart_probe()
605 port->ops = &altera_uart_ops; in altera_uart_probe()
606 port->flags = UPF_BOOT_AUTOCONF; in altera_uart_probe()
607 port->dev = &pdev->dev; in altera_uart_probe()
609 platform_set_drvdata(pdev, port); in altera_uart_probe()
611 uart_add_one_port(&altera_uart_driver, port); in altera_uart_probe()
618 struct uart_port *port = platform_get_drvdata(pdev); in altera_uart_remove() local
620 if (port) { in altera_uart_remove()
621 uart_remove_one_port(&altera_uart_driver, port); in altera_uart_remove()
622 port->mapbase = 0; in altera_uart_remove()
623 iounmap(port->membase); in altera_uart_remove()