mtk_init.c 869 B

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