Lines Matching refs:port

53 	struct uart_port	port;  member
60 static unsigned int mcf_tx_empty(struct uart_port *port) in mcf_tx_empty() argument
62 return (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXEMPTY) ? in mcf_tx_empty()
68 static unsigned int mcf_get_mctrl(struct uart_port *port) in mcf_get_mctrl() argument
70 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_get_mctrl()
73 sigs = (readb(port->membase + MCFUART_UIPR) & MCFUART_UIPR_CTS) ? in mcf_get_mctrl()
76 sigs |= (mcf_getppdcd(port->line) ? TIOCM_CD : 0); in mcf_get_mctrl()
77 sigs |= (mcf_getppdtr(port->line) ? TIOCM_DTR : 0); in mcf_get_mctrl()
84 static void mcf_set_mctrl(struct uart_port *port, unsigned int sigs) in mcf_set_mctrl() argument
86 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_set_mctrl()
89 mcf_setppdtr(port->line, (sigs & TIOCM_DTR)); in mcf_set_mctrl()
91 writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP1); in mcf_set_mctrl()
93 writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP0); in mcf_set_mctrl()
98 static void mcf_start_tx(struct uart_port *port) in mcf_start_tx() argument
100 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_start_tx()
102 if (port->rs485.flags & SER_RS485_ENABLED) { in mcf_start_tx()
104 writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR); in mcf_start_tx()
106 writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP1); in mcf_start_tx()
109 writeb(pp->imr, port->membase + MCFUART_UIMR); in mcf_start_tx()
114 static void mcf_stop_tx(struct uart_port *port) in mcf_stop_tx() argument
116 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_stop_tx()
119 writeb(pp->imr, port->membase + MCFUART_UIMR); in mcf_stop_tx()
124 static void mcf_stop_rx(struct uart_port *port) in mcf_stop_rx() argument
126 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_stop_rx()
129 writeb(pp->imr, port->membase + MCFUART_UIMR); in mcf_stop_rx()
134 static void mcf_break_ctl(struct uart_port *port, int break_state) in mcf_break_ctl() argument
138 spin_lock_irqsave(&port->lock, flags); in mcf_break_ctl()
140 writeb(MCFUART_UCR_CMDBREAKSTART, port->membase + MCFUART_UCR); in mcf_break_ctl()
142 writeb(MCFUART_UCR_CMDBREAKSTOP, port->membase + MCFUART_UCR); in mcf_break_ctl()
143 spin_unlock_irqrestore(&port->lock, flags); in mcf_break_ctl()
148 static int mcf_startup(struct uart_port *port) in mcf_startup() argument
150 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_startup()
153 spin_lock_irqsave(&port->lock, flags); in mcf_startup()
156 writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); in mcf_startup()
157 writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); in mcf_startup()
161 port->membase + MCFUART_UCR); in mcf_startup()
165 writeb(pp->imr, port->membase + MCFUART_UIMR); in mcf_startup()
167 spin_unlock_irqrestore(&port->lock, flags); in mcf_startup()
174 static void mcf_shutdown(struct uart_port *port) in mcf_shutdown() argument
176 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_shutdown()
179 spin_lock_irqsave(&port->lock, flags); in mcf_shutdown()
183 writeb(pp->imr, port->membase + MCFUART_UIMR); in mcf_shutdown()
186 writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); in mcf_shutdown()
187 writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); in mcf_shutdown()
189 spin_unlock_irqrestore(&port->lock, flags); in mcf_shutdown()
194 static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, in mcf_set_termios() argument
204 baud = uart_get_baud_rate(port, termios, old, 0, 230400); in mcf_set_termios()
255 spin_lock_irqsave(&port->lock, flags); in mcf_set_termios()
256 if (port->rs485.flags & SER_RS485_ENABLED) { in mcf_set_termios()
257 dev_dbg(port->dev, "Setting UART to RS485\n"); in mcf_set_termios()
261 uart_update_timeout(port, termios->c_cflag, baud); in mcf_set_termios()
262 writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); in mcf_set_termios()
263 writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); in mcf_set_termios()
264 writeb(MCFUART_UCR_CMDRESETMRPTR, port->membase + MCFUART_UCR); in mcf_set_termios()
265 writeb(mr1, port->membase + MCFUART_UMR); in mcf_set_termios()
266 writeb(mr2, port->membase + MCFUART_UMR); in mcf_set_termios()
267 writeb((baudclk & 0xff00) >> 8, port->membase + MCFUART_UBG1); in mcf_set_termios()
268 writeb((baudclk & 0xff), port->membase + MCFUART_UBG2); in mcf_set_termios()
270 writeb((baudfr & 0x0f), port->membase + MCFUART_UFPD); in mcf_set_termios()
273 port->membase + MCFUART_UCSR); in mcf_set_termios()
275 port->membase + MCFUART_UCR); in mcf_set_termios()
276 spin_unlock_irqrestore(&port->lock, flags); in mcf_set_termios()
283 struct uart_port *port = &pp->port; in mcf_rx_chars() local
286 while ((status = readb(port->membase + MCFUART_USR)) & MCFUART_USR_RXREADY) { in mcf_rx_chars()
287 ch = readb(port->membase + MCFUART_URB); in mcf_rx_chars()
289 port->icount.rx++; in mcf_rx_chars()
293 port->membase + MCFUART_UCR); in mcf_rx_chars()
296 port->icount.brk++; in mcf_rx_chars()
297 if (uart_handle_break(port)) in mcf_rx_chars()
300 port->icount.parity++; in mcf_rx_chars()
302 port->icount.overrun++; in mcf_rx_chars()
304 port->icount.frame++; in mcf_rx_chars()
307 status &= port->read_status_mask; in mcf_rx_chars()
317 if (uart_handle_sysrq_char(port, ch)) in mcf_rx_chars()
319 uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); in mcf_rx_chars()
322 tty_flip_buffer_push(&port->state->port); in mcf_rx_chars()
329 struct uart_port *port = &pp->port; in mcf_tx_chars() local
330 struct circ_buf *xmit = &port->state->xmit; in mcf_tx_chars()
332 if (port->x_char) { in mcf_tx_chars()
334 writeb(port->x_char, port->membase + MCFUART_UTB); in mcf_tx_chars()
335 port->x_char = 0; in mcf_tx_chars()
336 port->icount.tx++; in mcf_tx_chars()
340 while (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY) { in mcf_tx_chars()
343 writeb(xmit->buf[xmit->tail], port->membase + MCFUART_UTB); in mcf_tx_chars()
345 port->icount.tx++; in mcf_tx_chars()
349 uart_write_wakeup(port); in mcf_tx_chars()
352 mcf_stop_tx(port); in mcf_tx_chars()
354 if (port->rs485.flags & SER_RS485_ENABLED) in mcf_tx_chars()
356 port->membase + MCFUART_UCR); in mcf_tx_chars()
364 struct uart_port *port = data; in mcf_interrupt() local
365 struct mcf_uart *pp = container_of(port, struct mcf_uart, port); in mcf_interrupt()
369 isr = readb(port->membase + MCFUART_UISR) & pp->imr; in mcf_interrupt()
371 spin_lock(&port->lock); in mcf_interrupt()
380 spin_unlock(&port->lock); in mcf_interrupt()
387 static void mcf_config_port(struct uart_port *port, int flags) in mcf_config_port() argument
389 port->type = PORT_MCF; in mcf_config_port()
390 port->fifosize = MCFUART_TXFIFOSIZE; in mcf_config_port()
393 writeb(0, port->membase + MCFUART_UIMR); in mcf_config_port()
395 if (request_irq(port->irq, mcf_interrupt, 0, "UART", port)) in mcf_config_port()
397 "interrupt vector=%d\n", port->line, port->irq); in mcf_config_port()
402 static const char *mcf_type(struct uart_port *port) in mcf_type() argument
404 return (port->type == PORT_MCF) ? "ColdFire UART" : NULL; in mcf_type()
409 static int mcf_request_port(struct uart_port *port) in mcf_request_port() argument
417 static void mcf_release_port(struct uart_port *port) in mcf_release_port() argument
424 static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser) in mcf_verify_port() argument
434 static int mcf_config_rs485(struct uart_port *port, struct ktermios *termios, in mcf_config_rs485() argument
440 mr1 = readb(port->membase + MCFUART_UMR); in mcf_config_rs485()
441 mr2 = readb(port->membase + MCFUART_UMR); in mcf_config_rs485()
443 dev_dbg(port->dev, "Setting UART to RS485\n"); in mcf_config_rs485()
447 dev_dbg(port->dev, "Setting UART to RS232\n"); in mcf_config_rs485()
450 writeb(mr1, port->membase + MCFUART_UMR); in mcf_config_rs485()
451 writeb(mr2, port->membase + MCFUART_UMR); in mcf_config_rs485()
493 struct uart_port *port; in early_mcf_setup() local
497 port = &mcf_ports[i].port; in early_mcf_setup()
499 port->line = i; in early_mcf_setup()
500 port->type = PORT_MCF; in early_mcf_setup()
501 port->mapbase = platp[i].mapbase; in early_mcf_setup()
502 port->membase = (platp[i].membase) ? platp[i].membase : in early_mcf_setup()
503 (unsigned char __iomem *) port->mapbase; in early_mcf_setup()
504 port->iotype = SERIAL_IO_MEM; in early_mcf_setup()
505 port->irq = platp[i].irq; in early_mcf_setup()
506 port->uartclk = MCF_BUSCLK; in early_mcf_setup()
507 port->flags = UPF_BOOT_AUTOCONF; in early_mcf_setup()
508 port->rs485_config = mcf_config_rs485; in early_mcf_setup()
509 port->rs485_supported = mcf_rs485_supported; in early_mcf_setup()
510 port->ops = &mcf_uart_ops; in early_mcf_setup()
520 struct uart_port *port = &(mcf_ports + co->index)->port; in mcf_console_putc() local
524 if (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY) in mcf_console_putc()
527 writeb(c, port->membase + MCFUART_UTB); in mcf_console_putc()
529 if (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY) in mcf_console_putc()
549 struct uart_port *port; in mcf_console_setup() local
557 port = &mcf_ports[co->index].port; in mcf_console_setup()
558 if (port->membase == 0) in mcf_console_setup()
564 return uart_set_options(port, co, baud, parity, bits, flow); in mcf_console_setup()
619 struct uart_port *port; in mcf_probe() local
623 port = &mcf_ports[i].port; in mcf_probe()
625 port->line = i; in mcf_probe()
626 port->type = PORT_MCF; in mcf_probe()
627 port->mapbase = platp[i].mapbase; in mcf_probe()
628 port->membase = (platp[i].membase) ? platp[i].membase : in mcf_probe()
630 port->dev = &pdev->dev; in mcf_probe()
631 port->iotype = SERIAL_IO_MEM; in mcf_probe()
632 port->irq = platp[i].irq; in mcf_probe()
633 port->uartclk = MCF_BUSCLK; in mcf_probe()
634 port->ops = &mcf_uart_ops; in mcf_probe()
635 port->flags = UPF_BOOT_AUTOCONF; in mcf_probe()
636 port->rs485_config = mcf_config_rs485; in mcf_probe()
637 port->rs485_supported = mcf_rs485_supported; in mcf_probe()
638 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MCF_CONSOLE); in mcf_probe()
640 uart_add_one_port(&mcf_driver, port); in mcf_probe()
650 struct uart_port *port; in mcf_remove() local
654 port = &mcf_ports[i].port; in mcf_remove()
655 if (port) in mcf_remove()
656 uart_remove_one_port(&mcf_driver, port); in mcf_remove()