Debian Codegraph @

src/mainboard/starlabs/starbook/variants/tgl/devtree.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <chip.h>
4 #include <cpu/intel/turbo.h>
5 #include <device/device.h>
6 #include <device/pci_def.h>
7 #include <option.h>
8 #include <static.h>
9 #include <types.h>
10 #include <variants.h>
11
12 #define TJ_MAX 100
13 #define TCC(temp) (TJ_MAX - temp)
14
15 void devtree_update(void)
16 {
17 config_t *cfg = config_of_soc();
18
19 struct soc_power_limits_config *soc_conf_2core =
20 &cfg->power_limits_config[POWER_LIMITS_U_2_CORE];
21
22 struct soc_power_limits_config *soc_conf_4core =
23 &cfg->power_limits_config[POWER_LIMITS_U_4_CORE];
24
25 struct device *nic_dev = pcidev_on_root(0x14, 3);
26 struct device *tbt_pci_dev = pcidev_on_root(0x07, 0);
27 struct device *tbt_dma_dev = pcidev_on_root(0x0d, 2);
28 struct device *gna_dev = pcidev_on_root(0x08, 0);
29
30 uint8_t performance_scale = 100;
31
32 /* Set PL4 to 1.0C */
33 soc_conf_2core->tdp_pl4 = 65;
34 soc_conf_4core->tdp_pl4 = 65;
35
36 /* Set PL1 to 50% of PL2 */
37 soc_conf_2core->tdp_pl1_override = (soc_conf_2core->tdp_pl2_override / 2) & ~1;
38 soc_conf_4core->tdp_pl1_override = (soc_conf_4core->tdp_pl2_override / 2) & ~1;
39
40 /* Scale PL1 & PL2 based on CMOS settings */
41 switch (get_power_profile(PP_POWER_SAVER)) {
42 case PP_POWER_SAVER:
43 performance_scale -= 50;
44 cfg->tcc_offset = TCC(80);
45 break;
46 case PP_BALANCED:
47 performance_scale -= 25;
48 cfg->tcc_offset = TCC(90);
49 break;
50 case PP_PERFORMANCE:
51 /* Use the Intel defaults */
52 cfg->tcc_offset = TCC(100);
53 break;
54 }
55
56 soc_conf_2core->tdp_pl1_override = (soc_conf_2core->tdp_pl1_override * performance_scale) / 100;
57 soc_conf_2core->tdp_pl2_override = (soc_conf_2core->tdp_pl2_override * performance_scale) / 100;
58
59 soc_conf_4core->tdp_pl1_override = (soc_conf_4core->tdp_pl1_override * performance_scale) / 100;
60 soc_conf_4core->tdp_pl2_override = (soc_conf_4core->tdp_pl2_override * performance_scale) / 100;
61
62 /* Enable/Disable Wireless based on CMOS settings */
63 if (get_uint_option("wireless", 1) == 0)
64 nic_dev->enabled = 0;
65
66 /* Enable/Disable Webcam based on CMOS settings */
67 cfg->usb2_ports[CONFIG_CCD_PORT].enable = get_uint_option("webcam", 1);
68
69 /* Enable/Disable Card Reader based on CMOS Settings */
70 if (get_uint_option("card_reader", 1) == 0)
71 cfg->usb2_ports[5].enable = 0;
72
73 /* Enable/Disable Thunderbolt based on CMOS settings */
74 if (get_uint_option("thunderbolt", 1) == 0) {
75 cfg->UsbTcPortEn = 0;
76 cfg->TcssXhciEn = 0;
77 tbt_pci_dev->enabled = 0;
78 tbt_dma_dev->enabled = 0;
79 }
80
81 /* Enable/Disable GNA based on CMOS settings */
82 if (get_uint_option("gna", 0) == 0)
83 gna_dev->enabled = 0;
84 }