dptf: Move platform-specific information to `struct dptf_platform_info`

DPTF HIDs are different per-platform going forward, so refactor these
into SoC-specific structures which the DPTF driver can query at runtime
for platform-specific information.

Change-Id: I6307f9d28f4274b851323ad69180ff4ae35053da
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52220
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Sumeet R Pawnikar <sumeet.r.pawnikar@intel.com>
This commit is contained in:
Tim Wawrzynczak 2021-04-09 12:15:21 -06:00 committed by Patrick Georgi
parent 24ea3f3364
commit 7f7c3882a6
12 changed files with 107 additions and 45 deletions

View File

@ -5,13 +5,3 @@ config DRIVERS_INTEL_DPTF
help
When enabled, entries in the devicetree are used to generate
Intel DPTF Tables at runtime in the SSDT.
config DPTF_USE_EISA_HID
bool
depends on DRIVERS_INTEL_DPTF
default n
help
Prior to Tiger Lake, all DPTF devices used 7-character EISA
IDs. If selected, the 7-character _HIDs will be emitted,
otherwise, it will use the "new" style, which are regular
8-character _HIDs.

View File

@ -5,6 +5,7 @@
#include <console/console.h>
#include <device/device.h>
#include "chip.h"
#include "dptf.h"
/* Generic DPTF participants have a PTYP field to distinguish them */
enum dptf_generic_participant_type {
@ -14,14 +15,6 @@ enum dptf_generic_participant_type {
#define DEFAULT_CHARGER_STR "Battery Charger"
#define DPTF_DEVICE_HID_EISAID "INT3400"
#define GENERIC_HID_EISAID "INT3403"
#define FAN_HID_EISAID "INT3404"
#define DPTF_DEVICE_HID "INTC1040"
#define GENERIC_HID "INTC1043"
#define FAN_HID "INTC1044"
/*
* Helper method to determine if a device is "used" (called out anywhere as a source or a target
* of any policies, and therefore should be included in the ACPI tables.
@ -67,20 +60,26 @@ static int get_STA_value(const struct drivers_intel_dptf_config *config,
ACPI_STATUS_DEVICE_ALL_OFF;
}
static void dptf_write_hid(bool is_eisa, const char *hid)
{
if (is_eisa)
acpigen_emit_eisaid(hid);
else
acpigen_write_string(hid);
}
/* Devices with GENERIC _HID (distinguished by PTYP) */
static void dptf_write_generic_participant(const char *name,
enum dptf_generic_participant_type ptype,
const char *str, int sta_val)
const char *str, int sta_val,
const struct dptf_platform_info *platform_info)
{
/* Auto-incrementing UID for generic participants */
static int generic_uid = 0;
acpigen_write_device(name);
acpigen_write_name("_HID");
if (CONFIG(DPTF_USE_EISA_HID))
acpigen_emit_eisaid(GENERIC_HID_EISAID);
else
acpigen_write_string(GENERIC_HID);
dptf_write_hid(platform_info->use_eisa_hids, platform_info->generic_hid);
acpigen_write_name_integer("_UID", generic_uid++);
acpigen_write_STA(sta_val);
@ -107,49 +106,46 @@ static void write_tcpu(const struct device *pci_dev,
}
/* \_SB.DPTF.TFN1 */
static void write_fan(const struct drivers_intel_dptf_config *config)
static void write_fan(const struct drivers_intel_dptf_config *config,
const struct dptf_platform_info *platform_info)
{
acpigen_write_device("TFN1");
acpigen_write_name("_HID");
if (CONFIG(DPTF_USE_EISA_HID))
acpigen_emit_eisaid(FAN_HID_EISAID);
else
acpigen_write_string(FAN_HID);
dptf_write_hid(platform_info->use_eisa_hids, platform_info->fan_hid);
acpigen_write_name_integer("_UID", 0);
acpigen_write_STA(get_STA_value(config, DPTF_FAN));
acpigen_pop_len(); /* Device */
}
/* \_SB.DPTF.xxxx */
static void write_generic_devices(const struct drivers_intel_dptf_config *config)
static void write_generic_devices(const struct drivers_intel_dptf_config *config,
const struct dptf_platform_info *platform_info)
{
enum dptf_participant participant;
char name[ACPI_NAME_BUFFER_SIZE];
int i;
dptf_write_generic_participant("TCHG", DPTF_GENERIC_PARTICIPANT_TYPE_CHARGER,
DEFAULT_CHARGER_STR, get_STA_value(config,
DPTF_CHARGER));
DEFAULT_CHARGER_STR,
get_STA_value(config, DPTF_CHARGER),
platform_info);
for (i = 0, participant = DPTF_TEMP_SENSOR_0; i < 4; ++i, ++participant) {
snprintf(name, sizeof(name), "TSR%1d", i);
dptf_write_generic_participant(name, DPTF_GENERIC_PARTICIPANT_TYPE_TSR,
NULL, get_STA_value(config, participant));
NULL, get_STA_value(config, participant),
platform_info);
}
}
/* \_SB.DPTF - note: leaves the Scope open for child devices*/
static void write_open_dptf_device(const struct device *dev)
static void write_open_dptf_device(const struct device *dev,
const struct dptf_platform_info *platform_info)
{
acpigen_write_scope("\\_SB");
acpigen_write_device(acpi_device_name(dev));
acpigen_write_name("_HID");
if (CONFIG(DPTF_USE_EISA_HID))
acpigen_emit_eisaid(DPTF_DEVICE_HID_EISAID);
else
acpigen_write_string(DPTF_DEVICE_HID);
dptf_write_hid(platform_info->use_eisa_hids, platform_info->dptf_device_hid);
acpigen_write_name_integer("_UID", 0);
acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
}
@ -157,6 +153,7 @@ static void write_open_dptf_device(const struct device *dev)
/* Add minimal definitions of DPTF devices into the SSDT */
static void write_device_definitions(const struct device *dev)
{
const struct dptf_platform_info *platform_info = get_dptf_platform_info();
const struct drivers_intel_dptf_config *config;
struct device *parent;
@ -170,9 +167,9 @@ static void write_device_definitions(const struct device *dev)
config = config_of(dev);
write_tcpu(parent, config);
write_open_dptf_device(dev);
write_fan(config);
write_generic_devices(config);
write_open_dptf_device(dev, platform_info);
write_fan(config, platform_info);
write_generic_devices(config, platform_info);
acpigen_pop_len(); /* DPTF Device (write_open_dptf_device) */
acpigen_pop_len(); /* Scope */

View File

@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _DRIVERS_INTEL_DPTF_H_
#define _DRIVERS_INTEL_DPTF_H_
#include <types.h>
struct dptf_platform_info {
/*
* True indicates the platform-specific HIDs are to be emitted in EISA
* format instead of a string.
*/
bool use_eisa_hids;
const char *dptf_device_hid;
const char *generic_hid;
const char *fan_hid;
};
const struct dptf_platform_info *get_dptf_platform_info(void);
#endif /* _DRIVERS_INTEL_DPTF_H_ */

View File

@ -1,7 +1,6 @@
config BOARD_GOOGLE_BASEBOARD_DEDEDE
def_bool n
select BOARD_ROMSIZE_KB_16384 if !BOARD_ROMSIZE_KB_32768
select DPTF_USE_EISA_HID
select DRIVERS_GENERIC_GPIO_KEYS
select DRIVERS_I2C_GENERIC
select DRIVERS_I2C_GPIO_MUX

View File

@ -13,7 +13,6 @@ config BOARD_GOOGLE_BASEBOARD_PUFF
select SPD_READ_BY_WORD
select SOC_INTEL_CSE_LITE_SKU
select DRIVERS_INTEL_DPTF
select DPTF_USE_EISA_HID
config BOARD_GOOGLE_HATCH_COMMON
def_bool n

View File

@ -3,7 +3,6 @@ if BOARD_INTEL_JASPERLAKE_RVP || BOARD_INTEL_JASPERLAKE_RVP_EXT_EC
config BOARD_SPECIFIC_OPTIONS
def_bool y
select BOARD_ROMSIZE_KB_16384
select DPTF_USE_EISA_HID
select DRIVERS_I2C_DA7219
select DRIVERS_I2C_HID
select DRIVERS_INTEL_DPTF

View File

@ -32,6 +32,7 @@ romstage-y += uart.c
ramstage-y += acpi.c
ramstage-y += chip.c
ramstage-y += cpu.c
ramstage-y += dptf.c
ramstage-y += elog.c
ramstage-y += finalize.c
ramstage-y += fsp_params.c

View File

@ -0,0 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <drivers/intel/dptf/dptf.h>
static const struct dptf_platform_info cnl_dptf_platform_info = {
.use_eisa_hids = true,
/* _HID for the toplevel DPTF device, typically \_SB.DPTF */
.dptf_device_hid = "INT3400",
/* _HID for Intel DPTF Generic Device (these require PTYP as well) */
.generic_hid = "INT3403",
/* _HID for Intel DPTF Fan Device */
.fan_hid = "INT3404",
};
const struct dptf_platform_info *get_dptf_platform_info(void)
{
return &cnl_dptf_platform_info;
}

View File

@ -30,6 +30,7 @@ romstage-y += reset.c
ramstage-y += acpi.c
ramstage-y += chip.c
ramstage-y += cpu.c
ramstage-y += dptf.c
ramstage-y += elog.c
ramstage-y += espi.c
ramstage-y += finalize.c

View File

@ -0,0 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <drivers/intel/dptf/dptf.h>
static const struct dptf_platform_info jsl_dptf_platform_info = {
.use_eisa_hids = true,
/* _HID for the toplevel DPTF device, typically \_SB.DPTF */
.dptf_device_hid = "INT3400",
/* _HID for Intel DPTF Generic Device (these require PTYP as well) */
.generic_hid = "INT3403",
/* _HID for Intel DPTF Fan Device */
.fan_hid = "INT3404",
};
const struct dptf_platform_info *get_dptf_platform_info(void)
{
return &jsl_dptf_platform_info;
}

View File

@ -30,6 +30,7 @@ romstage-y += reset.c
ramstage-y += acpi.c
ramstage-y += chip.c
ramstage-y += cpu.c
ramstage-y += dptf.c
ramstage-y += elog.c
ramstage-y += espi.c
ramstage-y += finalize.c

View File

@ -0,0 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <drivers/intel/dptf/dptf.h>
static const struct dptf_platform_info tgl_dptf_platform_info = {
.use_eisa_hids = false,
/* _HID for the toplevel DPTF device, typically \_SB.DPTF */
.dptf_device_hid = "INTC1040",
/* _HID for Intel DPTF Generic Device (these require PTYP as well) */
.generic_hid = "INTC1043",
/* _HID for Intel DPTF Fan Device */
.fan_hid = "INTC1044",
};
const struct dptf_platform_info *get_dptf_platform_info(void)
{
return &tgl_dptf_platform_info;
}