Lines Matching refs:port

24 static inline void write_uart_reg(int port, uint reg, unsigned char data) {  in write_uart_reg()  argument
25 *(volatile unsigned char *)(uart[port].base + (reg << uart[port].shift)) = data; in write_uart_reg()
28 static inline unsigned char read_uart_reg(int port, uint reg) { in read_uart_reg() argument
29 return *(volatile unsigned char *)(uart[port].base + (reg << uart[port].shift)); in read_uart_reg()
102 void uart_init_port(int port, uint baud) { in uart_init_port() argument
104 uint16_t baud_divisor = (uart[port].clk_freq / 16 / baud); in uart_init_port()
106 write_uart_reg(port, UART_IER, 0); in uart_init_port()
107 write_uart_reg(port, UART_LCR, LCR_BKSE | LCRVAL); // config mode A in uart_init_port()
108 write_uart_reg(port, UART_DLL, baud_divisor & 0xff); in uart_init_port()
109 write_uart_reg(port, UART_DLH, (baud_divisor >> 8) & 0xff); in uart_init_port()
110 write_uart_reg(port, UART_LCR, LCRVAL); // operational mode in uart_init_port()
111 write_uart_reg(port, UART_MCR, MCRVAL); in uart_init_port()
112 write_uart_reg(port, UART_FCR, FCRVAL); in uart_init_port()
122 int uart_putc(int port, char c ) { in uart_putc() argument
123 while (!(read_uart_reg(port, UART_LSR) & (1<<6))) // wait for the last char to get out in uart_putc()
125 write_uart_reg(port, UART_THR, c); in uart_putc()
129 int uart_getc(int port, bool wait) { /* returns -1 if no data available */ in uart_getc() argument
131 while (!(read_uart_reg(port, UART_LSR) & (1<<0))) // wait for data to show up in the rx fifo in uart_getc()
134 if (!(read_uart_reg(port, UART_LSR) & (1<<0))) in uart_getc()
137 return read_uart_reg(port, UART_RHR); in uart_getc()
140 void uart_flush_tx(int port) { in uart_flush_tx() argument
141 while (!(read_uart_reg(port, UART_LSR) & (1<<6))) // wait for the last char to get out in uart_flush_tx()
145 void uart_flush_rx(int port) { in uart_flush_rx() argument
147 while (read_uart_reg(port, UART_LSR) & (1<<0)) { in uart_flush_rx()
148 volatile char c = read_uart_reg(port, UART_RHR); in uart_flush_rx()