blob: 01628680f770832e9a42f229d94e48b73e5de1ef [file] [log] [blame]
Anson Huang5aba17f2018-06-05 16:11:24 +08001/*
Anson Huangedf6d7d2019-01-15 13:53:03 +08002 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
Anson Huang5aba17f2018-06-05 16:11:24 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
Soby Mathew58873ae2018-10-10 16:03:09 +01009#define USE_FINISH_CONSOLE_REG_2
Anson Huang5aba17f2018-06-05 16:11:24 +080010#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 Huangedf6d7d2019-01-15 13:53:03 +080018 .globl console_lpuart_flush
Anson Huang5aba17f2018-06-05 16:11:24 +080019
20func 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 Huangedf6d7d2019-01-15 13:53:03 +080031 finish_console_register lpuart putc=1, getc=1, flush=1
Anson Huang5aba17f2018-06-05 16:11:24 +080032
33register_fail:
34 ret x7
35endfunc console_lpuart_register
36
37func console_lpuart_init
38 mov w0, #1
39 ret
40endfunc console_lpuart_init
41
42func 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
481:
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]
542:
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
60putc_error:
61 mov w0, #-1
62 ret
63endfunc console_lpuart_putc
64
65func console_lpuart_getc
66 ldr x0, [x0, #CONSOLE_T_DRVDATA]
67 cbz x0, getc_error
68 /* Check if the receive FIFO state */
69 ret
70getc_error:
71 mov w0, #-1
72 ret
73endfunc console_lpuart_getc
Anson Huangedf6d7d2019-01-15 13:53:03 +080074
75func console_lpuart_flush
76 mov x0, #0
77 ret
78endfunc console_lpuart_flush