Lines Matching refs:port
96 struct uart_port port; member
105 static void wait_for_xmit_empty(struct uart_port *port) in wait_for_xmit_empty() argument
111 port->membase))) == 0) in wait_for_xmit_empty()
119 static void wait_for_xmit_ready(struct uart_port *port) in wait_for_xmit_ready() argument
125 port->membase))) < 32) in wait_for_xmit_ready()
133 static void lpc32xx_hsuart_console_putchar(struct uart_port *port, int ch) in lpc32xx_hsuart_console_putchar() argument
135 wait_for_xmit_ready(port); in lpc32xx_hsuart_console_putchar()
136 writel((u32)ch, LPC32XX_HSUART_FIFO(port->membase)); in lpc32xx_hsuart_console_putchar()
148 if (up->port.sysrq) in lpc32xx_hsuart_console_write()
151 locked = spin_trylock(&up->port.lock); in lpc32xx_hsuart_console_write()
153 spin_lock(&up->port.lock); in lpc32xx_hsuart_console_write()
155 uart_console_write(&up->port, s, count, lpc32xx_hsuart_console_putchar); in lpc32xx_hsuart_console_write()
156 wait_for_xmit_empty(&up->port); in lpc32xx_hsuart_console_write()
159 spin_unlock(&up->port.lock); in lpc32xx_hsuart_console_write()
166 struct uart_port *port; in lpc32xx_hsuart_console_setup() local
175 port = &lpc32xx_hs_ports[co->index].port; in lpc32xx_hsuart_console_setup()
176 if (!port->membase) in lpc32xx_hsuart_console_setup()
182 return uart_set_options(port, co, baud, parity, bits, flow); in lpc32xx_hsuart_console_setup()
248 static void __serial_uart_flush(struct uart_port *port) in __serial_uart_flush() argument
253 while ((readl(LPC32XX_HSUART_LEVEL(port->membase)) > 0) && in __serial_uart_flush()
255 tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); in __serial_uart_flush()
258 static void __serial_lpc32xx_rx(struct uart_port *port) in __serial_lpc32xx_rx() argument
260 struct tty_port *tport = &port->state->port; in __serial_lpc32xx_rx()
264 tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); in __serial_lpc32xx_rx()
267 port->icount.rx++; in __serial_lpc32xx_rx()
272 LPC32XX_HSUART_IIR(port->membase)); in __serial_lpc32xx_rx()
273 port->icount.frame++; in __serial_lpc32xx_rx()
280 tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); in __serial_lpc32xx_rx()
283 spin_unlock(&port->lock); in __serial_lpc32xx_rx()
285 spin_lock(&port->lock); in __serial_lpc32xx_rx()
288 static void __serial_lpc32xx_tx(struct uart_port *port) in __serial_lpc32xx_tx() argument
290 struct circ_buf *xmit = &port->state->xmit; in __serial_lpc32xx_tx()
293 if (port->x_char) { in __serial_lpc32xx_tx()
294 writel((u32)port->x_char, LPC32XX_HSUART_FIFO(port->membase)); in __serial_lpc32xx_tx()
295 port->icount.tx++; in __serial_lpc32xx_tx()
296 port->x_char = 0; in __serial_lpc32xx_tx()
300 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) in __serial_lpc32xx_tx()
305 LPC32XX_HSUART_LEVEL(port->membase))) < 64) { in __serial_lpc32xx_tx()
307 LPC32XX_HSUART_FIFO(port->membase)); in __serial_lpc32xx_tx()
309 port->icount.tx++; in __serial_lpc32xx_tx()
315 uart_write_wakeup(port); in __serial_lpc32xx_tx()
319 tmp = readl(LPC32XX_HSUART_CTRL(port->membase)); in __serial_lpc32xx_tx()
321 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in __serial_lpc32xx_tx()
327 struct uart_port *port = dev_id; in serial_lpc32xx_interrupt() local
328 struct tty_port *tport = &port->state->port; in serial_lpc32xx_interrupt()
331 spin_lock(&port->lock); in serial_lpc32xx_interrupt()
334 status = readl(LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_interrupt()
338 writel(LPC32XX_HSU_BRK_INT, LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_interrupt()
339 port->icount.brk++; in serial_lpc32xx_interrupt()
340 uart_handle_break(port); in serial_lpc32xx_interrupt()
345 writel(LPC32XX_HSU_FE_INT, LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_interrupt()
350 LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_interrupt()
351 port->icount.overrun++; in serial_lpc32xx_interrupt()
358 __serial_lpc32xx_rx(port); in serial_lpc32xx_interrupt()
361 if ((status & LPC32XX_HSU_TX_INT) && (!uart_tx_stopped(port))) { in serial_lpc32xx_interrupt()
362 writel(LPC32XX_HSU_TX_INT, LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_interrupt()
363 __serial_lpc32xx_tx(port); in serial_lpc32xx_interrupt()
366 spin_unlock(&port->lock); in serial_lpc32xx_interrupt()
372 static unsigned int serial_lpc32xx_tx_empty(struct uart_port *port) in serial_lpc32xx_tx_empty() argument
376 if (LPC32XX_HSU_TX_LEV(readl(LPC32XX_HSUART_LEVEL(port->membase))) == 0) in serial_lpc32xx_tx_empty()
383 static void serial_lpc32xx_set_mctrl(struct uart_port *port, in serial_lpc32xx_set_mctrl() argument
390 static unsigned int serial_lpc32xx_get_mctrl(struct uart_port *port) in serial_lpc32xx_get_mctrl() argument
397 static void serial_lpc32xx_stop_tx(struct uart_port *port) in serial_lpc32xx_stop_tx() argument
401 tmp = readl(LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_stop_tx()
403 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_stop_tx()
407 static void serial_lpc32xx_start_tx(struct uart_port *port) in serial_lpc32xx_start_tx() argument
411 __serial_lpc32xx_tx(port); in serial_lpc32xx_start_tx()
412 tmp = readl(LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_start_tx()
414 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_start_tx()
418 static void serial_lpc32xx_stop_rx(struct uart_port *port) in serial_lpc32xx_stop_rx() argument
422 tmp = readl(LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_stop_rx()
424 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_stop_rx()
427 LPC32XX_HSU_FE_INT), LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_stop_rx()
431 static void serial_lpc32xx_break_ctl(struct uart_port *port, in serial_lpc32xx_break_ctl() argument
437 spin_lock_irqsave(&port->lock, flags); in serial_lpc32xx_break_ctl()
438 tmp = readl(LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_break_ctl()
443 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_break_ctl()
444 spin_unlock_irqrestore(&port->lock, flags); in serial_lpc32xx_break_ctl()
477 static int serial_lpc32xx_startup(struct uart_port *port) in serial_lpc32xx_startup() argument
483 spin_lock_irqsave(&port->lock, flags); in serial_lpc32xx_startup()
485 __serial_uart_flush(port); in serial_lpc32xx_startup()
489 LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_startup()
491 writel(0xFF, LPC32XX_HSUART_RATE(port->membase)); in serial_lpc32xx_startup()
499 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_startup()
501 lpc32xx_loopback_set(port->mapbase, 0); /* get out of loopback mode */ in serial_lpc32xx_startup()
503 spin_unlock_irqrestore(&port->lock, flags); in serial_lpc32xx_startup()
505 retval = request_irq(port->irq, serial_lpc32xx_interrupt, in serial_lpc32xx_startup()
506 0, MODNAME, port); in serial_lpc32xx_startup()
509 LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_startup()
515 static void serial_lpc32xx_shutdown(struct uart_port *port) in serial_lpc32xx_shutdown() argument
520 spin_lock_irqsave(&port->lock, flags); in serial_lpc32xx_shutdown()
524 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_shutdown()
526 lpc32xx_loopback_set(port->mapbase, 1); /* go to loopback mode */ in serial_lpc32xx_shutdown()
528 spin_unlock_irqrestore(&port->lock, flags); in serial_lpc32xx_shutdown()
530 free_irq(port->irq, port); in serial_lpc32xx_shutdown()
534 static void serial_lpc32xx_set_termios(struct uart_port *port, in serial_lpc32xx_set_termios() argument
548 baud = uart_get_baud_rate(port, termios, old, 0, in serial_lpc32xx_set_termios()
549 port->uartclk / 14); in serial_lpc32xx_set_termios()
551 quot = __serial_get_clock_div(port->uartclk, baud); in serial_lpc32xx_set_termios()
553 spin_lock_irqsave(&port->lock, flags); in serial_lpc32xx_set_termios()
556 tmp = readl(LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_set_termios()
561 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_set_termios()
563 writel(quot, LPC32XX_HSUART_RATE(port->membase)); in serial_lpc32xx_set_termios()
565 uart_update_timeout(port, termios->c_cflag, baud); in serial_lpc32xx_set_termios()
567 spin_unlock_irqrestore(&port->lock, flags); in serial_lpc32xx_set_termios()
574 static const char *serial_lpc32xx_type(struct uart_port *port) in serial_lpc32xx_type() argument
579 static void serial_lpc32xx_release_port(struct uart_port *port) in serial_lpc32xx_release_port() argument
581 if ((port->iotype == UPIO_MEM32) && (port->mapbase)) { in serial_lpc32xx_release_port()
582 if (port->flags & UPF_IOREMAP) { in serial_lpc32xx_release_port()
583 iounmap(port->membase); in serial_lpc32xx_release_port()
584 port->membase = NULL; in serial_lpc32xx_release_port()
587 release_mem_region(port->mapbase, SZ_4K); in serial_lpc32xx_release_port()
591 static int serial_lpc32xx_request_port(struct uart_port *port) in serial_lpc32xx_request_port() argument
595 if ((port->iotype == UPIO_MEM32) && (port->mapbase)) { in serial_lpc32xx_request_port()
598 if (!request_mem_region(port->mapbase, SZ_4K, MODNAME)) in serial_lpc32xx_request_port()
600 else if (port->flags & UPF_IOREMAP) { in serial_lpc32xx_request_port()
601 port->membase = ioremap(port->mapbase, SZ_4K); in serial_lpc32xx_request_port()
602 if (!port->membase) { in serial_lpc32xx_request_port()
603 release_mem_region(port->mapbase, SZ_4K); in serial_lpc32xx_request_port()
612 static void serial_lpc32xx_config_port(struct uart_port *port, int uflags) in serial_lpc32xx_config_port() argument
616 ret = serial_lpc32xx_request_port(port); in serial_lpc32xx_config_port()
619 port->type = PORT_UART00; in serial_lpc32xx_config_port()
620 port->fifosize = 64; in serial_lpc32xx_config_port()
622 __serial_uart_flush(port); in serial_lpc32xx_config_port()
626 LPC32XX_HSUART_IIR(port->membase)); in serial_lpc32xx_config_port()
628 writel(0xFF, LPC32XX_HSUART_RATE(port->membase)); in serial_lpc32xx_config_port()
634 LPC32XX_HSUART_CTRL(port->membase)); in serial_lpc32xx_config_port()
637 static int serial_lpc32xx_verify_port(struct uart_port *port, in serial_lpc32xx_verify_port() argument
691 p->port.mapbase = res->start; in serial_hs_lpc32xx_probe()
692 p->port.membase = NULL; in serial_hs_lpc32xx_probe()
694 p->port.irq = platform_get_irq(pdev, 0); in serial_hs_lpc32xx_probe()
695 if (p->port.irq < 0) { in serial_hs_lpc32xx_probe()
698 return p->port.irq; in serial_hs_lpc32xx_probe()
701 p->port.iotype = UPIO_MEM32; in serial_hs_lpc32xx_probe()
702 p->port.uartclk = LPC32XX_MAIN_OSC_FREQ; in serial_hs_lpc32xx_probe()
703 p->port.regshift = 2; in serial_hs_lpc32xx_probe()
704 p->port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP; in serial_hs_lpc32xx_probe()
705 p->port.dev = &pdev->dev; in serial_hs_lpc32xx_probe()
706 p->port.ops = &serial_lpc32xx_pops; in serial_hs_lpc32xx_probe()
707 p->port.line = uarts_registered++; in serial_hs_lpc32xx_probe()
708 spin_lock_init(&p->port.lock); in serial_hs_lpc32xx_probe()
711 lpc32xx_loopback_set(p->port.mapbase, 1); in serial_hs_lpc32xx_probe()
713 ret = uart_add_one_port(&lpc32xx_hs_reg, &p->port); in serial_hs_lpc32xx_probe()
727 uart_remove_one_port(&lpc32xx_hs_reg, &p->port); in serial_hs_lpc32xx_remove()
739 uart_suspend_port(&lpc32xx_hs_reg, &p->port); in serial_hs_lpc32xx_suspend()
748 uart_resume_port(&lpc32xx_hs_reg, &p->port); in serial_hs_lpc32xx_resume()