mpc8610hpcd_diu.c 2.9 KB

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