printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / northbridge / intel / i82830 / northbridge.c
index 689bf19bc2dfcca4c814488b8b3c3e76d27b3ede..5cd13b7033b164108343a4638b42f7d21ad36fd6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the coreboot project.
  *
- * Copyright (C) 2008 Joseph Smith <joe@smittys.pointclark.net>
+ * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include <stdlib.h>
 #include <string.h>
 #include <bitops.h>
+#include <boot/tables.h>
+#include <arch/coreboot_tables.h>
 #include "chip.h"
 #include "i82830.h"
 
 static void northbridge_init(device_t dev)
 {
-       printk_spew("Northbridge init\n");
+       printk(BIOS_SPEW, "Northbridge init\n");
 }
 
 static struct device_operations northbridge_operations = {
@@ -45,31 +47,12 @@ static struct device_operations northbridge_operations = {
        .ops_pci = 0,
 };
 
-static struct pci_driver northbridge_driver __pci_driver = {
+static const struct pci_driver northbridge_driver __pci_driver = {
        .ops = &northbridge_operations,
        .vendor = PCI_VENDOR_ID_INTEL,
        .device = 0x3575,
 };
 
-#define BRIDGE_IO_MASK (IORESOURCE_IO | IORESOURCE_MEM)
-
-static void pci_domain_read_resources(device_t dev)
-{
-       struct resource *resource;
-
-       /* Initialize the system wide I/O space constraints. */
-       resource = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0));
-       resource->limit = 0xffffUL;
-       resource->flags =
-           IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | IORESOURCE_ASSIGNED;
-
-       /* Initialize the system wide memory resources constraints. */
-       resource = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0));
-       resource->limit = 0xffffffffULL;
-       resource->flags =
-           IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE | IORESOURCE_ASSIGNED;
-}
-
 static void ram_resource(device_t dev, unsigned long index,
                         unsigned long basek, unsigned long sizek)
 {
@@ -107,6 +90,22 @@ static uint32_t find_pci_tolm(struct bus *bus)
        return tolm;
 }
 
+/* IGD memory */
+uint64_t uma_memory_base=0, uma_memory_size=0;
+
+int add_northbridge_resources(struct lb_memory *mem)
+{
+       printk(BIOS_DEBUG, "Adding IGD UMA memory area\n");
+       lb_add_memory_range(mem, LB_MEM_RESERVED,
+               uma_memory_base, uma_memory_size);
+
+       return 0;
+}
+
+#if CONFIG_WRITE_HIGH_TABLES==1
+#define HIGH_TABLES_SIZE 64    // maximum size of high tables in KB
+extern uint64_t high_tables_base, high_tables_size;
+#endif
 static void pci_domain_set_resources(device_t dev)
 {
        device_t mc_dev;
@@ -121,8 +120,10 @@ static void pci_domain_set_resources(device_t dev)
 
                if (CONFIG_VIDEO_MB == 512) {
                        igd_memory = (CONFIG_VIDEO_MB);
+                       printk(BIOS_DEBUG, "%dKB IGD UMA\n", igd_memory >> 10);
                } else {
                        igd_memory = (CONFIG_VIDEO_MB * 1024);
+                       printk(BIOS_DEBUG, "%dMB IGD UMA\n", igd_memory >> 10);
                }
 
                /* Get the value of the highest DRB. This tells the end of
@@ -131,7 +132,11 @@ static void pci_domain_set_resources(device_t dev)
                 */
                tomk = ((unsigned long)pci_read_config8(mc_dev, DRB + 3)) << 15;
                tomk -= igd_memory;
-               printk_debug("Setting RAM size to %d\n", tomk);
+
+               /* For reserving UMA memory in the memory map */
+               uma_memory_base = tomk * 1024ULL;
+               uma_memory_size = igd_memory * 1024ULL;
+               printk(BIOS_DEBUG, "Available memory: %ldKB\n", tomk);
 
                /* Compute the top of low memory. */
                tolmk = pci_tolm >> 10;
@@ -144,16 +149,16 @@ static void pci_domain_set_resources(device_t dev)
                idx = 10;
                ram_resource(dev, idx++, 0, 640);
                ram_resource(dev, idx++, 1024, tolmk - 1024);
+
+#if CONFIG_WRITE_HIGH_TABLES==1
+               /* Leave some space for ACPI, PIRQ and MP tables */
+               high_tables_base = (tomk - HIGH_TABLES_SIZE) * 1024;
+               high_tables_size = HIGH_TABLES_SIZE * 1024;
+#endif
        }
        assign_resources(&dev->link[0]);
 }
 
-static unsigned int pci_domain_scan_bus(device_t dev, unsigned int max)
-{
-       max = pci_scan_bus(&dev->link[0], PCI_DEVFN(0, 0), 0xff, max);
-       return max;
-}
-
 static struct device_operations pci_domain_ops = {
        .read_resources         = pci_domain_read_resources,
        .set_resources          = pci_domain_set_resources,