Commit e007e963 authored by Thomas Schäfer's avatar Thomas Schäfer
Browse files

pitx-imx8m: add 'core_variant' environment variable



- Read i.MX cpu type using standard 'get_imx_type' functioin.
- Convert string to lowercase and set core variant appropriately.
- Remove blank characters from string as the core_variant variable
  could be used to select appropriate device tree before OS boot.
Signed-off-by: Thomas Schäfer's avatarThomas Schaefer <thomas.schaefer@kontron.com>
parent d096614c
......@@ -31,6 +31,7 @@
#include <i2c.h>
#include <search.h>
#include <environment.h>
#include <linux/ctype.h>
#include "pitx-imx8m.h"
#include "../common/emb_eep.h"
......@@ -520,9 +521,32 @@ static enum boot_source pitx_imx8m_boot_source(void)
};
}
static void get_core_variant(char *variant, int maxlen)
{
u32 cpu_rev = get_cpu_rev();
char *p_var = variant;
const char *p_cpuvar = get_imx_type((cpu_rev&0x1FF000) >> 12);
int len = strlen(p_cpuvar);
memset(variant, 0, maxlen);
if (len > maxlen)
len = maxlen;
/* convert variant string to lowercase */
for (; len > 0 ; len--, p_cpuvar++) {
if (*p_cpuvar != ' ')
*p_var++ = tolower(*p_cpuvar);
}
}
int board_late_init(void)
{
char core_variant[32];
get_core_variant(core_variant, 32);
env_set("core_variant", core_variant);
env_set_ulong("bootsource", pitx_imx8m_boot_source());
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
env_set("board_name", "PITX-iMX8M");
env_set("board_rev", "iMX8MQ");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment