nmhw21: support for user module device tree node

- fill out /user_module node with:
  - status: okay/disabled
  - model: UM type
  - hw version/revision
  - network configuration
- show product variant in boot log
- set product variant in device tree /model
This commit is contained in:
Rene Straub 2019-03-30 14:14:46 +01:00
parent 3e938e9ab8
commit 29d7a20fdb
1 changed files with 45 additions and 2 deletions

View File

@ -142,6 +142,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int hw_ver = -1; static int hw_ver = -1;
static int hw_rev = -1; static int hw_rev = -1;
static int hw_patch = -1; static int hw_patch = -1;
static char hw_variant_name[64];
#endif #endif
#if !defined(CONFIG_SPL_BUILD) #if !defined(CONFIG_SPL_BUILD)
@ -789,6 +790,13 @@ void set_console(void)
} }
} }
static void get_variant_name(void)
{
bd_get_variantname(hw_variant_name, sizeof(hw_variant_name));
printf("SYS: %s\n", hw_variant_name);
}
static void get_hw_version(void) static void get_hw_version(void)
{ {
bd_get_hw_version(&hw_ver, &hw_rev); bd_get_hw_version(&hw_ver, &hw_rev);
@ -954,6 +962,7 @@ int board_late_init(void)
puts("Could not get board ID.\n"); puts("Could not get board ID.\n");
} }
get_variant_name();
get_hw_version(); get_hw_version();
get_pmic_version(); get_pmic_version();
@ -1191,7 +1200,7 @@ int board_fit_config_name_match(const char *name)
#if defined(CONFIG_OF_BOARD_SETUP) && !defined(CONFIG_SPL_BUILD) #if defined(CONFIG_OF_BOARD_SETUP) && !defined(CONFIG_SPL_BUILD)
static void ft_hw_version(void *blob) static void ft_hw_info(void *blob)
{ {
int node_offset; int node_offset;
char hw_version[16]; char hw_version[16];
@ -1200,10 +1209,43 @@ static void ft_hw_version(void *blob)
node_offset = fdt_path_offset(blob, "/"); node_offset = fdt_path_offset(blob, "/");
if (node_offset != -1) { 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);
} }
} }
static void ft_user_module(void *blob)
{
if (um_present()) {
int node_offset;
node_offset = fdt_path_offset(blob, "/user_module/");
if (node_offset != -1) {
const char* model = um_type_as_str();
struct in_addr ip;
struct in_addr mask;
uint8_t ver = 0;
uint8_t rev = 0;
char hw_version[16];
char tmp[22];
um_version(&ver, &rev);
um_network_address(&ip, &mask);
fdt_setprop_string(blob, node_offset, "status", "okay");
fdt_setprop_string(blob, node_offset, "model", model);
snprintf(hw_version, sizeof(hw_version), "%d.%d", hw_ver, hw_rev);
fdt_setprop_string(blob, node_offset, "nm,carrierboard,version", hw_version);
ip_to_string(ip, tmp);
fdt_setprop_string(blob, node_offset, "ipv4-addr", tmp);
ip_to_string(mask, tmp);
fdt_setprop_string(blob, node_offset, "ipv4-mask", tmp);
}
}
}
static void ft_user_interface(void *blob) static void ft_user_interface(void *blob)
{ {
int ui_hw_version = ui_version(); int ui_hw_version = ui_version();
@ -1293,8 +1335,9 @@ static void ft_eth(void *blob)
int ft_board_setup(void *blob, bd_t *bd) int ft_board_setup(void *blob, bd_t *bd)
{ {
ft_hw_version(blob); ft_hw_info(blob);
ft_user_interface(blob); ft_user_interface(blob);
ft_user_module(blob);
ft_eth(blob); ft_eth(blob);
return 0; return 0;