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 | 8331188 | 2019-09-25 08:00:11 -0600 | [diff] [blame^] | 8 | #include <asm/fsp1/fsp_support.h> |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 12 | static int do_hdr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 13 | { |
| 14 | struct fsp_header *hdr = find_fsp_header(); |
| 15 | u32 img_addr = hdr->img_base; |
| 16 | char *sign = (char *)&hdr->sign; |
| 17 | int i; |
| 18 | |
| 19 | printf("FSP : binary 0x%08x, header 0x%08x\n", |
| 20 | CONFIG_FSP_ADDR, (int)hdr); |
| 21 | printf("Header : sign "); |
| 22 | for (i = 0; i < sizeof(hdr->sign); i++) |
| 23 | printf("%c", *sign++); |
| 24 | printf(", size %d, rev %d\n", hdr->hdr_len, hdr->hdr_rev); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 25 | printf("Image : rev "); |
| 26 | if (hdr->hdr_rev == FSP_HEADER_REVISION_1) { |
| 27 | printf("%d.%d", |
| 28 | (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff); |
| 29 | } else { |
| 30 | printf("%d.%d.%d.%d", |
| 31 | (hdr->img_rev >> 24) & 0xff, (hdr->img_rev >> 16) & 0xff, |
| 32 | (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff); |
| 33 | } |
| 34 | printf(", id "); |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 35 | for (i = 0; i < ARRAY_SIZE(hdr->img_id); i++) |
| 36 | printf("%c", hdr->img_id[i]); |
| 37 | printf(", addr 0x%08x, size %d\n", img_addr, hdr->img_size); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 38 | if (hdr->hdr_rev == FSP_HEADER_REVISION_2) { |
| 39 | printf("GFX :%ssupported\n", |
| 40 | hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un"); |
| 41 | } |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 42 | printf("VPD : addr 0x%08x, size %d\n", |
| 43 | hdr->cfg_region_off + img_addr, hdr->cfg_region_size); |
| 44 | printf("\nNumber of APIs Supported : %d\n", hdr->api_num); |
| 45 | printf("\tTempRamInit : 0x%08x\n", hdr->fsp_tempram_init + img_addr); |
| 46 | printf("\tFspInit : 0x%08x\n", hdr->fsp_init + img_addr); |
| 47 | printf("\tFspNotify : 0x%08x\n", hdr->fsp_notify + img_addr); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 48 | if (hdr->hdr_rev == FSP_HEADER_REVISION_2) { |
| 49 | printf("\tMemoryInit : 0x%08x\n", |
| 50 | hdr->fsp_mem_init + img_addr); |
| 51 | printf("\tTempRamExit : 0x%08x\n", |
| 52 | hdr->fsp_tempram_exit + img_addr); |
| 53 | printf("\tSiliconInit : 0x%08x\n", |
| 54 | hdr->fsp_silicon_init + img_addr); |
| 55 | } |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 60 | static cmd_tbl_t fsp_commands[] = { |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 61 | U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""), |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 65 | { |
| 66 | cmd_tbl_t *fsp_cmd; |
| 67 | int ret; |
| 68 | |
| 69 | if (argc < 2) |
| 70 | return CMD_RET_USAGE; |
| 71 | fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands)); |
| 72 | argc -= 2; |
| 73 | argv += 2; |
| 74 | if (!fsp_cmd || argc > fsp_cmd->maxargs) |
| 75 | return CMD_RET_USAGE; |
| 76 | |
| 77 | ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv); |
| 78 | |
| 79 | return cmd_process_error(fsp_cmd, ret); |
| 80 | } |
| 81 | |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 82 | U_BOOT_CMD( |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 83 | fsp, 2, 1, do_fsp, |
| 84 | "Show Intel Firmware Support Package (FSP) related information", |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 85 | "hdr - Print FSP header information" |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 86 | ); |