From patchwork Thu Sep 3 05:07:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1356315 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=buHTSW+5; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=soUNU+zi; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bhpk04dbHz9sTR for ; Thu, 3 Sep 2020 15:08:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8046822FB; Thu, 3 Sep 2020 07:07:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="buHTSW+5"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="soUNU+zi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5B11B822E1; Thu, 3 Sep 2020 07:07: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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AF853822D8 for ; Thu, 3 Sep 2020 07:07:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6D2045C0190; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 03 Sep 2020 01:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=U4jA0nvRK7Czr dgeNIS5gDY5tElSJ2feLLbT7NYhO6s=; b=buHTSW+5/tt6GjGA2vOU6Ivto0Cdk fngE70LZVaDreoNlTLgMANhhiJzWyBYb3mjmMUR2EHBJeYNdzuOYpRL/hBztVsqa B+hq24fQr6OsXlroOC+9DIkrBtgkfEXrmaHqyO9jP0/BBHQUHBAjJr6RkItNOJqs tL5255/XbQw05IUwTN+fwQs+x1qtv9dPXiYVdELfBIhuTKSyQJaKqBLEO3mPFxRz PIISy3OQi1lzdrJdmurLcp6DfbzqB9nJfuD0CtslCI1Bu09KsMgr7sn/mxITx0Vy qyWz9p5t9Vr2A3xct652aED771i3Ra6UK+UYoSayMMMyCG4g+rb0DzJhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=U4jA0nvRK7CzrdgeNIS5gDY5tElSJ2feLLbT7NYhO6s=; b=soUNU+zi uXuVOTwtphqr7B11oSRvrTR5EMY1G0DCfVWT5s+K/e9h3V/TodXW0tbddWCX1Qhf 2EbJfg61h8/UFqtAFCwuDtcIaxiykHsoFtLgyvzZrBQIoWF9LF/YDvRSmyDr1lyV hY8s0GIVyKaAXjkwwoUEaknhWhGHrbVOeWZTWUnB9W1++iN+4uXoWlMohB72yOlk 3TZ7XBSJLe2Nd4NxPuirhOfuGpWFLHiTQ/cSUcvZW+8DPmy+hZL/KNYEgY4NjN0I uAZwnZNHCO2j+82cPGETrg4u4iziby3clWWhVNK04wJCiBfVWlkQgL5VP4ORJUzp E1csDeRCXdGAgw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id B6856306005E; Thu, 3 Sep 2020 01:07:17 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Maxime Ripard Cc: Andre Przywara , Peter Robinson , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 1/8] sunxi: board: Use a more descriptive variable name Date: Thu, 3 Sep 2020 00:07:09 -0500 Message-Id: <20200903050716.48488-2-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903050716.48488-1-samuel@sholland.org> References: <20200903050716.48488-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean The variable "cmp_str" always leaves me wondering if it is the DT name of the current board (yes) or DT name in the FIT config entry (no). In preparation for expanding the functionality here, rename it to something that obviously means "this is the DT name we are looking for". Signed-off-by: Samuel Holland --- board/sunxi/board.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 71e2b758a3e..674e6816d2d 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -892,14 +892,14 @@ int ft_board_setup(void *blob, struct bd_info *bd) int board_fit_config_name_match(const char *name) { struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION); - const char *cmp_str = (const char *)spl; + const char *best_dt_name = (const char *)spl; /* Check if there is a DT name stored in the SPL header and use that. */ if (spl != INVALID_SPL_HEADER && spl->dt_name_offset) { - cmp_str += spl->dt_name_offset; + best_dt_name += spl->dt_name_offset; } else { #ifdef CONFIG_DEFAULT_DEVICE_TREE - cmp_str = CONFIG_DEFAULT_DEVICE_TREE; + best_dt_name = CONFIG_DEFAULT_DEVICE_TREE; #else return 0; #endif @@ -907,15 +907,15 @@ int board_fit_config_name_match(const char *name) #ifdef CONFIG_PINE64_DT_SELECTION /* Differentiate the two Pine64 board DTs by their DRAM size. */ - if (strstr(name, "-pine64") && strstr(cmp_str, "-pine64")) { + if (strstr(name, "-pine64") && strstr(best_dt_name, "-pine64")) { if ((gd->ram_size > 512 * 1024 * 1024)) return !strstr(name, "plus"); else return !!strstr(name, "plus"); } else { - return strcmp(name, cmp_str); + return strcmp(name, best_dt_name); } #endif - return strcmp(name, cmp_str); + return strcmp(name, best_dt_name); } #endif From patchwork Thu Sep 3 05:07:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1356309 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=Sj8OLfL4; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=gP0Xb3h8; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bhphf6BH6z9sTR for ; Thu, 3 Sep 2020 15:07:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A8413822E3; Thu, 3 Sep 2020 07:07:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="Sj8OLfL4"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="gP0Xb3h8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B2D9822E8; Thu, 3 Sep 2020 07:07:23 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 88299822CA for ; Thu, 3 Sep 2020 07:07:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 76A985C0185; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 03 Sep 2020 01:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=PQN64SHY0DFbJ Xj9YPEcwJKL0bbybvo9/xMWQLiHCkU=; b=Sj8OLfL4WM4t/eW8xPA7XiaXE7bRC 9oDd5605MwRja78aJ+GwV1TuxapJm7IlVNnlBETATblOjQenK4B7tAuxyPitzu+K yJP+d0AYfgltsx888/hHtABBhsY20/7onFV1xxF/nB6fWwM6UTYfzsg2QQ2QYHmb R5QGX38IUdDGZPR/U3bd2roatbUMK+xMqPZku3+3xxbSlLdWpeXp3YBmNCZFrkef DjNUZE0kZWZIXIEk25bliOi1Yol1RZQZBq4As373rtZSvdXJbPKxU6C5c2TH6OgZ ZcjNRU6zogMnOHhe/nklaCLzZQPx8Wz5Nse8PYJuRlDGk5tu5tOcONmog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=PQN64SHY0DFbJXj9YPEcwJKL0bbybvo9/xMWQLiHCkU=; b=gP0Xb3h8 lzo0knlriZlcpqJf2dY4yeWblYiYIsakrHO3GUDeZ7G9RYeSSWZ89RjUPZIHn4tw mTk7vKxHbWz88EaQ+iPXaHsygzVk6RGrnU+7eGtJzZmUmKAm19hTi1uqkP/nXGyY yyL1IKzw3pieBI1wHq1JPBo+AqTyAsrhrjgdalM+f9/0WwcdAWLTWYUXdR65xW1W oFUPZ3bjJWrhFb1KFwEiJKdkK9tpivNCGKLe9fvnTLEelYQVoKMAE5G0xVdJhIqY mQAq41sXJ3LRSeQWUb4Nd00bQsDTsroKLXDYc1P2K57wRGNIalbkkWZmbadPn2VW 5jUVvdCWPvDEZQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 0C6DA306005B; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Maxime Ripard Cc: Andre Przywara , Peter Robinson , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 2/8] sunxi: board: Add a helper to get the SPL DT name Date: Thu, 3 Sep 2020 00:07:10 -0500 Message-Id: <20200903050716.48488-3-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903050716.48488-1-samuel@sholland.org> References: <20200903050716.48488-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean This moves the validity checking and typecasts all to one place away from the string comparison logic, and it detangles the compile-time and runtime control flow. The new helper will also be used by U-Boot proper in a future commit. Signed-off-by: Samuel Holland --- board/sunxi/board.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 674e6816d2d..5c9b811f27a 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -319,6 +319,17 @@ static struct boot_file_head * get_spl_header(uint8_t req_version) return spl; } +static const char *get_spl_dt_name(void) +{ + struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION); + + /* Check if there is a DT name stored in the SPL header. */ + if (spl != INVALID_SPL_HEADER && spl->dt_name_offset) + return (char *)spl + spl->dt_name_offset; + + return NULL; +} + int dram_init(void) { struct boot_file_head *spl = get_spl_header(SPL_DRAM_HEADER_VERSION); @@ -891,20 +902,17 @@ int ft_board_setup(void *blob, struct bd_info *bd) #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) { - struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION); - const char *best_dt_name = (const char *)spl; + const char *best_dt_name = get_spl_dt_name(); - /* Check if there is a DT name stored in the SPL header and use that. */ - if (spl != INVALID_SPL_HEADER && spl->dt_name_offset) { - best_dt_name += spl->dt_name_offset; - } else { #ifdef CONFIG_DEFAULT_DEVICE_TREE + if (best_dt_name == NULL) best_dt_name = CONFIG_DEFAULT_DEVICE_TREE; -#else - return 0; #endif - }; + if (best_dt_name == NULL) { + /* No DT name was provided, so accept the first config. */ + return 0; + } #ifdef CONFIG_PINE64_DT_SELECTION /* Differentiate the two Pine64 board DTs by their DRAM size. */ if (strstr(name, "-pine64") && strstr(best_dt_name, "-pine64")) { From patchwork Thu Sep 3 05:07:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1356311 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=YljKqDaX; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=KFsvPFSQ; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bhpj50Q5mz9sTR for ; Thu, 3 Sep 2020 15:07:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 921A1822EA; Thu, 3 Sep 2020 07:07:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="YljKqDaX"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="KFsvPFSQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 29DBC822EA; Thu, 3 Sep 2020 07:07: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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AA176822D5 for ; Thu, 3 Sep 2020 07:07:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C1C965C01A4; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 03 Sep 2020 01:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=Qd9EKlOeDxNxU GjePDGIEyZE9Rx9hOCoFpYSpjLblzg=; b=YljKqDaXzM+KcF2P5M1Qm4ZqIN47C vZyob9mNeC9Ih6xzht0zmIiswyR4o06F6F75APKEHOLdF98lM16tFq5lm2c0K2C/ FLv20iU82lyakGbT5y0fX9BUw2B1l6InAM81fN1aIyj6vKXDINvzr0Njek5zd82e EBZJnaT7r4LgQ3tDupNPvYm+nq18jIibpUUERREvoNh6ktNeYOJbWPpuyRpW06+o zKpzwXrrMFjcTuczM3DCSk0LchI0IGfF9STJXcWYrkwILpOIIZIn7Pcxbxg3LuPP EF8OLTHGhbp2yvtbSVxuSyV5XrLKaiMTJNs8Z8T/AVWTfuAfwA146icVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Qd9EKlOeDxNxUGjePDGIEyZE9Rx9hOCoFpYSpjLblzg=; b=KFsvPFSQ oz3tuB0IgFDRGBPs9pm02ZFiQW6XW9io0ha6PFYr7sl2irhSUuA89cAncxDeQ99n /SKVx+jefi15iu+rEUTEdZwFzb8FbfQ6faNIyvJ1RL4m+eH9ifIF0yuc62Qe9Pt2 Y0+6e1tDB3SyFRABn0Vib5DrnmbMSYeSJZug7TRAxINnW/qdG6pq1ycNPbhvYy7V L0yBLcV7gP/gwEF5OtEWV2X22kqKFir6fKCsAVDK2KUTmM3ezGifn8h6u7n8ksWC +4UbNfjcBKfNLHFEEIb7CdNdtixI4oo/XIsA8eDHULQ0v7cF7bZ1KAR+jBSW4Bf9 CRQNy2hCu5K+Rg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 56CF53060062; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Maxime Ripard Cc: Andre Przywara , Peter Robinson , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 3/8] sunxi: board: Simplify Pine A64 DT selection logic Date: Thu, 3 Sep 2020 00:07:11 -0500 Message-Id: <20200903050716.48488-4-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903050716.48488-1-samuel@sholland.org> References: <20200903050716.48488-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean Instead of using an entirely separate matching algorithm, simply update the name of the DT we want to match. Enabling this logic does not depend on the FIT config name, only on the initial guess of the board name. Importantly, the initial guess must be "sun50i-a64-pine64-plus", because otherwise the logic would trigger when "sun50i-a64-pine64-lts" was written to the SPL header. Signed-off-by: Samuel Holland --- board/sunxi/board.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 5c9b811f27a..fb0d5bf4743 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -914,14 +914,10 @@ int board_fit_config_name_match(const char *name) return 0; } #ifdef CONFIG_PINE64_DT_SELECTION -/* Differentiate the two Pine64 board DTs by their DRAM size. */ - if (strstr(name, "-pine64") && strstr(best_dt_name, "-pine64")) { - if ((gd->ram_size > 512 * 1024 * 1024)) - return !strstr(name, "plus"); - else - return !!strstr(name, "plus"); - } else { - return strcmp(name, best_dt_name); + else if (strstr(best_dt_name, "-pine64-plus")) { + /* Differentiate the Pine A64 boards by their DRAM size. */ + if ((gd->ram_size == 512 * 1024 * 1024)) + best_dt_name = "sun50i-a64-pine64"; } #endif return strcmp(name, best_dt_name); From patchwork Thu Sep 3 05:07:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1356310 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=none (p=none dis=none) header.from=sholland.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=WQvh0tb6; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=Va8mMuMz; 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 4Bhphw0Nkzz9sTR for ; Thu, 3 Sep 2020 15:07:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19AFA822DF; Thu, 3 Sep 2020 07:07:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="WQvh0tb6"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Va8mMuMz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3129B822E3; Thu, 3 Sep 2020 07:07:24 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D694E822E1 for ; Thu, 3 Sep 2020 07:07:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 1C9B95C0116; Thu, 3 Sep 2020 01:07:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 03 Sep 2020 01:07:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=CNkIsGtVD92kV ynV0NXjTV4vykOq+sdspxFol5f0iNM=; b=WQvh0tb6tyqtZYusFC0NyOcSeWaQm ikcA+euqToY6scf0d256r+20fb4HnTosS+vXbhpF5vlo1hBhc2RW2/e+dR3a3AKH qb8j3UwBWhpnwwZMS8HqUob5Cfq1BxHU1+/2tjRXvlMxDxNd/HvUoRlLBhfK57OA Ln6MfWcRmxHlq5Js5MGAD9hRdzkPrnDX4x/NdRttkUaH/WMSGNEO0TnKW88PYXsE 8u0eiuJQWWLED8nBAxf89vvVUf7o+It6gx5i+r5Bjl/BE5Ykj4O4kpMX2MeiB+Zh KjYjivDQw8wmG4CrFKPCq4Bd/RoSQd9zHYBp6QuYpvY80vw+jLX7oVwMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=CNkIsGtVD92kVynV0NXjTV4vykOq+sdspxFol5f0iNM=; b=Va8mMuMz othxHX11xn91XUTb1pYRnk4BO4zhPNKy7f+RU+S4/3DaYnmV9zl4x03LblsUWZRs bnICHr20DS5YKUcqT9ag5zm1ocAxwJQGTc/SnTpWkZsJXR8unpsmm89jDyV+w5dM p3YUeZ3AhxjEFHJXhqUnnOIXSLXGzYsnWA+szWf0dHI7tpZJqaV5O4X8xTk2X5cp 2siDwjLGLi7PUtB/vcNZmOOZQbROGonW6mu2iNurHnrBUk4gOOmQhmeiEkjJb9lk +MfMZsLXllNr8/o7323d6iP90v1scxaBASDC+q2zzEmUVAmU/Y/fyH0B6frHJy3O QTcFTnYy45X3Zw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id A21AB306005B; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Maxime Ripard Cc: Andre Przywara , Peter Robinson , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 4/8] sunxi: board: Add PinePhone DT selection logic Date: Thu, 3 Sep 2020 00:07:12 -0500 Message-Id: <20200903050716.48488-5-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903050716.48488-1-samuel@sholland.org> References: <20200903050716.48488-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean There are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index be0822bfb7d..8421f3b6854 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endif diff --git a/board/sunxi/board.c b/board/sunxi/board.c index fb0d5bf4743..3d64ed18664 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name) best_dt_name = "sun50i-a64-pine64"; } #endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION + else if (strstr(best_dt_name, "-pinephone")) { + /* Differentiate the PinePhone revisions by GPIO inputs. */ + prcm_apb0_enable(PRCM_APB0_GATE_PIO); + sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_UP); + sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_INPUT); + udelay(100); + + /* PL6 is pulled low by the modem on v1.2. */ + if (gpio_get_value(SUNXI_GPL(6)) == 0) + best_dt_name = "sun50i-a64-pinephone-1.2"; + else + best_dt_name = "sun50i-a64-pinephone-1.1"; + + sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_DISABLE); + sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_DISABLE); + prcm_apb0_disable(PRCM_APB0_GATE_PIO); + } +#endif + return strcmp(name, best_dt_name); } #endif From patchwork Thu Sep 3 05:07:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1356314 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=none (p=none dis=none) header.from=sholland.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=fyCJtExp; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=B5Js1Nb8; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bhpjn2MLBz9sTR for ; Thu, 3 Sep 2020 15:08:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 774738230A; Thu, 3 Sep 2020 07:07:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="fyCJtExp"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="B5Js1Nb8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43189822ED; Thu, 3 Sep 2020 07:07: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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2BF26822D9 for ; Thu, 3 Sep 2020 07:07:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 672025C018A; Thu, 3 Sep 2020 01:07:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 03 Sep 2020 01:07:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=azt3bcG2gyjJM Z+euNV8r3HcVvCpV+eSxdiwdmzQYjE=; b=fyCJtExpAf8Pds8sXBs5pz5z9Werb vqBSzut0Ck+pcCvap7NpVy7HIRtLqRZZ5TVdGQrBdCyjMYPaBcpnxw/mfUNJKoX9 WjOBrSnHpTrRp42ZQmJhQhQwBcX/s0j54ruprCfSqKSDuTOBG1N1JvKxI/PpfY6r SsSEbwLKYq1RtK4noXm6JikphM9ME5i5XlR5n4XPsXPdM3UhM9DZXrkVwtWp+NyK 4Xz63Is8oAxwJZAmqv049v/YeMe/Rsf9FY93zxcnQyZVoOHuW1s17AsX7jF8wDRy xqvpvT8c3cJYXaFLGLrY+nmcGoKIjQSszLh9y5NwbGmjlEElJCcUUJW1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=azt3bcG2gyjJMZ+euNV8r3HcVvCpV+eSxdiwdmzQYjE=; b=B5Js1Nb8 5VzNH4aOuAW1FHK3OmKXRhz2sqhORkqO2K1N+kVfuPWZeATNjSIGEHwqkBJeJDNc i+/y18eeCQg5sWkt3YCGaFv//m+LNamP1DRTkwLglswewvGqj0zfgN4MjMJvBWt3 0bbdP8+D9o1geSld8IyI3lyRZgu7QN+3vJs4xxyTQL6xTOg6VizhNwm6nwSSl2u8 O6WzLWqrShbb6PD7Lqy5FrJ+BiqwRR+QrRp1JI86QDXssPJh1CtMiF2LnrkmwPxB DSp3hr1nqudSNopltfwdUyNu3GdkGbMCE8Iv+4KIZpD8oRH12hS19aRtIqosAuXm 1Ljrqzx4Vp/yNA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id EE48F306005E; Thu, 3 Sep 2020 01:07:18 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Maxime Ripard Cc: Andre Przywara , Peter Robinson , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 5/8] sunxi: board: Save the chosen DT name in the SPL header Date: Thu, 3 Sep 2020 00:07:13 -0500 Message-Id: <20200903050716.48488-6-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903050716.48488-1-samuel@sholland.org> References: <20200903050716.48488-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean This overwrites the name loaded from the SPL image. It will be different if there was previously no name provided, or if a more accurate name was determined by the board variant selection logic. This means that the DT name in the SPL header now always matches the DT appended to U-Boot. Signed-off-by: Samuel Holland --- board/sunxi/board.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 3d64ed18664..eaa40a1ea96 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -331,6 +331,21 @@ static const char *get_spl_dt_name(void) return NULL; } +static void set_spl_dt_name(const char *name) +{ + struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION); + + if (spl == INVALID_SPL_HEADER) + return; + + /* Promote the header version for U-Boot proper, if needed. */ + if (spl->spl_signature[3] < SPL_DT_HEADER_VERSION) + spl->spl_signature[3] = SPL_DT_HEADER_VERSION; + + strcpy((char *)&spl->string_pool, name); + spl->dt_name_offset = offsetof(struct boot_file_head, string_pool); +} + int dram_init(void) { struct boot_file_head *spl = get_spl_header(SPL_DRAM_HEADER_VERSION); @@ -904,6 +919,7 @@ int ft_board_setup(void *blob, struct bd_info *bd) int board_fit_config_name_match(const char *name) { const char *best_dt_name = get_spl_dt_name(); + int ret; #ifdef CONFIG_DEFAULT_DEVICE_TREE if (best_dt_name == NULL) @@ -941,6 +957,15 @@ int board_fit_config_name_match(const char *name) } #endif - return strcmp(name, best_dt_name); + ret = strcmp(name, best_dt_name); + + /* + * If one of the FIT configurations matches the most accurate DT name, + * update the SPL header to provide that DT name to U-Boot proper. + */ + if (ret == 0) + set_spl_dt_name(best_dt_name); + + return ret; } #endif From patchwork Thu Sep 3 05:07:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1356313 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=none (p=none dis=none) header.from=sholland.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=Ps0W2fd7; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=irLh9odg; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhpjY18DVz9sTR for ; Thu, 3 Sep 2020 15:08:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1375E82300; Thu, 3 Sep 2020 07:07:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="Ps0W2fd7"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="irLh9odg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9DCE822E1; Thu, 3 Sep 2020 07:07: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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2CC5D822DF for ; Thu, 3 Sep 2020 07:07:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id AAA455C0197; Thu, 3 Sep 2020 01:07:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 03 Sep 2020 01:07:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=YJZBYh6lhnaT4 or+KKTYoX0BgbruFrnszv2AxRFjCUg=; b=Ps0W2fd7vmO9tBRewK6ov5Y2vWsh9 oAAVK6vPK0hEzUkkeBIkhSenj5xlmR2HCeP5LxQU+Vgty5CzLJnc48U8lCQwGRFR ZZ6tAiD9/vOtdVCbU2dRH7WK3uoAEi4AB688do5c3H3KhS8ZN6N7vsakr50TbczK beuX76xciz0QEuRhJUFbnK9EYpV8/CDS1OFv6P+kA6OSIb71gm9FeFgdHHpmdQ/U 7sE6vbkMYhL7pFMzeBCYWSfUWF6NK3gfJApDaxFqR1KBlszLuGbIXLVYWImA3WV8 sFDNZWGk2swSOB1ivq+Xvb2WTlPidjY0OrROgggZcyDHPRFEoZaS1ezAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=YJZBYh6lhnaT4or+KKTYoX0BgbruFrnszv2AxRFjCUg=; b=irLh9odg 4mUJO3vUBGyeYD/WBs8BrulYezzsNoTAJp4uGEv0b9KyxbofUjok4+liYvAT/QZa ED/iKo1bqgGmEwNPLoM0YORd0pXRd5jyv9W53Z96qzGsNOe0iGkJtSlOMXF3Lrfl aIpGPRSMoRkqztR6oWBAEHeCm3NCFY4LDzzCoPFQqdcWmiDl+Wi3YfpApRGHdL3v 4XVOruQFZlZUHZPp42VOzgbJyz+uWB3Z/RN2y0P7Lof1CrYtsWNftV4LuXDQ70VZ P9TlSWjk75qTa1dqHdj/cvbi5WFBqa4FJKgCCV1OgCCEAc1ZGLhPBVDjt4W7FHJh hNPlKS0liPCmGQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 4678A306005B; Thu, 3 Sep 2020 01:07:19 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Maxime Ripard Cc: Andre Przywara , Peter Robinson , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 6/8] sunxi: board: Set fdtfile to match the DT chosen by SPL Date: Thu, 3 Sep 2020 00:07:14 -0500 Message-Id: <20200903050716.48488-7-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903050716.48488-1-samuel@sholland.org> References: <20200903050716.48488-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean Previously, fdtfile was always the value in CONFIG_DEFAULT_DEVICE_TREE. This meant that, regardless of the DT chosen by SPL (either by changing the header in the image or by the selection code at runtime), Linux always used the default DT. By using the name from the SPL header (which, because of the previous commit, always matches the DT used by U-Boot proper), Linux also sees the same board as U-Boot/SPL, even if the boot script later loads a DT from disk. Signed-off-by: Samuel Holland --- board/sunxi/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index eaa40a1ea96..5457b28e135 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -870,6 +870,7 @@ static void setup_environment(const void *fdt) int misc_init_r(void) { + const char *spl_dt_name; uint boot; env_set("fel_booted", NULL); @@ -888,6 +889,16 @@ int misc_init_r(void) env_set("mmc_bootdev", "1"); } + /* Set fdtfile to match the FIT configuration chosen in SPL. */ + spl_dt_name = get_spl_dt_name(); + if (spl_dt_name) { + char *prefix = IS_ENABLED(CONFIG_ARM64) ? "allwinner/" : ""; + char str[64]; + + snprintf(str, sizeof(str), "%s%s.dtb", prefix, spl_dt_name); + env_set("fdtfile", str); + } + setup_environment(gd->fdt_blob); #ifdef CONFIG_USB_ETHER