arm64: zynqmp: SoC changes for v5.2 - Add support for ZynqMP fpga manager - Defer some probes which depends on firmware driver to be ready - Debugfs fix * tag 'zynqmp-soc-for-v5.2' of https://github.com/Xilinx/linux-xlnx: fpga manager: Adding FPGA Manager support for Xilinx zynqmp dt-bindings: fpga: Add bindings for ZynqMP fpga driver firmware: xilinx: Add fpga API's drivers: Defer probe if firmware is not ready firmware: xilinx: fix debugfs write handler
Unified · Split
| @@ -0,0 +1,25 @@ | ||
| 1 | +Devicetree bindings for Zynq Ultrascale MPSoC FPGA Manager. | |
| 2 | +The ZynqMP SoC uses the PCAP (Processor configuration Port) to configure the | |
| 3 | +Programmable Logic (PL). The configuration uses the firmware interface. | |
| 4 | + | |
| 5 | +Required properties: | |
| 6 | +- compatible: should contain "xlnx,zynqmp-pcap-fpga" | |
| 7 | + | |
| 8 | +Example for full FPGA configuration: | |
| 9 | + | |
| 10 | + fpga-region0 { | |
| 11 | + compatible = "fpga-region"; | |
| 12 | + fpga-mgr = <&zynqmp_pcap>; | |
| 13 | + #address-cells = <0x1>; | |
| 14 | + #size-cells = <0x1>; | |
| 15 | + }; | |
| 16 | + | |
| 17 | + firmware { | |
| 18 | + zynqmp_firmware: zynqmp-firmware { | |
| 19 | + compatible = "xlnx,zynqmp-firmware"; | |
| 20 | + method = "smc"; | |
| 21 | + zynqmp_pcap: pcap { | |
| 22 | + compatible = "xlnx,zynqmp-pcap-fpga"; | |
| 23 | + }; | |
| 24 | + }; | |
| 25 | + }; | |
| @@ -41,8 +41,8 @@ Example of EEMI ops usage: · 40 unmodified lines | ||
| 41 | 41 | int ret; |
| 42 | 42 | |
| 43 | 43 | eemi_ops = zynqmp_pm_get_eemi_ops(); |
| 44 | − if (!eemi_ops) | |
| 45 | − return -ENXIO; | |
| 44 | + if (IS_ERR(eemi_ops)) | |
| 45 | + return PTR_ERR(eemi_ops); | |
| 46 | 46 | |
| 47 | 47 | ret = eemi_ops->query_data(qdata, ret_payload); |
| 48 | 48 | |
| @@ -695,8 +695,8 @@ static int zynqmp_clock_probe(struct platform_device *pdev) · 694 unmodified lines | ||
| 695 | 695 | struct device *dev = &pdev->dev; |
| 696 | 696 | |
| 697 | 697 | eemi_ops = zynqmp_pm_get_eemi_ops(); |
| 698 | − if (!eemi_ops) | |
| 699 | − return -ENXIO; | |
| 698 | + if (IS_ERR(eemi_ops)) | |
| 699 | + return PTR_ERR(eemi_ops); | |
| 700 | 700 | |
| 701 | 701 | ret = zynqmp_clk_setup(dev->of_node); |
| 702 | 702 | |
| @@ -90,9 +90,6 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret) · 89 unmodified lines | ||
| 90 | 90 | int ret; |
| 91 | 91 | struct zynqmp_pm_query_data qdata = {0}; |
| 92 | 92 | |
| 93 | − if (!eemi_ops) | |
| 94 | − return -ENXIO; | |
| 95 | − | |
| 96 | 93 | switch (pm_id) { |
| 97 | 94 | case PM_GET_API_VERSION: |
| 98 | 95 | ret = eemi_ops->get_api_version(&pm_api_version); |
| @@ -163,21 +160,14 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file, · 64 unmodified lines | ||
| 163 | 160 | |
| 164 | 161 | strcpy(debugfs_buf, ""); |
| 165 | 162 | |
| 166 | − if (*off != 0 || len == 0) | |
| 163 | + if (*off != 0 || len <= 1 || len > PAGE_SIZE - 1) | |
| 167 | 164 | return -EINVAL; |
| 168 | 165 | |
| 169 | − kern_buff = kzalloc(len, GFP_KERNEL); | |
| 170 | − if (!kern_buff) | |
| 171 | − return -ENOMEM; | |
| 172 | − | |
| 166 | + kern_buff = memdup_user_nul(ptr, len); | |
| 167 | + if (IS_ERR(kern_buff)) | |
| 168 | + return PTR_ERR(kern_buff); | |
| 173 | 169 | tmp_buff = kern_buff; |
| 174 | 170 | |
| 175 | − ret = strncpy_from_user(kern_buff, ptr, len); | |
| 176 | − if (ret < 0) { | |
| 177 | − ret = -EFAULT; | |
| 178 | − goto err; | |
| 179 | − } | |
| 180 | − | |
| 181 | 171 | /* Read the API name from a user request */ |
| 182 | 172 | pm_api_req = strsep(&kern_buff, " "); |
| 183 | 173 | |
| @@ -24,6 +24,8 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <linux/firmware/xlnx-zynqmp.h> |
| 25 | 25 | #include "zynqmp-debug.h" |
| 26 | 26 | |
| 27 | +static const struct zynqmp_eemi_ops *eemi_ops_tbl; | |
| 28 | + | |
| 27 | 29 | static const struct mfd_cell firmware_devs[] = { |
| 28 | 30 | { |
| 29 | 31 | .name = "zynqmp_power_controller", |
| @@ -537,6 +539,49 @@ static int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset, · 507 unmodified lines | ||
| 537 | 539 | return ret; |
| 538 | 540 | } |
| 539 | 541 | |
| 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 | + | |
| 540 | 585 | /** |
| 541 | 586 | * zynqmp_pm_init_finalize() - PM call to inform firmware that the caller |
| 542 | 587 | * master has initialized its own power management |
| @@ -640,6 +685,8 @@ static const struct zynqmp_eemi_ops eemi_ops = { · 97 unmodified lines | ||
| 640 | 685 | .request_node = zynqmp_pm_request_node, |
| 641 | 686 | .release_node = zynqmp_pm_release_node, |
| 642 | 687 | .set_requirement = zynqmp_pm_set_requirement, |
| 688 | + .fpga_load = zynqmp_pm_fpga_load, | |
| 689 | + .fpga_get_status = zynqmp_pm_fpga_get_status, | |
| 643 | 690 | }; |
| 644 | 691 | |
| 645 | 692 | /** |
| @@ -649,7 +696,11 @@ static const struct zynqmp_eemi_ops eemi_ops = { · 3 unmodified lines | ||
| 649 | 696 | */ |
| 650 | 697 | const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void) |
| 651 | 698 | { |
| 652 | − return &eemi_ops; | |
| 699 | + if (eemi_ops_tbl) | |
| 700 | + return eemi_ops_tbl; | |
| 701 | + else | |
| 702 | + return ERR_PTR(-EPROBE_DEFER); | |
| 703 | + | |
| 653 | 704 | } |
| 654 | 705 | EXPORT_SYMBOL_GPL(zynqmp_pm_get_eemi_ops); |
| 655 | 706 | |
| @@ -694,6 +745,9 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) · 38 unmodified lines | ||
| 694 | 745 | pr_info("%s Trustzone version v%d.%d\n", __func__, |
| 695 | 746 | pm_tz_version >> 16, pm_tz_version & 0xFFFF); |
| 696 | 747 | |
| 748 | + /* Assign eemi_ops_table */ | |
| 749 | + eemi_ops_tbl = &eemi_ops; | |
| 750 | + | |
| 697 | 751 | zynqmp_pm_api_debugfs_init(); |
| 698 | 752 | |
| 699 | 753 | ret = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, firmware_devs, |
| @@ -204,4 +204,13 @@ config FPGA_DFL_PCI · 203 unmodified lines | ||
| 204 | 204 | |
| 205 | 205 | To compile this as a module, choose M here. |
| 206 | 206 | |
| 207 | +config FPGA_MGR_ZYNQMP_FPGA | |
| 208 | + tristate "Xilinx ZynqMP FPGA" | |
| 209 | + depends on ARCH_ZYNQMP || COMPILE_TEST | |
| 210 | + help | |
| 211 | + FPGA manager driver support for Xilinx ZynqMP FPGAs. | |
| 212 | + This driver uses the processor configuration port(PCAP) | |
| 213 | + to configure the programmable logic(PL) through PS | |
| 214 | + on ZynqMP SoC. | |
| 215 | + | |
| 207 | 216 | endif # FPGA |
| @@ -17,6 +17,7 @@ obj-$(CONFIG_FPGA_MGR_STRATIX10_SOC) += stratix10-soc.o · 16 unmodified lines | ||
| 17 | 17 | obj-$(CONFIG_FPGA_MGR_TS73XX) += ts73xx-fpga.o |
| 18 | 18 | obj-$(CONFIG_FPGA_MGR_XILINX_SPI) += xilinx-spi.o |
| 19 | 19 | obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o |
| 20 | +obj-$(CONFIG_FPGA_MGR_ZYNQMP_FPGA) += zynqmp-fpga.o | |
| 20 | 21 | obj-$(CONFIG_ALTERA_PR_IP_CORE) += altera-pr-ip-core.o |
| 21 | 22 | obj-$(CONFIG_ALTERA_PR_IP_CORE_PLAT) += altera-pr-ip-core-plat.o |
| 22 | 23 | |
| @@ -0,0 +1,159 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +/* | |
| 3 | + * Copyright (C) 2019 Xilinx, Inc. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +#include <linux/dma-mapping.h> | |
| 7 | +#include <linux/fpga/fpga-mgr.h> | |
| 8 | +#include <linux/io.h> | |
| 9 | +#include <linux/kernel.h> | |
| 10 | +#include <linux/module.h> | |
| 11 | +#include <linux/of_address.h> | |
| 12 | +#include <linux/string.h> | |
| 13 | +#include <linux/firmware/xlnx-zynqmp.h> | |
| 14 | + | |
| 15 | +/* Constant Definitions */ | |
| 16 | +#define IXR_FPGA_DONE_MASK BIT(3) | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * struct zynqmp_fpga_priv - Private data structure | |
| 20 | + * @dev: Device data structure | |
| 21 | + * @flags: flags which is used to identify the bitfile type | |
| 22 | + */ | |
| 23 | +struct zynqmp_fpga_priv { | |
| 24 | + struct device *dev; | |
| 25 | + u32 flags; | |
| 26 | +}; | |
| 27 | + | |
| 28 | +static int zynqmp_fpga_ops_write_init(struct fpga_manager *mgr, | |
| 29 | + struct fpga_image_info *info, | |
| 30 | + const char *buf, size_t size) | |
| 31 | +{ | |
| 32 | + struct zynqmp_fpga_priv *priv; | |
| 33 | + | |
| 34 | + priv = mgr->priv; | |
| 35 | + priv->flags = info->flags; | |
| 36 | + | |
| 37 | + return 0; | |
| 38 | +} | |
| 39 | + | |
| 40 | +static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, | |
| 41 | + const char *buf, size_t size) | |
| 42 | +{ | |
| 43 | + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 44 | + struct zynqmp_fpga_priv *priv; | |
| 45 | + dma_addr_t dma_addr; | |
| 46 | + u32 eemi_flags = 0; | |
| 47 | + char *kbuf; | |
| 48 | + int ret; | |
| 49 | + | |
| 50 | + if (!eemi_ops || !eemi_ops->fpga_load) | |
| 51 | + return -ENXIO; | |
| 52 | + | |
| 53 | + priv = mgr->priv; | |
| 54 | + | |
| 55 | + kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr, GFP_KERNEL); | |
| 56 | + if (!kbuf) | |
| 57 | + return -ENOMEM; | |
| 58 | + | |
| 59 | + memcpy(kbuf, buf, size); | |
| 60 | + | |
| 61 | + wmb(); /* ensure all writes are done before initiate FW call */ | |
| 62 | + | |
| 63 | + if (priv->flags & FPGA_MGR_PARTIAL_RECONFIG) | |
| 64 | + eemi_flags |= XILINX_ZYNQMP_PM_FPGA_PARTIAL; | |
| 65 | + | |
| 66 | + ret = eemi_ops->fpga_load(dma_addr, size, eemi_flags); | |
| 67 | + | |
| 68 | + dma_free_coherent(priv->dev, size, kbuf, dma_addr); | |
| 69 | + | |
| 70 | + return ret; | |
| 71 | +} | |
| 72 | + | |
| 73 | +static int zynqmp_fpga_ops_write_complete(struct fpga_manager *mgr, | |
| 74 | + struct fpga_image_info *info) | |
| 75 | +{ | |
| 76 | + return 0; | |
| 77 | +} | |
| 78 | + | |
| 79 | +static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) | |
| 80 | +{ | |
| 81 | + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 82 | + u32 status; | |
| 83 | + | |
| 84 | + if (!eemi_ops || !eemi_ops->fpga_get_status) | |
| 85 | + return FPGA_MGR_STATE_UNKNOWN; | |
| 86 | + | |
| 87 | + eemi_ops->fpga_get_status(&status); | |
| 88 | + if (status & IXR_FPGA_DONE_MASK) | |
| 89 | + return FPGA_MGR_STATE_OPERATING; | |
| 90 | + | |
| 91 | + return FPGA_MGR_STATE_UNKNOWN; | |
| 92 | +} | |
| 93 | + | |
| 94 | +static const struct fpga_manager_ops zynqmp_fpga_ops = { | |
| 95 | + .state = zynqmp_fpga_ops_state, | |
| 96 | + .write_init = zynqmp_fpga_ops_write_init, | |
| 97 | + .write = zynqmp_fpga_ops_write, | |
| 98 | + .write_complete = zynqmp_fpga_ops_write_complete, | |
| 99 | +}; | |
| 100 | + | |
| 101 | +static int zynqmp_fpga_probe(struct platform_device *pdev) | |
| 102 | +{ | |
| 103 | + struct device *dev = &pdev->dev; | |
| 104 | + struct zynqmp_fpga_priv *priv; | |
| 105 | + struct fpga_manager *mgr; | |
| 106 | + int ret; | |
| 107 | + | |
| 108 | + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | |
| 109 | + if (!priv) | |
| 110 | + return -ENOMEM; | |
| 111 | + | |
| 112 | + priv->dev = dev; | |
| 113 | + | |
| 114 | + mgr = devm_fpga_mgr_create(dev, "Xilinx ZynqMP FPGA Manager", | |
| 115 | + &zynqmp_fpga_ops, priv); | |
| 116 | + if (!mgr) | |
| 117 | + return -ENOMEM; | |
| 118 | + | |
| 119 | + platform_set_drvdata(pdev, mgr); | |
| 120 | + | |
| 121 | + ret = fpga_mgr_register(mgr); | |
| 122 | + if (ret) { | |
| 123 | + dev_err(dev, "unable to register FPGA manager"); | |
| 124 | + return ret; | |
| 125 | + } | |
| 126 | + | |
| 127 | + return 0; | |
| 128 | +} | |
| 129 | + | |
| 130 | +static int zynqmp_fpga_remove(struct platform_device *pdev) | |
| 131 | +{ | |
| 132 | + struct fpga_manager *mgr = platform_get_drvdata(pdev); | |
| 133 | + | |
| 134 | + fpga_mgr_unregister(mgr); | |
| 135 | + | |
| 136 | + return 0; | |
| 137 | +} | |
| 138 | + | |
| 139 | +static const struct of_device_id zynqmp_fpga_of_match[] = { | |
| 140 | + { .compatible = "xlnx,zynqmp-pcap-fpga", }, | |
| 141 | + {}, | |
| 142 | +}; | |
| 143 | + | |
| 144 | +MODULE_DEVICE_TABLE(of, zynqmp_fpga_of_match); | |
| 145 | + | |
| 146 | +static struct platform_driver zynqmp_fpga_driver = { | |
| 147 | + .probe = zynqmp_fpga_probe, | |
| 148 | + .remove = zynqmp_fpga_remove, | |
| 149 | + .driver = { | |
| 150 | + .name = "zynqmp_fpga_manager", | |
| 151 | + .of_match_table = of_match_ptr(zynqmp_fpga_of_match), | |
| 152 | + }, | |
| 153 | +}; | |
| 154 | + | |
| 155 | +module_platform_driver(zynqmp_fpga_driver); | |
| 156 | + | |
| 157 | +MODULE_AUTHOR("Nava kishore Manne <navam@xilinx.com>"); | |
| 158 | +MODULE_DESCRIPTION("Xilinx ZynqMp FPGA Manager"); | |
| 159 | +MODULE_LICENSE("GPL"); | |
| @@ -16,6 +16,8 @@ struct zynqmp_nvmem_data { · 15 unmodified lines | ||
| 16 | 16 | struct nvmem_device *nvmem; |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | +static const struct zynqmp_eemi_ops *eemi_ops; | |
| 20 | + | |
| 19 | 21 | static int zynqmp_nvmem_read(void *context, unsigned int offset, |
| 20 | 22 | void *val, size_t bytes) |
| 21 | 23 | { |
| @@ -23,9 +25,7 @@ static int zynqmp_nvmem_read(void *context, unsigned int offset, · 1 unmodified line | ||
| 23 | 25 | int idcode, version; |
| 24 | 26 | struct zynqmp_nvmem_data *priv = context; |
| 25 | 27 | |
| 26 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 27 | − | |
| 28 | − if (!eemi_ops || !eemi_ops->get_chipid) | |
| 28 | + if (!eemi_ops->get_chipid) | |
| 29 | 29 | return -ENXIO; |
| 30 | 30 | |
| 31 | 31 | ret = eemi_ops->get_chipid(&idcode, &version); |
| @@ -61,6 +61,10 @@ static int zynqmp_nvmem_probe(struct platform_device *pdev) · 29 unmodified lines | ||
| 61 | 61 | if (!priv) |
| 62 | 62 | return -ENOMEM; |
| 63 | 63 | |
| 64 | + eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 65 | + if (IS_ERR(eemi_ops)) | |
| 66 | + return PTR_ERR(eemi_ops); | |
| 67 | + | |
| 64 | 68 | priv->dev = dev; |
| 65 | 69 | econfig.dev = dev; |
| 66 | 70 | econfig.reg_read = zynqmp_nvmem_read; |
| @@ -79,11 +79,11 @@ static int zynqmp_reset_probe(struct platform_device *pdev) · 78 unmodified lines | ||
| 79 | 79 | if (!priv) |
| 80 | 80 | return -ENOMEM; |
| 81 | 81 | |
| 82 | − platform_set_drvdata(pdev, priv); | |
| 83 | − | |
| 84 | 82 | priv->eemi_ops = zynqmp_pm_get_eemi_ops(); |
| 85 | − if (!priv->eemi_ops) | |
| 86 | − return -ENXIO; | |
| 83 | + if (IS_ERR(priv->eemi_ops)) | |
| 84 | + return PTR_ERR(priv->eemi_ops); | |
| 85 | + | |
| 86 | + platform_set_drvdata(pdev, priv); | |
| 87 | 87 | |
| 88 | 88 | priv->rcdev.ops = &zynqmp_reset_ops; |
| 89 | 89 | priv->rcdev.owner = THIS_MODULE; |
| @@ -23,6 +23,8 @@ · 22 unmodified lines | ||
| 23 | 23 | /* Flag stating if PM nodes mapped to the PM domain has been requested */ |
| 24 | 24 | #define ZYNQMP_PM_DOMAIN_REQUESTED BIT(0) |
| 25 | 25 | |
| 26 | +static const struct zynqmp_eemi_ops *eemi_ops; | |
| 27 | + | |
| 26 | 28 | /** |
| 27 | 29 | * struct zynqmp_pm_domain - Wrapper around struct generic_pm_domain |
| 28 | 30 | * @gpd: Generic power domain |
| @@ -71,9 +73,8 @@ static int zynqmp_gpd_power_on(struct generic_pm_domain *domain) · 42 unmodified lines | ||
| 71 | 73 | { |
| 72 | 74 | int ret; |
| 73 | 75 | struct zynqmp_pm_domain *pd; |
| 74 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 75 | 76 | |
| 76 | − if (!eemi_ops || !eemi_ops->set_requirement) | |
| 77 | + if (!eemi_ops->set_requirement) | |
| 77 | 78 | return -ENXIO; |
| 78 | 79 | |
| 79 | 80 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); |
| @@ -107,9 +108,8 @@ static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) · 27 unmodified lines | ||
| 107 | 108 | struct zynqmp_pm_domain *pd; |
| 108 | 109 | u32 capabilities = 0; |
| 109 | 110 | bool may_wakeup; |
| 110 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 111 | 111 | |
| 112 | − if (!eemi_ops || !eemi_ops->set_requirement) | |
| 112 | + if (!eemi_ops->set_requirement) | |
| 113 | 113 | return -ENXIO; |
| 114 | 114 | |
| 115 | 115 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); |
| @@ -160,9 +160,8 @@ static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, · 44 unmodified lines | ||
| 160 | 160 | { |
| 161 | 161 | int ret; |
| 162 | 162 | struct zynqmp_pm_domain *pd; |
| 163 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 164 | 163 | |
| 165 | − if (!eemi_ops || !eemi_ops->request_node) | |
| 164 | + if (!eemi_ops->request_node) | |
| 166 | 165 | return -ENXIO; |
| 167 | 166 | |
| 168 | 167 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); |
| @@ -197,9 +196,8 @@ static void zynqmp_gpd_detach_dev(struct generic_pm_domain *domain, · 28 unmodified lines | ||
| 197 | 196 | { |
| 198 | 197 | int ret; |
| 199 | 198 | struct zynqmp_pm_domain *pd; |
| 200 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 201 | 199 | |
| 202 | − if (!eemi_ops || !eemi_ops->release_node) | |
| 200 | + if (!eemi_ops->release_node) | |
| 203 | 201 | return; |
| 204 | 202 | |
| 205 | 203 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); |
| @@ -266,6 +264,10 @@ static int zynqmp_gpd_probe(struct platform_device *pdev) · 60 unmodified lines | ||
| 266 | 264 | struct zynqmp_pm_domain *pd; |
| 267 | 265 | struct device *dev = &pdev->dev; |
| 268 | 266 | |
| 267 | + eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 268 | + if (IS_ERR(eemi_ops)) | |
| 269 | + return PTR_ERR(eemi_ops); | |
| 270 | + | |
| 269 | 271 | pd = devm_kcalloc(dev, ZYNQMP_NUM_DOMAINS, sizeof(*pd), GFP_KERNEL); |
| 270 | 272 | if (!pd) |
| 271 | 273 | return -ENOMEM; |
| @@ -31,6 +31,7 @@ static const char *const suspend_modes[] = { · 30 unmodified lines | ||
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | static enum pm_suspend_mode suspend_mode = PM_SUSPEND_MODE_STD; |
| 34 | +static const struct zynqmp_eemi_ops *eemi_ops; | |
| 34 | 35 | |
| 35 | 36 | enum pm_api_cb_id { |
| 36 | 37 | PM_INIT_SUSPEND_CB = 30, |
| @@ -92,9 +93,8 @@ static ssize_t suspend_mode_store(struct device *dev, · 55 unmodified lines | ||
| 92 | 93 | const char *buf, size_t count) |
| 93 | 94 | { |
| 94 | 95 | int md, ret = -EINVAL; |
| 95 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 96 | 96 | |
| 97 | − if (!eemi_ops || !eemi_ops->set_suspend_mode) | |
| 97 | + if (!eemi_ops->set_suspend_mode) | |
| 98 | 98 | return ret; |
| 99 | 99 | |
| 100 | 100 | for (md = PM_SUSPEND_MODE_FIRST; md < ARRAY_SIZE(suspend_modes); md++) |
| @@ -120,9 +120,11 @@ static int zynqmp_pm_probe(struct platform_device *pdev) · 19 unmodified lines | ||
| 120 | 120 | int ret, irq; |
| 121 | 121 | u32 pm_api_version; |
| 122 | 122 | |
| 123 | − const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 123 | + eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 124 | + if (IS_ERR(eemi_ops)) | |
| 125 | + return PTR_ERR(eemi_ops); | |
| 124 | 126 | |
| 125 | − if (!eemi_ops || !eemi_ops->get_api_version || !eemi_ops->init_finalize) | |
| 127 | + if (!eemi_ops->get_api_version || !eemi_ops->init_finalize) | |
| 126 | 128 | return -ENXIO; |
| 127 | 129 | |
| 128 | 130 | eemi_ops->init_finalize(); |
| @@ -138,6 +138,7 @@ · 137 unmodified lines | ||
| 138 | 138 | |
| 139 | 139 | #define SPI_AUTOSUSPEND_TIMEOUT 3000 |
| 140 | 140 | enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; |
| 141 | +static const struct zynqmp_eemi_ops *eemi_ops; | |
| 141 | 142 | |
| 142 | 143 | /** |
| 143 | 144 | * struct zynqmp_qspi - Defines qspi driver instance |
| @@ -1021,6 +1022,10 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) · 877 unmodified lines | ||
| 1021 | 1022 | struct resource *res; |
| 1022 | 1023 | struct device *dev = &pdev->dev; |
| 1023 | 1024 | |
| 1025 | + eemi_ops = zynqmp_pm_get_eemi_ops(); | |
| 1026 | + if (IS_ERR(eemi_ops)) | |
| 1027 | + return PTR_ERR(eemi_ops); | |
| 1028 | + | |
| 1024 | 1029 | master = spi_alloc_master(&pdev->dev, sizeof(*xqspi)); |
| 1025 | 1030 | if (!master) |
| 1026 | 1031 | return -ENOMEM; |
| @@ -48,6 +48,14 @@ · 47 unmodified lines | ||
| 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, |
| @@ -56,6 +64,8 @@ enum pm_api_id { · 2 unmodified lines | ||
| 56 | 64 | PM_RESET_ASSERT = 17, |
| 57 | 65 | PM_RESET_GET_STATUS, |
| 58 | 66 | PM_PM_INIT_FINALIZE = 21, |
| 67 | + PM_FPGA_LOAD, | |
| 68 | + PM_FPGA_GET_STATUS, | |
| 59 | 69 | PM_GET_CHIPID = 24, |
| 60 | 70 | PM_IOCTL = 34, |
| 61 | 71 | PM_QUERY_DATA, |
| @@ -258,6 +268,8 @@ struct zynqmp_pm_query_data { · 196 unmodified lines | ||
| 258 | 268 | struct zynqmp_eemi_ops { |
| 259 | 269 | int (*get_api_version)(u32 *version); |
| 260 | 270 | 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); | |
| 261 | 273 | int (*query_data)(struct zynqmp_pm_query_data qdata, u32 *out); |
| 262 | 274 | int (*clock_enable)(u32 clock_id); |
| 263 | 275 | int (*clock_disable)(u32 clock_id); |
| @@ -293,7 +305,7 @@ const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void); · 29 unmodified lines | ||
| 293 | 305 | #else |
| 294 | 306 | static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void) |
| 295 | 307 | { |
| 296 | − return NULL; | |
| 308 | + return ERR_PTR(-ENODEV); | |
| 297 | 309 | } |
| 298 | 310 | #endif |
| 299 | 311 | |