mpc8610hpcd_diu.c 4.1 KB

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