summaryrefslogtreecommitdiff
path: root/src/soc/intel/apollolake/pnpconfig.c
blob: ebc1880778c5e0fbc54ec605bd5b4162c24d6e18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* SPDX-License-Identifier: GPL-2.0-only */

#include <bootstate.h>
#include <console/console.h>
#include <intelblocks/pcr.h>
#include <soc/pci_devs.h>
#include <soc/pnpconfig.h>
#include "chip.h"

static const struct pnpconfig perf[] = {
	VALUEFORPERF_MSG_VALUES_PLATFORM_DEFAULT,
};

static const struct pnpconfig power[] = {
	VALUEFORPOWER_MSG_VALUES_PLATFORM_DEFAULT,
};

static const struct pnpconfig power_perf[] = {
	VALUEFORPWRPERF_MSG_VALUES_PLATFORM_DEFAULT,
};

static void pnp_settings(void *unused)
{
	int index;
	size_t arrsize;
	const struct pnpconfig *pnpconfigarr;
	struct soc_intel_apollolake_config *config;

	config = config_of_soc();

	switch (config->pnp_settings) {
	case PNP_PERF:
		pnpconfigarr = perf;
		arrsize = ARRAY_SIZE(perf);
		break;
	case PNP_POWER:
		pnpconfigarr = power;
		arrsize = ARRAY_SIZE(power);
		break;
	case PNP_PERF_POWER:
		pnpconfigarr = power_perf;
		arrsize = ARRAY_SIZE(power_perf);
		break;
	default:
		printk(BIOS_NOTICE, "Invalid PNP settings selected");
		return;
	}

	for (index = 0; index < arrsize; index++)
		pcr_rmw32(pnpconfigarr[index].msgport,
			  pnpconfigarr[index].msgregaddr,
			  pnpconfigarr[index].mask,
			  pnpconfigarr[index].value);
}

BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, pnp_settings, NULL);