Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Nava kishore Manne and committed by
Michal Simek
e840decc 3d031378

+57
+45
drivers/firmware/xilinx/zynqmp.c
··· 540 540 } 541 541 542 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 + 585 + /** 543 586 * zynqmp_pm_init_finalize() - PM call to inform firmware that the caller 544 587 * master has initialized its own power management 545 588 * ··· 685 642 .request_node = zynqmp_pm_request_node, 686 643 .release_node = zynqmp_pm_release_node, 687 644 .set_requirement = zynqmp_pm_set_requirement, 645 + .fpga_load = zynqmp_pm_fpga_load, 646 + .fpga_get_status = zynqmp_pm_fpga_get_status, 688 647 }; 689 648 690 649 /**
+12
include/linux/firmware/xlnx-zynqmp.h
··· 48 48 #define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U 49 49 #define ZYNQMP_PM_CAPABILITY_POWER 0x8U 50 50 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 + 51 59 enum pm_api_id { 52 60 PM_GET_API_VERSION = 1, 53 61 PM_REQUEST_NODE = 13, ··· 64 56 PM_RESET_ASSERT = 17, 65 57 PM_RESET_GET_STATUS, 66 58 PM_PM_INIT_FINALIZE = 21, 59 + PM_FPGA_LOAD, 60 + PM_FPGA_GET_STATUS, 67 61 PM_GET_CHIPID = 24, 68 62 PM_IOCTL = 34, 69 63 PM_QUERY_DATA, ··· 268 258 struct zynqmp_eemi_ops { 269 259 int (*get_api_version)(u32 *version); 270 260 int (*get_chipid)(u32 *idcode, u32 *version); 261 + int (*fpga_load)(const u64 address, const u32 size, const u32 flags); 262 + int (*fpga_get_status)(u32 *value); 271 263 int (*query_data)(struct zynqmp_pm_query_data qdata, u32 *out); 272 264 int (*clock_enable)(u32 clock_id); 273 265 int (*clock_disable)(u32 clock_id);