dcu.c 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2014 Freescale Semiconductor, Inc.
  4. *
  5. * FSL DCU Framebuffer driver
  6. */
  7. #include <common.h>
  8. #include <fsl_dcu_fb.h>
  9. #include <asm/global_data.h>
  10. #include "div64.h"
  11. #include "../common/dcu_sii9022a.h"
  12. DECLARE_GLOBAL_DATA_PTR;
  13. unsigned int dcu_set_pixel_clock(unsigned int pixclock)
  14. {
  15. unsigned long long div;
  16. div = (unsigned long long)(gd->bus_clk / 1000);
  17. div *= (unsigned long long)pixclock;
  18. do_div(div, 1000000000);
  19. return div;
  20. }
  21. int platform_dcu_init(struct fb_info *fbinfo,
  22. unsigned int xres, unsigned int yres,
  23. const char *port,
  24. struct fb_videomode *dcu_fb_videomode)
  25. {
  26. const char *name;
  27. unsigned int pixel_format;
  28. if (strncmp(port, "twr_lcd", 4) == 0) {
  29. name = "TWR_LCD_RGB card";
  30. } else {
  31. name = "HDMI";
  32. dcu_set_dvi_encoder(dcu_fb_videomode);
  33. }
  34. printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
  35. pixel_format = 32;
  36. fsl_dcu_init(fbinfo, xres, yres, pixel_format);
  37. return 0;
  38. }