Attention is currently required from: Andrey Petrov, Patrick Rudolph. Felix Singer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/52834 )
Change subject: soc/intel/apollolake: Use set_dev_state_by_devicetree() ......................................................................
soc/intel/apollolake: Use set_dev_state_by_devicetree()
Change-Id: I919f1bcfa96956f0285ad803bd81e714ab4bb97a Signed-off-by: Felix Singer felixsinger@posteo.net --- M src/soc/intel/apollolake/chip.c M src/soc/intel/apollolake/romstage.c 2 files changed, 52 insertions(+), 74 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/52834/1
diff --git a/src/soc/intel/apollolake/chip.c b/src/soc/intel/apollolake/chip.c index 7172231..dd0f993 100644 --- a/src/soc/intel/apollolake/chip.c +++ b/src/soc/intel/apollolake/chip.c @@ -8,6 +8,7 @@ #include <cpu/x86/mp.h> #include <device/mmio.h> #include <device/device.h> +#include <device/devenmap.h> #include <device/pci.h> #include <device/pci_ops.h> #include <intelblocks/acpi.h> @@ -342,18 +343,6 @@ static void disable_dev(struct device *dev, FSP_S_CONFIG *silconfig) { switch (dev->path.pci.devfn) { - case PCH_DEVFN_NPK: - /* - * Disable this device in the parse_devicetree_setting() function - * in romstage.c - */ - break; - case PCH_DEVFN_ISH: - silconfig->IshEnable = 0; - break; - case PCH_DEVFN_SATA: - silconfig->EnableSata = 0; - break; case PCH_DEVFN_PCIE5: silconfig->PcieRootPortEn[0] = 0; silconfig->PcieRpHotPlug[0] = 0; @@ -378,76 +367,38 @@ silconfig->PcieRootPortEn[5] = 0; silconfig->PcieRpHotPlug[5] = 0; break; + case PCH_DEVFN_NPK: + /* + * Disable this device in the parse_devicetree_setting() function + * in romstage.c + */ + case PCH_DEVFN_ISH: + case PCH_DEVFN_SATA: case PCH_DEVFN_XHCI: - silconfig->Usb30Mode = 0; - break; case PCH_DEVFN_XDCI: - silconfig->UsbOtg = 0; - break; case PCH_DEVFN_I2C0: - silconfig->I2c0Enable = 0; - break; case PCH_DEVFN_I2C1: - silconfig->I2c1Enable = 0; - break; case PCH_DEVFN_I2C2: - silconfig->I2c2Enable = 0; - break; case PCH_DEVFN_I2C3: - silconfig->I2c3Enable = 0; - break; case PCH_DEVFN_I2C4: - silconfig->I2c4Enable = 0; - break; case PCH_DEVFN_I2C5: - silconfig->I2c5Enable = 0; - break; case PCH_DEVFN_I2C6: - silconfig->I2c6Enable = 0; - break; case PCH_DEVFN_I2C7: - silconfig->I2c7Enable = 0; - break; case PCH_DEVFN_UART0: - silconfig->Hsuart0Enable = 0; - break; case PCH_DEVFN_UART1: - silconfig->Hsuart1Enable = 0; - break; case PCH_DEVFN_UART2: - silconfig->Hsuart2Enable = 0; - break; case PCH_DEVFN_UART3: - silconfig->Hsuart3Enable = 0; - break; case PCH_DEVFN_SPI0: - silconfig->Spi0Enable = 0; - break; case PCH_DEVFN_SPI1: - silconfig->Spi1Enable = 0; - break; case PCH_DEVFN_SPI2: - silconfig->Spi2Enable = 0; - break; case PCH_DEVFN_SDCARD: - silconfig->SdcardEnabled = 0; - break; case PCH_DEVFN_EMMC: - silconfig->eMMCEnabled = 0; - break; case PCH_DEVFN_SDIO: - silconfig->SdioEnabled = 0; - break; case PCH_DEVFN_SMBUS: - silconfig->SmbusEnable = 0; - break; #if !CONFIG(SOC_INTEL_GEMINILAKE) case SA_DEVFN_IPU: - silconfig->IpuEn = 0; - break; #endif case PCH_DEVFN_HDA: - silconfig->HdaEnable = 0; break; default: printk(BIOS_WARNING, "PCI:%02x.%01x: Could not disable the device\n", @@ -618,6 +569,39 @@ mainboard_devtree_update(dev);
/* Parse device tree and disable unused device*/ + + const struct device_enable_map devmap[] = { + { &silconfig->IshEnable, PCH_DEVFN_ISH }, + { &silconfig->EnableSata, PCH_DEVFN_SATA }, + { &silconfig->Usb30Mode, PCH_DEVFN_XHCI }, + { &silconfig->UsbOtg, PCH_DEVFN_XDCI }, + { &silconfig->I2c0Enable, PCH_DEVFN_I2C0 }, + { &silconfig->I2c1Enable, PCH_DEVFN_I2C1 }, + { &silconfig->I2c2Enable, PCH_DEVFN_I2C2 }, + { &silconfig->I2c3Enable, PCH_DEVFN_I2C3 }, + { &silconfig->I2c4Enable, PCH_DEVFN_I2C4 }, + { &silconfig->I2c5Enable, PCH_DEVFN_I2C5 }, + { &silconfig->I2c6Enable, PCH_DEVFN_I2C6 }, + { &silconfig->I2c7Enable, PCH_DEVFN_I2C7 }, + { &silconfig->Hsuart0Enable, PCH_DEVFN_UART0 }, + { &silconfig->Hsuart1Enable, PCH_DEVFN_UART1 }, + { &silconfig->Hsuart2Enable, PCH_DEVFN_UART2 }, + { &silconfig->Hsuart3Enable, PCH_DEVFN_UART3 }, + { &silconfig->Spi0Enable, PCH_DEVFN_SPI0 }, + { &silconfig->Spi1Enable, PCH_DEVFN_SPI1 }, + { &silconfig->Spi2Enable, PCH_DEVFN_SPI2 }, + { &silconfig->SdcardEnabled, PCH_DEVFN_SDCARD }, + { &silconfig->eMMCEnabled, PCH_DEVFN_EMMC }, + { &silconfig->SdioEnabled, PCH_DEVFN_SDIO }, + { &silconfig->SmbusEnable, PCH_DEVFN_SMBUS }, + { &silconfig->HdaEnable PCH_DEVFN_HDA }, +#if !CONFIG(SOC_INTEL_GEMINILAKE) + { &silconfig->IpuEn, SA_DEVFN_IPU }, +#endif + }; + + set_dev_state_by_devicetree(devmap, ARRAY_SIZE(devmap)); + parse_devicetree(silconfig);
memcpy(silconfig->PcieRpClkReqNumber, cfg->pcie_rp_clkreq_pin, @@ -682,11 +666,8 @@ else apl_fsp_silicon_init_params_cb(cfg, silconfig);
- /* Enable xDCI controller if enabled in devicetree and allowed */ - dev = pcidev_path_on_root(PCH_DEVFN_XDCI); - if (!xdci_can_enable()) - dev->enabled = 0; - silconfig->UsbOtg = dev->enabled; + /* Enable xDCI controller if allowed */ + silconfig->UsbOtg = xdci_can_enable();
silconfig->VmxEnable = CONFIG(ENABLE_VMX);
diff --git a/src/soc/intel/apollolake/romstage.c b/src/soc/intel/apollolake/romstage.c index 0aa6c39..0a338f1 100644 --- a/src/soc/intel/apollolake/romstage.c +++ b/src/soc/intel/apollolake/romstage.c @@ -254,17 +254,6 @@ #endif }
-static void parse_devicetree_setting(FSPM_UPD *m_upd) -{ - DEVTREE_CONST struct device *dev = pcidev_path_on_root(PCH_DEVFN_NPK); - -#if CONFIG(SOC_INTEL_GEMINILAKE) - m_upd->FspmConfig.TraceHubEn = is_dev_enabled(dev); -#else - m_upd->FspmConfig.NpkEn = is_dev_enabled(dev); -#endif -} - void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) { check_full_retrain(mupd); @@ -276,7 +265,15 @@
mainboard_memory_init_params(mupd);
- parse_devicetree_setting(mupd); + const struct device_enable_map devmap[] = { +#if CONFIG(SOC_INTEL_GEMINILAKE) + { &m_upd->FspmConfig.TraceHubEn, PCH_DEVFN_NPK }, +#else + { &m_upd->FspmConfig.NpkEn, PCH_DEVFN_NPK }, +#endif + }; + + set_dev_state_by_devicetree(devmap, ARRAY_SIZE(devmap));
/* Do NOT let FSP do any GPIO pad configuration */ mupd->FspmConfig.PreMemGpioTablePtr = (uintptr_t) NULL;