MrRockchip

shitpatch1

Jun 25th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. diff --git a/src/device/Kconfig b/src/device/Kconfig
  2. index a5e00aa331..22a2f773fd 100644
  3. --- a/src/device/Kconfig
  4. +++ b/src/device/Kconfig
  5. @@ -65,6 +65,23 @@ config MAINBOARD_HAS_EARLY_LIBGFXINIT
  6. stage) support of `libgfxinit`. Usually this requires a list
  7. of ports to be probed for displays.
  8.  
  9. +config MAINBOARD_VERSION_HAS_AMD_DGPU_WITHOUT_EEPROM
  10. + def_bool n
  11. + help
  12. + Selected by mainboards that have a version with the onboard AMD
  13. + discrete GPU without its own EEPROM storage for VGA Option ROM.
  14. +
  15. +config AMD_DGPU_WITHOUT_EEPROM
  16. + def_bool n
  17. + prompt "AMD discrete GPU without EEPROM"
  18. + depends on MAINBOARD_VERSION_HAS_AMD_DGPU_WITHOUT_EEPROM
  19. + help
  20. + Some platforms like Lenovo G505S have the motherboard versions
  21. + with the onboard AMD discrete GPU without its own dedicated EEPROM
  22. + storage for VGA Option ROM. For such a discrete GPU to be usable
  23. + with coreboot, the PCI init of GPUs has to be done differently.
  24. + Enable this option if your motherboard has such a discrete GPU.
  25. +
  26. choice
  27. prompt "Graphics initialization"
  28. default NO_GFX_INIT if VGA_ROM_RUN_DEFAULT && PAYLOAD_SEABIOS
  29. diff --git a/src/device/pci_device.c b/src/device/pci_device.c
  30. index a3ddcdcc9e..69dbb4b3a6 100644
  31. --- a/src/device/pci_device.c
  32. +++ b/src/device/pci_device.c
  33. @@ -860,6 +860,10 @@ static int should_run_oprom(struct device *dev, struct rom_header *rom)
  34. if (should_run >= 0)
  35. return should_run;
  36.  
  37. + if (CONFIG(AMD_DGPU_WITHOUT_EEPROM) &&
  38. + ((dev->class >> 8) == PCI_CLASS_DISPLAY_OTHER))
  39. + return 0;
  40. +
  41. if (CONFIG(ALWAYS_RUN_OPROM)) {
  42. should_run = 1;
  43. return should_run;
  44. @@ -881,8 +885,13 @@ static int should_load_oprom(struct device *dev)
  45. * ROMs when coming out of an S3 resume.
  46. */
  47. if (!CONFIG(S3_VGA_ROM_RUN) && acpi_is_wakeup_s3() &&
  48. - ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA))
  49. + (((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA) ||
  50. + (CONFIG(AMD_DGPU_WITHOUT_EEPROM) &&
  51. + ((dev->class >> 8) == PCI_CLASS_DISPLAY_OTHER))))
  52. return 0;
  53. + if (CONFIG(AMD_DGPU_WITHOUT_EEPROM) &&
  54. + ((dev->class >> 8) == PCI_CLASS_DISPLAY_OTHER))
  55. + return 1;
  56. if (CONFIG(ALWAYS_LOAD_OPROM))
  57. return 1;
  58. if (should_run_oprom(dev, NULL))
  59. @@ -905,8 +914,10 @@ void pci_dev_init(struct device *dev)
  60. if (!CONFIG(VGA_ROM_RUN))
  61. return;
  62.  
  63. - /* Only execute VGA ROMs. */
  64. - if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA))
  65. + /* Only process VGA ROMs. */
  66. + if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) &&
  67. + (!CONFIG(AMD_DGPU_WITHOUT_EEPROM) ||
  68. + ((dev->class >> 8) != PCI_CLASS_DISPLAY_OTHER)))
  69. return;
  70.  
  71. if (!should_load_oprom(dev))
  72. @@ -914,12 +925,20 @@ void pci_dev_init(struct device *dev)
  73. timestamp_add_now(TS_OPROM_INITIALIZE);
  74.  
  75. rom = pci_rom_probe(dev);
  76. - if (rom == NULL)
  77. + if (rom == NULL) {
  78. + printk(BIOS_DEBUG, "PCI_CLASS_DISPLAY_%s%s ROM probe failed\n",
  79. + (dev->class >> 8) == PCI_CLASS_DISPLAY_VGA ? "VGA" : "",
  80. + (dev->class >> 8) == PCI_CLASS_DISPLAY_OTHER ? "OTHER" : "");
  81. return;
  82. + }
  83.  
  84. ram = pci_rom_load(dev, rom);
  85. - if (ram == NULL)
  86. + if (ram == NULL) {
  87. + printk(BIOS_DEBUG, "PCI_CLASS_DISPLAY_%s%s ROM load failed\n",
  88. + (dev->class >> 8) == PCI_CLASS_DISPLAY_VGA ? "VGA" : "",
  89. + (dev->class >> 8) == PCI_CLASS_DISPLAY_OTHER ? "OTHER" : "");
  90. return;
  91. + }
  92. timestamp_add_now(TS_OPROM_COPY_END);
  93.  
  94. if (!should_run_oprom(dev, rom))
  95. diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c
  96. index bc693fb764..3d36b561d3 100644
  97. --- a/src/device/pci_rom.c
  98. +++ b/src/device/pci_rom.c
  99. @@ -232,6 +232,12 @@ pci_rom_write_acpi_tables(const struct device *device, unsigned long current,
  100. if ((device->class >> 16) != PCI_BASE_CLASS_DISPLAY)
  101. return current;
  102.  
  103. + /* Write ACPI VFCT only for Discrete VGA. */
  104. + /* TODO: do this also for Integrated VGA. */
  105. + if (CONFIG(AMD_DGPU_WITHOUT_EEPROM) &&
  106. + ((device->class >> 8) == PCI_CLASS_DISPLAY_VGA))
  107. + return current;
  108. +
  109. /* Only handle enabled devices */
  110. if (!device->enabled)
  111. return current;
  112. diff --git a/src/mainboard/lenovo/g505s/Kconfig b/src/mainboard/lenovo/g505s/Kconfig
  113. index dbf8b68253..5576f6af9b 100644
  114. --- a/src/mainboard/lenovo/g505s/Kconfig
  115. +++ b/src/mainboard/lenovo/g505s/Kconfig
  116. @@ -16,6 +16,7 @@ config BOARD_SPECIFIC_OPTIONS
  117. select HAVE_ACPI_TABLES
  118. select BOARD_ROMSIZE_KB_4096
  119. select GFXUMA
  120. + select MAINBOARD_VERSION_HAS_AMD_DGPU_WITHOUT_EEPROM
  121. select NO_UART_ON_SUPERIO
  122.  
  123. config MAINBOARD_DIR
  124. diff --git a/src/mainboard/lenovo/g505s/devicetree.cb b/src/mainboard/lenovo/g505s/devicetree.cb
  125. index 4b4df367b1..6d7d3e526f 100644
  126. --- a/src/mainboard/lenovo/g505s/devicetree.cb
  127. +++ b/src/mainboard/lenovo/g505s/devicetree.cb
  128. @@ -15,7 +15,7 @@ chip northbridge/amd/agesa/family15tn/root_complex
  129. device pci 0.2 on end # IOMMU
  130. device pci 1.0 on end # Internal Graphics P2P bridge 0x99XX
  131. device pci 1.1 on end # Internal Multimedia
  132. - device pci 2.0 off end
  133. + device pci 2.0 on end # Discrete Graphics PCI bus 0x666X
  134. device pci 3.0 off end
  135. device pci 4.0 on end # PCIE MINI0
  136. device pci 5.0 on end # PCIE MINI1
Advertisement
Add Comment
Please, Sign In to add comment