diff mbox series

[v11,01/13] fpga: add option for loading FPGA secure bitstreams

Message ID 20220705192320.415861-2-oleksandr.suvorov@foundries.io
State Superseded
Delegated to: Michal Simek
Headers show
Series fpga: zynqmp: Adding support of loading authenticated images | expand

Commit Message

Oleksandr Suvorov July 5, 2022, 7:23 p.m. UTC
It allows using this feature without enabling the "fpga loads"
command.

Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
Co-developed-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
Tested-by: Ricardo Salveti <ricardo@foundries.io>
Tested-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
---

(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(-)

Comments

Simon Glass July 12, 2022, 10:58 a.m. UTC | #1
Hi,

On Tue, 5 Jul 2022 at 13:23, Oleksandr Suvorov
<oleksandr.suvorov@foundries.io> wrote:
>
> It allows using this feature without enabling the "fpga loads"
> command.
>
> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
> Co-developed-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
> Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
> Tested-by: Ricardo Salveti <ricardo@foundries.io>
> Tested-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
> ---
>
> (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(-)

This should use driver model, with a UCLASS_FPGA, etc. Can someone
please figure out how to convert it?

Regards,
Simon
Michal Simek July 12, 2022, 11:45 a.m. UTC | #2
Hi,

On 7/12/22 12:58, Simon Glass wrote:
> Hi,
> 
> On Tue, 5 Jul 2022 at 13:23, Oleksandr Suvorov
> <oleksandr.suvorov@foundries.io> wrote:
>>
>> It allows using this feature without enabling the "fpga loads"
>> command.
>>
>> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
>> Co-developed-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
>> Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
>> Tested-by: Ricardo Salveti <ricardo@foundries.io>
>> Tested-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
>> ---
>>
>> (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(-)
> 
> This should use driver model, with a UCLASS_FPGA, etc. Can someone
> please figure out how to convert it?

We discussed this before and can be done on the top of this series.

M
diff mbox series

Patch

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 09193b61b95..4a295c7b526 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1009,8 +1009,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 dc0b3dd31b7..6f8ef7b8dba 100644
--- a/drivers/fpga/Kconfig
+++ b/drivers/fpga/Kconfig
@@ -85,4 +85,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,