18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved. 48c2ecf20Sopenharmony_ci * Copyright 2008 Juergen Beisert, kernel@pengutronix.de 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __ASM_ARCH_MXC_HARDWARE_H__ 88c2ecf20Sopenharmony_ci#define __ASM_ARCH_MXC_HARDWARE_H__ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 118c2ecf20Sopenharmony_ci#include <asm/io.h> 128c2ecf20Sopenharmony_ci#include <soc/imx/revision.h> 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci#include <linux/sizes.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define addr_in_module(addr, mod) \ 178c2ecf20Sopenharmony_ci ((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define IMX_IO_P2V_MODULE(addr, module) \ 208c2ecf20Sopenharmony_ci (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \ 218c2ecf20Sopenharmony_ci (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * This is rather complicated for humans and ugly to verify, but for a machine 258c2ecf20Sopenharmony_ci * it's OK. Still more as it is usually only applied to constants. The upsides 268c2ecf20Sopenharmony_ci * on using this approach are: 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * - same mapping on all i.MX machines 298c2ecf20Sopenharmony_ci * - works for assembler, too 308c2ecf20Sopenharmony_ci * - no need to nurture #defines for virtual addresses 318c2ecf20Sopenharmony_ci * 328c2ecf20Sopenharmony_ci * The downside it, it's hard to verify (but I have a script for that). 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * Obviously this needs to be injective for each SoC. In general it maps the 358c2ecf20Sopenharmony_ci * whole address space to [0xf4000000, 0xf5ffffff]. So [0xf6000000,0xfeffffff] 368c2ecf20Sopenharmony_ci * is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there). 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * It applies the following mappings for the different SoCs: 398c2ecf20Sopenharmony_ci * 408c2ecf20Sopenharmony_ci * mx1: 418c2ecf20Sopenharmony_ci * IO 0x00200000+0x100000 -> 0xf4000000+0x100000 428c2ecf20Sopenharmony_ci * mx21: 438c2ecf20Sopenharmony_ci * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000 448c2ecf20Sopenharmony_ci * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000 458c2ecf20Sopenharmony_ci * X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000 468c2ecf20Sopenharmony_ci * mx25: 478c2ecf20Sopenharmony_ci * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 488c2ecf20Sopenharmony_ci * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 498c2ecf20Sopenharmony_ci * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 508c2ecf20Sopenharmony_ci * mx27: 518c2ecf20Sopenharmony_ci * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000 528c2ecf20Sopenharmony_ci * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000 538c2ecf20Sopenharmony_ci * X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000 548c2ecf20Sopenharmony_ci * mx31: 558c2ecf20Sopenharmony_ci * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 568c2ecf20Sopenharmony_ci * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 578c2ecf20Sopenharmony_ci * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 588c2ecf20Sopenharmony_ci * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000 598c2ecf20Sopenharmony_ci * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 608c2ecf20Sopenharmony_ci * mx35: 618c2ecf20Sopenharmony_ci * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 628c2ecf20Sopenharmony_ci * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 638c2ecf20Sopenharmony_ci * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 648c2ecf20Sopenharmony_ci * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000 658c2ecf20Sopenharmony_ci * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 668c2ecf20Sopenharmony_ci * mx51: 678c2ecf20Sopenharmony_ci * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 688c2ecf20Sopenharmony_ci * IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000 698c2ecf20Sopenharmony_ci * DEBUG 0x60000000+0x100000 -> 0xf5000000+0x100000 708c2ecf20Sopenharmony_ci * SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000 718c2ecf20Sopenharmony_ci * AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000 728c2ecf20Sopenharmony_ci * AIPS2 0x83f00000+0x100000 -> 0xf5300000+0x100000 738c2ecf20Sopenharmony_ci * mx53: 748c2ecf20Sopenharmony_ci * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 758c2ecf20Sopenharmony_ci * DEBUG 0x40000000+0x100000 -> 0xf5000000+0x100000 768c2ecf20Sopenharmony_ci * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 778c2ecf20Sopenharmony_ci * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000 788c2ecf20Sopenharmony_ci * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000 798c2ecf20Sopenharmony_ci * mx6q: 808c2ecf20Sopenharmony_ci * SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000 818c2ecf20Sopenharmony_ci * CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000 828c2ecf20Sopenharmony_ci * ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000 838c2ecf20Sopenharmony_ci * UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_ci#define IMX_IO_P2V(x) ( \ 868c2ecf20Sopenharmony_ci (((x) & 0x80000000) >> 7) | \ 878c2ecf20Sopenharmony_ci (0xf4000000 + \ 888c2ecf20Sopenharmony_ci (((x) & 0x50000000) >> 6) + \ 898c2ecf20Sopenharmony_ci (((x) & 0x0b000000) >> 4) + \ 908c2ecf20Sopenharmony_ci (((x) & 0x000fffff)))) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x)) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#include "mxc.h" 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#include "mx3x.h" 978c2ecf20Sopenharmony_ci#include "mx31.h" 988c2ecf20Sopenharmony_ci#include "mx35.h" 998c2ecf20Sopenharmony_ci#include "mx2x.h" 1008c2ecf20Sopenharmony_ci#include "mx27.h" 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define imx_map_entry(soc, name, _type) { \ 1038c2ecf20Sopenharmony_ci .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ 1048c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ 1058c2ecf20Sopenharmony_ci .length = soc ## _ ## name ## _SIZE, \ 1068c2ecf20Sopenharmony_ci .type = _type, \ 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* There's an off-by-one between the gpio bank number and the gpiochip */ 1108c2ecf20Sopenharmony_ci/* range e.g. GPIO_1_5 is gpio 5 under linux */ 1118c2ecf20Sopenharmony_ci#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr)) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */ 114