Sean Rhodes | 5da05b6 | 2022-01-10 21:58:04 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Sean Rhodes | 7a21e53 | 2022-06-07 22:45:20 +0100 | [diff] [blame] | 3 | #include <cpu/intel/turbo.h> |
Sean Rhodes | 5da05b6 | 2022-01-10 21:58:04 +0000 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pci_def.h> |
| 6 | #include <option.h> |
| 7 | #include <types.h> |
| 8 | #include <variants.h> |
| 9 | |
| 10 | #include "soc/intel/apollolake/chip.h" |
| 11 | |
| 12 | enum cmos_power_profile get_power_profile(enum cmos_power_profile fallback) |
| 13 | { |
| 14 | const unsigned int power_profile = get_uint_option("power_profile", fallback); |
| 15 | return power_profile < NUM_POWER_PROFILES ? power_profile : fallback; |
| 16 | } |
| 17 | |
| 18 | void devtree_update(void) |
| 19 | { |
| 20 | config_t *cfg = config_of_soc(); |
| 21 | |
| 22 | struct soc_power_limits_config *soc_conf = |
| 23 | &cfg->power_limits_config; |
| 24 | |
| 25 | struct device *nic_dev = pcidev_on_root(0x0c, 0); |
| 26 | |
| 27 | /* Update PL1 & PL2 based on CMOS settings */ |
| 28 | switch (get_power_profile(PP_POWER_SAVER)) { |
| 29 | case PP_POWER_SAVER: |
Sean Rhodes | 7a21e53 | 2022-06-07 22:45:20 +0100 | [diff] [blame] | 30 | disable_turbo(); |
Sean Rhodes | 83d3410 | 2022-05-24 21:56:45 +0100 | [diff] [blame] | 31 | soc_conf->tdp_pl1_override = 6; |
| 32 | soc_conf->tdp_pl2_override = 10; |
| 33 | cfg->tcc_offset = 15; |
Sean Rhodes | 5da05b6 | 2022-01-10 21:58:04 +0000 | [diff] [blame] | 34 | break; |
| 35 | case PP_BALANCED: |
Sean Rhodes | 83d3410 | 2022-05-24 21:56:45 +0100 | [diff] [blame] | 36 | soc_conf->tdp_pl1_override = 10; |
| 37 | soc_conf->tdp_pl2_override = 15; |
| 38 | cfg->tcc_offset = 10; |
Sean Rhodes | 5da05b6 | 2022-01-10 21:58:04 +0000 | [diff] [blame] | 39 | break; |
| 40 | case PP_PERFORMANCE: |
Sean Rhodes | 83d3410 | 2022-05-24 21:56:45 +0100 | [diff] [blame] | 41 | soc_conf->tdp_pl1_override = 10; |
| 42 | soc_conf->tdp_pl2_override = 20; |
| 43 | cfg->tcc_offset = 5; |
Sean Rhodes | 5da05b6 | 2022-01-10 21:58:04 +0000 | [diff] [blame] | 44 | break; |
| 45 | } |
| 46 | |
| 47 | /* Enable/Disable Wireless based on CMOS settings */ |
| 48 | if (get_uint_option("wireless", 1) == 0) |
| 49 | nic_dev->enabled = 0; |
| 50 | |
| 51 | /* Enable/Disable Webcam based on CMOS settings */ |
Sean Rhodes | 5c0e3d4 | 2022-05-20 10:28:39 +0100 | [diff] [blame] | 52 | cfg->usb2_port[CONFIG_WEBCAM_USB_PORT].enable = get_uint_option("webcam", 1); |
Sean Rhodes | 5da05b6 | 2022-01-10 21:58:04 +0000 | [diff] [blame] | 53 | } |