coreboot.c 1.9 KB

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