Attention is currently required from: Hung-Te Lin. Jianjun Wang has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/63019 )
Change subject: soc/mediatek: Add mtk_early_init for passing data across sessions ......................................................................
soc/mediatek: Add mtk_early_init for passing data across sessions
Passing pcie timestamp from bootblock stage to ram stage, it can be used for other modules if they needs to passing data across sessions.
TEST=Build pass and boot up to kernel successfully via SSD on Dojo board, here is the SSD information in boot log: == NVME IDENTIFY CONTROLLER DATA == PCI VID : 0x15b7 PCI SSVID : 0x15b7 SN : 21517J440114 MN : WDC PC SN530 SDBPTPZ-256G-1006 RAB : 0x4 AERL : 0x7 SQES : 0x66 CQES : 0x44 NN : 0x1 Identified NVMe model WDC PC SN530 SDBPTPZ-256G-1006
BUG=b:178565024 BRANCH=cherry
Signed-off-by: Jianjun Wang jianjun.wang@mediatek.com Change-Id: I01f91b7fe2cbe4f73b5c616bb7aae778dee27d9a --- M src/soc/mediatek/common/Kconfig A src/soc/mediatek/common/early_init.c A src/soc/mediatek/common/include/soc/early_init.h 3 files changed, 73 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/19/63019/1
diff --git a/src/soc/mediatek/common/Kconfig b/src/soc/mediatek/common/Kconfig index cd3b2a2..dd018ec 100644 --- a/src/soc/mediatek/common/Kconfig +++ b/src/soc/mediatek/common/Kconfig @@ -50,4 +50,8 @@ and dumps to internal RAM on the WDT reset. We reserve 1MB on DRAM to store logs of DFD.
+config MEDIATEK_EARLY_INIT + bool + help + This option allows passing data across sessions. endif diff --git a/src/soc/mediatek/common/early_init.c b/src/soc/mediatek/common/early_init.c new file mode 100644 index 0000000..fee8f61 --- /dev/null +++ b/src/soc/mediatek/common/early_init.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <assert.h> +#include <soc/early_init.h> +#include <stdlib.h> +#include <string.h> +#include <timer.h> + +static struct mtk_early_init *mtk_find_early_init(void) +{ + assert(sizeof(struct mtk_early_init) <= REGION_SIZE(mtk_early_init)); + return (struct mtk_early_init *)_mtk_early_init; +} + +void mtk_clear_early_init(void) +{ + struct mtk_early_init *init = mtk_find_early_init(); + + if (!init) + return; + + memset(init, 0, sizeof(*init)); +} + +void mtk_pcie_save_timestamp(void) +{ + struct mono_time timestamp; + struct mtk_early_init *init = mtk_find_early_init(); + + if (!init) + return; + + timer_monotonic_get(×tamp); + + init->pcie_timestamp_us = timestamp.microseconds; +} + +uint64_t mtk_pcie_perst_elapsed_time(void) +{ + struct mtk_early_init *init = mtk_find_early_init(); + struct mono_time cur_time; + + if (!init) + return 0; + + timer_monotonic_get(&cur_time); + + return cur_time.microseconds - init->pcie_timestamp_us; +} diff --git a/src/soc/mediatek/common/include/soc/early_init.h b/src/soc/mediatek/common/include/soc/early_init.h new file mode 100644 index 0000000..b8a08fa --- /dev/null +++ b/src/soc/mediatek/common/include/soc/early_init.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_EARLY_INIT_H +#define SOC_MEDIATEK_EARLY_INIT_H + +#include <soc/symbols.h> +#include <stdint.h> +#include <symbols.h> + +DECLARE_REGION(mtk_early_init); + +struct mtk_early_init { + long pcie_timestamp_us; +}; + +void mtk_clear_early_init(void); +void mtk_pcie_save_timestamp(void); +uint64_t mtk_pcie_perst_elapsed_time(void); + +#endif /* SOC_MEDIATEK_EARLY_INIT_H */