Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 1 | /* |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Renesas Electronics Corporation. All rights reserved. |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 9 | #include <console_macros.S> |
| 10 | #include <drivers/renesas/rcar/console/console.h> |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 11 | |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 12 | .globl console_rcar_register |
| 13 | .globl console_rcar_init |
| 14 | .globl console_rcar_putc |
| 15 | .globl console_rcar_flush |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 16 | |
| 17 | .extern rcar_log_init |
| 18 | .extern rcar_set_log_data |
| 19 | |
| 20 | /* ----------------------------------------------- |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 21 | * int console_rcar_register( |
| 22 | * uintptr_t base, uint32_t clk, uint32_t baud, |
Andre Przywara | 52fb049 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 23 | * console_t *console) |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 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 |
Andre Przywara | 52fb049 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 30 | * x3 - pointer to empty console_t struct |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 31 | * Out: return 1 on success, 0 on error |
| 32 | * Clobber list : x0, x1, x2, x6, x7, x14 |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 33 | * ----------------------------------------------- |
| 34 | */ |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 35 | func console_rcar_register |
| 36 | mov x7, x30 |
| 37 | mov x6, x3 |
| 38 | cbz x6, register_fail |
Andre Przywara | 52fb049 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 39 | str x0, [x6, #CONSOLE_T_BASE] |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 40 | |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 41 | 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 | |
| 48 | register_fail: |
| 49 | ret x7 |
| 50 | endfunc console_rcar_register |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 51 | |
| 52 | /* --------------------------------------------- |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 53 | * 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-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 63 | * --------------------------------------------- |
| 64 | */ |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 65 | func console_rcar_init |
| 66 | mov w0, #0 |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 67 | ret |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 68 | endfunc console_rcar_init |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 69 | |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 70 | /* -------------------------------------------------------- |
Andre Przywara | 52fb049 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 71 | * int console_rcar_putc(int c, console_t *console) |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 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 |
Andre Przywara | 52fb049 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 75 | * x1 - pointer to console_t structure |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 76 | * Out : return -1 on error else return character. |
| 77 | * Clobber list : x2 |
| 78 | * -------------------------------------------------------- |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 79 | */ |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 80 | func console_rcar_putc |
| 81 | b rcar_set_log_data |
| 82 | endfunc console_rcar_putc |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 83 | |
| 84 | /* --------------------------------------------- |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 85 | * int console_rcar_flush(void) |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 86 | * 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 Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 93 | func console_rcar_flush |
Jorge Ramirez-Ortiz | f1751c0 | 2018-09-23 09:41:00 +0200 | [diff] [blame] | 94 | mov w0, #0 |
| 95 | ret |
Marek Vasut | 0aa268e | 2019-05-18 19:29:16 +0200 | [diff] [blame] | 96 | endfunc console_rcar_flush |