38 changes: 19 additions & 19 deletions src/drivers/intel/fsp1_1/fsp_util.c
Expand Up @@ -89,26 +89,26 @@ void print_fsp_info(FSP_INFO_HEADER *fsp_header)
(u8)((fsp_header->ImageRevision >> 16) & 0xff),
(u8)((fsp_header->ImageRevision >> 8) & 0xff),
(u8)(fsp_header->ImageRevision & 0xff));
#if CONFIG(DISPLAY_FSP_ENTRY_POINTS)
printk(BIOS_SPEW, "FSP Entry Points:\n");
printk(BIOS_SPEW, " %p: Image Base\n", fsp_base);
printk(BIOS_SPEW, " %p: TempRamInit\n",
&fsp_base[fsp_header->TempRamInitEntryOffset]);
printk(BIOS_SPEW, " %p: FspInit\n",
&fsp_base[fsp_header->FspInitEntryOffset]);
if (fsp_header->HeaderRevision >= FSP_HEADER_REVISION_2) {
printk(BIOS_SPEW, " %p: MemoryInit\n",
&fsp_base[fsp_header->FspMemoryInitEntryOffset]);
printk(BIOS_SPEW, " %p: TempRamExit\n",
&fsp_base[fsp_header->TempRamExitEntryOffset]);
printk(BIOS_SPEW, " %p: SiliconInit\n",
&fsp_base[fsp_header->FspSiliconInitEntryOffset]);
if (CONFIG(DISPLAY_FSP_ENTRY_POINTS)) {
printk(BIOS_SPEW, "FSP Entry Points:\n");
printk(BIOS_SPEW, " %p: Image Base\n", fsp_base);
printk(BIOS_SPEW, " %p: TempRamInit\n",
&fsp_base[fsp_header->TempRamInitEntryOffset]);
printk(BIOS_SPEW, " %p: FspInit\n",
&fsp_base[fsp_header->FspInitEntryOffset]);
if (fsp_header->HeaderRevision >= FSP_HEADER_REVISION_2) {
printk(BIOS_SPEW, " %p: MemoryInit\n",
&fsp_base[fsp_header->FspMemoryInitEntryOffset]);
printk(BIOS_SPEW, " %p: TempRamExit\n",
&fsp_base[fsp_header->TempRamExitEntryOffset]);
printk(BIOS_SPEW, " %p: SiliconInit\n",
&fsp_base[fsp_header->FspSiliconInitEntryOffset]);
}
printk(BIOS_SPEW, " %p: NotifyPhase\n",
&fsp_base[fsp_header->NotifyPhaseEntryOffset]);
printk(BIOS_SPEW, " %p: Image End\n",
&fsp_base[fsp_header->ImageSize]);
}
printk(BIOS_SPEW, " %p: NotifyPhase\n",
&fsp_base[fsp_header->NotifyPhaseEntryOffset]);
printk(BIOS_SPEW, " %p: Image End\n",
&fsp_base[fsp_header->ImageSize]);
#endif
}

void fsp_notify(u32 phase)
Expand Down
2 changes: 0 additions & 2 deletions src/drivers/intel/fsp1_1/ramstage.c
Expand Up @@ -2,7 +2,6 @@

#include <bootmode.h>
#include <bootsplash.h>
#include <acpi/acpi.h>
#include <console/console.h>
#include <fsp/ramstage.h>
#include <fsp/util.h>
Expand All @@ -11,7 +10,6 @@
#include <stage_cache.h>
#include <string.h>
#include <timestamp.h>
#include <cbmem.h>

static void display_hob_info(FSP_INFO_HEADER *fsp_info_header)
{
Expand Down
1 change: 0 additions & 1 deletion src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c
Expand Up @@ -3,7 +3,6 @@
#include <console/console.h>
#include <cpu/cpu.h>
#include <cpu/x86/mp.h>
#include <cpu/x86/lapic.h>
#include <cpu/intel/microcode.h>
#include <fsp/api.h>
#include <fsp/ppi/mp_service_ppi.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/intel/gma/acpi.c
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <string.h>
#include "i915.h"
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/intel/gma/opregion.c
Expand Up @@ -332,8 +332,8 @@ enum cb_err intel_gma_init_igd_opregion(void)
return CB_ERR;
}

if (is_ext_vbt_required(opregion, vbt))
opregion_size += vbt->hdr_vbt_size;
/* Add the space for the extended VBT header even if it's not used */
opregion_size += vbt->hdr_vbt_size;

opregion = cbmem_add(CBMEM_ID_IGD_OPREGION, opregion_size);
if (!opregion) {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/intel/mipi_camera/camera.c
Expand Up @@ -139,7 +139,7 @@ static void camera_fill_cio2(const struct device *dev)
if (CONFIG(ACPI_ADL_IPU_ES_SUPPORT)) {
u32 cpu_id = cpu_get_cpuid();
if (cpu_id == CPUID_ALDERLAKE_J0 || cpu_id == CPUID_ALDERLAKE_Q0 ||
cpu_id == CPUID_ALDERLAKE_N_A0)
cpu_id == CPUID_ALDERLAKE_N_A0 || cpu_id == CPUID_RAPTORLAKE_P_J0)
acpi_dp_add_integer(dsd, "is_es", 1);
else
acpi_dp_add_integer(dsd, "is_es", 0);
Expand Down
48 changes: 39 additions & 9 deletions src/drivers/intel/usb4/retimer/retimer.c
Expand Up @@ -27,7 +27,8 @@ static const char *usb4_retimer_path_arg(const char *arg)
/* Each polling cycle takes up to 25 ms with a total of 12 of these iterations */
#define USB4_RETIMER_ITERATION_NUM 12
#define USB4_RETIMER_POLL_CYCLE_MS 25
static void usb4_retimer_execute_ec_cmd(uint8_t port, uint8_t cmd, uint8_t expected_value)
static void usb4_retimer_execute_ec_cmd(uint8_t port, uint8_t cmd, uint8_t expected_value,
struct acpi_gpio *power_gpio)
{
const char *RFWU = ec_retimer_fw_update_path();
const uint8_t data = cmd << USB_RETIMER_FW_UPDATE_OP_SHIFT | port;
Expand All @@ -36,6 +37,7 @@ static void usb4_retimer_execute_ec_cmd(uint8_t port, uint8_t cmd, uint8_t expec
ec_retimer_fw_update(data);
/* If RFWU has return value 0xfe, return error -1 */
acpigen_write_if_lequal_namestr_int(RFWU, USB_RETIMER_FW_UPDATE_ERROR);
acpigen_disable_tx_gpio(power_gpio);
acpigen_write_return_integer(-1);
acpigen_pop_len(); /* If */

Expand All @@ -49,7 +51,27 @@ static void usb4_retimer_execute_ec_cmd(uint8_t port, uint8_t cmd, uint8_t expec
acpigen_emit_byte(BREAK_OP);
acpigen_pop_len(); /* If */

if (cmd == USB_RETIMER_FW_UPDATE_SET_TBT) {
if (cmd == USB_RETIMER_FW_UPDATE_GET_MUX) {
acpigen_write_if_lequal_namestr_int(RFWU, USB_RETIMER_FW_UPDATE_INVALID_MUX);
acpigen_write_sleep(USB4_RETIMER_POLL_CYCLE_MS);
acpigen_emit_byte(DECREMENT_OP);
acpigen_emit_byte(LOCAL2_OP);
acpigen_emit_byte(CONTINUE_OP);
acpigen_pop_len(); /* If */

acpigen_emit_byte(AND_OP);
acpigen_emit_namestring(RFWU);
acpigen_write_integer(USB_RETIMER_FW_UPDATE_MUX_MASK);
acpigen_emit_byte(LOCAL3_OP);
acpigen_write_if();
acpigen_emit_byte(LNOT_OP);
acpigen_emit_byte(LEQUAL_OP);
acpigen_emit_byte(LOCAL3_OP);
acpigen_emit_byte(0);
acpigen_disable_tx_gpio(power_gpio);
acpigen_write_return_integer(-1);
acpigen_pop_len(); /* If */
} else if (cmd == USB_RETIMER_FW_UPDATE_SET_TBT) {
/*
* EC return either USB_PD_MUX_USB4_ENABLED or USB_PD_MUX_TBT_COMPAT_ENABLED
* to RFWU after the USB_RETIMER_FW_UPDATE_SET_TBT command execution. It is
Expand All @@ -70,6 +92,7 @@ static void usb4_retimer_execute_ec_cmd(uint8_t port, uint8_t cmd, uint8_t expec
* Return: -1 if timeout error occurring
*/
acpigen_write_if_lequal_op_int(LOCAL2_OP, 0);
acpigen_disable_tx_gpio(power_gpio);
acpigen_write_return_integer(-1);
acpigen_pop_len(); /* If */
}
Expand Down Expand Up @@ -97,39 +120,44 @@ static void enable_retimer_online_state(uint8_t port, struct acpi_gpio *power_gp
* Otherwise proceed Retimer firmware upgrade operation.
*/
expected_value = USB_PD_MUX_NONE;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_GET_MUX, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_GET_MUX, expected_value,
power_gpio);

/*
* Suspend PD
* Command: USB_RETIMER_FW_UPDATE_SUSPEND_PD
* Expect return value: 0
*/
expected_value = 0;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SUSPEND_PD, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SUSPEND_PD, expected_value,
power_gpio);

/*
* Set MUX USB Mode
* Command: USB_RETIMER_FW_UPDATE_SUSPEND_PD
* Expect return value: USB_PD_MUX_USB_ENABLED
*/
expected_value = USB_PD_MUX_USB_ENABLED;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SET_USB, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SET_USB, expected_value,
power_gpio);

/*
* Set MUX Safe Mode
* Command: USB_RETIMER_FW_UPDATE_SET_SAFE
* Expect return value: USB_PD_MUX_SAFE_MODE
*/
expected_value = USB_PD_MUX_SAFE_MODE;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SET_SAFE, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SET_SAFE, expected_value,
power_gpio);

/*
* Set MUX TBT Mode
* Command: USB_RETIMER_FW_UPDATE_SET_TBT
* Expect return value: USB_PD_MUX_USB4_ENABLED or USB_PD_MUX_TBT_COMPAT_ENABLED
*/
expected_value = USB_PD_MUX_USB4_ENABLED;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SET_TBT, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_SET_TBT, expected_value,
power_gpio);
}

static void disable_retimer_online_state(uint8_t port, struct acpi_gpio *power_gpio)
Expand All @@ -149,15 +177,17 @@ static void disable_retimer_online_state(uint8_t port, struct acpi_gpio *power_g
* Expect return value: 0
*/
expected_value = 0;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_DISCONNECT, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_DISCONNECT, expected_value,
power_gpio);

/*
* Resume PD
* Command: USB_RETIMER_FW_UPDATE_RESUME_PD
* Expect return value: 1
*/
expected_value = 1;
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_RESUME_PD, expected_value);
usb4_retimer_execute_ec_cmd(port, USB_RETIMER_FW_UPDATE_RESUME_PD, expected_value,
power_gpio);

/* Force power off */
acpigen_disable_tx_gpio(power_gpio);
Expand Down
14 changes: 12 additions & 2 deletions src/drivers/intel/usb4/retimer/retimer.h
Expand Up @@ -6,12 +6,22 @@
/* Flags representing mux state */
#define USB_PD_MUX_NONE 0 /* Open switch */
#define USB_PD_MUX_USB_ENABLED BIT(0) /* USB connected */
#define USB_PD_MUX_DP_ENABLED BIT(1) /* DP connected */
#define USB_PD_MUX_SAFE_MODE BIT(5) /* DP is in safe mode */
#define USB_PD_MUX_TBT_COMPAT_ENABLED BIT(6) /* TBT compat enabled */
#define USB_PD_MUX_USB4_ENABLED BIT(7) /* USB4 enabled */

#define USB_RETIMER_FW_UPDATE_OP_SHIFT 4
#define USB_RETIMER_FW_UPDATE_ERROR 0xfe
/* USB Retimer firmware update mux mask */
#define USB_RETIMER_FW_UPDATE_MUX_MASK (USB_PD_MUX_USB_ENABLED | \
USB_PD_MUX_DP_ENABLED | \
USB_PD_MUX_SAFE_MODE | \
USB_PD_MUX_TBT_COMPAT_ENABLED | \
USB_PD_MUX_USB4_ENABLED)

#define USB_RETIMER_FW_UPDATE_OP_SHIFT 4
#define USB_RETIMER_FW_UPDATE_ERROR 0xfe
#define USB_RETIMER_FW_UPDATE_INVALID_MUX 0xff

/* Retimer firmware update operations */
#define USB_RETIMER_FW_UPDATE_SUSPEND_PD 1 /* Suspend PD port */
#define USB_RETIMER_FW_UPDATE_RESUME_PD 2 /* Resume PD port */
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/ipmi/chip.h
Expand Up @@ -2,7 +2,7 @@

#include <device/device.h>

#ifndef _IMPI_CHIP_H_
#ifndef _IPMI_CHIP_H_
#define _IPMI_CHIP_H_

#include <stdint.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/lenovo/wacom.c
Expand Up @@ -2,7 +2,6 @@

#include <types.h>
#include <console/console.h>
#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <device/device.h>
#include <device/pnp.h>
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/pc80/tpm/Kconfig
@@ -1,10 +1,10 @@
config MAINBOARD_HAS_LPC_TPM
config MEMORY_MAPPED_TPM
bool
default n
help
Board has LPC TPM support
Board has memory mapped TPM support

if MAINBOARD_HAS_LPC_TPM
if MEMORY_MAPPED_TPM

config TPM_TIS_BASE_ADDRESS
hex
Expand Down
8 changes: 3 additions & 5 deletions src/drivers/pc80/tpm/Makefile.inc
@@ -1,5 +1,3 @@
bootblock-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c
verstage-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c
romstage-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c
ramstage-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c
postcar-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c
ifeq ($(CONFIG_MEMORY_MAPPED_TPM),y)
all-y += tis.c
endif
1 change: 0 additions & 1 deletion src/drivers/spi/cbfs_spi.c
Expand Up @@ -11,7 +11,6 @@
#include <console/console.h>
#include <spi_flash.h>
#include <symbols.h>
#include <cbmem.h>
#include <stdint.h>
#include <timer.h>

Expand Down
24 changes: 15 additions & 9 deletions src/drivers/spi/spi_flash.c
Expand Up @@ -192,23 +192,29 @@ int spi_flash_cmd_poll_bit(const struct spi_flash *flash, unsigned long timeout,
{
const struct spi_slave *spi = &flash->spi;
int ret;
int attempt = 0;
u8 status;
struct mono_time current, end;

timer_monotonic_get(&current);
end = current;
mono_time_add_msecs(&end, timeout);
struct stopwatch sw;

stopwatch_init_msecs_expire(&sw, timeout);
do {
attempt++;

ret = do_spi_flash_cmd(spi, &cmd, 1, &status, 1);
if (ret)
if (ret) {
printk(BIOS_WARNING,
"SF: SPI command failed on attempt %d with rc %d\n", attempt,
ret);
return -1;
}

if ((status & poll_bit) == 0)
return 0;
timer_monotonic_get(&current);
} while (!mono_time_after(&current, &end));
} while (!stopwatch_expired(&sw));

printk(BIOS_WARNING, "SF: timeout at %ld msec after %d attempts\n",
stopwatch_duration_msecs(&sw), attempt);

printk(BIOS_DEBUG, "SF: timeout at %ld msec\n",timeout);
return -1;
}

Expand Down
14 changes: 0 additions & 14 deletions src/drivers/spi/tpm/Kconfig
Expand Up @@ -12,17 +12,3 @@ config DRIVER_TPM_SPI_CHIP
int "Chip Select of the TPM chip on its SPI bus"
default 0
depends on SPI_TPM

config MAINBOARD_HAS_SPI_TPM_CR50
bool
default n
select MAINBOARD_HAS_SPI_TPM
help
Board has a CR50 SPI TPM

config MAINBOARD_HAS_SPI_TPM
bool
default n
select SPI_TPM
help
Board has SPI TPM support
8 changes: 3 additions & 5 deletions src/drivers/spi/tpm/Makefile.inc
@@ -1,5 +1,3 @@
bootblock-$(CONFIG_SPI_TPM) += tis.c tpm.c
verstage-$(CONFIG_SPI_TPM) += tis.c tpm.c
romstage-$(CONFIG_SPI_TPM) += tis.c tpm.c
ramstage-$(CONFIG_SPI_TPM) += tis.c tpm.c
postcar-$(CONFIG_SPI_TPM) += tis.c tpm.c
ifeq ($(CONFIG_TPM)$(CONFIG_SPI_TPM),yy)
all-y += tis.c tpm.c
endif
15 changes: 7 additions & 8 deletions src/drivers/spi/tpm/tpm.c
Expand Up @@ -104,7 +104,7 @@ static enum cb_err start_transaction(int read_write, size_t bytes, unsigned int
static int tpm_sync_needed;
static struct stopwatch wake_up_sw;

if (CONFIG(TPM_CR50)) {
if (CONFIG(TPM_GOOGLE)) {
/*
* First Cr50 access in each coreboot stage where TPM is used will be
* prepended by a wake up pulse on the CS line.
Expand Down Expand Up @@ -186,7 +186,7 @@ static enum cb_err start_transaction(int read_write, size_t bytes, unsigned int
*/

header_resp.body[3] = 0;
if (CONFIG(TPM_CR50))
if (CONFIG(TPM_GOOGLE))
ret = spi_xfer(&spi_slave, header.body, sizeof(header.body), NULL, 0);
else
ret = spi_xfer(&spi_slave, header.body, sizeof(header.body),
Expand Down Expand Up @@ -419,6 +419,7 @@ static enum cb_err tpm2_claim_locality(void)
/* Device/vendor ID values of the TPM devices this driver supports. */
static const uint32_t supported_did_vids[] = {
0x00281ae0, /* H1 based Cr50 security chip. */
0x504a6666, /* H1D3C based Ti50 security chip. */
0x0000104a /* ST33HTPH2E32 */
};

Expand Down Expand Up @@ -496,15 +497,13 @@ int tpm2_init(struct spi_slave *spi_if)
printk(BIOS_INFO, "Connected to device vid:did:rid of %4.4x:%4.4x:%2.2x\n",
tpm_info.vendor_id, tpm_info.device_id, tpm_info.revision);

/* Do some cr50-specific things here. */
if (CONFIG(TPM_CR50) && tpm_info.vendor_id == 0x1ae0) {
struct cr50_firmware_version ver;

/* Do some GSC-specific things here. */
if (CONFIG(TPM_GOOGLE)) {
if (tpm_first_access_this_boot()) {
/* This is called for the side-effect of printing the firmware version
string */
cr50_get_firmware_version(&ver);
cr50_set_board_cfg();
cr50_get_firmware_version(NULL);
cr50_set_board_cfg();
}
}
return 0;
Expand Down
10 changes: 5 additions & 5 deletions src/drivers/tpm/Makefile.inc
@@ -1,3 +1,5 @@
ifeq ($(CONFIG_TPM),y)

ramstage-$(CONFIG_TPM_INIT_RAMSTAGE) += tpm.c

ifeq ($(CONFIG_TPM_PPI),y)
Expand All @@ -6,8 +8,6 @@ else
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += ppi_stub.c
endif

bootblock-$(CONFIG_TPM_CR50) += cr50.c
verstage-$(CONFIG_TPM_CR50) += cr50.c
romstage-$(CONFIG_TPM_CR50) += cr50.c
ramstage-$(CONFIG_TPM_CR50) += cr50.c
postcar-$(CONFIG_TPM_CR50) += cr50.c
all-$(CONFIG_TPM_GOOGLE) += cr50.c

endif
36 changes: 24 additions & 12 deletions src/drivers/tpm/cr50.c
Expand Up @@ -5,6 +5,9 @@
#include <string.h>
#include <types.h>

#define CR50_DID_VID 0x00281ae0L
#define TI50_DID_VID 0x504a6666L

#define CR50_BOARD_CFG_LOCKBIT_MASK 0x80000000U
#define CR50_BOARD_CFG_FEATUREBITS_MASK 0x3FFFFFFFU

Expand Down Expand Up @@ -84,7 +87,7 @@ static uint32_t cr50_get_board_cfg(void)
const enum cb_err ret = tis_vendor_read(get_reg_addr(CR50_BOARD_CFG_REG), &value,
sizeof(value));
if (ret != CB_SUCCESS) {
printk(BIOS_INFO, "Error reading from cr50\n");
printk(BIOS_ERR, "Error reading from Cr50\n");
return 0;
}

Expand All @@ -96,6 +99,11 @@ static uint32_t cr50_get_board_cfg(void)
*/
enum cb_err cr50_set_board_cfg(void)
{
/* If we get here and we aren't cr50, then we must be ti50 which does
* not currently need to support a board_cfg register. */
if (!CONFIG(TPM_GOOGLE_CR50))
return CB_SUCCESS;

struct cr50_firmware_version ver;
enum cb_err ret;
uint32_t value;
Expand All @@ -109,7 +117,7 @@ enum cb_err cr50_set_board_cfg(void)
/* Set the CR50_BOARD_CFG register, for e.g. asking cr50 to use longer ready pulses. */
ret = tis_vendor_read(get_reg_addr(CR50_BOARD_CFG_REG), &value, sizeof(value));
if (ret != CB_SUCCESS) {
printk(BIOS_INFO, "Error reading from cr50\n");
printk(BIOS_ERR, "Error reading from Cr50\n");
return CB_ERR;
}

Expand Down Expand Up @@ -142,19 +150,15 @@ enum cb_err cr50_set_board_cfg(void)

bool cr50_is_long_interrupt_pulse_enabled(void)
{
/*
* Ti50 FW versions under 0.15 don't support the board cfg register,
* and all Ti50 versions only support long IRQ pulses.
* TODO: Remove this after all Ti50 stocks uprev to 0.15 or above.
*/
if (CONFIG(MAINBOARD_NEEDS_I2C_TI50_WORKAROUND))
return true;
if (CONFIG(TPM_GOOGLE_CR50))
return !!(cr50_get_board_cfg() & CR50_BOARD_CFG_100US_READY_PULSE);

return !!(cr50_get_board_cfg() & CR50_BOARD_CFG_100US_READY_PULSE);
/* Ti50 and future GSCs will support only long interrupt pulses. */
return true;
}

static enum cb_err cr50_parse_fw_version(const char *version_str,
struct cr50_firmware_version *ver)
struct cr50_firmware_version *ver)
{
int epoch, major, minor;

Expand Down Expand Up @@ -187,6 +191,13 @@ enum cb_err cr50_get_firmware_version(struct cr50_firmware_version *version)
cr50_firmware_version.minor)
goto success;

if (CONFIG(TI50_FIRMWARE_VERSION_NOT_SUPPORTED)) {
printk(BIOS_ERR, "Reading Ti50 firmware version is not supported\n");
if (version)
*version = cr50_firmware_version;
return CB_ERR;
}

int chunk_count = 0;
size_t chunk_size = 50;
char version_str[301];
Expand Down Expand Up @@ -219,6 +230,7 @@ enum cb_err cr50_get_firmware_version(struct cr50_firmware_version *version)
}

success:
*version = cr50_firmware_version;
if (version)
*version = cr50_firmware_version;
return CB_SUCCESS;
}
4 changes: 2 additions & 2 deletions src/drivers/tpm/cr50.h
Expand Up @@ -5,7 +5,7 @@

#include <types.h>

/* Structure describing the elements of Cr50 firmware version. */
/* Structure describing the elements of GSC firmware version. */
struct cr50_firmware_version {
int epoch;
int major;
Expand All @@ -15,7 +15,7 @@ struct cr50_firmware_version {
/* Indicates whether Cr50 ready pulses are guaranteed to be at least 100us. */
bool cr50_is_long_interrupt_pulse_enabled(void);

/* Get the Cr50 firmware version information. */
/* Get the GSC firmware version information. */
enum cb_err cr50_get_firmware_version(struct cr50_firmware_version *version);

/* Set the BOARD_CFG register depending on Cr50 Kconfigs */
Expand Down
1 change: 0 additions & 1 deletion src/drivers/tpm/ppi.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <types.h>
#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
#include <cbmem.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/tpm/ppi_stub.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <types.h>
#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>

Expand Down
17 changes: 8 additions & 9 deletions src/drivers/usb/ehci_debug.c
Expand Up @@ -20,16 +20,15 @@ struct ehci_debug_info {
struct dbgp_pipe ep_pipe[DBGP_MAX_ENDPOINTS];
} __packed;

#if CONFIG(DEBUG_CONSOLE_INIT)
/* When selected, you can debug the connection of usbdebug dongle.
* EHCI port register bits and USB packets are dumped on console,
* assuming some other console already works.
/* With CONFIG(DEBUG_CONSOLE_INIT), you can debug the connection of
* usbdebug dongle. EHCI port register bits and USB packets are dumped
* on console, assuming some other console already works.
*/
# define dprintk(LEVEL, args...) \
do { if (!dbgp_enabled()) printk(LEVEL, ##args); } while (0)
#else
# define dprintk(LEVEL, args...) do {} while (0)
#endif
#define dprintk(LEVEL, args...) \
do { \
if (CONFIG(DEBUG_CONSOLE_INIT) && !dbgp_enabled()) \
printk(LEVEL, ##args); \
} while (0)

#define DBGP_LEN_UPDATE(x, len) (((x) & ~0x0f) | ((len) & 0x0f))

Expand Down
8 changes: 8 additions & 0 deletions src/drivers/usb/hub/Kconfig
@@ -0,0 +1,8 @@
config DRIVERS_USB_HUB
bool
default n
depends on HAVE_ACPI_TABLES
help
This driver is for soldered down USB Hub in the mainboard. When enabled,
this driver will add ACPI support for the USB hub and any devices on the
downstream facing ports.
1 change: 1 addition & 0 deletions src/drivers/usb/hub/Makefile.inc
@@ -0,0 +1 @@
ramstage-$(CONFIG_DRIVERS_USB_HUB) += acpi.c
88 changes: 88 additions & 0 deletions src/drivers/usb/hub/acpi.c
@@ -0,0 +1,88 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
#include <stdlib.h>

#include "chip.h"

static const char *usb_hub_acpi_name(const struct device *dev)
{
char *name;
const char *pattern;

/* USB ACPI driver does not have acpi_name operation defined. Hence return
the ACPI name for both the hub and any downstream facing ports. */
switch (dev->path.usb.port_type) {
case 0:
return "EHUB";
case 2:
pattern = "HS%02d";
break;
case 3:
pattern = "SS%02d";
break;
default:
return NULL;
}

name = malloc(ACPI_NAME_BUFFER_SIZE);
snprintf(name, ACPI_NAME_BUFFER_SIZE, pattern, dev->path.usb.port_id + 1);
name[4] = '\0';

return name;
}

static void usb_hub_add_ports(const struct device *dev)
{
const struct drivers_usb_hub_config *config = config_of(dev);
struct device *port = NULL;
unsigned int child_count = 0;

while ((port = dev_bus_each_child(dev->link_list, port)) != NULL) {
if (child_count++ >= config->port_count) {
printk(BIOS_WARNING, "%s cannot be added. Port Count limit reached.\n",
dev_name(port));
continue;
}
acpigen_write_device(usb_hub_acpi_name(port));
acpigen_write_name_byte("_ADR", port->path.usb.port_id + 1);
acpigen_write_device_end();
}
}

static void usb_hub_acpi_fill_ssdt(const struct device *dev)
{
const struct drivers_usb_hub_config *config = config_of(dev);
const char *scope = acpi_device_scope(dev);
const char *name = acpi_device_name(dev);

acpigen_write_scope(scope);
acpigen_write_device(name);
acpigen_write_ADR(0);
if (config->name)
acpigen_write_name_string("_DDN", config->name);
if (config->desc)
acpigen_write_name_unicode("_STR", config->desc);
usb_hub_add_ports(dev);
acpigen_write_device_end();
acpigen_write_scope_end();
}

static struct device_operations usb_hub_ops = {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
.scan_bus = scan_static_bus,
.acpi_fill_ssdt = usb_hub_acpi_fill_ssdt,
.acpi_name = usb_hub_acpi_name
};

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

struct chip_operations drivers_usb_hub_ops = {
CHIP_NAME("USB Hub")
.enable_dev = usb_hub_acpi_enable
};
12 changes: 12 additions & 0 deletions src/drivers/usb/hub/chip.h
@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef __DRIVERS_USB_HUB_CHIP_H__
#define __DRIVERS_USB_HUB_CHIP_H__

struct drivers_usb_hub_config {
const char *name;
const char *desc;
unsigned int port_count; /* Number of Super-speed or High-speed ports */
};

#endif /* __DRIVERS_USB_HUB_CHIP_H__ */
3 changes: 3 additions & 0 deletions src/drivers/usb/pci_xhci/pci_xhci.c
Expand Up @@ -257,6 +257,9 @@ static const unsigned short amd_pci_device_ids[] = {
PCI_DID_AMD_FAM17H_MODEL18H_XHCI1,
PCI_DID_AMD_FAM17H_MODEL20H_XHCI0,
PCI_DID_AMD_FAM17H_MODEL60H_XHCI,
PCI_DID_AMD_FAM17H_MODELA0H_XHCI0,
PCI_DID_AMD_FAM17H_MODELA0H_XHCI1,
PCI_DID_AMD_FAM17H_MODELA0H_XHCI2,
0
};

Expand Down
1 change: 1 addition & 0 deletions src/drivers/wifi/generic/generic.c
Expand Up @@ -118,6 +118,7 @@ static const unsigned short intel_pci_device_ids[] = {
/* Garfield Peak */
PCI_DID_GrP_6SERIES_1_WIFI,
PCI_DID_GrP_6SERIES_2_WIFI,
PCI_DID_GrP_6SERIES_3_WIFI,
0
};

Expand Down
2 changes: 1 addition & 1 deletion src/ec/acpi/ec.c
Expand Up @@ -142,7 +142,7 @@ void ec_clr_bit(u8 addr, u8 bit)

void ec_set_ports(u16 cmd_reg, u16 data_reg)
{
if (!ENV_STAGE_HAS_DATA_SECTION)
if (!ENV_HAS_DATA_SECTION)
return;

ec_cmd_reg = cmd_reg;
Expand Down
1 change: 1 addition & 0 deletions src/ec/google/chromeec/Makefile.inc
Expand Up @@ -2,6 +2,7 @@ ifeq ($(CONFIG_EC_GOOGLE_CHROMEEC),y)

subdirs-y += audio_codec
subdirs-y += i2c_tunnel
subdirs-y += mux

bootblock-$(CONFIG_EC_GOOGLE_CHROMEEC_BOARDID) += ec_boardid.c
verstage-$(CONFIG_EC_GOOGLE_CHROMEEC_BOARDID) += ec_boardid.c
Expand Down
46 changes: 0 additions & 46 deletions src/ec/google/chromeec/acpi/superio.asl
Expand Up @@ -37,12 +37,6 @@ Device (SIO) {
IO (Decode16, EC_LPC_ADDR_MEMMAP, EC_LPC_ADDR_MEMMAP,
0x08, EC_MEMMAP_SIZE)
})

Name (_PRS, ResourceTemplate ()
{
IO (Decode16, EC_LPC_ADDR_MEMMAP, EC_LPC_ADDR_MEMMAP,
0x08, EC_MEMMAP_SIZE)
})
}
#endif

Expand Down Expand Up @@ -70,23 +64,6 @@ Device (SIO) {
EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION1, 0x08,
EC_HOST_CMD_REGION_SIZE)
})

Name (_PRS, ResourceTemplate ()
{
StartDependentFn (0, 0) {
IO (Decode16, EC_LPC_ADDR_HOST_DATA,
EC_LPC_ADDR_HOST_DATA, 0x01, 0x01)
IO (Decode16, EC_LPC_ADDR_HOST_CMD,
EC_LPC_ADDR_HOST_CMD, 0x01, 0x01)
IO (Decode16,
EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION0,
0x08, EC_HOST_CMD_REGION_SIZE)
IO (Decode16,
EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION1,
0x08, EC_HOST_CMD_REGION_SIZE)
}
EndDependentFn ()
})
}
#endif

Expand All @@ -104,15 +81,6 @@ Device (SIO) {
IO (Decode16, 0x03F8, 0x3F8, 0x08, 0x08)
IRQNoFlags () {4}
})

Name (_PRS, ResourceTemplate ()
{
StartDependentFn (0, 0) {
IO (Decode16, 0x03F8, 0x3F8, 0x08, 0x08)
IRQNoFlags () {4}
}
EndDependentFn ()
})
}
#endif
}
Expand Down Expand Up @@ -140,20 +108,6 @@ Scope (\_SB.PCI0)
IRQ (Edge, ActiveHigh, Exclusive) {1}
#endif
})

Name (_PRS, ResourceTemplate()
{
StartDependentFn (0, 0) {
IO (Decode16, 0x60, 0x60, 0x01, 0x01)
IO (Decode16, 0x64, 0x64, 0x01, 0x01)
#ifdef SIO_EC_PS2K_IRQ
SIO_EC_PS2K_IRQ
#else
IRQ (Edge, ActiveHigh, Exclusive) {1}
#endif
}
EndDependentFn ()
})
}
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/ec/google/chromeec/chip.h
Expand Up @@ -11,6 +11,7 @@
struct ec_google_chromeec_config {
/* Pointer to PMC Mux connector for each Type-C port */
DEVTREE_CONST struct device *mux_conn[MAX_TYPEC_PORTS];
DEVTREE_CONST struct device *retimer_conn[MAX_TYPEC_PORTS];
};

#endif /* EC_GOOGLE_CHROMEEC_CHIP_H */
1 change: 1 addition & 0 deletions src/ec/google/chromeec/ec_acpi.c
Expand Up @@ -195,6 +195,7 @@ static void fill_ssdt_typec_device(const struct device *dev)
.orientation_switch = config->mux_conn[i],
.usb_role_switch = config->mux_conn[i],
.mode_switch = config->mux_conn[i],
.retimer_switch = config->retimer_conn[i],
.pld = &pld,
};

Expand Down
10 changes: 5 additions & 5 deletions src/ec/google/chromeec/ec_smbios.c
Expand Up @@ -27,13 +27,13 @@ const char *smbios_mainboard_manufacturer(void)
if (manuf)
return manuf;

if (google_chromeec_cbi_get_oem_name(&oem_name[0],
ARRAY_SIZE(oem_name)) < 0) {
manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
if (google_chromeec_cbi_get_oem_name(&oem_name[0], ARRAY_SIZE(oem_name)) < 0)
printk(BIOS_INFO, "Couldn't obtain OEM name from CBI\n");
manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
} else {
else if (strlen(oem_name) > 0)
manuf = &oem_name[0];
}
else
printk(BIOS_INFO, "OEM name from CBI is empty, use default\n");

return manuf;
}
Expand Down
11 changes: 11 additions & 0 deletions src/ec/google/chromeec/mux/Kconfig
@@ -0,0 +1,11 @@
if EC_GOOGLE_CHROMEEC

config EC_GOOGLE_CHROMEEC_MUX
bool
depends on HAVE_ACPI_TABLES
help
This enables the Cros EC Mux driver that is required to fill the
SSDT nodes for the EC Mux platform device which is used to
configure Type C muxes and retimers.

endif
2 changes: 2 additions & 0 deletions src/ec/google/chromeec/mux/Makefile.inc
@@ -0,0 +1,2 @@
subdirs-y += conn
ramstage-$(CONFIG_EC_GOOGLE_CHROMEEC_MUX) += mux.c
1 change: 1 addition & 0 deletions src/ec/google/chromeec/mux/conn/Makefile.inc
@@ -0,0 +1 @@
ramstage-$(CONFIG_EC_GOOGLE_CHROMEEC_MUX) += conn.c
43 changes: 43 additions & 0 deletions src/ec/google/chromeec/mux/conn/conn.c
@@ -0,0 +1,43 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <acpi/acpigen.h>

static const char *conn_acpi_name(const struct device *dev)
{
static char name[5];
snprintf(name, sizeof(name), "CON%1X", dev->path.generic.id);
return name;
}

static void conn_fill_ssdt(const struct device *dev)
{
const char *name;
name = acpi_device_name(dev);
if (!name)
return;

acpigen_write_scope(acpi_device_scope(dev));
acpigen_write_device(name);

acpigen_write_name_integer("_ADR", dev->path.generic.id);

acpigen_write_device_end();
acpigen_write_scope_end();
}

static struct device_operations conn_dev_ops = {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
.acpi_name = conn_acpi_name,
.acpi_fill_ssdt = conn_fill_ssdt,
};

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

struct chip_operations ec_google_chromeec_mux_conn_ops = {
CHIP_NAME("CrosEC Type C Mux device")
.enable_dev = conn_enable,
};
41 changes: 41 additions & 0 deletions src/ec/google/chromeec/mux/mux.c
@@ -0,0 +1,41 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <acpi/acpigen.h>

#define GOOGLE_CHROMEEC_MUX_DEVICE_HID "GOOG001A"
#define GOOGLE_CHROMEEC_MUX_DEVICE_NAME "ECMX"

static void mux_fill_ssdt(const struct device *dev)
{
acpigen_write_scope(acpi_device_scope(dev));
acpigen_write_device(GOOGLE_CHROMEEC_MUX_DEVICE_NAME);
acpigen_write_name_string("_HID", GOOGLE_CHROMEEC_MUX_DEVICE_HID);
acpigen_write_name_string("_DDN", "ChromeOS EC Embedded Controller "
"Mux & Retimer control");

acpigen_write_device_end();
acpigen_write_scope_end();
}

static const char *mux_acpi_name(const struct device *dev)
{
return GOOGLE_CHROMEEC_MUX_DEVICE_NAME;
}

static struct device_operations mux_ops = {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
.acpi_name = mux_acpi_name,
.acpi_fill_ssdt = mux_fill_ssdt,
.scan_bus = scan_static_bus,
};

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

struct chip_operations ec_google_chromeec_mux_ops = {
CHIP_NAME("CrosEC Type C Mux device")
.enable_dev = mux_enable
};
2 changes: 1 addition & 1 deletion src/ec/lenovo/h8/Kconfig
Expand Up @@ -28,7 +28,7 @@ config H8_SUPPORT_BT_ON_WIFI
Disable BDC detection and assume bluetooth is installed. Required for
bluetooth on wifi cards, as it's not possible to detect it in coreboot.

config H8_HAS_BAT_TRESHOLDS_IMPL
config H8_HAS_BAT_THRESHOLDS_IMPL
bool
default n

Expand Down
2 changes: 1 addition & 1 deletion src/ec/lenovo/h8/acpi/thinkpad.asl
Expand Up @@ -304,7 +304,7 @@ Device (HKEY)
}
}

#if CONFIG(H8_HAS_BAT_TRESHOLDS_IMPL)
#if CONFIG(H8_HAS_BAT_THRESHOLDS_IMPL)
#include "thinkpad_bat_thresholds.asl"
#endif
}
4 changes: 0 additions & 4 deletions src/ec/purism/librem/Kconfig

This file was deleted.

2 changes: 1 addition & 1 deletion src/ec/starlabs/merlin/variants/apl/ecdefs.h
Expand Up @@ -20,7 +20,7 @@
#define ECRAM_KBL_TIMEOUT 0x1a
#define ECRAM_FN_LOCK_STATE 0x2c
#define ECRAM_FN_CTRL_REVERSE 0x2d
#define ECRAM_MAX_CHARGE 0x46
#define ECRAM_MAX_CHARGE dead_code_t(uint8_t)
#define ECRAM_FAN_MODE dead_code_t(uint8_t)

#endif
2 changes: 1 addition & 1 deletion src/ec/starlabs/merlin/variants/glk/ecdefs.h
Expand Up @@ -20,7 +20,7 @@
#define ECRAM_KBL_TIMEOUT 0x1a
#define ECRAM_FN_LOCK_STATE 0x2c
#define ECRAM_FN_CTRL_REVERSE 0x2d
#define ECRAM_MAX_CHARGE 0x46
#define ECRAM_MAX_CHARGE dead_code_t(uint8_t)
#define ECRAM_FAN_MODE dead_code_t(uint8_t)

#endif
2 changes: 1 addition & 1 deletion src/ec/starlabs/merlin/variants/kbl/ecdefs.h
Expand Up @@ -18,6 +18,6 @@
#define ECRAM_FN_LOCK_STATE 0x2c
#define ECRAM_FAN_MODE 0x42
#define ECRAM_FN_CTRL_REVERSE 0x43
#define ECRAM_MAX_CHARGE 0xff /* TODO: Add */
#define ECRAM_MAX_CHARGE dead_code_t(uint8_t)

#endif
11 changes: 11 additions & 0 deletions src/include/acpi/acpi.h
Expand Up @@ -636,6 +636,15 @@ typedef struct acpi_madt_ioapic {
u32 gsi_base; /* Global system interrupt base */
} __packed acpi_madt_ioapic_t;

#define MP_IRQ_POLARITY_DEFAULT 0x0
#define MP_IRQ_POLARITY_HIGH 0x1
#define MP_IRQ_POLARITY_LOW 0x3
#define MP_IRQ_POLARITY_MASK 0x3
#define MP_IRQ_TRIGGER_DEFAULT 0x0
#define MP_IRQ_TRIGGER_EDGE 0x4
#define MP_IRQ_TRIGGER_LEVEL 0xc
#define MP_IRQ_TRIGGER_MASK 0xc

/* MADT: Interrupt Source Override Structure */
typedef struct acpi_madt_irqoverride {
u8 type; /* Type (2) */
Expand Down Expand Up @@ -1278,6 +1287,8 @@ void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id);
void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length);
void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt);

void soc_lpi_get_constraints(void *unused);

void acpi_fill_fadt(acpi_fadt_t *fadt);
void arch_fill_fadt(acpi_fadt_t *fadt);
void soc_fill_fadt(acpi_fadt_t *fadt);
Expand Down
1 change: 0 additions & 1 deletion src/include/acpi/acpi_gnvs.h
Expand Up @@ -7,7 +7,6 @@

struct global_nvs;

void acpi_create_gnvs(void);
size_t size_of_dnvs(void);

#if CONFIG(ACPI_SOC_NVS)
Expand Down
3 changes: 3 additions & 0 deletions src/include/acpi/acpigen_usb.h
Expand Up @@ -41,6 +41,8 @@ enum usb_typec_data_role {
* host or device, for the USB port
* @mode_switch: Reference to the ACPI device that controls routing of data lines to
* various endpoints (xHCI, DP, etc.) on the SoC.
* @retimer_switch: Reference to the ACPI device that controls the configuration
* of the retimer in the Type C signal chain.
* @pld: Reference to PLD information.
*/
struct typec_connector_class_config {
Expand All @@ -53,6 +55,7 @@ struct typec_connector_class_config {
const struct device *orientation_switch;
const struct device *usb_role_switch;
const struct device *mode_switch;
const struct device *retimer_switch;
const struct acpi_pld *pld;
};

Expand Down
2 changes: 2 additions & 0 deletions src/include/cpu/intel/cpu_ids.h
Expand Up @@ -59,4 +59,6 @@
#define CPUID_ALDERLAKE_N_A0 0xb06e0
#define CPUID_METEORLAKE_A0_1 0xa06a0
#define CPUID_METEORLAKE_A0_2 0xa06a1
#define CPUID_RAPTORLAKE_P_J0 0xb06a2

#endif /* CPU_INTEL_CPU_IDS_H */
4 changes: 4 additions & 0 deletions src/include/cpu/x86/mp.h
Expand Up @@ -117,6 +117,10 @@ enum cb_err mp_run_on_all_aps(void (*func)(void *), void *arg, long expire_us,
/* Like mp_run_on_aps() but also runs func on BSP. */
enum cb_err mp_run_on_all_cpus(void (*func)(void *), void *arg);

/* Like mp_run_on_all_cpus but make sure all APs finish executing the
function call. The time limit on a function call is 1 second. */
enum cb_err mp_run_on_all_cpus_synchronously(void (*func)(void *), void *arg);

/*
* Park all APs to prepare for OS boot. This is handled automatically
* by the coreboot infrastructure.
Expand Down
42 changes: 9 additions & 33 deletions src/include/cpu/x86/mtrr.h
Expand Up @@ -114,43 +114,19 @@ void clear_all_var_mtrr(void);

asmlinkage void display_mtrrs(void);

/* Variable MTRR structure to help track and set MTRRs prior to ramstage. This
and the following APIs can be used to set up more complex MTRR solutions
instead of open coding get_free_var_mtrr() and set_var_mtrr() or for determining
a future solution, such as postcar_loader. */
struct var_mtrr_context {
uint32_t upper_mask;
int max_var_mtrrs;
int used_var_mtrrs;
void *arg; /* optional callback parameter */
uint32_t max_var_mtrrs;
uint32_t used_var_mtrrs;
struct {
msr_t base;
msr_t mask;
} mtrr[];
};

/* Returns 0-relative MTRR from context. Use MTRR_PHYS_BASE|MASK macros for calculating
MSR address value. */
static inline int var_mtrr_context_current_mtrr(const struct var_mtrr_context *ctx)
{
return ctx->used_var_mtrrs;
}

/* Initialize var_mtrr_context object. Assumes all variable MTRRs are not yet used. */
void var_mtrr_context_init(struct var_mtrr_context *ctx, void *arg);
/* Allocate a variable mtrr base and mask, calling the provided callback for each MTRR
MSR base-mask pair needed to accommodate the address and size request.
Returns < 0 on error and 0 on success. */
int var_mtrr_set_with_cb(struct var_mtrr_context *ctx,
uintptr_t addr, size_t size, int type,
void (*callback)(const struct var_mtrr_context *ctx,
uintptr_t base_addr, size_t size,
msr_t base, msr_t mask));
/* Same as var_mtrr_set_with_cb() but just write the MSRs directly. */
void var_mtrr_context_init(struct var_mtrr_context *ctx);
int var_mtrr_set(struct var_mtrr_context *ctx, uintptr_t addr, size_t size, int type);

/*
* Set the MTRRs using the data on the stack from setup_stack_and_mtrrs.
* Return a new top_of_stack value which removes the setup_stack_and_mtrrs data.
*/
asmlinkage void *soc_set_mtrrs(void *top_of_stack);
asmlinkage void soc_enable_mtrrs(void);
void commit_mtrr_setup(const struct var_mtrr_context *ctx);
void postcar_mtrr_setup(void);

/* fms: find most significant bit set, stolen from Linux Kernel Source. */
static inline unsigned int fms(unsigned int x)
Expand Down
10 changes: 5 additions & 5 deletions src/include/device/dram/common.h
Expand Up @@ -40,11 +40,11 @@
* disabled.
* @{
*/
#if CONFIG(DEBUG_RAM_SETUP)
#define printram(x, ...) printk(BIOS_DEBUG, x, ##__VA_ARGS__)
#else
#define printram(x, ...)
#endif
#define printram(x, ...) \
do { \
if (CONFIG(DEBUG_RAM_SETUP)) \
printk(BIOS_DEBUG, x, ##__VA_ARGS__); \
} while (0)
/** @} */

/** Result of the SPD decoding process */
Expand Down
28 changes: 28 additions & 0 deletions src/include/device/i2c_simple.h
Expand Up @@ -142,4 +142,32 @@ static inline int i2c_writeb(unsigned int bus, uint8_t slave, uint8_t reg,
return i2c_transfer(bus, &seg, 1);
}

/**
* Read multi-bytes from an I2C device with two bytes register address/offset
* with two segments in one frame
*
* [start][slave addr][w][register high addr][register low addr]
* [start][slave addr][r][data...][stop]
*/
static inline int i2c_2ba_read_bytes(unsigned int bus, uint8_t slave, uint16_t offset,
uint8_t *data, int len)
{
struct i2c_msg seg[2];
uint8_t eeprom_offset[2];

eeprom_offset[0] = offset >> 8;
eeprom_offset[1] = offset & 0xff;

seg[0].flags = 0;
seg[0].slave = slave;
seg[0].buf = eeprom_offset;
seg[0].len = sizeof(eeprom_offset);
seg[1].flags = I2C_M_RD;
seg[1].slave = slave;
seg[1].buf = data;
seg[1].len = len;

return i2c_transfer(bus, seg, ARRAY_SIZE(seg));
}

#endif /* _DEVICE_I2C_SIMPLE_H_ */
60 changes: 57 additions & 3 deletions src/include/device/pci_ids.h
Expand Up @@ -3008,8 +3008,6 @@
#define PCI_DID_INTEL_ADP_P_ESPI_29 0x7a1d
#define PCI_DID_INTEL_ADP_P_ESPI_30 0x7a1e
#define PCI_DID_INTEL_ADP_P_ESPI_31 0x7a1f
#define PCI_DID_INTEL_ADP_P_ESPI_32 0x5181
#define PCI_DID_INTEL_ADP_P_ESPI_33 0x5182
#define PCI_DID_INTEL_ADP_S_ESPI_0 0x7a80
#define PCI_DID_INTEL_ADP_S_ESPI_1 0x7a81
#define PCI_DID_INTEL_ADP_S_ESPI_2 0x7a82
Expand Down Expand Up @@ -3074,7 +3072,6 @@
#define PCI_DID_INTEL_ADP_M_N_ESPI_29 0x549d
#define PCI_DID_INTEL_ADP_M_N_ESPI_30 0x549e
#define PCI_DID_INTEL_ADP_M_N_ESPI_31 0x549f
#define PCI_DID_INTEL_ADP_M_ESPI_32 0x5186
#define PCI_DID_INTEL_SPR_ESPI_1 0x1b80
#define PCI_DID_INTEL_MTL_ESPI_0 0x7e00
#define PCI_DID_INTEL_MTL_ESPI_1 0x7e01
Expand All @@ -3084,6 +3081,38 @@
#define PCI_DID_INTEL_MTL_ESPI_5 0x7e05
#define PCI_DID_INTEL_MTL_ESPI_6 0x7e06
#define PCI_DID_INTEL_MTL_ESPI_7 0x7e07
#define PCI_DID_INTEL_RPP_P_ESPI_0 0x5180
#define PCI_DID_INTEL_RPP_P_ADP_P_ESPI_1 0x5181
#define PCI_DID_INTEL_RPP_P_ADP_P_ESPI_2 0x5182
#define PCI_DID_INTEL_RPP_P_ESPI_3 0x5183
#define PCI_DID_INTEL_RPP_P_ESPI_4 0x5184
#define PCI_DID_INTEL_RPP_P_ESPI_5 0x5185
#define PCI_DID_INTEL_RPP_P_ADP_M_ESPI_6 0x5186
#define PCI_DID_INTEL_RPP_P_ESPI_7 0x5187
#define PCI_DID_INTEL_RPP_P_ESPI_8 0x5188
#define PCI_DID_INTEL_RPP_P_ESPI_9 0x5189
#define PCI_DID_INTEL_RPP_P_ESPI_10 0x518a
#define PCI_DID_INTEL_RPP_P_ESPI_11 0x518b
#define PCI_DID_INTEL_RPP_P_ESPI_12 0x518c
#define PCI_DID_INTEL_RPP_P_ESPI_13 0x518d
#define PCI_DID_INTEL_RPP_P_ESPI_14 0x518e
#define PCI_DID_INTEL_RPP_P_ESPI_15 0x518f
#define PCI_DID_INTEL_RPP_P_ESPI_16 0x5190
#define PCI_DID_INTEL_RPP_P_ESPI_17 0x5191
#define PCI_DID_INTEL_RPP_P_ESPI_18 0x5192
#define PCI_DID_INTEL_RPP_P_ESPI_19 0x5193
#define PCI_DID_INTEL_RPP_P_ESPI_20 0x5194
#define PCI_DID_INTEL_RPP_P_ESPI_21 0x5195
#define PCI_DID_INTEL_RPP_P_ESPI_22 0x5196
#define PCI_DID_INTEL_RPP_P_ESPI_23 0x5197
#define PCI_DID_INTEL_RPP_P_ESPI_24 0x5198
#define PCI_DID_INTEL_RPP_P_ESPI_25 0x5199
#define PCI_DID_INTEL_RPP_P_ESPI_26 0x519a
#define PCI_DID_INTEL_RPP_P_ESPI_27 0x519b
#define PCI_DID_INTEL_RPP_P_ESPI_28 0x519c
#define PCI_DID_INTEL_RPP_P_ESPI_29 0x519d
#define PCI_DID_INTEL_RPP_P_ESPI_30 0x519e
#define PCI_DID_INTEL_RPP_P_ESPI_31 0x519f

/* Intel PCIE device ids */
#define PCI_DID_INTEL_LPT_H_PCIE_RP1 0x8c10
Expand Down Expand Up @@ -3434,6 +3463,10 @@
#define PCI_DID_INTEL_MTL_IOE_P_PCIE_RP11 0x7ecb
#define PCI_DID_INTEL_MTL_IOE_P_PCIE_RP12 0x7ecc

#define PCI_DID_INTEL_RPL_P_PCIE_RP1 0xa74d
#define PCI_DID_INTEL_RPL_P_PCIE_RP2 0xa70d
#define PCI_DID_INTEL_RPL_P_PCIE_RP3 0xa72d

/* Intel SATA device Ids */
#define PCI_DID_INTEL_LPT_H_DESKTOP_SATA_IDE 0x8c00
#define PCI_DID_INTEL_LPT_H_DESKTOP_SATA_AHCI 0x8c02
Expand Down Expand Up @@ -3506,6 +3539,8 @@
#define PCI_DID_INTEL_ADP_M_SATA_2 0x54d7
#define PCI_DID_INTEL_ADP_M_SATA_3 0x282a
#define PCI_DID_INTEL_MTL_SATA 0x7e63
#define PCI_DID_INTEL_RPP_P_SATA_1 0x51d3
#define PCI_DID_INTEL_RPP_P_SATA_2 0x51d7

/* Intel PMC device Ids */
#define PCI_DID_INTEL_SPT_LP_PMC 0x9d21
Expand All @@ -3530,6 +3565,7 @@
#define PCI_DID_INTEL_MTL_SOC_PMC 0x7e21
#define PCI_DID_INTEL_MTL_IOE_M_PMC 0x7ebe
#define PCI_DID_INTEL_MTL_IOE_P_PMC 0x7ece
#define PCI_DID_INTEL_RPP_P_PMC 0x51a1

/* Intel I2C device Ids */
#define PCI_DID_INTEL_LPT_LP_I2C0 0x9c61
Expand Down Expand Up @@ -3959,6 +3995,9 @@
#define PCI_DID_INTEL_MTL_M_GT2 0x7d40
#define PCI_DID_INTEL_MTL_P_GT2_1 0x7d50
#define PCI_DID_INTEL_MTL_P_GT2_2 0x7d60
#define PCI_DID_INTEL_RPL_P_GT1 0xa720
#define PCI_DID_INTEL_RPL_P_GT2 0xa7a8
#define PCI_DID_INTEL_RPL_P_GT3 0xa7a0


/* Intel Northbridge Ids */
Expand Down Expand Up @@ -4079,6 +4118,8 @@
#define PCI_DID_INTEL_MTL_M_ID 0x7D00
#define PCI_DID_INTEL_MTL_P_ID_1 0x7D01
#define PCI_DID_INTEL_MTL_P_ID_2 0x7D02
#define PCI_DID_INTEL_RPL_P_ID_1 0xa706
#define PCI_DID_INTEL_RPL_P_ID_2 0xa707

/* Intel SMBUS device Ids */
#define PCI_DID_INTEL_LPT_H_SMBUS 0x8c22
Expand All @@ -4102,6 +4143,7 @@
#define PCI_DID_INTEL_ADP_S_SMBUS 0x7aa3
#define PCI_DID_INTEL_ADP_M_N_SMBUS 0x54a3
#define PCI_DID_INTEL_MTL_SMBUS 0x7e22
#define PCI_DID_INTEL_RPP_P_SMBUS 0x51a3

/* Intel EHCI device IDs */
#define PCI_DID_INTEL_LPT_H_EHCI_1 0x8c26
Expand Down Expand Up @@ -4137,6 +4179,7 @@
#define PCI_DID_INTEL_MTL_XHCI 0x7e7d
#define PCI_DID_INTEL_MTL_M_TCSS_XHCI 0x7eb0
#define PCI_DID_INTEL_MTL_P_TCSS_XHCI 0x7ec0
#define PCI_DID_INTEL_RPP_P_TCSS_XHCI 0xa71e

/* Intel P2SB device Ids */
#define PCI_DID_INTEL_APL_P2SB 0x5a92
Expand All @@ -4161,6 +4204,7 @@
#define PCI_DID_INTEL_MTL_SOC_P2SB 0x7e20
#define PCI_DID_INTEL_MTL_IOE_M_P2SB 0x7eb8
#define PCI_DID_INTEL_MTL_IOE_P_P2SB 0x7ec8
#define PCI_DID_INTEL_RPP_P_P2SB 0x51a0

/* Intel SRAM device Ids */
#define PCI_DID_INTEL_APL_SRAM 0x5aec
Expand Down Expand Up @@ -4206,6 +4250,7 @@
#define PCI_DID_INTEL_ADP_S_AUDIO_7 0x7ad6
#define PCI_DID_INTEL_ADP_S_AUDIO_8 0x7ad7
#define PCI_DID_INTEL_ADP_P_AUDIO 0x51c8
#define PCI_DID_INTEL_RPP_P_AUDIO 0x51ca

#define PCI_DID_INTEL_ADP_M_N_AUDIO_1 0x54c8
#define PCI_DID_INTEL_ADP_M_N_AUDIO_2 0x54c9
Expand Down Expand Up @@ -4337,6 +4382,11 @@
#define PCI_DID_INTEL_MTL_M_TBT_DMA0 0x7eb2
#define PCI_DID_INTEL_MTL_P_TBT_DMA0 0x7ec2
#define PCI_DID_INTEL_MTL_P_TBT_DMA1 0x7ec3
#define PCI_DID_INTEL_RPL_TBT_RP0 0xa76e
#define PCI_DID_INTEL_RPL_TBT_RP1 0xa73f
#define PCI_DID_INTEL_RPL_TBT_RP2 0xa72f
#define PCI_DID_INTEL_RPL_TBT_DMA0 0xa73e
#define PCI_DID_INTEL_RPL_TBT_DMA1 0xa76d

/* Intel WIFI Ids */
#define PCI_DID_1000_SERIES_WIFI 0x0084
Expand Down Expand Up @@ -4369,20 +4419,23 @@
#define PCI_DID_TyP_6SERIES_WIFI 0x2725
#define PCI_DID_GrP_6SERIES_1_WIFI 0x51f0
#define PCI_DID_GrP_6SERIES_2_WIFI 0x7af0
#define PCI_DID_GrP_6SERIES_3_WIFI 0x51f1

#define PCI_DID_INTEL_TGL_IPU 0x9a19
#define PCI_DID_INTEL_TGL_H_IPU 0x9a39
#define PCI_DID_INTEL_JSL_IPU 0x4e19
#define PCI_DID_INTEL_ADL_IPU 0x465d
#define PCI_DID_INTEL_ADL_N_IPU 0x462e
#define PCI_DID_INTEL_MTL_IPU 0x7d19
#define PCI_DID_INTEL_RPL_IPU 0xa75d

/* Intel Dynamic Tuning Technology Device */
#define PCI_DID_INTEL_CML_DTT 0x1903
#define PCI_DID_INTEL_TGL_DTT 0x9A03
#define PCI_DID_INTEL_JSL_DTT 0x4E03
#define PCI_DID_INTEL_ADL_DTT 0x461d
#define PCI_DID_INTEL_MTL_DTT 0x7d03
#define PCI_DID_INTEL_RPL_DTT 0xa71d

/* Intel CNVi WiFi/BT device IDs */
#define PCI_DID_INTEL_CML_LP_CNVI_WIFI 0x02f0
Expand Down Expand Up @@ -4427,6 +4480,7 @@
#define PCI_DID_INTEL_ADP_N_PMC_CRASHLOG_SRAM 0x54ef
#define PCI_DID_INTEL_TGP_PMC_CRASHLOG_SRAM 0xa0ef
#define PCI_DID_INTEL_MTL_CRASHLOG_SRAM 0x7d0d
#define PCI_DID_INTEL_RPL_CPU_CRASHLOG_SRAM 0xa77d

#define PCI_VID_COMPUTONE 0x8e0e
#define PCI_DID_COMPUTONE_IP2EX 0x0291
Expand Down
2 changes: 1 addition & 1 deletion src/include/memory_info.h
Expand Up @@ -8,7 +8,7 @@

#define DIMM_INFO_SERIAL_SIZE 4
#define DIMM_INFO_PART_NUMBER_SIZE 33
#define DIMM_INFO_TOTAL 16
#define DIMM_INFO_TOTAL 32

/**
* If this table is filled and put in CBMEM,
Expand Down
18 changes: 9 additions & 9 deletions src/include/rules.h
Expand Up @@ -268,15 +268,15 @@
/* Indicates memory layout is determined with arch/x86/car.ld. */
#define ENV_CACHE_AS_RAM (ENV_ROMSTAGE_OR_BEFORE && !CONFIG(RESET_VECTOR_IN_RAM))
/* No .data sections with execute-in-place from ROM. */
#define ENV_STAGE_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
#define ENV_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
#else
/* Both .data and .bss, sometimes SRAM not DRAM. */
#define ENV_STAGE_HAS_DATA_SECTION 1
#define ENV_HAS_DATA_SECTION 1
#define ENV_CACHE_AS_RAM 0
#endif

/* Currently rmodules, ramstage and smm have heap. */
#define ENV_STAGE_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM)
#define ENV_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM)

/* Set USER_SPACE in the makefile for the rare code that runs in userspace */
#if defined(__USER_SPACE__)
Expand All @@ -293,21 +293,21 @@
#endif

#if ENV_X86
#define STAGE_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE
#define ENV_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE
#elif ENV_RISCV
#define STAGE_HAS_SPINLOCKS 1
#define ENV_HAS_SPINLOCKS 1
#else
#define STAGE_HAS_SPINLOCKS 0
#define ENV_HAS_SPINLOCKS 0
#endif

/* When set <arch/smp/spinlock.h> is included for the spinlock implementation. */
#define ENV_STAGE_SUPPORTS_SMP (CONFIG(SMP) && STAGE_HAS_SPINLOCKS)
#define ENV_SUPPORTS_SMP (CONFIG(SMP) && ENV_HAS_SPINLOCKS)

#if ENV_X86 && CONFIG(COOP_MULTITASKING) && (ENV_RAMSTAGE || ENV_ROMSTAGE)
/* TODO: Enable in all x86 stages */
#define ENV_STAGE_SUPPORTS_COOP 1
#define ENV_SUPPORTS_COOP 1
#else
#define ENV_STAGE_SUPPORTS_COOP 0
#define ENV_SUPPORTS_COOP 0
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion src/include/smp/spinlock.h
@@ -1,7 +1,7 @@
#ifndef SMP_SPINLOCK_H
#define SMP_SPINLOCK_H

#if ENV_STAGE_SUPPORTS_SMP
#if ENV_SUPPORTS_SMP
#include <arch/smp/spinlock.h>
#else /* !CONFIG_SMP */

Expand Down
2 changes: 1 addition & 1 deletion src/include/stddef.h
Expand Up @@ -32,7 +32,7 @@ typedef __WINT_TYPE__ wint_t;
#define DEVTREE_CONST
#endif

#if ENV_STAGE_HAS_DATA_SECTION
#if ENV_HAS_DATA_SECTION
#define MAYBE_STATIC_NONZERO static
#else
#define MAYBE_STATIC_NONZERO
Expand Down
2 changes: 1 addition & 1 deletion src/include/thread.h
Expand Up @@ -37,7 +37,7 @@ int thread_run_until(struct thread_handle *handle, enum cb_err (*func)(void *),
/* Waits until the thread has terminated and returns the error code */
enum cb_err thread_join(struct thread_handle *handle);

#if ENV_STAGE_SUPPORTS_COOP
#if ENV_SUPPORTS_COOP

struct thread {
int id;
Expand Down
15 changes: 15 additions & 0 deletions src/lib/Makefile.inc
Expand Up @@ -394,3 +394,18 @@ endif
ramstage-y += uuid.c

romstage-$(CONFIG_SPD_CACHE_IN_FMAP) += spd_cache.c

cbfs-files-y += cbfs_master_header
cbfs_master_header-file := cbfs_master_header.c:struct
cbfs_master_header-type := "cbfs header"
cbfs_master_header-position := 0

ifeq ($(CONFIG_ARCH_X86),y)
$(call src-to-obj,bootblock,$(dir)/master_header_pointer.c): $(obj)/fmap_config.h
bootblock-y += master_header_pointer.c
else
cbfs-files-y += header_pointer
header_pointer-file := master_header_pointer.c:struct
header_pointer-position := -4
header_pointer-type := "cbfs header"
endif
2 changes: 1 addition & 1 deletion src/lib/bootmem.c
Expand Up @@ -4,9 +4,9 @@
#include <bootmem.h>
#include <cbmem.h>
#include <device/resource.h>
#include <stdlib.h>
#include <symbols.h>
#include <assert.h>
#include <types.h>

static int initialized;
static int table_written;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/cbfs.c
Expand Up @@ -19,7 +19,7 @@
#include <thread.h>
#include <timestamp.h>

#if ENV_STAGE_HAS_DATA_SECTION
#if ENV_HAS_DATA_SECTION
struct mem_pool cbfs_cache =
MEM_POOL_INIT(_cbfs_cache, REGION_SIZE(cbfs_cache), CONFIG_CBFS_CACHE_ALIGN);
#else
Expand Down Expand Up @@ -363,7 +363,7 @@ static enum cb_err get_preload_rdev(struct region_device *rdev, const char *name
enum cb_err err;
struct cbfs_preload_context *context;

if (!CONFIG(CBFS_PRELOAD) || !ENV_STAGE_SUPPORTS_COOP)
if (!CONFIG(CBFS_PRELOAD) || !ENV_SUPPORTS_COOP)
return CB_ERR_ARG;

context = find_cbfs_preload_context(name);
Expand Down
30 changes: 30 additions & 0 deletions src/lib/cbfs_master_header.c
@@ -0,0 +1,30 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <endian.h>
#include <fmap_config.h>
#include <commonlib/bsd/cbfs_serialized.h>

struct cbfs_header header = {
.magic = cpu_to_be32(CBFS_HEADER_MAGIC),
.version = cpu_to_be32(CBFS_HEADER_VERSION),
/*
* The offset and romsize fields within the master header are absolute
* values within the boot media. As such, romsize needs to reflect
* the end 'offset' for a CBFS. To achieve that the current buffer
* representing the CBFS region's size is added to the offset of
* the region within a larger image.
*/
.romsize = cpu_to_be32(FMAP_SECTION_COREBOOT_START + FMAP_SECTION_COREBOOT_SIZE
- FMAP_SECTION_FLASH_START),
/*
* The 4 bytes are left out for two reasons:
* 1. the cbfs master header pointer resides there
* 2. some cbfs implementations assume that an image that resides
* below 4GB has a bootblock and get confused when the end of the
* image is at 4GB == 0.
*/
.bootblocksize = cpu_to_be32(4),
.align = cpu_to_be32(CBFS_ALIGNMENT),
.offset = cpu_to_be32(FMAP_SECTION_COREBOOT_START - FMAP_SECTION_FLASH_START),
.architecture = cpu_to_be32(CBFS_ARCHITECTURE_UNKNOWN),
};
6 changes: 2 additions & 4 deletions src/lib/coreboot_table.c
Expand Up @@ -15,14 +15,14 @@
#include <drivers/tpm/tpm_ppi.h>
#include <fmap.h>
#include <fw_config.h>
#include <stdlib.h>
#include <cbfs.h>
#include <cbmem.h>
#include <bootmem.h>
#include <bootsplash.h>
#include <inttypes.h>
#include <spi_flash.h>
#include <smmstore.h>
#include <types.h>

#if CONFIG(USE_OPTION_TABLE)
#include <option_table.h>
Expand All @@ -37,9 +37,7 @@ static struct lb_header *lb_table_init(unsigned long addr)
{
struct lb_header *header;

/* 16 byte align the address */
addr += 15;
addr &= ~15;
addr = ALIGN_UP(addr, 16);

header = (void *)addr;
header->signature[0] = 'L';
Expand Down
1 change: 0 additions & 1 deletion src/lib/edid_fill_fb.c
Expand Up @@ -6,7 +6,6 @@
#include <framebuffer_info.h>
#include <string.h>
#include <stdlib.h>
#include <bootsplash.h>
#include <list.h>

struct fb_info {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/fit.c
Expand Up @@ -5,15 +5,14 @@
#include <console/console.h>
#include <ctype.h>
#include <endian.h>
#include <stdint.h>
#include <bootmem.h>
#include <stdlib.h>
#include <string.h>
#include <program_loading.h>
#include <memrange.h>
#include <fit.h>
#include <boardid.h>
#include <commonlib/stdlib.h>
#include <types.h>

static struct list_node image_nodes;
static struct list_node config_nodes;
Expand Down
16 changes: 11 additions & 5 deletions src/lib/fmap.c
Expand Up @@ -273,7 +273,7 @@ ssize_t fmap_overwrite_area(const char *name, const void *buffer, size_t size)
return rdev_writeat(&rdev, buffer, 0, size);
}

static void fmap_register_cbmem_cache(int unused)
static void fmap_register_cbmem_cache(void)
{
const struct cbmem_entry *e;

Expand All @@ -290,7 +290,7 @@ static void fmap_register_cbmem_cache(int unused)
* The main reason to copy the FMAP into CBMEM is to make it available to the
* OS on every architecture. As side effect use the CBMEM copy as cache.
*/
static void fmap_setup_cbmem_cache(int unused)
static void fmap_add_cbmem_cache(void)
{
struct region_device fmrd;

Expand All @@ -311,11 +311,17 @@ static void fmap_setup_cbmem_cache(int unused)
cbmem_entry_remove(cbmem_entry_find(CBMEM_ID_FMAP));
return;
}
}

static void fmap_setup_cbmem_cache(int unused)
{
if (ENV_ROMSTAGE)
fmap_add_cbmem_cache();

/* Finally advertise the cache for the current stage */
fmap_register_cbmem_cache(unused);
fmap_register_cbmem_cache();
}

ROMSTAGE_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
RAMSTAGE_CBMEM_INIT_HOOK(fmap_register_cbmem_cache)
POSTCAR_CBMEM_INIT_HOOK(fmap_register_cbmem_cache)
RAMSTAGE_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
POSTCAR_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
9 changes: 0 additions & 9 deletions src/lib/hardwaremain.c
Expand Up @@ -19,12 +19,10 @@
#include <device/device.h>
#include <device/pci.h>
#include <program_loading.h>
#include <stdlib.h>
#include <thread.h>
#include <timer.h>
#include <timestamp.h>
#include <types.h>
#include <vendorcode/google/chromeos/chromeos.h>
#include <version.h>

static boot_state_t bs_pre_device(void *arg);
Expand Down Expand Up @@ -463,13 +461,6 @@ void main(void)
/* Handoff sleep type from romstage. */
acpi_is_wakeup_s3();

/* Initialise GNVS early. */
if (CONFIG(ACPI_SOC_NVS))
acpi_create_gnvs();

if (CONFIG(CHROMEOS_NVS))
chromeos_init_chromeos_acpi();

/* Schedule the static boot state entries. */
boot_state_schedule_static_entries();

Expand Down
1 change: 0 additions & 1 deletion src/lib/imd.c
Expand Up @@ -4,7 +4,6 @@
#include <cbmem.h>
#include <console/console.h>
#include <imd.h>
#include <stdlib.h>
#include <string.h>
#include <types.h>
#include <imd_private.h>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/imd_cbmem.c
Expand Up @@ -7,7 +7,7 @@
#include <cbmem.h>
#include <imd.h>
#include <lib.h>
#include <stdlib.h>
#include <types.h>

/* The program loader passes on cbmem_top and the program entry point
has to fill in the _cbmem_top_ptr symbol based on the calling arguments. */
Expand Down
21 changes: 21 additions & 0 deletions src/lib/master_header_pointer.c
@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <commonlib/bsd/cbfs_serialized.h>
#include <endian.h>
#include <fmap_config.h>
#include <stdint.h>

#if CONFIG(BOOTBLOCK_IN_CBFS)
__attribute__((used, __section__(".header_pointer")))
#endif

#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1)
#define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START)
#else
#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START
#endif

uint32_t header_pointer =
cpu_to_le32(COREBOOT_CBFS_START + ALIGN_UP(sizeof(struct cbfs_file)
+ sizeof("cbfs_master_header"),
CBFS_ATTRIBUTE_ALIGN));
7 changes: 2 additions & 5 deletions src/lib/prog_loaders.c
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */


#include <stdlib.h>
#include <cbfs.h>
#include <cbmem.h>
#include <console/console.h>
Expand Down Expand Up @@ -89,11 +87,10 @@ void run_ramstage(void)
struct prog ramstage =
PROG_INIT(PROG_RAMSTAGE, CONFIG_CBFS_PREFIX "/ramstage");

/* Call "end of romstage" here if postcar stage doesn't exist */
if (ENV_POSTCAR)
timestamp_add_now(TS_POSTCAR_END);

/* Call "end of romstage" here if postcar stage doesn't exist */
if (ENV_ROMSTAGE)
else
timestamp_add_now(TS_ROMSTAGE_END);

/*
Expand Down
4 changes: 2 additions & 2 deletions src/lib/program.ld
Expand Up @@ -72,7 +72,7 @@
#endif

/* Include data, bss, and heap in that order. Not defined for all stages. */
#if ENV_STAGE_HAS_DATA_SECTION
#if ENV_HAS_DATA_SECTION
.data . : {
. = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
_data = .;
Expand Down Expand Up @@ -130,7 +130,7 @@
}
#endif

#if ENV_STAGE_HAS_HEAP_SECTION
#if ENV_HAS_HEAP_SECTION
.heap . : {
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_heap = .;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/rmodule.c
@@ -1,13 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <assert.h>
#include <cbmem.h>
#include <cbfs.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <console/console.h>
#include <program_loading.h>
#include <rmodule.h>
#include <types.h>

/* Change this define to get more verbose debugging for module loading. */
#define PK_ADJ_LEVEL BIOS_NEVER
Expand Down
3 changes: 1 addition & 2 deletions src/lib/selfboot.c
Expand Up @@ -3,8 +3,6 @@
#include <commonlib/bsd/compression.h>
#include <commonlib/endian.h>
#include <console/console.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <symbols.h>
#include <cbfs.h>
Expand All @@ -13,6 +11,7 @@
#include <program_loading.h>
#include <timestamp.h>
#include <cbmem.h>
#include <types.h>

/* The type syntax for C is essentially unparsable. -- Rob Pike */
typedef int (*checker_t)(struct cbfs_payload_segment *cbfssegs, void *args);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/spd_bin.c
Expand Up @@ -34,11 +34,12 @@ static bool use_ddr4_params(int dram_type)
case SPD_DRAM_LPDDR3_JEDEC:
case SPD_DRAM_DDR4:
case SPD_DRAM_DDR5:
case SPD_DRAM_LPDDR5:
case SPD_DRAM_LPDDR4:
case SPD_DRAM_LPDDR4X:
return true;
default:
printk(BIOS_ERR, "Defaulting to using DDR4 params. Please add dram_type check for %d to %s\n",
printk(BIOS_NOTICE, "Defaulting to using DDR4 params. Please add dram_type check for %d to %s\n",
dram_type, __func__);
return true;
}
Expand Down Expand Up @@ -165,6 +166,7 @@ static void spd_get_name(const uint8_t spd[], int type, const char **spd_name, s
case SPD_DRAM_LPDDR3_JEDEC:
case SPD_DRAM_DDR4:
case SPD_DRAM_DDR5:
case SPD_DRAM_LPDDR5:
case SPD_DRAM_LPDDR4:
case SPD_DRAM_LPDDR4X:
if (spd[DDR4_SPD_PART_OFF]) {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/spd_cache.c
Expand Up @@ -155,6 +155,10 @@ bool check_if_dimm_changed(u8 *spd_cache, struct spd_block *blk)
bool dimm_changed = false;
/* Check if the dimm is the same with last system boot. */
for (i = 0; i < SC_SPD_NUMS && !dimm_changed; i++) {
if (blk->addr_map[i] == 0) {
printk(BIOS_NOTICE, "SPD_CACHE: DIMM%d does not exist\n", i);
continue;
}
/* Return true if any error happened here. */
if (get_spd_sn(blk->addr_map[i], &sn) == CB_ERR)
return true;
Expand Down
4 changes: 1 addition & 3 deletions src/lib/thread.c
@@ -1,14 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <bootstate.h>
#include <console/console.h>
#include <smp/node.h>
#include <thread.h>
#include <timer.h>
#include <types.h>

static u8 thread_stacks[CONFIG_STACK_SIZE * CONFIG_NUM_THREADS] __aligned(sizeof(uint64_t));
static bool initialized;
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/acer/aspire_vn7_572g/Kconfig
Expand Up @@ -16,7 +16,7 @@ config BOARD_SPECIFIC_OPTIONS
select INTEL_GMA_HAVE_VBT
select INTEL_INT15
select INTEL_LPSS_UART_FOR_CONSOLE
select MAINBOARD_HAS_CRB_TPM
select CRB_TPM
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_TPM2
select NO_UART_ON_SUPERIO
Expand Down
1 change: 1 addition & 0 deletions src/mainboard/amd/chausie/Kconfig
Expand Up @@ -6,6 +6,7 @@ config BOARD_SPECIFIC_OPTIONS
def_bool y
select BOARD_ROMSIZE_KB_16384
select HAVE_ACPI_RESUME
select EC_ACPI
select SOC_AMD_SABRINA
select SOC_AMD_COMMON_BLOCK_USE_ESPI
select AMD_SOC_CONSOLE_UART
Expand Down
1 change: 1 addition & 0 deletions src/mainboard/amd/chausie/Makefile.inc
Expand Up @@ -2,6 +2,7 @@

bootblock-y += bootblock.c
bootblock-y += early_gpio.c
bootblock-y += ec.c

romstage-y += port_descriptors.c

Expand Down
9 changes: 9 additions & 0 deletions src/mainboard/amd/chausie/bootblock.c
@@ -1,9 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <bootblock_common.h>
#include <soc/espi.h>
#include "ec.h"
#include "gpio.h"

void bootblock_mainboard_early_init(void)
{
mainboard_program_early_gpios();

espi_switch_to_spi1_pads();
}

void bootblock_mainboard_init(void)
{
chausie_ec_init();
}
125 changes: 124 additions & 1 deletion src/mainboard/amd/chausie/devicetree.cb
Expand Up @@ -2,7 +2,15 @@

chip soc/amd/sabrina
register "common_config.espi_config" = "{
.std_io_decode_bitmap = ESPI_DECODE_IO_0x80_EN | ESPI_DECODE_IO_0X2E_0X2F_EN,
.std_io_decode_bitmap = ESPI_DECODE_IO_0x80_EN | ESPI_DECODE_IO_0X2E_0X2F_EN | ESPI_DECODE_IO_0X60_0X64_EN,
.generic_io_range[0] = {
.base = 0x3f8,
.size = 8,
},
.generic_io_range[1] = {
.base = 0x600,
.size = 256,
},
.io_mode = ESPI_IO_MODE_QUAD,
.op_freq_mhz = ESPI_OP_FREQ_16_MHZ,
.crc_check_enable = 1,
Expand All @@ -16,6 +24,11 @@ chip soc/amd/sabrina
register "i2c_scl_reset" = "GPIO_I2C0_SCL | GPIO_I2C1_SCL |
GPIO_I2C2_SCL | GPIO_I2C3_SCL"

register "i2c[0].early_init" = "1"
register "i2c[1].early_init" = "1"
register "i2c[2].early_init" = "1"
register "i2c[3].early_init" = "1"

# I2C Pad Control RX Select Configuration
register "i2c_pad[0].rx_level" = "I2C_PAD_RX_1_8V"
register "i2c_pad[1].rx_level" = "I2C_PAD_RX_1_8V"
Expand All @@ -26,6 +39,116 @@ chip soc/amd/sabrina

register "pspp_policy" = "DXIO_PSPP_DISABLED" # TODO: reenable when PSPP works

register "usb_phy_custom" = "1"
register "usb_phy" = "{
.Usb2PhyPort[0] = {
.compdistune = 0x3,
.pllbtune = 0x1,
.pllitune = 0x0,
.pllptune = 0xe,
.sqrxtune = 0x3,
.txfslstune = 0x3,
.txpreempamptune = 0x2,
.txpreemppulsetune = 0x0,
.txrisetune = 0x1,
.txvreftune = 0x3,
.txhsxvtune = 0x3,
.txrestune = 0x2,
},
.Usb2PhyPort[1] = {
.compdistune = 0x3,
.pllbtune = 0x1,
.pllitune = 0x0,
.pllptune = 0xe,
.sqrxtune = 0x3,
.txfslstune = 0x3,
.txpreempamptune = 0x2,
.txpreemppulsetune = 0x0,
.txrisetune = 0x1,
.txvreftune = 0x3,
.txhsxvtune = 0x3,
.txrestune = 0x2,
},
.Usb2PhyPort[2] = {
.compdistune = 0x3,
.pllbtune = 0x1,
.pllitune = 0x0,
.pllptune = 0xe,
.sqrxtune = 0x3,
.txfslstune = 0x3,
.txpreempamptune = 0x2,
.txpreemppulsetune = 0x0,
.txrisetune = 0x1,
.txvreftune = 0x3,
.txhsxvtune = 0x3,
.txrestune = 0x2,
},
.Usb2PhyPort[3] = {
.compdistune = 0x3,
.pllbtune = 0x1,
.pllitune = 0x0,
.pllptune = 0xe,
.sqrxtune = 0x3,
.txfslstune = 0x3,
.txpreempamptune = 0x2,
.txpreemppulsetune = 0x0,
.txrisetune = 0x1,
.txvreftune = 0x3,
.txhsxvtune = 0x3,
.txrestune = 0x2,
},
.Usb2PhyPort[4] = {
.compdistune = 0x3,
.pllbtune = 0x1,
.pllitune = 0x0,
.pllptune = 0xe,
.sqrxtune = 0x3,
.txfslstune = 0x3,
.txpreempamptune = 0x2,
.txpreemppulsetune = 0x0,
.txrisetune = 0x1,
.txvreftune = 0x3,
.txhsxvtune = 0x3,
.txrestune = 0x2,
},
.Usb2PhyPort[5] = {
.compdistune = 0x3,
.pllbtune = 0x1,
.pllitune = 0x0,
.pllptune = 0xe,
.sqrxtune = 0x3,
.txfslstune = 0x3,
.txpreempamptune = 0x2,
.txpreemppulsetune = 0x0,
.txrisetune = 0x1,
.txvreftune = 0x3,
.txhsxvtune = 0x3,
.txrestune = 0x2,
},
.Usb3PhyPort[0] = {
.tx_term_ctrl = 0x2,
.rx_term_ctrl = 0x2,
.tx_vboost_lvl_en = 0x0,
.tx_vboost_lvl = 0x5,
},
.Usb3PhyPort[1] = {
.tx_term_ctrl = 0x2,
.rx_term_ctrl = 0x2,
.tx_vboost_lvl_en = 0x0,
.tx_vboost_lvl = 0x5,
},
.Usb3PhyPort[2] = {
.tx_term_ctrl = 0x2,
.rx_term_ctrl = 0x2,
.tx_vboost_lvl_en = 0x0,
.tx_vboost_lvl = 0x5,
},
.ComboPhyStaticConfig[0] = USB_COMBO_PHY_MODE_USB_C,
.ComboPhyStaticConfig[1] = USB_COMBO_PHY_MODE_USB_C,
.BatteryChargerEnable = 0,
.PhyP3CpmP4Support = 0,
}"

device domain 0 on
device ref iommu on end
device ref gpp_bridge_0 on end # GBE
Expand Down
58 changes: 58 additions & 0 deletions src/mainboard/amd/chausie/ec.c
@@ -0,0 +1,58 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <ec/acpi/ec.h>
#include "ec.h"

#define CHAUSIE_EC_CMD 0x666
#define CHAUSIE_EC_DATA 0x662

#define EC_GPIO_3_ADDR 0xA3
#define EC_GPIO_LOM_RESET_AUX (1 << 1)

#define EC_GPIO_7_ADDR 0xA7
#define EC_GPIO_DT_PWREN (1 << 2)
#define EC_GPIO_WWAN_MODULE_RST (1 << 5)

#define EC_GPIO_8_ADDR 0xA8
#define EC_GPIO_SMBUS0_EN (1 << 0)

#define EC_GPIO_A_ADDR 0xAA
#define EC_GPIO_WWAN_PWREN (1 << 3)
#define EC_GPIO_M2_SSD0_PWREN (1 << 6)
#define EC_GPIO_LOM_PWREN (1 << 7)

#define EC_GPIO_C_ADDR 0xAC
#define EC_GPIO_DT_N_WLAN_SW (1 << 1)
#define EC_GPIO_MP2_SEL (1 << 2)
#define EC_GPIO_WWAN_N_LOM_SW (1 << 3)

static void configure_ec_gpio(void)
{
uint8_t tmp;

tmp = ec_read(EC_GPIO_3_ADDR);
tmp |= EC_GPIO_LOM_RESET_AUX;
ec_write(EC_GPIO_3_ADDR, tmp);

tmp = ec_read(EC_GPIO_7_ADDR);
tmp |= EC_GPIO_WWAN_MODULE_RST | EC_GPIO_DT_PWREN;
ec_write(EC_GPIO_7_ADDR, tmp);

tmp = ec_read(EC_GPIO_8_ADDR);
tmp |= EC_GPIO_SMBUS0_EN;
ec_write(EC_GPIO_8_ADDR, tmp);

tmp = ec_read(EC_GPIO_A_ADDR);
tmp |= EC_GPIO_M2_SSD0_PWREN | EC_GPIO_LOM_PWREN | EC_GPIO_WWAN_PWREN;
ec_write(EC_GPIO_A_ADDR, tmp);

tmp = ec_read(EC_GPIO_C_ADDR);
tmp |= EC_GPIO_WWAN_N_LOM_SW | EC_GPIO_MP2_SEL | EC_GPIO_DT_N_WLAN_SW;
ec_write(EC_GPIO_C_ADDR, tmp);
}

void chausie_ec_init(void)
{
ec_set_ports(CHAUSIE_EC_CMD, CHAUSIE_EC_DATA);
configure_ec_gpio();
}
8 changes: 8 additions & 0 deletions src/mainboard/amd/chausie/ec.h
@@ -0,0 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef CHAUSIE_EC_H
#define CHAUSIE_EC_H

void chausie_ec_init(void);

#endif /* CHAUSIE_EC_H */
46 changes: 44 additions & 2 deletions src/mainboard/amd/chausie/port_descriptors.c
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <device/i2c_simple.h>
#include <soc/gpio.h>
#include <soc/platform_descriptors.h>
#include <types.h>
Expand Down Expand Up @@ -47,13 +49,13 @@ static const fsp_dxio_descriptor chausie_dxio_descriptors[] = {
},
};

static const fsp_ddi_descriptor chausie_ddi_descriptors[] = {
static fsp_ddi_descriptor chausie_ddi_descriptors[] = {
{ /* DDI0 - eDP */
.connector_type = DDI_EDP,
.aux_index = DDI_AUX1,
.hdp_index = DDI_HDP1
},
{ /* DDI1 - HDMI - TODO: add runtime HDMI/DP connector card detection */
{ /* DDI1 - HDMI/DP */
.connector_type = DDI_HDMI,
.aux_index = DDI_AUX2,
.hdp_index = DDI_HDP2
Expand All @@ -75,10 +77,50 @@ static const fsp_ddi_descriptor chausie_ddi_descriptors[] = {
}
};

static uint8_t get_ddi1_type(void)
{
const uint8_t eeprom_i2c_bus = 2;
const uint8_t eeprom_i2c_address = 0x55;
const uint16_t eeprom_connector_type_offset = 2;
uint8_t eeprom_connector_type_data[2];
uint16_t connector_type;

if (i2c_2ba_read_bytes(eeprom_i2c_bus, eeprom_i2c_address,
eeprom_connector_type_offset, eeprom_connector_type_data,
sizeof(eeprom_connector_type_data))) {
printk(BIOS_NOTICE,
"Display connector type couldn't be determined. Disabling DDI1.\n");
return DDI_UNUSED_TYPE;
}

connector_type = eeprom_connector_type_data[1] | eeprom_connector_type_data[0] << 8;

switch (connector_type) {
case 0xc:
printk(BIOS_DEBUG, "Configuring DDI1 as HDMI.\n");
return DDI_HDMI;
break;
case 0x13:
printk(BIOS_DEBUG, "Configuring DDI1 as DP.\n");
return DDI_DP;
break;
case 0x14:
printk(BIOS_DEBUG, "Configuring DDI1 as eDP.\n");
return DDI_EDP;
break;
default:
printk(BIOS_WARNING, "Unexpected display connector type %x. Disabling DDI1.\n",
connector_type);
return DDI_UNUSED_TYPE;
}
}

void mainboard_get_dxio_ddi_descriptors(
const fsp_dxio_descriptor **dxio_descs, size_t *dxio_num,
const fsp_ddi_descriptor **ddi_descs, size_t *ddi_num)
{
chausie_ddi_descriptors[1].connector_type = get_ddi1_type();

*dxio_descs = chausie_dxio_descriptors;
*dxio_num = ARRAY_SIZE(chausie_dxio_descriptors);
*ddi_descs = chausie_ddi_descriptors;
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/amd/majolica/Makefile.inc
Expand Up @@ -13,7 +13,7 @@ APCB_SOURCES_RECOVERY = $(MAINBOARD_BLOBS_DIR)/APCB_CZN_D4_DefaultRecovery.bin

ifeq ($(CONFIG_MAJOLICA_HAVE_MCHP_FW),y)
$(call add_intermediate, add_mchp_fw)
$(CBFSTOOL) $(obj)/coreboot.pre write -r EC -f $(CONFIG_MAJOLICA_MCHP_FW_FILE) --fill-upward
$(CBFSTOOL) $< write -r EC -f $(CONFIG_MAJOLICA_MCHP_FW_FILE) --fill-upward
else
files_added:: warn_no_mchp
endif # CONFIG_MAJOLICA_HAVE_MCHP_FW
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/amd/mandolin/Makefile.inc
Expand Up @@ -19,7 +19,7 @@ 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
$(CBFSTOOL) $< write -r EC -f $(CONFIG_MANDOLIN_MCHP_FW_FILE) --fill-upward

else
files_added:: warn_no_mchp
Expand Down
3 changes: 1 addition & 2 deletions src/mainboard/amd/olivehill/bootblock.c
Expand Up @@ -7,12 +7,11 @@
void bootblock_mainboard_early_init(void)
{
int i;
u32 val;

/* Disable PCI-PCI bridge and release GPIO32/33 for other uses. */
pm_write8(0xea, 0x1);

/* On Larne, after LpcClkDrvSth is set, it needs some time to be stable, because of the buffer ICS551M */
for (i = 0; i < 200000; i++)
val = inb(0xcd6);
inb(0xcd6);
}
6 changes: 2 additions & 4 deletions src/mainboard/amd/padmelon/bootblock/bootblock.c
Expand Up @@ -13,11 +13,9 @@
/* Enable IO access to port, then enable UART HW control pins */
static void enable_serial(unsigned int base_port, unsigned int io_enable)
{
u32 temp;
u8 reg;
temp = pci_read_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE);
temp |= io_enable;
pci_write_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE, temp);

pci_or_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE, io_enable);

/*
* Remove this section if HW handshake is not needed. This is needed
Expand Down
5 changes: 1 addition & 4 deletions src/mainboard/amd/padmelon/fan_init.c
Expand Up @@ -72,11 +72,8 @@ struct fintek_fan system_fan = {

static void init_fan_control(void *unused)
{
u32 temp;
/* Open a LPC IO access to 0x0220-0x0227 */
temp = pci_read_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE);
temp |= DECODE_ENABLE_SERIAL_PORT2;
pci_write_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE, temp);
pci_or_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE, DECODE_ENABLE_SERIAL_PORT2);

set_fan(&cpu_fan);
set_fan(&system_fan);
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/asrock/b85m_pro4/Kconfig
Expand Up @@ -11,7 +11,7 @@ config BOARD_SPECIFIC_OPTIONS
select HAVE_OPTION_TABLE
select INTEL_GMA_HAVE_VBT
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_USES_IFD_GBE_REGION
select NORTHBRIDGE_INTEL_HASWELL
select SERIRQ_CONTINUOUS_MODE
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/asrock/h110m/Kconfig
Expand Up @@ -15,7 +15,7 @@ config BOARD_SPECIFIC_OPTIONS
select SUPERIO_NUVOTON_NCT6791D
select REALTEK_8168_RESET
select RT8168_SET_LED_MODE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM

config DISABLE_HECI1_AT_PRE_BOOT
default y
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/asus/am1i-a/Kconfig
Expand Up @@ -18,7 +18,7 @@ config BOARD_SPECIFIC_OPTIONS
select SOUTHBRIDGE_AMD_AGESA_YANGTZE
select DEFAULT_POST_ON_LPC
select SUPERIO_ITE_IT8623E
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM

config MAINBOARD_DIR
default "asus/am1i-a"
Expand Down
4 changes: 2 additions & 2 deletions src/mainboard/asus/am1i-a/bootblock.c
Expand Up @@ -103,7 +103,7 @@ static void ite_gpio_conf(pnp_devfn_t dev)

void bootblock_mainboard_early_init(void)
{
u32 val, i;
u32 i;

/* Disable PCI-PCI bridge and release GPIO32/33 for other uses. */
pm_write8(0xea, 0x1);
Expand All @@ -128,5 +128,5 @@ void bootblock_mainboard_early_init(void)
* because of the buffer ICS551M
*/
for (i = 0; i < 200000; i++)
val = inb(0xcd6);
inb(0xcd6);
}
4 changes: 2 additions & 2 deletions src/mainboard/asus/h61-series/Kconfig.name
Expand Up @@ -34,7 +34,7 @@ config BOARD_ASUS_P8H61_M_PRO
select DRIVERS_ASMEDIA_ASPM_BLACKLIST
select HAVE_CMOS_DEFAULT
select HAVE_OPTION_TABLE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select REALTEK_8168_RESET
select RT8168_SET_LED_MODE
select SUPERIO_NUVOTON_NCT6776
Expand All @@ -46,7 +46,7 @@ config BOARD_ASUS_P8H61_M_PRO_CM6630
select DRIVERS_ASMEDIA_ASPM_BLACKLIST
select HAVE_CMOS_DEFAULT
select HAVE_OPTION_TABLE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select REALTEK_8168_RESET
select RT8168_SET_LED_MODE
select SUPERIO_NUVOTON_NCT6776
8 changes: 2 additions & 6 deletions src/mainboard/asus/p2b/dsdt.asl
Expand Up @@ -22,11 +22,7 @@ DefinitionBlock (
#include <acpi/dsdt_top.asl>
/* \_SB scope defining the main processor is generated in SSDT. */

OperationRegion(X80, SystemIO, 0x80, 1)
Field(X80, ByteAcc, NoLock, Preserve)
{
P80, 8
}
#include <arch/x86/acpi/post.asl>

/*
* Intel 82371EB (PIIX4E) datasheet, section 7.2.3, page 142
Expand Down Expand Up @@ -77,7 +73,7 @@ DefinitionBlock (
/* Arms SMI for device 12 */
TO12 = 1
/* Put out a POST code */
P80 = Arg0 | 0xF0
DBG0 = Arg0 | 0xF0
}

Method (\_WAK, 1, NotSerialized)
Expand Down
6 changes: 3 additions & 3 deletions src/mainboard/asus/p8x7x-series/Kconfig.name
Expand Up @@ -2,7 +2,7 @@ config BOARD_ASUS_P8C_WS
bool "P8C_WS"
select BOARD_ASUS_P8X7X_SERIES
select BOARD_ROMSIZE_KB_8192
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select SUPERIO_NUVOTON_NCT6776
select USE_NATIVE_RAMINIT

Expand All @@ -18,7 +18,7 @@ config BOARD_ASUS_P8Z77_M_PRO
select BOARD_ASUS_P8X7X_SERIES
select BOARD_ROMSIZE_KB_8192
select DRIVERS_ASMEDIA_ASPM_BLACKLIST # for ASM1061 eSATA
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select SUPERIO_NUVOTON_NCT6779D

config BOARD_ASUS_P8Z77_V_LX2
Expand All @@ -34,7 +34,7 @@ config BOARD_ASUS_P8Z77_V
select BOARD_ASUS_P8X7X_SERIES
select BOARD_ROMSIZE_KB_8192
select DRIVERS_ASMEDIA_ASPM_BLACKLIST # for ASM1061 eSATA
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_USES_IFD_GBE_REGION
select SUPERIO_NUVOTON_NCT6779D
select USE_NATIVE_RAMINIT
Expand Down
3 changes: 0 additions & 3 deletions src/mainboard/bap/ode_e20XX/Kconfig
Expand Up @@ -2,9 +2,6 @@

if BOARD_ODE_E20XX

config IGNORE_IASL_MISSING_DEPENDENCY
def_bool y

config BOARD_SPECIFIC_OPTIONS
def_bool y
select CPU_AMD_AGESA_FAMILY16_KB
Expand Down
10 changes: 0 additions & 10 deletions src/mainboard/bap/ode_e20XX/acpi/superio.asl
Expand Up @@ -10,11 +10,6 @@ Device (UAR1) {
IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
IRQNoFlags () {4}
})
Name (_PRS, ResourceTemplate ()
{
IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
IRQNoFlags () {4}
})
}

Device (UAR2) {
Expand All @@ -25,9 +20,4 @@ Device (UAR2) {
IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
IRQNoFlags () {3}
})
Name (_PRS, ResourceTemplate ()
{
IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
IRQNoFlags () {3}
})
}
2 changes: 1 addition & 1 deletion src/mainboard/clevo/cml-u/Kconfig
Expand Up @@ -9,7 +9,7 @@ config BOARD_CLEVO_CMLU_COMMON
select INTEL_GMA_HAVE_VBT
select INTEL_LPSS_UART_FOR_CONSOLE
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM2
select NO_UART_ON_SUPERIO
select SOC_INTEL_COMETLAKE_1
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/clevo/kbl-u/Kconfig
Expand Up @@ -10,7 +10,7 @@ config BOARD_CLEVO_KBLU_COMMON
select INTEL_GMA_HAVE_VBT
select INTEL_LPSS_UART_FOR_CONSOLE
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM2
select NO_UART_ON_SUPERIO
select SOC_INTEL_COMMON_BLOCK_HDA_VERB
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/clevo/tgl-u/Kconfig
Expand Up @@ -9,7 +9,7 @@ config BOARD_CLEVO_TGLU_COMMON
select HAVE_OPTION_TABLE
select INTEL_GMA_HAVE_VBT
select INTEL_LPSS_UART_FOR_CONSOLE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM2
select NO_UART_ON_SUPERIO
select SOC_INTEL_COMMON_BLOCK_HDA_VERB
Expand Down
4 changes: 2 additions & 2 deletions src/mainboard/clevo/tgl-u/variants/l140mu/devicetree.cb
Expand Up @@ -23,11 +23,11 @@ chip soc/intel/tigerlake
device ref igpu on
register "gfx" = "GMA_DEFAULT_PANEL(0)"
# eDP
register "DdiPortAConfig" = "1"
register "DdiPortAConfig" = "DDI_PORT_CFG_EDP"
register "DdiPortAHpd" = "1"
register "DdiPortADdc" = "0"
# HDMI
register "DdiPortBConfig" = "0"
register "DdiPortBConfig" = "DDI_PORT_CFG_NO_LFP"
register "DdiPortBHpd" = "1"
register "DdiPortBDdc" = "1"
end
Expand Down
5 changes: 1 addition & 4 deletions src/mainboard/dell/snb_ivb_workstations/Kconfig
Expand Up @@ -7,7 +7,7 @@ config BOARD_DELL_SNB_IVB_WORKSTATIONS
select NORTHBRIDGE_INTEL_SANDYBRIDGE
select SERIRQ_CONTINUOUS_MODE
select USE_NATIVE_RAMINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM1
select MAINBOARD_USES_IFD_GBE_REGION
select SUPERIO_SMSC_SCH5545
Expand All @@ -20,9 +20,6 @@ config BOARD_DELL_SNB_IVB_WORKSTATIONS

if BOARD_DELL_SNB_IVB_WORKSTATIONS

config IGNORE_IASL_MISSING_DEPENDENCY
def_bool y

config MAINBOARD_DIR
default "dell/snb_ivb_workstations"

Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/emulation/qemu-q35/Kconfig
Expand Up @@ -12,7 +12,7 @@ config BOARD_SPECIFIC_OPTIONS
select BOARD_ROMSIZE_KB_16384 if VBOOT
select MAINBOARD_HAS_NATIVE_VGA_INIT
select MAINBOARD_FORCE_NATIVE_VGA_INIT if !CHROMEOS
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_CHROMEOS
select SOUTHBRIDGE_INTEL_COMMON_ACPI_MADT
select BOOT_DEVICE_NOT_SPI_FLASH
Expand Down
8 changes: 1 addition & 7 deletions src/mainboard/facebook/fbg1701/Kconfig
Expand Up @@ -10,7 +10,7 @@ config BOARD_SPECIFIC_OPTIONS
select HAVE_IFD_BIN
select HAVE_ME_BIN
select HAVE_OPTION_TABLE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM2
select SOC_INTEL_BRASWELL
select SOC_INTEL_COMMON_BLOCK_HDA_VERB
Expand Down Expand Up @@ -47,12 +47,6 @@ config RO_REGION_ONLY

endif # VBOOT

config ONBOARD_SAMSUNG_MEM
bool "Onboard memory manufacturer Samsung"
default n
help
Samsung K4B8G1646D memory

config MAINBOARD_DIR
default "facebook/fbg1701"

Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/facebook/monolith/Kconfig
Expand Up @@ -7,7 +7,7 @@ config BOARD_SPECIFIC_OPTIONS
select HAVE_ACPI_TABLES
select HAVE_OPTION_TABLE
select SOC_INTEL_KABYLAKE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM2
select MAINBOARD_USES_IFD_GBE_REGION
select INTEL_GMA_HAVE_VBT
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/foxconn/g41s-k/Kconfig
Expand Up @@ -16,7 +16,7 @@ config BOARD_SPECIFIC_OPTIONS
select HAVE_ACPI_TABLES
select HAVE_CMOS_DEFAULT
select HAVE_OPTION_TABLE
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select INTEL_GMA_HAVE_VBT
select MAINBOARD_HAS_LIBGFXINIT

Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/gigabyte/ga-b75m-d3h/Kconfig
Expand Up @@ -15,7 +15,7 @@ config BOARD_SPECIFIC_OPTIONS
select INTEL_INT15
select SERIRQ_CONTINUOUS_MODE
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM

config DRAM_RESET_GATE_GPIO
int
Expand Down
3 changes: 2 additions & 1 deletion src/mainboard/google/asurada/Kconfig
Expand Up @@ -23,7 +23,8 @@ config BOARD_SPECIFIC_OPTIONS
select EC_GOOGLE_CHROMEEC
select EC_GOOGLE_CHROMEEC_BOARDID
select EC_GOOGLE_CHROMEEC_SPI
select MAINBOARD_HAS_SPI_TPM_CR50 if VBOOT
select SPI_TPM if VBOOT
select TPM_GOOGLE_CR50 if VBOOT
select MAINBOARD_HAS_TPM2 if VBOOT
select MAINBOARD_HAS_NATIVE_VGA_INIT
select MAINBOARD_FORCE_NATIVE_VGA_INIT
Expand Down
5 changes: 1 addition & 4 deletions src/mainboard/google/auron/Kconfig
Expand Up @@ -10,7 +10,7 @@ config BOARD_GOOGLE_BASEBOARD_AURON
select INTEL_INT15
select MAINBOARD_HAS_CHROMEOS
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM1
select SOC_INTEL_BROADWELL

Expand Down Expand Up @@ -44,9 +44,6 @@ config BOARD_GOOGLE_SAMUS

if BOARD_GOOGLE_BASEBOARD_AURON

config IGNORE_IASL_MISSING_DEPENDENCY
def_bool y

config VBOOT
select EC_GOOGLE_CHROMEEC_SWITCHES
select VBOOT_LID_SWITCH
Expand Down
5 changes: 1 addition & 4 deletions src/mainboard/google/beltino/Kconfig
Expand Up @@ -8,7 +8,7 @@ config BOARD_GOOGLE_BASEBOARD_BELTINO
select INTEL_LYNXPOINT_LP
select MAINBOARD_HAS_CHROMEOS
select MAINBOARD_HAS_LIBGFXINIT
select MAINBOARD_HAS_LPC_TPM
select MEMORY_MAPPED_TPM
select MAINBOARD_HAS_TPM1
select NORTHBRIDGE_INTEL_HASWELL
select SOUTHBRIDGE_INTEL_LYNXPOINT
Expand All @@ -31,9 +31,6 @@ config BOARD_GOOGLE_ZAKO

if BOARD_GOOGLE_BASEBOARD_BELTINO

config IGNORE_IASL_MISSING_DEPENDENCY
def_bool y

config VBOOT
select VBOOT_VBNV_CMOS

Expand Down
22 changes: 14 additions & 8 deletions src/mainboard/google/brya/Kconfig
@@ -1,7 +1,6 @@
config BOARD_GOOGLE_BRYA_COMMON
def_bool n
select BOARD_ROMSIZE_KB_32768
select CR50_USE_LONG_INTERRUPT_PULSES
select DRIVERS_GENERIC_ALC1015
select DRIVERS_GENERIC_GPIO_KEYS
select DRIVERS_GENERIC_MAX98357A
Expand All @@ -22,15 +21,16 @@ config BOARD_GOOGLE_BRYA_COMMON
select EC_GOOGLE_CHROMEEC
select EC_GOOGLE_CHROMEEC_BOARDID
select EC_GOOGLE_CHROMEEC_ESPI
select EC_GOOGLE_CHROMEEC_MUX
select EC_GOOGLE_CHROMEEC_SKUID
select FW_CONFIG
select FW_CONFIG_SOURCE_CHROMEEC_CBI
select GOOGLE_SMBIOS_MAINBOARD_VERSION
select HAVE_ACPI_RESUME
select HAVE_ACPI_TABLES
select I2C_TPM
select INTEL_LPSS_UART_FOR_CONSOLE
select MAINBOARD_HAS_CHROMEOS
select MAINBOARD_HAS_I2C_TPM_CR50
select MAINBOARD_HAS_TPM2
select PMC_IPC_ACPI_INTERFACE
select SOC_INTEL_COMMON_BLOCK_PCIE_RTD3
Expand All @@ -45,6 +45,7 @@ config BOARD_GOOGLE_BASEBOARD_BRYA
select MEMORY_SOLDERDOWN if !BOARD_GOOGLE_BANSHEE
select SOC_INTEL_ALDERLAKE_PCH_P
select SYSTEM_TYPE_LAPTOP
select TPM_GOOGLE_CR50

config BOARD_GOOGLE_BASEBOARD_BRASK
def_bool n
Expand All @@ -56,22 +57,21 @@ config BOARD_GOOGLE_BASEBOARD_BRASK
select RT8168_GET_MAC_FROM_VPD
select RT8168_SET_LED_MODE
select SOC_INTEL_ALDERLAKE_PCH_P
select TPM_GOOGLE_CR50

config BOARD_GOOGLE_BASEBOARD_NISSA
def_bool n
select BOARD_GOOGLE_BRYA_COMMON
select CHROMEOS_DRAM_PART_NUMBER_IN_CBI if CHROMEOS
select MAINBOARD_NEEDS_I2C_TI50_WORKAROUND
select MEMORY_SOLDERDOWN
select SOC_INTEL_ALDERLAKE_PCH_N
select SOC_INTEL_CSE_LITE_COMPRESS_ME_RW
select SYSTEM_TYPE_LAPTOP
select TI50_FIRMWARE_VERSION_NOT_SUPPORTED
select TPM_GOOGLE_TI50

if BOARD_GOOGLE_BRYA_COMMON

config IGNORE_IASL_MISSING_DEPENDENCY
def_bool y

config BASEBOARD_DIR
string
default "brya" if BOARD_GOOGLE_BASEBOARD_BRYA
Expand All @@ -95,7 +95,7 @@ config DEVICETREE

config DRIVER_TPM_I2C_BUS
hex
default 0x3 if BOARD_GOOGLE_BRYA0
default 0x1 if BOARD_GOOGLE_BRYA0
default 0x3 if BOARD_GOOGLE_BRYA4ES
default 0x1 if BOARD_GOOGLE_BRASK
default 0x1 if BOARD_GOOGLE_PRIMUS
Expand All @@ -121,6 +121,8 @@ config DRIVER_TPM_I2C_BUS
default 0x0 if BOARD_GOOGLE_CRAASK
default 0x1 if BOARD_GOOGLE_CROTA
default 0x1 if BOARD_GOOGLE_MOLI
default 0x1 if BOARD_GOOGLE_OSIRIS
default 0x1 if BOARD_GOOGLE_MITHRAX

config DRIVER_TPM_I2C_ADDR
hex
Expand Down Expand Up @@ -174,6 +176,8 @@ config MAINBOARD_PART_NUMBER
default "Moli" if BOARD_GOOGLE_MOLI
default "Kinox" if BOARD_GOOGLE_KINOX
default "Craask" if BOARD_GOOGLE_CRAASK
default "Osiris" if BOARD_GOOGLE_OSIRIS
default "Mithrax" if BOARD_GOOGLE_MITHRAX

config VARIANT_DIR
default "brya0" if BOARD_GOOGLE_BRYA0
Expand Down Expand Up @@ -202,9 +206,11 @@ config VARIANT_DIR
default "moli" if BOARD_GOOGLE_MOLI
default "kinox" if BOARD_GOOGLE_KINOX
default "craask" if BOARD_GOOGLE_CRAASK
default "osiris" if BOARD_GOOGLE_OSIRIS
default "mithrax" if BOARD_GOOGLE_MITHRAX

config VBOOT
select VBOOT_EARLY_EC_SYNC
select VBOOT_EARLY_EC_SYNC if !BOARD_GOOGLE_BASEBOARD_NISSA
select VBOOT_LID_SWITCH

config DIMM_SPD_SIZE
Expand Down
20 changes: 20 additions & 0 deletions src/mainboard/google/brya/Kconfig.name
Expand Up @@ -159,6 +159,7 @@ config BOARD_GOOGLE_TANIKS
select DRIVERS_GENESYSLOGIC_GL9750
select DRIVERS_GENESYSLOGIC_GL9763E
select DRIVERS_GENESYSLOGIC_GL9763E_L1_MAX
select CHROMEOS_WIFI_SAR if CHROMEOS

config BOARD_GOOGLE_VELL
bool "-> Vell"
Expand All @@ -185,6 +186,8 @@ config BOARD_GOOGLE_BANSHEE
config BOARD_GOOGLE_CROTA
bool "-> Crota"
select BOARD_GOOGLE_BASEBOARD_BRYA
select CHROMEOS_WIFI_SAR if CHROMEOS
select DRIVERS_GENESYSLOGIC_GL9750
select DRIVERS_I2C_CS42L42

config BOARD_GOOGLE_MOLI
Expand All @@ -198,3 +201,20 @@ config BOARD_GOOGLE_KINOX
config BOARD_GOOGLE_CRAASK
bool "-> Craask"
select BOARD_GOOGLE_BASEBOARD_NISSA
select DRIVERS_GENERIC_GPIO_KEYS
select DRIVERS_GENESYSLOGIC_GL9750
select DRIVERS_INTEL_MIPI_CAMERA
select HAVE_WWAN_POWER_SEQUENCE

config BOARD_GOOGLE_OSIRIS
bool "-> Osiris"
select BOARD_GOOGLE_BASEBOARD_BRYA
select RT8168_GEN_ACPI_POWER_RESOURCE
select RT8168_GET_MAC_FROM_VPD
select RT8168_SET_LED_MODE

config BOARD_GOOGLE_MITHRAX
bool "-> Mithrax"
select BOARD_GOOGLE_BASEBOARD_BRYA
select DRIVERS_GENERIC_GPIO_KEYS
select DRIVERS_GENESYSLOGIC_GL9755
1 change: 1 addition & 0 deletions src/mainboard/google/brya/chromeos-nissa.fmd
Expand Up @@ -47,6 +47,7 @@ FLASH 32M {
# memory protected range specification.
WP_RO 4M {
RO_VPD(PRESERVE) 16K
RO_GSCVD 8K
RO_SECTION {
FMAP 2K
RO_FRID 64
Expand Down
4 changes: 2 additions & 2 deletions src/mainboard/google/brya/mainboard.c
Expand Up @@ -59,12 +59,12 @@ void mainboard_update_soc_chip_config(struct soc_intel_alderlake_config *config)
variant_update_soc_chip_config(config);
}

__weak void variant_update_soc_chip_config(struct soc_intel_alderlake_config *config)
void __weak variant_update_soc_chip_config(struct soc_intel_alderlake_config *config)
{
/* default implementation does nothing */
}

__weak void variant_init(void)
void __weak variant_init(void)
{
/* default implementation does nothing */
}
Expand Down
1 change: 1 addition & 0 deletions src/mainboard/google/brya/variants/agah/Makefile.inc
Expand Up @@ -6,3 +6,4 @@ romstage-y += gpio.c
romstage-y += memory.c

ramstage-y += gpio.c
ramstage-y += variant.c
4 changes: 2 additions & 2 deletions src/mainboard/google/brya/variants/agah/gpio.c
Expand Up @@ -75,8 +75,8 @@ static const struct pad_config override_gpio_table[] = {
/* D16 : ISH_UART0_CTS# ==> NC */
PAD_NC_LOCK(GPP_D16, NONE, LOCK_CONFIG),

/* E0 : SATAXPCIE0 ==> EN_PPVAR_GPU_NVVDD_X_OD */
PAD_CFG_GPO(GPP_E0, 0, DEEP),
/* E0 : SATAXPCIE0 ==> EN_PPVAR_GPU_NVVDD_X_ODL */
PAD_CFG_GPO(GPP_E0, 1, DEEP),
/* E3 : PROC_GP0 ==> NC */
PAD_NC(GPP_E3, NONE),
/* E4 : SATA_DEVSLP0 ==> PG_PPVAR_GPU_FBVDDQ_X_OD */
Expand Down
19 changes: 17 additions & 2 deletions src/mainboard/google/brya/variants/agah/overridetree.cb
Expand Up @@ -31,8 +31,8 @@ chip soc/intel/alderlake
}"

register "sagv" = "SaGv_Enabled"
register "tcss_aux_ori" = "1"
register "typec_aux_bias_pads[0]" = "{.pad_auxp_dc = GPP_E22, .pad_auxn_dc = GPP_E23}"
register "tcss_aux_ori" = "0x10"
register "typec_aux_bias_pads[2]" = "{.pad_auxp_dc = GPP_E22, .pad_auxn_dc = GPP_E23}"

register "usb2_ports[1]" = "USB2_PORT_EMPTY" # Disable USB2_C1
register "usb2_ports[3]" = "USB2_PORT_EMPTY" # Disable M.2 WWAN
Expand All @@ -58,6 +58,15 @@ chip soc/intel/alderlake
}"

device domain 0 on
device ref pcie4_0 on
# Enable CPU PCIe RP 1 using CLKREQ 0 and CLKSRC 0
register "cpu_pcie_rp[CPU_RP(1)]" = "{
.clk_req = 0,
.clk_src = 0,
.flags = PCIE_RP_LTR | PCIE_RP_AER,
}"
device pci 00.0 alias dgpu on end
end
device ref dtt on
chip drivers/intel/dptf
## sensor information
Expand Down Expand Up @@ -148,6 +157,12 @@ chip soc/intel/alderlake
end
end
device ref pcie_rp3 on
# Enable PCIE 3 using clk 4
register "pch_pcie_rp[PCH_RP(3)]" = "{
.clk_src = 4,
.clk_req = 4,
.flags = PCIE_RP_LTR | PCIE_RP_AER,
}"
chip drivers/net
register "customized_leds" = "0x05af"
register "stop_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_D2)"
Expand Down
179 changes: 179 additions & 0 deletions src/mainboard/google/brya/variants/agah/variant.c
@@ -0,0 +1,179 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <baseboard/variants.h>
#include <delay.h>
#include <gpio.h>
#include <timer.h>
#include <types.h>

#define GPU_1V8_PWR_EN GPP_E18
#define GPU_1V8_PG GPP_E20
#define NV33_PWR_EN GPP_A21
#define NV33_PG GPP_A22
#define NVVDD_PWR_EN GPP_E0
#define NVVDD_PG GPP_E16
#define PEXVDD_PWR_EN GPP_E10
#define PEXVDD_PG GPP_E17
#define FBVDD_PWR_EN GPP_A17
#define FBVDD_PG GPP_E4
#define GPU_PERST_L GPP_B3
#define GPU_ALLRAILS_PG GPP_E5

#define DEFAULT_PG_TIMEOUT_US 20000

#define VGAR_BYTE_OFFSET 5

/* Maximum size of PCI config space to save. */
#define GPU_CONFIG_SAVE_SPACE_BYTES 0x100

static bool gpu_powered_on;

struct power_rail_sequence {
const char *name;

/* This is the GPIO (output) connected to the VR's enable pin. */
gpio_t pwr_en_gpio;
bool pwr_en_active_low;

/* This is the GPIO (input) connected to the VR's power-good pin. */
gpio_t pg_gpio;
};

/* In GCOFF exit order (i.e., power-on order) */
static const struct power_rail_sequence gpu_rails[] = {
{ "GPU 1.8V", GPU_1V8_PWR_EN, false, GPU_1V8_PG, },
{ "NV3_3", NV33_PWR_EN, false, NV33_PG, },
{ "NVVDD+MSVDD", NVVDD_PWR_EN, true, NVVDD_PG, },
{ "PEXVDD", PEXVDD_PWR_EN, false, PEXVDD_PG, },
{ "FBVDD", FBVDD_PWR_EN, false, FBVDD_PG, },
};

enum rail_state {
RAIL_OFF = 0,
RAIL_ON = 1,
};

/* Assert the VR's enable pin, and wait until the VR's power-good is asserted. */
static bool sequence_rail(const struct power_rail_sequence *seq, enum rail_state state)
{
if (seq->pwr_en_active_low)
state = !state;

gpio_output(seq->pwr_en_gpio, state);
return wait_us(DEFAULT_PG_TIMEOUT_US, gpio_get(seq->pg_gpio) == state) > 0;
}

static void dgpu_power_sequence_off(void)
{
/* Assert reset and clear power-good */
gpio_output(GPU_PERST_L, 0);
mdelay(5);

/* Inform the GPU that the power is no longer good. */
gpio_output(GPU_ALLRAILS_PG, 0);

for (int i = (int)ARRAY_SIZE(gpu_rails) - 1; i >= 0; i--) {
if (!sequence_rail(&gpu_rails[i], RAIL_OFF)) {
printk(BIOS_ERR, "Failed to disable %s rail, continuing!\n",
gpu_rails[i].name);
}
}
}

static void dgpu_power_sequence_on(void)
{
/* Assert PERST# */
gpio_output(GPU_PERST_L, 0);

for (size_t i = 0; i < ARRAY_SIZE(gpu_rails); i++) {
if (!sequence_rail(&gpu_rails[i], RAIL_ON)) {
printk(BIOS_ERR, "Failed to enable %s rail, sequencing back down!\n",
gpu_rails[i].name);

/* If an error occurred, then perform the power-off sequence and
return early to avoid setting GPU_ALLRAILS_PG and PERST_L. */
dgpu_power_sequence_off();
return;
}
}

/* Set power-good and release PERST# */
gpio_output(GPU_ALLRAILS_PG, 1);
mdelay(1);
gpio_output(GPU_PERST_L, 1);

printk(BIOS_INFO, "Sequenced GPU successfully\n");
gpu_powered_on = true;
}

void variant_init(void)
{
if (acpi_is_wakeup_s3())
return;

dgpu_power_sequence_on();
}

void variant_finalize(void)
{
if (acpi_is_wakeup_s3() || !gpu_powered_on)
return;

/*
* Because the dGPU is used here in a way similar to "hybrid graphics"
* modes, it is powered down here. The DRIVERS_GFX_NVIDIA_SAVE_BARS
* option is selected for agah, so the BARs will be saved to ACPI memory
* during its finalize routine. Thus, it is powered down here, as the
* proper resources have already been allocated.
*/
dgpu_power_sequence_off();

printk(BIOS_INFO, "GPU power sequenced off.\n");
}

/* Save PCI BARs to the ACPI copy of the "saved PCI config space" */
void variant_fill_ssdt(const struct device *unused)
{
if (!gpu_powered_on)
return;

const struct device *dgpu = DEV_PTR(dgpu);
acpigen_write_scope("\\_SB.PCI0.PEG0.PEGP");
acpigen_write_method("_INI", 0);
{
/* Local0 = VGAR */
acpigen_write_store();
acpigen_emit_namestring("VGAR");
acpigen_emit_byte(LOCAL0_OP);

/*
* CreateDWordField(Local0, 11, BAR0)
* BAR0 = bases[0]
* CreateDWordField(Local0, 15, BAR1)
* BAR1 = bases[1]
* ...
*/
for (unsigned int idx = PCI_BASE_ADDRESS_0, i = 0; idx <= PCI_BASE_ADDRESS_5;
idx += sizeof(uint32_t), ++i) {
char name[ACPI_NAME_BUFFER_SIZE];
const struct resource *res;

res = probe_resource(dgpu, idx);
if (!res)
continue;

snprintf(name, sizeof(name), "BAR%1d", i);
acpigen_write_create_dword_field(LOCAL0_OP, idx - VGAR_BYTE_OFFSET,
name);
acpigen_write_store_int_to_namestr(res->base & 0xffffffff, name);
}

/* VGAR = Local0 */
acpigen_write_store_op_to_namestr(LOCAL0_OP, "VGAR");
}

acpigen_write_method_end();
acpigen_write_scope_end();
}
2 changes: 2 additions & 0 deletions src/mainboard/google/brya/variants/anahera/gpio.c
Expand Up @@ -61,6 +61,8 @@ static const struct pad_config override_gpio_table[] = {
PAD_CFG_GPO(GPP_E16, 1, DEEP),
/* E20 : USB_C1_LSX_SOC_TX ==> EN_PP3300_eMMC */
PAD_CFG_GPO(GPP_E20, 1, DEEP),
/* E22 : DDPA_CTRLCLK ==> SC_PWR_SV */
PAD_CFG_GPO(GPP_E22, 1, DEEP),
/* E23 : DDPA_CTRLDATA ==> NC */
PAD_NC(GPP_E23, NONE),

Expand Down
2 changes: 2 additions & 0 deletions src/mainboard/google/brya/variants/anahera4es/gpio.c
Expand Up @@ -65,6 +65,8 @@ static const struct pad_config override_gpio_table[] = {
PAD_CFG_GPO(GPP_E16, 1, DEEP),
/* E20 : USB_C1_LSX_SOC_TX ==> EN_PP3300_eMMC */
PAD_CFG_GPO(GPP_E20, 1, DEEP),
/* E22 : DDPA_CTRLCLK ==> SC_PWR_SV */
PAD_CFG_GPO(GPP_E22, 1, DEEP),
/* E23 : DDPA_CTRLDATA ==> NC */
PAD_NC(GPP_E23, NONE),

Expand Down
14 changes: 14 additions & 0 deletions src/mainboard/google/brya/variants/banshee/overridetree.cb
Expand Up @@ -22,6 +22,20 @@ chip soc/intel/alderlake
},
}"

register "ext_fivr_settings" = "{
.configure_ext_fivr = 1,
.v1p05_enable_bitmap = FIVR_ENABLE_ALL_SX,
.vnn_enable_bitmap = FIVR_ENABLE_ALL_SX,
.v1p05_supported_voltage_bitmap = FIVR_VOLTAGE_NORMAL |
FIVR_VOLTAGE_MIN_ACTIVE |
FIVR_VOLTAGE_MIN_RETENTION,
.vnn_supported_voltage_bitmap = FIVR_VOLTAGE_NORMAL |
FIVR_VOLTAGE_MIN_ACTIVE |
FIVR_VOLTAGE_MIN_RETENTION,
.v1p05_icc_max_ma = 500,
.vnn_sx_voltage_mv = 1250,
}"

register "usb2_ports[3]" = "USB2_PORT_EMPTY" # Disable Port 3
register "usb2_ports[4]" = "USB2_PORT_EMPTY" # Disable Port 4
register "usb2_ports[6]" = "USB2_PORT_EMPTY" # Disable Port 6
Expand Down
@@ -1,3 +1,11 @@
fw_config
field STORAGE 30 31
option STORAGE_EMMC 0
option STORAGE_NVME 1
option STORAGE_UFS 2
end
end

chip soc/intel/alderlake

# GPE configuration
Expand Down
4 changes: 2 additions & 2 deletions src/mainboard/google/brya/variants/baseboard/nissa/gpio.c
Expand Up @@ -234,15 +234,15 @@ static const struct pad_config gpio_table[] = {
/* F12 : GSXDOUT ==> WWAN_RST_L */
PAD_CFG_GPO_LOCK(GPP_F12, 1, LOCK_CONFIG),
/* F13 : GSXSLOAD ==> SOC_PEN_DETECT_R_ODL */
PAD_CFG_GPI_GPIO_DRIVER_LOCK(GPP_F13, NONE, LOCK_CONFIG),
PAD_CFG_GPI_INT_LOCK(GPP_F13, NONE, EDGE_BOTH, LOCK_CONFIG),
/* F14 : GSXDIN ==> TCHPAD_INT_ODL */
PAD_CFG_GPI_IRQ_WAKE_LOCK(GPP_F14, NONE, LEVEL, INVERT, LOCK_CONFIG),
/* F15 : GSXSRESET# ==> SOC_PEN_DETECT_ODL */
PAD_CFG_GPI_SCI_HIGH_LOCK(GPP_F15, NONE, EDGE_SINGLE, LOCK_CONFIG),
/* F16 : NC */
PAD_NC_LOCK(GPP_F16, NONE, LOCK_CONFIG),
/* F17 : THC1_SPI2_RST# ==> EC_SOC_WAKE_ODL */
PAD_CFG_GPI_SCI_LOCK(GPP_F17, NONE, LEVEL, INVERT, LOCK_CONFIG),
PAD_CFG_GPI_IRQ_WAKE_LOCK(GPP_F17, NONE, LEVEL, INVERT, LOCK_CONFIG),
/* F18 : THC1_SPI2_INT# ==> EC_IN_RW_OD */
PAD_CFG_GPI_LOCK(GPP_F18, NONE, LOCK_CONFIG),
/* F19 : Not available */
Expand Down
3 changes: 0 additions & 3 deletions src/mainboard/google/brya/variants/baseboard/nissa/memory.c
Expand Up @@ -11,9 +11,6 @@ static const struct mb_cfg baseboard_memcfg = {
.rcomp = {
/* Baseboard uses only 100ohm Rcomp resistors */
.resistor = 100,

/* Baseboard Rcomp target values */
.targets = { 40, 36, 35, 35, 35 },
},

/* DQ byte map */
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/google/brya/variants/brya0/fw_config.c
Expand Up @@ -144,7 +144,7 @@ static void fw_config_handle(void *unused)
printk(BIOS_INFO, "Configure audio over I2S with MAX98360 ALC5682I.\n");
gpio_configure_pads(max98360_enable_pads, ARRAY_SIZE(max98360_enable_pads));
printk(BIOS_INFO, "BT offload enabled\n");
gpio_configure_pads(i2s0_disable_pads, ARRAY_SIZE(i2s0_disable_pads));
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads));
gpio_configure_pads(bt_i2s_enable_pads, ARRAY_SIZE(bt_i2s_enable_pads));
}
}
Expand Down