1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <arch/cache.h>
4 #include <device/mmio.h>
6 #include <console/console.h>
8 #include <program_loading.h>
10 #include <soc/soc_services.h>
12 #include "mbn_header.h"
15 uint32_t size
; /* size of the whole table */
16 uint8_t *cdt_ptr
; /* pointer to CDT */
19 static void *load_ipq_blob(const char *file_name
)
21 struct mbn_header
*blob_mbn
;
25 blob_mbn
= cbfs_map(file_name
, &blob_size
);
29 /* some sanity checks on the headers */
30 if ((blob_mbn
->mbn_version
!= 3) ||
31 (blob_mbn
->mbn_total_size
> blob_size
))
34 blob_dest
= (void *)blob_mbn
->mbn_destination
;
36 if (blob_mbn
->mbn_destination
) {
37 /* Copy the blob to the appropriate memory location. */
38 memcpy(blob_dest
, blob_mbn
+ 1, blob_mbn
->mbn_total_size
);
39 cache_sync_instructions();
46 #define DDR_VERSION() ((const char *)"private build")
47 #define MAX_DDR_VERSION_SIZE 48
50 uint64_t entry_point
; /* Write only for Core Boot */
52 } sys_debug_qsee_info_type_t
;
55 sys_debug_qsee_info_type_t
*qsee_info
;
56 uint64_t sdi_entry
; /* Read only for Core Boot */
59 sbl_rw_ret_info_t
*sbl_rw_ret_info
;
61 int initialize_dram(void)
63 struct mbn_header
*cdt
;
64 struct cdt_info cdt_header
;
67 * FIXME: Hard coding the address. Have to somehow get it
70 void *tzbsp
= (uint8_t *)0x87e80000;
72 sbl_rw_ret_info_t (*(*ddr_init_function
)(struct cdt_info
*cdt_header
));
74 cdt
= load_ipq_blob(CONFIG_CDT_MBN
);
75 ddr_init_function
= load_ipq_blob(CONFIG_DDR_MBN
);
77 if (!cdt
|| !ddr_init_function
) {
78 printk(BIOS_ERR
, "cdt: %p, ddr_init_function: %p\n",
79 cdt
, ddr_init_function
);
80 die("could not find DDR initialization blobs\n");
83 cdt_header
.size
= cdt
->mbn_total_size
;
84 cdt_header
.cdt_ptr
= (uint8_t *)(cdt
+ 1);
86 sbl_rw_ret_info
= ddr_init_function(&cdt_header
);
87 if (sbl_rw_ret_info
== NULL
)
88 die("Fail to Initialize DDR\n");
91 * Once DDR initializer finished, its version can be found at a fixed
94 printk(BIOS_INFO
, "DDR version %.*s initialized\n",
95 MAX_DDR_VERSION_SIZE
, DDR_VERSION());
97 printk(BIOS_INFO
, "SDI Entry: 0x%llx\n", sbl_rw_ret_info
->sdi_entry
);
98 sw_entry
= read32(TCSR_RESET_DEBUG_SW_ENTRY
) & 0x1;
99 sw_entry
|= (sbl_rw_ret_info
->sdi_entry
& ~0x1);
100 write32(TCSR_RESET_DEBUG_SW_ENTRY
, sw_entry
);
101 sbl_rw_ret_info
->qsee_info
->entry_point
= (uint32_t)tzbsp
;
106 void start_tzbsp(void)
108 void *tzbsp
= load_ipq_blob(CONFIG_TZ_MBN
);
111 die("could not find or map TZBSP\n");
113 printk(BIOS_INFO
, "Starting TZBSP\n");
115 tz_init_wrapper(0, 0, tzbsp
);