mpc8610hpcd_diu.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 <devices.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. tmp_val = in8(PIXIS_BASE + PIXIS_BRDCFG0);
  63. pixis_arch = in8(PIXIS_BASE + PIXIS_VER);
  64. monitor_port = getenv("monitor");
  65. if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
  66. xres = 1280;
  67. yres = 1024;
  68. if (pixis_arch == 0x01)
  69. pixel_format = 0x88882317;
  70. else
  71. pixel_format = 0x88883316;
  72. gamma_fix = 0;
  73. out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08);
  74. } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
  75. xres = 1024;
  76. yres = 768;
  77. pixel_format = 0x88883316;
  78. gamma_fix = 0;
  79. out8(PIXIS_BASE + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
  80. } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
  81. xres = 1280;
  82. yres = 1024;
  83. pixel_format = 0x88883316;
  84. gamma_fix = 1;
  85. out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val & 0xe7);
  86. } else { /* DVI */
  87. xres = 1280;
  88. yres = 1024;
  89. pixel_format = 0x88882317;
  90. gamma_fix = 0;
  91. out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08);
  92. }
  93. fsl_diu_init(xres, pixel_format, gamma_fix,
  94. (unsigned char *)FSL_Logo_BMP);
  95. }
  96. int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
  97. int flag, int argc, char *argv[])
  98. {
  99. unsigned int addr;
  100. if (argc < 2) {
  101. cmd_usage(cmdtp);
  102. return 1;
  103. }
  104. if (!strncmp(argv[1],"init",4)) {
  105. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  106. fsl_diu_clear_screen();
  107. drv_video_init();
  108. #else
  109. mpc8610hpcd_diu_init();
  110. #endif
  111. } else {
  112. addr = simple_strtoul(argv[1], NULL, 16);
  113. fsl_diu_clear_screen();
  114. fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
  115. }
  116. return 0;
  117. }
  118. U_BOOT_CMD(
  119. diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp,
  120. "diufb - Init or Display BMP file\n",
  121. "init\n - initialize DIU\n"
  122. "addr\n - display bmp at address 'addr'\n"
  123. );
  124. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  125. /*
  126. * The Graphic Device
  127. */
  128. GraphicDevice ctfb;
  129. void *video_hw_init(void)
  130. {
  131. GraphicDevice *pGD = (GraphicDevice *) &ctfb;
  132. struct fb_info *info;
  133. mpc8610hpcd_diu_init();
  134. /* fill in Graphic device struct */
  135. sprintf(pGD->modeIdent,
  136. "%dx%dx%d %ldkHz %ldHz",
  137. xres, yres, 32, 64, 60);
  138. pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
  139. pGD->winSizeX = xres;
  140. pGD->winSizeY = yres - info->logo_height;
  141. pGD->plnSizeX = pGD->winSizeX;
  142. pGD->plnSizeY = pGD->winSizeY;
  143. pGD->gdfBytesPP = 4;
  144. pGD->gdfIndex = GDF_32BIT_X888RGB;
  145. pGD->isaBase = 0;
  146. pGD->pciBase = 0;
  147. pGD->memSize = info->screen_size - info->logo_size;
  148. /* Cursor Start Address */
  149. pGD->dprBase = 0;
  150. pGD->vprBase = 0;
  151. pGD->cprBase = 0;
  152. return (void *)pGD;
  153. }
  154. void video_set_lut (unsigned int index, /* color number */
  155. unsigned char r, /* red */
  156. unsigned char g, /* green */
  157. unsigned char b /* blue */
  158. )
  159. {
  160. return;
  161. }
  162. #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
  163. #endif /* CONFIG_FSL_DIU_FB */