Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Kyösti Mälkki | 5daa1d3 | 2020-06-14 12:01:58 +0300 | [diff] [blame] | 4 | #include <acpi/acpi_gnvs.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpigen.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 6 | #include <string.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 7 | #include <version.h> |
Kyösti Mälkki | 661ad46 | 2020-12-29 06:26:21 +0200 | [diff] [blame] | 8 | #include <soc/nvs.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 9 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 10 | #include "pch.h" |
| 11 | |
Kyösti Mälkki | 0c1dd9c | 2020-06-17 23:37:49 +0300 | [diff] [blame] | 12 | static void acpi_create_serialio_ssdt_entry(int id, struct global_nvs *gnvs) |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 13 | { |
| 14 | char sio_name[5] = {}; |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 15 | snprintf(sio_name, sizeof(sio_name), "S%1uEN", id); |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 16 | acpigen_write_name_byte(sio_name, gnvs->s0b[id] ? 1 : 0); |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | void acpi_create_serialio_ssdt(acpi_header_t *ssdt) |
| 20 | { |
| 21 | unsigned long current = (unsigned long)ssdt + sizeof(acpi_header_t); |
Kyösti Mälkki | 0c1dd9c | 2020-06-17 23:37:49 +0300 | [diff] [blame] | 22 | struct global_nvs *gnvs = acpi_get_gnvs(); |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 23 | int id; |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 24 | |
| 25 | if (!gnvs) |
| 26 | return; |
| 27 | |
| 28 | /* Fill the SSDT header */ |
| 29 | memset((void *)ssdt, 0, sizeof(acpi_header_t)); |
| 30 | memcpy(&ssdt->signature, "SSDT", 4); |
Himanshu Sahdev | 1506253 | 2019-09-23 15:43:28 +0530 | [diff] [blame] | 31 | ssdt->revision = get_acpi_table_revision(SSDT); |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 32 | memcpy(&ssdt->oem_id, OEM_ID, 6); |
Vladimir Serbinenko | 6b330f2 | 2014-10-05 11:08:40 +0200 | [diff] [blame] | 33 | memcpy(&ssdt->oem_table_id, "SERIALIO", 8); |
| 34 | ssdt->oem_revision = 43; |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 35 | memcpy(&ssdt->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 36 | ssdt->asl_compiler_revision = asl_revision; |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 37 | ssdt->length = sizeof(acpi_header_t); |
Angel Pons | 8cb8374 | 2020-10-17 18:28:29 +0200 | [diff] [blame] | 38 | acpigen_set_current((char *)current); |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 39 | |
| 40 | /* Fill the SSDT with an entry for each SerialIO device */ |
| 41 | for (id = 0; id < 8; id++) |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 42 | acpi_create_serialio_ssdt_entry(id, gnvs); |
Duncan Laurie | d7cb8d0 | 2013-05-15 15:03:57 -0700 | [diff] [blame] | 43 | |
| 44 | /* (Re)calculate length and checksum. */ |
| 45 | current = (unsigned long)acpigen_get_current(); |
| 46 | ssdt->length = current - (unsigned long)ssdt; |
| 47 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 48 | } |