2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Corey Osgood <corey.osgood@gmail.com>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * Note: Some of the VGA control registers are located on the memory
23 * controller. Registers are set both in raminit.c and northbridge.c.
26 #include <console/console.h>
29 #include <device/device.h>
30 #include <device/pci.h>
31 #include <device/pci_ids.h>
37 #include "northbridge.h"
40 void write_protect_vgabios(void)
42 /* Don't bother for now. */
45 static void vga_init(device_t dev)
49 print_debug("Copying BOCHS BIOS to 0xf000\n");
51 * Copy BOCHS BIOS from 4G-ROM_SIZE-64k (in flash) to 0xf0000 (in RAM)
52 * This is for compatibility with the VGA ROM's BIOS callbacks.
54 memcpy(0xf0000, (0xffffffff - ROM_SIZE - 0xffff), 0x10000);
56 printk_debug("Initializing VGA\n");
58 /* Set memory rate to 200 MHz. */
59 outb(0x3d, CRTM_INDEX);
60 reg8 = inb(CRTM_DATA);
63 outb(0x3d, CRTM_INDEX);
64 outb(reg8, CRTM_DATA);
66 /* Set framebuffer size. */
67 reg8 = (CONFIG_VIDEO_MB / 4);
71 pci_write_config8(dev, 0x04, 0x07);
72 pci_write_config8(dev, 0x0d, 0x20);
73 pci_write_config32(dev, 0x10, 0xf4000008);
74 pci_write_config32(dev, 0x14, 0xfb000000);
76 printk_debug("INSTALL REAL-MODE IDT\n");
78 printk_debug("DO THE VGA BIOS\n");
80 /* VGA seems to work without this, but crash & burn with it. */
81 // printk_debug("Enable VGA console\n");
82 // vga_enable_console();
84 /* It's not clear if these need to be programmed before or after
85 * the VGA BIOS runs. Try both, clean up later. */
86 /* Set memory rate to 200 MHz (again). */
87 outb(0x3d, CRTM_INDEX);
88 reg8 = inb(CRTM_DATA);
91 outb(0x3d, CRTM_INDEX);
92 outb(reg8, CRTM_DATA);
94 /* Set framebuffer size (again). */
95 reg8 = (CONFIG_VIDEO_MB / 4);
99 /* Clear the BOCHS BIOS out of memory, so it doesn't confuse Linux. */
100 memset(0xf0000, 0, 0x10000);
103 static void vga_read_resources(device_t dev)
105 dev->rom_address = 0xfff80000;
106 dev->on_mainboard = 1;
107 pci_dev_read_resources(dev);
110 static const struct device_operations vga_operations = {
111 .read_resources = vga_read_resources,
112 .set_resources = pci_dev_set_resources,
113 .enable_resources = pci_dev_enable_resources,
118 static const struct pci_driver vga_driver __pci_driver = {
119 .ops = &vga_operations,
120 .vendor = PCI_VENDOR_ID_VIA,
121 .device = PCI_DEVICE_ID_VIA_CN700_VGA,