From patchwork Wed Jun 24 12:49:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1316191 X-Patchwork-Delegate: trini@ti.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=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.a=rsa-sha256 header.s=20150623 header.b=pEv3FeJB; 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 49sNJW0lpdz9sSJ for ; Wed, 24 Jun 2020 22:49:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B13398203F; Wed, 24 Jun 2020 14:49:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.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=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="pEv3FeJB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF8B182065; Wed, 24 Jun 2020 14:49:21 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) (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 2022D81F87 for ; Wed, 24 Jun 2020 14:49:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x641.google.com with SMTP id ga4so2288545ejb.11 for ; Wed, 24 Jun 2020 05:49:15 -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:mime-version :content-transfer-encoding; bh=f+iTst6KmGaet+HD5YnJesyFdVhtA55WqLLCtKpaCNU=; b=pEv3FeJBxD3sEMzYdwmtWXUJoo8dQubcKT9D5O2JXgROt0100ZI4lHA1sj9uDUff3V BC2T9S/OC8aUL8tbnkQqyadnV8j5lA/gopbps6KIuGvSOl8kVKyysOavkA91FufCtxge QPoJZ/b/0VgQDbcPkGJSvGbviFujHF1UGhcktaXDunCn5o3PUHIxPnwg87Qk9VsZCVoX APhZdpjSxiU8mlfmNMNe2F0D1dQGe9pStd4STFinghau3cqh+B+7Eu6U5faCiV25cb0A wcBQL+4WRf9ne56WimAWngLvhBK4mV5PIeeIVXa3sPhGCULAgX5Ln0foZtND2Q0e927F 0Kag== 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 :mime-version:content-transfer-encoding; bh=f+iTst6KmGaet+HD5YnJesyFdVhtA55WqLLCtKpaCNU=; b=FC8Fx/ra1H2FH29m54SljkJGNzpXey3i+yNTwxEYAQwhHT/5Pldlxk5UD41nVU5YKy Ov4BF7nZ5aMypAaRQcHGb9tp97REb0sDD29zIfwYXDyT6s86B6x2jZE7CUTpJIRgVEE7 N9W6VljHfWHe5KDnGQUdASGkdw1xIGnZnG06P/6LbvrO8a46o5eXr6zlXAYFXKLFDMw7 Q8ih+79ItgC03/sDJIjjQ9F3RrYfunZTpUnZMhUkUZu43Xqjd8sbeJXEFOFQeOMLnz4E VaC/GbUTRzdSVSKOBv9RHiBZYMSn89VhNXQ0Vcqzj+GuP3ATvpFw44onAff6vxvxxLJ/ G5iQ== X-Gm-Message-State: AOAM5303GCh0YqEm3sqlvBeolSVjkvFe3HEpEr6m43FgBGtdmyULQwgC MRTIBw9OkDt0c7lionDYzVRZgX02mxJkMg== X-Google-Smtp-Source: ABdhPJyM2bwKFez++bzH+l+l85Cf7gGyO0mIAyztzv5LBnRdas2u3ZbvXN9DXJ+ffrX+0KU2hLAlGQ== X-Received: by 2002:a17:906:50b:: with SMTP id j11mr6744395eja.127.1593002954336; Wed, 24 Jun 2020 05:49:14 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id x16sm7764702edl.82.2020.06.24.05.49.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jun 2020 05:49:13 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: T Karthik Reddy Subject: [PATCH v2] xilinx: versal: Add new versal loadpdi command Date: Wed, 24 Jun 2020 14:49:12 +0200 Message-Id: <18ffdc789797c3cc6cb42ad2aaea5b466df0a880.1593002951.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.27.0 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 From: T Karthik Reddy Versal loadpdi command is used for loading secure & non-secure pdi images. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- Changes in v2: - Fix failures for versal mini configuration and create Kconfig entry for versal specific commands. Dependency to firmware should ensure that it is not enabled for mini configurations. arch/arm/Kconfig | 1 + board/xilinx/versal/Kconfig | 14 +++++ board/xilinx/versal/Makefile | 1 + board/xilinx/versal/cmds.c | 105 +++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 board/xilinx/versal/Kconfig create mode 100644 board/xilinx/versal/cmds.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 54d65f84889f..b1bd640b2d92 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1920,6 +1920,7 @@ source "board/vscom/baltos/Kconfig" source "board/xilinx/Kconfig" source "board/xilinx/zynq/Kconfig" source "board/xilinx/zynqmp/Kconfig" +source "board/xilinx/versal/Kconfig" source "board/phytium/durian/Kconfig" source "arch/arm/Kconfig.debug" diff --git a/board/xilinx/versal/Kconfig b/board/xilinx/versal/Kconfig new file mode 100644 index 000000000000..c0cccc2068b2 --- /dev/null +++ b/board/xilinx/versal/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2020, Xilinx, Inc. +# +# SPDX-License-Identifier: GPL-2.0 + +if ARCH_VERSAL + +config CMD_VERSAL + bool "Enable Versal specific commands" + default y + depends on ZYNQMP_FIRMWARE + help + Enable Versal specific commands. + +endif diff --git a/board/xilinx/versal/Makefile b/board/xilinx/versal/Makefile index e9307d7fa690..90e034315406 100644 --- a/board/xilinx/versal/Makefile +++ b/board/xilinx/versal/Makefile @@ -5,4 +5,5 @@ # obj-y := board.o +obj-$(CONFIG_CMD_VERSAL) += cmds.o obj-y += ../common/board.o diff --git a/board/xilinx/versal/cmds.c b/board/xilinx/versal/cmds.c new file mode 100644 index 000000000000..981c80ee4742 --- /dev/null +++ b/board/xilinx/versal/cmds.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2020 Xilinx, Inc. + * Michal Simek + */ + +#include +#include +#include +#include +#include +#include +#include + +static int do_versal_load_pdi(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 buf_lo, buf_hi; + u32 ret_payload[5]; + ulong addr, *pdi_buf; + size_t len; + int ret; + + if (argc != cmdtp->maxargs) { + debug("pdi_load: incorrect parameters passed\n"); + return CMD_RET_USAGE; + } + + addr = simple_strtol(argv[2], NULL, 16); + if (!addr) { + debug("pdi_load: zero pdi_data address\n"); + return CMD_RET_USAGE; + } + + len = simple_strtoul(argv[3], NULL, 16); + if (!len) { + debug("pdi_load: zero size\n"); + return CMD_RET_USAGE; + } + + pdi_buf = (ulong *)ALIGN((ulong)addr, ARCH_DMA_MINALIGN); + if ((ulong)addr != (ulong)pdi_buf) { + memcpy((void *)pdi_buf, (void *)addr, len); + debug("Pdi addr:0x%lx aligned to 0x%lx\n", + addr, (ulong)pdi_buf); + } + + flush_dcache_range((ulong)pdi_buf, (ulong)pdi_buf + len); + + buf_lo = lower_32_bits((ulong)pdi_buf); + buf_hi = upper_32_bits((ulong)pdi_buf); + + ret = xilinx_pm_request(VERSAL_PM_LOAD_PDI, VERSAL_PM_PDI_TYPE, buf_lo, + buf_hi, 0, ret_payload); + if (ret) + printf("PDI load failed with err: 0x%08x\n", ret); + + return ret; +} + +static struct cmd_tbl cmd_versal_sub[] = { + U_BOOT_CMD_MKENT(loadpdi, 4, 1, do_versal_load_pdi, "", ""), +}; + +/** + * do_versal - Handle the "versal" command-line command + * @cmdtp: Command data struct pointer + * @flag: Command flag + * @argc: Command-line argument count + * @argv: Array of command-line arguments + * + * Processes the versal specific commands + * + * Return: return 0 on success, Error value if command fails. + * CMD_RET_USAGE incase of incorrect/missing parameters. + */ +static int do_versal(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *c; + int ret = CMD_RET_USAGE; + + if (argc < 2) + return CMD_RET_USAGE; + + c = find_cmd_tbl(argv[1], &cmd_versal_sub[0], + ARRAY_SIZE(cmd_versal_sub)); + if (c) + ret = c->cmd(c, flag, argc, argv); + + return cmd_process_error(c, ret); +} + +#ifdef CONFIG_SYS_LONGHELP +static char versal_help_text[] = + "loadpdi addr len - Load pdi image\n" + "load pdi image at ddr address 'addr' with pdi image size 'len'\n" +; +#endif + +U_BOOT_CMD(versal, 4, 1, do_versal, + "versal sub-system", + versal_help_text +) +