Lines Matching refs:port

124 static inline void vt8500_write(struct uart_port *port, unsigned int val,  in vt8500_write()  argument
127 writel(val, port->membase + off); in vt8500_write()
130 static inline unsigned int vt8500_read(struct uart_port *port, unsigned int off) in vt8500_read() argument
132 return readl(port->membase + off); in vt8500_read()
135 static void vt8500_stop_tx(struct uart_port *port) in vt8500_stop_tx() argument
137 struct vt8500_port *vt8500_port = container_of(port, in vt8500_stop_tx()
142 vt8500_write(port, vt8500_port->ier, VT8500_URIER); in vt8500_stop_tx()
145 static void vt8500_stop_rx(struct uart_port *port) in vt8500_stop_rx() argument
147 struct vt8500_port *vt8500_port = container_of(port, in vt8500_stop_rx()
152 vt8500_write(port, vt8500_port->ier, VT8500_URIER); in vt8500_stop_rx()
155 static void vt8500_enable_ms(struct uart_port *port) in vt8500_enable_ms() argument
157 struct vt8500_port *vt8500_port = container_of(port, in vt8500_enable_ms()
162 vt8500_write(port, vt8500_port->ier, VT8500_URIER); in vt8500_enable_ms()
165 static void handle_rx(struct uart_port *port) in handle_rx() argument
167 struct tty_port *tport = &port->state->port; in handle_rx()
172 if ((vt8500_read(port, VT8500_URISR) & RXOVER)) { in handle_rx()
173 port->icount.overrun++; in handle_rx()
178 while (vt8500_read(port, VT8500_URFIDX) & 0x1f00) { in handle_rx()
182 c = readw(port->membase + VT8500_RXFIFO) & 0x3ff; in handle_rx()
185 c &= ~port->read_status_mask; in handle_rx()
188 port->icount.frame++; in handle_rx()
191 port->icount.parity++; in handle_rx()
194 port->icount.rx++; in handle_rx()
196 if (!uart_handle_sysrq_char(port, c)) in handle_rx()
200 spin_unlock(&port->lock); in handle_rx()
202 spin_lock(&port->lock); in handle_rx()
205 static void handle_tx(struct uart_port *port) in handle_tx() argument
207 struct circ_buf *xmit = &port->state->xmit; in handle_tx()
209 if (port->x_char) { in handle_tx()
210 writeb(port->x_char, port->membase + VT8500_TXFIFO); in handle_tx()
211 port->icount.tx++; in handle_tx()
212 port->x_char = 0; in handle_tx()
214 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { in handle_tx()
215 vt8500_stop_tx(port); in handle_tx()
219 while ((vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16) { in handle_tx()
223 writeb(xmit->buf[xmit->tail], port->membase + VT8500_TXFIFO); in handle_tx()
226 port->icount.tx++; in handle_tx()
230 uart_write_wakeup(port); in handle_tx()
233 vt8500_stop_tx(port); in handle_tx()
236 static void vt8500_start_tx(struct uart_port *port) in vt8500_start_tx() argument
238 struct vt8500_port *vt8500_port = container_of(port, in vt8500_start_tx()
243 vt8500_write(port, vt8500_port->ier, VT8500_URIER); in vt8500_start_tx()
244 handle_tx(port); in vt8500_start_tx()
246 vt8500_write(port, vt8500_port->ier, VT8500_URIER); in vt8500_start_tx()
249 static void handle_delta_cts(struct uart_port *port) in handle_delta_cts() argument
251 port->icount.cts++; in handle_delta_cts()
252 wake_up_interruptible(&port->state->port.delta_msr_wait); in handle_delta_cts()
257 struct uart_port *port = dev_id; in vt8500_irq() local
260 spin_lock(&port->lock); in vt8500_irq()
261 isr = vt8500_read(port, VT8500_URISR); in vt8500_irq()
264 vt8500_write(port, isr, VT8500_URISR); in vt8500_irq()
267 handle_rx(port); in vt8500_irq()
269 handle_tx(port); in vt8500_irq()
271 handle_delta_cts(port); in vt8500_irq()
273 spin_unlock(&port->lock); in vt8500_irq()
278 static unsigned int vt8500_tx_empty(struct uart_port *port) in vt8500_tx_empty() argument
280 return (vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16 ? in vt8500_tx_empty()
284 static unsigned int vt8500_get_mctrl(struct uart_port *port) in vt8500_get_mctrl() argument
288 usr = vt8500_read(port, VT8500_URUSR); in vt8500_get_mctrl()
295 static void vt8500_set_mctrl(struct uart_port *port, unsigned int mctrl) in vt8500_set_mctrl() argument
297 unsigned int lcr = vt8500_read(port, VT8500_URLCR); in vt8500_set_mctrl()
304 vt8500_write(port, lcr, VT8500_URLCR); in vt8500_set_mctrl()
307 static void vt8500_break_ctl(struct uart_port *port, int break_ctl) in vt8500_break_ctl() argument
310 vt8500_write(port, in vt8500_break_ctl()
311 vt8500_read(port, VT8500_URLCR) | VT8500_BREAK, in vt8500_break_ctl()
315 static int vt8500_set_baud_rate(struct uart_port *port, unsigned int baud) in vt8500_set_baud_rate() argument
318 container_of(port, struct vt8500_port, uart); in vt8500_set_baud_rate()
323 div |= (uart_get_divisor(port, baud) - 1) & 0x3ff; in vt8500_set_baud_rate()
326 baud = port->uartclk / 16 / ((div & 0x3ff) + 1); in vt8500_set_baud_rate()
328 while ((vt8500_read(port, VT8500_URUSR) & (1 << 5)) && --loops) in vt8500_set_baud_rate()
331 vt8500_write(port, div, VT8500_URDIV); in vt8500_set_baud_rate()
334 vt8500_write(port, mult_frac(baud, 4096, 1000000), VT8500_URBKR); in vt8500_set_baud_rate()
339 static int vt8500_startup(struct uart_port *port) in vt8500_startup() argument
342 container_of(port, struct vt8500_port, uart); in vt8500_startup()
346 "vt8500_serial%d", port->line); in vt8500_startup()
348 ret = request_irq(port->irq, vt8500_irq, IRQF_TRIGGER_HIGH, in vt8500_startup()
349 vt8500_port->name, port); in vt8500_startup()
353 vt8500_write(port, 0x03, VT8500_URLCR); /* enable TX & RX */ in vt8500_startup()
358 static void vt8500_shutdown(struct uart_port *port) in vt8500_shutdown() argument
361 container_of(port, struct vt8500_port, uart); in vt8500_shutdown()
368 free_irq(port->irq, port); in vt8500_shutdown()
371 static void vt8500_set_termios(struct uart_port *port, in vt8500_set_termios() argument
376 container_of(port, struct vt8500_port, uart); in vt8500_set_termios()
381 spin_lock_irqsave(&port->lock, flags); in vt8500_set_termios()
384 baud = uart_get_baud_rate(port, termios, old, 900, 921600); in vt8500_set_termios()
385 baud = vt8500_set_baud_rate(port, baud); in vt8500_set_termios()
425 port->read_status_mask = 0; in vt8500_set_termios()
427 port->read_status_mask = FER | PER; in vt8500_set_termios()
429 uart_update_timeout(port, termios->c_cflag, baud); in vt8500_set_termios()
449 spin_unlock_irqrestore(&port->lock, flags); in vt8500_set_termios()
452 static const char *vt8500_type(struct uart_port *port) in vt8500_type() argument
455 container_of(port, struct vt8500_port, uart); in vt8500_type()
459 static void vt8500_release_port(struct uart_port *port) in vt8500_release_port() argument
463 static int vt8500_request_port(struct uart_port *port) in vt8500_request_port() argument
468 static void vt8500_config_port(struct uart_port *port, int flags) in vt8500_config_port() argument
470 port->type = PORT_VT8500; in vt8500_config_port()
473 static int vt8500_verify_port(struct uart_port *port, in vt8500_verify_port() argument
478 if (unlikely(port->irq != ser->irq)) in vt8500_verify_port()
488 static inline void wait_for_xmitr(struct uart_port *port) in wait_for_xmitr() argument
494 status = vt8500_read(port, VT8500_URFIDX); in wait_for_xmitr()
502 static void vt8500_console_putchar(struct uart_port *port, int c) in vt8500_console_putchar() argument
504 wait_for_xmitr(port); in vt8500_console_putchar()
505 writeb(c, port->membase + VT8500_TXFIFO); in vt8500_console_putchar()
570 static int vt8500_get_poll_char(struct uart_port *port) in vt8500_get_poll_char() argument
572 unsigned int status = vt8500_read(port, VT8500_URFIDX); in vt8500_get_poll_char()
577 return vt8500_read(port, VT8500_RXFIFO) & 0xff; in vt8500_get_poll_char()
580 static void vt8500_put_poll_char(struct uart_port *port, unsigned char c) in vt8500_put_poll_char() argument
585 status = vt8500_read(port, VT8500_URFIDX); in vt8500_put_poll_char()
592 vt8500_write(port, c, VT8500_TXFIFO); in vt8500_put_poll_char()
644 int port; in vt8500_serial_probe() local
658 port = of_alias_get_id(np, "serial"); in vt8500_serial_probe()
659 if (port >= VT8500_MAX_PORTS) in vt8500_serial_probe()
660 port = -1; in vt8500_serial_probe()
662 port = -1; in vt8500_serial_probe()
665 if (port < 0) { in vt8500_serial_probe()
667 port = find_first_zero_bit(&vt8500_ports_in_use, in vt8500_serial_probe()
671 if (port >= VT8500_MAX_PORTS) in vt8500_serial_probe()
675 if (test_and_set_bit(port, &vt8500_ports_in_use)) { in vt8500_serial_probe()
712 vt8500_port->uart.line = port; in vt8500_serial_probe()
724 vt8500_uart_ports[port] = vt8500_port; in vt8500_serial_probe()