aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/include/mach/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/include/mach/io.h')
-rw-r--r--arch/arm/mach-tegra/include/mach/io.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/include/mach/io.h b/arch/arm/mach-tegra/include/mach/io.h
new file mode 100644
index 00000000000..2b091bf83f3
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/io.h
@@ -0,0 +1,136 @@
1/*
2 * arch/arm/mach-tegra/include/mach/io.h
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Copyright (C) 2011-2012 NVIDIA Corporation.
6 *
7 * Author:
8 * Colin Cross <ccross@google.com>
9 * Erik Gilling <konkers@google.com>
10 *
11 * This software is licensed under the terms of the GNU General Public
12 * License version 2, as published by the Free Software Foundation, and
13 * may be copied, distributed, and modified under those terms.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 */
21
22#ifndef __MACH_TEGRA_IO_H
23#define __MACH_TEGRA_IO_H
24
25#ifdef CONFIG_ARCH_TEGRA_2x_SOC
26#define IO_SPACE_LIMIT 0xffff
27#else
28#define IO_SPACE_LIMIT 0xffffffff
29#endif
30
31/* On TEGRA, many peripherals are very closely packed in
32 * two 256MB io windows (that actually only use about 64KB
33 * at the start of each).
34 *
35 * We will just map the first 1MB of each window (to minimize
36 * pt entries needed) and provide a macro to transform physical
37 * io addresses to an appropriate void __iomem *.
38 *
39 */
40
41#define IO_IRAM_PHYS 0x40000000
42#define IO_IRAM_VIRT 0xFE400000
43#define IO_IRAM_SIZE SZ_256K
44
45#define IO_CPU_PHYS 0x50000000
46#define IO_CPU_VIRT 0xFE000000
47#define IO_CPU_SIZE SZ_1M
48
49#define IO_PPSB_PHYS 0x60000000
50#define IO_PPSB_VIRT 0xFE200000
51#define IO_PPSB_SIZE SZ_1M
52
53#define IO_APB_PHYS 0x70000000
54#define IO_APB_VIRT 0xFE300000
55#define IO_APB_SIZE SZ_1M
56
57#ifdef CONFIG_ARCH_TEGRA_2x_SOC
58#define IO_USB_PHYS 0xC5000000
59#else
60#define IO_USB_PHYS 0x7D000000
61#endif
62#define IO_USB_VIRT 0xFE500000
63#define IO_USB_SIZE SZ_1M
64
65#ifdef CONFIG_ARCH_TEGRA_2x_SOC
66#define IO_SDMMC_PHYS 0xC8000000
67#else
68#define IO_SDMMC_PHYS 0x78000000
69#endif
70#define IO_SDMMC_VIRT 0xFE600000
71#define IO_SDMMC_SIZE SZ_1M
72
73#define IO_HOST1X_PHYS 0x54000000
74#define IO_HOST1X_VIRT 0xFE700000
75#define IO_HOST1X_SIZE SZ_8M
76
77#ifdef CONFIG_ARCH_TEGRA_2x_SOC
78#define IO_PPCS_PHYS 0xC4000000
79#else
80#define IO_PPCS_PHYS 0x7C000000
81#endif
82#define IO_PPCS_VIRT 0xFE100000
83#define IO_PPCS_SIZE SZ_1M
84
85#define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz)))
86#define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst)))
87
88#define IO_TO_VIRT(n) ( \
89 IO_TO_VIRT_BETWEEN((n), IO_PPSB_PHYS, IO_PPSB_SIZE) ? \
90 IO_TO_VIRT_XLATE((n), IO_PPSB_PHYS, IO_PPSB_VIRT) : \
91 IO_TO_VIRT_BETWEEN((n), IO_APB_PHYS, IO_APB_SIZE) ? \
92 IO_TO_VIRT_XLATE((n), IO_APB_PHYS, IO_APB_VIRT) : \
93 IO_TO_VIRT_BETWEEN((n), IO_CPU_PHYS, IO_CPU_SIZE) ? \
94 IO_TO_VIRT_XLATE((n), IO_CPU_PHYS, IO_CPU_VIRT) : \
95 IO_TO_VIRT_BETWEEN((n), IO_IRAM_PHYS, IO_IRAM_SIZE) ? \
96 IO_TO_VIRT_XLATE((n), IO_IRAM_PHYS, IO_IRAM_VIRT) : \
97 IO_TO_VIRT_BETWEEN((n), IO_HOST1X_PHYS, IO_HOST1X_SIZE) ? \
98 IO_TO_VIRT_XLATE((n), IO_HOST1X_PHYS, IO_HOST1X_VIRT) : \
99 IO_TO_VIRT_BETWEEN((n), IO_USB_PHYS, IO_USB_SIZE) ? \
100 IO_TO_VIRT_XLATE((n), IO_USB_PHYS, IO_USB_VIRT) : \
101 IO_TO_VIRT_BETWEEN((n), IO_SDMMC_PHYS, IO_SDMMC_SIZE) ? \
102 IO_TO_VIRT_XLATE((n), IO_SDMMC_PHYS, IO_SDMMC_VIRT) : \
103 IO_TO_VIRT_BETWEEN((n), IO_PPCS_PHYS, IO_PPCS_SIZE) ? \
104 IO_TO_VIRT_XLATE((n), IO_PPCS_PHYS, IO_PPCS_VIRT) : \
105 0)
106
107#ifndef __ASSEMBLER__
108
109#define __arch_ioremap tegra_ioremap
110#define __arch_iounmap tegra_iounmap
111
112void __iomem *tegra_ioremap(unsigned long phys, size_t size, unsigned int type);
113void tegra_iounmap(volatile void __iomem *addr);
114
115#define IO_ADDRESS(n) ((void __iomem *) IO_TO_VIRT(n))
116
117#if defined(CONFIG_TEGRA_PCI)
118extern void __iomem *tegra_pcie_io_base;
119
120static inline void __iomem *__io(unsigned long addr)
121{
122 return tegra_pcie_io_base + (addr & IO_SPACE_LIMIT);
123}
124#else
125static inline void __iomem *__io(unsigned long addr)
126{
127 return (void __iomem *)addr;
128}
129#endif
130
131#define __io(a) __io(a)
132#define __mem_pci(a) (a)
133
134#endif
135
136#endif