xref: /rk3399_ARM-atf/plat/imx/common/lpuart_console.S (revision c948f77136c42a92d0bb660543a3600c36dcf7f1)
1/*
2 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#define USE_FINISH_CONSOLE_REG_2
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
18	.globl	console_lpuart_flush
19
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
31	finish_console_register lpuart putc=1, getc=1, flush=1
32
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
74
75func console_lpuart_flush
76	mov	x0, #0
77	ret
78endfunc console_lpuart_flush
79