]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/bios_emulator/atibios.c
Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / drivers / bios_emulator / atibios.c
index 084339c1b29af6c3b2f1c615aa307c7983414c13..3b2ed6e109b645359c0edb9e0fe0f1ddd0b7c507 100644 (file)
@@ -1,9 +1,9 @@
 /****************************************************************************
 *
-*                    Video BOOT Graphics Card POST Module
+*                   Video BOOT Graphics Card POST Module
 *
 *  ========================================================================
-*   Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+*   Copyright (C) 2007 Freescale Semiconductor, Inc.
 *   Jason Jin <Jason.jin@freescale.com>
 *
 *   Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
 *
 *  ========================================================================
 *
-* Language:     ANSI C
-* Environment:  Linux Kernel
-* Developer:    Kendall Bennett
+* Language:    ANSI C
+* Environment: Linux Kernel
+* Developer:   Kendall Bennett
 *
-* Description:  Module to implement booting PCI/AGP controllers on the
-*               bus. We use the x86 real mode emulator to run the BIOS on
-*               graphics controllers to bring the cards up.
+* Description: Module to implement booting PCI/AGP controllers on the
+*              bus. We use the x86 real mode emulator to run the BIOS on
+*              graphics controllers to bring the cards up.
 *
-*               Note that at present this module does *not* support
-*               multiple controllers.
+*              Note that at present this module does *not* support
+*              multiple controllers.
 *
-*               The orignal name of this file is warmboot.c.
-*               Jason ported this file to u-boot to run the ATI video card
-*               BIOS in u-boot.
+*              The orignal name of this file is warmboot.c.
+*              Jason ported this file to u-boot to run the ATI video card
+*              BIOS in u-boot.
 ****************************************************************************/
 #include <common.h>
-
-#ifdef CONFIG_BIOSEMU
-
 #include "biosemui.h"
 #include <malloc.h>
 
 /* Length of the BIOS image */
-#define MAX_BIOSLEN         (128 * 1024L)
-
-/* Define some useful types and macros */
-#define true                1
-#define false               0
+#define MAX_BIOSLEN        (128 * 1024L)
 
 /* Place to save PCI BAR's that we change and later restore */
 static u32 saveROMBaseAddress;
@@ -68,7 +61,7 @@ static u32 saveBaseAddress20;
 
 /****************************************************************************
 PARAMETERS:
-pcidev  - PCI device info for the video card on the bus to boot
+pcidev - PCI device info for the video card on the bus to boot
 VGAInfo - BIOS emulator VGA info structure
 
 REMARKS:
@@ -102,8 +95,8 @@ static void PCI_doBIOSPOST(pci_dev_t pcidev, BE_VGAInfo * VGAInfo)
 
 /****************************************************************************
 PARAMETERS:
-pcidev  - PCI device info for the video card on the bus
-bar     - Place to return the base address register offset to use
+pcidev - PCI device info for the video card on the bus
+bar    - Place to return the base address register offset to use
 
 RETURNS:
 The address to use to map the secondary BIOS (AGP devices)
@@ -166,7 +159,7 @@ static void PCI_fixupIObase(pci_dev_t pcidev, int reg, u32 * base)
 
 /****************************************************************************
 PARAMETERS:
-pcidev  - PCI device info for the video card on the bus
+pcidev - PCI device info for the video card on the bus
 
 RETURNS:
 Pointers to the mapped BIOS image
@@ -176,7 +169,7 @@ Maps a pointer to the BIOS image on the graphics card on the PCI bus.
 ****************************************************************************/
 void *PCI_mapBIOSImage(pci_dev_t pcidev)
 {
-       u32 BIOSImagePhys;
+       u32 BIOSImageBus;
        int BIOSImageBAR;
        u8 *BIOSImage;
 
@@ -196,18 +189,20 @@ void *PCI_mapBIOSImage(pci_dev_t pcidev)
        /* Some cards have problems that stop us from being able to read the
         BIOS image from the ROM BAR. To fix this we have to do some chipset
         specific programming for different cards to solve this problem.
-        */
+       */
 
-       if ((BIOSImagePhys = PCI_findBIOSAddr(pcidev, &BIOSImageBAR)) == 0) {
+       BIOSImageBus = PCI_findBIOSAddr(pcidev, &BIOSImageBAR);
+       if (BIOSImageBus == 0) {
                printf("Find bios addr error\n");
                return NULL;
        }
 
-       BIOSImage = (u8 *) BIOSImagePhys;
+       BIOSImage = pci_bus_to_virt(pcidev, BIOSImageBus,
+                                   PCI_REGION_MEM, 0, MAP_NOCACHE);
 
        /*Change the PCI BAR registers to map it onto the bus.*/
        pci_write_config_dword(pcidev, BIOSImageBAR, 0);
-       pci_write_config_dword(pcidev, PCI_ROM_ADDRESS, BIOSImagePhys | 0x1);
+       pci_write_config_dword(pcidev, PCI_ROM_ADDRESS, BIOSImageBus | 0x1);
 
        udelay(1);
 
@@ -223,7 +218,7 @@ void *PCI_mapBIOSImage(pci_dev_t pcidev)
 
 /****************************************************************************
 PARAMETERS:
-pcidev  - PCI device info for the video card on the bus
+pcidev - PCI device info for the video card on the bus
 
 REMARKS:
 Unmaps the BIOS image for the device and restores framebuffer mappings
@@ -239,11 +234,11 @@ void PCI_unmapBIOSImage(pci_dev_t pcidev, void *BIOSImage)
 
 /****************************************************************************
 PARAMETERS:
-pcidev  - PCI device info for the video card on the bus to boot
+pcidev - PCI device info for the video card on the bus to boot
 VGAInfo - BIOS emulator VGA info structure
 
 RETURNS:
-True if successfully initialised, false if not.
+true if successfully initialised, false if not.
 
 REMARKS:
 Loads and POST's the display controllers BIOS, directly from the BIOS
@@ -294,9 +289,9 @@ static int PCI_postController(pci_dev_t pcidev, BE_VGAInfo * VGAInfo)
 
 /****************************************************************************
 PARAMETERS:
-pcidev      - PCI device info for the video card on the bus to boot
+pcidev     - PCI device info for the video card on the bus to boot
 pVGAInfo    - Place to return VGA info structure is requested
-cleanUp     - True to clean up on exit, false to leave emulator active
+cleanUp            - true to clean up on exit, false to leave emulator active
 
 REMARKS:
 Boots the PCI/AGP video card on the bus using the Video ROM BIOS image
@@ -318,7 +313,8 @@ int BootVideoCardBIOS(pci_dev_t pcidev, BE_VGAInfo ** pVGAInfo, int cleanUp)
        BE_init(0, 65536, VGAInfo, 0);
 
        /*Post all the display controller BIOS'es*/
-       PCI_postController(pcidev, VGAInfo);
+       if (!PCI_postController(pcidev, VGAInfo))
+               return false;
 
        /*Cleanup and exit the emulator if requested. If the BIOS emulator
        is needed after booting the card, we will not call BE_exit and
@@ -336,5 +332,3 @@ int BootVideoCardBIOS(pci_dev_t pcidev, BE_VGAInfo ** pVGAInfo, int cleanUp)
                *pVGAInfo = VGAInfo;
        return true;
 }
-
-#endif