]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
meson: Add soc_rev to environment
authorPascal Vizeli <pvizeli@syshack.ch>
Fri, 27 Nov 2020 16:28:21 +0000 (17:28 +0100)
committerNeil Armstrong <narmstrong@baylibre.com>
Mon, 11 Jan 2021 13:59:54 +0000 (14:59 +0100)
Add SoC revision to environment. This can be useful to select the
correct device tree at runtime (N2/N2+).

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
arch/arm/include/asm/arch-meson/boot.h
arch/arm/mach-meson/board-info.c
board/amlogic/odroid-n2/odroid-n2.c

index a90fe55081c0d338f4d4a0087a63d18511117af1..c67d12d06c90b77fb5598aa1e17fae39514bb8fc 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef __MESON_BOOT_H__
 #define __MESON_BOOT_H__
 
+#include <linux/types.h>
+
 /* Boot device */
 #define BOOT_DEVICE_RESERVED    0
 #define BOOT_DEVICE_EMMC        1
@@ -17,4 +19,6 @@
 
 int meson_get_boot_device(void);
 
+int meson_get_soc_rev(char *buff, size_t buff_len);
+
 #endif /* __MESON_BOOT_H__ */
index a0bcf38f29f304a3a437c2280397fe9aafd366ba..90e7dfaa3ce9f89caae783a3e64896bffe0b548c 100644 (file)
@@ -187,3 +187,15 @@ int show_board_info(void)
 
        return 0;
 }
+
+int meson_get_soc_rev(char *buff, size_t buff_len)
+{
+       unsigned int socinfo;
+
+       socinfo = get_socinfo();
+       if (!socinfo)
+               return -1;
+
+       /* Write SoC info */
+       return snprintf(buff, buff_len, "%x", socinfo_to_minor(socinfo));
+}
index caf7fd68100708b578483a45d38bb25bcc484b70..dc0d933a39e6f6cd98d13dd2bd9828dfe2f1d8a8 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <asm/arch/sm.h>
 #include <asm/arch/eth.h>
+#include <asm/arch/boot.h>
 
 #define EFUSE_MAC_OFFSET       20
 #define EFUSE_MAC_SIZE         12
@@ -23,6 +24,10 @@ int misc_init_r(void)
        char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
        ssize_t len;
 
+       if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG) &&
+           meson_get_soc_rev(tmp, sizeof(tmp)) > 0)
+               env_set("soc_rev", tmp);
+
        meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
        if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {