blob: 565b63da4d314fe6a203f5729f77c30ff496941d [file] [log] [blame]
York Sunfd7cbfd2008-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
30#ifdef CONFIG_FSL_DIU_FB
31
32#include "../freescale/common/pixis.h"
33#include "../freescale/common/fsl_diu_fb.h"
34
35#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
36#include <devices.h>
37#include <video_fb.h>
38#endif
39
John Rigby2a1979c2008-10-30 16:39:35 -060040#ifdef CONFIG_FSL_DIU_LOGO_BMP
York Sunfd7cbfd2008-05-05 10:20:01 -050041extern unsigned int FSL_Logo_BMP[];
John Rigby2a1979c2008-10-30 16:39:35 -060042#else
43#define FSL_Logo_BMP NULL
44#endif
York Sunfd7cbfd2008-05-05 10:20:01 -050045
46static int xres, yres;
47
48void diu_set_pixel_clock(unsigned int pixclock)
49{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020050 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
York Sunfd7cbfd2008-05-05 10:20:01 -050051 volatile clk512x_t *clk = &immap->clk;
52 volatile unsigned int *clkdvdr = &clk->scfr[0];
53 unsigned long speed_ccb, temp, pixval;
54
55 speed_ccb = get_bus_freq(0) * 4;
56 temp = 1000000000/pixclock;
57 temp *= 1000;
58 pixval = speed_ccb / temp;
59 debug("DIU pixval = %lu\n", pixval);
60
61 /* Modify PXCLK in GUTS CLKDVDR */
62 debug("DIU: Current value of CLKDVDR = 0x%08x\n", *clkdvdr);
63 temp = *clkdvdr & 0xFFFFFF00;
Kenneth Johansson96273102008-07-12 13:18:34 -060064 *clkdvdr = temp | (pixval & 0xFF);
York Sunfd7cbfd2008-05-05 10:20:01 -050065 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *clkdvdr);
66}
67
68int ads5121_diu_init(void)
69{
70 unsigned int pixel_format;
71
72 xres = 1024;
73 yres = 768;
74 pixel_format = 0x88883316;
75
76 return fsl_diu_init(xres, pixel_format, 0,
77 (unsigned char *)FSL_Logo_BMP);
78}
79
80int ads5121diu_init_show_bmp(cmd_tbl_t *cmdtp,
81 int flag, int argc, char *argv[])
82{
83 unsigned int addr;
84
85 if (argc < 2) {
Peter Tyserddb3af92009-01-27 18:03:10 -060086 cmd_usage(cmdtp);
York Sunfd7cbfd2008-05-05 10:20:01 -050087 return 1;
88 }
89
90 if (!strncmp(argv[1], "init", 4)) {
91#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
92 fsl_diu_clear_screen();
93 drv_video_init();
94#else
95 return ads5121_diu_init();
96#endif
97 } else {
98 addr = simple_strtoul(argv[1], NULL, 16);
99 fsl_diu_clear_screen();
100 fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
101 }
102
103 return 0;
104}
105
106U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200107 diufb, CONFIG_SYS_MAXARGS, 1, ads5121diu_init_show_bmp,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600108 "Init or Display BMP file",
York Sunfd7cbfd2008-05-05 10:20:01 -0500109 "init\n - initialize DIU\n"
110 "addr\n - display bmp at address 'addr'\n"
111 );
112
113
114#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
115
116/*
117 * The Graphic Device
118 */
119GraphicDevice ctfb;
120void *video_hw_init(void)
121{
122 GraphicDevice *pGD = (GraphicDevice *) &ctfb;
123 struct fb_info *info;
124
125 if (ads5121_diu_init() < 0)
126 return;
127
128 /* fill in Graphic device struct */
129 sprintf(pGD->modeIdent, "%dx%dx%d %ldkHz %ldHz",
130 xres, yres, 32, 64, 60);
131
132 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
133 pGD->winSizeX = xres;
134 pGD->winSizeY = yres - info->logo_height;
135 pGD->plnSizeX = pGD->winSizeX;
136 pGD->plnSizeY = pGD->winSizeY;
137
138 pGD->gdfBytesPP = 4;
139 pGD->gdfIndex = GDF_32BIT_X888RGB;
140
141 pGD->isaBase = 0;
142 pGD->pciBase = 0;
143 pGD->memSize = info->screen_size - info->logo_size;
144
145 /* Cursor Start Address */
146 pGD->dprBase = 0;
147 pGD->vprBase = 0;
148 pGD->cprBase = 0;
149
150 return (void *)pGD;
151}
152
153/**
154 * Set the LUT
155 *
156 * @index: color number
157 * @r: red
158 * @b: blue
159 * @g: green
160 */
161void video_set_lut
162 (unsigned int index, unsigned char r, unsigned char g, unsigned char b)
163{
164 return;
165}
166
167#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
168
169#endif /* CONFIG_FSL_DIU_FB */