]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/arm/mach-rockchip/rk_early_print.c
dm: ns16550: Allow the driver to be omitted if requested
[people/ms/u-boot.git] / arch / arm / mach-rockchip / rk_early_print.c
CommitLineData
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
11static struct rk_uart *uart_ptr;
12
13static void uart_wrtie_byte(char byte)
14{
15 writel(byte, &uart_ptr->rbr);
16 while (!(readl(&uart_ptr->lsr) & 0x40))
17 ;
18}
19
20void 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
30void 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 */
54void 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}