From patchwork Fri Sep 11 04:35:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 1362233 X-Patchwork-Delegate: sr@denx.de 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=AMy6v6lM; 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 4Bnjbx0Vldz9sTS for ; Fri, 11 Sep 2020 14:35:22 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E6B0821ED; Fri, 11 Sep 2020 06:35:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="AMy6v6lM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47A5582242; Fri, 11 Sep 2020 06:35:15 +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,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3DFA881B79 for ; Fri, 11 Sep 2020 06:35:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=a.heider@gmail.com Received: by mail-wm1-x341.google.com with SMTP id s13so3158103wmh.4 for ; Thu, 10 Sep 2020 21:35:12 -0700 (PDT) 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=7eiMr9WgHXwMBnlAA1SeMCphc7+6gZ3Z9Pwe5KjixhY=; b=AMy6v6lMbkF0Kv2i9I+kfXvAahp5KiNUY7agqaas4oHBNcj8Reho3zLIH4nVS5GckW aS7YZhmChtxRZ1+GFMzoUJH/x+OWEDl61HjAEtIoxyjX9ZQbfyyxPwhChSLeK/hay42L IuHHAdGu+uQO3GCD7xbfwElAiXXTLMAA4rLeveYNPH1FM7TAvbmWCatEqDZmVl5pl7cB FoTPoHs414vZPO9pIUx7rbR+SSptjsaTGu8MjSgqTPDHtD8Wz0l1IAa5Gy3mScwVcGb+ UzNUaIyZhUa+L+KULSZ/ZoOkk8s7vjkCTF/8omZdtRIfmXMMP51eEq3WW3+o3WdscWDM 60FQ== 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=7eiMr9WgHXwMBnlAA1SeMCphc7+6gZ3Z9Pwe5KjixhY=; b=Fedsj2p9DgVGvs2Z/dOn+mrO7YHPv+E/Wz6aFyknIkYOY3IXH0sFGP6DX+zM+bkHgX 89zdOJkhr9BtS5MzJiEk9cHgyKnls6cwq25ps5rI1J2QiR/35nDXGrCmSsfzhNl71djm ue3agB9N/OQCQnj1ReE6fk2aY6f8cSyQJb0lefAvOb/LwOr8PXlALzGXarGOLdNKGR6U EJFLdLyRrZeYwG9DZtCuDLzuITUYL+fJE7QQ8kDRgSDWQacPS6uggcRjbO162IvMV9jx qIs0maprzpc4Zt71hvXWwx/1YJyH6P/Xjw/iK2C87wOSyOMFrbwz94SOADitEDFWD36+ m10A== X-Gm-Message-State: AOAM531otW+f1LfiYVXz+HbXMkDzIjXktWpaIilBPYX/gcRNN4O3gVis 3mSFvGHx/j1OYGwxE+pMkAQ= X-Google-Smtp-Source: ABdhPJwHw91LniXgQRood92AfDqxAnsSD/1m8lrwWhjkTcYw3m5YDj3A07RjlrkwqLn1jp91S2UfMg== X-Received: by 2002:a1c:7e83:: with SMTP id z125mr236111wmc.32.1599798911764; Thu, 10 Sep 2020 21:35:11 -0700 (PDT) Received: from mamamia.internal (a89-183-10-251.net-htp.de. [89.183.10.251]) by smtp.gmail.com with ESMTPSA id k8sm1670612wma.16.2020.09.10.21.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 21:35:11 -0700 (PDT) From: Andre Heider To: Stefan Roese , Konstantin Porotchkin Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?G=C3=A9rald_Ker?= =?utf-8?q?ma?= , u-boot@lists.denx.de, Dennis Gilmore Subject: [PATCH v2] arm: mvebu: Espressobin: Set environment variable fdtfile Date: Fri, 11 Sep 2020 06:35:10 +0200 Message-Id: <20200911043510.488790-1-a.heider@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200905120744.634300-1-a.heider@gmail.com> References: <20200905120744.634300-1-a.heider@gmail.com> 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 Required for the generic distro mechanism. Linux ships with 4 variants: marvell/armada-3720-espressobin-v7-emmc.dtb marvell/armada-3720-espressobin-v7.dtb marvell/armada-3720-espressobin-emmc.dtb marvell/armada-3720-espressobin.dtb Use available information to determine the appropriate filename. Fixes booting GRUB EFI arm64 on Fedora. Reported-by: Dennis Gilmore Signed-off-by: Andre Heider --- v2: - enable BOARD_LATE_INIT only for espressobin, via defconfig - don't overwrite a set/saved $fdtfile This still has the issue that $fdtfile doesn't show up after `env default -a`. Pali may look into that, but the infrastructure for it needs to be created first. Until then, this can be considered as v2010.10 material as it fixes booting distros relying on $fdtfile. Tested myself on a v5 board without eMMC. Tested by GĂ©rald on v7 emmc, v7/ddr4 detection confirmed working. board/Marvell/mvebu_armada-37xx/board.c | 47 +++++++++++++++++++++ configs/mvebu_espressobin-88f3720_defconfig | 1 + 2 files changed, 48 insertions(+) diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index 90bfc139aa..73d69e0388 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -50,6 +51,22 @@ DECLARE_GLOBAL_DATA_PTR; #define MVEBU_G2_SMI_PHY_CMD_REG (24) #define MVEBU_G2_SMI_PHY_DATA_REG (25) +/* + * Memory Controller Registers + * + * Assembled based on public information: + * https://gitlab.nic.cz/turris/mox-boot-builder/-/blob/master/wtmi/main.c#L332-336 + * https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/blob/mv_ddr-armada-18.12/drivers/mv_ddr_mc6.h#L309-L332 + * + * And checked against the written register values for the various topologies: + * https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/blob/mv_ddr-armada-atf-mainline/a3700/mv_ddr_tim.h + */ +#define A3700_CH0_MC_CTRL2_REG MVEBU_REGISTER(0x002c4) +#define A3700_MC_CTRL2_SDRAM_TYPE_MASK 0xf +#define A3700_MC_CTRL2_SDRAM_TYPE_OFFS 4 +#define A3700_MC_CTRL2_SDRAM_TYPE_DDR3 2 +#define A3700_MC_CTRL2_SDRAM_TYPE_DDR4 3 + int board_early_init_f(void) { return 0; @@ -63,6 +80,36 @@ int board_init(void) return 0; } +#ifdef CONFIG_BOARD_LATE_INIT +int board_late_init(void) +{ + bool ddr4, emmc; + + if (env_get("fdtfile")) + return 0; + + if (!of_machine_is_compatible("globalscale,espressobin")) + return 0; + + /* If the memory controller has been configured for DDR4, we're running on v7 */ + ddr4 = ((readl(A3700_CH0_MC_CTRL2_REG) >> A3700_MC_CTRL2_SDRAM_TYPE_OFFS) + & A3700_MC_CTRL2_SDRAM_TYPE_MASK) == A3700_MC_CTRL2_SDRAM_TYPE_DDR4; + + emmc = of_machine_is_compatible("globalscale,espressobin-emmc"); + + if (ddr4 && emmc) + env_set("fdtfile", "marvell/armada-3720-espressobin-v7-emmc.dtb"); + else if (ddr4) + env_set("fdtfile", "marvell/armada-3720-espressobin-v7.dtb"); + else if (emmc) + env_set("fdtfile", "marvell/armada-3720-espressobin-emmc.dtb"); + else + env_set("fdtfile", "marvell/armada-3720-espressobin.dtb"); + + return 0; +} +#endif + /* Board specific AHCI / SATA enable code */ int board_ahci_enable(void) { diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig index 5e9fcd1f26..559aeb076f 100644 --- a/configs/mvebu_espressobin-88f3720_defconfig +++ b/configs/mvebu_espressobin-88f3720_defconfig @@ -85,3 +85,4 @@ CONFIG_USB_ETHER_SMSC95XX=y CONFIG_SHA1=y CONFIG_SHA256=y CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_BOARD_LATE_INIT=y