2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-10-09 11:14:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2021-03-15 05:00:27 +00:00
|
|
|
#include <init.h>
|
2022-07-30 21:52:04 +00:00
|
|
|
#include <vesa.h>
|
2016-10-09 11:14:16 +00:00
|
|
|
#include <video.h>
|
2021-03-15 05:00:18 +00:00
|
|
|
#include <asm/cb_sysinfo.h>
|
2016-10-09 11:14:16 +00:00
|
|
|
|
|
|
|
static int save_vesa_mode(struct cb_framebuffer *fb,
|
|
|
|
struct vesa_mode_info *vesa)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If there is no framebuffer structure, bail out and keep
|
|
|
|
* running on the serial console.
|
|
|
|
*/
|
|
|
|
if (!fb)
|
2021-03-15 05:00:27 +00:00
|
|
|
return log_msg_ret("save", -ENXIO);
|
2016-10-09 11:14:16 +00:00
|
|
|
|
|
|
|
vesa->x_resolution = fb->x_resolution;
|
|
|
|
vesa->y_resolution = fb->y_resolution;
|
|
|
|
vesa->bits_per_pixel = fb->bits_per_pixel;
|
|
|
|
vesa->bytes_per_scanline = fb->bytes_per_line;
|
|
|
|
vesa->phys_base_ptr = fb->physical_address;
|
|
|
|
vesa->red_mask_size = fb->red_mask_size;
|
|
|
|
vesa->red_mask_pos = fb->red_mask_pos;
|
|
|
|
vesa->green_mask_size = fb->green_mask_size;
|
|
|
|
vesa->green_mask_pos = fb->green_mask_pos;
|
|
|
|
vesa->blue_mask_size = fb->blue_mask_size;
|
|
|
|
vesa->blue_mask_pos = fb->blue_mask_pos;
|
|
|
|
vesa->reserved_mask_size = fb->reserved_mask_size;
|
|
|
|
vesa->reserved_mask_pos = fb->reserved_mask_pos;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int coreboot_video_probe(struct udevice *dev)
|
|
|
|
{
|
2020-12-03 23:55:23 +00:00
|
|
|
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
2016-10-09 11:14:16 +00:00
|
|
|
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
|
|
|
struct cb_framebuffer *fb = lib_sysinfo.framebuffer;
|
|
|
|
struct vesa_mode_info *vesa = &mode_info.vesa;
|
|
|
|
int ret;
|
|
|
|
|
2021-03-15 05:00:27 +00:00
|
|
|
if (ll_boot_init())
|
|
|
|
return log_msg_ret("ll", -ENODEV);
|
|
|
|
|
2016-10-09 11:14:16 +00:00
|
|
|
printf("Video: ");
|
|
|
|
|
|
|
|
/* Initialize vesa_mode_info structure */
|
|
|
|
ret = save_vesa_mode(fb, vesa);
|
2021-03-15 05:00:27 +00:00
|
|
|
if (ret) {
|
|
|
|
ret = log_msg_ret("save", ret);
|
2016-10-09 11:14:16 +00:00
|
|
|
goto err;
|
2021-03-15 05:00:27 +00:00
|
|
|
}
|
2016-10-09 11:14:16 +00:00
|
|
|
|
2023-03-10 20:47:13 +00:00
|
|
|
ret = vesa_setup_video_priv(vesa, vesa->phys_base_ptr, uc_priv, plat);
|
2021-03-15 05:00:27 +00:00
|
|
|
if (ret) {
|
|
|
|
ret = log_msg_ret("setup", ret);
|
2016-10-09 11:14:16 +00:00
|
|
|
goto err;
|
2021-03-15 05:00:27 +00:00
|
|
|
}
|
2016-10-09 11:14:16 +00:00
|
|
|
|
|
|
|
printf("%dx%dx%d\n", uc_priv->xsize, uc_priv->ysize,
|
|
|
|
vesa->bits_per_pixel);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2021-03-15 05:00:27 +00:00
|
|
|
printf("No video mode configured in coreboot (err=%d)\n", ret);
|
2016-10-09 11:14:16 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-09-20 03:00:11 +00:00
|
|
|
static int coreboot_video_bind(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
|
|
|
|
|
|
|
|
/* Set the maximum supported resolution */
|
|
|
|
uc_plat->size = 4096 * 2160 * 4;
|
|
|
|
log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-09 11:14:16 +00:00
|
|
|
static const struct udevice_id coreboot_video_ids[] = {
|
|
|
|
{ .compatible = "coreboot-fb" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(coreboot_video) = {
|
|
|
|
.name = "coreboot_video",
|
|
|
|
.id = UCLASS_VIDEO,
|
|
|
|
.of_match = coreboot_video_ids,
|
2023-09-20 03:00:11 +00:00
|
|
|
.bind = coreboot_video_bind,
|
2016-10-09 11:14:16 +00:00
|
|
|
.probe = coreboot_video_probe,
|
|
|
|
};
|