blob: 04e435f913c7a1649ddaa5c5fe9e6a449a06bb59 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Anatolij Gustschinbed53752008-01-11 14:30:01 +01002/*
3 * (C) Copyright 2007
4 * DENX Software Engineering, Anatolij Gustschin, agust@denx.de
Anatolij Gustschinbed53752008-01-11 14:30:01 +01005 */
6
7/*
8 * mb862xx.c - Graphic interface for Fujitsu CoralP/Lime
9 * PCI and video mode code was derived from smiLynxEM driver.
10 */
11
12#include <common.h>
Simon Glassc05ed002020-05-10 11:40:11 -060013#include <linux/delay.h>
Anatolij Gustschinbed53752008-01-11 14:30:01 +010014
Anatolij Gustschinbed53752008-01-11 14:30:01 +010015#include <asm/io.h>
Simon Glass7b51b572019-08-01 09:46:52 -060016#include <env.h>
Anatolij Gustschinbed53752008-01-11 14:30:01 +010017#include <pci.h>
18#include <video_fb.h>
19#include "videomodes.h"
20#include <mb862xx.h>
21
Yuri Tikhonov0d489262008-03-24 11:30:54 +010022#if defined(CONFIG_POST)
23#include <post.h>
24#endif
Anatolij Gustschine8652862009-07-07 13:24:08 +020025
Anatolij Gustschinbed53752008-01-11 14:30:01 +010026/*
27 * Graphic Device
28 */
29GraphicDevice mb862xx;
30
31/*
32 * 32MB external RAM - 256K Chip MMIO = 0x1FC0000 ;
33 */
34#define VIDEO_MEM_SIZE 0x01FC0000
35
36#if defined(CONFIG_PCI)
37#if defined(CONFIG_VIDEO_CORALP)
38
39static struct pci_device_id supported[] = {
40 { PCI_VENDOR_ID_FUJITSU, PCI_DEVICE_ID_CORAL_P },
41 { PCI_VENDOR_ID_FUJITSU, PCI_DEVICE_ID_CORAL_PA },
42 { }
43};
44
45/* Internal clock frequency divider table, index is mode number */
46unsigned int fr_div[] = { 0x00000f00, 0x00000900, 0x00000500 };
47#endif
48#endif
49
50#if defined(CONFIG_VIDEO_CORALP)
51#define rd_io in32r
52#define wr_io out32r
53#else
Anatolij Gustschine8652862009-07-07 13:24:08 +020054#define rd_io(addr) in_be32((volatile unsigned *)(addr))
55#define wr_io(addr, val) out_be32((volatile unsigned *)(addr), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010056#endif
57
Anatolij Gustschincce99b22009-07-07 13:27:07 +020058#define HOST_RD_REG(off) rd_io((dev->frameAdrs + GC_HOST_BASE + (off)))
59#define HOST_WR_REG(off, val) wr_io((dev->frameAdrs + GC_HOST_BASE + (off)), \
Anatolij Gustschine8652862009-07-07 13:24:08 +020060 (val))
Anatolij Gustschincce99b22009-07-07 13:27:07 +020061#define DISP_RD_REG(off) rd_io((dev->frameAdrs + GC_DISP_BASE + (off)))
62#define DISP_WR_REG(off, val) wr_io((dev->frameAdrs + GC_DISP_BASE + (off)), \
Anatolij Gustschine8652862009-07-07 13:24:08 +020063 (val))
64#define DE_RD_REG(off) rd_io((dev->dprBase + (off)))
65#define DE_WR_REG(off, val) wr_io((dev->dprBase + (off)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010066
67#if defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschincce99b22009-07-07 13:27:07 +020068#define DE_WR_FIFO(val) wr_io((dev->dprBase + (GC_GEO_FIFO)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010069#else
Anatolij Gustschincce99b22009-07-07 13:27:07 +020070#define DE_WR_FIFO(val) wr_io((dev->dprBase + (GC_FIFO)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010071#endif
72
Anatolij Gustschincce99b22009-07-07 13:27:07 +020073#define L0PAL_WR_REG(idx, val) wr_io((dev->frameAdrs + \
74 (GC_DISP_BASE | GC_L0PAL0) + \
Anatolij Gustschine8652862009-07-07 13:24:08 +020075 ((idx) << 2)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010076
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +020077#if defined(CONFIG_VIDEO_MB862xx_ACCEL)
Anatolij Gustschine8652862009-07-07 13:24:08 +020078static void gdc_sw_reset (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +010079{
Anatolij Gustschine8652862009-07-07 13:24:08 +020080 GraphicDevice *dev = &mb862xx;
81
Anatolij Gustschincce99b22009-07-07 13:27:07 +020082 HOST_WR_REG (GC_SRST, 0x1);
Simon Glass07e11142020-05-10 11:40:10 -060083 udelay(500);
Anatolij Gustschinbed53752008-01-11 14:30:01 +010084 video_hw_init ();
85}
86
87
Anatolij Gustschine8652862009-07-07 13:24:08 +020088static void de_wait (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +010089{
Anatolij Gustschine8652862009-07-07 13:24:08 +020090 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +010091 int lc = 0x10000;
92
Anatolij Gustschine8652862009-07-07 13:24:08 +020093 /*
94 * Sync with software writes to framebuffer,
95 * try to reset if engine locked
96 */
Anatolij Gustschincce99b22009-07-07 13:27:07 +020097 while (DE_RD_REG (GC_CTR) & 0x00000131)
Anatolij Gustschinbed53752008-01-11 14:30:01 +010098 if (lc-- < 0) {
99 gdc_sw_reset ();
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200100 puts ("gdc reset done after drawing engine lock.\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100101 break;
102 }
103}
104
Anatolij Gustschine8652862009-07-07 13:24:08 +0200105static void de_wait_slots (int slots)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100106{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200107 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100108 int lc = 0x10000;
109
110 /* Wait for free fifo slots */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200111 while (DE_RD_REG (GC_IFCNT) < slots)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100112 if (lc-- < 0) {
113 gdc_sw_reset ();
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200114 puts ("gdc reset done after drawing engine lock.\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100115 break;
116 }
117}
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +0200118#endif
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100119
120#if !defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200121static void board_disp_init (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100122{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200123 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100124 const gdc_regs *regs = board_get_regs ();
125
126 while (regs->index) {
127 DISP_WR_REG (regs->index, regs->value);
128 regs++;
129 }
130}
131#endif
132
133/*
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +0200134 * Init drawing engine if accel enabled.
135 * Also clears visible framebuffer.
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100136 */
137static void de_init (void)
138{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200139 GraphicDevice *dev = &mb862xx;
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +0200140#if defined(CONFIG_VIDEO_MB862xx_ACCEL)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200141 int cf = (dev->gdfBytesPP == 1) ? 0x0000 : 0x8000;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100142
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200143 dev->dprBase = dev->frameAdrs + GC_DRAW_BASE;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100144
145 /* Setup mode and fbbase, xres, fg, bg */
146 de_wait_slots (2);
147 DE_WR_FIFO (0xf1010108);
148 DE_WR_FIFO (cf | 0x0300);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200149 DE_WR_REG (GC_FBR, 0x0);
150 DE_WR_REG (GC_XRES, dev->winSizeX);
151 DE_WR_REG (GC_FC, 0x0);
152 DE_WR_REG (GC_BC, 0x0);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100153 /* Reset clipping */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200154 DE_WR_REG (GC_CXMIN, 0x0);
155 DE_WR_REG (GC_CXMAX, dev->winSizeX);
156 DE_WR_REG (GC_CYMIN, 0x0);
157 DE_WR_REG (GC_CYMAX, dev->winSizeY);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100158
159 /* Clear framebuffer using drawing engine */
160 de_wait_slots (3);
161 DE_WR_FIFO (0x09410000);
162 DE_WR_FIFO (0x00000000);
Anatolij Gustschine8652862009-07-07 13:24:08 +0200163 DE_WR_FIFO (dev->winSizeY << 16 | dev->winSizeX);
Anatolij Gustschin322716a2008-07-12 17:31:36 +0200164 /* sync with SW access to framebuffer */
165 de_wait ();
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +0200166#else
167 unsigned int i, *p;
168
169 i = dev->winSizeX * dev->winSizeY;
170 p = (unsigned int *)dev->frameAdrs;
171 while (i--)
172 *p++ = 0;
173#endif
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100174}
175
176#if defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschind7ffd272011-05-27 16:08:20 +0200177/* use CCF and MMR parameters for Coral-P Eval. Board as default */
178#ifndef CONFIG_SYS_MB862xx_CCF
179#define CONFIG_SYS_MB862xx_CCF 0x00090000
180#endif
181#ifndef CONFIG_SYS_MB862xx_MMR
182#define CONFIG_SYS_MB862xx_MMR 0x11d7fa13
183#endif
184
Anatolij Gustschine8652862009-07-07 13:24:08 +0200185unsigned int pci_video_init (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100186{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200187 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100188 pci_dev_t devbusfn;
Anatolij Gustschind7ffd272011-05-27 16:08:20 +0200189 u16 device;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100190
Anatolij Gustschine8652862009-07-07 13:24:08 +0200191 if ((devbusfn = pci_find_devices (supported, 0)) < 0) {
Anatolij Gustschin01b0f502011-07-16 22:28:23 +0200192 puts("controller not present\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100193 return 0;
194 }
195
196 /* PCI setup */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200197 pci_write_config_dword (devbusfn, PCI_COMMAND,
198 (PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
199 pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0, &dev->frameAdrs);
200 dev->frameAdrs = pci_mem_to_phys (devbusfn, dev->frameAdrs);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100201
Anatolij Gustschine8652862009-07-07 13:24:08 +0200202 if (dev->frameAdrs == 0) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200203 puts ("PCI config: failed to get base address\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100204 return 0;
205 }
206
Anatolij Gustschine8652862009-07-07 13:24:08 +0200207 dev->pciBase = dev->frameAdrs;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100208
Anatolij Gustschind7ffd272011-05-27 16:08:20 +0200209 puts("Coral-");
210
211 pci_read_config_word(devbusfn, PCI_DEVICE_ID, &device);
212 switch (device) {
213 case PCI_DEVICE_ID_CORAL_P:
214 puts("P\n");
215 break;
216 case PCI_DEVICE_ID_CORAL_PA:
217 puts("PA\n");
218 break;
219 default:
220 puts("Unknown\n");
221 return 0;
222 }
223
224 /* Setup clocks and memory mode for Coral-P(A) */
225 HOST_WR_REG(GC_CCF, CONFIG_SYS_MB862xx_CCF);
Simon Glass07e11142020-05-10 11:40:10 -0600226 udelay(200);
Anatolij Gustschind7ffd272011-05-27 16:08:20 +0200227 HOST_WR_REG(GC_MMR, CONFIG_SYS_MB862xx_MMR);
Simon Glass07e11142020-05-10 11:40:10 -0600228 udelay(100);
Anatolij Gustschine8652862009-07-07 13:24:08 +0200229 return dev->frameAdrs;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100230}
231
232unsigned int card_init (void)
233{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200234 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100235 unsigned int cf, videomode, div = 0;
236 unsigned long t1, hsync, vsync;
237 char *penv;
238 int tmp, i, bpp;
239 struct ctfb_res_modes *res_mode;
240 struct ctfb_res_modes var_mode;
241
Anatolij Gustschine8652862009-07-07 13:24:08 +0200242 memset (dev, 0, sizeof (GraphicDevice));
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100243
Anatolij Gustschine8652862009-07-07 13:24:08 +0200244 if (!pci_video_init ())
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100245 return 0;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100246
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100247 tmp = 0;
248 videomode = 0x310;
249 /* get video mode via environment */
Simon Glass00caae62017-08-03 12:22:12 -0600250 penv = env_get("videomode");
251 if (penv) {
Anatolij Gustschine8652862009-07-07 13:24:08 +0200252 /* decide if it is a string */
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100253 if (penv[0] <= '9') {
254 videomode = (int) simple_strtoul (penv, NULL, 16);
255 tmp = 1;
256 }
257 } else {
258 tmp = 1;
259 }
Anatolij Gustschine8652862009-07-07 13:24:08 +0200260
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100261 if (tmp) {
Anatolij Gustschine8652862009-07-07 13:24:08 +0200262 /* parameter are vesa modes, search params */
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100263 for (i = 0; i < VESA_MODES_COUNT; i++) {
264 if (vesa_modes[i].vesanr == videomode)
265 break;
266 }
267 if (i == VESA_MODES_COUNT) {
Anatolij Gustschine8652862009-07-07 13:24:08 +0200268 printf ("\tno VESA Mode found, fallback to mode 0x%x\n",
269 videomode);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100270 i = 0;
271 }
Anatolij Gustschine8652862009-07-07 13:24:08 +0200272 res_mode = (struct ctfb_res_modes *)
273 &res_mode_init[vesa_modes[i].resindex];
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100274 if (vesa_modes[i].resindex > 2) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200275 puts ("\tUnsupported resolution, using default\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100276 bpp = vesa_modes[1].bits_per_pixel;
277 div = fr_div[1];
278 }
279 bpp = vesa_modes[i].bits_per_pixel;
280 div = fr_div[vesa_modes[i].resindex];
281 } else {
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100282 res_mode = (struct ctfb_res_modes *) &var_mode;
283 bpp = video_get_params (res_mode, penv);
284 }
285
286 /* calculate hsync and vsync freq (info only) */
287 t1 = (res_mode->left_margin + res_mode->xres +
288 res_mode->right_margin + res_mode->hsync_len) / 8;
289 t1 *= 8;
290 t1 *= res_mode->pixclock;
291 t1 /= 1000;
292 hsync = 1000000000L / t1;
293 t1 *= (res_mode->upper_margin + res_mode->yres +
294 res_mode->lower_margin + res_mode->vsync_len);
295 t1 /= 1000;
296 vsync = 1000000000L / t1;
297
298 /* fill in Graphic device struct */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200299 sprintf (dev->modeIdent, "%dx%dx%d %ldkHz %ldHz", res_mode->xres,
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100300 res_mode->yres, bpp, (hsync / 1000), (vsync / 1000));
Anatolij Gustschine8652862009-07-07 13:24:08 +0200301 printf ("\t%s\n", dev->modeIdent);
302 dev->winSizeX = res_mode->xres;
303 dev->winSizeY = res_mode->yres;
304 dev->memSize = VIDEO_MEM_SIZE;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100305
306 switch (bpp) {
307 case 8:
Anatolij Gustschine8652862009-07-07 13:24:08 +0200308 dev->gdfIndex = GDF__8BIT_INDEX;
309 dev->gdfBytesPP = 1;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100310 break;
311 case 15:
312 case 16:
Anatolij Gustschine8652862009-07-07 13:24:08 +0200313 dev->gdfIndex = GDF_15BIT_555RGB;
314 dev->gdfBytesPP = 2;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100315 break;
316 default:
Anatolij Gustschine8652862009-07-07 13:24:08 +0200317 printf ("\t%d bpp configured, but only 8,15 and 16 supported\n",
318 bpp);
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200319 puts ("\tfallback to 15bpp\n");
Anatolij Gustschine8652862009-07-07 13:24:08 +0200320 dev->gdfIndex = GDF_15BIT_555RGB;
321 dev->gdfBytesPP = 2;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100322 }
323
324 /* Setup dot clock (internal pll, division rate) */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200325 DISP_WR_REG (GC_DCM1, div);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100326 /* L0 init */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200327 cf = (dev->gdfBytesPP == 1) ? 0x00000000 : 0x80000000;
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200328 DISP_WR_REG (GC_L0M, ((dev->winSizeX * dev->gdfBytesPP) / 64) << 16 |
Anatolij Gustschine8652862009-07-07 13:24:08 +0200329 (dev->winSizeY - 1) | cf);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200330 DISP_WR_REG (GC_L0OA0, 0x0);
331 DISP_WR_REG (GC_L0DA0, 0x0);
332 DISP_WR_REG (GC_L0DY_L0DX, 0x0);
333 DISP_WR_REG (GC_L0EM, 0x0);
334 DISP_WR_REG (GC_L0WY_L0WX, 0x0);
335 DISP_WR_REG (GC_L0WH_L0WW, (dev->winSizeY - 1) << 16 | dev->winSizeX);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100336
337 /* Display timing init */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200338 DISP_WR_REG (GC_HTP_A, (dev->winSizeX +
339 res_mode->left_margin +
340 res_mode->right_margin +
341 res_mode->hsync_len - 1) << 16);
342 DISP_WR_REG (GC_HDB_HDP_A, (dev->winSizeX - 1) << 16 |
343 (dev->winSizeX - 1));
344 DISP_WR_REG (GC_VSW_HSW_HSP_A, (res_mode->vsync_len - 1) << 24 |
345 (res_mode->hsync_len - 1) << 16 |
346 (dev->winSizeX +
347 res_mode->right_margin - 1));
348 DISP_WR_REG (GC_VTR_A, (dev->winSizeY + res_mode->lower_margin +
349 res_mode->upper_margin +
350 res_mode->vsync_len - 1) << 16);
351 DISP_WR_REG (GC_VDP_VSP_A, (dev->winSizeY-1) << 16 |
352 (dev->winSizeY +
353 res_mode->lower_margin - 1));
354 DISP_WR_REG (GC_WY_WX, 0x0);
355 DISP_WR_REG (GC_WH_WW, dev->winSizeY << 16 | dev->winSizeX);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100356 /* Display enable, L0 layer */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200357 DISP_WR_REG (GC_DCM1, 0x80010000 | div);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100358
Anatolij Gustschine8652862009-07-07 13:24:08 +0200359 return dev->frameAdrs;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100360}
361#endif
362
Wolfgang Grandeggerc28d3bb2009-10-23 12:03:13 +0200363
364#if !defined(CONFIG_VIDEO_CORALP)
365int mb862xx_probe(unsigned int addr)
366{
367 GraphicDevice *dev = &mb862xx;
368 unsigned int reg;
369
370 dev->frameAdrs = addr;
371 dev->dprBase = dev->frameAdrs + GC_DRAW_BASE;
372
373 /* Try to access GDC ID/Revision registers */
374 reg = HOST_RD_REG (GC_CID);
375 reg = HOST_RD_REG (GC_CID);
376 if (reg == 0x303) {
377 reg = DE_RD_REG(GC_REV);
378 reg = DE_RD_REG(GC_REV);
379 if ((reg & ~0xff) == 0x20050100)
380 return MB862XX_TYPE_LIME;
381 }
382
383 return 0;
384}
385#endif
386
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100387void *video_hw_init (void)
388{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200389 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100390
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200391 puts ("Video: Fujitsu ");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100392
Anatolij Gustschine8652862009-07-07 13:24:08 +0200393 memset (dev, 0, sizeof (GraphicDevice));
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100394
395#if defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200396 if (card_init () == 0)
397 return NULL;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100398#else
Anatolij Gustschine8652862009-07-07 13:24:08 +0200399 /*
400 * Preliminary init of the onboard graphic controller,
401 * retrieve base address
402 */
403 if ((dev->frameAdrs = board_video_init ()) == 0) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200404 puts ("Controller not found!\n");
Anatolij Gustschine8652862009-07-07 13:24:08 +0200405 return NULL;
Wolfgang Grandeggerc28d3bb2009-10-23 12:03:13 +0200406 } else {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200407 puts ("Lime\n");
Wolfgang Grandeggerc28d3bb2009-10-23 12:03:13 +0200408
409 /* Set Change of Clock Frequency Register */
410 HOST_WR_REG (GC_CCF, CONFIG_SYS_MB862xx_CCF);
411 /* Delay required */
412 udelay(300);
413 /* Set Memory I/F Mode Register) */
414 HOST_WR_REG (GC_MMR, CONFIG_SYS_MB862xx_MMR);
415 }
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100416#endif
417
418 de_init ();
419
420#if !defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200421 board_disp_init ();
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100422#endif
423
Stefan Roese04386f62015-10-02 08:20:35 +0200424#if (defined(CONFIG_LWMON5) || \
425 defined(CONFIG_SOCRATES)) && !(CONFIG_POST & CONFIG_SYS_POST_SYSMON)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100426 /* Lamp on */
427 board_backlight_switch (1);
428#endif
429
Anatolij Gustschine8652862009-07-07 13:24:08 +0200430 return dev;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100431}
432
433/*
434 * Set a RGB color in the LUT
435 */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200436void video_set_lut (unsigned int index, unsigned char r,
437 unsigned char g, unsigned char b)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100438{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200439 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100440
441 L0PAL_WR_REG (index, (r << 16) | (g << 8) | (b));
442}
443
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +0200444#if defined(CONFIG_VIDEO_MB862xx_ACCEL)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100445/*
446 * Drawing engine Fill and BitBlt screen region
447 */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200448void video_hw_rectfill (unsigned int bpp, unsigned int dst_x,
449 unsigned int dst_y, unsigned int dim_x,
450 unsigned int dim_y, unsigned int color)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100451{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200452 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100453
454 de_wait_slots (3);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200455 DE_WR_REG (GC_FC, color);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100456 DE_WR_FIFO (0x09410000);
457 DE_WR_FIFO ((dst_y << 16) | dst_x);
458 DE_WR_FIFO ((dim_y << 16) | dim_x);
459 de_wait ();
460}
461
Anatolij Gustschine8652862009-07-07 13:24:08 +0200462void video_hw_bitblt (unsigned int bpp, unsigned int src_x,
463 unsigned int src_y, unsigned int dst_x,
464 unsigned int dst_y, unsigned int width,
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100465 unsigned int height)
466{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200467 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100468 unsigned int ctrl = 0x0d000000L;
469
470 if (src_x >= dst_x && src_y >= dst_y)
471 ctrl |= 0x00440000L;
472 else if (src_x >= dst_x && src_y <= dst_y)
473 ctrl |= 0x00460000L;
474 else if (src_x <= dst_x && src_y >= dst_y)
475 ctrl |= 0x00450000L;
476 else
477 ctrl |= 0x00470000L;
478
479 de_wait_slots (4);
480 DE_WR_FIFO (ctrl);
481 DE_WR_FIFO ((src_y << 16) | src_x);
482 DE_WR_FIFO ((dst_y << 16) | dst_x);
483 DE_WR_FIFO ((height << 16) | width);
484 de_wait (); /* sync */
485}
Anatolij Gustschin5d16ca82009-10-23 12:03:14 +0200486#endif