rcar_console.S 2.74 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2019, Renesas Electronics Corporation. All rights reserved.
3
4
5
6
7
8
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch.h>
#include <asm_macros.S>
9
10
#include <console_macros.S>
#include <drivers/renesas/rcar/console/console.h>
11

12
13
14
15
	.globl	console_rcar_register
	.globl	console_rcar_init
	.globl	console_rcar_putc
	.globl	console_rcar_flush
16
17
18
19
20

	.extern	rcar_log_init
	.extern	rcar_set_log_data

	/* -----------------------------------------------
21
22
23
24
25
26
27
28
29
30
31
32
	 * 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
33
34
	 * -----------------------------------------------
	 */
35
36
37
38
39
func console_rcar_register
	mov	x7, x30
	mov	x6, x3
	cbz	x6, register_fail
	str	x0, [x6, #CONSOLE_T_RCAR_BASE]
40

41
42
43
44
45
46
47
48
49
50
	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
51
52

	/* ---------------------------------------------
53
54
55
56
57
58
59
60
61
62
	 * 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
63
64
	 * ---------------------------------------------
	 */
65
66
func console_rcar_init
	mov	w0, #0
67
	ret
68
endfunc console_rcar_init
69

70
71
72
73
74
75
76
77
78
	/* --------------------------------------------------------
	 * 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
	 * --------------------------------------------------------
79
	 */
80
81
82
func console_rcar_putc
	b	rcar_set_log_data
endfunc console_rcar_putc
83
84

	/* ---------------------------------------------
85
	 * int console_rcar_flush(void)
86
87
88
89
90
91
92
	 * 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
	 * ---------------------------------------------
	 */
93
func console_rcar_flush
94
95
	mov	w0, #0
	ret
96
endfunc console_rcar_flush