blob: 1adb9af7c1907682a67444cf845ca7e903dc7006 [file] [log] [blame]
Marc Jones734daf62007-05-04 18:58:42 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Jordan Crouseb29209f2007-05-10 17:57:03 +00003 *
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Jordan Crouseb29209f2007-05-10 17:57:03 +000015 */
Marc Jones734daf62007-05-04 18:58:42 +000016
Ron Minnich5e9dc232006-07-28 16:06:16 +000017#include <arch/io.h>
18#include <stdint.h>
19#include <cpu/amd/vr.h>
Indrek Kruusa7d944122006-09-13 21:59:09 +000020#include <console/console.h>
Edwin Beasant4355beb2010-01-27 19:20:29 +000021#include <cpu/amd/lxdef.h>
22#include <cpu/x86/msr.h>
23#include <stdlib.h>
24
25void geodelx_vga_msr_init(void);
26void graphics_init(void);
27
28struct msrinit {
29 u32 msrnum;
30 msr_t msr;
31};
32
33static const struct msrinit geodelx_vga_msr[] = {
Stefan Reinauer14e22772010-04-27 06:56:47 +000034 /* Enable the GLIU Memory routing to the hardware
Edwin Beasant4355beb2010-01-27 19:20:29 +000035 * PDID1 : Port 4, GLIU0
36 * PBASE : 0x000A0
37 * PMASK : 0xFFFE0
38 */
39 {.msrnum = MSR_GLIU0_BASE4, {.lo = 0x0a0fffe0, .hi = 0x80000000}},
40 /* Enable the GLIU IO Routing
41 * IDID : Port 4, GLIU0
42 * IBASE : 0x003c0
43 * IMASK : 0xffff0
44 */
45 {.msrnum = GLIU0_IOD_BM_0, {.lo = 0x3c0ffff0, .hi = 0x80000000}},
46 /* Enable the GLIU IO Routing
47 * IDID : Port 4, GLIU0
48 * IBASE : 0x003d0
49 * IMASK : 0xffff0
50 */
51 {.msrnum = GLIU0_IOD_BM_1, {.lo = 0x3d0ffff0, .hi = 0x80000000}},
52};
53
54void geodelx_vga_msr_init(void)
55{
56 int i;
57 for (i = 0; i < ARRAY_SIZE(geodelx_vga_msr); i++)
58 wrmsr(geodelx_vga_msr[i].msrnum, geodelx_vga_msr[i].msr);
59}
Ron Minnich5e9dc232006-07-28 16:06:16 +000060
Ron Minnich5e9dc232006-07-28 16:06:16 +000061 /*
Jordan Crousef8030bd2007-05-10 18:16:03 +000062 * This function mirrors the Graphics_Init routine in GeodeROM.
63 */
Ron Minnich5e9dc232006-07-28 16:06:16 +000064void graphics_init(void)
65{
Indrek Kruusa7d944122006-09-13 21:59:09 +000066 uint16_t wClassIndex, wData, res;
Jordan Crousef8030bd2007-05-10 18:16:03 +000067
Ron Minnich5e9dc232006-07-28 16:06:16 +000068 /* SoftVG initialization */
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000069 printk(BIOS_DEBUG, "Graphics init...\n");
Stefan Reinauer14e22772010-04-27 06:56:47 +000070
Edwin Beasant4355beb2010-01-27 19:20:29 +000071 geodelx_vga_msr_init();
Stefan Reinauer14e22772010-04-27 06:56:47 +000072
Ron Minnich5e9dc232006-07-28 16:06:16 +000073 /* Call SoftVG with the main configuration parameters. */
Indrek Kruusa7d944122006-09-13 21:59:09 +000074 /* NOTE: SoftVG expects the memory size to be given in 2MB blocks */
Jordan Crousef8030bd2007-05-10 18:16:03 +000075
76 wClassIndex = (VRC_VG << 8) + VG_CONFIG;
77
Indrek Kruusa7d944122006-09-13 21:59:09 +000078 /*
Jordan Crousef8030bd2007-05-10 18:16:03 +000079 * Graphics Driver Enabled (13) 0, NO (lets BIOS controls the GP)
80 * External Monochrome Card Support(12) 0, NO
81 * Controller Priority Select(11) 1, Primary
82 * Display Select(10:8) 0x0, CRT
83 * Graphics Memory Size(7:1) CONFIG_VIDEO_MB >> 1,
Uwe Hermann607614d2010-11-18 20:12:13 +000084 * defined in devicetree.cb
Jordan Crousef8030bd2007-05-10 18:16:03 +000085 * PLL Reference Clock Bypass(0) 0, Default
Indrek Kruusa7d944122006-09-13 21:59:09 +000086 */
87
Marc Jones734daf62007-05-04 18:58:42 +000088 /* Video RAM has to be given in 2MB chunks
Indrek Kruusa7d944122006-09-13 21:59:09 +000089 * the value is read @ 7:1 (value in 7:0 looks like /2)
90 * so we can add the real value in megabytes
91 */
Jordan Crousef8030bd2007-05-10 18:16:03 +000092
Stefan Reinauer14e22772010-04-27 06:56:47 +000093 wData = VG_CFG_DRIVER | VG_CFG_PRIORITY |
Jordan Crousef8030bd2007-05-10 18:16:03 +000094 VG_CFG_DSCRT | (CONFIG_VIDEO_MB & VG_MEM_MASK);
Indrek Kruusa7d944122006-09-13 21:59:09 +000095 vrWrite(wClassIndex, wData);
Jordan Crousef8030bd2007-05-10 18:16:03 +000096
Indrek Kruusa7d944122006-09-13 21:59:09 +000097 res = vrRead(wClassIndex);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000098 printk(BIOS_DEBUG, "VRC_VG value: 0x%04x\n", res);
Ron Minnich5e9dc232006-07-28 16:06:16 +000099}