MTRR related improvements for AMD family 10h and family 0Fh systems
[coreboot.git] / src / northbridge / amd / amdk8 / amdk8_acpi.c
index ba4b75a0ce224ea3b80ee328d90d02272e14abb4..712315ee09ab8a057945ca91b1994eb7b0b92f31 100644 (file)
@@ -1,42 +1,28 @@
-/*============================================================================
-Copyright 2005 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
-This software and any related documentation (the "Materials") are the
-confidential proprietary information of AMD. Unless otherwise provided in a
-software agreement specifically licensing the Materials, the Materials are
-provided in confidence and may not be distributed, modified, or reproduced in
-whole or in part by any means.
-LIMITATION OF LIABILITY: THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY
-EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO
-WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY
-PARTICULAR PURPOSE, OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR
-USAGE OF TRADE. IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY
-DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS,
-BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OF OR
-INABILITY TO USE THE MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION
-OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
-LIMITATION MAY NOT APPLY TO YOU.
-AMD does not assume any responsibility for any errors which may appear in the
-Materials nor any responsibility to support or update the Materials. AMD
-retains the right to modify the Materials at any time, without notice, and is
-not obligated to provide such modified Materials to you.
-NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
-further information, software, technical information, know-how, or show-how
-available to you.
-U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with "RESTRICTED
-RIGHTS." Use, duplication, or disclosure by the Government is subject to the
-restrictions as set forth in FAR 52.227-14 and DFAR 252.227-7013, et seq., or
-its successor. Use of the Materials by the Government constitutes
-acknowledgement of AMD's proprietary rights in them.
-============================================================================*/
-// 2005.9 serengeti support
-// by yhlu
-//
-
 /*
- * 2005.9 yhlu add madt lapic creat dynamically and SRAT related
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2005 Advanced Micro Devices, Inc.
+ * Copyright (C) 2010 Advanced Micro Devices, Inc.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+/*
+ * Description: Add madt lapic creat dynamically and SRAT related by yhlu
+*/
+
 #include <console/console.h>
 #include <string.h>
 #include <arch/acpi.h>
@@ -45,28 +31,10 @@ acknowledgement of AMD's proprietary rights in them.
 #include <cpu/x86/msr.h>
 #include <cpu/amd/mtrr.h>
 #include <cpu/amd/amdk8_sysconf.h>
+#include "amdk8_acpi.h"
 
 //it seems some functions can be moved arch/i386/boot/acpi.c
 
-unsigned long acpi_create_madt_lapics(unsigned long current)
-{
-       device_t cpu;
-       int cpu_index = 0;
-
-       for(cpu = all_devices; cpu; cpu = cpu->next) {
-               if ((cpu->path.type != DEVICE_PATH_APIC) ||
-                   (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER)) {
-                       continue;
-               }
-               if (!cpu->enabled) {
-                       continue;
-               }
-               current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, cpu_index, cpu->path.apic.apic_id);
-               cpu_index++;
-       }
-       return current;
-}
-
 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint)
 {
        device_t cpu;
@@ -99,7 +67,7 @@ unsigned long acpi_create_srat_lapics(unsigned long current)
                if (!cpu->enabled) {
                        continue;
                }
-               printk_debug("SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n", cpu_index, cpu->path.apic.node_id, cpu->path.apic.apic_id);
+               printk(BIOS_DEBUG, "SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n", cpu_index, cpu->path.apic.node_id, cpu->path.apic.apic_id);
                current += acpi_create_srat_lapic((acpi_srat_lapic_t *)current, cpu->path.apic.node_id, cpu->path.apic.apic_id);
                cpu_index++;
        }
@@ -121,14 +89,14 @@ struct acpi_srat_mem_state {
        unsigned long current;
 };
 
-void set_srat_mem(void *gp, struct device *dev, struct resource *res)
+static void set_srat_mem(void *gp, struct device *dev, struct resource *res)
 {
        struct acpi_srat_mem_state *state = gp;
        unsigned long basek, sizek;
        basek = resk(res->base);
        sizek = resk(res->size);
 
-       printk_debug("set_srat_mem: dev %s, res->index=%04lx startk=%08lx, sizek=%08lx\n",
+       printk(BIOS_DEBUG, "set_srat_mem: dev %s, res->index=%04lx startk=%08lx, sizek=%08lx\n",
                     dev_path(dev), res->index, basek, sizek);
        /*
         * 0-640K must be on node 0
@@ -237,8 +205,6 @@ unsigned long acpi_fill_slit(unsigned long current)
 }
 
 static int k8acpi_write_HT(void) {
-       device_t dev;
-       uint32_t dword;
        int len, lenp, i;
 
        len = acpigen_write_name("HCLK");
@@ -269,7 +235,7 @@ static int k8acpi_write_HT(void) {
        return len;
 }
 
-static int k8acpi_write_pci_data(int dlen, char *name, int offset) {
+static int k8acpi_write_pci_data(int dlen, const char *name, int offset) {
        device_t dev;
        uint32_t dword;
        int len, lenp, i;
@@ -291,7 +257,7 @@ int k8acpi_write_vars(void)
 {
        int lens;
        msr_t msr;
-       char pscope[] = "\\._SB_PCI0";
+       char pscope[] = "\\_SB.PCI0";
 
        lens = acpigen_write_scope(pscope);
        lens += k8acpi_write_pci_data(4, "BUSN", 0xe0);
@@ -311,3 +277,26 @@ int k8acpi_write_vars(void)
        acpigen_patch_len(lens - 1);
        return lens;
 }
+
+void update_ssdtx(void *ssdtx, int i)
+{
+       u8 *PCI;
+       u8 *HCIN;
+       u8 *UID;
+
+       PCI = ssdtx + 0x32;
+       HCIN = ssdtx + 0x39;
+       UID = ssdtx + 0x40;
+
+       if (i < 7) {
+               *PCI = (u8) ('4' + i - 1);
+       } else {
+               *PCI = (u8) ('A' + i - 1 - 6);
+       }
+       *HCIN = (u8) i;
+       *UID = (u8) (i + 3);
+
+       /* FIXME: need to update the GSI id in the ssdtx too */
+
+}
+