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 | |
Peter Tyser | 8d1f268 | 2010-04-12 22:28:09 -0500 | [diff] [blame] | 30 | #include "../../../../board/freescale/common/fsl_diu_fb.h" |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 31 | |
| 32 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 33 | #include <stdio_dev.h> |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 34 | #include <video_fb.h> |
| 35 | #endif |
| 36 | |
Anatolij Gustschin | a3921ee | 2010-04-24 19:27:09 +0200 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 39 | static int xres, yres; |
| 40 | |
| 41 | void diu_set_pixel_clock(unsigned int pixclock) |
| 42 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 43 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 44 | volatile clk512x_t *clk = &immap->clk; |
| 45 | volatile unsigned int *clkdvdr = &clk->scfr[0]; |
| 46 | unsigned long speed_ccb, temp, pixval; |
| 47 | |
| 48 | speed_ccb = get_bus_freq(0) * 4; |
| 49 | temp = 1000000000/pixclock; |
| 50 | temp *= 1000; |
| 51 | pixval = speed_ccb / temp; |
| 52 | debug("DIU pixval = %lu\n", pixval); |
| 53 | |
| 54 | /* Modify PXCLK in GUTS CLKDVDR */ |
Detlev Zundel | 57ae8a5 | 2010-01-21 17:55:58 +0100 | [diff] [blame] | 55 | debug("DIU: Current value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr)); |
| 56 | temp = in_be32(clkdvdr) & 0xFFFFFF00; |
| 57 | out_be32(clkdvdr, temp | (pixval & 0xFF)); |
| 58 | debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr)); |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 59 | } |
| 60 | |
Wolfgang Denk | de26ef9 | 2009-05-16 10:47:38 +0200 | [diff] [blame] | 61 | int mpc5121_diu_init(void) |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 62 | { |
| 63 | unsigned int pixel_format; |
| 64 | |
Anatolij Gustschin | a3921ee | 2010-04-24 19:27:09 +0200 | [diff] [blame] | 65 | #if defined(CONFIG_VIDEO_XRES) & defined(CONFIG_VIDEO_YRES) |
| 66 | xres = CONFIG_VIDEO_XRES; |
| 67 | yres = CONFIG_VIDEO_YRES; |
| 68 | #else |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 69 | xres = 1024; |
| 70 | yres = 768; |
Anatolij Gustschin | a3921ee | 2010-04-24 19:27:09 +0200 | [diff] [blame] | 71 | #endif |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 72 | pixel_format = 0x88883316; |
| 73 | |
Wolfgang Denk | de26ef9 | 2009-05-16 10:47:38 +0200 | [diff] [blame] | 74 | debug("mpc5121_diu_init\n"); |
Timur Tabi | e69e520 | 2010-08-31 19:56:43 -0500 | [diff] [blame^] | 75 | |
| 76 | return fsl_diu_init(xres, pixel_format, 0); |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 77 | } |
| 78 | |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 79 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
| 80 | |
| 81 | /* |
| 82 | * The Graphic Device |
| 83 | */ |
| 84 | GraphicDevice ctfb; |
| 85 | void *video_hw_init(void) |
| 86 | { |
| 87 | GraphicDevice *pGD = (GraphicDevice *) &ctfb; |
| 88 | struct fb_info *info; |
| 89 | |
Wolfgang Denk | de26ef9 | 2009-05-16 10:47:38 +0200 | [diff] [blame] | 90 | if (mpc5121_diu_init() < 0) |
Anatolij Gustschin | 51c2ac9 | 2010-03-16 17:10:08 +0100 | [diff] [blame] | 91 | return NULL; |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 92 | |
| 93 | /* fill in Graphic device struct */ |
Anatolij Gustschin | 51c2ac9 | 2010-03-16 17:10:08 +0100 | [diff] [blame] | 94 | sprintf(pGD->modeIdent, "%dx%dx%d %dkHz %dHz", |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 95 | xres, yres, 32, 64, 60); |
| 96 | |
| 97 | pGD->frameAdrs = (unsigned int)fsl_fb_open(&info); |
| 98 | pGD->winSizeX = xres; |
Timur Tabi | e69e520 | 2010-08-31 19:56:43 -0500 | [diff] [blame^] | 99 | pGD->winSizeY = yres; |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 100 | pGD->plnSizeX = pGD->winSizeX; |
| 101 | pGD->plnSizeY = pGD->winSizeY; |
| 102 | |
| 103 | pGD->gdfBytesPP = 4; |
| 104 | pGD->gdfIndex = GDF_32BIT_X888RGB; |
| 105 | |
| 106 | pGD->isaBase = 0; |
| 107 | pGD->pciBase = 0; |
Timur Tabi | e69e520 | 2010-08-31 19:56:43 -0500 | [diff] [blame^] | 108 | pGD->memSize = info->screen_size; |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 109 | |
| 110 | /* Cursor Start Address */ |
| 111 | pGD->dprBase = 0; |
| 112 | pGD->vprBase = 0; |
| 113 | pGD->cprBase = 0; |
| 114 | |
| 115 | return (void *)pGD; |
| 116 | } |
| 117 | |
York Sun | 0e1bad4 | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 118 | #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */ |