York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 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 "../freescale/common/pixis.h" |
| 33 | #include "../freescale/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 | void diu_set_pixel_clock(unsigned int pixclock) |
| 45 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame^] | 46 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 47 | volatile clk512x_t *clk = &immap->clk; |
| 48 | volatile unsigned int *clkdvdr = &clk->scfr[0]; |
| 49 | unsigned long speed_ccb, temp, pixval; |
| 50 | |
| 51 | speed_ccb = get_bus_freq(0) * 4; |
| 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", *clkdvdr); |
| 59 | temp = *clkdvdr & 0xFFFFFF00; |
Kenneth Johansson | f889265 | 2008-07-12 13:18:34 -0600 | [diff] [blame] | 60 | *clkdvdr = temp | (pixval & 0xFF); |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 61 | debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *clkdvdr); |
| 62 | } |
| 63 | |
| 64 | int ads5121_diu_init(void) |
| 65 | { |
| 66 | unsigned int pixel_format; |
| 67 | |
| 68 | xres = 1024; |
| 69 | yres = 768; |
| 70 | pixel_format = 0x88883316; |
| 71 | |
| 72 | return fsl_diu_init(xres, pixel_format, 0, |
| 73 | (unsigned char *)FSL_Logo_BMP); |
| 74 | } |
| 75 | |
| 76 | int ads5121diu_init_show_bmp(cmd_tbl_t *cmdtp, |
| 77 | int flag, int argc, char *argv[]) |
| 78 | { |
| 79 | unsigned int addr; |
| 80 | |
| 81 | if (argc < 2) { |
| 82 | printf("Usage:\n%s\n", cmdtp->usage); |
| 83 | return 1; |
| 84 | } |
| 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 | return ads5121_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 | |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | U_BOOT_CMD( |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame^] | 103 | diufb, CONFIG_SYS_MAXARGS, 1, ads5121diu_init_show_bmp, |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 104 | "diufb init | addr - Init or Display BMP file\n", |
| 105 | "init\n - initialize DIU\n" |
| 106 | "addr\n - display bmp at address 'addr'\n" |
| 107 | ); |
| 108 | |
| 109 | |
| 110 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
| 111 | |
| 112 | /* |
| 113 | * The Graphic Device |
| 114 | */ |
| 115 | GraphicDevice ctfb; |
| 116 | void *video_hw_init(void) |
| 117 | { |
| 118 | GraphicDevice *pGD = (GraphicDevice *) &ctfb; |
| 119 | struct fb_info *info; |
| 120 | |
| 121 | if (ads5121_diu_init() < 0) |
| 122 | return; |
| 123 | |
| 124 | /* fill in Graphic device struct */ |
| 125 | sprintf(pGD->modeIdent, "%dx%dx%d %ldkHz %ldHz", |
| 126 | xres, yres, 32, 64, 60); |
| 127 | |
| 128 | pGD->frameAdrs = (unsigned int)fsl_fb_open(&info); |
| 129 | pGD->winSizeX = xres; |
| 130 | pGD->winSizeY = yres - info->logo_height; |
| 131 | pGD->plnSizeX = pGD->winSizeX; |
| 132 | pGD->plnSizeY = pGD->winSizeY; |
| 133 | |
| 134 | pGD->gdfBytesPP = 4; |
| 135 | pGD->gdfIndex = GDF_32BIT_X888RGB; |
| 136 | |
| 137 | pGD->isaBase = 0; |
| 138 | pGD->pciBase = 0; |
| 139 | pGD->memSize = info->screen_size - info->logo_size; |
| 140 | |
| 141 | /* Cursor Start Address */ |
| 142 | pGD->dprBase = 0; |
| 143 | pGD->vprBase = 0; |
| 144 | pGD->cprBase = 0; |
| 145 | |
| 146 | return (void *)pGD; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Set the LUT |
| 151 | * |
| 152 | * @index: color number |
| 153 | * @r: red |
| 154 | * @b: blue |
| 155 | * @g: green |
| 156 | */ |
| 157 | void video_set_lut |
| 158 | (unsigned int index, unsigned char r, unsigned char g, unsigned char b) |
| 159 | { |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */ |
| 164 | |
| 165 | #endif /* CONFIG_FSL_DIU_FB */ |