blob: 18b71514a363be5dbf51245f9a32b433e860a755 [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
Patrick Georgib890a122015-03-26 15:17:45 +010018 * Foundation, Inc.
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000019 */
20
21#include <types.h>
22#include <string.h>
23#include <console/console.h>
24#include <arch/acpi.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000025#include <arch/ioapic.h>
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000026#include <arch/acpigen.h>
27#include <arch/smp/mpspec.h>
28#include <device/device.h>
29#include <device/pci.h>
30#include <device/pci_ids.h>
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000031
stepan836ae292010-12-08 05:42:47 +000032#include "southbridge/intel/i82801gx/nvs.h"
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020033#include "mainboard.h"
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000034
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020035void acpi_create_gnvs(global_nvs_t *gnvs)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000036{
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000037 /* Enable COM port(s) */
38 gnvs->cmap = 0x01;
39 gnvs->cmbp = 0x00;
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000040}
41
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000042static long acpi_create_ecdt(acpi_ecdt_t * ecdt)
43{
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070044 /* Attention: Make sure these match the values from
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000045 * the DSDT's ec.asl
46 */
47 static const char ec_id[] = "\\_SB.PCI0.LPCB.EC0";
48 int ecdt_len = sizeof(acpi_ecdt_t) + strlen(ec_id) + 1;
49
50 acpi_header_t *header = &(ecdt->header);
51
52 memset((void *) ecdt, 0, ecdt_len);
53
54 /* fill out header fields */
55 memcpy(header->signature, "ECDT", 4);
56 memcpy(header->oem_id, OEM_ID, 6);
57 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
58 memcpy(header->asl_compiler_id, ASLC, 4);
59
60 header->length = ecdt_len;
61 header->revision = 1;
62
63 /* Location of the two EC registers */
64 ecdt->ec_control.space_id = ACPI_ADDRESS_SPACE_IO;
65 ecdt->ec_control.bit_width = 8;
66 ecdt->ec_control.bit_offset = 0;
67 ecdt->ec_control.addrl = 0x66;
68 ecdt->ec_control.addrh = 0;
69
70 ecdt->ec_data.space_id = ACPI_ADDRESS_SPACE_IO; /* Memory */
71 ecdt->ec_data.bit_width = 8;
72 ecdt->ec_data.bit_offset = 0;
73 ecdt->ec_data.addrl = 0x62;
74 ecdt->ec_data.addrh = 0;
75
76 ecdt->uid = 1; // Must match _UID of the EC0 node.
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070077
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000078 ecdt->gpe_bit = 23; // SCI interrupt within GPEx_STS
79
80 strncpy((char *)ecdt->ec_id, ec_id, strlen(ec_id));
81
82 header->checksum =
83 acpi_checksum((void *) ecdt, ecdt_len);
84
85 return header->length;
86}
87
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000088unsigned long acpi_fill_madt(unsigned long current)
89{
90 /* Local APICs */
91 current = acpi_create_madt_lapics(current);
92
93 /* IOAPIC */
94 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
95 2, IO_APIC_ADDR, 0);
96
97 /* INT_SRC_OVR */
98 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
99 current, 0, 0, 2, 0);
100 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
101 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH);
102
103 /* LAPIC_NMI */
104 current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)
105 current, 0, 0x0005, 0x01);
106 current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)
107 current, 1, 0x0005, 0x01);
108
109 return current;
110}
111
Patrick Georgi26b00e62012-04-20 19:19:47 +0200112#define ALIGN_CURRENT current = (ALIGN(current, 16))
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200113unsigned long mainboard_write_acpi_tables(device_t device,
114 unsigned long start,
115 acpi_rsdp_t *rsdp)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000116{
117 unsigned long current;
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000118 acpi_header_t *ecdt;
119
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000120 current = start;
121
122 /* Align ACPI tables to 16byte */
123 ALIGN_CURRENT;
124
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000125 printk(BIOS_DEBUG, "ACPI: * ECDT\n");
126 ecdt = (acpi_header_t *)current;
127 current += acpi_create_ecdt((acpi_ecdt_t *)current);
128 ALIGN_CURRENT;
129 acpi_add_table(rsdp, ecdt);
130
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000131 printk(BIOS_DEBUG, "current = %lx\n", current);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000132 return current;
133}