static void ambauart_break_ctl(struct uart_port *port, int break_state) { unsigned int lcr_h; lcr_h = UART_GET_LCRH(port); if (break_state == -1) lcr_h |= AMBA_UARTLCR_H_BRK; else lcr_h &= ~AMBA_UARTLCR_H_BRK; UART_PUT_LCRH(port, lcr_h); }
static void pl010_break_ctl(struct uart_port *port, int break_state) { unsigned long flags; unsigned int lcr_h; spin_lock_irqsave(&port->lock, flags); lcr_h = UART_GET_LCRH(port); if (break_state == -1) lcr_h |= UART01x_LCRH_BRK; else lcr_h &= ~UART01x_LCRH_BRK; UART_PUT_LCRH(port, lcr_h); spin_unlock_irqrestore(&port->lock, flags); }
static void pl010_shutdown(struct uart_port *port) { /* * Free the interrupt */ free_irq(port->irq, port); /* * disable all interrupts, disable the port */ UART_PUT_CR(port, 0); /* disable break condition and fifos */ UART_PUT_LCRH(port, UART_GET_LCRH(port) & ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN)); }
static void ambauart_shutdown(struct uart_port *port, struct uart_info *info) { /* * Free the interrupt */ free_irq(port->irq, info); /* * disable all interrupts, disable the port */ UART_PUT_CR(port, 0); /* disable break condition and fifos */ UART_PUT_LCRH(port, UART_GET_LCRH(port) & ~(AMBA_UARTLCR_H_BRK | AMBA_UARTLCR_H_FEN)); }
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); }