From: Neil Armstrong Date: Fri, 27 Nov 2020 17:35:09 +0100 Subject: [PATCH 2/2] meson: Add soc_rev to environment In-Reply-To: References: <537d604eeb14149783c1bb398af9f4c9a82374d0.1606492351.git.stefan@agner.ch> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 27/11/2020 17:28, Stefan Agner wrote: > From: Pascal Vizeli > > Add SoC revision to environment. This can be useful to select the > correct device tree at runtime (N2/N2+). > > Signed-off-by: Pascal Vizeli > Signed-off-by: Stefan Agner > --- > > arch/arm/include/asm/arch-meson/boot.h | 4 ++++ > arch/arm/mach-meson/board-info.c | 12 ++++++++++++ > board/amlogic/odroid-n2/odroid-n2.c | 5 +++++ > 3 files changed, 21 insertions(+) > > diff --git a/arch/arm/include/asm/arch-meson/boot.h b/arch/arm/include/asm/arch-meson/boot.h > index a90fe55081..c67d12d06c 100644 > --- a/arch/arm/include/asm/arch-meson/boot.h > +++ b/arch/arm/include/asm/arch-meson/boot.h > @@ -7,6 +7,8 @@ > #ifndef __MESON_BOOT_H__ > #define __MESON_BOOT_H__ > > +#include > + > /* 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__ */ > diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c > index a0bcf38f29..90e7dfaa3c 100644 > --- a/arch/arm/mach-meson/board-info.c > +++ b/arch/arm/mach-meson/board-info.c > @@ -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)); > +} > diff --git a/board/amlogic/odroid-n2/odroid-n2.c b/board/amlogic/odroid-n2/odroid-n2.c > index caf7fd6810..dc0d933a39 100644 > --- a/board/amlogic/odroid-n2/odroid-n2.c > +++ b/board/amlogic/odroid-n2/odroid-n2.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > #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)) { > Reviewed-by: Neil Armstrong Applying it u-boot-amlogic-next Thanks ! Neil