From patchwork Wed Mar 28 09:54:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 892056 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="jhPfWsKA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40B3DZ2VY1z9s0y for ; Wed, 28 Mar 2018 20:56:14 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EA1C8C21FF7; Wed, 28 Mar 2018 09:55:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 55614C220B0; Wed, 28 Mar 2018 09:54:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C85A8C220A8; Wed, 28 Mar 2018 09:54:48 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by lists.denx.de (Postfix) with ESMTPS id 16120C22052 for ; Wed, 28 Mar 2018 09:54:45 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id z73so1644894wrb.0 for ; Wed, 28 Mar 2018 02:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ASOn3i71cfoCJHgraEws+UKutUsLxwZIc++Q6d3rKPE=; b=jhPfWsKAw/kua44DOHKlLIezmiGUufEbH389nf05HOvjon1SbYQ27PJ5S0GQ7uPDqw b478aQ7uEX0kcB7buii12XvJSaxMs4F06ElAlEC5KTpZM91L47T9yrpY7z7xpcDWCC5k vCZF9L7ytUdheXfbjHIqBUYvsP3GLT/BjlVDZqMMv0DH5Oij4C3FEIIVXuooTjtEr/R4 GLDs5Z1eHL82Krh6bJtVwXvuM3E9eWuq4c5waxwQZdIljJMbN1pBa+UJvZYDGRHFSL+C pjuLiD4QMfKMd3ki31Rb37NcV/0AiKGrwBvoeXMH9zqO+ZM1gavM38wMybsdMp2GGQOo Ympg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ASOn3i71cfoCJHgraEws+UKutUsLxwZIc++Q6d3rKPE=; b=L1DxiK6YM7kI+DHOjFxexdDPldeuoTDw554v+gSUOiMYXmRsxjkl44oRP4UpAmezXk CAinXyZ/QmDUhbdJ0fKwi3Y1+ZDSrHOFd9Lwymtv50Kkcm4J4ioFS0vsbdmturguI1QH tAhrEkHtTA4k31qCIAYV+rc6DrRWrkFDmskTlkKtiOA26JNb7n+A4/+wLRd+rUJl+kn3 PRqv1jMxwlhh+PTJ6r5YwVm3FV+WJSWpic1zhx6DxnJcvi0/3+DCcRLugfAk/l8xksWU nPyz5AlxaKkm4qN53LPLwN7M367MKjAVPjri4zzDqsK/Hamk8wQhnjFByCiC86K+wY3j Fj5Q== X-Gm-Message-State: AElRT7HW3bt3jaMID3cLJr3Wf5CyGD5bEv5oxVoAOddw1xTWghfHrehX 2UpQi7ZViuE3V4izlXNTx/CplezHWkU= X-Google-Smtp-Source: AIpwx4+dttiBZnMZa52RFadFgwh4bP39sjr5YQvdENxT3+G82YS4G6pRvtYYA9Sk/fia8H0fQ/mMgQ== X-Received: by 10.223.177.213 with SMTP id r21mr2418628wra.89.1522230884308; Wed, 28 Mar 2018 02:54:44 -0700 (PDT) Received: from bender.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id g4sm4739679wrd.1.2018.03.28.02.54.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Mar 2018 02:54:43 -0700 (PDT) From: Neil Armstrong To: u-boot@lists.denx.de Date: Wed, 28 Mar 2018 11:54:37 +0200 Message-Id: <1522230877-21267-3-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522230877-21267-1-git-send-email-narmstrong@baylibre.com> References: <1522230877-21267-1-git-send-email-narmstrong@baylibre.com> Cc: trini@konsulko.com, linux-amlogic@lists.infradead.org Subject: [U-Boot] [PATCH u-boot 2/2] ARM: meson: Add cpu info display for GX SoCs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "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 for the Linux meson-gx-socinfo driver and adapted to U-Boot printing. Signed-off-by: Neil Armstrong --- 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 + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include + +#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); + 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 diff --git a/configs/p212_defconfig b/configs/p212_defconfig index d276e06..4302977 100644 --- a/configs/p212_defconfig +++ b/configs/p212_defconfig @@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" p212" CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-p212" 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