console: Introduce a way for mainboard to override the loglevel

This change adds a config option to allow mainboard to override
the console loglevel. When the option is set, the platform has
to define the function get_console_loglevel returning a valid
loglevel value.

This allows a mainboard to sample a GPIO to switch the loglevel
value between different environments (qualification vs production)
without re-flashing.

Change-Id: Id6cc72b8fe5c4c50a6f83ce80e6440b078eec6e2
Signed-off-by: Julien Viard de Galbert <jviarddegalbert@online.net>
Reviewed-on: https://review.coreboot.org/23712
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Julien Viard de Galbert 2018-02-20 15:01:27 +01:00 committed by Nico Huber
parent 8f825e0cd0
commit 4ecd42f9b5
3 changed files with 24 additions and 2 deletions

View File

@ -298,6 +298,14 @@ config SPI_CONSOLE
This is currently working only in ramstage due to how the spi
drivers are written.
config CONSOLE_OVERRIDE_LOGLEVEL
boolean
help
Set to "y" when the platform overrides the loglevel by providing
a get_console_loglevel routine.
if !CONSOLE_OVERRIDE_LOGLEVEL
choice
prompt "Default console log level"
default DEFAULT_CONSOLE_LOGLEVEL_8
@ -355,6 +363,8 @@ config DEFAULT_CONSOLE_LOGLEVEL
help
Map the log level config names to an integer.
endif
config NO_POST
bool "Don't show any POST codes"
default n

View File

@ -34,7 +34,7 @@ static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
static inline int get_log_level(void)
{
if (CONSOLE_LEVEL_CONST)
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
return get_console_loglevel();
return console_loglevel;
}
@ -49,7 +49,7 @@ static inline void set_log_level(int new_level)
static void init_log_level(void)
{
int debug_level = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
int debug_level = get_console_loglevel();
if (CONSOLE_LEVEL_CONST)
return;

View File

@ -64,6 +64,18 @@ void do_putchar(unsigned char byte);
#define printk(LEVEL, fmt, args...) \
do { do_printk(LEVEL, fmt, ##args); } while (0)
#if IS_ENABLED(CONFIG_CONSOLE_OVERRIDE_LOGLEVEL)
/*
* This function should be implemented at mainboard level.
* The returned value will _replace_ the loglevel value;
*/
int get_console_loglevel(void);
#else
static inline int get_console_loglevel(void)
{
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
}
#endif
#else
static inline void console_init(void) {}
static inline int console_log_level(int msg_level) { return 0; }