Blackfin arch: SMP supporting patchset: Blackfin CPLB related code
[safe/jmp/linux-2.6] / arch / blackfin / include / asm / cplbinit.h
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
30 #ifndef __ASM_CPLBINIT_H__
31 #define __ASM_CPLBINIT_H__
32
33 #include <asm/blackfin.h>
34 #include <asm/cplb.h>
35
36 #ifdef CONFIG_MPU
37
38 #include <asm/cplb-mpu.h>
39 extern void bfin_icache_init(struct cplb_entry *icplb_tbl);
40 extern void bfin_dcache_init(struct cplb_entry *icplb_tbl);
41
42 #else
43
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
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 };
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
103 extern u_long icplb_tables[NR_CPUS][CPLB_TBL_ENTRIES+1];
104 extern u_long dcplb_tables[NR_CPUS][CPLB_TBL_ENTRIES+1];
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
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];
117 #ifdef CONFIG_CPLB_INFO
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];
120 #endif
121 extern void bfin_icache_init(u_long icplbs[]);
122 extern void bfin_dcache_init(u_long dcplbs[]);
123
124 #endif /* CONFIG_MPU */
125
126 #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE)
127 extern void generate_cplb_tables_cpu(unsigned int cpu);
128 #endif
129 #endif