mpc8610hpcd_diu.c 1.9 KB

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