coreboot.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <asm/cb_sysinfo.h>
  7. #include <asm/global_data.h>
  8. #include <init.h>
  9. #include <smbios.h>
  10. int board_early_init_r(void)
  11. {
  12. /*
  13. * Make sure PCI bus is enumerated so that peripherals on the PCI bus
  14. * can be discovered by their drivers
  15. */
  16. pci_init();
  17. return 0;
  18. }
  19. #ifdef CONFIG_SMBIOS_PARSER
  20. int show_board_info(void)
  21. {
  22. const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size);
  23. if (!smbios)
  24. goto fallback;
  25. const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION);
  26. const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION);
  27. const struct smbios_type0 *t0 = (struct smbios_type0 *)bios;
  28. const struct smbios_type1 *t1 = (struct smbios_type1 *)system;
  29. if (!t0 || !t1)
  30. goto fallback;
  31. const char *bios_ver = smbios_string(bios, t0->bios_ver);
  32. const char *bios_date = smbios_string(bios, t0->bios_release_date);
  33. const char *model = smbios_string(system, t1->product_name);
  34. const char *manufacturer = smbios_string(system, t1->manufacturer);
  35. if (!model || !manufacturer || !bios_ver)
  36. goto fallback;
  37. printf("Vendor: %s\n", manufacturer);
  38. printf("Model: %s\n", model);
  39. printf("BIOS Version: %s\n", bios_ver);
  40. if (bios_date)
  41. printf("BIOS date: %s\n", bios_date);
  42. return 0;
  43. fallback:
  44. #ifdef CONFIG_OF_CONTROL
  45. DECLARE_GLOBAL_DATA_PTR;
  46. model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
  47. if (model)
  48. printf("Model: %s\n", model);
  49. #endif
  50. return checkboard();
  51. }
  52. #endif