blob: fc743dc92858f646c68db44878de46210e7a66ed [file] [log] [blame]
Simon Glass98931802020-09-22 12:44:52 -06001/* 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 Glass5dc4f392021-01-24 10:06:07 -070012#include <linux/bitops.h>
Simon Glass279672f2020-11-04 09:57:34 -070013/*
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
22enum {
Simon Glass5dc4f392021-01-24 10:06:07 -070023 BOOT_REASON_OTHER = 0,
24 BOOT_REASON_S3DIAG = 9
25};
26
27enum {
Simon Glass279672f2020-11-04 09:57:34 -070028 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
34enum {
Simon Glass5dc4f392021-01-24 10:06:07 -070035 RECOVERY_REASON_NONE = 0,
36 RECOVERY_REASON_ME = 1
37};
38
39enum {
40 ACTIVE_ECFW_RO = 0,
41 ACTIVE_ECFW_RW = 1
42};
43
44enum {
45 BINF_RECOVERY = 0,
46 BINF_RW_A = 1,
47 BINF_RW_B = 2
48};
49
50enum {
Simon Glass279672f2020-11-04 09:57:34 -070051 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
59struct __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 Glass5dc4f392021-01-24 10:06:07 -070065 u8 hwid[256]; /* 0e HWID */
66 u8 fwid[64]; /* 10e FWID */
67 u8 frid[64]; /* 14e FRID - 275 */
Simon Glass279672f2020-11-04 09:57:34 -070068 u32 main_fw_type; /* 18e (2 = developer mode) */
Simon Glass5dc4f392021-01-24 10:06:07 -070069 u32 recovery_reason; /* 192 recovery reason */
70 u32 fmap_base; /* 196 fmap base address */
Simon Glass279672f2020-11-04 09:57:34 -070071 u8 vdat[3072]; /* 19a VDAT space filled by verified boot */
Simon Glass5dc4f392021-01-24 10:06:07 -070072 u32 fwid_ptr; /* d9a smbios bios version */
Simon Glass279672f2020-11-04 09:57:34 -070073 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 Glass98931802020-09-22 12:44:52 -060083struct __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 Glass279672f2020-11-04 09:57:34 -0700105 struct chromeos_acpi_gnvs chromeos;
Simon Glass98931802020-09-22 12:44:52 -0600106#else
107 u8 unused2[0x1000 - 0x100]; /* Pad out to 4096 bytes */
108#endif
109};
Simon Glass3cde0e92021-02-23 05:35:40 -0500110#ifdef CONFIG_CHROMEOS
Simon Glass98931802020-09-22 12:44:52 -0600111check_member(acpi_global_nvs, chromeos, GNVS_CHROMEOS_ACPI_OFFSET);
Simon Glass3cde0e92021-02-23 05:35:40 -0500112#else
113check_member(acpi_global_nvs, unused2, GNVS_CHROMEOS_ACPI_OFFSET);
114#endif
Simon Glass98931802020-09-22 12:44:52 -0600115
116#endif /* _INTEL_GNVS_H_ */