soc/amd/common/block/lpc: Add helper function lpc_early_init()

This change adds a helper function lpc_early_init() which does the
following things:
1. Enables LPC controller
2. Disables any LPC decodes (These can be set up later by SoC or
mainboard as required).
3. Sets SPI base so that MMIO base for SPI and eSPI controllers is
initialized.

BUG=b:153675913

Signed-off-by: Furquan Shaikh <furquan@google.com>
Change-Id: I016f29339466c3fee92fe9b62a13d72297c29b8e
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41257
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Furquan Shaikh 2020-05-11 16:35:08 -07:00
parent 3f3f53cd5e
commit 6d28802d32
2 changed files with 27 additions and 0 deletions

View File

@ -180,6 +180,15 @@ int lpc_set_wideio_range(uint16_t start, uint16_t size);
uintptr_t lpc_get_spibase(void); uintptr_t lpc_get_spibase(void);
/*
* Perform early initialization for LPC:
* 1. Enable LPC controller
* 2. Disable any LPC decodes
* 3. Set SPI Base which is the MMIO base for both SPI and eSPI controller (if supported by
* platform).
*/
void lpc_early_init(void);
/* /*
* Sets MMIO base address for SPI controller and eSPI controller (if supported by platform). * Sets MMIO base address for SPI controller and eSPI controller (if supported by platform).
* *

View File

@ -5,6 +5,7 @@
#include <device/device.h> #include <device/device.h>
#include <device/pci_ops.h> #include <device/pci_ops.h>
#include <device/pci_def.h> #include <device/pci_def.h>
#include <amdblocks/acpimmio.h>
#include <amdblocks/lpc.h> #include <amdblocks/lpc.h>
#include <soc/iomap.h> #include <soc/iomap.h>
#include <soc/southbridge.h> #include <soc/southbridge.h>
@ -349,3 +350,20 @@ void lpc_enable_spi_rom(uint32_t enable)
pci_write_config32(_LPCB_DEV, SPIROM_BASE_ADDRESS_REGISTER, reg32); pci_write_config32(_LPCB_DEV, SPIROM_BASE_ADDRESS_REGISTER, reg32);
} }
static void lpc_enable_controller(void)
{
u8 byte;
/* Enable LPC controller */
byte = pm_io_read8(PM_LPC_GATING);
byte |= PM_LPC_ENABLE;
pm_io_write8(PM_LPC_GATING, byte);
}
void lpc_early_init(void)
{
lpc_enable_controller();
lpc_disable_decodes();
lpc_set_spibase(SPI_BASE_ADDRESS);
}