diff options
Diffstat (limited to 'roms/u-boot/arch/x86/cpu/apollolake')
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/Kconfig | 113 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/Makefile | 27 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/acpi.c | 226 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/cpu.c | 202 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/cpu_common.c | 102 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/cpu_spl.c | 196 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/fsp_bindings.c | 1856 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/fsp_m.c | 67 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/fsp_s.c | 229 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/hostbridge.c | 395 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/lpc.c | 144 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/pch.c | 38 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/pmc.c | 224 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/punit.c | 97 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/spl.c | 157 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/systemagent.c | 23 | ||||
-rw-r--r-- | roms/u-boot/arch/x86/cpu/apollolake/uart.c | 142 |
17 files changed, 4238 insertions, 0 deletions
diff --git a/roms/u-boot/arch/x86/cpu/apollolake/Kconfig b/roms/u-boot/arch/x86/cpu/apollolake/Kconfig new file mode 100644 index 000000000..b3ce05317 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/Kconfig @@ -0,0 +1,113 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright 2019 Google LLC +# + +config INTEL_APOLLOLAKE + bool + select FSP_VERSION2 + select HAVE_FSP + select ARCH_MISC_INIT + select USE_CAR + select INTEL_SOC + select INTEL_PMC + select TPL_X86_TSC_TIMER_NATIVE + select SPL_PCH_SUPPORT + select TPL_PCH_SUPPORT + select PCIEX_LENGTH_256MB + select PCH_SUPPORT + select P2SB + select SMP_AP_WORK + select INTEL_GMA_SWSMISCI + select ACPI_GNVS_EXTERNAL + select TPL_OF_PLATDATA_PARENT + select TPL_OF_PLATDATA_INST + select TPL_READ_ONLY + imply ENABLE_MRC_CACHE + imply AHCI_PCI + imply SCSI + imply SCSI_AHCI + imply SPI_FLASH + imply USB + imply USB_EHCI_HCD + imply TPL + imply SPL + imply TPL_X86_16BIT_INIT + imply TPL_OF_PLATDATA + imply ACPI_PMC + imply MMC + imply DM_MMC + imply MMC_PCI + imply MMC_SDHCI + imply CMD_MMC + imply VIDEO_FSP + imply PINCTRL_INTEL + imply PINCTRL_INTEL_APL + imply HAVE_VBT + imply HAVE_X86_FIT + imply INTEL_GPIO + imply SMP + imply HAVE_ITSS + imply HAVE_P2SB + imply CLK + imply CMD_CLK + imply CLK_INTEL + imply ACPI_GPE + imply INTEL_GMA_ACPI + +if INTEL_APOLLOLAKE + +config DCACHE_RAM_BASE + default 0xfef00000 + +config DCACHE_RAM_SIZE + default 0xc0000 + +config DCACHE_RAM_MRC_VAR_SIZE + default 0xb0000 + +config CPU_SPECIFIC_OPTIONS + def_bool y + select SMM_TSEG + select X86_RAMTEST + +config SMM_TSEG_SIZE + hex + default 0x800000 + +config MMCONF_BASE_ADDRESS + hex + default 0xe0000000 + +config TPL_SIZE_LIMIT + default 0x7800 + +config CPU_ADDR_BITS + default 39 + +config APL_SPI_FLASH_BOOT + bool "Support booting with SPI-flash driver instead memory-mapped SPI" + select TPL_SPI_FLASH_SUPPORT + select TPL_SPI_SUPPORT + select TPL_DM_SPI + select TPL_DM_SPI_FLASH + help + This enables SPI and SPI flash in TPL. Without the this only + available boot method is to use memory-mapped SPI. Since this is + actually fast and produces a TPL which is 7KB smaller, memory-mapped + SPI is the default. + +config APL_BOOT_FROM_FAST_SPI_FLASH + bool "Boot using SPI flash driver" + select APL_SPI_FLASH_BOOT + help + This option is separate from APL_SPI_FLASH_BOOT since it is useful to + be able to compare booting speed with the same build. Enable this to + use the SPI-flash driver to load SPL, U-Boot and FSP-M. For technical + reasons FSP-S is currently always loaded from memory-mapped SPI. See + Apollo Lake's arch_fsp_init_r() for details about that. + +config VBT_ADDR + default 0xff3f1000 + +endif diff --git a/roms/u-boot/arch/x86/cpu/apollolake/Makefile b/roms/u-boot/arch/x86/cpu/apollolake/Makefile new file mode 100644 index 000000000..2ddf4af62 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2019 Google LLC + +obj-$(CONFIG_SPL_BUILD) += cpu_spl.o +obj-$(CONFIG_SPL_BUILD) += spl.o +obj-$(CONFIG_SPL_BUILD) += systemagent.o +obj-y += cpu_common.o + +ifndef CONFIG_TPL_BUILD +obj-y += cpu.o +obj-y += punit.o +obj-y += fsp_bindings.o +ifdef CONFIG_SPL_BUILD +obj-y += fsp_m.o +endif +endif +ifndef CONFIG_SPL_BUILD +obj-y += acpi.o +obj-y += fsp_s.o +endif + +obj-y += hostbridge.o +obj-y += lpc.o +obj-y += pch.o +obj-y += pmc.o +obj-y += uart.o diff --git a/roms/u-boot/arch/x86/cpu/apollolake/acpi.c b/roms/u-boot/arch/x86/cpu/apollolake/acpi.c new file mode 100644 index 000000000..fd21c0b49 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/acpi.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 Intel Corp. + * Copyright (C) 2017-2019 Siemens AG + * (Written by Lance Zhao <lijian.zhao@intel.com> for Intel Corp.) + * Copyright 2019 Google LLC + * + * Modified from coreboot apollolake/acpi.c + */ + +#define LOG_CATEGORY LOGC_ACPI + +#include <common.h> +#include <cpu.h> +#include <dm.h> +#include <log.h> +#include <p2sb.h> +#include <pci.h> +#include <acpi/acpigen.h> +#include <acpi/acpi_s3.h> +#include <asm/acpi_table.h> +#include <asm/cpu_common.h> +#include <asm/intel_acpi.h> +#include <asm/intel_gnvs.h> +#include <asm/intel_pinctrl.h> +#include <asm/intel_pinctrl_defs.h> +#include <asm/intel_regs.h> +#include <asm/io.h> +#include <asm/mpspec.h> +#include <asm/tables.h> +#include <asm/arch/iomap.h> +#include <asm/arch/gpio.h> +#include <asm/arch/pm.h> +#include <asm/arch/systemagent.h> +#include <dm/acpi.h> +#include <dm/uclass-internal.h> +#include <power/acpi_pmc.h> + +int arch_read_sci_irq_select(void) +{ + struct acpi_pmc_upriv *upriv; + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &dev); + if (ret) + return log_msg_ret("pmc", ret); + upriv = dev_get_uclass_priv(dev); + + return readl(upriv->pmc_bar0 + IRQ_REG); +} + +int arch_write_sci_irq_select(uint scis) +{ + struct acpi_pmc_upriv *upriv; + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &dev); + if (ret) + return log_msg_ret("pmc", ret); + upriv = dev_get_uclass_priv(dev); + writel(scis, upriv->pmc_bar0 + IRQ_REG); + + return 0; +} + +/** + * chromeos_init_acpi() - Initialise basic data to boot Chrome OS + * + * This tells Chrome OS to boot in developer mode + * + * @cros: Structure to initialise + */ +static void chromeos_init_acpi(struct chromeos_acpi_gnvs *cros) +{ + cros->active_main_fw = 1; + cros->active_main_fw = 1; /* A */ + cros->switches = CHSW_DEVELOPER_SWITCH; + cros->main_fw_type = 2; /* Developer */ +} + +int acpi_create_gnvs(struct acpi_global_nvs *gnvs) +{ + struct udevice *cpu; + int ret; + + /* Clear out GNV */ + memset(gnvs, '\0', sizeof(*gnvs)); + + /* TODO(sjg@chromium.org): Add the console log to gnvs->cbmc */ + + if (IS_ENABLED(CONFIG_CHROMEOS)) + chromeos_init_acpi(&gnvs->chromeos); + + /* Set unknown wake source */ + gnvs->pm1i = ~0ULL; + + /* CPU core count */ + gnvs->pcnt = 1; + ret = uclass_find_first_device(UCLASS_CPU, &cpu); + if (cpu) { + ret = cpu_get_count(cpu); + if (ret > 0) + gnvs->pcnt = ret; + } + + gnvs->dpte = 1; + + return 0; +} + +uint32_t acpi_fill_soc_wake(uint32_t generic_pm1_en) +{ + /* + * WAK_STS bit is set when the system is in one of the sleep states + * (via the SLP_EN bit) and an enabled wake event occurs. Upon setting + * this bit, the PMC will transition the system to the ON state and + * can only be set by hardware and can only be cleared by writing a one + * to this bit position. + */ + generic_pm1_en |= WAK_STS | RTC_EN | PWRBTN_EN; + + return generic_pm1_en; +} + +int arch_madt_sci_irq_polarity(int sci) +{ + return MP_IRQ_POLARITY_LOW; +} + +void fill_fadt(struct acpi_fadt *fadt) +{ + fadt->pm_tmr_blk = IOMAP_ACPI_BASE + PM1_TMR; + + fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; + fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; + + fadt->pm_tmr_len = 4; + fadt->duty_width = 3; + + fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; + + fadt->x_pm_tmr_blk.space_id = 1; + fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; + fadt->x_pm_tmr_blk.addrl = IOMAP_ACPI_BASE + PM1_TMR; +} + +void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, + void *dsdt) +{ + struct acpi_table_header *header = &fadt->header; + + acpi_fadt_common(fadt, facs, dsdt); + intel_acpi_fill_fadt(fadt); + fill_fadt(fadt); + header->checksum = table_compute_checksum(fadt, header->length); +} + +int apl_acpi_fill_dmar(struct acpi_ctx *ctx) +{ + struct udevice *dev, *sa_dev; + u64 gfxvtbar = readq(MCHBAR_REG(GFXVTBAR)) & VTBAR_MASK; + u64 defvtbar = readq(MCHBAR_REG(DEFVTBAR)) & VTBAR_MASK; + bool gfxvten = readl(MCHBAR_REG(GFXVTBAR)) & VTBAR_ENABLED; + bool defvten = readl(MCHBAR_REG(DEFVTBAR)) & VTBAR_ENABLED; + void *tmp; + int ret; + + uclass_find_first_device(UCLASS_VIDEO, &dev); + ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &sa_dev); + if (ret) + return log_msg_ret("no sa", ret); + + /* IGD has to be enabled, GFXVTBAR set and enabled */ + if (dev && device_active(dev) && gfxvtbar && gfxvten) { + tmp = ctx->current; + + acpi_create_dmar_drhd(ctx, 0, 0, gfxvtbar); + ret = acpi_create_dmar_ds_pci(ctx, PCI_BDF(0, 2, 0)); + if (ret) + return log_msg_ret("ds_pci", ret); + acpi_dmar_drhd_fixup(ctx, tmp); + + /* Add RMRR entry */ + tmp = ctx->current; + acpi_create_dmar_rmrr(ctx->current, 0, sa_get_gsm_base(sa_dev), + sa_get_tolud_base(sa_dev) - 1); + acpi_create_dmar_ds_pci(ctx->current, PCI_BDF(0, 2, 0)); + acpi_dmar_rmrr_fixup(ctx, tmp); + } + + /* DEFVTBAR has to be set and enabled */ + if (defvtbar && defvten) { + struct udevice *p2sb_dev; + u16 ibdf, hbdf; + uint ioapic, hpet; + int ret; + + tmp = ctx->current; + /* + * P2SB may already be hidden. There's no clear rule, when. + * It is needed to get bus, device and function for IOAPIC and + * HPET device which is stored in P2SB device. So unhide it to + * get the info and hide it again when done. + * + * TODO(sjg@chromium.org): p2sb_unhide() ? + */ + ret = uclass_first_device_err(UCLASS_P2SB, &p2sb_dev); + if (ret) + return log_msg_ret("p2sb", ret); + + dm_pci_read_config16(p2sb_dev, PCH_P2SB_IBDF, &ibdf); + ioapic = PCI_TO_BDF(ibdf); + dm_pci_read_config16(p2sb_dev, PCH_P2SB_HBDF, &hbdf); + hpet = PCI_TO_BDF(hbdf); + /* TODO(sjg@chromium.org): p2sb_hide() ? */ + + acpi_create_dmar_drhd(ctx, DRHD_INCLUDE_PCI_ALL, 0, defvtbar); + acpi_create_dmar_ds_ioapic(ctx, 2, ioapic); + acpi_create_dmar_ds_msi_hpet(ctx, 0, hpet); + acpi_dmar_drhd_fixup(tmp, ctx->current); + } + + return 0; +} diff --git a/roms/u-boot/arch/x86/cpu/apollolake/cpu.c b/roms/u-boot/arch/x86/cpu/apollolake/cpu.c new file mode 100644 index 000000000..647c9df6a --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/cpu.c @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + */ + +#include <common.h> +#include <cpu.h> +#include <dm.h> +#include <log.h> +#include <acpi/acpigen.h> +#include <acpi/acpi_table.h> +#include <asm/cpu_common.h> +#include <asm/cpu_x86.h> +#include <asm/global_data.h> +#include <asm/intel_acpi.h> +#include <asm/msr.h> +#include <asm/mtrr.h> +#include <asm/arch/cpu.h> +#include <asm/arch/iomap.h> +#include <dm/acpi.h> + +#ifdef CONFIG_ACPIGEN +#define CSTATE_RES(address_space, width, offset, address) \ + { \ + .space_id = address_space, \ + .bit_width = width, \ + .bit_offset = offset, \ + .addrl = address, \ + } + +static struct acpi_cstate cstate_map[] = { + { + /* C1 */ + .ctype = 1, /* ACPI C1 */ + .latency = 1, + .power = 1000, + .resource = { + .space_id = ACPI_ADDRESS_SPACE_FIXED, + }, + }, { + .ctype = 2, /* ACPI C2 */ + .latency = 50, + .power = 10, + .resource = { + .space_id = ACPI_ADDRESS_SPACE_IO, + .bit_width = 8, + .addrl = 0x415, + }, + }, { + .ctype = 3, /* ACPI C3 */ + .latency = 150, + .power = 10, + .resource = { + .space_id = ACPI_ADDRESS_SPACE_IO, + .bit_width = 8, + .addrl = 0x419, + }, + }, +}; + +static int acpi_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + uint core_id = dev_seq(dev); + int cores_per_package; + int ret; + + cores_per_package = cpu_get_cores_per_package(); + ret = acpi_generate_cpu_header(ctx, core_id, cstate_map, + ARRAY_SIZE(cstate_map)); + + /* Generate P-state tables */ + generate_p_state_entries(ctx, core_id, cores_per_package); + + /* Generate T-state tables */ + generate_t_state_entries(ctx, core_id, cores_per_package, NULL, 0); + + acpigen_pop_len(ctx); + + if (device_is_last_sibling(dev)) { + ret = acpi_generate_cpu_package_final(ctx, cores_per_package); + + if (ret) + return ret; + } + + return 0; +} +#endif /* CONFIG_ACPIGEN */ + +static int apl_get_info(const struct udevice *dev, struct cpu_info *info) +{ + return cpu_intel_get_info(info, INTEL_BCLK_MHZ); +} + +static void update_fixed_mtrrs(void) +{ + native_write_msr(MTRR_FIX_64K_00000_MSR, + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK), + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK)); + native_write_msr(MTRR_FIX_16K_80000_MSR, + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK), + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK)); + native_write_msr(MTRR_FIX_4K_E0000_MSR, + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK), + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK)); + native_write_msr(MTRR_FIX_4K_E8000_MSR, + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK), + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK)); + native_write_msr(MTRR_FIX_4K_F0000_MSR, + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK), + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK)); + native_write_msr(MTRR_FIX_4K_F8000_MSR, + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK), + MTRR_FIX_TYPE(MTRR_TYPE_WRBACK)); +} + +static void setup_core_msrs(void) +{ + wrmsrl(MSR_PMG_CST_CONFIG_CONTROL, + PKG_C_STATE_LIMIT_C2_MASK | CORE_C_STATE_LIMIT_C10_MASK | + IO_MWAIT_REDIRECT_MASK | CST_CFG_LOCK_MASK); + /* Power Management I/O base address for I/O trapping to C-states */ + wrmsrl(MSR_PMG_IO_CAPTURE_ADR, ACPI_PMIO_CST_REG | + (PMG_IO_BASE_CST_RNG_BLK_SIZE << 16)); + /* Disable C1E */ + msr_clrsetbits_64(MSR_POWER_CTL, 0x2, 0); + /* Disable support for MONITOR and MWAIT instructions */ + msr_clrsetbits_64(MSR_IA32_MISC_ENABLE, MISC_ENABLE_MWAIT, 0); + /* + * Enable and Lock the Advanced Encryption Standard (AES-NI) + * feature register + */ + msr_clrsetbits_64(MSR_FEATURE_CONFIG, FEATURE_CONFIG_RESERVED_MASK, + FEATURE_CONFIG_LOCK); + + update_fixed_mtrrs(); +} + +static int soc_core_init(void) +{ + struct udevice *pmc; + int ret; + + /* Clear out pending MCEs */ + cpu_mca_configure(); + + /* Set core MSRs */ + setup_core_msrs(); + /* + * Enable ACPI PM timer emulation, which also lets microcode know + * location of ACPI_BASE_ADDRESS. This also enables other features + * implemented in microcode. + */ + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &pmc); + if (ret) + return log_msg_ret("PMC", ret); + enable_pm_timer_emulation(pmc); + + return 0; +} + +static int cpu_apl_probe(struct udevice *dev) +{ + if (gd->flags & GD_FLG_RELOC) { + int ret; + + ret = soc_core_init(); + if (ret) + return log_ret(ret); + } + + return 0; +} + +#ifdef CONFIG_ACPIGEN +struct acpi_ops apl_cpu_acpi_ops = { + .fill_ssdt = acpi_cpu_fill_ssdt, +}; +#endif + +static const struct cpu_ops cpu_x86_apl_ops = { + .get_desc = cpu_x86_get_desc, + .get_info = apl_get_info, + .get_count = cpu_x86_get_count, + .get_vendor = cpu_x86_get_vendor, +}; + +static const struct udevice_id cpu_x86_apl_ids[] = { + { .compatible = "intel,apl-cpu" }, + { } +}; + +U_BOOT_DRIVER(intel_apl_cpu) = { + .name = "intel_apl_cpu", + .id = UCLASS_CPU, + .of_match = cpu_x86_apl_ids, + .bind = cpu_x86_bind, + .probe = cpu_apl_probe, + .ops = &cpu_x86_apl_ops, + ACPI_OPS_PTR(&apl_cpu_acpi_ops) + .flags = DM_FLAG_PRE_RELOC, +}; diff --git a/roms/u-boot/arch/x86/cpu/apollolake/cpu_common.c b/roms/u-boot/arch/x86/cpu/apollolake/cpu_common.c new file mode 100644 index 000000000..5d7d26b14 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/cpu_common.c @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + */ + +#include <common.h> +#include <dm.h> +#include <log.h> +#include <asm/cpu_common.h> +#include <asm/io.h> +#include <asm/msr.h> +#include <asm/pci.h> +#include <asm/arch/cpu.h> +#include <asm/arch/iomap.h> +#include <asm/arch/uart.h> +#include <power/acpi_pmc.h> + +/* Define this here to avoid referencing any drivers for the debug UART 1 */ +#define PCH_DEV_P2SB PCI_BDF(0, 0x0d, 0) + +void cpu_flush_l1d_to_l2(void) +{ + struct msr_t msr; + + msr = msr_read(MSR_POWER_MISC); + msr.lo |= FLUSH_DL1_L2; + msr_write(MSR_POWER_MISC, msr); +} + +void enable_pm_timer_emulation(const struct udevice *pmc) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(pmc); + msr_t msr; + + /* + * The derived frequency is calculated as follows: + * (CTC_FREQ * msr[63:32]) >> 32 = target frequency. + * + * Back-solve the multiplier so the 3.579545MHz ACPI timer frequency is + * used. + */ + msr.hi = (3579545ULL << 32) / CTC_FREQ; + + /* Set PM1 timer IO port and enable */ + msr.lo = EMULATE_PM_TMR_EN | (upriv->acpi_base + R_ACPI_PM1_TMR); + debug("PM timer %x %x\n", msr.hi, msr.lo); + msr_write(MSR_EMULATE_PM_TIMER, msr); +} + +static void pch_uart_init(void) +{ + /* + * Set up the pinmux so that the UART rx/tx signals are connected + * outside the SoC. + * + * There are about 500 lines of code required to program the GPIO + * configuration for the UARTs. But it boils down to four writes, and + * for the debug UART we want the minimum possible amount of code before + * the UART is running. So just add the magic writes here. See + * apl_hostbridge_early_init_pinctrl() for the full horror. + */ + if (PCI_FUNC(PCH_DEV_UART) == 1) { + writel(0x40000402, 0xd0c50650); + writel(0x3c47, 0xd0c50654); + writel(0x40000400, 0xd0c50658); + writel(0x3c48, 0xd0c5065c); + } else { /* UART2 */ + writel(0x40000402, 0xd0c50670); + writel(0x3c4b, 0xd0c50674); + writel(0x40000400, 0xd0c50678); + writel(0x3c4c, 0xd0c5067c); + } + +#ifdef CONFIG_DEBUG_UART + apl_uart_init(PCH_DEV_UART, CONFIG_DEBUG_UART_BASE); +#endif +} + +static void p2sb_enable_bar(ulong bar) +{ + /* Enable PCR Base address in PCH */ + pci_x86_write_config(PCH_DEV_P2SB, PCI_BASE_ADDRESS_0, bar, + PCI_SIZE_32); + pci_x86_write_config(PCH_DEV_P2SB, PCI_BASE_ADDRESS_1, 0, PCI_SIZE_32); + + /* Enable P2SB MSE */ + pci_x86_write_config(PCH_DEV_P2SB, PCI_COMMAND, + PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY, + PCI_SIZE_8); +} + +/* + * board_debug_uart_init() - Init the debug UART ready for use + * + * This is the minimum init needed to get the UART running. It avoids any + * drivers or complex code, so that the UART is running as soon as possible. + */ +void board_debug_uart_init(void) +{ + p2sb_enable_bar(IOMAP_P2SB_BAR); + pch_uart_init(); +} diff --git a/roms/u-boot/arch/x86/cpu/apollolake/cpu_spl.c b/roms/u-boot/arch/x86/cpu/apollolake/cpu_spl.c new file mode 100644 index 000000000..8f48457ee --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/cpu_spl.c @@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + * + * Portions taken from coreboot + */ + +#include <common.h> +#include <dm.h> +#include <ec_commands.h> +#include <init.h> +#include <log.h> +#include <spi_flash.h> +#include <spl.h> +#include <syscon.h> +#include <acpi/acpi_s3.h> +#include <asm/cpu.h> +#include <asm/cpu_common.h> +#include <asm/cpu_x86.h> +#include <asm/fast_spi.h> +#include <asm/global_data.h> +#include <asm/intel_pinctrl.h> +#include <asm/intel_regs.h> +#include <asm/io.h> +#include <asm/msr.h> +#include <asm/mtrr.h> +#include <asm/pci.h> +#include <asm/arch/cpu.h> +#include <asm/arch/gpio.h> +#include <asm/arch/iomap.h> +#include <asm/arch/lpc.h> +#include <asm/arch/pch.h> +#include <asm/arch/systemagent.h> +#include <asm/fsp2/fsp_api.h> +#include <linux/sizes.h> +#include <power/acpi_pmc.h> + +static int fast_spi_cache_bios_region(void) +{ + uint map_size, offset; + ulong map_base, base; + int ret; + + ret = fast_spi_early_init(PCH_DEV_SPI, IOMAP_SPI_BASE); + if (ret) + return log_msg_ret("early_init", ret); + + ret = fast_spi_get_bios_mmap(PCH_DEV_SPI, &map_base, &map_size, + &offset); + if (ret) + return log_msg_ret("get_mmap", ret); + + base = SZ_4G - map_size; + mtrr_set_next_var(MTRR_TYPE_WRPROT, base, map_size); + log_debug("BIOS cache base=%lx, size=%x\n", base, (uint)map_size); + + return 0; +} + +static void google_chromeec_ioport_range(uint *out_basep, uint *out_sizep) +{ + uint base; + uint size; + + if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_MEC)) { + base = MEC_EMI_BASE; + size = MEC_EMI_SIZE; + } else { + base = EC_HOST_CMD_REGION0; + size = 2 * EC_HOST_CMD_REGION_SIZE; + /* Make sure MEMMAP region follows host cmd region */ + assert(base + size == EC_LPC_ADDR_MEMMAP); + size += EC_MEMMAP_SIZE; + } + + *out_basep = base; + *out_sizep = size; +} + +static void early_ec_init(void) +{ + uint base, size; + + /* + * Set up LPC decoding for the Chrome OS EC I/O port ranges: + * - Ports 62/66, 60/64, and 200->208 + * - Chrome OS EC communication I/O ports + */ + lpc_enable_fixed_io_ranges(LPC_IOE_EC_62_66 | LPC_IOE_KBC_60_64 | + LPC_IOE_LGE_200); + google_chromeec_ioport_range(&base, &size); + lpc_open_pmio_window(base, size); +} + +static int arch_cpu_init_tpl(void) +{ + struct udevice *pmc, *sa, *p2sb, *serial, *spi, *lpc; + int ret; + + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &pmc); + if (ret) + return log_msg_ret("PMC", ret); + + /* Clear global reset promotion bit */ + ret = pmc_global_reset_set_enable(pmc, false); + if (ret) + return log_msg_ret("disable global reset", ret); + + enable_pm_timer_emulation(pmc); + + ret = uclass_first_device_err(UCLASS_P2SB, &p2sb); + if (ret) + return log_msg_ret("p2sb", ret); + ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &sa); + if (ret) + return log_msg_ret("northbridge", ret); + gd->baudrate = CONFIG_BAUDRATE; + ret = uclass_first_device_err(UCLASS_SERIAL, &serial); + if (ret) + return log_msg_ret("serial", ret); + if (CONFIG_IS_ENABLED(SPI_FLASH_SUPPORT)) { + ret = uclass_first_device_err(UCLASS_SPI, &spi); + if (ret) + return log_msg_ret("SPI", ret); + } else { + /* Alternative code if we don't have SPI in TPL */ + if (IS_ENABLED(CONFIG_APL_BOOT_FROM_FAST_SPI_FLASH)) + printf("Warning: Enable APL_SPI_FLASHBOOT to use SPI-flash driver in TPL"); + ret = fast_spi_cache_bios_region(); + if (ret) + return log_msg_ret("BIOS cache", ret); + } + ret = pmc_disable_tco(pmc); + if (ret) + return log_msg_ret("disable TCO", ret); + ret = pmc_gpe_init(pmc); + if (ret) + return log_msg_ret("pmc_gpe", ret); + ret = uclass_first_device_err(UCLASS_LPC, &lpc); + if (ret) + return log_msg_ret("lpc", ret); + + early_ec_init(); + + return 0; +} + +/* + * Enables several BARs and devices which are needed for memory init + * - MCH_BASE_ADDR is needed in order to talk to the memory controller + * - HPET is enabled because FSP wants to store a pointer to global data in the + * HPET comparator register + */ +static int arch_cpu_init_spl(void) +{ + struct udevice *pmc, *p2sb; + int ret; + + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &pmc); + if (ret) + return log_msg_ret("Could not probe PMC", ret); + ret = uclass_first_device_err(UCLASS_P2SB, &p2sb); + if (ret) + return log_msg_ret("Cannot set up p2sb", ret); + + lpc_io_setup_comm_a_b(); + + /* TODO(sjg@chromium.org): Enable upper RTC bank here */ + + ret = pmc_init(pmc); + if (ret < 0) + return log_msg_ret("Could not init PMC", ret); + if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) { + ret = pmc_prev_sleep_state(pmc); + if (ret < 0) + return log_msg_ret("Could not get PMC sleep state", + ret); + gd->arch.prev_sleep_state = ret; + } + + return 0; +} + +int arch_cpu_init(void) +{ + int ret = 0; + + if (spl_phase() == PHASE_TPL) + ret = arch_cpu_init_tpl(); + else if (spl_phase() == PHASE_SPL) + ret = arch_cpu_init_spl(); + if (ret) + printf("%s: Error %d\n", __func__, ret); + + return ret; +} diff --git a/roms/u-boot/arch/x86/cpu/apollolake/fsp_bindings.c b/roms/u-boot/arch/x86/cpu/apollolake/fsp_bindings.c new file mode 100644 index 000000000..319c78b95 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/fsp_bindings.c @@ -0,0 +1,1856 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2020 B&R Industrial Automation GmbH - http://www.br-automation.com + */ + +#include <common.h> +#include <dm.h> +#include <log.h> +#include <asm/arch/fsp_bindings.h> + +/** + * read_u8_prop() - Read an u8 property from devicetree (scalar or array) + * @node: Valid node reference to read property from + * @name: Name of the property to read from + * @count: If the property is expected to be an array, this is the + * number of expected elements + * Set to 0 if the property is expected to be a scalar + * @dst: Pointer to destination of where to save the value(s) read + * from devicetree + */ +static void read_u8_prop(ofnode node, char *name, size_t count, u8 *dst) +{ + u32 tmp; + const u8 *buf; + int ret; + + if (count == 0) { + ret = ofnode_read_u32(node, name, &tmp); + if (ret == 0) + *dst = tmp; + } else { + buf = ofnode_read_u8_array_ptr(node, name, count); + if (buf) + memcpy(dst, buf, count); + } +} + +/** + * read_u16_prop() - Read an u16 property from devicetree (scalar or array) + * @node: Valid node reference to read property from + * @name: Name of the property to read from + * @count: If the property is expected to be an array, this is the + * number of expected elements + * Set to 0 if the property is expected to be a scalar + * @dst: Pointer to destination of where to save the value(s) read + * from devicetree + * @return 0 on success, -ve on error + */ +static int read_u16_prop(ofnode node, char *name, size_t count, u16 *dst) +{ + u32 tmp; + u32 buf[32]; + int ret; + + if (ARRAY_SIZE(buf) < count) { + debug("ERROR: %s buffer to small!\n", __func__); + return -ENOSPC; + } + + if (count == 0) { + ret = ofnode_read_u32(node, name, &tmp); + if (ret == 0) + *dst = tmp; + } else { + ret = ofnode_read_u32_array(node, name, buf, count); + if (ret == 0) + for (int i = 0; i < count; i++) + dst[i] = buf[i]; + } + + return 0; +} + +/** + * read_u32_prop() - Read an u32 property from devicetree (scalar or array) + * @node: Valid node reference to read property from + * @name: Name of the property to read from + * @count: If the property is expected to be an array, this is the + * number of expected elements + * set to 0 if the property is expected to be a scalar + * @dst: Pointer to destination of where to save the value(s) read + * from devicetree + */ +static void read_u32_prop(ofnode node, char *name, size_t count, u32 *dst) +{ + if (count == 0) + ofnode_read_u32(node, name, dst); + else + ofnode_read_u32_array(node, name, dst, count); +} + +/** + * read_u64_prop() - Read an u64 property from devicetree (scalar or array) + * @node: Valid node reference to read property from + * @name: Name of the property to read from + * @count: If the property is expected to be an array, this is the + * number of expected elements + * set to 0 if the property is expected to be a scalar + * @dst: Pointer to destination of where to save the value(s) read + * from devicetree + */ +static int read_u64_prop(ofnode node, char *name, size_t count, u64 *dst) +{ + if (count == 0) { + ofnode_read_u64(node, name, dst); + } else { + debug("ERROR: %s u64 arrays not supported!\n", __func__); + return -EINVAL; + } + + return 0; +} + +/** + * read_string_prop() - Read a string property from devicetree + * @node: Valid node reference to read property from + * @name: Name of the property to read from + * @count: Size of the destination buffer + * @dst: Pointer to destination of where to save the values read + * from devicetree + */ +static void read_string_prop(ofnode node, char *name, size_t count, char *dst) +{ + const char *string_buf; + + if (count > 0) { + string_buf = ofnode_read_string(node, name); + if (string_buf) + strlcpy(dst, string_buf, count); + } +} + +/** + * read_swizzle_prop() - Read a swizzle property from devicetree + * @node: Valid node reference to read property from + * @name: Name of the property to read from + * @count: Number of elements in the swizzle configuration + * @dst: pointer to destination of where to save the values read + * from devicetree + */ +static void read_swizzle_prop(ofnode node, char *name, size_t count, u8 *dst) +{ + const struct lpddr4_chan_swizzle_cfg *sch; + /* Number of bytes to copy per DQS */ + const size_t sz = DQ_BITS_PER_DQS; + const struct lpddr4_swizzle_cfg *swizzle_cfg; + + swizzle_cfg = (const struct lpddr4_swizzle_cfg *) + ofnode_read_u8_array_ptr(node, name, count); + + if (!swizzle_cfg) + return; + /* + * CH0_DQB byte lanes in the bit swizzle configuration field are + * not 1:1. The mapping within the swizzling field is: + * indices [0:7] - byte lane 1 (DQS1) DQ[8:15] + * indices [8:15] - byte lane 0 (DQS0) DQ[0:7] + * indices [16:23] - byte lane 3 (DQS3) DQ[24:31] + * indices [24:31] - byte lane 2 (DQS2) DQ[16:23] + */ + sch = &swizzle_cfg->phys[LP4_PHYS_CH0B]; + memcpy(&dst[0 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS1], sz); + memcpy(&dst[1 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS0], sz); + memcpy(&dst[2 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS3], sz); + memcpy(&dst[3 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS2], sz); + + /* + * CH0_DQA byte lanes in the bit swizzle configuration field are 1:1. + */ + sch = &swizzle_cfg->phys[LP4_PHYS_CH0A]; + memcpy(&dst[4 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS0], sz); + memcpy(&dst[5 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS1], sz); + memcpy(&dst[6 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS2], sz); + memcpy(&dst[7 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS3], sz); + + sch = &swizzle_cfg->phys[LP4_PHYS_CH1B]; + memcpy(&dst[8 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS1], sz); + memcpy(&dst[9 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS0], sz); + memcpy(&dst[10 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS3], sz); + memcpy(&dst[11 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS2], sz); + + /* + * CH0_DQA byte lanes in the bit swizzle configuration field are 1:1. + */ + sch = &swizzle_cfg->phys[LP4_PHYS_CH1A]; + memcpy(&dst[12 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS0], sz); + memcpy(&dst[13 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS1], sz); + memcpy(&dst[14 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS2], sz); + memcpy(&dst[15 * DQ_BITS_PER_DQS], &sch->dqs[LP4_DQS3], sz); +} + +/** + * fsp_update_config_from_dtb() - Read FSP config from devicetree node + * @node: Valid node reference to read property from + * @cfg: Pointer to FSP config structure + * @fsp_bindings: Binding describing which devicetree properties should + * be stored where in the FSP configuration structure + * The end of the list is declared by a NULL pointer in propname + * @return 0 on success, -ve on error + * + * This function reads the configuration for FSP from the provided + * devicetree node and saves it in the FSP configuration structure. + * Configuration options that are not present in the devicetree are + * left at their current value. + */ +__maybe_unused +static int fsp_update_config_from_dtb(ofnode node, u8 *cfg, + const struct fsp_binding *fsp_bindings) +{ + const struct fsp_binding *fspb; + int ret; + + for (int i = 0; fsp_bindings[i].propname; i++) { + fspb = &fsp_bindings[i]; + + switch (fspb->type) { + case FSP_UINT8: + read_u8_prop(node, fspb->propname, fspb->count, + &cfg[fspb->offset]); + break; + case FSP_UINT16: + ret = read_u16_prop(node, fspb->propname, fspb->count, + (u16 *)&cfg[fspb->offset]); + if (ret) + return ret; + break; + case FSP_UINT32: + read_u32_prop(node, fspb->propname, fspb->count, + (u32 *)&cfg[fspb->offset]); + break; + case FSP_UINT64: + ret = read_u64_prop(node, fspb->propname, fspb->count, + (u64 *)&cfg[fspb->offset]); + if (ret) + return ret; + break; + case FSP_STRING: + read_string_prop(node, fspb->propname, fspb->count, + (char *)&cfg[fspb->offset]); + break; + case FSP_LPDDR4_SWIZZLE: + read_swizzle_prop(node, fspb->propname, fspb->count, + &cfg[fspb->offset]); + break; + } + } + + return 0; +} + +#if defined(CONFIG_SPL_BUILD) +const struct fsp_binding fsp_m_bindings[] = { + { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, serial_debug_port_address), + .propname = "fspm,serial-debug-port-address", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, serial_debug_port_type), + .propname = "fspm,serial-debug-port-type", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, serial_debug_port_device), + .propname = "fspm,serial-debug-port-device", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, serial_debug_port_stride_size), + .propname = "fspm,serial-debug-port-stride-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, mrc_fast_boot), + .propname = "fspm,mrc-fast-boot", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, igd), + .propname = "fspm,igd", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, igd_dvmt50_pre_alloc), + .propname = "fspm,igd-dvmt50-pre-alloc", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, igd_aperture_size), + .propname = "fspm,igd-aperture-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, gtt_size), + .propname = "fspm,gtt-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, primary_video_adaptor), + .propname = "fspm,primary-video-adaptor", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, package), + .propname = "fspm,package", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, profile), + .propname = "fspm,profile", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, memory_down), + .propname = "fspm,memory-down", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, ddr3_l_page_size), + .propname = "fspm,ddr3-l-page-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, ddr3_lasr), + .propname = "fspm,ddr3-lasr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, scrambler_support), + .propname = "fspm,scrambler-support", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, interleaved_mode), + .propname = "fspm,interleaved-mode", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_m_config, channel_hash_mask), + .propname = "fspm,channel-hash-mask", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_m_config, slice_hash_mask), + .propname = "fspm,slice-hash-mask", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, channels_slices_enable), + .propname = "fspm,channels-slices-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, min_ref_rate2x_enable), + .propname = "fspm,min-ref-rate2x-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, dual_rank_support_enable), + .propname = "fspm,dual-rank-support-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, rmt_mode), + .propname = "fspm,rmt-mode", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_m_config, memory_size_limit), + .propname = "fspm,memory-size-limit", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_m_config, low_memory_max_value), + .propname = "fspm,low-memory-max-value", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_m_config, high_memory_max_value), + .propname = "fspm,high-memory-max-value", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, disable_fast_boot), + .propname = "fspm,disable-fast-boot", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, dimm0_spd_address), + .propname = "fspm,dimm0-spd-address", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, dimm1_spd_address), + .propname = "fspm,dimm1-spd-address", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].rank_enable), + .propname = "fspm,ch0-rank-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].device_width), + .propname = "fspm,ch0-device-width", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].dram_density), + .propname = "fspm,ch0-dram-density", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].option), + .propname = "fspm,ch0-option", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].odt_config), + .propname = "fspm,ch0-odt-config", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].tristate_clk1), + .propname = "fspm,ch0-tristate-clk1", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].mode2_n), + .propname = "fspm,ch0-mode2-n", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[0].odt_levels), + .propname = "fspm,ch0-odt-levels", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].rank_enable), + .propname = "fspm,ch1-rank-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].device_width), + .propname = "fspm,ch1-device-width", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].dram_density), + .propname = "fspm,ch1-dram-density", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].option), + .propname = "fspm,ch1-option", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].odt_config), + .propname = "fspm,ch1-odt-config", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].tristate_clk1), + .propname = "fspm,ch1-tristate-clk1", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].mode2_n), + .propname = "fspm,ch1-mode2-n", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[1].odt_levels), + .propname = "fspm,ch1-odt-levels", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].rank_enable), + .propname = "fspm,ch2-rank-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].device_width), + .propname = "fspm,ch2-device-width", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].dram_density), + .propname = "fspm,ch2-dram-density", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].option), + .propname = "fspm,ch2-option", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].odt_config), + .propname = "fspm,ch2-odt-config", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].tristate_clk1), + .propname = "fspm,ch2-tristate-clk1", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].mode2_n), + .propname = "fspm,ch2-mode2-n", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[2].odt_levels), + .propname = "fspm,ch2-odt-levels", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].rank_enable), + .propname = "fspm,ch3-rank-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].device_width), + .propname = "fspm,ch3-device-width", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].dram_density), + .propname = "fspm,ch3-dram-density", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].option), + .propname = "fspm,ch3-option", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].odt_config), + .propname = "fspm,ch3-odt-config", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].tristate_clk1), + .propname = "fspm,ch3-tristate-clk1", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].mode2_n), + .propname = "fspm,ch3-mode2-n", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, chan[3].odt_levels), + .propname = "fspm,ch3-odt-levels", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, rmt_check_run), + .propname = "fspm,rmt-check-run", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_m_config, + rmt_margin_check_scale_high_threshold), + .propname = "fspm,rmt-margin-check-scale-high-threshold", + }, { + .type = FSP_LPDDR4_SWIZZLE, + .offset = offsetof(struct fsp_m_config, ch_bit_swizzling), + .propname = "fspm,ch-bit-swizzling", + .count = SIZE_OF_MEMBER(struct fsp_m_config, ch_bit_swizzling) / + SIZE_OF_MEMBER(struct fsp_m_config, ch_bit_swizzling[0][0]) + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, msg_level_mask), + .propname = "fspm,msg-level-mask", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, pre_mem_gpio_table_pin_num), + .propname = "fspm,pre-mem-gpio-table-pin-num", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_m_config, + pre_mem_gpio_table_pin_num), + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, pre_mem_gpio_table_ptr), + .propname = "fspm,pre-mem-gpio-table-ptr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, pre_mem_gpio_table_entry_num), + .propname = "fspm,pre-mem-gpio-table-entry-num", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, enhance_port8xh_decoding), + .propname = "fspm,enhance-port8xh-decoding", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, spd_write_enable), + .propname = "fspm,spd-write-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, mrc_data_saving), + .propname = "fspm,mrc-data-saving", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, oem_loading_base), + .propname = "fspm,oem-loading-base", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, oem_file_name), + .propname = "fspm,oem-file-name", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_m_config, oem_file_name), + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, mrc_boot_data_ptr), + .propname = "fspm,mrc-boot-data-ptr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, e_mmc_trace_len), + .propname = "fspm,emmc-trace-len", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, skip_cse_rbp), + .propname = "fspm,skip-cse-rbp", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, npk_en), + .propname = "fspm,npk-en", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, fw_trace_en), + .propname = "fspm,fw-trace-en", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, fw_trace_destination), + .propname = "fspm,fw-trace-destination", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, recover_dump), + .propname = "fspm,recover-dump", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, msc0_wrap), + .propname = "fspm,msc0-wrap", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, msc1_wrap), + .propname = "fspm,msc1-wrap", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, msc0_size), + .propname = "fspm,msc0-size", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, msc1_size), + .propname = "fspm,msc1-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, pti_mode), + .propname = "fspm,pti-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, pti_training), + .propname = "fspm,pti-training", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, pti_speed), + .propname = "fspm,pti-speed", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, punit_mlvl), + .propname = "fspm,punit-mlvl", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, pmc_mlvl), + .propname = "fspm,pmc-mlvl", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, sw_trace_en), + .propname = "fspm,sw-trace-en", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, periodic_retraining_disable), + .propname = "fspm,periodic-retraining-disable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, enable_reset_system), + .propname = "fspm,enable-reset-system", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, enable_s3_heci2), + .propname = "fspm,enable-s3-heci2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_m_config, variable_nvs_buffer_ptr), + .propname = "fspm,variable-nvs-buffer-ptr", + }, { + .type = FSP_UINT64, + .offset = offsetof(struct fsp_m_config, start_timer_ticker_of_pfet_assert), + .propname = "fspm,start-timer-ticker-of-pfet-assert", + }, { + .type = FSP_UINT8, .offset = offsetof(struct fsp_m_config, rt_en), + .propname = "fspm,rt-en", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_m_config, skip_pcie_power_sequence), + .propname = "fspm,skip-pcie-power-sequence", + }, { + .propname = NULL + } +}; + +int fsp_m_update_config_from_dtb(ofnode node, struct fsp_m_config *cfg) +{ + return fsp_update_config_from_dtb(node, (u8 *)cfg, fsp_m_bindings); +} +#endif + +#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) +const struct fsp_binding fsp_s_bindings[] = { + { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, active_processor_cores), + .propname = "fsps,active-processor-cores", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, disable_core1), + .propname = "fsps,disable-core1", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, disable_core2), + .propname = "fsps,disable-core2", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, disable_core3), + .propname = "fsps,disable-core3", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, vmx_enable), + .propname = "fsps,vmx-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, proc_trace_mem_size), + .propname = "fsps,proc-trace-mem-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, proc_trace_enable), + .propname = "fsps,proc-trace-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, eist), + .propname = "fsps,eist", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, boot_p_state), + .propname = "fsps,boot-p-state", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, enable_cx), + .propname = "fsps,enable-cx", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, c1e), + .propname = "fsps,c1e", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, bi_proc_hot), + .propname = "fsps,bi-proc-hot", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pkg_c_state_limit), + .propname = "fsps,pkg-c-state-limit", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, c_state_auto_demotion), + .propname = "fsps,c-state-auto-demotion", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, c_state_un_demotion), + .propname = "fsps,c-state-un-demotion", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, max_core_c_state), + .propname = "fsps,max-core-c-state", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pkg_c_state_demotion), + .propname = "fsps,pkg-c-state-demotion", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pkg_c_state_un_demotion), + .propname = "fsps,pkg-c-state-un-demotion", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, turbo_mode), + .propname = "fsps,turbo-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hda_verb_table_entry_num), + .propname = "fsps,hda-verb-table-entry-num", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, hda_verb_table_ptr), + .propname = "fsps,hda-verb-table-ptr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, p2sb_unhide), + .propname = "fsps,p2sb-unhide", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ipu_en), + .propname = "fsps,ipu-en", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ipu_acpi_mode), + .propname = "fsps,ipu-acpi-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, force_wake), + .propname = "fsps,force-wake", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, gtt_mm_adr), + .propname = "fsps,gtt-mm-adr", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, gm_adr), + .propname = "fsps,gm-adr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pavp_lock), + .propname = "fsps,pavp-lock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, graphics_freq_modify), + .propname = "fsps,graphics-freq-modify", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, graphics_freq_req), + .propname = "fsps,graphics-freq-req", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, graphics_video_freq), + .propname = "fsps,graphics-video-freq", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pm_lock), + .propname = "fsps,pm-lock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dop_clock_gating), + .propname = "fsps,dop-clock-gating", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, unsolicited_attack_override), + .propname = "fsps,unsolicited-attack-override", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, wopcm_support), + .propname = "fsps,wopcm-support", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, wopcm_size), + .propname = "fsps,wopcm-size", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, power_gating), + .propname = "fsps,power-gating", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, unit_level_clock_gating), + .propname = "fsps,unit-level-clock-gating", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, fast_boot), + .propname = "fsps,fast-boot", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dyn_sr), + .propname = "fsps,dyn-sr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sa_ipu_enable), + .propname = "fsps,sa-ipu-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pm_support), + .propname = "fsps,pm-support", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, enable_render_standby), + .propname = "fsps,enable-render-standby", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, logo_size), + .propname = "fsps,logo-size", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, logo_ptr), + .propname = "fsps,logo-ptr", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, graphics_config_ptr), + .propname = "fsps,graphics-config-ptr", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pavp_enable), + .propname = "fsps,pavp-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pavp_pr3), + .propname = "fsps,pavp-pr3", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, cd_clock), + .propname = "fsps,cd-clock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pei_graphics_peim_init), + .propname = "fsps,pei-graphics-peim-init", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, write_protection_enable), + .propname = "fsps,write-protection-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + write_protection_enable), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, read_protection_enable), + .propname = "fsps,read-protection-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + read_protection_enable), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, protected_range_limit), + .propname = "fsps,protected-range-limit", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + protected_range_limit), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, protected_range_base), + .propname = "fsps,protected-range-base", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + protected_range_base), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, gmm), + .propname = "fsps,gmm", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_pgcb_clk_trunk), + .propname = "fsps,clk-gating-pgcb-clk-trunk", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_sb), + .propname = "fsps,clk-gating-sb", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_sb_clk_trunk), + .propname = "fsps,clk-gating-sb-clk-trunk", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_sb_clk_partition), + .propname = "fsps,clk-gating-sb-clk-partition", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_core), + .propname = "fsps,clk-gating-core", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_dma), + .propname = "fsps,clk-gating-dma", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_reg_access), + .propname = "fsps,clk-gating-reg-access", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_host), + .propname = "fsps,clk-gating-host", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_partition), + .propname = "fsps,clk-gating-partition", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, clk_gating_trunk), + .propname = "fsps,clk-gating-trunk", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hda_enable), + .propname = "fsps,hda-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dsp_enable), + .propname = "fsps,dsp-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pme), + .propname = "fsps,pme", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_io_buffer_ownership), + .propname = "fsps,hd-audio-io-buffer-ownership", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_io_buffer_voltage), + .propname = "fsps,hd-audio-io-buffer-voltage", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_vc_type), + .propname = "fsps,hd-audio-vc-type", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_link_frequency), + .propname = "fsps,hd-audio-link-frequency", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_i_disp_link_frequency), + .propname = "fsps,hd-audio-i-disp-link-frequency", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_i_disp_link_tmode), + .propname = "fsps,hd-audio-i-disp-link-tmode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dsp_endpoint_dmic), + .propname = "fsps,dsp-endpoint-dmic", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dsp_endpoint_bluetooth), + .propname = "fsps,dsp-endpoint-bluetooth", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dsp_endpoint_i2s_skp), + .propname = "fsps,dsp-endpoint-i2s-skp", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dsp_endpoint_i2s_hp), + .propname = "fsps,dsp-endpoint-i2s-hp", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, audio_ctl_pwr_gate), + .propname = "fsps,audio-ctl-pwr-gate", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, audio_dsp_pwr_gate), + .propname = "fsps,audio-dsp-pwr-gate", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, mmt), + .propname = "fsps,mmt", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hmt), + .propname = "fsps,hmt", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_pwr_gate), + .propname = "fsps,hd-audio-pwr-gate", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_clk_gate), + .propname = "fsps,hd-audio-clk-gate", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, dsp_feature_mask), + .propname = "fsps,dsp-feature-mask", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, dsp_pp_module_mask), + .propname = "fsps,dsp-pp-module-mask", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, bios_cfg_lock_down), + .propname = "fsps,bios-cfg-lock-down", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hpet), + .propname = "fsps,hpet", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hpet_bdf_valid), + .propname = "fsps,hpet-bdf-valid", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hpet_bus_number), + .propname = "fsps,hpet-bus-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hpet_device_number), + .propname = "fsps,hpet-device-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hpet_function_number), + .propname = "fsps,hpet-function-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_bdf_valid), + .propname = "fsps,io-apic-bdf-valid", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_bus_number), + .propname = "fsps,io-apic-bus-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_device_number), + .propname = "fsps,io-apic-device-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_function_number), + .propname = "fsps,io-apic-function-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_entry24_119), + .propname = "fsps,io-apic-entry24-119", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_id), + .propname = "fsps,io-apic-id", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, io_apic_range_select), + .propname = "fsps,io-apic-range-select", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ish_enable), + .propname = "fsps,ish-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, bios_interface), + .propname = "fsps,bios-interface", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, bios_lock), + .propname = "fsps,bios-lock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, spi_eiss), + .propname = "fsps,spi-eiss", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, bios_lock_sw_smi_number), + .propname = "fsps,bios-lock-sw-smi-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, lpss_s0ix_enable), + .propname = "fsps,lpss-s0ix-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c_clk_gate_cfg), + .propname = "fsps,i2c-clk-gate-cfg", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, i2c_clk_gate_cfg), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hsuart_clk_gate_cfg), + .propname = "fsps,hsuart-clk-gate-cfg", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, hsuart_clk_gate_cfg), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, spi_clk_gate_cfg), + .propname = "fsps,spi-clk-gate-cfg", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, spi_clk_gate_cfg), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c0_enable), + .propname = "fsps,i2c0-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c1_enable), + .propname = "fsps,i2c1-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c2_enable), + .propname = "fsps,i2c2-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c3_enable), + .propname = "fsps,i2c3-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c4_enable), + .propname = "fsps,i2c4-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c5_enable), + .propname = "fsps,i2c5-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c6_enable), + .propname = "fsps,i2c6-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, i2c7_enable), + .propname = "fsps,i2c7-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hsuart0_enable), + .propname = "fsps,hsuart0-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hsuart1_enable), + .propname = "fsps,hsuart1-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hsuart2_enable), + .propname = "fsps,hsuart2-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hsuart3_enable), + .propname = "fsps,hsuart3-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, spi0_enable), + .propname = "fsps,spi0-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, spi1_enable), + .propname = "fsps,spi1-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, spi2_enable), + .propname = "fsps,spi2-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, os_dbg_enable), + .propname = "fsps,os-dbg-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dci_en), + .propname = "fsps,dci-en", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, + uart2_kernel_debug_base_address), + .propname = "fsps,uart2-kernel-debug-base-address", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_clock_gating_disabled), + .propname = "fsps,pcie-clock-gating-disabled", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_root_port8xh_decode), + .propname = "fsps,pcie-root-port8xh-decode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie8xh_decode_port_index), + .propname = "fsps,pcie8xh-decode-port-index", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + pcie_root_port_peer_memory_write_enable), + .propname = "fsps,pcie-root-port-peer-memory-write-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_aspm_sw_smi_number), + .propname = "fsps,pcie-aspm-sw-smi-number", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_root_port_en), + .propname = "fsps,pcie-root-port-en", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_root_port_en), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_hide), + .propname = "fsps,pcie-rp-hide", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_hide), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_slot_implemented), + .propname = "fsps,pcie-rp-slot-implemented", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_slot_implemented), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_hot_plug), + .propname = "fsps,pcie-rp-hot-plug", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_hot_plug), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_pm_sci), + .propname = "fsps,pcie-rp-pm-sci", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_pm_sci), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_ext_sync), + .propname = "fsps,pcie-rp-ext-sync", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_ext_sync), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + pcie_rp_transmitter_half_swing), + .propname = "fsps,pcie-rp-transmitter-half-swing", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_transmitter_half_swing), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_acs_enabled), + .propname = "fsps,pcie-rp-acs-enabled", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_acs_enabled), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_clk_req_supported), + .propname = "fsps,pcie-rp-clk-req-supported", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_clk_req_supported), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_clk_req_number), + .propname = "fsps,pcie-rp-clk-req-number", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_clk_req_number), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_clk_req_detect), + .propname = "fsps,pcie-rp-clk-req-detect", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_clk_req_detect), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, advanced_error_reporting), + .propname = "fsps,advanced-error-reporting", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + advanced_error_reporting), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pme_interrupt), + .propname = "fsps,pme-interrupt", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pme_interrupt), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, unsupported_request_report), + .propname = "fsps,unsupported-request-report", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + unsupported_request_report), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, fatal_error_report), + .propname = "fsps,fatal-error-report", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, fatal_error_report), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, no_fatal_error_report), + .propname = "fsps,no-fatal-error-report", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + no_fatal_error_report), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, correctable_error_report), + .propname = "fsps,correctable-error-report", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + correctable_error_report), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + system_error_on_fatal_error), + .propname = "fsps,system-error-on-fatal-error", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + system_error_on_fatal_error), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + system_error_on_non_fatal_error), + .propname = "fsps,system-error-on-non-fatal-error", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + system_error_on_non_fatal_error), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + system_error_on_correctable_error), + .propname = "fsps,system-error-on-correctable-error", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + system_error_on_correctable_error), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_speed), + .propname = "fsps,pcie-rp-speed", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_speed), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, physical_slot_number), + .propname = "fsps,physical-slot-number", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + physical_slot_number), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_completion_timeout), + .propname = "fsps,pcie-rp-completion-timeout", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_completion_timeout), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ptm_enable), + .propname = "fsps,ptm-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, ptm_enable), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_aspm), + .propname = "fsps,pcie-rp-aspm", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_aspm), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_l1_substates), + .propname = "fsps,pcie-rp-l1-substates", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_l1_substates), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_ltr_enable), + .propname = "fsps,pcie-rp-ltr-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, pcie_rp_ltr_enable), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_ltr_config_lock), + .propname = "fsps,pcie-rp-ltr-config-lock", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_ltr_config_lock), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pme_b0_s5_dis), + .propname = "fsps,pme-b0-s5-dis", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pci_clock_run), + .propname = "fsps,pci-clock-run", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, timer8254_clk_setting), + .propname = "fsps,timer8254-clk-setting", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, enable_sata), + .propname = "fsps,enable-sata", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_mode), + .propname = "fsps,sata-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_salp_support), + .propname = "fsps,sata-salp-support", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_pwr_opt_enable), + .propname = "fsps,sata-pwr-opt-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, e_sata_speed_limit), + .propname = "fsps,e-sata-speed-limit", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, speed_limit), + .propname = "fsps,speed-limit", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_enable), + .propname = "fsps,sata-ports-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_enable), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_dev_slp), + .propname = "fsps,sata-ports-dev-slp", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_dev_slp), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_hot_plug), + .propname = "fsps,sata-ports-hot-plug", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_hot_plug), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_interlock_sw), + .propname = "fsps,sata-ports-interlock-sw", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + sata_ports_interlock_sw), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_external), + .propname = "fsps,sata-ports-external", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_external), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_spin_up), + .propname = "fsps,sata-ports-spin-up", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_spin_up), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_solid_state_drive), + .propname = "fsps,sata-ports-solid-state-drive", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + sata_ports_solid_state_drive), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_enable_dito_config), + .propname = "fsps,sata-ports-enable-dito-config", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + sata_ports_enable_dito_config), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_dm_val), + .propname = "fsps,sata-ports-dm-val", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_dm_val), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, sata_ports_dito_val), + .propname = "fsps,sata-ports-dito-val", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, sata_ports_dito_val), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, sub_system_vendor_id), + .propname = "fsps,sub-system-vendor-id", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, sub_system_id), + .propname = "fsps,sub-system-id", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, crid_settings), + .propname = "fsps,crid-settings", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, reset_select), + .propname = "fsps,reset-select", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sdcard_enabled), + .propname = "fsps,sdcard-enabled", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, e_mmc_enabled), + .propname = "fsps,emmc-enabled", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, e_mmc_host_max_speed), + .propname = "fsps,emmc-host-max-speed", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ufs_enabled), + .propname = "fsps,ufs-enabled", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sdio_enabled), + .propname = "fsps,sdio-enabled", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, gpp_lock), + .propname = "fsps,gpp-lock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sirq_enable), + .propname = "fsps,sirq-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sirq_mode), + .propname = "fsps,sirq-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, start_frame_pulse), + .propname = "fsps,start-frame-pulse", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, smbus_enable), + .propname = "fsps,smbus-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, arp_enable), + .propname = "fsps,arp-enable", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, num_rsvd_smbus_addresses), + .propname = "fsps,num-rsvd-smbus-addresses", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, rsvd_smbus_address_table), + .propname = "fsps,rsvd-smbus-address-table", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + rsvd_smbus_address_table), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, disable_compliance_mode), + .propname = "fsps,disable-compliance-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, usb_per_port_ctl), + .propname = "fsps,usb-per-port-ctl", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, usb30_mode), + .propname = "fsps,usb30-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb20_enable), + .propname = "fsps,port-usb20-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, port_usb20_enable), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_us20b_over_current_pin), + .propname = "fsps,port-us20b-over-current-pin", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_us20b_over_current_pin), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, usb_otg), + .propname = "fsps,usb-otg", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hsic_support_enable), + .propname = "fsps,hsic-support-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb30_enable), + .propname = "fsps,port-usb30-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, port_usb30_enable), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_us30b_over_current_pin), + .propname = "fsps,port-us30b-over-current-pin", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_us30b_over_current_pin), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ssic_port_enable), + .propname = "fsps,ssic-port-enable", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, ssic_port_enable), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, dlane_pwr_gating), + .propname = "fsps,dlane-pwr-gating", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, vtd_enable), + .propname = "fsps,vtd-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, lock_down_global_smi), + .propname = "fsps,lock-down-global-smi", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, reset_wait_timer), + .propname = "fsps,reset-wait-timer", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, rtc_lock), + .propname = "fsps,rtc-lock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_test_mode), + .propname = "fsps,sata-test-mode", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, ssic_rate), + .propname = "fsps,ssic-rate", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, ssic_rate), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, dynamic_power_gating), + .propname = "fsps,dynamic-power-gating", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, pcie_rp_ltr_max_snoop_latency), + .propname = "fsps,pcie-rp-ltr-max-snoop-latency", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_ltr_max_snoop_latency), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + pcie_rp_snoop_latency_override_mode), + .propname = "fsps,pcie-rp-snoop-latency-override-mode", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_snoop_latency_override_mode), + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, + pcie_rp_snoop_latency_override_value), + .propname = "fsps,pcie-rp-snoop-latency-override-value", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_snoop_latency_override_value), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + pcie_rp_snoop_latency_override_multiplier), + .propname = "fsps,pcie-rp-snoop-latency-override-multiplier", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_snoop_latency_override_multiplier), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, skip_mp_init), + .propname = "fsps,skip-mp-init", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dci_auto_detect), + .propname = "fsps,dci-auto-detect", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, + pcie_rp_ltr_max_non_snoop_latency), + .propname = "fsps,pcie-rp-ltr-max-non-snoop-latency", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_ltr_max_non_snoop_latency), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + pcie_rp_non_snoop_latency_override_mode), + .propname = "fsps,pcie-rp-non-snoop-latency-override-mode", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_non_snoop_latency_override_mode), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, tco_timer_halt_lock), + .propname = "fsps,tco-timer-halt-lock", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pwr_btn_override_period), + .propname = "fsps,pwr-btn-override-period", + }, { + .type = FSP_UINT16, + .offset = offsetof(struct fsp_s_config, + pcie_rp_non_snoop_latency_override_value), + .propname = "fsps,pcie-rp-non-snoop-latency-override-value", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_non_snoop_latency_override_value), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + pcie_rp_non_snoop_latency_override_multiplier), + .propname = "fsps,pcie-rp-non-snoop-latency-override-multiplier", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_non_snoop_latency_override_multiplier), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_slot_power_limit_scale), + .propname = "fsps,pcie-rp-slot-power-limit-scale", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_slot_power_limit_scale), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_slot_power_limit_value), + .propname = "fsps,pcie-rp-slot-power-limit-value", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_slot_power_limit_value), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, disable_native_power_button), + .propname = "fsps,disable-native-power-button", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, power_butter_debounce_mode), + .propname = "fsps,power-butter-debounce-mode", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdio_tx_cmd_cntl), + .propname = "fsps,sdio-tx-cmd-cntl", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdio_tx_data_cntl1), + .propname = "fsps,sdio-tx-data-cntl1", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdio_tx_data_cntl2), + .propname = "fsps,sdio-tx-data-cntl2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdio_rx_cmd_data_cntl1), + .propname = "fsps,sdio-rx-cmd-data-cntl1", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdio_rx_cmd_data_cntl2), + .propname = "fsps,sdio-rx-cmd-data-cntl2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdcard_tx_cmd_cntl), + .propname = "fsps,sdcard-tx-cmd-cntl", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdcard_tx_data_cntl1), + .propname = "fsps,sdcard-tx-data-cntl1", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdcard_tx_data_cntl2), + .propname = "fsps,sdcard-tx-data-cntl2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdcard_rx_cmd_data_cntl1), + .propname = "fsps,sdcard-rx-cmd-data-cntl1", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdcard_rx_strobe_cntl), + .propname = "fsps,sdcard-rx-strobe-cntl", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, sdcard_rx_cmd_data_cntl2), + .propname = "fsps,sdcard-rx-cmd-data-cntl2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_tx_cmd_cntl), + .propname = "fsps,emmc-tx-cmd-cntl", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_tx_data_cntl1), + .propname = "fsps,emmc-tx-data-cntl1", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_tx_data_cntl2), + .propname = "fsps,emmc-tx-data-cntl2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_rx_cmd_data_cntl1), + .propname = "fsps,emmc-rx-cmd-data-cntl1", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_rx_strobe_cntl), + .propname = "fsps,emmc-rx-strobe-cntl", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_rx_cmd_data_cntl2), + .propname = "fsps,emmc-rx-cmd-data-cntl2", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, emmc_master_sw_cntl), + .propname = "fsps,emmc-master-sw-cntl", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pcie_rp_selectable_deemphasis), + .propname = "fsps,pcie-rp-selectable-deemphasis", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + pcie_rp_selectable_deemphasis), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, monitor_mwait_enable), + .propname = "fsps,monitor-mwait-enable", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, hd_audio_dsp_uaa_compliance), + .propname = "fsps,hd-audio-dsp-uaa-compliance", + }, { + .type = FSP_UINT32, + .offset = offsetof(struct fsp_s_config, ipc), + .propname = "fsps,ipc", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, ipc), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, sata_ports_disable_dynamic_pg), + .propname = "fsps,sata-ports-disable-dynamic-pg", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + sata_ports_disable_dynamic_pg), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, init_s3_cpu), + .propname = "fsps,init-s3-cpu", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, skip_punit_init), + .propname = "fsps,skip-punit-init", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb20_per_port_tx_pe_half), + .propname = "fsps,port-usb20-per-port-tx-pe-half", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_per_port_tx_pe_half), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb20_per_port_pe_txi_set), + .propname = "fsps,port-usb20-per-port-pe-txi-set", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_per_port_pe_txi_set), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb20_per_port_txi_set), + .propname = "fsps,port-usb20-per-port-txi-set", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_per_port_txi_set), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb20_hs_skew_sel), + .propname = "fsps,port-usb20-hs-skew-sel", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_hs_skew_sel), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + port_usb20_i_usb_tx_emphasis_en), + .propname = "fsps,port-usb20-i-usb-tx-emphasis-en", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_i_usb_tx_emphasis_en), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, + port_usb20_per_port_rxi_set), + .propname = "fsps,port-usb20-per-port-rxi-set", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_per_port_rxi_set), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, port_usb20_hs_npre_drv_sel), + .propname = "fsps,port-usb20-hs-npre-drv-sel", + .count = ARRAY_SIZE_OF_MEMBER(struct fsp_s_config, + port_usb20_hs_npre_drv_sel), + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, os_selection), + .propname = "fsps,os-selection", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, dptf_enabled), + .propname = "fsps,dptf-enabled", + }, { + .type = FSP_UINT8, + .offset = offsetof(struct fsp_s_config, pwm_enabled), + .propname = "fsps,pwm-enabled", + }, { + .propname = NULL + } +}; + +int fsp_s_update_config_from_dtb(ofnode node, struct fsp_s_config *cfg) +{ + return fsp_update_config_from_dtb(node, (u8 *)cfg, fsp_s_bindings); +} +#endif diff --git a/roms/u-boot/arch/x86/cpu/apollolake/fsp_m.c b/roms/u-boot/arch/x86/cpu/apollolake/fsp_m.c new file mode 100644 index 000000000..c6be707e4 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/fsp_m.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <common.h> +#include <dm.h> +#include <log.h> +#include <asm/arch/iomap.h> +#include <asm/arch/fsp_bindings.h> +#include <asm/fsp2/fsp_internal.h> +#include <dm/uclass-internal.h> + +int fspm_update_config(struct udevice *dev, struct fspm_upd *upd) +{ + struct fsp_m_config *cfg = &upd->config; + struct fspm_arch_upd *arch = &upd->arch; + int cache_ret = 0; + ofnode node; + int ret; + + arch->nvs_buffer_ptr = NULL; + cache_ret = prepare_mrc_cache(upd); + if (cache_ret && cache_ret != -ENOENT) + return log_msg_ret("mrc", cache_ret); + arch->stack_base = (void *)(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE - + arch->stack_size); + arch->boot_loader_tolum_size = 0; + arch->boot_mode = cache_ret ? FSP_BOOT_WITH_FULL_CONFIGURATION : + FSP_BOOT_ASSUMING_NO_CONFIGURATION_CHANGES; + + node = dev_ofnode(dev); + if (!ofnode_valid(node)) + return log_msg_ret("node", -ENOENT); + node = ofnode_find_subnode(node, "fsp-m"); + if (!ofnode_valid(node)) + return log_msg_ret("fspm", -ENOENT); + + ret = fsp_m_update_config_from_dtb(node, cfg); + if (ret) + return log_msg_ret("dtb", cache_ret); + + return cache_ret; +} + +/* + * The FSP-M binary appears to break the SPI controller. It can be fixed by + * writing the BAR again, so do that here + */ +int fspm_done(struct udevice *dev) +{ + struct udevice *spi; + int ret; + + /* Don't probe the device, since that reads the BAR */ + ret = uclass_find_first_device(UCLASS_SPI, &spi); + if (ret) + return log_msg_ret("SPI", ret); + if (!spi) + return log_msg_ret("no SPI", -ENODEV); + + dm_pci_write_config32(spi, PCI_BASE_ADDRESS_0, + IOMAP_SPI_BASE | PCI_BASE_ADDRESS_SPACE_MEMORY); + + return 0; +} diff --git a/roms/u-boot/arch/x86/cpu/apollolake/fsp_s.c b/roms/u-boot/arch/x86/cpu/apollolake/fsp_s.c new file mode 100644 index 000000000..a9b13c0c7 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/fsp_s.c @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <common.h> +#include <binman.h> +#include <bootstage.h> +#include <dm.h> +#include <init.h> +#include <irq.h> +#include <log.h> +#include <malloc.h> +#include <p2sb.h> +#include <acpi/acpi_s3.h> +#include <asm/global_data.h> +#include <asm/intel_pinctrl.h> +#include <asm/io.h> +#include <asm/intel_regs.h> +#include <asm/msr.h> +#include <asm/msr-index.h> +#include <asm/pci.h> +#include <asm/arch/cpu.h> +#include <asm/arch/systemagent.h> +#include <asm/arch/fsp_bindings.h> +#include <asm/arch/fsp/fsp_configs.h> +#include <asm/arch/fsp/fsp_s_upd.h> +#include <dm/uclass-internal.h> +#include <linux/bitops.h> + +#define PCH_P2SB_E0 0xe0 +#define HIDE_BIT BIT(0) + +int fsps_update_config(struct udevice *dev, ulong rom_offset, + struct fsps_upd *upd) +{ + struct fsp_s_config *cfg = &upd->config; + ofnode node; + + if (IS_ENABLED(CONFIG_HAVE_VBT)) { + void *buf; + int ret; + + ret = binman_entry_map(ofnode_null(), "intel-vbt", &buf, NULL); + if (ret) + return log_msg_ret("Cannot find VBT", ret); + if (*(u32 *)buf != VBT_SIGNATURE) + return log_msg_ret("VBT signature", -EINVAL); + + /* + * Load VBT before devicetree-specific config. This only + * supports memory-mapped SPI at present. + */ + cfg->graphics_config_ptr = (ulong)buf; + } + + node = dev_read_subnode(dev, "fsp-s"); + if (!ofnode_valid(node)) + return log_msg_ret("fsp-s settings", -ENOENT); + + return fsp_s_update_config_from_dtb(node, cfg); +} + +/* Configure package power limits */ +static int set_power_limits(struct udevice *dev) +{ + msr_t rapl_msr_reg, limit; + u32 power_unit; + u32 tdp, min_power, max_power; + u32 pl2_val; + u32 override_tdp[2]; + int ret; + + /* Get units */ + rapl_msr_reg = msr_read(MSR_PKG_POWER_SKU_UNIT); + power_unit = 1 << (rapl_msr_reg.lo & 0xf); + + /* Get power defaults for this SKU */ + rapl_msr_reg = msr_read(MSR_PKG_POWER_SKU); + tdp = rapl_msr_reg.lo & PKG_POWER_LIMIT_MASK; + pl2_val = rapl_msr_reg.hi & PKG_POWER_LIMIT_MASK; + min_power = (rapl_msr_reg.lo >> 16) & PKG_POWER_LIMIT_MASK; + max_power = rapl_msr_reg.hi & PKG_POWER_LIMIT_MASK; + + if (min_power > 0 && tdp < min_power) + tdp = min_power; + + if (max_power > 0 && tdp > max_power) + tdp = max_power; + + ret = dev_read_u32_array(dev, "tdp-pl-override-mw", override_tdp, + ARRAY_SIZE(override_tdp)); + if (ret) + return log_msg_ret("tdp-pl-override-mw", ret); + + /* Set PL1 override value */ + if (override_tdp[0]) + tdp = override_tdp[0] * power_unit / 1000; + + /* Set PL2 override value */ + if (override_tdp[1]) + pl2_val = override_tdp[1] * power_unit / 1000; + + /* Set long term power limit to TDP */ + limit.lo = tdp & PKG_POWER_LIMIT_MASK; + /* Set PL1 Pkg Power clamp bit */ + limit.lo |= PKG_POWER_LIMIT_CLAMP; + + limit.lo |= PKG_POWER_LIMIT_EN; + limit.lo |= (MB_POWER_LIMIT1_TIME_DEFAULT & + PKG_POWER_LIMIT_TIME_MASK) << PKG_POWER_LIMIT_TIME_SHIFT; + + /* Set short term power limit PL2 */ + limit.hi = pl2_val & PKG_POWER_LIMIT_MASK; + limit.hi |= PKG_POWER_LIMIT_EN; + + /* Program package power limits in RAPL MSR */ + msr_write(MSR_PKG_POWER_LIMIT, limit); + log_debug("RAPL PL1 %d.%dW\n", tdp / power_unit, + 100 * (tdp % power_unit) / power_unit); + log_debug("RAPL PL2 %d.%dW\n", pl2_val / power_unit, + 100 * (pl2_val % power_unit) / power_unit); + + /* + * Sett RAPL MMIO register for Power limits. RAPL driver is using MSR + * instead of MMIO, so disable LIMIT_EN bit for MMIO + */ + writel(limit.lo & ~PKG_POWER_LIMIT_EN, MCHBAR_REG(MCHBAR_RAPL_PPL)); + writel(limit.hi & ~PKG_POWER_LIMIT_EN, MCHBAR_REG(MCHBAR_RAPL_PPL + 4)); + + return 0; +} + +int p2sb_unhide(void) +{ + struct udevice *dev; + int ret; + + ret = uclass_find_first_device(UCLASS_P2SB, &dev); + if (ret) + return log_msg_ret("p2sb", ret); + ret = p2sb_set_hide(dev, false); + if (ret) + return log_msg_ret("hide", ret); + + return 0; +} + +/* Overwrites the SCI IRQ if another IRQ number is given by device tree */ +static void set_sci_irq(void) +{ + /* Skip this for now */ +} + +int arch_fsps_preinit(void) +{ + struct udevice *itss; + int ret; + + if (!ll_boot_init()) + return 0; + ret = irq_first_device_type(X86_IRQT_ITSS, &itss); + if (ret) + return log_msg_ret("no itss", ret); + + /* + * Clear the GPI interrupt status and enable registers. These + * registers do not get reset to default state when booting from S5. + */ + ret = pinctrl_gpi_clear_int_cfg(); + if (ret) + return log_msg_ret("gpi_clear", ret); + + return 0; +} + +int arch_fsp_init_r(void) +{ + bool s3wake; + struct udevice *dev, *itss; + int ret; + + if (!ll_boot_init()) + return 0; + + s3wake = IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && + gd->arch.prev_sleep_state == ACPI_S3; + + /* + * This must be called before any devices are probed. Put any probing + * into arch_fsps_preinit() above. + * + * We don't use CONFIG_APL_BOOT_FROM_FAST_SPI_FLASH here since it will + * force PCI to be probed. + */ + ret = fsp_silicon_init(s3wake, false); + if (ret) + return ret; + + ret = irq_first_device_type(X86_IRQT_ITSS, &itss); + if (ret) + return log_msg_ret("no itss", ret); + + /* + * Restore GPIO IRQ polarities back to previous settings. This was + * stored in reserve_arch() - see X86_IRQT_ITSS + */ + irq_restore_polarities(itss); + + /* soc_init() */ + ret = p2sb_unhide(); + if (ret) + return log_msg_ret("unhide p2sb", ret); + + /* Set RAPL MSR for Package power limits*/ + ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &dev); + if (ret) + return log_msg_ret("Cannot get northbridge", ret); + set_power_limits(dev); + + /* + * FSP-S routes SCI to IRQ 9. With the help of this function you can + * select another IRQ for SCI. + */ + set_sci_irq(); + + return 0; +} diff --git a/roms/u-boot/arch/x86/cpu/apollolake/hostbridge.c b/roms/u-boot/arch/x86/cpu/apollolake/hostbridge.c new file mode 100644 index 000000000..9decab7aa --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/hostbridge.c @@ -0,0 +1,395 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + * Copyright (C) 2015 - 2017 Intel Corp. + * Copyright (C) 2017 - 2019 Siemens AG + * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.) + * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.) + * + * Portions from coreboot soc/intel/apollolake/chip.c + */ + +#define LOG_CATEGORY UCLASS_NORTHBRIDGE + +#include <common.h> +#include <dm.h> +#include <dt-structs.h> +#include <log.h> +#include <spl.h> +#include <tables_csum.h> +#include <acpi/acpi_table.h> +#include <asm/acpi_nhlt.h> +#include <asm/intel_pinctrl.h> +#include <asm/intel_regs.h> +#include <asm/io.h> +#include <asm/pci.h> +#include <asm/arch/acpi.h> +#include <asm/arch/hostbridge.h> +#include <asm/arch/systemagent.h> +#include <dt-bindings/sound/nhlt.h> +#include <dm/acpi.h> + +enum { + PCIEXBAR = 0x60, + PCIEXBAR_LENGTH_256MB = 0, + PCIEXBAR_LENGTH_128MB, + PCIEXBAR_LENGTH_64MB, + + PCIEXBAR_PCIEXBAREN = 1 << 0, + + BGSM = 0xb4, /* Base GTT Stolen Memory */ + TSEG = 0xb8, /* TSEG base */ + TOLUD = 0xbc, +}; + +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) +static const struct nhlt_format_config dmic_1ch_formats[] = { + /* 48 KHz 16-bits per sample. */ + { + .num_channels = 1, + .sample_freq_khz = 48, + .container_bits_per_sample = 16, + .valid_bits_per_sample = 16, + .settings_file = "dmic-1ch-48khz-16b.dat", + }, +}; + +static const struct nhlt_dmic_array_config dmic_1ch_mic_config = { + .tdm_config = { + .config_type = NHLT_TDM_MIC_ARRAY, + }, + .array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED, +}; + +static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = { + { + .link = NHLT_LINK_PDM, + .device = NHLT_PDM_DEV, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_DMIC, + .cfg = &dmic_1ch_mic_config, + .cfg_size = sizeof(dmic_1ch_mic_config), + .formats = dmic_1ch_formats, + .num_formats = ARRAY_SIZE(dmic_1ch_formats), + }, +}; + +static const struct nhlt_format_config dmic_2ch_formats[] = { + /* 48 KHz 16-bits per sample. */ + { + .num_channels = 2, + .sample_freq_khz = 48, + .container_bits_per_sample = 16, + .valid_bits_per_sample = 16, + .settings_file = "dmic-2ch-48khz-16b.dat", + }, +}; + +static const struct nhlt_dmic_array_config dmic_2ch_mic_config = { + .tdm_config = { + .config_type = NHLT_TDM_MIC_ARRAY, + }, + .array_type = NHLT_MIC_ARRAY_2CH_SMALL, +}; + +static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = { + { + .link = NHLT_LINK_PDM, + .device = NHLT_PDM_DEV, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_DMIC, + .cfg = &dmic_2ch_mic_config, + .cfg_size = sizeof(dmic_2ch_mic_config), + .formats = dmic_2ch_formats, + .num_formats = ARRAY_SIZE(dmic_2ch_formats), + }, +}; + +static const struct nhlt_format_config dmic_4ch_formats[] = { + /* 48 KHz 16-bits per sample. */ + { + .num_channels = 4, + .sample_freq_khz = 48, + .container_bits_per_sample = 16, + .valid_bits_per_sample = 16, + .settings_file = "dmic-4ch-48khz-16b.dat", + }, +}; + +static const struct nhlt_dmic_array_config dmic_4ch_mic_config = { + .tdm_config = { + .config_type = NHLT_TDM_MIC_ARRAY, + }, + .array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED, +}; + +static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = { + { + .link = NHLT_LINK_PDM, + .device = NHLT_PDM_DEV, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_DMIC, + .cfg = &dmic_4ch_mic_config, + .cfg_size = sizeof(dmic_4ch_mic_config), + .formats = dmic_4ch_formats, + .num_formats = ARRAY_SIZE(dmic_4ch_formats), + }, +}; +#endif + +static int apl_hostbridge_early_init_pinctrl(struct udevice *dev) +{ + struct apl_hostbridge_plat *plat = dev_get_plat(dev); + struct udevice *pinctrl; + int ret; + + ret = uclass_first_device_err(UCLASS_PINCTRL, &pinctrl); + if (ret) + return log_msg_ret("no hostbridge pinctrl", ret); + + return pinctrl_config_pads(pinctrl, plat->early_pads, + plat->early_pads_count); +} + +static int apl_hostbridge_early_init(struct udevice *dev) +{ + struct apl_hostbridge_plat *plat = dev_get_plat(dev); + u32 region_size; + ulong base; + u32 reg; + int ret; + + /* Set up the MCHBAR */ + pci_x86_read_config(plat->bdf, MCHBAR, &base, PCI_SIZE_32); + base = MCH_BASE_ADDRESS; + pci_x86_write_config(plat->bdf, MCHBAR, base | 1, PCI_SIZE_32); + + /* + * The PCIEXBAR is assumed to live in the memory mapped IO space under + * 4GiB + */ + pci_x86_write_config(plat->bdf, PCIEXBAR + 4, 0, PCI_SIZE_32); + + switch (plat->pciex_region_size >> 20) { + default: + case 256: + region_size = PCIEXBAR_LENGTH_256MB; + break; + case 128: + region_size = PCIEXBAR_LENGTH_128MB; + break; + case 64: + region_size = PCIEXBAR_LENGTH_64MB; + break; + } + + reg = CONFIG_MMCONF_BASE_ADDRESS | (region_size << 1) + | PCIEXBAR_PCIEXBAREN; + pci_x86_write_config(plat->bdf, PCIEXBAR, reg, PCI_SIZE_32); + + /* + * TSEG defines the base of SMM range. BIOS determines the base + * of TSEG memory which must be at or below Graphics base of GTT + * Stolen memory, hence its better to clear TSEG register early + * to avoid power on default non-zero value (if any). + */ + pci_x86_write_config(plat->bdf, TSEG, 0, PCI_SIZE_32); + + ret = apl_hostbridge_early_init_pinctrl(dev); + if (ret) + return log_msg_ret("pinctrl", ret); + + return 0; +} + +static int apl_hostbridge_of_to_plat(struct udevice *dev) +{ + struct apl_hostbridge_plat *plat = dev_get_plat(dev); + struct udevice *pinctrl; + int ret; + + /* + * The host bridge holds the early pad data needed to get through TPL. + * This is a small amount of data, enough to fit in TPL, so we keep it + * separate from the full pad data, stored in the fsp-s subnode. That + * subnode is not present in TPL, to save space. + */ + ret = uclass_first_device_err(UCLASS_PINCTRL, &pinctrl); + if (ret) + return log_msg_ret("no hostbridge PINCTRL", ret); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + int root; + + /* Get length of PCI Express Region */ + plat->pciex_region_size = dev_read_u32_default(dev, "pciex-region-size", + 256 << 20); + + root = pci_get_devfn(dev); + if (root < 0) + return log_msg_ret("Cannot get host-bridge PCI address", root); + plat->bdf = root; + + ret = pinctrl_read_pads(pinctrl, dev_ofnode(dev), "early-pads", + &plat->early_pads, &plat->early_pads_count); + if (ret) + return log_msg_ret("early-pads", ret); +#else + struct dtd_intel_apl_hostbridge *dtplat = &plat->dtplat; + int size; + + plat->pciex_region_size = dtplat->pciex_region_size; + plat->bdf = pci_ofplat_get_devfn(dtplat->reg[0]); + + /* Assume that if everything is 0, it is empty */ + plat->early_pads = dtplat->early_pads; + size = ARRAY_SIZE(dtplat->early_pads); + plat->early_pads_count = pinctrl_count_pads(pinctrl, plat->early_pads, + size); + +#endif + + return 0; +} + +static int apl_hostbridge_probe(struct udevice *dev) +{ + if (spl_phase() == PHASE_TPL) + return apl_hostbridge_early_init(dev); + + return 0; +} + +static int apl_acpi_hb_get_name(const struct udevice *dev, char *out_name) +{ + return acpi_copy_name(out_name, "RHUB"); +} + +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) +static int apl_acpi_hb_write_tables(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct acpi_table_header *header; + struct acpi_dmar *dmar; + u32 val; + + /* + * Create DMAR table only if virtualization is enabled. Due to some + * constraints on Apollo Lake SoC (some stepping affected), VTD could + * not be enabled together with IPU. Doing so will override and disable + * VTD while leaving CAPID0_A still reporting that VTD is available. + * As in this case FSP will lock VTD to disabled state, we need to make + * sure that DMAR table generation only happens when at least DEFVTBAR + * is enabled. Otherwise the DMAR header will be generated while the + * content of the table will be missing. + */ + dm_pci_read_config32(dev, CAPID0_A, &val); + if ((val & VTD_DISABLE) || + !(readl(MCHBAR_REG(DEFVTBAR)) & VTBAR_ENABLED)) + return 0; + + log_debug("ACPI: * DMAR\n"); + dmar = (struct acpi_dmar *)ctx->current; + header = &dmar->header; + acpi_create_dmar(dmar, DMAR_INTR_REMAP); + ctx->current += sizeof(struct acpi_dmar); + apl_acpi_fill_dmar(ctx); + + /* (Re)calculate length and checksum */ + header->length = ctx->current - (void *)dmar; + header->checksum = table_compute_checksum((void *)dmar, header->length); + + acpi_align(ctx); + acpi_add_table(ctx, dmar); + + return 0; +} + +static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + struct nhlt *nhlt = ctx->nhlt; + u32 channels; + ofnode node; + + node = ofnode_find_subnode(dev_ofnode(dev), "nhlt"); + if (ofnode_read_u32(node, "intel,dmic-channels", &channels)) + return log_msg_ret("channels", -EINVAL); + switch (channels) { + case 1: + return nhlt_add_endpoints(nhlt, dmic_1ch_descriptors, + ARRAY_SIZE(dmic_1ch_descriptors)); + case 2: + return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors, + ARRAY_SIZE(dmic_2ch_descriptors)); + case 4: + return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors, + ARRAY_SIZE(dmic_4ch_descriptors)); + } + + return log_msg_ret("channels", -EINVAL); +} +#endif + +static int apl_hostbridge_remove(struct udevice *dev) +{ + /* + * TODO(sjg@chromium.org): Consider adding code from coreboot's + * platform_fsp_notify_status() + */ + + return 0; +} + +static ulong sa_read_reg(struct udevice *dev, int reg) +{ + u32 val; + + /* All regions concerned for have 1 MiB alignment */ + dm_pci_read_config32(dev, BGSM, &val); + + return ALIGN_DOWN(val, 1 << 20); +} + +ulong sa_get_tolud_base(struct udevice *dev) +{ + return sa_read_reg(dev, TOLUD); +} + +ulong sa_get_gsm_base(struct udevice *dev) +{ + return sa_read_reg(dev, BGSM); +} + +ulong sa_get_tseg_base(struct udevice *dev) +{ + return sa_read_reg(dev, TSEG); +} + +struct acpi_ops apl_hostbridge_acpi_ops = { + .get_name = apl_acpi_hb_get_name, +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) + .write_tables = apl_acpi_hb_write_tables, + .setup_nhlt = apl_acpi_setup_nhlt, +#endif +}; + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) +static const struct udevice_id apl_hostbridge_ids[] = { + { .compatible = "intel,apl-hostbridge" }, + { } +}; +#endif + +U_BOOT_DRIVER(intel_apl_hostbridge) = { + .name = "intel_apl_hostbridge", + .id = UCLASS_NORTHBRIDGE, + .of_match = of_match_ptr(apl_hostbridge_ids), + .of_to_plat = apl_hostbridge_of_to_plat, + .probe = apl_hostbridge_probe, + .remove = apl_hostbridge_remove, + .plat_auto = sizeof(struct apl_hostbridge_plat), + ACPI_OPS_PTR(&apl_hostbridge_acpi_ops) + .flags = DM_FLAG_OS_PREPARE, +}; diff --git a/roms/u-boot/arch/x86/cpu/apollolake/lpc.c b/roms/u-boot/arch/x86/cpu/apollolake/lpc.c new file mode 100644 index 000000000..e085890d6 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/lpc.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + * + * From coreboot Apollo Lake support lpc.c + */ + +#include <common.h> +#include <dm.h> +#include <log.h> +#include <spl.h> +#include <acpi/acpi_table.h> +#include <asm/cpu_common.h> +#include <asm/intel_acpi.h> +#include <asm/lpc_common.h> +#include <asm/pci.h> +#include <asm/arch/iomap.h> +#include <asm/arch/lpc.h> +#include <dm/acpi.h> +#include <linux/log2.h> + +void lpc_enable_fixed_io_ranges(uint io_enables) +{ + pci_x86_clrset_config(PCH_DEV_LPC, LPC_IO_ENABLES, 0, io_enables, + PCI_SIZE_16); +} + +/* + * Find the first unused IO window. + * Returns -1 if not found, 0 for reg 0x84, 1 for reg 0x88 ... + */ +static int find_unused_pmio_window(void) +{ + int i; + ulong lgir; + + for (i = 0; i < LPC_NUM_GENERIC_IO_RANGES; i++) { + pci_x86_read_config(PCH_DEV_LPC, LPC_GENERIC_IO_RANGE(i), + &lgir, PCI_SIZE_32); + + if (!(lgir & LPC_LGIR_EN)) + return i; + } + + return -1; +} + +int lpc_open_pmio_window(uint base, uint size) +{ + int i, lgir_reg_num; + u32 lgir_reg_offset, lgir, window_size, alignment; + ulong bridged_size, bridge_base; + ulong reg; + + log_debug("LPC: Trying to open IO window from %x size %x\n", base, + size); + + bridged_size = 0; + bridge_base = base; + + while (bridged_size < size) { + /* Each IO range register can only open a 256-byte window */ + window_size = min(size, (uint)LPC_LGIR_MAX_WINDOW_SIZE); + + /* Window size must be a power of two for the AMASK to work */ + alignment = 1UL << (order_base_2(window_size)); + window_size = ALIGN(window_size, alignment); + + /* Address[15:2] in LGIR[15:12] and Mask[7:2] in LGIR[23:18] */ + lgir = (bridge_base & LPC_LGIR_ADDR_MASK) | LPC_LGIR_EN; + lgir |= ((window_size - 1) << 16) & LPC_LGIR_AMASK_MASK; + + /* Skip programming if same range already programmed */ + for (i = 0; i < LPC_NUM_GENERIC_IO_RANGES; i++) { + pci_x86_read_config(PCH_DEV_LPC, + LPC_GENERIC_IO_RANGE(i), ®, + PCI_SIZE_32); + if (lgir == reg) + return -EALREADY; + } + + lgir_reg_num = find_unused_pmio_window(); + if (lgir_reg_num < 0) { + if (spl_phase() > PHASE_TPL) { + log_err("LPC: Cannot open IO window: %lx size %lx\n", + bridge_base, size - bridged_size); + log_err("No more IO windows\n"); + } + return -ENOSPC; + } + lgir_reg_offset = LPC_GENERIC_IO_RANGE(lgir_reg_num); + + pci_x86_write_config(PCH_DEV_LPC, lgir_reg_offset, lgir, + PCI_SIZE_32); + + log_debug("LPC: Opened IO window LGIR%d: base %lx size %x\n", + lgir_reg_num, bridge_base, window_size); + + bridged_size += window_size; + bridge_base += window_size; + } + + return 0; +} + +void lpc_io_setup_comm_a_b(void) +{ + /* ComA Range 3F8h-3FFh [2:0] */ + u16 com_ranges = LPC_IOD_COMA_RANGE; + u16 com_enable = LPC_IOE_COMA_EN; + + /* Setup I/O Decode Range Register for LPC */ + pci_write_config16(PCH_DEV_LPC, LPC_IO_DECODE, com_ranges); + /* Enable ComA and ComB Port */ + lpc_enable_fixed_io_ranges(com_enable); +} + +static int apl_acpi_lpc_get_name(const struct udevice *dev, char *out_name) +{ + return acpi_copy_name(out_name, "LPCB"); +} + +struct acpi_ops apl_lpc_acpi_ops = { + .get_name = apl_acpi_lpc_get_name, +#ifdef CONFIG_GENERATE_ACPI_TABLE + .write_tables = intel_southbridge_write_acpi_tables, +#endif + .inject_dsdt = southbridge_inject_dsdt, +}; + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) +static const struct udevice_id apl_lpc_ids[] = { + { .compatible = "intel,apl-lpc" }, + { } +}; +#endif + +/* All pads are LPC already configured by the hostbridge, so no probing here */ +U_BOOT_DRIVER(intel_apl_lpc) = { + .name = "intel_apl_lpc", + .id = UCLASS_LPC, + .of_match = of_match_ptr(apl_lpc_ids), + ACPI_OPS_PTR(&apl_lpc_acpi_ops) +}; diff --git a/roms/u-boot/arch/x86/cpu/apollolake/pch.c b/roms/u-boot/arch/x86/cpu/apollolake/pch.c new file mode 100644 index 000000000..39d6ad5ed --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/pch.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + */ + +#include <common.h> +#include <dm.h> +#include <pch.h> +#include <spl.h> +#include <asm/lpc_common.h> + +#define BIOS_CTRL 0xdc + +static int apl_set_spi_protect(struct udevice *dev, bool protect) +{ + if (spl_phase() == PHASE_SPL) + return lpc_set_spi_protect(dev, BIOS_CTRL, protect); + + return 0; +} + +static const struct pch_ops apl_pch_ops = { + .set_spi_protect = apl_set_spi_protect, +}; + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) +static const struct udevice_id apl_pch_ids[] = { + { .compatible = "intel,apl-pch" }, + { } +}; +#endif + +U_BOOT_DRIVER(intel_apl_pch) = { + .name = "intel_apl_pch", + .id = UCLASS_PCH, + .of_match = of_match_ptr(apl_pch_ids), + .ops = &apl_pch_ops, +}; diff --git a/roms/u-boot/arch/x86/cpu/apollolake/pmc.c b/roms/u-boot/arch/x86/cpu/apollolake/pmc.c new file mode 100644 index 000000000..1d21187c9 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/pmc.c @@ -0,0 +1,224 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Intel Corporation. + * Copyright 2019 Google LLC + * + * Modified from coreboot pmclib.c, pmc.c and pmutil.c + */ + +#define LOG_CATEGORY UCLASS_ACPI_PMC + +#include <common.h> +#include <dm.h> +#include <dt-structs.h> +#include <log.h> +#include <spl.h> +#include <acpi/acpi_s3.h> +#include <asm/io.h> +#include <asm/pci.h> +#include <asm/arch/pmc.h> +#include <linux/bitops.h> +#include <power/acpi_pmc.h> + +#define GPIO_GPE_CFG 0x1050 + +/* Memory mapped IO registers behind PMC_BASE_ADDRESS */ +#define PRSTS 0x1000 +#define GEN_PMCON1 0x1020 +#define COLD_BOOT_STS BIT(27) +#define COLD_RESET_STS BIT(26) +#define WARM_RESET_STS BIT(25) +#define GLOBAL_RESET_STS BIT(24) +#define SRS BIT(20) +#define MS4V BIT(18) +#define RPS BIT(2) +#define GEN_PMCON1_CLR1_BITS (COLD_BOOT_STS | COLD_RESET_STS | \ + WARM_RESET_STS | GLOBAL_RESET_STS | \ + SRS | MS4V) +#define GEN_PMCON2 0x1024 +#define GEN_PMCON3 0x1028 + +/* Offset of TCO registers from ACPI base I/O address */ +#define TCO_REG_OFFSET 0x60 +#define TCO1_STS 0x64 +#define DMISCI_STS BIT(9) +#define BOOT_STS BIT(18) +#define TCO2_STS 0x66 +#define TCO1_CNT 0x68 +#define TCO_LOCK BIT(12) +#define TCO2_CNT 0x6a + +enum { + ETR = 0x1048, + CF9_LOCK = 1UL << 31, + CF9_GLB_RST = 1 << 20, +}; + +static int apl_pmc_fill_power_state(struct udevice *dev) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + + upriv->tco1_sts = inw(upriv->acpi_base + TCO1_STS); + upriv->tco2_sts = inw(upriv->acpi_base + TCO2_STS); + + upriv->prsts = readl(upriv->pmc_bar0 + PRSTS); + upriv->gen_pmcon1 = readl(upriv->pmc_bar0 + GEN_PMCON1); + upriv->gen_pmcon2 = readl(upriv->pmc_bar0 + GEN_PMCON2); + upriv->gen_pmcon3 = readl(upriv->pmc_bar0 + GEN_PMCON3); + + return 0; +} + +static int apl_prev_sleep_state(struct udevice *dev, int prev_sleep_state) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + + /* WAK_STS bit will not be set when waking from G3 state */ + if (!(upriv->pm1_sts & WAK_STS) && + (upriv->gen_pmcon1 & COLD_BOOT_STS)) + prev_sleep_state = ACPI_S5; + + return prev_sleep_state; +} + +static int apl_disable_tco(struct udevice *dev) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + + pmc_disable_tco_base(upriv->acpi_base + TCO_REG_OFFSET); + + return 0; +} + +static int apl_global_reset_set_enable(struct udevice *dev, bool enable) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + + if (enable) + setbits_le32(upriv->pmc_bar0 + ETR, CF9_GLB_RST); + else + clrbits_le32(upriv->pmc_bar0 + ETR, CF9_GLB_RST); + + return 0; +} + +int apl_pmc_ofdata_to_uc_plat(struct udevice *dev) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + struct apl_pmc_plat *plat = dev_get_plat(dev); + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + u32 base[6]; + int size; + int ret; + + ret = dev_read_u32_array(dev, "early-regs", base, + ARRAY_SIZE(base)); + if (ret) + return log_msg_ret("Missing/short early-regs", ret); + if (spl_phase() == PHASE_TPL) { + upriv->pmc_bar0 = (void *)base[0]; + upriv->pmc_bar2 = (void *)base[2]; + + /* Since PCI is not enabled, we must get the BDF manually */ + plat->bdf = pci_get_devfn(dev); + if (plat->bdf < 0) + return log_msg_ret("Cannot get PMC PCI address", + plat->bdf); + } + upriv->acpi_base = base[4]; + + /* Get the dwX values for pmc gpe settings */ + size = dev_read_size(dev, "gpe0-dw"); + if (size < 0) + return log_msg_ret("Cannot read gpe0-dm", size); + upriv->gpe0_count = size / sizeof(u32); + ret = dev_read_u32_array(dev, "gpe0-dw", upriv->gpe0_dw, + upriv->gpe0_count); + if (ret) + return log_msg_ret("Bad gpe0-dw", ret); + + return pmc_ofdata_to_uc_plat(dev); +#else + struct dtd_intel_apl_pmc *dtplat = &plat->dtplat; + + plat->bdf = pci_ofplat_get_devfn(dtplat->reg[0]); + upriv->pmc_bar0 = (void *)dtplat->early_regs[0]; + upriv->pmc_bar2 = (void *)dtplat->early_regs[2]; + upriv->acpi_base = dtplat->early_regs[4]; + upriv->gpe0_dwx_mask = dtplat->gpe0_dwx_mask; + upriv->gpe0_dwx_shift_base = dtplat->gpe0_dwx_shift_base; + upriv->gpe0_sts_reg = dtplat->gpe0_sts; + upriv->gpe0_sts_reg += upriv->acpi_base; + upriv->gpe0_en_reg = dtplat->gpe0_en; + upriv->gpe0_en_reg += upriv->acpi_base; + upriv->gpe0_count = min((int)ARRAY_SIZE(dtplat->gpe0_dw), GPE0_REG_MAX); + memcpy(upriv->gpe0_dw, dtplat->gpe0_dw, sizeof(dtplat->gpe0_dw)); +#endif + upriv->gpe_cfg = (u32 *)(upriv->pmc_bar0 + GPIO_GPE_CFG); + + return 0; +} + +static int enable_pmcbar(struct udevice *dev) +{ + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + struct apl_pmc_plat *priv = dev_get_plat(dev); + pci_dev_t pmc = priv->bdf; + + /* + * Set PMC base addresses and enable decoding. BARs 1 and 3 are 64-bit + * BARs. + */ + pci_x86_write_config(pmc, PCI_BASE_ADDRESS_0, (ulong)upriv->pmc_bar0, + PCI_SIZE_32); + pci_x86_write_config(pmc, PCI_BASE_ADDRESS_1, 0, PCI_SIZE_32); + pci_x86_write_config(pmc, PCI_BASE_ADDRESS_2, (ulong)upriv->pmc_bar2, + PCI_SIZE_32); + pci_x86_write_config(pmc, PCI_BASE_ADDRESS_3, 0, PCI_SIZE_32); + pci_x86_write_config(pmc, PCI_BASE_ADDRESS_4, upriv->acpi_base, + PCI_SIZE_16); + pci_x86_write_config(pmc, PCI_COMMAND, PCI_COMMAND_IO | + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER, + PCI_SIZE_16); + + return 0; +} + +static int apl_pmc_probe(struct udevice *dev) +{ + if (spl_phase() == PHASE_TPL) { + return enable_pmcbar(dev); + } else { + struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); + + upriv->pmc_bar0 = (void *)dm_pci_read_bar32(dev, 0); + upriv->pmc_bar2 = (void *)dm_pci_read_bar32(dev, 2); + } + + return 0; +} + +static const struct acpi_pmc_ops apl_pmc_ops = { + .init = apl_pmc_fill_power_state, + .prev_sleep_state = apl_prev_sleep_state, + .disable_tco = apl_disable_tco, + .global_reset_set_enable = apl_global_reset_set_enable, +}; + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) +static const struct udevice_id apl_pmc_ids[] = { + { .compatible = "intel,apl-pmc" }, + { } +}; +#endif + +U_BOOT_DRIVER(intel_apl_pmc) = { + .name = "intel_apl_pmc", + .id = UCLASS_ACPI_PMC, + .of_match = of_match_ptr(apl_pmc_ids), + .of_to_plat = apl_pmc_ofdata_to_uc_plat, + .probe = apl_pmc_probe, + .ops = &apl_pmc_ops, + .plat_auto = sizeof(struct apl_pmc_plat), +}; diff --git a/roms/u-boot/arch/x86/cpu/apollolake/punit.c b/roms/u-boot/arch/x86/cpu/apollolake/punit.c new file mode 100644 index 000000000..5ed796357 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/punit.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + */ + +#include <common.h> +#include <dm.h> +#include <log.h> +#include <spl.h> +#include <asm/cpu.h> +#include <asm/cpu_common.h> +#include <asm/intel_regs.h> +#include <asm/io.h> +#include <asm/pci.h> +#include <asm/arch/systemagent.h> +#include <linux/delay.h> + +/* + * Punit Initialisation code. This all isn't documented, but + * this is the recipe. + */ +static int punit_init(struct udevice *dev) +{ + struct udevice *cpu; + u32 reg; + ulong start; + int ret; + + /* Thermal throttle activation offset */ + ret = uclass_first_device_err(UCLASS_CPU, &cpu); + if (ret) + return log_msg_ret("Cannot find CPU", ret); + cpu_configure_thermal_target(cpu); + + /* + * Software Core Disable Mask (P_CR_CORE_DISABLE_MASK_0_0_0_MCHBAR). + * Enable all cores here. + */ + writel(0, MCHBAR_REG(CORE_DISABLE_MASK)); + + /* P-Unit bring up */ + reg = readl(MCHBAR_REG(BIOS_RESET_CPL)); + if (reg == 0xffffffff) { + /* P-unit not found */ + debug("Punit MMIO not available\n"); + return -ENOENT; + } + + /* Set Punit interrupt pin IPIN offset 3D */ + dm_pci_write_config8(dev, PCI_INTERRUPT_PIN, 0x2); + + /* Set PUINT IRQ to 24 and INTPIN LOCK */ + writel(PUINT_THERMAL_DEVICE_IRQ_VEC_NUMBER | + PUINT_THERMAL_DEVICE_IRQ_LOCK, + MCHBAR_REG(PUNIT_THERMAL_DEVICE_IRQ)); + + /* Stage0 BIOS Reset Complete (RST_CPL) */ + enable_bios_reset_cpl(); + + /* + * Poll for bit 8 to check if PCODE has completed its action in response + * to BIOS Reset complete. We wait here till 1 ms for the bit to get + * set. + */ + start = get_timer(0); + while (!(readl(MCHBAR_REG(BIOS_RESET_CPL)) & PCODE_INIT_DONE)) { + if (get_timer(start) > 1) { + debug("PCODE Init Done timeout\n"); + return -ETIMEDOUT; + } + udelay(100); + } + debug("PUNIT init complete\n"); + + return 0; +} + +static int apl_punit_probe(struct udevice *dev) +{ + if (spl_phase() == PHASE_SPL) + return punit_init(dev); + + return 0; +} + +static const struct udevice_id apl_syscon_ids[] = { + { .compatible = "intel,apl-punit", .data = X86_SYSCON_PUNIT }, + { } +}; + +U_BOOT_DRIVER(intel_apl_punit) = { + .name = "intel_apl_punit", + .id = UCLASS_SYSCON, + .of_match = apl_syscon_ids, + .probe = apl_punit_probe, + DM_HEADER(<asm/cpu.h>) /* for X86_SYSCON_PUNIT */ +}; diff --git a/roms/u-boot/arch/x86/cpu/apollolake/spl.c b/roms/u-boot/arch/x86/cpu/apollolake/spl.c new file mode 100644 index 000000000..f2d25734c --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/spl.c @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + */ + +#define LOG_CATEGORY LOGC_BOOT + +#include <common.h> +#include <binman_sym.h> +#include <bootstage.h> +#include <dm.h> +#include <image.h> +#include <log.h> +#include <malloc.h> +#include <spi.h> +#include <spl.h> +#include <spi_flash.h> +#include <asm/fast_spi.h> +#include <asm/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/iomap.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> + +/* This reads the next phase from mapped SPI flash */ +static int rom_load_image(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev) +{ + ulong spl_pos = spl_get_image_pos(); + ulong spl_size = spl_get_image_size(); + struct udevice *dev; + ulong map_base; + size_t map_size; + uint offset; + int ret; + + spl_image->size = CONFIG_SYS_MONITOR_LEN; /* We don't know SPL size */ + spl_image->entry_point = spl_get_image_text_base(); + spl_image->load_addr = spl_image->entry_point; + spl_image->os = IH_OS_U_BOOT; + spl_image->name = "U-Boot"; + log_debug("Reading from mapped SPI %lx, size %lx\n", spl_pos, spl_size); + + if (CONFIG_IS_ENABLED(SPI_FLASH_SUPPORT)) { + ret = uclass_find_first_device(UCLASS_SPI_FLASH, &dev); + if (ret) + return log_msg_ret("spi_flash", ret); + if (!dev) + return log_msg_ret("spi_flash dev", -ENODEV); + ret = dm_spi_get_mmap(dev, &map_base, &map_size, &offset); + if (ret) + return log_msg_ret("mmap", ret); + } else { + ret = fast_spi_get_bios_mmap(PCH_DEV_SPI, &map_base, &map_size, + &offset); + if (ret) + return ret; + } + spl_pos += map_base & ~0xff000000; + log_debug(", base %lx, pos %lx, load %lx\n", map_base, spl_pos, + spl_image->load_addr); + bootstage_start(BOOTSTAGE_ID_ACCUM_MMAP_SPI, "mmap_spi"); + memcpy((void *)spl_image->load_addr, (void *)spl_pos, spl_size); + cpu_flush_l1d_to_l2(); + bootstage_accum(BOOTSTAGE_ID_ACCUM_MMAP_SPI); + + return 0; +} +SPL_LOAD_IMAGE_METHOD("Mapped SPI", 2, BOOT_DEVICE_SPI_MMAP, rom_load_image); + +#if CONFIG_IS_ENABLED(SPI_FLASH_SUPPORT) + +static int apl_flash_std_read(struct udevice *dev, u32 offset, size_t len, + void *buf) +{ + struct spi_flash *flash = dev_get_uclass_priv(dev); + struct mtd_info *mtd = &flash->mtd; + size_t retlen; + + return log_ret(mtd->_read(mtd, offset, len, &retlen, buf)); +} + +static int apl_flash_probe(struct udevice *dev) +{ + return spi_flash_std_probe(dev); +} + +static const struct dm_spi_flash_ops apl_flash_ops = { + .read = apl_flash_std_read, +}; + +static const struct udevice_id apl_flash_ids[] = { + { .compatible = "jedec,spi-nor" }, + { } +}; + +U_BOOT_DRIVER(winbond_w25q128fw) = { + .name = "winbond_w25q128fw", + .id = UCLASS_SPI_FLASH, + .of_match = apl_flash_ids, + .probe = apl_flash_probe, + .priv_auto = sizeof(struct spi_nor), + .ops = &apl_flash_ops, +}; + +/* This uses a SPI flash device to read the next phase */ +static int spl_fast_spi_load_image(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev) +{ + ulong spl_pos = spl_get_image_pos(); + ulong spl_size = spl_get_image_size(); + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_SPI_FLASH, &dev); + if (ret) + return ret; + + spl_image->size = CONFIG_SYS_MONITOR_LEN; /* We don't know SPL size */ + spl_image->entry_point = spl_phase() == PHASE_TPL ? + CONFIG_SPL_TEXT_BASE : CONFIG_SYS_TEXT_BASE; + spl_image->load_addr = spl_image->entry_point; + spl_image->os = IH_OS_U_BOOT; + spl_image->name = "U-Boot"; + spl_pos &= ~0xff000000; + log_debug("Reading from flash %lx, size %lx\n", spl_pos, spl_size); + ret = spi_flash_read_dm(dev, spl_pos, spl_size, + (void *)spl_image->load_addr); + cpu_flush_l1d_to_l2(); + if (ret) + return ret; + + return 0; +} +SPL_LOAD_IMAGE_METHOD("Fast SPI", 1, BOOT_DEVICE_FAST_SPI, + spl_fast_spi_load_image); + +void board_boot_order(u32 *spl_boot_list) +{ + bool use_spi_flash = IS_ENABLED(CONFIG_APL_BOOT_FROM_FAST_SPI_FLASH); + + if (use_spi_flash) { + spl_boot_list[0] = BOOT_DEVICE_FAST_SPI; + spl_boot_list[1] = BOOT_DEVICE_SPI_MMAP; + } else { + spl_boot_list[0] = BOOT_DEVICE_SPI_MMAP; + spl_boot_list[1] = BOOT_DEVICE_FAST_SPI; + } +} + +#else + +void board_boot_order(u32 *spl_boot_list) +{ + spl_boot_list[0] = BOOT_DEVICE_SPI_MMAP; +} +#endif diff --git a/roms/u-boot/arch/x86/cpu/apollolake/systemagent.c b/roms/u-boot/arch/x86/cpu/apollolake/systemagent.c new file mode 100644 index 000000000..b6bc2ba14 --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/systemagent.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Intel Corporation. + * Take from coreboot project file of the same name + */ + +#include <common.h> +#include <asm/intel_regs.h> +#include <asm/io.h> +#include <asm/arch/systemagent.h> + +void enable_bios_reset_cpl(void) +{ + /* + * Set bits 0+1 of BIOS_RESET_CPL to indicate to the CPU + * that BIOS has initialised memory and power management + * + * The FSP-S does not do this. If we leave this as zero then I believe + * the power-aware interrupts don't work in Linux, and CPU 0 always gets + * the interrupt. + */ + setbits_8(MCHBAR_REG(BIOS_RESET_CPL), 3); +} diff --git a/roms/u-boot/arch/x86/cpu/apollolake/uart.c b/roms/u-boot/arch/x86/cpu/apollolake/uart.c new file mode 100644 index 000000000..876fa592b --- /dev/null +++ b/roms/u-boot/arch/x86/cpu/apollolake/uart.c @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Special driver to handle of-platdata + * + * Copyright 2019 Google LLC + * + * Some code from coreboot lpss.c + */ + +#include <common.h> +#include <dm.h> +#include <dt-structs.h> +#include <malloc.h> +#include <ns16550.h> +#include <spl.h> +#include <asm/io.h> +#include <asm/pci.h> +#include <asm/lpss.h> +#include <dm/device-internal.h> +#include <asm/arch/uart.h> + +/* Low-power Subsystem (LPSS) clock register */ +enum { + LPSS_CLOCK_CTL_REG = 0x200, + LPSS_CNT_CLOCK_EN = 1, + LPSS_CNT_CLK_UPDATE = 1U << 31, + LPSS_CLOCK_DIV_N_SHIFT = 16, + LPSS_CLOCK_DIV_N_MASK = 0x7fff << LPSS_CLOCK_DIV_N_SHIFT, + LPSS_CLOCK_DIV_M_SHIFT = 1, + LPSS_CLOCK_DIV_M_MASK = 0x7fff << LPSS_CLOCK_DIV_M_SHIFT, + + /* These set the UART input clock speed */ + LPSS_UART_CLK_M_VAL = 0x25a, + LPSS_UART_CLK_N_VAL = 0x7fff, +}; + +static void lpss_clk_update(void *regs, u32 clk_m_val, u32 clk_n_val) +{ + u32 clk_sel; + + clk_sel = clk_n_val << LPSS_CLOCK_DIV_N_SHIFT | + clk_m_val << LPSS_CLOCK_DIV_M_SHIFT; + clk_sel |= LPSS_CNT_CLK_UPDATE | LPSS_CNT_CLOCK_EN; + + writel(clk_sel, regs + LPSS_CLOCK_CTL_REG); +} + +static void uart_lpss_init(void *regs) +{ + /* Take UART out of reset */ + lpss_reset_release(regs); + + /* Set M and N divisor inputs and enable clock */ + lpss_clk_update(regs, LPSS_UART_CLK_M_VAL, LPSS_UART_CLK_N_VAL); +} + +void apl_uart_init(pci_dev_t bdf, ulong base) +{ + /* Set UART base address */ + pci_x86_write_config(bdf, PCI_BASE_ADDRESS_0, base, PCI_SIZE_32); + + /* Enable memory access and bus master */ + pci_x86_write_config(bdf, PCI_COMMAND, PCI_COMMAND_MEMORY | + PCI_COMMAND_MASTER, PCI_SIZE_32); + + uart_lpss_init((void *)base); +} + +/* + * This driver uses its own compatible string but almost everything else from + * the standard ns16550 driver. This allows us to provide an of-platdata + * implementation, since the platdata produced by of-platdata does not match + * struct apl_ns16550_plat. + * + * When running with of-platdata (generally TPL), the platdata is converted to + * something that ns16550 expects. When running withoutof-platdata (SPL, U-Boot + * proper), we use ns16550's of_to_plat routine. + */ + +static int apl_ns16550_probe(struct udevice *dev) +{ + struct apl_ns16550_plat *plat = dev_get_plat(dev); + + if (!CONFIG_IS_ENABLED(PCI)) + apl_uart_init(plat->ns16550.bdf, plat->ns16550.base); + + return ns16550_serial_probe(dev); +} + +static int apl_ns16550_of_to_plat(struct udevice *dev) +{ +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_intel_apl_ns16550 *dtplat; + struct apl_ns16550_plat *plat = dev_get_plat(dev); + struct ns16550_plat ns; + + /* + * The device's plat uses struct apl_ns16550_plat which starts with the + * dtd struct, but the ns16550 driver expects it to be struct ns16550. + * Set up what that driver expects. Note that this means that the values + * cannot be read in this driver when using of-platdata. + * + * TODO(sjg@chromium.org): Consider having a separate plat pointer for + * of-platdata so that it is not necessary to overwrite this. + */ + dtplat = &plat->dtplat; + ns.base = dtplat->early_regs[0]; + ns.reg_width = 1; + ns.reg_shift = dtplat->reg_shift; + ns.reg_offset = 0; + ns.clock = dtplat->clock_frequency; + ns.fcr = UART_FCR_DEFVAL; + ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]); + memcpy(plat, &ns, sizeof(ns)); +#else + int ret; + + ret = ns16550_serial_of_to_plat(dev); + if (ret) + return ret; +#endif /* OF_PLATDATA */ + + return 0; +} + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) +static const struct udevice_id apl_ns16550_serial_ids[] = { + { .compatible = "intel,apl-ns16550" }, + { }, +}; +#endif + +U_BOOT_DRIVER(intel_apl_ns16550) = { + .name = "intel_apl_ns16550", + .id = UCLASS_SERIAL, + .of_match = of_match_ptr(apl_ns16550_serial_ids), + .plat_auto = sizeof(struct apl_ns16550_plat), + .priv_auto = sizeof(struct ns16550), + .ops = &ns16550_serial_ops, + .of_to_plat = apl_ns16550_of_to_plat, + .probe = apl_ns16550_probe, +}; |