static void __init pl010_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits) { if (UART_GET_CR(port) & UART01x_CR_UARTEN) { unsigned int lcr_h, quot; lcr_h = UART_GET_LCRH(port); *parity = 'n'; if (lcr_h & UART01x_LCRH_PEN) { if (lcr_h & UART01x_LCRH_EPS) *parity = 'e'; else *parity = 'o'; } if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7) *bits = 7; else *bits = 8; quot = UART_GET_LCRL(port) | UART_GET_LCRM(port) << 8; *baud = port->uartclk / (16 * (quot + 1)); } }
static void pl010_enable_ms(struct uart_port *port) { unsigned int cr; cr = UART_GET_CR(port); cr |= UART010_CR_MSIE; UART_PUT_CR(port, cr); }
static void pl010_start_tx(struct uart_port *port) { unsigned int cr; cr = UART_GET_CR(port); cr |= UART010_CR_TIE; UART_PUT_CR(port, cr); }
static void pl010_stop_rx(struct uart_port *port) { unsigned int cr; cr = UART_GET_CR(port); cr &= ~(UART010_CR_RIE | UART010_CR_RTIE); UART_PUT_CR(port, cr); }
static void ambauart_enable_ms(struct uart_port *port) { unsigned int cr; cr = UART_GET_CR(port); cr |= AMBA_UARTCR_MSIE; UART_PUT_CR(port, cr); }
static void ambauart_stop_rx(struct uart_port *port) { unsigned int cr; cr = UART_GET_CR(port); cr &= ~(AMBA_UARTCR_RIE | AMBA_UARTCR_RTIE); UART_PUT_CR(port, cr); }
static void ambauart_stop_tx(struct uart_port *port, u_int from_tty) { unsigned int cr; cr = UART_GET_CR(port); cr &= ~AMBA_UARTCR_TIE; UART_PUT_CR(port, cr); }
static void pl010_stop_tx(struct uart_port *port, unsigned int tty_stop) { unsigned int cr; cr = UART_GET_CR(port); cr &= ~UART010_CR_TIE; UART_PUT_CR(port, cr); }
static void ambauart_start_tx(struct uart_port *port, unsigned int tty_start) { unsigned int cr; cr = UART_GET_CR(port); cr |= AMBA_UARTCR_TIE; UART_PUT_CR(port, cr); }
static void ambauart_start_tx(struct uart_port *port, u_int nonempty, u_int from_tty) { if (nonempty) { unsigned int cr; cr = UART_GET_CR(port); cr |= AMBA_UARTCR_TIE; UART_PUT_CR(port, cr); } }
static void pl010_console_write(struct console *co, const char *s, unsigned int count) { struct uart_port *port = &amba_ports[co->index].port; unsigned int status, old_cr; int i; /* * First save the CR then disable the interrupts */ old_cr = UART_GET_CR(port); UART_PUT_CR(port, UART01x_CR_UARTEN); /* * Now, do each character */ for (i = 0; i < count; i++) { do { status = UART_GET_FR(port); } while (!UART_TX_READY(status)); UART_PUT_CHAR(port, s[i]); if (s[i] == '\n') { do { status = UART_GET_FR(port); } while (!UART_TX_READY(status)); UART_PUT_CHAR(port, '\r'); } } /* * Finally, wait for transmitter to become empty * and restore the TCR */ do { status = UART_GET_FR(port); } while (status & UART01x_FR_BUSY); UART_PUT_CR(port, old_cr); }
static void pl010_set_termios(struct uart_port *port, struct termios *termios, struct termios *old) { unsigned int lcr_h, old_cr; unsigned long flags; unsigned int baud, quot; /* * Ask the core to calculate the divisor for us. */ baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); quot = uart_get_divisor(port, baud); switch (termios->c_cflag & CSIZE) { case CS5: lcr_h = UART01x_LCRH_WLEN_5; break; case CS6: lcr_h = UART01x_LCRH_WLEN_6; break; case CS7: lcr_h = UART01x_LCRH_WLEN_7; break; default: // CS8 lcr_h = UART01x_LCRH_WLEN_8; break; } if (termios->c_cflag & CSTOPB) lcr_h |= UART01x_LCRH_STP2; if (termios->c_cflag & PARENB) { lcr_h |= UART01x_LCRH_PEN; if (!(termios->c_cflag & PARODD)) lcr_h |= UART01x_LCRH_EPS; } if (port->fifosize > 1) lcr_h |= UART01x_LCRH_FEN; spin_lock_irqsave(&port->lock, flags); /* * Update the per-port timeout. */ uart_update_timeout(port, termios->c_cflag, baud); port->read_status_mask = UART01x_RSR_OE; if (termios->c_iflag & INPCK) port->read_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE; if (termios->c_iflag & (BRKINT | PARMRK)) port->read_status_mask |= UART01x_RSR_BE; /* * Characters to ignore */ port->ignore_status_mask = 0; if (termios->c_iflag & IGNPAR) port->ignore_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE; if (termios->c_iflag & IGNBRK) { port->ignore_status_mask |= UART01x_RSR_BE; /* * If we're ignoring parity and break indicators, * ignore overruns too (for real raw support). */ if (termios->c_iflag & IGNPAR) port->ignore_status_mask |= UART01x_RSR_OE; } /* * Ignore all characters if CREAD is not set. */ if ((termios->c_cflag & CREAD) == 0) port->ignore_status_mask |= UART_DUMMY_RSR_RX; /* first, disable everything */ old_cr = UART_GET_CR(port) & ~UART010_CR_MSIE; if (UART_ENABLE_MS(port, termios->c_cflag)) old_cr |= UART010_CR_MSIE; UART_PUT_CR(port, 0); /* Set baud rate */ quot -= 1; UART_PUT_LCRM(port, ((quot & 0xf00) >> 8)); UART_PUT_LCRL(port, (quot & 0xff)); /* * ----------v----------v----------v----------v----- * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L * ----------^----------^----------^----------^----- */ UART_PUT_LCRH(port, lcr_h); UART_PUT_CR(port, old_cr); spin_unlock_irqrestore(&port->lock, flags); }
static void ambauart_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot) { u_int lcr_h, old_cr; unsigned long flags; #if DEBUG printk("ambauart_set_cflag(0x%x) called\n", cflag); #endif /* byte size and parity */ switch (cflag & CSIZE) { case CS5: lcr_h = AMBA_UARTLCR_H_WLEN_5; break; case CS6: lcr_h = AMBA_UARTLCR_H_WLEN_6; break; case CS7: lcr_h = AMBA_UARTLCR_H_WLEN_7; break; default: lcr_h = AMBA_UARTLCR_H_WLEN_8; break; // CS8 } if (cflag & CSTOPB) lcr_h |= AMBA_UARTLCR_H_STP2; if (cflag & PARENB) { lcr_h |= AMBA_UARTLCR_H_PEN; if (!(cflag & PARODD)) lcr_h |= AMBA_UARTLCR_H_EPS; } if (port->fifosize > 1) lcr_h |= AMBA_UARTLCR_H_FEN; port->read_status_mask = AMBA_UARTRSR_OE; if (iflag & INPCK) port->read_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE; if (iflag & (BRKINT | PARMRK)) port->read_status_mask |= AMBA_UARTRSR_BE; /* * Characters to ignore */ port->ignore_status_mask = 0; if (iflag & IGNPAR) port->ignore_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE; if (iflag & IGNBRK) { port->ignore_status_mask |= AMBA_UARTRSR_BE; /* * If we're ignoring parity and break indicators, * ignore overruns too (for real raw support). */ if (iflag & IGNPAR) port->ignore_status_mask |= AMBA_UARTRSR_OE; } /* * Ignore all characters if CREAD is not set. */ if ((cflag & CREAD) == 0) port->ignore_status_mask |= UART_DUMMY_RSR_RX; /* first, disable everything */ save_flags(flags); cli(); old_cr = UART_GET_CR(port) & ~AMBA_UARTCR_MSIE; if ((port->flags & ASYNC_HARDPPS_CD) || (cflag & CRTSCTS) || !(cflag & CLOCAL)) old_cr |= AMBA_UARTCR_MSIE; UART_PUT_CR(port, 0); /* Set baud rate */ quot -= 1; UART_PUT_LCRM(port, ((quot & 0xf00) >> 8)); UART_PUT_LCRL(port, (quot & 0xff)); /* * ----------v----------v----------v----------v----- * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L * ----------^----------^----------^----------^----- */ UART_PUT_LCRH(port, lcr_h); UART_PUT_CR(port, old_cr); restore_flags(flags); }