]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/pci/pci_rom.c
serial: ns16550: Fix build error due to a typo
[karo-tx-uboot.git] / drivers / pci / pci_rom.c
index 86f0e95cd5af5cf6fd89c566950c1f0dd13025e1..48c0a77fdd4e4e9bbd5ff6f1d3ff6fe8139d31d5 100644 (file)
@@ -81,7 +81,12 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 #ifdef CONFIG_X86_OPTION_ROM_ADDR
        rom_address = CONFIG_X86_OPTION_ROM_ADDR;
 #else
-       pci_write_config_dword(dev, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK);
+
+       if (pciauto_setup_rom(pci_bus_to_hose(PCI_BUS(dev)), dev)) {
+               debug("Cannot find option ROM\n");
+               return -ENOENT;
+       }
+
        pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_address);
        if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
                debug("%s: rom_address=%x\n", __func__, rom_address);
@@ -93,7 +98,7 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
                               rom_address | PCI_ROM_ADDRESS_ENABLE);
 #endif
        debug("Option ROM address %x\n", rom_address);
-       rom_header = (struct pci_rom_header *)rom_address;
+       rom_header = (struct pci_rom_header *)(unsigned long)rom_address;
 
        debug("PCI expansion ROM, signature %#04x, INIT size %#04x, data ptr %#04x\n",
              le16_to_cpu(rom_header->signature),
@@ -117,7 +122,7 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
            (vendev == mapped_vendev)) {
                printf("ID mismatch: vendor ID %04x, device ID %04x\n",
                       rom_vendor, rom_device);
-               return -EPERM;
+               /* Continue anyway */
        }
 
        debug("PCI ROM image, Class Code %04x%02x, Code Type %02x\n",
@@ -157,7 +162,13 @@ int pci_rom_load(uint16_t class, struct pci_rom_header *rom_header,
 
        rom_size = rom_header->size * 512;
 
+#ifdef PCI_VGA_RAM_IMAGE_START
        target = (void *)PCI_VGA_RAM_IMAGE_START;
+#else
+       target = (void *)malloc(rom_size);
+       if (!target)
+               return -ENOMEM;
+#endif
        if (target != rom_header) {
                ulong start = get_timer(0);
 
@@ -217,11 +228,12 @@ int vbe_get_video_info(struct graphic_device *gdev)
 #endif
 }
 
-int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
+int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
 {
        struct pci_rom_header *rom, *ram;
        int vesa_mode = -1;
        uint16_t class;
+       bool emulate;
        int ret;
 
        /* Only execute VGA ROMs */
@@ -251,6 +263,29 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
        vesa_mode = CONFIG_FRAMEBUFFER_VESA_MODE;
 #endif
        debug("Selected vesa mode %#x\n", vesa_mode);
+
+       if (exec_method & PCI_ROM_USE_NATIVE) {
+#ifdef CONFIG_X86
+               emulate = false;
+#else
+               if (!(exec_method & PCI_ROM_ALLOW_FALLBACK)) {
+                       printf("BIOS native execution is only available on x86\n");
+                       return -ENOSYS;
+               }
+               emulate = true;
+#endif
+       } else {
+#ifdef CONFIG_BIOSEMU
+               emulate = true;
+#else
+               if (!(exec_method & PCI_ROM_ALLOW_FALLBACK)) {
+                       printf("BIOS emulation not available - see CONFIG_BIOSEMU\n");
+                       return -ENOSYS;
+               }
+               emulate = false;
+#endif
+       }
+
        if (emulate) {
 #ifdef CONFIG_BIOSEMU
                BE_VGAInfo *info;
@@ -263,9 +298,6 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
                                  vesa_mode, &mode_info);
                if (ret)
                        return ret;
-#else
-               printf("BIOS emulation not available - see CONFIG_BIOSEMU\n");
-               return -ENOSYS;
 #endif
        } else {
 #ifdef CONFIG_X86
@@ -273,9 +305,6 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
 
                bios_run_on_x86(dev, (unsigned long)ram, vesa_mode,
                                &mode_info);
-#else
-               printf("BIOS native execution is only available on x86\n");
-               return -ENOSYS;
 #endif
        }
        debug("Final vesa mode %#x\n", mode_info.video_mode);