diff options
Diffstat (limited to 'src/drivers/uart/sifive.c')
-rw-r--r-- | src/drivers/uart/sifive.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/drivers/uart/sifive.c b/src/drivers/uart/sifive.c index dd47cafcf186..ce8ead0d05fd 100644 --- a/src/drivers/uart/sifive.c +++ b/src/drivers/uart/sifive.c @@ -46,11 +46,10 @@ struct sifive_uart_registers { #define IP_TXWM BIT(0) #define IP_RXWM BIT(1) -void uart_init(int idx) +static void sifive_uart_init(struct sifive_uart_registers *regs, int div) { - struct sifive_uart_registers *regs = uart_platform_baseptr(idx); - - /* TODO: Configure the divisor */ + /* Configure the divisor */ + write32(®s->div, div); /* Enable transmission, one stop bit, transmit watermark at 1 */ write32(®s->txctrl, TXCTRL_TXEN|TXCTRL_NSTOP(1)|TXCTRL_TXCNT(1)); @@ -59,6 +58,14 @@ void uart_init(int idx) write32(®s->rxctrl, RXCTRL_RXEN|RXCTRL_RXCNT(0)); } +void uart_init(int idx) +{ + unsigned int div; + div = uart_baudrate_divisor(get_uart_baudrate(), + uart_platform_refclk(), uart_input_clock_divider()); + sifive_uart_init(uart_platform_baseptr(idx), div); +} + static bool uart_can_tx(struct sifive_uart_registers *regs) { return !(read32(®s->txdata) & TXDATA_FULL); |