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
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <baseboard/variants.h>
#include <bootblock_common.h>
#include <console/console.h>
#include <intelblocks/mp_init.h>
#include <fmap.h>
#include <commonlib/region.h>
#include <console/console.h>
#include <intelblocks/pmclib.h>
#include <cf9_reset.h>
#define SI_DESC_REGION "SI_DESC"
#define SI_DESC_REGION_SZ 4096
#define PMC_DESC_7_BYTE3 0xc32
/* It updates PMC Descriptor in the Descriptor Region */
static void configure_pmc_descriptor(void)
{
uint8_t si_desc_buf[SI_DESC_REGION_SZ];
struct region_device desc_rdev;
if (fmap_locate_area_as_rdev_rw(SI_DESC_REGION, &desc_rdev) < 0) {
printk(BIOS_ERR, "Failed to locate %s in the FMAP\n", SI_DESC_REGION);
return;
}
if (rdev_readat(&desc_rdev, si_desc_buf, 0, SI_DESC_REGION_SZ) != SI_DESC_REGION_SZ) {
printk(BIOS_ERR, "Failed to read Descriptor Region from SPI Flash\n");
return;
}
if (si_desc_buf[PMC_DESC_7_BYTE3] == 0x40) {
si_desc_buf[PMC_DESC_7_BYTE3] = 0x44;
if (rdev_eraseat(&desc_rdev, 0, SI_DESC_REGION_SZ) != SI_DESC_REGION_SZ) {
printk(BIOS_ERR, "Failed to erase Descriptor Region area\n");
return;
}
if (rdev_writeat(&desc_rdev, si_desc_buf, 0, SI_DESC_REGION_SZ)
!= SI_DESC_REGION_SZ) {
printk(BIOS_ERR, "Failed to update Descriptor Region\n");
return;
}
printk(BIOS_DEBUG, "Update of PMC Descriptor successful, trigger GLOBAL RESET\n");
pmc_global_reset_enable(1);
do_full_reset();
die("Failed to trigger GLOBAL RESET\n");
}
printk(BIOS_DEBUG, "Update of PMC Descriptor is not required!\n");
}
void bootblock_mainboard_early_init(void)
{
const struct pad_config *pads;
size_t num;
pads = variant_early_gpio_table(&num);
gpio_configure_pads(pads, num);
}
void bootblock_mainboard_init(void)
{
if (cpu_get_cpuid() == CPUID_ALDERLAKE_A0)
configure_pmc_descriptor();
}
|