/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved.3* Copyright 2008 Juergen Beisert, [email protected]4*/56#ifndef __ASM_ARCH_MXC_HARDWARE_H__7#define __ASM_ARCH_MXC_HARDWARE_H__89#ifndef __ASSEMBLY__10#include <asm/io.h>11#include <soc/imx/revision.h>12#endif13#include <linux/sizes.h>1415#define addr_in_module(addr, mod) \16((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE)1718#define IMX_IO_P2V_MODULE(addr, module) \19(((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \20(addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0)2122/*23* This is rather complicated for humans and ugly to verify, but for a machine24* it's OK. Still more as it is usually only applied to constants. The upsides25* on using this approach are:26*27* - same mapping on all i.MX machines28* - works for assembler, too29* - no need to nurture #defines for virtual addresses30*31* The downside it, it's hard to verify (but I have a script for that).32*33* Obviously this needs to be injective for each SoC. In general it maps the34* whole address space to [0xf4000000, 0xf5ffffff]. So [0xf6000000,0xfeffffff]35* is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there).36*37* It applies the following mappings for the different SoCs:38*39* mx1:40* IO 0x00200000+0x100000 -> 0xf4000000+0x10000041* mx21:42* AIPI 0x10000000+0x100000 -> 0xf4400000+0x10000043* SAHB1 0x80000000+0x100000 -> 0xf5000000+0x10000044* X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x00400045* mx25:46* AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x10000047* AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x10000048* AVIC 0x68000000+0x100000 -> 0xf5800000+0x10000049* mx27:50* AIPI 0x10000000+0x100000 -> 0xf4400000+0x10000051* SAHB1 0x80000000+0x100000 -> 0xf5000000+0x10000052* X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x10000053* mx31:54* AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x10000055* AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x10000056* AVIC 0x68000000+0x100000 -> 0xf5800000+0x10000057* X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x01000058* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x10000059* mx35:60* AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x10000061* AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x10000062* AVIC 0x68000000+0x100000 -> 0xf5800000+0x10000063* X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x01000064* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x10000065* mx51:66* TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x00400067* IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x02000068* DEBUG 0x60000000+0x100000 -> 0xf5000000+0x10000069* SPBA0 0x70000000+0x100000 -> 0xf5400000+0x10000070* AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x10000071* AIPS2 0x83f00000+0x100000 -> 0xf5300000+0x10000072* mx53:73* TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x00400074* DEBUG 0x40000000+0x100000 -> 0xf5000000+0x10000075* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x10000076* AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x10000077* AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x10000078* mx6q:79* SCU 0x00a00000+0x004000 -> 0xf4000000+0x00400080* CCM 0x020c4000+0x004000 -> 0xf42c4000+0x00400081* ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x00400082* UART4 0x021f0000+0x004000 -> 0xf42f0000+0x00400083*/84#define IMX_IO_P2V(x) ( \85(((x) & 0x80000000) >> 7) | \86(0xf4000000 + \87(((x) & 0x50000000) >> 6) + \88(((x) & 0x0b000000) >> 4) + \89(((x) & 0x000fffff))))9091#define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x))9293#include "mxc.h"9495#include "mx3x.h"96#include "mx31.h"97#include "mx35.h"98#include "mx2x.h"99#include "mx27.h"100101#define imx_map_entry(soc, name, _type) { \102.virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \103.pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \104.length = soc ## _ ## name ## _SIZE, \105.type = _type, \106}107108#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */109110111