Commit 13e81d45f80b58e57a78daf6850d4f3a6bc20d9e

Authored by Pavel Machek
Committed by Marek Vasut
1 parent 60d804c2f3

arm: socfpga: nic301: Add NIC-301 configuration code

Add code which configures the AMBA NIC-301 and the SCU on the SoCFPGA .
The code sets the access permissions for the CPU to the AMBA slaves such
that the CPU can access them in both secure and non-secure mode.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chin Liang See <clsee@altera.com>
Cc: Dinh Nguyen <dinguyen@altera.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Pavel Machek <pavel@denx.de>

Showing 1 changed file with 26 additions and 0 deletions Side-by-side Diff

arch/arm/cpu/armv7/socfpga/misc.c
... ... @@ -13,6 +13,7 @@
13 13 #include <asm/arch/system_manager.h>
14 14 #include <asm/arch/dwmmc.h>
15 15 #include <asm/arch/nic301.h>
  16 +#include <asm/arch/scu.h>
16 17 #include <asm/pl310.h>
17 18  
18 19 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -23,6 +24,8 @@
23 24 (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
24 25 static struct nic301_registers *nic301_regs =
25 26 (struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
  27 +static struct scu_registers *scu_regs =
  28 + (struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
26 29  
27 30 int dram_init(void)
28 31 {
29 32  
... ... @@ -146,8 +149,31 @@
146 149 return 0;
147 150 }
148 151  
  152 +/*
  153 + * Convert all NIC-301 AMBA slaves from secure to non-secure
  154 + */
  155 +static void socfpga_nic301_slave_ns(void)
  156 +{
  157 + writel(0x1, &nic301_regs->lwhps2fpgaregs);
  158 + writel(0x1, &nic301_regs->hps2fpgaregs);
  159 + writel(0x1, &nic301_regs->acp);
  160 + writel(0x1, &nic301_regs->rom);
  161 + writel(0x1, &nic301_regs->ocram);
  162 + writel(0x1, &nic301_regs->sdrdata);
  163 +}
  164 +
149 165 int misc_init_r(void)
150 166 {
  167 + socfpga_bridges_reset(1);
  168 + socfpga_nic301_slave_ns();
  169 +
  170 + /*
  171 + * Private components security:
  172 + * U-Boot : configure private timer, global timer and cpu component
  173 + * access as non secure for kernel stage (as required by Linux)
  174 + */
  175 + setbits_le32(&scu_regs->sacr, 0xfff);
  176 +
151 177 /* Configure the L2 controller to make SDRAM start at 0 */
152 178 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
153 179 writel(0x2, &nic301_regs->remap);