xref: /arm-trusted-firmware/drivers/renesas/common/console/rcar_console.S (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu/*
2*91f16700Schasinglulu * Copyright (c) 2018-2021, Renesas Electronics Corporation. All rights reserved.
3*91f16700Schasinglulu *
4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu */
6*91f16700Schasinglulu
7*91f16700Schasinglulu#include <arch.h>
8*91f16700Schasinglulu#include <asm_macros.S>
9*91f16700Schasinglulu#include <console_macros.S>
10*91f16700Schasinglulu#include <drivers/renesas/rcar/console/console.h>
11*91f16700Schasinglulu
12*91f16700Schasinglulu	.globl	console_rcar_register
13*91f16700Schasinglulu	.globl	console_rcar_init
14*91f16700Schasinglulu	.globl	console_rcar_putc
15*91f16700Schasinglulu	.globl	console_rcar_flush
16*91f16700Schasinglulu
17*91f16700Schasinglulu	.extern	rcar_log_init
18*91f16700Schasinglulu	.extern	rcar_set_log_data
19*91f16700Schasinglulu
20*91f16700Schasinglulu	/* -----------------------------------------------
21*91f16700Schasinglulu	 * int console_rcar_register(
22*91f16700Schasinglulu	 *      uintptr_t base, uint32_t clk, uint32_t baud,
23*91f16700Schasinglulu	 *      console_t *console)
24*91f16700Schasinglulu	 * Function to initialize and register a new rcar
25*91f16700Schasinglulu	 * console. Storage passed in for the console struct
26*91f16700Schasinglulu	 * *must* be persistent (i.e. not from the stack).
27*91f16700Schasinglulu	 * In: x0 - UART register base address
28*91f16700Schasinglulu	 *     w1 - UART clock in Hz
29*91f16700Schasinglulu	 *     w2 - Baud rate
30*91f16700Schasinglulu	 *     x3 - pointer to empty console_t struct
31*91f16700Schasinglulu	 * Out: return 1 on success, 0 on error
32*91f16700Schasinglulu	 * Clobber list : x0, x1, x2, x6, x7, x14
33*91f16700Schasinglulu	 * -----------------------------------------------
34*91f16700Schasinglulu	 */
35*91f16700Schasinglulufunc console_rcar_register
36*91f16700Schasinglulu	mov	x7, x30
37*91f16700Schasinglulu	mov	x6, x3
38*91f16700Schasinglulu	cbz	x6, register_fail
39*91f16700Schasinglulu	str	x0, [x6, #CONSOLE_T_BASE]
40*91f16700Schasinglulu
41*91f16700Schasinglulu	bl	rcar_log_init
42*91f16700Schasinglulu	cbz	x0, register_fail
43*91f16700Schasinglulu
44*91f16700Schasinglulu	mov	x0, x6
45*91f16700Schasinglulu	mov	x30, x7
46*91f16700Schasinglulu	finish_console_register rcar, putc=1, getc=0, flush=1
47*91f16700Schasinglulu
48*91f16700Schasingluluregister_fail:
49*91f16700Schasinglulu	ret	x7
50*91f16700Schasingluluendfunc console_rcar_register
51*91f16700Schasinglulu
52*91f16700Schasinglulu	/* ---------------------------------------------
53*91f16700Schasinglulu	 * int console_rcar_init(unsigned long base_addr,
54*91f16700Schasinglulu	 * unsigned int uart_clk, unsigned int baud_rate)
55*91f16700Schasinglulu	 * Function to initialize the console without a
56*91f16700Schasinglulu	 * C Runtime to print debug information. This
57*91f16700Schasinglulu	 * function will be accessed by crash reporting.
58*91f16700Schasinglulu	 * In: x0 - console base address
59*91f16700Schasinglulu	 *     w1 - Uart clock in Hz
60*91f16700Schasinglulu	 *     w2 - Baud rate
61*91f16700Schasinglulu	 * Out: return 1 on success
62*91f16700Schasinglulu	 * Clobber list : x1, x2
63*91f16700Schasinglulu	 * ---------------------------------------------
64*91f16700Schasinglulu	 */
65*91f16700Schasinglulufunc console_rcar_init
66*91f16700Schasinglulu	mov	w0, #1
67*91f16700Schasinglulu	ret
68*91f16700Schasingluluendfunc console_rcar_init
69*91f16700Schasinglulu
70*91f16700Schasinglulu	/* --------------------------------------------------------
71*91f16700Schasinglulu	 * int console_rcar_putc(int c, console_t *console)
72*91f16700Schasinglulu	 * Function to output a character over the console. It
73*91f16700Schasinglulu	 * returns the character printed on success or -1 on error.
74*91f16700Schasinglulu	 * In : w0 - character to be printed
75*91f16700Schasinglulu	 *      x1 - pointer to console_t structure
76*91f16700Schasinglulu	 * Out : return -1 on error else return character.
77*91f16700Schasinglulu	 * Clobber list : x2
78*91f16700Schasinglulu	 * --------------------------------------------------------
79*91f16700Schasinglulu	 */
80*91f16700Schasinglulufunc console_rcar_putc
81*91f16700Schasinglulu	b	rcar_set_log_data
82*91f16700Schasingluluendfunc console_rcar_putc
83*91f16700Schasinglulu
84*91f16700Schasinglulu	/* ---------------------------------------------
85*91f16700Schasinglulu	 * void console_rcar_flush(void)
86*91f16700Schasinglulu	 * Function to force a write of all buffered
87*91f16700Schasinglulu	 * data that hasn't been output. It returns void
88*91f16700Schasinglulu	 * Clobber list : x0, x1
89*91f16700Schasinglulu	 * ---------------------------------------------
90*91f16700Schasinglulu	 */
91*91f16700Schasinglulufunc console_rcar_flush
92*91f16700Schasinglulu	ret
93*91f16700Schasingluluendfunc console_rcar_flush
94