Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2013 Freescale Semiconductor, Inc. |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame^] | 6 | #include <config.h> |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 7 | #include <asm/mmu.h> |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame^] | 8 | #include <asm/ppc.h> |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 9 | |
| 10 | struct fsl_e_tlb_entry tlb_table[] = { |
| 11 | /* TLB 0 - for temp stack in cache */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 12 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR, |
| 13 | CFG_SYS_INIT_RAM_ADDR_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 14 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 15 | 0, 0, BOOKE_PAGESZ_4K, 0), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 16 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR + 4 * 1024, |
| 17 | CFG_SYS_INIT_RAM_ADDR_PHYS + 4 * 1024, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 18 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 19 | 0, 0, BOOKE_PAGESZ_4K, 0), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 20 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR + 8 * 1024, |
| 21 | CFG_SYS_INIT_RAM_ADDR_PHYS + 8 * 1024, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 22 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 23 | 0, 0, BOOKE_PAGESZ_4K, 0), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 24 | SET_TLB_ENTRY(0, CFG_SYS_INIT_RAM_ADDR + 12 * 1024, |
| 25 | CFG_SYS_INIT_RAM_ADDR_PHYS + 12 * 1024, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 26 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 27 | 0, 0, BOOKE_PAGESZ_4K, 0), |
| 28 | |
| 29 | /* TLB 1 */ |
| 30 | /* *I*** - Covers boot page */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 31 | #if defined(CONFIG_SYS_RAMBOOT) && defined(CFG_SYS_INIT_L3_ADDR) && \ |
Udit Agarwal | d2dd2f7 | 2019-11-07 16:11:39 +0000 | [diff] [blame] | 32 | !defined(CONFIG_NXP_ESBC) |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 33 | /* |
| 34 | * *I*G - L3SRAM. When L3 is used as 256K SRAM, the address of the |
| 35 | * SRAM is at 0xfffc0000, it covered the 0xfffff000. |
| 36 | */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 37 | SET_TLB_ENTRY(1, CFG_SYS_INIT_L3_ADDR, CFG_SYS_INIT_L3_ADDR, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 38 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 39 | 0, 0, BOOKE_PAGESZ_256K, 1), |
Sumit Garg | afaca2a | 2016-07-14 12:27:52 -0400 | [diff] [blame] | 40 | |
Udit Agarwal | d2dd2f7 | 2019-11-07 16:11:39 +0000 | [diff] [blame] | 41 | #elif defined(CONFIG_NXP_ESBC) && defined(CONFIG_SPL_BUILD) |
Sumit Garg | afaca2a | 2016-07-14 12:27:52 -0400 | [diff] [blame] | 42 | /* |
| 43 | * *I*G - L3SRAM. When L3 is used as 256K SRAM, in case of Secure Boot |
| 44 | * the physical address of the SRAM is at 0xbffc0000, |
| 45 | * and virtual address is 0xfffc0000 |
| 46 | */ |
| 47 | |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 48 | SET_TLB_ENTRY(1, CFG_SYS_INIT_L3_VADDR, |
| 49 | CFG_SYS_INIT_L3_ADDR, |
Sumit Garg | afaca2a | 2016-07-14 12:27:52 -0400 | [diff] [blame] | 50 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 51 | 0, 0, BOOKE_PAGESZ_256K, 1), |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 52 | #else |
| 53 | SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000, |
| 54 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 55 | 0, 0, BOOKE_PAGESZ_4K, 1), |
| 56 | #endif |
| 57 | |
| 58 | /* *I*G* - CCSRBAR */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 59 | SET_TLB_ENTRY(1, CFG_SYS_CCSRBAR, CFG_SYS_CCSRBAR_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 60 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 61 | 0, 1, BOOKE_PAGESZ_16M, 1), |
| 62 | |
| 63 | /* *I*G* - Flash, localbus */ |
| 64 | /* This will be changed to *I*G* after relocation to RAM. */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 65 | SET_TLB_ENTRY(1, CFG_SYS_FLASH_BASE, CFG_SYS_FLASH_BASE_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 66 | MAS3_SX|MAS3_SR, MAS2_W|MAS2_G, |
| 67 | 0, 2, BOOKE_PAGESZ_256M, 1), |
| 68 | |
Prabhakar Kushwaha | c8d8e1a | 2014-04-08 19:13:56 +0530 | [diff] [blame] | 69 | #ifndef CONFIG_SPL_BUILD |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 70 | /* *I*G* - PCI */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 71 | SET_TLB_ENTRY(1, CFG_SYS_PCIE1_MEM_VIRT, CFG_SYS_PCIE1_MEM_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 72 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 73 | 0, 3, BOOKE_PAGESZ_1G, 1), |
| 74 | |
| 75 | /* *I*G* - PCI I/O */ |
Tom Rini | 56af659 | 2022-11-16 13:10:33 -0500 | [diff] [blame] | 76 | SET_TLB_ENTRY(1, CFG_SYS_PCIE1_IO_VIRT, CFG_SYS_PCIE1_IO_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 77 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 78 | 0, 4, BOOKE_PAGESZ_256K, 1), |
| 79 | |
| 80 | /* Bman/Qman */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 81 | #ifdef CFG_SYS_BMAN_MEM_PHYS |
| 82 | SET_TLB_ENTRY(1, CFG_SYS_BMAN_MEM_BASE, CFG_SYS_BMAN_MEM_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 83 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 84 | 0, 5, BOOKE_PAGESZ_16M, 1), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 85 | SET_TLB_ENTRY(1, CFG_SYS_BMAN_MEM_BASE + 0x01000000, |
| 86 | CFG_SYS_BMAN_MEM_PHYS + 0x01000000, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 87 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 88 | 0, 6, BOOKE_PAGESZ_16M, 1), |
| 89 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 90 | #ifdef CFG_SYS_QMAN_MEM_PHYS |
| 91 | SET_TLB_ENTRY(1, CFG_SYS_QMAN_MEM_BASE, CFG_SYS_QMAN_MEM_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 92 | MAS3_SX|MAS3_SW|MAS3_SR, 0, |
| 93 | 0, 7, BOOKE_PAGESZ_16M, 1), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 94 | SET_TLB_ENTRY(1, CFG_SYS_QMAN_MEM_BASE + 0x01000000, |
| 95 | CFG_SYS_QMAN_MEM_PHYS + 0x01000000, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 96 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 97 | 0, 8, BOOKE_PAGESZ_16M, 1), |
| 98 | #endif |
Prabhakar Kushwaha | c8d8e1a | 2014-04-08 19:13:56 +0530 | [diff] [blame] | 99 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 100 | #ifdef CFG_SYS_DCSRBAR_PHYS |
| 101 | SET_TLB_ENTRY(1, CFG_SYS_DCSRBAR, CFG_SYS_DCSRBAR_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 102 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 103 | 0, 9, BOOKE_PAGESZ_4M, 1), |
| 104 | #endif |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 105 | #ifdef CFG_SYS_NAND_BASE |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 106 | /* |
| 107 | * *I*G - NAND |
| 108 | * entry 14 and 15 has been used hard coded, they will be disabled |
| 109 | * in cpu_init_f, so we use entry 16 for nand. |
| 110 | */ |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 111 | SET_TLB_ENTRY(1, CFG_SYS_NAND_BASE, CFG_SYS_NAND_BASE_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 112 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 113 | 0, 10, BOOKE_PAGESZ_64K, 1), |
| 114 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 115 | #ifdef CFG_SYS_CPLD_BASE |
| 116 | SET_TLB_ENTRY(1, CFG_SYS_CPLD_BASE, CFG_SYS_CPLD_BASE_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 117 | MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 118 | 0, 11, BOOKE_PAGESZ_256K, 1), |
| 119 | #endif |
Prabhakar Kushwaha | c8d8e1a | 2014-04-08 19:13:56 +0530 | [diff] [blame] | 120 | |
| 121 | #if defined(CONFIG_RAMBOOT_PBL) && !defined(CONFIG_SPL_BUILD) |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 122 | 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] | 123 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_M, |
Prabhakar Kushwaha | c8d8e1a | 2014-04-08 19:13:56 +0530 | [diff] [blame] | 124 | 0, 12, BOOKE_PAGESZ_1G, 1), |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 125 | SET_TLB_ENTRY(1, CFG_SYS_DDR_SDRAM_BASE + 0x40000000, |
| 126 | CFG_SYS_DDR_SDRAM_BASE + 0x40000000, |
York Sun | 05204d0 | 2017-12-05 10:57:54 -0800 | [diff] [blame] | 127 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_M, |
Prabhakar Kushwaha | c8d8e1a | 2014-04-08 19:13:56 +0530 | [diff] [blame] | 128 | 0, 13, BOOKE_PAGESZ_1G, 1) |
| 129 | #endif |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | int num_tlb_entries = ARRAY_SIZE(tlb_table); |