2008-01-27 18:39:16 +08:00
|
|
|
/*
|
|
|
|
* Blackfin CPLB initialization
|
|
|
|
*
|
2009-09-24 22:11:24 +08:00
|
|
|
* Copyright 2008-2009 Analog Devices Inc.
|
2008-01-27 18:39:16 +08:00
|
|
|
*
|
2009-09-24 22:11:24 +08:00
|
|
|
* Licensed under the GPL-2 or later.
|
2008-01-27 18:39:16 +08:00
|
|
|
*/
|
2009-09-24 22:11:24 +08:00
|
|
|
|
2008-01-27 18:39:16 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <asm/blackfin.h>
|
|
|
|
#include <asm/cplb.h>
|
|
|
|
#include <asm/cplbinit.h>
|
2009-01-07 23:14:39 +08:00
|
|
|
#include <asm/mem_map.h>
|
2008-01-27 18:39:16 +08:00
|
|
|
|
2008-11-18 17:48:22 +08:00
|
|
|
struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS];
|
|
|
|
struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS];
|
2008-01-27 18:39:16 +08:00
|
|
|
|
|
|
|
int first_switched_icplb, first_switched_dcplb;
|
|
|
|
int first_mask_dcplb;
|
|
|
|
|
2008-11-18 17:48:22 +08:00
|
|
|
void __init generate_cplb_tables_cpu(unsigned int cpu)
|
2008-01-27 18:39:16 +08:00
|
|
|
{
|
|
|
|
int i_d, i_i;
|
|
|
|
unsigned long addr;
|
|
|
|
unsigned long d_data, i_data;
|
|
|
|
unsigned long d_cache = 0, i_cache = 0;
|
|
|
|
|
2008-04-24 05:13:10 +08:00
|
|
|
printk(KERN_INFO "MPU: setting up cplb tables with memory protection\n");
|
|
|
|
|
2009-06-16 17:48:33 +08:00
|
|
|
#ifdef CONFIG_BFIN_EXTMEM_ICACHEABLE
|
2008-01-27 18:39:16 +08:00
|
|
|
i_cache = CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND;
|
|
|
|
#endif
|
|
|
|
|
2009-06-16 17:48:33 +08:00
|
|
|
#ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
|
2008-01-27 18:39:16 +08:00
|
|
|
d_cache = CPLB_L1_CHBL;
|
2009-10-30 15:57:22 +08:00
|
|
|
#ifdef CONFIG_BFIN_EXTMEM_WRITETHROUGH
|
2008-01-27 18:39:16 +08:00
|
|
|
d_cache |= CPLB_L1_AOW | CPLB_WT;
|
|
|
|
#endif
|
|
|
|
#endif
|
2008-11-18 17:48:22 +08:00
|
|
|
|
2008-01-27 18:39:16 +08:00
|
|
|
i_d = i_i = 0;
|
|
|
|
|
|
|
|
/* Set up the zero page. */
|
2008-11-18 17:48:22 +08:00
|
|
|
dcplb_tbl[cpu][i_d].addr = 0;
|
|
|
|
dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
|
2008-01-27 18:39:16 +08:00
|
|
|
|
2008-11-18 17:48:22 +08:00
|
|
|
icplb_tbl[cpu][i_i].addr = 0;
|
2009-05-06 01:14:39 +08:00
|
|
|
icplb_tbl[cpu][i_i++].data = CPLB_VALID | i_cache | CPLB_USER_RD | PAGE_SIZE_1KB;
|
2008-01-27 18:39:16 +08:00
|
|
|
|
|
|
|
/* Cover kernel memory with 4M pages. */
|
|
|
|
addr = 0;
|
|
|
|
d_data = d_cache | CPLB_SUPV_WR | CPLB_VALID | PAGE_SIZE_4MB | CPLB_DIRTY;
|
|
|
|
i_data = i_cache | CPLB_VALID | CPLB_PORTPRIO | PAGE_SIZE_4MB;
|
|
|
|
|
|
|
|
for (; addr < memory_start; addr += 4 * 1024 * 1024) {
|
2008-11-18 17:48:22 +08:00
|
|
|
dcplb_tbl[cpu][i_d].addr = addr;
|
|
|
|
dcplb_tbl[cpu][i_d++].data = d_data;
|
|
|
|
icplb_tbl[cpu][i_i].addr = addr;
|
|
|
|
icplb_tbl[cpu][i_i++].data = i_data | (addr == 0 ? CPLB_USER_RD : 0);
|
2008-01-27 18:39:16 +08:00
|
|
|
}
|
|
|
|
|
2010-01-07 12:11:17 +08:00
|
|
|
#ifdef CONFIG_ROMKERNEL
|
|
|
|
/* Cover kernel XIP flash area */
|
|
|
|
addr = CONFIG_ROM_BASE & ~(4 * 1024 * 1024 - 1);
|
|
|
|
dcplb_tbl[cpu][i_d].addr = addr;
|
|
|
|
dcplb_tbl[cpu][i_d++].data = d_data | CPLB_USER_RD;
|
|
|
|
icplb_tbl[cpu][i_i].addr = addr;
|
|
|
|
icplb_tbl[cpu][i_i++].data = i_data | CPLB_USER_RD;
|
|
|
|
#endif
|
|
|
|
|
2008-01-27 18:39:16 +08:00
|
|
|
/* Cover L1 memory. One 4M area for code and data each is enough. */
|
|
|
|
#if L1_DATA_A_LENGTH > 0 || L1_DATA_B_LENGTH > 0
|
2008-11-18 17:48:22 +08:00
|
|
|
dcplb_tbl[cpu][i_d].addr = get_l1_data_a_start_cpu(cpu);
|
|
|
|
dcplb_tbl[cpu][i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
|
2008-01-27 18:39:16 +08:00
|
|
|
#endif
|
2008-10-09 14:11:57 +08:00
|
|
|
#if L1_CODE_LENGTH > 0
|
2008-11-18 17:48:22 +08:00
|
|
|
icplb_tbl[cpu][i_i].addr = get_l1_code_start_cpu(cpu);
|
|
|
|
icplb_tbl[cpu][i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
|
2008-10-09 14:11:57 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Cover L2 memory */
|
|
|
|
#if L2_LENGTH > 0
|
2008-11-18 17:48:22 +08:00
|
|
|
dcplb_tbl[cpu][i_d].addr = L2_START;
|
2009-06-16 17:48:33 +08:00
|
|
|
dcplb_tbl[cpu][i_d++].data = L2_DMEMORY;
|
2008-11-18 17:48:22 +08:00
|
|
|
icplb_tbl[cpu][i_i].addr = L2_START;
|
2009-06-16 17:48:33 +08:00
|
|
|
icplb_tbl[cpu][i_i++].data = L2_IMEMORY;
|
2008-10-09 14:11:57 +08:00
|
|
|
#endif
|
2008-01-27 18:39:16 +08:00
|
|
|
|
|
|
|
first_mask_dcplb = i_d;
|
|
|
|
first_switched_dcplb = i_d + (1 << page_mask_order);
|
|
|
|
first_switched_icplb = i_i;
|
|
|
|
|
|
|
|
while (i_d < MAX_CPLBS)
|
2008-11-18 17:48:22 +08:00
|
|
|
dcplb_tbl[cpu][i_d++].data = 0;
|
2008-01-27 18:39:16 +08:00
|
|
|
while (i_i < MAX_CPLBS)
|
2008-11-18 17:48:22 +08:00
|
|
|
icplb_tbl[cpu][i_i++].data = 0;
|
2008-01-27 18:39:16 +08:00
|
|
|
}
|
2009-01-07 23:14:38 +08:00
|
|
|
|
2009-12-12 22:22:22 +08:00
|
|
|
void __init generate_cplb_tables_all(void)
|
2009-01-07 23:14:38 +08:00
|
|
|
{
|
|
|
|
}
|