2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-08-16 05:41:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2020-09-22 18:45:03 +00:00
|
|
|
#define LOG_CATEGORY UCLASS_VIDEO
|
|
|
|
|
2017-08-16 05:41:56 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2017-08-16 05:41:56 +00:00
|
|
|
#include <vbe.h>
|
|
|
|
#include <video.h>
|
2020-09-22 18:45:03 +00:00
|
|
|
#include <acpi/acpi_table.h>
|
2019-12-07 04:42:16 +00:00
|
|
|
#include <asm/fsp/fsp_support.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-09-22 18:45:03 +00:00
|
|
|
#include <asm/intel_opregion.h>
|
2019-12-07 04:42:19 +00:00
|
|
|
#include <asm/mtrr.h>
|
2020-09-22 18:45:03 +00:00
|
|
|
#include <dm/acpi.h>
|
2017-08-16 05:41:56 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
struct pixel {
|
|
|
|
u8 pos;
|
|
|
|
u8 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fsp_framebuffer {
|
|
|
|
struct pixel red;
|
|
|
|
struct pixel green;
|
|
|
|
struct pixel blue;
|
|
|
|
struct pixel rsvd;
|
|
|
|
} fsp_framebuffer_format_map[] = {
|
|
|
|
[pixel_rgbx_8bpc] = { {0, 8}, {8, 8}, {16, 8}, {24, 8} },
|
|
|
|
[pixel_bgrx_8bpc] = { {16, 8}, {8, 8}, {0, 8}, {24, 8} },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int save_vesa_mode(struct vesa_mode_info *vesa)
|
|
|
|
{
|
|
|
|
const struct hob_graphics_info *ginfo;
|
|
|
|
const struct fsp_framebuffer *fbinfo;
|
|
|
|
|
|
|
|
ginfo = fsp_get_graphics_info(gd->arch.hob_list, NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there is no graphics info structure, bail out and keep
|
|
|
|
* running on the serial console.
|
2017-10-19 01:20:59 +00:00
|
|
|
*
|
|
|
|
* Note: on some platforms (eg: Braswell), the FSP will not produce
|
|
|
|
* the graphics info HOB unless you plug some cables to the display
|
|
|
|
* interface (eg: HDMI) on the board.
|
2017-08-16 05:41:56 +00:00
|
|
|
*/
|
|
|
|
if (!ginfo) {
|
|
|
|
debug("FSP graphics hand-off block not found\n");
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
vesa->x_resolution = ginfo->width;
|
|
|
|
vesa->y_resolution = ginfo->height;
|
|
|
|
vesa->bits_per_pixel = 32;
|
|
|
|
vesa->bytes_per_scanline = ginfo->pixels_per_scanline * 4;
|
|
|
|
vesa->phys_base_ptr = ginfo->fb_base;
|
|
|
|
|
|
|
|
if (ginfo->pixel_format >= pixel_bitmask) {
|
|
|
|
debug("FSP set unknown framebuffer format: %d\n",
|
|
|
|
ginfo->pixel_format);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
fbinfo = &fsp_framebuffer_format_map[ginfo->pixel_format];
|
|
|
|
vesa->red_mask_size = fbinfo->red.size;
|
|
|
|
vesa->red_mask_pos = fbinfo->red.pos;
|
|
|
|
vesa->green_mask_size = fbinfo->green.size;
|
|
|
|
vesa->green_mask_pos = fbinfo->green.pos;
|
|
|
|
vesa->blue_mask_size = fbinfo->blue.size;
|
|
|
|
vesa->blue_mask_pos = fbinfo->blue.pos;
|
|
|
|
vesa->reserved_mask_size = fbinfo->rsvd.size;
|
|
|
|
vesa->reserved_mask_pos = fbinfo->rsvd.pos;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsp_video_probe(struct udevice *dev)
|
|
|
|
{
|
2020-12-03 23:55:23 +00:00
|
|
|
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
2017-08-16 05:41:56 +00:00
|
|
|
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
|
|
|
struct vesa_mode_info *vesa = &mode_info.vesa;
|
|
|
|
int ret;
|
|
|
|
|
2020-04-26 15:12:53 +00:00
|
|
|
if (!ll_boot_init())
|
2021-03-15 05:00:28 +00:00
|
|
|
return -ENODEV;
|
2020-04-26 15:12:53 +00:00
|
|
|
|
2017-08-16 05:41:56 +00:00
|
|
|
printf("Video: ");
|
|
|
|
|
|
|
|
/* Initialize vesa_mode_info structure */
|
|
|
|
ret = save_vesa_mode(vesa);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The framebuffer base address in the FSP graphics info HOB reflects
|
|
|
|
* the value assigned by the FSP. After PCI enumeration the framebuffer
|
|
|
|
* base address may be relocated. Let's get the updated one from device.
|
|
|
|
*
|
|
|
|
* For IGD, it seems to be always on BAR2.
|
|
|
|
*/
|
|
|
|
vesa->phys_base_ptr = dm_pci_read_bar32(dev, 2);
|
2020-05-10 20:17:02 +00:00
|
|
|
gd->fb_base = vesa->phys_base_ptr;
|
2017-08-16 05:41:56 +00:00
|
|
|
|
|
|
|
ret = vbe_setup_video_priv(vesa, uc_priv, plat);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
2019-12-07 04:42:19 +00:00
|
|
|
mtrr_add_request(MTRR_TYPE_WRCOMB, vesa->phys_base_ptr, 256 << 20);
|
|
|
|
mtrr_commit(true);
|
|
|
|
|
2020-05-10 20:17:02 +00:00
|
|
|
printf("%dx%dx%d @ %x\n", uc_priv->xsize, uc_priv->ysize,
|
|
|
|
vesa->bits_per_pixel, vesa->phys_base_ptr);
|
2017-08-16 05:41:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
printf("No video mode configured in FSP!\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-07-03 03:12:31 +00:00
|
|
|
static int fsp_video_bind(struct udevice *dev)
|
|
|
|
{
|
2020-12-03 23:55:23 +00:00
|
|
|
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
2020-07-03 03:12:31 +00:00
|
|
|
|
|
|
|
/* Set the maximum supported resolution */
|
|
|
|
plat->size = 2560 * 1600 * 4;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-22 18:45:03 +00:00
|
|
|
#ifdef CONFIG_INTEL_GMA_ACPI
|
|
|
|
static int fsp_video_acpi_write_tables(const struct udevice *dev,
|
|
|
|
struct acpi_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct igd_opregion *opregion;
|
|
|
|
int ret;
|
|
|
|
|
2020-11-04 16:57:39 +00:00
|
|
|
log_debug("ACPI: * IGD OpRegion\n");
|
2020-09-22 18:45:03 +00:00
|
|
|
opregion = (struct igd_opregion *)ctx->current;
|
|
|
|
|
|
|
|
ret = intel_gma_init_igd_opregion((struct udevice *)dev, opregion);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
acpi_inc_align(ctx, sizeof(struct igd_opregion));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct acpi_ops fsp_video_acpi_ops = {
|
|
|
|
#ifdef CONFIG_INTEL_GMA_ACPI
|
|
|
|
.write_tables = fsp_video_acpi_write_tables,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2017-08-16 05:41:56 +00:00
|
|
|
static const struct udevice_id fsp_video_ids[] = {
|
|
|
|
{ .compatible = "fsp-fb" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(fsp_video) = {
|
|
|
|
.name = "fsp_video",
|
|
|
|
.id = UCLASS_VIDEO,
|
|
|
|
.of_match = fsp_video_ids,
|
2020-07-03 03:12:31 +00:00
|
|
|
.bind = fsp_video_bind,
|
2017-08-16 05:41:56 +00:00
|
|
|
.probe = fsp_video_probe,
|
2020-07-03 03:12:31 +00:00
|
|
|
.flags = DM_FLAG_PRE_RELOC,
|
2020-09-22 18:45:03 +00:00
|
|
|
ACPI_OPS_PTR(&fsp_video_acpi_ops)
|
2017-08-16 05:41:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_device_id fsp_video_supported[] = {
|
|
|
|
{ PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, 0xffff00) },
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_PCI_DEVICE(fsp_video, fsp_video_supported);
|