Simon Glass | 9893180 | 2020-09-22 12:44:52 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2019 Intel Corporation. |
| 4 | * |
| 5 | * Taken from coreboot intelblocks/nvs.h |
| 6 | * Copyright 2019 Google LLC |
| 7 | */ |
| 8 | |
| 9 | #ifndef _INTEL_GNVS_H_ |
| 10 | #define _INTEL_GNVS_H_ |
| 11 | |
Simon Glass | 5dc4f39 | 2021-01-24 10:06:07 -0700 | [diff] [blame] | 12 | #include <linux/bitops.h> |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 13 | /* |
| 14 | * The chromeos_acpi portion of ACPI GNVS is assumed to live from offset |
| 15 | * 0x100 - 0x1000. When defining acpi_global_nvs, use check_member |
| 16 | * to ensure that it is properly aligned: |
| 17 | * |
| 18 | * check_member(acpi_global_nvs, chromeos, GNVS_CHROMEOS_ACPI_OFFSET); |
| 19 | */ |
| 20 | #define GNVS_CHROMEOS_ACPI_OFFSET 0x100 |
| 21 | |
| 22 | enum { |
Simon Glass | 5dc4f39 | 2021-01-24 10:06:07 -0700 | [diff] [blame] | 23 | BOOT_REASON_OTHER = 0, |
| 24 | BOOT_REASON_S3DIAG = 9 |
| 25 | }; |
| 26 | |
| 27 | enum { |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 28 | CHSW_RECOVERY_X86 = BIT(1), |
| 29 | CHSW_RECOVERY_EC = BIT(2), |
| 30 | CHSW_DEVELOPER_SWITCH = BIT(5), |
| 31 | CHSW_FIRMWARE_WP = BIT(9), |
| 32 | }; |
| 33 | |
| 34 | enum { |
Simon Glass | 5dc4f39 | 2021-01-24 10:06:07 -0700 | [diff] [blame] | 35 | RECOVERY_REASON_NONE = 0, |
| 36 | RECOVERY_REASON_ME = 1 |
| 37 | }; |
| 38 | |
| 39 | enum { |
| 40 | ACTIVE_ECFW_RO = 0, |
| 41 | ACTIVE_ECFW_RW = 1 |
| 42 | }; |
| 43 | |
| 44 | enum { |
| 45 | BINF_RECOVERY = 0, |
| 46 | BINF_RW_A = 1, |
| 47 | BINF_RW_B = 2 |
| 48 | }; |
| 49 | |
| 50 | enum { |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 51 | FIRMWARE_TYPE_AUTO_DETECT = -1, |
| 52 | FIRMWARE_TYPE_RECOVERY = 0, |
| 53 | FIRMWARE_TYPE_NORMAL = 1, |
| 54 | FIRMWARE_TYPE_DEVELOPER = 2, |
| 55 | FIRMWARE_TYPE_NETBOOT = 3, |
| 56 | FIRMWARE_TYPE_LEGACY = 4, |
| 57 | }; |
| 58 | |
| 59 | struct __packed chromeos_acpi_gnvs { |
| 60 | /* ChromeOS-specific */ |
| 61 | u32 boot_reason; /* 00 boot reason */ |
| 62 | u32 active_main_fw; /* 04 (0=recovery, 1=A, 2=B) */ |
| 63 | u32 activeec_fw; /* 08 (0=RO, 1=RW) */ |
| 64 | u16 switches; /* 0c CHSW */ |
Simon Glass | 5dc4f39 | 2021-01-24 10:06:07 -0700 | [diff] [blame] | 65 | u8 hwid[256]; /* 0e HWID */ |
| 66 | u8 fwid[64]; /* 10e FWID */ |
| 67 | u8 frid[64]; /* 14e FRID - 275 */ |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 68 | u32 main_fw_type; /* 18e (2 = developer mode) */ |
Simon Glass | 5dc4f39 | 2021-01-24 10:06:07 -0700 | [diff] [blame] | 69 | u32 recovery_reason; /* 192 recovery reason */ |
| 70 | u32 fmap_base; /* 196 fmap base address */ |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 71 | u8 vdat[3072]; /* 19a VDAT space filled by verified boot */ |
Simon Glass | 5dc4f39 | 2021-01-24 10:06:07 -0700 | [diff] [blame] | 72 | u32 fwid_ptr; /* d9a smbios bios version */ |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 73 | u32 mehh[8]; /* d9e management engine hash */ |
| 74 | u32 ramoops_base; /* dbe ramoops base address */ |
| 75 | u32 ramoops_len; /* dc2 ramoops length */ |
| 76 | u32 vpd_ro_base; /* dc6 pointer to RO_VPD */ |
| 77 | u32 vpd_ro_size; /* dca size of RO_VPD */ |
| 78 | u32 vpd_rw_base; /* dce pointer to RW_VPD */ |
| 79 | u32 vpd_rw_size; /* dd2 size of RW_VPD */ |
| 80 | u8 pad[298]; /* dd6-eff */ |
| 81 | }; |
| 82 | |
Simon Glass | 9893180 | 2020-09-22 12:44:52 -0600 | [diff] [blame] | 83 | struct __packed acpi_global_nvs { |
| 84 | /* Miscellaneous */ |
| 85 | u8 pcnt; /* 0x00 - Processor Count */ |
| 86 | u8 ppcm; /* 0x01 - Max PPC State */ |
| 87 | u8 lids; /* 0x02 - LID State */ |
| 88 | u8 pwrs; /* 0x03 - AC Power State */ |
| 89 | u8 dpte; /* 0x04 - Enable DPTF */ |
| 90 | u32 cbmc; /* 0x05 - 0x08 - coreboot Memory Console */ |
| 91 | u64 pm1i; /* 0x09 - 0x10 - System Wake Source - PM1 Index */ |
| 92 | u64 gpei; /* 0x11 - 0x18 - GPE Wake Source */ |
| 93 | u64 nhla; /* 0x19 - 0x20 - NHLT Address */ |
| 94 | u32 nhll; /* 0x21 - 0x24 - NHLT Length */ |
| 95 | u32 prt0; /* 0x25 - 0x28 - PERST_0 Address */ |
| 96 | u8 scdp; /* 0x29 - SD_CD GPIO portid */ |
| 97 | u8 scdo; /* 0x2a - GPIO pad offset relative to the community */ |
| 98 | u8 uior; /* 0x2b - UART debug controller init on S3 resume */ |
| 99 | u8 ecps; /* 0x2c - SGX Enabled status */ |
| 100 | u64 emna; /* 0x2d - 0x34 EPC base address */ |
| 101 | u64 elng; /* 0x35 - 0x3C EPC Length */ |
| 102 | u8 unused1[0x100 - 0x3d]; /* Pad out to 256 bytes */ |
| 103 | #ifdef CONFIG_CHROMEOS |
| 104 | /* ChromeOS-specific (0x100 - 0xfff) */ |
Simon Glass | 279672f | 2020-11-04 09:57:34 -0700 | [diff] [blame] | 105 | struct chromeos_acpi_gnvs chromeos; |
Simon Glass | 9893180 | 2020-09-22 12:44:52 -0600 | [diff] [blame] | 106 | #else |
| 107 | u8 unused2[0x1000 - 0x100]; /* Pad out to 4096 bytes */ |
| 108 | #endif |
| 109 | }; |
Simon Glass | 3cde0e9 | 2021-02-23 05:35:40 -0500 | [diff] [blame] | 110 | #ifdef CONFIG_CHROMEOS |
Simon Glass | 9893180 | 2020-09-22 12:44:52 -0600 | [diff] [blame] | 111 | check_member(acpi_global_nvs, chromeos, GNVS_CHROMEOS_ACPI_OFFSET); |
Simon Glass | 3cde0e9 | 2021-02-23 05:35:40 -0500 | [diff] [blame] | 112 | #else |
| 113 | check_member(acpi_global_nvs, unused2, GNVS_CHROMEOS_ACPI_OFFSET); |
| 114 | #endif |
Simon Glass | 9893180 | 2020-09-22 12:44:52 -0600 | [diff] [blame] | 115 | |
| 116 | #endif /* _INTEL_GNVS_H_ */ |