coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
systemagent.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef SOC_INTEL_COMMON_BLOCK_SA_H
4 #define SOC_INTEL_COMMON_BLOCK_SA_H
5 
6 #include <device/device.h>
7 #include <soc/iomap.h>
8 #include <soc/nvs.h>
9 #include <stddef.h>
10 
11 /* Device 0:0.0 PCI configuration space */
12 #define MCHBAR 0x48
13 #define PCIEXBAR 0x60
14 #define TOUUD 0xa8 /* Top of Upper Usable DRAM */
15 #define BDSM 0xb0 /* Base Data Stolen Memory */
16 #define BGSM 0xb4 /* Base GTT Stolen Memory */
17 #define TSEG 0xb8 /* TSEG base */
18 #define TOLUD 0xbc /* Top of Low Used Memory */
19 
20 /* MCHBAR */
21 #define MCHBAR8(x) (*(volatile u8 *)(uintptr_t)(MCH_BASE_ADDRESS + x))
22 #define MCHBAR16(x) (*(volatile u16 *)(uintptr_t)(MCH_BASE_ADDRESS + x))
23 #define MCHBAR32(x) (*(volatile u32 *)(uintptr_t)(MCH_BASE_ADDRESS + x))
24 #define MCHBAR64(x) (*(volatile u64 *)(uintptr_t)(MCH_BASE_ADDRESS + x))
25 
26 /* REGBAR */
27 #define REGBAR_OFFSET(pid, x) (REG_BASE_ADDRESS + ((pid) << 16) + (x))
28 #define REGBAR8(pid, x) (*(volatile u8 *)(uintptr_t)REGBAR_OFFSET(pid, x))
29 #define REGBAR16(pid, x) (*(volatile u16 *)(uintptr_t)REGBAR_OFFSET(pid, x))
30 #define REGBAR32(pid, x) (*(volatile u32 *)(uintptr_t)REGBAR_OFFSET(pid, x))
31 #define REGBAR64(pid, x) (*(volatile u64 *)(uintptr_t)REGBAR_OFFSET(pid, x))
32 
33 /* Perform System Agent Initialization during Bootblock phase */
35 
36 /*
37  * Fixed MMIO range
38  * INDEX = Either PCI configuration space registers or MMIO offsets
39  * mapped from REG.
40  * BASE = 64 bit Address.
41  * SIZE = 64 bit base length
42  * DESCRIPTION = Name of the register/offset.
43  */
45  unsigned int index;
48  const char *description;
49 };
50 
51 /* API to set Fixed MMIO address into PCI configuration space */
52 void sa_set_pci_bar(const struct sa_mmio_descriptor *fixed_set_resources,
53  size_t count);
54 /* API to set Fixed MMIO address into MCH base address */
55 void sa_set_mch_bar(const struct sa_mmio_descriptor *fixed_set_resources,
56  size_t count);
57 /*
58  * API to program fixed mmio resource range based on SoC input
59  * struct sa_mmio_descriptor
60  */
61 void sa_add_fixed_mmio_resources(struct device *dev, int *resource_cnt,
62  const struct sa_mmio_descriptor *sa_fixed_resources, size_t count);
63 /*
64  * API to set BIOS Reset CPL through MCHBAR
65  * SoC to provide BIOS_RESET_CPL register offset through soc/systemagent.h
66  */
67 void enable_bios_reset_cpl(void);
68 /* API to enable PAM registers */
69 void enable_pam_region(void);
70 /* API to enable Power Aware Interrupt Routing through MCHBAR */
71 void enable_power_aware_intr(void);
72 /* API to get TOLUD base address */
74 /* API to get GSM base address */
76 /* API to get TSEG base address */
78 /* API to get TSEG size */
79 size_t sa_get_tseg_size(void);
80 /* Fill MMIO resource above 4GB into GNVS */
81 void sa_fill_gnvs(struct global_nvs *gnvs);
82 /* API to lock PAM registers */
83 void sa_lock_pam(void);
84 
85 /*
86  * SoC overrides
87  *
88  * All new SoC must implement below functionality for ramstage.
89  */
90 
91 /* Perform System Agent Initialization during Ramstage phase */
92 void soc_systemagent_init(struct device *dev);
93 /*
94  * SoC call to provide all known fixed memory ranges for Device 0:0.0.
95  * SoC function should provide fixed resource ranges in form of
96  * struct sa_mmio_descriptor along with resource count.
97  */
98 void soc_add_fixed_mmio_resources(struct device *dev, int *resource_cnt);
99 
100 /* SoC specific APIs to get UNCORE PRMRR base and mask values
101  * returns 0, if able to get base and mask values; otherwise returns -1 */
103 
104 /* Returns the maximum supported capacity of a channel as encoded by DDRSZ in MiB */
106 
107 #endif /* SOC_INTEL_COMMON_BLOCK_SA_H */
void enable_bios_reset_cpl(void)
void sa_lock_pam(void)
Definition: systemagent.c:309
void sa_set_mch_bar(const struct sa_mmio_descriptor *fixed_set_resources, size_t count)
void enable_pam_region(void)
void soc_add_fixed_mmio_resources(struct device *dev, int *resource_cnt)
Definition: systemagent.c:25
uintptr_t sa_get_tseg_base(void)
size_t sa_get_tseg_size(void)
void sa_fill_gnvs(struct global_nvs *gnvs)
Definition: systemagent.c:140
void enable_power_aware_intr(void)
Definition: systemagent.c:298
void soc_systemagent_init(struct device *dev)
Definition: systemagent.c:53
int soc_get_uncore_prmmr_base_and_mask(uint64_t *base, uint64_t *mask)
Definition: systemagent.c:48
uintptr_t sa_get_tolud_base(void)
uintptr_t sa_get_gsm_base(void)
void sa_set_pci_bar(const struct sa_mmio_descriptor *fixed_set_resources, size_t count)
uint32_t soc_systemagent_max_chan_capacity_mib(u8 capid0_a_ddrsz)
Definition: systemagent.c:96
void bootblock_systemagent_early_init(void)
void sa_add_fixed_mmio_resources(struct device *dev, int *resource_cnt, const struct sa_mmio_descriptor *sa_fixed_resources, size_t count)
Definition: systemagent.c:87
struct global_nvs * gnvs
uintptr_t base
Definition: uart.c:17
static const int mask[4]
Definition: gpio.c:308
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:17
uint8_t u8
Definition: stdint.h:45
Definition: device.h:107
Definition: nvs.h:14
unsigned int index
Definition: systemagent.h:45
const char * description
Definition: systemagent.h:48
#define count