10 #include <soc/pci_devs.h>
12 #include <soc/soc_util.h>
18 if (stack >= MAX_IIO_STACK) {
19 printk(
BIOS_ERR,
"%s: Stack %u does not exist!\n", __func__, stack);
29 uint32_t pam0123_unlock_dram = 0x33333330;
30 uint32_t pam456_unlock_dram = 0x00333333;
43 __FILE__, __func__, reg1, reg2);
61 printk(
BIOS_ERR,
"MSR_PPIN_CTL_LOCK is 1, PPIN access is not allowed\n");
79 unsigned int core_count, thread_count;
92 static const IIO_UDS *hob;
93 const uint8_t fsp_hob_iio_universal_data_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID;
108 info->no_of_stacks = 0;
109 for (
int s = 0;
s < hob->PlatformData.numofIIO; ++
s) {
110 for (
int x = 0;
x < MAX_IIO_STACK; ++
x) {
111 const STACK_RES *ri = &hob->PlatformData.IIO_resource[
s].StackRes[
x];
114 assert(
info->no_of_stacks < (CONFIG_MAX_SOCKET * MAX_IIO_STACK));
127 static void get_core_thread_bits(
uint32_t *core_bits,
uint32_t *thread_bits)
133 cpuid_regs =
cpuid(0);
134 assert(cpuid_regs.eax >= 0xb);
136 *thread_bits = *core_bits = 0;
141 *thread_bits = (cpuid_regs.eax & 0x1f);
143 *core_bits = (cpuid_regs.eax & 0x1f) - *thread_bits;
154 *
package = (apicid >> (thread_bits + core_bits));
156 *core = (
uint32_t)((apicid >> thread_bits) & ~((~0) << core_bits));
158 *thread = (
uint32_t)(apicid & ~((~0) << thread_bits));
164 int apic_ids[CONFIG_MAX_CPUS] = {0}, apic_ids_by_thread[CONFIG_MAX_CPUS] = {0};
167 unsigned int core_count, thread_count;
168 unsigned int num_sockets;
190 assert(num_apics == (num_sockets * thread_count));
194 for (
int id = 0;
id < num_apics; ++id) {
195 int apic_id = apic_ids[id];
197 apic_ids_by_thread[index + (num_apics/2) - 1] = apic_id;
199 apic_ids_by_thread[index++] = apic_id;
205 get_core_thread_bits(&core_bits, &thread_bits);
218 get_cpu_info_from_apicid(dev->
path.
apic.
apic_id, core_bits, thread_bits,
242 "mask: 0x%x, target: 0x%x\n", __func__, dev, reg,
mask, target);
257 printk(
BIOS_SPEW,
"%s - pci_s_write_config32 reg: 0x%x, data: 0x%x\n", __func__,
262 printk(
BIOS_SPEW,
"%s - pci_s_write_config32 reg: 0x%x, data: 0x%lx\n", __func__,
273 static bool set_bios_reset_cpl_for_package(
uint32_t socket,
uint32_t rst_cpl_mask,
291 static void set_bios_init_completion_for_package(
uint32_t socket)
304 die(
"BIOS PCU Misc Config Read timed out.\n");
312 die(
"BIOS PCU Misc Config Write timed out.\n");
316 timedout = set_bios_reset_cpl_for_package(socket,
RST_CPL3_MASK,
319 die(
"BIOS RESET CPL3 timed out.\n");
325 timedout = set_bios_reset_cpl_for_package(socket,
RST_CPL4_MASK,
328 die(
"BIOS RESET CPL4 timed out.\n");
333 printk(
BIOS_SPEW,
"%s - pci_s_write_config32 PCU_CR1_DESIRED_CORES_CFG2_REG 0x%x, data: 0x%x\n",
349 if (socket == sbsp_socket_id)
351 set_bios_init_completion_for_package(socket);
355 set_bios_init_completion_for_package(sbsp_socket_id);
static struct cpuid_result cpuid_ext(int op, unsigned int ecx)
void * memcpy(void *dest, const void *src, size_t n)
#define assert(statement)
#define printk(level,...)
void __noreturn die(const char *fmt,...)
int cpu_read_topology(unsigned int *num_phys, unsigned int *num_virt)
DEVTREE_CONST struct device *DEVTREE_CONST all_devices
Linked list of ALL devices.
static struct smmstore_params_info info
#define MSR_PLATFORM_INFO
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
static __always_inline msr_t rdmsr(unsigned int index)
static __always_inline void wrmsr(unsigned int index, msr_t msr)
static __always_inline void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
static int stopwatch_expired(struct stopwatch *sw)
static void stopwatch_init_msecs_expire(struct stopwatch *sw, long ms)
uint32_t get_socket_stack_busno(uint32_t socket, uint32_t stack)
bool is_iio_stack_res(const STACK_RES *res)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
@ DEVICE_PATH_CPU_CLUSTER
static __always_inline uint32_t pci_s_read_config32(pci_devfn_t dev, uint16_t reg)
static __always_inline uint32_t pci_io_read_config32(pci_devfn_t dev, uint16_t reg)
static __always_inline void pci_io_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value)
static __always_inline void pci_s_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value)
#define PCI_DEV(SEGBUS, DEV, FN)
#define PCODE_INIT_DONE3_MASK
#define PCU_CR1_BIOS_MB_DATA_REG
#define PCU_CR1_DESIRED_CORES_CFG2_REG_LOCK_MASK
#define BIOS_CMD_READ_PCU_MISC_CFG
#define PCODE_INIT_DONE4_MASK
#define SAD_ALL_PAM0123_CSR
#define PCU_CR1_BIOS_MB_INTERFACE_REG
#define SAD_ALL_PAM456_CSR
#define UBOX_DECS_CPUBUSNO_CSR
#define UBOX_DECS_CPUBUSNO1_CSR
#define PCU_CR1_DESIRED_CORES_CFG2_REG
#define BIOS_CMD_WRITE_PCU_MISC_CFG
#define PCU_CR1_BIOS_RESET_CPL_REG
#define BIOS_MB_RUN_BUSY_MASK
#define MSR_PPIN_CTL_ENABLE
#define MSR_PPIN_CTL_LOCK
void xeonsp_init_cpu_config(void)
void set_bios_init_completion(void)
int get_platform_thread_count(void)
static unsigned int get_threads_per_package(void)
msr_t read_msr_ppin(void)
void unlock_pam_regions(void)
void get_iiostack_info(struct iiostack_resource *info)
const IIO_UDS * get_iio_uds(void)
uint8_t get_stack_busno(const uint8_t stack)
unsigned int soc_get_num_cpus(void)
void bubblesort(int *v, size_t num_entries, sort_order_t order)
DEVTREE_CONST struct device * dev
enum device_path_type type
DEVTREE_CONST struct bus * bus
DEVTREE_CONST struct device * next
#define s(param, src_bits, pmcreg, dst_bits)