Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1 | /* |
Matthias Fuchs | 83a49c8 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 2 | * (C) Copyright 2008 |
| 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Wolfgang Denk | 25ddd1f | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 8 | #include <asm-offsets.h> |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 9 | #include <ppc_asm.tmpl> |
Peter Tyser | 61f2b38 | 2010-04-12 22:28:07 -0500 | [diff] [blame] | 10 | #include <asm/mmu.h> |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 11 | #include <config.h> |
| 12 | |
Matthias Fuchs | 83a49c8 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 13 | /* |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 14 | * TLB TABLE |
| 15 | * |
| 16 | * This table is used by the cpu boot code to setup the initial tlb |
| 17 | * entries. Rather than make broad assumptions in the cpu source tree, |
| 18 | * this table lets each board set things up however they like. |
| 19 | * |
| 20 | * Pointer to the table is returned in r1 |
Matthias Fuchs | 83a49c8 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 21 | */ |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 22 | .section .bootpg,"ax" |
| 23 | .globl tlbtab |
| 24 | |
| 25 | tlbtab: |
| 26 | tlbtab_start |
| 27 | |
Niklaus Giger | 4d332db | 2008-01-10 18:50:33 +0100 | [diff] [blame] | 28 | /* vxWorks needs this as first entry for the Machine Check interrupt */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 29 | tlbentry( 0x40000000, SZ_256M, 0, 0, AC_RWX | SA_IG ) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 30 | |
Stefan Roese | d873133 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 31 | /* |
| 32 | * The RAM-boot version skips the SDRAM TLB (identified by EPN=0). This |
| 33 | * entry is already configured for SDRAM via the JTAG debugger and mustn't |
| 34 | * be re-initialized by this RAM-booting U-Boot version. |
| 35 | */ |
| 36 | #ifndef CONFIG_SYS_RAMBOOT |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 37 | /* TLB-entry for DDR SDRAM (Up to 2GB) */ |
Stefan Roese | ea2e142 | 2007-10-31 20:57:11 +0100 | [diff] [blame] | 38 | #ifdef CONFIG_4xx_DCACHE |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 39 | tlbentry( CONFIG_SYS_SDRAM_BASE, SZ_256M, CONFIG_SYS_SDRAM_BASE, 0, AC_RWX | SA_G) |
Stefan Roese | ea2e142 | 2007-10-31 20:57:11 +0100 | [diff] [blame] | 40 | #else |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 41 | tlbentry( CONFIG_SYS_SDRAM_BASE, SZ_256M, CONFIG_SYS_SDRAM_BASE, 0, AC_RWX | SA_IG ) |
Stefan Roese | ea2e142 | 2007-10-31 20:57:11 +0100 | [diff] [blame] | 42 | #endif |
Stefan Roese | d873133 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 43 | #endif /* CONFIG_SYS_RAMBOOT */ |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 44 | |
Niklaus Giger | 4d332db | 2008-01-10 18:50:33 +0100 | [diff] [blame] | 45 | /* TLB-entry for EBC */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 46 | tlbentry( CONFIG_SYS_BCSR_BASE, SZ_256M, CONFIG_SYS_BCSR_BASE, 1, AC_RWX | SA_IG ) |
Niklaus Giger | 4d332db | 2008-01-10 18:50:33 +0100 | [diff] [blame] | 47 | |
| 48 | /* BOOT_CS (FLASH) must be forth. Before relocation SA_I can be off to use the |
| 49 | * speed up boot process. It is patched after relocation to enable SA_I |
| 50 | */ |
| 51 | #ifndef CONFIG_NAND_SPL |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 52 | tlbentry( CONFIG_SYS_BOOT_BASE_ADDR, SZ_256M, CONFIG_SYS_BOOT_BASE_ADDR, 1, AC_RWX | SA_G ) |
Niklaus Giger | 4d332db | 2008-01-10 18:50:33 +0100 | [diff] [blame] | 53 | #else |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 54 | tlbentry( CONFIG_SYS_NAND_BOOT_SPL_SRC, SZ_4K, CONFIG_SYS_NAND_BOOT_SPL_SRC, 1, AC_RWX | SA_G ) |
Niklaus Giger | 4d332db | 2008-01-10 18:50:33 +0100 | [diff] [blame] | 55 | #endif |
| 56 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 57 | #ifdef CONFIG_SYS_INIT_RAM_DCACHE |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 58 | /* TLB-entry for init-ram in dcache (SA_I must be turned off!) */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 59 | tlbentry( CONFIG_SYS_INIT_RAM_ADDR, SZ_64K, CONFIG_SYS_INIT_RAM_ADDR, 0, AC_RWX | SA_G ) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 60 | #endif |
| 61 | |
| 62 | /* TLB-entry for PCI Memory */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 63 | tlbentry( CONFIG_SYS_PCI_MEMBASE, SZ_256M, CONFIG_SYS_PCI_MEMBASE, 1, AC_RW | SA_IG ) |
| 64 | tlbentry( CONFIG_SYS_PCI_MEMBASE1, SZ_256M, CONFIG_SYS_PCI_MEMBASE1, 1, AC_RW | SA_IG ) |
| 65 | tlbentry( CONFIG_SYS_PCI_MEMBASE2, SZ_256M, CONFIG_SYS_PCI_MEMBASE2, 1, AC_RW | SA_IG ) |
| 66 | tlbentry( CONFIG_SYS_PCI_MEMBASE3, SZ_256M, CONFIG_SYS_PCI_MEMBASE3, 1, AC_RW | SA_IG ) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 67 | |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 68 | /* TLB-entry for NAND */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 69 | tlbentry( CONFIG_SYS_NAND_ADDR, SZ_1K, CONFIG_SYS_NAND_ADDR, 1, AC_RWX | SA_IG ) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 70 | |
| 71 | /* TLB-entry for Internal Registers & OCM */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 72 | tlbentry( 0xe0000000, SZ_16M, 0xe0000000, 0, AC_RWX | SA_I ) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 73 | |
| 74 | /*TLB-entry PCI registers*/ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 75 | tlbentry( 0xEEC00000, SZ_1K, 0xEEC00000, 1, AC_RWX | SA_IG ) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 76 | |
| 77 | /* TLB-entry for peripherals */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 78 | tlbentry( 0xEF000000, SZ_16M, 0xEF000000, 1, AC_RWX | SA_IG) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 79 | |
Gary Jennejohn | 81b73de | 2007-08-31 15:21:46 +0200 | [diff] [blame] | 80 | /* TLB-entry PCI IO Space - from sr@denx.de */ |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 81 | tlbentry(0xE8000000, SZ_64K, 0xE8000000, 1, AC_RWX | SA_IG) |
Gary Jennejohn | 81b73de | 2007-08-31 15:21:46 +0200 | [diff] [blame] | 82 | |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 83 | tlbtab_end |
| 84 | |
| 85 | #if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL) |
| 86 | /* |
| 87 | * For NAND booting the first TLB has to be reconfigured to full size |
| 88 | * and with caching disabled after running from RAM! |
| 89 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 90 | #define TLB00 TLB0(CONFIG_SYS_BOOT_BASE_ADDR, SZ_256M) |
| 91 | #define TLB01 TLB1(CONFIG_SYS_BOOT_BASE_ADDR, 1) |
Stefan Roese | cf6eb6d | 2010-04-14 13:57:18 +0200 | [diff] [blame] | 92 | #define TLB02 TLB2(AC_RWX | SA_IG) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 93 | |
| 94 | .globl reconfig_tlb0 |
| 95 | reconfig_tlb0: |
| 96 | sync |
| 97 | isync |
Stefan Roese | 3edf68c | 2009-03-26 16:14:13 +0100 | [diff] [blame] | 98 | addi r4,r0,CONFIG_SYS_TLB_FOR_BOOT_FLASH /* TLB entry # */ |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 99 | lis r5,TLB00@h |
| 100 | ori r5,r5,TLB00@l |
| 101 | tlbwe r5,r4,0x0000 /* Save it out */ |
| 102 | lis r5,TLB01@h |
| 103 | ori r5,r5,TLB01@l |
| 104 | tlbwe r5,r4,0x0001 /* Save it out */ |
| 105 | lis r5,TLB02@h |
| 106 | ori r5,r5,TLB02@l |
| 107 | tlbwe r5,r4,0x0002 /* Save it out */ |
| 108 | sync |
| 109 | isync |
| 110 | blr |
| 111 | #endif |