coreboot.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <vbe.h>
  8. #include <video.h>
  9. #include <asm/arch/sysinfo.h>
  10. static int save_vesa_mode(struct cb_framebuffer *fb,
  11. struct vesa_mode_info *vesa)
  12. {
  13. /*
  14. * If there is no framebuffer structure, bail out and keep
  15. * running on the serial console.
  16. */
  17. if (!fb)
  18. return -ENXIO;
  19. vesa->x_resolution = fb->x_resolution;
  20. vesa->y_resolution = fb->y_resolution;
  21. vesa->bits_per_pixel = fb->bits_per_pixel;
  22. vesa->bytes_per_scanline = fb->bytes_per_line;
  23. vesa->phys_base_ptr = fb->physical_address;
  24. vesa->red_mask_size = fb->red_mask_size;
  25. vesa->red_mask_pos = fb->red_mask_pos;
  26. vesa->green_mask_size = fb->green_mask_size;
  27. vesa->green_mask_pos = fb->green_mask_pos;
  28. vesa->blue_mask_size = fb->blue_mask_size;
  29. vesa->blue_mask_pos = fb->blue_mask_pos;
  30. vesa->reserved_mask_size = fb->reserved_mask_size;
  31. vesa->reserved_mask_pos = fb->reserved_mask_pos;
  32. return 0;
  33. }
  34. static int coreboot_video_probe(struct udevice *dev)
  35. {
  36. struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
  37. struct video_priv *uc_priv = dev_get_uclass_priv(dev);
  38. struct cb_framebuffer *fb = lib_sysinfo.framebuffer;
  39. struct vesa_mode_info *vesa = &mode_info.vesa;
  40. int ret;
  41. printf("Video: ");
  42. /* Initialize vesa_mode_info structure */
  43. ret = save_vesa_mode(fb, vesa);
  44. if (ret)
  45. goto err;
  46. ret = vbe_setup_video_priv(vesa, uc_priv, plat);
  47. if (ret)
  48. goto err;
  49. printf("%dx%dx%d\n", uc_priv->xsize, uc_priv->ysize,
  50. vesa->bits_per_pixel);
  51. return 0;
  52. err:
  53. printf("No video mode configured in coreboot!\n");
  54. return ret;
  55. }
  56. static const struct udevice_id coreboot_video_ids[] = {
  57. { .compatible = "coreboot-fb" },
  58. { }
  59. };
  60. U_BOOT_DRIVER(coreboot_video) = {
  61. .name = "coreboot_video",
  62. .id = UCLASS_VIDEO,
  63. .of_match = coreboot_video_ids,
  64. .probe = coreboot_video_probe,
  65. };