2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-06-03 04:04:48 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Common functions for OMAP4/5 based boards
|
|
|
|
*
|
|
|
|
* (C) Copyright 2010
|
|
|
|
* Texas Instruments, <www.ti.com>
|
|
|
|
*
|
|
|
|
* Author :
|
|
|
|
* Aneesh V <aneesh@ti.com>
|
|
|
|
* Steve Sakoman <steve@sakoman.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2014-06-03 04:04:48 +00:00
|
|
|
#include <asm/cache.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2014-06-03 04:04:48 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2016-09-14 05:13:29 +00:00
|
|
|
/*
|
|
|
|
* Without LPAE short descriptors are used
|
|
|
|
* Set C - Cache Bit3
|
|
|
|
* Set B - Buffer Bit2
|
|
|
|
* The last 2 bits set to 0b10
|
|
|
|
* Do Not set XN bit4
|
|
|
|
* So value is 0xe
|
|
|
|
*
|
|
|
|
* With LPAE cache configuration happens via MAIR0 register
|
|
|
|
* AttrIndx value is 0x3 for picking byte3 for MAIR0 which has 0xFF.
|
|
|
|
* 0xFF maps to Cache writeback with Read and Write Allocate set
|
|
|
|
* The bits[1:0] should have the value 0b01 for the first level
|
|
|
|
* descriptor.
|
|
|
|
* So the value is 0xd
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARMV7_LPAE
|
|
|
|
#define ARMV7_DCACHE_POLICY DCACHE_WRITEALLOC
|
|
|
|
#else
|
|
|
|
#define ARMV7_DCACHE_POLICY DCACHE_WRITEBACK & ~TTB_SECT_XN_MASK
|
|
|
|
#endif
|
|
|
|
|
2014-06-03 04:04:48 +00:00
|
|
|
#define ARMV7_DOMAIN_CLIENT 1
|
|
|
|
#define ARMV7_DOMAIN_MASK (0x3 << 0)
|
|
|
|
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
2018-05-03 15:04:49 +00:00
|
|
|
|
|
|
|
/* Enable I cache if not enabled */
|
|
|
|
if (!icache_status())
|
|
|
|
icache_enable();
|
|
|
|
|
2014-06-03 04:04:48 +00:00
|
|
|
dcache_enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dram_bank_mmu_setup(int bank)
|
|
|
|
{
|
2020-06-26 06:13:33 +00:00
|
|
|
struct bd_info *bd = gd->bd;
|
2014-06-03 04:04:48 +00:00
|
|
|
int i;
|
|
|
|
|
2016-09-14 05:13:28 +00:00
|
|
|
u32 start = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT;
|
|
|
|
u32 size = bd->bi_dram[bank].size >> MMU_SECTION_SHIFT;
|
2014-06-03 04:04:48 +00:00
|
|
|
u32 end = start + size;
|
|
|
|
|
|
|
|
debug("%s: bank: %d\n", __func__, bank);
|
|
|
|
for (i = start; i < end; i++)
|
2016-09-14 05:13:29 +00:00
|
|
|
set_section_dcache(i, ARMV7_DCACHE_POLICY);
|
2014-06-03 04:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void arm_init_domains(void)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
reg = get_dacr();
|
|
|
|
/*
|
|
|
|
* Set DOMAIN to client access so that all permissions
|
|
|
|
* set in pagetables are validated by the mmu.
|
|
|
|
*/
|
|
|
|
reg &= ~ARMV7_DOMAIN_MASK;
|
|
|
|
reg |= ARMV7_DOMAIN_CLIENT;
|
|
|
|
set_dacr(reg);
|
|
|
|
}
|