blob: ebc1880778c5e0fbc54ec605bd5b4162c24d6e18 [file] [log] [blame]
Angel Pons6bc13742020-04-05 15:46:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Divya Chellap0b15b702017-11-29 18:53:03 +05302
3#include <bootstate.h>
4#include <console/console.h>
5#include <intelblocks/pcr.h>
6#include <soc/pci_devs.h>
7#include <soc/pnpconfig.h>
8#include "chip.h"
9
10static const struct pnpconfig perf[] = {
11 VALUEFORPERF_MSG_VALUES_PLATFORM_DEFAULT,
12};
13
14static const struct pnpconfig power[] = {
15 VALUEFORPOWER_MSG_VALUES_PLATFORM_DEFAULT,
16};
17
18static const struct pnpconfig power_perf[] = {
19 VALUEFORPWRPERF_MSG_VALUES_PLATFORM_DEFAULT,
20};
21
22static void pnp_settings(void *unused)
23{
24 int index;
25 size_t arrsize;
26 const struct pnpconfig *pnpconfigarr;
Kyösti Mälkki28dc7dc2019-07-12 13:10:19 +030027 struct soc_intel_apollolake_config *config;
28
Kyösti Mälkkid5f645c2019-09-28 00:20:27 +030029 config = config_of_soc();
Kyösti Mälkki28dc7dc2019-07-12 13:10:19 +030030
Divya Chellap0b15b702017-11-29 18:53:03 +053031 switch (config->pnp_settings) {
32 case PNP_PERF:
33 pnpconfigarr = perf;
34 arrsize = ARRAY_SIZE(perf);
35 break;
36 case PNP_POWER:
37 pnpconfigarr = power;
38 arrsize = ARRAY_SIZE(power);
39 break;
40 case PNP_PERF_POWER:
41 pnpconfigarr = power_perf;
42 arrsize = ARRAY_SIZE(power_perf);
43 break;
44 default:
45 printk(BIOS_NOTICE, "Invalid PNP settings selected");
46 return;
47 }
48
49 for (index = 0; index < arrsize; index++)
50 pcr_rmw32(pnpconfigarr[index].msgport,
51 pnpconfigarr[index].msgregaddr,
52 pnpconfigarr[index].mask,
53 pnpconfigarr[index].value);
54}
55
56BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, pnp_settings, NULL);