util/amdfwtool: Add fanless SMU firmware options

The Stoney Ridge program has OPNs that are considered fanless.  These
APUs are strapped to search for unique SMU firmware, indicated by
Type[8]=1 in the directory table entry.

Add new options to amdfwtool and include the blobs in the build with
the appropriate bit set in the Type encoding.

Original-Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Original-Reviewed-by: Marc Jones <marcj303@gmail.com>
(cherry picked from commit 8df0d6847c39bb021271983018ac6f448f9ff9da)

Change-Id: I4b80ccf8fd9644f9a9d300e6c67aed9834a2c7a7
Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Reviewed-on: https://review.coreboot.org/18991
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Marshall Dawson 2017-03-17 16:30:51 -06:00 committed by Martin Roth
parent e91d170d21
commit f4b9b41c47
1 changed files with 85 additions and 63 deletions

View File

@ -149,53 +149,58 @@ static void usage(void)
{ {
printf("amdfwtool: Create AMD Firmware combination\n"); printf("amdfwtool: Create AMD Firmware combination\n");
printf("Usage: amdfwtool [options] -f <size> -o <filename>\n"); printf("Usage: amdfwtool [options] -f <size> -o <filename>\n");
printf("-x | --xhci <FILE> Add XHCI blob\n"); printf("-x | --xhci <FILE> Add XHCI blob\n");
printf("-i | --imc <FILE> Add IMC blob\n"); printf("-i | --imc <FILE> Add IMC blob\n");
printf("-g | --gec <FILE> Add GEC blob\n"); printf("-g | --gec <FILE> Add GEC blob\n");
printf("\nPSP options:\n"); printf("\nPSP options:\n");
printf("-p | --pubkey <FILE> Add pubkey\n"); printf("-p | --pubkey <FILE> Add pubkey\n");
printf("-b | --bootloader <FILE> Add bootloader\n"); printf("-b | --bootloader <FILE> Add bootloader\n");
printf("-s | --smufirmware <FILE> Add smufirmware\n"); printf("-s | --smufirmware <FILE> Add smufirmware\n");
printf("-r | --recovery <FILE> Add recovery\n"); printf("-r | --recovery <FILE> Add recovery\n");
printf("-k | --rtmpubkey <FILE> Add rtmpubkey\n"); printf("-k | --rtmpubkey <FILE> Add rtmpubkey\n");
printf("-c | --secureos <FILE> Add secureos\n"); printf("-c | --secureos <FILE> Add secureos\n");
printf("-n | --nvram <FILE> Add nvram\n"); printf("-n | --nvram <FILE> Add nvram\n");
printf("-d | --securedebug <FILE> Add securedebug\n"); printf("-d | --securedebug <FILE> Add securedebug\n");
printf("-t | --trustlets <FILE> Add trustlets\n"); printf("-t | --trustlets <FILE> Add trustlets\n");
printf("-u | --trustletkey <FILE> Add trustletkey\n"); printf("-u | --trustletkey <FILE> Add trustletkey\n");
printf("-w | --smufirmware2 <FILE> Add smufirmware2\n"); printf("-w | --smufirmware2 <FILE> Add smufirmware2\n");
printf("-m | --smuscs <FILE> Add smuscs\n"); printf("-m | --smuscs <FILE> Add smuscs\n");
#if PSP2 #if PSP2
printf("\nPSP2 options:\n"); printf("\nPSP2 options:\n");
printf("-P | --pubkey2 <FILE> Add pubkey\n"); printf("-P | --pubkey2 <FILE> Add pubkey\n");
printf("-B | --bootloader2 <FILE> Add bootloader\n"); printf("-B | --bootloader2 <FILE> Add bootloader\n");
printf("-S | --smufirmware_2 <FILE> Add smufirmware\n"); printf("-S | --smufirmware_2 <FILE> Add smufirmware\n");
printf("-R | --recovery2 <FILE> Add recovery\n"); printf("-L | --smufnfirmware_2 <FILE> Add fanless smufirmware\n");
printf("-K | --rtmpubkey2 <FILE> Add rtmpubkey\n"); printf("-R | --recovery2 <FILE> Add recovery\n");
printf("-C | --secureos2 <FILE> Add secureos\n"); printf("-K | --rtmpubkey2 <FILE> Add rtmpubkey\n");
printf("-N | --nvram2 <FILE> Add nvram\n"); printf("-C | --secureos2 <FILE> Add secureos\n");
printf("-D | --securedebug2 <FILE> Add securedebug\n"); printf("-N | --nvram2 <FILE> Add nvram\n");
printf("-T | --trustlets2 <FILE> Add trustlets\n"); printf("-D | --securedebug2 <FILE> Add securedebug\n");
printf("-U | --trustletkey2 <FILE> Add trustletkey\n"); printf("-T | --trustlets2 <FILE> Add trustlets\n");
printf("-W | --smufirmware2_2 <FILE> Add smufirmware2\n"); printf("-U | --trustletkey2 <FILE> Add trustletkey\n");
printf("-M | --smuscs2 <FILE> Add smuscs\n"); printf("-W | --smufirmware2_2 <FILE> Add smufirmware2\n");
printf("-E | --smufnfirmware2_2 <FILE> Add fanless smufirmware2\n");
printf("-M | --smuscs2 <FILE> Add smuscs\n");
#endif #endif
printf("\n-o | --output <filename> output filename\n"); printf("\n-o | --output <filename> output filename\n");
printf("-f | --flashsize <HEX_VAL> ROM size in bytes\n"); printf("-f | --flashsize <HEX_VAL> ROM size in bytes\n");
printf(" size must be larger than %dKB\n", printf(" size must be larger than %dKB\n",
MIN_ROM_KB); MIN_ROM_KB);
printf(" and must a multiple of 1024\n"); printf(" and must a multiple of 1024\n");
printf("-h | --help show this help\n"); printf("-h | --help show this help\n");
} }
#define FANLESS_FW 0x100 /* type[15:8]: 0=non-fanless OPNs, 1=fanless */
typedef enum _amd_fw_type { typedef enum _amd_fw_type {
AMD_FW_PSP_PUBKEY = 0, AMD_FW_PSP_PUBKEY = 0,
AMD_FW_PSP_BOOTLOADER = 1, AMD_FW_PSP_BOOTLOADER = 1,
AMD_FW_PSP_SMU_FIRMWARE = 8, AMD_FW_PSP_SMU_FIRMWARE = 8,
AMD_FW_PSP_SMU_FN_FIRMWARE = FANLESS_FW + AMD_FW_PSP_SMU_FIRMWARE,
AMD_FW_PSP_RECOVERY = 3, AMD_FW_PSP_RECOVERY = 3,
AMD_FW_PSP_RTM_PUBKEY = 5, AMD_FW_PSP_RTM_PUBKEY = 5,
AMD_FW_PSP_SECURED_OS = 2, AMD_FW_PSP_SECURED_OS = 2,
@ -204,6 +209,7 @@ typedef enum _amd_fw_type {
AMD_FW_PSP_TRUSTLETS = 12, AMD_FW_PSP_TRUSTLETS = 12,
AMD_FW_PSP_TRUSTLETKEY = 13, AMD_FW_PSP_TRUSTLETKEY = 13,
AMD_FW_PSP_SMU_FIRMWARE2 = 18, AMD_FW_PSP_SMU_FIRMWARE2 = 18,
AMD_FW_PSP_SMU_FN_FIRMWARE2 = FANLESS_FW + AMD_FW_PSP_SMU_FIRMWARE2,
AMD_PSP_FUSE_CHAIN = 11, AMD_PSP_FUSE_CHAIN = 11,
AMD_FW_PSP_SMUSCS = 95, AMD_FW_PSP_SMUSCS = 95,
@ -230,6 +236,8 @@ static amd_fw_entry amd_psp_fw_table[] = {
{ .type = AMD_FW_PSP_TRUSTLETS }, { .type = AMD_FW_PSP_TRUSTLETS },
{ .type = AMD_FW_PSP_TRUSTLETKEY }, { .type = AMD_FW_PSP_TRUSTLETKEY },
{ .type = AMD_FW_PSP_SMU_FIRMWARE2 }, { .type = AMD_FW_PSP_SMU_FIRMWARE2 },
{ .type = AMD_FW_PSP_SMU_FN_FIRMWARE },
{ .type = AMD_FW_PSP_SMU_FN_FIRMWARE2 },
{ .type = AMD_FW_PSP_SMUSCS }, { .type = AMD_FW_PSP_SMUSCS },
{ .type = AMD_PSP_FUSE_CHAIN }, { .type = AMD_PSP_FUSE_CHAIN },
{ .type = AMD_FW_INVALID }, { .type = AMD_FW_INVALID },
@ -248,6 +256,8 @@ static amd_fw_entry amd_psp2_fw_table[] = {
{ .type = AMD_FW_PSP_TRUSTLETS }, { .type = AMD_FW_PSP_TRUSTLETS },
{ .type = AMD_FW_PSP_TRUSTLETKEY }, { .type = AMD_FW_PSP_TRUSTLETKEY },
{ .type = AMD_FW_PSP_SMU_FIRMWARE2 }, { .type = AMD_FW_PSP_SMU_FIRMWARE2 },
{ .type = AMD_FW_PSP_SMU_FN_FIRMWARE },
{ .type = AMD_FW_PSP_SMU_FN_FIRMWARE2 },
{ .type = AMD_FW_PSP_SMUSCS }, { .type = AMD_FW_PSP_SMUSCS },
{ .type = AMD_PSP_FUSE_CHAIN }, { .type = AMD_PSP_FUSE_CHAIN },
{ .type = AMD_FW_INVALID }, { .type = AMD_FW_INVALID },
@ -367,50 +377,52 @@ static uint32_t integrate_psp_firmwares(char *base, uint32_t pos,
#if PSP2 #if PSP2
static const char *optstring = static const char *optstring =
"x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:P:B:S:R:K:C:N:D:T:U:W:M:o:f:h"; "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:P:B:S:L:R:K:C:N:D:T:U:W:E:M:o:f:h";
#else #else
static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:h"; static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:h";
#endif #endif
static struct option long_options[] = { static struct option long_options[] = {
{"xhci", required_argument, 0, 'x' }, {"xhci", required_argument, 0, 'x' },
{"imc", required_argument, 0, 'i' }, {"imc", required_argument, 0, 'i' },
{"gec", required_argument, 0, 'g' }, {"gec", required_argument, 0, 'g' },
/* PSP */ /* PSP */
{"pubkey", required_argument, 0, 'p' }, {"pubkey", required_argument, 0, 'p' },
{"bootloader", required_argument, 0, 'b' }, {"bootloader", required_argument, 0, 'b' },
{"smufirmware", required_argument, 0, 's' }, {"smufirmware", required_argument, 0, 's' },
{"recovery", required_argument, 0, 'r' }, {"recovery", required_argument, 0, 'r' },
{"rtmpubkey", required_argument, 0, 'k' }, {"rtmpubkey", required_argument, 0, 'k' },
{"secureos", required_argument, 0, 'c' }, {"secureos", required_argument, 0, 'c' },
{"nvram", required_argument, 0, 'n' }, {"nvram", required_argument, 0, 'n' },
{"securedebug", required_argument, 0, 'd' }, {"securedebug", required_argument, 0, 'd' },
{"trustlets", required_argument, 0, 't' }, {"trustlets", required_argument, 0, 't' },
{"trustletkey", required_argument, 0, 'u' }, {"trustletkey", required_argument, 0, 'u' },
{"smufirmware2", required_argument, 0, 'w' }, {"smufirmware2", required_argument, 0, 'w' },
{"smuscs", required_argument, 0, 'm' }, {"smuscs", required_argument, 0, 'm' },
/* TODO: PSP2 */ /* TODO: PSP2 */
#if PSP2 #if PSP2
{"pubkey2", required_argument, 0, 'P' }, {"pubkey2", required_argument, 0, 'P' },
{"bootloader2", required_argument, 0, 'B' }, {"bootloader2", required_argument, 0, 'B' },
{"smufirmware_2", required_argument, 0, 'S' }, {"smufirmware_2", required_argument, 0, 'S' },
{"recovery2", required_argument, 0, 'R' }, {"smufnfirmware_2", required_argument, 0, 'L' },
{"rtmpubkey2", required_argument, 0, 'K' }, {"recovery2", required_argument, 0, 'R' },
{"secureos2", required_argument, 0, 'C' }, {"rtmpubkey2", required_argument, 0, 'K' },
{"nvram2", required_argument, 0, 'N' }, {"secureos2", required_argument, 0, 'C' },
{"securedebug2", required_argument, 0, 'D' }, {"nvram2", required_argument, 0, 'N' },
{"trustlets2", required_argument, 0, 'T' }, {"securedebug2", required_argument, 0, 'D' },
{"trustletkey2", required_argument, 0, 'U' }, {"trustlets2", required_argument, 0, 'T' },
{"smufirmware2_2", required_argument, 0, 'W' }, {"trustletkey2", required_argument, 0, 'U' },
{"smuscs2", required_argument, 0, 'M' }, {"smufirmware2_2", required_argument, 0, 'W' },
{"smufnfirmware2_2", required_argument, 0, 'E' },
{"smuscs2", required_argument, 0, 'M' },
#endif #endif
{"output", required_argument, 0, 'o' }, {"output", required_argument, 0, 'o' },
{"flashsize", required_argument, 0, 'f' }, {"flashsize", required_argument, 0, 'f' },
{"help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h' },
{NULL, 0, 0, 0 } {NULL, 0, 0, 0 }
}; };
static void register_fw_filename(amd_fw_type type, char filename[], int pspflag) static void register_fw_filename(amd_fw_type type, char filename[], int pspflag)
@ -552,6 +564,11 @@ int main(int argc, char **argv)
optarg, 2); optarg, 2);
psp2flag = 1; psp2flag = 1;
break; break;
case 'L':
register_fw_filename(AMD_FW_PSP_SMU_FN_FIRMWARE,
optarg, 2);
psp2flag = 1;
break;
case 'R': case 'R':
register_fw_filename(AMD_FW_PSP_RECOVERY, optarg, 2); register_fw_filename(AMD_FW_PSP_RECOVERY, optarg, 2);
psp2flag = 1; psp2flag = 1;
@ -586,6 +603,11 @@ int main(int argc, char **argv)
optarg, 2); optarg, 2);
psp2flag = 1; psp2flag = 1;
break; break;
case 'E':
register_fw_filename(AMD_FW_PSP_SMU_FN_FIRMWARE2,
optarg, 2);
psp2flag = 1;
break;
case 'M': case 'M':
register_fw_filename(AMD_FW_PSP_SMUSCS, optarg, 2); register_fw_filename(AMD_FW_PSP_SMUSCS, optarg, 2);
psp2flag = 1; psp2flag = 1;