From patchwork Sat Mar 14 00:11:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1254739 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=cJGApE72; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48fNL65ZzNz9sPR for ; Sat, 14 Mar 2020 11:12:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C6E381527; Sat, 14 Mar 2020 01:12:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="cJGApE72"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C87F0814D6; Sat, 14 Mar 2020 01:11:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 14E6C81269 for ; Sat, 14 Mar 2020 01:11:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=33551ae11=atish.patra@wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1584144700; x=1615680700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aGRwAHLabl4ETDwU1f15Gse6/o8sYxXuAnbohjK+WzA=; b=cJGApE729wiwMsneWEbbK+fKl6j4vtwN+Rk2xgaj60MqvTQgMQ2r+fHx FOTRB5I8HZM80ti7n01uI/a0O0gcUFmHsU5wTlqAxfcHuzIGlNivxwd+H fgZDjInezQ+3uyxv6Aj1U9/GVzguIUKp+x4NLI4SA3C7Ari2N8+3AvR23 rIGYhoVe4Hs819IqSsuoaM/mieRYbENmWUIoZybTC5bkPTqZC7lpCh/yO ss8WpJ8CmgAleYkORS2+GvEL5ozELkL72r+oz5PGnUbstW3UIjNO7mD+8 t3OVKJ9JLk/f5uq4Jx2Icw/f+hYpJjEPAtw0vZgEEZ6Pq/VTWapE4tQ73 A==; IronPort-SDR: 4zzFdew5ylJ/cLKKaewj+cz9NYAkNHLEkGncn5yQlVvMNdFh7aJ52V3gZQ3o7Foost+KvQzwgD bbnAcRl1ZiZRnj50UaAf7/QgsOmOndAZY+xJYkt03uEbQus8AUD4ZrdMPwHVEsHUtWa8k7BB5t guwC4SXvfMKOnANoW5Ep6+VuGvj4DZKOURT6KEUS5R9KwZJKQeCpJ5tNM2lx/JPNNLVXQ+EO3m AWFoX21wLjhBYx5/gZe6ozTLKq0A0kzYsbPfp+WHSEMFMCx0/Sm+DVdduz8g48aGc4/jyUtfn8 Fnw= X-IronPort-AV: E=Sophos;i="5.70,550,1574092800"; d="scan'208";a="133903976" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 14 Mar 2020 08:11:37 +0800 IronPort-SDR: uquQQ1j1llzZIlcip09Yjhij0Wy7cgcil856lOhrZk5iSRMyoVHEZRT+mmYLxt7f0Kd3cgwELP a6Yww2tWHULnyKKlSLCnnOa837Svh0e8uUW1sK6mjT1DrD+rgvXFeVYj7qSWfmGiK9Hw2irwlx IUkGaau4XHAxsfLt840tUicc0qtLdii/cxQROOy7LtOgBvOXB+/gUD5Jj/wQdcemKPNrkeuBas cqFNNXWct3ewJrG9UOq+Ps01eoEfYLeqfNvVbjJj0n3e6CZS4oyVjPjn9nf45fPWkr7+9AB7TE 13cb4xsTJmGXNXYEZpig4f+D Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2020 17:03:11 -0700 IronPort-SDR: lRZOnMQM4FE4lyqPhJ52dMLe952yQskawJtp+8RR8JOol6yJw/K6tBY5MiBxbgiAftBqsXC4Rl CfBhhM8SyinXUbOL7+gLAhGWzIgWTzemvb5E26zfirXZ6nGTVd5lPHccrSltveGVow8NtIziDi 2bNIvlvuZ7vUVkbrFTEBQFh4iVqxk3dlm8d10I3tlKAdhNBHLDR4dQbPo+5/kHpAgIkTT2xIJS psZHZMzcmcRBZQUOfexZmKitOjOcpRbIrbk3bkcjOR8o4Tkm0GPDe+SmBx3yM6dv/ixFD5M1Gw x3k= WDCIronportException: Internal Received: from wdapacbjl0003.my.asia.wdc.com (HELO yoda.hgst.com) ([10.86.54.92]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Mar 2020 17:11:36 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Rick Chen , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v2 1/4] riscv: Add boot hartid to Device tree Date: Fri, 13 Mar 2020 17:11:29 -0700 Message-Id: <20200314001132.17393-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200314001132.17393-1-atish.patra@wdc.com> References: <20200314001132.17393-1-atish.patra@wdc.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Linux booting protocol mandates that register "a0" contains the hartid. However, U-boot can not pass the hartid via a0 during via standard UEFI protocol. DT nodes are commonly used to pass such information to the OS. Add a DT node under chosen node to indicate the boot hartid. EFI stub in Linux kernel will parse this node and pass it to the real kernel in "a0" before jumping to it. Signed-off-by: Atish Patra Reviewed-by: Rick Chen --- arch/riscv/lib/bootm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index fad16901c5f2..f927694ae32f 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -28,6 +28,28 @@ __weak void board_quiesce_devices(void) int arch_fixup_fdt(void *blob) { + u32 size; + int chosen_offset, err; + + size = fdt_totalsize(blob); + err = fdt_open_into(blob, blob, size + 32); + if (err < 0) { + printf("Device Tree can't be expanded to accommodate new node"); + return -1; + } + chosen_offset = fdt_path_offset(blob, "/chosen"); + if (chosen_offset < 0) { + err = fdt_add_subnode(blob, 0, "chosen"); + if (err < 0) { + printf("chosen node can not be added\n"); + return -1; + } + } + + /* Overwrite the boot-hartid as U-Boot is the last state BL */ + fdt_setprop_u32(blob, chosen_offset, "boot-hartid", + gd->arch.boot_hart); + return 0; }