From patchwork Wed Sep 11 07:51:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1160713 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=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="UAxiE6Cu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46SvHJ4CsCz9s00 for ; Wed, 11 Sep 2019 17:51:40 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 59530C21C2C; Wed, 11 Sep 2019 07:51:28 +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=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 C6251C21C2C; Wed, 11 Sep 2019 07:51:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 414DFC21C2C; Wed, 11 Sep 2019 07:51:25 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id E185AC21C29 for ; Wed, 11 Sep 2019 07:51:24 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id c10so2214535wmc.0 for ; Wed, 11 Sep 2019 00:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=59/9a+AqjWTXIMB7nXspExrhEBcSGvN+hg74sSd9J7o=; b=UAxiE6CuPEXiljU/76/uLIaw1io+YcaKXQYvIXcd9MW2madPKIhKSa8tObTmMgxZsb dIjL/9qq+EAtNhLeIX7UymJ508c9qOZWmpT5uLy3qWp2Uszq0bHog94P/in7MAPXqIMO wkUNMWgfHF+F0yQ9x0Prkyoh6SegkhrFNmWxAh4KOjHKirQC1MXXjZ++mLWrJnNQW7gu LOlvdHspLv/rSAa0TDqFsiVHYG9E6UCQoFyZu+oYSA4RpCRdy2njV1WXT4fyiB2FuJlI UOEdbmdzw79yj6OOXsJSAB2LSVszIOaEBVm4idku8mEbniTJQI6g/R/BDjW5wuOiW0iW QiBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=59/9a+AqjWTXIMB7nXspExrhEBcSGvN+hg74sSd9J7o=; b=e502xJiqPD658UwSd02RmNiFQAIMB7PdVe4vc91ibKlv2Y+sHuJrMCZxbEt5lw34Ts Y45584OJ1mB6jiK109JdYr3PGoljwVazpcW1sEMfzCS5sjZmJdab7gQLOg91sOjF49ux dGPmwkS5hmVnKKvQSB4ET/RZ/ejM7AI8GJLs1D/rBBa4OIk+iAGFfFlB9TDRsubl0Mwz Yr7yBIzaorBsmCNCGn8mhvwOxtpTjshXjuY1wT6MpP8pVZDjgrP9g+kXpcuT0EwI79d1 WIP02kI45uIG3jAlcrDCHwP3TPOwQ+vX2BBNCNIGMvrDNu/fngqLbW9nrM6vHaR8GpBf zfEg== X-Gm-Message-State: APjAAAVigzGIEqJ3MzO6kKKzE9KJV07VM+HozY+raP8DJDAp8cbE/IZ4 FJFQoXNm0jeEo4WZzEzw9UsqIqLnmFg= X-Google-Smtp-Source: APXvYqzG9/StYw9ivXXQQCfgJTGEpr9H2IAIRsTMuJRZvro8GNSoLobTrSz3Fqdq/d0eY4kYpC3C1Q== X-Received: by 2002:a7b:ce0e:: with SMTP id m14mr2829061wmc.138.1568188284326; Wed, 11 Sep 2019 00:51:24 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id c10sm26377065wrf.58.2019.09.11.00.51.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 00:51:23 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Wed, 11 Sep 2019 09:51:22 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 Subject: [U-Boot] [PATCH] arm64: versal: Add platform detection code to versal_virt 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Detect which platform U-Boot is running at and based on that choose DTS file which U-Boot uses for own configuration. Signed-off-by: Michal Simek --- arch/arm/mach-versal/cpu.c | 18 +++++--- arch/arm/mach-versal/include/mach/hardware.h | 9 ++++ board/xilinx/versal/board.c | 43 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-versal/cpu.c b/arch/arm/mach-versal/cpu.c index f0d047d3232f..3505b4638ed8 100644 --- a/arch/arm/mach-versal/cpu.c +++ b/arch/arm/mach-versal/cpu.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -113,11 +114,18 @@ void *board_fdt_blob_setup(void) { static void *fw_dtb = (void *)CONFIG_VERSAL_OF_BOARD_DTB_ADDR; - if (fdt_magic(fw_dtb) != FDT_MAGIC) { - printf("DTB is not passed via %llx\n", (u64)fw_dtb); - return NULL; - } + if (fdt_magic(fw_dtb) == FDT_MAGIC) + return fw_dtb; + + printf("DTB is not passed via 0x%llx\n", (u64)fw_dtb); + + /* Try to look at FDT is at end of image */ + fw_dtb = (ulong *)&_end; + + if (fdt_magic(fw_dtb) == FDT_MAGIC) + return fw_dtb; - return fw_dtb; + printf("DTB is also not passed via 0x%llx\n", (u64)fw_dtb); + return NULL; } #endif diff --git a/arch/arm/mach-versal/include/mach/hardware.h b/arch/arm/mach-versal/include/mach/hardware.h index e26beab2e9cd..ac1bad02ec1c 100644 --- a/arch/arm/mach-versal/include/mach/hardware.h +++ b/arch/arm/mach-versal/include/mach/hardware.h @@ -52,6 +52,15 @@ struct rpu_regs { #define rpu_base ((struct rpu_regs *)VERSAL_RPU_BASEADDR) +#define VERSAL_PMC_TAP_BASEADDR 0xF11A0000 + +struct pmc_tap_regs { + u32 idcode; /* 0x0 */ + u32 version; /* 0x4 */ +}; + +#define pmc_base_base ((struct pmc_tap_regs *)VERSAL_PMC_TAP_BASEADDR) + #define VERSAL_CRP_BASEADDR 0xF1260000 struct crp_regs { diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 5718e1aa7e47..12ea7a0d0589 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -217,3 +217,46 @@ int dram_init(void) void reset_cpu(ulong addr) { } + +#define PMC_TAP_VERSION_PLATFORM_MASK 0xF +#define PMC_TAP_VERSION_PLATFORM_SHIFT 24 + +/* pmc_tap_version platform */ +#define PMC_TAP_VERSION_SILICON 0 +#define PMC_TAP_VERSION_SPP 1 +#define PMC_TAP_VERSION_EMU 2 +#define PMC_TAP_VERSION_QEMU 3 + +int __maybe_unused board_fit_config_name_match(const char *name) +{ + u32 version, platform; + char *platform_name = NULL; + + version = readl(&pmc_base_base->version); + platform = (version >> PMC_TAP_VERSION_PLATFORM_SHIFT) & + PMC_TAP_VERSION_PLATFORM_MASK; + + switch (platform) { + case PMC_TAP_VERSION_SILICON: + platform_name = "versal-tenzing"; /* For now */ + debug("Running on Silicon\n"); + break; + case PMC_TAP_VERSION_SPP: + platform_name = "versal-spp"; + break; + case PMC_TAP_VERSION_EMU: + platform_name = "versal-emu"; + break; + case PMC_TAP_VERSION_QEMU: + platform_name = "versal-qemu"; /* Internal QEMU */ + debug("Running on QEMU which is suspicious\n"); + break; + } + + if (!strncmp(name, platform_name, sizeof(platform_name))) { + printf("Selecting DTB %s for board %s\n", name, platform_name); + return 0; + } + + return -1; +}