• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// SPDX-License-Identifier: GPL-2.0
2
3// Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
4
5#include <platform.h>
6
7@******************************************************************************
8@
9@  void uart_early_init(void);
10@
11.text
12.align	2
13.global	uart_early_init
14.type	uart_early_init, %function
15uart_early_init:
16	ldr	a4, uart_base_addr_L0
17	mov	a3, #0
18	/* Disable UART */
19	str	a3, [a4, #48]
20	/* Set baud rate to 115200, uart clock:24M */
21	add	a3, a3, #13
22	str	a3, [a4, #36]
23	mov	a3, #1
24	str	a3, [a4, #40]
25	/* Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled. */
26	ldr	a3, =112
27	str	a3, [a4, #44]
28	/* Enable UART */
29	ldr	a3, =769
30	str	a3, [a4, #48]
31	bx	lr
32uart_base_addr_L0:
33	.word UART0_REG_BASE
34
35@******************************************************************************
36@
37@  void uart_early_puts(const char *ss);
38@
39.align	2
40.global	uart_early_puts
41.type	uart_early_puts, %function
42uart_early_puts:
43#if !defined(CONFIG_SUPPORT_CA_RELEASE)
44	ldr	a2, uart_base_addr_L1
45	b	next_char
46output:
47	ldr	a4, [a2, #24]
48	tst	a4, #32
49	bne	output
50	str	a3, [a2, #0]
51	add	a1, a1, #1
52next_char:
53	ldrb	a3, [a1]
54	cmp	a3, #0
55	bne	output
56#endif /* CONFIG_SUPPORT_CA_RELEASE */
57	bx	lr
58uart_base_addr_L1:
59	.word UART0_REG_BASE
60
61@******************************************************************************
62@
63@  void uart_early_put_hex(int hex);
64@
65@  call example:
66@    mov	r0, sp
67@    bl	uart_early_put_hex
68@
69.align	2
70.global	uart_early_put_hex
71.type	uart_early_put_hex, %function
72uart_early_put_hex:
73#if !defined(CONFIG_SUPPORT_CA_RELEASE)
74	ldr	a2, uart_base_addr_L2
75	mov	a3, #28
76wait2:
77	ldr	a4, [a2, #24]
78	tst	a4, #32
79	bne	wait2
80
81	mov	a4, #0xF
82	and	a4, a4, a1, lsr a3
83	cmp	a4, #9
84	addle	a4, a4, #0x30	@ a4 = a4 + '0'
85	addgt	a4, a4, #55	@ a4 = a4 - 10 + 'A'
86	str	a4, [a2, #0]
87	cmp	a3, #0
88	beq	exit2
89	sub	a3, a3, #4
90	b	wait2
91exit2:
92#endif /* CONFIG_SUPPORT_CA_RELEASE */
93	bx	lr
94uart_base_addr_L2:
95	.word UART0_REG_BASE
96
97@******************************************************************************
98@
99@  void uart_early_putc(int chr);
100@
101@  call example:
102@    mov	r0, #'A'
103@    bl	uart_early_putc
104@
105.align	2
106.global	uart_early_putc
107.type	uart_early_putc, %function
108uart_early_putc:
109#if !defined(CONFIG_SUPPORT_CA_RELEASE)
110	ldr	a2, uart_base_addr_L3
111wait3:
112	ldr	a4, [a2, #24]
113	tst	a4, #32
114	bne	wait3
115	str	a1, [a2, #0]
116
117#endif /* CONFIG_SUPPORT_CA_RELEASE */
118	bx	lr
119uart_base_addr_L3:
120	.word UART0_REG_BASE
121