Commit 018358fc authored by Marek Vasut's avatar Marek Vasut
Browse files

rcar_gen3: console: Convert to multi-console API



Convert the R-Car Gen3 platform and both SCIF and Log drivers
to multi-console API.
Signed-off-by: default avatarMarek Vasut <marek.vasut+renesas@gmail.com>
Change-Id: I18556973937d150b60453f9150d54ee612571e35
parent e1368771
/* /*
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <arch.h> #include <arch.h>
#include <asm_macros.S> #include <asm_macros.S>
#include <console_macros.S>
#include <drivers/renesas/rcar/console/console.h>
.globl console_init .globl console_rcar_register
.globl console_putc .globl console_rcar_init
.globl console_uninit .globl console_rcar_putc
.globl console_core_init .globl console_rcar_flush
.globl console_core_putc
.globl console_core_getc
.globl console_flush
.extern rcar_log_init .extern rcar_log_init
.extern rcar_set_log_data .extern rcar_set_log_data
/* ----------------------------------------------- /* -----------------------------------------------
* int console_core_init(unsigned long base_addr, * int console_rcar_register(
* unsigned int uart_clk, unsigned int baud_rate) * uintptr_t base, uint32_t clk, uint32_t baud,
* Function to initialize the log area. This * console_rcar_t *console)
* function will be accessed by console_init and * Function to initialize and register a new rcar
* crash reporting. * console. Storage passed in for the console struct
* Return 1 on SUCCESS, 0 on error * *must* be persistent (i.e. not from the stack).
* In: x0 - Not used * In: x0 - UART register base address
* w1 - Not used * w1 - UART clock in Hz
* w2 - Not used * 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 func console_rcar_register
b rcar_log_init mov x7, x30
endfunc console_core_init mov x6, x3
func console_init cbz x6, register_fail
b console_core_init str x0, [x6, #CONSOLE_T_RCAR_BASE]
endfunc console_init
/* -------------------------------------------------------- bl rcar_log_init
* int console_core_putc(int c, unsigned long base_addr) cbz x0, register_fail
* Function to output a character over the log area.
* Return 1 on SUCCESS, 0 on error mov x0, x6
* In : w0 - Not used mov x30, x7
* x1 - Not used finish_console_register rcar, putc=1, getc=0, flush=1
* --------------------------------------------------------
*/ register_fail:
func console_core_putc ret x7
b rcar_set_log_data endfunc console_rcar_register
endfunc console_core_putc
func console_putc
b console_core_putc
endfunc console_putc
/* --------------------------------------------- /* ---------------------------------------------
* int console_core_getc(unsigned long base_addr) * int console_rcar_init(unsigned long base_addr,
* Function to get a character from the console. * unsigned int uart_clk, unsigned int baud_rate)
* It returns the character grabbed on success * Function to initialize the console without a
* or -1 on error. * C Runtime to print debug information. This
* In : x0 - console base address * function will be accessed by crash reporting.
* Clobber list : x0, x1 * 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 ret
endfunc console_core_getc endfunc console_rcar_init
/* ----------------------------------------------- /* --------------------------------------------------------
* void console_uninit(void) * int console_rcar_putc(int c, console_rcar_t *console)
* Function to finish the use of console driver. * 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 func console_rcar_putc
ret b rcar_set_log_data
endfunc console_uninit endfunc console_rcar_putc
/* --------------------------------------------- /* ---------------------------------------------
* int console_flush(void) * int console_rcar_flush(void)
* Function to force a write of all buffered * Function to force a write of all buffered
* data that hasn't been output. It returns 0 * data that hasn't been output. It returns 0
* upon successful completion, otherwise it * upon successful completion, otherwise it
...@@ -83,7 +90,7 @@ endfunc console_uninit ...@@ -83,7 +90,7 @@ endfunc console_uninit
* Clobber list : x0, x1 * Clobber list : x0, x1
* --------------------------------------------- * ---------------------------------------------
*/ */
func console_flush func console_rcar_flush
mov w0, #0 mov w0, #0
ret ret
endfunc console_flush endfunc console_rcar_flush
/* /*
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <arch.h> #include <arch.h>
#include <asm_macros.S> #include <asm_macros.S>
#include <console_macros.S>
#include <drivers/renesas/rcar/console/console.h>
#define SCIF_INTERNAL_CLK 0 #define SCIF_INTERNAL_CLK 0
#define SCIF_EXTARNAL_CLK 1 #define SCIF_EXTARNAL_CLK 1
...@@ -116,49 +118,49 @@ ...@@ -116,49 +118,49 @@
#define CKS_XIN_SCIF_CLK (0x0000) #define CKS_XIN_SCIF_CLK (0x0000)
#define CKS_INIT_DATA (CKS_CKS_DIV_CLK + CKS_XIN_SCIF_CLK) #define CKS_INIT_DATA (CKS_CKS_DIV_CLK + CKS_XIN_SCIF_CLK)
.globl console_init .globl console_rcar_register
.globl console_uninit .globl console_rcar_init
.globl console_putc .globl console_rcar_putc
.globl console_core_init .globl console_rcar_flush
.globl console_core_putc
.globl console_getc
.globl console_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, * int console_rcar_register(
* unsigned int uart_clk, unsigned int baud_rate) * uintptr_t base, uint32_t clk, uint32_t baud,
* Function to initialize the console without a * console_rcar_t *console)
* C Runtime to print debug information. It saves * Function to initialize and register a new rcar
* the console base to the data section. * console. Storage passed in for the console struct
* In: x0 - console base address * *must* be persistent (i.e. not from the stack).
* w1 - Uart clock in Hz * In: x0 - UART register base address
* w1 - UART clock in Hz
* w2 - Baud rate * w2 - Baud rate
* out: return 1 on success. * x3 - pointer to empty console_rcar_t struct
* Clobber list : x1 - x3 * Out: return 1 on success, 0 on error
* Clobber list : x0, x1, x2, x6, x7, x14
* ----------------------------------------------- * -----------------------------------------------
*/ */
func console_init func console_rcar_register
b console_core_init mov x7, x30
endfunc console_init mov x6, x3
cbz x6, register_fail
str x0, [x6, #CONSOLE_T_RCAR_BASE]
func console_uninit bl console_rcar_init
ret
endfunc console_uninit 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) * unsigned int uart_clk, unsigned int baud_rate)
* Function to initialize the console without a * Function to initialize the console without a
* C Runtime to print debug information. This * C Runtime to print debug information. This
* function will be accessed by console_init and * function will be accessed by console_rcar_register
* crash reporting. * and crash reporting.
* In: x0 - console base address * In: x0 - console base address
* w1 - Uart clock in Hz * w1 - Uart clock in Hz
* w2 - Baud rate * w2 - Baud rate
...@@ -166,7 +168,7 @@ endfunc console_uninit ...@@ -166,7 +168,7 @@ endfunc console_uninit
* Clobber list : x1, x2 * Clobber list : x1, x2
* ----------------------------------------------- * -----------------------------------------------
*/ */
func console_core_init func console_rcar_init
ldr x0, =CPG_BASE ldr x0, =CPG_BASE
ldr w1, [x0, #CPG_SMSTPCR] ldr w1, [x0, #CPG_SMSTPCR]
and w1, w1, #~MSTP and w1, w1, #~MSTP
...@@ -261,33 +263,19 @@ func console_core_init ...@@ -261,33 +263,19 @@ func console_core_init
mov x0, #1 mov x0, #1
ret ret
endfunc console_core_init endfunc console_rcar_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
/* -------------------------------------------------------- /* --------------------------------------------------------
* 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 * Function to output a character over the console. It
* returns the character printed on success or -1 on error. * returns the character printed on success or -1 on error.
* In : w0 - character to be printed * In : w0 - character to be printed
* x1 - console base address * x1 - pointer to console_t structure
* Out : return -1 on error else return character. * Out : return -1 on error else return character.
* Clobber list : x2 * Clobber list : x2
* -------------------------------------------------------- * --------------------------------------------------------
*/ */
func console_core_putc func console_rcar_putc
ldr x1, =SCIF_BASE ldr x1, =SCIF_BASE
cmp w0, #0xA cmp w0, #0xA
/* Prepend '\r' to '\n' */ /* Prepend '\r' to '\n' */
...@@ -314,23 +302,10 @@ func console_core_putc ...@@ -314,23 +302,10 @@ func console_core_putc
strh w2, [x1, #SCIF_SCFSR] strh w2, [x1, #SCIF_SCFSR]
ret ret
endfunc console_core_putc endfunc console_rcar_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
/* --------------------------------------------- /* ---------------------------------------------
* int console_flush(void) * int console_rcar_flush(void)
* Function to force a write of all buffered * Function to force a write of all buffered
* data that hasn't been output. It returns 0 * data that hasn't been output. It returns 0
* upon successful completion, otherwise it * upon successful completion, otherwise it
...@@ -338,7 +313,7 @@ endfunc console_getc ...@@ -338,7 +313,7 @@ endfunc console_getc
* Clobber list : x0, x1 * Clobber list : x0, x1
* --------------------------------------------- * ---------------------------------------------
*/ */
func console_flush func console_rcar_flush
ldr x0, =SCIF_BASE ldr x0, =SCIF_BASE
1: 1:
/* Check TEND flag */ /* Check TEND flag */
...@@ -354,4 +329,4 @@ func console_flush ...@@ -354,4 +329,4 @@ func console_flush
mov w0, #0 mov w0, #0
ret ret
endfunc console_flush endfunc console_rcar_flush
/*
* Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RCAR_PRINTF_H
#define RCAR_PRINTF_H
#define CONSOLE_T_RCAR_BASE CONSOLE_T_DRVDATA
#ifndef __ASSEMBLY__
#include <stdint.h>
typedef struct {
console_t console;
uintptr_t base;
} console_rcar_t;
/*
* Initialize a new rcar console instance and register it with the console
* framework. The |console| pointer must point to storage that will be valid
* for the lifetime of the console, such as a global or static local variable.
* Its contents will be reinitialized from scratch.
*/
int console_rcar_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud,
console_rcar_t *console);
#endif /*__ASSEMBLY__*/
#endif /* RCAR_PRINTF_H */
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
.globl plat_crash_console_init .globl plat_crash_console_init
.globl plat_crash_console_putc .globl plat_crash_console_putc
.globl plat_crash_console_flush .globl plat_crash_console_flush
.globl plat_invalidate_icache .globl plat_invalidate_icache
.globl plat_report_exception .globl plat_report_exception
.globl plat_secondary_reset .globl plat_secondary_reset
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
.globl plat_my_core_pos .globl plat_my_core_pos
.extern rcar_log_init .extern rcar_log_init
.extern console_rcar_init
.extern console_rcar_putc
.extern console_rcar_flush
#if IMAGE_BL2 #if IMAGE_BL2
#define INT_ID_MASK (0x3ff) #define INT_ID_MASK (0x3ff)
.extern bl2_interrupt_error_type .extern bl2_interrupt_error_type
...@@ -258,7 +262,7 @@ func plat_crash_console_init ...@@ -258,7 +262,7 @@ func plat_crash_console_init
mov sp, x2 mov sp, x2
str x1, [sp, #-16]! str x1, [sp, #-16]!
str x30, [sp, #-16]! str x30, [sp, #-16]!
bl console_core_init bl console_rcar_init
ldr x30, [sp], #16 ldr x30, [sp], #16
ldr x1, [sp], #16 ldr x1, [sp], #16
mov sp, x1 mov sp, x1
...@@ -280,7 +284,7 @@ func plat_crash_console_putc ...@@ -280,7 +284,7 @@ func plat_crash_console_putc
str x3, [sp, #-16]! str x3, [sp, #-16]!
str x4, [sp, #-16]! str x4, [sp, #-16]!
str x5, [sp, #-16]! str x5, [sp, #-16]!
bl console_core_putc bl console_rcar_putc
ldr x5, [sp], #16 ldr x5, [sp], #16
ldr x4, [sp], #16 ldr x4, [sp], #16
ldr x3, [sp], #16 ldr x3, [sp], #16
...@@ -292,11 +296,10 @@ endfunc plat_crash_console_putc ...@@ -292,11 +296,10 @@ endfunc plat_crash_console_putc
/* --------------------------------------------- /* ---------------------------------------------
* int plat_crash_console_flush() * int plat_crash_console_flush()
*
* --------------------------------------------- * ---------------------------------------------
*/ */
func plat_crash_console_flush func plat_crash_console_flush
b console_flush b console_rcar_flush
endfunc plat_crash_console_flush endfunc plat_crash_console_flush
/* -------------------------------------------------------------------- /* --------------------------------------------------------------------
......
/* /*
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -686,8 +686,7 @@ void bl2_el3_early_platform_setup(u_register_t arg1, u_register_t arg2, ...@@ -686,8 +686,7 @@ void bl2_el3_early_platform_setup(u_register_t arg1, u_register_t arg2,
if (boot_cpu == MODEMR_BOOT_CPU_CA57 || if (boot_cpu == MODEMR_BOOT_CPU_CA57 ||
boot_cpu == MODEMR_BOOT_CPU_CA53) { boot_cpu == MODEMR_BOOT_CPU_CA53) {
rcar_pfc_init(); rcar_pfc_init();
/* console configuration (platform specific) done in driver */ rcar_console_boot_init();
console_init(0, 0, 0);
} }
plat_rcar_gic_driver_init(); plat_rcar_gic_driver_init();
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved. * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -79,9 +79,7 @@ struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type) ...@@ -79,9 +79,7 @@ struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type)
void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3) u_register_t arg2, u_register_t arg3)
{ {
/* dummy config: the actual console configuration (platform specific) rcar_console_runtime_init();
is done in the driver (scif.c) */
console_init(1, 0, 0);
NOTICE("BL3-1 : Rev.%s\n", version_of_renesas); NOTICE("BL3-1 : Rev.%s\n", version_of_renesas);
......
/* /*
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -99,4 +99,9 @@ void plat_cci_init(void); ...@@ -99,4 +99,9 @@ void plat_cci_init(void);
void mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit); void mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit);
void cpg_write(uintptr_t regadr, uint32_t regval); void cpg_write(uintptr_t regadr, uint32_t regval);
void rcar_console_boot_init(void);
void rcar_console_boot_end(void);
void rcar_console_runtime_init(void);
void rcar_console_runtime_end(void);
#endif /* RCAR_PRIVATE_H */ #endif /* RCAR_PRIVATE_H */
# #
# 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 # SPDX-License-Identifier: BSD-3-Clause
# #
...@@ -12,6 +12,7 @@ RESET_TO_BL31 := 1 ...@@ -12,6 +12,7 @@ RESET_TO_BL31 := 1
GENERATE_COT := 1 GENERATE_COT := 1
BL2_AT_EL3 := 1 BL2_AT_EL3 := 1
ENABLE_SVE_FOR_NS := 0 ENABLE_SVE_FOR_NS := 0
MULTI_CONSOLE_API := 1
CRASH_REPORTING := 1 CRASH_REPORTING := 1
HANDLE_EA_EL3_FIRST := 1 HANDLE_EA_EL3_FIRST := 1
......
...@@ -67,3 +67,38 @@ void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie, ...@@ -67,3 +67,38 @@ void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie,
panic(); panic();
} }
#include <drivers/renesas/rcar/console/console.h>
static console_rcar_t rcar_boot_console;
static console_rcar_t rcar_runtime_console;
void rcar_console_boot_init(void)
{
int ret;
ret = console_rcar_register(0, 0, 0, &rcar_boot_console);
if (!ret)
panic();
console_set_scope(&rcar_boot_console.console, CONSOLE_FLAG_BOOT);
}
void rcar_console_boot_end(void)
{
}
void rcar_console_runtime_init(void)
{
int ret;
ret = console_rcar_register(1, 0, 0, &rcar_runtime_console);
if (!ret)
panic();
console_set_scope(&rcar_boot_console.console, CONSOLE_FLAG_RUNTIME);
}
void rcar_console_runtime_end(void)
{
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment