From 34e91fa6e16b57c98143fb1df36bd2d838688eb3 Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Fri, 6 Jul 2018 20:27:10 +0200 Subject: [PATCH] hancock: set board version in device-tree --- board/nm/hancock/board.c | 33 +++++++++++++++++++++++++++++--- include/configs/am335x_hancock.h | 2 ++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/board/nm/hancock/board.c b/board/nm/hancock/board.c index 76a090a2be..aad48bfe0c 100644 --- a/board/nm/hancock/board.c +++ b/board/nm/hancock/board.c @@ -34,13 +34,13 @@ #include #include #include +#include #include "../common/bdparser.h" #include "../common/board_descriptor.h" #include "board.h" #include "da9063.h" #include "sja1105.h" -#include "fileaccess.h" DECLARE_GLOBAL_DATA_PTR; @@ -369,7 +369,7 @@ static void init_pmic_spl(void) bus = da9063_claim_i2c_bus(); - /* Workaround for pre v1.3 config (reports ID 0x3e) */ + /* Workaround for pre v1.3 config (reports ID 0x3e -> 3.14) */ rc = da9063_get_reg(PMIC_REG_CONFIG_ID, &val); if (!rc && (val == 0x3E)) { printf("Detected pre v1.3 PMIC config. Fixing registers\n"); @@ -836,7 +836,6 @@ static void check_reset_button(void) int board_late_init(void) { - #if !defined(CONFIG_SPL_BUILD) if (read_eeprom() < 0) { puts("Could not get board ID.\n"); @@ -1010,3 +1009,31 @@ int board_fit_config_name_match(const char *name) return 0; } #endif + +#if defined(CONFIG_OF_BOARD_SETUP) + +static void ft_hw_version(void *blob) +{ + int node_offset; + int hw_ver, hw_rev, hw_patch; + char hw_version[16]; + + bd_get_hw_version(&hw_ver, &hw_rev); + bd_get_hw_patch(&hw_patch); + + snprintf(hw_version, sizeof(hw_version), "%d.%d.%d", hw_ver, hw_rev, hw_patch); + + node_offset = fdt_path_offset(blob, "/"); + if (node_offset != -1) { + fdt_setprop_string(blob, node_offset, "nm,carrierboard,version", hw_version); + } +} + +int ft_board_setup(void *blob, bd_t *bd) +{ + ft_hw_version(blob); + + return 0; +} + +#endif diff --git a/include/configs/am335x_hancock.h b/include/configs/am335x_hancock.h index 5e7e602dc3..189112a974 100644 --- a/include/configs/am335x_hancock.h +++ b/include/configs/am335x_hancock.h @@ -230,6 +230,8 @@ #define CONFIG_CMD_PXE +#define CONFIG_OF_BOARD_SETUP + /* SPL command is not needed */ #undef CONFIG_CMD_SPL