vesa.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <log.h>
  8. #include <pci.h>
  9. #include <vesa.h>
  10. #include <video.h>
  11. #include <asm/mtrr.h>
  12. static int vesa_video_probe(struct udevice *dev)
  13. {
  14. struct video_uc_plat *plat = dev_get_uclass_plat(dev);
  15. ulong fbbase;
  16. int ret;
  17. ret = vesa_setup_video(dev, NULL);
  18. if (ret)
  19. return log_ret(ret);
  20. /* Use write-combining for the graphics memory, 256MB */
  21. fbbase = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
  22. mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20);
  23. return 0;
  24. }
  25. static int vesa_video_bind(struct udevice *dev)
  26. {
  27. struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
  28. /* Set the maximum supported resolution */
  29. uc_plat->size = 2560 * 1600 * 4;
  30. log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
  31. return 0;
  32. }
  33. static const struct udevice_id vesa_video_ids[] = {
  34. { .compatible = "vesa-fb" },
  35. { }
  36. };
  37. U_BOOT_DRIVER(vesa_video) = {
  38. .name = "vesa_video",
  39. .id = UCLASS_VIDEO,
  40. .of_match = vesa_video_ids,
  41. .bind = vesa_video_bind,
  42. .probe = vesa_video_probe,
  43. };
  44. static struct pci_device_id vesa_video_supported[] = {
  45. { PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, ~0) },
  46. { },
  47. };
  48. U_BOOT_PCI_DEVICE(vesa_video, vesa_video_supported);