Jiaxun Yang | 6423e59 | 2020-05-26 17:21:16 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | #include <linux/pci.h> |
| 4 | #include <loongson.h> |
| 5 | |
Bjorn Helgaas | 66d28b2 | 2022-01-26 09:40:01 -0600 | [diff] [blame^] | 6 | static void pci_fixup_video(struct pci_dev *pdev) |
Jiaxun Yang | 6423e59 | 2020-05-26 17:21:16 +0800 | [diff] [blame] | 7 | { |
| 8 | struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; |
| 9 | |
| 10 | if (res->start) |
| 11 | return; |
| 12 | |
| 13 | if (!loongson_sysconf.vgabios_addr) |
| 14 | return; |
| 15 | |
| 16 | pci_disable_rom(pdev); |
| 17 | if (res->parent) |
| 18 | release_resource(res); |
| 19 | |
| 20 | res->start = virt_to_phys((void *) loongson_sysconf.vgabios_addr); |
| 21 | res->end = res->start + 256*1024 - 1; |
| 22 | res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW | |
| 23 | IORESOURCE_PCI_FIXED; |
| 24 | |
Bjorn Helgaas | 66d28b2 | 2022-01-26 09:40:01 -0600 | [diff] [blame^] | 25 | dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n", res); |
Jiaxun Yang | 6423e59 | 2020-05-26 17:21:16 +0800 | [diff] [blame] | 26 | } |
Bjorn Helgaas | 66d28b2 | 2022-01-26 09:40:01 -0600 | [diff] [blame^] | 27 | DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_ATI, 0x9615, |
| 28 | PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video); |