From: narmstrong@baylibre.com (Neil Armstrong)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH u-boot 2/2] ARM: meson: Add cpu info display for GX SoCs
Date: Mon, 9 Apr 2018 15:47:46 +0200 [thread overview]
Message-ID: <492995cc-3679-54a5-cc47-4eed68f11da5@baylibre.com> (raw)
In-Reply-To: <20180404204953.GA12368@gmail.com>
On 04/04/2018 22:49, Beniamino Galvani wrote:
> On Wed, Mar 28, 2018 at 11:54:37AM +0200, Neil Armstrong wrote:
>> 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 for the Linux meson-gx-socinfo driver and adapted
>> to U-Boot printing.
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>> arch/arm/include/asm/arch-meson/gx.h | 1 +
>> arch/arm/mach-meson/Makefile | 2 +-
>> arch/arm/mach-meson/cpu_info.c | 105 +++++++++++++++++++++++++++++++++++
>> configs/khadas-vim_defconfig | 2 +-
>> configs/libretech-cc_defconfig | 2 +-
>> configs/odroid-c2_defconfig | 2 +-
>> configs/odroid_defconfig | 1 +
>> configs/p212_defconfig | 2 +-
>> 8 files changed, 112 insertions(+), 5 deletions(-)
>> create mode 100644 arch/arm/mach-meson/cpu_info.c
>>
>> diff --git a/arch/arm/include/asm/arch-meson/gx.h b/arch/arm/include/asm/arch-meson/gx.h
>> index 7930efd..6d5b4ea 100644
>> --- a/arch/arm/include/asm/arch-meson/gx.h
>> +++ b/arch/arm/include/asm/arch-meson/gx.h
>> @@ -17,6 +17,7 @@
>> /* Always-On Peripherals registers */
>> #define GX_AO_ADDR(off) (GX_AOBUS_BASE + ((off) << 2))
>>
>> +#define GX_AO_SEC_SD_CFG8 GX_AO_ADDR(0x88)
>> #define GX_AO_SEC_GP_CFG0 GX_AO_ADDR(0x90)
>> #define GX_AO_SEC_GP_CFG3 GX_AO_ADDR(0x93)
>> #define GX_AO_SEC_GP_CFG4 GX_AO_ADDR(0x94)
>> diff --git a/arch/arm/mach-meson/Makefile b/arch/arm/mach-meson/Makefile
>> index b4e8dde..5a01ff0 100644
>> --- a/arch/arm/mach-meson/Makefile
>> +++ b/arch/arm/mach-meson/Makefile
>> @@ -4,4 +4,4 @@
>> # SPDX-License-Identifier: GPL-2.0+
>> #
>>
>> -obj-y += board.o sm.o eth.o
>> +obj-y += board.o sm.o eth.o cpu_info.o
>> diff --git a/arch/arm/mach-meson/cpu_info.c b/arch/arm/mach-meson/cpu_info.c
>> new file mode 100644
>> index 0000000..657768f
>> --- /dev/null
>> +++ b/arch/arm/mach-meson/cpu_info.c
>> @@ -0,0 +1,105 @@
>> +/*
>> + * Copyright (C) 2018 BayLibre, SAS
>> + * Author: Neil Armstrong <narmstrong@baylibre.com>
>> + *
>> + * SPDX-License-Identifier: GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <asm/io.h>
>> +#include <linux/bitfield.h>
>> +#include <asm/arch/gx.h>
>> +
>> +#ifdef CONFIG_DISPLAY_CPUINFO
>> +
>> +#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 },
>> +};
>> +
>> +static const struct meson_gx_package_id {
>> + const char *name;
>> + unsigned int major_id;
>> + unsigned int pack_id;
>> +} soc_packages[] = {
>> + { "S905", 0x1f, 0 },
>> + { "S905M", 0x1f, 0x20 },
>> + { "S905D", 0x21, 0 },
>> + { "S905X", 0x21, 0x80 },
>> + { "S905L", 0x21, 0xc0 },
>> + { "S905M2", 0x21, 0xe0 },
>> + { "S912", 0x22, 0 },
>> +};
>> +
>> +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 print_cpuinfo(void)
>> +{
>> + u32 socinfo = readl(GX_AO_SEC_SD_CFG8);
>
> Perhaps, add a blank line between declarations and code? checkpatch
> issues a warning about this.
Ok
>
>> + printf("CPU: Amlogic Meson %s (%s) rev %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;
>> +}
>> +#endif /* CONFIG_DISPLAY_CPUINFO */
>> diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig
>> index a0b3f8d..970d373 100644
>> --- a/configs/khadas-vim_defconfig
>> +++ b/configs/khadas-vim_defconfig
>> @@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" khadas-vim"
>> CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-khadas-vim"
>> CONFIG_DEBUG_UART=y
>> CONFIG_OF_BOARD_SETUP=y
>> -# CONFIG_DISPLAY_CPUINFO is not set
>> +CONFIG_DISPLAY_CPUINFO=y
>> # CONFIG_DISPLAY_BOARDINFO is not set
>> # CONFIG_CMD_BDI is not set
>> # CONFIG_CMD_IMI is not set
>> diff --git a/configs/libretech-cc_defconfig b/configs/libretech-cc_defconfig
>> index a7177b9..cfbba30 100644
>> --- a/configs/libretech-cc_defconfig
>> +++ b/configs/libretech-cc_defconfig
>> @@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" libretech-cc"
>> CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc"
>> CONFIG_DEBUG_UART=y
>> CONFIG_OF_BOARD_SETUP=y
>> -# CONFIG_DISPLAY_CPUINFO is not set
>> +CONFIG_DISPLAY_CPUINFO=y
>> # CONFIG_DISPLAY_BOARDINFO is not set
>> # CONFIG_CMD_BDI is not set
>> # CONFIG_CMD_IMI is not set
>> diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig
>> index 49461aa..657b647 100644
>> --- a/configs/odroid-c2_defconfig
>> +++ b/configs/odroid-c2_defconfig
>> @@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" odroid-c2"
>> CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-odroidc2"
>> CONFIG_DEBUG_UART=y
>> CONFIG_OF_BOARD_SETUP=y
>> -# CONFIG_DISPLAY_CPUINFO is not set
>> +CONFIG_DISPLAY_CPUINFO=y
>> # CONFIG_DISPLAY_BOARDINFO is not set
>> # CONFIG_CMD_BDI is not set
>> # CONFIG_CMD_IMI is not set
>> diff --git a/configs/odroid_defconfig b/configs/odroid_defconfig
>> index 810874d..251bf38 100644
>> --- a/configs/odroid_defconfig
>> +++ b/configs/odroid_defconfig
>> @@ -56,3 +56,4 @@ CONFIG_USB_HOST_ETHER=y
>> CONFIG_USB_ETHER_SMSC95XX=y
>> CONFIG_LIB_HW_RAND=y
>> CONFIG_ERRNO_STR=y
>> +CONFIG_DISPLAY_CPUINFO=y
>
> Odroid is not an Amlogic board.
Oops, will remove it.
>
> With these 2 issues fixed: Reviewed-by: Beniamino Galvani <b.galvani@gmail.com>
>
> Beniamino
>
next prev parent reply other threads:[~2018-04-09 13:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-28 9:54 [PATCH u-boot 0/2] Cleanup for Amlogic GX SoCs Neil Armstrong
2018-03-28 9:54 ` [PATCH u-boot 1/2] ARM: meson: rename GXBB to GX Neil Armstrong
2018-04-04 20:40 ` Beniamino Galvani
2018-04-09 13:48 ` Neil Armstrong
2018-03-28 9:54 ` [PATCH u-boot 2/2] ARM: meson: Add cpu info display for GX SoCs Neil Armstrong
2018-04-04 20:49 ` Beniamino Galvani
2018-04-09 13:47 ` Neil Armstrong [this message]
2018-04-08 13:50 ` Simon Glass
2018-04-09 13:48 ` Neil Armstrong
2018-04-10 13:51 ` Neil Armstrong
2018-04-10 14:37 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=492995cc-3679-54a5-cc47-4eed68f11da5@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=linus-amlogic@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox