soc/cavium: Clean uart code

* Only init UART_FOR_CONSOLE
* Allow UART init with zero baudrate.
* Init UART0..3 on Cavium's cn8100_sff_evb to fix kernel panic.

Tested on CN8100_SFF_EVB.

Change-Id: I1043b30318ec6210e2dd6b7ac313a41171d37f55
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25448
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
This commit is contained in:
Patrick Rudolph 2018-03-28 12:28:02 +02:00 committed by Patrick Rudolph
parent 06c7d64be9
commit d0dcf877e4
3 changed files with 18 additions and 5 deletions

View File

@ -21,10 +21,8 @@
void bootblock_mainboard_early_init(void) void bootblock_mainboard_early_init(void)
{ {
if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) { if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) {
if (!uart_is_enabled(0)) if (!uart_is_enabled(CONFIG_UART_FOR_CONSOLE))
uart_setup(0, CONFIG_TTYS0_BAUD); uart_setup(CONFIG_UART_FOR_CONSOLE, CONFIG_TTYS0_BAUD);
if (!uart_is_enabled(1))
uart_setup(0, CONFIG_TTYS0_BAUD);
} }
} }

View File

@ -22,12 +22,19 @@
#include <soc/twsi.h> #include <soc/twsi.h>
#include <soc/gpio.h> #include <soc/gpio.h>
#include <delay.h> #include <delay.h>
#include <soc/uart.h>
extern const struct bdk_devicetree_key_value devtree[]; extern const struct bdk_devicetree_key_value devtree[];
static void mainboard_init(struct device *dev) static void mainboard_init(struct device *dev)
{ {
/* FIXME: stub */ size_t i;
/* Init UARTs */
for (i = 0; i < 4; i++) {
if (!uart_is_enabled(i))
uart_setup(i, 0);
}
} }
static void mainboard_enable(struct device *dev) static void mainboard_enable(struct device *dev)

View File

@ -232,6 +232,14 @@ int uart_setup(const size_t bus, int baudrate)
ctl.s.csclk_en = 1; ctl.s.csclk_en = 1;
write64(&uart->uctl_ctl, ctl.u); write64(&uart->uctl_ctl, ctl.u);
/**
* Exit here if the UART is not going to be used in coreboot.
* The previous initialization steps are sufficient to make the Linux
* kernel not panic.
*/
if (!baudrate)
return 0;
/** /**
* 7. Initialize the integer and fractional baud rate divider registers * 7. Initialize the integer and fractional baud rate divider registers
* UARTIBRD and UARTFBRD as follows: * UARTIBRD and UARTFBRD as follows: