blob: 40ba866d77c0845a0044eecfb881c9d0887b3d30 [file] [log] [blame]
Simon Glassac4df6f2019-09-25 08:11:30 -06001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
4 */
5
6#include <common.h>
Simon Glass5c2aabf2019-09-25 08:56:32 -06007#include <acpi_s3.h>
Simon Glassac4df6f2019-09-25 08:11:30 -06008#include <dm.h>
9#include <errno.h>
10#include <rtc.h>
Simon Glassac4df6f2019-09-25 08:11:30 -060011#include <asm/cmos_layout.h>
12#include <asm/early_cmos.h>
13#include <asm/io.h>
14#include <asm/mrccache.h>
15#include <asm/post.h>
16#include <asm/processor.h>
17#include <asm/fsp/fsp_support.h>
18
19DECLARE_GLOBAL_DATA_PTR;
20
21int checkcpu(void)
22{
23 return 0;
24}
25
26int print_cpuinfo(void)
27{
28 post_code(POST_CPU_INFO);
29 return default_print_cpuinfo();
30}
31
32int fsp_init_phase_pci(void)
33{
34 u32 status;
35
36 /* call into FspNotify */
37 debug("Calling into FSP (notify phase INIT_PHASE_PCI): ");
38 status = fsp_notify(NULL, INIT_PHASE_PCI);
39 if (status)
40 debug("fail, error code %x\n", status);
41 else
42 debug("OK\n");
43
44 return status ? -EPERM : 0;
45}
46
47void board_final_cleanup(void)
48{
49 u32 status;
50
51 /* call into FspNotify */
52 debug("Calling into FSP (notify phase INIT_PHASE_BOOT): ");
53 status = fsp_notify(NULL, INIT_PHASE_BOOT);
54 if (status)
55 debug("fail, error code %x\n", status);
56 else
57 debug("OK\n");
58}
59
60void *fsp_prepare_mrc_cache(void)
61{
62 struct mrc_data_container *cache;
63 struct mrc_region entry;
64 int ret;
65
66 ret = mrccache_get_region(NULL, &entry);
67 if (ret)
68 return NULL;
69
70 cache = mrccache_find_current(&entry);
71 if (!cache)
72 return NULL;
73
74 debug("%s: mrc cache at %p, size %x checksum %04x\n", __func__,
75 cache->data, cache->data_size, cache->checksum);
76
77 return cache->data;
78}
79
80#ifdef CONFIG_HAVE_ACPI_RESUME
81int fsp_save_s3_stack(void)
82{
83 struct udevice *dev;
84 int ret;
85
86 if (gd->arch.prev_sleep_state == ACPI_S3)
87 return 0;
88
89 ret = uclass_get_device(UCLASS_RTC, 0, &dev);
90 if (ret) {
91 debug("Cannot find RTC: err=%d\n", ret);
92 return -ENODEV;
93 }
94
95 /* Save the stack address to CMOS */
96 ret = rtc_write32(dev, CMOS_FSP_STACK_ADDR, gd->start_addr_sp);
97 if (ret) {
98 debug("Save stack address to CMOS: err=%d\n", ret);
99 return -EIO;
100 }
101
102 return 0;
103}
104#endif