board_info.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: GPL-2.0+
  2. #include <common.h>
  3. #include <dm.h>
  4. #include <init.h>
  5. #include <sysinfo.h>
  6. #include <asm/global_data.h>
  7. #include <linux/libfdt.h>
  8. #include <linux/compiler.h>
  9. DECLARE_GLOBAL_DATA_PTR;
  10. int __weak checkboard(void)
  11. {
  12. return 0;
  13. }
  14. /*
  15. * Check sysinfo for board information. Failing that if the root node of the DTB
  16. * has a "model" property, show it.
  17. *
  18. * Then call checkboard().
  19. */
  20. int __weak show_board_info(void)
  21. {
  22. if (IS_ENABLED(CONFIG_OF_CONTROL)) {
  23. struct udevice *dev;
  24. const char *model;
  25. char str[80];
  26. int ret = -ENOSYS;
  27. if (IS_ENABLED(CONFIG_SYSINFO)) {
  28. /* This might provide more detail */
  29. ret = sysinfo_get(&dev);
  30. if (!ret) {
  31. ret = sysinfo_detect(dev);
  32. if (!ret) {
  33. ret = sysinfo_get_str(dev,
  34. SYSINFO_ID_BOARD_MODEL,
  35. sizeof(str), str);
  36. }
  37. }
  38. }
  39. /* Fail back to the main 'model' if available */
  40. if (ret)
  41. model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
  42. else
  43. model = str;
  44. if (model)
  45. printf("Model: %s\n", model);
  46. }
  47. return checkboard();
  48. }