2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-12-14 08:47:15 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Common board functions for OMAP3 based boards.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2004-2008
|
|
|
|
* Texas Instruments, <www.ti.com>
|
|
|
|
*
|
|
|
|
* Author :
|
|
|
|
* Sunil Kumar <sunilsaini05@gmail.com>
|
|
|
|
* Shashi Ranjan <shashiranjanmca05@gmail.com>
|
|
|
|
*
|
|
|
|
* Derived from Beagle Board and 3430 SDP code by
|
|
|
|
* Richard Woodruff <r-woodruff2@ti.com>
|
|
|
|
* Syed Mohammed Khasim <khasim@ti.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <command.h>
|
2014-10-23 03:37:15 +00:00
|
|
|
#include <dm.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2012-08-13 19:03:19 +00:00
|
|
|
#include <spl.h>
|
2008-12-14 08:47:15 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/arch/mem.h>
|
2009-06-20 09:02:17 +00:00
|
|
|
#include <asm/cache.h>
|
2011-06-16 23:30:53 +00:00
|
|
|
#include <asm/armv7.h>
|
2014-10-23 03:37:15 +00:00
|
|
|
#include <asm/gpio.h>
|
2011-09-14 19:29:26 +00:00
|
|
|
#include <asm/omap_common.h>
|
2012-04-13 12:20:03 +00:00
|
|
|
#include <linux/compiler.h>
|
2008-12-14 08:47:15 +00:00
|
|
|
|
2011-06-16 23:30:53 +00:00
|
|
|
/* Declarations */
|
2008-12-14 08:47:15 +00:00
|
|
|
extern omap3_sysinfo sysinfo;
|
2012-10-31 05:23:28 +00:00
|
|
|
#ifndef CONFIG_SYS_L2CACHE_OFF
|
2011-06-16 23:30:53 +00:00
|
|
|
static void omap3_invalidate_l2_cache_secure(void);
|
2012-10-31 05:23:28 +00:00
|
|
|
#endif
|
2008-12-14 08:47:15 +00:00
|
|
|
|
2019-12-07 04:41:35 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_GPIO)
|
2019-05-29 20:42:53 +00:00
|
|
|
#if !CONFIG_IS_ENABLED(OF_CONTROL)
|
|
|
|
/* Manually initialize GPIO banks when OF_CONTROL doesn't */
|
2020-12-03 23:55:23 +00:00
|
|
|
static const struct omap_gpio_plat omap34xx_gpio[] = {
|
2015-07-31 23:55:09 +00:00
|
|
|
{ 0, OMAP34XX_GPIO1_BASE },
|
|
|
|
{ 1, OMAP34XX_GPIO2_BASE },
|
|
|
|
{ 2, OMAP34XX_GPIO3_BASE },
|
|
|
|
{ 3, OMAP34XX_GPIO4_BASE },
|
|
|
|
{ 4, OMAP34XX_GPIO5_BASE },
|
|
|
|
{ 5, OMAP34XX_GPIO6_BASE },
|
2014-10-23 03:37:15 +00:00
|
|
|
};
|
|
|
|
|
2020-12-29 03:34:54 +00:00
|
|
|
U_BOOT_DRVINFOS(omap34xx_gpios) = {
|
2014-10-23 03:37:15 +00:00
|
|
|
{ "gpio_omap", &omap34xx_gpio[0] },
|
|
|
|
{ "gpio_omap", &omap34xx_gpio[1] },
|
|
|
|
{ "gpio_omap", &omap34xx_gpio[2] },
|
|
|
|
{ "gpio_omap", &omap34xx_gpio[3] },
|
|
|
|
{ "gpio_omap", &omap34xx_gpio[4] },
|
|
|
|
{ "gpio_omap", &omap34xx_gpio[5] },
|
|
|
|
};
|
2019-05-29 20:42:53 +00:00
|
|
|
#endif
|
2014-10-23 03:37:15 +00:00
|
|
|
#else
|
|
|
|
|
2011-07-21 13:29:29 +00:00
|
|
|
static const struct gpio_bank gpio_bank_34xx[6] = {
|
2015-07-31 23:55:09 +00:00
|
|
|
{ (void *)OMAP34XX_GPIO1_BASE },
|
|
|
|
{ (void *)OMAP34XX_GPIO2_BASE },
|
|
|
|
{ (void *)OMAP34XX_GPIO3_BASE },
|
|
|
|
{ (void *)OMAP34XX_GPIO4_BASE },
|
|
|
|
{ (void *)OMAP34XX_GPIO5_BASE },
|
|
|
|
{ (void *)OMAP34XX_GPIO6_BASE },
|
2011-07-21 13:29:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx;
|
|
|
|
|
2014-10-23 03:37:15 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-14 08:47:15 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Routine: secure_unlock
|
|
|
|
* Description: Setup security registers for access
|
|
|
|
* (GP Device only)
|
|
|
|
*****************************************************************************/
|
|
|
|
void secure_unlock_mem(void)
|
|
|
|
{
|
2009-08-08 07:30:21 +00:00
|
|
|
struct pm *pm_rt_ape_base = (struct pm *)PM_RT_APE_BASE_ADDR_ARM;
|
|
|
|
struct pm *pm_gpmc_base = (struct pm *)PM_GPMC_BASE_ADDR_ARM;
|
|
|
|
struct pm *pm_ocm_ram_base = (struct pm *)PM_OCM_RAM_BASE_ADDR_ARM;
|
|
|
|
struct pm *pm_iva2_base = (struct pm *)PM_IVA2_BASE_ADDR_ARM;
|
|
|
|
struct sms *sms_base = (struct sms *)OMAP34XX_SMS_BASE;
|
2008-12-14 08:47:15 +00:00
|
|
|
|
|
|
|
/* Protection Module Register Target APE (PM_RT) */
|
|
|
|
writel(UNLOCK_1, &pm_rt_ape_base->req_info_permission_1);
|
|
|
|
writel(UNLOCK_1, &pm_rt_ape_base->read_permission_0);
|
|
|
|
writel(UNLOCK_1, &pm_rt_ape_base->wirte_permission_0);
|
|
|
|
writel(UNLOCK_2, &pm_rt_ape_base->addr_match_1);
|
|
|
|
|
|
|
|
writel(UNLOCK_3, &pm_gpmc_base->req_info_permission_0);
|
|
|
|
writel(UNLOCK_3, &pm_gpmc_base->read_permission_0);
|
|
|
|
writel(UNLOCK_3, &pm_gpmc_base->wirte_permission_0);
|
|
|
|
|
|
|
|
writel(UNLOCK_3, &pm_ocm_ram_base->req_info_permission_0);
|
|
|
|
writel(UNLOCK_3, &pm_ocm_ram_base->read_permission_0);
|
|
|
|
writel(UNLOCK_3, &pm_ocm_ram_base->wirte_permission_0);
|
|
|
|
writel(UNLOCK_2, &pm_ocm_ram_base->addr_match_2);
|
|
|
|
|
|
|
|
/* IVA Changes */
|
|
|
|
writel(UNLOCK_3, &pm_iva2_base->req_info_permission_0);
|
|
|
|
writel(UNLOCK_3, &pm_iva2_base->read_permission_0);
|
|
|
|
writel(UNLOCK_3, &pm_iva2_base->wirte_permission_0);
|
|
|
|
|
|
|
|
/* SDRC region 0 public */
|
|
|
|
writel(UNLOCK_1, &sms_base->rg_att0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Routine: secureworld_exit()
|
|
|
|
* Description: If chip is EMU and boot type is external
|
|
|
|
* configure secure registers and exit secure world
|
|
|
|
* general use.
|
|
|
|
*****************************************************************************/
|
2014-06-16 21:22:23 +00:00
|
|
|
void secureworld_exit(void)
|
2008-12-14 08:47:15 +00:00
|
|
|
{
|
|
|
|
unsigned long i;
|
|
|
|
|
2012-02-02 12:51:02 +00:00
|
|
|
/* configure non-secure access control register */
|
2008-12-14 08:47:15 +00:00
|
|
|
__asm__ __volatile__("mrc p15, 0, %0, c1, c1, 2":"=r"(i));
|
|
|
|
/* enabling co-processor CP10 and CP11 accesses in NS world */
|
|
|
|
__asm__ __volatile__("orr %0, %0, #0xC00":"=r"(i));
|
|
|
|
/*
|
|
|
|
* allow allocation of locked TLBs and L2 lines in NS world
|
|
|
|
* allow use of PLE registers in NS world also
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__("orr %0, %0, #0x70000":"=r"(i));
|
|
|
|
__asm__ __volatile__("mcr p15, 0, %0, c1, c1, 2":"=r"(i));
|
|
|
|
|
|
|
|
/* Enable ASA in ACR register */
|
|
|
|
__asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
|
|
|
|
__asm__ __volatile__("orr %0, %0, #0x10":"=r"(i));
|
|
|
|
__asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
|
|
|
|
|
|
|
|
/* Exiting secure world */
|
|
|
|
__asm__ __volatile__("mrc p15, 0, %0, c1, c1, 0":"=r"(i));
|
|
|
|
__asm__ __volatile__("orr %0, %0, #0x31":"=r"(i));
|
|
|
|
__asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Routine: try_unlock_sram()
|
|
|
|
* Description: If chip is GP/EMU(special) type, unlock the SRAM for
|
|
|
|
* general use.
|
|
|
|
*****************************************************************************/
|
2014-06-16 21:22:23 +00:00
|
|
|
void try_unlock_memory(void)
|
2008-12-14 08:47:15 +00:00
|
|
|
{
|
|
|
|
int mode;
|
|
|
|
int in_sdram = is_running_in_sdram();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if GP device unlock device SRAM for general use
|
|
|
|
* secure code breaks for Secure/Emulation device - HS/E/T
|
|
|
|
*/
|
|
|
|
mode = get_device_type();
|
|
|
|
if (mode == GP_DEVICE)
|
|
|
|
secure_unlock_mem();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If device is EMU and boot is XIP external booting
|
|
|
|
* Unlock firewalls and disable L2 and put chip
|
|
|
|
* out of secure world
|
|
|
|
*
|
|
|
|
* Assuming memories are unlocked by the demon who put us in SDRAM
|
|
|
|
*/
|
|
|
|
if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F)
|
|
|
|
&& (!in_sdram)) {
|
|
|
|
secure_unlock_mem();
|
|
|
|
secureworld_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-02 15:00:00 +00:00
|
|
|
void early_system_init(void)
|
|
|
|
{
|
|
|
|
hw_data_init();
|
|
|
|
}
|
|
|
|
|
2021-02-07 13:50:13 +00:00
|
|
|
#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && \
|
|
|
|
!defined(CONFIG_SKIP_LOWLEVEL_INIT_ONLY)
|
2008-12-14 08:47:15 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Routine: s_init
|
|
|
|
* Description: Does early system init of muxing and clocks.
|
|
|
|
* - Called path is with SRAM stack.
|
|
|
|
*****************************************************************************/
|
|
|
|
void s_init(void)
|
|
|
|
{
|
|
|
|
watchdog_init();
|
2017-06-02 15:00:00 +00:00
|
|
|
early_system_init();
|
2008-12-14 08:47:15 +00:00
|
|
|
|
|
|
|
try_unlock_memory();
|
|
|
|
|
2011-06-16 23:30:53 +00:00
|
|
|
#ifndef CONFIG_SYS_L2CACHE_OFF
|
|
|
|
/* Invalidate L2-cache from secure mode */
|
|
|
|
omap3_invalidate_l2_cache_secure();
|
2008-12-14 08:47:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
set_muxconf_regs();
|
2010-12-18 12:24:20 +00:00
|
|
|
sdelay(100);
|
2008-12-14 08:47:15 +00:00
|
|
|
|
|
|
|
prcm_init();
|
|
|
|
|
|
|
|
per_clocks_enable();
|
|
|
|
|
2012-02-06 03:55:35 +00:00
|
|
|
#ifdef CONFIG_USB_EHCI_OMAP
|
|
|
|
ehci_clocks_enable();
|
|
|
|
#endif
|
2015-03-03 15:03:02 +00:00
|
|
|
}
|
2021-02-07 13:50:13 +00:00
|
|
|
#endif
|
2012-02-06 03:55:35 +00:00
|
|
|
|
2015-03-03 15:03:02 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
void board_init_f(ulong dummy)
|
|
|
|
{
|
2017-06-02 15:00:00 +00:00
|
|
|
early_system_init();
|
2015-03-03 15:03:02 +00:00
|
|
|
mem_init();
|
2017-07-14 13:53:20 +00:00
|
|
|
/*
|
|
|
|
* Save the boot parameters passed from romcode.
|
|
|
|
* We cannot delay the saving further than this,
|
|
|
|
* to prevent overwrites.
|
|
|
|
*/
|
|
|
|
save_omap_boot_params();
|
2008-12-14 08:47:15 +00:00
|
|
|
}
|
2015-03-03 15:03:02 +00:00
|
|
|
#endif
|
2008-12-14 08:47:15 +00:00
|
|
|
|
2012-04-13 12:20:03 +00:00
|
|
|
/*
|
|
|
|
* Routine: misc_init_r
|
|
|
|
* Description: A basic misc_init_r that just displays the die ID
|
|
|
|
*/
|
|
|
|
int __weak misc_init_r(void)
|
|
|
|
{
|
2015-08-27 17:37:13 +00:00
|
|
|
omap_die_id_display();
|
2012-04-13 12:20:03 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-14 08:47:15 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Routine: wait_for_command_complete
|
|
|
|
* Description: Wait for posting to finish on watchdog
|
|
|
|
*****************************************************************************/
|
2014-10-08 20:57:41 +00:00
|
|
|
static void wait_for_command_complete(struct watchdog *wd_base)
|
2008-12-14 08:47:15 +00:00
|
|
|
{
|
|
|
|
int pending = 1;
|
|
|
|
do {
|
|
|
|
pending = readl(&wd_base->wwps);
|
|
|
|
} while (pending);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Routine: watchdog_init
|
|
|
|
* Description: Shut down watch dogs
|
|
|
|
*****************************************************************************/
|
|
|
|
void watchdog_init(void)
|
|
|
|
{
|
2009-08-08 07:30:21 +00:00
|
|
|
struct watchdog *wd2_base = (struct watchdog *)WD2_BASE;
|
|
|
|
struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
|
2008-12-14 08:47:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
|
|
|
|
* either taken care of by ROM (HS/EMU) or not accessible (GP).
|
|
|
|
* We need to take care of WD2-MPU or take a PRCM reset. WD3
|
|
|
|
* should not be running and does not generate a PRCM reset.
|
|
|
|
*/
|
|
|
|
|
2014-03-25 13:49:48 +00:00
|
|
|
setbits_le32(&prcm_base->fclken_wkup, 0x20);
|
|
|
|
setbits_le32(&prcm_base->iclken_wkup, 0x20);
|
2008-12-14 08:47:15 +00:00
|
|
|
wait_on_value(ST_WDT2, 0x20, &prcm_base->idlest_wkup, 5);
|
|
|
|
|
|
|
|
writel(WD_UNLOCK1, &wd2_base->wspr);
|
|
|
|
wait_for_command_complete(wd2_base);
|
|
|
|
writel(WD_UNLOCK2, &wd2_base->wspr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Dummy function to handle errors for EABI incompatibility
|
|
|
|
*****************************************************************************/
|
|
|
|
void abort(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-14 19:29:26 +00:00
|
|
|
#if defined(CONFIG_NAND_OMAP_GPMC) & !defined(CONFIG_SPL_BUILD)
|
2008-12-14 08:47:15 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* OMAP3 specific command to switch between NAND HW and SW ecc
|
|
|
|
*****************************************************************************/
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_switch_ecc(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2008-12-14 08:47:15 +00:00
|
|
|
{
|
2017-03-06 12:54:30 +00:00
|
|
|
int hw, strength = 1;
|
|
|
|
|
2013-04-04 23:52:50 +00:00
|
|
|
if (argc < 2 || argc > 3)
|
2008-12-14 08:47:15 +00:00
|
|
|
goto usage;
|
2013-04-04 23:52:50 +00:00
|
|
|
|
|
|
|
if (strncmp(argv[1], "hw", 2) == 0) {
|
2017-03-06 12:54:30 +00:00
|
|
|
hw = 1;
|
|
|
|
if (argc == 3) {
|
|
|
|
if (strncmp(argv[2], "bch8", 4) == 0)
|
|
|
|
strength = 8;
|
2016-06-07 06:55:42 +00:00
|
|
|
else if (strncmp(argv[2], "bch16", 5) == 0)
|
2017-03-06 12:54:30 +00:00
|
|
|
strength = 16;
|
|
|
|
else if (strncmp(argv[2], "hamming", 7) != 0)
|
2013-04-04 23:52:50 +00:00
|
|
|
goto usage;
|
|
|
|
}
|
|
|
|
} else if (strncmp(argv[1], "sw", 2) == 0) {
|
2017-03-06 12:54:30 +00:00
|
|
|
hw = 0;
|
|
|
|
if (argc == 3) {
|
|
|
|
if (strncmp(argv[2], "bch8", 4) == 0)
|
|
|
|
strength = 8;
|
|
|
|
else if (strncmp(argv[2], "hamming", 7) != 0)
|
2015-02-18 19:25:11 +00:00
|
|
|
goto usage;
|
|
|
|
}
|
2013-04-04 23:52:50 +00:00
|
|
|
} else {
|
2008-12-14 08:47:15 +00:00
|
|
|
goto usage;
|
2013-04-04 23:52:50 +00:00
|
|
|
}
|
2008-12-14 08:47:15 +00:00
|
|
|
|
2017-03-06 12:54:30 +00:00
|
|
|
return -omap_nand_switch_ecc(hw, strength);
|
2008-12-14 08:47:15 +00:00
|
|
|
|
|
|
|
usage:
|
2009-04-03 08:30:07 +00:00
|
|
|
printf ("Usage: nandecc %s\n", cmdtp->usage);
|
2008-12-14 08:47:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
2013-04-04 23:52:50 +00:00
|
|
|
nandecc, 3, 1, do_switch_ecc,
|
2009-11-17 12:30:23 +00:00
|
|
|
"switch OMAP3 NAND ECC calculation algorithm",
|
2016-06-07 06:55:42 +00:00
|
|
|
"hw [hamming|bch8|bch16] - Switch between NAND hardware 1-bit hamming"
|
|
|
|
" and 8-bit/16-bit BCH\n"
|
2013-04-04 23:52:50 +00:00
|
|
|
" ecc calculation (second parameter may"
|
|
|
|
" be omitted).\n"
|
|
|
|
"nandecc sw - Switch to NAND software ecc algorithm."
|
2009-05-24 15:06:54 +00:00
|
|
|
);
|
2008-12-14 08:47:15 +00:00
|
|
|
|
2011-09-14 19:29:26 +00:00
|
|
|
#endif /* CONFIG_NAND_OMAP_GPMC & !CONFIG_SPL_BUILD */
|
2009-04-27 15:57:27 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DISPLAY_BOARDINFO
|
|
|
|
/**
|
|
|
|
* Print board information
|
|
|
|
*/
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
|
|
|
char *mem_s ;
|
|
|
|
|
|
|
|
if (is_mem_sdr())
|
|
|
|
mem_s = "mSDR";
|
|
|
|
else
|
|
|
|
mem_s = "LPDDR";
|
|
|
|
|
|
|
|
printf("%s + %s/%s\n", sysinfo.board_string, mem_s,
|
|
|
|
sysinfo.nand_string);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_DISPLAY_BOARDINFO */
|
2011-06-16 23:30:53 +00:00
|
|
|
|
|
|
|
static void omap3_emu_romcode_call(u32 service_id, u32 *parameters)
|
|
|
|
{
|
|
|
|
u32 i, num_params = *parameters;
|
|
|
|
u32 *sram_scratch_space = (u32 *)OMAP3_PUBLIC_SRAM_SCRATCH_AREA;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* copy the parameters to an un-cached area to avoid coherency
|
|
|
|
* issues
|
|
|
|
*/
|
|
|
|
for (i = 0; i < num_params; i++) {
|
|
|
|
__raw_writel(*parameters, sram_scratch_space);
|
|
|
|
parameters++;
|
|
|
|
sram_scratch_space++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now make the PPA call */
|
|
|
|
do_omap3_emu_romcode_call(service_id, OMAP3_PUBLIC_SRAM_SCRATCH_AREA);
|
|
|
|
}
|
|
|
|
|
2015-03-09 22:12:09 +00:00
|
|
|
void __weak omap3_set_aux_cr_secure(u32 acr)
|
2011-06-16 23:30:53 +00:00
|
|
|
{
|
2015-03-09 22:12:09 +00:00
|
|
|
struct emu_hal_params emu_romcode_params;
|
|
|
|
|
|
|
|
emu_romcode_params.num_params = 1;
|
|
|
|
emu_romcode_params.param1 = acr;
|
|
|
|
omap3_emu_romcode_call(OMAP3_EMU_HAL_API_WRITE_ACR,
|
|
|
|
(u32 *)&emu_romcode_params);
|
2011-06-16 23:30:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 01:16:53 +00:00
|
|
|
void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr,
|
|
|
|
u32 cpu_rev_comb, u32 cpu_variant,
|
|
|
|
u32 cpu_rev)
|
|
|
|
{
|
|
|
|
if (get_device_type() == GP_DEVICE)
|
|
|
|
omap_smc1(OMAP3_GP_ROMCODE_API_WRITE_L2ACR, l2auxctrl);
|
|
|
|
|
|
|
|
/* L2 Cache Auxiliary Control Register is not banked */
|
|
|
|
}
|
|
|
|
|
2015-03-09 22:12:09 +00:00
|
|
|
void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb,
|
|
|
|
u32 cpu_variant, u32 cpu_rev)
|
2011-06-16 23:30:53 +00:00
|
|
|
{
|
2015-03-09 22:12:09 +00:00
|
|
|
/* Write ACR - affects secure banked bits */
|
|
|
|
if (get_device_type() == GP_DEVICE)
|
|
|
|
omap_smc1(OMAP3_GP_ROMCODE_API_WRITE_ACR, acr);
|
|
|
|
else
|
|
|
|
omap3_set_aux_cr_secure(acr);
|
2015-03-09 22:12:08 +00:00
|
|
|
|
2015-03-09 22:12:09 +00:00
|
|
|
/* Write ACR - affects non-secure banked bits - some erratas need it */
|
|
|
|
asm volatile ("mcr p15, 0, %0, c1, c0, 1" : : "r" (acr));
|
2011-06-16 23:30:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 22:12:09 +00:00
|
|
|
|
2011-06-16 23:30:53 +00:00
|
|
|
#ifndef CONFIG_SYS_L2CACHE_OFF
|
2012-10-31 05:23:28 +00:00
|
|
|
static void omap3_update_aux_cr(u32 set_bits, u32 clear_bits)
|
|
|
|
{
|
|
|
|
u32 acr;
|
|
|
|
|
|
|
|
/* Read ACR */
|
|
|
|
asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
|
|
|
|
acr &= ~clear_bits;
|
|
|
|
acr |= set_bits;
|
2015-03-09 22:12:09 +00:00
|
|
|
v7_arch_cp15_set_acr(acr, 0, 0, 0, 0);
|
2012-10-31 05:23:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-06-16 23:30:53 +00:00
|
|
|
/* Invalidate the entire L2 cache from secure mode */
|
|
|
|
static void omap3_invalidate_l2_cache_secure(void)
|
|
|
|
{
|
|
|
|
if (get_device_type() == GP_DEVICE) {
|
2015-03-09 22:12:05 +00:00
|
|
|
omap_smc1(OMAP3_GP_ROMCODE_API_L2_INVAL, 0);
|
2011-06-16 23:30:53 +00:00
|
|
|
} else {
|
|
|
|
struct emu_hal_params emu_romcode_params;
|
|
|
|
emu_romcode_params.num_params = 1;
|
|
|
|
emu_romcode_params.param1 = 0;
|
|
|
|
omap3_emu_romcode_call(OMAP3_EMU_HAL_API_L2_INVAL,
|
|
|
|
(u32 *)&emu_romcode_params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void v7_outer_cache_enable(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
2015-03-09 22:12:09 +00:00
|
|
|
* Set L2EN
|
2011-06-16 23:30:53 +00:00
|
|
|
* On some revisions L2EN bit is banked on some revisions it's not
|
|
|
|
* No harm in setting both banked bits(in fact this is required
|
|
|
|
* by an erratum)
|
|
|
|
*/
|
|
|
|
omap3_update_aux_cr(0x2, 0);
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:15 +00:00
|
|
|
void omap3_outer_cache_disable(void)
|
2011-06-16 23:30:53 +00:00
|
|
|
{
|
|
|
|
/*
|
2015-03-09 22:12:09 +00:00
|
|
|
* Clear L2EN
|
2011-06-16 23:30:53 +00:00
|
|
|
* On some revisions L2EN bit is banked on some revisions it's not
|
|
|
|
* No harm in clearing both banked bits(in fact this is required
|
|
|
|
* by an erratum)
|
|
|
|
*/
|
|
|
|
omap3_update_aux_cr(0, 0x2);
|
|
|
|
}
|
2012-11-13 07:57:54 +00:00
|
|
|
#endif /* !CONFIG_SYS_L2CACHE_OFF */
|