void uart_init(unsigned uart, unsigned baud) { unsigned divisor; uart_base = (void *)(0xb0030000 + (uart * 0x1000)); uart_baud = baud; divisor = (uart_clk + (uart_baud * (16 / 2))) / (16 * uart_baud); if (configure_uart_clock_and_pinmux(uart)) return; /* No Uart support is possible */ while (!(read_lsr() & LSR_TEMT)); write_ier(0); write_lcr(LCR_BKSE | LCR_8N1); write_dll(0); write_dlm(0); write_lcr(LCR_8N1); write_mcr(MCR_DTR | MCR_RTS); write_fcr(FCR_FIFO_EN | FCR_RXSR | FCR_TXSR | FCR_UME); write_lcr(LCR_BKSE | LCR_8N1); write_dll(divisor & 0xff); write_dlm((divisor >> 8) & 0xff); write_lcr(LCR_8N1); }
static void reset_mcr() { write_mcr(MCR_DTR | MCR_RTS | MCR_AO1 | MCR_AO2); }