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. |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <types.h> |
| 18 | #include <string.h> |
| 19 | #include <console/console.h> |
| 20 | #include <arch/acpi.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 21 | #include <arch/ioapic.h> |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 22 | #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 Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 27 | |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 28 | #include "southbridge/intel/i82801gx/nvs.h" |
Vladimir Serbinenko | 0e64617 | 2014-08-31 00:27:05 +0200 | [diff] [blame] | 29 | #include "mainboard.h" |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 30 | |
Vladimir Serbinenko | 0e64617 | 2014-08-31 00:27:05 +0200 | [diff] [blame] | 31 | void acpi_create_gnvs(global_nvs_t *gnvs) |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 32 | { |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 33 | /* Enable COM port(s) */ |
| 34 | gnvs->cmap = 0x01; |
| 35 | gnvs->cmbp = 0x00; |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 38 | static long acpi_create_ecdt(acpi_ecdt_t * ecdt) |
| 39 | { |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 40 | /* Attention: Make sure these match the values from |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 41 | * 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 Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 73 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 74 | 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 Couzens | 83fc32f | 2015-04-12 22:28:37 +0200 | [diff] [blame] | 84 | unsigned long mainboard_write_acpi_tables(device_t device, |
| 85 | unsigned long start, |
| 86 | acpi_rsdp_t *rsdp) |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 87 | { |
| 88 | unsigned long current; |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 89 | acpi_header_t *ecdt; |
| 90 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 91 | current = start; |
| 92 | |
| 93 | /* Align ACPI tables to 16byte */ |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame^] | 94 | current = acpi_align_current(current); |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 95 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 96 | printk(BIOS_DEBUG, "ACPI: * ECDT\n"); |
| 97 | ecdt = (acpi_header_t *)current; |
| 98 | current += acpi_create_ecdt((acpi_ecdt_t *)current); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame^] | 99 | current = acpi_align_current(current); |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 100 | acpi_add_table(rsdp, ecdt); |
| 101 | |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 102 | printk(BIOS_DEBUG, "current = %lx\n", current); |
Stefan Reinauer | 7cfa7f9 | 2010-05-16 14:24:41 +0000 | [diff] [blame] | 103 | return current; |
| 104 | } |