vesa.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <vbe.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 = vbe_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_add_request(MTRR_TYPE_WRCOMB, fbbase, 256 << 20);
  23. mtrr_commit(true);
  24. return 0;
  25. }
  26. static int vesa_video_bind(struct udevice *dev)
  27. {
  28. struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
  29. /* Set the maximum supported resolution */
  30. uc_plat->size = 2560 * 1600 * 4;
  31. log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
  32. return 0;
  33. }
  34. static const struct udevice_id vesa_video_ids[] = {
  35. { .compatible = "vesa-fb" },
  36. { }
  37. };
  38. U_BOOT_DRIVER(vesa_video) = {
  39. .name = "vesa_video",
  40. .id = UCLASS_VIDEO,
  41. .of_match = vesa_video_ids,
  42. .bind = vesa_video_bind,
  43. .probe = vesa_video_probe,
  44. };
  45. static struct pci_device_id vesa_video_supported[] = {
  46. { PCI_DEVICE_CLASS(PCI_CLASS_DISPLAY_VGA << 8, ~0) },
  47. { },
  48. };
  49. U_BOOT_PCI_DEVICE(vesa_video, vesa_video_supported);