soc/amd/common/block/spi: Support fast speed override

Add support to override SPI ROM fast speed based on board version. This
will allow boards to start at lower speeds during bringup and then
switch to higher speeds after assessing the signal integrity. Also
implement a default no-op override.

BUG=None
TEST=Build and boot to OS in Guybrush. Perform S5->S0, G3->S0, warm
reset and suspend/resume cycles for 50 iterations each.

Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Change-Id: Ia8ff3b3bdb53fee142527ae63aa7785945909304
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58116
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Karthikeyan Ramasubramanian 2021-10-05 13:46:40 -06:00 committed by Felix Held
parent 5705b63a08
commit 2526be8db3
2 changed files with 7 additions and 0 deletions

View File

@ -117,4 +117,5 @@ void spi_write16(uint8_t reg, uint16_t val);
void spi_write32(uint8_t reg, uint32_t val); void spi_write32(uint8_t reg, uint32_t val);
void fch_spi_config_modes(void); void fch_spi_config_modes(void);
void mainboard_spi_fast_speed_override(uint8_t *fast_speed);
#endif /* AMD_BLOCK_SPI_H */ #endif /* AMD_BLOCK_SPI_H */

View File

@ -50,6 +50,11 @@ void show_spi_speeds_and_modes(void)
printk(BIOS_DEBUG, "SPI Read Mode: %s\n", read_mode_str[DECODE_SPI_READ_MODE(val32)]); printk(BIOS_DEBUG, "SPI Read Mode: %s\n", read_mode_str[DECODE_SPI_READ_MODE(val32)]);
} }
void __weak mainboard_spi_fast_speed_override(uint8_t *fast_speed)
{
/* No overriding SPI speeds. */
}
static uint8_t lower_speed(uint8_t speed1, uint8_t speed2) static uint8_t lower_speed(uint8_t speed1, uint8_t speed2)
{ {
uint8_t speeds[] = {SPI_SPEED_800K, SPI_SPEED_16M, SPI_SPEED_22M, uint8_t speeds[] = {SPI_SPEED_800K, SPI_SPEED_16M, SPI_SPEED_22M,
@ -102,6 +107,7 @@ void fch_spi_config_modes(void)
read_mode = CONFIG_EFS_SPI_READ_MODE; read_mode = CONFIG_EFS_SPI_READ_MODE;
fast_speed = CONFIG_EFS_SPI_SPEED; fast_speed = CONFIG_EFS_SPI_SPEED;
} }
mainboard_spi_fast_speed_override(&fast_speed);
if (fast_speed != CONFIG_EFS_SPI_SPEED) { if (fast_speed != CONFIG_EFS_SPI_SPEED) {
normal_speed = lower_speed(normal_speed, fast_speed); normal_speed = lower_speed(normal_speed, fast_speed);