1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <common.h>
28#include <command.h>
29#include <asm/io.h>
30#include <fsl_diu_fb.h>
31#include "../common/pixis.h"
32
33#define PX_BRDCFG0_DLINK 0x10
34#define PX_BRDCFG0_DVISEL 0x08
35
36void diu_set_pixel_clock(unsigned int pixclock)
37{
38 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
39 volatile ccsr_gur_t *gur = &immap->im_gur;
40 volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
41 unsigned long speed_ccb, temp, pixval;
42
43 speed_ccb = get_bus_freq(0);
44 temp = 1000000000/pixclock;
45 temp *= 1000;
46 pixval = speed_ccb / temp;
47 debug("DIU pixval = %lu\n", pixval);
48
49
50 debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
51 temp = *guts_clkdvdr & 0x2000FFFF;
52 *guts_clkdvdr = temp;
53 *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
54 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
55}
56
57int platform_diu_init(unsigned int xres, unsigned int yres, const char *port)
58{
59 const char *name;
60 int gamma_fix = 0;
61 u32 pixel_format = 0x88883316;
62 u8 temp;
63
64 temp = in_8(&pixis->brdcfg0);
65
66 if (strncmp(port, "dlvds", 5) == 0) {
67
68 gamma_fix = 1;
69 temp &= ~(PX_BRDCFG0_DLINK | PX_BRDCFG0_DVISEL);
70 name = "Dual-Link LVDS";
71 } else if (strncmp(port, "lvds", 4) == 0) {
72
73 temp = (temp & ~PX_BRDCFG0_DVISEL) | PX_BRDCFG0_DLINK;
74 name = "Single-Link LVDS";
75 } else {
76
77 if (in_8(&pixis->ver) == 1)
78 pixel_format = 0x88882317;
79 temp |= PX_BRDCFG0_DVISEL;
80 name = "DVI";
81 }
82
83 printf("DIU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
84 out_8(&pixis->brdcfg0, temp);
85
86 return fsl_diu_init(xres, yres, pixel_format, gamma_fix);
87}
88