blob: c4108af33673689f16c73143cb1ad66a2a3b87a5 [file] [log] [blame]
York Sun0e1bad42008-05-05 10:20:01 -05001/*
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
Anatolij Gustschin9e70d132010-09-24 01:06:37 +020030#include <fsl_diu_fb.h>
York Sun0e1bad42008-05-05 10:20:01 -050031
Anatolij Gustschina3921ee2010-04-24 19:27:09 +020032DECLARE_GLOBAL_DATA_PTR;
33
York Sun0e1bad42008-05-05 10:20:01 -050034void diu_set_pixel_clock(unsigned int pixclock)
35{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020036 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
York Sun0e1bad42008-05-05 10:20:01 -050037 volatile clk512x_t *clk = &immap->clk;
38 volatile unsigned int *clkdvdr = &clk->scfr[0];
39 unsigned long speed_ccb, temp, pixval;
40
41 speed_ccb = get_bus_freq(0) * 4;
42 temp = 1000000000/pixclock;
43 temp *= 1000;
44 pixval = speed_ccb / temp;
45 debug("DIU pixval = %lu\n", pixval);
46
47 /* Modify PXCLK in GUTS CLKDVDR */
Detlev Zundel57ae8a52010-01-21 17:55:58 +010048 debug("DIU: Current value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
49 temp = in_be32(clkdvdr) & 0xFFFFFF00;
50 out_be32(clkdvdr, temp | (pixval & 0xFF));
51 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
York Sun0e1bad42008-05-05 10:20:01 -050052}
53
Anatolij Gustschin9e70d132010-09-24 01:06:37 +020054int platform_diu_init(unsigned int *xres, unsigned int *yres)
York Sun0e1bad42008-05-05 10:20:01 -050055{
56 unsigned int pixel_format;
57
Anatolij Gustschina3921ee2010-04-24 19:27:09 +020058#if defined(CONFIG_VIDEO_XRES) & defined(CONFIG_VIDEO_YRES)
Anatolij Gustschin9e70d132010-09-24 01:06:37 +020059 *xres = CONFIG_VIDEO_XRES;
60 *yres = CONFIG_VIDEO_YRES;
Anatolij Gustschina3921ee2010-04-24 19:27:09 +020061#else
Anatolij Gustschin9e70d132010-09-24 01:06:37 +020062 *xres = 1024;
63 *yres = 768;
Anatolij Gustschina3921ee2010-04-24 19:27:09 +020064#endif
York Sun0e1bad42008-05-05 10:20:01 -050065 pixel_format = 0x88883316;
66
Wolfgang Denkde26ef92009-05-16 10:47:38 +020067 debug("mpc5121_diu_init\n");
Timur Tabie69e5202010-08-31 19:56:43 -050068
Anatolij Gustschin9e70d132010-09-24 01:06:37 +020069 return fsl_diu_init(*xres, pixel_format, 0);
York Sun0e1bad42008-05-05 10:20:01 -050070}