All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ARM: meson: display Amlogic SoC Information
@ 2019-03-19 14:26 Julien Masson
  2019-03-23 10:02   ` Neil Armstrong
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Masson @ 2019-03-19 14:26 UTC (permalink / raw)
  To: u-boot

The Amlogic SoCs have a registers containing the die revision
and packaging type to determine the SoC family and package marketing
name like S905X for the GXL SoC Family.

This code is taken from the Linux meson-gx-socinfo driver and adapted
to U-Boot printing.

Signed-off-by: Julien Masson <jmasson@baylibre.com>
---
 arch/arm/mach-meson/board-common.c | 140 +++++++++++++++++++++++++++++++++++++
 configs/khadas-vim_defconfig       |   2 +-
 configs/libretech-cc_defconfig     |   2 +-
 configs/odroid-c2_defconfig        |   2 +-
 configs/p212_defconfig             |   2 +-
 5 files changed, 144 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c
index 8c41301..e766ebc 100644
--- a/arch/arm/mach-meson/board-common.c
+++ b/arch/arm/mach-meson/board-common.c
@@ -7,11 +7,59 @@
 #include <asm/arch/boot.h>
 #include <linux/libfdt.h>
 #include <linux/err.h>
+#include <linux/bitfield.h>
 #include <asm/arch/mem.h>
 #include <asm/arch/sm.h>
 #include <asm/armv8/mmu.h>
+#include <asm/io.h>
 #include <asm/unaligned.h>
 #include <efi_loader.h>
+#include <dm.h>
+#include <syscon.h>
+#include <regmap.h>
+
+#define AO_SEC_SD_CFG8		0xe0
+#define AO_SEC_SOCINFO_OFFSET	AO_SEC_SD_CFG8
+
+#define SOCINFO_MAJOR	GENMASK(31, 24)
+#define SOCINFO_PACK	GENMASK(23, 16)
+#define SOCINFO_MINOR	GENMASK(15, 8)
+#define SOCINFO_MISC	GENMASK(7, 0)
+
+static const struct meson_gx_soc_id {
+	const char *name;
+	unsigned int id;
+} soc_ids[] = {
+	{ "GXBB",   0x1f },
+	{ "GXTVBB", 0x20 },
+	{ "GXL",    0x21 },
+	{ "GXM",    0x22 },
+	{ "TXL",    0x23 },
+	{ "TXLX",   0x24 },
+	{ "AXG",    0x25 },
+	{ "GXLX",   0x26 },
+	{ "TXHD",   0x27 },
+};
+
+static const struct meson_gx_package_id {
+	const char *name;
+	unsigned int major_id;
+	unsigned int pack_id;
+} soc_packages[] = {
+	{ "S905",   0x1f, 0 },
+	{ "S905H",  0x1f, 0x13 },
+	{ "S905M",  0x1f, 0x20 },
+	{ "S905D",  0x21, 0 },
+	{ "S905X",  0x21, 0x80 },
+	{ "S905W",  0x21, 0xa0 },
+	{ "S905L",  0x21, 0xc0 },
+	{ "S905M2", 0x21, 0xe0 },
+	{ "S912",   0x22, 0 },
+	{ "962X",   0x24, 0x10 },
+	{ "962E",   0x24, 0x20 },
+	{ "A113X",  0x25, 0x37 },
+	{ "A113D",  0x25, 0x22 },
+};
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -115,3 +163,95 @@ void reset_cpu(ulong addr)
 {
 	psci_system_reset();
 }
+
+static inline unsigned int socinfo_to_major(u32 socinfo)
+{
+	return FIELD_GET(SOCINFO_MAJOR, socinfo);
+}
+
+static inline unsigned int socinfo_to_minor(u32 socinfo)
+{
+	return FIELD_GET(SOCINFO_MINOR, socinfo);
+}
+
+static inline unsigned int socinfo_to_pack(u32 socinfo)
+{
+	return FIELD_GET(SOCINFO_PACK, socinfo);
+}
+
+static inline unsigned int socinfo_to_misc(u32 socinfo)
+{
+	return FIELD_GET(SOCINFO_MISC, socinfo);
+}
+
+static const char *socinfo_to_package_id(u32 socinfo)
+{
+	unsigned int pack = socinfo_to_pack(socinfo) & 0xf0;
+	unsigned int major = socinfo_to_major(socinfo);
+	int i;
+
+	for (i = 0 ; i < ARRAY_SIZE(soc_packages) ; ++i) {
+		if (soc_packages[i].major_id == major &&
+		    soc_packages[i].pack_id == pack)
+			return soc_packages[i].name;
+	}
+
+	return "Unknown";
+}
+
+static const char *socinfo_to_soc_id(u32 socinfo)
+{
+	unsigned int id = socinfo_to_major(socinfo);
+	int i;
+
+	for (i = 0 ; i < ARRAY_SIZE(soc_ids) ; ++i) {
+		if (soc_ids[i].id == id)
+			return soc_ids[i].name;
+	}
+
+	return "Unknown";
+}
+
+int show_board_info(void)
+{
+	struct regmap *regmap;
+	int nodeoffset, ret;
+	ofnode node;
+	unsigned int socinfo;
+
+	/* find the offset of compatible node */
+	nodeoffset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
+						   "amlogic,meson-gx-ao-secure");
+	if (nodeoffset < 0)
+		return 0;
+
+	/* check if chip-id is available */
+	if (!fdt_getprop(gd->fdt_blob, nodeoffset, "amlogic,has-chip-id", NULL))
+		return 0;
+
+	/* get regmap from the syscon node */
+	node = offset_to_ofnode(nodeoffset);
+	regmap = syscon_node_to_regmap(node);
+	if (IS_ERR(regmap)) {
+		printf("%s: failed to get regmap\n", __func__);
+		return 0;
+	}
+
+	/* read soc info */
+	ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo);
+	if (ret && !socinfo) {
+		printf("%s: invalid chipid value\n", __func__);
+		return 0;
+	}
+
+	/* print board information */
+	printf("Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
+	       socinfo_to_soc_id(socinfo),
+	       socinfo_to_package_id(socinfo),
+	       socinfo_to_major(socinfo),
+	       socinfo_to_minor(socinfo),
+	       socinfo_to_pack(socinfo),
+	       socinfo_to_misc(socinfo));
+
+	return 0;
+}
diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig
index 6f1ad0e..aeec2be 100644
--- a/configs/khadas-vim_defconfig
+++ b/configs/khadas-vim_defconfig
@@ -11,7 +11,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_MISC_INIT_R=y
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_DISPLAY_BOARDINFO=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_ADC=y
diff --git a/configs/libretech-cc_defconfig b/configs/libretech-cc_defconfig
index d28c7ab..a1b9fd9 100644
--- a/configs/libretech-cc_defconfig
+++ b/configs/libretech-cc_defconfig
@@ -10,7 +10,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_MISC_INIT_R=y
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_DISPLAY_BOARDINFO=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_ADC=y
diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig
index 747da18..04904c2 100644
--- a/configs/odroid-c2_defconfig
+++ b/configs/odroid-c2_defconfig
@@ -10,7 +10,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_MISC_INIT_R=y
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_DISPLAY_BOARDINFO=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_GPIO=y
diff --git a/configs/p212_defconfig b/configs/p212_defconfig
index b048863..0422740 100644
--- a/configs/p212_defconfig
+++ b/configs/p212_defconfig
@@ -11,7 +11,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_MISC_INIT_R=y
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_DISPLAY_BOARDINFO=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_GPIO=y
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] ARM: meson: display Amlogic SoC Information
  2019-03-19 14:26 [U-Boot] [PATCH] ARM: meson: display Amlogic SoC Information Julien Masson
@ 2019-03-23 10:02   ` Neil Armstrong
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Armstrong @ 2019-03-23 10:02 UTC (permalink / raw)
  To: u-boot

Hi Julien,

First, please also CC to u-boot-amlogic at groups.io !

Le 19/03/2019 15:26, Julien Masson a écrit :
> The Amlogic SoCs have a registers containing the die revision
> and packaging type to determine the SoC family and package marketing
> name like S905X for the GXL SoC Family.
> 
> This code is taken from the Linux meson-gx-socinfo driver and adapted
> to U-Boot printing.
> 
> Signed-off-by: Julien Masson <jmasson@baylibre.com>
> ---
>  arch/arm/mach-meson/board-common.c | 140 +++++++++++++++++++++++++++++++++++++
>  configs/khadas-vim_defconfig       |   2 +-
>  configs/libretech-cc_defconfig     |   2 +-
>  configs/odroid-c2_defconfig        |   2 +-
>  configs/p212_defconfig             |   2 +-

Please add to all the Amlogic boards, including nanopi-k2, khadas-vim2 and s400

>  5 files changed, 144 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c
> index 8c41301..e766ebc 100644
> --- a/arch/arm/mach-meson/board-common.c
> +++ b/arch/arm/mach-meson/board-common.c
> @@ -7,11 +7,59 @@
>  #include <asm/arch/boot.h>
>  #include <linux/libfdt.h>
>  #include <linux/err.h>
> +#include <linux/bitfield.h>
>  #include <asm/arch/mem.h>
>  #include <asm/arch/sm.h>
>  #include <asm/armv8/mmu.h>
> +#include <asm/io.h>
>  #include <asm/unaligned.h>
>  #include <efi_loader.h>
> +#include <dm.h>
> +#include <syscon.h>
> +#include <regmap.h>
> +
> +#define AO_SEC_SD_CFG8		0xe0
> +#define AO_SEC_SOCINFO_OFFSET	AO_SEC_SD_CFG8
> +
> +#define SOCINFO_MAJOR	GENMASK(31, 24)
> +#define SOCINFO_PACK	GENMASK(23, 16)
> +#define SOCINFO_MINOR	GENMASK(15, 8)
> +#define SOCINFO_MISC	GENMASK(7, 0)
> +
> +static const struct meson_gx_soc_id {
> +	const char *name;
> +	unsigned int id;
> +} soc_ids[] = {
> +	{ "GXBB",   0x1f },
> +	{ "GXTVBB", 0x20 },
> +	{ "GXL",    0x21 },
> +	{ "GXM",    0x22 },
> +	{ "TXL",    0x23 },
> +	{ "TXLX",   0x24 },
> +	{ "AXG",    0x25 },
> +	{ "GXLX",   0x26 },
> +	{ "TXHD",   0x27 },
> +};
> +
> +static const struct meson_gx_package_id {
> +	const char *name;
> +	unsigned int major_id;
> +	unsigned int pack_id;
> +} soc_packages[] = {
> +	{ "S905",   0x1f, 0 },
> +	{ "S905H",  0x1f, 0x13 },
> +	{ "S905M",  0x1f, 0x20 },
> +	{ "S905D",  0x21, 0 },
> +	{ "S905X",  0x21, 0x80 },
> +	{ "S905W",  0x21, 0xa0 },
> +	{ "S905L",  0x21, 0xc0 },
> +	{ "S905M2", 0x21, 0xe0 },
> +	{ "S912",   0x22, 0 },
> +	{ "962X",   0x24, 0x10 },
> +	{ "962E",   0x24, 0x20 },
> +	{ "A113X",  0x25, 0x37 },
> +	{ "A113D",  0x25, 0x22 },
> +};

Can you handle the mask into this struct aswell like
https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/commit/?h=v5.2/drivers&id=dce47aed20c7de3ee2011b7a63e67f08e9dcfb5e ?

You should also add the new IDs like in :
https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/commit/?h=v5.2/drivers&id=65f80df58eb770b2b687c35142c113d1ad6fa415

>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -115,3 +163,95 @@ void reset_cpu(ulong addr)
>  {
>  	psci_system_reset();
>  }
> +
> +static inline unsigned int socinfo_to_major(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_MAJOR, socinfo);
> +}
> +
> +static inline unsigned int socinfo_to_minor(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_MINOR, socinfo);
> +}
> +
> +static inline unsigned int socinfo_to_pack(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_PACK, socinfo);
> +}
> +
> +static inline unsigned int socinfo_to_misc(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_MISC, socinfo);
> +}
> +
> +static const char *socinfo_to_package_id(u32 socinfo)
> +{
> +	unsigned int pack = socinfo_to_pack(socinfo) & 0xf0;
> +	unsigned int major = socinfo_to_major(socinfo);
> +	int i;
> +
> +	for (i = 0 ; i < ARRAY_SIZE(soc_packages) ; ++i) {
> +		if (soc_packages[i].major_id == major &&
> +		    soc_packages[i].pack_id == pack)
> +			return soc_packages[i].name;
> +	}
> +
> +	return "Unknown";
> +}
> +
> +static const char *socinfo_to_soc_id(u32 socinfo)
> +{
> +	unsigned int id = socinfo_to_major(socinfo);
> +	int i;
> +
> +	for (i = 0 ; i < ARRAY_SIZE(soc_ids) ; ++i) {
> +		if (soc_ids[i].id == id)
> +			return soc_ids[i].name;
> +	}
> +
> +	return "Unknown";
> +}
> +
> +int show_board_info(void)
> +{
> +	struct regmap *regmap;
> +	int nodeoffset, ret;
> +	ofnode node;
> +	unsigned int socinfo;
> +
> +	/* find the offset of compatible node */
> +	nodeoffset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
> +						   "amlogic,meson-gx-ao-secure");
> +	if (nodeoffset < 0)
> +		return 0;
> +
> +	/* check if chip-id is available */
> +	if (!fdt_getprop(gd->fdt_blob, nodeoffset, "amlogic,has-chip-id", NULL))
> +		return 0;
> +
> +	/* get regmap from the syscon node */
> +	node = offset_to_ofnode(nodeoffset);
> +	regmap = syscon_node_to_regmap(node);
> +	if (IS_ERR(regmap)) {
> +		printf("%s: failed to get regmap\n", __func__);
> +		return 0;
> +	}
> +
> +	/* read soc info */
> +	ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo);
> +	if (ret && !socinfo) {
> +		printf("%s: invalid chipid value\n", __func__);
> +		return 0;
> +	}
> +
> +	/* print board information */
> +	printf("Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
> +	       socinfo_to_soc_id(socinfo),
> +	       socinfo_to_package_id(socinfo),
> +	       socinfo_to_major(socinfo),
> +	       socinfo_to_minor(socinfo),
> +	       socinfo_to_pack(socinfo),
> +	       socinfo_to_misc(socinfo));

Can you also show the board model from DT like the original show_board_info() ?

> +
> +	return 0;
> +}

Looks good, but can you move this code to a separate C file, like board-info.c ?

> diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig
> index 6f1ad0e..aeec2be 100644
> --- a/configs/khadas-vim_defconfig
> +++ b/configs/khadas-vim_defconfig
> @@ -11,7 +11,7 @@ CONFIG_OF_BOARD_SETUP=y
>  CONFIG_CONSOLE_MUX=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_ADC=y
> diff --git a/configs/libretech-cc_defconfig b/configs/libretech-cc_defconfig
> index d28c7ab..a1b9fd9 100644
> --- a/configs/libretech-cc_defconfig
> +++ b/configs/libretech-cc_defconfig
> @@ -10,7 +10,7 @@ CONFIG_NR_DRAM_BANKS=1
>  CONFIG_OF_BOARD_SETUP=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_ADC=y
> diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig
> index 747da18..04904c2 100644
> --- a/configs/odroid-c2_defconfig
> +++ b/configs/odroid-c2_defconfig
> @@ -10,7 +10,7 @@ CONFIG_OF_BOARD_SETUP=y
>  CONFIG_CONSOLE_MUX=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_GPIO=y
> diff --git a/configs/p212_defconfig b/configs/p212_defconfig
> index b048863..0422740 100644
> --- a/configs/p212_defconfig
> +++ b/configs/p212_defconfig
> @@ -11,7 +11,7 @@ CONFIG_OF_BOARD_SETUP=y
>  CONFIG_CONSOLE_MUX=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_GPIO=y
> 

Thanks !!

Neil

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: meson: display Amlogic SoC Information
@ 2019-03-23 10:02   ` Neil Armstrong
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Armstrong @ 2019-03-23 10:02 UTC (permalink / raw)
  To: Julien Masson, u-boot; +Cc: Beniamino Galvani, Albert Aribaud, u-boot-amlogic

Hi Julien,

First, please also CC to u-boot-amlogic@groups.io !

Le 19/03/2019 15:26, Julien Masson a écrit :
> The Amlogic SoCs have a registers containing the die revision
> and packaging type to determine the SoC family and package marketing
> name like S905X for the GXL SoC Family.
> 
> This code is taken from the Linux meson-gx-socinfo driver and adapted
> to U-Boot printing.
> 
> Signed-off-by: Julien Masson <jmasson@baylibre.com>
> ---
>  arch/arm/mach-meson/board-common.c | 140 +++++++++++++++++++++++++++++++++++++
>  configs/khadas-vim_defconfig       |   2 +-
>  configs/libretech-cc_defconfig     |   2 +-
>  configs/odroid-c2_defconfig        |   2 +-
>  configs/p212_defconfig             |   2 +-

Please add to all the Amlogic boards, including nanopi-k2, khadas-vim2 and s400

>  5 files changed, 144 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c
> index 8c41301..e766ebc 100644
> --- a/arch/arm/mach-meson/board-common.c
> +++ b/arch/arm/mach-meson/board-common.c
> @@ -7,11 +7,59 @@
>  #include <asm/arch/boot.h>
>  #include <linux/libfdt.h>
>  #include <linux/err.h>
> +#include <linux/bitfield.h>
>  #include <asm/arch/mem.h>
>  #include <asm/arch/sm.h>
>  #include <asm/armv8/mmu.h>
> +#include <asm/io.h>
>  #include <asm/unaligned.h>
>  #include <efi_loader.h>
> +#include <dm.h>
> +#include <syscon.h>
> +#include <regmap.h>
> +
> +#define AO_SEC_SD_CFG8		0xe0
> +#define AO_SEC_SOCINFO_OFFSET	AO_SEC_SD_CFG8
> +
> +#define SOCINFO_MAJOR	GENMASK(31, 24)
> +#define SOCINFO_PACK	GENMASK(23, 16)
> +#define SOCINFO_MINOR	GENMASK(15, 8)
> +#define SOCINFO_MISC	GENMASK(7, 0)
> +
> +static const struct meson_gx_soc_id {
> +	const char *name;
> +	unsigned int id;
> +} soc_ids[] = {
> +	{ "GXBB",   0x1f },
> +	{ "GXTVBB", 0x20 },
> +	{ "GXL",    0x21 },
> +	{ "GXM",    0x22 },
> +	{ "TXL",    0x23 },
> +	{ "TXLX",   0x24 },
> +	{ "AXG",    0x25 },
> +	{ "GXLX",   0x26 },
> +	{ "TXHD",   0x27 },
> +};
> +
> +static const struct meson_gx_package_id {
> +	const char *name;
> +	unsigned int major_id;
> +	unsigned int pack_id;
> +} soc_packages[] = {
> +	{ "S905",   0x1f, 0 },
> +	{ "S905H",  0x1f, 0x13 },
> +	{ "S905M",  0x1f, 0x20 },
> +	{ "S905D",  0x21, 0 },
> +	{ "S905X",  0x21, 0x80 },
> +	{ "S905W",  0x21, 0xa0 },
> +	{ "S905L",  0x21, 0xc0 },
> +	{ "S905M2", 0x21, 0xe0 },
> +	{ "S912",   0x22, 0 },
> +	{ "962X",   0x24, 0x10 },
> +	{ "962E",   0x24, 0x20 },
> +	{ "A113X",  0x25, 0x37 },
> +	{ "A113D",  0x25, 0x22 },
> +};

Can you handle the mask into this struct aswell like
https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/commit/?h=v5.2/drivers&id=dce47aed20c7de3ee2011b7a63e67f08e9dcfb5e ?

You should also add the new IDs like in :
https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/commit/?h=v5.2/drivers&id=65f80df58eb770b2b687c35142c113d1ad6fa415

>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -115,3 +163,95 @@ void reset_cpu(ulong addr)
>  {
>  	psci_system_reset();
>  }
> +
> +static inline unsigned int socinfo_to_major(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_MAJOR, socinfo);
> +}
> +
> +static inline unsigned int socinfo_to_minor(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_MINOR, socinfo);
> +}
> +
> +static inline unsigned int socinfo_to_pack(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_PACK, socinfo);
> +}
> +
> +static inline unsigned int socinfo_to_misc(u32 socinfo)
> +{
> +	return FIELD_GET(SOCINFO_MISC, socinfo);
> +}
> +
> +static const char *socinfo_to_package_id(u32 socinfo)
> +{
> +	unsigned int pack = socinfo_to_pack(socinfo) & 0xf0;
> +	unsigned int major = socinfo_to_major(socinfo);
> +	int i;
> +
> +	for (i = 0 ; i < ARRAY_SIZE(soc_packages) ; ++i) {
> +		if (soc_packages[i].major_id == major &&
> +		    soc_packages[i].pack_id == pack)
> +			return soc_packages[i].name;
> +	}
> +
> +	return "Unknown";
> +}
> +
> +static const char *socinfo_to_soc_id(u32 socinfo)
> +{
> +	unsigned int id = socinfo_to_major(socinfo);
> +	int i;
> +
> +	for (i = 0 ; i < ARRAY_SIZE(soc_ids) ; ++i) {
> +		if (soc_ids[i].id == id)
> +			return soc_ids[i].name;
> +	}
> +
> +	return "Unknown";
> +}
> +
> +int show_board_info(void)
> +{
> +	struct regmap *regmap;
> +	int nodeoffset, ret;
> +	ofnode node;
> +	unsigned int socinfo;
> +
> +	/* find the offset of compatible node */
> +	nodeoffset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
> +						   "amlogic,meson-gx-ao-secure");
> +	if (nodeoffset < 0)
> +		return 0;
> +
> +	/* check if chip-id is available */
> +	if (!fdt_getprop(gd->fdt_blob, nodeoffset, "amlogic,has-chip-id", NULL))
> +		return 0;
> +
> +	/* get regmap from the syscon node */
> +	node = offset_to_ofnode(nodeoffset);
> +	regmap = syscon_node_to_regmap(node);
> +	if (IS_ERR(regmap)) {
> +		printf("%s: failed to get regmap\n", __func__);
> +		return 0;
> +	}
> +
> +	/* read soc info */
> +	ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo);
> +	if (ret && !socinfo) {
> +		printf("%s: invalid chipid value\n", __func__);
> +		return 0;
> +	}
> +
> +	/* print board information */
> +	printf("Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
> +	       socinfo_to_soc_id(socinfo),
> +	       socinfo_to_package_id(socinfo),
> +	       socinfo_to_major(socinfo),
> +	       socinfo_to_minor(socinfo),
> +	       socinfo_to_pack(socinfo),
> +	       socinfo_to_misc(socinfo));

Can you also show the board model from DT like the original show_board_info() ?

> +
> +	return 0;
> +}

Looks good, but can you move this code to a separate C file, like board-info.c ?

> diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig
> index 6f1ad0e..aeec2be 100644
> --- a/configs/khadas-vim_defconfig
> +++ b/configs/khadas-vim_defconfig
> @@ -11,7 +11,7 @@ CONFIG_OF_BOARD_SETUP=y
>  CONFIG_CONSOLE_MUX=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_ADC=y
> diff --git a/configs/libretech-cc_defconfig b/configs/libretech-cc_defconfig
> index d28c7ab..a1b9fd9 100644
> --- a/configs/libretech-cc_defconfig
> +++ b/configs/libretech-cc_defconfig
> @@ -10,7 +10,7 @@ CONFIG_NR_DRAM_BANKS=1
>  CONFIG_OF_BOARD_SETUP=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_ADC=y
> diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig
> index 747da18..04904c2 100644
> --- a/configs/odroid-c2_defconfig
> +++ b/configs/odroid-c2_defconfig
> @@ -10,7 +10,7 @@ CONFIG_OF_BOARD_SETUP=y
>  CONFIG_CONSOLE_MUX=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_GPIO=y
> diff --git a/configs/p212_defconfig b/configs/p212_defconfig
> index b048863..0422740 100644
> --- a/configs/p212_defconfig
> +++ b/configs/p212_defconfig
> @@ -11,7 +11,7 @@ CONFIG_OF_BOARD_SETUP=y
>  CONFIG_CONSOLE_MUX=y
>  CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
> -# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_DISPLAY_BOARDINFO=y
>  # CONFIG_CMD_BDI is not set
>  # CONFIG_CMD_IMI is not set
>  CONFIG_CMD_GPIO=y
> 

Thanks !!

Neil

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-23 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 14:26 [U-Boot] [PATCH] ARM: meson: display Amlogic SoC Information Julien Masson
2019-03-23 10:02 ` Neil Armstrong
2019-03-23 10:02   ` Neil Armstrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.