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
124 while (!(status & 0x10) && max_count--) { in serial21285_rx_chars()
127 port->icount.rx++; in serial21285_rx_chars()
132 port->icount.parity++; in serial21285_rx_chars()
134 port->icount.frame++; in serial21285_rx_chars()
136 port->icount.overrun++; in serial21285_rx_chars()
138 rxs &= port->read_status_mask; in serial21285_rx_chars()
146 uart_insert_char(port, rxs, RXSTAT_OVERRUN, ch, flag); in serial21285_rx_chars()
150 tty_flip_buffer_push(&port->state->port); in serial21285_rx_chars()
157 struct uart_port *port = dev_id; in serial21285_tx_chars() local
160 uart_port_tx_limited(port, ch, 256, in serial21285_tx_chars()
168 static unsigned int serial21285_tx_empty(struct uart_port *port) in serial21285_tx_empty() argument
174 static unsigned int serial21285_get_mctrl(struct uart_port *port) in serial21285_get_mctrl() argument
179 static void serial21285_set_mctrl(struct uart_port *port, unsigned int mctrl) in serial21285_set_mctrl() argument
183 static void serial21285_break_ctl(struct uart_port *port, int break_state) in serial21285_break_ctl() argument
188 uart_port_lock_irqsave(port, &flags); in serial21285_break_ctl()
195 uart_port_unlock_irqrestore(port, flags); in serial21285_break_ctl()
198 static int serial21285_startup(struct uart_port *port) in serial21285_startup() argument
202 tx_enable(port); in serial21285_startup()
203 rx_enable(port); in serial21285_startup()
206 serial21285_name, port); in serial21285_startup()
209 serial21285_name, port); in serial21285_startup()
211 free_irq(IRQ_CONRX, port); in serial21285_startup()
217 static void serial21285_shutdown(struct uart_port *port) in serial21285_shutdown() argument
219 free_irq(IRQ_CONTX, port); in serial21285_shutdown()
220 free_irq(IRQ_CONRX, port); in serial21285_shutdown()
224 serial21285_set_termios(struct uart_port *port, struct ktermios *termios, in serial21285_set_termios() argument
233 termios->c_cflag &= ~(HUPCL | CRTSCTS | CMSPAR); in serial21285_set_termios()
234 termios->c_cflag |= CLOCAL; in serial21285_set_termios()
239 termios->c_iflag &= ~(IGNBRK | BRKINT); in serial21285_set_termios()
244 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in serial21285_set_termios()
245 quot = uart_get_divisor(port, baud); in serial21285_set_termios()
246 b = port->uartclk / (16 * quot); in serial21285_set_termios()
249 switch (termios->c_cflag & CSIZE) { in serial21285_set_termios()
264 if (termios->c_cflag & CSTOPB) in serial21285_set_termios()
266 if (termios->c_cflag & PARENB) { in serial21285_set_termios()
268 if (!(termios->c_cflag & PARODD)) in serial21285_set_termios()
272 if (port->fifosize) in serial21285_set_termios()
275 uart_port_lock_irqsave(port, &flags); in serial21285_set_termios()
278 * Update the per-port timeout. in serial21285_set_termios()
280 uart_update_timeout(port, termios->c_cflag, baud); in serial21285_set_termios()
285 port->read_status_mask = RXSTAT_OVERRUN; in serial21285_set_termios()
286 if (termios->c_iflag & INPCK) in serial21285_set_termios()
287 port->read_status_mask |= RXSTAT_FRAME | RXSTAT_PARITY; in serial21285_set_termios()
292 port->ignore_status_mask = 0; in serial21285_set_termios()
293 if (termios->c_iflag & IGNPAR) in serial21285_set_termios()
294 port->ignore_status_mask |= RXSTAT_FRAME | RXSTAT_PARITY; in serial21285_set_termios()
295 if (termios->c_iflag & IGNBRK && termios->c_iflag & IGNPAR) in serial21285_set_termios()
296 port->ignore_status_mask |= RXSTAT_OVERRUN; in serial21285_set_termios()
301 if ((termios->c_cflag & CREAD) == 0) in serial21285_set_termios()
302 port->ignore_status_mask |= RXSTAT_DUMMY_READ; in serial21285_set_termios()
304 quot -= 1; in serial21285_set_termios()
310 *CSR_UARTCON = 1; in serial21285_set_termios()
312 uart_port_unlock_irqrestore(port, flags); in serial21285_set_termios()
315 static const char *serial21285_type(struct uart_port *port) in serial21285_type() argument
317 return port->type == PORT_21285 ? "DC21285" : NULL; in serial21285_type()
320 static void serial21285_release_port(struct uart_port *port) in serial21285_release_port() argument
322 release_mem_region(port->mapbase, 32); in serial21285_release_port()
325 static int serial21285_request_port(struct uart_port *port) in serial21285_request_port() argument
327 return request_mem_region(port->mapbase, 32, serial21285_name) in serial21285_request_port()
328 != NULL ? 0 : -EBUSY; in serial21285_request_port()
331 static void serial21285_config_port(struct uart_port *port, int flags) in serial21285_config_port() argument
333 if (flags & UART_CONFIG_TYPE && serial21285_request_port(port) == 0) in serial21285_config_port()
334 port->type = PORT_21285; in serial21285_config_port()
340 static int serial21285_verify_port(struct uart_port *port, struct serial_struct *ser) in serial21285_verify_port() argument
343 if (ser->type != PORT_UNKNOWN && ser->type != PORT_21285) in serial21285_verify_port()
344 ret = -EINVAL; in serial21285_verify_port()
345 if (ser->irq <= 0) in serial21285_verify_port()
346 ret = -EINVAL; in serial21285_verify_port()
347 if (ser->baud_base != port->uartclk / 16) in serial21285_verify_port()
348 ret = -EINVAL; in serial21285_verify_port()
385 static void serial21285_console_putchar(struct uart_port *port, unsigned char ch) in serial21285_console_putchar() argument
400 serial21285_get_options(struct uart_port *port, int *baud, in serial21285_get_options() argument
403 if (*CSR_UARTCON == 1) { in serial21285_get_options()
431 *baud = port->uartclk / (16 * (tmp + 1)); in serial21285_get_options()
437 struct uart_port *port = &serial21285_port; in serial21285_console_setup() local
445 * if so, search for the first available port that does have in serial21285_console_setup()
451 serial21285_get_options(port, &baud, &parity, &bits); in serial21285_console_setup()
453 return uart_set_options(port, co, baud, parity, bits, flow); in serial21285_console_setup()
465 .index = -1,
488 .nr = 1,