2021-06-26 15:54:49

by Nava kishore Manne

[permalink] [raw]
Subject: [PATCH v8 1/5] drivers: firmware: Add PDI load API support

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 <[email protected]>
Reviewed-by: Moritz Fischer <[email protected]>
---
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
+#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__ */
--
2.17.1


2021-07-06 21:05:56

by Tom Rix

[permalink] [raw]
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 <[email protected]>
> Reviewed-by: Moritz Fischer <[email protected]>
> ---
> 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__ */

2021-07-08 11:42:19

by Nava kishore Manne

[permalink] [raw]
Subject: RE: [PATCH v8 1/5] drivers: firmware: Add PDI load API support

Hi Tom,

Please fix my response inline.

> -----Original Message-----
> From: Tom Rix <[email protected]>
> Sent: Wednesday, July 7, 2021 2:34 AM
> To: Nava kishore Manne <[email protected]>; [email protected]; Michal
> Simek <[email protected]>; [email protected]; [email protected]; Rajan Vaja
> <[email protected]>; [email protected]; Amit Sunil Dhamne
> <[email protected]>; Tejas Patel <[email protected]>;
> [email protected]; Sai Krishna Potthuri <[email protected]>; Ravi
> Patel <[email protected]>; [email protected]; Jiaying Liang
> <[email protected]>; [email protected]; linux-arm-
> [email protected]; [email protected]; linux-
> [email protected]; git <[email protected]>; [email protected]
> 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 <[email protected]>
> > Reviewed-by: Moritz Fischer <[email protected]>
> > ---
> > 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.