mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
board: ibex_ast2700: Add FMC header support
Define and parse the header of the First Mutable Code (FMC) of AST2700 SoCs at runtime phase. The FMC header contains the information to load prebuilt binaries required for device initialization such as DRAM and VGA. Signed-off-by: Chia-Wei Wang <chiawei_wang@aspeedtech.com> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
This commit is contained in:
parent
4b0129e810
commit
73f802ac95
3 changed files with 117 additions and 0 deletions
52
arch/riscv/include/asm/arch-ast2700/fmc_hdr.h
Normal file
52
arch/riscv/include/asm/arch-ast2700/fmc_hdr.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) ASPEED Technology Inc.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_AST2700_FMC_HDR_H__
|
||||
#define __ASM_AST2700_FMC_HDR_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#define HDR_MAGIC 0x48545341 /* ASTH */
|
||||
#define HDR_PB_MAX 30
|
||||
|
||||
enum prebuilt_type {
|
||||
PBT_END_MARK = 0x0,
|
||||
|
||||
PBT_DDR4_PMU_TRAIN_IMEM,
|
||||
PBT_DDR4_PMU_TRAIN_DMEM,
|
||||
PBT_DDR4_2D_PMU_TRAIN_IMEM,
|
||||
PBT_DDR4_2D_PMU_TRAIN_DMEM,
|
||||
PBT_DDR5_PMU_TRAIN_IMEM,
|
||||
PBT_DDR5_PMU_TRAIN_DMEM,
|
||||
PBT_DP_FW,
|
||||
PBT_UEFI_X64_AST2700,
|
||||
|
||||
PBT_NUM
|
||||
};
|
||||
|
||||
struct fmc_hdr_preamble {
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
};
|
||||
|
||||
struct fmc_hdr_body {
|
||||
uint32_t fmc_size;
|
||||
union {
|
||||
struct {
|
||||
uint32_t type;
|
||||
uint32_t size;
|
||||
} pbs[0];
|
||||
uint32_t raz[29];
|
||||
};
|
||||
};
|
||||
|
||||
struct fmc_hdr {
|
||||
struct fmc_hdr_preamble preamble;
|
||||
struct fmc_hdr_body body;
|
||||
} __packed;
|
||||
|
||||
int fmc_hdr_get_prebuilt(uint32_t type, uint32_t *ofst, uint32_t *size);
|
||||
|
||||
#endif
|
|
@ -1,2 +1,3 @@
|
|||
obj-y += ibex_ast2700.o
|
||||
obj-y += fmc_hdr.o
|
||||
obj-y += sli.o
|
||||
|
|
64
board/aspeed/ibex_ast2700/fmc_hdr.c
Normal file
64
board/aspeed/ibex_ast2700/fmc_hdr.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (c) Aspeed Technology Inc.
|
||||
*/
|
||||
|
||||
#include <asm/arch/fmc_hdr.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/sections.h>
|
||||
#include <errno.h>
|
||||
#include <spl.h>
|
||||
#include <string.h>
|
||||
|
||||
int fmc_hdr_get_prebuilt(uint32_t type, uint32_t *ofst, uint32_t *size)
|
||||
{
|
||||
struct fmc_hdr_preamble *preamble;
|
||||
struct fmc_hdr_body *body;
|
||||
struct fmc_hdr *hdr;
|
||||
uint32_t t, s, o;
|
||||
int i;
|
||||
|
||||
if (type >= PBT_NUM)
|
||||
return -EINVAL;
|
||||
|
||||
if (!ofst || !size)
|
||||
return -EINVAL;
|
||||
|
||||
hdr = (struct fmc_hdr *)(_start - sizeof(*hdr));
|
||||
preamble = &hdr->preamble;
|
||||
body = &hdr->body;
|
||||
|
||||
if (preamble->magic != HDR_MAGIC)
|
||||
return -EIO;
|
||||
|
||||
for (i = 0, o = sizeof(*hdr) + body->fmc_size; i < HDR_PB_MAX; ++i) {
|
||||
t = body->pbs[i].type;
|
||||
s = body->pbs[i].size;
|
||||
|
||||
/* skip if unrecognized, yet */
|
||||
if (t >= PBT_NUM) {
|
||||
o += s;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* prebuilt end mark */
|
||||
if (t == 0 && s == 0)
|
||||
break;
|
||||
|
||||
/* return the prebuilt info if found */
|
||||
if (t == type) {
|
||||
*ofst = o;
|
||||
*size = s;
|
||||
|
||||
goto found;
|
||||
}
|
||||
|
||||
/* update offset for next prebuilt */
|
||||
o += s;
|
||||
}
|
||||
|
||||
return -ENODATA;
|
||||
|
||||
found:
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue