]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c
Merge branch 'master' of git://git.denx.de/u-boot-blackfin
[karo-tx-uboot.git] / board / freescale / mpc8610hpcd / mpc8610hpcd_diu.c
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 #include <fsl_diu_fb.h>
30
31 void diu_set_pixel_clock(unsigned int pixclock)
32 {
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;
37
38         speed_ccb = get_bus_freq(0);
39         temp = 1000000000/pixclock;
40         temp *= 1000;
41         pixval = speed_ccb / temp;
42         debug("DIU pixval = %lu\n", pixval);
43
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);
50 }
51
52 int platform_diu_init(unsigned int *xres, unsigned int *yres)
53 {
54         char *monitor_port;
55         int gamma_fix;
56         unsigned int pixel_format;
57         unsigned char tmp_val;
58         unsigned char pixis_arch;
59         u8 *pixis_base = (u8 *)PIXIS_BASE;
60
61         tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
62         pixis_arch = in_8(pixis_base + PIXIS_VER);
63
64         monitor_port = getenv("monitor");
65         if (!strncmp(monitor_port, "0", 1)) {   /* 0 - DVI */
66                 *xres = 1280;
67                 *yres = 1024;
68                 if (pixis_arch == 0x01)
69                         pixel_format = 0x88882317;
70                 else
71                         pixel_format = 0x88883316;
72                 gamma_fix = 0;
73                 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
74
75         } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
76                 *xres = 1024;
77                 *yres = 768;
78                 pixel_format = 0x88883316;
79                 gamma_fix = 0;
80                 out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
81
82         } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
83                 *xres = 1280;
84                 *yres = 1024;
85                 pixel_format = 0x88883316;
86                 gamma_fix = 1;
87                 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
88
89         } else {        /* DVI */
90                 *xres = 1280;
91                 *yres = 1024;
92                 pixel_format = 0x88882317;
93                 gamma_fix = 0;
94                 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
95         }
96
97         return fsl_diu_init(*xres, pixel_format, gamma_fix);
98 }