blob: 0e28f75957330d92406b08adbc13024b9e5017c8 [file] [log] [blame]
Bernd Schmidt29440a22007-07-12 16:25:29 +08001/*
2 * Blackfin CPLB initialization
3 *
4 * Copyright 2004-2007 Analog Devices Inc.
5 *
6 * Bugs: Enter bugs at http://blackfin.uclinux.org/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see the file COPYING, or write
20 * to the Free Software Foundation, Inc.,
21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
Mike Frysinger38316382008-11-18 17:48:22 +080023
Bernd Schmidt29440a22007-07-12 16:25:29 +080024#include <linux/module.h>
25
26#include <asm/blackfin.h>
Mike Frysinger04be80e2008-10-16 23:33:53 +080027#include <asm/cacheflush.h>
Robin Getz3bebca22007-10-10 23:55:26 +080028#include <asm/cplb.h>
Bernd Schmidt29440a22007-07-12 16:25:29 +080029#include <asm/cplbinit.h>
Graf Yangdbc895f2009-01-07 23:14:39 +080030#include <asm/mem_map.h>
Bernd Schmidt29440a22007-07-12 16:25:29 +080031
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080032struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
33struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
Bernd Schmidt29440a22007-07-12 16:25:29 +080034
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080035int first_switched_icplb PDT_ATTR;
36int first_switched_dcplb PDT_ATTR;
Bernd Schmidt29440a22007-07-12 16:25:29 +080037
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080038struct cplb_boundary dcplb_bounds[9] PDT_ATTR;
39struct cplb_boundary icplb_bounds[7] PDT_ATTR;
Bernd Schmidt29440a22007-07-12 16:25:29 +080040
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080041int icplb_nr_bounds PDT_ATTR;
42int dcplb_nr_bounds PDT_ATTR;
Bernd Schmidt29440a22007-07-12 16:25:29 +080043
Graf Yangb8a98982008-11-18 17:48:22 +080044void __init generate_cplb_tables_cpu(unsigned int cpu)
Bernd Schmidt29440a22007-07-12 16:25:29 +080045{
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080046 int i_d, i_i;
47 unsigned long addr;
Bernd Schmidt29440a22007-07-12 16:25:29 +080048
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080049 struct cplb_entry *d_tbl = dcplb_tbl[cpu];
50 struct cplb_entry *i_tbl = icplb_tbl[cpu];
Bernd Schmidt29440a22007-07-12 16:25:29 +080051
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080052 printk(KERN_INFO "NOMPU: setting up cplb tables\n");
Bernd Schmidt29440a22007-07-12 16:25:29 +080053
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080054 i_d = i_i = 0;
Mike Frysinger8cab0282008-04-24 05:13:10 +080055
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080056 /* Set up the zero page. */
57 d_tbl[i_d].addr = 0;
58 d_tbl[i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
Bernd Schmidt29440a22007-07-12 16:25:29 +080059
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080060 /* Cover kernel memory with 4M pages. */
61 addr = 0;
Bernd Schmidt29440a22007-07-12 16:25:29 +080062
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080063 for (; addr < memory_start; addr += 4 * 1024 * 1024) {
64 d_tbl[i_d].addr = addr;
65 d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;
66 i_tbl[i_i].addr = addr;
67 i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;
Bernd Schmidt29440a22007-07-12 16:25:29 +080068 }
69
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080070 /* Cover L1 memory. One 4M area for code and data each is enough. */
71 if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
72 d_tbl[i_d].addr = L1_DATA_A_START;
73 d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
74 }
75 i_tbl[i_i].addr = L1_CODE_START;
76 i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
Bernd Schmidt29440a22007-07-12 16:25:29 +080077
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080078 first_switched_dcplb = i_d;
79 first_switched_icplb = i_i;
Mike Frysingerdce783c2008-11-18 17:48:21 +080080
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080081 BUG_ON(first_switched_dcplb > MAX_CPLBS);
82 BUG_ON(first_switched_icplb > MAX_CPLBS);
Bernd Schmidt29440a22007-07-12 16:25:29 +080083
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080084 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;
Bernd Schmidt29440a22007-07-12 16:25:29 +080088}
Bernd Schmidt29440a22007-07-12 16:25:29 +080089
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080090void __init generate_cplb_tables_all(void)
91{
92 int i_d, i_i;
93
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;
Mike Frysinger38316382008-11-18 17:48:22 +0800100#endif
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +0800101 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;
106 }
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);
112 }
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;
132 }
133 dcplb_nr_bounds = i_d;
134 BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds));
135
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;
148 }
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);
154 }
155 /* Addressing hole up to BootROM. */
156 icplb_bounds[i_i].eaddr = BOOT_ROM_START;
157 icplb_bounds[i_i++].data = 0;
158 /* BootROM -- largest one should be less than 1 meg. */
159 icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
160 icplb_bounds[i_i++].data = SDRAM_IGENERIC;
161 if (L2_LENGTH) {
162 /* Addressing hole up to L2 SRAM, including the async bank. */
163 icplb_bounds[i_i].eaddr = L2_START;
164 icplb_bounds[i_i++].data = 0;
165 /* L2 SRAM. */
166 icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH;
167 icplb_bounds[i_i++].data = L2_IMEMORY;
168 }
169 icplb_nr_bounds = i_i;
170 BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds));
171}