bmips: add new target
[openwrt/staging/ldir.git] / target / linux / bmips / image / lzma-loader / src / board.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * BCM63XX specific implementation parts
4 *
5 * Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
6 * Copyright (C) 2014 Jonas Gorski <jogo@openwrt.org>
7 */
8
9 #include <stddef.h>
10 #include "config.h"
11
12 #define READREG(r) *(volatile unsigned int *)(r)
13 #define WRITEREG(r,v) *(volatile unsigned int *)(r) = v
14
15 #define UART_IR_REG 0x10
16 #define UART_FIFO_REG 0x14
17
18 static void wait_xfered(void)
19 {
20 unsigned int val;
21
22 do {
23 val = READREG(UART_BASE + UART_IR_REG);
24 if (val & (1 << 5))
25 break;
26 } while (1);
27 }
28
29 void board_putc(int ch)
30 {
31 if (!UART_BASE)
32 return;
33
34 wait_xfered();
35 WRITEREG(UART_BASE + UART_FIFO_REG, ch);
36 wait_xfered();
37 }