of_early_populate.h 930 B

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * COPYRIGHT(C) 2020-2021 Samsung Electronics Co., Ltd. All Right Reserved.
  4. */
  5. #ifndef __OF_EARLY_POPULATE_H__
  6. #define __OF_EARLY_POPULATE_H__
  7. /* FIXME: This is tricky! */
  8. /* NOTE: A helper function to enable the device before
  9. * 'of_platform_default_populate' is called.
  10. * The idea is inspired from 'of_platform_default_populate_init' that
  11. * this function calls a 'of_platform_device_create' before calling
  12. * 'of_platform_default_populate_init' to make some devices earlier.
  13. */
  14. static __always_inline int __of_platform_early_populate_init(
  15. const struct of_device_id *matches)
  16. {
  17. #if IS_BUILTIN(CONFIG_SEC_DEBUG)
  18. struct device_node *np;
  19. struct platform_device *pdev;
  20. np = of_find_matching_node(NULL, matches);
  21. if (!np)
  22. return -EINVAL;
  23. pdev = of_platform_device_create(np, NULL, NULL);
  24. if (!pdev)
  25. return -ENODEV;
  26. #endif
  27. return 0;
  28. }
  29. #endif /* __OF_EARLY_POPULATE_H__ */