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 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 16 | struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS]; |
| 17 | struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS]; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 18 | |
| 19 | int first_switched_icplb, first_switched_dcplb; |
| 20 | int first_mask_dcplb; |
| 21 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 22 | void __init generate_cplb_tables_cpu(unsigned int cpu) |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 23 | { |
| 24 | int i_d, i_i; |
| 25 | unsigned long addr; |
| 26 | unsigned long d_data, i_data; |
| 27 | unsigned long d_cache = 0, i_cache = 0; |
| 28 | |
Mike Frysinger | 8cab028 | 2008-04-24 05:13:10 +0800 | [diff] [blame] | 29 | printk(KERN_INFO "MPU: setting up cplb tables with memory protection\n"); |
| 30 | |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 31 | #ifdef CONFIG_BFIN_EXTMEM_ICACHEABLE |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 32 | i_cache = CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND; |
| 33 | #endif |
| 34 | |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 35 | #ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 36 | d_cache = CPLB_L1_CHBL; |
André Goddard Rosa | 7bae2c4 | 2009-10-30 05:57:22 -0200 | [diff] [blame] | 37 | #ifdef CONFIG_BFIN_EXTMEM_WRITETHROUGH |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 38 | d_cache |= CPLB_L1_AOW | CPLB_WT; |
| 39 | #endif |
| 40 | #endif |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 41 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 42 | i_d = i_i = 0; |
| 43 | |
| 44 | /* Set up the zero page. */ |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 45 | dcplb_tbl[cpu][i_d].addr = 0; |
| 46 | dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 47 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 48 | icplb_tbl[cpu][i_i].addr = 0; |
Robin Getz | a17c7f6 | 2009-05-05 17:14:39 +0000 | [diff] [blame] | 49 | 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] | 50 | |
| 51 | /* Cover kernel memory with 4M pages. */ |
| 52 | addr = 0; |
| 53 | d_data = d_cache | CPLB_SUPV_WR | CPLB_VALID | PAGE_SIZE_4MB | CPLB_DIRTY; |
| 54 | i_data = i_cache | CPLB_VALID | CPLB_PORTPRIO | PAGE_SIZE_4MB; |
| 55 | |
| 56 | for (; addr < memory_start; addr += 4 * 1024 * 1024) { |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 57 | dcplb_tbl[cpu][i_d].addr = addr; |
| 58 | dcplb_tbl[cpu][i_d++].data = d_data; |
| 59 | icplb_tbl[cpu][i_i].addr = addr; |
| 60 | 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] | 61 | } |
| 62 | |
Barry Song | d86bfb1 | 2010-01-07 04:11:17 +0000 | [diff] [blame] | 63 | #ifdef CONFIG_ROMKERNEL |
| 64 | /* Cover kernel XIP flash area */ |
| 65 | addr = CONFIG_ROM_BASE & ~(4 * 1024 * 1024 - 1); |
| 66 | dcplb_tbl[cpu][i_d].addr = addr; |
| 67 | dcplb_tbl[cpu][i_d++].data = d_data | CPLB_USER_RD; |
| 68 | icplb_tbl[cpu][i_i].addr = addr; |
| 69 | icplb_tbl[cpu][i_i++].data = i_data | CPLB_USER_RD; |
| 70 | #endif |
| 71 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 72 | /* Cover L1 memory. One 4M area for code and data each is enough. */ |
| 73 | #if L1_DATA_A_LENGTH > 0 || L1_DATA_B_LENGTH > 0 |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 74 | dcplb_tbl[cpu][i_d].addr = get_l1_data_a_start_cpu(cpu); |
| 75 | dcplb_tbl[cpu][i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 76 | #endif |
Sonic Zhang | f099f39 | 2008-10-09 14:11:57 +0800 | [diff] [blame] | 77 | #if L1_CODE_LENGTH > 0 |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 78 | icplb_tbl[cpu][i_i].addr = get_l1_code_start_cpu(cpu); |
| 79 | icplb_tbl[cpu][i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB; |
Sonic Zhang | f099f39 | 2008-10-09 14:11:57 +0800 | [diff] [blame] | 80 | #endif |
| 81 | |
| 82 | /* Cover L2 memory */ |
| 83 | #if L2_LENGTH > 0 |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 84 | dcplb_tbl[cpu][i_d].addr = L2_START; |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 85 | dcplb_tbl[cpu][i_d++].data = L2_DMEMORY; |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 86 | icplb_tbl[cpu][i_i].addr = L2_START; |
Jie Zhang | 41ba653 | 2009-06-16 09:48:33 +0000 | [diff] [blame] | 87 | icplb_tbl[cpu][i_i++].data = L2_IMEMORY; |
Sonic Zhang | f099f39 | 2008-10-09 14:11:57 +0800 | [diff] [blame] | 88 | #endif |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 89 | |
| 90 | first_mask_dcplb = i_d; |
| 91 | first_switched_dcplb = i_d + (1 << page_mask_order); |
| 92 | first_switched_icplb = i_i; |
| 93 | |
| 94 | while (i_d < MAX_CPLBS) |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 95 | dcplb_tbl[cpu][i_d++].data = 0; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 96 | while (i_i < MAX_CPLBS) |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 97 | icplb_tbl[cpu][i_i++].data = 0; |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 98 | } |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 99 | |
Mike Frysinger | 0a68b53 | 2009-12-12 14:22:22 +0000 | [diff] [blame] | 100 | void __init generate_cplb_tables_all(void) |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 101 | { |
| 102 | } |