mpc8610hpcd_diu.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. #ifdef CONFIG_FSL_DIU_FB
  29. #include "../common/pixis.h"
  30. #include "../common/fsl_diu_fb.h"
  31. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  32. #include <stdio_dev.h>
  33. #include <video_fb.h>
  34. #endif
  35. extern unsigned int FSL_Logo_BMP[];
  36. static int xres, yres;
  37. void diu_set_pixel_clock(unsigned int pixclock)
  38. {
  39. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  40. volatile ccsr_gur_t *gur = &immap->im_gur;
  41. volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
  42. unsigned long speed_ccb, temp, pixval;
  43. speed_ccb = get_bus_freq(0);
  44. temp = 1000000000/pixclock;
  45. temp *= 1000;
  46. pixval = speed_ccb / temp;
  47. debug("DIU pixval = %lu\n", pixval);
  48. /* Modify PXCLK in GUTS CLKDVDR */
  49. debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
  50. temp = *guts_clkdvdr & 0x2000FFFF;
  51. *guts_clkdvdr = temp; /* turn off clock */
  52. *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
  53. debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
  54. }
  55. void mpc8610hpcd_diu_init(void)
  56. {
  57. char *monitor_port;
  58. int gamma_fix;
  59. unsigned int pixel_format;
  60. unsigned char tmp_val;
  61. unsigned char pixis_arch;
  62. u8 *pixis_base = (u8 *)PIXIS_BASE;
  63. tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
  64. pixis_arch = in_8(pixis_base + PIXIS_VER);
  65. monitor_port = getenv("monitor");
  66. if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
  67. xres = 1280;
  68. yres = 1024;
  69. if (pixis_arch == 0x01)
  70. pixel_format = 0x88882317;
  71. else
  72. pixel_format = 0x88883316;
  73. gamma_fix = 0;
  74. out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
  75. } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
  76. xres = 1024;
  77. yres = 768;
  78. pixel_format = 0x88883316;
  79. gamma_fix = 0;
  80. out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
  81. } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
  82. xres = 1280;
  83. yres = 1024;
  84. pixel_format = 0x88883316;
  85. gamma_fix = 1;
  86. out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
  87. } else { /* DVI */
  88. xres = 1280;
  89. yres = 1024;
  90. pixel_format = 0x88882317;
  91. gamma_fix = 0;
  92. out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
  93. }
  94. fsl_diu_init(xres, pixel_format, gamma_fix,
  95. (unsigned char *)FSL_Logo_BMP);
  96. }
  97. int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
  98. int flag, int argc, char *argv[])
  99. {
  100. unsigned int addr;
  101. if (argc < 2) {
  102. cmd_usage(cmdtp);
  103. return 1;
  104. }
  105. if (!strncmp(argv[1],"init",4)) {
  106. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  107. fsl_diu_clear_screen();
  108. drv_video_init();
  109. #else
  110. mpc8610hpcd_diu_init();
  111. #endif
  112. } else {
  113. addr = simple_strtoul(argv[1], NULL, 16);
  114. fsl_diu_clear_screen();
  115. fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
  116. }
  117. return 0;
  118. }
  119. U_BOOT_CMD(
  120. diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp,
  121. "Init or Display BMP file",
  122. "init\n - initialize DIU\n"
  123. "addr\n - display bmp at address 'addr'"
  124. );
  125. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  126. /*
  127. * The Graphic Device
  128. */
  129. GraphicDevice ctfb;
  130. void *video_hw_init(void)
  131. {
  132. GraphicDevice *pGD = (GraphicDevice *) &ctfb;
  133. struct fb_info *info;
  134. mpc8610hpcd_diu_init();
  135. /* fill in Graphic device struct */
  136. sprintf(pGD->modeIdent,
  137. "%dx%dx%d %ldkHz %ldHz",
  138. xres, yres, 32, 64, 60);
  139. pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
  140. pGD->winSizeX = xres;
  141. pGD->winSizeY = yres - info->logo_height;
  142. pGD->plnSizeX = pGD->winSizeX;
  143. pGD->plnSizeY = pGD->winSizeY;
  144. pGD->gdfBytesPP = 4;
  145. pGD->gdfIndex = GDF_32BIT_X888RGB;
  146. pGD->isaBase = 0;
  147. pGD->pciBase = 0;
  148. pGD->memSize = info->screen_size - info->logo_size;
  149. /* Cursor Start Address */
  150. pGD->dprBase = 0;
  151. pGD->vprBase = 0;
  152. pGD->cprBase = 0;
  153. return (void *)pGD;
  154. }
  155. void video_set_lut (unsigned int index, /* color number */
  156. unsigned char r, /* red */
  157. unsigned char g, /* green */
  158. unsigned char b /* blue */
  159. )
  160. {
  161. return;
  162. }
  163. #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
  164. #endif /* CONFIG_FSL_DIU_FB */