ADD: [nrhw20] configurable u-boot console

BugzID: 42044
This commit is contained in:
Marcel Reichmuth 2018-11-20 08:43:41 +01:00
parent a719e384a5
commit e35e718394
9 changed files with 72 additions and 17 deletions

View File

@ -47,6 +47,7 @@
#define BOOT_DEVICE_UART 0x41
#define BOOT_DEVICE_USBETH 0x44
#define BOOT_DEVICE_CPGMAC 0x46
#define BOOT_DEVICE_JTAG 0x58
#define MMC_BOOT_DEVICES_START BOOT_DEVICE_MMC1
#define MMC_BOOT_DEVICES_END BOOT_DEVICE_MMC2

View File

@ -254,18 +254,23 @@ static inline int __maybe_unused read_eeprom(void)
}
/* Selects console for SPL.
* U-Boot console is defined by CONFIG_CONS_INDEX (via menuconfig)
* U-Boot console is defined by CONSOLE_INDEX variable
* defined using serial_set_console_index(int index)
*/
struct serial_device *default_serial_console(void)
{
if (spl_boot_device() == BOOT_DEVICE_UART) {
/* Mux Pins for selected UART properly.
Note: uart indexes start at 0 while
eserial indexes start at 1. */
if ((spl_boot_device() == BOOT_DEVICE_UART) ||
(spl_boot_device() == BOOT_DEVICE_JTAG)) {
enable_uart0_pin_mux();
return &eserial1_device;
} else {
/* Use bluetooth uart, if no ouput shall be seen. */
enable_uart5_pin_mux();
return &eserial6_device;
}
else {
enable_uart1_pin_mux();
return &eserial2_device;
}
}
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
@ -541,6 +546,9 @@ int board_init(void)
#if !defined(CONFIG_SPL_BUILD)
extern int console_init_f(void);
extern void serial_set_console_index(int index);
/*
* Set Linux console based on
* - Selection in /root/boot/consoledev
@ -574,6 +582,26 @@ void set_console(void)
setenv("defaultconsole", buf);
}
}
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
defaultconsole = getenv("defaultconsole");
if (strstr(defaultconsole, "ttyS0")) {
/* Only use internal console, if explicitely specified */
serial_set_console_index(0);
// } else if (strstr(defaultconsole, "ttyNull")) {
// /* If no console shall be available use bluetooth uart. */
// serial_set_console_index(5);
} else {
/* Otherwise and especially, if no console is specified
use the default console, which is the external console */
serial_set_console_index(1);
}
serial_init(); /* serial communications setup */
console_init_f(); /* stage 1 init of console */
#else
serial_set_console_index(1);
#endif
}
static void set_devicetree_name(void)

View File

@ -19,6 +19,8 @@
void enable_uart0_pin_mux(void);
void disable_uart0_pin_mux(void);
void enable_uart1_pin_mux(void);
void enable_uart3_pin_mux(void);
void enable_uart5_pin_mux(void);
/*
void enable_uart2_pin_mux(void);
void enable_uart3_pin_mux(void);

View File

@ -249,3 +249,12 @@ void enable_uart1_pin_mux(void)
configure_module_pin_mux(uart1_pin_mux);
}
void enable_uart3_pin_mux(void)
{
configure_module_pin_mux(uart3_pin_mux);
}
void enable_uart5_pin_mux(void)
{
configure_module_pin_mux(uart5_pin_mux);
}

View File

@ -888,8 +888,10 @@ static init_fnc_t init_sequence_f[] = {
init_timebase,
#endif
init_baud_rate, /* initialze baudrate settings */
#if !defined(CONFIG_PRE_CONSOLE_BUFFER)
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
#endif
#ifdef CONFIG_SANDBOX
sandbox_early_getopt_check,
#endif

View File

@ -414,7 +414,7 @@ int tstc(void)
#define PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL 1
#ifdef CONFIG_PRE_CONSOLE_BUFFER
#define CIRC_BUF_IDX(idx) ((idx) % (unsigned long)CONFIG_PRE_CON_BUF_SZ)
#define CIRC_BUF_IDX(idx) ((idx) % (unsigned long)(CONFIG_PRE_CON_BUF_SZ))
static void pre_console_putc(const char c)
{

View File

@ -27,6 +27,17 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
#error "Serial is required before relocation - define CONFIG_SYS_MALLOC_F_LEN to make this work"
#endif
#ifdef CONFIG_CONS_INDEX
static int CONSOLE_INDEX = CONFIG_CONS_INDEX - 1;
#else
static int CONSOLE_INDEX = 0;
#endif
void serial_set_console_index(int index)
{
CONSOLE_INDEX = index;
}
static void serial_find_console_or_panic(void)
{
const void *blob = gd->fdt_blob;
@ -84,18 +95,12 @@ static void serial_find_console_or_panic(void)
* extremis just the first serial device we can find. But we
* insist on having a console (even if it is silent).
*/
#ifdef CONFIG_CONS_INDEX
#define INDEX (CONFIG_CONS_INDEX - 1)
#else
#define INDEX 0
#endif
if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
!uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
if (!uclass_get_device_by_seq(UCLASS_SERIAL, CONSOLE_INDEX, &dev) ||
!uclass_get_device(UCLASS_SERIAL, CONSOLE_INDEX, &dev) ||
(!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
gd->cur_serial_dev = dev;
return;
}
#undef INDEX
}
#ifdef CONFIG_REQUIRE_SERIAL_CONSOLE
@ -115,7 +120,9 @@ int serial_init(void)
/* Called after relocation */
void serial_initialize(void)
{
#if !defined(CONFIG_PRE_CONSOLE_BUFFER)
serial_init();
#endif
}
static void _serial_putc(struct udevice *dev, char ch)

View File

@ -307,8 +307,6 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
unmap_sysmem(buf);
/* If we requested a specific number of bytes, check we got it */
if (ret == 0 && len && *actread != len)
printf("** %s shorter than offset + len **\n", filename);
fs_close();
return ret;

View File

@ -36,6 +36,10 @@
#define CONFIG_MACH_TYPE MACH_TYPE_TIAM335EVM
#define CONFIG_BOARD_LATE_INIT
#define CONFIG_PRE_CONSOLE_BUFFER 1
#define CONFIG_PRE_CON_BUF_ADDR 0x80000000
#define CONFIG_PRE_CON_BUF_SZ 64*1024
/* Clock Defines */
#define V_OSCK 0 /* 0 means detect from sysboot1 config */
#define V_SCLK (V_OSCK)
@ -105,6 +109,10 @@
/* UART Configuration */
#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot, Shield */
#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: eMMC Boot, User UART */
#define CONFIG_SYS_NS16550_COM3 0x48024000 /* Unused */
#define CONFIG_SYS_NS16550_COM4 0x481A6000 /* GNSS */
#define CONFIG_SYS_NS16550_COM5 0x481A8000 /* Unused */
#define CONFIG_SYS_NS16550_COM6 0x481AA000 /* Bluetooth */
#define CONFIG_I2C
#define CONFIG_I2C_MULTI_BUS