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 26 #include <common.h> 27 #include <command.h> 28 #include <asm/io.h> 29 30 #ifdef CONFIG_FSL_DIU_FB 31 32 #include "../common/pixis.h" 33 #include "../common/fsl_diu_fb.h" 34 35 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) 36 #include <devices.h> 37 #include <video_fb.h> 38 #endif 39 40 extern unsigned int FSL_Logo_BMP[]; 41 42 static int xres, yres; 43 44 45 void mpc8610hpcd_diu_init(void) 46 { 47 char *monitor_port; 48 int gamma_fix; 49 unsigned int pixel_format; 50 unsigned char tmp_val; 51 unsigned char pixis_arch; 52 53 tmp_val = in8(PIXIS_BASE + PIXIS_BRDCFG0); 54 pixis_arch = in8(PIXIS_BASE + PIXIS_VER); 55 56 monitor_port = getenv("monitor"); 57 if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */ 58 xres = 1280; 59 yres = 1024; 60 if (pixis_arch == 0x01) 61 pixel_format = 0x88882317; 62 else 63 pixel_format = 0x88883316; 64 gamma_fix = 0; 65 out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08); 66 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 out8(PIXIS_BASE + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10); 73 74 } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */ 75 xres = 1280; 76 yres = 1024; 77 pixel_format = 0x88883316; 78 gamma_fix = 1; 79 out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val & 0xe7); 80 81 } else { /* DVI */ 82 xres = 1280; 83 yres = 1024; 84 pixel_format = 0x88882317; 85 gamma_fix = 0; 86 out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08); 87 } 88 89 fsl_diu_init(xres, pixel_format, gamma_fix, 90 (unsigned char *)FSL_Logo_BMP); 91 } 92 93 int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp, 94 int flag, int argc, char *argv[]) 95 { 96 unsigned int addr; 97 98 if (argc < 2) { 99 printf ("Usage:\n%s\n", cmdtp->usage); 100 return 1; 101 } 102 103 if (!strncmp(argv[1],"init",4)) { 104 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) 105 fsl_diu_clear_screen(); 106 drv_video_init(); 107 #else 108 mpc8610hpcd_diu_init(); 109 #endif 110 } else { 111 addr = simple_strtoul(argv[1], NULL, 16); 112 fsl_diu_clear_screen(); 113 fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0); 114 } 115 116 return 0; 117 } 118 119 U_BOOT_CMD( 120 diufb, CFG_MAXARGS, 1, mpc8610diu_init_show_bmp, 121 "diufb init | addr - Init or Display BMP file\n", 122 "init\n - initialize DIU\n" 123 "addr\n - display bmp at address 'addr'\n" 124 ); 125 126 127 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) 128 129 /* 130 * The Graphic Device 131 */ 132 GraphicDevice ctfb; 133 void *video_hw_init(void) 134 { 135 GraphicDevice *pGD = (GraphicDevice *) &ctfb; 136 struct fb_info *info; 137 138 mpc8610hpcd_diu_init(); 139 140 /* fill in Graphic device struct */ 141 sprintf(pGD->modeIdent, 142 "%dx%dx%d %ldkHz %ldHz", 143 xres, yres, 32, 64, 60); 144 145 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info); 146 pGD->winSizeX = xres; 147 pGD->winSizeY = yres - info->logo_height; 148 pGD->plnSizeX = pGD->winSizeX; 149 pGD->plnSizeY = pGD->winSizeY; 150 151 pGD->gdfBytesPP = 4; 152 pGD->gdfIndex = GDF_32BIT_X888RGB; 153 154 pGD->isaBase = 0; 155 pGD->pciBase = 0; 156 pGD->memSize = info->screen_size - info->logo_size; 157 158 /* Cursor Start Address */ 159 pGD->dprBase = 0; 160 pGD->vprBase = 0; 161 pGD->cprBase = 0; 162 163 return (void *)pGD; 164 } 165 166 void video_set_lut (unsigned int index, /* color number */ 167 unsigned char r, /* red */ 168 unsigned char g, /* green */ 169 unsigned char b /* blue */ 170 ) 171 { 172 return; 173 } 174 175 #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */ 176 177 #endif /* CONFIG_FSL_DIU_FB */ 178