| 1 |
|
| 2 |
|
| 3 |
#include <assert.h> |
| 4 |
#include <commonlib/sort.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <delay.h> |
| 7 |
#include <device/device.h> |
| 8 |
#include <device/pci.h> |
| 9 |
#include <device/pci_ids.h> |
| 10 |
#include <intelblocks/cfg.h> |
| 11 |
#include <intelblocks/cpulib.h> |
| 12 |
#include <intelblocks/p2sb.h> |
| 13 |
#include <intelpch/lockdown.h> |
| 14 |
#include <soc/chip_common.h> |
| 15 |
#include <soc/pch_pci_devs.h> |
| 16 |
#include <soc/pci_devs.h> |
| 17 |
#include <soc/msr.h> |
| 18 |
#include <soc/soc_util.h> |
| 19 |
#include <soc/util.h> |
| 20 |
#include <timer.h> |
| 21 |
|
| 22 |
msr_t read_msr_ppin(void) |
| 23 |
{ |
| 24 |
msr_t ppin = {0}; |
| 25 |
msr_t msr; |
| 26 |
|
| 27 |
|
| 28 |
msr = rdmsr(MSR_PLATFORM_INFO); |
| 29 |
if ((msr.lo & MSR_PPIN_CAP) == 0) { |
| 30 |
printk(BIOS_ERR, "MSR_PPIN_CAP is 0, PPIN is not supported\n"); |
| 31 |
return ppin; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
msr = rdmsr(MSR_PPIN_CTL); |
| 36 |
if (msr.lo & MSR_PPIN_CTL_LOCK) { |
| 37 |
printk(BIOS_ERR, "MSR_PPIN_CTL_LOCK is 1, PPIN access is not allowed\n"); |
| 38 |
return ppin; |
| 39 |
} |
| 40 |
|
| 41 |
if ((msr.lo & MSR_PPIN_CTL_ENABLE) == 0) { |
| 42 |
|
| 43 |
msr.lo |= MSR_PPIN_CTL_ENABLE; |
| 44 |
wrmsr(MSR_PPIN_CTL, msr); |
| 45 |
} |
| 46 |
ppin = rdmsr(MSR_PPIN); |
| 47 |
return ppin; |
| 48 |
} |
| 49 |
|
| 50 |
static unsigned int get_threads_per_package(void) |
| 51 |
{ |
| 52 |
unsigned int core_count, thread_count; |
| 53 |
cpu_read_topology(&core_count, &thread_count); |
| 54 |
return thread_count; |
| 55 |
} |
| 56 |
|
| 57 |
int get_platform_thread_count(void) |
| 58 |
{ |
| 59 |
return soc_get_num_cpus() * get_threads_per_package(); |
| 60 |
} |
| 61 |
|
| 62 |
const IIO_UDS *get_iio_uds(void) |
| 63 |
{ |
| 64 |
size_t hob_size; |
| 65 |
static const IIO_UDS *hob; |
| 66 |
const uint8_t fsp_hob_iio_universal_data_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID; |
| 67 |
|
| 68 |
if (hob) |
| 69 |
return hob; |
| 70 |
|
| 71 |
hob = fsp_find_extension_hob_by_guid(fsp_hob_iio_universal_data_guid, &hob_size); |
| 72 |
assert(hob && hob_size != 0); |
| 73 |
return hob; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
bool soc_cpu_is_enabled(const size_t idx) |
| 81 |
{ |
| 82 |
const IIO_UDS *hob = get_iio_uds(); |
| 83 |
assert(idx < CONFIG_MAX_SOCKET); |
| 84 |
|
| 85 |
return hob->PlatformData.IIO_resource[idx].Valid; |
| 86 |
} |
| 87 |
|
| 88 |
unsigned int soc_get_num_cpus(void) |
| 89 |
{ |
| 90 |
return get_iio_uds()->SystemStatus.numCpus; |
| 91 |
} |
| 92 |
|
| 93 |
unsigned int smbios_soc_get_max_sockets(void) |
| 94 |
{ |
| 95 |
return soc_get_num_cpus(); |
| 96 |
} |
| 97 |
|
| 98 |
union p2sb_bdf soc_get_hpet_bdf(void) |
| 99 |
{ |
| 100 |
if (CONFIG(SOC_INTEL_COMMON_IBL_BASE)) { |
| 101 |
union p2sb_bdf bdf = { |
| 102 |
.bus = HPET_BUS_NUM, |
| 103 |
.dev = HPET_DEV_NUM, |
| 104 |
.fn = HPET0_FUNC_NUM |
| 105 |
}; |
| 106 |
return bdf; |
| 107 |
} |
| 108 |
return p2sb_get_hpet_bdf(); |
| 109 |
} |
| 110 |
|
| 111 |
union p2sb_bdf soc_get_ioapic_bdf(void) |
| 112 |
{ |
| 113 |
if (CONFIG(SOC_INTEL_COMMON_IBL_BASE)) { |
| 114 |
union p2sb_bdf bdf = { |
| 115 |
.bus = PCH_IOAPIC_BUS_NUMBER, |
| 116 |
.dev = PCH_IOAPIC_DEV_NUM, |
| 117 |
.fn = PCH_IOAPIC_FUNC_NUM |
| 118 |
}; |
| 119 |
return bdf; |
| 120 |
} |
| 121 |
return p2sb_get_ioapic_bdf(); |
| 122 |
} |