Lines Matching +full:port +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for the serial port on the 21285 StrongArm-110 core logic chip.
19 #include <asm/mach-types.h>
31 #define RXSTAT_FRAME (1 << 0)
32 #define RXSTAT_PARITY (1 << 1)
33 #define RXSTAT_OVERRUN (1 << 2)
36 #define H_UBRLCR_BREAK (1 << 0)
37 #define H_UBRLCR_PARENB (1 << 1)
38 #define H_UBRLCR_PAREVN (1 << 2)
39 #define H_UBRLCR_STOPB (1 << 3)
40 #define H_UBRLCR_FIFO (1 << 4)
46 * this, use bits of the private_data pointer of the uart port structure.
49 #define rx_enabled_bit 1
51 static bool is_enabled(struct uart_port *port, int bit) in is_enabled() argument
53 unsigned long *private_data = (unsigned long *)&port->private_data; in is_enabled()
60 static void enable(struct uart_port *port, int bit) in enable() argument
62 unsigned long *private_data = (unsigned long *)&port->private_data; in enable()
67 static void disable(struct uart_port *port, int bit) in disable() argument
69 unsigned long *private_data = (unsigned long *)&port->private_data; in disable()
74 #define is_tx_enabled(port) is_enabled(port, tx_enabled_bit) argument
75 #define tx_enable(port) enable(port, tx_enabled_bit) argument
76 #define tx_disable(port) disable(port, tx_enabled_bit) argument
78 #define is_rx_enabled(port) is_enabled(port, rx_enabled_bit) argument
79 #define rx_enable(port) enable(port, rx_enabled_bit) argument
80 #define rx_disable(port) disable(port, rx_enabled_bit) argument
84 * BAUD_BASE / baud - 1
88 * int(BAUD_BASE / baud - 0.5) ->
89 * int(BAUD_BASE / baud - (baud >> 1) / baud) ->
90 * int((BAUD_BASE - (baud >> 1)) / baud)
93 static void serial21285_stop_tx(struct uart_port *port) in serial21285_stop_tx() argument
95 if (is_tx_enabled(port)) { in serial21285_stop_tx()
97 tx_disable(port); in serial21285_stop_tx()
101 static void serial21285_start_tx(struct uart_port *port) in serial21285_start_tx() argument
103 if (!is_tx_enabled(port)) { in serial21285_start_tx()
105 tx_enable(port); in serial21285_start_tx()
109 static void serial21285_stop_rx(struct uart_port *port) in serial21285_stop_rx() argument
111 if (is_rx_enabled(port)) { in serial21285_stop_rx()
113 rx_disable(port); in serial21285_stop_rx()
119 struct uart_port *port = dev_id; in serial21285_rx_chars() local
123 while (!(status & 0x10) && max_count--) { in serial21285_rx_chars()
126 port->icount.rx++; in serial21285_rx_chars()
131 port->icount.parity++; in serial21285_rx_chars()
133 port->icount.frame++; in serial21285_rx_chars()
135 port->icount.overrun++; in serial21285_rx_chars()
137 rxs &= port->read_status_mask; in serial21285_rx_chars()
145 uart_insert_char(port, rxs, RXSTAT_OVERRUN, ch, flag); in serial21285_rx_chars()
149 tty_flip_buffer_push(&port->state->port); in serial21285_rx_chars()
156 struct uart_port *port = dev_id; in serial21285_tx_chars() local
157 struct circ_buf *xmit = &port->state->xmit; in serial21285_tx_chars()
160 if (port->x_char) { in serial21285_tx_chars()
161 *CSR_UARTDR = port->x_char; in serial21285_tx_chars()
162 port->icount.tx++; in serial21285_tx_chars()
163 port->x_char = 0; in serial21285_tx_chars()
166 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { in serial21285_tx_chars()
167 serial21285_stop_tx(port); in serial21285_tx_chars()
172 *CSR_UARTDR = xmit->buf[xmit->tail]; in serial21285_tx_chars()
173 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in serial21285_tx_chars()
174 port->icount.tx++; in serial21285_tx_chars()
177 } while (--count > 0 && !(*CSR_UARTFLG & 0x20)); in serial21285_tx_chars()
180 uart_write_wakeup(port); in serial21285_tx_chars()
183 serial21285_stop_tx(port); in serial21285_tx_chars()
189 static unsigned int serial21285_tx_empty(struct uart_port *port) in serial21285_tx_empty() argument
195 static unsigned int serial21285_get_mctrl(struct uart_port *port) in serial21285_get_mctrl() argument
200 static void serial21285_set_mctrl(struct uart_port *port, unsigned int mctrl) in serial21285_set_mctrl() argument
204 static void serial21285_break_ctl(struct uart_port *port, int break_state) in serial21285_break_ctl() argument
209 spin_lock_irqsave(&port->lock, flags); in serial21285_break_ctl()
216 spin_unlock_irqrestore(&port->lock, flags); in serial21285_break_ctl()
219 static int serial21285_startup(struct uart_port *port) in serial21285_startup() argument
223 tx_enable(port); in serial21285_startup()
224 rx_enable(port); in serial21285_startup()
227 serial21285_name, port); in serial21285_startup()
230 serial21285_name, port); in serial21285_startup()
232 free_irq(IRQ_CONRX, port); in serial21285_startup()
238 static void serial21285_shutdown(struct uart_port *port) in serial21285_shutdown() argument
240 free_irq(IRQ_CONTX, port); in serial21285_shutdown()
241 free_irq(IRQ_CONRX, port); in serial21285_shutdown()
245 serial21285_set_termios(struct uart_port *port, struct ktermios *termios, in serial21285_set_termios() argument
254 termios->c_cflag &= ~(HUPCL | CRTSCTS | CMSPAR); in serial21285_set_termios()
255 termios->c_cflag |= CLOCAL; in serial21285_set_termios()
260 termios->c_iflag &= ~(IGNBRK | BRKINT); in serial21285_set_termios()
265 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in serial21285_set_termios()
266 quot = uart_get_divisor(port, baud); in serial21285_set_termios()
267 b = port->uartclk / (16 * quot); in serial21285_set_termios()
270 switch (termios->c_cflag & CSIZE) { in serial21285_set_termios()
285 if (termios->c_cflag & CSTOPB) in serial21285_set_termios()
287 if (termios->c_cflag & PARENB) { in serial21285_set_termios()
289 if (!(termios->c_cflag & PARODD)) in serial21285_set_termios()
293 if (port->fifosize) in serial21285_set_termios()
296 spin_lock_irqsave(&port->lock, flags); in serial21285_set_termios()
299 * Update the per-port timeout. in serial21285_set_termios()
301 uart_update_timeout(port, termios->c_cflag, baud); in serial21285_set_termios()
306 port->read_status_mask = RXSTAT_OVERRUN; in serial21285_set_termios()
307 if (termios->c_iflag & INPCK) in serial21285_set_termios()
308 port->read_status_mask |= RXSTAT_FRAME | RXSTAT_PARITY; in serial21285_set_termios()
313 port->ignore_status_mask = 0; in serial21285_set_termios()
314 if (termios->c_iflag & IGNPAR) in serial21285_set_termios()
315 port->ignore_status_mask |= RXSTAT_FRAME | RXSTAT_PARITY; in serial21285_set_termios()
316 if (termios->c_iflag & IGNBRK && termios->c_iflag & IGNPAR) in serial21285_set_termios()
317 port->ignore_status_mask |= RXSTAT_OVERRUN; in serial21285_set_termios()
322 if ((termios->c_cflag & CREAD) == 0) in serial21285_set_termios()
323 port->ignore_status_mask |= RXSTAT_DUMMY_READ; in serial21285_set_termios()
325 quot -= 1; in serial21285_set_termios()
331 *CSR_UARTCON = 1; in serial21285_set_termios()
333 spin_unlock_irqrestore(&port->lock, flags); in serial21285_set_termios()
336 static const char *serial21285_type(struct uart_port *port) in serial21285_type() argument
338 return port->type == PORT_21285 ? "DC21285" : NULL; in serial21285_type()
341 static void serial21285_release_port(struct uart_port *port) in serial21285_release_port() argument
343 release_mem_region(port->mapbase, 32); in serial21285_release_port()
346 static int serial21285_request_port(struct uart_port *port) in serial21285_request_port() argument
348 return request_mem_region(port->mapbase, 32, serial21285_name) in serial21285_request_port()
349 != NULL ? 0 : -EBUSY; in serial21285_request_port()
352 static void serial21285_config_port(struct uart_port *port, int flags) in serial21285_config_port() argument
354 if (flags & UART_CONFIG_TYPE && serial21285_request_port(port) == 0) in serial21285_config_port()
355 port->type = PORT_21285; in serial21285_config_port()
361 static int serial21285_verify_port(struct uart_port *port, struct serial_struct *ser) in serial21285_verify_port() argument
364 if (ser->type != PORT_UNKNOWN && ser->type != PORT_21285) in serial21285_verify_port()
365 ret = -EINVAL; in serial21285_verify_port()
366 if (ser->irq <= 0) in serial21285_verify_port()
367 ret = -EINVAL; in serial21285_verify_port()
368 if (ser->baud_base != port->uartclk / 16) in serial21285_verify_port()
369 ret = -EINVAL; in serial21285_verify_port()
406 static void serial21285_console_putchar(struct uart_port *port, int ch) in serial21285_console_putchar() argument
421 serial21285_get_options(struct uart_port *port, int *baud, in serial21285_get_options() argument
424 if (*CSR_UARTCON == 1) { in serial21285_get_options()
452 *baud = port->uartclk / (16 * (tmp + 1)); in serial21285_get_options()
458 struct uart_port *port = &serial21285_port; in serial21285_console_setup() local
469 * if so, search for the first available port that does have in serial21285_console_setup()
475 serial21285_get_options(port, &baud, &parity, &bits); in serial21285_console_setup()
477 return uart_set_options(port, co, baud, parity, bits, flow); in serial21285_console_setup()
489 .index = -1,
512 .nr = 1,