arm: stm32mp1: Set soc_type, soc_pkg, soc_rev env variables

Split up get_soc_name(), clean the decoding up a bit, and set up
environment variables which contain the SoC type, package, revision.
This is useful on SoMs, where multiple SoC options are populated.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
This commit is contained in:
Marek Vasut 2021-03-31 14:15:09 +02:00 committed by Patrice Chotard
parent a08d1a916b
commit 2c2d7d6a72

View file

@ -352,89 +352,78 @@ u32 get_cpu_package(void)
return get_otp(BSEC_OTP_PKG, PKG_SHIFT, PKG_MASK); return get_otp(BSEC_OTP_PKG, PKG_SHIFT, PKG_MASK);
} }
void get_soc_name(char name[SOC_NAME_SIZE]) static const char * const soc_type[] = {
{ "????",
char *cpu_s, *cpu_r, *pkg; "151C", "151A", "151F", "151D",
"153C", "153A", "153F", "153D",
"157C", "157A", "157F", "157D"
};
/* MPUs Part Numbers */ static const char * const soc_pkg[] = { "??", "AD", "AC", "AB", "AA" };
switch (get_cpu_type()) { static const char * const soc_rev[] = { "?", "A", "B", "Z" };
case CPU_STM32MP157Fxx:
cpu_s = "157F"; static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg,
break; unsigned int *rev)
case CPU_STM32MP157Dxx: {
cpu_s = "157D"; u32 cpu_type = get_cpu_type();
break; u32 ct = cpu_type & ~(BIT(7) | BIT(0));
case CPU_STM32MP157Cxx: u32 cm = ((cpu_type & BIT(7)) >> 6) | (cpu_type & BIT(0));
cpu_s = "157C"; u32 cp = get_cpu_package();
break;
case CPU_STM32MP157Axx: /* Bits 0 and 7 are the ACDF, 00:C 01:A 10:F 11:D */
cpu_s = "157A"; switch (ct) {
break; case CPU_STM32MP151Cxx:
case CPU_STM32MP153Fxx: *type = cm + 1;
cpu_s = "153F";
break;
case CPU_STM32MP153Dxx:
cpu_s = "153D";
break; break;
case CPU_STM32MP153Cxx: case CPU_STM32MP153Cxx:
cpu_s = "153C"; *type = cm + 5;
break; break;
case CPU_STM32MP153Axx: case CPU_STM32MP157Cxx:
cpu_s = "153A"; *type = cm + 9;
break;
case CPU_STM32MP151Fxx:
cpu_s = "151F";
break;
case CPU_STM32MP151Dxx:
cpu_s = "151D";
break;
case CPU_STM32MP151Cxx:
cpu_s = "151C";
break;
case CPU_STM32MP151Axx:
cpu_s = "151A";
break; break;
default: default:
cpu_s = "????"; *type = 0;
break; break;
} }
/* Package */ /* Package */
switch (get_cpu_package()) { switch (cp) {
case PKG_AA_LBGA448: case PKG_AA_LBGA448:
pkg = "AA";
break;
case PKG_AB_LBGA354: case PKG_AB_LBGA354:
pkg = "AB";
break;
case PKG_AC_TFBGA361: case PKG_AC_TFBGA361:
pkg = "AC";
break;
case PKG_AD_TFBGA257: case PKG_AD_TFBGA257:
pkg = "AD"; *pkg = cp;
break; break;
default: default:
pkg = "??"; *pkg = 0;
break; break;
} }
/* REVISION */ /* Revision */
switch (get_cpu_rev()) { switch (get_cpu_rev()) {
case CPU_REVA: case CPU_REVA:
cpu_r = "A"; *rev = 1;
break; break;
case CPU_REVB: case CPU_REVB:
cpu_r = "B"; *rev = 2;
break; break;
case CPU_REVZ: case CPU_REVZ:
cpu_r = "Z"; *rev = 3;
break; break;
default: default:
cpu_r = "?"; *rev = 0;
break; break;
} }
}
snprintf(name, SOC_NAME_SIZE, "STM32MP%s%s Rev.%s", cpu_s, pkg, cpu_r); void get_soc_name(char name[SOC_NAME_SIZE])
{
unsigned int type, pkg, rev;
get_cpu_string_offsets(&type, &pkg, &rev);
snprintf(name, SOC_NAME_SIZE, "STM32MP%s%s Rev.%s",
soc_type[type], soc_pkg[pkg], soc_rev[rev]);
} }
#if defined(CONFIG_DISPLAY_CPUINFO) #if defined(CONFIG_DISPLAY_CPUINFO)
@ -626,11 +615,23 @@ static int setup_serial_number(void)
return 0; return 0;
} }
static void setup_soc_type_pkg_rev(void)
{
unsigned int type, pkg, rev;
get_cpu_string_offsets(&type, &pkg, &rev);
env_set("soc_type", soc_type[type]);
env_set("soc_pkg", soc_pkg[pkg]);
env_set("soc_rev", soc_rev[rev]);
}
int arch_misc_init(void) int arch_misc_init(void)
{ {
setup_boot_mode(); setup_boot_mode();
setup_mac_address(); setup_mac_address();
setup_serial_number(); setup_serial_number();
setup_soc_type_pkg_rev();
return 0; return 0;
} }