board_info.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 = uclass_first_device_err(UCLASS_SYSINFO, &dev);
  30. if (!ret)
  31. ret = sysinfo_get_str(dev,
  32. SYSINFO_ID_BOARD_MODEL,
  33. sizeof(str), str);
  34. }
  35. /* Fail back to the main 'model' if available */
  36. if (ret)
  37. model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
  38. else
  39. model = str;
  40. if (model)
  41. printf("Model: %s\n", model);
  42. }
  43. return checkboard();
  44. }