2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License v2 as published by
8 * the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <device/device.h>
21 #include <device/pci.h>
22 #include <device/pci_ops.h>
23 #include <device/pci_ids.h>
24 #include <console/console.h>
25 #include <cpu/x86/msr.h>
26 #include <cpu/amd/mtrr.h>
28 static void dram_enable(struct device *dev)
34 * Enable Lowest Interrupt arbitration for APIC, enable NB APIC
35 * decoding, MSI support, no SMRAM, compatible SMM.
37 pci_write_config8(dev, 0x86, 0x39);
40 * We want to use the 0xC0000-0xEFFFF as RAM mark area as RW, even if
41 * memory is doing K8 the DMA from SB will fail if we have it wrong,
42 * AND even we have it here, we must later copy it to SB to make it work :/
45 /* For CC000-CFFFF, bits 7:6 (10 = REn, 01 = WEn) bits 1:0 for
48 pci_write_config8(dev, 0x80, 0xff);
49 /* For page D0000-DFFFF */
50 pci_write_config8(dev, 0x81, 0xff);
51 /* For page E0000-EFFFF */
52 pci_write_config8(dev, 0x82, 0xff);
53 pci_write_config8(dev, 0x83, 0x30);
56 reg = pci_read_config16(dev, 0x84);
58 pci_write_config16(dev, 0x84, (msr.lo >> 16) | reg);
60 reg = pci_read_config16(dev, 0x88);
63 pci_write_config16(dev, 0x88, (msr.lo >> 24) | reg);
66 static struct device_operations dram_ops = {
67 .read_resources = pci_dev_read_resources,
68 .set_resources = pci_dev_set_resources,
69 .enable_resources = pci_dev_enable_resources,
70 .enable = dram_enable,
74 static struct pci_driver northbridge_driver __pci_driver = {
76 .vendor = PCI_VENDOR_ID_VIA,
77 .device = PCI_DEVICE_ID_VIA_K8T890CE_3,