blob: 7e4c14766347e4ddeadc4a8f117fb68d45071357 [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
Simon Glass1fa70f82019-11-14 12:57:34 -07006#include <cpu_func.h>
Simon Glassac4df6f2019-09-25 08:11:30 -06007#include <dm.h>
8#include <errno.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
Simon Glassac4df6f2019-09-25 08:11:30 -060011#include <rtc.h>
Simon Glass50461092020-04-08 16:57:35 -060012#include <acpi/acpi_s3.h>
Simon Glassac4df6f2019-09-25 08:11:30 -060013#include <asm/cmos_layout.h>
14#include <asm/early_cmos.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
Simon Glassac4df6f2019-09-25 08:11:30 -060016#include <asm/io.h>
17#include <asm/mrccache.h>
18#include <asm/post.h>
19#include <asm/processor.h>
20#include <asm/fsp/fsp_support.h>
21
22DECLARE_GLOBAL_DATA_PTR;
23
24int checkcpu(void)
25{
26 return 0;
27}
28
Simon Glassac4df6f2019-09-25 08:11:30 -060029int fsp_init_phase_pci(void)
30{
31 u32 status;
32
33 /* call into FspNotify */
34 debug("Calling into FSP (notify phase INIT_PHASE_PCI): ");
35 status = fsp_notify(NULL, INIT_PHASE_PCI);
36 if (status)
37 debug("fail, error code %x\n", status);
38 else
39 debug("OK\n");
40
41 return status ? -EPERM : 0;
42}
43
Simon Glass75ece5f2020-07-16 21:22:38 -060044void board_final_init(void)
Simon Glassac4df6f2019-09-25 08:11:30 -060045{
46 u32 status;
47
48 /* call into FspNotify */
49 debug("Calling into FSP (notify phase INIT_PHASE_BOOT): ");
50 status = fsp_notify(NULL, INIT_PHASE_BOOT);
51 if (status)
52 debug("fail, error code %x\n", status);
53 else
54 debug("OK\n");
55}
56
Sean Andersoncc841292022-11-22 12:54:51 -050057#if CONFIG_IS_ENABLED(DM_RTC)
Simon Glassac4df6f2019-09-25 08:11:30 -060058int fsp_save_s3_stack(void)
59{
60 struct udevice *dev;
61 int ret;
62
63 if (gd->arch.prev_sleep_state == ACPI_S3)
64 return 0;
65
66 ret = uclass_get_device(UCLASS_RTC, 0, &dev);
67 if (ret) {
68 debug("Cannot find RTC: err=%d\n", ret);
69 return -ENODEV;
70 }
71
72 /* Save the stack address to CMOS */
73 ret = rtc_write32(dev, CMOS_FSP_STACK_ADDR, gd->start_addr_sp);
74 if (ret) {
75 debug("Save stack address to CMOS: err=%d\n", ret);
76 return -EIO;
77 }
78
79 return 0;
80}
Sean Andersoncc841292022-11-22 12:54:51 -050081#endif