From patchwork Fri Jun 16 15:21:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Detlev Casanova X-Patchwork-Id: 1795984 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=m08kD4yJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QjNDR0vxPz20X8 for ; Sat, 17 Jun 2023 01:21:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 017AA8624A; Fri, 16 Jun 2023 17:21:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="m08kD4yJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C03A8625C; Fri, 16 Jun 2023 17:21:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AF0388625C for ; Fri, 16 Jun 2023 17:21:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.mtl.collabora.ca (mtl.collabora.ca [66.171.169.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9DA266606F84; Fri, 16 Jun 2023 16:21:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686928882; bh=BKeiQdBFlMt3RTFWy44oiA7jtW1TXmseRUpVZpmhleY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m08kD4yJhoKpMivo8g8NCh/5w6FCiIq7/65RcCj6T/c+8rgABT4qDE4V1+jKgv9e6 ihkpBToWbanzvZnpWZuUVCqklNzq1zpq+POo6GQnNJmuHAk8UQTDNchDk5kXejx5D1 y5uJc2kf2G8kUR6XVx6oDrxcT0LGCjDjo8M4e2kg+iyrR+IKpfMUIBurEeazeo/Wvh YAcj+evECyTkS9AyUgHexBZwAQ10piSR2nY6gCUZ8BSFmeFrZt4v9ljE9NukAWTPu5 cK1EFKVkYXffebAiDJDxFgbAogl4nBk+328FS6znyt3MqHQscT0Gsr03NBVOjJdkkb Uo4OZJyo3o8Og== From: Detlev Casanova To: u-boot@lists.denx.de Cc: Marek Vasut , Hai Pham , Tam Nguyen , Detlev Casanova Subject: [PATCH v1 1/4] sysinfo: Add IDs for board id and revision Date: Fri, 16 Jun 2023 11:21:19 -0400 Message-Id: <20230616152122.588168-2-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230616152122.588168-1-detlev.casanova@collabora.com> References: <20230616152122.588168-1-detlev.casanova@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean These IDs will be used by the sysinfo command. The new IDs are: * SYSINFO_ID_BOARD_ID: The board ID as an integer * SYSINFO_ID_BOARD_REVISION: The board revision as a string Signed-off-by: Detlev Casanova --- include/sysinfo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/sysinfo.h b/include/sysinfo.h index b140d742e93..e2a7b10b6f6 100644 --- a/include/sysinfo.h +++ b/include/sysinfo.h @@ -47,6 +47,10 @@ enum sysinfo_id { /* For show_board_info() */ SYSINFO_ID_BOARD_MODEL, + /* For sysinfo command */ + SYSINFO_ID_BOARD_ID, + SYSINFO_ID_BOARD_REVISION, + /* First value available for downstream/board used */ SYSINFO_ID_USER = 0x1000, }; From patchwork Fri Jun 16 15:21:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Detlev Casanova X-Patchwork-Id: 1795985 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=UBSDmnhX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QjNDh0th5z20X8 for ; Sat, 17 Jun 2023 01:21:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 58D288626E; Fri, 16 Jun 2023 17:21:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="UBSDmnhX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D223D8471A; Fri, 16 Jun 2023 17:21:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 77F2E86262 for ; Fri, 16 Jun 2023 17:21:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.mtl.collabora.ca (mtl.collabora.ca [66.171.169.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 88D076606F88; Fri, 16 Jun 2023 16:21:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686928883; bh=r35oa7TqCT/W7UWa5YKr/CXCDd5yA5SfmGAyBOVFs38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBSDmnhXjn/zbtCurDH7fVmdSM21ZldnsXSgwRSNxyti4s/WTyaJ5uo/VXriEkM/t jcWVhgEll9ma2gqbyrq49t9ceIIWL7z1qtrrG//DI93HlCnjZesfqorwInF3G88A2Q tC/HplS/r5ll7xFyd5q1df4LKzEMSm2dyjNl9ljvVjLYK2dxExPUwGj5+HkdfnIaDI HXzN0ey+CCkrGAVFAY45STs+IABjCJCPizBoOpAj6OYIxBs1lQPLAM0TDI3d3/JKM2 G9QvOEXejZwz6Q9e+4nJGbsS0LPrsQO4YQlZ3DuXFJSj3bYwyxW3NZLs2/sqryPEpt EHZJzrAzWDGQw== From: Detlev Casanova To: u-boot@lists.denx.de Cc: Marek Vasut , Hai Pham , Tam Nguyen , Detlev Casanova Subject: [PATCH v1 2/4] cmd: Add a sysinfo command Date: Fri, 16 Jun 2023 11:21:20 -0400 Message-Id: <20230616152122.588168-3-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230616152122.588168-1-detlev.casanova@collabora.com> References: <20230616152122.588168-1-detlev.casanova@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The command is able to show different information for the running system: * Model name * Board ID * Revision This command can be used by boot shell scripts to select configurations depending on the specific running system. Signed-off-by: Detlev Casanova --- cmd/Kconfig | 6 +++ cmd/Makefile | 1 + cmd/sysinfo.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 cmd/sysinfo.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 365371fb511..ba4844853a1 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -210,6 +210,12 @@ config CMD_SBI help Display information about the SBI implementation. +config CMD_SYSINFO + bool "sysinfo" + depends on SYSINFO + help + Display information about the system. + endmenu menu "Boot commands" diff --git a/cmd/Makefile b/cmd/Makefile index 6c37521b4e2..ba4d6de9a1b 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -165,6 +165,7 @@ obj-$(CONFIG_CMD_SPI) += spi.o obj-$(CONFIG_CMD_STRINGS) += strings.o obj-$(CONFIG_CMD_SMC) += smccc.o obj-$(CONFIG_CMD_SYSBOOT) += sysboot.o +obj-$(CONFIG_CMD_SYSINFO) += sysinfo.o obj-$(CONFIG_CMD_STACKPROTECTOR_TEST) += stackprot_test.o obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o obj-$(CONFIG_CMD_TERMINAL) += terminal.o diff --git a/cmd/sysinfo.c b/cmd/sysinfo.c new file mode 100644 index 00000000000..31cb27ae46e --- /dev/null +++ b/cmd/sysinfo.c @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2023 + * Detlev Casanova + */ + +#include +#include +#include +#include + +static int get_sysinfo(struct udevice **dev) +{ + int ret = sysinfo_get(dev); + + if (ret) { + debug("Cannot get sysinfo: %d\n", ret); + return ret; + } + + ret = sysinfo_detect(*dev); + if (ret) { + debug("Cannot detect sysinfo: %d\n", ret); + return ret; + } + + return 0; +} + +static int do_sysinfo_model(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + char model[64]; + int ret = get_sysinfo(&dev); + + if (ret) + return ret; + + ret = sysinfo_get_str(dev, + SYSINFO_ID_BOARD_MODEL, + 64, + model); + + if (ret) { + debug("Cannot get sysinfo str: %d\n", ret); + return ret; + } + + if (argc == 2) + env_set(argv[1], model); + else + printf("%s\n", model); + + return 0; +} + +static int do_sysinfo_id(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + u32 board_id; + char board_id_str[5] = { '\0' }; + int ret = get_sysinfo(&dev); + + if (ret) + return ret; + + ret = sysinfo_get_int(dev, + SYSINFO_ID_BOARD_ID, + &board_id); + + if (ret) { + debug("Cannot get sysinfo int: %d\n", ret); + return ret; + } + + sprintf(board_id_str, "0x%02x", board_id); + if (argc == 2) + env_set(argv[1], board_id_str); + else + printf("%s\n", board_id_str); + + return 0; +} + +static int do_sysinfo_revision(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + char rev[4]; + int ret = get_sysinfo(&dev); + + if (ret) + return ret; + + ret = sysinfo_get_str(dev, + SYSINFO_ID_BOARD_REVISION, + 4, + rev); + + if (ret) { + debug("Cannot get sysinfo str: %d\n", ret); + return ret; + } + + if (argc == 2) + env_set(argv[1], rev); + else + printf("%s\n", rev); + + return 0; +} + +static char sysinfo_help_text[] = + "model - Show or set the board model in varname\n" + "sysinfo id - Show or set the board id in varname (in format 0xHH)\n" + "sysinfo revision - Show or set the board revision in varname"; + +U_BOOT_CMD_WITH_SUBCMDS(sysinfo, "System information", sysinfo_help_text, + U_BOOT_SUBCMD_MKENT(model, 2, 1, do_sysinfo_model), + U_BOOT_SUBCMD_MKENT(id, 2, 1, do_sysinfo_id), + U_BOOT_SUBCMD_MKENT(revision, 2, 1, do_sysinfo_revision), +); From patchwork Fri Jun 16 15:21:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Detlev Casanova X-Patchwork-Id: 1795986 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=ZirmFzV0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QjNDx5Nmsz20X8 for ; Sat, 17 Jun 2023 01:22:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4657786287; Fri, 16 Jun 2023 17:21:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="ZirmFzV0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C08218627B; Fri, 16 Jun 2023 17:21:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5FAA786248 for ; Fri, 16 Jun 2023 17:21:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.mtl.collabora.ca (mtl.collabora.ca [66.171.169.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 661056606F85; Fri, 16 Jun 2023 16:21:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686928884; bh=A+QogZCz25oCFxbo1UmBBBpWNS/3Uc/2omMAhpIdsX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZirmFzV04l3vLM4UybtfNs8AvUTehW5kCO8gApRe7o5rzokC7FKeNPMfkdP8yL6Ig 2fBpWvSVNZrIbxABSlksogO5m2ETtv+gnNWDzLjYcjSNYVfk2efdFEYFagYAazo3RM D/6vBNBgHzCQgsW6JwgsFLQxRE/xtEeqZIqeWpW7YkMbHMs3h4LF9MCiw8Erv0gVxI knBIu0N7gs755xShHm8Zho5z+ANdMzsEpn9qQinFHQ4LJQNNgjsWD8g8U+Ayi1nOM2 9bocW2qS8iU/Z+WRr8iUuRWBD8YTFk17LQ3Ra3PgnSAg0HJ3iEtQHvHW0V0z7B0SsO 79nEcYhYQiz7g== From: Detlev Casanova To: u-boot@lists.denx.de Cc: Marek Vasut , Hai Pham , Tam Nguyen , Detlev Casanova Subject: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION Date: Fri, 16 Jun 2023 11:21:21 -0400 Message-Id: <20230616152122.588168-4-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230616152122.588168-1-detlev.casanova@collabora.com> References: <20230616152122.588168-1-detlev.casanova@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Expose that information to the command shell to let scripts select the correct devicetree name. Signed-off-by: Detlev Casanova --- drivers/sysinfo/rcar3.c | 46 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c index 7b127986da7..89ad46c5422 100644 --- a/drivers/sysinfo/rcar3.c +++ b/drivers/sysinfo/rcar3.c @@ -32,6 +32,8 @@ */ struct sysinfo_rcar_priv { char boardmodel[64]; + u8 id; + char revision[4]; u8 val; }; @@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char * switch (id) { case SYSINFO_ID_BOARD_MODEL: - strncpy(val, priv->boardmodel, size); - val[size - 1] = '\0'; + strlcpy(val, priv->boardmodel, size); + break; + case SYSINFO_ID_BOARD_REVISION: + strlcpy(val, priv->revision, size); + break; + default: + return -EINVAL; + }; + + val[size - 1] = '\0'; + return 0; +} + +static int sysinfo_rcar_get_int(struct udevice *dev, int id, int *val) +{ + struct sysinfo_rcar_priv *priv = dev_get_priv(dev); + + switch (id) { + case SYSINFO_ID_BOARD_ID: + *val = priv->id; return 0; default: return -EINVAL; }; + } static const struct sysinfo_ops sysinfo_rcar_ops = { .detect = sysinfo_rcar_detect, .get_str = sysinfo_rcar_get_str, + .get_int = sysinfo_rcar_get_int, }; static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) @@ -83,7 +105,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Salvator-X%s board rev %c.%c", salvator_xs ? "S" : "", rev_major, rev_minor); - return; + break; case BOARD_STARTER_KIT: if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */ rev_major = (board_rev & BIT(0)) ? '3' : '1'; @@ -92,7 +114,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Starter Kit board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_STARTER_KIT_PRE: if (!(board_rev & ~3)) { /* Only rev 0..3 is valid */ rev_major = (board_rev & BIT(1)) ? '2' : '1'; @@ -101,7 +123,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Starter Kit Premier board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_EAGLE: if (!board_rev) { /* Only rev 0 is valid */ rev_major = '1'; @@ -110,7 +132,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Eagle board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_EBISU_4D: ebisu_4d = true; fallthrough; @@ -122,7 +144,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Ebisu%s board rev %c.%c", ebisu_4d ? "-4D" : "", rev_major, rev_minor); - return; + break; case BOARD_DRAAK: if (!board_rev) { /* Only rev 0 is valid */ rev_major = '1'; @@ -131,7 +153,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Draak board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_KRIEK: if (!board_rev) { /* Only rev 0 is valid */ rev_major = '1'; @@ -140,7 +162,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Kriek board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_CONDOR_I: condor_i = true; fallthrough; @@ -152,13 +174,17 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Condor%s board rev %c.%c", condor_i ? "-I" : "", rev_major, rev_minor); - return; + break; default: snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas -Unknown- board rev ?.?"); priv->val = 0xff; return; } + + snprintf(priv->revision, sizeof(priv->revision), "%c.%c", rev_major, + rev_minor); + priv->id = board_id; } static int sysinfo_rcar_probe(struct udevice *dev) From patchwork Fri Jun 16 15:21:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Detlev Casanova X-Patchwork-Id: 1795987 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=XO+ZOpCX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QjNFB5h7qz20X8 for ; Sat, 17 Jun 2023 01:22:22 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F9C0862AA; Fri, 16 Jun 2023 17:21:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="XO+ZOpCX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC46586248; Fri, 16 Jun 2023 17:21:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3963B8624A for ; Fri, 16 Jun 2023 17:21:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.mtl.collabora.ca (mtl.collabora.ca [66.171.169.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 459AD6606F89; Fri, 16 Jun 2023 16:21:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686928884; bh=mwJanQCLHJT5Kl8gO91q7AaET1u6IkHZxlUEh3AP3Jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XO+ZOpCXzBaPI9MO9iabdVyL139XF2ez6YruJqaBYi+Ipy1DY2vSWwZWsDn++4n6h zAcEqJFC1QfRlHrxFGHuQpw9LDzr2bLeGvxoCFjUz2swpaEno1YmaEzw7PifaZQUG2 PpVIyzhGaucsMWtHjcarCCjHUGtJ0h/PMdl8vwuWqY+KzvKxJspNk/PGqL0sryB3yR rk6n5vIwzuSmDy1y12dhHN139retdIXUhWiioGLpFuPD1sw6SN2g57NNF+CGP46Sdw I7hpKqibT/deGS0tjL0KFWT3ecWtIP0oKjYawZt5tmIk24/fE86HmxmyGl1by7U35A X4LtNlix/zzwQ== From: Detlev Casanova To: u-boot@lists.denx.de Cc: Marek Vasut , Hai Pham , Tam Nguyen , Detlev Casanova Subject: [PATCH v1 4/4] configs: rcar3: Add shell function to select the linux devicetree Date: Fri, 16 Jun 2023 11:21:22 -0400 Message-Id: <20230616152122.588168-5-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230616152122.588168-1-detlev.casanova@collabora.com> References: <20230616152122.588168-1-detlev.casanova@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This function uses the sysinfo command to determine which linux device tree is selected for the running board. Signed-off-by: Detlev Casanova --- configs/rcar3_ulcb_defconfig | 1 + include/configs/rcar-gen3-common.h | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configs/rcar3_ulcb_defconfig b/configs/rcar3_ulcb_defconfig index b8fdb5e3826..bb5f8f742ea 100644 --- a/configs/rcar3_ulcb_defconfig +++ b/configs/rcar3_ulcb_defconfig @@ -47,6 +47,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +CONFIG_CMD_SYSINFO=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="r8a77950-ulcb-u-boot r8a77960-ulcb-u-boot r8a77965-ulcb-u-boot" CONFIG_MULTI_DTB_FIT_LZO=y diff --git a/include/configs/rcar-gen3-common.h b/include/configs/rcar-gen3-common.h index 213caa75238..b278eb85a81 100644 --- a/include/configs/rcar-gen3-common.h +++ b/include/configs/rcar-gen3-common.h @@ -33,6 +33,13 @@ /* ENV setting */ #define CFG_EXTRA_ENV_SETTINGS \ - "bootm_size=0x10000000\0" + "bootm_size=0x10000000\0" \ + "set_board_fdt=sysinfo revision board_rev; " \ + "sysinfo id board_id; " \ + "if test ${board_rev} = 2.1 && test ${board_id} = 0x0b; then " \ + "setenv fdtfile renesas/r8a779m1-ulcb.dtb; " \ + "elif test ${board_rev} = 2.0 && test ${board_id} = 0x0b; then "\ + "setenv fdtfile renesas/r8a77951-ulcb.dtb; " \ + "fi\0" \ #endif /* __RCAR_GEN3_COMMON_H */