uart/sifive: make divisor configurable
The SiFive UART on the HiFive Unleashed uses the tlclk as input clock which runs at coreclk / 2. The input frequency is configured in the board code depending on the current stage. (bootblock + romstage run at 33.33Mhz, ramstage at 1Ghz) Change-Id: Iaf66723dba3d308f809fde5b05dfc3e43f43bd42 Signed-off-by: Philipp Hug <philipp@hug.cx> Reviewed-on: https://review.coreboot.org/27440 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
This commit is contained in:
committed by
Ronald G. Minnich
parent
3e51d53064
commit
7524400242
@@ -46,11 +46,10 @@ struct sifive_uart_registers {
|
|||||||
#define IP_TXWM BIT(0)
|
#define IP_TXWM BIT(0)
|
||||||
#define IP_RXWM BIT(1)
|
#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);
|
/* Configure the divisor */
|
||||||
|
write32(®s->div, div);
|
||||||
/* TODO: Configure the divisor */
|
|
||||||
|
|
||||||
/* Enable transmission, one stop bit, transmit watermark at 1 */
|
/* Enable transmission, one stop bit, transmit watermark at 1 */
|
||||||
write32(®s->txctrl, TXCTRL_TXEN|TXCTRL_NSTOP(1)|TXCTRL_TXCNT(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));
|
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)
|
static bool uart_can_tx(struct sifive_uart_registers *regs)
|
||||||
{
|
{
|
||||||
return !(read32(®s->txdata) & TXDATA_FULL);
|
return !(read32(®s->txdata) & TXDATA_FULL);
|
||||||
|
@@ -20,7 +20,7 @@ config SOC_SIFIVE_FU540
|
|||||||
select ARCH_RAMSTAGE_RISCV
|
select ARCH_RAMSTAGE_RISCV
|
||||||
select BOOTBLOCK_CONSOLE
|
select BOOTBLOCK_CONSOLE
|
||||||
select DRIVERS_UART_SIFIVE
|
select DRIVERS_UART_SIFIVE
|
||||||
|
select UART_OVERRIDE_REFCLK
|
||||||
if SOC_SIFIVE_FU540
|
if SOC_SIFIVE_FU540
|
||||||
|
|
||||||
config RISCV_ARCH
|
config RISCV_ARCH
|
||||||
|
@@ -23,3 +23,11 @@ uintptr_t uart_platform_base(int idx)
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int uart_platform_refclk(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* The SiFive UART uses tlclk, which is coreclk/2 as input
|
||||||
|
*/
|
||||||
|
return 33330000 / 2;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user