blob: 7e6383dc7b2021003cbc9578aecb440ffde4541c [file] [log] [blame]
Bernd Schmidtb97b8a92008-01-27 18:39:16 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Blackfin CPLB exception handling for when MPU in on
Bernd Schmidtb97b8a92008-01-27 18:39:16 +08003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Copyright 2008-2009 Analog Devices Inc.
Bernd Schmidtb97b8a92008-01-27 18:39:16 +08005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later.
Bernd Schmidtb97b8a92008-01-27 18:39:16 +08007 */
Robin Getz96f10502009-09-24 14:11:24 +00008
Bernd Schmidtb97b8a92008-01-27 18:39:16 +08009#include <linux/module.h>
10#include <linux/mm.h>
11
12#include <asm/blackfin.h>
Mike Frysingera92946b2008-10-16 23:25:34 +080013#include <asm/cacheflush.h>
Yi Lieb7bd9c2009-08-07 01:20:58 +000014#include <asm/cplb.h>
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080015#include <asm/cplbinit.h>
16#include <asm/mmu_context.h>
17
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080018/*
19 * WARNING
20 *
21 * This file is compiled with certain -ffixed-reg options. We have to
22 * make sure not to call any functions here that could clobber these
23 * registers.
24 */
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080025
26int page_mask_nelts;
27int page_mask_order;
Graf Yangb8a98982008-11-18 17:48:22 +080028unsigned long *current_rwx_mask[NR_CPUS];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080029
Graf Yangb8a98982008-11-18 17:48:22 +080030int nr_dcplb_miss[NR_CPUS], nr_icplb_miss[NR_CPUS];
31int nr_icplb_supv_miss[NR_CPUS], nr_dcplb_prot[NR_CPUS];
32int nr_cplb_flush[NR_CPUS];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080033
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080034/*
35 * Given the contents of the status register, return the index of the
36 * CPLB that caused the fault.
37 */
38static inline int faulting_cplb_index(int status)
39{
40 int signbits = __builtin_bfin_norm_fr1x32(status & 0xFFFF);
41 return 30 - signbits;
42}
43
44/*
45 * Given the contents of the status register and the DCPLB_DATA contents,
46 * return true if a write access should be permitted.
47 */
48static inline int write_permitted(int status, unsigned long data)
49{
50 if (status & FAULT_USERSUPV)
51 return !!(data & CPLB_SUPV_WR);
52 else
53 return !!(data & CPLB_USER_WR);
54}
55
56/* Counters to implement round-robin replacement. */
Graf Yangb8a98982008-11-18 17:48:22 +080057static int icplb_rr_index[NR_CPUS], dcplb_rr_index[NR_CPUS];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080058
59/*
60 * Find an ICPLB entry to be evicted and return its index.
61 */
Graf Yangb8a98982008-11-18 17:48:22 +080062static int evict_one_icplb(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080063{
64 int i;
65 for (i = first_switched_icplb; i < MAX_CPLBS; i++)
Graf Yangb8a98982008-11-18 17:48:22 +080066 if ((icplb_tbl[cpu][i].data & CPLB_VALID) == 0)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080067 return i;
Graf Yangb8a98982008-11-18 17:48:22 +080068 i = first_switched_icplb + icplb_rr_index[cpu];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080069 if (i >= MAX_CPLBS) {
70 i -= MAX_CPLBS - first_switched_icplb;
Graf Yangb8a98982008-11-18 17:48:22 +080071 icplb_rr_index[cpu] -= MAX_CPLBS - first_switched_icplb;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080072 }
Graf Yangb8a98982008-11-18 17:48:22 +080073 icplb_rr_index[cpu]++;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080074 return i;
75}
76
Graf Yangb8a98982008-11-18 17:48:22 +080077static int evict_one_dcplb(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080078{
79 int i;
80 for (i = first_switched_dcplb; i < MAX_CPLBS; i++)
Graf Yangb8a98982008-11-18 17:48:22 +080081 if ((dcplb_tbl[cpu][i].data & CPLB_VALID) == 0)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080082 return i;
Graf Yangb8a98982008-11-18 17:48:22 +080083 i = first_switched_dcplb + dcplb_rr_index[cpu];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080084 if (i >= MAX_CPLBS) {
85 i -= MAX_CPLBS - first_switched_dcplb;
Graf Yangb8a98982008-11-18 17:48:22 +080086 dcplb_rr_index[cpu] -= MAX_CPLBS - first_switched_dcplb;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080087 }
Graf Yangb8a98982008-11-18 17:48:22 +080088 dcplb_rr_index[cpu]++;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080089 return i;
90}
91
Graf Yangb8a98982008-11-18 17:48:22 +080092static noinline int dcplb_miss(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080093{
94 unsigned long addr = bfin_read_DCPLB_FAULT_ADDR();
95 int status = bfin_read_DCPLB_STATUS();
96 unsigned long *mask;
97 int idx;
98 unsigned long d_data;
99
Graf Yangb8a98982008-11-18 17:48:22 +0800100 nr_dcplb_miss[cpu]++;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800101
102 d_data = CPLB_SUPV_WR | CPLB_VALID | CPLB_DIRTY | PAGE_SIZE_4KB;
Jie Zhang41ba6532009-06-16 09:48:33 +0000103#ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
Jie Zhang67834fa2009-06-10 06:26:26 +0000104 if (bfin_addr_dcacheable(addr)) {
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800105 d_data |= CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND;
Jie Zhang41ba6532009-06-16 09:48:33 +0000106# ifdef CONFIG_BFIN_EXTMEM_WRITETHROUGH
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800107 d_data |= CPLB_L1_AOW | CPLB_WT;
Jie Zhang41ba6532009-06-16 09:48:33 +0000108# endif
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800109 }
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800110#endif
Jie Zhang41ba6532009-06-16 09:48:33 +0000111
112 if (L2_LENGTH && addr >= L2_START && addr < L2_START + L2_LENGTH) {
113 addr = L2_START;
114 d_data = L2_DMEMORY;
115 } else if (addr >= physical_mem_end) {
Barry Songe1878372009-12-02 02:50:43 +0000116 if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE) {
Barry Songe18e7dd2009-12-07 10:05:58 +0000117 mask = current_rwx_mask[cpu];
118 if (mask) {
119 int page = (addr - (ASYNC_BANK0_BASE - _ramend)) >> PAGE_SHIFT;
120 int idx = page >> 5;
121 int bit = 1 << (page & 31);
122
123 if (mask[idx] & bit)
124 d_data |= CPLB_USER_RD;
125 }
Mike Frysinger4e354b52008-04-24 05:44:32 +0800126 } else if (addr >= BOOT_ROM_START && addr < BOOT_ROM_START + BOOT_ROM_LENGTH
127 && (status & (FAULT_RW | FAULT_USERSUPV)) == FAULT_USERSUPV) {
128 addr &= ~(1 * 1024 * 1024 - 1);
129 d_data &= ~PAGE_SIZE_4KB;
Mike Frysinger4bea8b22008-04-24 07:23:36 +0800130 d_data |= PAGE_SIZE_1MB;
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800131 } else
132 return CPLB_PROT_VIOL;
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800133 } else if (addr >= _ramend) {
Sonic Zhang5792ab22009-12-09 07:01:50 +0000134 d_data |= CPLB_USER_RD | CPLB_USER_WR;
135 if (reserved_mem_dcache_on)
136 d_data |= CPLB_L1_CHBL;
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800137 } else {
Graf Yangb8a98982008-11-18 17:48:22 +0800138 mask = current_rwx_mask[cpu];
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800139 if (mask) {
140 int page = addr >> PAGE_SHIFT;
Graf Yangb8a98982008-11-18 17:48:22 +0800141 int idx = page >> 5;
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800142 int bit = 1 << (page & 31);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800143
Graf Yangb8a98982008-11-18 17:48:22 +0800144 if (mask[idx] & bit)
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800145 d_data |= CPLB_USER_RD;
146
147 mask += page_mask_nelts;
Graf Yangb8a98982008-11-18 17:48:22 +0800148 if (mask[idx] & bit)
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800149 d_data |= CPLB_USER_WR;
150 }
151 }
Graf Yangb8a98982008-11-18 17:48:22 +0800152 idx = evict_one_dcplb(cpu);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800153
154 addr &= PAGE_MASK;
Graf Yangb8a98982008-11-18 17:48:22 +0800155 dcplb_tbl[cpu][idx].addr = addr;
156 dcplb_tbl[cpu][idx].data = d_data;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800157
Yi Lieb7bd9c2009-08-07 01:20:58 +0000158 _disable_dcplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800159 bfin_write32(DCPLB_DATA0 + idx * 4, d_data);
160 bfin_write32(DCPLB_ADDR0 + idx * 4, addr);
Yi Lieb7bd9c2009-08-07 01:20:58 +0000161 _enable_dcplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800162
163 return 0;
164}
165
Graf Yangb8a98982008-11-18 17:48:22 +0800166static noinline int icplb_miss(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800167{
168 unsigned long addr = bfin_read_ICPLB_FAULT_ADDR();
169 int status = bfin_read_ICPLB_STATUS();
170 int idx;
171 unsigned long i_data;
172
Graf Yangb8a98982008-11-18 17:48:22 +0800173 nr_icplb_miss[cpu]++;
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800174
175 /* If inside the uncached DMA region, fault. */
176 if (addr >= _ramend - DMA_UNCACHED_REGION && addr < _ramend)
177 return CPLB_PROT_VIOL;
178
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800179 if (status & FAULT_USERSUPV)
Graf Yangb8a98982008-11-18 17:48:22 +0800180 nr_icplb_supv_miss[cpu]++;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800181
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800182 /*
183 * First, try to find a CPLB that matches this address. If we
184 * find one, then the fact that we're in the miss handler means
185 * that the instruction crosses a page boundary.
186 */
187 for (idx = first_switched_icplb; idx < MAX_CPLBS; idx++) {
Graf Yangb8a98982008-11-18 17:48:22 +0800188 if (icplb_tbl[cpu][idx].data & CPLB_VALID) {
189 unsigned long this_addr = icplb_tbl[cpu][idx].addr;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800190 if (this_addr <= addr && this_addr + PAGE_SIZE > addr) {
191 addr += PAGE_SIZE;
192 break;
193 }
194 }
195 }
196
197 i_data = CPLB_VALID | CPLB_PORTPRIO | PAGE_SIZE_4KB;
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800198
Jie Zhang41ba6532009-06-16 09:48:33 +0000199#ifdef CONFIG_BFIN_EXTMEM_ICACHEABLE
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800200 /*
201 * Normal RAM, and possibly the reserved memory area, are
202 * cacheable.
203 */
204 if (addr < _ramend ||
205 (addr < physical_mem_end && reserved_mem_icache_on))
206 i_data |= CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800207#endif
208
Jie Zhang41ba6532009-06-16 09:48:33 +0000209 if (L2_LENGTH && addr >= L2_START && addr < L2_START + L2_LENGTH) {
210 addr = L2_START;
211 i_data = L2_IMEMORY;
212 } else if (addr >= physical_mem_end) {
Barry Songe1878372009-12-02 02:50:43 +0000213 if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE) {
Barry Songe18e7dd2009-12-07 10:05:58 +0000214 if (!(status & FAULT_USERSUPV)) {
215 unsigned long *mask = current_rwx_mask[cpu];
216
217 if (mask) {
218 int page = (addr - (ASYNC_BANK0_BASE - _ramend)) >> PAGE_SHIFT;
219 int idx = page >> 5;
220 int bit = 1 << (page & 31);
221
222 mask += 2 * page_mask_nelts;
223 if (mask[idx] & bit)
224 i_data |= CPLB_USER_RD;
225 }
226 }
Barry Songe1878372009-12-02 02:50:43 +0000227 } else if (addr >= BOOT_ROM_START && addr < BOOT_ROM_START + BOOT_ROM_LENGTH
Mike Frysinger4bea8b22008-04-24 07:23:36 +0800228 && (status & FAULT_USERSUPV)) {
229 addr &= ~(1 * 1024 * 1024 - 1);
230 i_data &= ~PAGE_SIZE_4KB;
231 i_data |= PAGE_SIZE_1MB;
232 } else
233 return CPLB_PROT_VIOL;
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800234 } else if (addr >= _ramend) {
235 i_data |= CPLB_USER_RD;
Sonic Zhang5792ab22009-12-09 07:01:50 +0000236 if (reserved_mem_icache_on)
237 i_data |= CPLB_L1_CHBL;
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800238 } else {
239 /*
240 * Two cases to distinguish - a supervisor access must
241 * necessarily be for a module page; we grant it
242 * unconditionally (could do better here in the future).
243 * Otherwise, check the x bitmap of the current process.
244 */
245 if (!(status & FAULT_USERSUPV)) {
Graf Yangb8a98982008-11-18 17:48:22 +0800246 unsigned long *mask = current_rwx_mask[cpu];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800247
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800248 if (mask) {
249 int page = addr >> PAGE_SHIFT;
Graf Yangb8a98982008-11-18 17:48:22 +0800250 int idx = page >> 5;
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800251 int bit = 1 << (page & 31);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800252
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800253 mask += 2 * page_mask_nelts;
Graf Yangb8a98982008-11-18 17:48:22 +0800254 if (mask[idx] & bit)
Bernd Schmidt1ebc7232008-04-24 02:58:26 +0800255 i_data |= CPLB_USER_RD;
256 }
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800257 }
258 }
Graf Yangb8a98982008-11-18 17:48:22 +0800259 idx = evict_one_icplb(cpu);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800260 addr &= PAGE_MASK;
Graf Yangb8a98982008-11-18 17:48:22 +0800261 icplb_tbl[cpu][idx].addr = addr;
262 icplb_tbl[cpu][idx].data = i_data;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800263
Yi Lieb7bd9c2009-08-07 01:20:58 +0000264 _disable_icplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800265 bfin_write32(ICPLB_DATA0 + idx * 4, i_data);
266 bfin_write32(ICPLB_ADDR0 + idx * 4, addr);
Yi Lieb7bd9c2009-08-07 01:20:58 +0000267 _enable_icplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800268
269 return 0;
270}
271
Graf Yangb8a98982008-11-18 17:48:22 +0800272static noinline int dcplb_protection_fault(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800273{
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800274 int status = bfin_read_DCPLB_STATUS();
275
Graf Yangb8a98982008-11-18 17:48:22 +0800276 nr_dcplb_prot[cpu]++;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800277
278 if (status & FAULT_RW) {
279 int idx = faulting_cplb_index(status);
Graf Yangb8a98982008-11-18 17:48:22 +0800280 unsigned long data = dcplb_tbl[cpu][idx].data;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800281 if (!(data & CPLB_WT) && !(data & CPLB_DIRTY) &&
282 write_permitted(status, data)) {
283 data |= CPLB_DIRTY;
Graf Yangb8a98982008-11-18 17:48:22 +0800284 dcplb_tbl[cpu][idx].data = data;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800285 bfin_write32(DCPLB_DATA0 + idx * 4, data);
286 return 0;
287 }
288 }
289 return CPLB_PROT_VIOL;
290}
291
292int cplb_hdr(int seqstat, struct pt_regs *regs)
293{
294 int cause = seqstat & 0x3f;
Yi Lib6dbde22009-08-20 04:17:47 +0000295 unsigned int cpu = raw_smp_processor_id();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800296 switch (cause) {
297 case 0x23:
Graf Yangb8a98982008-11-18 17:48:22 +0800298 return dcplb_protection_fault(cpu);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800299 case 0x2C:
Graf Yangb8a98982008-11-18 17:48:22 +0800300 return icplb_miss(cpu);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800301 case 0x26:
Graf Yangb8a98982008-11-18 17:48:22 +0800302 return dcplb_miss(cpu);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800303 default:
Bernd Schmidtb4bb68f2008-04-23 07:26:23 +0800304 return 1;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800305 }
306}
307
Graf Yangb8a98982008-11-18 17:48:22 +0800308void flush_switched_cplbs(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800309{
310 int i;
Bernd Schmidt5d2e3212008-10-07 16:27:01 +0800311 unsigned long flags;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800312
Graf Yangb8a98982008-11-18 17:48:22 +0800313 nr_cplb_flush[cpu]++;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800314
Yi Li6a01f232009-01-07 23:14:39 +0800315 local_irq_save_hw(flags);
Yi Lieb7bd9c2009-08-07 01:20:58 +0000316 _disable_icplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800317 for (i = first_switched_icplb; i < MAX_CPLBS; i++) {
Graf Yangb8a98982008-11-18 17:48:22 +0800318 icplb_tbl[cpu][i].data = 0;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800319 bfin_write32(ICPLB_DATA0 + i * 4, 0);
320 }
Yi Lieb7bd9c2009-08-07 01:20:58 +0000321 _enable_icplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800322
Yi Lieb7bd9c2009-08-07 01:20:58 +0000323 _disable_dcplb();
Bernd Schmidtd56daae2008-04-24 02:56:36 +0800324 for (i = first_switched_dcplb; i < MAX_CPLBS; i++) {
Graf Yangb8a98982008-11-18 17:48:22 +0800325 dcplb_tbl[cpu][i].data = 0;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800326 bfin_write32(DCPLB_DATA0 + i * 4, 0);
327 }
Yi Lieb7bd9c2009-08-07 01:20:58 +0000328 _enable_dcplb();
Yi Li6a01f232009-01-07 23:14:39 +0800329 local_irq_restore_hw(flags);
Bernd Schmidt5d2e3212008-10-07 16:27:01 +0800330
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800331}
332
Graf Yangb8a98982008-11-18 17:48:22 +0800333void set_mask_dcplbs(unsigned long *masks, unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800334{
335 int i;
336 unsigned long addr = (unsigned long)masks;
337 unsigned long d_data;
Bernd Schmidt5d2e3212008-10-07 16:27:01 +0800338 unsigned long flags;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800339
Bernd Schmidt5d2e3212008-10-07 16:27:01 +0800340 if (!masks) {
Graf Yangb8a98982008-11-18 17:48:22 +0800341 current_rwx_mask[cpu] = masks;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800342 return;
Bernd Schmidt5d2e3212008-10-07 16:27:01 +0800343 }
344
Yi Li6a01f232009-01-07 23:14:39 +0800345 local_irq_save_hw(flags);
Graf Yangb8a98982008-11-18 17:48:22 +0800346 current_rwx_mask[cpu] = masks;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800347
Jie Zhang41ba6532009-06-16 09:48:33 +0000348 if (L2_LENGTH && addr >= L2_START && addr < L2_START + L2_LENGTH) {
349 addr = L2_START;
350 d_data = L2_DMEMORY;
351 } else {
352 d_data = CPLB_SUPV_WR | CPLB_VALID | CPLB_DIRTY | PAGE_SIZE_4KB;
353#ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
354 d_data |= CPLB_L1_CHBL;
355# ifdef CONFIG_BFIN_EXTMEM_WRITETHROUGH
356 d_data |= CPLB_L1_AOW | CPLB_WT;
357# endif
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800358#endif
Jie Zhang41ba6532009-06-16 09:48:33 +0000359 }
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800360
Yi Lieb7bd9c2009-08-07 01:20:58 +0000361 _disable_dcplb();
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800362 for (i = first_mask_dcplb; i < first_switched_dcplb; i++) {
Graf Yangb8a98982008-11-18 17:48:22 +0800363 dcplb_tbl[cpu][i].addr = addr;
364 dcplb_tbl[cpu][i].data = d_data;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800365 bfin_write32(DCPLB_DATA0 + i * 4, d_data);
366 bfin_write32(DCPLB_ADDR0 + i * 4, addr);
367 addr += PAGE_SIZE;
368 }
Yi Lieb7bd9c2009-08-07 01:20:58 +0000369 _enable_dcplb();
Yi Li6a01f232009-01-07 23:14:39 +0800370 local_irq_restore_hw(flags);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +0800371}