Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Kyösti Mälkki | 967d94d | 2016-11-22 11:52:14 +0200 | [diff] [blame] | 3 | |
| 4 | #ifndef _STATE_MACHINE_H_ |
| 5 | #define _STATE_MACHINE_H_ |
| 6 | |
| 7 | #include <stdint.h> |
Kyösti Mälkki | acc599b | 2016-11-24 14:31:07 +0200 | [diff] [blame] | 8 | #include <AGESA.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 9 | #include <AMD.h> |
| 10 | |
Kyösti Mälkki | acc599b | 2016-11-24 14:31:07 +0200 | [diff] [blame] | 11 | /* eventlog */ |
Kyösti Mälkki | acc599b | 2016-11-24 14:31:07 +0200 | [diff] [blame] | 12 | void agesawrapper_trace(AGESA_STATUS ret, AMD_CONFIG_PARAMS *StdHeader, const char *func); |
Kyösti Mälkki | 0a7cab8 | 2017-07-29 08:11:52 +0300 | [diff] [blame] | 13 | AGESA_STATUS agesawrapper_amdreadeventlog(UINT8 HeapStatus); |
Kyösti Mälkki | 967d94d | 2016-11-22 11:52:14 +0200 | [diff] [blame] | 14 | |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 15 | /* For suspend-to-ram support. */ |
| 16 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 17 | #if !CONFIG(CPU_AMD_PI) |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 18 | /* TODO: With binaryPI we need different interface. */ |
| 19 | AGESA_STATUS OemInitResume(AMD_S3_PARAMS *dataBlock); |
| 20 | AGESA_STATUS OemS3LateRestore(AMD_S3_PARAMS *dataBlock); |
| 21 | AGESA_STATUS OemS3Save(AMD_S3_PARAMS *dataBlock); |
| 22 | #endif |
| 23 | |
Kyösti Mälkki | 38aff1a | 2017-07-26 00:57:30 +0300 | [diff] [blame] | 24 | /* For FCH */ |
| 25 | AGESA_STATUS fchs3earlyrestore(AMD_CONFIG_PARAMS *StdHeader); |
| 26 | AGESA_STATUS fchs3laterestore(AMD_CONFIG_PARAMS *StdHeader); |
| 27 | |
Kyösti Mälkki | 967d94d | 2016-11-22 11:52:14 +0200 | [diff] [blame] | 28 | struct sysinfo |
| 29 | { |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 30 | AMD_CONFIG_PARAMS StdHeader; |
| 31 | |
Kyösti Mälkki | 967d94d | 2016-11-22 11:52:14 +0200 | [diff] [blame] | 32 | int s3resume; |
| 33 | }; |
| 34 | |
Kyösti Mälkki | ba22e15 | 2016-11-23 06:47:15 +0200 | [diff] [blame] | 35 | void board_BeforeAgesa(struct sysinfo *cb); |
Kyösti Mälkki | df7ff31 | 2016-11-25 12:02:00 +0200 | [diff] [blame] | 36 | |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 37 | void agesa_set_interface(struct sysinfo *cb); |
Kyösti Mälkki | d1d4f93 | 2017-09-24 08:21:00 +0300 | [diff] [blame] | 38 | |
| 39 | struct agesa_state { |
| 40 | u8 apic_id; |
| 41 | |
| 42 | AGESA_STRUCT_NAME func; |
| 43 | const char *function_name; |
Kyösti Mälkki | 43f6d9d | 2019-03-14 14:59:31 +0200 | [diff] [blame] | 44 | uint32_t ts_entry_id; |
| 45 | uint32_t ts_exit_id; |
Kyösti Mälkki | d1d4f93 | 2017-09-24 08:21:00 +0300 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | void agesa_state_on_entry(struct agesa_state *task, AGESA_STRUCT_NAME func); |
| 49 | void agesa_state_on_exit(struct agesa_state *task, |
| 50 | AMD_CONFIG_PARAMS *StdHeader); |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 51 | int agesa_execute_state(struct sysinfo *cb, AGESA_STRUCT_NAME func); |
| 52 | |
| 53 | /* AGESA dispatchers */ |
| 54 | |
| 55 | AGESA_STATUS module_dispatch(AGESA_STRUCT_NAME func, AMD_CONFIG_PARAMS *StdHeader); |
| 56 | |
| 57 | void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset); |
| 58 | void board_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset); |
| 59 | |
| 60 | void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early); |
| 61 | void board_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early); |
| 62 | |
| 63 | /* Normal boot */ |
| 64 | void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post); |
| 65 | void board_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post); |
| 66 | void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post); |
| 67 | |
| 68 | void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env); |
| 69 | void board_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env); |
| 70 | void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env); |
| 71 | |
| 72 | void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid); |
| 73 | void board_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid); |
| 74 | |
Michał Żygowski | 506b9c1 | 2019-12-20 16:57:13 +0100 | [diff] [blame] | 75 | void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late); |
| 76 | void board_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late); |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 77 | void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late); |
| 78 | void completion_InitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late); |
| 79 | |
| 80 | /* S3 Resume */ |
| 81 | void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume); |
| 82 | void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume); |
| 83 | |
| 84 | void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late); |
| 85 | void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late); |
| 86 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 87 | #if CONFIG(CPU_AMD_PI_00660F01) |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 88 | typedef void AMD_S3SAVE_PARAMS; |
| 89 | #endif |
| 90 | void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save); |
| 91 | |
Kyösti Mälkki | bf201d5 | 2017-03-30 17:26:25 +0300 | [diff] [blame] | 92 | /* FCH callouts, not used with CIMx. */ |
| 93 | #define HAS_AGESA_FCH_OEM_CALLOUT \ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 94 | CONFIG(SOUTHBRIDGE_AMD_AGESA_HUDSON) || \ |
| 95 | CONFIG(SOUTHBRIDGE_AMD_AGESA_YANGTZE) || \ |
| 96 | CONFIG(SOUTHBRIDGE_AMD_PI_AVALON) || \ |
| 97 | CONFIG(SOUTHBRIDGE_AMD_PI_BOLTON) || \ |
| 98 | CONFIG(SOUTHBRIDGE_AMD_PI_KERN) |
Kyösti Mälkki | bf201d5 | 2017-03-30 17:26:25 +0300 | [diff] [blame] | 99 | |
| 100 | #if HAS_AGESA_FCH_OEM_CALLOUT |
| 101 | /* FIXME: Structures included here were supposed to be private to AGESA. */ |
| 102 | #include <FchCommonCfg.h> |
| 103 | void agesa_fch_oem_config(uintptr_t Data, AMD_CONFIG_PARAMS *StdHeader); |
| 104 | void board_FCH_InitReset(struct sysinfo *cb, FCH_RESET_DATA_BLOCK *FchReset); |
| 105 | void board_FCH_InitEnv(struct sysinfo *cb, FCH_DATA_BLOCK *FchEnv); |
| 106 | #endif |
| 107 | |
Kyösti Mälkki | 967d94d | 2016-11-22 11:52:14 +0200 | [diff] [blame] | 108 | #endif /* _STATE_MACHINE_H_ */ |