2 * Copyright 2007 Freescale Semiconductor, Inc.
3 * York Sun <yorksun@freescale.com>
5 * FSL DIU Framebuffer driver
7 * See file CREDITS for list of people who contributed to this
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.
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.
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,
29 #include <fsl_diu_fb.h>
31 void diu_set_pixel_clock(unsigned int pixclock)
33 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
34 volatile ccsr_gur_t *gur = &immap->im_gur;
35 volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
36 unsigned long speed_ccb, temp, pixval;
38 speed_ccb = get_bus_freq(0);
39 temp = 1000000000/pixclock;
41 pixval = speed_ccb / temp;
42 debug("DIU pixval = %lu\n", pixval);
44 /* Modify PXCLK in GUTS CLKDVDR */
45 debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
46 temp = *guts_clkdvdr & 0x2000FFFF;
47 *guts_clkdvdr = temp; /* turn off clock */
48 *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
49 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
52 int platform_diu_init(unsigned int *xres, unsigned int *yres)
56 unsigned int pixel_format;
57 unsigned char tmp_val;
58 unsigned char pixis_arch;
59 u8 *pixis_base = (u8 *)PIXIS_BASE;
61 tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
62 pixis_arch = in_8(pixis_base + PIXIS_VER);
64 monitor_port = getenv("monitor");
65 if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
68 if (pixis_arch == 0x01)
69 pixel_format = 0x88882317;
71 pixel_format = 0x88883316;
73 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
75 } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
78 pixel_format = 0x88883316;
80 out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
82 } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
85 pixel_format = 0x88883316;
87 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
92 pixel_format = 0x88882317;
94 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
97 return fsl_diu_init(*xres, pixel_format, gamma_fix);