coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
systemagent.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 /*
4  * This file is created based on Intel Tiger Lake Processor SA Datasheet
5  * Document number: 571131
6  * Chapter number: 3
7  */
8 
9 #include <console/console.h>
10 #include <device/device.h>
11 #include <delay.h>
12 #include <device/pci.h>
13 #include <device/pci_ids.h>
14 #include <device/pci_ops.h>
17 #include <soc/iomap.h>
18 #include <soc/soc_chip.h>
19 #include <soc/systemagent.h>
20 
21 /*
22  * SoC implementation
23  *
24  * Add all known fixed memory ranges for Host Controller/Memory
25  * controller.
26  */
27 void soc_add_fixed_mmio_resources(struct device *dev, int *index)
28 {
29  static const struct sa_mmio_descriptor soc_fixed_resources[] = {
30  { PCIEXBAR, CONFIG_ECAM_MMCONF_BASE_ADDRESS, CONFIG_ECAM_MMCONF_LENGTH,
31  "PCIEXBAR" },
32  { MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" },
33  { DMIBAR, DMI_BASE_ADDRESS, DMI_BASE_SIZE, "DMIBAR" },
34  { EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" },
35  { REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" },
37  };
38 
39  sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources,
40  ARRAY_SIZE(soc_fixed_resources));
41 
42  /* Add Vt-d resources if VT-d is enabled */
44  return;
45 
48 }
49 
50 /*
51  * SoC implementation
52  *
53  * Perform System Agent Initialization during Ramstage phase.
54  */
55 void soc_systemagent_init(struct device *dev)
56 {
57  struct soc_power_limits_config *soc_config;
58  struct device *sa;
59  uint16_t sa_pci_id;
61 
62  /* Get System Agent PCI ID */
64  sa_pci_id = sa ? pci_read_config16(sa, PCI_DEVICE_ID) : 0xFFFF;
65 
66  /* Enable Power Aware Interrupt Routing */
68 
69  /* Enable BIOS Reset CPL */
71 
72  /* Configure turbo power limits 1ms after reset complete bit */
73  mdelay(1);
75 
76  /*
77  * Choose a power limits configuration based on the SoC SKU,
78  * differentiated here based on SA PCI ID.
79  */
80  switch (sa_pci_id) {
82  soc_config = &config->power_limits_config[POWER_LIMITS_U_2_CORE];
83  break;
85  soc_config = &config->power_limits_config[POWER_LIMITS_U_4_CORE];
86  break;
88  soc_config = &config->power_limits_config[POWER_LIMITS_Y_2_CORE];
89  break;
91  soc_config = &config->power_limits_config[POWER_LIMITS_Y_4_CORE];
92  break;
94  soc_config = &config->power_limits_config[POWER_LIMITS_H_6_CORE];
95  break;
97  soc_config = &config->power_limits_config[POWER_LIMITS_H_8_CORE];
98  break;
99  default:
100  printk(BIOS_ERR, "TGL: unknown SA ID: 0x%4x, skipping power limits "
101  "configuration\n", sa_pci_id);
102  return;
103  }
104 
106 }
107 
109 {
110  switch (capid0_a_ddrsz) {
111  case 1:
112  return 8192;
113  case 2:
114  return 4096;
115  case 3:
116  return 2048;
117  default:
118  return 65536;
119  }
120 }
#define REGBAR
Definition: systemagent.h:25
static const struct sa_mmio_descriptor soc_vtd_resources[]
Definition: systemagent.h:41
void soc_add_fixed_mmio_resources(struct device *dev, int *index)
Definition: systemagent.c:25
void soc_systemagent_init(struct device *dev)
Definition: systemagent.c:53
uint32_t soc_systemagent_max_chan_capacity_mib(u8 capid0_a_ddrsz)
Definition: systemagent.c:96
#define ARRAY_SIZE(a)
Definition: helpers.h:12
void enable_bios_reset_cpl(void)
void enable_power_aware_intr(void)
Definition: systemagent.c:298
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
#define printk(level,...)
Definition: stdlib.h:16
void set_power_limits(u8 power_limit_1_time)
Definition: haswell_init.c:313
void mdelay(unsigned int msecs)
Definition: delay.c:2
DEVTREE_CONST struct device * pcidev_path_on_root(pci_devfn_t devfn)
Definition: device_const.c:255
#define CAPID0_A
Definition: host_bridge.h:65
#define MCHBAR
Definition: host_bridge.h:7
#define PCIEXBAR
Definition: host_bridge.h:32
#define VTD_DISABLE
Definition: host_bridge.h:67
#define DMIBAR
Definition: host_bridge.h:33
#define EPBAR
Definition: host_bridge.h:6
#define EDRAMBAR
Definition: mchbar.h:19
#define config_of_soc()
Definition: device.h:394
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
#define REG_BASE_ADDRESS
Definition: iomap.h:67
#define REG_BASE_SIZE
Definition: iomap.h:68
#define DMI_BASE_ADDRESS
Definition: iomap.h:37
#define EP_BASE_ADDRESS
Definition: iomap.h:40
#define MCH_BASE_ADDRESS
Definition: iomap.h:82
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
enum board_config config
Definition: memory.c:448
#define DMI_BASE_SIZE
Definition: memmap.h:8
#define EP_BASE_SIZE
Definition: memmap.h:10
#define EDRAM_BASE_ADDRESS
Definition: memmap.h:12
#define MCH_BASE_SIZE
Definition: memmap.h:6
#define EDRAM_BASE_SIZE
Definition: memmap.h:13
#define PCI_DEVICE_ID
Definition: pci_def.h:9
#define PCI_DID_INTEL_TGL_ID_H_6_1
Definition: pci_ids.h:4022
#define PCI_DID_INTEL_TGL_ID_U_4_2
Definition: pci_ids.h:4019
#define PCI_DID_INTEL_TGL_ID_Y_4_2
Definition: pci_ids.h:4021
#define PCI_DID_INTEL_TGL_ID_Y_2_2
Definition: pci_ids.h:4020
#define PCI_DID_INTEL_TGL_ID_U_2_2
Definition: pci_ids.h:4018
#define PCI_DID_INTEL_TGL_ID_H_8_1
Definition: pci_ids.h:4023
#define MOBILE_SKU_PL1_TIME_SEC
Definition: power_limit.h:16
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
@ POWER_LIMITS_U_2_CORE
Definition: chip.h:30
@ POWER_LIMITS_H_8_CORE
Definition: chip.h:35
@ POWER_LIMITS_Y_4_CORE
Definition: chip.h:33
@ POWER_LIMITS_U_4_CORE
Definition: chip.h:31
@ POWER_LIMITS_H_6_CORE
Definition: chip.h:34
@ POWER_LIMITS_Y_2_CORE
Definition: chip.h:32
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
uint8_t u8
Definition: stdint.h:45
Definition: device.h:107
unsigned int index
Definition: systemagent.h:45