]>
Commit | Line | Data |
---|---|---|
07d8d35a | 1 | /* |
2 | * (C) Copyright 2015 Rockchip Electronics Co., Ltd | |
3 | * | |
4 | * SPDX-License-Identifier: GPL-2.0+ | |
5 | */ | |
6 | ||
7 | #include <asm/io.h> | |
8 | #include <asm/arch/uart.h> | |
9 | #include <common.h> | |
10 | ||
11 | static struct rk_uart *uart_ptr; | |
12 | ||
13 | static void uart_wrtie_byte(char byte) | |
14 | { | |
15 | writel(byte, &uart_ptr->rbr); | |
16 | while (!(readl(&uart_ptr->lsr) & 0x40)) | |
17 | ; | |
18 | } | |
19 | ||
20 | void print(char *s) | |
21 | { | |
22 | while (*s) { | |
23 | if (*s == '\n') | |
24 | uart_wrtie_byte('\r'); | |
25 | uart_wrtie_byte(*s); | |
26 | s++; | |
27 | } | |
28 | } | |
29 | ||
30 | void print_hex(unsigned int n) | |
31 | { | |
32 | int i; | |
33 | int temp; | |
34 | ||
35 | uart_wrtie_byte('0'); | |
36 | uart_wrtie_byte('x'); | |
37 | ||
38 | for (i = 8; i > 0; i--) { | |
39 | temp = (n >> (i - 1) * 4) & 0x0f; | |
40 | if (temp < 10) | |
41 | uart_wrtie_byte((char)(temp + '0')); | |
42 | else | |
43 | uart_wrtie_byte((char)(temp - 10 + 'a')); | |
44 | } | |
45 | uart_wrtie_byte('\n'); | |
46 | uart_wrtie_byte('\r'); | |
47 | } | |
48 | ||
49 | /* | |
50 | * TODO: since rk3036 only 4K sram to use in SPL, for saving space, | |
51 | * we implement uart driver this way, we should convert this to use | |
52 | * ns16550 driver in future, which support DEBUG_UART in the standard way | |
53 | */ | |
54 | void rk_uart_init(void *base) | |
55 | { | |
56 | uart_ptr = (struct rk_uart *)base; | |
57 | writel(0x83, &uart_ptr->lcr); | |
58 | writel(0x0d, &uart_ptr->rbr); | |
59 | writel(0x03, &uart_ptr->lcr); | |
60 | ||
61 | /* fifo enable, sfe is shadow register of FCR[0] */ | |
62 | writel(0x01, &uart_ptr->sfe); | |
63 | } |