Lines Matching refs:port
111 static inline void vt8500_write(struct uart_port *port, unsigned int val,
114 writel(val, port->membase + off);
117 static inline unsigned int vt8500_read(struct uart_port *port, unsigned int off)
119 return readl(port->membase + off);
122 static void vt8500_stop_tx(struct uart_port *port)
124 struct vt8500_port *vt8500_port = container_of(port,
129 vt8500_write(port, vt8500_port->ier, VT8500_URIER);
132 static void vt8500_stop_rx(struct uart_port *port)
134 struct vt8500_port *vt8500_port = container_of(port,
139 vt8500_write(port, vt8500_port->ier, VT8500_URIER);
142 static void vt8500_enable_ms(struct uart_port *port)
144 struct vt8500_port *vt8500_port = container_of(port,
149 vt8500_write(port, vt8500_port->ier, VT8500_URIER);
152 static void handle_rx(struct uart_port *port)
154 struct tty_port *tport = &port->state->port;
159 if ((vt8500_read(port, VT8500_URISR) & RXOVER)) {
160 port->icount.overrun++;
165 while (vt8500_read(port, VT8500_URFIDX) & 0x1f00) {
169 c = readw(port->membase + VT8500_RXFIFO) & 0x3ff;
172 c &= ~port->read_status_mask;
175 port->icount.frame++;
178 port->icount.parity++;
181 port->icount.rx++;
183 if (!uart_handle_sysrq_char(port, c))
190 static unsigned int vt8500_tx_empty(struct uart_port *port)
192 unsigned int idx = vt8500_read(port, VT8500_URFIDX) & 0x1f;
197 static void handle_tx(struct uart_port *port)
201 uart_port_tx(port, ch,
202 vt8500_tx_empty(port),
203 writeb(ch, port->membase + VT8500_TXFIFO));
206 static void vt8500_start_tx(struct uart_port *port)
208 struct vt8500_port *vt8500_port = container_of(port,
213 vt8500_write(port, vt8500_port->ier, VT8500_URIER);
214 handle_tx(port);
216 vt8500_write(port, vt8500_port->ier, VT8500_URIER);
219 static void handle_delta_cts(struct uart_port *port)
221 port->icount.cts++;
222 wake_up_interruptible(&port->state->port.delta_msr_wait);
227 struct uart_port *port = dev_id;
230 spin_lock(&port->lock);
231 isr = vt8500_read(port, VT8500_URISR);
234 vt8500_write(port, isr, VT8500_URISR);
237 handle_rx(port);
239 handle_tx(port);
241 handle_delta_cts(port);
243 spin_unlock(&port->lock);
248 static unsigned int vt8500_get_mctrl(struct uart_port *port)
252 usr = vt8500_read(port, VT8500_URUSR);
259 static void vt8500_set_mctrl(struct uart_port *port, unsigned int mctrl)
261 unsigned int lcr = vt8500_read(port, VT8500_URLCR);
268 vt8500_write(port, lcr, VT8500_URLCR);
271 static void vt8500_break_ctl(struct uart_port *port, int break_ctl)
274 vt8500_write(port,
275 vt8500_read(port, VT8500_URLCR) | VT8500_BREAK,
279 static int vt8500_set_baud_rate(struct uart_port *port, unsigned int baud)
282 container_of(port, struct vt8500_port, uart);
287 div |= (uart_get_divisor(port, baud) - 1) & 0x3ff;
290 baud = port->uartclk / 16 / ((div & 0x3ff) + 1);
292 while ((vt8500_read(port, VT8500_URUSR) & (1 << 5)) && --loops)
295 vt8500_write(port, div, VT8500_URDIV);
298 vt8500_write(port, mult_frac(baud, 4096, 1000000), VT8500_URBKR);
303 static int vt8500_startup(struct uart_port *port)
306 container_of(port, struct vt8500_port, uart);
310 "vt8500_serial%d", port->line);
312 ret = request_irq(port->irq, vt8500_irq, IRQF_TRIGGER_HIGH,
313 vt8500_port->name, port);
317 vt8500_write(port, 0x03, VT8500_URLCR); /* enable TX & RX */
322 static void vt8500_shutdown(struct uart_port *port)
325 container_of(port, struct vt8500_port, uart);
332 free_irq(port->irq, port);
335 static void vt8500_set_termios(struct uart_port *port,
340 container_of(port, struct vt8500_port, uart);
345 spin_lock_irqsave(&port->lock, flags);
348 baud = uart_get_baud_rate(port, termios, old, 900, 921600);
349 baud = vt8500_set_baud_rate(port, baud);
389 port->read_status_mask = 0;
391 port->read_status_mask = FER | PER;
393 uart_update_timeout(port, termios->c_cflag, baud);
413 spin_unlock_irqrestore(&port->lock, flags);
416 static const char *vt8500_type(struct uart_port *port)
419 container_of(port, struct vt8500_port, uart);
423 static void vt8500_release_port(struct uart_port *port)
427 static int vt8500_request_port(struct uart_port *port)
432 static void vt8500_config_port(struct uart_port *port, int flags)
434 port->type = PORT_VT8500;
437 static int vt8500_verify_port(struct uart_port *port,
442 if (unlikely(port->irq != ser->irq))
452 static void wait_for_xmitr(struct uart_port *port)
458 status = vt8500_read(port, VT8500_URFIDX);
466 static void vt8500_console_putchar(struct uart_port *port, unsigned char c)
468 wait_for_xmitr(port);
469 writeb(c, port->membase + VT8500_TXFIFO);
534 static int vt8500_get_poll_char(struct uart_port *port)
536 unsigned int status = vt8500_read(port, VT8500_URFIDX);
541 return vt8500_read(port, VT8500_RXFIFO) & 0xff;
544 static void vt8500_put_poll_char(struct uart_port *port, unsigned char c)
549 status = vt8500_read(port, VT8500_URFIDX);
556 vt8500_write(port, c, VT8500_TXFIFO);
607 int port;
619 port = of_alias_get_id(np, "serial");
620 if (port >= VT8500_MAX_PORTS)
621 port = -1;
623 port = -1;
626 if (port < 0) {
627 /* calculate the port id */
628 port = find_first_zero_bit(vt8500_ports_in_use,
632 if (port >= VT8500_MAX_PORTS)
635 /* reserve the port id */
636 if (test_and_set_bit(port, vt8500_ports_in_use)) {
637 /* port already in use - shouldn't really happen */
673 vt8500_port->uart.line = port;
686 vt8500_uart_ports[port] = vt8500_port;