nmhw: add support for late console initialization
- backport from nrsw to support COMIO shield
This commit is contained in:
parent
b274acceb4
commit
d9bbba2295
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* board.c
|
||||
*
|
||||
* Board functions for Netmodule nmhw24 board, based on AM335x EVB
|
||||
* Board functions for Netmodule NRHW 24, based on AM335x EVB
|
||||
*
|
||||
* Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/
|
||||
* Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
|
||||
|
|
@ -234,23 +234,29 @@ 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 selected in set_console()
|
||||
*/
|
||||
struct serial_device *default_serial_console(void)
|
||||
{
|
||||
/* Mux pins for selected UART properly.
|
||||
* Note: uart indexes start at 0 while
|
||||
* eserial indexes start at 1.
|
||||
*/
|
||||
|
||||
/* Provide UART on UART2 regardless of boot mode */
|
||||
enable_uart1_pin_mux();
|
||||
return &eserial2_device;
|
||||
|
||||
#if 0 /* TODO: Check whether really required */
|
||||
if (spl_boot_device() == BOOT_DEVICE_UART) {
|
||||
if ((spl_boot_device() == BOOT_DEVICE_UART) ||
|
||||
(spl_boot_device() == BOOT_DEVICE_JTAG)) {
|
||||
enable_uart0_pin_mux();
|
||||
return &eserial1_device;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Use internal uart, if no output shall be seen. */
|
||||
enable_uart1_pin_mux();
|
||||
return &eserial2_device;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +350,7 @@ void am33xx_spl_board_init(void)
|
|||
/* Set CORE Frequencies to OPP100 (600MHz) */
|
||||
do_setup_dpll(&dpll_core_regs, &dpll_core_opp100);
|
||||
|
||||
/* Configure I2C busses */
|
||||
/* Configure both I2C buses used */
|
||||
init_i2c();
|
||||
|
||||
/* Setup PMIC */
|
||||
|
|
@ -374,7 +380,6 @@ const struct dpll_params *get_dpll_ddr_params(void)
|
|||
|
||||
void set_uart_mux_conf(void)
|
||||
{
|
||||
/* TODO: Set depending on boot mode (SPL/UBoot, eMMC/UART) */
|
||||
enable_uart0_pin_mux();
|
||||
enable_uart1_pin_mux();
|
||||
}
|
||||
|
|
@ -453,7 +458,7 @@ static void init_ethernet(void)
|
|||
static void init_sim_mux(void)
|
||||
{
|
||||
/*
|
||||
* Switch onboard SIM to onboard modem (Mux = 1)
|
||||
* Switch pluggable micro SIM to onboard modem (mux = 0)
|
||||
*/
|
||||
REQUEST_AND_CLEAR_GPIO(GPIO_SIM_SEL);
|
||||
}
|
||||
|
|
@ -533,7 +538,7 @@ int board_init(void)
|
|||
|
||||
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
||||
|
||||
/* Configure I2C busses */
|
||||
/* Configure both I2C buses used */
|
||||
init_i2c();
|
||||
|
||||
da9063_init(CONFIG_PMIC_I2C_BUS);
|
||||
|
|
@ -550,28 +555,60 @@ int board_init(void)
|
|||
|
||||
#if !defined(CONFIG_SPL_BUILD)
|
||||
|
||||
/* TODO: Move to top of file or place into header file */
|
||||
extern int console_init_f(void);
|
||||
extern void serial_set_console_index(int index);
|
||||
|
||||
/*
|
||||
* Set Linux console based on
|
||||
* - Selection in /root/boot/consoledev
|
||||
* - Available tty interfaces
|
||||
* - ttyS1: standard console (default, internal only)
|
||||
* - ttyS0: COMIO shield (or used as console by kernel,
|
||||
* when no other console available)
|
||||
* - ttyNull0: Dummy device if no real UART is available
|
||||
*/
|
||||
void set_console(void)
|
||||
{
|
||||
const char *defaultconsole = getenv("defaultconsole");
|
||||
|
||||
if (defaultconsole == 0) {
|
||||
/* Use the default console */
|
||||
setenv("defaultconsole", "ttyS1");
|
||||
}
|
||||
|
||||
#if 0
|
||||
const char *defaultconsole = getenv("defaultconsole");
|
||||
char buf[8];
|
||||
|
||||
/* Set default console to ttyS1 if not yet defined in env */
|
||||
if (defaultconsole == 0) {
|
||||
setenv("defaultconsole", "ttyS1");
|
||||
}
|
||||
|
||||
/* Always use internal console for u-boot
|
||||
as comio shield is not ready at that time.
|
||||
(Needs to be initialized first using the
|
||||
shieldcmd that is run by bootcmd.) */
|
||||
serial_set_console_index(1);
|
||||
|
||||
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
||||
serial_init(); /* serial communications setup */
|
||||
console_init_f(); /* stage 1 init of console */
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (shield_id != SHIELD_COM_IO) {
|
||||
/* Don't allow changing to ttyS0 for the kernel console, because
|
||||
* ttyS0 is not available if no comio shield is populated. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* With comio shield the defaultconsole for the kernel should
|
||||
be ttyS0 and not ttyS1 */
|
||||
setenv("defaultconsole", "ttyS0");
|
||||
|
||||
/* If consoledev file is present, take the tty defined in it as console */
|
||||
if (read_file("/root/boot/consoledev",buf, 5) == 5) {
|
||||
if (read_file("/root/boot/consoledev",buf, sizeof(buf)) > 3) {
|
||||
if (strstr(buf, "tty") == buf) {
|
||||
buf[5] = 0;
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
for (i=0; i<sizeof(buf); i++) {
|
||||
if (buf[i]<=' ') {
|
||||
buf[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setenv("defaultconsole", buf);
|
||||
}
|
||||
}
|
||||
|
|
@ -674,6 +711,7 @@ static void check_fct(void)
|
|||
i2c_set_bus_num(old_bus);
|
||||
}
|
||||
|
||||
|
||||
struct shield_command {
|
||||
int shield_id;
|
||||
const char *name;
|
||||
|
|
@ -752,7 +790,6 @@ static void shield_init(void)
|
|||
shield_config();
|
||||
}
|
||||
|
||||
|
||||
static bool get_button_state(void)
|
||||
{
|
||||
uint8_t state = 0x00;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,20 @@ 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
|
||||
|
||||
/* TODO: Rename CONSOLE_INDEX to console_index, to make clear it
|
||||
* is a variable now
|
||||
*/
|
||||
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 +98,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 +123,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)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@
|
|||
#define CONFIG_MACH_TYPE MACH_TYPE_TIAM335EVM
|
||||
#define CONFIG_BOARD_LATE_INIT
|
||||
|
||||
#define CONFIG_PRE_CONSOLE_BUFFER
|
||||
#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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue