Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Blackfin CPLB initialization |
| 3 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 4 | * Copyright 2008-2009 Analog Devices Inc. |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 5 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 6 | * Licensed under the GPL-2 or later. |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 7 | */ |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 8 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 9 | #include <linux/module.h> |
| 10 | |
| 11 | #include <asm/blackfin.h> |
| 12 | #include <asm/cplb.h> |
| 13 | #include <asm/cplbinit.h> |
Graf Yang | dbc895f | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 14 | #include <asm/mem_map.h> |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 15 | |
Mike Frysinger | c605999 | 2008-02-02 12:28:23 +0800 | [diff] [blame] | 16 | #if ANOMALY_05000263 |
| 17 | # error the MPU will not function safely while Anomaly 05000263 applies |
| 18 | #endif |
| 19 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 20 | struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS]; |
| 21 | struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS]; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 22 | |
| 23 | int first_switched_icplb, first_switched_dcplb; |
| 24 | int first_mask_dcplb; |
| 25 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 26 | void __init generate_cplb_tables_cpu(unsigned int cpu) |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 27 | { |
| 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 Frysinger | 8cab028 | 2008-04-24 05:13:10 +0800 | [diff] [blame] | 33 | printk(KERN_INFO "MPU: setting up cplb tables with memory protection\n"); |
| 34 | |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 35 | #ifdef CONFIG_BFIN_EXTMEM_ICACHEABLE |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 36 | i_cache = CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND; |
| 37 | #endif |
| 38 | |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 40 | d_cache = CPLB_L1_CHBL; |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 41 | #ifdef CONFIG_BFIN_EXTMEM_WRITETROUGH |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 42 | d_cache |= CPLB_L1_AOW | CPLB_WT; |
| 43 | #endif |
| 44 | #endif |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 45 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 46 | i_d = i_i = 0; |
| 47 | |
| 48 | /* Set up the zero page. */ |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 49 | dcplb_tbl[cpu][i_d].addr = 0; |
| 50 | dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 51 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 52 | icplb_tbl[cpu][i_i].addr = 0; |
Robin Getz | a17c7f6 | 2009-05-05 17:14:39 +0000 | [diff] [blame] | 53 | icplb_tbl[cpu][i_i++].data = CPLB_VALID | i_cache | CPLB_USER_RD | PAGE_SIZE_1KB; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 54 | |
| 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 Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 61 | 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 Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 65 | } |
| 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 Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 69 | 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 Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 71 | #endif |
Sonic Zhang | f099f39 | 2008-10-09 14:11:57 +0800 | [diff] [blame] | 72 | #if L1_CODE_LENGTH > 0 |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 73 | 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 Zhang | f099f39 | 2008-10-09 14:11:57 +0800 | [diff] [blame] | 75 | #endif |
| 76 | |
| 77 | /* Cover L2 memory */ |
| 78 | #if L2_LENGTH > 0 |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 79 | dcplb_tbl[cpu][i_d].addr = L2_START; |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 80 | dcplb_tbl[cpu][i_d++].data = L2_DMEMORY; |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 81 | icplb_tbl[cpu][i_i].addr = L2_START; |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 82 | icplb_tbl[cpu][i_i++].data = L2_IMEMORY; |
Sonic Zhang | f099f39 | 2008-10-09 14:11:57 +0800 | [diff] [blame] | 83 | #endif |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 84 | |
| 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 Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 90 | dcplb_tbl[cpu][i_d++].data = 0; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 91 | while (i_i < MAX_CPLBS) |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 92 | icplb_tbl[cpu][i_i++].data = 0; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 93 | } |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 94 | |
| 95 | void generate_cplb_tables_all(void) |
| 96 | { |
| 97 | } |