mpc8610hpcd_diu.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2007-2011 Freescale Semiconductor, Inc.
  4. * Authors: York Sun <yorksun@freescale.com>
  5. * Timur Tabi <timur@freescale.com>
  6. *
  7. * FSL DIU Framebuffer driver
  8. */
  9. #include <common.h>
  10. #include <clock_legacy.h>
  11. #include <command.h>
  12. #include <log.h>
  13. #include <asm/io.h>
  14. #include <fsl_diu_fb.h>
  15. #include "../common/pixis.h"
  16. #define PX_BRDCFG0_DLINK 0x10
  17. #define PX_BRDCFG0_DVISEL 0x08
  18. void diu_set_pixel_clock(unsigned int pixclock)
  19. {
  20. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  21. volatile ccsr_gur_t *gur = &immap->im_gur;
  22. volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
  23. unsigned long speed_ccb, temp, pixval;
  24. speed_ccb = get_bus_freq(0);
  25. temp = 1000000000/pixclock;
  26. temp *= 1000;
  27. pixval = speed_ccb / temp;
  28. debug("DIU pixval = %lu\n", pixval);
  29. /* Modify PXCLK in GUTS CLKDVDR */
  30. debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
  31. temp = *guts_clkdvdr & 0x2000FFFF;
  32. *guts_clkdvdr = temp; /* turn off clock */
  33. *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
  34. debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
  35. }
  36. int platform_diu_init(unsigned int xres, unsigned int yres, const char *port)
  37. {
  38. const char *name;
  39. int gamma_fix = 0;
  40. u32 pixel_format = 0x88883316;
  41. u8 temp;
  42. temp = in_8(&pixis->brdcfg0);
  43. if (strncmp(port, "dlvds", 5) == 0) {
  44. /* Dual link LVDS */
  45. gamma_fix = 1;
  46. temp &= ~(PX_BRDCFG0_DLINK | PX_BRDCFG0_DVISEL);
  47. name = "Dual-Link LVDS";
  48. } else if (strncmp(port, "lvds", 4) == 0) {
  49. /* Single link LVDS */
  50. temp = (temp & ~PX_BRDCFG0_DVISEL) | PX_BRDCFG0_DLINK;
  51. name = "Single-Link LVDS";
  52. } else {
  53. /* DVI */
  54. if (in_8(&pixis->ver) == 1) /* Board version */
  55. pixel_format = 0x88882317;
  56. temp |= PX_BRDCFG0_DVISEL;
  57. name = "DVI";
  58. }
  59. printf("DIU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
  60. out_8(&pixis->brdcfg0, temp);
  61. return fsl_diu_init(xres, yres, pixel_format, gamma_fix);
  62. }