hw25: add board type detection

This commit is contained in:
Rene Straub 2020-10-19 16:49:35 +02:00
parent 50dbe9d830
commit d3f9300741
1 changed files with 36 additions and 4 deletions

View File

@ -115,7 +115,10 @@ DECLARE_GLOBAL_DATA_PTR;
static int hw_ver = -1;
static int hw_rev = -1;
static int hw_patch = -1;
static int hw_type = -1;
static char hw_variant_name[64];
#else
static int hw_type = -1;
#endif
#if !defined(CONFIG_SPL_BUILD)
@ -391,6 +394,24 @@ void check_pmic_reset_reason(unsigned int reset_reason_shm_location)
#endif
static void init_bd_spl(void)
{
hw_type = 25; /* Assume hw25, unless BD tells different */
if (read_eeprom() >= 0) {
int hw_type_from_bd = -1;
/* If entry is found returns value, otherwise 0 */
bd_get_hw_type(&hw_type_from_bd);
if (hw_type_from_bd != 0) {
hw_type = hw_type_from_bd;
}
}
else {
puts("Could not get board ID.\n");
}
}
void am33xx_spl_board_init(void)
{
/* Set CPU speed to 600 MHz (fix) */
@ -402,6 +423,9 @@ void am33xx_spl_board_init(void)
/* Configure both I2C buses used */
init_i2c();
/* Get board descriptor */
init_bd_spl();
/* Setup PMIC */
init_pmic_spl();
@ -692,8 +716,13 @@ static void get_hw_version(void)
bd_get_hw_version(&hw_ver, &hw_rev);
bd_get_hw_patch(&hw_patch);
bd_get_hw_type(&hw_type);
if (hw_type == 0) {
/* Fallback to HW25 if tag is not present */
hw_type = 25;
}
printf("HW25: V%d.%d\n", hw_ver, hw_rev);
printf("HW%02d: V%d.%d\n", hw_type, hw_ver, hw_rev);
#ifdef CONFIG_NRSW_BUILD
/* add hardware versions to environment */
@ -1118,14 +1147,17 @@ static void ft_bootloader_version(void *blob)
static void ft_hw_info(void *blob)
{
int node_offset;
char hw_version[16];
char hw_version_str[16];
char hw_type_str[8];
snprintf(hw_version, sizeof(hw_version), "%d.%d.%d", hw_ver, hw_rev, hw_patch);
snprintf(hw_version_str, sizeof(hw_version_str), "%d.%d.%d", hw_ver, hw_rev, hw_patch);
snprintf(hw_type_str, sizeof(hw_type_str), "%d", hw_type);
node_offset = fdt_path_offset(blob, "/");
if (node_offset != -1) {
fdt_setprop_string(blob, node_offset, "model", hw_variant_name);
fdt_setprop_string(blob, node_offset, "nm,carrierboard,version", hw_version);
fdt_setprop_string(blob, node_offset, "nm,carrierboard,version", hw_version_str);
fdt_setprop_string(blob, node_offset, "nm,carrierboard,type", hw_type_str);
}
}