Skip to content

Commit e840dec

Browse files
Nava kishore ManneMichal Simek
authored andcommitted
firmware: xilinx: Add fpga API's
This Patch Adds fpga API's to support the Bitstream loading by using firmware interface. Signed-off-by: Nava kishore Manne <nava.manne@xilinx.com> Reviewed-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
1 parent 3d03137 commit e840dec

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎drivers/firmware/xilinx/zynqmp.c‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,49 @@ static int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset,
539539
return ret;
540540
}
541541

542+
/**
543+
* zynqmp_pm_fpga_load - Perform the fpga load
544+
* @address: Address to write to
545+
* @size: pl bitstream size
546+
* @flags: Bitstream type
547+
* -XILINX_ZYNQMP_PM_FPGA_FULL: FPGA full reconfiguration
548+
* -XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
549+
*
550+
* This function provides access to pmufw. To transfer
551+
* the required bitstream into PL.
552+
*
553+
* Return: Returns status, either success or error+reason
554+
*/
555+
static int zynqmp_pm_fpga_load(const u64 address, const u32 size,
556+
const u32 flags)
557+
{
558+
return zynqmp_pm_invoke_fn(PM_FPGA_LOAD, lower_32_bits(address),
559+
upper_32_bits(address), size, flags, NULL);
560+
}
561+
562+
/**
563+
* zynqmp_pm_fpga_get_status - Read value from PCAP status register
564+
* @value: Value to read
565+
*
566+
* This function provides access to the pmufw to get the PCAP
567+
* status
568+
*
569+
* Return: Returns status, either success or error+reason
570+
*/
571+
static int zynqmp_pm_fpga_get_status(u32 *value)
572+
{
573+
u32 ret_payload[PAYLOAD_ARG_CNT];
574+
int ret;
575+
576+
if (!value)
577+
return -EINVAL;
578+
579+
ret = zynqmp_pm_invoke_fn(PM_FPGA_GET_STATUS, 0, 0, 0, 0, ret_payload);
580+
*value = ret_payload[1];
581+
582+
return ret;
583+
}
584+
542585
/**
543586
* zynqmp_pm_init_finalize() - PM call to inform firmware that the caller
544587
* master has initialized its own power management
@@ -642,6 +685,8 @@ static const struct zynqmp_eemi_ops eemi_ops = {
642685
.request_node = zynqmp_pm_request_node,
643686
.release_node = zynqmp_pm_release_node,
644687
.set_requirement = zynqmp_pm_set_requirement,
688+
.fpga_load = zynqmp_pm_fpga_load,
689+
.fpga_get_status = zynqmp_pm_fpga_get_status,
645690
};
646691

647692
/**

‎include/linux/firmware/xlnx-zynqmp.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
#define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U
4949
#define ZYNQMP_PM_CAPABILITY_POWER 0x8U
5050

51+
/*
52+
* Firmware FPGA Manager flags
53+
* XILINX_ZYNQMP_PM_FPGA_FULL: FPGA full reconfiguration
54+
* XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
55+
*/
56+
#define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
57+
#define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
58+
5159
enum pm_api_id {
5260
PM_GET_API_VERSION = 1,
5361
PM_REQUEST_NODE = 13,
@@ -56,6 +64,8 @@ enum pm_api_id {
5664
PM_RESET_ASSERT = 17,
5765
PM_RESET_GET_STATUS,
5866
PM_PM_INIT_FINALIZE = 21,
67+
PM_FPGA_LOAD,
68+
PM_FPGA_GET_STATUS,
5969
PM_GET_CHIPID = 24,
6070
PM_IOCTL = 34,
6171
PM_QUERY_DATA,
@@ -258,6 +268,8 @@ struct zynqmp_pm_query_data {
258268
struct zynqmp_eemi_ops {
259269
int (*get_api_version)(u32 *version);
260270
int (*get_chipid)(u32 *idcode, u32 *version);
271+
int (*fpga_load)(const u64 address, const u32 size, const u32 flags);
272+
int (*fpga_get_status)(u32 *value);
261273
int (*query_data)(struct zynqmp_pm_query_data qdata, u32 *out);
262274
int (*clock_enable)(u32 clock_id);
263275
int (*clock_disable)(u32 clock_id);

0 commit comments

Comments
 (0)