rcar_gen3: drivers: console
authorJorge Ramirez-Ortiz <jramirez@baylibre.com>
Sun, 23 Sep 2018 07:41:00 +0000 (09:41 +0200)
committerldts <jorge.ramirez.ortiz@gmail.com>
Wed, 17 Oct 2018 16:41:53 +0000 (18:41 +0200)
Signed-off-by: ldts <jramirez@baylibre.com>
drivers/renesas/rcar/console/rcar_console.S [new file with mode: 0644]
drivers/renesas/rcar/console/rcar_printf.c [new file with mode: 0644]
drivers/renesas/rcar/console/rcar_printf.h [new file with mode: 0644]

diff --git a/drivers/renesas/rcar/console/rcar_console.S b/drivers/renesas/rcar/console/rcar_console.S
new file mode 100644 (file)
index 0000000..e3c7363
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch.h>
+#include <asm_macros.S>
+
+       .globl  console_init
+       .globl  console_putc
+       .globl  console_uninit
+       .globl  console_core_init
+       .globl  console_core_putc
+       .globl  console_core_getc
+       .globl  console_flush
+
+       .extern rcar_log_init
+       .extern rcar_set_log_data
+
+       /* -----------------------------------------------
+        * int console_core_init(unsigned long base_addr,
+        * unsigned int uart_clk, unsigned int baud_rate)
+        * Function to initialize the log area. This
+        * function will be accessed by console_init and
+        * crash reporting.
+        * Return 1 on SUCCESS, 0 on error
+        * In: x0 - Not used
+        *     w1 - Not used
+        *     w2 - Not used
+        * -----------------------------------------------
+        */
+func console_core_init
+       b       rcar_log_init
+endfunc console_core_init
+func  console_init
+       b       console_core_init
+endfunc console_init
+
+       /* --------------------------------------------------------
+        * int console_core_putc(int c, unsigned long base_addr)
+        * Function to output a character over the log area.
+        * Return 1 on SUCCESS, 0 on error
+        * In : w0 - Not used
+        *      x1 - Not used
+        * --------------------------------------------------------
+        */
+func console_core_putc
+       b       rcar_set_log_data
+endfunc console_core_putc
+func console_putc
+       b       console_core_putc
+endfunc console_putc
+
+       /* ---------------------------------------------
+        * int console_core_getc(unsigned long base_addr)
+        * Function to get a character from the console.
+        * It returns the character grabbed on success
+        * or -1 on error.
+        * In : x0 - console base address
+        * Clobber list : x0, x1
+        * ---------------------------------------------
+        */
+func console_core_getc
+       ret
+endfunc console_core_getc
+
+       /* -----------------------------------------------
+        * void console_uninit(void)
+        * Function to finish the use of console driver.
+        * -----------------------------------------------
+        */
+func console_uninit
+       ret
+endfunc console_uninit
+
+       /* ---------------------------------------------
+        * int console_flush(void)
+        * Function to force a write of all buffered
+        * data that hasn't been output. It returns 0
+        * upon successful completion, otherwise it
+        * returns -1.
+        * Clobber list : x0, x1
+        * ---------------------------------------------
+        */
+func console_flush
+       mov     w0, #0
+       ret
+endfunc console_flush
diff --git a/drivers/renesas/rcar/console/rcar_printf.c b/drivers/renesas/rcar/console/rcar_printf.c
new file mode 100644 (file)
index 0000000..9321b58
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <debug.h>
+#include <stdarg.h>
+#include <stdint.h>
+
+#include       <arch_helpers.h>
+#include       <platform_def.h>
+#include       <bakery_lock.h>
+#include       "rcar_def.h"
+#include       "rcar_private.h"
+#include       "rcar_printf.h"
+
+#define INDEX_TIMER_COUNT      (4U)
+
+extern RCAR_INSTANTIATE_LOCK typedef struct log_head {
+       uint8_t head[4];
+       uint32_t index;
+       uint32_t size;
+       uint8_t res[4];
+} loghead_t;
+
+typedef struct log_map {
+       loghead_t header;
+       uint8_t log_data[RCAR_BL31_LOG_MAX];
+       uint8_t res_data[RCAR_LOG_RES_SIZE];
+} logmap_t;
+
+int32_t rcar_set_log_data(int32_t c)
+{
+       logmap_t *t_log;
+
+       t_log = (logmap_t *) RCAR_BL31_LOG_BASE;
+
+       rcar_lock_get();
+
+       /*
+        * If index is broken, then index and size initialize
+        */
+       if (t_log->header.index >= (uint32_t) RCAR_BL31_LOG_MAX) {
+               t_log->header.index = 0U;
+               t_log->header.size = 0U;
+       }
+       /*
+        * data store to log area then index and size renewal
+        */
+       t_log->log_data[t_log->header.index] = (uint8_t) c;
+       t_log->header.index++;
+       if (t_log->header.size < t_log->header.index) {
+               t_log->header.size = t_log->header.index;
+       }
+       if (t_log->header.index >= (uint32_t) RCAR_BL31_LOG_MAX) {
+               t_log->header.index = 0U;
+       }
+
+       rcar_lock_release();
+
+       return 1;
+}
+
+int32_t rcar_log_init(void)
+{
+
+       static const uint8_t const_header[] = "TLOG";
+       logmap_t *t_log;
+       int16_t init_flag = 0;
+
+       t_log = (logmap_t *) RCAR_BL31_LOG_BASE;
+       if (memcmp
+           ((const void *)t_log->header.head, (const void *)const_header,
+            sizeof(t_log->header.head)) != 0) {
+               /*
+                * Log header is not "TLOG", then log area initialize
+                */
+               init_flag = 1;
+       }
+       if (t_log->header.index >= (uint32_t) RCAR_BL31_LOG_MAX) {
+               /*
+                * index is broken, then log area initialize
+                */
+               init_flag = 1;
+       }
+       if (init_flag == 1) {
+               (void)memset((void *)t_log->log_data, 0,
+                            (size_t) RCAR_BL31_LOG_MAX);
+               (void)memcpy((void *)t_log->header.head,
+                            (const void *)const_header,
+                            sizeof(t_log->header.head));
+               t_log->header.index = 0U;
+               t_log->header.size = 0U;
+#ifndef IMAGE_BL2
+               rcar_stack_generic_timer[INDEX_TIMER_COUNT] = 0U;
+#endif
+       }
+       rcar_lock_init();
+
+       return 1;
+}
diff --git a/drivers/renesas/rcar/console/rcar_printf.h b/drivers/renesas/rcar/console/rcar_printf.h
new file mode 100644 (file)
index 0000000..dd7a61b
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef        RCAR_PRINTF_H__
+#define        RCAR_PRINTF_H__
+
+#include <string.h>
+
+int32_t rcar_set_log_data(int32_t c);
+int32_t rcar_log_init(void);
+
+#if IMAGE_BL31
+extern uint64_t rcar_stack_generic_timer[5];
+#endif
+
+#endif