blob: a3b0b04b45c90f9bc4808ece62482521f85fcf24 [file] [log] [blame]
Russell Kinga09e64f2008-08-05 16:14:15 +01001/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20#ifndef __ASM_ARCH_MXC_HARDWARE_H__
21#define __ASM_ARCH_MXC_HARDWARE_H__
22
Shawn Guo24a83fe2013-05-10 09:08:07 +080023#include <asm/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <asm/sizes.h>
25
Rob Herringc177aa92012-02-13 13:24:15 -060026#define addr_in_module(addr, mod) \
27 ((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE)
28
Uwe Kleine-Königf5d7a132010-10-25 11:40:30 +020029#define IMX_IO_P2V_MODULE(addr, module) \
30 (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \
31 (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0)
Uwe Kleine-König1f2ddd62009-12-16 19:05:04 +010032
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020033/*
34 * This is rather complicated for humans and ugly to verify, but for a machine
35 * it's OK. Still more as it is usually only applied to constants. The upsides
36 * on using this approach are:
37 *
38 * - same mapping on all i.MX machines
39 * - works for assembler, too
40 * - no need to nurture #defines for virtual addresses
41 *
42 * The downside it, it's hard to verify (but I have a script for that).
43 *
44 * Obviously this needs to be injective for each SoC. In general it maps the
45 * whole address space to [0xf4000000, 0xf5ffffff]. So [0xf6000000,0xfeffffff]
46 * is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there).
47 *
48 * It applies the following mappings for the different SoCs:
49 *
50 * mx1:
51 * IO 0x00200000+0x100000 -> 0xf4000000+0x100000
52 * mx21:
53 * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050054 * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020055 * X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000
56 * mx25:
57 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
58 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
59 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
60 * mx27:
61 * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050062 * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020063 * X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000
64 * mx31:
65 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
66 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
67 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050068 * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020069 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
70 * mx35:
71 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
72 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
73 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050074 * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020075 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
76 * mx51:
Robert Lee2ce2e4b2012-05-21 17:50:24 -050077 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020078 * IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050079 * DEBUG 0x60000000+0x100000 -> 0xf5000000+0x100000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020080 * SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000
81 * AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050082 * AIPS2 0x83f00000+0x100000 -> 0xf5300000+0x100000
Jason Liu4c542392011-09-09 17:17:49 +080083 * mx53:
84 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050085 * DEBUG 0x40000000+0x100000 -> 0xf5000000+0x100000
Jason Liu4c542392011-09-09 17:17:49 +080086 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
87 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000
88 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000
Shawn Guobac89d72011-10-02 15:09:11 +080089 * mx6q:
Robert Lee2ce2e4b2012-05-21 17:50:24 -050090 * SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
Shawn Guobac89d72011-10-02 15:09:11 +080091 * CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
Robert Lee2ce2e4b2012-05-21 17:50:24 -050092 * ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
Shawn Guobac89d72011-10-02 15:09:11 +080093 * UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020094 */
95#define IMX_IO_P2V(x) ( \
Robert Lee2ce2e4b2012-05-21 17:50:24 -050096 (((x) & 0x80000000) >> 7) | \
97 (0xf4000000 + \
Uwe Kleine-Königa9963142010-10-25 15:44:25 +020098 (((x) & 0x50000000) >> 6) + \
99 (((x) & 0x0b000000) >> 4) + \
Robert Lee2ce2e4b2012-05-21 17:50:24 -0500100 (((x) & 0x000fffff))))
Uwe Kleine-Königa9963142010-10-25 15:44:25 +0200101
102#define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x))
103
Shawn Guo50f2de62012-09-14 14:14:45 +0800104#include "mxc.h"
Uwe Kleine-Königd286a432011-04-02 00:15:49 +0200105
Shawn Guo50f2de62012-09-14 14:14:45 +0800106#include "mx51.h"
107#include "mx53.h"
108#include "mx3x.h"
109#include "mx31.h"
110#include "mx35.h"
111#include "mx2x.h"
112#include "mx21.h"
113#include "mx27.h"
114#include "mx1.h"
115#include "mx25.h"
Sascha Hauer8c25c362009-06-04 11:32:12 +0200116
Uwe Kleine-König08ff97b2010-10-25 15:38:09 +0200117#define imx_map_entry(soc, name, _type) { \
118 .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \
119 .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \
120 .length = soc ## _ ## name ## _SIZE, \
121 .type = _type, \
122}
123
Shawn Guo1dfa86b2011-08-14 00:14:05 +0800124/* There's a off-by-one betweem the gpio bank number and the gpiochip */
125/* range e.g. GPIO_1_5 is gpio 5 under linux */
126#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr))
127
Russell Kinga09e64f2008-08-05 16:14:15 +0100128#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */