summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/intel/common/block/include/intelblocks/pmclib.h4
-rw-r--r--src/soc/intel/common/block/pmc/pmclib.c21
2 files changed, 20 insertions, 5 deletions
diff --git a/src/soc/intel/common/block/include/intelblocks/pmclib.h b/src/soc/intel/common/block/include/intelblocks/pmclib.h
index a54ae18a8c..4972a09f8b 100644
--- a/src/soc/intel/common/block/include/intelblocks/pmclib.h
+++ b/src/soc/intel/common/block/include/intelblocks/pmclib.h
@@ -7,19 +7,19 @@
#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.
+ * @XTAL_UNKNOWN_FREQ: Unsupported external crystal.
*/
enum pch_pmc_xtal {
XTAL_24_MHZ,
XTAL_19_2_MHZ,
XTAL_38_4_MHZ,
+ XTAL_UNKNOWN_FREQ = 0xf,
};
/*
diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c
index 64c25ff5fe..81d25e02a0 100644
--- a/src/soc/intel/common/block/pmc/pmclib.c
+++ b/src/soc/intel/common/block/pmc/pmclib.c
@@ -732,7 +732,22 @@ 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)));
+ uint32_t xtal_freq = 0;
+ const uint32_t epoc = read32p(soc_read_pmc_base() + PCH_PMC_EPOC);
+
+ /* XTAL frequency in bits 21, 20, 17 */
+ xtal_freq |= !!(epoc & (1 << 21)) << 2;
+ xtal_freq |= !!(epoc & (1 << 20)) << 1;
+ xtal_freq |= !!(epoc & (1 << 17)) << 0;
+ switch (xtal_freq) {
+ case 0:
+ return XTAL_24_MHZ;
+ case 1:
+ return XTAL_19_2_MHZ;
+ case 2:
+ return XTAL_38_4_MHZ;
+ default:
+ printk(BIOS_ERR, "Unknown EPOC XTAL frequency setting %u\n", xtal_freq);
+ return XTAL_UNKNOWN_FREQ;
+ }
}