1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #include <console/console.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
7 #include <hob_iiouds.h>
8 #include <intelblocks/cpulib.h>
9 #include <intelblocks/pcr.h>
10 #include <soc/iomap.h>
12 #include <soc/pci_devs.h>
13 #include <soc/pcr_ids.h>
14 #include <soc/soc_util.h>
19 * +-------------------------+ TOLM
20 * | System Management Mode |
23 * +-------------------------+ SMM base (aligned)
25 * | Chipset Reserved Memory |
27 * +-------------------------+ top_of_ram (aligned)
31 * +-------------------------+
33 * | FSP Reserved Memory |
35 * +-------------------------+
37 * | Various CBMEM Entries |
39 * +-------------------------+ top_of_stack (8 byte aligned)
41 * | stack (CBMEM Entry) |
43 * +-------------------------+
46 const struct SystemMemoryMapHob
*get_system_memory_map(void)
49 const uint8_t mem_hob_guid
[16] = FSP_SYSTEM_MEMORYMAP_HOB_GUID
;
50 const struct SystemMemoryMapHob
*memmap_addr
;
52 memmap_addr
= fsp_find_extension_hob_by_guid(mem_hob_guid
, &hob_size
);
53 assert(memmap_addr
&& hob_size
!= 0);
58 bool is_pcie_iio_stack_res(const STACK_RES
*res
)
60 return res
->BusBase
< res
->BusLimit
;
63 bool is_ubox_stack_res(const STACK_RES
*res
)
66 * Unlike on later platforms there's no separate "UBOX" stack.
68 * The UBOX devices can always be found on the first bus on the stack IIO0 (CSTACK).
69 * This bus is also referred to as uncore bus 0 or B(30).
70 * It has at a fixed address the UBOX:
75 * The PCU devices can always be on the first bus of the stack IIO1 (PSTACK).
76 * This bus is also referred to as uncore bus 1 or B(31).
77 * It has at a fixed address the PCU:
78 * B(31):30.0 8086:2080
79 * B(31):30.1 8086:2081
80 * B(31):30.2 8086:2082
86 /* Returns the UBOX(stack) bus number when called from socket0 */
87 uint8_t socket0_get_ubox_busno(const uint8_t stack
)
89 if (stack
>= MAX_IIO_STACK
) {
90 printk(BIOS_ERR
, "%s: Stack %u does not exist!\n", __func__
, stack
);
93 const pci_devfn_t dev
= PCI_DEV(UBOX_DECS_BUS
, UBOX_DECS_DEV
, UBOX_DECS_FUNC
);
94 const uint16_t offset
= stack
/ 4 ? UBOX_DECS_CPUBUSNO1_CSR
: UBOX_DECS_CPUBUSNO_CSR
;
95 return pci_io_read_config32(dev
, offset
) >> (8 * (stack
% 4)) & 0xff;
99 void config_reset_cpl3_csrs(void)
101 uint32_t data
, plat_info
, max_min_turbo_limit_ratio
;
105 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR0_DEVID
, dev
))) {
106 data
= pci_read_config32(dev
, PCU_CR0_P_STATE_LIMITS
);
107 data
|= P_STATE_LIMITS_LOCK
;
108 pci_write_config32(dev
, PCU_CR0_P_STATE_LIMITS
, data
);
110 plat_info
= pci_read_config32(dev
, PCU_CR0_PLATFORM_INFO
);
111 dump_csr64(dev
, PCU_CR0_PLATFORM_INFO
);
112 max_min_turbo_limit_ratio
=
113 (plat_info
& MAX_NON_TURBO_LIM_RATIO_MASK
) >>
114 MAX_NON_TURBO_LIM_RATIO_SHIFT
;
115 printk(BIOS_SPEW
, "plat_info: 0x%x, max_min_turbo_limit_ratio: 0x%x\n",
116 plat_info
, max_min_turbo_limit_ratio
);
120 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR1_DEVID
, dev
))) {
121 data
= pci_read_config32(dev
, PCU_CR1_SAPMCTL
);
122 /* clear bits 27:31 - FSP sets this with 0x7 which needs to be cleared */
124 data
|= SAPMCTL_LOCK_MASK
;
125 pci_write_config32(dev
, PCU_CR1_SAPMCTL
, data
);
129 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR2_DEVID
, dev
))) {
130 data
= PCIE_IN_PKGCSTATE_L1_MASK
;
131 pci_write_config32(dev
, PCU_CR2_PKG_CST_ENTRY_CRITERIA_MASK
, data
);
133 data
= KTI_IN_PKGCSTATE_L1_MASK
;
134 pci_write_config32(dev
, PCU_CR2_PKG_CST_ENTRY_CRITERIA_MASK2
, data
);
136 data
= PROCHOT_RATIO
;
137 printk(BIOS_SPEW
, "PCU_CR2_PROCHOT_RESPONSE_RATIO_REG data: 0x%x\n", data
);
138 pci_write_config32(dev
, PCU_CR2_PROCHOT_RESPONSE_RATIO_REG
, data
);
139 dump_csr(dev
, PCU_CR2_PROCHOT_RESPONSE_RATIO_REG
);
141 data
= pci_read_config32(dev
, PCU_CR2_DYNAMIC_PERF_POWER_CTL
);
142 data
|= UNOCRE_PLIMIT_OVERRIDE_SHIFT
;
143 pci_write_config32(dev
, PCU_CR2_DYNAMIC_PERF_POWER_CTL
, data
);
150 * Ports Stack Stack(HOB) IioConfigIou
151 * ==========================================
152 * 0 CSTACK stack 0 IOU0
153 * 1A..1D PSTACKZ stack 1 IOU1
154 * 2A..2D PSTACK1 stack 2 IOU2
155 * 3A..3D PSTACK2 stack 3 IOU3
156 * 5A..4D PSTACK3 stack 4 IOU4
157 * 5A..5D PSTACK4 stack 5 IOU5
159 int soc_get_stack_for_port(int port
)
163 else if (port
>= PORT_1A
&& port
<= PORT_1D
)
165 else if (port
>= PORT_2A
&& port
<= PORT_2D
)
167 else if (port
>= PORT_3A
&& port
<= PORT_3D
)
169 else if (port
>= PORT_4A
&& port
<= PORT_4D
)
170 return PSTACK3
; // MCP0
171 else if (port
>= PORT_5A
&& port
<= PORT_5D
)
172 return PSTACK4
; // MCP1
177 uint8_t soc_get_iio_ioapicid(int socket
, int stack
)
179 uint8_t ioapic_id
= socket
? 0xf : 0x9;
198 bool is_memtype_reserved(uint16_t mem_type
)
200 return !!(mem_type
& MEM_TYPE_RESERVED
);
203 bool is_memtype_non_volatile(uint16_t mem_type
)
205 return !(mem_type
& MEMTYPE_VOLATILE_MASK
);
208 bool is_memtype_processor_attached(uint16_t mem_type
)
213 uint8_t get_cxl_node_count(void)
218 bool get_mmio_high_base_size(resource_t
*base
, resource_t
*size
)