summaryrefslogtreecommitdiff
path: root/src/mainboard/agami/aruma/acpi_tables_static.c
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2007-04-12 00:12:41 +0000
committerStefan Reinauer <stepan@openbios.org>2007-04-12 00:12:41 +0000
commitb615c7bb3a01a1a3bfefb9f9e882c762ca4e19bd (patch)
treef98ff1ee5bbf2a5d6f48b4082b0e237f66ee1d7f /src/mainboard/agami/aruma/acpi_tables_static.c
parent2f7b1deca3829acb3f6d2912e24900292b1b8d6e (diff)
Vendor specific patch, thus self-acked.
* going back to old board specific dsdt for agami aruma. This is hopefully dropped again some day, but until then here's a working solution. * Some minor Agami specific changes. * drop obsolete bringup workaround hyperclocking.diff * increase image size again, x86emu wants it. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2606 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/mainboard/agami/aruma/acpi_tables_static.c')
-rw-r--r--src/mainboard/agami/aruma/acpi_tables_static.c239
1 files changed, 239 insertions, 0 deletions
diff --git a/src/mainboard/agami/aruma/acpi_tables_static.c b/src/mainboard/agami/aruma/acpi_tables_static.c
new file mode 100644
index 0000000000..f899100102
--- /dev/null
+++ b/src/mainboard/agami/aruma/acpi_tables_static.c
@@ -0,0 +1,239 @@
+/*
+ * Agami Aruma ACPI support
+ *
+ * written by Stefan Reinauer <stepan@coresystems.de>
+ * (C) 2005 Stefan Reinauer
+ * (C) 2007 coresystems GmbH
+ */
+
+#include <console/console.h>
+#include <string.h>
+#include <arch/acpi.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+
+extern unsigned char AmlCode[];
+
+#define IO_APIC_ADDR 0xfec00000UL
+
+unsigned long acpi_fill_madt(unsigned long current)
+{
+ unsigned int gsi_base=0x18, ioapic_nr=2, i;
+ device_t dev=0;
+
+ /* create all subtables for 4p */
+ current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 0, 0); //SDE BSP APIC ID=0
+ current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 1, 17);
+ current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 2, 18);
+ current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 3, 19);
+
+ /* Write 8111 IOAPIC */
+ current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, 1,
+ IO_APIC_ADDR, 0);
+
+ /* Write the first 8131 IOAPICs */
+ for(i = 0; i < 2; i++) {
+ if (dev = dev_find_device(PCI_VENDOR_ID_AMD, 0x7451, dev)){
+ ACPI_WRITE_MADT_IOAPIC(dev, ioapic_nr);
+ ioapic_nr++;
+ }
+ }
+
+ /* Write the 8132 IOAPICs if they exist */
+ for(i = 0; i < 4; i++) {
+ if (dev = dev_find_device(PCI_VENDOR_ID_AMD, 0x7459, dev)){
+ ACPI_WRITE_MADT_IOAPIC(dev, ioapic_nr);
+ ioapic_nr++;
+ }
+ }
+
+ /* in the event there were no 8132s reset dev and look for the 8131s */
+ /* first skip the onboard 8131 */
+ dev=dev_find_device(PCI_VENDOR_ID_AMD, 0x7451, 0);
+ dev=dev_find_device(PCI_VENDOR_ID_AMD, 0x7451, dev);
+
+ /* Write all 8131 IOAPICs */
+ while((dev = dev_find_device(PCI_VENDOR_ID_AMD, 0x7451, dev))) {
+ ACPI_WRITE_MADT_IOAPIC(dev, ioapic_nr);
+ ioapic_nr++;
+ }
+
+ current += acpi_create_madt_irqoverride( (acpi_madt_irqoverride_t *)
+ current, 1, 0, 2, 0 );
+
+ current += acpi_create_madt_irqoverride( (acpi_madt_irqoverride_t *)
+ current, 1, 0, 2, 0 );
+
+ return current;
+}
+
+
+/* The next two tables are used by our DSDT and are freely defined
+ * here. This construct is used because the bus numbers containing
+ * the 8131 bridges may vary so that we need to pass LinuxBIOS
+ * knowledge into the DSDT
+ */
+typedef struct lnxc_busses {
+ u8 secondary;
+ u8 subordinate;
+} acpi_lnxb_busses_t;
+
+typedef struct acpi_lnxb {
+ struct acpi_table_header header;
+ acpi_lnxb_busses_t busses[5];
+} acpi_lnxb_t;
+
+/* special linuxbios acpi table */
+void acpi_create_lnxb(acpi_lnxb_t *lnxb)
+{
+ device_t dev;
+ int busidx=0;
+
+ acpi_header_t *header=&(lnxb->header);
+
+ /* fill out header fields */
+ memcpy(header->signature, "LNXB", 4);
+ memcpy(header->oem_id, OEM_ID, 6);
+ memcpy(header->oem_table_id, "LNXBIOS ", 8);
+ memcpy(header->asl_compiler_id, ASLC, 4);
+
+ header->length = sizeof(acpi_lnxb_t);
+ header->revision = 1;
+
+ /*
+ * Write external 8131 bus ranges
+ */
+ /* first skip the onboard 8131 */
+ dev=dev_find_device(PCI_VENDOR_ID_AMD, 0x7450, 0);
+ dev=dev_find_device(PCI_VENDOR_ID_AMD, 0x7450, dev);
+ /* now look at the last 8131 in each chain,
+ * as it contains the valid bus ranges
+ */
+ /* Add a check for 8132 devices, device ID == 0x7458 */
+ while((dev = dev_find_device(PCI_VENDOR_ID_AMD, 0x7458, dev))
+ && busidx<5 ) {
+ int subu, fn, slot;
+ acpi_lnxb_busses_t *busses;
+
+ if(PCI_SLOT(dev->path.u.pci.devfn)!=4)
+ continue;
+
+ busses=&(lnxb->busses[busidx]);
+ lnxb->busses[busidx].secondary = dev->bus->secondary;
+ lnxb->busses[busidx].subordinate =
+ pci_read_config8(dev, PCI_SUBORDINATE_BUS);
+#if 0
+ /* SDE-test print out lnbx table values */
+ printk_info("ACPI: 7458 lnxb value, secondary %lx, subordinate %1x \n",
+ lnxb->busses[busidx].secondary, lnxb->busses[busidx].subordinate);
+#endif
+ busidx++;
+ }
+ dev=dev_find_device(PCI_VENDOR_ID_AMD, 0x7450, 0);
+ dev=dev_find_device(PCI_VENDOR_ID_AMD, 0x7450, dev);
+ while((dev = dev_find_device(PCI_VENDOR_ID_AMD, 0x7450, dev))
+ && busidx<5 ) {
+ int subu, fn, slot;
+ acpi_lnxb_busses_t *busses;
+
+ if(PCI_SLOT(dev->path.u.pci.devfn)!=4)
+ continue;
+
+ busses=&(lnxb->busses[busidx]);
+ lnxb->busses[busidx].secondary = dev->bus->secondary;
+ lnxb->busses[busidx].subordinate =
+ pci_read_config8(dev, PCI_SUBORDINATE_BUS);
+#if 0
+ /* SDE-test print out lnbx table values */
+ printk_info("ACPI: 7450 lnxb value, secondary %lx, subordinate %1x \n",
+ lnxb->busses[busidx].secondary, lnxb->busses[busidx].subordinate);
+#endif
+ busidx++;
+ }
+ header->checksum = acpi_checksum((void *)lnxb, sizeof(acpi_lnxb_t));
+}
+
+
+
+unsigned long write_acpi_tables(unsigned long start)
+{
+ unsigned long current;
+ acpi_rsdp_t *rsdp;
+ acpi_rsdt_t *rsdt;
+ acpi_hpet_t *hpet;
+ acpi_madt_t *madt;
+ acpi_fadt_t *fadt;
+ acpi_facs_t *facs;
+ acpi_lnxb_t *lnxb;
+ acpi_header_t *dsdt;
+
+ /* Align ACPI tables to 16byte */
+ start = ( start + 0x0f ) & -0x10;
+ current = start;
+
+ printk_info("ACPI: Writing ACPI tables at %lx...\n", start);
+
+ /* We need at least an RSDP and an RSDT Table */
+ rsdp = (acpi_rsdp_t *) current;
+ current += sizeof(acpi_rsdp_t);
+ rsdt = (acpi_rsdt_t *) current;
+ current += sizeof(acpi_rsdt_t);
+
+ /* clear all table memory */
+ memset((void *)start, 0, current - start);
+
+ acpi_write_rsdp(rsdp, rsdt);
+ acpi_write_rsdt(rsdt);
+
+ /*
+ * We explicitly add these tables later on:
+ */
+ printk_debug("ACPI: * HPET\n");
+
+ hpet = (acpi_hpet_t *) current;
+ current += sizeof(acpi_hpet_t);
+ acpi_create_hpet(hpet);
+ acpi_add_table(rsdt,hpet);
+
+ /* If we want to use HPET Timers Linux wants an MADT */
+ printk_debug("ACPI: * MADT\n");
+
+ madt = (acpi_madt_t *) current;
+ acpi_create_madt(madt);
+ current+=madt->header.length;
+ acpi_add_table(rsdt,madt);
+
+ printk_debug("ACPI: * LNXB\n");
+ lnxb=(acpi_lnxb_t *)current;
+ current += sizeof(acpi_facs_t);
+ acpi_create_lnxb(lnxb);
+
+ printk_debug("ACPI: * FACS\n");
+ facs = (acpi_facs_t *) current;
+ current += sizeof(acpi_facs_t);
+ acpi_create_facs(facs);
+
+ dsdt = (acpi_header_t *)current;
+ current += ((acpi_header_t *)AmlCode)->length;
+ memcpy((void *)dsdt,(void *)AmlCode, \
+ ((acpi_header_t *)AmlCode)->length);
+
+ /* fix up dsdt */
+ ((u32 *)dsdt)[11]=((u32)lnxb)+sizeof(acpi_header_t);
+
+ /* recalculate checksum */
+ dsdt->checksum = 0;
+ dsdt->checksum = acpi_checksum(dsdt,dsdt->length);
+ printk_debug("ACPI: * DSDT @ %08x Length %x\n",dsdt,dsdt->length);
+ printk_debug("ACPI: * FADT\n");
+
+ fadt = (acpi_fadt_t *) current;
+ current += sizeof(acpi_fadt_t);
+
+ acpi_create_fadt(fadt,facs,dsdt);
+ acpi_add_table(rsdt,fadt);
+
+ printk_info("ACPI: done.\n");
+ return current;
+}
+