From patchwork Wed Feb 20 12:09:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Gerasimov X-Patchwork-Id: 1045308 X-Patchwork-Delegate: matthias.bgg@gmail.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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="h6rgyBgL"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 444Gs11Mynz9s71 for ; Wed, 20 Feb 2019 23:20:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E9CA8C21F78; Wed, 20 Feb 2019 12:19:53 +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=FREEMAIL_FROM, 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 E408EC21EB4; Wed, 20 Feb 2019 12:19:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 05BFBC21E70; Wed, 20 Feb 2019 12:18:51 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id B4A7DC22044 for ; Wed, 20 Feb 2019 12:18:42 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id w17so25667448wrn.12 for ; Wed, 20 Feb 2019 04:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DBozaX7okvGFIAv4ZXGqkmkza29aofnoabaji3y0MfM=; b=h6rgyBgLOxW2JHWUrl2X+KA/ugIC7kGN0vBU0DpxDl1iSzWq5C0j8H9MDRYGqxrnX9 wiinAC2ij0ZhwZCBoYR0dT21gtwIhyf9lmZI5zR1HzxqroVOcby5F082ULBYpsqgPwak Knlq7eGdCE2gZL7qiCaZPQTalzEWyn4bXv5KxRajxXhhmHa1bxKfS4V+ZXliPsuRGsoI fcxpMHXJZYjVclqGUIfwTvLW++lFGWwfbWGpxZCoXCP9cly3uDo9a/+5Gu61s5J8V+c6 8IVauAW9S4s2hYXFpmEYIHgw3JEoMUPTsCXhnOFe70buxDZnxHgxxEJ3gZb4BN7EOmce KQdw== 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:mime-version:content-transfer-encoding; bh=DBozaX7okvGFIAv4ZXGqkmkza29aofnoabaji3y0MfM=; b=qCwHU1Sg43KSXso+4gHc1aOaW55SlY+GkKcGsUqFrVYC3NOISe4fgCAUn6+tB5wRNQ qRug/CgJ9SZq9CbC67VHe1qscn/A4OYK/cBgckNDWmo2CL6xNlU6wCGXn7fqSELpDWlp tAFwqLuJVJcrG0kt1IElC1r+Fp7jM00eGX70AKOoUiIiniSku0Bn4w5SONOZELoBgRYU UoaExHAJMAW0LZi1TxvuvN+TzRFum0WxJormbSXr24n3dvdVpk5iwfgmIGvM5xyH2nnR hg3bLwyWXuuty/Irfq2SJzehOW0EsyF4KLhWzIqNv63LUf1wOai2wOEMuxvDYmphQQ0U xB+A== X-Gm-Message-State: AHQUAuYf1pHV7xDSeE/khcXp6oaxIJrZAVcJMFwaAOGhNJ7JP6fF70ME Llwtoc5on1OX341kDdUOdgPOnZT1TDw= X-Google-Smtp-Source: AHgI3IZFxx+Mun6LmhLakMZ6VvLchlhXHvi401vGb6uRd/AVfisTz2emJNne7D8NlQKRMmwliluopg== X-Received: by 2002:a5d:6b07:: with SMTP id v7mr12299079wrw.314.1550665121994; Wed, 20 Feb 2019 04:18:41 -0800 (PST) Received: from herelaptop.internal.advancedtelematic.com (p57bf9f95.dip0.t-ipconnect.de. [87.191.159.149]) by smtp.gmail.com with ESMTPSA id a1sm18711553wrq.96.2019.02.20.04.18.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 04:18:41 -0800 (PST) From: Anton Gerasimov To: u-boot@lists.denx.de, agraf@suse.de Date: Wed, 20 Feb 2019 13:09:13 +0100 Message-Id: <6186373fff2a94eddd91b28b41fb212c0d86caa1.1550664195.git.tossel@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [U-Boot] [PATCH v2 1/1] board: raspberrypi: add serial and revision to the device tree 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Raspberry Pi bootloader adds this node to fdt, but if u-boot script doesn't reuse the tree provided by it, this information is lost. Revision and serial are displayed in /proc/cpuinfo after boot. Suggested-By: Ricardo Salveti Reported-by: Karl Eaves Signed-off-by: Anton Gerasimov Reviewed-by: Alexander Graf --- board/raspberrypi/rpi/rpi.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 153a1fdcb7..f6a2cdfbfd 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -238,6 +238,8 @@ static uint32_t rev_scheme; static uint32_t rev_type; static const struct rpi_model *model; +static uint64_t serial; + #ifdef CONFIG_ARM64 static struct mm_region bcm2837_mem_map[] = { { @@ -381,8 +383,8 @@ static void set_serial_number(void) return; } - snprintf(serial_string, sizeof(serial_string), "%016llx", - msg->get_board_serial.body.resp.serial); + serial = msg->get_board_serial.body.resp.serial; + snprintf(serial_string, sizeof(serial_string), "%016llx", serial); env_set("serial#", serial_string); } @@ -475,6 +477,33 @@ void *board_fdt_blob_setup(void) return (void *)fw_dtb_pointer; } +static int ft_add_revision_info(void *blob) { + int off; + int ret; + + off = fdt_subnode_offset(blob, 0, "system"); + + if (off < 0) { + off = fdt_add_subnode(blob, 0, "system"); + if (off < 0) + return -1; + } + + if (!fdt_getprop(blob, off, "linux,serial", NULL)) { + ret = fdt_setprop_u64(blob, off, "linux,serial", serial); + if (ret < 0) + return -1; + } + + if (!fdt_getprop(blob, off, "linux,revision", NULL)) { + ret = fdt_setprop_u32(blob, off, "linux,revision", revision); + if (ret < 0) + return -1; + } + + return 0; +} + int ft_board_setup(void *blob, bd_t *bd) { /* @@ -484,6 +513,8 @@ int ft_board_setup(void *blob, bd_t *bd) */ lcd_dt_simplefb_add_node(blob); + ft_add_revision_info(blob); + #ifdef CONFIG_EFI_LOADER /* Reserve the spin table */ efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);