blob: 1375e9823db62726397768f1d6833df22fb02b27 [file] [log] [blame]
Martin Roth4b341932020-10-06 15:29:28 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Felix Heldcd507152020-11-24 20:37:15 +01003#include <bootblock_common.h>
Martin Roth4b341932020-10-06 15:29:28 -06004#include <console/console.h>
Martin Roth4b341932020-10-06 15:29:28 -06005#include <soc/psp_transfer.h>
Raul E Rangelfe1418d2022-02-24 12:36:38 -07006#include <symbols.h>
Felix Heldcd507152020-11-24 20:37:15 +01007#include <timestamp.h>
Raul E Rangel86302a82022-01-18 15:29:54 -07008
Felix Heldcd507152020-11-24 20:37:15 +01009void boot_with_psp_timestamp(uint64_t base_timestamp)
10{
11 const struct transfer_info_struct *info = (const struct transfer_info_struct *)
12 (void *)(uintptr_t)_transfer_buffer;
13
14 if (!transfer_buffer_valid(info) || info->timestamp == 0)
15 return;
16
Raul E Rangel08de3e32022-02-25 17:10:09 -070017 replay_transfer_buffer_cbmemc();
Raul E Rangel86302a82022-01-18 15:29:54 -070018
Felix Heldcd507152020-11-24 20:37:15 +010019 /*
20 * info->timestamp is PSP's timestamp (in microseconds)
21 * when x86 processor is released.
22 */
23 uint64_t psp_last_ts = info->timestamp;
24
25 int i;
26 struct timestamp_table *psp_ts_table =
27 (struct timestamp_table *)(void *)
28 ((uintptr_t)_transfer_buffer + info->timestamp_offset);
29 /* new base_timestamp will be offset for all PSP timestamps. */
30 base_timestamp -= psp_last_ts;
31
32 for (i = 0; i < psp_ts_table->num_entries; i++) {
33 struct timestamp_entry *tse = &psp_ts_table->entries[i];
34 /*
35 * We ignore the time between x86 processor release and bootblock.
36 * Since timestamp_add subtracts base_time, we first add old base_time
37 * to make it absolute then add base_timestamp again since
38 * it'll be a new base_time.
39 *
40 * We don't need to convert unit since both PSP and coreboot
41 * will use 1us granularity.
42 *
43 */
44 tse->entry_stamp += psp_ts_table->base_time + base_timestamp;
45 }
46
47 bootblock_main_with_timestamp(base_timestamp, psp_ts_table->entries,
48 psp_ts_table->num_entries);
49}