Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 1 | /* |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Soby Mathew | 58873ae | 2018-10-10 16:03:09 +0100 | [diff] [blame] | 9 | #define USE_FINISH_CONSOLE_REG_2 |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 10 | #include <console_macros.S> |
| 11 | #include <assert_macros.S> |
| 12 | #include "imx8_lpuart.h" |
| 13 | |
| 14 | .globl console_lpuart_register |
| 15 | .globl console_lpuart_init |
| 16 | .globl console_lpuart_putc |
| 17 | .globl console_lpuart_getc |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 18 | .globl console_lpuart_flush |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 19 | |
| 20 | func console_lpuart_register |
| 21 | mov x7, x30 |
| 22 | mov x6, x3 |
| 23 | cbz x6, register_fail |
| 24 | str x0, [x6, #CONSOLE_T_DRVDATA] |
| 25 | |
| 26 | bl console_lpuart_init |
| 27 | cbz x0, register_fail |
| 28 | |
| 29 | mov x0, x6 |
| 30 | mov x30, x7 |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 31 | finish_console_register lpuart putc=1, getc=1, flush=1 |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 32 | |
| 33 | register_fail: |
| 34 | ret x7 |
| 35 | endfunc console_lpuart_register |
| 36 | |
| 37 | func console_lpuart_init |
| 38 | mov w0, #1 |
| 39 | ret |
| 40 | endfunc console_lpuart_init |
| 41 | |
| 42 | func console_lpuart_putc |
| 43 | ldr x1, [x1, #CONSOLE_T_DRVDATA] |
| 44 | cbz x1, putc_error |
| 45 | /* Prepare '\r' to '\n' */ |
| 46 | cmp w0, #0xA |
| 47 | b.ne 2f |
| 48 | 1: |
| 49 | /* Check if the transmit FIFO is full */ |
| 50 | ldr w2, [x1, #STAT] |
| 51 | tbz w2, #23, 1b |
| 52 | mov w2, #0xD |
| 53 | str w2, [x1, #DATA] |
| 54 | 2: |
| 55 | /* Check if the transmit FIFO is full */ |
| 56 | ldr w2, [x1, #STAT] |
| 57 | tbz w2, #23, 2b |
| 58 | str w0, [x1, #DATA] |
| 59 | ret |
| 60 | putc_error: |
| 61 | mov w0, #-1 |
| 62 | ret |
| 63 | endfunc console_lpuart_putc |
| 64 | |
| 65 | func console_lpuart_getc |
| 66 | ldr x0, [x0, #CONSOLE_T_DRVDATA] |
| 67 | cbz x0, getc_error |
| 68 | /* Check if the receive FIFO state */ |
| 69 | ret |
| 70 | getc_error: |
| 71 | mov w0, #-1 |
| 72 | ret |
| 73 | endfunc console_lpuart_getc |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 74 | |
| 75 | func console_lpuart_flush |
| 76 | mov x0, #0 |
| 77 | ret |
| 78 | endfunc console_lpuart_flush |