Full support for Ginger Console
[linux-ginger.git] / arch / blackfin / kernel / cplb-nompu / cplbinit.c
blobfd9a2f31e686f63ceabe2354b401df5c919bb1f6
1 /*
2 * Blackfin CPLB initialization
4 * Copyright 2007-2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
7 */
9 #include <linux/module.h>
11 #include <asm/blackfin.h>
12 #include <asm/cacheflush.h>
13 #include <asm/cplb.h>
14 #include <asm/cplbinit.h>
15 #include <asm/mem_map.h>
17 struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
18 struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
20 int first_switched_icplb PDT_ATTR;
21 int first_switched_dcplb PDT_ATTR;
23 struct cplb_boundary dcplb_bounds[9] PDT_ATTR;
24 struct cplb_boundary icplb_bounds[9] PDT_ATTR;
26 int icplb_nr_bounds PDT_ATTR;
27 int dcplb_nr_bounds PDT_ATTR;
29 void __init generate_cplb_tables_cpu(unsigned int cpu)
31 int i_d, i_i;
32 unsigned long addr;
34 struct cplb_entry *d_tbl = dcplb_tbl[cpu];
35 struct cplb_entry *i_tbl = icplb_tbl[cpu];
37 printk(KERN_INFO "NOMPU: setting up cplb tables\n");
39 i_d = i_i = 0;
41 #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
42 /* Set up the zero page. */
43 d_tbl[i_d].addr = 0;
44 d_tbl[i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
45 i_tbl[i_i].addr = 0;
46 i_tbl[i_i++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
47 #endif
49 /* Cover kernel memory with 4M pages. */
50 addr = 0;
52 for (; addr < memory_start; addr += 4 * 1024 * 1024) {
53 d_tbl[i_d].addr = addr;
54 d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;
55 i_tbl[i_i].addr = addr;
56 i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;
59 /* Cover L1 memory. One 4M area for code and data each is enough. */
60 if (cpu == 0) {
61 if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
62 d_tbl[i_d].addr = L1_DATA_A_START;
63 d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
65 i_tbl[i_i].addr = L1_CODE_START;
66 i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
68 #ifdef CONFIG_SMP
69 else {
70 if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
71 d_tbl[i_d].addr = COREB_L1_DATA_A_START;
72 d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
74 i_tbl[i_i].addr = COREB_L1_CODE_START;
75 i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
77 #endif
78 first_switched_dcplb = i_d;
79 first_switched_icplb = i_i;
81 BUG_ON(first_switched_dcplb > MAX_CPLBS);
82 BUG_ON(first_switched_icplb > MAX_CPLBS);
84 while (i_d < MAX_CPLBS)
85 d_tbl[i_d++].data = 0;
86 while (i_i < MAX_CPLBS)
87 i_tbl[i_i++].data = 0;
90 void __init generate_cplb_tables_all(void)
92 int i_d, i_i;
94 i_d = 0;
95 /* Normal RAM, including MTD FS. */
96 #ifdef CONFIG_MTD_UCLINUX
97 dcplb_bounds[i_d].eaddr = memory_mtd_start + mtd_size;
98 #else
99 dcplb_bounds[i_d].eaddr = memory_end;
100 #endif
101 dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
102 /* DMA uncached region. */
103 if (DMA_UNCACHED_REGION) {
104 dcplb_bounds[i_d].eaddr = _ramend;
105 dcplb_bounds[i_d++].data = SDRAM_DNON_CHBL;
107 if (_ramend != physical_mem_end) {
108 /* Reserved memory. */
109 dcplb_bounds[i_d].eaddr = physical_mem_end;
110 dcplb_bounds[i_d++].data = (reserved_mem_dcache_on ?
111 SDRAM_DGENERIC : SDRAM_DNON_CHBL);
113 /* Addressing hole up to the async bank. */
114 dcplb_bounds[i_d].eaddr = ASYNC_BANK0_BASE;
115 dcplb_bounds[i_d++].data = 0;
116 /* ASYNC banks. */
117 dcplb_bounds[i_d].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;
118 dcplb_bounds[i_d++].data = SDRAM_EBIU;
119 /* Addressing hole up to BootROM. */
120 dcplb_bounds[i_d].eaddr = BOOT_ROM_START;
121 dcplb_bounds[i_d++].data = 0;
122 /* BootROM -- largest one should be less than 1 meg. */
123 dcplb_bounds[i_d].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
124 dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
125 if (L2_LENGTH) {
126 /* Addressing hole up to L2 SRAM. */
127 dcplb_bounds[i_d].eaddr = L2_START;
128 dcplb_bounds[i_d++].data = 0;
129 /* L2 SRAM. */
130 dcplb_bounds[i_d].eaddr = L2_START + L2_LENGTH;
131 dcplb_bounds[i_d++].data = L2_DMEMORY;
133 dcplb_nr_bounds = i_d;
134 BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds));
136 i_i = 0;
137 /* Normal RAM, including MTD FS. */
138 #ifdef CONFIG_MTD_UCLINUX
139 icplb_bounds[i_i].eaddr = memory_mtd_start + mtd_size;
140 #else
141 icplb_bounds[i_i].eaddr = memory_end;
142 #endif
143 icplb_bounds[i_i++].data = SDRAM_IGENERIC;
144 /* DMA uncached region. */
145 if (DMA_UNCACHED_REGION) {
146 icplb_bounds[i_i].eaddr = _ramend;
147 icplb_bounds[i_i++].data = 0;
149 if (_ramend != physical_mem_end) {
150 /* Reserved memory. */
151 icplb_bounds[i_i].eaddr = physical_mem_end;
152 icplb_bounds[i_i++].data = (reserved_mem_icache_on ?
153 SDRAM_IGENERIC : SDRAM_INON_CHBL);
155 /* Addressing hole up to the async bank. */
156 icplb_bounds[i_i].eaddr = ASYNC_BANK0_BASE;
157 icplb_bounds[i_i++].data = 0;
158 /* ASYNC banks. */
159 icplb_bounds[i_i].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;
160 icplb_bounds[i_i++].data = SDRAM_EBIU;
161 /* Addressing hole up to BootROM. */
162 icplb_bounds[i_i].eaddr = BOOT_ROM_START;
163 icplb_bounds[i_i++].data = 0;
164 /* BootROM -- largest one should be less than 1 meg. */
165 icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
166 icplb_bounds[i_i++].data = SDRAM_IGENERIC;
168 if (L2_LENGTH) {
169 /* Addressing hole up to L2 SRAM. */
170 icplb_bounds[i_i].eaddr = L2_START;
171 icplb_bounds[i_i++].data = 0;
172 /* L2 SRAM. */
173 icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH;
174 icplb_bounds[i_i++].data = L2_IMEMORY;
176 icplb_nr_bounds = i_i;
177 BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds));