coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
lpm.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <arch/cpu.h>
4 #include <device/device.h>
5 #include <device/pci_ops.h>
6 #include <device/pci_ids.h>
7 #include <cpu/intel/cpu_ids.h>
8 #include <soc/lpm.h>
9 #include <soc/pci_devs.h>
10 #include <soc/soc_chip.h>
11 #include <types.h>
12 
13 /* Function returns true if the platform is TGL-UP3 */
14 static bool platform_is_up3(void)
15 {
16  const struct device *dev = pcidev_path_on_root(SA_DEVFN_ROOT);
19 
21  return false;
22 
23  return ((mchid == PCI_DID_INTEL_TGL_ID_U_2_2) ||
25 }
26 
28 {
29  int disable_mask;
30 
31  /* Disable any sub-states requested by mainboard */
32  disable_mask = config->LpmStateDisableMask;
33 
34  /* UP3 does not support S0i2.2/S0i3.3/S0i3.4 */
35  if (platform_is_up3())
36  disable_mask |= LPM_S0i3_3 | LPM_S0i3_4 | LPM_S0i2_2;
37 
38  /* If external bypass is not used, S0i3 isn't recommended. */
39  if (config->external_bypass == false)
40  disable_mask |= LPM_S0i3_0 | LPM_S0i3_1 | LPM_S0i3_2 | LPM_S0i3_3 | LPM_S0i3_4;
41 
42  /* If external clock gating is not implemented, S0i3.4 isn't recommended. */
43  if (config->external_clk_gated == false)
44  disable_mask |= LPM_S0i3_4;
45 
46  /*
47  * If external phy gating is not implemented,
48  * S0i3.3/S0i3.4/S0i2.2 are not recommended.
49  */
50  if (config->external_phy_gated == false)
51  disable_mask |= LPM_S0i3_3 | LPM_S0i3_4 | LPM_S0i2_2;
52 
53  /* If CNVi or ISH is used, S0i3.2/S0i3.3/S0i3.4 cannot be achieved. */
55  disable_mask |= LPM_S0i3_2 | LPM_S0i3_3 | LPM_S0i3_4;
56 
57  return LPM_S0iX_ALL & ~disable_mask;
58 }
uint32_t cpu_get_cpuid(void)
Definition: cpu_common.c:63
#define CPUID_TIGERLAKE_B0
Definition: cpu_ids.h:49
#define CPUID_TIGERLAKE_A0
Definition: cpu_ids.h:48
bool is_devfn_enabled(unsigned int devfn)
Definition: device_const.c:382
DEVTREE_CONST struct device * pcidev_path_on_root(pci_devfn_t devfn)
Definition: device_const.c:255
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static bool platform_is_up3(void)
Definition: lpm.c:14
int get_supported_lpm_mask(struct soc_intel_tigerlake_config *config)
Definition: lpm.c:27
enum board_config config
Definition: memory.c:448
#define PCI_DEVICE_ID
Definition: pci_def.h:9
#define PCI_DID_INTEL_TGL_ID_U_4_2
Definition: pci_ids.h:4019
#define PCI_DID_INTEL_TGL_ID_U_2_2
Definition: pci_ids.h:4018
u16 mchid
unsigned int cpu_id
Definition: chip.h:47
@ LPM_S0i3_2
Definition: chip.h:137
@ LPM_S0i3_3
Definition: chip.h:138
@ LPM_S0i2_2
Definition: chip.h:134
@ LPM_S0i3_0
Definition: chip.h:135
@ LPM_S0iX_ALL
Definition: chip.h:140
@ LPM_S0i3_1
Definition: chip.h:136
@ LPM_S0i3_4
Definition: chip.h:139
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
#define PCH_DEVFN_ISH
Definition: pci_devs.h:106
#define PCH_DEVFN_CNVI_WIFI
Definition: pci_devs.h:127
unsigned short uint16_t
Definition: stdint.h:11
uint32_t u32
Definition: stdint.h:51
Definition: device.h:107