Lines Matching full:port

117 	struct uart_port port;  member
121 #define to_rda_uart_port(port) container_of(port, struct rda_uart_port, port) argument
125 static inline void rda_uart_write(struct uart_port *port, u32 val, in rda_uart_write() argument
128 writel(val, port->membase + off); in rda_uart_write()
131 static inline u32 rda_uart_read(struct uart_port *port, unsigned int off) in rda_uart_read() argument
133 return readl(port->membase + off); in rda_uart_read()
136 static unsigned int rda_uart_tx_empty(struct uart_port *port) in rda_uart_tx_empty() argument
142 uart_port_lock_irqsave(port, &flags); in rda_uart_tx_empty()
144 val = rda_uart_read(port, RDA_UART_STATUS); in rda_uart_tx_empty()
147 uart_port_unlock_irqrestore(port, flags); in rda_uart_tx_empty()
152 static unsigned int rda_uart_get_mctrl(struct uart_port *port) in rda_uart_get_mctrl() argument
157 cmd_set = rda_uart_read(port, RDA_UART_CMD_SET); in rda_uart_get_mctrl()
158 status = rda_uart_read(port, RDA_UART_STATUS); in rda_uart_get_mctrl()
167 static void rda_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) in rda_uart_set_mctrl() argument
172 val = rda_uart_read(port, RDA_UART_CMD_SET); in rda_uart_set_mctrl()
173 rda_uart_write(port, (val | RDA_UART_RTS), RDA_UART_CMD_SET); in rda_uart_set_mctrl()
176 val = rda_uart_read(port, RDA_UART_CMD_CLR); in rda_uart_set_mctrl()
177 rda_uart_write(port, (val | RDA_UART_RTS), RDA_UART_CMD_CLR); in rda_uart_set_mctrl()
180 val = rda_uart_read(port, RDA_UART_CTRL); in rda_uart_set_mctrl()
187 rda_uart_write(port, val, RDA_UART_CTRL); in rda_uart_set_mctrl()
190 static void rda_uart_stop_tx(struct uart_port *port) in rda_uart_stop_tx() argument
194 val = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_stop_tx()
196 rda_uart_write(port, val, RDA_UART_IRQ_MASK); in rda_uart_stop_tx()
198 val = rda_uart_read(port, RDA_UART_CMD_SET); in rda_uart_stop_tx()
200 rda_uart_write(port, val, RDA_UART_CMD_SET); in rda_uart_stop_tx()
203 static void rda_uart_stop_rx(struct uart_port *port) in rda_uart_stop_rx() argument
207 val = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_stop_rx()
209 rda_uart_write(port, val, RDA_UART_IRQ_MASK); in rda_uart_stop_rx()
212 val = rda_uart_read(port, RDA_UART_RXTX_BUFFER); in rda_uart_stop_rx()
214 val = rda_uart_read(port, RDA_UART_CMD_SET); in rda_uart_stop_rx()
216 rda_uart_write(port, val, RDA_UART_CMD_SET); in rda_uart_stop_rx()
219 static void rda_uart_start_tx(struct uart_port *port) in rda_uart_start_tx() argument
223 if (uart_tx_stopped(port)) { in rda_uart_start_tx()
224 rda_uart_stop_tx(port); in rda_uart_start_tx()
228 val = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_start_tx()
230 rda_uart_write(port, val, RDA_UART_IRQ_MASK); in rda_uart_start_tx()
239 static void rda_uart_set_termios(struct uart_port *port, in rda_uart_set_termios() argument
243 struct rda_uart_port *rda_port = to_rda_uart_port(port); in rda_uart_set_termios()
249 uart_port_lock_irqsave(port, &flags); in rda_uart_set_termios()
251 baud = uart_get_baud_rate(port, termios, old, 9600, port->uartclk / 4); in rda_uart_set_termios()
254 ctrl = rda_uart_read(port, RDA_UART_CTRL); in rda_uart_set_termios()
255 cmd_set = rda_uart_read(port, RDA_UART_CMD_SET); in rda_uart_set_termios()
256 cmd_clr = rda_uart_read(port, RDA_UART_CMD_CLR); in rda_uart_set_termios()
261 dev_warn(port->dev, "bit size not supported, using 7 bits\n"); in rda_uart_set_termios()
311 irq_mask = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_set_termios()
312 rda_uart_write(port, 0, RDA_UART_IRQ_MASK); in rda_uart_set_termios()
314 rda_uart_write(port, triggers, RDA_UART_IRQ_TRIGGERS); in rda_uart_set_termios()
315 rda_uart_write(port, ctrl, RDA_UART_CTRL); in rda_uart_set_termios()
316 rda_uart_write(port, cmd_set, RDA_UART_CMD_SET); in rda_uart_set_termios()
317 rda_uart_write(port, cmd_clr, RDA_UART_CMD_CLR); in rda_uart_set_termios()
319 rda_uart_write(port, irq_mask, RDA_UART_IRQ_MASK); in rda_uart_set_termios()
325 /* update the per-port timeout */ in rda_uart_set_termios()
326 uart_update_timeout(port, termios->c_cflag, baud); in rda_uart_set_termios()
328 uart_port_unlock_irqrestore(port, flags); in rda_uart_set_termios()
331 static void rda_uart_send_chars(struct uart_port *port) in rda_uart_send_chars() argument
333 struct tty_port *tport = &port->state->port; in rda_uart_send_chars()
337 if (uart_tx_stopped(port)) in rda_uart_send_chars()
340 if (port->x_char) { in rda_uart_send_chars()
341 while (!(rda_uart_read(port, RDA_UART_STATUS) & in rda_uart_send_chars()
345 rda_uart_write(port, port->x_char, RDA_UART_RXTX_BUFFER); in rda_uart_send_chars()
346 port->icount.tx++; in rda_uart_send_chars()
347 port->x_char = 0; in rda_uart_send_chars()
350 while ((rda_uart_read(port, RDA_UART_STATUS) & RDA_UART_TX_FIFO_MASK) && in rda_uart_send_chars()
351 uart_fifo_get(port, &ch)) in rda_uart_send_chars()
352 rda_uart_write(port, ch, RDA_UART_RXTX_BUFFER); in rda_uart_send_chars()
355 uart_write_wakeup(port); in rda_uart_send_chars()
359 val = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_send_chars()
361 rda_uart_write(port, val, RDA_UART_IRQ_MASK); in rda_uart_send_chars()
365 static void rda_uart_receive_chars(struct uart_port *port) in rda_uart_receive_chars() argument
369 status = rda_uart_read(port, RDA_UART_STATUS); in rda_uart_receive_chars()
374 port->icount.parity++; in rda_uart_receive_chars()
379 port->icount.frame++; in rda_uart_receive_chars()
384 port->icount.overrun++; in rda_uart_receive_chars()
388 val = rda_uart_read(port, RDA_UART_RXTX_BUFFER); in rda_uart_receive_chars()
391 port->icount.rx++; in rda_uart_receive_chars()
392 if (!uart_prepare_sysrq_char(port, val)) in rda_uart_receive_chars()
393 tty_insert_flip_char(&port->state->port, val, flag); in rda_uart_receive_chars()
395 status = rda_uart_read(port, RDA_UART_STATUS); in rda_uart_receive_chars()
398 tty_flip_buffer_push(&port->state->port); in rda_uart_receive_chars()
403 struct uart_port *port = dev_id; in rda_interrupt() local
406 uart_port_lock(port); in rda_interrupt()
409 val = rda_uart_read(port, RDA_UART_IRQ_CAUSE); in rda_interrupt()
410 rda_uart_write(port, val, RDA_UART_IRQ_CAUSE); in rda_interrupt()
413 rda_uart_receive_chars(port); in rda_interrupt()
416 irq_mask = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_interrupt()
418 rda_uart_write(port, irq_mask, RDA_UART_IRQ_MASK); in rda_interrupt()
420 rda_uart_send_chars(port); in rda_interrupt()
423 uart_unlock_and_check_sysrq(port); in rda_interrupt()
428 static int rda_uart_startup(struct uart_port *port) in rda_uart_startup() argument
434 uart_port_lock_irqsave(port, &flags); in rda_uart_startup()
435 rda_uart_write(port, 0, RDA_UART_IRQ_MASK); in rda_uart_startup()
436 uart_port_unlock_irqrestore(port, flags); in rda_uart_startup()
438 ret = request_irq(port->irq, rda_interrupt, IRQF_NO_SUSPEND, in rda_uart_startup()
439 "rda-uart", port); in rda_uart_startup()
443 uart_port_lock_irqsave(port, &flags); in rda_uart_startup()
445 val = rda_uart_read(port, RDA_UART_CTRL); in rda_uart_startup()
447 rda_uart_write(port, val, RDA_UART_CTRL); in rda_uart_startup()
450 val = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_startup()
452 rda_uart_write(port, val, RDA_UART_IRQ_MASK); in rda_uart_startup()
454 uart_port_unlock_irqrestore(port, flags); in rda_uart_startup()
459 static void rda_uart_shutdown(struct uart_port *port) in rda_uart_shutdown() argument
464 uart_port_lock_irqsave(port, &flags); in rda_uart_shutdown()
466 rda_uart_stop_tx(port); in rda_uart_shutdown()
467 rda_uart_stop_rx(port); in rda_uart_shutdown()
469 val = rda_uart_read(port, RDA_UART_CTRL); in rda_uart_shutdown()
471 rda_uart_write(port, val, RDA_UART_CTRL); in rda_uart_shutdown()
473 uart_port_unlock_irqrestore(port, flags); in rda_uart_shutdown()
476 static const char *rda_uart_type(struct uart_port *port) in rda_uart_type() argument
478 return (port->type == PORT_RDA) ? "rda-uart" : NULL; in rda_uart_type()
481 static int rda_uart_request_port(struct uart_port *port) in rda_uart_request_port() argument
483 struct platform_device *pdev = to_platform_device(port->dev); in rda_uart_request_port()
490 if (!devm_request_mem_region(port->dev, port->mapbase, in rda_uart_request_port()
491 resource_size(res), dev_name(port->dev))) in rda_uart_request_port()
494 if (port->flags & UPF_IOREMAP) { in rda_uart_request_port()
495 port->membase = devm_ioremap(port->dev, port->mapbase, in rda_uart_request_port()
497 if (!port->membase) in rda_uart_request_port()
504 static void rda_uart_config_port(struct uart_port *port, int flags) in rda_uart_config_port() argument
509 port->type = PORT_RDA; in rda_uart_config_port()
510 rda_uart_request_port(port); in rda_uart_config_port()
513 uart_port_lock_irqsave(port, &irq_flags); in rda_uart_config_port()
516 rda_uart_write(port, 0, RDA_UART_IRQ_MASK); in rda_uart_config_port()
519 rda_uart_write(port, 0, RDA_UART_STATUS); in rda_uart_config_port()
521 uart_port_unlock_irqrestore(port, irq_flags); in rda_uart_config_port()
524 static void rda_uart_release_port(struct uart_port *port) in rda_uart_release_port() argument
526 struct platform_device *pdev = to_platform_device(port->dev); in rda_uart_release_port()
533 if (port->flags & UPF_IOREMAP) { in rda_uart_release_port()
534 devm_release_mem_region(port->dev, port->mapbase, in rda_uart_release_port()
536 devm_iounmap(port->dev, port->membase); in rda_uart_release_port()
537 port->membase = NULL; in rda_uart_release_port()
541 static int rda_uart_verify_port(struct uart_port *port, in rda_uart_verify_port() argument
544 if (port->type != PORT_RDA) in rda_uart_verify_port()
547 if (port->irq != ser->irq) in rda_uart_verify_port()
572 static void rda_console_putchar(struct uart_port *port, unsigned char ch) in rda_console_putchar() argument
574 if (!port->membase) in rda_console_putchar()
577 while (!(rda_uart_read(port, RDA_UART_STATUS) & RDA_UART_TX_FIFO_MASK)) in rda_console_putchar()
580 rda_uart_write(port, ch, RDA_UART_RXTX_BUFFER); in rda_console_putchar()
583 static void rda_uart_port_write(struct uart_port *port, const char *s, in rda_uart_port_write() argument
591 locked = uart_port_trylock_irqsave(port, &flags); in rda_uart_port_write()
593 uart_port_lock_irqsave(port, &flags); in rda_uart_port_write()
595 old_irq_mask = rda_uart_read(port, RDA_UART_IRQ_MASK); in rda_uart_port_write()
596 rda_uart_write(port, 0, RDA_UART_IRQ_MASK); in rda_uart_port_write()
598 uart_console_write(port, s, count, rda_console_putchar); in rda_uart_port_write()
601 while (!(rda_uart_read(port, RDA_UART_STATUS) & RDA_UART_TX_FIFO_MASK)) in rda_uart_port_write()
604 rda_uart_write(port, old_irq_mask, RDA_UART_IRQ_MASK); in rda_uart_port_write()
607 uart_port_unlock_irqrestore(port, flags); in rda_uart_port_write()
619 rda_uart_port_write(&rda_port->port, s, count); in rda_uart_console_write()
634 if (!rda_port || !rda_port->port.membase) in rda_uart_console_setup()
640 return uart_set_options(&rda_port->port, co, baud, parity, bits, flow); in rda_uart_console_setup()
667 rda_uart_port_write(&dev->port, s, count); in rda_uart_early_console_write()
673 if (!device->port.membase) in rda_uart_early_console_setup()
728 dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); in rda_uart_probe()
742 rda_port->port.dev = &pdev->dev; in rda_uart_probe()
743 rda_port->port.regshift = 0; in rda_uart_probe()
744 rda_port->port.line = pdev->id; in rda_uart_probe()
745 rda_port->port.type = PORT_RDA; in rda_uart_probe()
746 rda_port->port.iotype = UPIO_MEM; in rda_uart_probe()
747 rda_port->port.mapbase = res_mem->start; in rda_uart_probe()
748 rda_port->port.irq = irq; in rda_uart_probe()
749 rda_port->port.uartclk = clk_get_rate(rda_port->clk); in rda_uart_probe()
750 if (rda_port->port.uartclk == 0) { in rda_uart_probe()
754 rda_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | in rda_uart_probe()
756 rda_port->port.x_char = 0; in rda_uart_probe()
757 rda_port->port.fifosize = RDA_UART_TX_FIFO_SIZE; in rda_uart_probe()
758 rda_port->port.ops = &rda_uart_ops; in rda_uart_probe()
763 ret = uart_add_one_port(&rda_uart_driver, &rda_port->port); in rda_uart_probe()
774 uart_remove_one_port(&rda_uart_driver, &rda_port->port); in rda_uart_remove()