blob: 2289659269ea26513edf55ab2b8f8736bf13d686 [file] [log] [blame]
developer6d8e8f82022-06-20 10:25:35 +08001/*
2 * Copyright (c) 2022, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <common/debug.h>
8#include <lib/utils_def.h>
9#include <lib/mtk_init/mtk_init.h>
10
11INIT_CALL_TABLE(EXPAND_AS_EXTERN);
12extern struct initcall __MTK_PLAT_INITCALL_END__[];
13
14struct initcall *initcall_list[] = {
15 INIT_CALL_TABLE(EXPAND_AS_SYMBOL_ARR)
16 __MTK_PLAT_INITCALL_END__
17};
18
19void mtk_init_one_level(uint32_t level)
20{
21 const struct initcall *entry;
22 int error;
23
24 if (level >= MTK_INIT_LVL_MAX) {
25 ERROR("invalid level:%u\n", level);
26 panic();
27 }
28
29 INFO("init calling level:%u\n", level);
30 for (entry = initcall_list[level];
31 (entry != NULL) && (entry < initcall_list[level + 1]);
32 entry++) {
33 INFO("calling %s\n", entry->name);
34 error = entry->fn();
35 if (error != 0) {
36 ERROR("init %s fail, errno:%d\n", entry->name, error);
37 }
38 }
39}