diff options
author | Olof Johansson <olof@lixom.net> | 2012-02-26 17:43:43 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-02-26 17:43:43 -0500 |
commit | 0f830e5c902106e7fe51460fd1e3263bea72bf41 (patch) | |
tree | b83090bb272fce3ebda9aac311f2185ce78be7a3 /arch/arm/mach-tegra/include | |
parent | 9335e9199bd059fc4f5e4e6fcfb9fca1d482e460 (diff) | |
parent | bdc93a77da75ee421125896ce4bbd91afff63809 (diff) |
Merge branch 'for-3.4/soc-drivers' into for-3.4/t30-smp
Conflicts:
arch/arm/mach-tegra/Makefile
Diffstat (limited to 'arch/arm/mach-tegra/include')
-rw-r--r-- | arch/arm/mach-tegra/include/mach/debug-macro.S | 88 | ||||
-rw-r--r-- | arch/arm/mach-tegra/include/mach/gpio-tegra.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-tegra/include/mach/irammap.h | 35 | ||||
-rw-r--r-- | arch/arm/mach-tegra/include/mach/uncompress.h | 118 |
4 files changed, 219 insertions, 24 deletions
diff --git a/arch/arm/mach-tegra/include/mach/debug-macro.S b/arch/arm/mach-tegra/include/mach/debug-macro.S index 619abc63aee8..90069abd37bd 100644 --- a/arch/arm/mach-tegra/include/mach/debug-macro.S +++ b/arch/arm/mach-tegra/include/mach/debug-macro.S | |||
@@ -1,11 +1,17 @@ | |||
1 | /* | 1 | /* |
2 | * arch/arm/mach-tegra/include/mach/debug-macro.S | 2 | * arch/arm/mach-tegra/include/mach/debug-macro.S |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Google, Inc. | 4 | * Copyright (C) 2010,2011 Google, Inc. |
5 | * Copyright (C) 2011-2012 NVIDIA CORPORATION. All Rights Reserved. | ||
5 | * | 6 | * |
6 | * Author: | 7 | * Author: |
7 | * Colin Cross <ccross@google.com> | 8 | * Colin Cross <ccross@google.com> |
8 | * Erik Gilling <konkers@google.com> | 9 | * Erik Gilling <konkers@google.com> |
10 | * Doug Anderson <dianders@chromium.org> | ||
11 | * Stephen Warren <swarren@nvidia.com> | ||
12 | * | ||
13 | * Portions based on mach-omap2's debug-macro.S | ||
14 | * Copyright (C) 1994-1999 Russell King | ||
9 | * | 15 | * |
10 | * This software is licensed under the terms of the GNU General Public | 16 | * This software is licensed under the terms of the GNU General Public |
11 | * License version 2, as published by the Free Software Foundation, and | 17 | * License version 2, as published by the Free Software Foundation, and |
@@ -18,18 +24,78 @@ | |||
18 | * | 24 | * |
19 | */ | 25 | */ |
20 | 26 | ||
27 | #include <linux/serial_reg.h> | ||
28 | |||
21 | #include <mach/io.h> | 29 | #include <mach/io.h> |
22 | #include <mach/iomap.h> | 30 | #include <mach/iomap.h> |
31 | #include <mach/irammap.h> | ||
32 | |||
33 | .macro addruart, rp, rv, tmp | ||
34 | adr \rp, 99f @ actual addr of 99f | ||
35 | ldr \rv, [\rp] @ linked addr is stored there | ||
36 | sub \rv, \rv, \rp @ offset between the two | ||
37 | ldr \rp, [\rp, #4] @ linked tegra_uart_config | ||
38 | sub \tmp, \rp, \rv @ actual tegra_uart_config | ||
39 | ldr \rp, [\tmp] @ Load tegra_uart_config | ||
40 | cmp \rp, #1 @ needs intitialization? | ||
41 | bne 100f @ no; go load the addresses | ||
42 | mov \rv, #0 @ yes; record init is done | ||
43 | str \rv, [\tmp] | ||
44 | mov \rp, #TEGRA_IRAM_BASE @ See if cookie is in IRAM | ||
45 | ldr \rv, [\rp, #TEGRA_IRAM_DEBUG_UART_OFFSET] | ||
46 | movw \rp, #TEGRA_IRAM_DEBUG_UART_COOKIE & 0xffff | ||
47 | movt \rp, #TEGRA_IRAM_DEBUG_UART_COOKIE >> 16 | ||
48 | cmp \rv, \rp @ Cookie present? | ||
49 | bne 100f @ No, use default UART | ||
50 | mov \rp, #TEGRA_IRAM_BASE @ Load UART address from IRAM | ||
51 | ldr \rv, [\rp, #TEGRA_IRAM_DEBUG_UART_OFFSET + 4] | ||
52 | str \rv, [\tmp, #4] @ Store in tegra_uart_phys | ||
53 | sub \rv, \rv, #IO_APB_PHYS @ Calculate virt address | ||
54 | add \rv, \rv, #IO_APB_VIRT | ||
55 | str \rv, [\tmp, #8] @ Store in tegra_uart_virt | ||
56 | b 100f | ||
57 | |||
58 | .align | ||
59 | 99: .word . | ||
60 | .word tegra_uart_config | ||
61 | .ltorg | ||
62 | |||
63 | 100: ldr \rp, [\tmp, #4] @ Load tegra_uart_phys | ||
64 | ldr \rv, [\tmp, #8] @ Load tegra_uart_virt | ||
65 | .endm | ||
66 | |||
67 | #define UART_SHIFT 2 | ||
68 | |||
69 | /* | ||
70 | * Code below is swiped from <asm/hardware/debug-8250.S>, but add an extra | ||
71 | * check to make sure that we aren't in the CONFIG_TEGRA_DEBUG_UART_NONE case. | ||
72 | * We use the fact that all 5 valid UART addresses all have something in the | ||
73 | * 2nd-to-lowest byte. | ||
74 | */ | ||
23 | 75 | ||
24 | .macro addruart, rp, rv, tmp | 76 | .macro senduart, rd, rx |
25 | ldr \rp, =IO_APB_PHYS @ physical | 77 | tst \rx, #0x0000ff00 |
26 | ldr \rv, =IO_APB_VIRT @ virtual | 78 | strneb \rd, [\rx, #UART_TX << UART_SHIFT] |
27 | orr \rp, \rp, #(TEGRA_DEBUG_UART_BASE & 0xFF) | 79 | 1001: |
28 | orr \rp, \rp, #(TEGRA_DEBUG_UART_BASE & 0xFF00) | 80 | .endm |
29 | orr \rv, \rv, #(TEGRA_DEBUG_UART_BASE & 0xFF) | ||
30 | orr \rv, \rv, #(TEGRA_DEBUG_UART_BASE & 0xFF00) | ||
31 | .endm | ||
32 | 81 | ||
33 | #define UART_SHIFT 2 | 82 | .macro busyuart, rd, rx |
34 | #include <asm/hardware/debug-8250.S> | 83 | tst \rx, #0x0000ff00 |
84 | beq 1002f | ||
85 | 1001: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT] | ||
86 | and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE | ||
87 | teq \rd, #UART_LSR_TEMT | UART_LSR_THRE | ||
88 | bne 1001b | ||
89 | 1002: | ||
90 | .endm | ||
35 | 91 | ||
92 | .macro waituart, rd, rx | ||
93 | #ifdef FLOW_CONTROL | ||
94 | tst \rx, #0x0000ff00 | ||
95 | beq 1002f | ||
96 | 1001: ldrb \rd, [\rx, #UART_MSR << UART_SHIFT] | ||
97 | tst \rd, #UART_MSR_CTS | ||
98 | beq 1001b | ||
99 | 1002: | ||
100 | #endif | ||
101 | .endm | ||
diff --git a/arch/arm/mach-tegra/include/mach/gpio-tegra.h b/arch/arm/mach-tegra/include/mach/gpio-tegra.h index 87d37fdf5084..6140820555e1 100644 --- a/arch/arm/mach-tegra/include/mach/gpio-tegra.h +++ b/arch/arm/mach-tegra/include/mach/gpio-tegra.h | |||
@@ -25,8 +25,6 @@ | |||
25 | 25 | ||
26 | #define TEGRA_NR_GPIOS INT_GPIO_NR | 26 | #define TEGRA_NR_GPIOS INT_GPIO_NR |
27 | 27 | ||
28 | #define TEGRA_GPIO_TO_IRQ(gpio) (INT_GPIO_BASE + (gpio)) | ||
29 | |||
30 | struct tegra_gpio_table { | 28 | struct tegra_gpio_table { |
31 | int gpio; /* GPIO number */ | 29 | int gpio; /* GPIO number */ |
32 | bool enable; /* Enable for GPIO at init? */ | 30 | bool enable; /* Enable for GPIO at init? */ |
diff --git a/arch/arm/mach-tegra/include/mach/irammap.h b/arch/arm/mach-tegra/include/mach/irammap.h new file mode 100644 index 000000000000..0cbe63261854 --- /dev/null +++ b/arch/arm/mach-tegra/include/mach/irammap.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef __MACH_TEGRA_IRAMMAP_H | ||
18 | #define __MACH_TEGRA_IRAMMAP_H | ||
19 | |||
20 | #include <asm/sizes.h> | ||
21 | |||
22 | /* The first 1K of IRAM is permanently reserved for the CPU reset handler */ | ||
23 | #define TEGRA_IRAM_RESET_HANDLER_OFFSET 0 | ||
24 | #define TEGRA_IRAM_RESET_HANDLER_SIZE SZ_1K | ||
25 | |||
26 | /* | ||
27 | * These locations are written to by uncompress.h, and read by debug-macro.S. | ||
28 | * The first word holds the cookie value if the data is valid. The second | ||
29 | * word holds the UART physical address. | ||
30 | */ | ||
31 | #define TEGRA_IRAM_DEBUG_UART_OFFSET SZ_1K | ||
32 | #define TEGRA_IRAM_DEBUG_UART_SIZE 8 | ||
33 | #define TEGRA_IRAM_DEBUG_UART_COOKIE 0x55415254 | ||
34 | |||
35 | #endif | ||
diff --git a/arch/arm/mach-tegra/include/mach/uncompress.h b/arch/arm/mach-tegra/include/mach/uncompress.h index 4e8323770c79..b066ba0ee3c3 100644 --- a/arch/arm/mach-tegra/include/mach/uncompress.h +++ b/arch/arm/mach-tegra/include/mach/uncompress.h | |||
@@ -2,10 +2,14 @@ | |||
2 | * arch/arm/mach-tegra/include/mach/uncompress.h | 2 | * arch/arm/mach-tegra/include/mach/uncompress.h |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Google, Inc. | 4 | * Copyright (C) 2010 Google, Inc. |
5 | * Copyright (C) 2011 Google, Inc. | ||
6 | * Copyright (C) 2011-2012 NVIDIA CORPORATION. All Rights Reserved. | ||
5 | * | 7 | * |
6 | * Author: | 8 | * Author: |
7 | * Colin Cross <ccross@google.com> | 9 | * Colin Cross <ccross@google.com> |
8 | * Erik Gilling <konkers@google.com> | 10 | * Erik Gilling <konkers@google.com> |
11 | * Doug Anderson <dianders@chromium.org> | ||
12 | * Stephen Warren <swarren@nvidia.com> | ||
9 | * | 13 | * |
10 | * This software is licensed under the terms of the GNU General Public | 14 | * This software is licensed under the terms of the GNU General Public |
11 | * License version 2, as published by the Free Software Foundation, and | 15 | * License version 2, as published by the Free Software Foundation, and |
@@ -21,40 +25,132 @@ | |||
21 | #ifndef __MACH_TEGRA_UNCOMPRESS_H | 25 | #ifndef __MACH_TEGRA_UNCOMPRESS_H |
22 | #define __MACH_TEGRA_UNCOMPRESS_H | 26 | #define __MACH_TEGRA_UNCOMPRESS_H |
23 | 27 | ||
28 | #include <linux/kernel.h> | ||
24 | #include <linux/types.h> | 29 | #include <linux/types.h> |
25 | #include <linux/serial_reg.h> | 30 | #include <linux/serial_reg.h> |
26 | 31 | ||
27 | #include <mach/iomap.h> | 32 | #include <mach/iomap.h> |
33 | #include <mach/irammap.h> | ||
34 | |||
35 | #define DEBUG_UART_SHIFT 2 | ||
36 | |||
37 | volatile u8 *uart; | ||
28 | 38 | ||
29 | static void putc(int c) | 39 | static void putc(int c) |
30 | { | 40 | { |
31 | volatile u8 *uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE; | ||
32 | int shift = 2; | ||
33 | |||
34 | if (uart == NULL) | 41 | if (uart == NULL) |
35 | return; | 42 | return; |
36 | 43 | ||
37 | while (!(uart[UART_LSR << shift] & UART_LSR_THRE)) | 44 | while (!(uart[UART_LSR << DEBUG_UART_SHIFT] & UART_LSR_THRE)) |
38 | barrier(); | 45 | barrier(); |
39 | uart[UART_TX << shift] = c; | 46 | uart[UART_TX << DEBUG_UART_SHIFT] = c; |
40 | } | 47 | } |
41 | 48 | ||
42 | static inline void flush(void) | 49 | static inline void flush(void) |
43 | { | 50 | { |
44 | } | 51 | } |
45 | 52 | ||
53 | static inline void save_uart_address(void) | ||
54 | { | ||
55 | u32 *buf = (u32 *)(TEGRA_IRAM_BASE + TEGRA_IRAM_DEBUG_UART_OFFSET); | ||
56 | |||
57 | if (uart) { | ||
58 | buf[0] = TEGRA_IRAM_DEBUG_UART_COOKIE; | ||
59 | buf[1] = (u32)uart; | ||
60 | } else | ||
61 | buf[0] = 0; | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | * Setup before decompression. This is where we do UART selection for | ||
66 | * earlyprintk and init the uart_base register. | ||
67 | */ | ||
46 | static inline void arch_decomp_setup(void) | 68 | static inline void arch_decomp_setup(void) |
47 | { | 69 | { |
48 | volatile u8 *uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE; | 70 | static const struct { |
49 | int shift = 2; | 71 | u32 base; |
72 | u32 reset_reg; | ||
73 | u32 clock_reg; | ||
74 | u32 bit; | ||
75 | } uarts[] = { | ||
76 | { | ||
77 | TEGRA_UARTA_BASE, | ||
78 | TEGRA_CLK_RESET_BASE + 0x04, | ||
79 | TEGRA_CLK_RESET_BASE + 0x10, | ||
80 | 6, | ||
81 | }, | ||
82 | { | ||
83 | TEGRA_UARTB_BASE, | ||
84 | TEGRA_CLK_RESET_BASE + 0x04, | ||
85 | TEGRA_CLK_RESET_BASE + 0x10, | ||
86 | 7, | ||
87 | }, | ||
88 | { | ||
89 | TEGRA_UARTC_BASE, | ||
90 | TEGRA_CLK_RESET_BASE + 0x08, | ||
91 | TEGRA_CLK_RESET_BASE + 0x14, | ||
92 | 23, | ||
93 | }, | ||
94 | { | ||
95 | TEGRA_UARTD_BASE, | ||
96 | TEGRA_CLK_RESET_BASE + 0x0c, | ||
97 | TEGRA_CLK_RESET_BASE + 0x18, | ||
98 | 1, | ||
99 | }, | ||
100 | { | ||
101 | TEGRA_UARTE_BASE, | ||
102 | TEGRA_CLK_RESET_BASE + 0x0c, | ||
103 | TEGRA_CLK_RESET_BASE + 0x18, | ||
104 | 2, | ||
105 | }, | ||
106 | }; | ||
107 | int i; | ||
108 | volatile u32 *apb_misc = (volatile u32 *)TEGRA_APB_MISC_BASE; | ||
109 | u32 chip, div; | ||
110 | |||
111 | /* | ||
112 | * Look for the first UART that: | ||
113 | * a) Is not in reset. | ||
114 | * b) Is clocked. | ||
115 | * c) Has a 'D' in the scratchpad register. | ||
116 | * | ||
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. | ||
120 | * | ||
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. | ||
124 | */ | ||
125 | for (i = 0; i < ARRAY_SIZE(uarts); i++) { | ||
126 | if (*(u8 *)uarts[i].reset_reg & BIT(uarts[i].bit)) | ||
127 | continue; | ||
50 | 128 | ||
129 | if (!(*(u8 *)uarts[i].clock_reg & BIT(uarts[i].bit))) | ||
130 | continue; | ||
131 | |||
132 | uart = (volatile u8 *)uarts[i].base; | ||
133 | if (uart[UART_SCR << DEBUG_UART_SHIFT] != 'D') | ||
134 | continue; | ||
135 | |||
136 | break; | ||
137 | } | ||
138 | if (i == ARRAY_SIZE(uarts)) | ||
139 | uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE; | ||
140 | save_uart_address(); | ||
51 | if (uart == NULL) | 141 | if (uart == NULL) |
52 | return; | 142 | return; |
53 | 143 | ||
54 | uart[UART_LCR << shift] |= UART_LCR_DLAB; | 144 | chip = (apb_misc[0x804 / 4] >> 8) & 0xff; |
55 | uart[UART_DLL << shift] = 0x75; | 145 | if (chip == 0x20) |
56 | uart[UART_DLM << shift] = 0x0; | 146 | div = 0x0075; |
57 | uart[UART_LCR << shift] = 3; | 147 | else |
148 | div = 0x00dd; | ||
149 | |||
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; | ||
58 | } | 154 | } |
59 | 155 | ||
60 | static inline void arch_decomp_wdog(void) | 156 | static inline void arch_decomp_wdog(void) |