Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
Bin Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 6 | #include <dm.h> |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 7 | #include <log.h> |
Bin Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 8 | #include <pci.h> |
Simon Glass | ec86bc6 | 2022-07-30 15:52:04 -0600 | [diff] [blame] | 9 | #include <vesa.h> |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 10 | #include <video.h> |
| 11 | #include <asm/mtrr.h> |
Bin Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 12 | |
| 13 | static int vesa_video_probe(struct udevice *dev) |
| 14 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 15 | struct video_uc_plat *plat = dev_get_uclass_plat(dev); |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 16 | ulong fbbase; |
| 17 | int ret; |
| 18 | |
Simon Glass | 5b92520 | 2022-07-30 15:52:05 -0600 | [diff] [blame] | 19 | ret = vesa_setup_video(dev, NULL); |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 20 | 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 Meng | 3413305 | 2023-07-31 14:01:07 +0800 | [diff] [blame] | 25 | mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20); |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 26 | |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | static int vesa_video_bind(struct udevice *dev) |
| 31 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 32 | struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 33 | |
| 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 Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static const struct udevice_id vesa_video_ids[] = { |
| 42 | { .compatible = "vesa-fb" }, |
| 43 | { } |
| 44 | }; |
| 45 | |
| 46 | U_BOOT_DRIVER(vesa_video) = { |
| 47 | .name = "vesa_video", |
| 48 | .id = UCLASS_VIDEO, |
| 49 | .of_match = vesa_video_ids, |
Simon Glass | 0fc300a | 2020-07-02 21:12:36 -0600 | [diff] [blame] | 50 | .bind = vesa_video_bind, |
Bin Meng | 2c9bb7a | 2016-10-09 04:14:11 -0700 | [diff] [blame] | 51 | .probe = vesa_video_probe, |
| 52 | }; |
| 53 | |
| 54 | static struct pci_device_id vesa_video_supported[] = { |
| 55 | { PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, ~0) }, |
| 56 | { }, |
| 57 | }; |
| 58 | |
| 59 | U_BOOT_PCI_DEVICE(vesa_video, vesa_video_supported); |