Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 3 | * |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2010 coresystems GmbH |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 19 | * MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #include <types.h> |
| 23 | #include <string.h> |
| 24 | #include <console/console.h> |
| 25 | #include <arch/acpi.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 26 | #include <arch/ioapic.h> |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 27 | #include <arch/acpigen.h> |
| 28 | #include <arch/smp/mpspec.h> |
| 29 | #include <device/device.h> |
| 30 | #include <device/pci.h> |
| 31 | #include <device/pci_ids.h> |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 32 | |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 33 | #include "southbridge/intel/i82801gx/nvs.h" |
Vladimir Serbinenko | 0e64617 | 2014-08-31 00:27:05 +0200 | [diff] [blame^] | 34 | #include "mainboard.h" |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 35 | |
Vladimir Serbinenko | 0e64617 | 2014-08-31 00:27:05 +0200 | [diff] [blame^] | 36 | void acpi_create_gnvs(global_nvs_t *gnvs) |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 37 | { |
| 38 | memset((void *)gnvs, 0, sizeof(*gnvs)); |
| 39 | gnvs->apic = 1; |
| 40 | gnvs->mpen = 1; /* Enable Multi Processing */ |
| 41 | |
| 42 | /* Enable COM port(s) */ |
| 43 | gnvs->cmap = 0x01; |
| 44 | gnvs->cmbp = 0x00; |
| 45 | |
| 46 | /* IGD Displays */ |
| 47 | gnvs->ndid = 2; |
| 48 | gnvs->did[0] = 0x80000100; |
| 49 | gnvs->did[1] = 0x80000410; |
| 50 | gnvs->did[2] = 0x80000320; |
| 51 | gnvs->did[3] = 0x80000410; |
| 52 | gnvs->did[4] = 0x00000005; |
| 53 | } |
| 54 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 55 | static long acpi_create_ecdt(acpi_ecdt_t * ecdt) |
| 56 | { |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 57 | /* Attention: Make sure these match the values from |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 58 | * the DSDT's ec.asl |
| 59 | */ |
| 60 | static const char ec_id[] = "\\_SB.PCI0.LPCB.EC0"; |
| 61 | int ecdt_len = sizeof(acpi_ecdt_t) + strlen(ec_id) + 1; |
| 62 | |
| 63 | acpi_header_t *header = &(ecdt->header); |
| 64 | |
| 65 | memset((void *) ecdt, 0, ecdt_len); |
| 66 | |
| 67 | /* fill out header fields */ |
| 68 | memcpy(header->signature, "ECDT", 4); |
| 69 | memcpy(header->oem_id, OEM_ID, 6); |
| 70 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 71 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 72 | |
| 73 | header->length = ecdt_len; |
| 74 | header->revision = 1; |
| 75 | |
| 76 | /* Location of the two EC registers */ |
| 77 | ecdt->ec_control.space_id = ACPI_ADDRESS_SPACE_IO; |
| 78 | ecdt->ec_control.bit_width = 8; |
| 79 | ecdt->ec_control.bit_offset = 0; |
| 80 | ecdt->ec_control.addrl = 0x66; |
| 81 | ecdt->ec_control.addrh = 0; |
| 82 | |
| 83 | ecdt->ec_data.space_id = ACPI_ADDRESS_SPACE_IO; /* Memory */ |
| 84 | ecdt->ec_data.bit_width = 8; |
| 85 | ecdt->ec_data.bit_offset = 0; |
| 86 | ecdt->ec_data.addrl = 0x62; |
| 87 | ecdt->ec_data.addrh = 0; |
| 88 | |
| 89 | ecdt->uid = 1; // Must match _UID of the EC0 node. |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 90 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 91 | ecdt->gpe_bit = 23; // SCI interrupt within GPEx_STS |
| 92 | |
| 93 | strncpy((char *)ecdt->ec_id, ec_id, strlen(ec_id)); |
| 94 | |
| 95 | header->checksum = |
| 96 | acpi_checksum((void *) ecdt, ecdt_len); |
| 97 | |
| 98 | return header->length; |
| 99 | } |
| 100 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 101 | unsigned long acpi_fill_madt(unsigned long current) |
| 102 | { |
| 103 | /* Local APICs */ |
| 104 | current = acpi_create_madt_lapics(current); |
| 105 | |
| 106 | /* IOAPIC */ |
| 107 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, |
| 108 | 2, IO_APIC_ADDR, 0); |
| 109 | |
| 110 | /* INT_SRC_OVR */ |
| 111 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 112 | current, 0, 0, 2, 0); |
| 113 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 114 | current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH); |
| 115 | |
| 116 | /* LAPIC_NMI */ |
| 117 | current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *) |
| 118 | current, 0, 0x0005, 0x01); |
| 119 | current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *) |
| 120 | current, 1, 0x0005, 0x01); |
| 121 | |
| 122 | return current; |
| 123 | } |
| 124 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 125 | unsigned long acpi_fill_slit(unsigned long current) |
| 126 | { |
| 127 | // Not implemented |
| 128 | return current; |
| 129 | } |
| 130 | |
| 131 | unsigned long acpi_fill_srat(unsigned long current) |
| 132 | { |
| 133 | /* No NUMA, no SRAT */ |
| 134 | return current; |
| 135 | } |
| 136 | |
Patrick Georgi | 26b00e6 | 2012-04-20 19:19:47 +0200 | [diff] [blame] | 137 | #define ALIGN_CURRENT current = (ALIGN(current, 16)) |
Vladimir Serbinenko | 0e64617 | 2014-08-31 00:27:05 +0200 | [diff] [blame^] | 138 | unsigned long mainboard_write_acpi_tables(unsigned long start, acpi_rsdp_t *rsdp) |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 139 | { |
| 140 | unsigned long current; |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 141 | acpi_header_t *ecdt; |
| 142 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 143 | current = start; |
| 144 | |
| 145 | /* Align ACPI tables to 16byte */ |
| 146 | ALIGN_CURRENT; |
| 147 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 148 | printk(BIOS_DEBUG, "ACPI: * ECDT\n"); |
| 149 | ecdt = (acpi_header_t *)current; |
| 150 | current += acpi_create_ecdt((acpi_ecdt_t *)current); |
| 151 | ALIGN_CURRENT; |
| 152 | acpi_add_table(rsdp, ecdt); |
| 153 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 154 | printk(BIOS_DEBUG, "current = %lx\n", current); |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 155 | return current; |
| 156 | } |