blob: 29baa67a4a708e8f78768927edf762d07b8dea3d [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,
Andre Przywara52fb0492020-01-25 00:58:35 +000023 * console_t *console)
Marek Vasut0aa268e2019-05-18 19:29:16 +020024 * 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
Andre Przywara52fb0492020-01-25 00:58:35 +000030 * x3 - pointer to empty console_t struct
Marek Vasut0aa268e2019-05-18 19:29:16 +020031 * 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
Andre Przywara52fb0492020-01-25 00:58:35 +000039 str x0, [x6, #CONSOLE_T_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 /* --------------------------------------------------------
Andre Przywara52fb0492020-01-25 00:58:35 +000071 * int console_rcar_putc(int c, console_t *console)
Marek Vasut0aa268e2019-05-18 19:29:16 +020072 * 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
Andre Przywara52fb0492020-01-25 00:58:35 +000075 * x1 - pointer to console_t structure
Marek Vasut0aa268e2019-05-18 19:29:16 +020076 * 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 /* ---------------------------------------------
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050085 * void console_rcar_flush(void)
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020086 * Function to force a write of all buffered
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050087 * data that hasn't been output. It returns void
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020088 * Clobber list : x0, x1
89 * ---------------------------------------------
90 */
Marek Vasut0aa268e2019-05-18 19:29:16 +020091func console_rcar_flush
Jorge Ramirez-Ortizf1751c02018-09-23 09:41:00 +020092 ret
Marek Vasut0aa268e2019-05-18 19:29:16 +020093endfunc console_rcar_flush