Subrata Banik | 2b2ade9 | 2020-10-31 21:07:16 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <console/console.h> |
Subrata Banik | da7d00e | 2023-04-26 16:31:56 +0530 | [diff] [blame] | 4 | #include <fsp/api.h> |
Subrata Banik | 2b2ade9 | 2020-10-31 21:07:16 +0530 | [diff] [blame] | 5 | #include <fsp/util.h> |
| 6 | #include <soc/intel/common/reset.h> |
Elyes Haouas | 8ed5835 | 2022-10-22 22:17:28 +0200 | [diff] [blame] | 7 | #include <stdint.h> |
Subrata Banik | 2b2ade9 | 2020-10-31 21:07:16 +0530 | [diff] [blame] | 8 | |
Subrata Banik | da7d00e | 2023-04-26 16:31:56 +0530 | [diff] [blame] | 9 | static const uint8_t fsp_reset_guid[16] = { |
| 10 | 0xff, 0x97, 0x05, 0xea, 0x58, 0x88, 0xca, 0x41, |
| 11 | 0xbb, 0xc1, 0xfe, 0x18, 0xfc, 0xd2, 0x8e, 0x22 |
| 12 | }; |
| 13 | |
| 14 | static const uint8_t fsp_global_reset_guid[16] = { |
| 15 | 0x4c, 0x1b, 0xb3, 0x9d, 0xef, 0xf5, 0xbb, 0x48, |
| 16 | 0x94, 0x2b, 0x18, 0x1f, 0x7e, 0x3a, 0x3e, 0x40 |
| 17 | }; |
| 18 | |
| 19 | /* Platform Reset String as per Intel FSP is "PCH RESET" in unicode */ |
| 20 | #define PLATFORM_RESET_STRING_LENGTH 20 |
| 21 | |
| 22 | struct pch_reset_data { |
| 23 | char reserved[PLATFORM_RESET_STRING_LENGTH]; |
| 24 | efi_guid_t global_reset_uid; |
| 25 | }; |
| 26 | |
| 27 | /* This structure is used to provide information about PCH Reset */ |
| 28 | struct fsp_reset_hob { |
| 29 | EFI_RESET_TYPE reset_type; |
| 30 | struct pch_reset_data reset_data; |
| 31 | }; |
| 32 | |
Subrata Banik | 2b2ade9 | 2020-10-31 21:07:16 +0530 | [diff] [blame] | 33 | void chipset_handle_reset(uint32_t status) |
| 34 | { |
| 35 | if (status == CONFIG_FSP_STATUS_GLOBAL_RESET) { |
| 36 | printk(BIOS_DEBUG, "GLOBAL RESET!\n"); |
| 37 | global_reset(); |
| 38 | } |
| 39 | |
| 40 | printk(BIOS_ERR, "unhandled reset type %x\n", status); |
| 41 | die("unknown reset type"); |
| 42 | } |
Subrata Banik | da7d00e | 2023-04-26 16:31:56 +0530 | [diff] [blame] | 43 | |
| 44 | static uint32_t fsp_reset_type_to_status(EFI_RESET_TYPE reset_type) |
| 45 | { |
| 46 | uint32_t status; |
| 47 | |
| 48 | switch (reset_type) { |
| 49 | case EfiResetCold: |
| 50 | status = FSP_STATUS_RESET_REQUIRED_COLD; |
| 51 | break; |
| 52 | case EfiResetWarm: |
| 53 | status = FSP_STATUS_RESET_REQUIRED_WARM; |
| 54 | break; |
| 55 | default: |
| 56 | printk(BIOS_ERR, "unhandled reset type %x\n", reset_type); |
| 57 | die("unknown reset type"); |
| 58 | } |
| 59 | |
| 60 | return status; |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | * Return PCH Reset Status |
| 65 | * The return status can be between EfiResetCold, EfiResetWarm, EfiResetShutdown |
| 66 | * or EfiResetPlatformSpecific. |
| 67 | * |
| 68 | * If reset type is `EfiResetPlatformSpecific` then relying on pch_reset_data structure |
| 69 | * to know if the reset type is a global reset. |
| 70 | */ |
| 71 | uint32_t fsp_get_pch_reset_status(void) |
| 72 | { |
Subrata Banik | da7d00e | 2023-04-26 16:31:56 +0530 | [diff] [blame] | 73 | size_t size; |
| 74 | const struct fsp_reset_hob *hob = fsp_find_extension_hob_by_guid(fsp_reset_guid, &size); |
| 75 | if (!hob) |
| 76 | return 0; |
| 77 | |
| 78 | if ((hob->reset_type == EfiResetPlatformSpecific) && |
| 79 | fsp_guid_compare((void *)&(hob->reset_data.global_reset_uid), |
| 80 | fsp_global_reset_guid)) |
| 81 | return CONFIG_FSP_STATUS_GLOBAL_RESET; |
| 82 | |
| 83 | return fsp_reset_type_to_status(hob->reset_type); |
| 84 | } |