Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
| 3 | * DENX Software Engineering, Anatolij Gustschin, agust@denx.de |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Jerry Van Baren | 5afb2fe | 2009-02-05 22:18:02 -0500 | [diff] [blame] | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * mb862xx.c - Graphic interface for Fujitsu CoralP/Lime |
| 26 | * PCI and video mode code was derived from smiLynxEM driver. |
| 27 | */ |
| 28 | |
| 29 | #include <common.h> |
| 30 | |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 31 | #include <asm/io.h> |
| 32 | #include <pci.h> |
| 33 | #include <video_fb.h> |
| 34 | #include "videomodes.h" |
| 35 | #include <mb862xx.h> |
| 36 | |
Yuri Tikhonov | 48116dc | 2008-03-24 11:30:54 +0100 | [diff] [blame] | 37 | #if defined(CONFIG_POST) |
| 38 | #include <post.h> |
| 39 | #endif |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 40 | |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 41 | /* |
| 42 | * Graphic Device |
| 43 | */ |
| 44 | GraphicDevice mb862xx; |
| 45 | |
| 46 | /* |
| 47 | * 32MB external RAM - 256K Chip MMIO = 0x1FC0000 ; |
| 48 | */ |
| 49 | #define VIDEO_MEM_SIZE 0x01FC0000 |
| 50 | |
| 51 | #if defined(CONFIG_PCI) |
| 52 | #if defined(CONFIG_VIDEO_CORALP) |
| 53 | |
| 54 | static struct pci_device_id supported[] = { |
| 55 | { PCI_VENDOR_ID_FUJITSU, PCI_DEVICE_ID_CORAL_P }, |
| 56 | { PCI_VENDOR_ID_FUJITSU, PCI_DEVICE_ID_CORAL_PA }, |
| 57 | { } |
| 58 | }; |
| 59 | |
| 60 | /* Internal clock frequency divider table, index is mode number */ |
| 61 | unsigned int fr_div[] = { 0x00000f00, 0x00000900, 0x00000500 }; |
| 62 | #endif |
| 63 | #endif |
| 64 | |
| 65 | #if defined(CONFIG_VIDEO_CORALP) |
| 66 | #define rd_io in32r |
| 67 | #define wr_io out32r |
| 68 | #else |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 69 | #define rd_io(addr) in_be32((volatile unsigned *)(addr)) |
| 70 | #define wr_io(addr, val) out_be32((volatile unsigned *)(addr), (val)) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 71 | #endif |
| 72 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 73 | #define HOST_RD_REG(off) rd_io((dev->frameAdrs + 0x01fc0000 + (off))) |
| 74 | #define HOST_WR_REG(off, val) wr_io((dev->frameAdrs + 0x01fc0000 + (off)), \ |
| 75 | (val)) |
| 76 | #define DISP_RD_REG(off) rd_io((dev->frameAdrs + 0x01fd0000 + (off))) |
| 77 | #define DISP_WR_REG(off, val) wr_io((dev->frameAdrs + 0x01fd0000 + (off)), \ |
| 78 | (val)) |
| 79 | #define DE_RD_REG(off) rd_io((dev->dprBase + (off))) |
| 80 | #define DE_WR_REG(off, val) wr_io((dev->dprBase + (off)), (val)) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 81 | |
| 82 | #if defined(CONFIG_VIDEO_CORALP) |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 83 | #define DE_WR_FIFO(val) wr_io((dev->dprBase + (0x8400)), (val)) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 84 | #else |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 85 | #define DE_WR_FIFO(val) wr_io((dev->dprBase + (0x04a0)), (val)) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 86 | #endif |
| 87 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 88 | #define L0PAL_WR_REG(idx, val) wr_io((dev->frameAdrs + 0x01fd0400 + \ |
| 89 | ((idx) << 2)), (val)) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 90 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 91 | static void gdc_sw_reset (void) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 92 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 93 | GraphicDevice *dev = &mb862xx; |
| 94 | |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 95 | HOST_WR_REG (0x002c, 0x00000001); |
| 96 | udelay (500); |
| 97 | video_hw_init (); |
| 98 | } |
| 99 | |
| 100 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 101 | static void de_wait (void) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 102 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 103 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 104 | int lc = 0x10000; |
| 105 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 106 | /* |
| 107 | * Sync with software writes to framebuffer, |
| 108 | * try to reset if engine locked |
| 109 | */ |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 110 | while (DE_RD_REG (0x0400) & 0x00000131) |
| 111 | if (lc-- < 0) { |
| 112 | gdc_sw_reset (); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 113 | printf ("gdc reset done after drawing engine lock.\n"); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 114 | break; |
| 115 | } |
| 116 | } |
| 117 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 118 | static void de_wait_slots (int slots) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 119 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 120 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 121 | int lc = 0x10000; |
| 122 | |
| 123 | /* Wait for free fifo slots */ |
| 124 | while (DE_RD_REG (0x0408) < slots) |
| 125 | if (lc-- < 0) { |
| 126 | gdc_sw_reset (); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 127 | printf ("gdc reset done after drawing engine lock.\n"); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 128 | break; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | #if !defined(CONFIG_VIDEO_CORALP) |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 133 | static void board_disp_init (void) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 134 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 135 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 136 | const gdc_regs *regs = board_get_regs (); |
| 137 | |
| 138 | while (regs->index) { |
| 139 | DISP_WR_REG (regs->index, regs->value); |
| 140 | regs++; |
| 141 | } |
| 142 | } |
| 143 | #endif |
| 144 | |
| 145 | /* |
| 146 | * Init drawing engine |
| 147 | */ |
| 148 | static void de_init (void) |
| 149 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 150 | GraphicDevice *dev = &mb862xx; |
| 151 | int cf = (dev->gdfBytesPP == 1) ? 0x0000 : 0x8000; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 152 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 153 | dev->dprBase = dev->frameAdrs + 0x01ff0000; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 154 | |
| 155 | /* Setup mode and fbbase, xres, fg, bg */ |
| 156 | de_wait_slots (2); |
| 157 | DE_WR_FIFO (0xf1010108); |
| 158 | DE_WR_FIFO (cf | 0x0300); |
| 159 | DE_WR_REG (0x0440, 0x0000); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 160 | DE_WR_REG (0x0444, dev->winSizeX); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 161 | DE_WR_REG (0x0480, 0x0000); |
| 162 | DE_WR_REG (0x0484, 0x0000); |
| 163 | /* Reset clipping */ |
| 164 | DE_WR_REG (0x0454, 0x0000); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 165 | DE_WR_REG (0x0458, dev->winSizeX); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 166 | DE_WR_REG (0x045c, 0x0000); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 167 | DE_WR_REG (0x0460, dev->winSizeY); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 168 | |
| 169 | /* Clear framebuffer using drawing engine */ |
| 170 | de_wait_slots (3); |
| 171 | DE_WR_FIFO (0x09410000); |
| 172 | DE_WR_FIFO (0x00000000); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 173 | DE_WR_FIFO (dev->winSizeY << 16 | dev->winSizeX); |
Anatolij Gustschin | a8755aa | 2008-07-12 17:31:36 +0200 | [diff] [blame] | 174 | /* sync with SW access to framebuffer */ |
| 175 | de_wait (); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | #if defined(CONFIG_VIDEO_CORALP) |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 179 | unsigned int pci_video_init (void) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 180 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 181 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 182 | pci_dev_t devbusfn; |
| 183 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 184 | if ((devbusfn = pci_find_devices (supported, 0)) < 0) { |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 185 | printf ("PCI video controller not found!\n"); |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | /* PCI setup */ |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 190 | pci_write_config_dword (devbusfn, PCI_COMMAND, |
| 191 | (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)); |
| 192 | pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0, &dev->frameAdrs); |
| 193 | dev->frameAdrs = pci_mem_to_phys (devbusfn, dev->frameAdrs); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 194 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 195 | if (dev->frameAdrs == 0) { |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 196 | printf ("PCI config: failed to get base address\n"); |
| 197 | return 0; |
| 198 | } |
| 199 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 200 | dev->pciBase = dev->frameAdrs; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 201 | |
| 202 | /* Setup clocks and memory mode for Coral-P Eval. Board */ |
| 203 | HOST_WR_REG (0x0038, 0x00090000); |
| 204 | udelay (200); |
| 205 | HOST_WR_REG (0xfffc, 0x11d7fa13); |
| 206 | udelay (100); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 207 | return dev->frameAdrs; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | unsigned int card_init (void) |
| 211 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 212 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 213 | unsigned int cf, videomode, div = 0; |
| 214 | unsigned long t1, hsync, vsync; |
| 215 | char *penv; |
| 216 | int tmp, i, bpp; |
| 217 | struct ctfb_res_modes *res_mode; |
| 218 | struct ctfb_res_modes var_mode; |
| 219 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 220 | memset (dev, 0, sizeof (GraphicDevice)); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 221 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 222 | if (!pci_video_init ()) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 223 | return 0; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 224 | |
| 225 | printf ("CoralP\n"); |
| 226 | |
| 227 | tmp = 0; |
| 228 | videomode = 0x310; |
| 229 | /* get video mode via environment */ |
| 230 | if ((penv = getenv ("videomode")) != NULL) { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 231 | /* decide if it is a string */ |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 232 | if (penv[0] <= '9') { |
| 233 | videomode = (int) simple_strtoul (penv, NULL, 16); |
| 234 | tmp = 1; |
| 235 | } |
| 236 | } else { |
| 237 | tmp = 1; |
| 238 | } |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 239 | |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 240 | if (tmp) { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 241 | /* parameter are vesa modes, search params */ |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 242 | for (i = 0; i < VESA_MODES_COUNT; i++) { |
| 243 | if (vesa_modes[i].vesanr == videomode) |
| 244 | break; |
| 245 | } |
| 246 | if (i == VESA_MODES_COUNT) { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 247 | printf ("\tno VESA Mode found, fallback to mode 0x%x\n", |
| 248 | videomode); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 249 | i = 0; |
| 250 | } |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 251 | res_mode = (struct ctfb_res_modes *) |
| 252 | &res_mode_init[vesa_modes[i].resindex]; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 253 | if (vesa_modes[i].resindex > 2) { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 254 | printf ("\tUnsupported resolution, using default\n"); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 255 | bpp = vesa_modes[1].bits_per_pixel; |
| 256 | div = fr_div[1]; |
| 257 | } |
| 258 | bpp = vesa_modes[i].bits_per_pixel; |
| 259 | div = fr_div[vesa_modes[i].resindex]; |
| 260 | } else { |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 261 | res_mode = (struct ctfb_res_modes *) &var_mode; |
| 262 | bpp = video_get_params (res_mode, penv); |
| 263 | } |
| 264 | |
| 265 | /* calculate hsync and vsync freq (info only) */ |
| 266 | t1 = (res_mode->left_margin + res_mode->xres + |
| 267 | res_mode->right_margin + res_mode->hsync_len) / 8; |
| 268 | t1 *= 8; |
| 269 | t1 *= res_mode->pixclock; |
| 270 | t1 /= 1000; |
| 271 | hsync = 1000000000L / t1; |
| 272 | t1 *= (res_mode->upper_margin + res_mode->yres + |
| 273 | res_mode->lower_margin + res_mode->vsync_len); |
| 274 | t1 /= 1000; |
| 275 | vsync = 1000000000L / t1; |
| 276 | |
| 277 | /* fill in Graphic device struct */ |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 278 | sprintf (dev->modeIdent, "%dx%dx%d %ldkHz %ldHz", res_mode->xres, |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 279 | res_mode->yres, bpp, (hsync / 1000), (vsync / 1000)); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 280 | printf ("\t%s\n", dev->modeIdent); |
| 281 | dev->winSizeX = res_mode->xres; |
| 282 | dev->winSizeY = res_mode->yres; |
| 283 | dev->memSize = VIDEO_MEM_SIZE; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 284 | |
| 285 | switch (bpp) { |
| 286 | case 8: |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 287 | dev->gdfIndex = GDF__8BIT_INDEX; |
| 288 | dev->gdfBytesPP = 1; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 289 | break; |
| 290 | case 15: |
| 291 | case 16: |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 292 | dev->gdfIndex = GDF_15BIT_555RGB; |
| 293 | dev->gdfBytesPP = 2; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 294 | break; |
| 295 | default: |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 296 | printf ("\t%d bpp configured, but only 8,15 and 16 supported\n", |
| 297 | bpp); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 298 | printf ("\tSwitching back to 15bpp\n"); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 299 | dev->gdfIndex = GDF_15BIT_555RGB; |
| 300 | dev->gdfBytesPP = 2; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | /* Setup dot clock (internal pll, division rate) */ |
| 304 | DISP_WR_REG (0x0100, div); |
| 305 | /* L0 init */ |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 306 | cf = (dev->gdfBytesPP == 1) ? 0x00000000 : 0x80000000; |
| 307 | DISP_WR_REG (0x0020, ((dev->winSizeX * dev->gdfBytesPP) / 64) << 16 | |
| 308 | (dev->winSizeY - 1) | cf); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 309 | DISP_WR_REG (0x0024, 0x00000000); |
| 310 | DISP_WR_REG (0x0028, 0x00000000); |
| 311 | DISP_WR_REG (0x002c, 0x00000000); |
| 312 | DISP_WR_REG (0x0110, 0x00000000); |
| 313 | DISP_WR_REG (0x0114, 0x00000000); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 314 | DISP_WR_REG (0x0118, (dev->winSizeY - 1) << 16 | dev->winSizeX); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 315 | |
| 316 | /* Display timing init */ |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 317 | DISP_WR_REG (0x0004, (dev->winSizeX + |
| 318 | res_mode->left_margin + |
| 319 | res_mode->right_margin + |
| 320 | res_mode->hsync_len - 1) << 16); |
| 321 | DISP_WR_REG (0x0008, (dev->winSizeX - 1) << 16 | (dev->winSizeX - 1)); |
| 322 | DISP_WR_REG (0x000c, (res_mode->vsync_len - 1) << 24 | |
| 323 | (res_mode->hsync_len - 1) << 16 | |
| 324 | (dev->winSizeX + res_mode->right_margin - 1)); |
| 325 | DISP_WR_REG (0x0010, (dev->winSizeY + res_mode->lower_margin + |
| 326 | res_mode->upper_margin + |
| 327 | res_mode->vsync_len - 1) << 16); |
| 328 | DISP_WR_REG (0x0014, (dev->winSizeY-1) << 16 | |
| 329 | (dev->winSizeY + res_mode->lower_margin - 1)); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 330 | DISP_WR_REG (0x0018, 0x00000000); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 331 | DISP_WR_REG (0x001c, dev->winSizeY << 16 | dev->winSizeX); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 332 | /* Display enable, L0 layer */ |
| 333 | DISP_WR_REG (0x0100, 0x80010000 | div); |
| 334 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 335 | return dev->frameAdrs; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 336 | } |
| 337 | #endif |
| 338 | |
| 339 | void *video_hw_init (void) |
| 340 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 341 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 342 | |
| 343 | printf ("Video: Fujitsu "); |
| 344 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 345 | memset (dev, 0, sizeof (GraphicDevice)); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 346 | |
| 347 | #if defined(CONFIG_VIDEO_CORALP) |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 348 | if (card_init () == 0) |
| 349 | return NULL; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 350 | #else |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 351 | /* |
| 352 | * Preliminary init of the onboard graphic controller, |
| 353 | * retrieve base address |
| 354 | */ |
| 355 | if ((dev->frameAdrs = board_video_init ()) == 0) { |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 356 | printf ("Controller not found!\n"); |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 357 | return NULL; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 358 | } else |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 359 | printf ("Lime\n"); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 360 | #endif |
| 361 | |
| 362 | de_init (); |
| 363 | |
| 364 | #if !defined(CONFIG_VIDEO_CORALP) |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 365 | board_disp_init (); |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 366 | #endif |
| 367 | |
Anatolij Gustschin | e6f5c91 | 2008-08-15 15:42:13 +0200 | [diff] [blame] | 368 | #if (defined(CONFIG_LWMON5) || \ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 369 | defined(CONFIG_SOCRATES)) && !(CONFIG_POST & CONFIG_SYS_POST_SYSMON) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 370 | /* Lamp on */ |
| 371 | board_backlight_switch (1); |
| 372 | #endif |
| 373 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 374 | return dev; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | /* |
| 378 | * Set a RGB color in the LUT |
| 379 | */ |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 380 | void video_set_lut (unsigned int index, unsigned char r, |
| 381 | unsigned char g, unsigned char b) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 382 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 383 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 384 | |
| 385 | L0PAL_WR_REG (index, (r << 16) | (g << 8) | (b)); |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | * Drawing engine Fill and BitBlt screen region |
| 390 | */ |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 391 | void video_hw_rectfill (unsigned int bpp, unsigned int dst_x, |
| 392 | unsigned int dst_y, unsigned int dim_x, |
| 393 | unsigned int dim_y, unsigned int color) |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 394 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 395 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 396 | |
| 397 | de_wait_slots (3); |
| 398 | DE_WR_REG (0x0480, color); |
| 399 | DE_WR_FIFO (0x09410000); |
| 400 | DE_WR_FIFO ((dst_y << 16) | dst_x); |
| 401 | DE_WR_FIFO ((dim_y << 16) | dim_x); |
| 402 | de_wait (); |
| 403 | } |
| 404 | |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 405 | void video_hw_bitblt (unsigned int bpp, unsigned int src_x, |
| 406 | unsigned int src_y, unsigned int dst_x, |
| 407 | unsigned int dst_y, unsigned int width, |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 408 | unsigned int height) |
| 409 | { |
Anatolij Gustschin | 4d991e9 | 2009-07-07 13:24:08 +0200 | [diff] [blame^] | 410 | GraphicDevice *dev = &mb862xx; |
Anatolij Gustschin | 3545f59 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 411 | unsigned int ctrl = 0x0d000000L; |
| 412 | |
| 413 | if (src_x >= dst_x && src_y >= dst_y) |
| 414 | ctrl |= 0x00440000L; |
| 415 | else if (src_x >= dst_x && src_y <= dst_y) |
| 416 | ctrl |= 0x00460000L; |
| 417 | else if (src_x <= dst_x && src_y >= dst_y) |
| 418 | ctrl |= 0x00450000L; |
| 419 | else |
| 420 | ctrl |= 0x00470000L; |
| 421 | |
| 422 | de_wait_slots (4); |
| 423 | DE_WR_FIFO (ctrl); |
| 424 | DE_WR_FIFO ((src_y << 16) | src_x); |
| 425 | DE_WR_FIFO ((dst_y << 16) | dst_x); |
| 426 | DE_WR_FIFO ((height << 16) | width); |
| 427 | de_wait (); /* sync */ |
| 428 | } |