soc/intel: Use config_of_path(SA_DEVFN_ROOT)
We do not want to disguise somewhat complex function
calls as simple macros.
Change-Id: I53324603c9ece1334c6e09d51338084166f7a585
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34299
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: David Guckian
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/soc/intel/apollolake/acpi.c b/src/soc/intel/apollolake/acpi.c
index cec706f..f729f31 100644
--- a/src/soc/intel/apollolake/acpi.c
+++ b/src/soc/intel/apollolake/acpi.c
@@ -90,7 +90,7 @@
void acpi_create_gnvs(struct global_nvs_t *gnvs)
{
struct soc_intel_apollolake_config *cfg;
- struct device *dev = SA_DEV_ROOT;
+ cfg = config_of_path(SA_DEVFN_ROOT);
/* Clear out GNVS. */
memset(gnvs, 0, sizeof(*gnvs));
@@ -110,12 +110,6 @@
/* CPU core count */
gnvs->pcnt = dev_count_cpu();
- if (!dev || !dev->chip_info) {
- printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
- return;
- }
- cfg = dev->chip_info;
-
/* Enable DPTF based on mainboard configuration */
gnvs->dpte = cfg->dptf_enable;
@@ -158,7 +152,7 @@
void soc_fill_fadt(acpi_fadt_t *fadt)
{
const struct soc_intel_apollolake_config *cfg;
- struct device *dev = SA_DEV_ROOT;
+ cfg = config_of_path(SA_DEVFN_ROOT);
fadt->pm_tmr_blk = ACPI_BASE_ADDRESS + PM1_TMR;
@@ -174,13 +168,8 @@
fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
fadt->x_pm_tmr_blk.addrl = ACPI_BASE_ADDRESS + PM1_TMR;
- if (!dev || !dev->chip_info) {
- printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
- return;
- }
- cfg = dev->chip_info;
- if(cfg->lpss_s0ix_enable)
+ if (cfg->lpss_s0ix_enable)
fadt->flags |= ACPI_FADT_LOW_PWR_IDLE_S0;
}
diff --git a/src/soc/intel/apollolake/chip.c b/src/soc/intel/apollolake/chip.c
index 1d5e6d9..3c4bf96 100644
--- a/src/soc/intel/apollolake/chip.c
+++ b/src/soc/intel/apollolake/chip.c
@@ -295,24 +295,18 @@
static void set_power_limits(void)
{
static struct soc_intel_apollolake_config *cfg;
- struct device *dev = SA_DEV_ROOT;
msr_t rapl_msr_reg, limit;
uint32_t power_unit;
uint32_t tdp, min_power, max_power;
uint32_t pl2_val;
+ cfg = config_of_path(SA_DEVFN_ROOT);
+
if (CONFIG(APL_SKIP_SET_POWER_LIMITS)) {
printk(BIOS_INFO, "Skip the RAPL settings.\n");
return;
}
- if (!dev || !dev->chip_info) {
- printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
- return;
- }
-
- cfg = dev->chip_info;
-
/* Get units */
rapl_msr_reg = rdmsr(MSR_PKG_POWER_SKU_UNIT);
power_unit = 1 << (rapl_msr_reg.lo & 0xf);
@@ -368,15 +362,9 @@
static void set_sci_irq(void)
{
static struct soc_intel_apollolake_config *cfg;
- struct device *dev = SA_DEV_ROOT;
uint32_t scis;
- if (!dev || !dev->chip_info) {
- printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
- return;
- }
-
- cfg = dev->chip_info;
+ cfg = config_of_path(SA_DEVFN_ROOT);
/* Change only if a device tree entry exists. */
if (cfg->sci_irq) {
@@ -550,7 +538,7 @@
static void parse_devicetree(FSP_S_CONFIG *silconfig)
{
- struct device *dev = SA_DEV_ROOT;
+ struct device *dev = pcidev_path_on_root(SA_DEVFN_ROOT);
if (!dev) {
printk(BIOS_ERR, "Could not find root device\n");
@@ -679,21 +667,16 @@
{
FSP_S_CONFIG *silconfig = &silupd->FspsConfig;
static struct soc_intel_apollolake_config *cfg;
+ struct device *dev;
/* Load VBT before devicetree-specific config. */
silconfig->GraphicsConfigPtr = (uintptr_t)vbt_get();
- struct device *dev = SA_DEV_ROOT;
-
- if (!dev || !dev->chip_info) {
- printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
- return;
- }
+ dev = pcidev_path_on_root(SA_DEVFN_ROOT);
+ cfg = config_of(dev);
mainboard_devtree_update(dev);
- cfg = dev->chip_info;
-
/* Parse device tree and disable unused device*/
parse_devicetree(silconfig);
diff --git a/src/soc/intel/apollolake/cpu.c b/src/soc/intel/apollolake/cpu.c
index aad0f6b..625d956 100644
--- a/src/soc/intel/apollolake/cpu.c
+++ b/src/soc/intel/apollolake/cpu.c
@@ -295,14 +295,7 @@
int soc_fill_sgx_param(struct sgx_param *sgx_param)
{
- struct device *dev = SA_DEV_ROOT;
- assert(dev != NULL);
- config_t *conf = dev->chip_info;
-
- if (!conf) {
- printk(BIOS_ERR, "Failed to get chip_info for SGX param\n");
- return -1;
- }
+ config_t *conf = config_of_path(SA_DEVFN_ROOT);
sgx_param->enable = conf->sgx_enable;
return 0;
diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c
index 1bf3202..84b61da 100644
--- a/src/soc/intel/apollolake/pmutil.c
+++ b/src/soc/intel/apollolake/pmutil.c
@@ -148,13 +148,7 @@
{
DEVTREE_CONST struct soc_intel_apollolake_config *config;
- /* Look up the device in devicetree */
- DEVTREE_CONST struct device *dev = pcidev_path_on_root(SA_DEVFN_ROOT);
- if (!dev || !dev->chip_info) {
- printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
- return;
- }
- config = dev->chip_info;
+ config = config_of_path(SA_DEVFN_ROOT);
/* Assign to out variable */
*dw0 = config->gpe0_dw1;
diff --git a/src/soc/intel/apollolake/pnpconfig.c b/src/soc/intel/apollolake/pnpconfig.c
index f9d493e..0e9e931 100644
--- a/src/soc/intel/apollolake/pnpconfig.c
+++ b/src/soc/intel/apollolake/pnpconfig.c
@@ -37,8 +37,10 @@
int index;
size_t arrsize;
const struct pnpconfig *pnpconfigarr;
- struct device *dev = SA_DEV_ROOT;
- struct soc_intel_apollolake_config *config = dev->chip_info;
+ struct soc_intel_apollolake_config *config;
+
+ config = config_of_path(SA_DEVFN_ROOT);
+
switch (config->pnp_settings) {
case PNP_PERF:
pnpconfigarr = perf;
diff --git a/src/soc/intel/apollolake/romstage.c b/src/soc/intel/apollolake/romstage.c
index 72a566a..6d3b346 100644
--- a/src/soc/intel/apollolake/romstage.c
+++ b/src/soc/intel/apollolake/romstage.c
@@ -100,17 +100,8 @@
/* Thermal throttle activation offset */
static void configure_thermal_target(void)
{
- const struct device *dev = pcidev_path_on_root(SA_DEVFN_ROOT);
- if (!dev) {
- printk(BIOS_ERR, "Could not find SOC devicetree config\n");
- return;
- }
- const config_t *conf = dev->chip_info;
- if (!dev->chip_info) {
- printk(BIOS_ERR, "Could not find chip info\n");
- return;
- }
msr_t msr;
+ const config_t *conf = config_of_path(SA_DEVFN_ROOT);
if (!conf->tcc_offset)
return;