diff mbox series

[v8,1/5] drivers: firmware: Add PDI load API support

Message ID 20210626155248.5004-2-nava.manne@xilinx.com (mailing list archive)
State New
Headers show
Series Add Bitstream configuration support for Versal | expand

Commit Message

Nava kishore Manne June 26, 2021, 3:52 p.m. UTC
This patch adds load PDI API support to enable full/partial PDI loading
from linux. Programmable Device Image (PDI) is combination of headers,
images and bitstream files to be loaded.

Signed-off-by: Nava kishore Manne <nava.manne@xilinx.com>
Reviewed-by: Moritz Fischer <mdf@kernel.org>
---
Changes for v2:
              -Updated API Doc and commit msg.
               No functional changes.

Changes for v3:
              -None.

Changes for v4:
              -Rebased the changes on linux-next.
               No functional changes

Changes for v5:
              -None.

Changes for v6:
              -None.

Changes for v7:
              -None.

Changes for v8:
               -None.

 drivers/firmware/xilinx/zynqmp.c     | 17 +++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h | 10 ++++++++++
 2 files changed, 27 insertions(+)

Comments

Tom Rix July 6, 2021, 9:03 p.m. UTC | #1
On 6/26/21 8:52 AM, Nava kishore Manne wrote:
> This patch adds load PDI API support to enable full/partial PDI loading
> from linux. Programmable Device Image (PDI) is combination of headers,
> images and bitstream files to be loaded.
>
> Signed-off-by: Nava kishore Manne <nava.manne@xilinx.com>
> Reviewed-by: Moritz Fischer <mdf@kernel.org>
> ---
> Changes for v2:
>                -Updated API Doc and commit msg.
>                 No functional changes.
>
> Changes for v3:
>                -None.
>
> Changes for v4:
>                -Rebased the changes on linux-next.
>                 No functional changes
>
> Changes for v5:
>                -None.
>
> Changes for v6:
>                -None.
>
> Changes for v7:
>                -None.
>
> Changes for v8:
>                 -None.
>
>   drivers/firmware/xilinx/zynqmp.c     | 17 +++++++++++++++++
>   include/linux/firmware/xlnx-zynqmp.h | 10 ++++++++++
>   2 files changed, 27 insertions(+)
>
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 15b138326ecc..2db571da9ad8 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -1011,6 +1011,23 @@ int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities,
>   }
>   EXPORT_SYMBOL_GPL(zynqmp_pm_set_requirement);
>   
> +/**
> + * zynqmp_pm_load_pdi - Load and process PDI
> + * @src:       Source device where PDI is located
> + * @address:   PDI src address
> + *
> + * This function provides support to load PDI from linux
> + *
> + * Return: Returns status, either success or error+reason
> + */
> +int zynqmp_pm_load_pdi(const u32 src, const u64 address)
> +{
> +	return zynqmp_pm_invoke_fn(PM_LOAD_PDI, src,
> +				   lower_32_bits(address),
> +				   upper_32_bits(address), 0, NULL);
> +}
> +EXPORT_SYMBOL_GPL(zynqmp_pm_load_pdi);
> +
>   /**
>    * zynqmp_pm_aes - Access AES hardware to encrypt/decrypt the data using
>    * AES-GCM core.
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index 9d1a5c175065..56b426fe020c 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -52,6 +52,10 @@
>   #define	ZYNQMP_PM_CAPABILITY_WAKEUP	0x4U
>   #define	ZYNQMP_PM_CAPABILITY_UNUSABLE	0x8U
>   
> +/* Loader commands */
> +#define PM_LOAD_PDI	0x701
This should be defined in enum pm_api_id
> +#define PDI_SRC_DDR	0xF

This is only used by versal_fpga_ops_write(), consider moving the 
#define to versal-fpga.c

Tom

> +
>   /*
>    * Firmware FPGA Manager flags
>    * XILINX_ZYNQMP_PM_FPGA_FULL:	FPGA full reconfiguration
> @@ -411,6 +415,7 @@ int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
>   				 u32 *value);
>   int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
>   				 u32 value);
> +int zynqmp_pm_load_pdi(const u32 src, const u64 address);
>   #else
>   static inline int zynqmp_pm_get_api_version(u32 *version)
>   {
> @@ -622,6 +627,11 @@ static inline int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
>   {
>   	return -ENODEV;
>   }
> +
> +static inline int zynqmp_pm_load_pdi(const u32 src, const u64 address)
> +{
> +	return -ENODEV;
> +}
>   #endif
>   
>   #endif /* __FIRMWARE_ZYNQMP_H__ */
Nava kishore Manne July 8, 2021, 11:40 a.m. UTC | #2
Hi Tom,

	Please fix my response inline.

> -----Original Message-----
> From: Tom Rix <trix@redhat.com>
> Sent: Wednesday, July 7, 2021 2:34 AM
> To: Nava kishore Manne <navam@xilinx.com>; robh+dt@kernel.org; Michal
> Simek <michals@xilinx.com>; mdf@kernel.org; arnd@arndb.de; Rajan Vaja
> <RAJANV@xilinx.com>; gregkh@linuxfoundation.org; Amit Sunil Dhamne
> <amitsuni@xlnx.xilinx.com>; Tejas Patel <tejasp@xlnx.xilinx.com>;
> zou_wei@huawei.com; Sai Krishna Potthuri <lakshmis@xilinx.com>; Ravi
> Patel <ravipate@xlnx.xilinx.com>; iwamatsu@nigauri.org; Jiaying Liang
> <jliang@xilinx.com>; devicetree@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linux-
> fpga@vger.kernel.org; git <git@xilinx.com>; chinnikishore369@gmail.com
> Subject: Re: [PATCH v8 1/5] drivers: firmware: Add PDI load API support
> 
> 
> On 6/26/21 8:52 AM, Nava kishore Manne wrote:
> > This patch adds load PDI API support to enable full/partial PDI
> > loading from linux. Programmable Device Image (PDI) is combination of
> > headers, images and bitstream files to be loaded.
> >
> > Signed-off-by: Nava kishore Manne <nava.manne@xilinx.com>
> > Reviewed-by: Moritz Fischer <mdf@kernel.org>
> > ---
> > Changes for v2:
> >                -Updated API Doc and commit msg.
> >                 No functional changes.
> >
> > Changes for v3:
> >                -None.
> >
> > Changes for v4:
> >                -Rebased the changes on linux-next.
> >                 No functional changes
> >
> > Changes for v5:
> >                -None.
> >
> > Changes for v6:
> >                -None.
> >
> > Changes for v7:
> >                -None.
> >
> > Changes for v8:
> >                 -None.
> >
> >   drivers/firmware/xilinx/zynqmp.c     | 17 +++++++++++++++++
> >   include/linux/firmware/xlnx-zynqmp.h | 10 ++++++++++
> >   2 files changed, 27 insertions(+)
> >
> > diff --git a/drivers/firmware/xilinx/zynqmp.c
> > b/drivers/firmware/xilinx/zynqmp.c
> > index 15b138326ecc..2db571da9ad8 100644
> > --- a/drivers/firmware/xilinx/zynqmp.c
> > +++ b/drivers/firmware/xilinx/zynqmp.c
> > @@ -1011,6 +1011,23 @@ int zynqmp_pm_set_requirement(const u32
> node, const u32 capabilities,
> >   }
> >   EXPORT_SYMBOL_GPL(zynqmp_pm_set_requirement);
> >
> > +/**
> > + * zynqmp_pm_load_pdi - Load and process PDI
> > + * @src:       Source device where PDI is located
> > + * @address:   PDI src address
> > + *
> > + * This function provides support to load PDI from linux
> > + *
> > + * Return: Returns status, either success or error+reason  */ int
> > +zynqmp_pm_load_pdi(const u32 src, const u64 address) {
> > +	return zynqmp_pm_invoke_fn(PM_LOAD_PDI, src,
> > +				   lower_32_bits(address),
> > +				   upper_32_bits(address), 0, NULL); }
> > +EXPORT_SYMBOL_GPL(zynqmp_pm_load_pdi);
> > +
> >   /**
> >    * zynqmp_pm_aes - Access AES hardware to encrypt/decrypt the data
> using
> >    * AES-GCM core.
> > diff --git a/include/linux/firmware/xlnx-zynqmp.h
> > b/include/linux/firmware/xlnx-zynqmp.h
> > index 9d1a5c175065..56b426fe020c 100644
> > --- a/include/linux/firmware/xlnx-zynqmp.h
> > +++ b/include/linux/firmware/xlnx-zynqmp.h
> > @@ -52,6 +52,10 @@
> >   #define	ZYNQMP_PM_CAPABILITY_WAKEUP	0x4U
> >   #define	ZYNQMP_PM_CAPABILITY_UNUSABLE	0x8U
> >
> > +/* Loader commands */
> > +#define PM_LOAD_PDI	0x701
> This should be defined in enum pm_api_id
> > +#define PDI_SRC_DDR	0xF
> 
> This is only used by versal_fpga_ops_write(), consider moving the #define to
> versal-fpga.c
> 

Yes, currently only versal_fpga_write() is using this #define but it’s a generic thing for Versal platform
That’s why we placed it here.

Regards,
Navakishore.
diff mbox series

Patch

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 15b138326ecc..2db571da9ad8 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1011,6 +1011,23 @@  int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities,
 }
 EXPORT_SYMBOL_GPL(zynqmp_pm_set_requirement);
 
+/**
+ * zynqmp_pm_load_pdi - Load and process PDI
+ * @src:       Source device where PDI is located
+ * @address:   PDI src address
+ *
+ * This function provides support to load PDI from linux
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_load_pdi(const u32 src, const u64 address)
+{
+	return zynqmp_pm_invoke_fn(PM_LOAD_PDI, src,
+				   lower_32_bits(address),
+				   upper_32_bits(address), 0, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_load_pdi);
+
 /**
  * zynqmp_pm_aes - Access AES hardware to encrypt/decrypt the data using
  * AES-GCM core.
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 9d1a5c175065..56b426fe020c 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -52,6 +52,10 @@ 
 #define	ZYNQMP_PM_CAPABILITY_WAKEUP	0x4U
 #define	ZYNQMP_PM_CAPABILITY_UNUSABLE	0x8U
 
+/* Loader commands */
+#define PM_LOAD_PDI	0x701
+#define PDI_SRC_DDR	0xF
+
 /*
  * Firmware FPGA Manager flags
  * XILINX_ZYNQMP_PM_FPGA_FULL:	FPGA full reconfiguration
@@ -411,6 +415,7 @@  int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
 				 u32 *value);
 int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
 				 u32 value);
+int zynqmp_pm_load_pdi(const u32 src, const u64 address);
 #else
 static inline int zynqmp_pm_get_api_version(u32 *version)
 {
@@ -622,6 +627,11 @@  static inline int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
 {
 	return -ENODEV;
 }
+
+static inline int zynqmp_pm_load_pdi(const u32 src, const u64 address)
+{
+	return -ENODEV;
+}
 #endif
 
 #endif /* __FIRMWARE_ZYNQMP_H__ */