ti: k3: common: Add console initialization base
authorNishanth Menon <nm@ti.com>
Fri, 14 Oct 2016 01:13:44 +0000 (01:13 +0000)
committerAndrew F. Davis <afd@ti.com>
Tue, 19 Jun 2018 17:42:35 +0000 (12:42 -0500)
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
plat/ti/k3/common/k3_bl31_setup.c
plat/ti/k3/common/k3_console.c [new file with mode: 0644]
plat/ti/k3/common/k3_helpers.S
plat/ti/k3/common/plat_common.mk
plat/ti/k3/include/k3_console.h [new file with mode: 0644]
plat/ti/k3/include/platform_def.h

index 11289df498e9d8a33e590576d7997dc6f7bb1412..866f6e4203e506c64ecc5b15a58a66457a409f82 100644 (file)
@@ -9,6 +9,7 @@
 #include <assert.h>
 #include <bl_common.h>
 #include <debug.h>
+#include <k3_console.h>
 #include <plat_arm.h>
 #include <platform_def.h>
 #include <string.h>
@@ -16,6 +17,7 @@
 /* Table of regions to map using the MMU */
 const mmap_region_t plat_arm_mmap[] = {
        MAP_REGION_FLAT(SHARED_RAM_BASE, SHARED_RAM_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
+       MAP_REGION_FLAT(K3_USART_BASE_ADDRESS, K3_USART_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
        { /* sentinel */ }
 };
 
@@ -55,6 +57,8 @@ void bl31_early_platform_setup(bl31_params_t *from_bl2,
        assert(from_bl2 == NULL);
        assert(plat_params_from_bl2 == NULL);
 
+       bl31_console_setup();
+
 #ifdef BL32_BASE
        /* Populate entry point information for BL32 */
        SET_PARAM_HEAD(&bl32_image_ep_info, PARAM_EP, VERSION_1, 0);
diff --git a/plat/ti/k3/common/k3_console.c b/plat/ti/k3/common/k3_console.c
new file mode 100644 (file)
index 0000000..ff3ca61
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <console.h>
+#include <k3_console.h>
+#include <platform_def.h>
+#include <uart_16550.h>
+
+void bl31_console_setup(void)
+{
+       static console_16550_t console;
+
+       /* Initialize the console to provide early debug support */
+       console_16550_register(K3_USART_BASE_ADDRESS, K3_USART_CLK_SPEED,
+                              K3_USART_BAUD, &console);
+}
index 40f9da98e562300869eacb64a646e7d1d892402c..c95e9c367a08c3a78efc9984b01b18dc84529e36 100644 (file)
@@ -92,3 +92,31 @@ func plat_my_core_pos
 out:
        ret
 endfunc plat_my_core_pos
+
+       /* ---------------------------------------------
+        * int plat_crash_console_init(void)
+        * Function to initialize the crash console
+        * without a C Runtime to print crash report.
+        * Clobber list : x0 - x4
+        * ---------------------------------------------
+        */
+func plat_crash_console_init
+       mov_imm x0, CRASH_CONSOLE_BASE
+       mov_imm x1, CRASH_CONSOLE_CLK
+       mov_imm x2, CRASH_CONSOLE_BAUD_RATE
+       mov w3, #0x0
+       b       console_core_init
+
+endfunc plat_crash_console_init
+
+       /* ---------------------------------------------
+        * int plat_crash_console_putc(void)
+        * Function to print a character on the crash
+        * console without a C Runtime.
+        * Clobber list : x1, x2
+        * ---------------------------------------------
+        */
+func plat_crash_console_putc
+       mov_imm x1, CRASH_CONSOLE_BASE
+       b       console_core_putc
+endfunc plat_crash_console_putc
index f707c63a325dfde3269aa3353d475fb79fdd09f4..56a60a8dd6f6388e13710d2fde3143e79667d6c5 100644 (file)
@@ -25,6 +25,10 @@ ERRATA_A53_836870    :=      1
 ERRATA_A53_843419      :=      1
 ERRATA_A53_855873      :=      1
 
+MULTI_CONSOLE_API      :=      1
+TI_16550_MDR_QUIRK     :=      1
+$(eval $(call add_define,TI_16550_MDR_QUIRK))
+
 # Libraries
 include lib/xlat_tables_v2/xlat_tables.mk
 
@@ -33,10 +37,16 @@ PLAT_INCLUDES               +=      \
                                -Iinclude/plat/arm/common/              \
                                -Iinclude/plat/arm/common/aarch64/      \
 
+K3_CONSOLE_SOURCES     +=      \
+                               drivers/console/aarch64/console.S       \
+                               drivers/ti/uart/aarch64/16550_console.S \
+                               ${PLAT_PATH}/common/k3_console.c        \
+
 PLAT_BL_COMMON_SOURCES +=      \
                                plat/arm/common/arm_common.c            \
                                lib/cpus/aarch64/cortex_a53.S           \
                                ${XLAT_TABLES_LIB_SRCS}                 \
+                               ${K3_CONSOLE_SOURCES}                   \
 
 BL31_SOURCES           +=      \
                                ${PLAT_PATH}/common/k3_bl31_setup.c     \
diff --git a/plat/ti/k3/include/k3_console.h b/plat/ti/k3/include/k3_console.h
new file mode 100644 (file)
index 0000000..5b01a31
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __K3_CONSOLE_H__
+#define __K3_CONSOLE_H__
+
+void bl31_console_setup(void);
+
+#endif /* __K3_CONSOLE_H__ */
index 10389528caffae10dc6b4c0fac818a7e60cc8748..7b38be57caf0b51915c598eb51f18fa6ba4f751c 100644 (file)
 #define CACHE_WRITEBACK_SHIFT          6
 #define CACHE_WRITEBACK_GRANULE                (1 << CACHE_WRITEBACK_SHIFT)
 
+/* Platform default console definitions */
+#ifndef K3_USART_BASE_ADDRESS
+#define K3_USART_BASE_ADDRESS 0x02800000
+#endif
+
+/* USART has a default size for address space */
+#define K3_USART_SIZE 0x1000
+
+#ifndef K3_USART_CLK_SPEED
+#define K3_USART_CLK_SPEED 48000000
+#endif
+
+#ifndef K3_USART_BAUD
+#define K3_USART_BAUD 115200
+#endif
+
+/* Crash console defaults */
+#define CRASH_CONSOLE_BASE K3_USART_BASE_ADDRESS
+#define CRASH_CONSOLE_CLK K3_USART_CLK_SPEED
+#define CRASH_CONSOLE_BAUD_RATE K3_USART_BAUD
+
 #endif /* __PLATFORM_DEF_H__ */