Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Blackfin CPLB initialization |
| 3 | * |
| 4 | * Copyright 2004-2007 Analog Devices Inc. |
| 5 | * |
| 6 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, see the file COPYING, or write |
| 20 | * to the Free Software Foundation, Inc., |
| 21 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 | */ |
Mike Frysinger | 3831638 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 23 | |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 24 | #include <linux/module.h> |
| 25 | |
| 26 | #include <asm/blackfin.h> |
Mike Frysinger | 04be80e | 2008-10-16 23:33:53 +0800 | [diff] [blame] | 27 | #include <asm/cacheflush.h> |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 28 | #include <asm/cplb.h> |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 29 | #include <asm/cplbinit.h> |
Graf Yang | dbc895f | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 30 | #include <asm/mem_map.h> |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 31 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 32 | struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR; |
| 33 | struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 34 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 35 | int first_switched_icplb PDT_ATTR; |
| 36 | int first_switched_dcplb PDT_ATTR; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 37 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 38 | struct cplb_boundary dcplb_bounds[9] PDT_ATTR; |
| 39 | struct cplb_boundary icplb_bounds[7] PDT_ATTR; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 40 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 41 | int icplb_nr_bounds PDT_ATTR; |
| 42 | int dcplb_nr_bounds PDT_ATTR; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 43 | |
Graf Yang | b8a9898 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 44 | void __init generate_cplb_tables_cpu(unsigned int cpu) |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 45 | { |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 46 | int i_d, i_i; |
| 47 | unsigned long addr; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 48 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 49 | struct cplb_entry *d_tbl = dcplb_tbl[cpu]; |
| 50 | struct cplb_entry *i_tbl = icplb_tbl[cpu]; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 51 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 52 | printk(KERN_INFO "NOMPU: setting up cplb tables\n"); |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 53 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 54 | i_d = i_i = 0; |
Mike Frysinger | 8cab028 | 2008-04-24 05:13:10 +0800 | [diff] [blame] | 55 | |
Bernd Schmidt | e84dcaa | 2009-03-02 18:37:48 +0800 | [diff] [blame^] | 56 | #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 57 | /* Set up the zero page. */ |
| 58 | d_tbl[i_d].addr = 0; |
| 59 | d_tbl[i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB; |
Bernd Schmidt | e84dcaa | 2009-03-02 18:37:48 +0800 | [diff] [blame^] | 60 | i_tbl[i_i].addr = 0; |
| 61 | i_tbl[i_i++].data = SDRAM_OOPS | PAGE_SIZE_1KB; |
| 62 | #endif |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 63 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 64 | /* Cover kernel memory with 4M pages. */ |
| 65 | addr = 0; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 66 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 67 | for (; addr < memory_start; addr += 4 * 1024 * 1024) { |
| 68 | d_tbl[i_d].addr = addr; |
| 69 | d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB; |
| 70 | i_tbl[i_i].addr = addr; |
| 71 | i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 72 | } |
| 73 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 74 | /* Cover L1 memory. One 4M area for code and data each is enough. */ |
| 75 | if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) { |
| 76 | d_tbl[i_d].addr = L1_DATA_A_START; |
| 77 | d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB; |
| 78 | } |
| 79 | i_tbl[i_i].addr = L1_CODE_START; |
| 80 | i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 81 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 82 | first_switched_dcplb = i_d; |
| 83 | first_switched_icplb = i_i; |
Mike Frysinger | dce783c | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 84 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 85 | BUG_ON(first_switched_dcplb > MAX_CPLBS); |
| 86 | BUG_ON(first_switched_icplb > MAX_CPLBS); |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 87 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 88 | while (i_d < MAX_CPLBS) |
| 89 | d_tbl[i_d++].data = 0; |
| 90 | while (i_i < MAX_CPLBS) |
| 91 | i_tbl[i_i++].data = 0; |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 92 | } |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 93 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 94 | void __init generate_cplb_tables_all(void) |
| 95 | { |
| 96 | int i_d, i_i; |
| 97 | |
| 98 | i_d = 0; |
| 99 | /* Normal RAM, including MTD FS. */ |
| 100 | #ifdef CONFIG_MTD_UCLINUX |
| 101 | dcplb_bounds[i_d].eaddr = memory_mtd_start + mtd_size; |
| 102 | #else |
| 103 | dcplb_bounds[i_d].eaddr = memory_end; |
Mike Frysinger | 3831638 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 104 | #endif |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 105 | dcplb_bounds[i_d++].data = SDRAM_DGENERIC; |
| 106 | /* DMA uncached region. */ |
| 107 | if (DMA_UNCACHED_REGION) { |
| 108 | dcplb_bounds[i_d].eaddr = _ramend; |
| 109 | dcplb_bounds[i_d++].data = SDRAM_DNON_CHBL; |
| 110 | } |
| 111 | if (_ramend != physical_mem_end) { |
| 112 | /* Reserved memory. */ |
| 113 | dcplb_bounds[i_d].eaddr = physical_mem_end; |
| 114 | dcplb_bounds[i_d++].data = (reserved_mem_dcache_on ? |
| 115 | SDRAM_DGENERIC : SDRAM_DNON_CHBL); |
| 116 | } |
| 117 | /* Addressing hole up to the async bank. */ |
| 118 | dcplb_bounds[i_d].eaddr = ASYNC_BANK0_BASE; |
| 119 | dcplb_bounds[i_d++].data = 0; |
| 120 | /* ASYNC banks. */ |
| 121 | dcplb_bounds[i_d].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE; |
| 122 | dcplb_bounds[i_d++].data = SDRAM_EBIU; |
| 123 | /* Addressing hole up to BootROM. */ |
| 124 | dcplb_bounds[i_d].eaddr = BOOT_ROM_START; |
| 125 | dcplb_bounds[i_d++].data = 0; |
| 126 | /* BootROM -- largest one should be less than 1 meg. */ |
| 127 | dcplb_bounds[i_d].eaddr = BOOT_ROM_START + (1 * 1024 * 1024); |
| 128 | dcplb_bounds[i_d++].data = SDRAM_DGENERIC; |
| 129 | if (L2_LENGTH) { |
| 130 | /* Addressing hole up to L2 SRAM. */ |
| 131 | dcplb_bounds[i_d].eaddr = L2_START; |
| 132 | dcplb_bounds[i_d++].data = 0; |
| 133 | /* L2 SRAM. */ |
| 134 | dcplb_bounds[i_d].eaddr = L2_START + L2_LENGTH; |
| 135 | dcplb_bounds[i_d++].data = L2_DMEMORY; |
| 136 | } |
| 137 | dcplb_nr_bounds = i_d; |
| 138 | BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds)); |
| 139 | |
| 140 | i_i = 0; |
| 141 | /* Normal RAM, including MTD FS. */ |
| 142 | #ifdef CONFIG_MTD_UCLINUX |
| 143 | icplb_bounds[i_i].eaddr = memory_mtd_start + mtd_size; |
| 144 | #else |
| 145 | icplb_bounds[i_i].eaddr = memory_end; |
| 146 | #endif |
| 147 | icplb_bounds[i_i++].data = SDRAM_IGENERIC; |
| 148 | /* DMA uncached region. */ |
| 149 | if (DMA_UNCACHED_REGION) { |
| 150 | icplb_bounds[i_i].eaddr = _ramend; |
| 151 | icplb_bounds[i_i++].data = 0; |
| 152 | } |
| 153 | if (_ramend != physical_mem_end) { |
| 154 | /* Reserved memory. */ |
| 155 | icplb_bounds[i_i].eaddr = physical_mem_end; |
| 156 | icplb_bounds[i_i++].data = (reserved_mem_icache_on ? |
| 157 | SDRAM_IGENERIC : SDRAM_INON_CHBL); |
| 158 | } |
| 159 | /* Addressing hole up to BootROM. */ |
| 160 | icplb_bounds[i_i].eaddr = BOOT_ROM_START; |
| 161 | icplb_bounds[i_i++].data = 0; |
| 162 | /* BootROM -- largest one should be less than 1 meg. */ |
| 163 | icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024); |
| 164 | icplb_bounds[i_i++].data = SDRAM_IGENERIC; |
| 165 | if (L2_LENGTH) { |
| 166 | /* Addressing hole up to L2 SRAM, including the async bank. */ |
| 167 | icplb_bounds[i_i].eaddr = L2_START; |
| 168 | icplb_bounds[i_i++].data = 0; |
| 169 | /* L2 SRAM. */ |
| 170 | icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH; |
| 171 | icplb_bounds[i_i++].data = L2_IMEMORY; |
| 172 | } |
| 173 | icplb_nr_bounds = i_i; |
| 174 | BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds)); |
| 175 | } |