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