<p>Shaunak Saha has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21051">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">soc/intel/common/block: Add functions to common CPU library code<br><br>This patch adds few helper functions in CPU common libraray code<br>which are mainly needed for ACPI module.<br><br>TEST= System boots properly and no regression observed.<br><br>Change-Id: Id34eb7e03069656238ca0cbdf6ce33f116e0e413<br>Signed-off-by: Shaunak Saha <shaunak.saha@intel.com><br>---<br>M src/soc/intel/common/block/cpu/cpulib.c<br>M src/soc/intel/common/block/include/intelblocks/cpulib.h<br>2 files changed, 98 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/21051/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/soc/intel/common/block/cpu/cpulib.c b/src/soc/intel/common/block/cpu/cpulib.c<br>index 5920512..97629b9 100644<br>--- a/src/soc/intel/common/block/cpu/cpulib.c<br>+++ b/src/soc/intel/common/block/cpu/cpulib.c<br>@@ -14,6 +14,7 @@<br> * GNU General Public License for more details.<br> */<br> <br>+#include <arch/acpigen.h><br> #include <arch/io.h><br> #include <console/console.h><br> #include <cpu/intel/turbo.h><br>@@ -238,5 +239,66 @@<br> msr = rdmsr(MSR_CORE_THREAD_COUNT);<br> *num_virt = (msr.lo >> 0) & 0xffff;<br> *num_phys = (msr.lo >> 16) & 0xffff;<br>- return (*num_virt == *num_phys);<br>+ return (*num_virt == *num_phys);<br>+}<br>+<br>+__attribute__ ((weak))<br>+int cpu_get_coord_type(void)<br>+{<br>+ return HW_ALL;<br>+}<br>+<br>+__attribute__ ((weak))<br>+uint32_t cpu_get_min_ratio(void)<br>+{<br>+ msr_t msr;<br>+ /* Get bus ratio limits and calculate clock speeds */<br>+ msr = rdmsr(MSR_PLATFORM_INFO);<br>+ return ((msr.hi >> 8) & 0xff); /* Max Efficiency Ratio */<br>+}<br>+<br>+__attribute__ ((weak))<br>+uint32_t cpu_get_max_ratio(void)<br>+{<br>+ msr_t msr;<br>+ uint32_t ratio_max;<br>+ if (cpu_config_tdp_levels()) {<br>+ /* Set max ratio to nominal TDP ratio */<br>+ msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);<br>+ ratio_max = msr.lo & 0xff;<br>+ } else {<br>+ msr = rdmsr(MSR_PLATFORM_INFO);<br>+ /* Max Non-Turbo Ratio */<br>+ ratio_max = (msr.lo >> 8) & 0xff;<br>+ }<br>+ return ratio_max;<br>+}<br>+<br>+__attribute__ ((weak))<br>+uint32_t cpu_get_bus_clock(void)<br>+{<br>+ /* CPU bus clock is set by default here to 100MHz.<br>+ * This function returns the bus clock in KHz.<br>+ */<br>+ return CONFIG_CPU_BCLK_MHZ * KHz;<br>+}<br>+<br>+__attribute__ ((weak))<br>+uint32_t cpu_get_power_max(void)<br>+{<br>+ msr_t msr;<br>+ int power_unit;<br>+<br>+ msr = rdmsr(MSR_PKG_POWER_SKU_UNIT);<br>+ power_unit = 2 << ((msr.lo & 0xf) - 1);<br>+ msr = rdmsr(MSR_PKG_POWER_SKU);<br>+ return ((msr.lo & 0x7fff) / power_unit) * 1000;<br>+}<br>+<br>+__attribute__ ((weak))<br>+uint32_t cpu_get_max_turbo_ratio(void)<br>+{<br>+ msr_t msr;<br>+ msr = rdmsr(MSR_TURBO_RATIO_LIMIT);<br>+ return msr.lo & 0xff;<br> }<br>diff --git a/src/soc/intel/common/block/include/intelblocks/cpulib.h b/src/soc/intel/common/block/include/intelblocks/cpulib.h<br>index f414521..3d40a92 100644<br>--- a/src/soc/intel/common/block/include/intelblocks/cpulib.h<br>+++ b/src/soc/intel/common/block/include/intelblocks/cpulib.h<br>@@ -121,4 +121,39 @@<br> */<br> int cpu_read_topology(unsigned int *num_phys, unsigned int *num_virt);<br> <br>+/*<br>+ * cpu_get_bus_clock returns the bus clock frequency in KHz.<br>+ * This is the value the clock ratio is multiplied with.<br>+ */<br>+uint32_t cpu_get_bus_clock(void);<br>+<br>+/*<br>+ * cpu_get_coord_type returns coordination type (SW_ANY or SW_ALL or HW_ALL)<br>+ * which is used to populate _PSD object.<br>+ */<br>+int cpu_get_coord_type(void);<br>+<br>+/*<br>+ * cpu_get_min_ratio returns the minimum frequency ratio that is supported<br>+ * by this processor<br>+ */<br>+uint32_t cpu_get_min_ratio(void);<br>+<br>+/*<br>+ * cpu_get_max_ratio returns the nominal TDP ratio if available or the<br>+ * maximum non turbo frequency ratio for this processor<br>+ */<br>+uint32_t cpu_get_max_ratio(void);<br>+<br>+/*<br>+ * cpu_get_power_max calculates CPU TDP in mW<br>+ */<br>+uint32_t cpu_get_power_max(void);<br>+<br>+/*<br>+ * cpu_get_max_turbo_ratio returns the maximum turbo ratio limit for the<br>+ * processor<br>+ */<br>+uint32_t cpu_get_max_turbo_ratio(void);<br>+<br> #endif /* SOC_INTEL_COMMON_BLOCK_CPULIB_H */<br></pre><p>To view, visit <a href="https://review.coreboot.org/21051">change 21051</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21051"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Id34eb7e03069656238ca0cbdf6ce33f116e0e413 </div>
<div style="display:none"> Gerrit-Change-Number: 21051 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Shaunak Saha <shaunak.saha@intel.com> </div>