From 9a830ee06c66058b1421c017b25a65a22921e9f6 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 9 Oct 2018 00:32:36 -0700 Subject: platform: Restructure bmc_platform type Segregate the BMC platform configuration into hardware and software components. This allows population of platform default values for hardware configuration that may no-longer be accessible by the host. Signed-off-by: Andrew Jeffery [stewart: fixup pci-quirk unit test] Signed-off-by: Stewart Smith --- core/pci-quirk.c | 21 +++++++++++++++++---- core/test/run-pci-quirk.c | 8 ++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/pci-quirk.c b/core/pci-quirk.c index 7ed6b79..3a85836 100644 --- a/core/pci-quirk.c +++ b/core/pci-quirk.c @@ -14,9 +14,12 @@ * limitations under the License. */ +#define pr_fmt(fmt) "PCI-QUIRK: " fmt + #include #include #include +#include #include static void quirk_astbmc_vga(struct phb *phb __unused, @@ -25,10 +28,20 @@ static void quirk_astbmc_vga(struct phb *phb __unused, struct dt_node *np = pd->dn; uint32_t revision, mcr_configuration, mcr_scu_mpll, mcr_scu_strap; - revision = ast_ahb_readl(SCU_REVISION_ID); - mcr_configuration = ast_ahb_readl(MCR_CONFIGURATION); - mcr_scu_mpll = ast_ahb_readl(MCR_SCU_MPLL); - mcr_scu_strap = ast_ahb_readl(MCR_SCU_STRAP); + if (ast_sio_is_enabled()) { + revision = ast_ahb_readl(SCU_REVISION_ID); + mcr_configuration = ast_ahb_readl(MCR_CONFIGURATION); + mcr_scu_mpll = ast_ahb_readl(MCR_SCU_MPLL); + mcr_scu_strap = ast_ahb_readl(MCR_SCU_STRAP); + } else { + prlog(PR_WARNING, "Assumed platform default parameters for %s\n", + __func__); + revision = bmc_platform->hw->scu_revision_id; + mcr_configuration = bmc_platform->hw->mcr_configuration; + mcr_scu_mpll = bmc_platform->hw->mcr_scu_mpll; + mcr_scu_strap = bmc_platform->hw->mcr_scu_strap; + } + dt_add_property_cells(np, "aspeed,scu-revision-id", revision); dt_add_property_cells(np, "aspeed,mcr-configuration", mcr_configuration); dt_add_property_cells(np, "aspeed,mcr-scu-mpll", mcr_scu_mpll); diff --git a/core/test/run-pci-quirk.c b/core/test/run-pci-quirk.c index b9db680..2f71302 100644 --- a/core/test/run-pci-quirk.c +++ b/core/test/run-pci-quirk.c @@ -7,6 +7,14 @@ struct dt_property; struct dt_node; +static struct bmc_platform fake_bmc; +const struct bmc_platform *bmc_platform = &fake_bmc; + +static int ast_sio_is_enabled(void) +{ + return 0; +} + static uint32_t ast_ahb_readl(uint32_t reg) { return reg; -- cgit v1.1