mpc8610hpcd_diu.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2007-2011 Freescale Semiconductor, Inc.
  3. * Authors: York Sun <yorksun@freescale.com>
  4. * Timur Tabi <timur@freescale.com>
  5. *
  6. * FSL DIU Framebuffer driver
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. #include <asm/io.h>
  29. #include <fsl_diu_fb.h>
  30. #include "../common/pixis.h"
  31. #define PX_BRDCFG0_DLINK 0x10
  32. #define PX_BRDCFG0_DVISEL 0x08
  33. void diu_set_pixel_clock(unsigned int pixclock)
  34. {
  35. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  36. volatile ccsr_gur_t *gur = &immap->im_gur;
  37. volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
  38. unsigned long speed_ccb, temp, pixval;
  39. speed_ccb = get_bus_freq(0);
  40. temp = 1000000000/pixclock;
  41. temp *= 1000;
  42. pixval = speed_ccb / temp;
  43. debug("DIU pixval = %lu\n", pixval);
  44. /* Modify PXCLK in GUTS CLKDVDR */
  45. debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
  46. temp = *guts_clkdvdr & 0x2000FFFF;
  47. *guts_clkdvdr = temp; /* turn off clock */
  48. *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
  49. debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
  50. }
  51. int platform_diu_init(unsigned int xres, unsigned int yres, const char *port)
  52. {
  53. const char *name;
  54. int gamma_fix = 0;
  55. u32 pixel_format = 0x88883316;
  56. u8 temp;
  57. temp = in_8(&pixis->brdcfg0);
  58. if (strncmp(port, "dlvds", 5) == 0) {
  59. /* Dual link LVDS */
  60. gamma_fix = 1;
  61. temp &= ~(PX_BRDCFG0_DLINK | PX_BRDCFG0_DVISEL);
  62. name = "Dual-Link LVDS";
  63. } else if (strncmp(port, "lvds", 4) == 0) {
  64. /* Single link LVDS */
  65. temp = (temp & ~PX_BRDCFG0_DVISEL) | PX_BRDCFG0_DLINK;
  66. name = "Single-Link LVDS";
  67. } else {
  68. /* DVI */
  69. if (in_8(&pixis->ver) == 1) /* Board version */
  70. pixel_format = 0x88882317;
  71. temp |= PX_BRDCFG0_DVISEL;
  72. name = "DVI";
  73. }
  74. printf("DIU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
  75. out_8(&pixis->brdcfg0, temp);
  76. return fsl_diu_init(xres, pixel_format, gamma_fix);
  77. }