2 * coreboot Framebuffer driver.
4 * Copyright (C) 2011 The Chromium OS authors
6 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/tables.h>
11 #include <asm/arch/sysinfo.h>
13 #include "videomodes.h"
20 static int parse_coreboot_table_fb(GraphicDevice *gdev)
22 struct cb_framebuffer *fb = lib_sysinfo.framebuffer;
24 /* If there is no framebuffer structure, bail out and keep
25 * running on the serial console.
30 gdev->winSizeX = fb->x_resolution;
31 gdev->winSizeY = fb->y_resolution;
33 gdev->plnSizeX = fb->x_resolution;
34 gdev->plnSizeY = fb->y_resolution;
36 gdev->gdfBytesPP = fb->bits_per_pixel / 8;
38 switch (fb->bits_per_pixel) {
40 gdev->gdfIndex = GDF_32BIT_X888RGB;
43 gdev->gdfIndex = GDF_16BIT_565RGB;
46 gdev->gdfIndex = GDF__8BIT_INDEX;
50 gdev->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
51 gdev->pciBase = (unsigned int)fb->physical_address;
53 gdev->frameAdrs = (unsigned int)fb->physical_address;
54 gdev->memSize = fb->bytes_per_line * fb->y_resolution;
56 gdev->vprBase = (unsigned int)fb->physical_address;
57 gdev->cprBase = (unsigned int)fb->physical_address;
62 void *video_hw_init(void)
64 GraphicDevice *gdev = &ctfb;
69 if (!parse_coreboot_table_fb(gdev)) {
70 printf("No video mode configured in coreboot!\n");
74 bits_per_pixel = gdev->gdfBytesPP * 8;
76 /* fill in Graphic device struct */
77 sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
79 printf("%s\n", gdev->modeIdent);
81 memset((void *)gdev->pciBase, 0,
82 gdev->winSizeX * gdev->winSizeY * gdev->gdfBytesPP);