~ubuntu-branches/ubuntu/saucy/seabios/saucy-proposed

« back to all changes in this revision

Viewing changes to vgasrc/geodevga.c

  • Committer: Package Import Robot
  • Author(s): Michael Tokarev
  • Date: 2013-07-08 21:34:44 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20130708213444-6ed9q23j39x143lu
Tags: 1.7.3-1
Multi-Arch: allowed

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
//
7
7
// This file may be distributed under the terms of the GNU LGPLv3 license.
8
8
 
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_*
33
33
        : "c"(msrAddr)
34
34
        : "cc"
35
35
    );
 
36
 
 
37
    dprintf(4, "%s(0x%08x) = 0x%08x-0x%08x\n"
 
38
            , __func__, msrAddr, val.hi, val.lo);
36
39
    return val.val;
37
40
}
38
41
 
41
44
    union u64_u32_u uand, uor;
42
45
    uand.val = ~off;
43
46
    uor.val = on;
 
47
 
 
48
    dprintf(4, "%s(0x%08x, 0x%016llx, 0x%016llx)\n"
 
49
            , __func__, msrAddr, off, on);
 
50
 
44
51
    asm __volatile__ (
45
52
        "push   %%eax                   \n"
46
53
        "movw   $0x0AC1C, %%dx          \n"
140
147
{
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);
144
151
    return val;
145
152
}
146
153
 
148
155
{
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);
152
159
}
153
160
 
154
161
/****************************************************************
204
211
* Init Functions
205
212
****************************************************************/
206
213
 
207
 
/* Set up the dc (display controller) portion of the geodelx
208
 
*  The dc provides hardware support for VGA graphics.
209
 
*/
210
 
static void dc_setup(void)
211
 
{
212
 
    dprintf(2, "DC_SETUP\n");
213
 
 
214
 
    geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
215
 
 
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);
220
 
 
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);
225
 
 
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);
228
 
 
229
 
    geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
230
 
 
231
 
    u32 fb_size = framebuffer_size(); // in byte
232
 
    dprintf(1, "%d KB of video memory at 0x%08x\n", fb_size / 1024, fb);
233
 
 
234
 
    /* update VBE variables */
235
 
    SET_VGA(VBE_framebuffer, fb);
236
 
    SET_VGA(VBE_total_memory, fb_size / 1024 / 64); // number of 64K blocks
237
 
}
238
 
 
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.
244
 
*/
245
 
static void vp_setup(void)
246
 
{
247
 
    u32 msr_addr;
 
214
static void geodevga_set_output_mode(void)
 
215
{
 
216
    u64 msr_addr;
248
217
    u64 msr;
249
218
 
250
 
    dprintf(2,"VP_SETUP\n");
251
 
 
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");
275
242
    }
276
243
    geode_msr_mask(msr_addr, ~msr, msr);
277
 
 
 
244
}
 
245
 
 
246
/* Set up the dc (display controller) portion of the geodelx
 
247
*  The dc provides hardware support for VGA graphics.
 
248
*/
 
249
static void dc_setup(void)
 
250
{
 
251
    dprintf(2, "DC_SETUP\n");
 
252
 
 
253
    geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
 
254
 
 
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);
 
259
 
 
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);
 
262
 
 
263
    geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
 
264
}
 
265
 
 
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.
 
271
*/
 
272
static void vp_setup(void)
 
273
{
 
274
    dprintf(2,"VP_SETUP\n");
 
275
 
 
276
    geodevga_set_output_mode();
278
277
 
279
278
    /* Set mmio registers
280
279
    * there may be some timing issues here, the reads seem
295
294
 
296
295
    /* setup flat panel */
297
296
    if (CONFIG_VGA_OUTPUT_PANEL || CONFIG_VGA_OUTPUT_CRT_PANEL) {
 
297
        u64 msr;
 
298
 
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,
370
371
    0xff };
371
372
 
372
 
int geodevga_init(void)
 
373
int geodevga_setup(void)
373
374
{
374
 
    int ret = stdvga_init();
 
375
    int ret = stdvga_setup();
375
376
    if (ret)
376
377
        return ret;
377
378
 
378
 
    dprintf(1,"GEODEVGA_INIT\n");
 
379
    dprintf(1,"GEODEVGA_SETUP\n");
379
380
 
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);
382
383
    }
383
384
 
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));
410
411
 
 
412
    /* setup framebuffer */
 
413
    geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
 
414
 
 
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);
 
419
 
 
420
    geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
 
421
 
 
422
    u32 fb_size = framebuffer_size(); // in byte
 
423
    dprintf(1, "%d KB of video memory at 0x%08x\n", fb_size / 1024, fb);
 
424
 
 
425
    /* update VBE variables */
 
426
    SET_VGA(VBE_framebuffer, fb);
 
427
    SET_VGA(VBE_total_memory, fb_size / 1024 / 64); // number of 64K blocks
 
428
 
411
429
    vp_setup();
412
430
    dc_setup();
413
431