2 * This file is part of the coreboot project.
4 * Copyright (C) 2003 Ronald G. Minnich
5 * Copyright (C) 2003-2004 Eric W. Biederman
6 * Copyright (C) 2006 Jon Dufresne <jon.dufresne@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <console/console.h>
26 #include <device/device.h>
27 #include <device/pci.h>
28 #include <device/pci_ids.h>
32 #include <cpu/x86/cache.h>
36 static void northbridge_init(device_t dev)
38 printk(BIOS_SPEW, "Northbridge init\n");
41 static struct device_operations northbridge_operations = {
42 .read_resources = pci_dev_read_resources,
43 .set_resources = pci_dev_set_resources,
44 .enable_resources = pci_dev_enable_resources,
45 .init = northbridge_init,
50 static const struct pci_driver northbridge_driver __pci_driver = {
51 .ops = &northbridge_operations,
52 .vendor = PCI_VENDOR_ID_INTEL,
56 #if CONFIG_WRITE_HIGH_TABLES==1
57 #define HIGH_TABLES_SIZE 64 // maximum size of high tables in KB
58 extern uint64_t high_tables_base, high_tables_size;
60 static void pci_domain_set_resources(device_t dev)
65 printk(BIOS_DEBUG, "Entered with dev vid = %x\n", dev->vendor);
66 printk(BIOS_DEBUG, "Entered with dev did = %x\n", dev->device);
68 pci_tolm = find_pci_tolm(dev->link_list);
69 mc_dev = dev->link_list->children->sibling;
70 printk(BIOS_DEBUG, "MC dev vendor = %x\n", mc_dev->vendor);
71 printk(BIOS_DEBUG, "MC dev device = %x\n", mc_dev->device);
74 /* Figure out which areas are/should be occupied by RAM.
75 * This is all computed in kilobytes and converted to/from
76 * the memory controller right at the edges.
77 * Having different variables in different units is
78 * too confusing to get right. Kilobytes are good up to
79 * 4 Terabytes of RAM...
81 unsigned long tomk, tolmk;
84 /* Get the value of the highest DRB. This tells the end of
85 * the physical memory. The units are ticks of 32MB
88 tomk = (unsigned long)pci_read_config8(mc_dev, 0x43);
89 tomk = tomk * 32 * 1024;
90 /* add vga_mem detection */
91 tomk = tomk - 16 * 1024;
92 /* Compute the top of Low memory */
93 tolmk = pci_tolm >> 10;
95 /* The PCI hole does not overlap memory
99 /* Write the ram configuration registers,
100 * preserving the reserved bits.
103 /* Report the memory regions */
104 printk(BIOS_DEBUG, "tomk = %ld\n", tomk);
105 printk(BIOS_DEBUG, "tolmk = %ld\n", tolmk);
108 /* avoid pam region */
109 ram_resource(dev, idx++, 0, 640);
110 /* ram_resource(dev, idx++, 1024, tolmk - 1024); */
111 ram_resource(dev, idx++, 768, tolmk - 768);
113 #if CONFIG_WRITE_HIGH_TABLES==1
114 /* Leave some space for ACPI, PIRQ and MP tables */
115 high_tables_base = (tomk - HIGH_TABLES_SIZE) * 1024;
116 high_tables_size = HIGH_TABLES_SIZE * 1024;
119 assign_resources(dev->link_list);
122 static struct device_operations pci_domain_ops = {
123 .read_resources = pci_domain_read_resources,
124 .set_resources = pci_domain_set_resources,
125 .enable_resources = NULL,
127 .scan_bus = pci_domain_scan_bus,
130 static void cpu_bus_init(device_t dev)
132 initialize_cpus(dev->link_list);
135 static void cpu_bus_noop(device_t dev)
139 static struct device_operations cpu_bus_ops = {
140 .read_resources = cpu_bus_noop,
141 .set_resources = cpu_bus_noop,
142 .enable_resources = cpu_bus_noop,
143 .init = cpu_bus_init,
147 static void enable_dev(struct device *dev)
149 /* Set the operations if it is a special bus type */
150 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
151 dev->ops = &pci_domain_ops;
154 else if (dev->path.type == DEVICE_PATH_APIC_CLUSTER) {
155 dev->ops = &cpu_bus_ops;
159 struct chip_operations northbridge_intel_i855_ops = {
160 CHIP_NAME("Intel 855 Northbridge")
161 .enable_dev = enable_dev,