• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute  it and/or modify it
5 * under  the terms of  the GNU General  Public License as published by the
6 * Free Software Foundation;  either version 2 of the  License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19#include <config.h>
20
21@******************************************************************************
22@
23@  void uart_early_init(void);
24@
25.text
26.align	2
27.global	uart_early_init
28.type	uart_early_init, %function
29uart_early_init:
30#ifndef CONFIG_HISI_DISABLE_CONSOLE
31	ldr	a4, uart_base_addr_L0
32	mov	a3, #0
33	/* Disable UART */
34	str	a3, [a4, #48]
35	/* Set baud rate to 115200, uart clock:24M */
36	add	a3, a3, #13
37	str	a3, [a4, #36]
38	mov	a3, #1
39	str	a3, [a4, #40]
40	/* Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled. */
41	ldr	a3, =112
42	str	a3, [a4, #44]
43	/* Enable UART */
44	ldr	a3, =769
45	str	a3, [a4, #48]
46#endif
47	bx	lr
48uart_base_addr_L0:
49	.word CONFIG_CUR_UART_BASE
50
51@******************************************************************************
52@
53@  void uart_early_puts(const char *ss);
54@
55.align	2
56.global	uart_early_puts
57.type	uart_early_puts, %function
58uart_early_puts:
59#ifndef CONFIG_HISI_DISABLE_CONSOLE
60#if !defined(CONFIG_SUPPORT_CA_RELEASE)
61	ldr	a2, uart_base_addr_L1
62	b	next_char
63output:
64	ldr	a4, [a2, #24]
65	tst	a4, #32
66	bne	output
67	str	a3, [a2, #0]
68	add	a1, a1, #1
69next_char:
70	ldrb	a3, [a1]
71	cmp	a3, #0
72	bne	output
73#endif /* CONFIG_SUPPORT_CA_RELEASE */
74#endif /* CONFIG_HISI_DISABLE_CONSOLE */
75	bx	lr
76uart_base_addr_L1:
77	.word CONFIG_CUR_UART_BASE
78
79@******************************************************************************
80@
81@  void uart_early_put_hex(int hex);
82@
83@  call example:
84@    mov	r0, sp
85@    bl	uart_early_put_hex
86@
87.align	2
88.global	uart_early_put_hex
89.type	uart_early_put_hex, %function
90uart_early_put_hex:
91#if !defined(CONFIG_SUPPORT_CA_RELEASE)
92	ldr	a2, uart_base_addr_L2
93	mov	a3, #28
94wait2:
95	ldr	a4, [a2, #24]
96	tst	a4, #32
97	bne	wait2
98
99	mov	a4, #0xF
100	and	a4, a4, a1, lsr a3
101	cmp	a4, #9
102	addle	a4, a4, #0x30	@ a4 = a4 + '0'
103	addgt	a4, a4, #55	@ a4 = a4 - 10 + 'A'
104	str	a4, [a2, #0]
105	cmp	a3, #0
106	beq	exit2
107	sub	a3, a3, #4
108	b	wait2
109exit2:
110#endif /* CONFIG_SUPPORT_CA_RELEASE */
111	bx	lr
112uart_base_addr_L2:
113	.word CONFIG_CUR_UART_BASE
114
115@******************************************************************************
116@
117@  void uart_early_putc(int chr);
118@
119@  call example:
120@    mov	r0, #'A'
121@    bl	uart_early_putc
122@
123.align	2
124.global	uart_early_putc
125.type	uart_early_putc, %function
126uart_early_putc:
127#ifndef CONFIG_HISI_DISABLE_CONSOLE
128#if !defined(CONFIG_SUPPORT_CA_RELEASE)
129	ldr	a2, uart_base_addr_L3
130wait3:
131	ldr	a4, [a2, #24]
132	tst	a4, #32
133	bne	wait3
134	str	a1, [a2, #0]
135
136#endif /* CONFIG_SUPPORT_CA_RELEASE */
137#endif /* CONFIG_HISI_DISABLE_CONSOLE */
138	bx	lr
139uart_base_addr_L3:
140	.word CONFIG_CUR_UART_BASE
141