mpc8610hpcd_diu.c 1.9 KB

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