diff options
author | Huayang Duan <huayang.duan@mediatek.com> | 2020-06-22 17:44:01 +0800 |
---|---|---|
committer | Hung-Te Lin <hungte@chromium.org> | 2020-08-25 13:48:15 +0000 |
commit | 7452a2fdeffeef460483ee41ad74c9f90553a5e3 (patch) | |
tree | 3369cda170dacd1ac9515da2364b2d272b8a7eb1 /src/soc/mediatek/mt8192/dramc_param.c | |
parent | 2d5b252fd20493e67795a1af33ef730b1552afa3 (diff) |
soc/mediatek/mt8192: Add dramc param struct
Signed-off-by: Huayang Duan <huayang.duan@mediatek.com>
Change-Id: I3bae57e6777ab6fc46c771a034f814dd1175be95
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44566
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Diffstat (limited to 'src/soc/mediatek/mt8192/dramc_param.c')
-rw-r--r-- | src/soc/mediatek/mt8192/dramc_param.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/soc/mediatek/mt8192/dramc_param.c b/src/soc/mediatek/mt8192/dramc_param.c new file mode 100644 index 0000000000..f8f6c7dd14 --- /dev/null +++ b/src/soc/mediatek/mt8192/dramc_param.c @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <string.h> +#include <soc/dramc_param.h> + +#define print(_x_...) printk(BIOS_INFO, _x_) + +struct dramc_param *get_dramc_param_from_blob(void *blob) +{ + return (struct dramc_param *)blob; +} + +void dump_param_header(const void *blob) +{ + const struct dramc_param *dparam = blob; + const struct dramc_param_header *header = &dparam->header; + + print("header.status = %#x\n", header->status); + print("header.version = %#x (expected: %#x)\n", + header->version, DRAMC_PARAM_HEADER_VERSION); + print("header.size = %#x (expected: %#lx)\n", + header->size, sizeof(*dparam)); + print("header.flags = %#x\n", header->flags); + print("header.checksum = %#x\n", header->checksum); +} + +int validate_dramc_param(const void *blob) +{ + const struct dramc_param *param = blob; + const struct dramc_param_header *hdr = ¶m->header; + + if (hdr->version != DRAMC_PARAM_HEADER_VERSION) + return DRAMC_ERR_INVALID_VERSION; + + if (hdr->size != sizeof(*param)) + return DRAMC_ERR_INVALID_SIZE; + + return DRAMC_SUCCESS; +} + +int is_valid_dramc_param(const void *blob) +{ + return validate_dramc_param(blob) == DRAMC_SUCCESS; +} + +int initialize_dramc_param(void *blob) +{ + struct dramc_param *param = blob; + struct dramc_param_header *hdr = ¶m->header; + + memset(hdr, 0, sizeof(*hdr)); + hdr->version = DRAMC_PARAM_HEADER_VERSION; + hdr->size = sizeof(*param); + return 0; +} |