Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2012 Chromium OS Authors |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of 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. |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 15 | */ |
| 16 | |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 17 | #include <arch/acpi.h> |
| 18 | #include <arch/acpigen.h> |
| 19 | #include <cbmem.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 20 | #include <types.h> |
| 21 | #include <string.h> |
| 22 | #include "pch.h" |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 23 | #include "nvs.h" |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 24 | |
| 25 | void acpi_create_intel_hpet(acpi_hpet_t * hpet) |
| 26 | { |
| 27 | acpi_header_t *header = &(hpet->header); |
| 28 | acpi_addr_t *addr = &(hpet->addr); |
| 29 | |
| 30 | memset((void *) hpet, 0, sizeof(acpi_hpet_t)); |
| 31 | |
| 32 | /* fill out header fields */ |
| 33 | memcpy(header->signature, "HPET", 4); |
| 34 | memcpy(header->oem_id, OEM_ID, 6); |
| 35 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 36 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 37 | |
| 38 | header->length = sizeof(acpi_hpet_t); |
| 39 | header->revision = 1; |
| 40 | |
| 41 | /* fill out HPET address */ |
| 42 | addr->space_id = 0; /* Memory */ |
| 43 | addr->bit_width = 64; |
| 44 | addr->bit_offset = 0; |
| 45 | addr->addrl = (unsigned long long)HPET_ADDR & 0xffffffff; |
| 46 | addr->addrh = (unsigned long long)HPET_ADDR >> 32; |
| 47 | |
| 48 | hpet->id = 0x8086a201; /* Intel */ |
| 49 | hpet->number = 0x00; |
| 50 | hpet->min_tick = 0x0080; |
| 51 | |
| 52 | header->checksum = |
| 53 | acpi_checksum((void *) hpet, sizeof(acpi_hpet_t)); |
| 54 | } |
| 55 | |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 56 | static void acpi_create_serialio_ssdt_entry(int id, global_nvs_t *gnvs) |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 57 | { |
| 58 | char sio_name[5] = {}; |
Vladimir Serbinenko | a37383d | 2013-11-26 02:41:26 +0100 | [diff] [blame] | 59 | snprintf(sio_name, sizeof (sio_name), "S%1uEN", id); |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 60 | acpigen_write_name_byte(sio_name, gnvs->s0b[id] ? 1 : 0); |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void acpi_create_serialio_ssdt(acpi_header_t *ssdt) |
| 64 | { |
| 65 | unsigned long current = (unsigned long)ssdt + sizeof(acpi_header_t); |
| 66 | global_nvs_t *gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 67 | int id; |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 68 | |
| 69 | if (!gnvs) |
| 70 | return; |
| 71 | |
| 72 | /* Fill the SSDT header */ |
| 73 | memset((void *)ssdt, 0, sizeof(acpi_header_t)); |
| 74 | memcpy(&ssdt->signature, "SSDT", 4); |
| 75 | ssdt->revision = 2; |
| 76 | memcpy(&ssdt->oem_id, OEM_ID, 6); |
Vladimir Serbinenko | 6b330f2 | 2014-10-05 11:08:40 +0200 | [diff] [blame] | 77 | memcpy(&ssdt->oem_table_id, "SERIALIO", 8); |
| 78 | ssdt->oem_revision = 43; |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 79 | memcpy(&ssdt->asl_compiler_id, ASLC, 4); |
| 80 | ssdt->asl_compiler_revision = 42; |
| 81 | ssdt->length = sizeof(acpi_header_t); |
| 82 | acpigen_set_current((char *) current); |
| 83 | |
| 84 | /* Fill the SSDT with an entry for each SerialIO device */ |
| 85 | for (id = 0; id < 8; id++) |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 86 | acpi_create_serialio_ssdt_entry(id, gnvs); |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 87 | |
| 88 | /* (Re)calculate length and checksum. */ |
| 89 | current = (unsigned long)acpigen_get_current(); |
| 90 | ssdt->length = current - (unsigned long)ssdt; |
| 91 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 92 | } |