2 * arch/arm/mach-tegra/include/mach/uncompress.h
4 * Copyright (C) 2010 Google, Inc.
5 * Copyright (C) 2011 Google, Inc.
6 * Copyright (C) 2011-2012 NVIDIA CORPORATION. All Rights Reserved.
9 * Colin Cross <ccross@google.com>
10 * Erik Gilling <konkers@google.com>
11 * Doug Anderson <dianders@chromium.org>
12 * Stephen Warren <swarren@nvidia.com>
14 * This software is licensed under the terms of the GNU General Public
15 * License version 2, as published by the Free Software Foundation, and
16 * may be copied, distributed, and modified under those terms.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
25 #ifndef __MACH_TEGRA_UNCOMPRESS_H
26 #define __MACH_TEGRA_UNCOMPRESS_H
28 #include <linux/kernel.h>
29 #include <linux/types.h>
30 #include <linux/serial_reg.h>
32 #include <mach/iomap.h>
33 #include <mach/irammap.h>
35 #define DEBUG_UART_SHIFT 2
39 static void putc(int c)
44 while (!(uart[UART_LSR << DEBUG_UART_SHIFT] & UART_LSR_THRE))
46 uart[UART_TX << DEBUG_UART_SHIFT] = c;
49 static inline void flush(void)
53 static inline void save_uart_address(void)
55 u32 *buf = (u32 *)(TEGRA_IRAM_BASE + TEGRA_IRAM_DEBUG_UART_OFFSET);
58 buf[0] = TEGRA_IRAM_DEBUG_UART_COOKIE;
65 * Setup before decompression. This is where we do UART selection for
66 * earlyprintk and init the uart_base register.
68 static inline void arch_decomp_setup(void)
78 TEGRA_CLK_RESET_BASE + 0x04,
79 TEGRA_CLK_RESET_BASE + 0x10,
84 TEGRA_CLK_RESET_BASE + 0x04,
85 TEGRA_CLK_RESET_BASE + 0x10,
90 TEGRA_CLK_RESET_BASE + 0x08,
91 TEGRA_CLK_RESET_BASE + 0x14,
96 TEGRA_CLK_RESET_BASE + 0x0c,
97 TEGRA_CLK_RESET_BASE + 0x18,
102 TEGRA_CLK_RESET_BASE + 0x0c,
103 TEGRA_CLK_RESET_BASE + 0x18,
108 volatile u32 *apb_misc = (volatile u32 *)TEGRA_APB_MISC_BASE;
112 * Look for the first UART that:
113 * a) Is not in reset.
115 * c) Has a 'D' in the scratchpad register.
117 * Note that on Tegra30, the first two conditions are required, since
118 * if not true, accesses to the UART scratch register will hang.
119 * Tegra20 doesn't have this issue.
121 * The intent is that the bootloader will tell the kernel which UART
122 * to use by setting up those conditions. If nothing found, we'll fall
123 * back to what's specified in TEGRA_DEBUG_UART_BASE.
125 for (i = 0; i < ARRAY_SIZE(uarts); i++) {
126 if (*(u8 *)uarts[i].reset_reg & BIT(uarts[i].bit))
129 if (!(*(u8 *)uarts[i].clock_reg & BIT(uarts[i].bit)))
132 uart = (volatile u8 *)uarts[i].base;
133 if (uart[UART_SCR << DEBUG_UART_SHIFT] != 'D')
138 if (i == ARRAY_SIZE(uarts))
139 uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE;
144 chip = (apb_misc[0x804 / 4] >> 8) & 0xff;
150 uart[UART_LCR << DEBUG_UART_SHIFT] |= UART_LCR_DLAB;
151 uart[UART_DLL << DEBUG_UART_SHIFT] = div & 0xff;
152 uart[UART_DLM << DEBUG_UART_SHIFT] = div >> 8;
153 uart[UART_LCR << DEBUG_UART_SHIFT] = 3;
156 static inline void arch_decomp_wdog(void)