York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 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 | |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 35 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 36 | #include <stdio_dev.h> |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 37 | #include <video_fb.h> |
| 38 | #endif |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 39 | |
| 40 | extern unsigned int FSL_Logo_BMP[]; |
| 41 | |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 42 | static int xres, yres; |
| 43 | |
York Sun | c496438 | 2008-05-05 10:19:59 -0500 | [diff] [blame] | 44 | void diu_set_pixel_clock(unsigned int pixclock) |
| 45 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
York Sun | c496438 | 2008-05-05 10:19:59 -0500 | [diff] [blame] | 47 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 48 | volatile unsigned int *guts_clkdvdr = &gur->clkdvdr; |
| 49 | unsigned long speed_ccb, temp, pixval; |
| 50 | |
| 51 | speed_ccb = get_bus_freq(0); |
| 52 | temp = 1000000000/pixclock; |
| 53 | temp *= 1000; |
| 54 | pixval = speed_ccb / temp; |
| 55 | debug("DIU pixval = %lu\n", pixval); |
| 56 | |
| 57 | /* Modify PXCLK in GUTS CLKDVDR */ |
| 58 | debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr); |
| 59 | temp = *guts_clkdvdr & 0x2000FFFF; |
| 60 | *guts_clkdvdr = temp; /* turn off clock */ |
| 61 | *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16); |
| 62 | debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr); |
| 63 | } |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 64 | |
| 65 | void mpc8610hpcd_diu_init(void) |
| 66 | { |
| 67 | char *monitor_port; |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 68 | int gamma_fix; |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 69 | unsigned int pixel_format; |
| 70 | unsigned char tmp_val; |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 71 | unsigned char pixis_arch; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 72 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 73 | |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 74 | tmp_val = in_8(pixis_base + PIXIS_BRDCFG0); |
| 75 | pixis_arch = in_8(pixis_base + PIXIS_VER); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 76 | |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 77 | monitor_port = getenv("monitor"); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 78 | if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */ |
| 79 | xres = 1280; |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 80 | yres = 1024; |
| 81 | if (pixis_arch == 0x01) |
| 82 | pixel_format = 0x88882317; |
| 83 | else |
| 84 | pixel_format = 0x88883316; |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 85 | gamma_fix = 0; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 86 | out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 87 | |
| 88 | } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */ |
| 89 | xres = 1024; |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 90 | yres = 768; |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 91 | pixel_format = 0x88883316; |
| 92 | gamma_fix = 0; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 93 | out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 94 | |
| 95 | } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */ |
| 96 | xres = 1280; |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 97 | yres = 1024; |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 98 | pixel_format = 0x88883316; |
| 99 | gamma_fix = 1; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 100 | out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 101 | |
| 102 | } else { /* DVI */ |
| 103 | xres = 1280; |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 104 | yres = 1024; |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 105 | pixel_format = 0x88882317; |
| 106 | gamma_fix = 0; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 107 | out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | fsl_diu_init(xres, pixel_format, gamma_fix, |
| 111 | (unsigned char *)FSL_Logo_BMP); |
| 112 | } |
| 113 | |
| 114 | int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp, |
| 115 | int flag, int argc, char *argv[]) |
| 116 | { |
| 117 | unsigned int addr; |
| 118 | |
| 119 | if (argc < 2) { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 120 | cmd_usage(cmdtp); |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | if (!strncmp(argv[1],"init",4)) { |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 125 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
| 126 | fsl_diu_clear_screen(); |
| 127 | drv_video_init(); |
| 128 | #else |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 129 | mpc8610hpcd_diu_init(); |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 130 | #endif |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 131 | } else { |
| 132 | addr = simple_strtoul(argv[1], NULL, 16); |
| 133 | fsl_diu_clear_screen(); |
| 134 | fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0); |
| 135 | } |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | U_BOOT_CMD( |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 141 | diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 142 | "Init or Display BMP file", |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 143 | "init\n - initialize DIU\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 144 | "addr\n - display bmp at address 'addr'" |
| 145 | ); |
York Sun | 59e7468 | 2007-10-31 14:59:04 -0500 | [diff] [blame] | 146 | |
| 147 | |
| 148 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
| 149 | |
| 150 | /* |
| 151 | * The Graphic Device |
| 152 | */ |
| 153 | GraphicDevice ctfb; |
| 154 | void *video_hw_init(void) |
| 155 | { |
| 156 | GraphicDevice *pGD = (GraphicDevice *) &ctfb; |
| 157 | struct fb_info *info; |
| 158 | |
| 159 | mpc8610hpcd_diu_init(); |
| 160 | |
| 161 | /* fill in Graphic device struct */ |
| 162 | sprintf(pGD->modeIdent, |
| 163 | "%dx%dx%d %ldkHz %ldHz", |
| 164 | xres, yres, 32, 64, 60); |
| 165 | |
| 166 | pGD->frameAdrs = (unsigned int)fsl_fb_open(&info); |
| 167 | pGD->winSizeX = xres; |
| 168 | pGD->winSizeY = yres - info->logo_height; |
| 169 | pGD->plnSizeX = pGD->winSizeX; |
| 170 | pGD->plnSizeY = pGD->winSizeY; |
| 171 | |
| 172 | pGD->gdfBytesPP = 4; |
| 173 | pGD->gdfIndex = GDF_32BIT_X888RGB; |
| 174 | |
| 175 | pGD->isaBase = 0; |
| 176 | pGD->pciBase = 0; |
| 177 | pGD->memSize = info->screen_size - info->logo_size; |
| 178 | |
| 179 | /* Cursor Start Address */ |
| 180 | pGD->dprBase = 0; |
| 181 | pGD->vprBase = 0; |
| 182 | pGD->cprBase = 0; |
| 183 | |
| 184 | return (void *)pGD; |
| 185 | } |
| 186 | |
| 187 | void video_set_lut (unsigned int index, /* color number */ |
| 188 | unsigned char r, /* red */ |
| 189 | unsigned char g, /* green */ |
| 190 | unsigned char b /* blue */ |
| 191 | ) |
| 192 | { |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */ |
| 197 | |
York Sun | b714517 | 2007-10-29 13:58:39 -0500 | [diff] [blame] | 198 | #endif /* CONFIG_FSL_DIU_FB */ |