Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved.
0004  * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
0005  */
0006 
0007 #ifndef __ASM_ARCH_MXC_HARDWARE_H__
0008 #define __ASM_ARCH_MXC_HARDWARE_H__
0009 
0010 #ifndef __ASSEMBLY__
0011 #include <asm/io.h>
0012 #include <soc/imx/revision.h>
0013 #endif
0014 #include <linux/sizes.h>
0015 
0016 #define addr_in_module(addr, mod) \
0017     ((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE)
0018 
0019 #define IMX_IO_P2V_MODULE(addr, module)                 \
0020     (((addr) - module ## _BASE_ADDR) < module ## _SIZE ?        \
0021      (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0)
0022 
0023 /*
0024  * This is rather complicated for humans and ugly to verify, but for a machine
0025  * it's OK.  Still more as it is usually only applied to constants.  The upsides
0026  * on using this approach are:
0027  *
0028  *  - same mapping on all i.MX machines
0029  *  - works for assembler, too
0030  *  - no need to nurture #defines for virtual addresses
0031  *
0032  * The downside it, it's hard to verify (but I have a script for that).
0033  *
0034  * Obviously this needs to be injective for each SoC.  In general it maps the
0035  * whole address space to [0xf4000000, 0xf5ffffff].  So [0xf6000000,0xfeffffff]
0036  * is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there).
0037  *
0038  * It applies the following mappings for the different SoCs:
0039  *
0040  * mx1:
0041  *  IO  0x00200000+0x100000 ->  0xf4000000+0x100000
0042  * mx21:
0043  *  AIPI    0x10000000+0x100000 ->  0xf4400000+0x100000
0044  *  SAHB1   0x80000000+0x100000 ->  0xf5000000+0x100000
0045  *  X_MEMC  0xdf000000+0x004000 ->  0xf5f00000+0x004000
0046  * mx25:
0047  *  AIPS1   0x43f00000+0x100000 ->  0xf5300000+0x100000
0048  *  AIPS2   0x53f00000+0x100000 ->  0xf5700000+0x100000
0049  *  AVIC    0x68000000+0x100000 ->  0xf5800000+0x100000
0050  * mx27:
0051  *  AIPI    0x10000000+0x100000 ->  0xf4400000+0x100000
0052  *  SAHB1   0x80000000+0x100000 ->  0xf5000000+0x100000
0053  *  X_MEMC  0xd8000000+0x100000 ->  0xf5c00000+0x100000
0054  * mx31:
0055  *  AIPS1   0x43f00000+0x100000 ->  0xf5300000+0x100000
0056  *  AIPS2   0x53f00000+0x100000 ->  0xf5700000+0x100000
0057  *  AVIC    0x68000000+0x100000 ->  0xf5800000+0x100000
0058  *  X_MEMC  0xb8000000+0x010000 ->  0xf5c00000+0x010000
0059  *  SPBA0   0x50000000+0x100000 ->  0xf5400000+0x100000
0060  * mx35:
0061  *  AIPS1   0x43f00000+0x100000 ->  0xf5300000+0x100000
0062  *  AIPS2   0x53f00000+0x100000 ->  0xf5700000+0x100000
0063  *  AVIC    0x68000000+0x100000 ->  0xf5800000+0x100000
0064  *  X_MEMC  0xb8000000+0x010000 ->  0xf5c00000+0x010000
0065  *  SPBA0   0x50000000+0x100000 ->  0xf5400000+0x100000
0066  * mx51:
0067  *  TZIC    0x0fffc000+0x004000 ->  0xf4bfc000+0x004000
0068  *  IRAM    0x1ffe0000+0x020000 ->  0xf4fe0000+0x020000
0069  *  DEBUG   0x60000000+0x100000 ->  0xf5000000+0x100000
0070  *  SPBA0   0x70000000+0x100000 ->  0xf5400000+0x100000
0071  *  AIPS1   0x73f00000+0x100000 ->  0xf5700000+0x100000
0072  *  AIPS2   0x83f00000+0x100000 ->  0xf5300000+0x100000
0073  * mx53:
0074  *  TZIC    0x0fffc000+0x004000 ->  0xf4bfc000+0x004000
0075  *  DEBUG   0x40000000+0x100000 ->  0xf5000000+0x100000
0076  *  SPBA0   0x50000000+0x100000 ->  0xf5400000+0x100000
0077  *  AIPS1   0x53f00000+0x100000 ->  0xf5700000+0x100000
0078  *  AIPS2   0x63f00000+0x100000 ->  0xf5300000+0x100000
0079  * mx6q:
0080  *  SCU 0x00a00000+0x004000 ->  0xf4000000+0x004000
0081  *  CCM 0x020c4000+0x004000 ->  0xf42c4000+0x004000
0082  *  ANATOP  0x020c8000+0x004000 ->  0xf42c8000+0x004000
0083  *  UART4   0x021f0000+0x004000 ->  0xf42f0000+0x004000
0084  */
0085 #define IMX_IO_P2V(x)   (                       \
0086             (((x) & 0x80000000) >> 7) |         \
0087             (0xf4000000 +                   \
0088             (((x) & 0x50000000) >> 6) +         \
0089             (((x) & 0x0b000000) >> 4) +         \
0090             (((x) & 0x000fffff))))
0091 
0092 #define IMX_IO_ADDRESS(x)   IOMEM(IMX_IO_P2V(x))
0093 
0094 #include "mxc.h"
0095 
0096 #include "mx3x.h"
0097 #include "mx31.h"
0098 #include "mx35.h"
0099 #include "mx2x.h"
0100 #include "mx27.h"
0101 
0102 #define imx_map_entry(soc, name, _type) {               \
0103     .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR),  \
0104     .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR),       \
0105     .length = soc ## _ ## name ## _SIZE,                \
0106     .type = _type,                          \
0107 }
0108 
0109 #endif /* __ASM_ARCH_MXC_HARDWARE_H__ */