7
7
// This file may be distributed under the terms of the GNU LGPLv3 license.
9
#include "geodevga.h" // geodevga_init
9
#include "geodevga.h" // geodevga_setup
10
10
#include "farptr.h" // SET_FARVAR
11
11
#include "biosvar.h" // GET_BDA
12
12
#include "vgabios.h" // VGAREG_*
41
44
union u64_u32_u uand, uor;
48
dprintf(4, "%s(0x%08x, 0x%016llx, 0x%016llx)\n"
49
, __func__, msrAddr, off, on);
46
53
"movw $0x0AC1C, %%dx \n"
141
148
u32 val = geode_mem_read(GET_GLOBAL(GeodeVP) + VP_FP_START + reg);
142
149
dprintf(4, "%s(0x%08x) = 0x%08x\n"
143
, __func__, GET_GLOBAL(GeodeVP) + reg, val);
150
, __func__, GET_GLOBAL(GeodeVP) + VP_FP_START + reg, val);
149
156
dprintf(4, "%s(0x%08x, 0x%08x)\n"
150
157
, __func__, GET_GLOBAL(GeodeVP) + VP_FP_START + reg, val);
151
geode_mem_mask(GET_GLOBAL(GeodeVP) + reg, ~0, val);
158
geode_mem_mask(GET_GLOBAL(GeodeVP) + VP_FP_START + reg, ~0, val);
154
161
/****************************************************************
205
212
****************************************************************/
207
/* Set up the dc (display controller) portion of the geodelx
208
* The dc provides hardware support for VGA graphics.
210
static void dc_setup(void)
212
dprintf(2, "DC_SETUP\n");
214
geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
216
/* zero memory config */
217
geode_dc_write(DC_FB_ST_OFFSET, 0x0);
218
geode_dc_write(DC_CB_ST_OFFSET, 0x0);
219
geode_dc_write(DC_CURS_ST_OFFSET, 0x0);
221
/* read fb-bar from pci, then point dc to the fb base */
222
u32 fb = GET_GLOBAL(GeodeFB);
223
if (geode_dc_read(DC_GLIU0_MEM_OFFSET) != fb)
224
geode_dc_write(DC_GLIU0_MEM_OFFSET, fb);
226
geode_dc_mask(DC_DISPLAY_CFG, ~DC_CFG_MSK, DC_DISPLAY_CFG_GDEN|DC_DISPLAY_CFG_TRUP);
227
geode_dc_write(DC_GENERAL_CFG, DC_DISPLAY_CFG_VGAE);
229
geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
231
u32 fb_size = framebuffer_size(); // in byte
232
dprintf(1, "%d KB of video memory at 0x%08x\n", fb_size / 1024, fb);
234
/* update VBE variables */
235
SET_VGA(VBE_framebuffer, fb);
236
SET_VGA(VBE_total_memory, fb_size / 1024 / 64); // number of 64K blocks
239
/* Setup the vp (video processor) portion of the geodelx
240
* Under VGA modes the vp was handled by softvg from inside VSA2.
241
* Without a softvg module, access is only available through a pci bar.
242
* The High Mem Access virtual register is used to configure the
243
* pci mmio bar from 16bit friendly io space.
245
static void vp_setup(void)
214
static void geodevga_set_output_mode(void)
250
dprintf(2,"VP_SETUP\n");
252
219
/* set output to crt and RGB/YUV */
253
220
if (CONFIG_VGA_GEODEGX2)
254
221
msr_addr = VP_MSR_CONFIG_GX2;
274
241
dprintf(1, "output: CRT\n");
276
243
geode_msr_mask(msr_addr, ~msr, msr);
246
/* Set up the dc (display controller) portion of the geodelx
247
* The dc provides hardware support for VGA graphics.
249
static void dc_setup(void)
251
dprintf(2, "DC_SETUP\n");
253
geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
255
/* zero memory config */
256
geode_dc_write(DC_FB_ST_OFFSET, 0x0);
257
geode_dc_write(DC_CB_ST_OFFSET, 0x0);
258
geode_dc_write(DC_CURS_ST_OFFSET, 0x0);
260
geode_dc_mask(DC_DISPLAY_CFG, ~DC_CFG_MSK, DC_DISPLAY_CFG_GDEN|DC_DISPLAY_CFG_TRUP);
261
geode_dc_write(DC_GENERAL_CFG, DC_GENERAL_CFG_VGAE);
263
geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
266
/* Setup the vp (video processor) portion of the geodelx
267
* Under VGA modes the vp was handled by softvg from inside VSA2.
268
* Without a softvg module, access is only available through a pci bar.
269
* The High Mem Access virtual register is used to configure the
270
* pci mmio bar from 16bit friendly io space.
272
static void vp_setup(void)
274
dprintf(2,"VP_SETUP\n");
276
geodevga_set_output_mode();
279
278
/* Set mmio registers
280
279
* there may be some timing issues here, the reads seem
296
295
/* setup flat panel */
297
296
if (CONFIG_VGA_OUTPUT_PANEL || CONFIG_VGA_OUTPUT_CRT_PANEL) {
298
299
dprintf(1, "Setting up flat panel\n");
299
300
/* write timing register */
300
301
geode_fp_write(FP_PT1, 0x0);
369
370
0x9b, 0x8d, 0x8f, 0x28, 0x40, 0x98, 0xb9, 0xa3,
372
int geodevga_init(void)
373
int geodevga_setup(void)
374
int ret = stdvga_init();
375
int ret = stdvga_setup();
378
dprintf(1,"GEODEVGA_INIT\n");
379
dprintf(1,"GEODEVGA_SETUP\n");
380
381
if ((ret=legacyio_check())) {
381
dprintf(1,"GEODEVGA_INIT legacyio_check=0x%x\n",ret);
382
dprintf(1,"GEODEVGA_SETUP legacyio_check=0x%x\n",ret);
384
385
// Updated timings from geode datasheets, table 6-53 in particular
408
409
dprintf(1, "dc addr: 0x%08x\n", GET_GLOBAL(GeodeDC));
409
410
dprintf(1, "vp addr: 0x%08x\n", GET_GLOBAL(GeodeVP));
412
/* setup framebuffer */
413
geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
415
/* read fb-bar from pci, then point dc to the fb base */
416
u32 fb = GET_GLOBAL(GeodeFB);
417
if (geode_dc_read(DC_GLIU0_MEM_OFFSET) != fb)
418
geode_dc_write(DC_GLIU0_MEM_OFFSET, fb);
420
geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
422
u32 fb_size = framebuffer_size(); // in byte
423
dprintf(1, "%d KB of video memory at 0x%08x\n", fb_size / 1024, fb);
425
/* update VBE variables */
426
SET_VGA(VBE_framebuffer, fb);
427
SET_VGA(VBE_total_memory, fb_size / 1024 / 64); // number of 64K blocks