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> |
| 9 | #include <console_macros.S> |
| 10 | #include <assert_macros.S> |
| 11 | #include "imx8_lpuart.h" |
| 12 | |
| 13 | .globl console_lpuart_register |
| 14 | .globl console_lpuart_init |
| 15 | .globl console_lpuart_putc |
| 16 | .globl console_lpuart_getc |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 17 | .globl console_lpuart_flush |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 18 | |
| 19 | func console_lpuart_register |
| 20 | mov x7, x30 |
| 21 | mov x6, x3 |
| 22 | cbz x6, register_fail |
Andre Przywara | ab26920 | 2020-03-05 13:56:56 +0000 | [diff] [blame] | 23 | str x0, [x6, #CONSOLE_T_BASE] |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 24 | |
| 25 | bl console_lpuart_init |
| 26 | cbz x0, register_fail |
| 27 | |
| 28 | mov x0, x6 |
| 29 | mov x30, x7 |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 30 | finish_console_register lpuart putc=1, getc=1, flush=1 |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 31 | |
| 32 | register_fail: |
| 33 | ret x7 |
| 34 | endfunc console_lpuart_register |
| 35 | |
| 36 | func console_lpuart_init |
| 37 | mov w0, #1 |
| 38 | ret |
| 39 | endfunc console_lpuart_init |
| 40 | |
| 41 | func console_lpuart_putc |
Andre Przywara | ab26920 | 2020-03-05 13:56:56 +0000 | [diff] [blame] | 42 | ldr x1, [x1, #CONSOLE_T_BASE] |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 43 | cbz x1, putc_error |
| 44 | /* Prepare '\r' to '\n' */ |
| 45 | cmp w0, #0xA |
| 46 | b.ne 2f |
| 47 | 1: |
| 48 | /* Check if the transmit FIFO is full */ |
| 49 | ldr w2, [x1, #STAT] |
| 50 | tbz w2, #23, 1b |
| 51 | mov w2, #0xD |
| 52 | str w2, [x1, #DATA] |
| 53 | 2: |
| 54 | /* Check if the transmit FIFO is full */ |
| 55 | ldr w2, [x1, #STAT] |
| 56 | tbz w2, #23, 2b |
| 57 | str w0, [x1, #DATA] |
| 58 | ret |
| 59 | putc_error: |
| 60 | mov w0, #-1 |
| 61 | ret |
| 62 | endfunc console_lpuart_putc |
| 63 | |
| 64 | func console_lpuart_getc |
Andre Przywara | ab26920 | 2020-03-05 13:56:56 +0000 | [diff] [blame] | 65 | ldr x0, [x0, #CONSOLE_T_BASE] |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 66 | cbz x0, getc_error |
| 67 | /* Check if the receive FIFO state */ |
| 68 | ret |
| 69 | getc_error: |
| 70 | mov w0, #-1 |
| 71 | ret |
| 72 | endfunc console_lpuart_getc |
Anson Huang | edf6d7d | 2019-01-15 13:53:03 +0800 | [diff] [blame] | 73 | |
| 74 | func console_lpuart_flush |
| 75 | mov x0, #0 |
| 76 | ret |
| 77 | endfunc console_lpuart_flush |