blob: ab756ac8ea128b1c3ddf43f574df8fe5a9f2f6aa [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>
11#include <asm/mtrr.h>
Bin Meng2c9bb7a2016-10-09 04:14:11 -070012
13static int vesa_video_probe(struct udevice *dev)
14{
Simon Glassb75b15b2020-12-03 16:55:23 -070015 struct video_uc_plat *plat = dev_get_uclass_plat(dev);
Simon Glass0fc300a2020-07-02 21:12:36 -060016 ulong fbbase;
17 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
23 /* Use write-combining for the graphics memory, 256MB */
24 fbbase = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
Bin Meng34133052023-07-31 14:01:07 +080025 mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20);
Simon Glass0fc300a2020-07-02 21:12:36 -060026
27 return 0;
28}
29
30static int vesa_video_bind(struct udevice *dev)
31{
Simon Glassb75b15b2020-12-03 16:55:23 -070032 struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
Simon Glass0fc300a2020-07-02 21:12:36 -060033
34 /* Set the maximum supported resolution */
35 uc_plat->size = 2560 * 1600 * 4;
36 log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
37
38 return 0;
Bin Meng2c9bb7a2016-10-09 04:14:11 -070039}
40
41static const struct udevice_id vesa_video_ids[] = {
42 { .compatible = "vesa-fb" },
43 { }
44};
45
46U_BOOT_DRIVER(vesa_video) = {
47 .name = "vesa_video",
48 .id = UCLASS_VIDEO,
49 .of_match = vesa_video_ids,
Simon Glass0fc300a2020-07-02 21:12:36 -060050 .bind = vesa_video_bind,
Bin Meng2c9bb7a2016-10-09 04:14:11 -070051 .probe = vesa_video_probe,
52};
53
54static struct pci_device_id vesa_video_supported[] = {
55 { PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, ~0) },
56 { },
57};
58
59U_BOOT_PCI_DEVICE(vesa_video, vesa_video_supported);