blob: 859efeceb43f25f645b2f78be4511af1f2c9ed0b [file] [log] [blame]
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +02001/*
Marek Vasut0aa268e2019-05-18 19:29:16 +02002 * Copyright (c) 2018-2019, Renesas Electronics Corporation. All rights reserved.
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
Marek Vasut0aa268e2019-05-18 19:29:16 +02009#include <console_macros.S>
10#include <drivers/renesas/rcar/console/console.h>
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020011
Marek Vasut0aa268e2019-05-18 19:29:16 +020012 .globl console_rcar_register
13 .globl console_rcar_init
14 .globl console_rcar_putc
15 .globl console_rcar_flush
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020016
17 .extern rcar_log_init
18 .extern rcar_set_log_data
19
20 /* -----------------------------------------------
Marek Vasut0aa268e2019-05-18 19:29:16 +020021 * int console_rcar_register(
22 * uintptr_t base, uint32_t clk, uint32_t baud,
23 * console_rcar_t *console)
24 * Function to initialize and register a new rcar
25 * console. Storage passed in for the console struct
26 * *must* be persistent (i.e. not from the stack).
27 * In: x0 - UART register base address
28 * w1 - UART clock in Hz
29 * w2 - Baud rate
30 * x3 - pointer to empty console_rcar_t struct
31 * Out: return 1 on success, 0 on error
32 * Clobber list : x0, x1, x2, x6, x7, x14
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020033 * -----------------------------------------------
34 */
Marek Vasut0aa268e2019-05-18 19:29:16 +020035func console_rcar_register
36 mov x7, x30
37 mov x6, x3
38 cbz x6, register_fail
39 str x0, [x6, #CONSOLE_T_RCAR_BASE]
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020040
Marek Vasut0aa268e2019-05-18 19:29:16 +020041 bl rcar_log_init
42 cbz x0, register_fail
43
44 mov x0, x6
45 mov x30, x7
46 finish_console_register rcar, putc=1, getc=0, flush=1
47
48register_fail:
49 ret x7
50endfunc console_rcar_register
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020051
52 /* ---------------------------------------------
Marek Vasut0aa268e2019-05-18 19:29:16 +020053 * int console_rcar_init(unsigned long base_addr,
54 * unsigned int uart_clk, unsigned int baud_rate)
55 * Function to initialize the console without a
56 * C Runtime to print debug information. This
57 * function will be accessed by crash reporting.
58 * In: x0 - console base address
59 * w1 - Uart clock in Hz
60 * w2 - Baud rate
61 * Out: return 1 on success
62 * Clobber list : x1, x2
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020063 * ---------------------------------------------
64 */
Marek Vasut0aa268e2019-05-18 19:29:16 +020065func console_rcar_init
66 mov w0, #0
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020067 ret
Marek Vasut0aa268e2019-05-18 19:29:16 +020068endfunc console_rcar_init
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020069
Marek Vasut0aa268e2019-05-18 19:29:16 +020070 /* --------------------------------------------------------
71 * int console_rcar_putc(int c, console_rcar_t *console)
72 * Function to output a character over the console. It
73 * returns the character printed on success or -1 on error.
74 * In : w0 - character to be printed
75 * x1 - pointer to console_rcar_t structure
76 * Out : return -1 on error else return character.
77 * Clobber list : x2
78 * --------------------------------------------------------
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020079 */
Marek Vasut0aa268e2019-05-18 19:29:16 +020080func console_rcar_putc
81 b rcar_set_log_data
82endfunc console_rcar_putc
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020083
84 /* ---------------------------------------------
Marek Vasut0aa268e2019-05-18 19:29:16 +020085 * int console_rcar_flush(void)
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020086 * Function to force a write of all buffered
87 * data that hasn't been output. It returns 0
88 * upon successful completion, otherwise it
89 * returns -1.
90 * Clobber list : x0, x1
91 * ---------------------------------------------
92 */
Marek Vasut0aa268e2019-05-18 19:29:16 +020093func console_rcar_flush
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020094 mov w0, #0
95 ret
Marek Vasut0aa268e2019-05-18 19:29:16 +020096endfunc console_rcar_flush