blob: f7b9cdce823977a58e944999f6cbb35b1d0e0bbd [file] [log] [blame]
Bernd Schmidtb97b8a92008-01-27 18:39:16 +08001/*
2 * Blackfin CPLB initialization
3 *
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
11#include <asm/blackfin.h>
12#include <asm/cplb.h>
13#include <asm/cplbinit.h>
Graf Yangdbc895f2009-01-07 23:14:39 +080014#include <asm/mem_map.h>
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080015
Mike Frysingerc6059992008-02-02 12:28:23 +080016#if ANOMALY_05000263
17# error the MPU will not function safely while Anomaly 05000263 applies
18#endif
19
Graf Yangb8a98982008-11-18 17:48:22 +080020struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS];
21struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS];
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080022
23int first_switched_icplb, first_switched_dcplb;
24int first_mask_dcplb;
25
Graf Yangb8a98982008-11-18 17:48:22 +080026void __init generate_cplb_tables_cpu(unsigned int cpu)
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080027{
28 int i_d, i_i;
29 unsigned long addr;
30 unsigned long d_data, i_data;
31 unsigned long d_cache = 0, i_cache = 0;
32
Mike Frysinger8cab0282008-04-24 05:13:10 +080033 printk(KERN_INFO "MPU: setting up cplb tables with memory protection\n");
34
Jie Zhang41ba6532009-06-16 09:48:33 +000035#ifdef CONFIG_BFIN_EXTMEM_ICACHEABLE
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080036 i_cache = CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND;
37#endif
38
Jie Zhang41ba6532009-06-16 09:48:33 +000039#ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080040 d_cache = CPLB_L1_CHBL;
Jie Zhang41ba6532009-06-16 09:48:33 +000041#ifdef CONFIG_BFIN_EXTMEM_WRITETROUGH
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080042 d_cache |= CPLB_L1_AOW | CPLB_WT;
43#endif
44#endif
Graf Yangb8a98982008-11-18 17:48:22 +080045
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080046 i_d = i_i = 0;
47
48 /* Set up the zero page. */
Graf Yangb8a98982008-11-18 17:48:22 +080049 dcplb_tbl[cpu][i_d].addr = 0;
50 dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080051
Graf Yangb8a98982008-11-18 17:48:22 +080052 icplb_tbl[cpu][i_i].addr = 0;
Robin Getza17c7f62009-05-05 17:14:39 +000053 icplb_tbl[cpu][i_i++].data = CPLB_VALID | i_cache | CPLB_USER_RD | PAGE_SIZE_1KB;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080054
55 /* Cover kernel memory with 4M pages. */
56 addr = 0;
57 d_data = d_cache | CPLB_SUPV_WR | CPLB_VALID | PAGE_SIZE_4MB | CPLB_DIRTY;
58 i_data = i_cache | CPLB_VALID | CPLB_PORTPRIO | PAGE_SIZE_4MB;
59
60 for (; addr < memory_start; addr += 4 * 1024 * 1024) {
Graf Yangb8a98982008-11-18 17:48:22 +080061 dcplb_tbl[cpu][i_d].addr = addr;
62 dcplb_tbl[cpu][i_d++].data = d_data;
63 icplb_tbl[cpu][i_i].addr = addr;
64 icplb_tbl[cpu][i_i++].data = i_data | (addr == 0 ? CPLB_USER_RD : 0);
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080065 }
66
67 /* Cover L1 memory. One 4M area for code and data each is enough. */
68#if L1_DATA_A_LENGTH > 0 || L1_DATA_B_LENGTH > 0
Graf Yangb8a98982008-11-18 17:48:22 +080069 dcplb_tbl[cpu][i_d].addr = get_l1_data_a_start_cpu(cpu);
70 dcplb_tbl[cpu][i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080071#endif
Sonic Zhangf099f392008-10-09 14:11:57 +080072#if L1_CODE_LENGTH > 0
Graf Yangb8a98982008-11-18 17:48:22 +080073 icplb_tbl[cpu][i_i].addr = get_l1_code_start_cpu(cpu);
74 icplb_tbl[cpu][i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
Sonic Zhangf099f392008-10-09 14:11:57 +080075#endif
76
77 /* Cover L2 memory */
78#if L2_LENGTH > 0
Graf Yangb8a98982008-11-18 17:48:22 +080079 dcplb_tbl[cpu][i_d].addr = L2_START;
Jie Zhang41ba6532009-06-16 09:48:33 +000080 dcplb_tbl[cpu][i_d++].data = L2_DMEMORY;
Graf Yangb8a98982008-11-18 17:48:22 +080081 icplb_tbl[cpu][i_i].addr = L2_START;
Jie Zhang41ba6532009-06-16 09:48:33 +000082 icplb_tbl[cpu][i_i++].data = L2_IMEMORY;
Sonic Zhangf099f392008-10-09 14:11:57 +080083#endif
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080084
85 first_mask_dcplb = i_d;
86 first_switched_dcplb = i_d + (1 << page_mask_order);
87 first_switched_icplb = i_i;
88
89 while (i_d < MAX_CPLBS)
Graf Yangb8a98982008-11-18 17:48:22 +080090 dcplb_tbl[cpu][i_d++].data = 0;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080091 while (i_i < MAX_CPLBS)
Graf Yangb8a98982008-11-18 17:48:22 +080092 icplb_tbl[cpu][i_i++].data = 0;
Bernd Schmidtb97b8a92008-01-27 18:39:16 +080093}
Bernd Schmidtdbdf20d2009-01-07 23:14:38 +080094
95void generate_cplb_tables_all(void)
96{
97}