From patchwork Fri Jul 22 14:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659595 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=EFFL9rSd; dkim-atps=neutral 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=) 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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBMR6Cllz9sGk for ; Sat, 23 Jul 2022 00:16:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9AA5083FB6; Fri, 22 Jul 2022 16:16:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="EFFL9rSd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D18E283FB5; Fri, 22 Jul 2022 16:16:25 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 5A36083F92 for ; Fri, 22 Jul 2022 16:16:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wr1-x433.google.com with SMTP id bv24so6690052wrb.3 for ; Fri, 22 Jul 2022 07:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=du/4twkO85QOIHLRv/BLFBmI/SODNJ2MYBHBH61eVno=; b=EFFL9rSd1umPpVg71/lPBS9rRDMRujy2IOMaSM0hxOwDntN2oT4BBGFAPKRD3fyviD obE1i/+Pc+q9ygqIHbFQv2c7DwjjZw7XNehtXCIiLazmUnQoF4+EAZLBMF2qfgGeCjJx s1q1CcaAoxKAixbggw7hIbow2ppYiTp9dzOxpfIfkajJomKjBqQyMN39Eir8Pw738pn1 cQ2Nvoo0iHlxIOxpGoKHsXLa4nE7FXzeUN10i/86rJMISQB9TnMP6hVFeIOOY0+5tWpl zfTr1yKv4g4RRtPSa00qucqC+Xw5nE4k4A1ZVF23N0HJzs9Mkkwc9U43TS/OFKE5WzqP uq0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=du/4twkO85QOIHLRv/BLFBmI/SODNJ2MYBHBH61eVno=; b=kvLTeCxj6rLgxf39qURX/vSpaOqcC3wFpCCZwvOoZfmJgDZyXwKBz1q1ooS42Elr6N D40soMEt3DAiL5l9B86Wz3RCTMVJLr+ZaWf7j4oYgnosbl24AfXd32lHsFXJZTyGgHaZ Wsbe0cy6V6bNzYy0I7uZtIyLZ7+kQcKzbRxdMBsUK2onc3I+qo7blzXjrAvQ4dm9kMKE iNNcyFqDELMlWjAt1kwuQX4qZy78/oYHoA0RHsEyBwS67yRyVkDV17bcpmAOqa23+vy+ TqTDBQUK6zyxdAEJTqBEjWlEhR55t8xmcqAh54xA7a/SI/5o777oXbDnK4Ees912TZxa 6B6w== X-Gm-Message-State: AJIora+Gv0+66jd1h3sII18wPAFy/xYW4AaKtkBbojSv1My0Jm6bIBKq C8J7huceTgtP86f5uqJJS1J/NJn2sr7cDQ== X-Google-Smtp-Source: AGRyM1v837Zhf7q7xWK7q98orNDd9VSRu+3V3F5UBiuUkleK1Ro7oePk6abyO0hvirSqrzpezGl+MA== X-Received: by 2002:a05:6000:1acf:b0:21d:b410:599a with SMTP id i15-20020a0560001acf00b0021db410599amr90225wry.123.1658499380565; Fri, 22 Jul 2022 07:16:20 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:19 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Ashok Reddy Soma , Heinrich Schuchardt , Masahisa Kojima , Michal Simek , Ovidiu Panait , Simon Glass Subject: [PATCH v12 01/13] fpga: add option for loading FPGA secure bitstreams Date: Fri, 22 Jul 2022 17:16:02 +0300 Message-Id: <20220722141614.297383-2-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean It allows using this feature without enabling the "fpga loads" command. Signed-off-by: Oleksandr Suvorov Co-developed-by: Adrian Fiergolski Signed-off-by: Adrian Fiergolski Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v1) cmd/Kconfig | 3 ++- drivers/fpga/Kconfig | 14 ++++++++++++++ drivers/fpga/fpga.c | 2 +- drivers/fpga/xilinx.c | 2 +- drivers/fpga/zynqmppl.c | 4 ++-- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index d5f842136cf..cefeca018d2 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1036,8 +1036,9 @@ config CMD_FPGA_LOADP a partial bitstream. config CMD_FPGA_LOAD_SECURE - bool "fpga loads - loads secure bitstreams (Xilinx only)" + bool "fpga loads - loads secure bitstreams" depends on CMD_FPGA + select FPGA_LOAD_SECURE help Enables the fpga loads command which is used to load secure (authenticated or encrypted or both) bitstreams on to FPGA. diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 76719517f54..4561ee72dd0 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -91,4 +91,18 @@ config FPGA_ZYNQPL Enable FPGA driver for loading bitstream in BIT and BIN format on Xilinx Zynq devices. +config FPGA_LOAD_SECURE + bool "Enable loading secure bitstreams" + depends on FPGA + help + Enables the fpga loads() functions that are used to load secure + (authenticated or encrypted or both) bitstreams on to FPGA. + +config SPL_FPGA_LOAD_SECURE + bool "Enable loading secure bitstreams for SPL" + depends on SPL_FPGA + help + Enables the fpga loads() functions that are used to load secure + (authenticated or encrypted or both) bitstreams on to FPGA. + endmenu diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index fe3dfa12335..3b0a44b2420 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -220,7 +220,7 @@ int fpga_fsload(int devnum, const void *buf, size_t size, } #endif -#if defined(CONFIG_CMD_FPGA_LOAD_SECURE) +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) int fpga_loads(int devnum, const void *buf, size_t size, struct fpga_secure_info *fpga_sec_info) { diff --git a/drivers/fpga/xilinx.c b/drivers/fpga/xilinx.c index cbebefb55fe..6bc1bc491fb 100644 --- a/drivers/fpga/xilinx.c +++ b/drivers/fpga/xilinx.c @@ -172,7 +172,7 @@ int xilinx_loadfs(xilinx_desc *desc, const void *buf, size_t bsize, } #endif -#if defined(CONFIG_CMD_FPGA_LOAD_SECURE) +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) int xilinx_loads(xilinx_desc *desc, const void *buf, size_t bsize, struct fpga_secure_info *fpga_sec_info) { diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 6b394869dbf..8ff12bf50a0 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -245,7 +245,7 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, return ret; } -#if defined(CONFIG_CMD_FPGA_LOAD_SECURE) && !defined(CONFIG_SPL_BUILD) +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) static int zynqmp_loads(xilinx_desc *desc, const void *buf, size_t bsize, struct fpga_secure_info *fpga_sec_info) { @@ -306,7 +306,7 @@ static int zynqmp_pcap_info(xilinx_desc *desc) struct xilinx_fpga_op zynqmp_op = { .load = zynqmp_load, -#if defined(CONFIG_CMD_FPGA_LOAD_SECURE) && !defined(CONFIG_SPL_BUILD) +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) .loads = zynqmp_loads, #endif .info = zynqmp_pcap_info, From patchwork Fri Jul 22 14:16:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659596 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=LNHRir07; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBMZ6BJSz9sGq for ; Sat, 23 Jul 2022 00:16:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DCB04840B3; Fri, 22 Jul 2022 16:16:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="LNHRir07"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF71083FB2; Fri, 22 Jul 2022 16:16: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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 8F5DD802C2 for ; Fri, 22 Jul 2022 16:16:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x333.google.com with SMTP id n185so2875834wmn.4 for ; Fri, 22 Jul 2022 07:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=POcOZ8OKrASW3luQNlqpPMrGP4tQ3eQfP2BpmwpHe8E=; b=LNHRir078K2TDVMVSFNraqr4AlPoPP0nmlytpMSdlFnSkgYq3sCHTG2/raG09xYqG+ prtRY8IvDxDM/aBOez2BvV5zcIjtclREFl+EGVEB/uGuMW+SKt4YcJHua5Rg52X2JUcj eVjW0Wp7t4VH/Mq05tbC7a0t54K2e6H5v1zpLao7w8TsgDlrTRT8bKmnAdNTXwLAMHo9 OTC6OQyRo80mvrmvFLDelahV2bgS2Ezi33CQXFhcXey7hQi6++mzaffu9WAuUTk21to2 eWGS6ZrZ26rX9pnpvTHD4HJwr3uE63/WvR3Td3gQbflRlIroo06jE3aJLokmt9CYA9TE xnlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=POcOZ8OKrASW3luQNlqpPMrGP4tQ3eQfP2BpmwpHe8E=; b=c0BUV9Ma9jnIjgD6ZNYF7ogpGomM4UVyyscFGokuR6ZyXQvIP0IrLTDZQjFYX9hiXK za+fuAEMl1hKpl1/crQBo3XuGhmjM/LVwQwBh6lXswAsknrSf36ipgoFOJbL3ooR+t3F lrwo5PgWoNMCIKg9AgYsf2kuHI62m9UegtcyliqDoH3rhqpPiJTdkuJ+UIBwpSnXQPbh cb2zGN+iDE621lPuaQ8YivzY7TvwM9EZDe2MQqCLfs4lMtk5FAfCa9zePYyLsaoB88q+ AiJT77ogrZ15tbn/kmQXcf4LgLXVS6ZZXRxLr0nR8PmWqHDMHB/i969wD/0+YqvX2MiS 4mdw== X-Gm-Message-State: AJIora8dzIvBvUqAGcQiIeQazLORZiCfPGG+dPR2F/yJEJn82qhbxOkp xZB1kVzMc6Xt8G/Lb0mwMTI+jSy5VhqBXg== X-Google-Smtp-Source: AGRyM1sdrjrieHcsqJQdXbQ2CpmUe+yK1mGAJmok0u/Got+S93v/2VSVKXxC0BPWTHXZVA0jEu+G3w== X-Received: by 2002:a05:600c:1da8:b0:3a3:1969:b0d with SMTP id p40-20020a05600c1da800b003a319690b0dmr12397501wms.172.1658499381853; Fri, 22 Jul 2022 07:16:21 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:21 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 02/13] fpga: xilinx: add missed identifier names Date: Fri, 22 Jul 2022 17:16:03 +0300 Message-Id: <20220722141614.297383-3-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-2-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Function definition arguments should also have identifier names. Add missed ones to struct xilinx_fpga_op callbacks, unifying code. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v1) include/xilinx.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/xilinx.h b/include/xilinx.h index ab4537becfa..362943bc717 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -48,12 +48,14 @@ typedef struct { /* typedef xilinx_desc */ } xilinx_desc; /* end, typedef xilinx_desc */ struct xilinx_fpga_op { - int (*load)(xilinx_desc *, const void *, size_t, bitstream_type); - int (*loadfs)(xilinx_desc *, const void *, size_t, fpga_fs_info *); + int (*load)(xilinx_desc *desc, const void *buf, size_t bsize, + bitstream_type bstype); + int (*loadfs)(xilinx_desc *desc, const void *buf, size_t bsize, + fpga_fs_info *fpga_fsinfo); int (*loads)(xilinx_desc *desc, const void *buf, size_t bsize, struct fpga_secure_info *fpga_sec_info); - int (*dump)(xilinx_desc *, const void *, size_t); - int (*info)(xilinx_desc *); + int (*dump)(xilinx_desc *desc, const void *buf, size_t bsize); + int (*info)(xilinx_desc *desc); }; /* Generic Xilinx Functions From patchwork Fri Jul 22 14:16:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659597 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=OqtcHCpM; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBMq3J7Dz9sGq for ; Sat, 23 Jul 2022 00:17:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1951A83FCA; Fri, 22 Jul 2022 16:16:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="OqtcHCpM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31F3E81877; Fri, 22 Jul 2022 16:16:28 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 7C3068210C for ; Fri, 22 Jul 2022 16:16:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x333.google.com with SMTP id ay11-20020a05600c1e0b00b003a3013da120so5270855wmb.5 for ; Fri, 22 Jul 2022 07:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=X/mENcILC8xl/xR4K/C1Mj1s7/0NVzvreklRPV4yciQ=; b=OqtcHCpMWZ+P3lxbWEHPfDrD+OYFNc5VSKQ3BdxM/tjsiz0TChU+tXYYGHuR4he5of 6fXEyEU38w33TA604j1q5RR428Prd0RMDR4TnwLrvifF7wGkDJgp48LXSFAnJwCQjT16 kOcOLzYLMtRLyOMxN+NOz7C75Fs540XEwvyIAMbrYjPK7jtxtRsciqADbSpGK0AtzxLE cTrSOV92YvJHUIQflk6/Lg/J/aXqzp7H2X7R+t1znO65UZi7Nti6qlkJ8DOvpNXRMFub HS/Ous+QIFDMP1RdoMq3T75a1DXYADlEF4HpzCcpZQQBwD5kLLXj37zZUB3HzQYz9beZ g/FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=X/mENcILC8xl/xR4K/C1Mj1s7/0NVzvreklRPV4yciQ=; b=DnIvcmFeGjss/UPCPHhT/tf31IBpgtKgah9Uh/eKKnGgWZHLdHORACIuENYUPY9cwp 1sCvspOeO6lkRPBnVQGsAo2eL79EDBV9ExiXkDcXLh9ejOBerpI996WyLPPwQpfuwYno zhbox3GfE8eKpedX1jHIC0OWIxc4SnkAg4zBDAJgmY4MAZpMlwJ+OOzaO0ntB7WEpAtY WV7tW40ChjbPzdY9muk/h/N4XvAyWrjxfT2KFdEJKvLdwHuJsmkkKjvN8IT06TezAtpM uJl97GSe6aM4Nv3u4N1Dwjbcfis2NmJMKv8x7R2REdUw4hGam/xMsopmnXRR2AbcdVNU JmKQ== X-Gm-Message-State: AJIora+91tgtzFH5xgDtiu/W1szEIda/LkvpOBzxPhGKIgUQgmTACxZt tFzPdCozIYsLfV8H+6ZBsxVEMkUi1Be/+Q== X-Google-Smtp-Source: AGRyM1uQZiAYPN9PxhlhRKWv+RHW9UQhPSAs7sQ/xUHSRPglYNgcq+H3lq4xT2iyqDo14G7xj31m/g== X-Received: by 2002:a7b:c391:0:b0:3a3:2f22:7bf6 with SMTP id s17-20020a7bc391000000b003a32f227bf6mr7776883wmj.96.1658499383397; Fri, 22 Jul 2022 07:16:23 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:22 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 03/13] fpga: xilinx: add bitstream flags to driver desc Date: Fri, 22 Jul 2022 17:16:04 +0300 Message-Id: <20220722141614.297383-4-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-3-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Store a set of supported bitstream types in xilinx_desc structure. It will be used to determine whether an FPGA image is able to be loaded with a given driver. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v10) Changes in v10: - move FPGA flags to macros; - initialize xilinx_desc structs directly, removing *_DESC macros; - initialize flags for mach-zynq; arch/arm/mach-zynq/cpu.c | 1 + board/xilinx/versal/board.c | 5 ++++- board/xilinx/zynqmp/zynqmp.c | 5 ++++- include/versalpl.h | 3 --- include/xilinx.h | 4 ++++ include/zynqmppl.h | 3 +-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c index 69b818f24b8..ac595ee0a27 100644 --- a/arch/arm/mach-zynq/cpu.c +++ b/arch/arm/mach-zynq/cpu.c @@ -22,6 +22,7 @@ xilinx_desc fpga = { .family = xilinx_zynq, .iface = devcfg, .operations = &zynq_op, + .flags = FPGA_LEGACY, }; #endif diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 81663e0cd0e..d8f39be56c8 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -27,7 +27,10 @@ DECLARE_GLOBAL_DATA_PTR; #if defined(CONFIG_FPGA_VERSALPL) -static xilinx_desc versalpl = XILINX_VERSAL_DESC; +static xilinx_desc versalpl = { + xilinx_versal, csu_dma, 1, &versal_op, 0, &versal_op, NULL, + FPGA_LEGACY +}; #endif int board_init(void) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 106c3953e1f..3faa3a00fc9 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -48,7 +48,10 @@ DECLARE_GLOBAL_DATA_PTR; #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) -static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; +static xilinx_desc zynqmppl = { + xilinx_zynqmp, csu_dma, 1, &zynqmp_op, 0, &zynqmp_op, NULL, + ZYNQMP_FPGA_FLAGS +}; #endif int __maybe_unused psu_uboot_init(void) diff --git a/include/versalpl.h b/include/versalpl.h index b94c82e6e66..0cc101be2f8 100644 --- a/include/versalpl.h +++ b/include/versalpl.h @@ -14,7 +14,4 @@ extern struct xilinx_fpga_op versal_op; -#define XILINX_VERSAL_DESC \ -{ xilinx_versal, csu_dma, 1, &versal_op, 0, &versal_op } - #endif /* _VERSALPL_H_ */ diff --git a/include/xilinx.h b/include/xilinx.h index 362943bc717..d9e4b8da968 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -37,6 +37,9 @@ typedef enum { /* typedef xilinx_family */ max_xilinx_type /* insert all new types before this */ } xilinx_family; /* end, typedef xilinx_family */ +/* FPGA bitstream supported types */ +#define FPGA_LEGACY BIT(0) + typedef struct { /* typedef xilinx_desc */ xilinx_family family; /* part type */ xilinx_iface iface; /* interface type */ @@ -45,6 +48,7 @@ typedef struct { /* typedef xilinx_desc */ int cookie; /* implementation specific cookie */ struct xilinx_fpga_op *operations; /* operations */ char *name; /* device name in bitstream */ + int flags; /* compatible flags */ } xilinx_desc; /* end, typedef xilinx_desc */ struct xilinx_fpga_op { diff --git a/include/zynqmppl.h b/include/zynqmppl.h index 35cfe17d444..8401a850afb 100644 --- a/include/zynqmppl.h +++ b/include/zynqmppl.h @@ -25,7 +25,6 @@ extern struct xilinx_fpga_op zynqmp_op; -#define XILINX_ZYNQMP_DESC \ -{ xilinx_zynqmp, csu_dma, 1, &zynqmp_op, 0, &zynqmp_op } +#define ZYNQMP_FPGA_FLAGS (FPGA_LEGACY) #endif /* _ZYNQMPPL_H_ */ From patchwork Fri Jul 22 14:16:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659598 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=iNQyOHah; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBN42s2Dz9sGq for ; Sat, 23 Jul 2022 00:17:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B0A483FA1; Fri, 22 Jul 2022 16:16:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="iNQyOHah"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F0F383FB2; Fri, 22 Jul 2022 16:16:29 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 A0E4E83FA1 for ; Fri, 22 Jul 2022 16:16:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x32f.google.com with SMTP id b21-20020a05600c4e1500b003a32bc8612fso2584371wmq.3 for ; Fri, 22 Jul 2022 07:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=QEcOZ6UFsohbA3i3FenAAYQDhbJwlbtc2EJCfDW5LjY=; b=iNQyOHahzU1flAzJsEDaYKwwEktpqzwN4U2TayUFLRBIHBdN7xCFsjs0CdpdLk1uVV P99l3j8IQYwxeO8oqwRxTvELevPb45SGSpF9dk9kPWyiUOuAcEKeATAYX2FUxGjskuFW RjmHetRQyFglaxlsBT1QGK7uKDF+B/vHZSmZrGs2wvNhHL1h4IyS2lhKiIFEb3oqshBk uHoDv3dsfterG+of2C5Fq128ufcCGve1tJd8b/+n3f1Y625FENYFMQzJcHjot8R/X0wS mbCZLHViqZ0EXKo8P8jwbce1HNP3indj8L12y+iWIcLLg3WZ2I5qXev5h7aZRzrVytND 089A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=QEcOZ6UFsohbA3i3FenAAYQDhbJwlbtc2EJCfDW5LjY=; b=2cKH/iqO6iDczsIVruBdRbzmuwd3qzFkflKERAlRc4NMfcWVnN2+D1ovhVYQBF1xux Kv8nD4zIrFYNGKDi9F/edZS0BmDV7/Z3iL1astNn4AwEmJDHcRrbBSN5smOAv0bPsC7y YetuJGYpSBhwLEwcbPh/uoRyxRvqFpGVnQkoz2Ev9iCHlg3Zme+I6gBzQMPbuFrhsURh oGSaG2S6vh28ypXvvrU1/do/162usEYkfjhcxunQZrlpLB0hiqiX1trbwXFvb3y64s7g wc1miL7ec7LxaWa26B5CUr16e0gCEy5UoYhKaaaIxp+7sNH7Kax3JpnCfKFzjALAN0KW XDiA== X-Gm-Message-State: AJIora+T4BfwbaQQcwZ/NfHCSKz2jAo5ZtLXExia0KR6NOZj/7l6oYwp XWqwiuU/Jkk95UYOUlQ9dkmZ10PbQchDQA== X-Google-Smtp-Source: AGRyM1t11dhOlU6OIXueNbgb3c/FQIerXA5Ob8AK7ceECRUt44o4B8pQVWPwa4NoEzHSHoCUPVPeyA== X-Received: by 2002:a05:600c:22c2:b0:3a3:19e3:a55 with SMTP id 2-20020a05600c22c200b003a319e30a55mr12771565wmg.53.1658499384770; Fri, 22 Jul 2022 07:16:24 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:24 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 04/13] fpga: zynqmp: add str2flags call Date: Fri, 22 Jul 2022 17:16:05 +0300 Message-Id: <20220722141614.297383-5-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-4-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Add a call to convert FPGA "compatible" string to a binary flag. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v1) drivers/fpga/zynqmppl.c | 11 ++++++++++- include/xilinx.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 8ff12bf50a0..19d079c9d9f 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -304,10 +304,19 @@ static int zynqmp_pcap_info(xilinx_desc *desc) return ret; } +static int __maybe_unused zynqmp_str2flag(xilinx_desc *desc, const char *str) +{ + if (!strncmp(str, "u-boot,fpga-legacy", 18)) + return FPGA_LEGACY; + + return 0; +} + struct xilinx_fpga_op zynqmp_op = { .load = zynqmp_load, + .info = zynqmp_pcap_info, #if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) .loads = zynqmp_loads, + .str2flag = zynqmp_str2flag, #endif - .info = zynqmp_pcap_info, }; diff --git a/include/xilinx.h b/include/xilinx.h index d9e4b8da968..ff5486d98a7 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -60,6 +60,9 @@ struct xilinx_fpga_op { struct fpga_secure_info *fpga_sec_info); int (*dump)(xilinx_desc *desc, const void *buf, size_t bsize); int (*info)(xilinx_desc *desc); +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) + int (*str2flag)(xilinx_desc *desc, const char *string); +#endif }; /* Generic Xilinx Functions From patchwork Fri Jul 22 14:16:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659599 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=D1YbSiUv; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBNH5sDGz9sGq for ; Sat, 23 Jul 2022 00:17:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1CD59840A8; Fri, 22 Jul 2022 16:16:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="D1YbSiUv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AB2B81877; Fri, 22 Jul 2022 16:16:30 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 661C683F9F for ; Fri, 22 Jul 2022 16:16:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x32f.google.com with SMTP id b21-20020a05600c4e1500b003a32bc8612fso2584392wmq.3 for ; Fri, 22 Jul 2022 07:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=nN9vRA+FPdZYfhEQ4m+VrxzvqnkfvSRSJVsMz49mk5M=; b=D1YbSiUvIUZPSdSZX2Ndp+1ITLY1RoZSsdrIQDW91zLY6sAzdEBn03a460GgK079hb EuN5PlNo+z5+FDloQgGSBnO/WSL6q1V/L89D+Xrhw4sTe7MK+OmoEBsZouEAJ529pn3K KL23GwORD+1KwpRYRe6pMOb/QdWPIOzu1R2J4iHraMLR5wnl5E1KOC6rufGBf8rN6Sqw l57R0ysPsxChSOelZLbixgcB3nF5SO07sCIhsdI5VJeoEpJuGZyKb5w0FMKVGYWoIH+s QykmiFLU/L4XfNvvFgeEfIgOE8fQ6XlLHXYGDWVKstewLruZwUuDWMIDPvWVA8LP8fmY T0tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=nN9vRA+FPdZYfhEQ4m+VrxzvqnkfvSRSJVsMz49mk5M=; b=OzSGE3E2SEOArssIJMchznjqT0CjyuiFsN0a+9NaDXRyqGW43lJSljNdim8EH/yGLY qW/sm5QJNPhNsS6C6deV0LEz9Zq7UBOSdLRTerstEaQHVFgdl6GfpSr6Z/XzJtn7p0Pq 11SiogLBhD5VbiqBWVeHARazDxKAd+beyM0Ps9iLB1ELDOMGD/4wi3B57tafBGY6YKOA 7EmOV0XrJeNYIkQQjk4olZ+HyHtXr9rdLHqjCHFF/Gt/WdpQj1hClXIQOqTiF+kfBI4J j+zESNqY5WW0MwBoeo4ImxMSLpfrAqXIrT0bX6F+U/7idQNYvVlbnBt/PaHVLK/ecHJz 1Y1Q== X-Gm-Message-State: AJIora8vjydUGkgeA1zOqUFk2MtJUmEhCz1O+ax+6Kv3gRsyVyiudfTe +KvDVFwkHuMi/YMPyh4ChmYmRSV4DFqWsg== X-Google-Smtp-Source: AGRyM1vzpPxXZgjy6jROEgCNxzXTZ85Z1er1tr2RLi7L/XFnSO5TUtXtq2/RMRsw7Oh2lqfzwmStgw== X-Received: by 2002:a05:600c:3ca4:b0:3a0:1825:2e29 with SMTP id bg36-20020a05600c3ca400b003a018252e29mr32279wmb.11.1658499385946; Fri, 22 Jul 2022 07:16:25 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:25 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 05/13] fpga: xilinx: pass compatible flags to xilinx_load() Date: Fri, 22 Jul 2022 17:16:06 +0300 Message-Id: <20220722141614.297383-6-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-5-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean This flag is used to check whether a Xilinx FPGA driver is able to load a particular FPGA bitstream image. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v1) drivers/fpga/fpga.c | 2 +- drivers/fpga/xilinx.c | 2 +- include/xilinx.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 3b0a44b2420..efbac9f0c47 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -263,7 +263,7 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) case fpga_xilinx: #if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_load(desc->devdesc, buf, bsize, - bstype); + bstype, 0); #else fpga_no_sup((char *)__func__, "Xilinx devices"); #endif diff --git a/drivers/fpga/xilinx.c b/drivers/fpga/xilinx.c index 6bc1bc491fb..5dd721575ec 100644 --- a/drivers/fpga/xilinx.c +++ b/drivers/fpga/xilinx.c @@ -139,7 +139,7 @@ int fpga_loadbitstream(int devnum, char *fpgadata, size_t size, } int xilinx_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { if (!xilinx_validate (desc, (char *)__FUNCTION__)) { printf ("%s: Invalid device descriptor\n", __FUNCTION__); diff --git a/include/xilinx.h b/include/xilinx.h index ff5486d98a7..0bbf14d8a1d 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -68,7 +68,7 @@ struct xilinx_fpga_op { /* Generic Xilinx Functions *********************************************************************/ int xilinx_load(xilinx_desc *desc, const void *image, size_t size, - bitstream_type bstype); + bitstream_type bstype, int flags); int xilinx_dump(xilinx_desc *desc, const void *buf, size_t bsize); int xilinx_info(xilinx_desc *desc); int xilinx_loadfs(xilinx_desc *desc, const void *buf, size_t bsize, From patchwork Fri Jul 22 14:16:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659600 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=lIEprDU7; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBNX1BzQz9sGq for ; Sat, 23 Jul 2022 00:17:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B54D48410A; Fri, 22 Jul 2022 16:16:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="lIEprDU7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C74B683FC0; Fri, 22 Jul 2022 16:16:32 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 7816683FB6 for ; Fri, 22 Jul 2022 16:16:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x335.google.com with SMTP id a18-20020a05600c349200b003a30de68697so5160247wmq.0 for ; Fri, 22 Jul 2022 07:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=4xVw5YUNc0TlZDpJKuWnxj6eLuVGdaGjYO5KZ+KqDeU=; b=lIEprDU7xmQ0lF/pomVDuz+mTYma7Ji4cyouYIb8Nq318BsfynTXpcC+NlEK6Ec5yd KOhBZtrDRTujwzsT5NZSWUJo6cqZHK5ok/mUcdvk6Sf3ImyPYhcc2olZDUUXa1UmW6/c kU6SkDw6+8Ckr6IQTfQz8LfAfVnYKjZ7pIa5CI+r/cVoMVL49XW9FrgOOR6s8lV0we6h GbclshYrdSvAY0R5iwSD9r5pS9D0hdrbrEX0lb8jT35ZfjFn3VdwYE6TRf1RndNcu9B7 Op7vvJTokzaep9AI0fTOj0Hv6GvyPgeigvKxLImb+Fb41PCt2Tx7/Hs+icVSARfrqo2N 1+tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=4xVw5YUNc0TlZDpJKuWnxj6eLuVGdaGjYO5KZ+KqDeU=; b=l6UYCkki4X73tgfWmkSryURq+Xe2zlRXyslbQcn/1N18RCE6r5R5NcBFNV5g4j2fGP jz+DVOZ6cItSwjm4/UW9cfBjw1Gito6UwfklMkEQI32tXOFUR1PiXgcbSVuskiXorI0m N+zieOCWRD4uZQdpHtoG5Xs5UQFR6r6zP+N1EcmlC/BKu7e/9GC8TlDBzO6bDf47c2rW qVXFC+EpARt7tYM3gPh99as0iDFfdZhK/LBCvYFL1BUuy/z2WbORkgM1eZEbVLVPlL7q yR5asGlLiw0+AWWAb7B4QVjXOuAM/aLmFl0C531thqIQ8DRjBdxaz/wtwO4MVJMriDln k25A== X-Gm-Message-State: AJIora/r3bL3ooDJyWWegiJz+gG9gTZVYhAKt8VldConkLMzat2I+FXu hRiOTAplBQySCKnth0Pa+Vfx4cQamrZbtg== X-Google-Smtp-Source: AGRyM1ttukOIlgIcTiB00B1P/z9WN8NbocIiDLTF3YtJue5Dm+htDHLTmKShJFAAoho3ZcfYRvRSqQ== X-Received: by 2002:a05:600c:4e10:b0:3a3:194d:dafb with SMTP id b16-20020a05600c4e1000b003a3194ddafbmr56905wmq.90.1658499387715; Fri, 22 Jul 2022 07:16:27 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:26 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Alexandru Gagniuc , Artem Lapkin , Aswath Govindraju , Heiko Schocher , Leo Yu-Chi Liang , Michal Simek , Nishanth Menon , Simon Glass Subject: [PATCH v12 06/13] fpga: pass compatible flags to fpga_load() Date: Fri, 22 Jul 2022 17:16:07 +0300 Message-Id: <20220722141614.297383-7-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-6-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean These flags may be used to check whether an FPGA driver is able to load a particular FPGA bitstream image. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v1) boot/image-board.c | 4 ++-- cmd/fpga.c | 8 ++++---- common/spl/spl_fit.c | 6 ++++-- drivers/fpga/fpga.c | 5 +++-- drivers/fpga/xilinx.c | 2 +- include/fpga.h | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/boot/image-board.c b/boot/image-board.c index cfc1c658e3a..9110617be26 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -703,14 +703,14 @@ int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images, img_len, BIT_FULL); if (err) err = fpga_load(devnum, (const void *)img_data, - img_len, BIT_FULL); + img_len, BIT_FULL, 0); } else { name = "partial"; err = fpga_loadbitstream(devnum, (char *)img_data, img_len, BIT_PARTIAL); if (err) err = fpga_load(devnum, (const void *)img_data, - img_len, BIT_PARTIAL); + img_len, BIT_PARTIAL, 0); } if (err) diff --git a/cmd/fpga.c b/cmd/fpga.c index 3fdd0b35e80..c4651dd403e 100644 --- a/cmd/fpga.c +++ b/cmd/fpga.c @@ -178,7 +178,7 @@ static int do_fpga_load(struct cmd_tbl *cmdtp, int flag, int argc, if (ret) return ret; - return fpga_load(dev, (void *)fpga_data, data_size, BIT_FULL); + return fpga_load(dev, (void *)fpga_data, data_size, BIT_FULL, 0); } static int do_fpga_loadb(struct cmd_tbl *cmdtp, int flag, int argc, @@ -209,7 +209,7 @@ static int do_fpga_loadp(struct cmd_tbl *cmdtp, int flag, int argc, if (ret) return ret; - return fpga_load(dev, (void *)fpga_data, data_size, BIT_PARTIAL); + return fpga_load(dev, (void *)fpga_data, data_size, BIT_PARTIAL, 0); } #endif @@ -315,7 +315,7 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int flag, int argc, data_size = image_get_data_size(hdr); } return fpga_load(dev, (void *)data, data_size, - BIT_FULL); + BIT_FULL, 0); } #endif #if defined(CONFIG_FIT) @@ -355,7 +355,7 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - return fpga_load(dev, fit_data, data_size, BIT_FULL); + return fpga_load(dev, fit_data, data_size, BIT_FULL, 0); } #endif default: diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 1bbf824684a..3c5a91916cc 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -581,6 +581,8 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node, { const char *compatible; int ret; + int devnum = 0; + int flags = 0; debug("FPGA bitstream at: %x, size: %x\n", (u32)fpga_image->load_addr, fpga_image->size); @@ -591,8 +593,8 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node, else if (strcmp(compatible, "u-boot,fpga-legacy")) printf("Ignoring compatible = %s property\n", compatible); - ret = fpga_load(0, (void *)fpga_image->load_addr, fpga_image->size, - BIT_FULL); + ret = fpga_load(devnum, (void *)fpga_image->load_addr, + fpga_image->size, BIT_FULL, flags); if (ret) { printf("%s: Cannot load the image to the FPGA\n", __func__); return ret; diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index efbac9f0c47..185bd547cb5 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -252,7 +252,8 @@ int fpga_loads(int devnum, const void *buf, size_t size, /* * Generic multiplexing code */ -int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) +int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype, + int flags) { int ret_val = FPGA_FAIL; /* assume failure */ const fpga_desc *desc = fpga_validate(devnum, buf, bsize, @@ -263,7 +264,7 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) case fpga_xilinx: #if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_load(desc->devdesc, buf, bsize, - bstype, 0); + bstype, flags); #else fpga_no_sup((char *)__func__, "Xilinx devices"); #endif diff --git a/drivers/fpga/xilinx.c b/drivers/fpga/xilinx.c index 5dd721575ec..d9951ca3ecf 100644 --- a/drivers/fpga/xilinx.c +++ b/drivers/fpga/xilinx.c @@ -135,7 +135,7 @@ int fpga_loadbitstream(int devnum, char *fpgadata, size_t size, dataptr += 4; printf(" bytes in bitstream = %d\n", swapsize); - return fpga_load(devnum, dataptr, swapsize, bstype); + return fpga_load(devnum, dataptr, swapsize, bstype, 0); } int xilinx_load(xilinx_desc *desc, const void *buf, size_t bsize, diff --git a/include/fpga.h b/include/fpga.h index ec5144334df..6365e1569e3 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -64,7 +64,7 @@ int fpga_count(void); const fpga_desc *const fpga_get_desc(int devnum); int fpga_is_partial_data(int devnum, size_t img_len); int fpga_load(int devnum, const void *buf, size_t bsize, - bitstream_type bstype); + bitstream_type bstype, int flags); int fpga_fsload(int devnum, const void *buf, size_t size, fpga_fs_info *fpga_fsinfo); int fpga_loads(int devnum, const void *buf, size_t size, From patchwork Fri Jul 22 14:16:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659601 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=kGHsOv0P; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBNm68ysz9sGq for ; Sat, 23 Jul 2022 00:18:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B54684118; Fri, 22 Jul 2022 16:16:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="kGHsOv0P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FE5F83FB3; Fri, 22 Jul 2022 16:16:33 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 B377B83FA1 for ; Fri, 22 Jul 2022 16:16:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wr1-x431.google.com with SMTP id b26so6713252wrc.2 for ; Fri, 22 Jul 2022 07:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=bsHESJOEjr7Rh7blPzvcLAbmsxSRmNbGvDSf7ST8V1E=; b=kGHsOv0PQ2eTZICmePSbhfrpVBbbrWqhmgiCsT4M8k8qT/hLdelIU3c/implrrUsR+ 7oGsT/7npOgPn0DnLgycbmGw3h0/SrN0W8mwYaNAqeIS9k7feaP3ypS8wf1Ejkwdpc6j RMJHf983iJwuzBe+iZHom8rIAM0jEWaf0qEjrboPxmrUUsEguEqDPqR29fYYSF9arQVt wbxGdL1SiUF82zxDZA4Lp+Pafbb/D8ug7oVZIOEjLdOPUQIc/8lfo1jrh9PVQ4A4txD3 beTzdQNsEzbLiiDHtBfUzErMy5BjJXHRrn/sqsLoryv5NmhrISqvhLFM/JVQJg/IhlVG 79Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=bsHESJOEjr7Rh7blPzvcLAbmsxSRmNbGvDSf7ST8V1E=; b=znKYaaP8vX4sIhrXUva0czQi8JiaKrjRF9yjv7JedJmISWwHO8dBYZtaRz3eQEMLHA rjffI/W6piDgPkUhgkaH3X6cFQ3Kd7OZu/qrlEC9lcBYamwR8CPt2rI/B1/+Soxi2hbW TiLvN/30VRIBJY55wHOejxL4epaTDUHgd5wjLE3l6aR/Or1d0wuRaGzyE0tIxuN/OU1s ypYDyZoVXpyTrjpBiHkQJP1gQFgm4yfBUNIA1u0jmK0NH8temI2b/E4fQ41VDRPg6Tn5 KtwyW+yb2cL6GTAfamD90mIDwkMSMfFtlqxaQllptqWBMqRz+NdKNAjlTseC4/+0f/3e MYig== X-Gm-Message-State: AJIora8e8c1wySoB8J/ve2AEvdL23CNp6V358yLbCR/SVBG9TKDmDnh9 mM6BQqj1vPonet6Gp3wpMaIdV2DEeVFUdA== X-Google-Smtp-Source: AGRyM1vjQ3ErX6wTOLw4JOBX1uNg5X1XPTsbNPy2R+vPmcH3rEQEDQgCBiALJfJu7YjJICHiXQO5Tw== X-Received: by 2002:adf:e187:0:b0:21d:64c6:74f0 with SMTP id az7-20020adfe187000000b0021d64c674f0mr85071wrb.221.1658499388953; Fri, 22 Jul 2022 07:16:28 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:28 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 07/13] fpga: add fpga_compatible2flag Date: Fri, 22 Jul 2022 17:16:08 +0300 Message-Id: <20220722141614.297383-8-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-7-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Add a "compatible" string to binary flag converter, which uses a callback str2flag() of given FPGA driver if available. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- Changes in v12: - define the function only if FPGA_LOAD_SECURE enabled; Changes in v10: - fix mixed types of return value; drivers/fpga/fpga.c | 26 ++++++++++++++++++++++++++ include/fpga.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 185bd547cb5..4db5c0a91e9 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -357,3 +357,29 @@ int fpga_info(int devnum) return fpga_dev_info(devnum); } + +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) +int fpga_compatible2flag(int devnum, const char *compatible) +{ + const fpga_desc * const desc = fpga_get_desc(devnum); + + if (!desc) + return 0; + + switch (desc->devtype) { +#if defined(CONFIG_FPGA_XILINX) + case fpga_xilinx: + { + xilinx_desc *xdesc = (xilinx_desc *)desc->devdesc; + + if (xdesc->operations && xdesc->operations->str2flag) + return xdesc->operations->str2flag(xdesc, compatible); + } +#endif + default: + break; + } + + return 0; +} +#endif diff --git a/include/fpga.h b/include/fpga.h index 6365e1569e3..13b1bbee3ca 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -75,5 +75,6 @@ int fpga_dump(int devnum, const void *buf, size_t bsize); int fpga_info(int devnum); const fpga_desc *const fpga_validate(int devnum, const void *buf, size_t bsize, char *fn); +int fpga_compatible2flag(int devnum, const char *compatible); #endif /* _FPGA_H_ */ From patchwork Fri Jul 22 14:16:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659602 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=eFJ5oPxP; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBP13lVRz9sGq for ; Sat, 23 Jul 2022 00:18:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BB068840FC; Fri, 22 Jul 2022 16:16:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="eFJ5oPxP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CFD8E83F9F; Fri, 22 Jul 2022 16:16:37 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 2A67383F9F for ; Fri, 22 Jul 2022 16:16:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wr1-x435.google.com with SMTP id k11so6241330wrx.5 for ; Fri, 22 Jul 2022 07:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=DtkR1zxYl3vL08tBJRnGC456tJdl26bRW2gHvYe7Qf4=; b=eFJ5oPxPRgi1zIUv0HTSfKxPayHoAw0va9JFkR65w1x8Pw8GRMgef/PMej+d0Ul0yU UBgPN0UnUaOOkGMuT+CYblw2oVh3zMcy4pakmZN1chuZRbDswasDM4DL7N1vu9o8XaLU S2i2ftXOkQLojrxGYGxbMfXdvPi8AB6Bm8HhXHSXBBO7wLMboU740y6/PPB6xArSbnlp A03eBoGcaOy4dpX5xFaY15oONRfllH5qn6Xr5WkdLND9JVdk6unQY3VcMGNr0Pasi+HT HWpyZjw6U5jigIQwrxvR76LA9R7S8U68JDLvxfh78+9b5Cpv/9xwjHOrdtVjQLwZKQ2e w6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=DtkR1zxYl3vL08tBJRnGC456tJdl26bRW2gHvYe7Qf4=; b=gIkaKG/XQIALgrTSHbQJc9J9cxY2zA3p06SEdYAFlLT0AG5W2k4imEFNyItagV+X47 BecJJVtYJ6C5Zc7Qhs5udbqeNzudcs9zVGHoPFU979zH9YSBGTFmnA4XZSUYKjhECte8 pTHg5uv+hQ9EruzRn2KsboNtfhlnIkN7zxls3jVAg+FIJKNeftgX0JeU8hOSv4VnVRAW pnq4FwpdNkPJ/ceH/vMPR8ofsErBWBm3UrBCWWfVjYSLhdb/XX6ryZ6trWKtTFt+EpsS THgdRxUo2SkDKi3OmkkK54Qv4Pw/3xVur9RaRrwQL4nPPXn6/hm2FeL6Gpt5ip27zGzK af5w== X-Gm-Message-State: AJIora8v7gKEeAEcCYN5q+jjZtyIyWZg4Kcy2Otvclz6xWGhM3i0tPR2 1J4MUEyYlFqaJ8vNR0EeiwS4Zj6jHJX5SA== X-Google-Smtp-Source: AGRyM1ui4J1uvBKouIKHceuRX4M61co643sQkkIhPnsXBcJnirocWedU+1baDlfbBqV3LqUbK7S2bw== X-Received: by 2002:a5d:5451:0:b0:21d:2295:6a05 with SMTP id w17-20020a5d5451000000b0021d22956a05mr106316wrv.302.1658499390351; Fri, 22 Jul 2022 07:16:30 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:29 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Aswath Govindraju , Heiko Schocher , Nishanth Menon , Simon Glass Subject: [PATCH v12 08/13] spl: fit: pass real compatible flags to fpga_load() Date: Fri, 22 Jul 2022 17:16:09 +0300 Message-Id: <20220722141614.297383-9-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-8-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> <20220722141614.297383-8-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Convert taken FPGA image "compatible" string to a binary compatible flag and pass it to an FPGA driver. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- Changes in v12: - convert "compatible" to flags only if FPGA_LOAD_SECURE enabled; Changes in v10: - made the message about ignoring legacy compatibe option as debug; common/spl/spl_fit.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 3c5a91916cc..a35be529656 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -588,10 +588,15 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node, (u32)fpga_image->load_addr, fpga_image->size); compatible = fdt_getprop(ctx->fit, node, "compatible", NULL); - if (!compatible) + if (!compatible) { warn_deprecated("'fpga' image without 'compatible' property"); - else if (strcmp(compatible, "u-boot,fpga-legacy")) - printf("Ignoring compatible = %s property\n", compatible); + } else { + if (CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)) + flags = fpga_compatible2flag(devnum, compatible); + if (strcmp(compatible, "u-boot,fpga-legacy")) + debug("Ignoring compatible = %s property\n", + compatible); + } ret = fpga_load(devnum, (void *)fpga_image->load_addr, fpga_image->size, BIT_FULL, flags); From patchwork Fri Jul 22 14:16:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659605 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=Clo1kin9; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBPj0H6nz9sGq for ; Sat, 23 Jul 2022 00:18:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39D1884147; Fri, 22 Jul 2022 16:17:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="Clo1kin9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9269583FB2; Fri, 22 Jul 2022 16:16:37 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 6BBEE83FB5 for ; Fri, 22 Jul 2022 16:16:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x334.google.com with SMTP id f24-20020a1cc918000000b003a30178c022so5281539wmb.3 for ; Fri, 22 Jul 2022 07:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=GPBko3PC5F0/Et2PZHDcaRyUUZD5nV6U7YTCVcHIgy8=; b=Clo1kin9LqpYVq9pRR1Aogu+Bt0x8BtfaSjbdw60/MVBIgybittllZRAYoFlby7i8P TY99ToerB5/T+rl4KRfBQf/1FYamkaczY8mY4YIX36rY0edBFsRX/+ocAX8oWb7R9UXi 0GniHeZ7h1U9HPOsRGyQxzV/uTl+5t1lEWBESM337qqGddC6/cWeOoMj76yotGQMBhfO Dk7cC1tgf45OyfdZDLzApFEVjGBAFzxSHqwSqHag96122wK6s/7t+eft2m0wju30o6Fk fHQyDXNJty/hgyqnlHSHB/5Nsi0xGzbuKEmKXJGM2G/SBaQWHtFvBAL4KHgU3hck4vRV AqJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=GPBko3PC5F0/Et2PZHDcaRyUUZD5nV6U7YTCVcHIgy8=; b=SzEVUjT9Ue/cjYC7Vzb47UCgTVffa2w9HYL08IGzyPDm+nmBIXuLlR0VijkhrpjkAe zgAO8tIXxL6hHcUfuQS6yzV/TwwrYdcOQ6I2GSGdv383ChQE2erq3sjOSf3My+4Cl1X0 G6Mnn/RVRhoLibrPvB20Q0ONRvFS61kCKqsWHkwZetWUIs2zFkd4Vt6qTTHUfF/H04W9 1IusTWWqwoWimKigBKgWHWkQDB2tAM4JrRXmhaVg/qVcQJ5kT2Hrt0vAC5RqhGyN+xnF eIfUC5RgMPx55De3GcyON8+74DR0ObtYuLu6OFlhvXQjmGFGiMCDw+aPjzmVGUqlaVHg 0C+w== X-Gm-Message-State: AJIora//w/VZ/KI51wnkO44UjLycYUUhrQZms5eRSirdNajmM67CFGaE kdgG9IKZzthU75j4PHQpGdt+WKAWe7H/GQ== X-Google-Smtp-Source: AGRyM1sOk04y79JSeTyNmPyq/gjN0Ty5rQV3y3b2QJps0KyxYjgI4K9tiZFxgK+w14URx4VRIs76Yg== X-Received: by 2002:a05:600c:3d93:b0:3a3:3a78:5411 with SMTP id bi19-20020a05600c3d9300b003a33a785411mr4375349wmb.114.1658499391533; Fri, 22 Jul 2022 07:16:31 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:31 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 09/13] fpga: xilinx: pass compatible flags to load() callback Date: Fri, 22 Jul 2022 17:16:10 +0300 Message-Id: <20220722141614.297383-10-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-9-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> <20220722141614.297383-8-oleksandr.suvorov@foundries.io> <20220722141614.297383-9-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean These flags may be used to check whether an FPGA driver is able to load a particular FPGA bitstream image. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (no changes since v1) drivers/fpga/spartan2.c | 2 +- drivers/fpga/spartan3.c | 2 +- drivers/fpga/versalpl.c | 2 +- drivers/fpga/virtex2.c | 2 +- drivers/fpga/xilinx.c | 2 +- drivers/fpga/zynqmppl.c | 2 +- drivers/fpga/zynqpl.c | 2 +- include/xilinx.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/fpga/spartan2.c b/drivers/fpga/spartan2.c index 3435400e58b..328740f3f35 100644 --- a/drivers/fpga/spartan2.c +++ b/drivers/fpga/spartan2.c @@ -41,7 +41,7 @@ static int spartan2_ss_dump(xilinx_desc *desc, const void *buf, size_t bsize); /* ------------------------------------------------------------------------- */ /* Spartan-II Generic Implementation */ static int spartan2_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { int ret_val = FPGA_FAIL; diff --git a/drivers/fpga/spartan3.c b/drivers/fpga/spartan3.c index 4850c99352d..918f6db5065 100644 --- a/drivers/fpga/spartan3.c +++ b/drivers/fpga/spartan3.c @@ -45,7 +45,7 @@ static int spartan3_ss_dump(xilinx_desc *desc, const void *buf, size_t bsize); /* ------------------------------------------------------------------------- */ /* Spartan-II Generic Implementation */ static int spartan3_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { int ret_val = FPGA_FAIL; diff --git a/drivers/fpga/versalpl.c b/drivers/fpga/versalpl.c index c44a7d34557..d3876a8f541 100644 --- a/drivers/fpga/versalpl.c +++ b/drivers/fpga/versalpl.c @@ -27,7 +27,7 @@ static ulong versal_align_dma_buffer(ulong *buf, u32 len) } static int versal_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { ulong bin_buf; int ret; diff --git a/drivers/fpga/virtex2.c b/drivers/fpga/virtex2.c index b3e0537bab0..83b90298cad 100644 --- a/drivers/fpga/virtex2.c +++ b/drivers/fpga/virtex2.c @@ -94,7 +94,7 @@ static int virtex2_ss_load(xilinx_desc *desc, const void *buf, size_t bsize); static int virtex2_ss_dump(xilinx_desc *desc, const void *buf, size_t bsize); static int virtex2_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { int ret_val = FPGA_FAIL; diff --git a/drivers/fpga/xilinx.c b/drivers/fpga/xilinx.c index d9951ca3ecf..8170c3368ef 100644 --- a/drivers/fpga/xilinx.c +++ b/drivers/fpga/xilinx.c @@ -151,7 +151,7 @@ int xilinx_load(xilinx_desc *desc, const void *buf, size_t bsize, return FPGA_FAIL; } - return desc->operations->load(desc, buf, bsize, bstype); + return desc->operations->load(desc, buf, bsize, bstype, flags); } #if defined(CONFIG_CMD_FPGA_LOADFS) diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 19d079c9d9f..a0624567882 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -200,7 +200,7 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf, } static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { ALLOC_CACHE_ALIGN_BUFFER(u32, bsizeptr, 1); u32 swap = 0; diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c index 2de40109a81..d8ebd542abd 100644 --- a/drivers/fpga/zynqpl.c +++ b/drivers/fpga/zynqpl.c @@ -371,7 +371,7 @@ static int zynq_validate_bitstream(xilinx_desc *desc, const void *buf, } static int zynq_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype) + bitstream_type bstype, int flags) { unsigned long ts; /* Timestamp */ u32 isr_status, swap; diff --git a/include/xilinx.h b/include/xilinx.h index 0bbf14d8a1d..e5f6db33fa2 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -53,7 +53,7 @@ typedef struct { /* typedef xilinx_desc */ struct xilinx_fpga_op { int (*load)(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype); + bitstream_type bstype, int flags); int (*loadfs)(xilinx_desc *desc, const void *buf, size_t bsize, fpga_fs_info *fpga_fsinfo); int (*loads)(xilinx_desc *desc, const void *buf, size_t bsize, From patchwork Fri Jul 22 14:16:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659603 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=FnFad/un; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBPF3Wlfz9sGq for ; Sat, 23 Jul 2022 00:18:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC4B884130; Fri, 22 Jul 2022 16:17:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="FnFad/un"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63F52802C2; Fri, 22 Jul 2022 16:16:37 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 06680802C2 for ; Fri, 22 Jul 2022 16:16:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x32d.google.com with SMTP id v5so2893597wmj.0 for ; Fri, 22 Jul 2022 07:16:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Bx86YStYEuPPdwRUvM2cW3VDNBc4v+FZlbfdsKKKoP0=; b=FnFad/unmo4hLI760CKBAgXFj4ptNwrANd0OC4Hyy/4CSh9oydgkuJH+qrsRER2YPI 5s9i1VSf112MwPk59NGg/eWM8r0LwMLqIJqmYX6EqfERJMfcqwWDqcQPyvgwQqvxGn/B 71QgPxX38SPgYHiA8G66bQJz/Ez1lg0BiMy7c+2+xp/ktx5iADgLecFoN4kPG8wufDAZ /J6Z4nYZ1ra4ww9hnjLb9TvjksmlJjQltJtjjRoS+7FItjtECI1rnaIxNyH+2kKUepJc Dn1PGtqj4rf2Hd5h82Z2hx1XRsqrcx/ALavTk+5WRNd7Ya3DiyPP4THb2Kh8bbbqtICH wScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Bx86YStYEuPPdwRUvM2cW3VDNBc4v+FZlbfdsKKKoP0=; b=6WcF3eOcl1fTjjPxAfbgzjvFsMwcHHT4FNh0b18O7mD04+cpGfNhfLWLlLODHcAWFX t6hwzoUaGKefTBsi4hzdIVg7XVE7PE64nHKVUh+JD5adJ7sldmz4938iOYqf87BlBoSh djbIcneDJCsBLxmGeqfubSGdnesjszJqjG/+wQnIpSP7E5lMOxzt3l/sG65W1K5kdarn LlqcQ6MXWd+8ncWr+B1Ch5GKRzhwCH97sL88+f4f3NYwHavGiroh+3jhhn/iWO1I6xbl E7ypCiaz6XN2UjBACb0YXsMJUyHIn1kbxaZPz+hMLql6ukbrKZ0geJFEpvwqgZi9Lubr Z3kA== X-Gm-Message-State: AJIora/99BmszJGwOp76FviC7VjtFtPDT5GS+uGKUaWHyS1BbRwYGq5V egLFBxld0RrUnxLuT6E4KIp2TIVYzfFcaw== X-Google-Smtp-Source: AGRyM1ts/ESHDHczsGg5vTbvV29d51eDHeeJXscPkqOC7xtHHBn1qPXVkwCL004MiKALNB6UoBqC/g== X-Received: by 2002:a7b:ce13:0:b0:3a3:102c:23d3 with SMTP id m19-20020a7bce13000000b003a3102c23d3mr24865wmc.67.1658499392638; Fri, 22 Jul 2022 07:16:32 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:32 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 10/13] fpga: zynqmp: reduce zynqmppl_load() code Date: Fri, 22 Jul 2022 17:16:11 +0300 Message-Id: <20220722141614.297383-11-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-10-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> <20220722141614.297383-8-oleksandr.suvorov@foundries.io> <20220722141614.297383-9-oleksandr.suvorov@foundries.io> <20220722141614.297383-10-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Reduce the function code by calling xilinx_pm_request() once only. Use the same variable bsize_req to store either bstream size in bytes or an address of bstream size according to a type required by the firmware version. Remove obsolete debug(). Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- Changes in v12: - fix a commit message - remove obsolete debug() message drivers/fpga/zynqmppl.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index a0624567882..2791f931861 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -207,38 +207,33 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, ulong bin_buf; int ret; u32 buf_lo, buf_hi; + u32 bsize_req = (u32)bsize; u32 ret_payload[PAYLOAD_ARG_CNT]; - bool xilfpga_old = false; if (zynqmp_firmware_version() <= PMUFW_V1_0) { puts("WARN: PMUFW v1.0 or less is detected\n"); puts("WARN: Not all bitstream formats are supported\n"); puts("WARN: Please upgrade PMUFW\n"); - xilfpga_old = true; if (zynqmp_validate_bitstream(desc, buf, bsize, bsize, &swap)) return FPGA_FAIL; bsizeptr = (u32 *)&bsize; flush_dcache_range((ulong)bsizeptr, (ulong)bsizeptr + sizeof(size_t)); + bsize_req = (u32)(uintptr_t)bsizeptr; bstype |= BIT(ZYNQMP_FPGA_BIT_NS); + } else { + bstype = 0; } bin_buf = zynqmp_align_dma_buffer((u32 *)buf, bsize, swap); - debug("%s called!\n", __func__); flush_dcache_range(bin_buf, bin_buf + bsize); buf_lo = (u32)bin_buf; buf_hi = upper_32_bits(bin_buf); - if (xilfpga_old) - ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo, - buf_hi, (u32)(uintptr_t)bsizeptr, - bstype, ret_payload); - else - ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo, - buf_hi, (u32)bsize, 0, ret_payload); - + ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo, buf_hi, + bsize_req, bstype, ret_payload); if (ret) printf("PL FPGA LOAD failed with err: 0x%08x\n", ret); From patchwork Fri Jul 22 14:16:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659604 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=f9bkHZeI; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBPT3r4fz9sGq for ; Sat, 23 Jul 2022 00:18:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F13A8413B; Fri, 22 Jul 2022 16:17:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="f9bkHZeI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5537D840F1; Fri, 22 Jul 2022 16:16:38 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 B4BA783FC2 for ; Fri, 22 Jul 2022 16:16:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x334.google.com with SMTP id f24-20020a1cc918000000b003a30178c022so5281679wmb.3 for ; Fri, 22 Jul 2022 07:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=r3eFHRC8v0swl+yPRgzqrcpxHAOz0SPSWTo9CLuYgHg=; b=f9bkHZeI5ENLDZWg30MI8IDYsKvQgID8VCcOPzuSlyvg06Z/HJfFaoTXcKMrP8PItT +8DzvO4z7O+QPgjS5/E+RtB8STRKcWhUeUeD1CtMwWOTrSNu/lJmulUeCubr3L6CNPsc YZVMEWKvjEYKB+HMC9Xu6sQ+Pg/kDjDpoRPsGR2+ubNW0Hqo0/MukD2iy5vh0RWvMRq8 4OatTh+8VzNTNq9a02U3P8SPjM+aAYY0alPaNVp+KCAqwlFU7i8+fOhdZ1ckkjI2UxY0 oBtpqAy4wuKBA7qy4GWxMc9d2N1A0d/isGFOWtznebZ5I2fRIlToCLxnfJay8RPj7qlW 0YFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=r3eFHRC8v0swl+yPRgzqrcpxHAOz0SPSWTo9CLuYgHg=; b=wrORPPK78ZL4AT4cu4jG2QabSNY3yqngcLNUHz6zhMnJVTkb+m0pntl50Wh/gPEy1q L4Bk+ykaFJWMCy/nupKLZkM3hmng9v7isCJ5KIbKQM7nzKStWp1QyNzpQ7eTqoZ7vlKS ub5YHBFFrE04x4gb/AN3d10hSHMkaEOFzMTr7pgVw98QCHE5zJa0AwqO9+sY1QFwD1pa FnSNFqmIItGyxxFoLtrVrEgXWPjCoKrIAXMbvWarnpuRt29+DdU/iL/YyEfcQ1psnWHw XjrKXRWfNZVIOnKIyIwI5vFnvVgCrWQM9NZYBTcCCH/RTC0GFTXcF33n11cwlTpsJ9ES IX2A== X-Gm-Message-State: AJIora9XZWzWRN8URhag8r7nQLZfJXnA68TkqgFJQao2I+d3QM3XTWbb X/dkYergJx7F7MH1mu3om+lC6gPhit9m4g== X-Google-Smtp-Source: AGRyM1vBGs7v0dZVDOdu3h0bQfmvOcnG+dfpvjPiAuffJp4apnSjQU7+wNBnGzzpJuFnDHiFo5RoWw== X-Received: by 2002:a7b:ca48:0:b0:3a3:365d:1089 with SMTP id m8-20020a7bca48000000b003a3365d1089mr13338wml.153.1658499394268; Fri, 22 Jul 2022 07:16:34 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:33 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 11/13] fpga: zynqmp: add bitstream compatible checking Date: Fri, 22 Jul 2022 17:16:12 +0300 Message-Id: <20220722141614.297383-12-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-11-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> <20220722141614.297383-8-oleksandr.suvorov@foundries.io> <20220722141614.297383-9-oleksandr.suvorov@foundries.io> <20220722141614.297383-10-oleksandr.suvorov@foundries.io> <20220722141614.297383-11-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Check whether the FPGA ZynqMP driver supports the given bitstream image type. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- Changes in v12: - exclude all secure-related code if FPGA_LOAD_SECURE is disabled Changes in v10: - fix grammar drivers/fpga/zynqmppl.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 2791f931861..feaf34fff11 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -199,6 +199,28 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf, return 0; } +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) +static int zynqmp_check_compatible(xilinx_desc *desc, int flags) +{ + /* If no flags set, the image is legacy */ + if (!flags) + return 0; + + /* For legacy bitstream images no need for other methods exist */ + if ((flags & desc->flags) && flags == FPGA_LEGACY) + return 0; + + /* + * Other images are handled in secure callback loads(). Check + * callback existence besides image type support. + */ + if (desc->operations->loads && (flags & desc->flags)) + return 0; + + return FPGA_FAIL; +} +#endif + static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, bitstream_type bstype, int flags) { @@ -210,6 +232,18 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, u32 bsize_req = (u32)bsize; u32 ret_payload[PAYLOAD_ARG_CNT]; +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) + ret = zynqmp_check_compatible(desc, flags); + if (ret) { + if (ret != -ENODATA) { + puts("Missing loads() operation or unsupported bitstream type\n"); + return FPGA_FAIL; + } + /* If flags is not set, the image treats as legacy */ + flags = FPGA_LEGACY; + } +#endif + if (zynqmp_firmware_version() <= PMUFW_V1_0) { puts("WARN: PMUFW v1.0 or less is detected\n"); puts("WARN: Not all bitstream formats are supported\n"); From patchwork Fri Jul 22 14:16:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659606 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=aoWpTr18; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBPw5F3qz9sGq for ; Sat, 23 Jul 2022 00:19:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1F92A84129; Fri, 22 Jul 2022 16:17:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="aoWpTr18"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CCED802C2; Fri, 22 Jul 2022 16:16:42 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 19BCC83FC0 for ; Fri, 22 Jul 2022 16:16:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wm1-x335.google.com with SMTP id a18-20020a05600c349200b003a30de68697so5160388wmq.0 for ; Fri, 22 Jul 2022 07:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=kI0Zz0akKOaQCJW1MH+a2iR+Xy8nZy8mCElFSDdwvD4=; b=aoWpTr186kAEDVejZsSJe/KPy5yvGecrk93jWOlIBUGdvP8W0zgiclOXNQcCTuzsHr xGqfGeAbmGBzVc+fRhgEdaCO1WY+wqEWjsNuq7it0kM8zn67Nf/RthNRf5jyksPZLZYm pM8+aH+KsDKhUrpqDumrX6BmeuFwgyYJivIcvwWYFtpLnu1spGM6ObgbVf+XbDgbhxGz mNMi7Q4CKn8rtYvlCMGhZbcYCIO4eiHrBSUDnWaUsbIm5Ve5R/c4IycuFSjlW4K+0WNG +B3NTj8082SrMvdOjK1cSKkhTNnMPUwYwFynlJsnAu/N4wObsenvHUwUxkkB4BSg9r2D mfWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=kI0Zz0akKOaQCJW1MH+a2iR+Xy8nZy8mCElFSDdwvD4=; b=m1xfOYjwGltp7GZgTKuIFadDJvrV4ebgAhybpPlZkwgtdFZVRnqZqZ7rzenfE7qVln q/2+Er5UgKZRsUNgWViIG6KbuPg7DLvNIzgVNUTxE8xz/N6SYSdRv0HUl7rlgYFJXBCT CJ6l4ASHe5UdyRHASY6+dHhbBKSstNXuwOpLso8xS0mGp0WXjeaxpXceKoQUt9wBlC1y S5Ww5O+qZJAOLgc546fxFEX6ZtIeSR9OZ4CZ/pthpaA5xKJcWyqPFBWYHfHAInYhkcHB 4I6JkPVdaiiLgX7kbInAYpnoKBEGNP+WGuSQVS7pEfji7kQ84vf/xJ3eqwLky2gbw3Ee lTWQ== X-Gm-Message-State: AJIora/J3pmLffLkl9pd/3B4p9RDo9HOyzhHSH5OwTaZ2oi+bJTjQgD2 bboZx0G4hy5v2EMqM3ODCq6rjPNLTOsaTg== X-Google-Smtp-Source: AGRyM1s/7fNg/oLw+Pt9DDBHnuUVCsHDXljOypcziFCaIdf4C2kKSRD7TOwA0qGQnYeABRj7i/B5sA== X-Received: by 2002:a7b:cbd1:0:b0:3a3:187a:296c with SMTP id n17-20020a7bcbd1000000b003a3187a296cmr12585246wmi.123.1658499395571; Fri, 22 Jul 2022 07:16:35 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:35 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Alexandru Gagniuc , Michal Simek , Simon Glass , Steffen Jaeckel Subject: [PATCH v12 12/13] fpga: zynqmp: support loading authenticated images Date: Fri, 22 Jul 2022 17:16:13 +0300 Message-Id: <20220722141614.297383-13-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-12-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> <20220722141614.297383-8-oleksandr.suvorov@foundries.io> <20220722141614.297383-9-oleksandr.suvorov@foundries.io> <20220722141614.297383-10-oleksandr.suvorov@foundries.io> <20220722141614.297383-11-oleksandr.suvorov@foundries.io> <20220722141614.297383-12-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Add supporting new compatible string "u-boot,zynqmp-fpga-ddrauth" to handle loading authenticated images (DDR). Based on solution by Jorge Ramirez-Ortiz Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti --- (no changes since v11) Changes in v11: - Fix treating an incoming FPGA image with empty flags parameter as legacy. Changes in v10: - Support DDR images only if FPGA_LOAD_SECURE enabled. boot/Kconfig | 4 ++-- doc/uImage.FIT/source_file_format.txt | 5 ++++- drivers/fpga/zynqmppl.c | 31 ++++++++++++++++++++++----- include/xilinx.h | 1 + include/zynqmppl.h | 4 ++++ 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index 17438b566d5..59d0c65c944 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -210,8 +210,8 @@ config SPL_LOAD_FIT 1. "loadables" images, other than FDTs, which do not have a "load" property will not be loaded. This limitation also applies to FPGA images with the correct "compatible" string. - 2. For FPGA images, only the "compatible" = "u-boot,fpga-legacy" - loading method is supported. + 2. For FPGA images, the supported "compatible" list is in the + doc/uImage.FIT/source_file_format.txt. 3. FDTs are only loaded for images with an "os" property of "u-boot". "linux" images are also supported with Falcon boot mode. diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt index f93ac6d1c7b..461e2af2a84 100644 --- a/doc/uImage.FIT/source_file_format.txt +++ b/doc/uImage.FIT/source_file_format.txt @@ -184,7 +184,10 @@ the '/images' node should have the following layout: Mandatory for types: "firmware", and "kernel". - compatible : compatible method for loading image. Mandatory for types: "fpga", and images that do not specify a load address. - To use the generic fpga loading routine, use "u-boot,fpga-legacy". + Supported compatible methods: + "u-boot,fpga-legacy" - the generic fpga loading routine. + "u-boot,zynqmp-fpga-ddrauth" - signed non-encrypted FPGA bitstream for + Xilinx Zynq UltraScale+ (ZymqMP) device. Optional nodes: - hash-1 : Each hash sub-node represents separate hash or checksum diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index feaf34fff11..200076c8c6a 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -202,9 +203,12 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf, #if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) static int zynqmp_check_compatible(xilinx_desc *desc, int flags) { - /* If no flags set, the image is legacy */ + /* + * If no flags set, the image may be legacy, but we need to + * signal caller this situation with specific error code. + */ if (!flags) - return 0; + return -ENODATA; /* For legacy bitstream images no need for other methods exist */ if ((flags & desc->flags) && flags == FPGA_LEGACY) @@ -217,7 +221,7 @@ static int zynqmp_check_compatible(xilinx_desc *desc, int flags) if (desc->operations->loads && (flags & desc->flags)) return 0; - return FPGA_FAIL; + return -ENODEV; } #endif @@ -231,8 +235,9 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, u32 buf_lo, buf_hi; u32 bsize_req = (u32)bsize; u32 ret_payload[PAYLOAD_ARG_CNT]; - #if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) + struct fpga_secure_info info = { 0 }; + ret = zynqmp_check_compatible(desc, flags); if (ret) { if (ret != -ENODATA) { @@ -242,6 +247,19 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, /* If flags is not set, the image treats as legacy */ flags = FPGA_LEGACY; } + + switch (flags) { + case FPGA_LEGACY: + break; /* Handle the legacy image later in this function */ + case FPGA_XILINX_ZYNQMP_DDRAUTH: + /* DDR authentication */ + info.authflag = ZYNQMP_FPGA_AUTH_DDR; + info.encflag = FPGA_NO_ENC_OR_NO_AUTH; + return desc->operations->loads(desc, buf, bsize, &info); + default: + printf("Unsupported bitstream type %d\n", flags); + return FPGA_FAIL; + } #endif if (zynqmp_firmware_version() <= PMUFW_V1_0) { @@ -337,7 +355,10 @@ static int __maybe_unused zynqmp_str2flag(xilinx_desc *desc, const char *str) { if (!strncmp(str, "u-boot,fpga-legacy", 18)) return FPGA_LEGACY; - +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) + if (!strncmp(str, "u-boot,zynqmp-fpga-ddrauth", 26)) + return FPGA_XILINX_ZYNQMP_DDRAUTH; +#endif return 0; } diff --git a/include/xilinx.h b/include/xilinx.h index e5f6db33fa2..97ee12cec42 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -39,6 +39,7 @@ typedef enum { /* typedef xilinx_family */ /* FPGA bitstream supported types */ #define FPGA_LEGACY BIT(0) +#define FPGA_XILINX_ZYNQMP_DDRAUTH BIT(1) typedef struct { /* typedef xilinx_desc */ xilinx_family family; /* part type */ diff --git a/include/zynqmppl.h b/include/zynqmppl.h index 8401a850afb..87ccd2f394c 100644 --- a/include/zynqmppl.h +++ b/include/zynqmppl.h @@ -25,6 +25,10 @@ extern struct xilinx_fpga_op zynqmp_op; +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) +#define ZYNQMP_FPGA_FLAGS (FPGA_LEGACY | FPGA_XILINX_ZYNQMP_DDRAUTH) +#else #define ZYNQMP_FPGA_FLAGS (FPGA_LEGACY) +#endif #endif /* _ZYNQMPPL_H_ */ From patchwork Fri Jul 22 14:16:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659607 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=jqbaGLIc; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBQ90rpSz9sGq for ; Sat, 23 Jul 2022 00:19:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BF1384144; Fri, 22 Jul 2022 16:17:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="jqbaGLIc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24154802C2; Fri, 22 Jul 2022 16:16:43 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (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 87E5F840BE for ; Fri, 22 Jul 2022 16:16:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-wr1-x42e.google.com with SMTP id h8so6698904wrw.1 for ; Fri, 22 Jul 2022 07:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Rn2cWCf3CioWqP6JiYEpZWAPrUyElveWNYxZddDkpE0=; b=jqbaGLIcYgV4BLF5L2WpMWZM2nLVQI8NCje40YI5Jm8cSas6qzNsdWRKCsqnW07lCM BkX84XQ3P2BBwGOybhpoH2wdpIimMgcXZdKOQ8i2IGBy3QzHgkRZqf2bIEQbBAsLcrAF /oLlsnjLyzbz+1ml6R16ZvHXFphJv4t3NMfIW+yqqVnFBTOnqaA8y/LdEnY+2QCskzxF WHBB0SYNYNG4qp1sD33IQSpfrIuQsQGAwz+Ez2cK9SBfj1cEDKD8nA/ehTJvqUOcsnr2 97eZti1jzyVo4VZygUwQ7rVt/nhPMOrJzI6ehGovScyb1gIw0Yaz+3Pz2f71egx4b15R /42Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Rn2cWCf3CioWqP6JiYEpZWAPrUyElveWNYxZddDkpE0=; b=acoSQlTY9EPiWBZmVY4Ah747Bgx5DB/Oj/k0qwr0ZbGjHIll1eVoFbtrHtEGU3WoL1 q7ns+2NrjZ7Mq29pxhYCYeXxx0ux5sXhlOysmAhFAjjAoKy7sD6i0ie8SLZDpyYc2XUk yG7fRy8MVeJjWA9C7ykD/5pC4qj+78NJctFOwynqvE1ml1iqTXMR5wlOlvy+efoNGIK9 TZmCs3b99PcsRDTNhQqlpIXq/FHUZMAxt0DPnzo2TRJR/ZycFfw03VkxGQBUp2s1cyeQ 6nngHu/DmLqNYvgOqY29esn9wIQ4805xZkuS/kN6E8zIEr9nAEyw/tk+TZLXOT8LyASp lCsg== X-Gm-Message-State: AJIora89kz2YxwqoDrF6ZiHz3QCeSJwn8j84MGAk+u40D/xj2nVW3i6L a/GVT4iGQ1SyuP5jDTBdlMqAmILTuXbkMQ== X-Google-Smtp-Source: AGRyM1sXOSAxZI4NQVZIJ3zEN+0Eby2r59IGr41ugtDuOG5ZlCJrv2HFSG8e4bKEvLSjw9Zewt7+hQ== X-Received: by 2002:a05:6000:1ac5:b0:21d:beaf:c2c3 with SMTP id i5-20020a0560001ac500b0021dbeafc2c3mr78384wry.609.1658499396675; Fri, 22 Jul 2022 07:16:36 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:36 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 13/13] fpga: zynqmp: support loading encrypted bitfiles Date: Fri, 22 Jul 2022 17:16:14 +0300 Message-Id: <20220722141614.297383-14-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-13-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> <20220722141614.297383-8-oleksandr.suvorov@foundries.io> <20220722141614.297383-9-oleksandr.suvorov@foundries.io> <20220722141614.297383-10-oleksandr.suvorov@foundries.io> <20220722141614.297383-11-oleksandr.suvorov@foundries.io> <20220722141614.297383-12-oleksandr.suvorov@foundries.io> <20220722141614.297383-13-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean From: Adrian Fiergolski Add supporting new compatible string "u-boot,zynqmp-fpga-enc" to handle loading encrypted bitfiles. This feature requires encrypted FSBL, as according to UG1085: "The CSU automatically locks out the AES key, stored in either BBRAM or eFUSEs, as a key source to the AES engine if the FSBL is not encrypted. This prevents using the BBRAM or eFUSE as the key source to the AES engine during run-time applications." Signed-off-by: Adrian Fiergolski Co-developed-by: Oleksandr Suvorov Signed-off-by: Oleksandr Suvorov Tested-by: Adrian Fiergolski --- Changes in v12: - reduce the size of SPL if FPGA_LOAD_SECURE disabled. Changes in v11: - add Tested-by records. Changes in v10: - Support ENC images only if FPGA_LOAD_SECURE enabled. Changes in v9: - remove an alien commit from a patchset :) Changes in v8: - Michal Simek's suggestions addressed: -- introduce the compatible flags in xilinx_desc; -- pass a binary compatible flag instead of "compatible" property to an FPGA driver. - Optimize a zynqmp_load() function. Changes in v7: - apply Michal Simek's suggestions As I applied changes on Oleksandr's patches, I indicated it by specifying myself as co-author in the commits logs. I am not sure if that is the convention of marking it. Changes in v6: - add support for the encrypted bitfiles. Changes in v5: - replace ifdef with if() where it's possible. Changes in v4: - change interface to xilinx_desc->operations->open() callback. - fix a bug from previous version of the patchset in dereferencing of a parent fpga_desc structure. Changes in v3: - remove the patch which introduced CMD_SPL_FPGA_LOAD_SECURE. - fix mixing definitions/declarations. - replace strcmp() calls with more secure strncmp(). - document the "u-boot,zynqmp-fpga-ddrauth" compatible string. - fix code style by check-patch recommendations. Changes in v2: - add function fit_fpga_load() to simplify calls of fpga_load() from contexts without a compatible attribute. - move all ZynqMP-specific logic to drivers/fpga/zynqmppl.c - prepare for passing a "compatible" FDT property to any fpga driver. doc/uImage.FIT/source_file_format.txt | 2 ++ drivers/fpga/zynqmppl.c | 8 ++++++++ include/fpga.h | 1 + include/xilinx.h | 1 + include/zynqmppl.h | 4 +++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt index 461e2af2a84..68701118409 100644 --- a/doc/uImage.FIT/source_file_format.txt +++ b/doc/uImage.FIT/source_file_format.txt @@ -188,6 +188,8 @@ the '/images' node should have the following layout: "u-boot,fpga-legacy" - the generic fpga loading routine. "u-boot,zynqmp-fpga-ddrauth" - signed non-encrypted FPGA bitstream for Xilinx Zynq UltraScale+ (ZymqMP) device. + "u-boot,zynqmp-fpga-enc" - encrypted FPGA bitstream for Xilinx Zynq + UltraScale+ (ZynqMP) device. Optional nodes: - hash-1 : Each hash sub-node represents separate hash or checksum diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 200076c8c6a..a6c8dcdcdcc 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -256,6 +256,11 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, info.authflag = ZYNQMP_FPGA_AUTH_DDR; info.encflag = FPGA_NO_ENC_OR_NO_AUTH; return desc->operations->loads(desc, buf, bsize, &info); + case FPGA_XILINX_ZYNQMP_ENC: + /* Encryption using device key */ + info.authflag = FPGA_NO_ENC_OR_NO_AUTH; + info.encflag = FPGA_ENC_DEV_KEY; + return desc->operations->loads(desc, buf, bsize, &info); default: printf("Unsupported bitstream type %d\n", flags); return FPGA_FAIL; @@ -358,6 +363,9 @@ static int __maybe_unused zynqmp_str2flag(xilinx_desc *desc, const char *str) #if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) if (!strncmp(str, "u-boot,zynqmp-fpga-ddrauth", 26)) return FPGA_XILINX_ZYNQMP_DDRAUTH; + + if (!strncmp(str, "u-boot,zynqmp-fpga-enc", 22)) + return FPGA_XILINX_ZYNQMP_ENC; #endif return 0; } diff --git a/include/fpga.h b/include/fpga.h index 13b1bbee3ca..a4e16401da7 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -20,6 +20,7 @@ /* device numbers must be non-negative */ #define FPGA_INVALID_DEVICE -1 +#define FPGA_ENC_DEV_KEY 0 #define FPGA_ENC_USR_KEY 1 #define FPGA_NO_ENC_OR_NO_AUTH 2 diff --git a/include/xilinx.h b/include/xilinx.h index 97ee12cec42..e4e29797988 100644 --- a/include/xilinx.h +++ b/include/xilinx.h @@ -40,6 +40,7 @@ typedef enum { /* typedef xilinx_family */ /* FPGA bitstream supported types */ #define FPGA_LEGACY BIT(0) #define FPGA_XILINX_ZYNQMP_DDRAUTH BIT(1) +#define FPGA_XILINX_ZYNQMP_ENC BIT(2) typedef struct { /* typedef xilinx_desc */ xilinx_family family; /* part type */ diff --git a/include/zynqmppl.h b/include/zynqmppl.h index 87ccd2f394c..acf75a8f079 100644 --- a/include/zynqmppl.h +++ b/include/zynqmppl.h @@ -26,7 +26,9 @@ extern struct xilinx_fpga_op zynqmp_op; #if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) -#define ZYNQMP_FPGA_FLAGS (FPGA_LEGACY | FPGA_XILINX_ZYNQMP_DDRAUTH) +#define ZYNQMP_FPGA_FLAGS (FPGA_LEGACY | \ + FPGA_XILINX_ZYNQMP_DDRAUTH | \ + FPGA_XILINX_ZYNQMP_ENC) #else #define ZYNQMP_FPGA_FLAGS (FPGA_LEGACY) #endif