Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: include/asm-blackfin/cplbinit.h |
| 3 | * Based on: |
| 4 | * Author: |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
Mike Frysinger | 81a487a | 2007-11-21 15:55:45 +0800 | [diff] [blame] | 30 | #ifndef __ASM_CPLBINIT_H__ |
| 31 | #define __ASM_CPLBINIT_H__ |
| 32 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 33 | #include <asm/blackfin.h> |
| 34 | #include <asm/cplb.h> |
| 35 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 36 | #ifdef CONFIG_MPU |
| 37 | |
| 38 | #include <asm/cplb-mpu.h> |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 39 | extern void bfin_icache_init(struct cplb_entry *icplb_tbl); |
| 40 | extern void bfin_dcache_init(struct cplb_entry *icplb_tbl); |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 41 | |
| 42 | #else |
| 43 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 44 | #define INITIAL_T 0x1 |
| 45 | #define SWITCH_T 0x2 |
| 46 | #define I_CPLB 0x4 |
| 47 | #define D_CPLB 0x8 |
| 48 | |
| 49 | #define IN_KERNEL 1 |
| 50 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 51 | #define ASYNC_MEMORY_CPLB_COVERAGE ((ASYNC_BANK0_SIZE + ASYNC_BANK1_SIZE + \ |
| 52 | ASYNC_BANK2_SIZE + ASYNC_BANK3_SIZE) / SIZE_4M) |
| 53 | |
| 54 | #define CPLB_MEM CONFIG_MAX_MEM_SIZE |
| 55 | |
| 56 | /* |
| 57 | * Number of required data CPLB switchtable entries |
| 58 | * MEMSIZE / 4 (we mostly install 4M page size CPLBs |
| 59 | * approx 16 for smaller 1MB page size CPLBs for allignment purposes |
| 60 | * 1 for L1 Data Memory |
| 61 | * possibly 1 for L2 Data Memory |
| 62 | * 1 for CONFIG_DEBUG_HUNT_FOR_ZERO |
| 63 | * 1 for ASYNC Memory |
| 64 | */ |
| 65 | #define MAX_SWITCH_D_CPLBS (((CPLB_MEM / 4) + 16 + 1 + 1 + 1 \ |
| 66 | + ASYNC_MEMORY_CPLB_COVERAGE) * 2) |
| 67 | |
| 68 | /* |
| 69 | * Number of required instruction CPLB switchtable entries |
| 70 | * MEMSIZE / 4 (we mostly install 4M page size CPLBs |
| 71 | * approx 12 for smaller 1MB page size CPLBs for allignment purposes |
| 72 | * 1 for L1 Instruction Memory |
| 73 | * possibly 1 for L2 Instruction Memory |
| 74 | * 1 for CONFIG_DEBUG_HUNT_FOR_ZERO |
| 75 | */ |
| 76 | #define MAX_SWITCH_I_CPLBS (((CPLB_MEM / 4) + 12 + 1 + 1 + 1) * 2) |
| 77 | |
| 78 | /* Number of CPLB table entries, used for cplb-nompu. */ |
| 79 | #define CPLB_TBL_ENTRIES (16 * 4) |
| 80 | |
| 81 | enum { |
| 82 | ZERO_P, L1I_MEM, L1D_MEM, L2_MEM, SDRAM_KERN, SDRAM_RAM_MTD, SDRAM_DMAZ, |
| 83 | RES_MEM, ASYNC_MEM, OCB_ROM |
| 84 | }; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 85 | |
| 86 | struct cplb_desc { |
| 87 | u32 start; /* start address */ |
| 88 | u32 end; /* end address */ |
| 89 | u32 psize; /* prefered size if any otherwise 1MB or 4MB*/ |
| 90 | u16 attr;/* attributes */ |
| 91 | u16 i_conf;/* I-CPLB DATA */ |
| 92 | u16 d_conf;/* D-CPLB DATA */ |
| 93 | u16 valid;/* valid */ |
| 94 | const s8 name[30];/* name */ |
| 95 | }; |
| 96 | |
| 97 | struct cplb_tab { |
| 98 | u_long *tab; |
| 99 | u16 pos; |
| 100 | u16 size; |
| 101 | }; |
| 102 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 103 | extern u_long icplb_tables[NR_CPUS][CPLB_TBL_ENTRIES+1]; |
| 104 | extern u_long dcplb_tables[NR_CPUS][CPLB_TBL_ENTRIES+1]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 105 | |
| 106 | /* Till here we are discussing about the static memory management model. |
| 107 | * However, the operating envoronments commonly define more CPLB |
| 108 | * descriptors to cover the entire addressable memory than will fit into |
| 109 | * the available on-chip 16 CPLB MMRs. When this happens, the below table |
| 110 | * will be used which will hold all the potentially required CPLB descriptors |
| 111 | * |
| 112 | * This is how Page descriptor Table is implemented in uClinux/Blackfin. |
| 113 | */ |
| 114 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 115 | extern u_long ipdt_tables[NR_CPUS][MAX_SWITCH_I_CPLBS+1]; |
| 116 | extern u_long dpdt_tables[NR_CPUS][MAX_SWITCH_D_CPLBS+1]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 117 | #ifdef CONFIG_CPLB_INFO |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 118 | extern u_long ipdt_swapcount_tables[NR_CPUS][MAX_SWITCH_I_CPLBS]; |
| 119 | extern u_long dpdt_swapcount_tables[NR_CPUS][MAX_SWITCH_D_CPLBS]; |
Mike Frysinger | 81a487a | 2007-11-21 15:55:45 +0800 | [diff] [blame] | 120 | #endif |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 121 | extern void bfin_icache_init(u_long icplbs[]); |
| 122 | extern void bfin_dcache_init(u_long dcplbs[]); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 123 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 124 | #endif /* CONFIG_MPU */ |
| 125 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame^] | 126 | #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE) |
| 127 | extern void generate_cplb_tables_cpu(unsigned int cpu); |
| 128 | #endif |
Mike Frysinger | 81a487a | 2007-11-21 15:55:45 +0800 | [diff] [blame] | 129 | #endif |