util.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2013 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dm/util.h>
  8. #include <libfdt.h>
  9. #include <vsprintf.h>
  10. #ifdef CONFIG_DM_WARN
  11. void dm_warn(const char *fmt, ...)
  12. {
  13. va_list args;
  14. va_start(args, fmt);
  15. vprintf(fmt, args);
  16. va_end(args);
  17. }
  18. #endif
  19. #ifdef DEBUG
  20. void dm_dbg(const char *fmt, ...)
  21. {
  22. va_list args;
  23. va_start(args, fmt);
  24. vprintf(fmt, args);
  25. va_end(args);
  26. }
  27. #endif
  28. int list_count_items(struct list_head *head)
  29. {
  30. struct list_head *node;
  31. int count = 0;
  32. list_for_each(node, head)
  33. count++;
  34. return count;
  35. }
  36. bool dm_fdt_pre_reloc(const void *blob, int offset)
  37. {
  38. if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
  39. return true;
  40. #ifdef CONFIG_TPL_BUILD
  41. if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
  42. return true;
  43. #elif defined(CONFIG_SPL_BUILD)
  44. if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
  45. return true;
  46. #else
  47. /*
  48. * In regular builds individual spl and tpl handling both
  49. * count as handled pre-relocation for later second init.
  50. */
  51. if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) ||
  52. fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
  53. return true;
  54. #endif
  55. return false;
  56. }