blob: e96f6747a6f6e00017857a06da1a150d00caccb7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Meng2c9bb7a2016-10-09 04:14:11 -07002/*
3 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
Bin Meng2c9bb7a2016-10-09 04:14:11 -07004 */
5
Bin Meng2c9bb7a2016-10-09 04:14:11 -07006#include <dm.h>
Simon Glass0fc300a2020-07-02 21:12:36 -06007#include <log.h>
Bin Meng2c9bb7a2016-10-09 04:14:11 -07008#include <pci.h>
Simon Glassec86bc62022-07-30 15:52:04 -06009#include <vesa.h>
Simon Glass0fc300a2020-07-02 21:12:36 -060010#include <video.h>
Yuri Zaporozhetsa560ab62024-10-30 14:17:33 +010011#if defined(CONFIG_X86)
Simon Glass0fc300a2020-07-02 21:12:36 -060012#include <asm/mtrr.h>
Yuri Zaporozhetsa560ab62024-10-30 14:17:33 +010013#endif
Bin Meng2c9bb7a2016-10-09 04:14:11 -070014
15static int vesa_video_probe(struct udevice *dev)
16{
Simon Glass0fc300a2020-07-02 21:12:36 -060017 int ret;
18
Simon Glass5b925202022-07-30 15:52:05 -060019 ret = vesa_setup_video(dev, NULL);
Simon Glass0fc300a2020-07-02 21:12:36 -060020 if (ret)
21 return log_ret(ret);
22
Yuri Zaporozhetsa560ab62024-10-30 14:17:33 +010023#if defined(CONFIG_X86)
24 struct video_uc_plat *plat = dev_get_uclass_plat(dev);
25 ulong fbbase;
26
Simon Glass0fc300a2020-07-02 21:12:36 -060027 /* Use write-combining for the graphics memory, 256MB */
28 fbbase = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
Bin Meng34133052023-07-31 14:01:07 +080029 mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20);
Yuri Zaporozhetsa560ab62024-10-30 14:17:33 +010030#endif
Simon Glass0fc300a2020-07-02 21:12:36 -060031
32 return 0;
33}
34
35static int vesa_video_bind(struct udevice *dev)
36{
Simon Glassb75b15b2020-12-03 16:55:23 -070037 struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
Simon Glass0fc300a2020-07-02 21:12:36 -060038
39 /* Set the maximum supported resolution */
40 uc_plat->size = 2560 * 1600 * 4;
41 log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
42
43 return 0;
Bin Meng2c9bb7a2016-10-09 04:14:11 -070044}
45
46static const struct udevice_id vesa_video_ids[] = {
47 { .compatible = "vesa-fb" },
48 { }
49};
50
51U_BOOT_DRIVER(vesa_video) = {
52 .name = "vesa_video",
53 .id = UCLASS_VIDEO,
54 .of_match = vesa_video_ids,
Simon Glass0fc300a2020-07-02 21:12:36 -060055 .bind = vesa_video_bind,
Bin Meng2c9bb7a2016-10-09 04:14:11 -070056 .probe = vesa_video_probe,
57};
58
59static struct pci_device_id vesa_video_supported[] = {
60 { PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, ~0) },
61 { },
62};
63
64U_BOOT_PCI_DEVICE(vesa_video, vesa_video_supported);