1*16216333SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 250f2de61SShawn Guo /* 3df595746SAnson Huang * Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved. 450f2de61SShawn Guo * Copyright 2008 Juergen Beisert, kernel@pengutronix.de 550f2de61SShawn Guo */ 650f2de61SShawn Guo 750f2de61SShawn Guo #ifndef __ASM_ARCH_MXC_HARDWARE_H__ 850f2de61SShawn Guo #define __ASM_ARCH_MXC_HARDWARE_H__ 950f2de61SShawn Guo 10df595746SAnson Huang #ifndef __ASSEMBLY__ 1124a83fe4SShawn Guo #include <asm/io.h> 129bbef187SShawn Guo #include <soc/imx/revision.h> 13df595746SAnson Huang #endif 1487dfb311SMasahiro Yamada #include <linux/sizes.h> 1550f2de61SShawn Guo 1650f2de61SShawn Guo #define addr_in_module(addr, mod) \ 1750f2de61SShawn Guo ((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE) 1850f2de61SShawn Guo 1950f2de61SShawn Guo #define IMX_IO_P2V_MODULE(addr, module) \ 2050f2de61SShawn Guo (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \ 2150f2de61SShawn Guo (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0) 2250f2de61SShawn Guo 2350f2de61SShawn Guo /* 2450f2de61SShawn Guo * This is rather complicated for humans and ugly to verify, but for a machine 2550f2de61SShawn Guo * it's OK. Still more as it is usually only applied to constants. The upsides 2650f2de61SShawn Guo * on using this approach are: 2750f2de61SShawn Guo * 2850f2de61SShawn Guo * - same mapping on all i.MX machines 2950f2de61SShawn Guo * - works for assembler, too 3050f2de61SShawn Guo * - no need to nurture #defines for virtual addresses 3150f2de61SShawn Guo * 3250f2de61SShawn Guo * The downside it, it's hard to verify (but I have a script for that). 3350f2de61SShawn Guo * 3450f2de61SShawn Guo * Obviously this needs to be injective for each SoC. In general it maps the 3550f2de61SShawn Guo * whole address space to [0xf4000000, 0xf5ffffff]. So [0xf6000000,0xfeffffff] 3650f2de61SShawn Guo * is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there). 3750f2de61SShawn Guo * 3850f2de61SShawn Guo * It applies the following mappings for the different SoCs: 3950f2de61SShawn Guo * 4050f2de61SShawn Guo * mx1: 4150f2de61SShawn Guo * IO 0x00200000+0x100000 -> 0xf4000000+0x100000 4250f2de61SShawn Guo * mx21: 4350f2de61SShawn Guo * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000 4450f2de61SShawn Guo * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000 4550f2de61SShawn Guo * X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000 4650f2de61SShawn Guo * mx25: 4750f2de61SShawn Guo * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 4850f2de61SShawn Guo * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 4950f2de61SShawn Guo * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 5050f2de61SShawn Guo * mx27: 5150f2de61SShawn Guo * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000 5250f2de61SShawn Guo * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000 5350f2de61SShawn Guo * X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000 5450f2de61SShawn Guo * mx31: 5550f2de61SShawn Guo * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 5650f2de61SShawn Guo * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 5750f2de61SShawn Guo * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 5850f2de61SShawn Guo * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000 5950f2de61SShawn Guo * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 6050f2de61SShawn Guo * mx35: 6150f2de61SShawn Guo * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 6250f2de61SShawn Guo * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 6350f2de61SShawn Guo * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 6450f2de61SShawn Guo * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000 6550f2de61SShawn Guo * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 6650f2de61SShawn Guo * mx51: 6750f2de61SShawn Guo * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 6850f2de61SShawn Guo * IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000 6950f2de61SShawn Guo * DEBUG 0x60000000+0x100000 -> 0xf5000000+0x100000 7050f2de61SShawn Guo * SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000 7150f2de61SShawn Guo * AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000 7250f2de61SShawn Guo * AIPS2 0x83f00000+0x100000 -> 0xf5300000+0x100000 7350f2de61SShawn Guo * mx53: 7450f2de61SShawn Guo * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 7550f2de61SShawn Guo * DEBUG 0x40000000+0x100000 -> 0xf5000000+0x100000 7650f2de61SShawn Guo * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 7750f2de61SShawn Guo * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000 7850f2de61SShawn Guo * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000 7950f2de61SShawn Guo * mx6q: 8050f2de61SShawn Guo * SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000 8150f2de61SShawn Guo * CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000 8250f2de61SShawn Guo * ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000 8350f2de61SShawn Guo * UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000 8450f2de61SShawn Guo */ 8550f2de61SShawn Guo #define IMX_IO_P2V(x) ( \ 8650f2de61SShawn Guo (((x) & 0x80000000) >> 7) | \ 8750f2de61SShawn Guo (0xf4000000 + \ 8850f2de61SShawn Guo (((x) & 0x50000000) >> 6) + \ 8950f2de61SShawn Guo (((x) & 0x0b000000) >> 4) + \ 9050f2de61SShawn Guo (((x) & 0x000fffff)))) 9150f2de61SShawn Guo 9250f2de61SShawn Guo #define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x)) 9350f2de61SShawn Guo 9450f2de61SShawn Guo #include "mxc.h" 9550f2de61SShawn Guo 9650f2de61SShawn Guo #include "mx3x.h" 9750f2de61SShawn Guo #include "mx31.h" 9850f2de61SShawn Guo #include "mx35.h" 9950f2de61SShawn Guo #include "mx2x.h" 10050f2de61SShawn Guo #include "mx21.h" 10150f2de61SShawn Guo #include "mx27.h" 10250f2de61SShawn Guo 10350f2de61SShawn Guo #define imx_map_entry(soc, name, _type) { \ 10450f2de61SShawn Guo .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ 10550f2de61SShawn Guo .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ 10650f2de61SShawn Guo .length = soc ## _ ## name ## _SIZE, \ 10750f2de61SShawn Guo .type = _type, \ 10850f2de61SShawn Guo } 10950f2de61SShawn Guo 1103481bdceSMartin Kaiser /* There's an off-by-one between the gpio bank number and the gpiochip */ 11150f2de61SShawn Guo /* range e.g. GPIO_1_5 is gpio 5 under linux */ 11250f2de61SShawn Guo #define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr)) 11350f2de61SShawn Guo 11450f2de61SShawn Guo #endif /* __ASM_ARCH_MXC_HARDWARE_H__ */ 115