ARM: tegra: Introduce define DEBUG_UART_SHIFT
[cascardo/linux.git] / arch / arm / mach-tegra / include / mach / uncompress.h
1 /*
2  * arch/arm/mach-tegra/include/mach/uncompress.h
3  *
4  * Copyright (C) 2010 Google, Inc.
5  * Copyright (C) 2011 Google, Inc.
6  *
7  * Author:
8  *      Colin Cross <ccross@google.com>
9  *      Erik Gilling <konkers@google.com>
10  *      Doug Anderson <dianders@chromium.org>
11  *
12  * This software is licensed under the terms of the GNU General Public
13  * License version 2, as published by the Free Software Foundation, and
14  * may be copied, distributed, and modified under those terms.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  */
22
23 #ifndef __MACH_TEGRA_UNCOMPRESS_H
24 #define __MACH_TEGRA_UNCOMPRESS_H
25
26 #include <linux/types.h>
27 #include <linux/serial_reg.h>
28
29 #include <mach/iomap.h>
30
31 #define DEBUG_UART_SHIFT 2
32
33 static void putc(int c)
34 {
35         volatile u8 *uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE;
36
37         if (uart == NULL)
38                 return;
39
40         while (!(uart[UART_LSR << DEBUG_UART_SHIFT] & UART_LSR_THRE))
41                 barrier();
42         uart[UART_TX << DEBUG_UART_SHIFT] = c;
43 }
44
45 static inline void flush(void)
46 {
47 }
48
49 static inline void arch_decomp_setup(void)
50 {
51         volatile u32 *apb_misc = (volatile u32 *)TEGRA_APB_MISC_BASE;
52         u32 chip, div;
53         volatile u8 *uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE;
54
55         if (uart == NULL)
56                 return;
57
58         chip = (apb_misc[0x804 / 4] >> 8) & 0xff;
59         if (chip == 0x20)
60                 div = 0x0075;
61         else
62                 div = 0x00dd;
63
64         uart[UART_LCR << DEBUG_UART_SHIFT] |= UART_LCR_DLAB;
65         uart[UART_DLL << DEBUG_UART_SHIFT] = div & 0xff;
66         uart[UART_DLM << DEBUG_UART_SHIFT] = div >> 8;
67         uart[UART_LCR << DEBUG_UART_SHIFT] = 3;
68 }
69
70 static inline void arch_decomp_wdog(void)
71 {
72 }
73
74 #endif