soc/intel/cannonlake: Make use of is_devfn_enabled() function

1. Replace all pcidev_path_on_root() and is_dev_enabled() functions
combination with is_devfn_enabled().
2. Remove unused local variable of device structure type (struct device *).
3. Replace pcidev_path_on_root() and dev->enabled check with is_devfn_enabled()
call.

TEST=Able to build and boot without any regression seen on CML.

Signed-off-by: Subrata Banik <subrata.banik@intel.com>
Change-Id: Ib5df5fd32e2e2742d349754a942bf81ca505dd39
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55328
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Subrata Banik 2021-06-09 03:57:01 +05:30
parent 54a3417254
commit 6f910e24b6
2 changed files with 18 additions and 52 deletions

View File

@ -42,10 +42,7 @@ static const pci_devfn_t serial_io_dev[] = {
static uint8_t get_param_value(const config_t *config, uint32_t dev_offset) static uint8_t get_param_value(const config_t *config, uint32_t dev_offset)
{ {
struct device *dev; if (!is_devfn_enabled(serial_io_dev[dev_offset]))
dev = pcidev_path_on_root(serial_io_dev[dev_offset]);
if (!dev || !dev->enabled)
return PCH_SERIAL_IO_INDEX(PchSerialIoDisabled); return PCH_SERIAL_IO_INDEX(PchSerialIoDisabled);
if ((config->SerialIoDevMode[dev_offset] >= PchSerialIoMax) || if ((config->SerialIoDevMode[dev_offset] >= PchSerialIoMax) ||
@ -149,11 +146,8 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
params->PchLockDownRtcMemoryLock = 0; params->PchLockDownRtcMemoryLock = 0;
/* SATA */ /* SATA */
dev = pcidev_path_on_root(PCH_DEVFN_SATA); params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
if (!dev) if (params->SataEnable) {
params->SataEnable = 0;
else {
params->SataEnable = dev->enabled;
params->SataMode = config->SataMode; params->SataMode = config->SataMode;
params->SataPwrOptEnable = config->satapwroptimize; params->SataPwrOptEnable = config->satapwroptimize;
params->SataSalpSupport = config->SataSalpSupport; params->SataSalpSupport = config->SataSalpSupport;
@ -175,12 +169,9 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
params->PchPmSlpS0Vm075VSupport = config->PchPmSlpS0Vm075VSupport; params->PchPmSlpS0Vm075VSupport = config->PchPmSlpS0Vm075VSupport;
/* Lan */ /* Lan */
dev = pcidev_path_on_root(PCH_DEVFN_GBE); params->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE);
if (!dev) if (params->PchLanEnable) {
params->PchLanEnable = 0; if (config->s0ix_enable) {
else {
params->PchLanEnable = dev->enabled;
if (config->s0ix_enable && params->PchLanEnable) {
/* /*
* The VmControl UPDs need to be set as per board * The VmControl UPDs need to be set as per board
* design to allow voltage margining in S0ix to lower * design to allow voltage margining in S0ix to lower
@ -324,17 +315,10 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
#endif #endif
/* Enable CNVi Wifi if enabled in device tree */ /* Enable CNVi Wifi if enabled in device tree */
dev = pcidev_path_on_root(PCH_DEVFN_CNViWIFI);
#if CONFIG(SOC_INTEL_COMETLAKE) #if CONFIG(SOC_INTEL_COMETLAKE)
if (dev) params->CnviMode = is_devfn_enabled(PCH_DEVFN_CNViWIFI);
params->CnviMode = dev->enabled;
else
params->CnviMode = 0;
#else #else
if (dev) params->PchCnviMode = is_devfn_enabled(PCH_DEVFN_CNViWIFI);
params->PchCnviMode = dev->enabled;
else
params->PchCnviMode = 0;
#endif #endif
/* PCI Express */ /* PCI Express */
for (i = 0; i < ARRAY_SIZE(config->PcieClkSrcUsage); i++) { for (i = 0; i < ARRAY_SIZE(config->PcieClkSrcUsage); i++) {
@ -366,11 +350,8 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
}; };
/* eMMC and SD */ /* eMMC and SD */
dev = pcidev_path_on_root(PCH_DEVFN_EMMC); params->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC);
if (!dev) if (params->ScsEmmcEnabled) {
params->ScsEmmcEnabled = 0;
else {
params->ScsEmmcEnabled = dev->enabled;
params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled; params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
params->PchScsEmmcHs400DllDataValid = config->EmmcHs400DllNeed; params->PchScsEmmcHs400DllDataValid = config->EmmcHs400DllNeed;
if (config->EmmcHs400DllNeed == 1) { if (config->EmmcHs400DllNeed == 1) {
@ -381,29 +362,19 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
} }
} }
dev = pcidev_path_on_root(PCH_DEVFN_SDCARD); params->ScsSdCardEnabled = is_devfn_enabled(PCH_DEVFN_SDCARD);
if (!dev) { if (params->ScsSdCardEnabled) {
params->ScsSdCardEnabled = 0; params->SdCardPowerEnableActiveHigh = CONFIG(MB_HAS_ACTIVE_HIGH_SD_PWR_ENABLE);
} else {
params->ScsSdCardEnabled = dev->enabled;
params->SdCardPowerEnableActiveHigh =
CONFIG(MB_HAS_ACTIVE_HIGH_SD_PWR_ENABLE);
#if CONFIG(SOC_INTEL_COMETLAKE) #if CONFIG(SOC_INTEL_COMETLAKE)
params->ScsSdCardWpPinEnabled = config->ScsSdCardWpPinEnabled; params->ScsSdCardWpPinEnabled = config->ScsSdCardWpPinEnabled;
#endif #endif
} }
dev = pcidev_path_on_root(PCH_DEVFN_UFS); params->ScsUfsEnabled = is_devfn_enabled(PCH_DEVFN_UFS);
if (!dev)
params->ScsUfsEnabled = 0;
else
params->ScsUfsEnabled = dev->enabled;
dev = pcidev_path_on_root(PCH_DEVFN_CSE_3); params->Heci3Enabled = is_devfn_enabled(PCH_DEVFN_CSE_3);
params->Heci3Enabled = is_dev_enabled(dev);
#if !CONFIG(HECI_DISABLE_USING_SMM) #if !CONFIG(HECI_DISABLE_USING_SMM)
dev = pcidev_path_on_root(PCH_DEVFN_CSE); params->Heci1Disabled = !is_devfn_enabled(PCH_DEVFN_CSE);
params->Heci1Disabled = !is_dev_enabled(dev);
#endif #endif
params->Device4Enable = config->Device4Enable; params->Device4Enable = config->Device4Enable;
@ -510,11 +481,7 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
params->VrPowerDeliveryDesign = config->VrPowerDeliveryDesign; params->VrPowerDeliveryDesign = config->VrPowerDeliveryDesign;
#endif #endif
dev = pcidev_path_on_root(SA_DEVFN_IGD); params->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD);
if (CONFIG(RUN_FSP_GOP) && dev && dev->enabled)
params->PeiGraphicsPeimInit = 1;
else
params->PeiGraphicsPeimInit = 0;
params->PavpEnable = CONFIG(PAVP); params->PavpEnable = CONFIG(PAVP);

View File

@ -19,8 +19,7 @@ void smihandler_soc_at_finalize(void)
if (!CONFIG(HECI_DISABLE_USING_SMM)) if (!CONFIG(HECI_DISABLE_USING_SMM))
return; return;
const struct device *dev = pcidev_path_on_root(PCH_DEVFN_CSE); if (!is_devfn_enabled(PCH_DEVFN_CSE))
if (!is_dev_enabled(dev))
heci_disable(); heci_disable();
} }