Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 90699df | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 2 | /* |
Bin Meng | 3f56d45 | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 3 | * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 90699df | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <command.h> |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 8 | #include <asm/fsp/fsp_support.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Bin Meng | 90699df | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 13 | static int do_hdr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 14 | { |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 15 | struct fsp_header *hdr; |
| 16 | u32 img_addr; |
| 17 | char *sign; |
| 18 | uint addr; |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 19 | int i; |
| 20 | |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 21 | #ifdef CONFIG_FSP_VERSION2 |
| 22 | /* |
| 23 | * Only FSP-S is displayed. FSP-M was used in SPL but may not still be |
| 24 | * around, and we didn't keep a pointer to it. |
| 25 | */ |
| 26 | hdr = gd->arch.fsp_s_hdr; |
| 27 | img_addr = hdr->img_base; |
| 28 | addr = img_addr; |
| 29 | #else |
| 30 | addr = CONFIG_FSP_ADDR; |
| 31 | hdr = fsp_find_header(); |
| 32 | img_addr = hdr->img_base; |
| 33 | #endif |
| 34 | sign = (char *)&hdr->sign; |
| 35 | |
| 36 | printf("FSP : binary %08x, header %08x\n", addr, (int)hdr); |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 37 | printf("Header : sign "); |
| 38 | for (i = 0; i < sizeof(hdr->sign); i++) |
| 39 | printf("%c", *sign++); |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 40 | printf(", size %x, rev %d\n", hdr->hdr_len, hdr->hdr_rev); |
Bin Meng | c23720c | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 41 | printf("Image : rev "); |
| 42 | if (hdr->hdr_rev == FSP_HEADER_REVISION_1) { |
| 43 | printf("%d.%d", |
| 44 | (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff); |
| 45 | } else { |
| 46 | printf("%d.%d.%d.%d", |
| 47 | (hdr->img_rev >> 24) & 0xff, (hdr->img_rev >> 16) & 0xff, |
| 48 | (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff); |
| 49 | } |
| 50 | printf(", id "); |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 51 | for (i = 0; i < ARRAY_SIZE(hdr->img_id); i++) |
| 52 | printf("%c", hdr->img_id[i]); |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 53 | printf(", addr %08x, size %x\n", img_addr, hdr->img_size); |
| 54 | if (hdr->hdr_rev >= FSP_HEADER_REVISION_1) { |
Bin Meng | c23720c | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 55 | printf("GFX :%ssupported\n", |
| 56 | hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un"); |
| 57 | } |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 58 | printf("VPD : addr %08x, size %x\n", |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 59 | hdr->cfg_region_off + img_addr, hdr->cfg_region_size); |
Simon Glass | 95518ae | 2019-12-06 21:42:27 -0700 | [diff] [blame] | 60 | if (hdr->hdr_rev <= FSP_HEADER_REVISION_2) |
| 61 | printf("\nNumber of APIs Supported : %d\n", hdr->api_num); |
| 62 | if (hdr->fsp_tempram_init) |
| 63 | printf("\tTempRamInit : %08x\n", |
| 64 | hdr->fsp_tempram_init + img_addr); |
| 65 | if (hdr->fsp_init) |
| 66 | printf("\tFspInit : %08x\n", hdr->fsp_init + img_addr); |
| 67 | if (hdr->fsp_notify) |
| 68 | printf("\tFspNotify : %08x\n", hdr->fsp_notify + img_addr); |
| 69 | if (hdr->hdr_rev >= FSP_HEADER_REVISION_1) { |
| 70 | if (hdr->fsp_mem_init) |
| 71 | printf("\tMemoryInit : %08x\n", |
| 72 | hdr->fsp_mem_init + img_addr); |
| 73 | if (hdr->fsp_tempram_exit) |
| 74 | printf("\tTempRamExit : %08x\n", |
| 75 | hdr->fsp_tempram_exit + img_addr); |
| 76 | if (hdr->fsp_silicon_init) |
| 77 | printf("\tSiliconInit : %08x\n", |
| 78 | hdr->fsp_silicon_init + img_addr); |
Bin Meng | c23720c | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 79 | } |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 80 | |
| 81 | return 0; |
| 82 | } |
| 83 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 84 | static struct cmd_tbl fsp_commands[] = { |
Bin Meng | 8938dbd | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 85 | U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""), |
Bin Meng | 3f56d45 | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 88 | static int do_fsp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Bin Meng | 3f56d45 | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 89 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 90 | struct cmd_tbl *fsp_cmd; |
Bin Meng | 3f56d45 | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 91 | int ret; |
| 92 | |
| 93 | if (argc < 2) |
| 94 | return CMD_RET_USAGE; |
| 95 | fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands)); |
| 96 | argc -= 2; |
| 97 | argv += 2; |
| 98 | if (!fsp_cmd || argc > fsp_cmd->maxargs) |
| 99 | return CMD_RET_USAGE; |
| 100 | |
| 101 | ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv); |
| 102 | |
| 103 | return cmd_process_error(fsp_cmd, ret); |
| 104 | } |
| 105 | |
Bin Meng | 90699df | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 106 | U_BOOT_CMD( |
Bin Meng | 3f56d45 | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 107 | fsp, 2, 1, do_fsp, |
| 108 | "Show Intel Firmware Support Package (FSP) related information", |
Park, Aiden | 538aec9 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 109 | "hdr - Print FSP header information" |
Bin Meng | 90699df | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 110 | ); |