uniphier_console.S 1.42 KB
Newer Older
1
/*
2
 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <asm_macros.S>
8
#include <drivers/console.h>
9

10
#include "uniphier_console.h"
11
12
13

/*
 * In: w0 - character to be printed
14
15
 *     x1 - pointer to console structure
 * Out: return the character written (always succeeds)
16
17
 * Clobber: x2
 */
18
19
20
	.globl	uniphier_console_putc
func uniphier_console_putc
	ldr	x1, [x1, #CONSOLE_T_DRVDATA]
21
22
23
24
25

	/* Wait until the transmitter FIFO gets empty */
0:	ldr	w2, [x1, #UNIPHIER_UART_LSR]
	tbz	w2, #UNIPHIER_UART_LSR_THRE_BIT, 0b

26
	str	w0, [x1, #UNIPHIER_UART_TX]
27

28
	ret
29
endfunc uniphier_console_putc
30
31

/*
32
33
34
 * In: x0 - pointer to console structure
 * Out: return the character read, or ERROR_NO_PENDING_CHAR if no character
	is available
35
36
 * Clobber: x1
 */
37
38
39
	.globl	uniphier_console_getc
func uniphier_console_getc
	ldr	x0, [x0, #CONSOLE_T_DRVDATA]
40

41
42
	ldr	w1, [x0, #UNIPHIER_UART_LSR]
	tbz	w1, #UNIPHIER_UART_LSR_DR_BIT, 0f
43
44
45

	ldr	w0, [x0, #UNIPHIER_UART_RX]
	ret
46
47

0:	mov	w0, #ERROR_NO_PENDING_CHAR
48
	ret
49
endfunc uniphier_console_getc
50
51

/*
52
53
 * In: x0 - pointer to console structure
 * Out: return 0 (always succeeds)
54
55
 * Clobber: x1
 */
56
57
58
	.global uniphier_console_flush
func uniphier_console_flush
	ldr	x0, [x0, #CONSOLE_T_DRVDATA]
59
60
61
62
63
64
65

	/* wait until the transmitter gets empty */
0:	ldr	w1, [x0, #UNIPHIER_UART_LSR]
	tbz	w1, #UNIPHIER_UART_LSR_TEMT_BIT, 0b

	mov	w0, #0
	ret
66
endfunc uniphier_console_flush