blob: 50912c5c8bcadaeb1cf0edc1bdc56c2b99ba1146 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Meng02c57ab2016-10-09 04:14:11 -07002/*
3 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
Bin Meng02c57ab2016-10-09 04:14:11 -07004 */
5
6#include <common.h>
7#include <dm.h>
Simon Glass6c74ee32020-07-02 21:12:36 -06008#include <log.h>
Bin Meng02c57ab2016-10-09 04:14:11 -07009#include <pci.h>
Simon Glasscafe8712022-07-30 15:52:04 -060010#include <vesa.h>
Simon Glass6c74ee32020-07-02 21:12:36 -060011#include <video.h>
12#include <asm/mtrr.h>
Bin Meng02c57ab2016-10-09 04:14:11 -070013
14static int vesa_video_probe(struct udevice *dev)
15{
Simon Glass8a8d24b2020-12-03 16:55:23 -070016 struct video_uc_plat *plat = dev_get_uclass_plat(dev);
Simon Glass6c74ee32020-07-02 21:12:36 -060017 ulong fbbase;
18 int ret;
19
Simon Glassda62e1e2022-07-30 15:52:05 -060020 ret = vesa_setup_video(dev, NULL);
Simon Glass6c74ee32020-07-02 21:12:36 -060021 if (ret)
22 return log_ret(ret);
23
24 /* Use write-combining for the graphics memory, 256MB */
25 fbbase = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
Bin Mengbff002d2023-07-31 14:01:07 +080026 mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20);
Simon Glass6c74ee32020-07-02 21:12:36 -060027
28 return 0;
29}
30
31static int vesa_video_bind(struct udevice *dev)
32{
Simon Glass8a8d24b2020-12-03 16:55:23 -070033 struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
Simon Glass6c74ee32020-07-02 21:12:36 -060034
35 /* Set the maximum supported resolution */
36 uc_plat->size = 2560 * 1600 * 4;
37 log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
38
39 return 0;
Bin Meng02c57ab2016-10-09 04:14:11 -070040}
41
42static const struct udevice_id vesa_video_ids[] = {
43 { .compatible = "vesa-fb" },
44 { }
45};
46
47U_BOOT_DRIVER(vesa_video) = {
48 .name = "vesa_video",
49 .id = UCLASS_VIDEO,
50 .of_match = vesa_video_ids,
Simon Glass6c74ee32020-07-02 21:12:36 -060051 .bind = vesa_video_bind,
Bin Meng02c57ab2016-10-09 04:14:11 -070052 .probe = vesa_video_probe,
53};
54
55static struct pci_device_id vesa_video_supported[] = {
56 { PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, ~0) },
57 { },
58};
59
60U_BOOT_PCI_DEVICE(vesa_video, vesa_video_supported);