base-files: sysupgrade: fix streaming backup archives to stdout
[openwrt/staging/stintel.git] / target / linux / bcm63xx / image / lzma-loader / src / board.c
1 /*
2 * BCM63XX specific implementation parts
3 *
4 * Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
5 * Copyright (C) 2014 Jonas Gorski <jogo@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <stddef.h>
13 #include "config.h"
14
15 #define READREG(r) *(volatile unsigned int *)(r)
16 #define WRITEREG(r,v) *(volatile unsigned int *)(r) = v
17
18 #define UART_IR_REG 0x10
19 #define UART_FIFO_REG 0x14
20
21 static void wait_xfered(void)
22 {
23 unsigned int val;
24
25 do {
26 val = READREG(UART_BASE + UART_IR_REG);
27 if (val & (1 << 5))
28 break;
29 } while (1);
30 }
31
32 void board_putc(int ch)
33 {
34 if (!UART_BASE)
35 return;
36
37 wait_xfered();
38 WRITEREG(UART_BASE + UART_FIFO_REG, ch);
39 wait_xfered();
40 }