Consolidate all mem_map definitions for MediaTek ARMv8 platforms into a
single file. The size of the DDR and MMIO regions can vary, so Kconfig
options are added to configure them by target.

Signed-off-by: David Lechner <[email protected]>
---
 arch/arm/mach-mediatek/Kconfig                     | 21 ++++++++++++++++
 arch/arm/mach-mediatek/Makefile                    |  1 +
 .../arm/mach-mediatek/armv8-mem-map.c              | 14 ++++-------
 arch/arm/mach-mediatek/mt7622/init.c               | 20 ---------------
 arch/arm/mach-mediatek/mt7981/init.c               | 21 ----------------
 arch/arm/mach-mediatek/mt7986/init.c               | 21 ----------------
 arch/arm/mach-mediatek/mt7987/init.c               | 21 ----------------
 arch/arm/mach-mediatek/mt7988/init.c               | 21 ----------------
 arch/arm/mach-mediatek/mt8183/init.c               | 20 ---------------
 arch/arm/mach-mediatek/mt8512/init.c               | 21 ----------------
 arch/arm/mach-mediatek/mt8516/init.c               | 20 ---------------
 arch/arm/mach-mediatek/mt8518/init.c               | 21 ----------------
 board/mediatek/mt8365_evk/MAINTAINERS              |  5 ----
 board/mediatek/mt8365_evk/Makefile                 |  3 ---
 board/mediatek/mt8390_evk/MAINTAINERS              |  6 -----
 board/mediatek/mt8390_evk/Makefile                 |  3 ---
 board/mediatek/mt8390_evk/mt8390_evk.c             | 29 ----------------------
 17 files changed, 27 insertions(+), 241 deletions(-)

diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
index d1d2605b2cc..33717a1864f 100644
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -130,6 +130,27 @@ config TARGET_MT8518
 
 endchoice
 
+if ARM64
+
+config MTK_MEM_MAP_DDR_SIZE
+       hex "DDR .size in mem_map"
+       default 0x200000000 if TARGET_MT7987 || TARGET_MT7988 || TARGET_MT8188
+       default 0xc0000000 if TARGET_MT8365
+       default 0x80000000 if TARGET_MT7981 || TARGET_MT7986 || TARGET_MT8183
+       default 0x40000000 if TARGET_MT7622 || TARGET_MT8512
+       default 0x20000000
+       help
+               Target-specific DDR region size in mem_map.
+
+config MTK_MEM_MAP_MMIO_SIZE
+       hex "MMIO .size in mem_map"
+       default 0x40000000 if TARGET_MT7622 || TARGET_MT7981 || TARGET_MT7986 
|| TARGET_MT7987 || TARGET_MT7988 || TARGET_MT8512
+       default 0x20000000
+       help
+               Target-specific MMIO region size in mem_map.
+
+endif
+
 config SYS_BOARD
        string "Board name"
        default "mt7622" if TARGET_MT7622
diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
index 44591bed6fa..17e645989e5 100644
--- a/arch/arm/mach-mediatek/Makefile
+++ b/arch/arm/mach-mediatek/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier:     GPL-2.0
 
+obj-$(CONFIG_ARM64) += armv8-mem-map.o
 obj-y  += cpu.o
 obj-$(CONFIG_MTK_TZ_MOVABLE)   += tzcfg.o
 obj-$(CONFIG_XPL_BUILD)        += spl.o
diff --git a/board/mediatek/mt8365_evk/mt8365_evk.c 
b/arch/arm/mach-mediatek/armv8-mem-map.c
similarity index 55%
rename from board/mediatek/mt8365_evk/mt8365_evk.c
rename to arch/arm/mach-mediatek/armv8-mem-map.c
index 41a6febf03d..0abddb99f25 100644
--- a/board/mediatek/mt8365_evk/mt8365_evk.c
+++ b/arch/arm/mach-mediatek/armv8-mem-map.c
@@ -1,22 +1,18 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2023 BayLibre SAS
- * Author: Julien Masson <[email protected]>
- */
+// SPDX-License-Identifier: GPL-2.0-only
 
 #include <asm/armv8/mmu.h>
 
-static struct mm_region mt8365_evk_mem_map[] = {
+static struct mm_region mediatek_mem_map[] = {
        {
                /* DDR */
                .virt = 0x40000000UL,
                .phys = 0x40000000UL,
-               .size = 0xc0000000UL,
+               .size = CONFIG_MTK_MEM_MAP_DDR_SIZE,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
        }, {
                .virt = 0x00000000UL,
                .phys = 0x00000000UL,
-               .size = 0x20000000UL,
+               .size = CONFIG_MTK_MEM_MAP_MMIO_SIZE,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
@@ -25,4 +21,4 @@ static struct mm_region mt8365_evk_mem_map[] = {
        }
 };
 
-struct mm_region *mem_map = mt8365_evk_mem_map;
+struct mm_region *mem_map = mediatek_mem_map;
diff --git a/arch/arm/mach-mediatek/mt7622/init.c 
b/arch/arm/mach-mediatek/mt7622/init.c
index 368f2916224..a043ca87398 100644
--- a/arch/arm/mach-mediatek/mt7622/init.c
+++ b/arch/arm/mach-mediatek/mt7622/init.c
@@ -36,23 +36,3 @@ void reset_cpu(void)
 {
        psci_system_reset();
 }
-
-static struct mm_region mt7622_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-struct mm_region *mem_map = mt7622_mem_map;
diff --git a/arch/arm/mach-mediatek/mt7981/init.c 
b/arch/arm/mach-mediatek/mt7981/init.c
index 07da5897190..79afd6ce6be 100644
--- a/arch/arm/mach-mediatek/mt7981/init.c
+++ b/arch/arm/mach-mediatek/mt7981/init.c
@@ -30,24 +30,3 @@ void reset_cpu(void)
 {
        psci_system_reset();
 }
-
-static struct mm_region mt7981_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x80000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt7981_mem_map;
diff --git a/arch/arm/mach-mediatek/mt7986/init.c 
b/arch/arm/mach-mediatek/mt7986/init.c
index a521c95bd9d..1fe56b3f145 100644
--- a/arch/arm/mach-mediatek/mt7986/init.c
+++ b/arch/arm/mach-mediatek/mt7986/init.c
@@ -30,24 +30,3 @@ void reset_cpu(void)
 {
        psci_system_reset();
 }
-
-static struct mm_region mt7986_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x80000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt7986_mem_map;
diff --git a/arch/arm/mach-mediatek/mt7987/init.c 
b/arch/arm/mach-mediatek/mt7987/init.c
index 8b268297809..6364ab497f7 100644
--- a/arch/arm/mach-mediatek/mt7987/init.c
+++ b/arch/arm/mach-mediatek/mt7987/init.c
@@ -39,24 +39,3 @@ void reset_cpu(ulong addr)
 {
        psci_system_reset();
 }
-
-static struct mm_region mt7987_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x200000000ULL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt7987_mem_map;
diff --git a/arch/arm/mach-mediatek/mt7988/init.c 
b/arch/arm/mach-mediatek/mt7988/init.c
index 8bdd3848d26..7ff843585ec 100644
--- a/arch/arm/mach-mediatek/mt7988/init.c
+++ b/arch/arm/mach-mediatek/mt7988/init.c
@@ -38,24 +38,3 @@ void reset_cpu(ulong addr)
 {
        psci_system_reset();
 }
-
-static struct mm_region mt7988_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x200000000ULL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt7988_mem_map;
diff --git a/arch/arm/mach-mediatek/mt8183/init.c 
b/arch/arm/mach-mediatek/mt8183/init.c
index b445f3ea1e3..8dbf9c3df7e 100644
--- a/arch/arm/mach-mediatek/mt8183/init.c
+++ b/arch/arm/mach-mediatek/mt8183/init.c
@@ -47,23 +47,3 @@ int print_cpuinfo(void)
        printf("CPU:   MediaTek MT8183\n");
        return 0;
 }
-
-static struct mm_region mt8183_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x80000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x20000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-struct mm_region *mem_map = mt8183_mem_map;
diff --git a/arch/arm/mach-mediatek/mt8512/init.c 
b/arch/arm/mach-mediatek/mt8512/init.c
index 3b48caf5196..361c589cbc2 100644
--- a/arch/arm/mach-mediatek/mt8512/init.c
+++ b/arch/arm/mach-mediatek/mt8512/init.c
@@ -59,24 +59,3 @@ int print_cpuinfo(void)
        debug("CPU:   MediaTek MT8512\n");
        return 0;
 }
-
-static struct mm_region mt8512_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x40000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt8512_mem_map;
diff --git a/arch/arm/mach-mediatek/mt8516/init.c 
b/arch/arm/mach-mediatek/mt8516/init.c
index 82f8c509745..1d925dd478a 100644
--- a/arch/arm/mach-mediatek/mt8516/init.c
+++ b/arch/arm/mach-mediatek/mt8516/init.c
@@ -94,23 +94,3 @@ int print_cpuinfo(void)
        printf("CPU:   MediaTek MT8516\n");
        return 0;
 }
-
-static struct mm_region mt8516_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x20000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x20000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-struct mm_region *mem_map = mt8516_mem_map;
diff --git a/arch/arm/mach-mediatek/mt8518/init.c 
b/arch/arm/mach-mediatek/mt8518/init.c
index c04bcb63517..8fa1346021a 100644
--- a/arch/arm/mach-mediatek/mt8518/init.c
+++ b/arch/arm/mach-mediatek/mt8518/init.c
@@ -51,24 +51,3 @@ int print_cpuinfo(void)
        printf("CPU:   MediaTek MT8518\n");
        return 0;
 }
-
-static struct mm_region mt8518_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x20000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x20000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt8518_mem_map;
diff --git a/board/mediatek/mt8365_evk/MAINTAINERS 
b/board/mediatek/mt8365_evk/MAINTAINERS
deleted file mode 100644
index e0d65efe812..00000000000
--- a/board/mediatek/mt8365_evk/MAINTAINERS
+++ /dev/null
@@ -1,5 +0,0 @@
-MT8365 EVK
-M:     Julien Masson <[email protected]>
-S:     Maintained
-F:     board/mediatek/mt8365_evk/
-F:     configs/mt8365_evk_defconfig
diff --git a/board/mediatek/mt8365_evk/Makefile 
b/board/mediatek/mt8365_evk/Makefile
deleted file mode 100644
index 90fc92b28c5..00000000000
--- a/board/mediatek/mt8365_evk/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier:     GPL-2.0
-
-obj-y += mt8365_evk.o
diff --git a/board/mediatek/mt8390_evk/MAINTAINERS 
b/board/mediatek/mt8390_evk/MAINTAINERS
deleted file mode 100644
index d46b8b2e156..00000000000
--- a/board/mediatek/mt8390_evk/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-MT8390 EVK
-M:     Julien Masson <[email protected]>
-M:     Macpaul Lin <[email protected]>
-S:     Maintained
-F:     board/mediatek/mt8390_evk/
-F:     configs/mt8390_evk_defconfig
diff --git a/board/mediatek/mt8390_evk/Makefile 
b/board/mediatek/mt8390_evk/Makefile
deleted file mode 100644
index a26d46838c4..00000000000
--- a/board/mediatek/mt8390_evk/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier:     GPL-2.0
-
-obj-y += mt8390_evk.o
diff --git a/board/mediatek/mt8390_evk/mt8390_evk.c 
b/board/mediatek/mt8390_evk/mt8390_evk.c
deleted file mode 100644
index 5731199bf83..00000000000
--- a/board/mediatek/mt8390_evk/mt8390_evk.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2026 BayLibre SAS
- * Author: Julien Masson <[email protected]>
- */
-
-#include <linux/types.h>
-#include <asm/armv8/mmu.h>
-
-static struct mm_region mt8390_evk_mem_map[] = {
-       {
-               /* DDR */
-               .virt = 0x40000000UL,
-               .phys = 0x40000000UL,
-               .size = 0x200000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
-       }, {
-               .virt = 0x00000000UL,
-               .phys = 0x00000000UL,
-               .size = 0x20000000UL,
-               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-                        PTE_BLOCK_NON_SHARE |
-                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
-       }, {
-               0,
-       }
-};
-
-struct mm_region *mem_map = mt8390_evk_mem_map;

-- 
2.43.0

Reply via email to