mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 10:26:10 +01:00 
			
		
		
		
	x86: Add a few common Intel CPU functions
Add functions to query CPU information, needed for ACPI. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		| @@ -12,6 +12,7 @@ | ||||
| #include <dm.h> | ||||
| #include <errno.h> | ||||
| #include <log.h> | ||||
| #include <acpi/acpigen.h> | ||||
| #include <asm/cpu.h> | ||||
| #include <asm/cpu_common.h> | ||||
| #include <asm/intel_regs.h> | ||||
| @@ -227,3 +228,66 @@ void cpu_set_eist(bool eist_status) | ||||
| 		msr.lo &= ~MISC_ENABLE_ENHANCED_SPEEDSTEP; | ||||
| 	msr_write(MSR_IA32_MISC_ENABLE, msr); | ||||
| } | ||||
|  | ||||
| int cpu_get_coord_type(void) | ||||
| { | ||||
| 	return HW_ALL; | ||||
| } | ||||
|  | ||||
| int cpu_get_min_ratio(void) | ||||
| { | ||||
| 	msr_t msr; | ||||
|  | ||||
| 	/* Get bus ratio limits and calculate clock speeds */ | ||||
| 	msr = msr_read(MSR_PLATFORM_INFO); | ||||
|  | ||||
| 	return (msr.hi >> 8) & 0xff;	/* Max Efficiency Ratio */ | ||||
| } | ||||
|  | ||||
| int cpu_get_max_ratio(void) | ||||
| { | ||||
| 	u32 ratio_max; | ||||
| 	msr_t msr; | ||||
|  | ||||
| 	if (cpu_config_tdp_levels()) { | ||||
| 		/* Set max ratio to nominal TDP ratio */ | ||||
| 		msr = msr_read(MSR_CONFIG_TDP_NOMINAL); | ||||
| 		ratio_max = msr.lo & 0xff; | ||||
| 	} else { | ||||
| 		msr = msr_read(MSR_PLATFORM_INFO); | ||||
| 		/* Max Non-Turbo Ratio */ | ||||
| 		ratio_max = (msr.lo >> 8) & 0xff; | ||||
| 	} | ||||
|  | ||||
| 	return ratio_max; | ||||
| } | ||||
|  | ||||
| int cpu_get_bus_clock_khz(void) | ||||
| { | ||||
| 	/* | ||||
| 	 * CPU bus clock is set by default here to 100MHz. This function returns | ||||
| 	 * the bus clock in KHz. | ||||
| 	 */ | ||||
| 	return INTEL_BCLK_MHZ * 1000; | ||||
| } | ||||
|  | ||||
| int cpu_get_power_max(void) | ||||
| { | ||||
| 	int power_unit; | ||||
| 	msr_t msr; | ||||
|  | ||||
| 	msr = msr_read(MSR_PKG_POWER_SKU_UNIT); | ||||
| 	power_unit = 2 << ((msr.lo & 0xf) - 1); | ||||
| 	msr = msr_read(MSR_PKG_POWER_SKU); | ||||
|  | ||||
| 	return (msr.lo & 0x7fff) * 1000 / power_unit; | ||||
| } | ||||
|  | ||||
| int cpu_get_max_turbo_ratio(void) | ||||
| { | ||||
| 	msr_t msr; | ||||
|  | ||||
| 	msr = msr_read(MSR_TURBO_RATIO_LIMIT); | ||||
|  | ||||
| 	return msr.lo & 0xff; | ||||
| } | ||||
|   | ||||
| @@ -128,4 +128,53 @@ void cpu_set_eist(bool eist_status); | ||||
|  */ | ||||
| void cpu_set_p_state_to_turbo_ratio(void); | ||||
|  | ||||
| /** | ||||
|  * cpu_get_coord_type() - Get the type of coordination for P-State transition | ||||
|  * | ||||
|  * See ACPI spec v6.3 section 8.4.6.5 _PSD (P-State Dependency) | ||||
|  * | ||||
|  * @return HW_ALL (always) | ||||
|  */ | ||||
| int cpu_get_coord_type(void); | ||||
|  | ||||
| /** | ||||
|  * cpu_get_min_ratio() - get minimum support frequency ratio for CPU | ||||
|  * | ||||
|  * @return minimum ratio | ||||
|  */ | ||||
| int cpu_get_min_ratio(void); | ||||
|  | ||||
| /** | ||||
|  * cpu_get_max_ratio() - get nominal TDP ration or max non-turbo ratio | ||||
|  * | ||||
|  * If a nominal TDP ratio is available, it is returned. Otherwise this returns | ||||
|  * the  maximum non-turbo frequency ratio for this processor | ||||
|  * | ||||
|  * @return max ratio | ||||
|  */ | ||||
| int cpu_get_max_ratio(void); | ||||
|  | ||||
| /** | ||||
|  * cpu_get_bus_clock_khz() - Get the bus clock frequency in KHz | ||||
|  * | ||||
|  * This is the value the clock ratio is multiplied with | ||||
|  * | ||||
|  * @return bus-block frequency in KHz | ||||
|  */ | ||||
| int cpu_get_bus_clock_khz(void); | ||||
|  | ||||
| /** | ||||
|  * cpu_get_power_max() - Get maximum CPU TDP | ||||
|  * | ||||
|  * @return maximum CPU TDP (Thermal-design power) in mW | ||||
|  */ | ||||
| int cpu_get_power_max(void); | ||||
|  | ||||
| /** | ||||
|  * cpu_get_max_turbo_ratio() - Get maximum turbo ratio | ||||
|  * | ||||
|  * @return maximum ratio | ||||
|  */ | ||||
| int cpu_get_max_turbo_ratio(void); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -73,6 +73,18 @@ enum { | ||||
| 	RETURN_OP		= 0xa4, | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * enum psd_coord - Coordination types for P-states | ||||
|  * | ||||
|  * The type of coordination that exists (hardware) or is required (software) as | ||||
|  * a result of the underlying hardware dependency | ||||
|  */ | ||||
| enum psd_coord { | ||||
| 	SW_ALL = 0xfc, | ||||
| 	SW_ANY = 0xfd, | ||||
| 	HW_ALL = 0xfe | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * acpigen_get_current() - Get the current ACPI code output pointer | ||||
|  * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user