ARMv8/fsl-ppa: Consolidate PPA image stored-media flag for XIP
[oweals/u-boot.git] / arch / arm / cpu / armv8 / fsl-layerscape / ppa.c
1 /*
2  * Copyright 2016 NXP Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 #include <common.h>
7 #include <config.h>
8 #include <errno.h>
9 #include <asm/system.h>
10 #include <asm/types.h>
11 #include <asm/arch/soc.h>
12 #ifdef CONFIG_FSL_LSCH3
13 #include <asm/arch/immap_lsch3.h>
14 #elif defined(CONFIG_FSL_LSCH2)
15 #include <asm/arch/immap_lsch2.h>
16 #endif
17 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
18 #include <asm/armv8/sec_firmware.h>
19 #endif
20
21 int ppa_init(void)
22 {
23         const void *ppa_fit_addr;
24         u32 *boot_loc_ptr_l, *boot_loc_ptr_h;
25         int ret;
26
27 #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
28         ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
29 #else
30 #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined"
31 #endif
32
33 #ifdef CONFIG_FSL_LSCH3
34         struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
35         boot_loc_ptr_l = &gur->bootlocptrl;
36         boot_loc_ptr_h = &gur->bootlocptrh;
37 #elif defined(CONFIG_FSL_LSCH2)
38         struct ccsr_scfg __iomem *scfg = (void *)(CONFIG_SYS_FSL_SCFG_ADDR);
39         boot_loc_ptr_l = &scfg->scratchrw[1];
40         boot_loc_ptr_h = &scfg->scratchrw[0];
41 #endif
42
43         debug("fsl-ppa: boot_loc_ptr_l = 0x%p, boot_loc_ptr_h =0x%p\n",
44               boot_loc_ptr_l, boot_loc_ptr_h);
45         ret = sec_firmware_init(ppa_fit_addr, boot_loc_ptr_l, boot_loc_ptr_h);
46
47         return ret;
48 }