Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008-2013 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * (C) Copyright 2000 |
| 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <asm/mmu.h> |
| 11 | |
| 12 | struct fsl_e_tlb_entry tlb_table[] = { |
| 13 | /* TLB 0 - for temp stack in cache */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 14 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR, |
| 15 | CFG_SYS_INIT_RAM_ADDR_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 16 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 17 | 0, 0, BOOKE_PAGESZ_4K, 0), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 18 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR + 4 * 1024, |
| 19 | CFG_SYS_INIT_RAM_ADDR_PHYS + 4 * 1024, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 20 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 21 | 0, 0, BOOKE_PAGESZ_4K, 0), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 22 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR + 8 * 1024, |
| 23 | CFG_SYS_INIT_RAM_ADDR_PHYS + 8 * 1024, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 24 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 25 | 0, 0, BOOKE_PAGESZ_4K, 0), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 26 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR + 12 * 1024, |
| 27 | CFG_SYS_INIT_RAM_ADDR_PHYS + 12 * 1024, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 28 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 29 | 0, 0, BOOKE_PAGESZ_4K, 0), |
| 30 | |
| 31 | /* TLB 1 */ |
| 32 | /* *I*** - Covers boot page */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 33 | #if defined(CONFIG_SYS_RAMBOOT) && defined(CFG_SYS_INIT_L3_ADDR) |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 34 | /* |
| 35 | * *I*G - L3SRAM. When L3 is used as 1M SRAM, the address of the |
| 36 | * SRAM is at 0xfff00000, it covered the 0xfffff000. |
| 37 | */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 38 | SET_TLB_ENTRY(1, CFG_SYS_INIT_L3_ADDR, CFG_SYS_INIT_L3_ADDR, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 39 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 40 | 0, 0, BOOKE_PAGESZ_1M, 1), |
| 41 | #elif defined(CONFIG_SRIO_PCIE_BOOT_SLAVE) |
| 42 | /* |
| 43 | * SRIO_PCIE_BOOT-SLAVE. When slave boot, the address of the |
| 44 | * space is at 0xfff00000, it covered the 0xfffff000. |
| 45 | */ |
Tom Rini | 40eb556 | 2022-11-16 13:10:40 -0500 | [diff] [blame] | 46 | SET_TLB_ENTRY(1, CFG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR, |
| 47 | CFG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 48 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_W|MAS2_G, |
| 49 | 0, 0, BOOKE_PAGESZ_1M, 1), |
| 50 | #else |
| 51 | SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000, |
| 52 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 53 | 0, 0, BOOKE_PAGESZ_4K, 1), |
| 54 | #endif |
| 55 | |
| 56 | /* *I*G* - CCSRBAR */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 57 | SET_TLB_ENTRY(1, CFG_SYS_CCSRBAR, CFG_SYS_CCSRBAR_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 58 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 59 | 0, 1, BOOKE_PAGESZ_16M, 1), |
| 60 | |
| 61 | /* *I*G* - Flash, localbus */ |
| 62 | /* This will be changed to *I*G* after relocation to RAM. */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 63 | SET_TLB_ENTRY(1, CFG_SYS_FLASH_BASE, CFG_SYS_FLASH_BASE_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 64 | MAS3_SX|MAS3_SR, MAS2_W|MAS2_G, |
| 65 | 0, 2, BOOKE_PAGESZ_256M, 1), |
| 66 | |
Shengzhou Liu | d11b3cb | 2014-04-18 16:43:39 +0800 | [diff] [blame] | 67 | #ifndef CONFIG_SPL_BUILD |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 68 | /* *I*G* - PCIe 1, 0x80000000 */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 69 | SET_TLB_ENTRY(1, CFG_SYS_PCIE1_MEM_VIRT, CFG_SYS_PCIE1_MEM_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 70 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 71 | 0, 3, BOOKE_PAGESZ_512M, 1), |
| 72 | |
| 73 | /* *I*G* - PCIe 2, 0xa0000000 */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 74 | SET_TLB_ENTRY(1, CFG_SYS_PCIE2_MEM_VIRT, CFG_SYS_PCIE2_MEM_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 75 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 76 | 0, 4, BOOKE_PAGESZ_256M, 1), |
| 77 | |
| 78 | /* *I*G* - PCIe 3, 0xb0000000 */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 79 | SET_TLB_ENTRY(1, CFG_SYS_PCIE3_MEM_VIRT, CFG_SYS_PCIE3_MEM_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 80 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 81 | 0, 5, BOOKE_PAGESZ_256M, 1), |
| 82 | |
| 83 | |
| 84 | /* *I*G* - PCIe 4, 0xc0000000 */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 85 | SET_TLB_ENTRY(1, CFG_SYS_PCIE4_MEM_VIRT, CFG_SYS_PCIE4_MEM_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 86 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 87 | 0, 6, BOOKE_PAGESZ_256M, 1), |
| 88 | |
| 89 | /* *I*G* - PCI I/O */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 90 | SET_TLB_ENTRY(1, CFG_SYS_PCIE1_IO_VIRT, CFG_SYS_PCIE1_IO_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 91 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 92 | 0, 7, BOOKE_PAGESZ_256K, 1), |
| 93 | |
| 94 | /* Bman/Qman */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 95 | #ifdef CFG_SYS_BMAN_MEM_PHYS |
| 96 | SET_TLB_ENTRY(1, CFG_SYS_BMAN_MEM_BASE, CFG_SYS_BMAN_MEM_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 97 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 98 | 0, 9, BOOKE_PAGESZ_16M, 1), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 99 | SET_TLB_ENTRY(1, CFG_SYS_BMAN_MEM_BASE + 0x01000000, |
| 100 | CFG_SYS_BMAN_MEM_PHYS + 0x01000000, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 101 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 102 | 0, 10, BOOKE_PAGESZ_16M, 1), |
| 103 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 104 | #ifdef CFG_SYS_QMAN_MEM_PHYS |
| 105 | SET_TLB_ENTRY(1, CFG_SYS_QMAN_MEM_BASE, CFG_SYS_QMAN_MEM_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 106 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 107 | 0, 11, BOOKE_PAGESZ_16M, 1), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 108 | SET_TLB_ENTRY(1, CFG_SYS_QMAN_MEM_BASE + 0x01000000, |
| 109 | CFG_SYS_QMAN_MEM_PHYS + 0x01000000, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 110 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 111 | 0, 12, BOOKE_PAGESZ_16M, 1), |
| 112 | #endif |
Shengzhou Liu | d11b3cb | 2014-04-18 16:43:39 +0800 | [diff] [blame] | 113 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 114 | #ifdef CFG_SYS_DCSRBAR_PHYS |
| 115 | SET_TLB_ENTRY(1, CFG_SYS_DCSRBAR, CFG_SYS_DCSRBAR_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 116 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 117 | 0, 13, BOOKE_PAGESZ_32M, 1), |
| 118 | #endif |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 119 | #ifdef CFG_SYS_NAND_BASE |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 120 | /* |
| 121 | * *I*G - NAND |
| 122 | * entry 14 and 15 has been used hard coded, they will be disabled |
| 123 | * in cpu_init_f, so we use entry 16 for nand. |
| 124 | */ |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 125 | SET_TLB_ENTRY(1, CFG_SYS_NAND_BASE, CFG_SYS_NAND_BASE_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 126 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 127 | 0, 16, BOOKE_PAGESZ_64K, 1), |
| 128 | #endif |
| 129 | #ifdef QIXIS_BASE_PHYS |
| 130 | SET_TLB_ENTRY(1, QIXIS_BASE, QIXIS_BASE_PHYS, |
| 131 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 132 | 0, 17, BOOKE_PAGESZ_4K, 1), |
| 133 | #endif |
| 134 | #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE |
| 135 | /* |
| 136 | * SRIO_PCIE_BOOT-SLAVE. 1M space from 0xffe00000 for |
| 137 | * fetching ucode and ENV from master |
| 138 | */ |
Tom Rini | 40eb556 | 2022-11-16 13:10:40 -0500 | [diff] [blame] | 139 | SET_TLB_ENTRY(1, CFG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR, |
| 140 | CFG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR_PHYS, |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 141 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_G, |
| 142 | 0, 18, BOOKE_PAGESZ_1M, 1), |
| 143 | #endif |
| 144 | |
Shengzhou Liu | d11b3cb | 2014-04-18 16:43:39 +0800 | [diff] [blame] | 145 | #if defined(CONFIG_RAMBOOT_PBL) && !defined(CONFIG_SPL_BUILD) |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 146 | SET_TLB_ENTRY(1, CFG_SYS_DDR_SDRAM_BASE, CFG_SYS_DDR_SDRAM_BASE, |
York Sun | 05204d0 | 2017-12-05 10:57:54 -0800 | [diff] [blame] | 147 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_M, |
Shengzhou Liu | d11b3cb | 2014-04-18 16:43:39 +0800 | [diff] [blame] | 148 | 0, 19, BOOKE_PAGESZ_2G, 1) |
| 149 | #endif |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | int num_tlb_entries = ARRAY_SIZE(tlb_table); |