26 changes: 15 additions & 11 deletions src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <cpu/cpu.h>
#include <cpu/x86/mp.h>
#include <cpu/x86/lapic.h>
#include <cpu/intel/microcode.h>
Expand All @@ -10,7 +11,6 @@
#include <intelblocks/mp_init.h>

#define BSP_CPU_SLOT 0
#define SINGLE_CHIP_PACKAGE 0

efi_return_status_t mp_get_number_of_processors(efi_uintn_t *number_of_processors,
efi_uintn_t *number_of_enabled_processors)
Expand All @@ -28,7 +28,8 @@ efi_return_status_t mp_get_number_of_processors(efi_uintn_t *number_of_processor
efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number,
efi_processor_information *processor_info_buffer)
{
unsigned int num_virt_cores, num_phys_cores;
int apicid;
uint8_t package, core, thread;

if (cpu_index() < 0)
return FSP_DEVICE_ERROR;
Expand All @@ -39,7 +40,12 @@ efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number,
if (processor_number >= get_cpu_count())
return FSP_NOT_FOUND;

processor_info_buffer->ProcessorId = lapicid();
apicid = cpu_get_apic_id(processor_number);

if (apicid < 0)
return FSP_DEVICE_ERROR;

processor_info_buffer->ProcessorId = apicid;

processor_info_buffer->StatusFlag = PROCESSOR_HEALTH_STATUS_BIT
| PROCESSOR_ENABLED_BIT;
Expand All @@ -48,27 +54,25 @@ efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number,
processor_info_buffer->StatusFlag |= PROCESSOR_AS_BSP_BIT;

/* Fill EFI_CPU_PHYSICAL_LOCATION structure information */
cpu_read_topology(&num_phys_cores, &num_virt_cores);
get_cpu_topology_from_apicid(apicid, &package, &core, &thread);

/* FSP will add one to the value in this Package field */
processor_info_buffer->Location.Package = SINGLE_CHIP_PACKAGE;
processor_info_buffer->Location.Core = num_phys_cores;
processor_info_buffer->Location.Thread = num_virt_cores;
processor_info_buffer->Location.Package = package;
processor_info_buffer->Location.Core = core;
processor_info_buffer->Location.Thread = thread;

return FSP_SUCCESS;
}

efi_return_status_t mp_startup_all_aps(efi_ap_procedure procedure,
efi_uintn_t timeout_usec, void *argument)
bool run_serial, efi_uintn_t timeout_usec, void *argument)
{
if (cpu_index() < 0)
return FSP_DEVICE_ERROR;

if (procedure == NULL)
return FSP_INVALID_PARAMETER;

if (mp_run_on_aps((void *)procedure, argument,
MP_RUN_ON_ALL_CPUS, timeout_usec)) {
if (mp_run_on_all_aps((void *)procedure, argument, timeout_usec, !run_serial)) {
printk(BIOS_DEBUG, "%s: Exit with Failure\n", __func__);
return FSP_NOT_STARTED;
}
Expand Down
5 changes: 4 additions & 1 deletion src/drivers/intel/fsp2_0/silicon_init.c
Expand Up @@ -210,7 +210,10 @@ void fsps_load(void)
if (resume_from_stage_cache()) {
printk(BIOS_DEBUG, "Loading FSPS from stage_cache\n");
stage_cache_load_stage(STAGE_REFCODE, fsps);
if (fsp_validate_component(&fsps_hdr, prog_rdev(fsps)) != CB_SUCCESS)

struct region_device prog_rdev;
prog_chain_rdev(fsps, &prog_rdev);
if (fsp_validate_component(&fsps_hdr, &prog_rdev) != CB_SUCCESS)
die("On resume fsps header is invalid\n");
load_done = 1;
return;
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/intel/fsp2_0/util.c
Expand Up @@ -180,7 +180,7 @@ enum cb_err fsp_load_component(struct fsp_load_descriptor *fspld, struct fsp_hea
uint32_t compression_algo;
size_t output_size;
void *dest;
struct region_device source_rdev;
struct region_device source_rdev, prog_rdev;
struct prog *fsp_prog = &fspld->fsp_prog;

if (fspld->get_destination == NULL)
Expand All @@ -201,7 +201,8 @@ enum cb_err fsp_load_component(struct fsp_load_descriptor *fspld, struct fsp_hea

prog_set_area(fsp_prog, dest, output_size);

if (fsp_validate_component(hdr, prog_rdev(fsp_prog)) != CB_SUCCESS) {
prog_chain_rdev(fsp_prog, &prog_rdev);
if (fsp_validate_component(hdr, &prog_rdev) != CB_SUCCESS) {
printk(BIOS_ERR, "Invalid FSP header after load!\n");
return CB_ERR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/intel/gma/gma.ads
Expand Up @@ -8,7 +8,7 @@ package GMA is

function read_edid
(raw_edid : out HW.GFX.EDID.Raw_EDID_Data;
Port : in Interfaces.C.int)
port : in Interfaces.C.int)
return Interfaces.C.int
with
Export, Convention => C, External_Name => "gma_read_edid";
Expand Down
1 change: 1 addition & 0 deletions src/drivers/intel/mipi_camera/camera.c
Expand Up @@ -4,6 +4,7 @@
#include <acpi/acpi.h>
#include <acpi/acpi_device.h>
#include <acpi/acpigen.h>
#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/i2c_simple.h>
#include <device/device.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/intel/usb4/retimer/retimer.c
Expand Up @@ -77,7 +77,6 @@ static void usb4_retimer_cb_set_power_state(void *arg)
*/
acpigen_write_if_lequal_op_int(LOCAL0_OP, 0);
acpigen_disable_tx_gpio(power_gpio);
acpigen_pop_len(); /* If */

/*
* Else {
Expand Down
5 changes: 0 additions & 5 deletions src/drivers/ipmi/ocp/Kconfig
Expand Up @@ -3,8 +3,3 @@ config IPMI_OCP
default n
help
This implements OCP specific IPMI command

config IPMI_OCP_MANU_ID
hex
default 0x0
depends on IPMI_OCP
102 changes: 0 additions & 102 deletions src/drivers/ipmi/ocp/ipmi_ocp.c
Expand Up @@ -7,115 +7,15 @@
* end
*/

#include <arch/cpu.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pnp.h>
#include <drivers/ipmi/ipmi_kcs.h>
#include <drivers/ocp/dmi/ocp_dmi.h>
#include <intelblocks/cpulib.h>
#include <string.h>
#include <types.h>

#include "ipmi_ocp.h"

static int ipmi_set_processor_information_param1(struct device *dev)
{
int ret;
struct ipmi_processor_info_param1_req req1 = {0};
struct ipmi_rsp rsp;
int mfid = CONFIG_IPMI_OCP_MANU_ID;

memcpy(&req1.data.manufacturer_id, &mfid, 3);
printk(BIOS_DEBUG, "IPMI BMC manufacturer id: %02x%02x%02x\n",
req1.data.manufacturer_id[2], req1.data.manufacturer_id[1],
req1.data.manufacturer_id[0]);

req1.data.index = 0;
req1.data.parameter_selector = 1;

/* Get processor name. */
fill_processor_name(req1.product_name);
printk(BIOS_DEBUG, "IPMI BMC CPU NAME: %s.\n", req1.product_name);

ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_OEM_COMMON, 0,
IPMI_BMC_SET_PROCESSOR_INFORMATION, (u8 *) &req1,
sizeof(req1), (u8 *) &rsp, sizeof(rsp));

if (ret < sizeof(struct ipmi_rsp) || rsp.completion_code) {
printk(BIOS_ERR, "IPMI BMC: %s command failed (ret=%d rsp=0x%x)\n",
__func__, ret, rsp.completion_code);
return CB_ERR;
}
return CB_SUCCESS;
}

static int ipmi_set_processor_information_param2(struct device *dev)
{
int ret;
struct ipmi_processor_info_param2_req req2 = {0};
struct ipmi_rsp rsp;
uint8_t stepping_id;
int mfid = CONFIG_IPMI_OCP_MANU_ID;
unsigned int core_count, thread_count;
struct cpuinfo_x86 c;

memcpy(&req2.data.manufacturer_id, &mfid, 3);
printk(BIOS_DEBUG, "IPMI BMC manufacturer id: %02x%02x%02x\n",
req2.data.manufacturer_id[2], req2.data.manufacturer_id[1],
req2.data.manufacturer_id[0]);

req2.data.index = 0;
req2.data.parameter_selector = 2;

/* Get core number and thread number. */
cpu_read_topology(&core_count, &thread_count);
req2.core_number = core_count;
req2.thread_number = thread_count;
printk(BIOS_DEBUG, "IPMI BMC CPU has %u cores, %u threads enabled.\n",
req2.core_number, req2.thread_number);

/* Get processor frequency. */
req2.processor_freq = 100 * cpu_get_max_ratio();
printk(BIOS_DEBUG, "IPMI BMC CPU frequency is %u MHz.\n",
req2.processor_freq);

/* Get revision. */
get_fms(&c, cpuid_eax(1));
stepping_id = c.x86_mask;
printk(BIOS_DEBUG, "IPMI BMC CPU stepping id is %x.\n", stepping_id);
switch (stepping_id) {
/* TBD */
case 0x0a:
req2.revision[0] = 'A';
req2.revision[1] = '0';
break;
default:
req2.revision[0] = 'X';
req2.revision[1] = 'X';
}

ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_OEM_COMMON, 0,
IPMI_BMC_SET_PROCESSOR_INFORMATION, (u8 *) &req2,
sizeof(req2), (u8 *) &rsp, sizeof(rsp));

if (ret < sizeof(struct ipmi_rsp) || rsp.completion_code) {
printk(BIOS_ERR, "IPMI: %s command failed (ret=%d rsp=0x%x)\n",
__func__, ret, rsp.completion_code);
return CB_ERR;
}
return CB_SUCCESS;
}

static void ipmi_set_processor_information(struct device *dev)
{
if (ipmi_set_processor_information_param1(dev))
printk(BIOS_ERR, "IPMI BMC set param 1 processor info failed\n");

if (ipmi_set_processor_information_param2(dev))
printk(BIOS_ERR, "IPMI BMC set param 2 processor info failed\n");
}

static enum cb_err ipmi_set_ppin(struct device *dev)
{
int ret;
Expand Down Expand Up @@ -149,8 +49,6 @@ static void ipmi_ocp_final(struct device *dev)
{
/* Add OCP specific IPMI command */

/* Send processor information */
ipmi_set_processor_information(dev);
if (CONFIG(OCP_DMI))
ipmi_set_ppin(dev);
}
Expand Down
30 changes: 0 additions & 30 deletions src/drivers/ipmi/ocp/ipmi_ocp.h
Expand Up @@ -3,48 +3,18 @@
#ifndef __IPMI_OCP_H
#define __IPMI_OCP_H

#include <cpu/x86/msr.h>
#include <cpu/x86/name.h>
#include "drivers/ipmi/ipmi_kcs.h"

#define IPMI_NETFN_OEM 0x30
#define IPMI_OEM_SET_PPIN 0x77
#define IPMI_BMC_SET_POST_START 0x73
#define IPMI_OEM_SET_BIOS_BOOT_ORDER 0x52
#define IPMI_OEM_GET_BIOS_BOOT_ORDER 0x53

#define IPMI_NETFN_OEM_COMMON 0x36
#define IPMI_BMC_SET_PROCESSOR_INFORMATION 0x10
#define IPMI_BMC_GET_PROCESSOR_INFORMATION 0x11

#define MSR_CORE_THREAD_COUNT 0x35
#define MSR_PLATFORM_INFO 0xce

#define CMOS_BIT (1 << 1)
#define VALID_BIT (1 << 7)
#define CLEAR_CMOS_AND_VALID_BIT(x) ((x) &= ~(CMOS_BIT | VALID_BIT))
#define SET_CMOS_AND_VALID_BIT(x) ((x) |= (CMOS_BIT | VALID_BIT))
#define IS_CMOS_AND_VALID_BIT(x) ((x)&CMOS_BIT && (x)&VALID_BIT)

struct ipmi_processor_info_req {
uint8_t manufacturer_id[3];
uint8_t index;
uint8_t parameter_selector;
} __packed;

struct ipmi_processor_info_param1_req {
struct ipmi_processor_info_req data;
char product_name[48];
} __packed;

struct ipmi_processor_info_param2_req {
struct ipmi_processor_info_req data;
uint8_t core_number;
uint16_t thread_number;
uint16_t processor_freq;
char revision[2];
} __packed;

struct ppin_req {
uint32_t cpu0_lo;
uint32_t cpu0_hi;
Expand Down
15 changes: 4 additions & 11 deletions src/drivers/net/atl1e.c
Expand Up @@ -41,18 +41,11 @@ static u8 get_hex_digit(const u8 c)

static enum cb_err fetch_mac_string_cbfs(u8 *macstrbuf)
{
struct cbfsf fh;
uint32_t matchraw = CBFS_TYPE_RAW;

if (!cbfs_boot_locate(&fh, "atl1e-macaddress", &matchraw)) {
/* check the cbfs for the mac address */
if (rdev_readat(&fh.data, macstrbuf, 0, MACLEN) != MACLEN) {
printk(BIOS_ERR, "atl1e: Error reading MAC from CBFS\n");
return CB_ERR;
}
return CB_SUCCESS;
if (!cbfs_load("atl1e-macaddress", macstrbuf, MACLEN)) {
printk(BIOS_ERR, "atl1e: Error reading MAC from CBFS\n");
return CB_ERR;
}
return CB_ERR;
return CB_SUCCESS;
}

static void get_mac_address(u8 *macaddr, const u8 *strbuf)
Expand Down
15 changes: 4 additions & 11 deletions src/drivers/net/r8168.c
Expand Up @@ -166,18 +166,11 @@ static void fetch_mac_string_vpd(struct drivers_net_config *config, u8 *macstrbu

static enum cb_err fetch_mac_string_cbfs(u8 *macstrbuf)
{
struct cbfsf fh;
uint32_t matchraw = CBFS_TYPE_RAW;

if (!cbfs_boot_locate(&fh, "rt8168-macaddress", &matchraw)) {
/* check the cbfs for the mac address */
if (rdev_readat(&fh.data, macstrbuf, 0, MACLEN) != MACLEN) {
printk(BIOS_ERR, "r8168: Error reading MAC from CBFS\n");
return CB_ERR;
}
return CB_SUCCESS;
if (!cbfs_load("rt8168-macaddress", macstrbuf, MACLEN)) {
printk(BIOS_ERR, "r8168: Error reading MAC from CBFS\n");
return CB_ERR;
}
return CB_ERR;
return CB_SUCCESS;
}

static void get_mac_address(u8 *macaddr, const u8 *strbuf)
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/soundwire/alc1308/Kconfig
@@ -0,0 +1,2 @@
config DRIVERS_SOUNDWIRE_ALC1308
bool
1 change: 1 addition & 0 deletions src/drivers/soundwire/alc1308/Makefile.inc
@@ -0,0 +1 @@
ramstage-$(CONFIG_DRIVERS_SOUNDWIRE_ALC1308) += alc1308.c
151 changes: 151 additions & 0 deletions src/drivers/soundwire/alc1308/alc1308.c
@@ -0,0 +1,151 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
#include <acpi/acpi_soundwire.h>
#include <device/device.h>
#include <device/path.h>
#include <device/mipi_ids.h>
#include <device/soundwire.h>
#include <stdio.h>

#include "chip.h"

static struct soundwire_address alc1308_address = {
.version = SOUNDWIRE_VERSION_1_1,
.manufacturer_id = MIPI_MFG_ID_REALTEK,
.part_id = MIPI_DEV_ID_REALTEK_ALC1308,
.class = MIPI_CLASS_NONE
};

static struct soundwire_slave alc1308_slave = {
.wake_up_unavailable = false,
.test_mode_supported = false,
.clock_stop_mode1_supported = true,
.simplified_clockstopprepare_sm_supported = true,
.clockstopprepare_hard_reset_behavior = false,
.highPHY_capable = false,
.paging_supported = false,
.bank_delay_supported = false,
.port15_read_behavior = false,
.source_port_list = SOUNDWIRE_PORT(2) | SOUNDWIRE_PORT(4),
.sink_port_list = SOUNDWIRE_PORT(1)
};

static struct soundwire_audio_mode alc1308_audio_mode = {
/* Bus frequency must be 1/2/4/8 divider of supported input frequencies. */
.bus_frequency_configs_count = 12,
.bus_frequency_configs = {
9600 * KHz, 4800 * KHz, 2400 * KHz, 1200 * KHz, /* 9.6 MHz */
12000 * KHz, 6000 * KHz, 3000 * KHz, 1500 * KHz, /* 12 MHz */
12288 * KHz, 6144 * KHz, 3072 * KHz, 1536 * KHz /* 12.288 MHz */
},
/* Support 16 KHz to 96 KHz sampling frequency */
.sampling_frequency_configs_count = 8,
.sampling_frequency_configs = {
16 * KHz,
22.05 * KHz,
24 * KHz,
32 * KHz,
44.1 * KHz,
48 * KHz,
88.2 * KHz,
96 * KHz,
},
.prepare_channel_behavior = CHANNEL_PREPARE_ANY_FREQUENCY
};

static struct soundwire_dpn alc1308_dp1 = {
.port_wordlength_configs_count = 1,
.port_wordlength_configs = { 32 },
.data_port_type = FULL_DATA_PORT,
.max_grouping_supported = BLOCK_GROUP_COUNT_1,
.simplified_channelprepare_sm = false,
.imp_def_dpn_interrupts_supported = 0,
.min_channel_number = 1,
.max_channel_number = 2,
.modes_supported = MODE_ISOCHRONOUS | MODE_TX_CONTROLLED |
MODE_RX_CONTROLLED | MODE_FULL_ASYNCHRONOUS,
.block_packing_mode = true,
.port_audio_mode_count = 1,
.port_audio_mode_list = { 0 }
};

static const struct soundwire_codec alc1308_codec = {
.slave = &alc1308_slave,
.audio_mode = { &alc1308_audio_mode },
.dpn = {
{
/* Data Input for Speaker Path */
.port = 1,
.sink = &alc1308_dp1
},
{
/* Data out for I.V sensing */
.port = 2,
.source = &alc1308_dp1
},
{
/* Data out for I.V sensing */
.port = 4,
.source = &alc1308_dp1
}
}

};

static void soundwire_alc1308_fill_ssdt(const struct device *dev)
{
struct drivers_soundwire_alc1308_config *config = dev->chip_info;
const char *scope = acpi_device_scope(dev);
struct acpi_dp *dsd;

if (!dev->enabled || !scope)
return;

acpigen_write_scope(scope);
acpigen_write_device(acpi_device_name(dev));

/* Set codec address IDs. */
alc1308_address.link_id = dev->path.generic.id;
alc1308_address.unique_id = dev->path.generic.subid;

acpigen_write_ADR_soundwire_device(&alc1308_address);
acpigen_write_name_string("_DDN", config->desc ? : dev->chip_ops->name);
acpigen_write_STA(acpi_device_status(dev));

dsd = acpi_dp_new_table("_DSD");
soundwire_gen_codec(dsd, &alc1308_codec, NULL);
acpi_dp_write(dsd);

acpigen_pop_len(); /* Device */
acpigen_pop_len(); /* Scope */
}

static const char *soundwire_alc1308_acpi_name(const struct device *dev)
{
struct drivers_soundwire_alc1308_config *config = dev->chip_info;
static char name[5];

if (config->name)
return config->name;
snprintf(name, sizeof(name), "SW%1X%1X", dev->path.generic.id, dev->path.generic.subid);
return name;
}

static struct device_operations soundwire_alc1308_ops = {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
.acpi_name = soundwire_alc1308_acpi_name,
.acpi_fill_ssdt = soundwire_alc1308_fill_ssdt,
};

static void soundwire_alc1308_enable(struct device *dev)
{
dev->ops = &soundwire_alc1308_ops;
}

struct chip_operations drivers_soundwire_alc1308_ops = {
CHIP_NAME("Realtek ALC1308 SoundWire Codec")
.enable_dev = soundwire_alc1308_enable
};
11 changes: 11 additions & 0 deletions src/drivers/soundwire/alc1308/chip.h
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef __DRIVERS_SOUNDWIRE_ALC1308_CHIP_H__
#define __DRIVERS_SOUNDWIRE_ALC1308_CHIP_H__

struct drivers_soundwire_alc1308_config {
const char *name;
const char *desc;
};

#endif /* __DRIVERS_SOUNDWIRE_ALC1308_CHIP_H__ */
19 changes: 2 additions & 17 deletions src/drivers/spi/cbfs_spi.c
Expand Up @@ -7,6 +7,7 @@
*/

#include <boot_device.h>
#include <cbfs.h>
#include <console/console.h>
#include <spi_flash.h>
#include <symbols.h>
Expand Down Expand Up @@ -77,21 +78,7 @@ static const struct region_device_ops spi_ops = {
};

static struct mmap_helper_region_device mdev =
MMAP_HELPER_REGION_INIT(&spi_ops, 0, CONFIG_ROM_SIZE);

static void switch_to_postram_cache(int unused)
{
/*
* Call boot_device_init() to ensure spi_flash is initialized before
* backing mdev with postram cache. This prevents the mdev backing from
* being overwritten if spi_flash was not accessed before dram was up.
*/
boot_device_init();
if (_preram_cbfs_cache != _postram_cbfs_cache)
mmap_helper_device_init(&mdev, _postram_cbfs_cache,
REGION_SIZE(postram_cbfs_cache));
}
ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache);
MMAP_HELPER_DEV_INIT(&spi_ops, 0, CONFIG_ROM_SIZE, &cbfs_cache);

void boot_device_init(void)
{
Expand All @@ -105,8 +92,6 @@ void boot_device_init(void)
return;

spi_flash_init_done = true;

mmap_helper_device_init(&mdev, _cbfs_cache, REGION_SIZE(cbfs_cache));
}

/* Return the CBFS boot device. */
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/usb/pci_xhci/pci_xhci.c
Expand Up @@ -2,6 +2,7 @@

#include "pci_xhci.h"
#include <acpi/acpigen.h>
#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/pci.h>
#include <device/pci_ids.h>
Expand Down Expand Up @@ -255,6 +256,7 @@ static const unsigned short amd_pci_device_ids[] = {
PCI_DEVICE_ID_AMD_FAM17H_MODEL18H_XHCI0,
PCI_DEVICE_ID_AMD_FAM17H_MODEL18H_XHCI1,
PCI_DEVICE_ID_AMD_FAM17H_MODEL20H_XHCI0,
PCI_DEVICE_ID_AMD_FAM17H_MODEL60H_XHCI,
0
};

Expand Down
17 changes: 2 additions & 15 deletions src/drivers/wifi/generic/Kconfig
Expand Up @@ -21,9 +21,6 @@ config USE_SAR
default n
help
Enable it when wifi driver uses SAR configuration feature.
VPD entry "wifi_sar" is read to get SAR settings, if its
not found driver may look into CBFS for default settigs.
WIFI_SAR_CBFS is option to enable CBFS lookup.

config SAR_ENABLE
bool
Expand All @@ -40,20 +37,10 @@ config GEO_SAR_ENABLE
default n
depends on USE_SAR

config WIFI_SAR_CBFS
bool "Enable SAR table addition to CBFS"
default n
depends on USE_SAR
help
wifi driver would look for "wifi_sar" vpd key and load SAR settings from
it, if the vpd key is not found then the driver tries to look for sar
settings from CBFS with file name wifi_sar_defaults.hex.
So OEM/ODM can override wifi sar with VPD.

config WIFI_SAR_CBFS_FILEPATH
string "The cbfs file which has WIFI SAR defaults"
depends on WIFI_SAR_CBFS
default "src/mainboard/\$(MAINBOARDDIR)/wifi_sar_defaults.hex"
depends on USE_SAR
default ""

config DSAR_SET_NUM
hex "Number of SAR sets when D-SAR is enabled"
Expand Down
10 changes: 8 additions & 2 deletions src/drivers/wifi/generic/Makefile.inc
Expand Up @@ -5,8 +5,14 @@ ramstage-y += generic.c
ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c

cbfs-files-$(CONFIG_WIFI_SAR_CBFS) += wifi_sar_defaults.hex
wifi_sar_defaults.hex-file := $(call strip_quotes,$(CONFIG_WIFI_SAR_CBFS_FILEPATH))
CONFIG_WIFI_SAR_CBFS_FILEPATH := $(call strip_quotes,$(CONFIG_WIFI_SAR_CBFS_FILEPATH))

ifneq ($(CONFIG_WIFI_SAR_CBFS_FILEPATH),)

cbfs-files-$(CONFIG_USE_SAR) += wifi_sar_defaults.hex
wifi_sar_defaults.hex-file := $(CONFIG_WIFI_SAR_CBFS_FILEPATH)
wifi_sar_defaults.hex-type := raw

endif

endif
1 change: 1 addition & 0 deletions src/drivers/wifi/generic/acpi.c
Expand Up @@ -2,6 +2,7 @@

#include <acpi/acpi_device.h>
#include <acpi/acpigen.h>
#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/pci_ids.h>
#include <sar.h>
Expand Down
7 changes: 7 additions & 0 deletions src/ec/google/chromeec/Kconfig
Expand Up @@ -197,4 +197,11 @@ config EC_GOOGLE_CHROMEEC_SWITCHES
Enable support for Chrome OS mode switches provided by the Chrome OS
EC.

config EC_GOOGLE_CHROMEEC_INCLUDE_SSFC_IN_FW_CONFIG
depends on FW_CONFIG_SOURCE_CHROMEEC_CBI
bool
help
Fetch Second Source Factory Cache from CBI EEPROM and add it in the most significant
32 bits of firmware configuration.

source "src/ec/google/chromeec/*/Kconfig"
13 changes: 12 additions & 1 deletion src/ec/google/chromeec/ec.c
Expand Up @@ -848,8 +848,19 @@ int google_chromeec_cbi_get_fw_config(uint64_t *fw_config)
if (cbi_get_uint32(&config, CBI_TAG_FW_CONFIG))
return -1;

/* FIXME: Yet to determine source of other 32 bits... */
*fw_config = (uint64_t)config;
/*
* If SSFC is configured to be part of FW_CONFIG, add it at the most significant
* 32 bits.
*/
if (CONFIG(EC_GOOGLE_CHROMEEC_INCLUDE_SSFC_IN_FW_CONFIG)) {
uint32_t ssfc;

if (google_chromeec_cbi_get_ssfc(&ssfc))
return -1;

*fw_config |= (uint64_t)ssfc << 32;
}
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions src/ec/system76/ec/Kconfig
Expand Up @@ -12,3 +12,8 @@ config EC_SYSTEM76_EC_COLOR_KEYBOARD
depends on EC_SYSTEM76_EC
bool
default n

config EC_SYSTEM76_EC_OLED
depends on EC_SYSTEM76_EC
bool
default n
82 changes: 41 additions & 41 deletions src/ec/system76/ec/acpi/battery.asl
Expand Up @@ -30,29 +30,29 @@ Device (BAT0)

Name (PBIF, Package (0x0D)
{
One,
0xFFFFFFFF,
0xFFFFFFFF,
One,
0x39D0,
Zero,
Zero,
0x40,
0x40,
"BAT",
"0001",
"LION",
"Notebook"
One, // 0 - Power Unit
0xFFFFFFFF, // 1 - Design Capacity
0xFFFFFFFF, // 2 - Last Full Charge Capacity
One, // 3 - Battery Technology
0xFFFFFFFF, // 4 - Design Voltage
Zero, // 5 - Design Capacity of Warning
Zero, // 6 - Design Capacity of Low
0x40, // 7 - Battery Capacity Granularity 1
0x40, // 8 - Battery Capacity Granularity 2
" ", // 9 - Model Number
" ", // 10 - Serial Number
" ", // 11 - Battery Type
" " // 12 - OEM Information
})
Method (IVBI, 0, NotSerialized)
{
PBIF [One] = 0xFFFFFFFF
PBIF [0x02] = 0xFFFFFFFF
PBIF [0x04] = 0xFFFFFFFF
PBIF [0x09] = " "
PBIF [0x0A] = " "
PBIF [0x0B] = " "
PBIF [0x0C] = " "
PBIF [1] = 0xFFFFFFFF
PBIF [2] = 0xFFFFFFFF
PBIF [4] = 0xFFFFFFFF
PBIF [9] = " "
PBIF [10] = " "
PBIF [11] = " "
PBIF [12] = " "
BFCC = Zero
}

Expand All @@ -61,20 +61,20 @@ Device (BAT0)
If (^^PCI0.LPCB.EC0.BAT0)
{
Local0 = (^^PCI0.LPCB.EC0.BDC0 & 0xFFFF)
PBIF [One] = Local0
PBIF [1] = Local0
Local0 = (^^PCI0.LPCB.EC0.BFC0 & 0xFFFF)
PBIF [0x02] = Local0
PBIF [2] = Local0
BFCC = Local0
Local0 = (^^PCI0.LPCB.EC0.BDV0 & 0xFFFF)
PBIF [0x04] = Local0
PBIF [4] = Local0
Local0 = (^^PCI0.LPCB.EC0.BCW0 & 0xFFFF)
PBIF [0x05] = Local0
PBIF [5] = Local0
Local0 = (^^PCI0.LPCB.EC0.BCL0 & 0xFFFF)
PBIF [0x06] = Local0
PBIF [0x09] = "BAT"
PBIF [0x0A] = "0001"
PBIF [0x0B] = "LION"
PBIF [0x0C] = "Notebook"
PBIF [6] = Local0
PBIF [9] = "BAT"
PBIF [10] = "0001"
PBIF [11] = "LION"
PBIF [12] = "Notebook"
}
Else
{
Expand All @@ -98,17 +98,17 @@ Device (BAT0)

Name (PBST, Package (0x04)
{
Zero,
0xFFFFFFFF,
0xFFFFFFFF,
0x3D90
Zero, // 0 - Battery state
0xFFFFFFFF, // 1 - Battery present rate
0xFFFFFFFF, // 2 - Battery remaining capacity
0xFFFFFFFF // 3 - Battery present voltage
})
Method (IVBS, 0, NotSerialized)
{
PBST [Zero] = Zero
PBST [One] = 0xFFFFFFFF
PBST [0x02] = 0xFFFFFFFF
PBST [0x03] = 0x2710
PBST [0] = Zero
PBST [1] = 0xFFFFFFFF
PBST [2] = 0xFFFFFFFF
PBST [3] = 0xFFFFFFFF
}

Method (UPBS, 0, NotSerialized)
Expand Down Expand Up @@ -139,10 +139,10 @@ Device (BAT0)

Local2 = (^^PCI0.LPCB.EC0.BRC0 & 0xFFFF)
Local3 = (^^PCI0.LPCB.EC0.BPV0 & 0xFFFF)
PBST [Zero] = Local0
PBST [One] = Local1
PBST [0x02] = Local2
PBST [0x03] = Local3
PBST [0] = Local0
PBST [1] = Local1
PBST [2] = Local2
PBST [3] = Local3
If ((BFCC != ^^PCI0.LPCB.EC0.BFC0))
{
Notify (BAT0, 0x81) // Information Change
Expand Down
10 changes: 10 additions & 0 deletions src/ec/system76/ec/acpi/ec.asl
Expand Up @@ -62,9 +62,13 @@ Device (\_SB.PCI0.LPCB.EC0)
}
}

Name (S3OS, Zero)
Method (PTS, 1, Serialized) {
Debug = Concatenate("EC: PTS: ", ToHexString(Arg0))
If (ECOK) {
// Save ECOS during sleep
S3OS = ECOS

// Clear wake cause
WFNO = Zero
}
Expand All @@ -73,6 +77,9 @@ Device (\_SB.PCI0.LPCB.EC0)
Method (WAK, 1, Serialized) {
Debug = Concatenate("EC: WAK: ", ToHexString(Arg0))
If (ECOK) {
// Restore ECOS after sleep
ECOS = S3OS

// Set current AC state
^^^^AC.ACFG = ADP

Expand All @@ -97,6 +104,9 @@ Device (\_SB.PCI0.LPCB.EC0)
Method (_Q0B, 0, NotSerialized) // Screen Toggle
{
Debug = "EC: Screen Toggle"
#if CONFIG(EC_SYSTEM76_EC_OLED)
Notify (^^^^S76D, 0x85)
#endif // CONFIG(EC_SYSTEM76_EC_OLED)
}

Method (_Q0C, 0, NotSerialized) // Mute
Expand Down
1 change: 1 addition & 0 deletions src/ec/system76/ec/acpi/s76.asl
Expand Up @@ -6,6 +6,7 @@
// 0x82 - backlight down
// 0x83 - backlight up
// 0x84 - backlight color change
// 0x85 - OLED screen toggle
Device (S76D) {
Name (_HID, "17761776")
Name (_UID, 0)
Expand Down
15 changes: 14 additions & 1 deletion src/include/acpi/acpi.h
Expand Up @@ -410,7 +410,8 @@ enum dmar_type {
DMAR_RMRR = 1,
DMAR_ATSR = 2,
DMAR_RHSA = 3,
DMAR_ANDD = 4
DMAR_ANDD = 4,
DMAR_SATC = 5
};

enum {
Expand Down Expand Up @@ -465,6 +466,15 @@ typedef struct dmar_andd_entry {
u8 device_name[];
} __packed dmar_andd_entry_t;

typedef struct dmar_satc_entry {
u16 type;
u16 length;
u8 flags;
u8 reserved;
u16 segment_number;
u8 device_scope[];
} __packed dmar_satc_entry_t;

/* DMAR (DMA Remapping Reporting Structure) */
typedef struct acpi_dmar {
acpi_header_t header;
Expand Down Expand Up @@ -1099,9 +1109,12 @@ unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr,
u32 proximity_domain);
unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number,
const char *device_name);
unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags,
u16 segment, const char *device_scope);
void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current);
void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current);
void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current);
void acpi_dmar_satc_fixup(unsigned long base, unsigned long current);
unsigned long acpi_create_dmar_ds_pci_br(unsigned long current,
u8 bus, u8 dev, u8 fn);
unsigned long acpi_create_dmar_ds_pci(unsigned long current,
Expand Down
30 changes: 28 additions & 2 deletions src/include/acpi/acpigen.h
Expand Up @@ -293,6 +293,10 @@ void acpigen_pop_len(void);
void acpigen_set_current(char *curr);
char *acpigen_get_current(void);
char *acpigen_write_package(int nr_el);
inline void acpigen_write_package_end(void)
{
acpigen_pop_len();
}
void acpigen_write_zero(void);
void acpigen_write_one(void);
void acpigen_write_ones(void);
Expand All @@ -319,9 +323,21 @@ void acpigen_write_name_byte(const char *name, uint8_t val);
void acpigen_write_name_integer(const char *name, uint64_t val);
void acpigen_write_coreboot_hid(enum coreboot_acpi_ids id);
void acpigen_write_scope(const char *name);
inline void acpigen_write_scope_end(void)
{
acpigen_pop_len();
}
void acpigen_write_method(const char *name, int nargs);
void acpigen_write_method_serialized(const char *name, int nargs);
inline void acpigen_write_method_end(void)
{
acpigen_pop_len();
}
void acpigen_write_device(const char *name);
inline void acpigen_write_device_end(void)
{
acpigen_pop_len();
}
void acpigen_write_PPC(u8 nr);
void acpigen_write_PPC_NVS(void);
void acpigen_write_empty_PCT(void);
Expand All @@ -345,6 +361,10 @@ void acpigen_write_xpss_package(const struct acpi_xpss_sw_pstate *pstate_value);
void acpigen_write_xpss_object(const struct acpi_xpss_sw_pstate *pstate_values,
size_t nentries);
void acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len);
inline void acpigen_write_processor_end(void)
{
acpigen_pop_len();
}
void acpigen_write_processor_package(const char *name,
unsigned int first_core,
unsigned int core_count);
Expand All @@ -362,6 +382,10 @@ void acpigen_write_irq(u16 mask);
void acpigen_write_uuid(const char *uuid);
void acpigen_write_power_res(const char *name, uint8_t level, uint16_t order,
const char * const dev_states[], size_t dev_states_count);
inline void acpigen_write_power_res_end(void)
{
acpigen_pop_len();
}
void acpigen_write_sleep(uint64_t sleep_ms);
void acpigen_write_store(void);
void acpigen_write_store_int_to_namestr(uint64_t src, const char *dst);
Expand All @@ -381,6 +405,10 @@ void acpigen_write_if_and(uint8_t arg1, uint8_t arg2);
void acpigen_write_if_lequal_op_op(uint8_t op, uint8_t val);
void acpigen_write_if_lequal_op_int(uint8_t op, uint64_t val);
void acpigen_write_if_lequal_namestr_int(const char *namestr, uint64_t val);
inline void acpigen_write_if_end(void)
{
acpigen_pop_len();
}
void acpigen_write_else(void);
void acpigen_write_shiftleft_op_int(uint8_t src_result, uint64_t count);
void acpigen_write_to_buffer(uint8_t src, uint8_t dst);
Expand All @@ -394,8 +422,6 @@ void acpigen_write_return_byte(uint8_t arg);
void acpigen_write_upc(enum acpi_upc_type type);
void acpigen_write_pld(const struct acpi_pld *pld);
void acpigen_write_ADR(uint64_t adr);
void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn);
void acpigen_write_ADR_pci_device(const struct device *dev);
struct soundwire_address;
void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address);
void acpigen_write_create_byte_field(uint8_t op, size_t byte_offset, const char *name);
Expand Down
17 changes: 17 additions & 0 deletions src/include/acpi/acpigen_pci.h
@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef ACPIGEN_PCI_H
#define ACPIGEN_PCI_H

#include <device/device.h>
#include <device/pci_def.h>
#include <device/pci_type.h>

void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn);
void acpigen_write_ADR_pci_device(const struct device *dev);

void acpigen_write_PRT_GSI_entry(unsigned int pci_dev, unsigned int acpi_pin, unsigned int gsi);
void acpigen_write_PRT_source_entry(unsigned int pci_dev, unsigned int acpi_pin,
const char *source_path, unsigned int index);

#endif /* ACPIGEN_PCI_H */
2 changes: 2 additions & 0 deletions src/include/bootmem.h
Expand Up @@ -17,6 +17,8 @@
* Start at 0x10000 to make sure that the caller doesn't provide LB_MEM tags.
*/
enum bootmem_type {
BM_MEM_INVALID = 0, /* Invalid type (used in optional arguments). */

BM_MEM_FIRST = 0x10000, /* First entry in this list */
BM_MEM_RAM, /* Memory anyone can use */
BM_MEM_RESERVED, /* Don't use this memory region */
Expand Down
306 changes: 256 additions & 50 deletions src/include/cbfs.h

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/include/cpu/intel/microcode.h
Expand Up @@ -7,7 +7,11 @@
void intel_update_microcode_from_cbfs(void);
/* Find a microcode that matches the revision and platform family returning
* NULL if none found. The found microcode is cached for faster access on
* subsequent calls of this function. */
* subsequent calls of this function.
*
* Since this function caches the found microcode (NULL or a valid microcode
* pointer), it is expected to be run from BSP before starting any other APs.
* It is not multithread safe otherwise. */
const void *intel_microcode_find(void);

/* It is up to the caller to determine if parallel loading is possible as
Expand Down
6 changes: 6 additions & 0 deletions src/include/cpu/x86/mp.h
Expand Up @@ -125,6 +125,12 @@ enum {
int mp_run_on_aps(void (*func)(void *), void *arg, int logical_cpu_num,
long expire_us);

/*
* Runs func on all APs excluding BSP, with a provision to run calls in parallel
* or serially per AP.
*/
int mp_run_on_all_aps(void (*func)(void *), void *arg, long expire_us, bool run_parallel);

/* Like mp_run_on_aps() but also runs func on BSP. */
int mp_run_on_all_cpus(void (*func)(void *), void *arg);

Expand Down
54 changes: 22 additions & 32 deletions src/include/cpu/x86/smm.h
Expand Up @@ -60,27 +60,36 @@ struct smm_runtime {
u32 save_state_size;
u32 num_cpus;
u32 gnvs_ptr;
/* STM's 32bit entry into SMI handler */
u32 start32_offset;
/* The apic_id_to_cpu provides a mapping from APIC id to CPU number.
* The CPU number is indicated by the index into the array by matching
* the default APIC id and value at the index. The stub loader
* initializes this array with a 1:1 mapping. If the APIC ids are not
* contiguous like the 1:1 mapping it is up to the caller of the stub
* loader to adjust this mapping. */
u8 apic_id_to_cpu[CONFIG_MAX_CPUS];
uintptr_t save_state_top[CONFIG_MAX_CPUS];
} __packed;

struct smm_module_params {
void *arg;
size_t cpu;
const struct smm_runtime *runtime;
/* A canary value that has been placed at the end of the stack.
* If (uintptr_t)canary != *canary then a stack overflow has occurred.
*/
const uintptr_t *canary;
};

/* These parameters are used by the SMM stub code. A pointer to the params
* is also passed to the C-base handler. */
struct smm_stub_params {
u32 stack_size;
u32 stack_top;
u32 c_handler;
u32 fxsave_area;
u32 fxsave_area_size;
/* The apic_id_to_cpu provides a mapping from APIC id to CPU number.
* The CPU number is indicated by the index into the array by matching
* the default APIC id and value at the index. The stub loader
* initializes this array with a 1:1 mapping. If the APIC ids are not
* contiguous like the 1:1 mapping it is up to the caller of the stub
* loader to adjust this mapping. */
u8 apic_id_to_cpu[CONFIG_MAX_CPUS];
/* STM's 32bit entry into SMI handler */
u32 start32_offset;
} __packed;

/* smm_handler_t is called with arg of smm_module_params pointer. */
typedef asmlinkage void (*smm_handler_t)(void *);

Expand Down Expand Up @@ -119,49 +128,30 @@ static inline bool smm_points_to_smram(const void *ptr, const size_t len)
* - num_concurrent_save_states - number of concurrent cpus needing save state
* space
* - handler - optional handler to call. Only used during SMM relocation setup.
* - handler_arg - optional argument to handler for SMM relocation setup. For
* loading the SMM module, the handler_arg is filled in with
* the address of the module's parameters (if present).
* - runtime - this field is a result only. The SMM runtime location is filled
* into this field so the code doing the loading can manipulate the
* runtime's assumptions. e.g. updating the APIC id to CPU map to
* handle sparse APIC id space.
* The following parameters are only used when X86_SMM_LOADER_VERSION2 is enabled.
* - smm_entry - entry address of first CPU thread, all others will be tiled
* below this address.
* - smm_main_entry_offset - default entry offset (e.g 0x8000)
* - smram_start - smaram starting address
* - smram_end - smram ending address
*/
struct smm_loader_params {
void *stack_top;
size_t per_cpu_stack_size;
size_t num_concurrent_stacks;

size_t real_cpu_save_state_size;
size_t per_cpu_save_state_size;
size_t num_concurrent_save_states;

smm_handler_t handler;
void *handler_arg;

struct smm_runtime *runtime;

/* The following are only used by X86_SMM_LOADER_VERSION2 */
#if CONFIG(X86_SMM_LOADER_VERSION2)
uintptr_t smm_entry;
uintptr_t smm_main_entry_offset;
uintptr_t smram_start;
uintptr_t smram_end;
#endif
struct smm_stub_params *stub_params;
};

/* Both of these return 0 on success, < 0 on failure. */
int smm_setup_relocation_handler(struct smm_loader_params *params);
int smm_load_module(void *smram, size_t size, struct smm_loader_params *params);

#if CONFIG(X86_SMM_LOADER_VERSION2)
u32 smm_get_cpu_smbase(unsigned int cpu_num);
#endif

/* Backup and restore default SMM region. */
void *backup_default_smm_area(void);
Expand Down
2 changes: 1 addition & 1 deletion src/include/device/device.h
Expand Up @@ -43,7 +43,7 @@ struct device_operations {
void (*final)(struct device *dev);
void (*scan_bus)(struct device *bus);
void (*enable)(struct device *dev);
void (*disable)(struct device *dev);
void (*vga_disable)(struct device *dev);
void (*reset_bus)(struct bus *bus);
#if CONFIG(GENERATE_SMBIOS_TABLES)
int (*get_smbios_data)(struct device *dev, int *handle,
Expand Down
1 change: 1 addition & 0 deletions src/include/device/mipi_ids.h
Expand Up @@ -21,6 +21,7 @@
#define MIPI_MFG_ID_REALTEK 0x025d
#define MIPI_DEV_ID_REALTEK_ALC5682 0x5682
#define MIPI_DEV_ID_REALTEK_ALC711 0x0711
#define MIPI_DEV_ID_REALTEK_ALC1308 0x1308

#define MIPI_MFG_ID_MAXIM 0x019f
#define MIPI_DEV_ID_MAXIM_MAX98373 0x8373
Expand Down
2 changes: 1 addition & 1 deletion src/include/device/pci.h
Expand Up @@ -31,7 +31,7 @@ struct pci_operations {
/* set the Subsystem IDs for the PCI device */
void (*set_subsystem)(struct device *dev, unsigned int vendor,
unsigned int device);
void (*set_L1_ss_latency)(struct device *dev, unsigned int off);
void (*get_ltr_max_latencies)(u16 *max_snoop, u16 *max_nosnoop);
};

struct pci_driver {
Expand Down
14 changes: 8 additions & 6 deletions src/include/device/pci_def.h
Expand Up @@ -386,12 +386,6 @@
#define PCI_EXP_DEVCAP 4 /* Device capabilities */
#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */
#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */
#define PCI_EXP_DEV_CAP2_OFFSET 0x24 /* Device Capabilities 2 offset */
/* LTR mechanism supported.Bit 11 of Device Cap 2 Register */
#define LTR_MECHANISM_SUPPORT (1 << 11)
#define PCI_EXP_DEV_CTL_STS2_CAP_OFFSET 0x28 /* Device Control 2 offset */
/* LTR mechanism enable. Bit 10 of Device Control 2 Register */
#define LTR_MECHANISM_EN (1 << 10)
#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */
#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
Expand Down Expand Up @@ -445,6 +439,10 @@
#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
#define PCI_EXP_RTCAP 30 /* Root Capabilities */
#define PCI_EXP_RTSTA 32 /* Root Status */
#define PCI_EXP_DEVCAP2 36 /* Device capabilities 2 */
#define PCI_EXP_DEVCAP2_LTR 0x0800 /* LTR supported */
#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
#define PCI_EXP_DEV2_LTR 0x0400 /* LTR enabled */

/* Extended Capabilities (PCI-X 2.0 and Express) */
#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
Expand Down Expand Up @@ -520,6 +518,10 @@
#define PCI_PWR_CAP 12 /* Capability */
#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */

/* Latency Tolerance Reporting */
#define PCI_LTR_MAX_SNOOP 4
#define PCI_LTR_MAX_NOSNOOP 6

/*
* The PCI interface treats multi-function devices as independent
* devices. The slot/function address of each device is encoded
Expand Down
15 changes: 15 additions & 0 deletions src/include/device/pci_ids.h
Expand Up @@ -475,6 +475,7 @@
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL18H_DF4 0x15EC
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL18H_DF5 0x15ED
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL18H_DF6 0x15EE
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL18H_DF7 0x15EF
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL60H_DF0 0x1448
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL60H_DF1 0x1449
#define PCI_DEVICE_ID_AMD_FAM17H_MODEL60H_DF2 0x144A
Expand Down Expand Up @@ -2767,8 +2768,18 @@
#define PCI_DEVICE_ID_INTEL_DENVERTON_TRACEHUB 0x19e1

/* Intel Ibex Peak (5 Series Chipset and 3400 Series Chipset) */
#define PCI_DID_INTEL_IBEXPEAK_LPC_P55 0x3b02
#define PCI_DID_INTEL_IBEXPEAK_LPC_PM55 0x3b03
#define PCI_DID_INTEL_IBEXPEAK_LPC_H55 0x3b06
#define PCI_DID_INTEL_IBEXPEAK_LPC_QM57 0x3b07
#define PCI_DID_INTEL_IBEXPEAK_LPC_H57 0x3b08
#define PCI_DID_INTEL_IBEXPEAK_LPC_HM55 0x3b09
#define PCI_DID_INTEL_IBEXPEAK_LPC_Q57 0x3b0a
#define PCI_DID_INTEL_IBEXPEAK_LPC_HM57 0x3b0b
#define PCI_DID_INTEL_IBEXPEAK_LPC_QS57 0x3b0f
#define PCI_DID_INTEL_IBEXPEAK_LPC_3400 0x3b12
#define PCI_DID_INTEL_IBEXPEAK_LPC_3420 0x3b14
#define PCI_DID_INTEL_IBEXPEAK_LPC_3450 0x3b16
#define PCI_DID_INTEL_IBEXPEAK_MOBILE_SATA_IDE_1 0x3b28
#define PCI_DID_INTEL_IBEXPEAK_MOBILE_SATA_AHCI 0x3b29
#define PCI_DID_INTEL_IBEXPEAK_MOBILE_SATA_IDE_2 0x3b2e
Expand Down Expand Up @@ -3026,6 +3037,7 @@
#define PCI_DEVICE_ID_INTEL_ADP_M_ESPI_29 0x549d
#define PCI_DEVICE_ID_INTEL_ADP_M_ESPI_30 0x549e
#define PCI_DEVICE_ID_INTEL_ADP_M_ESPI_31 0x549f
#define PCI_DEVICE_ID_INTEL_SPR_ESPI_1 0x1b80

/* Intel PCIE device ids */
#define PCI_DEVICE_ID_INTEL_LPT_H_PCIE_RP1 0x8c10
Expand Down Expand Up @@ -3664,6 +3676,8 @@
#define PCI_DEVICE_ID_INTEL_ADP_M_SPI1 0x54ab
#define PCI_DEVICE_ID_INTEL_ADP_M_SPI2 0x54fb

#define PCI_DEVICE_ID_INTEL_SPR_HWSEQ_SPI 0x1bca

/* Intel IGD device Ids */
#define PCI_DEVICE_ID_INTEL_SKL_GT1F_DT2 0x1902
#define PCI_DEVICE_ID_INTEL_SKL_GT1_SULTM 0x1906
Expand Down Expand Up @@ -3900,6 +3914,7 @@
/* Intel SMBUS device Ids */
#define PCI_DEVICE_ID_INTEL_LPT_H_SMBUS 0x8c22
#define PCI_DEVICE_ID_INTEL_LPT_LP_SMBUS 0x9c22
#define PCI_DEVICE_ID_INTEL_WPT_LP_SMBUS 0x9ca2
#define PCI_DEVICE_ID_INTEL_APL_SMBUS 0x5ad4
#define PCI_DEVICE_ID_INTEL_SPT_LP_SMBUS 0x9d23
#define PCI_DEVICE_ID_INTEL_SPT_H_SMBUS 0xa123
Expand Down
3 changes: 2 additions & 1 deletion src/include/device/pci_type.h
Expand Up @@ -16,7 +16,8 @@ typedef u32 pci_devfn_t;
(((DEV) & 0x1F) << 15) | \
(((FN) & 0x07) << 12))

#define PCI_DEV_INVALID (0xffffffffU)
#define PCI_DEV_INVALID (0xffffffffU)
#define PCI_DEVFN_INVALID (0xffffffffU)

#if 1
/* FIXME: For most of the time in ramstage, we get valid device pointer
Expand Down
2 changes: 0 additions & 2 deletions src/include/device/pciexp.h
Expand Up @@ -26,11 +26,9 @@ void pciexp_scan_bridge(struct device *dev);

extern struct device_operations default_pciexp_ops_bus;

#if CONFIG(PCIEXP_HOTPLUG)
void pciexp_hotplug_scan_bridge(struct device *dev);

extern struct device_operations default_pciexp_hotplug_ops_bus;
#endif /* CONFIG(PCIEXP_HOTPLUG) */

unsigned int pciexp_find_extended_cap(struct device *dev, unsigned int cap);
#endif /* DEVICE_PCIEXP_H */
10 changes: 0 additions & 10 deletions src/include/fit_payload.h

This file was deleted.

7 changes: 5 additions & 2 deletions src/include/memory_info.h
Expand Up @@ -96,8 +96,11 @@ struct dimm_info {
} __packed;

struct memory_info {
/* controller specific */
bool ecc_capable;
/*
* SMBIOS error correction type.
* See the smbios.h smbios_memory_array_ecc enum.
*/
uint8_t ecc_type;
/* Maximum capacity the DRAM controller/mainboard supports */
uint32_t max_capacity_mib;
/* Maximum number of DIMMs the DRAM controller/mainboard supports */
Expand Down
68 changes: 26 additions & 42 deletions src/include/program_loading.h
Expand Up @@ -3,6 +3,7 @@
#define PROGRAM_LOADING_H

#include <bootmem.h>
#include <commonlib/bsd/cbfs_serialized.h>
#include <commonlib/region.h>
#include <stdint.h>
#include <stddef.h>
Expand Down Expand Up @@ -40,18 +41,13 @@ void arch_segment_loaded(uintptr_t start, size_t size, int flags);

/* Representation of a program. */
struct prog {
/* The region_device is the source of program content to load. After
* loading program it represents the memory region of the stages and
* payload. For architectures that use a bounce buffer
* then it would represent the bounce buffer. */
enum prog_type type;
uint32_t cbfs_type;
enum cbfs_type cbfs_type;
const char *name;
struct region_device rdev;
/* Entry to program with optional argument. It's up to the architecture
* to decide if argument is passed. */
void (*entry)(void *);
void *arg;
void *start; /* Program start in memory. */
size_t size; /* Program size in memory (including BSS). */
void (*entry)(void *); /* Function pointer to entry point. */
void *arg; /* Optional argument (only valid for some archs). */
};

#define PROG_INIT(type_, name_) \
Expand All @@ -70,26 +66,19 @@ static inline enum prog_type prog_type(const struct prog *prog)
return prog->type;
}

static inline uint32_t prog_cbfs_type(const struct prog *prog)
static inline enum cbfs_type prog_cbfs_type(const struct prog *prog)
{
return prog->cbfs_type;
}

static inline struct region_device *prog_rdev(struct prog *prog)
{
return &prog->rdev;
}

/* Only valid for loaded programs. */
static inline size_t prog_size(const struct prog *prog)
{
return region_device_sz(&prog->rdev);
return prog->size;
}

/* Only valid for loaded programs. */
static inline void *prog_start(const struct prog *prog)
{
return rdev_mmap_full(&prog->rdev);
return prog->start;
}

static inline void *prog_entry(const struct prog *prog)
Expand All @@ -105,15 +94,18 @@ static inline void *prog_entry_arg(const struct prog *prog)
/* region_device representing the 32-bit flat address space. */
extern const struct mem_region_device addrspace_32bit;

static inline void prog_memory_init(struct prog *prog, uintptr_t ptr,
size_t size)
/* Can be used to get an rdev representation of program area in memory. */
static inline void prog_chain_rdev(const struct prog *prog,
struct region_device *rdev_out)
{
rdev_chain(&prog->rdev, &addrspace_32bit.rdev, ptr, size);
rdev_chain(rdev_out, &addrspace_32bit.rdev,
(uintptr_t)prog->start, prog->size);
}

static inline void prog_set_area(struct prog *prog, void *start, size_t size)
{
prog_memory_init(prog, (uintptr_t)start, size);
prog->start = start;
prog->size = size;
}

static inline void prog_set_entry(struct prog *prog, void *e, void *arg)
Expand All @@ -127,13 +119,10 @@ static inline void prog_set_arg(struct prog *prog, void *arg)
prog->arg = arg;
}

/* Locate the identified program to run. Return 0 on success. < 0 on error. */
int prog_locate(struct prog *prog);
/* The prog_locate_hook() is called prior to CBFS traversal. The hook can be
* used to implement policy that allows or prohibits further progress through
* prog_locate(). The type and name field within struct prog are the only valid
* fields. A 0 return value allows further progress while a non-zero return
* value prohibits further progress */
* used to implement policy that allows or prohibits further program loading.
* The type and name field within struct prog are the only valid fields. A 0
* return value allows loading while a non-zero return value prohibits it. */
int prog_locate_hook(struct prog *prog);

/* Run the program described by prog. */
Expand All @@ -146,17 +135,6 @@ void arch_prog_run(struct prog *prog);
* code it needs to that as well. */
void platform_prog_run(struct prog *prog);

struct prog_loader_ops {
const char *name;
/* Determine if the loader is the active one. If so returns 1 else 0
* or < 0 on error. */
int (*is_loader_active)(struct prog *prog);
/* Returns < 0 on error or 0 on success. This function locates
* the rdev representing the file data associated with the passed in
* prog. */
int (*locate)(struct prog *prog);
};

/************************
* ROMSTAGE LOADING *
************************/
Expand All @@ -165,7 +143,7 @@ struct prog_loader_ops {
void run_romstage(void);

/* Runtime selector for CBFS_PREFIX of romstage. */
int legacy_romstage_selector(struct prog *romstage);
int legacy_romstage_select_and_load(struct prog *romstage);

/************************
* RAMSTAGE LOADING *
Expand Down Expand Up @@ -197,5 +175,11 @@ void payload_run(void);
*/
bool selfload_check(struct prog *payload, enum bootmem_type dest_type);
bool selfload(struct prog *payload);
/* Like selfload_check() but with the payload data already mapped to memory. */
bool selfload_mapped(struct prog *payload, void *mapping,
enum bootmem_type dest_type);

/* Load a FIT payload. The payload data must already be mapped to memory. */
void fit_payload(struct prog *payload, void *data);

#endif /* PROGRAM_LOADING_H */
2 changes: 2 additions & 0 deletions src/include/sar.h
Expand Up @@ -41,6 +41,8 @@ struct wifi_sar_limits {
*/
int get_wifi_sar_limits(struct wifi_sar_limits *sar_limits);

#define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex"

const char *get_wifi_sar_cbfs_filename(void);

#endif /* _SAR_H_ */
9 changes: 8 additions & 1 deletion src/include/smbios.h
Expand Up @@ -61,7 +61,6 @@ void smbios_type0_bios_version(uintptr_t address);

void smbios_ec_revision(uint8_t *ec_major_revision, uint8_t *ec_minor_revision);

unsigned int smbios_memory_error_correction_type(struct memory_info *meminfo);
unsigned int smbios_processor_external_clock(void);
unsigned int smbios_processor_characteristics(void);
struct cpuid_result;
Expand Down Expand Up @@ -312,6 +311,12 @@ struct smbios_type1 {
u8 eos[2];
} __packed;

#define SMBIOS_FEATURE_FLAGS_HOSTING_BOARD (1 << 0)
#define SMBIOS_FEATURE_FLAGS_REQUIRES_DAUGHTER_CARD (1 << 1)
#define SMBIOS_FEATURE_FLAGS_REMOVABLE (1 << 2)
#define SMBIOS_FEATURE_FLAGS_REPLACEABLE (1 << 3)
#define SMBIOS_FEATURE_FLAGS_HOT_SWAPPABLE (1 << 4)

typedef enum {
SMBIOS_BOARD_TYPE_UNKNOWN = 0x01,
SMBIOS_BOARD_TYPE_OTHER = 0x02,
Expand Down Expand Up @@ -958,6 +963,8 @@ struct smbios_type127 {

void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id,
struct smbios_type17 *t);
void smbios_fill_dimm_asset_tag(const struct dimm_info *dimm,
struct smbios_type17 *t);
void smbios_fill_dimm_locator(const struct dimm_info *dimm,
struct smbios_type17 *t);

Expand Down
3 changes: 1 addition & 2 deletions src/include/spd_bin.h
Expand Up @@ -43,8 +43,7 @@ struct spd_block {
};

void print_spd_info(uint8_t spd[]);
/* Return 0 on success & -1 on failure */
int get_spd_cbfs_rdev(struct region_device *spd_rdev, u8 spd_index);
uintptr_t spd_cbfs_map(u8 spd_index);
void dump_spd_info(struct spd_block *blk);
void get_spd_smbus(struct spd_block *blk);

Expand Down
6 changes: 3 additions & 3 deletions src/include/symbols.h
Expand Up @@ -32,9 +32,9 @@ DECLARE_OPTIONAL_REGION(timestamp)
DECLARE_REGION(preram_cbmem_console)
DECLARE_REGION(cbmem_init_hooks)
DECLARE_REGION(stack)
DECLARE_REGION(preram_cbfs_cache)
DECLARE_REGION(postram_cbfs_cache)
DECLARE_REGION(cbfs_cache)
DECLARE_OPTIONAL_REGION(preram_cbfs_cache)
DECLARE_OPTIONAL_REGION(postram_cbfs_cache)
DECLARE_OPTIONAL_REGION(cbfs_cache)
DECLARE_REGION(cbfs_mcache)
DECLARE_REGION(fmap_cache)
DECLARE_REGION(tpm_tcpa_log)
Expand Down
298 changes: 163 additions & 135 deletions src/lib/cbfs.c

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions src/lib/fit_payload.c
Expand Up @@ -13,7 +13,6 @@
#include <timestamp.h>
#include <string.h>
#include <lib.h>
#include <fit_payload.h>
#include <boardid.h>

/* Pack the device_tree and place it at given position. */
Expand Down Expand Up @@ -168,31 +167,23 @@ static void add_cb_fdt_data(struct device_tree *tree)
/*
* Parse the uImage FIT, choose a configuration and extract images.
*/
void fit_payload(struct prog *payload)
void fit_payload(struct prog *payload, void *data)
{
struct device_tree *dt = NULL;
struct region kernel = {0}, fdt = {0}, initrd = {0};
void *data;

data = rdev_mmap_full(prog_rdev(payload));

if (data == NULL)
return;

printk(BIOS_INFO, "FIT: Examine payload %s\n", payload->name);

struct fit_config_node *config = fit_load(data);

if (!config) {
printk(BIOS_ERR, "ERROR: Could not load FIT\n");
rdev_munmap(prog_rdev(payload), data);
return;
}

dt = unpack_fdt(config->fdt);
if (!dt) {
printk(BIOS_ERR, "ERROR: Failed to unflatten the FDT.\n");
rdev_munmap(prog_rdev(payload), data);
return;
}

Expand Down Expand Up @@ -225,7 +216,6 @@ void fit_payload(struct prog *payload)
if (!fit_payload_arch(payload, config, &kernel, &fdt, &initrd)) {
printk(BIOS_ERR, "ERROR: Failed to find free memory region\n");
bootmem_dump_ranges();
rdev_munmap(prog_rdev(payload), data);
return;
}

Expand All @@ -240,7 +230,6 @@ void fit_payload(struct prog *payload)
extract(&initrd, config->ramdisk)) {
printk(BIOS_ERR, "ERROR: Failed to extract initrd\n");
prog_set_entry(payload, NULL, NULL);
rdev_munmap(prog_rdev(payload), data);
return;
}

Expand All @@ -249,11 +238,8 @@ void fit_payload(struct prog *payload)
if (extract(&kernel, config->kernel)) {
printk(BIOS_ERR, "ERROR: Failed to extract kernel\n");
prog_set_entry(payload, NULL, NULL);
rdev_munmap(prog_rdev(payload), data);
return;
}

timestamp_add_now(TS_START_KERNEL);

rdev_munmap(prog_rdev(payload), data);
}
20 changes: 6 additions & 14 deletions src/lib/nhlt.c
Expand Up @@ -149,9 +149,8 @@ int nhlt_endpoint_add_formats(struct nhlt_endpoint *endp,

for (i = 0; i < num_formats; i++) {
struct nhlt_format *fmt;
struct cbfsf file;
struct region_device settings;
void *settings_data;
size_t size;
const struct nhlt_format_config *cfg = &formats[i];

fmt = nhlt_add_format(endp, cfg->num_channels,
Expand All @@ -167,23 +166,16 @@ int nhlt_endpoint_add_formats(struct nhlt_endpoint *endp,
continue;

/* Find the settings file in CBFS and place it in format. */
if (cbfs_boot_locate(&file, cfg->settings_file, NULL))
settings_data = cbfs_map(cfg->settings_file, &size);
if (!settings_data)
return -1;

cbfs_file_data(&settings, &file);

settings_data = rdev_mmap_full(&settings);

if (settings_data == NULL)
return -1;

if (nhlt_format_append_config(fmt, settings_data,
region_device_sz(&settings))) {
rdev_munmap(&settings, settings_data);
if (nhlt_format_append_config(fmt, settings_data, size)) {
cbfs_unmap(settings_data);
return -1;
}

rdev_munmap(&settings, settings_data);
cbfs_unmap(settings_data);
}

return 0;
Expand Down
47 changes: 15 additions & 32 deletions src/lib/prog_loaders.c
Expand Up @@ -14,50 +14,29 @@
#include <stage_cache.h>
#include <symbols.h>
#include <timestamp.h>
#include <fit_payload.h>
#include <security/vboot/vboot_common.h>

/* Only can represent up to 1 byte less than size_t. */
const struct mem_region_device addrspace_32bit =
MEM_REGION_DEV_RO_INIT(0, ~0UL);

int prog_locate(struct prog *prog)
{
struct cbfsf file;

if (prog_locate_hook(prog))
return -1;

if (cbfs_boot_locate(&file, prog_name(prog), NULL))
return -1;

cbfsf_file_type(&file, &prog->cbfs_type);

cbfs_file_data(prog_rdev(prog), &file);

return 0;
}

void run_romstage(void)
{
struct prog romstage =
PROG_INIT(PROG_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage");

vboot_run_logic();

timestamp_add_now(TS_START_COPYROM);

if (ENV_X86 && CONFIG(BOOTBLOCK_NORMAL)) {
if (legacy_romstage_selector(&romstage))
if (legacy_romstage_select_and_load(&romstage))
goto fail;
} else {
if (prog_locate(&romstage))
if (cbfs_prog_stage_load(&romstage))
goto fail;
}

timestamp_add_now(TS_START_COPYROM);

if (cbfs_prog_stage_load(&romstage))
goto fail;

timestamp_add_now(TS_END_COPYROM);

console_time_report();
Expand All @@ -78,6 +57,7 @@ static void run_ramstage_from_resume(struct prog *ramstage)
/* Load the cached ramstage to runtime location. */
stage_cache_load_stage(STAGE_RAMSTAGE, ramstage);

ramstage->cbfs_type = CBFS_TYPE_STAGE;
prog_set_arg(ramstage, cbmem_top());

if (prog_entry(ramstage) != NULL) {
Expand Down Expand Up @@ -120,9 +100,6 @@ void run_ramstage(void)

vboot_run_logic();

if (prog_locate(&ramstage))
goto fail;

timestamp_add_now(TS_START_COPYRAM);

if (ENV_X86) {
Expand Down Expand Up @@ -159,24 +136,30 @@ void payload_load(void)

timestamp_add_now(TS_LOAD_PAYLOAD);

if (prog_locate(payload))
if (prog_locate_hook(payload))
goto out;

payload->cbfs_type = CBFS_TYPE_QUERY;
void *mapping = cbfs_type_map(prog_name(payload), NULL, &payload->cbfs_type);
if (!mapping)
goto out;

switch (prog_cbfs_type(payload)) {
case CBFS_TYPE_SELF: /* Simple ELF */
selfload_check(payload, BM_MEM_RAM);
selfload_mapped(payload, mapping, BM_MEM_RAM);
break;
case CBFS_TYPE_FIT: /* Flattened image tree */
if (CONFIG(PAYLOAD_FIT_SUPPORT)) {
fit_payload(payload);
fit_payload(payload, mapping);
break;
} /* else fall-through */
default:
die_with_post_code(POST_INVALID_ROM,
"Unsupported payload type.\n");
"Unsupported payload type %d.\n", payload->cbfs_type);
break;
}

cbfs_unmap(mapping);
out:
if (prog_entry(payload) == NULL)
die_with_post_code(POST_INVALID_ROM, "Payload not loaded.\n");
Expand Down
73 changes: 31 additions & 42 deletions src/lib/rmodule.c
Expand Up @@ -12,6 +12,8 @@
/* Change this define to get more verbose debugging for module loading. */
#define PK_ADJ_LEVEL BIOS_NEVER

const size_t region_alignment = MIN_UNSAFE(DYN_CBMEM_ALIGN_SIZE, 4096);

static inline int rmodule_is_loaded(const struct rmodule *module)
{
return module->location != NULL;
Expand Down Expand Up @@ -189,20 +191,26 @@ int rmodule_load(void *base, struct rmodule *module)
return 0;
}

int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
size_t *region_size, int *load_offset)
static void *rmodule_cbfs_allocator(void *rsl_arg, size_t unused,
union cbfs_mdata *mdata)
{
/* region_alignment must be a power of 2. */
if (region_alignment & (region_alignment - 1))
BUG();

if (region_alignment < 4096)
region_alignment = 4096;
struct rmod_stage_load *rsl = rsl_arg;

assert(IS_POWER_OF_2(region_alignment) &&
region_alignment >= sizeof(struct rmodule_header));

/* The CBFS core just passes us the decompressed size of the file, but
we need to know the memlen of the binary image. We need to find and
parse the stage header explicitly. */
const struct cbfs_file_attr_stageheader *sattr = cbfs_find_attr(mdata,
CBFS_FILE_ATTR_TAG_STAGEHEADER, sizeof(*sattr));
if (!sattr) {
printk(BIOS_ERR, "rmodule '%s' has no stage header!\n",
rsl->prog->name);
return NULL;
}

/* Sanity check rmodule_header size. The code below assumes it is less
* than the minimum alignment required. */
if (region_alignment < sizeof(struct rmodule_header))
BUG();
const size_t memlen = be32toh(sattr->memlen);

/* Place the rmodule according to alignment. The rmodule files
* themselves are packed as a header and a payload, however the rmodule
Expand All @@ -214,7 +222,7 @@ int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
* to place the rmodule so that the program falls on the aligned
* address with the header just before it. Therefore, we need at least
* a page to account for the size of the header. */
*region_size = ALIGN(rmodule_size + region_alignment, 4096);
size_t region_size = ALIGN(memlen + region_alignment, 4096);
/* The program starts immediately after the header. However,
* it needs to be aligned to a 4KiB boundary. Therefore, adjust the
* program location so that the program lands on a page boundary. The
Expand All @@ -230,52 +238,33 @@ int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
* | >= 0 bytes from alignment |
* +--------------------------------+ region_alignment
*/
*load_offset = region_alignment;

return region_alignment - sizeof(struct rmodule_header);
uint8_t *stage_region = cbmem_add(rsl->cbmem_id, region_size);
if (stage_region == NULL)
return NULL;

return stage_region + region_alignment - sizeof(struct rmodule_header);
}

int rmodule_stage_load(struct rmod_stage_load *rsl)
{
struct rmodule rmod_stage;
size_t region_size;
char *stage_region;
int rmodule_offset;
int load_offset;
struct cbfs_stage stage;
void *rmod_loc;
struct region_device *fh;

if (rsl->prog == NULL || prog_name(rsl->prog) == NULL)
return -1;

fh = prog_rdev(rsl->prog);

if (rdev_readat(fh, &stage, 0, sizeof(stage)) != sizeof(stage))
if (prog_locate_hook(rsl->prog))
return -1;

rmodule_offset =
rmodule_calc_region(DYN_CBMEM_ALIGN_SIZE,
stage.memlen, &region_size, &load_offset);

stage_region = cbmem_add(rsl->cbmem_id, region_size);

if (stage_region == NULL)
return -1;

rmod_loc = &stage_region[rmodule_offset];

printk(BIOS_INFO, "Decompressing stage %s @ %p (%d bytes)\n",
prog_name(rsl->prog), rmod_loc, stage.memlen);

if (!cbfs_load_and_decompress(fh, sizeof(stage), stage.len, rmod_loc,
stage.memlen, stage.compression))
void *rmod_loc = cbfs_alloc(prog_name(rsl->prog),
rmodule_cbfs_allocator, rsl, NULL);
if (!rmod_loc)
return -1;

if (rmodule_parse(rmod_loc, &rmod_stage))
return -1;

if (rmodule_load(&stage_region[load_offset], &rmod_stage))
if (rmodule_load(rmod_loc + sizeof(struct rmodule_header), &rmod_stage))
return -1;

prog_set_area(rsl->prog, rmod_stage.location,
Expand Down
50 changes: 24 additions & 26 deletions src/lib/selfboot.c
Expand Up @@ -126,12 +126,15 @@ static int last_loadable_segment(struct cbfs_payload_segment *seg)
}

static int check_payload_segments(struct cbfs_payload_segment *cbfssegs,
void *args)
enum bootmem_type dest_type)
{
uint8_t *dest;
size_t memsz;
struct cbfs_payload_segment *seg, segment;
enum bootmem_type dest_type = *(enum bootmem_type *)args;

/* dest_type == INVALID means we're not supposed to check anything. */
if (dest_type == BM_MEM_INVALID)
return 0;

for (seg = cbfssegs;; ++seg) {
printk(BIOS_DEBUG, "Checking segment from ROM address %p\n", seg);
Expand Down Expand Up @@ -224,50 +227,45 @@ __weak int payload_arch_usable_ram_quirk(uint64_t start, uint64_t size)
return 0;
}

static void *selfprepare(struct prog *payload)
{
void *data;
data = rdev_mmap_full(prog_rdev(payload));
return data;
}

static bool _selfload(struct prog *payload, checker_t f, void *args)
bool selfload_mapped(struct prog *payload, void *mapping,
enum bootmem_type dest_type)
{
uintptr_t entry = 0;
struct cbfs_payload_segment *cbfssegs;
void *data;

data = selfprepare(payload);
if (data == NULL)
return false;

cbfssegs = &((struct cbfs_payload *)data)->segments;
cbfssegs = &((struct cbfs_payload *)mapping)->segments;

if (f && f(cbfssegs, args))
goto out;
if (check_payload_segments(cbfssegs, dest_type))
return false;

if (load_payload_segments(cbfssegs, &entry))
goto out;
return false;

printk(BIOS_SPEW, "Loaded segments\n");

rdev_munmap(prog_rdev(payload), data);

/* Pass cbtables to payload if architecture desires it. */
prog_set_entry(payload, (void *)entry, cbmem_find(CBMEM_ID_CBTABLE));

return true;
out:
rdev_munmap(prog_rdev(payload), data);
return false;
}

bool selfload_check(struct prog *payload, enum bootmem_type dest_type)
{
return _selfload(payload, check_payload_segments, &dest_type);
if (prog_locate_hook(payload))
return false;

payload->cbfs_type = CBFS_TYPE_SELF;
void *mapping = cbfs_type_map(prog_name(payload), NULL, &payload->cbfs_type);
if (!mapping)
return false;

bool ret = selfload_mapped(payload, mapping, dest_type);

cbfs_unmap(mapping);
return ret;
}

bool selfload(struct prog *payload)
{
return _selfload(payload, NULL, 0);
return selfload_check(payload, BM_MEM_INVALID);
}
15 changes: 7 additions & 8 deletions src/lib/spd_bin.c
Expand Up @@ -210,17 +210,16 @@ void print_spd_info(uint8_t spd[])
}
}

int get_spd_cbfs_rdev(struct region_device *spd_rdev, u8 spd_index)
uintptr_t spd_cbfs_map(u8 spd_index)
{
struct cbfsf fh;
enum cbfs_type cbfs_type = CBFS_TYPE_SPD;
size_t size;

uint32_t cbfs_type = CBFS_TYPE_SPD;
void *map = cbfs_type_map("spd.bin", &size, &cbfs_type);
if (!map || size < (spd_index + 1) * CONFIG_DIMM_SPD_SIZE)
return 0;

if (cbfs_boot_locate(&fh, "spd.bin", &cbfs_type) < 0)
return -1;
cbfs_file_data(spd_rdev, &fh);
return rdev_chain(spd_rdev, spd_rdev, spd_index * CONFIG_DIMM_SPD_SIZE,
CONFIG_DIMM_SPD_SIZE);
return (uintptr_t)map + spd_index * CONFIG_DIMM_SPD_SIZE;
}

#if CONFIG_DIMM_SPD_SIZE == 128
Expand Down
20 changes: 1 addition & 19 deletions src/mainboard/amd/bilby/Kconfig
Expand Up @@ -47,7 +47,7 @@ config SUPERIO_ADDR_BASE

config CBFS_SIZE
hex
default 0xfcf000 # Maximum size for the Bilby FMAP
default 0xfef000 # Maximum size for the Bilby FMAP

config MAINBOARD_DIR
string
Expand All @@ -65,24 +65,6 @@ config ONBOARD_VGA_IS_PRIMARY
bool
default y

config AMD_FWM_POSITION_INDEX
int
default 4
help
TODO: might need to be adapted for better placement of files in cbfs

config MANDOLIN_HAVE_MCHP_FW
bool "Have Microchip EC firmware?"
default n

config MANDOLIN_MCHP_FW_FILE
string
depends on MANDOLIN_HAVE_MCHP_FW
default "3rdparty/blobs/mainboard/amd/mandolin/EC_mandolin.bin" if BOARD_AMD_MANDOLIN
default "3rdparty/blobs/mainboard/amd/mandolin/EC_cereme.bin" if BOARD_AMD_BILBY
help
The EC firmware blob is usually the first 128kByte of the stock
firmware image.
if !AMD_LPC_DEBUG_CARD
choice
prompt "State of IOMux for LPC/eMMC signals"
Expand Down
16 changes: 0 additions & 16 deletions src/mainboard/amd/bilby/Makefile.inc
Expand Up @@ -14,20 +14,4 @@ ifeq ($(CONFIG_BOARD_AMD_BILBY),y)
APCB_SOURCES = $(MAINBOARD_BLOBS_DIR)/APCB_bilby.bin
endif

ifeq ($(CONFIG_MANDOLIN_HAVE_MCHP_FW),y)

$(call add_intermediate, add_mchp_fw)
$(CBFSTOOL) $(obj)/coreboot.pre write -r EC -f $(CONFIG_MANDOLIN_MCHP_FW_FILE) --fill-upward

else
files_added:: warn_no_mchp
endif # CONFIG_MANDOLIN_HAVE_MCHP_FW

PHONY+=warn_no_mchp
warn_no_mchp:
printf "\n\t** WARNING **\n"
printf "coreboot has been built without an the Microchip EC.\n"
printf "Do not flash this image. Your Mandolin's power button\n"
printf "will not respond when you press it.\n\n"

CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/acpi
1 change: 0 additions & 1 deletion src/mainboard/amd/bilby/board.fmd
@@ -1,6 +1,5 @@
FLASH@0xFF000000 16M {
BIOS {
EC 128K
RW_MRC_CACHE 64K
FMAP 4K
COREBOOT(CBFS)
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/amd/bilby/dsdt.asl
Expand Up @@ -25,7 +25,7 @@ DefinitionBlock (
#include <cpu.asl>

/* Contains the supported sleep states for this chipset */
#include <sleepstates.asl>
#include <soc/amd/common/acpi/sleepstates.asl>

/* Contains _SWS methods */
#include <soc/amd/common/acpi/acpi_wake_source.asl>
Expand Down
8 changes: 3 additions & 5 deletions src/mainboard/amd/bilby/mainboard.c
Expand Up @@ -75,7 +75,6 @@ static void init_tables(void)

static void pirq_setup(void)
{
init_tables();
intr_data_ptr = fch_apic_routing;
picr_data_ptr = fch_pic_routing;
}
Expand All @@ -96,15 +95,14 @@ static void mainboard_init(void *chip_info)
mainboard_program_emmc_gpios();
}

static void bilby_enable(struct device *dev)
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");

init_tables();
/* Initialize the PIRQ data structures for consumption */
pirq_setup();
}

struct chip_operations mainboard_ops = {
.init = mainboard_init,
.enable_dev = bilby_enable,
.enable_dev = mainboard_enable,
};
1 change: 0 additions & 1 deletion src/mainboard/amd/gardenia/Kconfig
Expand Up @@ -8,7 +8,6 @@ config BOARD_SPECIFIC_OPTIONS
select AMD_APU_STONEYRIDGE
select AMD_APU_PKG_FP4
select HAVE_PIRQ_TABLE
select HAVE_MP_TABLE
select HAVE_ACPI_TABLES
select BOARD_ROMSIZE_KB_8192
select GFXUMA
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/amd/gardenia/dsdt.asl
Expand Up @@ -28,7 +28,7 @@ DefinitionBlock (
#include <cpu.asl>

/* Contains the supported sleep states for this chipset */
#include <sleepstates.asl>
#include <soc/amd/common/acpi/sleepstates.asl>

/* Contains the Sleep methods (WAK, PTS, GTS, etc.) */
#include "acpi/sleep.asl"
Expand Down
7 changes: 2 additions & 5 deletions src/mainboard/amd/gardenia/mainboard.c
Expand Up @@ -75,16 +75,13 @@ static void mainboard_init(void *chip_info)
/*************************************************
* enable the dedicated function in gardenia board.
*************************************************/
static void gardenia_enable(struct device *dev)
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard "
CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");

/* Initialize the PIRQ data structures for consumption */
pirq_setup();
}

struct chip_operations mainboard_ops = {
.init = mainboard_init,
.enable_dev = gardenia_enable,
.enable_dev = mainboard_enable,
};
148 changes: 0 additions & 148 deletions src/mainboard/amd/gardenia/mptable.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/mainboard/amd/inagua/Kconfig
Expand Up @@ -10,7 +10,6 @@ config BOARD_SPECIFIC_OPTIONS
select SUPERIO_SMSC_KBC1100
select HAVE_OPTION_TABLE
select HAVE_PIRQ_TABLE
select HAVE_MP_TABLE
select HAVE_ACPI_TABLES
select BOARD_ROMSIZE_KB_2048
select GFXUMA
Expand Down Expand Up @@ -39,10 +38,6 @@ config ONBOARD_VGA_IS_PRIMARY
bool
default y

config VGA_BIOS
bool
default n

#config VGA_BIOS_FILE
# string "VGA BIOS path and filename"
# depends on VGA_BIOS
Expand Down
4 changes: 2 additions & 2 deletions src/mainboard/amd/inagua/acpi/routing.asl
Expand Up @@ -289,14 +289,14 @@ Scope(\_SB) {
Package(){0x0000FFFF, 3, 0, 16 },
})

Name(PSa, Package(){
Name(PSA, Package(){
/* PCIe slot - Hooked to PCIe slot 10 */
Package(){0x0000FFFF, 0, INTD, 0 },
Package(){0x0000FFFF, 1, INTA, 0 },
Package(){0x0000FFFF, 2, INTB, 0 },
Package(){0x0000FFFF, 3, INTC, 0 },
})
Name(APSa, Package(){
Name(APSA, Package(){
/* PCIe slot - Hooked to PCIe slot 10 */
Package(){0x0000FFFF, 0, 0, 18 },
Package(){0x0000FFFF, 1, 0, 19 },
Expand Down
24 changes: 23 additions & 1 deletion src/mainboard/amd/inagua/mainboard.c
Expand Up @@ -3,6 +3,21 @@
#include <amdblocks/acpimmio.h>
#include <console/console.h>
#include <device/device.h>
#include <southbridge/amd/common/amd_pci_util.h>

static const u8 mainboard_intr_data[] = {
[0x00] = 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* INTA# - INTH# */
[0x08] = 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, /* Misc-nil, 0, 1, 2, INT from Serial irq */
[0x10] = 0x09, 0x1F, 0x1F, 0x10, 0x1F, 0x12, 0x1F, 0x00,
[0x18] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[0x20] = 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
[0x28] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[0x30] = 0x12, 0x11, 0x12, 0x11, 0x12, 0x11, 0x12, 0x00,
[0x38] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[0x40] = 0x11, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[0x48] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[0x50] = 0x10, 0x11, 0x12, 0x13
};

static void init_gpios(void)
{
Expand Down Expand Up @@ -31,12 +46,19 @@ static void init_gpios(void)
gpio_100_write8(0x32, 0x48);
}

/* PIRQ Setup */
static void pirq_setup(void)
{
intr_data_ptr = mainboard_intr_data;
}

/**********************************************
* Enable the dedicated functions of the board.
**********************************************/
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
/* Initialize the PIRQ data structures for consumption */
pirq_setup();

/* Inagua mainboard specific setting */
init_gpios();
Expand Down
135 changes: 0 additions & 135 deletions src/mainboard/amd/inagua/mptable.c

This file was deleted.

2 changes: 2 additions & 0 deletions src/mainboard/amd/majolica/Kconfig
Expand Up @@ -5,7 +5,9 @@ if BOARD_AMD_MAJOLICA
config BOARD_SPECIFIC_OPTIONS
def_bool y
select BOARD_ROMSIZE_KB_16384
select HAVE_ACPI_RESUME
select SOC_AMD_CEZANNE
select SOC_AMD_COMMON_BLOCK_USE_ESPI
select AMD_SOC_CONSOLE_UART
select MAINBOARD_HAS_CHROMEOS

Expand Down
5 changes: 3 additions & 2 deletions src/mainboard/amd/majolica/Makefile.inc
Expand Up @@ -3,8 +3,9 @@
bootblock-y += bootblock.c
bootblock-y += early_gpio.c

APCB_SOURCES = $(MAINBOARD_BLOBS_DIR)/APCB_CZN_D4_Updatable.bin
APCB_SOURCES_68 = $(MAINBOARD_BLOBS_DIR)/APCB_CZN_D4_Updatable_68.bin
ramstage-y += chromeos.c

APCB_SOURCES = $(MAINBOARD_BLOBS_DIR)/APCB_CZN_D4.bin
APCB_SOURCES_RECOVERY = $(MAINBOARD_BLOBS_DIR)/APCB_CZN_D4_DefaultRecovery.bin

ifeq ($(CONFIG_MAJOLICA_HAVE_MCHP_FW),y)
Expand Down
26 changes: 26 additions & 0 deletions src/mainboard/amd/majolica/chromeos.c
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <boot/coreboot_tables.h>
#include <gpio.h>
#include <vendorcode/google/chromeos/chromeos.h>

void fill_lb_gpios(struct lb_gpios *gpios)
{
struct lb_gpio chromeos_gpios[] = {};
lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
}

int get_write_protect_state(void)
{
/* Majolica doesn't have a write protect pin */
return 0;
}

static const struct cros_gpio cros_gpios[] = {
/* No ChromeOS GPIOs */
};

void mainboard_chromeos_acpi_generate(void)
{
chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios));
}
63 changes: 63 additions & 0 deletions src/mainboard/amd/majolica/devicetree.cb
@@ -1,8 +1,71 @@
# SPDX-License-Identifier: GPL-2.0-only

chip soc/amd/cezanne
register "common_config.espi_config" = "{
.std_io_decode_bitmap = ESPI_DECODE_IO_0X60_0X64_EN | ESPI_DECODE_IO_0x80_EN
| ESPI_DECODE_IO_0X2E_0X2F_EN,
.io_mode = ESPI_IO_MODE_QUAD,
.op_freq_mhz = ESPI_OP_FREQ_16_MHZ,
.crc_check_enable = 1,
.dedicated_alert_pin = 1,
.periph_ch_en = 1,
.vw_ch_en = 1,
.oob_ch_en = 1,
.flash_ch_en = 0,
}"

device domain 0 on
device ref gpp_bridge_a on # Internal GPP Bridge 0 to Bus A
device ref gfx on end # Internal GPU (GFX)
device ref xhci_0 on # USB 3.1 (USB0)
chip drivers/usb/acpi
device ref xhci_0_root_hub on
chip drivers/usb/acpi
device ref usb3_port0 on end
end
chip drivers/usb/acpi
device ref usb3_port1 on end
end
chip drivers/usb/acpi
device ref usb2_port0 on end
end
chip drivers/usb/acpi
device ref usb2_port1 on end
end
chip drivers/usb/acpi
device ref usb2_port2 on end
end
chip drivers/usb/acpi
device ref usb2_port3 on end
end
end
end
end
device ref xhci_1 on # USB 3.1 (USB1)
chip drivers/usb/acpi
device ref xhci_1_root_hub on
chip drivers/usb/acpi
device ref usb3_port4 on end
end
chip drivers/usb/acpi
device ref usb3_port5 on end
end
chip drivers/usb/acpi
device ref usb2_port4 on end
end
chip drivers/usb/acpi
device ref usb2_port5 on end
end
chip drivers/usb/acpi
device ref usb2_port6 on end
end
chip drivers/usb/acpi
device ref usb2_port7 on end
end
end
end
end
end
end

end
4 changes: 4 additions & 0 deletions src/mainboard/amd/majolica/early_gpio.c
Expand Up @@ -6,6 +6,10 @@
/* GPIO pins used by coreboot should be initialized in bootblock */

static const struct soc_amd_gpio gpio_set_stage_reset[] = {
PAD_NF(GPIO_113, I2C2_SCL, PULL_NONE),
PAD_NF(GPIO_114, I2C2_SDA, PULL_NONE),
PAD_NF(GPIO_19, I2C3_SCL, PULL_NONE),
PAD_NF(GPIO_20, I2C3_SDA, PULL_NONE),
};

void mainboard_program_early_gpios(void)
Expand Down
11 changes: 6 additions & 5 deletions src/mainboard/amd/majolica/mainboard.c
Expand Up @@ -7,6 +7,7 @@
#include <soc/acpi.h>
#include <string.h>
#include <types.h>
#include <vendorcode/google/chromeos/chromeos.h>

/*
* These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
Expand Down Expand Up @@ -81,7 +82,6 @@ static void init_tables(void)

static void pirq_setup(void)
{
init_tables();
intr_data_ptr = fch_apic_routing;
picr_data_ptr = fch_pic_routing;
}
Expand All @@ -90,15 +90,16 @@ static void mainboard_init(void *chip_info)
{
}

static void majolica_enable(struct device *dev)
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");

init_tables();
/* Initialize the PIRQ data structures for consumption */
pirq_setup();

dev->ops->acpi_inject_dsdt = chromeos_dsdt_generator;
}

struct chip_operations mainboard_ops = {
.init = mainboard_init,
.enable_dev = majolica_enable,
.enable_dev = mainboard_enable,
};
2 changes: 1 addition & 1 deletion src/mainboard/amd/mandolin/dsdt.asl
Expand Up @@ -25,7 +25,7 @@ DefinitionBlock (
#include <cpu.asl>

/* Contains the supported sleep states for this chipset */
#include <sleepstates.asl>
#include <soc/amd/common/acpi/sleepstates.asl>

/* Contains _SWS methods */
#include <soc/amd/common/acpi/acpi_wake_source.asl>
Expand Down
8 changes: 3 additions & 5 deletions src/mainboard/amd/mandolin/mainboard.c
Expand Up @@ -75,7 +75,6 @@ static void init_tables(void)

static void pirq_setup(void)
{
init_tables();
intr_data_ptr = fch_apic_routing;
picr_data_ptr = fch_pic_routing;
}
Expand All @@ -96,15 +95,14 @@ static void mainboard_init(void *chip_info)
mainboard_program_emmc_gpios();
}

static void mandolin_enable(struct device *dev)
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");

init_tables();
/* Initialize the PIRQ data structures for consumption */
pirq_setup();
}

struct chip_operations mainboard_ops = {
.init = mainboard_init,
.enable_dev = mandolin_enable,
.enable_dev = mainboard_enable,
};
1 change: 0 additions & 1 deletion src/mainboard/amd/olivehill/Kconfig
Expand Up @@ -10,7 +10,6 @@ config BOARD_SPECIFIC_OPTIONS
select DEFAULT_POST_ON_LPC
select HAVE_OPTION_TABLE
select HAVE_PIRQ_TABLE
select HAVE_MP_TABLE
select HAVE_ACPI_RESUME
select HAVE_ACPI_TABLES
select BOARD_ROMSIZE_KB_4096
Expand Down
27 changes: 26 additions & 1 deletion src/mainboard/amd/olivehill/mainboard.c
Expand Up @@ -2,13 +2,38 @@

#include <console/console.h>
#include <device/device.h>
#include <southbridge/amd/common/amd_pci_util.h>

static const u8 mainboard_picr_data[0x54] = {
0x03, 0x04, 0x05, 0x07, 0x0B, 0x0A, 0x1F, 0x1F, 0xFA, 0xF1, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x03, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x04, 0x05, 0x04, 0x04, 0x05, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x04, 0x05, 0x07
};
static const u8 mainboard_intr_data[0x54] = {
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F,
0x09, 0x1F, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x12, 0x11, 0x12, 0x11, 0x12, 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x11, 0x12, 0x13
};

/* PIRQ Setup */
static void pirq_setup(void)
{
intr_data_ptr = mainboard_intr_data;
picr_data_ptr = mainboard_picr_data;
}

/**********************************************
* enable the dedicated function in mainboard.
**********************************************/
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
pirq_setup();
}

struct chip_operations mainboard_ops = {
Expand Down
173 changes: 0 additions & 173 deletions src/mainboard/amd/olivehill/mptable.c

This file was deleted.

4 changes: 3 additions & 1 deletion src/mainboard/amd/padmelon/Kconfig
Expand Up @@ -16,7 +16,6 @@ config BOARD_SPECIFIC_OPTIONS
select SUPERIO_FINTEK_COMMON_PRE_RAM
select SUPERIO_FINTEK_FAN_CONTROL
select SUPERIO_FINTEK_FAN_API_CALL
select VGA_BIOS
select AZALIA_PLUGIN_SUPPORT

config MAINBOARD_DIR
Expand Down Expand Up @@ -49,6 +48,9 @@ config IRQ_SLOT_COUNT
int
default 11

config VGA_BIOS
default y if USE_AMD_BLOBS

config HWM_PORT
hex
default 0x0225
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/amd/padmelon/dsdt.asl
Expand Up @@ -26,7 +26,7 @@ DefinitionBlock (
#include <cpu.asl>

/* Contains the supported sleep states for this chipset */
#include <sleepstates.asl>
#include <soc/amd/common/acpi/sleepstates.asl>

/* Contains the Sleep methods (WAK, PTS, GTS, etc.) */
#include "acpi/sleep.asl"
Expand Down
7 changes: 2 additions & 5 deletions src/mainboard/amd/padmelon/mainboard.c
Expand Up @@ -104,16 +104,13 @@ static void mainboard_init(void *chip_info)
/*************************************************
* enable the dedicated function in padmelon board.
*************************************************/
static void padmelon_enable(struct device *dev)
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard "
CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");

/* Initialize the PIRQ data structures for consumption */
pirq_setup();
}

struct chip_operations mainboard_ops = {
.init = mainboard_init,
.enable_dev = padmelon_enable,
.enable_dev = mainboard_enable,
};
1 change: 0 additions & 1 deletion src/mainboard/amd/parmer/Kconfig
Expand Up @@ -10,7 +10,6 @@ config BOARD_SPECIFIC_OPTIONS
select DEFAULT_POST_ON_LPC
select HAVE_OPTION_TABLE
select HAVE_PIRQ_TABLE
select HAVE_MP_TABLE
select HAVE_ACPI_RESUME
select HAVE_ACPI_TABLES
select BOARD_ROMSIZE_KB_4096
Expand Down
27 changes: 26 additions & 1 deletion src/mainboard/amd/parmer/mainboard.c
Expand Up @@ -2,13 +2,38 @@

#include <console/console.h>
#include <device/device.h>
#include <southbridge/amd/common/amd_pci_util.h>

static const u8 mainboard_picr_data[0x54] = {
0x1F, 0x1f, 0x1f, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0A, 0xF1, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F,
0x09, 0x1F, 0x1F, 0x0B, 0x1F, 0x0B, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1F, 0x1F, 0x1F, 0x1F
};
static const u8 mainboard_intr_data[0x54] = {
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F,
0x09, 0x1F, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x12, 0x11, 0x12, 0x11, 0x12, 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x11, 0x12, 0x13
};

/* PIRQ Setup */
static void pirq_setup(void)
{
intr_data_ptr = mainboard_intr_data;
picr_data_ptr = mainboard_picr_data;
}

/*************************************************
* enable the dedicated function in parmer board.
*************************************************/
static void mainboard_enable(struct device *dev)
{
printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
pirq_setup();
}

struct chip_operations mainboard_ops = {
Expand Down