acpigen,soc/amd,cpu/intel: rework static DWORD for CPPC table

Some elements in the ACPI CPPC table allow static DWORDs. Instead of
using a fake register resource, use a tagged union with the two types
"register" and "DWORD" and respective macros for CPPC table entries.

Test: dumped SSDT before and after do not differ.

Change-Id: Ib853261b5c0ea87ae2424fed188f2d1872be9a06
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57886
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Michael Niewöhner
2021-10-05 22:22:21 +02:00
committed by Felix Held
parent 679f4fa465
commit 38107fa80e
6 changed files with 73 additions and 67 deletions

View File

@@ -265,24 +265,37 @@ enum cppc_fields {
CPPC_MAX_FIELDS_VER_3,
};
typedef struct cppc_entry {
enum { CPPC_TYPE_REG, CPPC_TYPE_DWORD } type;
union {
acpi_addr_t reg;
uint32_t dword;
};
} cppc_entry_t;
#define CPPC_DWORD(_dword) \
(cppc_entry_t){ \
.type = CPPC_TYPE_DWORD, \
.dword = _dword, \
}
#define CPPC_REG(_reg) \
(cppc_entry_t){ \
.type = CPPC_TYPE_REG, \
.reg = _reg, \
}
#define CPPC_REG_MSR(address, offset, width) CPPC_REG(ACPI_REG_MSR(address, offset, width))
#define CPPC_UNSUPPORTED CPPC_REG(ACPI_REG_UNSUPPORTED)
struct cppc_config {
u32 version; /* must be 1, 2, or 3 */
/*
* The generic acpi_addr_t structure is being used, though
* anything besides PPC or FFIXED generally requires checking
* if the OS has advertised support for it (via _OSC).
*
* NOTE: some fields permit DWORDs to be used. If you
* provide a System Memory register with all zeros (which
* represents unsupported) then this will be used as-is.
* Otherwise, a System Memory register with a 32-bit
* width will be converted into a DWORD field (the value
* of which will be the value of 'addrl'. Any other use
* of System Memory register is currently undefined.
* (i.e., if you have an actual need for System Memory
* then you'll need to adjust this kludge).
*/
acpi_addr_t regs[CPPC_MAX_FIELDS_VER_3];
cppc_entry_t entries[CPPC_MAX_FIELDS_VER_3];
};
void acpigen_write_return_integer(uint64_t arg);