Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions drivers/gop/gop.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <pci/pci.h>
#include <arch/io.h>
#include <hwconfig.h>
#include <ewlog.h>

#include "gop.h"

Expand Down Expand Up @@ -150,6 +151,8 @@ set_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *This,

gop->fb = get_framebuffer(gop->dev, gop->pipe);
set_efi_color_order(gop->dev);

ewdbg("set_mode fb = 0x%x", gop->fb);
return gop->fb ? EFI_SUCCESS : EFI_DEVICE_ERROR;
}

Expand Down Expand Up @@ -236,9 +239,7 @@ static struct supported_device {
u16 did;
} SUPPORTED_DEVICES[] ={
{ .vid = 0x8086, .did = VGA_PID },
{ .vid = 0x8086, .did = VGA_PID2 },
};

static EFI_STATUS gop_init(EFI_SYSTEM_TABLE *st)
{
static gop_t gop_default = {
Expand All @@ -251,6 +252,8 @@ static EFI_STATUS gop_init(EFI_SYSTEM_TABLE *st)
};
pcidev_t pci_dev = 0;
size_t i;
uint16_t command;
uint32_t mmio;

if (!st)
return EFI_INVALID_PARAMETER;
Expand All @@ -264,14 +267,36 @@ static EFI_STATUS gop_init(EFI_SYSTEM_TABLE *st)
&pci_dev))
break;

ewdbg("VGA pci_dev = %x", pci_dev);
if (!pci_dev)
return EFI_UNSUPPORTED;

mmio = pci_read_config32(pci_dev, 0x10);
ewdbg("VGA mmio BAR0 = %x", mmio);
if ((mmio & 0x6) == 0x4) {
/* Stop memory space access */
command = pci_read_config32(pci_dev, 0x4) & 0xffff;
command &= ~0x02;
pci_write_config32(pci_dev, 0x04, command);

/* Re-config PCI BAR from 64bits to 32bits */
pci_write_config32(pci_dev, 0x14, 0x0);
pci_write_config32(pci_dev, 0x10, PLAN_CTRL_ADDR);
pci_write_config32(pci_dev, 0x1c, 0x0);
pci_write_config32(pci_dev, 0x18, PLAN_FB_ADDR);

/* Restart memory space access */
command = pci_read_config32(pci_dev, 0x4) & 0xffff;
command |= 0x02;
pci_write_config32(pci_dev, 0x04, command);
}

gop_default.dev = pci_dev;
get_resolution(pci_dev, &info.HorizontalResolution,
&info.VerticalResolution,
&gop_default.pipe);

&info.VerticalResolution,
&gop_default.pipe);
ewdbg("HorizontalResolution = %u, VerticalResolution, = %u ", \
info.HorizontalResolution,info.VerticalResolution);
/* If the BIOS has not programmed any surface, silently
disable the Graphical Output Protocol. */
if (!info.HorizontalResolution || !info.VerticalResolution)
Expand Down
8 changes: 8 additions & 0 deletions drivers/gop/gop.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@

extern ewdrv_t gop_drv;

/* VGA compatible controller */
#define VGA_PID 0xa7a0
#define IGD_BUS_NUM 0
#define IGD_DEV_NUM 2
#define IGD_FUN_NUM 0
#define PLAN_FB_ADDR 0xB0000000
#define PLAN_CTRL_ADDR 0xA0000000

#endif /* _GOP_H_ */