We define IO_APIC_ADDR in <arch/ioapic.h>, let's use it.
[coreboot.git] / src / mainboard / technexion / tim8690 / acpi_tables.c
index b77a3bd5078f411e4e93730fc19bcd29ac8b1eb3..02f04cf0b8c069ccef787404833bad124b5e3ac7 100644 (file)
 #include <console/console.h>
 #include <string.h>
 #include <arch/acpi.h>
+#include <arch/ioapic.h>
 #include <device/pci.h>
 #include <device/pci_ids.h>
 #include <cpu/x86/msr.h>
 #include <cpu/amd/mtrr.h>
 #include <cpu/amd/amdk8_sysconf.h>
-#include <../../../northbridge/amd/amdk8/amdk8_acpi.h>
+#include "northbridge/amd/amdk8/amdk8_acpi.h"
 #include <arch/cpu.h>
 #include <cpu/amd/model_fxx_powernow.h>
 
@@ -57,16 +58,7 @@ static void dump_mem(u32 start, u32 end)
 }
 #endif
 
-extern u8 AmlCode[];
-
-#if CONFIG_ACPI_SSDTX_NUM >= 1
-extern u8 AmlCode_ssdt2[];
-extern u8 AmlCode_ssdt3[];
-extern u8 AmlCode_ssdt4[];
-extern u8 AmlCode_ssdt5[];
-#endif
-
-#define IO_APIC_ADDR   0xfec00000UL
+extern const unsigned char AmlCode[];
 
 unsigned long acpi_fill_mcfg(unsigned long current)
 {
@@ -99,30 +91,6 @@ unsigned long acpi_fill_madt(unsigned long current)
        return current;
 }
 
-extern void get_bus_conf(void);
-
-static void update_ssdtx(void *ssdtx, int i)
-{
-       uint8_t *PCI;
-       uint8_t *HCIN;
-       uint8_t *UID;
-
-       PCI = ssdtx + 0x32;
-       HCIN = ssdtx + 0x39;
-       UID = ssdtx + 0x40;
-
-       if (i < 7) {
-               *PCI = (uint8_t) ('4' + i - 1);
-       } else {
-               *PCI = (uint8_t) ('A' + i - 1 - 6);
-       }
-       *HCIN = (uint8_t) i;
-       *UID = (uint8_t) (i + 3);
-
-       /* FIXME: need to update the GSI id in the ssdtx too */
-
-}
-
 unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id) {
        k8acpi_write_vars();
        amd_model_fxx_generate_powernow(pm_base + 8, 6, 1);
@@ -177,22 +145,6 @@ unsigned long write_acpi_tables(unsigned long start)
        current += madt->header.length;
        acpi_add_table(rsdp, madt);
 
-#if 0
-       /* SRAT */
-       printk(BIOS_DEBUG, "ACPI:    * SRAT\n");
-       srat = (acpi_srat_t *) current;
-       acpi_create_srat(srat);
-       current += srat->header.length;
-       acpi_add_table(rsdp, srat);
-
-       /* SLIT */
-       printk(BIOS_DEBUG, "ACPI:    * SLIT\n");
-       slit = (acpi_slit_t *) current;
-       acpi_create_slit(slit);
-       current += slit->header.length;
-       acpi_add_table(rsdp, slit);
-#endif
-
        /* SSDT */
        printk(BIOS_DEBUG, "ACPI:    * SSDT\n");
        ssdt = (acpi_header_t *)current;
@@ -201,47 +153,6 @@ unsigned long write_acpi_tables(unsigned long start)
        current += ssdt->length;
        acpi_add_table(rsdp, ssdt);
 
-#if CONFIG_ACPI_SSDTX_NUM >= 1
-
-       /* same htio, but different position? We may have to copy, change HCIN, and recalculate the checknum and add_table */
-
-       for (i = 1; i < sysconf.hc_possible_num; i++) { /* 0: is hc sblink */
-               if ((sysconf.pci1234[i] & 1) != 1)
-                       continue;
-               uint8_t c;
-               if (i < 7) {
-                       c = (uint8_t) ('4' + i - 1);
-               } else {
-                       c = (uint8_t) ('A' + i - 1 - 6);
-               }
-               printk(BIOS_DEBUG, "ACPI:    * SSDT for PCI%c Aka hcid = %d\n", c, sysconf.hcid[i]);    /* pci0 and pci1 are in dsdt */
-               current = (current + 0x07) & -0x08;
-               ssdtx = (acpi_header_t *) current;
-               switch (sysconf.hcid[i]) {
-               case 1: /* 8132 */
-                       p = AmlCode_ssdt2;
-                       break;
-               case 2: /* 8151 */
-                       p = AmlCode_ssdt3;
-                       break;
-               case 3: /* 8131 */
-                       p = AmlCode_ssdt4;
-                       break;
-               default:
-                       /* HTX no io apic */
-                       p = AmlCode_ssdt5;
-                       break;
-               }
-               current += ((acpi_header_t *) p)->length;
-               memcpy((void *)ssdtx, (void *)p, ((acpi_header_t *) p)->length);
-               update_ssdtx((void *)ssdtx, i);
-               ssdtx->checksum = 0;
-               ssdtx->checksum =
-                   acpi_checksum((u8 *)ssdtx, ssdtx->length);
-               acpi_add_table(rsdp, ssdtx);
-       }
-#endif
-
        /* FACS */
        printk(BIOS_DEBUG, "ACPI:    * FACS\n");
        facs = (acpi_facs_t *) current;
@@ -251,9 +162,9 @@ unsigned long write_acpi_tables(unsigned long start)
        /* DSDT */
        printk(BIOS_DEBUG, "ACPI:    * DSDT\n");
        dsdt = (acpi_header_t *) current;
-       memcpy((void *)dsdt, (void *)AmlCode,
-              ((acpi_header_t *) AmlCode)->length);
+       memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
        current += dsdt->length;
+       memcpy(dsdt, &AmlCode, dsdt->length);
        printk(BIOS_DEBUG, "ACPI:    * DSDT @ %p Length %x\n", dsdt, dsdt->length);
        /* FADT */
        printk(BIOS_DEBUG, "ACPI:    * FADT\n");
@@ -273,12 +184,6 @@ unsigned long write_acpi_tables(unsigned long start)
        printk(BIOS_DEBUG, "madt\n");
        dump_mem(madt, ((void *)madt) + madt->header.length);
 
-       printk(BIOS_DEBUG, "srat\n");
-       dump_mem(srat, ((void *)srat) + srat->header.length);
-
-       printk(BIOS_DEBUG, "slit\n");
-       dump_mem(slit, ((void *)slit) + slit->header.length);
-
        printk(BIOS_DEBUG, "ssdt\n");
        dump_mem(ssdt, ((void *)ssdt) + ssdt->length);