1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * arch/arm/mach-pxa/include/mach/uncompress.h
4 *
5 * Author:	Nicolas Pitre
6 * Copyright:	(C) 2001 MontaVista Software Inc.
7 */
8
9#include <linux/serial_reg.h>
10#include <asm/mach-types.h>
11
12#define FFUART_BASE	(0x40100000)
13#define BTUART_BASE	(0x40200000)
14#define STUART_BASE	(0x40700000)
15
16unsigned long uart_base;
17unsigned int uart_shift;
18unsigned int uart_is_pxa;
19
20static inline unsigned char uart_read(int offset)
21{
22	return *(volatile unsigned char *)(uart_base + (offset << uart_shift));
23}
24
25static inline void uart_write(unsigned char val, int offset)
26{
27	*(volatile unsigned char *)(uart_base + (offset << uart_shift)) = val;
28}
29
30static inline int uart_is_enabled(void)
31{
32	/* assume enabled by default for non-PXA uarts */
33	return uart_is_pxa ? uart_read(UART_IER) & UART_IER_UUE : 1;
34}
35
36static inline void putc(char c)
37{
38	if (!uart_is_enabled())
39		return;
40
41	while (!(uart_read(UART_LSR) & UART_LSR_THRE))
42		barrier();
43
44	uart_write(c, UART_TX);
45}
46
47/*
48 * This does not append a newline
49 */
50static inline void flush(void)
51{
52}
53
54static inline void arch_decomp_setup(void)
55{
56	/* initialize to default */
57	uart_base = FFUART_BASE;
58	uart_shift = 2;
59	uart_is_pxa = 1;
60
61	if (machine_is_littleton() || machine_is_intelmote2()
62	    || machine_is_csb726() || machine_is_stargate2()
63	    || machine_is_cm_x300() || machine_is_balloon3())
64		uart_base = STUART_BASE;
65
66	if (machine_is_arcom_zeus()) {
67		uart_base = 0x10000000;	/* nCS4 */
68		uart_shift = 1;
69		uart_is_pxa = 0;
70	}
71}
72