aboutsummaryrefslogtreecommitdiff
path: root/drivers/renesas
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/renesas')
-rw-r--r--drivers/renesas/rcar/console/rcar_console.S117
-rw-r--r--drivers/renesas/rcar/scif/scif.S113
2 files changed, 106 insertions, 124 deletions
diff --git a/drivers/renesas/rcar/console/rcar_console.S b/drivers/renesas/rcar/console/rcar_console.S
index e3c7363620..859efeceb4 100644
--- a/drivers/renesas/rcar/console/rcar_console.S
+++ b/drivers/renesas/rcar/console/rcar_console.S
@@ -1,81 +1,88 @@
/*
- * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
+ * Copyright (c) 2018-2019, Renesas Electronics Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch.h>
#include <asm_macros.S>
+#include <console_macros.S>
+#include <drivers/renesas/rcar/console/console.h>
- .globl console_init
- .globl console_putc
- .globl console_uninit
- .globl console_core_init
- .globl console_core_putc
- .globl console_core_getc
- .globl console_flush
+ .globl console_rcar_register
+ .globl console_rcar_init
+ .globl console_rcar_putc
+ .globl console_rcar_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
+ * int console_rcar_register(
+ * uintptr_t base, uint32_t clk, uint32_t baud,
+ * console_rcar_t *console)
+ * Function to initialize and register a new rcar
+ * console. Storage passed in for the console struct
+ * *must* be persistent (i.e. not from the stack).
+ * In: x0 - UART register base address
+ * w1 - UART clock in Hz
+ * w2 - Baud rate
+ * x3 - pointer to empty console_rcar_t struct
+ * Out: return 1 on success, 0 on error
+ * Clobber list : x0, x1, x2, x6, x7, x14
* -----------------------------------------------
*/
-func console_core_init
- b rcar_log_init
-endfunc console_core_init
-func console_init
- b console_core_init
-endfunc console_init
+func console_rcar_register
+ mov x7, x30
+ mov x6, x3
+ cbz x6, register_fail
+ str x0, [x6, #CONSOLE_T_RCAR_BASE]
- /* --------------------------------------------------------
- * 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
+ bl rcar_log_init
+ cbz x0, register_fail
+
+ mov x0, x6
+ mov x30, x7
+ finish_console_register rcar, putc=1, getc=0, flush=1
+
+register_fail:
+ ret x7
+endfunc console_rcar_register
/* ---------------------------------------------
- * 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
+ * int console_rcar_init(unsigned long base_addr,
+ * unsigned int uart_clk, unsigned int baud_rate)
+ * Function to initialize the console without a
+ * C Runtime to print debug information. This
+ * function will be accessed by crash reporting.
+ * In: x0 - console base address
+ * w1 - Uart clock in Hz
+ * w2 - Baud rate
+ * Out: return 1 on success
+ * Clobber list : x1, x2
* ---------------------------------------------
*/
-func console_core_getc
+func console_rcar_init
+ mov w0, #0
ret
-endfunc console_core_getc
+endfunc console_rcar_init
- /* -----------------------------------------------
- * void console_uninit(void)
- * Function to finish the use of console driver.
- * -----------------------------------------------
+ /* --------------------------------------------------------
+ * int console_rcar_putc(int c, console_rcar_t *console)
+ * Function to output a character over the console. It
+ * returns the character printed on success or -1 on error.
+ * In : w0 - character to be printed
+ * x1 - pointer to console_rcar_t structure
+ * Out : return -1 on error else return character.
+ * Clobber list : x2
+ * --------------------------------------------------------
*/
-func console_uninit
- ret
-endfunc console_uninit
+func console_rcar_putc
+ b rcar_set_log_data
+endfunc console_rcar_putc
/* ---------------------------------------------
- * int console_flush(void)
+ * int console_rcar_flush(void)
* Function to force a write of all buffered
* data that hasn't been output. It returns 0
* upon successful completion, otherwise it
@@ -83,7 +90,7 @@ endfunc console_uninit
* Clobber list : x0, x1
* ---------------------------------------------
*/
-func console_flush
+func console_rcar_flush
mov w0, #0
ret
-endfunc console_flush
+endfunc console_rcar_flush
diff --git a/drivers/renesas/rcar/scif/scif.S b/drivers/renesas/rcar/scif/scif.S
index 471d7b8084..8309bb26e0 100644
--- a/drivers/renesas/rcar/scif/scif.S
+++ b/drivers/renesas/rcar/scif/scif.S
@@ -1,11 +1,13 @@
/*
- * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
+ * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch.h>
#include <asm_macros.S>
+#include <console_macros.S>
+#include <drivers/renesas/rcar/console/console.h>
#define SCIF_INTERNAL_CLK 0
#define SCIF_EXTARNAL_CLK 1
@@ -116,49 +118,49 @@
#define CKS_XIN_SCIF_CLK (0x0000)
#define CKS_INIT_DATA (CKS_CKS_DIV_CLK + CKS_XIN_SCIF_CLK)
- .globl console_init
- .globl console_uninit
- .globl console_putc
- .globl console_core_init
- .globl console_core_putc
- .globl console_getc
- .globl console_flush
+ .globl console_rcar_register
+ .globl console_rcar_init
+ .globl console_rcar_putc
+ .globl console_rcar_flush
- /*
- * The console base is in the data section and not in .bss
- * even though it is zero-init. In particular, this allows
- * the console functions to start using this variable before
- * the runtime memory is initialized for images which do not
- * need to copy the .data section from ROM to RAM.
- */
/* -----------------------------------------------
- * int console_init(unsigned long base_addr,
- * unsigned int uart_clk, unsigned int baud_rate)
- * Function to initialize the console without a
- * C Runtime to print debug information. It saves
- * the console base to the data section.
- * In: x0 - console base address
- * w1 - Uart clock in Hz
+ * int console_rcar_register(
+ * uintptr_t base, uint32_t clk, uint32_t baud,
+ * console_rcar_t *console)
+ * Function to initialize and register a new rcar
+ * console. Storage passed in for the console struct
+ * *must* be persistent (i.e. not from the stack).
+ * In: x0 - UART register base address
+ * w1 - UART clock in Hz
* w2 - Baud rate
- * out: return 1 on success.
- * Clobber list : x1 - x3
+ * x3 - pointer to empty console_rcar_t struct
+ * Out: return 1 on success, 0 on error
+ * Clobber list : x0, x1, x2, x6, x7, x14
* -----------------------------------------------
*/
-func console_init
- b console_core_init
-endfunc console_init
+func console_rcar_register
+ mov x7, x30
+ mov x6, x3
+ cbz x6, register_fail
+ str x0, [x6, #CONSOLE_T_RCAR_BASE]
-func console_uninit
- ret
-endfunc console_uninit
+ bl console_rcar_init
+
+ mov x0, x6
+ mov x30, x7
+ finish_console_register rcar, putc=1, getc=0, flush=1
+
+register_fail:
+ ret x7
+endfunc console_rcar_register
/* -----------------------------------------------
- * int console_core_init(unsigned long base_addr,
+ * int console_rcar_init(unsigned long base_addr,
* unsigned int uart_clk, unsigned int baud_rate)
* Function to initialize the console without a
* C Runtime to print debug information. This
- * function will be accessed by console_init and
- * crash reporting.
+ * function will be accessed by console_rcar_register
+ * and crash reporting.
* In: x0 - console base address
* w1 - Uart clock in Hz
* w2 - Baud rate
@@ -166,7 +168,7 @@ endfunc console_uninit
* Clobber list : x1, x2
* -----------------------------------------------
*/
-func console_core_init
+func console_rcar_init
ldr x0, =CPG_BASE
ldr w1, [x0, #CPG_SMSTPCR]
and w1, w1, #~MSTP
@@ -261,33 +263,19 @@ func console_core_init
mov x0, #1
ret
-endfunc console_core_init
-
- /* ---------------------------------------------
- * int console_putc(int c)
- * Function to output a character over the
- * console. It returns the character printed on
- * success or -1 on error.
- * In : x0 - character to be printed
- * Out : return -1 on error else return character.
- * Clobber list : x1, x2
- * ---------------------------------------------
- */
-func console_putc
- b console_core_putc
-endfunc console_putc
+endfunc console_rcar_init
/* --------------------------------------------------------
- * int console_core_putc(int c, unsigned int base_addr)
+ * int console_rcar_putc(int c, unsigned int base_addr)
* Function to output a character over the console. It
* returns the character printed on success or -1 on error.
* In : w0 - character to be printed
- * x1 - console base address
+ * x1 - pointer to console_t structure
* Out : return -1 on error else return character.
* Clobber list : x2
* --------------------------------------------------------
*/
-func console_core_putc
+func console_rcar_putc
ldr x1, =SCIF_BASE
cmp w0, #0xA
/* Prepend '\r' to '\n' */
@@ -314,23 +302,10 @@ func console_core_putc
strh w2, [x1, #SCIF_SCFSR]
ret
-endfunc console_core_putc
-
- /* ---------------------------------------------
- * int console_getc(void)
- * Function to get a character from the console.
- * It returns the character grabbed on success
- * or -1 on error.
- * Clobber list : x0, x1
- * ---------------------------------------------
- */
-func console_getc
- mov w0, #-1
- ret
-endfunc console_getc
+endfunc console_rcar_putc
/* ---------------------------------------------
- * int console_flush(void)
+ * int console_rcar_flush(void)
* Function to force a write of all buffered
* data that hasn't been output. It returns 0
* upon successful completion, otherwise it
@@ -338,7 +313,7 @@ endfunc console_getc
* Clobber list : x0, x1
* ---------------------------------------------
*/
-func console_flush
+func console_rcar_flush
ldr x0, =SCIF_BASE
1:
/* Check TEND flag */
@@ -354,4 +329,4 @@ func console_flush
mov w0, #0
ret
-endfunc console_flush
+endfunc console_rcar_flush