• Home
  • Raw
  • Download

Lines Matching full:port

72 	struct uart_port port;  member
80 static inline void owl_uart_write(struct uart_port *port, u32 val, unsigned int off) in owl_uart_write() argument
82 writel(val, port->membase + off); in owl_uart_write()
85 static inline u32 owl_uart_read(struct uart_port *port, unsigned int off) in owl_uart_read() argument
87 return readl(port->membase + off); in owl_uart_read()
90 static void owl_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) in owl_uart_set_mctrl() argument
94 ctl = owl_uart_read(port, OWL_UART_CTL); in owl_uart_set_mctrl()
101 owl_uart_write(port, ctl, OWL_UART_CTL); in owl_uart_set_mctrl()
104 static unsigned int owl_uart_get_mctrl(struct uart_port *port) in owl_uart_get_mctrl() argument
109 ctl = owl_uart_read(port, OWL_UART_CTL); in owl_uart_get_mctrl()
110 stat = owl_uart_read(port, OWL_UART_STAT); in owl_uart_get_mctrl()
118 static unsigned int owl_uart_tx_empty(struct uart_port *port) in owl_uart_tx_empty() argument
124 spin_lock_irqsave(&port->lock, flags); in owl_uart_tx_empty()
126 val = owl_uart_read(port, OWL_UART_STAT); in owl_uart_tx_empty()
129 spin_unlock_irqrestore(&port->lock, flags); in owl_uart_tx_empty()
134 static void owl_uart_stop_rx(struct uart_port *port) in owl_uart_stop_rx() argument
138 val = owl_uart_read(port, OWL_UART_CTL); in owl_uart_stop_rx()
140 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_stop_rx()
142 val = owl_uart_read(port, OWL_UART_STAT); in owl_uart_stop_rx()
144 owl_uart_write(port, val, OWL_UART_STAT); in owl_uart_stop_rx()
147 static void owl_uart_stop_tx(struct uart_port *port) in owl_uart_stop_tx() argument
151 val = owl_uart_read(port, OWL_UART_CTL); in owl_uart_stop_tx()
153 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_stop_tx()
155 val = owl_uart_read(port, OWL_UART_STAT); in owl_uart_stop_tx()
157 owl_uart_write(port, val, OWL_UART_STAT); in owl_uart_stop_tx()
160 static void owl_uart_start_tx(struct uart_port *port) in owl_uart_start_tx() argument
164 if (uart_tx_stopped(port)) { in owl_uart_start_tx()
165 owl_uart_stop_tx(port); in owl_uart_start_tx()
169 val = owl_uart_read(port, OWL_UART_STAT); in owl_uart_start_tx()
171 owl_uart_write(port, val, OWL_UART_STAT); in owl_uart_start_tx()
173 val = owl_uart_read(port, OWL_UART_CTL); in owl_uart_start_tx()
175 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_start_tx()
178 static void owl_uart_send_chars(struct uart_port *port) in owl_uart_send_chars() argument
180 struct circ_buf *xmit = &port->state->xmit; in owl_uart_send_chars()
183 if (uart_tx_stopped(port)) in owl_uart_send_chars()
186 if (port->x_char) { in owl_uart_send_chars()
187 while (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)) in owl_uart_send_chars()
189 owl_uart_write(port, port->x_char, OWL_UART_TXDAT); in owl_uart_send_chars()
190 port->icount.tx++; in owl_uart_send_chars()
191 port->x_char = 0; in owl_uart_send_chars()
194 while (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)) { in owl_uart_send_chars()
199 owl_uart_write(port, ch, OWL_UART_TXDAT); in owl_uart_send_chars()
201 port->icount.tx++; in owl_uart_send_chars()
205 uart_write_wakeup(port); in owl_uart_send_chars()
208 owl_uart_stop_tx(port); in owl_uart_send_chars()
211 static void owl_uart_receive_chars(struct uart_port *port) in owl_uart_receive_chars() argument
215 val = owl_uart_read(port, OWL_UART_CTL); in owl_uart_receive_chars()
217 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_receive_chars()
219 stat = owl_uart_read(port, OWL_UART_STAT); in owl_uart_receive_chars()
224 port->icount.overrun++; in owl_uart_receive_chars()
228 port->icount.brk++; in owl_uart_receive_chars()
229 port->icount.frame++; in owl_uart_receive_chars()
231 stat &= port->read_status_mask; in owl_uart_receive_chars()
235 port->icount.rx++; in owl_uart_receive_chars()
237 val = owl_uart_read(port, OWL_UART_RXDAT); in owl_uart_receive_chars()
240 if ((stat & port->ignore_status_mask) == 0) in owl_uart_receive_chars()
241 tty_insert_flip_char(&port->state->port, val, flag); in owl_uart_receive_chars()
243 stat = owl_uart_read(port, OWL_UART_STAT); in owl_uart_receive_chars()
246 spin_unlock(&port->lock); in owl_uart_receive_chars()
247 tty_flip_buffer_push(&port->state->port); in owl_uart_receive_chars()
248 spin_lock(&port->lock); in owl_uart_receive_chars()
253 struct uart_port *port = dev_id; in owl_uart_irq() local
257 spin_lock_irqsave(&port->lock, flags); in owl_uart_irq()
259 stat = owl_uart_read(port, OWL_UART_STAT); in owl_uart_irq()
262 owl_uart_receive_chars(port); in owl_uart_irq()
265 owl_uart_send_chars(port); in owl_uart_irq()
267 stat = owl_uart_read(port, OWL_UART_STAT); in owl_uart_irq()
269 owl_uart_write(port, stat, OWL_UART_STAT); in owl_uart_irq()
271 spin_unlock_irqrestore(&port->lock, flags); in owl_uart_irq()
276 static void owl_uart_shutdown(struct uart_port *port) in owl_uart_shutdown() argument
281 spin_lock_irqsave(&port->lock, flags); in owl_uart_shutdown()
283 val = owl_uart_read(port, OWL_UART_CTL); in owl_uart_shutdown()
286 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_shutdown()
288 spin_unlock_irqrestore(&port->lock, flags); in owl_uart_shutdown()
290 free_irq(port->irq, port); in owl_uart_shutdown()
293 static int owl_uart_startup(struct uart_port *port) in owl_uart_startup() argument
299 ret = request_irq(port->irq, owl_uart_irq, IRQF_TRIGGER_HIGH, in owl_uart_startup()
300 "owl-uart", port); in owl_uart_startup()
304 spin_lock_irqsave(&port->lock, flags); in owl_uart_startup()
306 val = owl_uart_read(port, OWL_UART_STAT); in owl_uart_startup()
309 owl_uart_write(port, val, OWL_UART_STAT); in owl_uart_startup()
311 val = owl_uart_read(port, OWL_UART_CTL); in owl_uart_startup()
314 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_startup()
316 spin_unlock_irqrestore(&port->lock, flags); in owl_uart_startup()
327 static void owl_uart_set_termios(struct uart_port *port, in owl_uart_set_termios() argument
331 struct owl_uart_port *owl_port = to_owl_uart_port(port); in owl_uart_set_termios()
336 spin_lock_irqsave(&port->lock, flags); in owl_uart_set_termios()
338 ctl = owl_uart_read(port, OWL_UART_CTL); in owl_uart_set_termios()
381 owl_uart_write(port, ctl, OWL_UART_CTL); in owl_uart_set_termios()
383 baud = uart_get_baud_rate(port, termios, old, 9600, 3200000); in owl_uart_set_termios()
390 port->read_status_mask |= OWL_UART_STAT_RXER; in owl_uart_set_termios()
392 port->read_status_mask |= OWL_UART_STAT_RXST; in owl_uart_set_termios()
394 uart_update_timeout(port, termios->c_cflag, baud); in owl_uart_set_termios()
396 spin_unlock_irqrestore(&port->lock, flags); in owl_uart_set_termios()
399 static void owl_uart_release_port(struct uart_port *port) in owl_uart_release_port() argument
401 struct platform_device *pdev = to_platform_device(port->dev); in owl_uart_release_port()
408 if (port->flags & UPF_IOREMAP) { in owl_uart_release_port()
409 devm_release_mem_region(port->dev, port->mapbase, in owl_uart_release_port()
411 devm_iounmap(port->dev, port->membase); in owl_uart_release_port()
412 port->membase = NULL; in owl_uart_release_port()
416 static int owl_uart_request_port(struct uart_port *port) in owl_uart_request_port() argument
418 struct platform_device *pdev = to_platform_device(port->dev); in owl_uart_request_port()
425 if (!devm_request_mem_region(port->dev, port->mapbase, in owl_uart_request_port()
426 resource_size(res), dev_name(port->dev))) in owl_uart_request_port()
429 if (port->flags & UPF_IOREMAP) { in owl_uart_request_port()
430 port->membase = devm_ioremap(port->dev, port->mapbase, in owl_uart_request_port()
432 if (!port->membase) in owl_uart_request_port()
439 static const char *owl_uart_type(struct uart_port *port) in owl_uart_type() argument
441 return (port->type == PORT_OWL) ? "owl-uart" : NULL; in owl_uart_type()
444 static int owl_uart_verify_port(struct uart_port *port, in owl_uart_verify_port() argument
447 if (port->type != PORT_OWL) in owl_uart_verify_port()
450 if (port->irq != ser->irq) in owl_uart_verify_port()
456 static void owl_uart_config_port(struct uart_port *port, int flags) in owl_uart_config_port() argument
459 port->type = PORT_OWL; in owl_uart_config_port()
460 owl_uart_request_port(port); in owl_uart_config_port()
483 static void owl_console_putchar(struct uart_port *port, int ch) in owl_console_putchar() argument
485 if (!port->membase) in owl_console_putchar()
488 while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU) in owl_console_putchar()
491 owl_uart_write(port, ch, OWL_UART_TXDAT); in owl_console_putchar()
494 static void owl_uart_port_write(struct uart_port *port, const char *s, in owl_uart_port_write() argument
503 if (port->sysrq) in owl_uart_port_write()
506 locked = spin_trylock(&port->lock); in owl_uart_port_write()
508 spin_lock(&port->lock); in owl_uart_port_write()
512 old_ctl = owl_uart_read(port, OWL_UART_CTL); in owl_uart_port_write()
516 owl_uart_write(port, val, OWL_UART_CTL); in owl_uart_port_write()
518 uart_console_write(port, s, count, owl_console_putchar); in owl_uart_port_write()
521 while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TRFL_MASK) in owl_uart_port_write()
525 val = owl_uart_read(port, OWL_UART_STAT); in owl_uart_port_write()
527 owl_uart_write(port, val, OWL_UART_STAT); in owl_uart_port_write()
529 owl_uart_write(port, old_ctl, OWL_UART_CTL); in owl_uart_port_write()
532 spin_unlock(&port->lock); in owl_uart_port_write()
546 owl_uart_port_write(&owl_port->port, s, count); in owl_uart_console_write()
561 if (!owl_port || !owl_port->port.membase) in owl_uart_console_setup()
567 return uart_set_options(&owl_port->port, co, baud, parity, bits, flow); in owl_uart_console_setup()
594 owl_uart_port_write(&dev->port, s, count); in owl_uart_early_console_write()
600 if (!device->port.membase) in owl_uart_early_console_setup()
669 dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); in owl_uart_probe()
689 owl_port->port.dev = &pdev->dev; in owl_uart_probe()
690 owl_port->port.line = pdev->id; in owl_uart_probe()
691 owl_port->port.type = PORT_OWL; in owl_uart_probe()
692 owl_port->port.iotype = UPIO_MEM; in owl_uart_probe()
693 owl_port->port.mapbase = res_mem->start; in owl_uart_probe()
694 owl_port->port.irq = irq; in owl_uart_probe()
695 owl_port->port.uartclk = clk_get_rate(owl_port->clk); in owl_uart_probe()
696 if (owl_port->port.uartclk == 0) { in owl_uart_probe()
701 owl_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_LOW_LATENCY; in owl_uart_probe()
702 owl_port->port.x_char = 0; in owl_uart_probe()
703 owl_port->port.fifosize = (info) ? info->tx_fifosize : 16; in owl_uart_probe()
704 owl_port->port.ops = &owl_uart_ops; in owl_uart_probe()
709 ret = uart_add_one_port(&owl_uart_driver, &owl_port->port); in owl_uart_probe()
720 uart_remove_one_port(&owl_uart_driver, &owl_port->port); in owl_uart_remove()