Marc Jones | 734daf6 | 2007-05-04 18:58:42 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Jordan Crouse | b29209f | 2007-05-10 17:57:03 +0000 | [diff] [blame] | 3 | * |
| 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 Crouse | b29209f | 2007-05-10 17:57:03 +0000 | [diff] [blame] | 15 | */ |
Marc Jones | 734daf6 | 2007-05-04 18:58:42 +0000 | [diff] [blame] | 16 | |
Ron Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 17 | #include <arch/io.h> |
| 18 | #include <stdint.h> |
| 19 | #include <cpu/amd/vr.h> |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 20 | #include <console/console.h> |
Edwin Beasant | 4355beb | 2010-01-27 19:20:29 +0000 | [diff] [blame] | 21 | #include <cpu/amd/lxdef.h> |
| 22 | #include <cpu/x86/msr.h> |
| 23 | #include <stdlib.h> |
| 24 | |
| 25 | void geodelx_vga_msr_init(void); |
| 26 | void graphics_init(void); |
| 27 | |
| 28 | struct msrinit { |
| 29 | u32 msrnum; |
| 30 | msr_t msr; |
| 31 | }; |
| 32 | |
| 33 | static const struct msrinit geodelx_vga_msr[] = { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 34 | /* Enable the GLIU Memory routing to the hardware |
Edwin Beasant | 4355beb | 2010-01-27 19:20:29 +0000 | [diff] [blame] | 35 | * 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 | |
| 54 | void 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 Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 60 | |
Ron Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 61 | /* |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 62 | * This function mirrors the Graphics_Init routine in GeodeROM. |
| 63 | */ |
Ron Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 64 | void graphics_init(void) |
| 65 | { |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 66 | uint16_t wClassIndex, wData, res; |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 67 | |
Ron Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 68 | /* SoftVG initialization */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 69 | printk(BIOS_DEBUG, "Graphics init...\n"); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 70 | |
Edwin Beasant | 4355beb | 2010-01-27 19:20:29 +0000 | [diff] [blame] | 71 | geodelx_vga_msr_init(); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 72 | |
Ron Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 73 | /* Call SoftVG with the main configuration parameters. */ |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 74 | /* NOTE: SoftVG expects the memory size to be given in 2MB blocks */ |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 75 | |
| 76 | wClassIndex = (VRC_VG << 8) + VG_CONFIG; |
| 77 | |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 78 | /* |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 79 | * 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 Hermann | 607614d | 2010-11-18 20:12:13 +0000 | [diff] [blame] | 84 | * defined in devicetree.cb |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 85 | * PLL Reference Clock Bypass(0) 0, Default |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 86 | */ |
| 87 | |
Marc Jones | 734daf6 | 2007-05-04 18:58:42 +0000 | [diff] [blame] | 88 | /* Video RAM has to be given in 2MB chunks |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 89 | * 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 Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 92 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 93 | wData = VG_CFG_DRIVER | VG_CFG_PRIORITY | |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 94 | VG_CFG_DSCRT | (CONFIG_VIDEO_MB & VG_MEM_MASK); |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 95 | vrWrite(wClassIndex, wData); |
Jordan Crouse | f8030bd | 2007-05-10 18:16:03 +0000 | [diff] [blame] | 96 | |
Indrek Kruusa | 7d94412 | 2006-09-13 21:59:09 +0000 | [diff] [blame] | 97 | res = vrRead(wClassIndex); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 98 | printk(BIOS_DEBUG, "VRC_VG value: 0x%04x\n", res); |
Ron Minnich | 5e9dc23 | 2006-07-28 16:06:16 +0000 | [diff] [blame] | 99 | } |