Lines Matching full:port

65 static void mlb_usio_stop_tx(struct uart_port *port)  in mlb_usio_stop_tx()  argument
67 writew(readw(port->membase + MLB_USIO_REG_FCR) & ~MLB_USIO_FCR_FTIE, in mlb_usio_stop_tx()
68 port->membase + MLB_USIO_REG_FCR); in mlb_usio_stop_tx()
69 writeb(readb(port->membase + MLB_USIO_REG_SCR) & ~MLB_USIO_SCR_TBIE, in mlb_usio_stop_tx()
70 port->membase + MLB_USIO_REG_SCR); in mlb_usio_stop_tx()
73 static void mlb_usio_tx_chars(struct uart_port *port) in mlb_usio_tx_chars() argument
75 struct tty_port *tport = &port->state->port; in mlb_usio_tx_chars()
78 writew(readw(port->membase + MLB_USIO_REG_FCR) & ~MLB_USIO_FCR_FTIE, in mlb_usio_tx_chars()
79 port->membase + MLB_USIO_REG_FCR); in mlb_usio_tx_chars()
80 writeb(readb(port->membase + MLB_USIO_REG_SCR) & in mlb_usio_tx_chars()
82 port->membase + MLB_USIO_REG_SCR); in mlb_usio_tx_chars()
84 if (port->x_char) { in mlb_usio_tx_chars()
85 writew(port->x_char, port->membase + MLB_USIO_REG_DR); in mlb_usio_tx_chars()
86 port->icount.tx++; in mlb_usio_tx_chars()
87 port->x_char = 0; in mlb_usio_tx_chars()
90 if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) { in mlb_usio_tx_chars()
91 mlb_usio_stop_tx(port); in mlb_usio_tx_chars()
95 count = port->fifosize - in mlb_usio_tx_chars()
96 (readw(port->membase + MLB_USIO_REG_FBYTE) & 0xff); in mlb_usio_tx_chars()
101 if (!uart_fifo_get(port, &ch)) in mlb_usio_tx_chars()
104 writew(ch, port->membase + MLB_USIO_REG_DR); in mlb_usio_tx_chars()
105 port->icount.tx++; in mlb_usio_tx_chars()
108 writew(readw(port->membase + MLB_USIO_REG_FCR) & ~MLB_USIO_FCR_FDRQ, in mlb_usio_tx_chars()
109 port->membase + MLB_USIO_REG_FCR); in mlb_usio_tx_chars()
111 writeb(readb(port->membase + MLB_USIO_REG_SCR) | MLB_USIO_SCR_TBIE, in mlb_usio_tx_chars()
112 port->membase + MLB_USIO_REG_SCR); in mlb_usio_tx_chars()
115 uart_write_wakeup(port); in mlb_usio_tx_chars()
118 mlb_usio_stop_tx(port); in mlb_usio_tx_chars()
121 static void mlb_usio_start_tx(struct uart_port *port) in mlb_usio_start_tx() argument
123 u16 fcr = readw(port->membase + MLB_USIO_REG_FCR); in mlb_usio_start_tx()
125 writew(fcr | MLB_USIO_FCR_FTIE, port->membase + MLB_USIO_REG_FCR); in mlb_usio_start_tx()
129 writeb(readb(port->membase + MLB_USIO_REG_SCR) | MLB_USIO_SCR_TBIE, in mlb_usio_start_tx()
130 port->membase + MLB_USIO_REG_SCR); in mlb_usio_start_tx()
132 if (readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TBI) in mlb_usio_start_tx()
133 mlb_usio_tx_chars(port); in mlb_usio_start_tx()
136 static void mlb_usio_stop_rx(struct uart_port *port) in mlb_usio_stop_rx() argument
138 writeb(readb(port->membase + MLB_USIO_REG_SCR) & ~MLB_USIO_SCR_RIE, in mlb_usio_stop_rx()
139 port->membase + MLB_USIO_REG_SCR); in mlb_usio_stop_rx()
142 static void mlb_usio_enable_ms(struct uart_port *port) in mlb_usio_enable_ms() argument
144 writeb(readb(port->membase + MLB_USIO_REG_SCR) | in mlb_usio_enable_ms()
146 port->membase + MLB_USIO_REG_SCR); in mlb_usio_enable_ms()
149 static void mlb_usio_rx_chars(struct uart_port *port) in mlb_usio_rx_chars() argument
151 struct tty_port *ttyport = &port->state->port; in mlb_usio_rx_chars()
157 status = readb(port->membase + MLB_USIO_REG_SSR); in mlb_usio_rx_chars()
164 ch = readw(port->membase + MLB_USIO_REG_DR); in mlb_usio_rx_chars()
166 port->icount.rx++; in mlb_usio_rx_chars()
167 if (uart_handle_sysrq_char(port, ch)) in mlb_usio_rx_chars()
169 uart_insert_char(port, status, MLB_USIO_SSR_ORE, in mlb_usio_rx_chars()
174 port->icount.parity++; in mlb_usio_rx_chars()
176 port->icount.overrun++; in mlb_usio_rx_chars()
177 status &= port->read_status_mask; in mlb_usio_rx_chars()
191 uart_insert_char(port, status, MLB_USIO_SSR_ORE, in mlb_usio_rx_chars()
194 writeb(readb(port->membase + MLB_USIO_REG_SSR) | in mlb_usio_rx_chars()
196 port->membase + MLB_USIO_REG_SSR); in mlb_usio_rx_chars()
198 max_count = readw(port->membase + MLB_USIO_REG_FBYTE) >> 8; in mlb_usio_rx_chars()
199 writew(readw(port->membase + MLB_USIO_REG_FCR) | in mlb_usio_rx_chars()
201 port->membase + MLB_USIO_REG_FCR); in mlb_usio_rx_chars()
209 struct uart_port *port = dev_id; in mlb_usio_rx_irq() local
211 uart_port_lock(port); in mlb_usio_rx_irq()
212 mlb_usio_rx_chars(port); in mlb_usio_rx_irq()
213 uart_port_unlock(port); in mlb_usio_rx_irq()
220 struct uart_port *port = dev_id; in mlb_usio_tx_irq() local
222 uart_port_lock(port); in mlb_usio_tx_irq()
223 if (readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TBI) in mlb_usio_tx_irq()
224 mlb_usio_tx_chars(port); in mlb_usio_tx_irq()
225 uart_port_unlock(port); in mlb_usio_tx_irq()
230 static unsigned int mlb_usio_tx_empty(struct uart_port *port) in mlb_usio_tx_empty() argument
232 return (readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TBI) ? in mlb_usio_tx_empty()
236 static void mlb_usio_set_mctrl(struct uart_port *port, unsigned int mctrl) in mlb_usio_set_mctrl() argument
240 static unsigned int mlb_usio_get_mctrl(struct uart_port *port) in mlb_usio_get_mctrl() argument
246 static void mlb_usio_break_ctl(struct uart_port *port, int break_state) in mlb_usio_break_ctl() argument
250 static int mlb_usio_startup(struct uart_port *port) in mlb_usio_startup() argument
252 const char *portname = to_platform_device(port->dev)->name; in mlb_usio_startup()
254 int ret, index = port->line; in mlb_usio_startup()
258 0, portname, port); in mlb_usio_startup()
262 0, portname, port); in mlb_usio_startup()
264 free_irq(mlb_usio_irq[index][RX], port); in mlb_usio_startup()
268 escr = readb(port->membase + MLB_USIO_REG_ESCR); in mlb_usio_startup()
269 if (of_property_read_bool(port->dev->of_node, "auto-flow-control")) in mlb_usio_startup()
271 uart_port_lock_irqsave(port, &flags); in mlb_usio_startup()
272 writeb(0, port->membase + MLB_USIO_REG_SCR); in mlb_usio_startup()
273 writeb(escr, port->membase + MLB_USIO_REG_ESCR); in mlb_usio_startup()
274 writeb(MLB_USIO_SCR_UPCL, port->membase + MLB_USIO_REG_SCR); in mlb_usio_startup()
275 writeb(MLB_USIO_SSR_REC, port->membase + MLB_USIO_REG_SSR); in mlb_usio_startup()
276 writew(0, port->membase + MLB_USIO_REG_FCR); in mlb_usio_startup()
278 port->membase + MLB_USIO_REG_FCR); in mlb_usio_startup()
280 port->membase + MLB_USIO_REG_FCR); in mlb_usio_startup()
281 writew(0, port->membase + MLB_USIO_REG_FBYTE); in mlb_usio_startup()
282 writew(BIT(12), port->membase + MLB_USIO_REG_FBYTE); in mlb_usio_startup()
285 MLB_USIO_SCR_RXE, port->membase + MLB_USIO_REG_SCR); in mlb_usio_startup()
286 uart_port_unlock_irqrestore(port, flags); in mlb_usio_startup()
291 static void mlb_usio_shutdown(struct uart_port *port) in mlb_usio_shutdown() argument
293 int index = port->line; in mlb_usio_shutdown()
295 free_irq(mlb_usio_irq[index][RX], port); in mlb_usio_shutdown()
296 free_irq(mlb_usio_irq[index][TX], port); in mlb_usio_shutdown()
299 static void mlb_usio_set_termios(struct uart_port *port, in mlb_usio_set_termios() argument
331 if (of_property_read_bool(port->dev->of_node, "auto-flow-control") || in mlb_usio_set_termios()
335 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk); in mlb_usio_set_termios()
337 quot = port->uartclk / baud - 1; in mlb_usio_set_termios()
341 uart_port_lock_irqsave(port, &flags); in mlb_usio_set_termios()
342 uart_update_timeout(port, termios->c_cflag, baud); in mlb_usio_set_termios()
343 port->read_status_mask = MLB_USIO_SSR_ORE | MLB_USIO_SSR_RDRF | in mlb_usio_set_termios()
346 port->read_status_mask |= MLB_USIO_SSR_FRE | MLB_USIO_SSR_PE; in mlb_usio_set_termios()
348 port->ignore_status_mask = 0; in mlb_usio_set_termios()
350 port->ignore_status_mask |= MLB_USIO_SSR_FRE | MLB_USIO_SSR_PE; in mlb_usio_set_termios()
352 port->ignore_status_mask |= MLB_USIO_SSR_ORE; in mlb_usio_set_termios()
354 port->ignore_status_mask |= MLB_USIO_SSR_RDRF; in mlb_usio_set_termios()
356 writeb(0, port->membase + MLB_USIO_REG_SCR); in mlb_usio_set_termios()
357 writeb(MLB_USIO_SCR_UPCL, port->membase + MLB_USIO_REG_SCR); in mlb_usio_set_termios()
358 writeb(MLB_USIO_SSR_REC, port->membase + MLB_USIO_REG_SSR); in mlb_usio_set_termios()
359 writew(0, port->membase + MLB_USIO_REG_FCR); in mlb_usio_set_termios()
360 writeb(smr, port->membase + MLB_USIO_REG_SMR); in mlb_usio_set_termios()
361 writeb(escr, port->membase + MLB_USIO_REG_ESCR); in mlb_usio_set_termios()
362 writew(quot, port->membase + MLB_USIO_REG_BGR); in mlb_usio_set_termios()
363 writew(0, port->membase + MLB_USIO_REG_FCR); in mlb_usio_set_termios()
366 port->membase + MLB_USIO_REG_FCR); in mlb_usio_set_termios()
367 writew(0, port->membase + MLB_USIO_REG_FBYTE); in mlb_usio_set_termios()
368 writew(BIT(12), port->membase + MLB_USIO_REG_FBYTE); in mlb_usio_set_termios()
370 MLB_USIO_SCR_TXE, port->membase + MLB_USIO_REG_SCR); in mlb_usio_set_termios()
371 uart_port_unlock_irqrestore(port, flags); in mlb_usio_set_termios()
374 static const char *mlb_usio_type(struct uart_port *port) in mlb_usio_type() argument
376 return ((port->type == PORT_MLB_USIO) ? USIO_NAME : NULL); in mlb_usio_type()
379 static void mlb_usio_config_port(struct uart_port *port, int flags) in mlb_usio_config_port() argument
382 port->type = PORT_MLB_USIO; in mlb_usio_config_port()
403 static void mlb_usio_console_putchar(struct uart_port *port, unsigned char c) in mlb_usio_console_putchar() argument
405 while (!(readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TDRE)) in mlb_usio_console_putchar()
408 writew(c, port->membase + MLB_USIO_REG_DR); in mlb_usio_console_putchar()
414 struct uart_port *port = &mlb_usio_ports[co->index]; in mlb_usio_console_write() local
416 uart_console_write(port, s, count, mlb_usio_console_putchar); in mlb_usio_console_write()
421 struct uart_port *port; in mlb_usio_console_setup() local
430 port = &mlb_usio_ports[co->index]; in mlb_usio_console_setup()
431 if (!port->membase) in mlb_usio_console_setup()
438 if (of_property_read_bool(port->dev->of_node, "auto-flow-control")) in mlb_usio_console_setup()
441 return uart_set_options(port, co, baud, parity, bits, flow); in mlb_usio_console_setup()
469 uart_console_write(&dev->port, s, count, mlb_usio_console_putchar); in mlb_usio_early_console_write()
475 if (!device->port.membase) in mlb_usio_early_console_setup()
500 struct uart_port *port; in mlb_usio_probe() local
515 port = &mlb_usio_ports[index]; in mlb_usio_probe()
517 port->private_data = (void *)clk; in mlb_usio_probe()
524 port->membase = devm_ioremap(&pdev->dev, res->start, in mlb_usio_probe()
533 port->irq = mlb_usio_irq[index][RX]; in mlb_usio_probe()
534 port->uartclk = clk_get_rate(clk); in mlb_usio_probe()
535 port->fifosize = 128; in mlb_usio_probe()
536 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE); in mlb_usio_probe()
537 port->iotype = UPIO_MEM32; in mlb_usio_probe()
538 port->flags = UPF_BOOT_AUTOCONF | UPF_SPD_VHI; in mlb_usio_probe()
539 port->line = index; in mlb_usio_probe()
540 port->ops = &mlb_usio_ops; in mlb_usio_probe()
541 port->dev = &pdev->dev; in mlb_usio_probe()
543 ret = uart_add_one_port(&mlb_usio_uart_driver, port); in mlb_usio_probe()
545 dev_err(&pdev->dev, "Adding port failed: %d\n", ret); in mlb_usio_probe()
558 struct uart_port *port = &mlb_usio_ports[pdev->id]; in mlb_usio_remove() local
559 struct clk *clk = port->private_data; in mlb_usio_remove()
561 uart_remove_one_port(&mlb_usio_uart_driver, port); in mlb_usio_remove()