blob: 34d6f3494ac95e8a93f5a47cdb94b52407709b5a [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.
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000015 */
16
17#include <types.h>
18#include <string.h>
19#include <console/console.h>
20#include <arch/acpi.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000021#include <arch/ioapic.h>
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000022#include <arch/acpigen.h>
23#include <arch/smp/mpspec.h>
24#include <device/device.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000027
stepan836ae292010-12-08 05:42:47 +000028#include "southbridge/intel/i82801gx/nvs.h"
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020029#include "mainboard.h"
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000030
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020031void acpi_create_gnvs(global_nvs_t *gnvs)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000032{
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000033 /* Enable COM port(s) */
34 gnvs->cmap = 0x01;
35 gnvs->cmbp = 0x00;
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000036}
37
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000038static long acpi_create_ecdt(acpi_ecdt_t * ecdt)
39{
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070040 /* Attention: Make sure these match the values from
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000041 * the DSDT's ec.asl
42 */
43 static const char ec_id[] = "\\_SB.PCI0.LPCB.EC0";
44 int ecdt_len = sizeof(acpi_ecdt_t) + strlen(ec_id) + 1;
45
46 acpi_header_t *header = &(ecdt->header);
47
48 memset((void *) ecdt, 0, ecdt_len);
49
50 /* fill out header fields */
51 memcpy(header->signature, "ECDT", 4);
52 memcpy(header->oem_id, OEM_ID, 6);
53 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
54 memcpy(header->asl_compiler_id, ASLC, 4);
55
56 header->length = ecdt_len;
57 header->revision = 1;
58
59 /* Location of the two EC registers */
60 ecdt->ec_control.space_id = ACPI_ADDRESS_SPACE_IO;
61 ecdt->ec_control.bit_width = 8;
62 ecdt->ec_control.bit_offset = 0;
63 ecdt->ec_control.addrl = 0x66;
64 ecdt->ec_control.addrh = 0;
65
66 ecdt->ec_data.space_id = ACPI_ADDRESS_SPACE_IO; /* Memory */
67 ecdt->ec_data.bit_width = 8;
68 ecdt->ec_data.bit_offset = 0;
69 ecdt->ec_data.addrl = 0x62;
70 ecdt->ec_data.addrh = 0;
71
72 ecdt->uid = 1; // Must match _UID of the EC0 node.
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070073
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000074 ecdt->gpe_bit = 23; // SCI interrupt within GPEx_STS
75
76 strncpy((char *)ecdt->ec_id, ec_id, strlen(ec_id));
77
78 header->checksum =
79 acpi_checksum((void *) ecdt, ecdt_len);
80
81 return header->length;
82}
83
Alexander Couzens83fc32f2015-04-12 22:28:37 +020084unsigned long mainboard_write_acpi_tables(device_t device,
85 unsigned long start,
86 acpi_rsdp_t *rsdp)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000087{
88 unsigned long current;
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000089 acpi_header_t *ecdt;
90
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000091 current = start;
92
93 /* Align ACPI tables to 16byte */
Aaron Durbin07a1b282015-12-10 17:07:38 -060094 current = acpi_align_current(current);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000095
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000096 printk(BIOS_DEBUG, "ACPI: * ECDT\n");
97 ecdt = (acpi_header_t *)current;
98 current += acpi_create_ecdt((acpi_ecdt_t *)current);
Aaron Durbin07a1b282015-12-10 17:07:38 -060099 current = acpi_align_current(current);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000100 acpi_add_table(rsdp, ecdt);
101
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000102 printk(BIOS_DEBUG, "current = %lx\n", current);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000103 return current;
104}