bcm2835.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2012 Stephen Warren
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <log.h>
  8. #include <video.h>
  9. #include <asm/arch/mbox.h>
  10. #include <asm/arch/msg.h>
  11. #include <asm/cache.h>
  12. static int bcm2835_video_probe(struct udevice *dev)
  13. {
  14. struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
  15. struct video_priv *uc_priv = dev_get_uclass_priv(dev);
  16. int ret;
  17. int w, h, pitch;
  18. ulong fb_base, fb_size, fb_start, fb_end;
  19. debug("bcm2835: Query resolution...\n");
  20. ret = bcm2835_get_video_size(&w, &h);
  21. if (ret || w == 0 || h == 0)
  22. return -EIO;
  23. debug("bcm2835: Setting up display for %d x %d\n", w, h);
  24. ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
  25. BCM2835_MBOX_ALPHA_MODE_IGNORED,
  26. &fb_base, &fb_size, &pitch);
  27. if (ret)
  28. return -EIO;
  29. debug("bcm2835: Final resolution is %d x %d\n", w, h);
  30. /* Enable dcache for the frame buffer */
  31. fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
  32. fb_end = fb_base + fb_size;
  33. fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
  34. mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
  35. DCACHE_WRITEBACK);
  36. video_set_flush_dcache(dev, true);
  37. uc_priv->xsize = w;
  38. uc_priv->ysize = h;
  39. uc_priv->bpix = VIDEO_BPP32;
  40. plat->base = fb_base;
  41. plat->size = fb_size;
  42. return 0;
  43. }
  44. static const struct udevice_id bcm2835_video_ids[] = {
  45. { .compatible = "brcm,bcm2835-hdmi" },
  46. { .compatible = "brcm,bcm2708-fb" },
  47. { }
  48. };
  49. U_BOOT_DRIVER(bcm2835_video) = {
  50. .name = "bcm2835_video",
  51. .id = UCLASS_VIDEO,
  52. .of_match = bcm2835_video_ids,
  53. .probe = bcm2835_video_probe,
  54. };