Path: blob/master/arch/blackfin/kernel/cplb-nompu/cplbinit.c
15126 views
/*1* Blackfin CPLB initialization2*3* Copyright 2007-2009 Analog Devices Inc.4*5* Licensed under the GPL-2 or later.6*/78#include <linux/module.h>910#include <asm/blackfin.h>11#include <asm/cacheflush.h>12#include <asm/cplb.h>13#include <asm/cplbinit.h>14#include <asm/mem_map.h>1516struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;17struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;1819int first_switched_icplb PDT_ATTR;20int first_switched_dcplb PDT_ATTR;2122struct cplb_boundary dcplb_bounds[9] PDT_ATTR;23struct cplb_boundary icplb_bounds[9] PDT_ATTR;2425int icplb_nr_bounds PDT_ATTR;26int dcplb_nr_bounds PDT_ATTR;2728void __init generate_cplb_tables_cpu(unsigned int cpu)29{30int i_d, i_i;31unsigned long addr;3233struct cplb_entry *d_tbl = dcplb_tbl[cpu];34struct cplb_entry *i_tbl = icplb_tbl[cpu];3536printk(KERN_INFO "NOMPU: setting up cplb tables\n");3738i_d = i_i = 0;3940#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO41/* Set up the zero page. */42d_tbl[i_d].addr = 0;43d_tbl[i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;44i_tbl[i_i].addr = 0;45i_tbl[i_i++].data = SDRAM_OOPS | PAGE_SIZE_1KB;46#endif4748/* Cover kernel memory with 4M pages. */49addr = 0;5051for (; addr < memory_start; addr += 4 * 1024 * 1024) {52d_tbl[i_d].addr = addr;53d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;54i_tbl[i_i].addr = addr;55i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;56}5758#ifdef CONFIG_ROMKERNEL59/* Cover kernel XIP flash area */60addr = CONFIG_ROM_BASE & ~(4 * 1024 * 1024 - 1);61d_tbl[i_d].addr = addr;62d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;63i_tbl[i_i].addr = addr;64i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;65#endif6667/* Cover L1 memory. One 4M area for code and data each is enough. */68if (cpu == 0) {69if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {70d_tbl[i_d].addr = L1_DATA_A_START;71d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;72}73i_tbl[i_i].addr = L1_CODE_START;74i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;75}76#ifdef CONFIG_SMP77else {78if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {79d_tbl[i_d].addr = COREB_L1_DATA_A_START;80d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;81}82i_tbl[i_i].addr = COREB_L1_CODE_START;83i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;84}85#endif86first_switched_dcplb = i_d;87first_switched_icplb = i_i;8889BUG_ON(first_switched_dcplb > MAX_CPLBS);90BUG_ON(first_switched_icplb > MAX_CPLBS);9192while (i_d < MAX_CPLBS)93d_tbl[i_d++].data = 0;94while (i_i < MAX_CPLBS)95i_tbl[i_i++].data = 0;96}9798void __init generate_cplb_tables_all(void)99{100unsigned long uncached_end;101int i_d, i_i;102103i_d = 0;104/* Normal RAM, including MTD FS. */105#ifdef CONFIG_MTD_UCLINUX106uncached_end = memory_mtd_start + mtd_size;107#else108uncached_end = memory_end;109#endif110/*111* if DMA uncached is less than 1MB, mark the 1MB chunk as uncached112* so that we don't have to use 4kB pages and cause CPLB thrashing113*/114if ((DMA_UNCACHED_REGION >= 1 * 1024 * 1024) || !DMA_UNCACHED_REGION ||115((_ramend - uncached_end) >= 1 * 1024 * 1024))116dcplb_bounds[i_d].eaddr = uncached_end;117else118dcplb_bounds[i_d].eaddr = uncached_end & ~(1 * 1024 * 1024 - 1);119dcplb_bounds[i_d++].data = SDRAM_DGENERIC;120/* DMA uncached region. */121if (DMA_UNCACHED_REGION) {122dcplb_bounds[i_d].eaddr = _ramend;123dcplb_bounds[i_d++].data = SDRAM_DNON_CHBL;124}125if (_ramend != physical_mem_end) {126/* Reserved memory. */127dcplb_bounds[i_d].eaddr = physical_mem_end;128dcplb_bounds[i_d++].data = (reserved_mem_dcache_on ?129SDRAM_DGENERIC : SDRAM_DNON_CHBL);130}131/* Addressing hole up to the async bank. */132dcplb_bounds[i_d].eaddr = ASYNC_BANK0_BASE;133dcplb_bounds[i_d++].data = 0;134/* ASYNC banks. */135dcplb_bounds[i_d].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;136dcplb_bounds[i_d++].data = SDRAM_EBIU;137/* Addressing hole up to BootROM. */138dcplb_bounds[i_d].eaddr = BOOT_ROM_START;139dcplb_bounds[i_d++].data = 0;140/* BootROM -- largest one should be less than 1 meg. */141dcplb_bounds[i_d].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);142dcplb_bounds[i_d++].data = SDRAM_DGENERIC;143if (L2_LENGTH) {144/* Addressing hole up to L2 SRAM. */145dcplb_bounds[i_d].eaddr = L2_START;146dcplb_bounds[i_d++].data = 0;147/* L2 SRAM. */148dcplb_bounds[i_d].eaddr = L2_START + L2_LENGTH;149dcplb_bounds[i_d++].data = L2_DMEMORY;150}151dcplb_nr_bounds = i_d;152BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds));153154i_i = 0;155/* Normal RAM, including MTD FS. */156icplb_bounds[i_i].eaddr = uncached_end;157icplb_bounds[i_i++].data = SDRAM_IGENERIC;158if (_ramend != physical_mem_end) {159/* DMA uncached region. */160if (DMA_UNCACHED_REGION) {161/* Normally this hole is caught by the async below. */162icplb_bounds[i_i].eaddr = _ramend;163icplb_bounds[i_i++].data = 0;164}165/* Reserved memory. */166icplb_bounds[i_i].eaddr = physical_mem_end;167icplb_bounds[i_i++].data = (reserved_mem_icache_on ?168SDRAM_IGENERIC : SDRAM_INON_CHBL);169}170/* Addressing hole up to the async bank. */171icplb_bounds[i_i].eaddr = ASYNC_BANK0_BASE;172icplb_bounds[i_i++].data = 0;173/* ASYNC banks. */174icplb_bounds[i_i].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;175icplb_bounds[i_i++].data = SDRAM_EBIU;176/* Addressing hole up to BootROM. */177icplb_bounds[i_i].eaddr = BOOT_ROM_START;178icplb_bounds[i_i++].data = 0;179/* BootROM -- largest one should be less than 1 meg. */180icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);181icplb_bounds[i_i++].data = SDRAM_IGENERIC;182183if (L2_LENGTH) {184/* Addressing hole up to L2 SRAM. */185icplb_bounds[i_i].eaddr = L2_START;186icplb_bounds[i_i++].data = 0;187/* L2 SRAM. */188icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH;189icplb_bounds[i_i++].data = L2_IMEMORY;190}191icplb_nr_bounds = i_i;192BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds));193}194195196