blob: 1e22eae3dd55a8d4b1692b060811aaf0f42aa1d0 [file] [log] [blame]
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +00001/*
2 * This file is part of the coreboot project.
Stefan Reinauer5ff7c132011-10-31 12:56:45 -07003 *
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +00004 * 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 Hermann74d1a6e2010-10-12 17:34:08 +000026#include <arch/ioapic.h>
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000027#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 Reinauer7cfa7f92010-05-16 14:24:41 +000032
stepan836ae292010-12-08 05:42:47 +000033#include "southbridge/intel/i82801gx/nvs.h"
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020034#include "mainboard.h"
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000035
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020036void acpi_create_gnvs(global_nvs_t *gnvs)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000037{
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 Reinauer7cfa7f92010-05-16 14:24:41 +000055static long acpi_create_ecdt(acpi_ecdt_t * ecdt)
56{
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070057 /* Attention: Make sure these match the values from
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000058 * 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 Reinauer5ff7c132011-10-31 12:56:45 -070090
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000091 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 Reinauer7cfa7f92010-05-16 14:24:41 +0000101unsigned 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 Reinauer7cfa7f92010-05-16 14:24:41 +0000125unsigned long acpi_fill_slit(unsigned long current)
126{
127 // Not implemented
128 return current;
129}
130
131unsigned long acpi_fill_srat(unsigned long current)
132{
133 /* No NUMA, no SRAT */
134 return current;
135}
136
Patrick Georgi26b00e62012-04-20 19:19:47 +0200137#define ALIGN_CURRENT current = (ALIGN(current, 16))
Vladimir Serbinenko0e646172014-08-31 00:27:05 +0200138unsigned long mainboard_write_acpi_tables(unsigned long start, acpi_rsdp_t *rsdp)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000139{
140 unsigned long current;
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000141 acpi_header_t *ecdt;
142
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000143 current = start;
144
145 /* Align ACPI tables to 16byte */
146 ALIGN_CURRENT;
147
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000148 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 Reinauer7cfa7f92010-05-16 14:24:41 +0000154 printk(BIOS_DEBUG, "current = %lx\n", current);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000155 return current;
156}