From patchwork Sat Sep 5 12:07:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 1357986 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=YSBN2Pde; 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 4BkCx00CNTz9sSn for ; Sat, 5 Sep 2020 22:08:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66866822A3; Sat, 5 Sep 2020 14:07:54 +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="YSBN2Pde"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 781FE822A7; Sat, 5 Sep 2020 14:07:52 +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 B242B82286 for ; Sat, 5 Sep 2020 14:07:47 +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 s13so9091140wmh.4 for ; Sat, 05 Sep 2020 05:07:47 -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:mime-version :content-transfer-encoding; bh=2OrsiCFPX8z5o2htfGjNHEmFssfl5G3xXQGw6CADH4c=; b=YSBN2PdetyPPQWADT3+FQXOZwfhXQM553qAQ3cu5wAIqbmldV2Fy2c1u7DvYgGMcSe lpAqP5K1HUZHJIhLveCM9Z1TrULMWzO8NywtJWBu1mplPJddAuAN4oJ7/YCnjLY+0u2H EwKW6t+Aw8e9Zcd3MHDEGC8EBwhHjIMWahd61rH6uiU2cyEA6NigdcdRivqn/gbrWxL6 OyIoPsHo0FwzBnf9SE+pRxYVVIA8Y9j+f6M16V+nTqA+id1epfUJeKaSfJ/fO7VVfSTD 057zeJVSdFB57UPk1mXC9WGElW4+v/D0k9/juLhg9QjxWUf3M4VcpdcDfeao8x6dK59+ fDbg== 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:mime-version :content-transfer-encoding; bh=2OrsiCFPX8z5o2htfGjNHEmFssfl5G3xXQGw6CADH4c=; b=EgzVOtpUtYkrsityye2I5sMvtUqIlIkGKjBOk7bzt+6rKcN2kixV3ZiTgeht/6z5zA rHlUlSLiWqSP2R5lguO0C1+19NL01ycl6j5ScqL4PWGQyaXQUViTe+98AwrANdOLpCyc gLgpcXAr57J303MXejW/b4Ay8J4RDKZV37tcAz4Fy6jShX/1xDql5rcssHqkaTMbKBaj UQM2ABibBkXYUIG0gj7b9IKx4Wr34CpfVbkJQxEgfQyH5tSBrLoAO78Vc0evMv+L8RqA cG742aSO0QwVvYDsZ+7qlfuL36JPa2wjs4M/6W4nQ3BDs1eZDNondWDV1ubgjUSOxoMr qFEg== X-Gm-Message-State: AOAM5302HGOrR6bl8X2ekJN0ZH/UvVFUBeQ/o1PUr5ZP4IipjQbSk/fr dV98ppeFs2vyfJ0km89t9sk= X-Google-Smtp-Source: ABdhPJwPtCcYcOq/cclHL4Ux4k+9o6cO8QG2C4GH4yninPdIZqcQgWppf6eXdILfI3BOanUdZquxBw== X-Received: by 2002:a1c:4e08:: with SMTP id g8mr11746268wmh.53.1599307667155; Sat, 05 Sep 2020 05:07:47 -0700 (PDT) Received: from mamamia.internal (a89-183-15-160.net-htp.de. [89.183.15.160]) by smtp.gmail.com with ESMTPSA id h185sm17407463wme.25.2020.09.05.05.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 05:07:46 -0700 (PDT) From: Andre Heider To: Stefan Roese , Konstantin Porotchkin Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , u-boot@lists.denx.de Subject: [PATCH] arm: mvebu: Espressobin: Set environment variable fdtfile Date: Sat, 5 Sep 2020 14:07:44 +0200 Message-Id: <20200905120744.634300-1-a.heider@gmail.com> X-Mailer: git-send-email 2.28.0 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. Tested on a v5 board without eMMC. Signed-off-by: Andre Heider --- arch/arm/mach-mvebu/Kconfig | 1 + board/Marvell/mvebu_armada-37xx/board.c | 42 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 0d8e0922a2..31f5d26dc2 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -100,6 +100,7 @@ config TARGET_HELIOS4 config TARGET_MVEBU_ARMADA_37XX bool "Support Armada 37xx platforms" select ARMADA_3700 + select BOARD_LATE_INIT imply SCSI config TARGET_DB_88F6720 diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index 90bfc139aa..3bf0a08897 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,31 @@ int board_init(void) return 0; } +int board_late_init(void) +{ + bool ddr4, emmc; + + 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; +} + /* Board specific AHCI / SATA enable code */ int board_ahci_enable(void) {