diff options
author | Lean Sheng Tan <lean.sheng.tan@intel.com> | 2021-06-16 01:32:22 -0700 |
---|---|---|
committer | Werner Zeh <werner.zeh@siemens.com> | 2021-06-30 07:34:44 +0000 |
commit | 508dc163f183f99f4683365ef3a6443658979846 (patch) | |
tree | 6dfa0d6bebb5ca26d96a9af547db8d9a5243b68f /src/soc/intel | |
parent | f1ade489c85c95c572ef907bdb3b7f4835c1a9c7 (diff) |
soc/intel/common: Move PMC EPOC related code to Intel common code
Move PMC EPOC related code to intel/common/block because it is
generic for most Intel platforms and ADL, TGL & EHL use it.
Add a kconfig 'PMC_EPOC' to guard this common EPOC code.
The PMC EPOC register indicates which external crystal oscillator is
connected to the PCH. This frequency is important for determining the
IP clock of internal PCH devices.
Signed-off-by: Lean Sheng Tan <lean.sheng.tan@intel.com>
Change-Id: Ib5fd3c4a648964678ee40ed0f60ca10fe7953f56
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55565
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/soc/intel')
-rw-r--r-- | src/soc/intel/alderlake/Kconfig | 1 | ||||
-rw-r--r-- | src/soc/intel/alderlake/include/soc/pmc.h | 24 | ||||
-rw-r--r-- | src/soc/intel/alderlake/pmc.c | 7 | ||||
-rw-r--r-- | src/soc/intel/alderlake/soundwire.c | 1 | ||||
-rw-r--r-- | src/soc/intel/common/block/include/intelblocks/pmclib.h | 22 | ||||
-rw-r--r-- | src/soc/intel/common/block/pmc/Kconfig | 6 | ||||
-rw-r--r-- | src/soc/intel/common/block/pmc/pmclib.c | 11 | ||||
-rw-r--r-- | src/soc/intel/tigerlake/Kconfig | 1 | ||||
-rw-r--r-- | src/soc/intel/tigerlake/include/soc/pmc.h | 24 | ||||
-rw-r--r-- | src/soc/intel/tigerlake/pmc.c | 7 | ||||
-rw-r--r-- | src/soc/intel/tigerlake/soundwire.c | 1 |
11 files changed, 41 insertions, 64 deletions
diff --git a/src/soc/intel/alderlake/Kconfig b/src/soc/intel/alderlake/Kconfig index eafd08dba6..b590dfaab7 100644 --- a/src/soc/intel/alderlake/Kconfig +++ b/src/soc/intel/alderlake/Kconfig @@ -43,6 +43,7 @@ config CPU_SPECIFIC_OPTIONS select REG_SCRIPT select PMC_GLOBAL_RESET_ENABLE_LOCK select PMC_LOW_POWER_MODE_PROGRAM + select PMC_EPOC select SOC_INTEL_COMMON select SOC_INTEL_COMMON_ACPI_WAKE_SOURCE select SOC_INTEL_COMMON_BLOCK diff --git a/src/soc/intel/alderlake/include/soc/pmc.h b/src/soc/intel/alderlake/include/soc/pmc.h index 289568fb6d..2c02a2d467 100644 --- a/src/soc/intel/alderlake/include/soc/pmc.h +++ b/src/soc/intel/alderlake/include/soc/pmc.h @@ -100,30 +100,6 @@ extern struct device_operations pmc_ops; #define PCH2CPU_TPR_CFG_LOCK (1 << 31) #define PCH2CPU_TT_EN (1 << 26) -#define PCH_PMC_EPOC 0x18EC -#define PCH_EPOC_2LM(__epoc) ((__epoc) & 0x1) -/* XTAL frequency in bits 21, 20, 17 */ -#define PCH_EPOC_XTAL_FREQ(__epoc) ((((__epoc) >> 19) & 0x6) | ((__epoc) >> 17 & 0x1)) - -/** - * enum pch_pmc_xtal - External crystal oscillator frequency. - * @XTAL_24_MHZ: 24 MHz external crystal. - * @XTAL_19_2_MHZ: 19.2 MHz external crystal. - * @XTAL_38_4_MHZ: 38.4 MHz external crystal. - */ -enum pch_pmc_xtal { - XTAL_24_MHZ, - XTAL_19_2_MHZ, - XTAL_38_4_MHZ, -}; - -/** - * pmc_get_xtal_freq() - Return frequency of external oscillator. - * - * Return &enum pch_pmc_xtal corresponding to frequency returned by PMC. - */ -enum pch_pmc_xtal pmc_get_xtal_freq(void); - #define PCH_PWRM_ACPI_TMR_CTL 0x18FC #define ACPI_TIM_DIS (1 << 1) #define GPIO_GPE_CFG 0x1920 diff --git a/src/soc/intel/alderlake/pmc.c b/src/soc/intel/alderlake/pmc.c index 6ee3ef10f1..dd88b1d461 100644 --- a/src/soc/intel/alderlake/pmc.c +++ b/src/soc/intel/alderlake/pmc.c @@ -23,13 +23,6 @@ #define PMC_HID "INTC1026" -enum pch_pmc_xtal pmc_get_xtal_freq(void) -{ - uint8_t *const pmcbase = pmc_mmio_regs(); - - return PCH_EPOC_XTAL_FREQ(read32(pmcbase + PCH_PMC_EPOC)); -} - static void config_deep_sX(uint32_t offset, uint32_t mask, int sx, int enable) { uint32_t reg; diff --git a/src/soc/intel/alderlake/soundwire.c b/src/soc/intel/alderlake/soundwire.c index c3ff05d2e3..1fbdb4418e 100644 --- a/src/soc/intel/alderlake/soundwire.c +++ b/src/soc/intel/alderlake/soundwire.c @@ -6,7 +6,6 @@ #include <device/soundwire.h> #include <drivers/intel/soundwire/soundwire.h> #include <intelblocks/pmclib.h> -#include <soc/pmc.h> #include <stddef.h> #include <string.h> diff --git a/src/soc/intel/common/block/include/intelblocks/pmclib.h b/src/soc/intel/common/block/include/intelblocks/pmclib.h index ecc8166fb8..a54ae18a8c 100644 --- a/src/soc/intel/common/block/include/intelblocks/pmclib.h +++ b/src/soc/intel/common/block/include/intelblocks/pmclib.h @@ -6,6 +6,28 @@ #include <device/pci_type.h> #include <types.h> +#define PCH_PMC_EPOC 0x18EC +/* XTAL frequency in bits 21, 20, 17 */ +#define PCH_EPOC_XTAL_FREQ(__epoc) ((((__epoc) >> 19) & 0x6) | ((__epoc) >> 17 & 0x1)) + +/** + * enum pch_pmc_xtal - External crystal oscillator frequency. + * @XTAL_24_MHZ: 24 MHz external crystal. + * @XTAL_19_2_MHZ: 19.2 MHz external crystal. + * @XTAL_38_4_MHZ: 38.4 MHz external crystal. + */ +enum pch_pmc_xtal { + XTAL_24_MHZ, + XTAL_19_2_MHZ, + XTAL_38_4_MHZ, +}; + +/* + * pmc_get_xtal_freq() - Return &enum pch_pmc_xtal corresponding to + * frequency of external oscillator. + */ +enum pch_pmc_xtal pmc_get_xtal_freq(void); + /* Forward declare the power state struct here */ struct chipset_power_state; diff --git a/src/soc/intel/common/block/pmc/Kconfig b/src/soc/intel/common/block/pmc/Kconfig index 8cd26350b7..503e465530 100644 --- a/src/soc/intel/common/block/pmc/Kconfig +++ b/src/soc/intel/common/block/pmc/Kconfig @@ -19,6 +19,12 @@ config SOC_INTEL_COMMON_BLOCK_PMC_DISCOVERABLE Select this on platforms where the PMC device is discoverable when scanning busses. +config PMC_EPOC + bool + help + Enable this for PMC devices to perform EPOC (CPU Early Power-on + Configuration) related functions. + endif # SOC_INTEL_COMMON_BLOCK_PMC config PMC_INVALID_READ_AFTER_WRITE diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c index a5f2dca550..64c25ff5fe 100644 --- a/src/soc/intel/common/block/pmc/pmclib.c +++ b/src/soc/intel/common/block/pmc/pmclib.c @@ -2,6 +2,7 @@ #include <acpi/acpi_pm.h> #include <arch/io.h> +#include <assert.h> #include <bootmode.h> #include <device/mmio.h> #include <cbmem.h> @@ -725,3 +726,13 @@ void pmc_set_acpi_mode(void) apm_control(APM_CNT_ACPI_DISABLE); } } + +enum pch_pmc_xtal pmc_get_xtal_freq(void) +{ + if (!CONFIG(PMC_EPOC)) + dead_code(); + + const uintptr_t pmcbase = soc_read_pmc_base(); + + return PCH_EPOC_XTAL_FREQ(read32((uint32_t *)(pmcbase + PCH_PMC_EPOC))); +} diff --git a/src/soc/intel/tigerlake/Kconfig b/src/soc/intel/tigerlake/Kconfig index 26da244203..7bc2ba2b0c 100644 --- a/src/soc/intel/tigerlake/Kconfig +++ b/src/soc/intel/tigerlake/Kconfig @@ -40,6 +40,7 @@ config CPU_SPECIFIC_OPTIONS select REG_SCRIPT select PMC_GLOBAL_RESET_ENABLE_LOCK select PMC_LOW_POWER_MODE_PROGRAM + select PMC_EPOC select SOC_INTEL_COMMON select SOC_INTEL_COMMON_ACPI_WAKE_SOURCE select SOC_INTEL_COMMON_BLOCK diff --git a/src/soc/intel/tigerlake/include/soc/pmc.h b/src/soc/intel/tigerlake/include/soc/pmc.h index 9674d496a1..9111ab4a44 100644 --- a/src/soc/intel/tigerlake/include/soc/pmc.h +++ b/src/soc/intel/tigerlake/include/soc/pmc.h @@ -101,30 +101,6 @@ extern struct device_operations pmc_ops; #define PCH2CPU_TPR_CFG_LOCK (1 << 31) #define PCH2CPU_TT_EN (1 << 26) -#define PCH_PMC_EPOC 0x18EC -#define PCH_EPOC_2LM(__epoc) ((__epoc) & 0x1) -/* XTAL frequency in bits 21, 20, 17 */ -#define PCH_EPOC_XTAL_FREQ(__epoc) ((((__epoc) >> 19) & 0x6) | ((__epoc) >> 17 & 0x1)) - -/** - * enum pch_pmc_xtal - External crystal oscillator frequency. - * @XTAL_24_MHZ: 24 MHz external crystal. - * @XTAL_19_2_MHZ: 19.2 MHz external crystal. - * @XTAL_38_4_MHZ: 38.4 MHz external crystal. - */ -enum pch_pmc_xtal { - XTAL_24_MHZ, - XTAL_19_2_MHZ, - XTAL_38_4_MHZ, -}; - -/** - * pmc_get_xtal_freq() - Return frequency of external oscillator. - * - * Return &enum pch_pmc_xtal corresponding to frequency returned by PMC. - */ -enum pch_pmc_xtal pmc_get_xtal_freq(void); - #define PCH_PWRM_ACPI_TMR_CTL 0x18FC #define ACPI_TIM_DIS (1 << 1) #define GPIO_GPE_CFG 0x1920 diff --git a/src/soc/intel/tigerlake/pmc.c b/src/soc/intel/tigerlake/pmc.c index 190f3ffddc..dd2b61b3c0 100644 --- a/src/soc/intel/tigerlake/pmc.c +++ b/src/soc/intel/tigerlake/pmc.c @@ -22,13 +22,6 @@ #define PMC_HID "INTC1026" -enum pch_pmc_xtal pmc_get_xtal_freq(void) -{ - uint8_t *const pmcbase = pmc_mmio_regs(); - - return PCH_EPOC_XTAL_FREQ(read32(pmcbase + PCH_PMC_EPOC)); -} - static void config_deep_sX(uint32_t offset, uint32_t mask, int sx, int enable) { uint32_t reg; diff --git a/src/soc/intel/tigerlake/soundwire.c b/src/soc/intel/tigerlake/soundwire.c index f69efce2f9..878ce1973c 100644 --- a/src/soc/intel/tigerlake/soundwire.c +++ b/src/soc/intel/tigerlake/soundwire.c @@ -6,7 +6,6 @@ #include <device/soundwire.h> #include <drivers/intel/soundwire/soundwire.h> #include <intelblocks/pmclib.h> -#include <soc/pmc.h> #include <string.h> static const struct soundwire_link link_xtal_38_4 = { |