1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <intelblocks/cpulib.h>
7 #include <soc/pci_devs.h>
8 #include <soc/soc_util.h>
10 #include <pc80/mc146818rtc.h>
12 const struct SystemMemoryMapHob
*get_system_memory_map(void)
15 const uint8_t mem_hob_guid
[16] = FSP_SYSTEM_MEMORYMAP_HOB_GUID
;
16 const struct SystemMemoryMapHob
**memmap_addr
;
18 memmap_addr
= (const struct SystemMemoryMapHob
**)
19 fsp_find_extension_hob_by_guid(mem_hob_guid
, &hob_size
);
20 /* hob_size is the size of the 8-byte address not the hob data */
21 assert(memmap_addr
&& hob_size
!= 0);
22 /* assert the pointer to the hob is not NULL */
28 bool is_pcie_iio_stack_res(const STACK_RES
*res
)
30 return res
->Personality
== TYPE_UBOX_IIO
;
33 bool is_ubox_stack_res(const STACK_RES
*res
)
35 return res
->Personality
== TYPE_UBOX
;
38 /* Returns the UBOX(stack) bus number when called from socket0 */
39 uint8_t socket0_get_ubox_busno(const uint8_t stack
)
41 if (stack
>= MAX_IIO_STACK
) {
42 printk(BIOS_ERR
, "%s: Stack %u does not exist!\n", __func__
, stack
);
45 const pci_devfn_t dev
= PCI_DEV(UBOX_DECS_BUS
, UBOX_DECS_DEV
, UBOX_DECS_FUNC
);
46 const uint16_t offset
= stack
/ 4 ? UBOX_DECS_CPUBUSNO1_CSR
: UBOX_DECS_CPUBUSNO_CSR
;
47 return pci_io_read_config32(dev
, offset
) >> (8 * (stack
% 4)) & 0xff;
52 * Ports Stack Stack(HOB) IioConfigIou
53 * ==========================================
54 * 0 CSTACK stack 0 IOU0
55 * 1A..1D PSTACKZ stack 1 IOU1
56 * 2A..2D PSTACK1 stack 2 IOU2
57 * 3A..3D PSTACK2 stack 4 IOU3
59 int soc_get_stack_for_port(int port
)
63 else if (port
>= PORT_1A
&& port
<= PORT_1D
)
65 else if (port
>= PORT_2A
&& port
<= PORT_2D
)
67 else if (port
>= PORT_3A
&& port
<= PORT_3D
)
73 uint8_t soc_get_iio_ioapicid(int socket
, int stack
)
75 uint8_t ioapic_id
= socket
? 0xf : 0x9;
94 void soc_set_mrc_cold_boot_flag(bool cold_boot_required
)
96 uint8_t mrc_status
= cmos_read(CMOS_OFFSET_MRC_STATUS
);
97 uint8_t new_mrc_status
= (mrc_status
& 0xfe) | cold_boot_required
;
98 printk(BIOS_SPEW
, "MRC status: 0x%02x want 0x%02x\n", mrc_status
, new_mrc_status
);
99 if (new_mrc_status
!= mrc_status
) {
100 cmos_write(new_mrc_status
, CMOS_OFFSET_MRC_STATUS
);
104 void get_iiostack_info(struct iiostack_resource
*info
)
106 const IIO_UDS
*hob
= get_iio_uds();
108 // copy IIO Stack info from FSP HOB
109 info
->no_of_stacks
= 0;
110 for (int socket
= 0, iio
= 0; iio
< hob
->PlatformData
.numofIIO
; ++socket
) {
111 if (!soc_cpu_is_enabled(socket
))
114 for (int x
= 0; x
< MAX_IIO_STACK
; ++x
) {
116 ri
= &hob
->PlatformData
.IIO_resource
[socket
].StackRes
[x
];
117 if (!is_pcie_iio_stack_res(ri
))
119 assert(info
->no_of_stacks
< (CONFIG_MAX_SOCKET
* MAX_IIO_STACK
));
120 memcpy(&info
->res
[info
->no_of_stacks
++], ri
, sizeof(STACK_RES
));
125 bool is_memtype_reserved(uint16_t mem_type
)
127 return !!(mem_type
& MEM_TYPE_RESERVED
);
130 bool is_memtype_non_volatile(uint16_t mem_type
)
132 return !(mem_type
& MEMTYPE_VOLATILE_MASK
);
135 bool is_memtype_processor_attached(uint16_t mem_type
)
140 uint8_t get_cxl_node_count(void)
145 bool get_mmio_high_base_size(resource_t
*base
, resource_t
*size
)