Skip to contentSkip to conversation

ARM: meson: isolate loading of socinfo

PATCH New Stefan Agner 2 participants 4 messages Nov 27, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: meson: isolate loading of socinfo

Move loading of socinfo into a separate function so the value can be reused later.

---

 arch/arm/mach-meson/board-info.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm/mach-meson/board-info.c +13 -1
index e61d1adb10..a0bcf38f29 100644
@@ -131,7 +131,7 @@ static void print_board_model(void)
 	printf("Model: %s\n", model ? model : "Unknown");
 }
 
-int show_board_info(void)
+static unsigned int get_socinfo(void)
 {
 	struct regmap *regmap;
 	int nodeoffset, ret;
@@ -163,8 +163,20 @@ int show_board_info(void)
 		return 0;
 	}
 
+	return socinfo;
+}
+
+int show_board_info(void)
+{
+	unsigned int socinfo;
+
 	/* print board information */
 	print_board_model();
+
+	socinfo = get_socinfo();
+	if (!socinfo)
+		return 0;
+
 	printf("SoC:   Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
 	       socinfo_to_soc_id(socinfo),
 	       socinfo_to_package_id(socinfo),
Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 meson: Add soc_rev to environment

From: Pascal Vizeli <[email protected]>

Add SoC revision to environment. This can be useful to select the correct device tree at runtime (N2/N2+).

---

 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(+)
arch/arm/include/asm/arch-meson/boot.h +4 -0
index a90fe55081..c67d12d06c 100644
@@ -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__ */
arch/arm/mach-meson/board-info.c +12 -0
index a0bcf38f29..90e7dfaa3c 100644
@@ -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));
+}
board/amlogic/odroid-n2/odroid-n2.c +5 -0
index caf7fd6810..dc0d933a39 100644
@@ -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)) {
Signature · 1 line
2.29.2
#2 lore raw

PATCH 2/2 meson: Add soc_rev to environment

Quoted 68 lines · Stefan Agner

From: Pascal Vizeli <[email protected]>

Add SoC revision to environment. This can be useful to select the correct device tree at runtime (N2/N2+).

---

 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(+)
arch/arm/include/asm/arch-meson/boot.h +4 -0
index a90fe55081..c67d12d06c 100644
@@ -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__ */
arch/arm/mach-meson/board-info.c +12 -0
index a0bcf38f29..90e7dfaa3c 100644
@@ -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));
+}
board/amlogic/odroid-n2/odroid-n2.c +1 -0
index caf7fd6810..dc0d933a39 100644
@@ -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

board/amlogic/odroid-n2/odroid-n2.c int misc_init_r(void) · line 33

Quoted 10 lines
board/amlogic/odroid-n2/odroid-n2.c +4 -0
@@ -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)) {

Applying it u-boot-amlogic-next

Thanks !

Neil

#3 lore raw

PATCH 1/2 ARM: meson: isolate loading of socinfo

In reply to Stefan Agner
Quoted 34 lines · Stefan Agner

Move loading of socinfo into a separate function so the value can be reused later.

---

 arch/arm/mach-meson/board-info.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm/mach-meson/board-info.c +8 -1
index e61d1adb10..a0bcf38f29 100644
@@ -131,7 +131,7 @@ static void print_board_model(void)
 	printf("Model: %s\n", model ? model : "Unknown");
 }
 
-int show_board_info(void)
+static unsigned int get_socinfo(void)
 {
 	struct regmap *regmap;
 	int nodeoffset, ret;
@@ -163,8 +163,20 @@ int show_board_info(void)
 		return 0;
 	}
 
+	return socinfo;
+}
+
+int show_board_info(void)
+{
+	unsigned int socinfo;
+

arch/arm/mach-meson/board-info.c int show_board_info(void) · line 182

Quoted 10 lines
arch/arm/mach-meson/board-info.c +5 -0
 	/* print board information */
 	print_board_model();
+
+	socinfo = get_socinfo();
+	if (!socinfo)
+		return 0;
+
 	printf("SoC:   Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
 	       socinfo_to_soc_id(socinfo),
 	       socinfo_to_package_id(socinfo),

Applying it u-boot-amlogic-next

Thanks !

Neil