[U-Boot] [PATCH 1/2] tegra: Implement pre-console putc() for fdt warning

When there is not device tree file available to U-Boot, we panic. Implement board_pre_console_putc() so that this panic will be displayed on the serial console.
Signed-off-by: Simon Glass sjg@chromium.org --- arch/arm/cpu/armv7/tegra2/board.c | 58 +++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv7/tegra2/board.c b/arch/arm/cpu/armv7/tegra2/board.c index 349d50e..4ca1e1f 100644 --- a/arch/arm/cpu/armv7/tegra2/board.c +++ b/arch/arm/cpu/armv7/tegra2/board.c @@ -23,9 +23,11 @@
#include <common.h> #include <asm/io.h> +#include <ns16550.h> #include "ap20.h" #include <asm/arch/clock.h> #include <asm/arch/funcmux.h> +#include <asm/arch/gpio.h> #include <asm/arch/sys_proto.h> #include <asm/arch/tegra2.h> #include <asm/arch/pmc.h> @@ -37,6 +39,7 @@ enum { UARTA = 1 << 0, UARTB = 1 << 1, UARTD = 1 << 3, + UART_ALL = 0xf, UART_COUNT = 4, };
@@ -149,3 +152,58 @@ void enable_caches(void) dcache_enable(); } #endif + + +/* + * Possible UART locations: we ignore UARTC at 0x70006200 and UARTE at + * 0x70006400, since we don't have code to init them + */ +static u32 uart_reg_addr[] = { + NV_PA_APB_UARTA_BASE, + NV_PA_APB_UARTB_BASE, + NV_PA_APB_UARTD_BASE, + 0 +}; + +#ifdef CONFIG_PRE_CONSOLE_PUTC +/* + * This is called when we have no console. About the only reason that this + * happen is if we don't have a valid fdt. So we don't know what kind of + * Tegra board we are. We blindly try to print a message every which way we + * know. + */ +void board_pre_console_putc(int ch) +{ + int uart_ids = UART_ALL; /* turn it all on! */ + u32 *uart_addr; + int clock_freq, multiplier, baudrate, divisor; + + /* Try to enable all possible UARTs */ + setup_uarts(uart_ids); + + /* + * Seaboard has a UART switch on PI3. We might be a Seaboard, + * so flip it! + */ +#ifdef CONFIG_SPI_UART_SWITCH + gpio_direction_output(GPIO_PI3, 0); +#endif + + /* + * Now send the string out all the Tegra UARTs. We don't try all + * possible configurations, but this could be added if required. + */ + clock_freq = CONFIG_DEFAULT_NS16550_CLK; + multiplier = CONFIG_DEFAULT_NS16550_MULT; + baudrate = CONFIG_BAUDRATE; + divisor = (clock_freq + (baudrate * (multiplier / 2))) / + (multiplier * baudrate); + + for (uart_addr = uart_reg_addr; *uart_addr; uart_addr++) { + NS16550_init((NS16550_t)*uart_addr, divisor); + NS16550_putc((NS16550_t)*uart_addr, ch); + if (ch == '\n') + NS16550_putc((NS16550_t)*uart_addr, '\r'); + } +} +#endif

This is used to display panic messages before the console is active.
Signed-off-by: Simon Glass sjg@chromium.org --- include/configs/tegra2-common.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h index e6f385f..6ced617 100644 --- a/include/configs/tegra2-common.h +++ b/include/configs/tegra2-common.h @@ -68,11 +68,18 @@ */ #define V_NS16550_CLK 216000000 /* 216MHz (pllp_out0) */
+/* Default serial clock and multiplier */ +#define CONFIG_DEFAULT_NS16550_CLK V_NS16550_CLK +#define CONFIG_DEFAULT_NS16550_MULT 16 + #define CONFIG_SYS_NS16550 #define CONFIG_SYS_NS16550_SERIAL #define CONFIG_SYS_NS16550_REG_SIZE (-4) #define CONFIG_SYS_NS16550_CLK V_NS16550_CLK
+/* We use this for a warning message when no device tree is present */ +#define CONFIG_PRE_CONSOLE_PUTC + /* * select serial console configuration */

Hi,
On Thu, Mar 8, 2012 at 6:52 PM, Simon Glass sjg@chromium.org wrote:
This is used to display panic messages before the console is active.
Signed-off-by: Simon Glass sjg@chromium.org
Please don't send u-boot patches to linux-tegra.
Thanks,
-Olof

On 03/08/2012 07:52 PM, Simon Glass wrote:
This is used to display panic messages before the console is active.
Signed-off-by: Simon Glass sjg@chromium.org
I applied both these patches on top of u-boot-tegra/master, built for Ventana, and loaded/ran u-boot.bin, and don't see any useful serial output; there's a bit of periodic binary spew. u-boot-dtb.bin works as expected.
So, these patches don't appear to solve the problem.

Hi Stephen,
On Fri, Mar 9, 2012 at 8:57 AM, Stephen Warren swarren@wwwdotorg.org wrote:
On 03/08/2012 07:52 PM, Simon Glass wrote:
This is used to display panic messages before the console is active.
Signed-off-by: Simon Glass sjg@chromium.org
I applied both these patches on top of u-boot-tegra/master, built for Ventana, and loaded/ran u-boot.bin, and don't see any useful serial output; there's a bit of periodic binary spew. u-boot-dtb.bin works as expected.
I don't have a ventana but I think Seaboard is equivalent. I will test on that and figure out what piece is missing.
So, these patches don't appear to solve the problem.
They do in our tree, but I will take a look.
Regards, Simon

-linux-tegra
Hi Stephen,
On Fri, Mar 9, 2012 at 8:57 AM, Stephen Warren swarren@wwwdotorg.org wrote:
On 03/08/2012 07:52 PM, Simon Glass wrote:
This is used to display panic messages before the console is active.
Signed-off-by: Simon Glass sjg@chromium.org
I applied both these patches on top of u-boot-tegra/master, built for Ventana, and loaded/ran u-boot.bin, and don't see any useful serial output; there's a bit of periodic binary spew. u-boot-dtb.bin works as expected.
So, these patches don't appear to solve the problem.
You are seeing the output, but since it resets the ns16550 on every character we are just emitting garbage. I should have pushed back on just having a board_pre_console_panic() as it would be easier. Anyway, given that this is what we have, we need a function to drain the FIFO.
Also printf() is silently skipped without a console, so we need to stop that happening as well.
I will send a new series with those two new patches and dealing with Mike's comments. It seems to work fine for me on Seaboard.
Regards, Simon
participants (4)
-
Mike Frysinger
-
Olof Johansson
-
Simon Glass
-
Stephen Warren