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

Merge tag 'fpga-for-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/fpga/linux-fpga into char-misc-next

Xu writes:

FPGA Manager changes for 6.10-rc1

FPGA MGR core:

- Marco's change adds module owner parameter for all registration APIs.

FPGA test:

- Macro's change uses KUnit devices instead of platform devices.

DFL:

- Peter's change cleans up unused symbols.

Xlinux:

- Charles adds SelectMAP interface reprogramming support.
- Andy's header inclusion cleanup.

Altera:

- Krzysztof & Christophe's cleanup for drivers

* tag 'fpga-for-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/fpga/linux-fpga:
fpga: region: add owner module and take its refcount
fpga: dfl: remove unused member pdata from struct dfl_{afu,fme}
fpga: dfl: remove unused function is_dfl_feature_present()
fpga: ice40-spi: Don't use "proxy" headers
fpga: tests: use KUnit devices instead of platform devices
fpga: altera-cvp: Remove an unused field in struct altera_cvp_conf
fpga: altera: drop driver owner assignment
fpga: xilinx-core: add new gpio names for prog and init
fpga: xilinx-selectmap: add new driver
dt-bindings: fpga: xlnx,fpga-selectmap: add DT schema
fpga: xilinx-spi: extract a common driver core
fpga: bridge: add owner module and take its refcount
fpga: manager: add owner module and take its refcount

+676 -375
+86
Documentation/devicetree/bindings/fpga/xlnx,fpga-selectmap.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/fpga/xlnx,fpga-selectmap.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Xilinx SelectMAP FPGA interface 8 + 9 + maintainers: 10 + - Charles Perry <charles.perry@savoirfairelinux.com> 11 + 12 + description: | 13 + Xilinx 7 Series FPGAs support a method of loading the bitstream over a 14 + parallel port named the SelectMAP interface in the documentation. Only 15 + the x8 mode is supported where data is loaded at one byte per rising edge of 16 + the clock, with the MSB of each byte presented to the D0 pin. 17 + 18 + Datasheets: 19 + https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf 20 + 21 + allOf: 22 + - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml# 23 + 24 + properties: 25 + compatible: 26 + enum: 27 + - xlnx,fpga-xc7s-selectmap 28 + - xlnx,fpga-xc7a-selectmap 29 + - xlnx,fpga-xc7k-selectmap 30 + - xlnx,fpga-xc7v-selectmap 31 + 32 + reg: 33 + description: 34 + At least 1 byte of memory mapped IO 35 + maxItems: 1 36 + 37 + prog-gpios: 38 + description: 39 + config pin (referred to as PROGRAM_B in the manual) 40 + maxItems: 1 41 + 42 + done-gpios: 43 + description: 44 + config status pin (referred to as DONE in the manual) 45 + maxItems: 1 46 + 47 + init-gpios: 48 + description: 49 + initialization status and configuration error pin 50 + (referred to as INIT_B in the manual) 51 + maxItems: 1 52 + 53 + csi-gpios: 54 + description: 55 + chip select pin (referred to as CSI_B in the manual) 56 + Optional gpio for if the bus controller does not provide a chip select. 57 + maxItems: 1 58 + 59 + rdwr-gpios: 60 + description: 61 + read/write select pin (referred to as RDWR_B in the manual) 62 + Optional gpio for if the bus controller does not provide this pin. 63 + maxItems: 1 64 + 65 + required: 66 + - compatible 67 + - reg 68 + - prog-gpios 69 + - done-gpios 70 + - init-gpios 71 + 72 + unevaluatedProperties: false 73 + 74 + examples: 75 + - | 76 + #include <dt-bindings/gpio/gpio.h> 77 + fpga-mgr@8000000 { 78 + compatible = "xlnx,fpga-xc7s-selectmap"; 79 + reg = <0x8000000 0x4>; 80 + prog-gpios = <&gpio5 5 GPIO_ACTIVE_LOW>; 81 + init-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>; 82 + done-gpios = <&gpio2 30 GPIO_ACTIVE_HIGH>; 83 + csi-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>; 84 + rdwr-gpios = <&gpio3 10 GPIO_ACTIVE_LOW>; 85 + }; 86 + ...
+5 -2
Documentation/driver-api/fpga/fpga-bridge.rst
··· 6 6 7 7 * struct fpga_bridge - The FPGA Bridge structure 8 8 * struct fpga_bridge_ops - Low level Bridge driver ops 9 - * fpga_bridge_register() - Create and register a bridge 9 + * __fpga_bridge_register() - Create and register a bridge 10 10 * fpga_bridge_unregister() - Unregister a bridge 11 + 12 + The helper macro ``fpga_bridge_register()`` automatically sets 13 + the module that registers the FPGA bridge as the owner. 11 14 12 15 .. kernel-doc:: include/linux/fpga/fpga-bridge.h 13 16 :functions: fpga_bridge ··· 19 16 :functions: fpga_bridge_ops 20 17 21 18 .. kernel-doc:: drivers/fpga/fpga-bridge.c 22 - :functions: fpga_bridge_register 19 + :functions: __fpga_bridge_register 23 20 24 21 .. kernel-doc:: drivers/fpga/fpga-bridge.c 25 22 :functions: fpga_bridge_unregister
+20 -14
Documentation/driver-api/fpga/fpga-mgr.rst
··· 24 24 -------------------------------- 25 25 26 26 To add another FPGA manager, write a driver that implements a set of ops. The 27 - probe function calls fpga_mgr_register() or fpga_mgr_register_full(), such as:: 27 + probe function calls ``fpga_mgr_register()`` or ``fpga_mgr_register_full()``, 28 + such as:: 28 29 29 30 static const struct fpga_manager_ops socfpga_fpga_ops = { 30 31 .write_init = socfpga_fpga_ops_configure_init, ··· 70 69 } 71 70 72 71 Alternatively, the probe function could call one of the resource managed 73 - register functions, devm_fpga_mgr_register() or devm_fpga_mgr_register_full(). 74 - When these functions are used, the parameter syntax is the same, but the call 75 - to fpga_mgr_unregister() should be removed. In the above example, the 76 - socfpga_fpga_remove() function would not be required. 72 + register functions, ``devm_fpga_mgr_register()`` or 73 + ``devm_fpga_mgr_register_full()``. When these functions are used, the 74 + parameter syntax is the same, but the call to ``fpga_mgr_unregister()`` should be 75 + removed. In the above example, the ``socfpga_fpga_remove()`` function would not be 76 + required. 77 77 78 78 The ops will implement whatever device specific register writes are needed to 79 79 do the programming sequence for this particular FPGA. These ops return 0 for ··· 127 125 * struct fpga_manager - the FPGA manager struct 128 126 * struct fpga_manager_ops - Low level FPGA manager driver ops 129 127 * struct fpga_manager_info - Parameter structure for fpga_mgr_register_full() 130 - * fpga_mgr_register_full() - Create and register an FPGA manager using the 128 + * __fpga_mgr_register_full() - Create and register an FPGA manager using the 131 129 fpga_mgr_info structure to provide the full flexibility of options 132 - * fpga_mgr_register() - Create and register an FPGA manager using standard 130 + * __fpga_mgr_register() - Create and register an FPGA manager using standard 133 131 arguments 134 - * devm_fpga_mgr_register_full() - Resource managed version of 135 - fpga_mgr_register_full() 136 - * devm_fpga_mgr_register() - Resource managed version of fpga_mgr_register() 132 + * __devm_fpga_mgr_register_full() - Resource managed version of 133 + __fpga_mgr_register_full() 134 + * __devm_fpga_mgr_register() - Resource managed version of __fpga_mgr_register() 137 135 * fpga_mgr_unregister() - Unregister an FPGA manager 136 + 137 + Helper macros ``fpga_mgr_register_full()``, ``fpga_mgr_register()``, 138 + ``devm_fpga_mgr_register_full()``, and ``devm_fpga_mgr_register()`` are available 139 + to ease the registration. 138 140 139 141 .. kernel-doc:: include/linux/fpga/fpga-mgr.h 140 142 :functions: fpga_mgr_states ··· 153 147 :functions: fpga_manager_info 154 148 155 149 .. kernel-doc:: drivers/fpga/fpga-mgr.c 156 - :functions: fpga_mgr_register_full 150 + :functions: __fpga_mgr_register_full 157 151 158 152 .. kernel-doc:: drivers/fpga/fpga-mgr.c 159 - :functions: fpga_mgr_register 153 + :functions: __fpga_mgr_register 160 154 161 155 .. kernel-doc:: drivers/fpga/fpga-mgr.c 162 - :functions: devm_fpga_mgr_register_full 156 + :functions: __devm_fpga_mgr_register_full 163 157 164 158 .. kernel-doc:: drivers/fpga/fpga-mgr.c 165 - :functions: devm_fpga_mgr_register 159 + :functions: __devm_fpga_mgr_register 166 160 167 161 .. kernel-doc:: drivers/fpga/fpga-mgr.c 168 162 :functions: fpga_mgr_unregister
+8 -5
Documentation/driver-api/fpga/fpga-region.rst
··· 46 46 ---------------------------- 47 47 48 48 * struct fpga_region - The FPGA region struct 49 - * struct fpga_region_info - Parameter structure for fpga_region_register_full() 50 - * fpga_region_register_full() - Create and register an FPGA region using the 49 + * struct fpga_region_info - Parameter structure for __fpga_region_register_full() 50 + * __fpga_region_register_full() - Create and register an FPGA region using the 51 51 fpga_region_info structure to provide the full flexibility of options 52 - * fpga_region_register() - Create and register an FPGA region using standard 52 + * __fpga_region_register() - Create and register an FPGA region using standard 53 53 arguments 54 54 * fpga_region_unregister() - Unregister an FPGA region 55 + 56 + Helper macros ``fpga_region_register()`` and ``fpga_region_register_full()`` 57 + automatically set the module that registers the FPGA region as the owner. 55 58 56 59 The FPGA region's probe function will need to get a reference to the FPGA 57 60 Manager it will be using to do the programming. This usually would happen ··· 85 82 :functions: fpga_region_info 86 83 87 84 .. kernel-doc:: drivers/fpga/fpga-region.c 88 - :functions: fpga_region_register_full 85 + :functions: __fpga_region_register_full 89 86 90 87 .. kernel-doc:: drivers/fpga/fpga-region.c 91 - :functions: fpga_region_register 88 + :functions: __fpga_region_register 92 89 93 90 .. kernel-doc:: drivers/fpga/fpga-region.c 94 91 :functions: fpga_region_unregister
+12
drivers/fpga/Kconfig
··· 64 64 help 65 65 FPGA manager driver support for the Intel Stratix10 SoC. 66 66 67 + config FPGA_MGR_XILINX_CORE 68 + tristate 69 + 70 + config FPGA_MGR_XILINX_SELECTMAP 71 + tristate "Xilinx Configuration over SelectMAP" 72 + depends on HAS_IOMEM 73 + select FPGA_MGR_XILINX_CORE 74 + help 75 + FPGA manager driver support for Xilinx FPGA configuration 76 + over SelectMAP interface. 77 + 67 78 config FPGA_MGR_XILINX_SPI 68 79 tristate "Xilinx Configuration over Slave Serial (SPI)" 69 80 depends on SPI 81 + select FPGA_MGR_XILINX_CORE 70 82 help 71 83 FPGA manager driver support for Xilinx FPGA configuration 72 84 over slave serial interface.
+2
drivers/fpga/Makefile
··· 15 15 obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o 16 16 obj-$(CONFIG_FPGA_MGR_STRATIX10_SOC) += stratix10-soc.o 17 17 obj-$(CONFIG_FPGA_MGR_TS73XX) += ts73xx-fpga.o 18 + obj-$(CONFIG_FPGA_MGR_XILINX_CORE) += xilinx-core.o 19 + obj-$(CONFIG_FPGA_MGR_XILINX_SELECTMAP) += xilinx-selectmap.o 18 20 obj-$(CONFIG_FPGA_MGR_XILINX_SPI) += xilinx-spi.o 19 21 obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o 20 22 obj-$(CONFIG_FPGA_MGR_ZYNQMP_FPGA) += zynqmp-fpga.o
-1
drivers/fpga/altera-cvp.c
··· 72 72 struct cvp_priv; 73 73 74 74 struct altera_cvp_conf { 75 - struct fpga_manager *mgr; 76 75 struct pci_dev *pci_dev; 77 76 void __iomem *map; 78 77 void (*write_data)(struct altera_cvp_conf *conf,
-1
drivers/fpga/altera-ps-spi.c
··· 284 284 static struct spi_driver altera_ps_driver = { 285 285 .driver = { 286 286 .name = "altera-ps-spi", 287 - .owner = THIS_MODULE, 288 287 .of_match_table = of_ef_match, 289 288 }, 290 289 .id_table = altera_ps_spi_ids,
-2
drivers/fpga/dfl-afu-main.c
··· 858 858 if (!afu) 859 859 return -ENOMEM; 860 860 861 - afu->pdata = pdata; 862 - 863 861 mutex_lock(&pdata->lock); 864 862 dfl_fpga_pdata_set_private(pdata, afu); 865 863 afu_mmio_region_init(pdata);
-3
drivers/fpga/dfl-afu.h
··· 67 67 * @regions: the mmio region linked list of this afu feature device. 68 68 * @dma_regions: root of dma regions rb tree. 69 69 * @num_umsgs: num of umsgs. 70 - * @pdata: afu platform device's pdata. 71 70 */ 72 71 struct dfl_afu { 73 72 u64 region_cur_offset; ··· 74 75 u8 num_umsgs; 75 76 struct list_head regions; 76 77 struct rb_root dma_regions; 77 - 78 - struct dfl_feature_platform_data *pdata; 79 78 }; 80 79 81 80 /* hold pdata->lock when call __afu_port_enable/disable */
-2
drivers/fpga/dfl-fme-main.c
··· 679 679 if (!fme) 680 680 return -ENOMEM; 681 681 682 - fme->pdata = pdata; 683 - 684 682 mutex_lock(&pdata->lock); 685 683 dfl_fpga_pdata_set_private(pdata, fme); 686 684 mutex_unlock(&pdata->lock);
-2
drivers/fpga/dfl-fme.h
··· 24 24 * @mgr: FME's FPGA manager platform device. 25 25 * @region_list: linked list of FME's FPGA regions. 26 26 * @bridge_list: linked list of FME's FPGA bridges. 27 - * @pdata: fme platform device's pdata. 28 27 */ 29 28 struct dfl_fme { 30 29 struct platform_device *mgr; 31 30 struct list_head region_list; 32 31 struct list_head bridge_list; 33 - struct dfl_feature_platform_data *pdata; 34 32 }; 35 33 36 34 extern const struct dfl_feature_ops fme_pr_mgmt_ops;
-5
drivers/fpga/dfl.h
··· 437 437 return NULL; 438 438 } 439 439 440 - static inline bool is_dfl_feature_present(struct device *dev, u16 id) 441 - { 442 - return !!dfl_get_feature_ioaddr_by_id(dev, id); 443 - } 444 - 445 440 static inline 446 441 struct device *dfl_fpga_pdata_to_parent(struct dfl_feature_platform_data *pdata) 447 442 {
+31 -26
drivers/fpga/fpga-bridge.c
··· 55 55 } 56 56 EXPORT_SYMBOL_GPL(fpga_bridge_disable); 57 57 58 - static struct fpga_bridge *__fpga_bridge_get(struct device *dev, 58 + static struct fpga_bridge *__fpga_bridge_get(struct device *bridge_dev, 59 59 struct fpga_image_info *info) 60 60 { 61 61 struct fpga_bridge *bridge; 62 - int ret = -ENODEV; 63 62 64 - bridge = to_fpga_bridge(dev); 63 + bridge = to_fpga_bridge(bridge_dev); 65 64 66 65 bridge->info = info; 67 66 68 - if (!mutex_trylock(&bridge->mutex)) { 69 - ret = -EBUSY; 70 - goto err_dev; 71 - } 67 + if (!mutex_trylock(&bridge->mutex)) 68 + return ERR_PTR(-EBUSY); 72 69 73 - if (!try_module_get(dev->parent->driver->owner)) 74 - goto err_ll_mod; 70 + if (!try_module_get(bridge->br_ops_owner)) { 71 + mutex_unlock(&bridge->mutex); 72 + return ERR_PTR(-ENODEV); 73 + } 75 74 76 75 dev_dbg(&bridge->dev, "get\n"); 77 76 78 77 return bridge; 79 - 80 - err_ll_mod: 81 - mutex_unlock(&bridge->mutex); 82 - err_dev: 83 - put_device(dev); 84 - return ERR_PTR(ret); 85 78 } 86 79 87 80 /** ··· 91 98 struct fpga_bridge *of_fpga_bridge_get(struct device_node *np, 92 99 struct fpga_image_info *info) 93 100 { 94 - struct device *dev; 101 + struct fpga_bridge *bridge; 102 + struct device *bridge_dev; 95 103 96 - dev = class_find_device_by_of_node(&fpga_bridge_class, np); 97 - if (!dev) 104 + bridge_dev = class_find_device_by_of_node(&fpga_bridge_class, np); 105 + if (!bridge_dev) 98 106 return ERR_PTR(-ENODEV); 99 107 100 - return __fpga_bridge_get(dev, info); 108 + bridge = __fpga_bridge_get(bridge_dev, info); 109 + if (IS_ERR(bridge)) 110 + put_device(bridge_dev); 111 + 112 + return bridge; 101 113 } 102 114 EXPORT_SYMBOL_GPL(of_fpga_bridge_get); 103 115 ··· 123 125 struct fpga_bridge *fpga_bridge_get(struct device *dev, 124 126 struct fpga_image_info *info) 125 127 { 128 + struct fpga_bridge *bridge; 126 129 struct device *bridge_dev; 127 130 128 131 bridge_dev = class_find_device(&fpga_bridge_class, NULL, dev, ··· 131 132 if (!bridge_dev) 132 133 return ERR_PTR(-ENODEV); 133 134 134 - return __fpga_bridge_get(bridge_dev, info); 135 + bridge = __fpga_bridge_get(bridge_dev, info); 136 + if (IS_ERR(bridge)) 137 + put_device(bridge_dev); 138 + 139 + return bridge; 135 140 } 136 141 EXPORT_SYMBOL_GPL(fpga_bridge_get); 137 142 ··· 149 146 dev_dbg(&bridge->dev, "put\n"); 150 147 151 148 bridge->info = NULL; 152 - module_put(bridge->dev.parent->driver->owner); 149 + module_put(bridge->br_ops_owner); 153 150 mutex_unlock(&bridge->mutex); 154 151 put_device(&bridge->dev); 155 152 } ··· 319 316 ATTRIBUTE_GROUPS(fpga_bridge); 320 317 321 318 /** 322 - * fpga_bridge_register - create and register an FPGA Bridge device 319 + * __fpga_bridge_register - create and register an FPGA Bridge device 323 320 * @parent: FPGA bridge device from pdev 324 321 * @name: FPGA bridge name 325 322 * @br_ops: pointer to structure of fpga bridge ops 326 323 * @priv: FPGA bridge private data 324 + * @owner: owner module containing the br_ops 327 325 * 328 326 * Return: struct fpga_bridge pointer or ERR_PTR() 329 327 */ 330 328 struct fpga_bridge * 331 - fpga_bridge_register(struct device *parent, const char *name, 332 - const struct fpga_bridge_ops *br_ops, 333 - void *priv) 329 + __fpga_bridge_register(struct device *parent, const char *name, 330 + const struct fpga_bridge_ops *br_ops, 331 + void *priv, struct module *owner) 334 332 { 335 333 struct fpga_bridge *bridge; 336 334 int id, ret; ··· 361 357 362 358 bridge->name = name; 363 359 bridge->br_ops = br_ops; 360 + bridge->br_ops_owner = owner; 364 361 bridge->priv = priv; 365 362 366 363 bridge->dev.groups = br_ops->groups; ··· 391 386 392 387 return ERR_PTR(ret); 393 388 } 394 - EXPORT_SYMBOL_GPL(fpga_bridge_register); 389 + EXPORT_SYMBOL_GPL(__fpga_bridge_register); 395 390 396 391 /** 397 392 * fpga_bridge_unregister - unregister an FPGA bridge
+49 -33
drivers/fpga/fpga-mgr.c
··· 664 664 }; 665 665 ATTRIBUTE_GROUPS(fpga_mgr); 666 666 667 - static struct fpga_manager *__fpga_mgr_get(struct device *dev) 667 + static struct fpga_manager *__fpga_mgr_get(struct device *mgr_dev) 668 668 { 669 669 struct fpga_manager *mgr; 670 670 671 - mgr = to_fpga_manager(dev); 671 + mgr = to_fpga_manager(mgr_dev); 672 672 673 - if (!try_module_get(dev->parent->driver->owner)) 674 - goto err_dev; 673 + if (!try_module_get(mgr->mops_owner)) 674 + mgr = ERR_PTR(-ENODEV); 675 675 676 676 return mgr; 677 - 678 - err_dev: 679 - put_device(dev); 680 - return ERR_PTR(-ENODEV); 681 677 } 682 678 683 679 static int fpga_mgr_dev_match(struct device *dev, const void *data) ··· 689 693 */ 690 694 struct fpga_manager *fpga_mgr_get(struct device *dev) 691 695 { 692 - struct device *mgr_dev = class_find_device(&fpga_mgr_class, NULL, dev, 693 - fpga_mgr_dev_match); 696 + struct fpga_manager *mgr; 697 + struct device *mgr_dev; 698 + 699 + mgr_dev = class_find_device(&fpga_mgr_class, NULL, dev, fpga_mgr_dev_match); 694 700 if (!mgr_dev) 695 701 return ERR_PTR(-ENODEV); 696 702 697 - return __fpga_mgr_get(mgr_dev); 703 + mgr = __fpga_mgr_get(mgr_dev); 704 + if (IS_ERR(mgr)) 705 + put_device(mgr_dev); 706 + 707 + return mgr; 698 708 } 699 709 EXPORT_SYMBOL_GPL(fpga_mgr_get); 700 710 ··· 713 711 */ 714 712 struct fpga_manager *of_fpga_mgr_get(struct device_node *node) 715 713 { 716 - struct device *dev; 714 + struct fpga_manager *mgr; 715 + struct device *mgr_dev; 717 716 718 - dev = class_find_device_by_of_node(&fpga_mgr_class, node); 719 - if (!dev) 717 + mgr_dev = class_find_device_by_of_node(&fpga_mgr_class, node); 718 + if (!mgr_dev) 720 719 return ERR_PTR(-ENODEV); 721 720 722 - return __fpga_mgr_get(dev); 721 + mgr = __fpga_mgr_get(mgr_dev); 722 + if (IS_ERR(mgr)) 723 + put_device(mgr_dev); 724 + 725 + return mgr; 723 726 } 724 727 EXPORT_SYMBOL_GPL(of_fpga_mgr_get); 725 728 ··· 734 727 */ 735 728 void fpga_mgr_put(struct fpga_manager *mgr) 736 729 { 737 - module_put(mgr->dev.parent->driver->owner); 730 + module_put(mgr->mops_owner); 738 731 put_device(&mgr->dev); 739 732 } 740 733 EXPORT_SYMBOL_GPL(fpga_mgr_put); ··· 773 766 EXPORT_SYMBOL_GPL(fpga_mgr_unlock); 774 767 775 768 /** 776 - * fpga_mgr_register_full - create and register an FPGA Manager device 769 + * __fpga_mgr_register_full - create and register an FPGA Manager device 777 770 * @parent: fpga manager device from pdev 778 771 * @info: parameters for fpga manager 772 + * @owner: owner module containing the ops 779 773 * 780 774 * The caller of this function is responsible for calling fpga_mgr_unregister(). 781 775 * Using devm_fpga_mgr_register_full() instead is recommended. ··· 784 776 * Return: pointer to struct fpga_manager pointer or ERR_PTR() 785 777 */ 786 778 struct fpga_manager * 787 - fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info) 779 + __fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info, 780 + struct module *owner) 788 781 { 789 782 const struct fpga_manager_ops *mops = info->mops; 790 783 struct fpga_manager *mgr; ··· 812 803 } 813 804 814 805 mutex_init(&mgr->ref_mutex); 806 + 807 + mgr->mops_owner = owner; 815 808 816 809 mgr->name = info->name; 817 810 mgr->mops = info->mops; ··· 852 841 853 842 return ERR_PTR(ret); 854 843 } 855 - EXPORT_SYMBOL_GPL(fpga_mgr_register_full); 844 + EXPORT_SYMBOL_GPL(__fpga_mgr_register_full); 856 845 857 846 /** 858 - * fpga_mgr_register - create and register an FPGA Manager device 847 + * __fpga_mgr_register - create and register an FPGA Manager device 859 848 * @parent: fpga manager device from pdev 860 849 * @name: fpga manager name 861 850 * @mops: pointer to structure of fpga manager ops 862 851 * @priv: fpga manager private data 852 + * @owner: owner module containing the ops 863 853 * 864 854 * The caller of this function is responsible for calling fpga_mgr_unregister(). 865 855 * Using devm_fpga_mgr_register() instead is recommended. This simple ··· 871 859 * Return: pointer to struct fpga_manager pointer or ERR_PTR() 872 860 */ 873 861 struct fpga_manager * 874 - fpga_mgr_register(struct device *parent, const char *name, 875 - const struct fpga_manager_ops *mops, void *priv) 862 + __fpga_mgr_register(struct device *parent, const char *name, 863 + const struct fpga_manager_ops *mops, void *priv, struct module *owner) 876 864 { 877 865 struct fpga_manager_info info = { 0 }; 878 866 ··· 880 868 info.mops = mops; 881 869 info.priv = priv; 882 870 883 - return fpga_mgr_register_full(parent, &info); 871 + return __fpga_mgr_register_full(parent, &info, owner); 884 872 } 885 - EXPORT_SYMBOL_GPL(fpga_mgr_register); 873 + EXPORT_SYMBOL_GPL(__fpga_mgr_register); 886 874 887 875 /** 888 876 * fpga_mgr_unregister - unregister an FPGA manager ··· 912 900 } 913 901 914 902 /** 915 - * devm_fpga_mgr_register_full - resource managed variant of fpga_mgr_register() 903 + * __devm_fpga_mgr_register_full - resource managed variant of fpga_mgr_register() 916 904 * @parent: fpga manager device from pdev 917 905 * @info: parameters for fpga manager 906 + * @owner: owner module containing the ops 918 907 * 919 908 * Return: fpga manager pointer on success, negative error code otherwise. 920 909 * ··· 923 910 * function will be called automatically when the managing device is detached. 924 911 */ 925 912 struct fpga_manager * 926 - devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info) 913 + __devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info, 914 + struct module *owner) 927 915 { 928 916 struct fpga_mgr_devres *dr; 929 917 struct fpga_manager *mgr; ··· 933 919 if (!dr) 934 920 return ERR_PTR(-ENOMEM); 935 921 936 - mgr = fpga_mgr_register_full(parent, info); 922 + mgr = __fpga_mgr_register_full(parent, info, owner); 937 923 if (IS_ERR(mgr)) { 938 924 devres_free(dr); 939 925 return mgr; ··· 944 930 945 931 return mgr; 946 932 } 947 - EXPORT_SYMBOL_GPL(devm_fpga_mgr_register_full); 933 + EXPORT_SYMBOL_GPL(__devm_fpga_mgr_register_full); 948 934 949 935 /** 950 - * devm_fpga_mgr_register - resource managed variant of fpga_mgr_register() 936 + * __devm_fpga_mgr_register - resource managed variant of fpga_mgr_register() 951 937 * @parent: fpga manager device from pdev 952 938 * @name: fpga manager name 953 939 * @mops: pointer to structure of fpga manager ops 954 940 * @priv: fpga manager private data 941 + * @owner: owner module containing the ops 955 942 * 956 943 * Return: fpga manager pointer on success, negative error code otherwise. 957 944 * ··· 961 946 * device is detached. 962 947 */ 963 948 struct fpga_manager * 964 - devm_fpga_mgr_register(struct device *parent, const char *name, 965 - const struct fpga_manager_ops *mops, void *priv) 949 + __devm_fpga_mgr_register(struct device *parent, const char *name, 950 + const struct fpga_manager_ops *mops, void *priv, 951 + struct module *owner) 966 952 { 967 953 struct fpga_manager_info info = { 0 }; 968 954 ··· 971 955 info.mops = mops; 972 956 info.priv = priv; 973 957 974 - return devm_fpga_mgr_register_full(parent, &info); 958 + return __devm_fpga_mgr_register_full(parent, &info, owner); 975 959 } 976 - EXPORT_SYMBOL_GPL(devm_fpga_mgr_register); 960 + EXPORT_SYMBOL_GPL(__devm_fpga_mgr_register); 977 961 978 962 static void fpga_mgr_dev_release(struct device *dev) 979 963 {
+14 -10
drivers/fpga/fpga-region.c
··· 53 53 } 54 54 55 55 get_device(dev); 56 - if (!try_module_get(dev->parent->driver->owner)) { 56 + if (!try_module_get(region->ops_owner)) { 57 57 put_device(dev); 58 58 mutex_unlock(&region->mutex); 59 59 return ERR_PTR(-ENODEV); ··· 75 75 76 76 dev_dbg(dev, "put\n"); 77 77 78 - module_put(dev->parent->driver->owner); 78 + module_put(region->ops_owner); 79 79 put_device(dev); 80 80 mutex_unlock(&region->mutex); 81 81 } ··· 181 181 ATTRIBUTE_GROUPS(fpga_region); 182 182 183 183 /** 184 - * fpga_region_register_full - create and register an FPGA Region device 184 + * __fpga_region_register_full - create and register an FPGA Region device 185 185 * @parent: device parent 186 186 * @info: parameters for FPGA Region 187 + * @owner: module containing the get_bridges function 187 188 * 188 189 * Return: struct fpga_region or ERR_PTR() 189 190 */ 190 191 struct fpga_region * 191 - fpga_region_register_full(struct device *parent, const struct fpga_region_info *info) 192 + __fpga_region_register_full(struct device *parent, const struct fpga_region_info *info, 193 + struct module *owner) 192 194 { 193 195 struct fpga_region *region; 194 196 int id, ret = 0; ··· 215 213 region->compat_id = info->compat_id; 216 214 region->priv = info->priv; 217 215 region->get_bridges = info->get_bridges; 216 + region->ops_owner = owner; 218 217 219 218 mutex_init(&region->mutex); 220 219 INIT_LIST_HEAD(&region->bridge_list); ··· 244 241 245 242 return ERR_PTR(ret); 246 243 } 247 - EXPORT_SYMBOL_GPL(fpga_region_register_full); 244 + EXPORT_SYMBOL_GPL(__fpga_region_register_full); 248 245 249 246 /** 250 - * fpga_region_register - create and register an FPGA Region device 247 + * __fpga_region_register - create and register an FPGA Region device 251 248 * @parent: device parent 252 249 * @mgr: manager that programs this region 253 250 * @get_bridges: optional function to get bridges to a list 251 + * @owner: module containing the get_bridges function 254 252 * 255 253 * This simple version of the register function should be sufficient for most users. 256 254 * The fpga_region_register_full() function is available for users that need to ··· 260 256 * Return: struct fpga_region or ERR_PTR() 261 257 */ 262 258 struct fpga_region * 263 - fpga_region_register(struct device *parent, struct fpga_manager *mgr, 264 - int (*get_bridges)(struct fpga_region *)) 259 + __fpga_region_register(struct device *parent, struct fpga_manager *mgr, 260 + int (*get_bridges)(struct fpga_region *), struct module *owner) 265 261 { 266 262 struct fpga_region_info info = { 0 }; 267 263 268 264 info.mgr = mgr; 269 265 info.get_bridges = get_bridges; 270 266 271 - return fpga_region_register_full(parent, &info); 267 + return __fpga_region_register_full(parent, &info, owner); 272 268 } 273 - EXPORT_SYMBOL_GPL(fpga_region_register); 269 + EXPORT_SYMBOL_GPL(__fpga_region_register); 274 270 275 271 /** 276 272 * fpga_region_unregister - unregister an FPGA region
+2 -2
drivers/fpga/ice40-spi.c
··· 10 10 11 11 #include <linux/fpga/fpga-mgr.h> 12 12 #include <linux/gpio/consumer.h> 13 + #include <linux/mod_devicetable.h> 13 14 #include <linux/module.h> 14 - #include <linux/of_gpio.h> 15 15 #include <linux/spi/spi.h> 16 16 #include <linux/stringify.h> 17 17 ··· 199 199 .probe = ice40_fpga_probe, 200 200 .driver = { 201 201 .name = "ice40spi", 202 - .of_match_table = of_match_ptr(ice40_fpga_of_match), 202 + .of_match_table = ice40_fpga_of_match, 203 203 }, 204 204 .id_table = ice40_fpga_spi_ids, 205 205 };
+17 -16
drivers/fpga/tests/fpga-bridge-test.c
··· 7 7 * Author: Marco Pagani <marpagan@redhat.com> 8 8 */ 9 9 10 + #include <kunit/device.h> 10 11 #include <kunit/test.h> 11 - #include <linux/device.h> 12 12 #include <linux/fpga/fpga-bridge.h> 13 13 #include <linux/module.h> 14 14 #include <linux/types.h> ··· 19 19 20 20 struct bridge_ctx { 21 21 struct fpga_bridge *bridge; 22 - struct platform_device *pdev; 22 + struct device *dev; 23 23 struct bridge_stats stats; 24 24 }; 25 25 ··· 43 43 /** 44 44 * register_test_bridge() - Register a fake FPGA bridge for testing. 45 45 * @test: KUnit test context object. 46 + * @dev_name: name of the kunit device to be registered 46 47 * 47 48 * Return: Context of the newly registered FPGA bridge. 48 49 */ 49 - static struct bridge_ctx *register_test_bridge(struct kunit *test) 50 + static struct bridge_ctx *register_test_bridge(struct kunit *test, const char *dev_name) 50 51 { 51 52 struct bridge_ctx *ctx; 52 53 53 54 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); 54 55 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 55 56 56 - ctx->pdev = platform_device_register_simple("bridge_pdev", PLATFORM_DEVID_AUTO, NULL, 0); 57 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->pdev); 57 + ctx->dev = kunit_device_register(test, dev_name); 58 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->dev); 58 59 59 - ctx->bridge = fpga_bridge_register(&ctx->pdev->dev, "Fake FPGA bridge", &fake_bridge_ops, 60 + ctx->bridge = fpga_bridge_register(ctx->dev, "Fake FPGA bridge", &fake_bridge_ops, 60 61 &ctx->stats); 61 62 KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->bridge)); 62 63 63 64 return ctx; 64 65 } 65 66 66 - static void unregister_test_bridge(struct bridge_ctx *ctx) 67 + static void unregister_test_bridge(struct kunit *test, struct bridge_ctx *ctx) 67 68 { 68 69 fpga_bridge_unregister(ctx->bridge); 69 - platform_device_unregister(ctx->pdev); 70 + kunit_device_unregister(test, ctx->dev); 70 71 } 71 72 72 73 static void fpga_bridge_test_get(struct kunit *test) ··· 75 74 struct bridge_ctx *ctx = test->priv; 76 75 struct fpga_bridge *bridge; 77 76 78 - bridge = fpga_bridge_get(&ctx->pdev->dev, NULL); 77 + bridge = fpga_bridge_get(ctx->dev, NULL); 79 78 KUNIT_EXPECT_PTR_EQ(test, bridge, ctx->bridge); 80 79 81 - bridge = fpga_bridge_get(&ctx->pdev->dev, NULL); 80 + bridge = fpga_bridge_get(ctx->dev, NULL); 82 81 KUNIT_EXPECT_EQ(test, PTR_ERR(bridge), -EBUSY); 83 82 84 83 fpga_bridge_put(ctx->bridge); ··· 106 105 int ret; 107 106 108 107 ctx_0 = test->priv; 109 - ctx_1 = register_test_bridge(test); 108 + ctx_1 = register_test_bridge(test, "fpga-bridge-test-dev-1"); 110 109 111 110 INIT_LIST_HEAD(&bridge_list); 112 111 113 112 /* Get bridge 0 and add it to the list */ 114 - ret = fpga_bridge_get_to_list(&ctx_0->pdev->dev, NULL, &bridge_list); 113 + ret = fpga_bridge_get_to_list(ctx_0->dev, NULL, &bridge_list); 115 114 KUNIT_EXPECT_EQ(test, ret, 0); 116 115 117 116 KUNIT_EXPECT_PTR_EQ(test, ctx_0->bridge, 118 117 list_first_entry_or_null(&bridge_list, struct fpga_bridge, node)); 119 118 120 119 /* Get bridge 1 and add it to the list */ 121 - ret = fpga_bridge_get_to_list(&ctx_1->pdev->dev, NULL, &bridge_list); 120 + ret = fpga_bridge_get_to_list(ctx_1->dev, NULL, &bridge_list); 122 121 KUNIT_EXPECT_EQ(test, ret, 0); 123 122 124 123 KUNIT_EXPECT_PTR_EQ(test, ctx_1->bridge, ··· 142 141 143 142 KUNIT_EXPECT_TRUE(test, list_empty(&bridge_list)); 144 143 145 - unregister_test_bridge(ctx_1); 144 + unregister_test_bridge(test, ctx_1); 146 145 } 147 146 148 147 static int fpga_bridge_test_init(struct kunit *test) 149 148 { 150 - test->priv = register_test_bridge(test); 149 + test->priv = register_test_bridge(test, "fpga-bridge-test-dev-0"); 151 150 152 151 return 0; 153 152 } 154 153 155 154 static void fpga_bridge_test_exit(struct kunit *test) 156 155 { 157 - unregister_test_bridge(test->priv); 156 + unregister_test_bridge(test, test->priv); 158 157 } 159 158 160 159 static struct kunit_case fpga_bridge_test_cases[] = {
+8 -8
drivers/fpga/tests/fpga-mgr-test.c
··· 7 7 * Author: Marco Pagani <marpagan@redhat.com> 8 8 */ 9 9 10 + #include <kunit/device.h> 10 11 #include <kunit/test.h> 11 - #include <linux/device.h> 12 12 #include <linux/fpga/fpga-mgr.h> 13 13 #include <linux/module.h> 14 14 #include <linux/scatterlist.h> ··· 40 40 struct mgr_ctx { 41 41 struct fpga_image_info *img_info; 42 42 struct fpga_manager *mgr; 43 - struct platform_device *pdev; 43 + struct device *dev; 44 44 struct mgr_stats stats; 45 45 }; 46 46 ··· 194 194 struct mgr_ctx *ctx = test->priv; 195 195 struct fpga_manager *mgr; 196 196 197 - mgr = fpga_mgr_get(&ctx->pdev->dev); 197 + mgr = fpga_mgr_get(ctx->dev); 198 198 KUNIT_EXPECT_PTR_EQ(test, mgr, ctx->mgr); 199 199 200 200 fpga_mgr_put(ctx->mgr); ··· 284 284 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); 285 285 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 286 286 287 - ctx->pdev = platform_device_register_simple("mgr_pdev", PLATFORM_DEVID_AUTO, NULL, 0); 288 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->pdev); 287 + ctx->dev = kunit_device_register(test, "fpga-manager-test-dev"); 288 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->dev); 289 289 290 - ctx->mgr = devm_fpga_mgr_register(&ctx->pdev->dev, "Fake FPGA Manager", &fake_mgr_ops, 290 + ctx->mgr = devm_fpga_mgr_register(ctx->dev, "Fake FPGA Manager", &fake_mgr_ops, 291 291 &ctx->stats); 292 292 KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->mgr)); 293 293 294 - ctx->img_info = fpga_image_info_alloc(&ctx->pdev->dev); 294 + ctx->img_info = fpga_image_info_alloc(ctx->dev); 295 295 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->img_info); 296 296 297 297 test->priv = ctx; ··· 304 304 struct mgr_ctx *ctx = test->priv; 305 305 306 306 fpga_image_info_free(ctx->img_info); 307 - platform_device_unregister(ctx->pdev); 307 + kunit_device_unregister(test, ctx->dev); 308 308 } 309 309 310 310 static struct kunit_case fpga_mgr_test_cases[] = {
+19 -22
drivers/fpga/tests/fpga-region-test.c
··· 7 7 * Author: Marco Pagani <marpagan@redhat.com> 8 8 */ 9 9 10 + #include <kunit/device.h> 10 11 #include <kunit/test.h> 11 12 #include <linux/fpga/fpga-bridge.h> 12 13 #include <linux/fpga/fpga-mgr.h> 13 14 #include <linux/fpga/fpga-region.h> 14 15 #include <linux/module.h> 15 - #include <linux/platform_device.h> 16 16 #include <linux/types.h> 17 17 18 18 struct mgr_stats { ··· 26 26 27 27 struct test_ctx { 28 28 struct fpga_manager *mgr; 29 - struct platform_device *mgr_pdev; 29 + struct device *mgr_dev; 30 30 struct fpga_bridge *bridge; 31 - struct platform_device *bridge_pdev; 31 + struct device *bridge_dev; 32 32 struct fpga_region *region; 33 - struct platform_device *region_pdev; 33 + struct device *region_dev; 34 34 struct bridge_stats bridge_stats; 35 35 struct mgr_stats mgr_stats; 36 36 }; ··· 91 91 struct test_ctx *ctx = test->priv; 92 92 struct fpga_region *region; 93 93 94 - region = fpga_region_class_find(NULL, &ctx->region_pdev->dev, fake_region_match); 94 + region = fpga_region_class_find(NULL, ctx->region_dev, fake_region_match); 95 95 KUNIT_EXPECT_PTR_EQ(test, region, ctx->region); 96 96 97 97 put_device(&region->dev); ··· 108 108 char img_buf[4]; 109 109 int ret; 110 110 111 - img_info = fpga_image_info_alloc(&ctx->mgr_pdev->dev); 111 + img_info = fpga_image_info_alloc(ctx->mgr_dev); 112 112 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, img_info); 113 113 114 114 img_info->buf = img_buf; ··· 148 148 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); 149 149 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 150 150 151 - ctx->mgr_pdev = platform_device_register_simple("mgr_pdev", PLATFORM_DEVID_AUTO, NULL, 0); 152 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->mgr_pdev); 151 + ctx->mgr_dev = kunit_device_register(test, "fpga-manager-test-dev"); 152 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->mgr_dev); 153 153 154 - ctx->mgr = devm_fpga_mgr_register(&ctx->mgr_pdev->dev, "Fake FPGA Manager", &fake_mgr_ops, 155 - &ctx->mgr_stats); 154 + ctx->mgr = devm_fpga_mgr_register(ctx->mgr_dev, "Fake FPGA Manager", 155 + &fake_mgr_ops, &ctx->mgr_stats); 156 156 KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->mgr)); 157 157 158 - ctx->bridge_pdev = platform_device_register_simple("bridge_pdev", PLATFORM_DEVID_AUTO, 159 - NULL, 0); 160 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->bridge_pdev); 158 + ctx->bridge_dev = kunit_device_register(test, "fpga-bridge-test-dev"); 159 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->bridge_dev); 161 160 162 - ctx->bridge = fpga_bridge_register(&ctx->bridge_pdev->dev, "Fake FPGA Bridge", 161 + ctx->bridge = fpga_bridge_register(ctx->bridge_dev, "Fake FPGA Bridge", 163 162 &fake_bridge_ops, &ctx->bridge_stats); 164 163 KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->bridge)); 165 164 166 165 ctx->bridge_stats.enable = true; 167 166 168 - ctx->region_pdev = platform_device_register_simple("region_pdev", PLATFORM_DEVID_AUTO, 169 - NULL, 0); 170 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->region_pdev); 167 + ctx->region_dev = kunit_device_register(test, "fpga-region-test-dev"); 168 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->region_dev); 171 169 172 170 region_info.mgr = ctx->mgr; 173 171 region_info.priv = ctx->bridge; 174 172 region_info.get_bridges = fake_region_get_bridges; 175 173 176 - ctx->region = fpga_region_register_full(&ctx->region_pdev->dev, &region_info); 174 + ctx->region = fpga_region_register_full(ctx->region_dev, &region_info); 177 175 KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->region)); 178 176 179 177 test->priv = ctx; ··· 184 186 struct test_ctx *ctx = test->priv; 185 187 186 188 fpga_region_unregister(ctx->region); 187 - platform_device_unregister(ctx->region_pdev); 189 + kunit_device_unregister(test, ctx->region_dev); 188 190 189 191 fpga_bridge_unregister(ctx->bridge); 190 - platform_device_unregister(ctx->bridge_pdev); 192 + kunit_device_unregister(test, ctx->bridge_dev); 191 193 192 - platform_device_unregister(ctx->mgr_pdev); 194 + kunit_device_unregister(test, ctx->mgr_dev); 193 195 } 194 196 195 197 static struct kunit_case fpga_region_test_cases[] = { 196 198 KUNIT_CASE(fpga_region_test_class_find), 197 199 KUNIT_CASE(fpga_region_test_program_fpga), 198 - 199 200 {} 200 201 }; 201 202
+229
drivers/fpga/xilinx-core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Common parts of the Xilinx Spartan6 and 7 Series FPGA manager drivers. 4 + * 5 + * Copyright (C) 2017 DENX Software Engineering 6 + * 7 + * Anatolij Gustschin <agust@denx.de> 8 + */ 9 + 10 + #include "xilinx-core.h" 11 + 12 + #include <linux/delay.h> 13 + #include <linux/fpga/fpga-mgr.h> 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/of.h> 16 + 17 + static int get_done_gpio(struct fpga_manager *mgr) 18 + { 19 + struct xilinx_fpga_core *core = mgr->priv; 20 + int ret; 21 + 22 + ret = gpiod_get_value(core->done); 23 + if (ret < 0) 24 + dev_err(&mgr->dev, "Error reading DONE (%d)\n", ret); 25 + 26 + return ret; 27 + } 28 + 29 + static enum fpga_mgr_states xilinx_core_state(struct fpga_manager *mgr) 30 + { 31 + if (!get_done_gpio(mgr)) 32 + return FPGA_MGR_STATE_RESET; 33 + 34 + return FPGA_MGR_STATE_UNKNOWN; 35 + } 36 + 37 + /** 38 + * wait_for_init_b - wait for the INIT_B pin to have a given state, or wait 39 + * a given delay if the pin is unavailable 40 + * 41 + * @mgr: The FPGA manager object 42 + * @value: Value INIT_B to wait for (1 = asserted = low) 43 + * @alt_udelay: Delay to wait if the INIT_B GPIO is not available 44 + * 45 + * Returns 0 when the INIT_B GPIO reached the given state or -ETIMEDOUT if 46 + * too much time passed waiting for that. If no INIT_B GPIO is available 47 + * then always return 0. 48 + */ 49 + static int wait_for_init_b(struct fpga_manager *mgr, int value, 50 + unsigned long alt_udelay) 51 + { 52 + struct xilinx_fpga_core *core = mgr->priv; 53 + unsigned long timeout = jiffies + msecs_to_jiffies(1000); 54 + 55 + if (core->init_b) { 56 + while (time_before(jiffies, timeout)) { 57 + int ret = gpiod_get_value(core->init_b); 58 + 59 + if (ret == value) 60 + return 0; 61 + 62 + if (ret < 0) { 63 + dev_err(&mgr->dev, 64 + "Error reading INIT_B (%d)\n", ret); 65 + return ret; 66 + } 67 + 68 + usleep_range(100, 400); 69 + } 70 + 71 + dev_err(&mgr->dev, "Timeout waiting for INIT_B to %s\n", 72 + value ? "assert" : "deassert"); 73 + return -ETIMEDOUT; 74 + } 75 + 76 + udelay(alt_udelay); 77 + 78 + return 0; 79 + } 80 + 81 + static int xilinx_core_write_init(struct fpga_manager *mgr, 82 + struct fpga_image_info *info, const char *buf, 83 + size_t count) 84 + { 85 + struct xilinx_fpga_core *core = mgr->priv; 86 + int err; 87 + 88 + if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { 89 + dev_err(&mgr->dev, "Partial reconfiguration not supported\n"); 90 + return -EINVAL; 91 + } 92 + 93 + gpiod_set_value(core->prog_b, 1); 94 + 95 + err = wait_for_init_b(mgr, 1, 1); /* min is 500 ns */ 96 + if (err) { 97 + gpiod_set_value(core->prog_b, 0); 98 + return err; 99 + } 100 + 101 + gpiod_set_value(core->prog_b, 0); 102 + 103 + err = wait_for_init_b(mgr, 0, 0); 104 + if (err) 105 + return err; 106 + 107 + if (get_done_gpio(mgr)) { 108 + dev_err(&mgr->dev, "Unexpected DONE pin state...\n"); 109 + return -EIO; 110 + } 111 + 112 + /* program latency */ 113 + usleep_range(7500, 7600); 114 + return 0; 115 + } 116 + 117 + static int xilinx_core_write(struct fpga_manager *mgr, const char *buf, 118 + size_t count) 119 + { 120 + struct xilinx_fpga_core *core = mgr->priv; 121 + 122 + return core->write(core, buf, count); 123 + } 124 + 125 + static int xilinx_core_write_complete(struct fpga_manager *mgr, 126 + struct fpga_image_info *info) 127 + { 128 + struct xilinx_fpga_core *core = mgr->priv; 129 + unsigned long timeout = 130 + jiffies + usecs_to_jiffies(info->config_complete_timeout_us); 131 + bool expired = false; 132 + int done; 133 + int ret; 134 + const char padding[1] = { 0xff }; 135 + 136 + /* 137 + * This loop is carefully written such that if the driver is 138 + * scheduled out for more than 'timeout', we still check for DONE 139 + * before giving up and we apply 8 extra CCLK cycles in all cases. 140 + */ 141 + while (!expired) { 142 + expired = time_after(jiffies, timeout); 143 + 144 + done = get_done_gpio(mgr); 145 + if (done < 0) 146 + return done; 147 + 148 + ret = core->write(core, padding, sizeof(padding)); 149 + if (ret) 150 + return ret; 151 + 152 + if (done) 153 + return 0; 154 + } 155 + 156 + if (core->init_b) { 157 + ret = gpiod_get_value(core->init_b); 158 + 159 + if (ret < 0) { 160 + dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret); 161 + return ret; 162 + } 163 + 164 + dev_err(&mgr->dev, 165 + ret ? "CRC error or invalid device\n" : 166 + "Missing sync word or incomplete bitstream\n"); 167 + } else { 168 + dev_err(&mgr->dev, "Timeout after config data transfer\n"); 169 + } 170 + 171 + return -ETIMEDOUT; 172 + } 173 + 174 + static inline struct gpio_desc * 175 + xilinx_core_devm_gpiod_get(struct device *dev, const char *con_id, 176 + const char *legacy_con_id, enum gpiod_flags flags) 177 + { 178 + struct gpio_desc *desc; 179 + 180 + desc = devm_gpiod_get(dev, con_id, flags); 181 + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT && 182 + of_device_is_compatible(dev->of_node, "xlnx,fpga-slave-serial")) 183 + desc = devm_gpiod_get(dev, legacy_con_id, flags); 184 + 185 + return desc; 186 + } 187 + 188 + static const struct fpga_manager_ops xilinx_core_ops = { 189 + .state = xilinx_core_state, 190 + .write_init = xilinx_core_write_init, 191 + .write = xilinx_core_write, 192 + .write_complete = xilinx_core_write_complete, 193 + }; 194 + 195 + int xilinx_core_probe(struct xilinx_fpga_core *core) 196 + { 197 + struct fpga_manager *mgr; 198 + 199 + if (!core || !core->dev || !core->write) 200 + return -EINVAL; 201 + 202 + /* PROGRAM_B is active low */ 203 + core->prog_b = xilinx_core_devm_gpiod_get(core->dev, "prog", "prog_b", 204 + GPIOD_OUT_LOW); 205 + if (IS_ERR(core->prog_b)) 206 + return dev_err_probe(core->dev, PTR_ERR(core->prog_b), 207 + "Failed to get PROGRAM_B gpio\n"); 208 + 209 + core->init_b = xilinx_core_devm_gpiod_get(core->dev, "init", "init-b", 210 + GPIOD_IN); 211 + if (IS_ERR(core->init_b)) 212 + return dev_err_probe(core->dev, PTR_ERR(core->init_b), 213 + "Failed to get INIT_B gpio\n"); 214 + 215 + core->done = devm_gpiod_get(core->dev, "done", GPIOD_IN); 216 + if (IS_ERR(core->done)) 217 + return dev_err_probe(core->dev, PTR_ERR(core->done), 218 + "Failed to get DONE gpio\n"); 219 + 220 + mgr = devm_fpga_mgr_register(core->dev, 221 + "Xilinx Slave Serial FPGA Manager", 222 + &xilinx_core_ops, core); 223 + return PTR_ERR_OR_ZERO(mgr); 224 + } 225 + EXPORT_SYMBOL_GPL(xilinx_core_probe); 226 + 227 + MODULE_LICENSE("GPL"); 228 + MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); 229 + MODULE_DESCRIPTION("Xilinx 7 Series FPGA manager core");
+27
drivers/fpga/xilinx-core.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + #ifndef __XILINX_CORE_H 4 + #define __XILINX_CORE_H 5 + 6 + #include <linux/device.h> 7 + 8 + /** 9 + * struct xilinx_fpga_core - interface between the driver and the core manager 10 + * of Xilinx 7 Series FPGA manager 11 + * @dev: device node 12 + * @write: write callback of the driver 13 + */ 14 + struct xilinx_fpga_core { 15 + /* public: */ 16 + struct device *dev; 17 + int (*write)(struct xilinx_fpga_core *core, const char *buf, 18 + size_t count); 19 + /* private: handled by xilinx-core */ 20 + struct gpio_desc *prog_b; 21 + struct gpio_desc *init_b; 22 + struct gpio_desc *done; 23 + }; 24 + 25 + int xilinx_core_probe(struct xilinx_fpga_core *core); 26 + 27 + #endif /* __XILINX_CORE_H */
+95
drivers/fpga/xilinx-selectmap.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Xilinx Spartan6 and 7 Series SelectMAP interface driver 4 + * 5 + * (C) 2024 Charles Perry <charles.perry@savoirfairelinux.com> 6 + * 7 + * Manage Xilinx FPGA firmware loaded over the SelectMAP configuration 8 + * interface. 9 + */ 10 + 11 + #include "xilinx-core.h" 12 + 13 + #include <linux/gpio/consumer.h> 14 + #include <linux/io.h> 15 + #include <linux/module.h> 16 + #include <linux/mod_devicetable.h> 17 + #include <linux/of.h> 18 + #include <linux/platform_device.h> 19 + 20 + struct xilinx_selectmap_conf { 21 + struct xilinx_fpga_core core; 22 + void __iomem *base; 23 + }; 24 + 25 + #define to_xilinx_selectmap_conf(obj) \ 26 + container_of(obj, struct xilinx_selectmap_conf, core) 27 + 28 + static int xilinx_selectmap_write(struct xilinx_fpga_core *core, 29 + const char *buf, size_t count) 30 + { 31 + struct xilinx_selectmap_conf *conf = to_xilinx_selectmap_conf(core); 32 + size_t i; 33 + 34 + for (i = 0; i < count; ++i) 35 + writeb(buf[i], conf->base); 36 + 37 + return 0; 38 + } 39 + 40 + static int xilinx_selectmap_probe(struct platform_device *pdev) 41 + { 42 + struct xilinx_selectmap_conf *conf; 43 + struct gpio_desc *gpio; 44 + void __iomem *base; 45 + 46 + conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL); 47 + if (!conf) 48 + return -ENOMEM; 49 + 50 + conf->core.dev = &pdev->dev; 51 + conf->core.write = xilinx_selectmap_write; 52 + 53 + base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 54 + if (IS_ERR(base)) 55 + return dev_err_probe(&pdev->dev, PTR_ERR(base), 56 + "ioremap error\n"); 57 + conf->base = base; 58 + 59 + /* CSI_B is active low */ 60 + gpio = devm_gpiod_get_optional(&pdev->dev, "csi", GPIOD_OUT_HIGH); 61 + if (IS_ERR(gpio)) 62 + return dev_err_probe(&pdev->dev, PTR_ERR(gpio), 63 + "Failed to get CSI_B gpio\n"); 64 + 65 + /* RDWR_B is active low */ 66 + gpio = devm_gpiod_get_optional(&pdev->dev, "rdwr", GPIOD_OUT_HIGH); 67 + if (IS_ERR(gpio)) 68 + return dev_err_probe(&pdev->dev, PTR_ERR(gpio), 69 + "Failed to get RDWR_B gpio\n"); 70 + 71 + return xilinx_core_probe(&conf->core); 72 + } 73 + 74 + static const struct of_device_id xlnx_selectmap_of_match[] = { 75 + { .compatible = "xlnx,fpga-xc7s-selectmap", }, // Spartan-7 76 + { .compatible = "xlnx,fpga-xc7a-selectmap", }, // Artix-7 77 + { .compatible = "xlnx,fpga-xc7k-selectmap", }, // Kintex-7 78 + { .compatible = "xlnx,fpga-xc7v-selectmap", }, // Virtex-7 79 + {}, 80 + }; 81 + MODULE_DEVICE_TABLE(of, xlnx_selectmap_of_match); 82 + 83 + static struct platform_driver xilinx_selectmap_driver = { 84 + .driver = { 85 + .name = "xilinx-selectmap", 86 + .of_match_table = xlnx_selectmap_of_match, 87 + }, 88 + .probe = xilinx_selectmap_probe, 89 + }; 90 + 91 + module_platform_driver(xilinx_selectmap_driver); 92 + 93 + MODULE_LICENSE("GPL"); 94 + MODULE_AUTHOR("Charles Perry <charles.perry@savoirfairelinux.com>"); 95 + MODULE_DESCRIPTION("Load Xilinx FPGA firmware over SelectMap");
+15 -209
drivers/fpga/xilinx-spi.c
··· 10 10 * the slave serial configuration interface. 11 11 */ 12 12 13 - #include <linux/delay.h> 14 - #include <linux/device.h> 15 - #include <linux/fpga/fpga-mgr.h> 16 - #include <linux/gpio/consumer.h> 13 + #include "xilinx-core.h" 14 + 17 15 #include <linux/module.h> 18 16 #include <linux/mod_devicetable.h> 19 17 #include <linux/of.h> 20 18 #include <linux/spi/spi.h> 21 - #include <linux/sizes.h> 22 19 23 - struct xilinx_spi_conf { 24 - struct spi_device *spi; 25 - struct gpio_desc *prog_b; 26 - struct gpio_desc *init_b; 27 - struct gpio_desc *done; 28 - }; 29 - 30 - static int get_done_gpio(struct fpga_manager *mgr) 31 - { 32 - struct xilinx_spi_conf *conf = mgr->priv; 33 - int ret; 34 - 35 - ret = gpiod_get_value(conf->done); 36 - 37 - if (ret < 0) 38 - dev_err(&mgr->dev, "Error reading DONE (%d)\n", ret); 39 - 40 - return ret; 41 - } 42 - 43 - static enum fpga_mgr_states xilinx_spi_state(struct fpga_manager *mgr) 44 - { 45 - if (!get_done_gpio(mgr)) 46 - return FPGA_MGR_STATE_RESET; 47 - 48 - return FPGA_MGR_STATE_UNKNOWN; 49 - } 50 - 51 - /** 52 - * wait_for_init_b - wait for the INIT_B pin to have a given state, or wait 53 - * a given delay if the pin is unavailable 54 - * 55 - * @mgr: The FPGA manager object 56 - * @value: Value INIT_B to wait for (1 = asserted = low) 57 - * @alt_udelay: Delay to wait if the INIT_B GPIO is not available 58 - * 59 - * Returns 0 when the INIT_B GPIO reached the given state or -ETIMEDOUT if 60 - * too much time passed waiting for that. If no INIT_B GPIO is available 61 - * then always return 0. 62 - */ 63 - static int wait_for_init_b(struct fpga_manager *mgr, int value, 64 - unsigned long alt_udelay) 65 - { 66 - struct xilinx_spi_conf *conf = mgr->priv; 67 - unsigned long timeout = jiffies + msecs_to_jiffies(1000); 68 - 69 - if (conf->init_b) { 70 - while (time_before(jiffies, timeout)) { 71 - int ret = gpiod_get_value(conf->init_b); 72 - 73 - if (ret == value) 74 - return 0; 75 - 76 - if (ret < 0) { 77 - dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret); 78 - return ret; 79 - } 80 - 81 - usleep_range(100, 400); 82 - } 83 - 84 - dev_err(&mgr->dev, "Timeout waiting for INIT_B to %s\n", 85 - value ? "assert" : "deassert"); 86 - return -ETIMEDOUT; 87 - } 88 - 89 - udelay(alt_udelay); 90 - 91 - return 0; 92 - } 93 - 94 - static int xilinx_spi_write_init(struct fpga_manager *mgr, 95 - struct fpga_image_info *info, 96 - const char *buf, size_t count) 97 - { 98 - struct xilinx_spi_conf *conf = mgr->priv; 99 - int err; 100 - 101 - if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { 102 - dev_err(&mgr->dev, "Partial reconfiguration not supported\n"); 103 - return -EINVAL; 104 - } 105 - 106 - gpiod_set_value(conf->prog_b, 1); 107 - 108 - err = wait_for_init_b(mgr, 1, 1); /* min is 500 ns */ 109 - if (err) { 110 - gpiod_set_value(conf->prog_b, 0); 111 - return err; 112 - } 113 - 114 - gpiod_set_value(conf->prog_b, 0); 115 - 116 - err = wait_for_init_b(mgr, 0, 0); 117 - if (err) 118 - return err; 119 - 120 - if (get_done_gpio(mgr)) { 121 - dev_err(&mgr->dev, "Unexpected DONE pin state...\n"); 122 - return -EIO; 123 - } 124 - 125 - /* program latency */ 126 - usleep_range(7500, 7600); 127 - return 0; 128 - } 129 - 130 - static int xilinx_spi_write(struct fpga_manager *mgr, const char *buf, 20 + static int xilinx_spi_write(struct xilinx_fpga_core *core, const char *buf, 131 21 size_t count) 132 22 { 133 - struct xilinx_spi_conf *conf = mgr->priv; 23 + struct spi_device *spi = to_spi_device(core->dev); 134 24 const char *fw_data = buf; 135 25 const char *fw_data_end = fw_data + count; 136 26 ··· 31 141 remaining = fw_data_end - fw_data; 32 142 stride = min_t(size_t, remaining, SZ_4K); 33 143 34 - ret = spi_write(conf->spi, fw_data, stride); 144 + ret = spi_write(spi, fw_data, stride); 35 145 if (ret) { 36 - dev_err(&mgr->dev, "SPI error in firmware write: %d\n", 146 + dev_err(core->dev, "SPI error in firmware write: %d\n", 37 147 ret); 38 148 return ret; 39 149 } ··· 43 153 return 0; 44 154 } 45 155 46 - static int xilinx_spi_apply_cclk_cycles(struct xilinx_spi_conf *conf) 47 - { 48 - struct spi_device *spi = conf->spi; 49 - const u8 din_data[1] = { 0xff }; 50 - int ret; 51 - 52 - ret = spi_write(conf->spi, din_data, sizeof(din_data)); 53 - if (ret) 54 - dev_err(&spi->dev, "applying CCLK cycles failed: %d\n", ret); 55 - 56 - return ret; 57 - } 58 - 59 - static int xilinx_spi_write_complete(struct fpga_manager *mgr, 60 - struct fpga_image_info *info) 61 - { 62 - struct xilinx_spi_conf *conf = mgr->priv; 63 - unsigned long timeout = jiffies + usecs_to_jiffies(info->config_complete_timeout_us); 64 - bool expired = false; 65 - int done; 66 - int ret; 67 - 68 - /* 69 - * This loop is carefully written such that if the driver is 70 - * scheduled out for more than 'timeout', we still check for DONE 71 - * before giving up and we apply 8 extra CCLK cycles in all cases. 72 - */ 73 - while (!expired) { 74 - expired = time_after(jiffies, timeout); 75 - 76 - done = get_done_gpio(mgr); 77 - if (done < 0) 78 - return done; 79 - 80 - ret = xilinx_spi_apply_cclk_cycles(conf); 81 - if (ret) 82 - return ret; 83 - 84 - if (done) 85 - return 0; 86 - } 87 - 88 - if (conf->init_b) { 89 - ret = gpiod_get_value(conf->init_b); 90 - 91 - if (ret < 0) { 92 - dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret); 93 - return ret; 94 - } 95 - 96 - dev_err(&mgr->dev, 97 - ret ? "CRC error or invalid device\n" 98 - : "Missing sync word or incomplete bitstream\n"); 99 - } else { 100 - dev_err(&mgr->dev, "Timeout after config data transfer\n"); 101 - } 102 - 103 - return -ETIMEDOUT; 104 - } 105 - 106 - static const struct fpga_manager_ops xilinx_spi_ops = { 107 - .state = xilinx_spi_state, 108 - .write_init = xilinx_spi_write_init, 109 - .write = xilinx_spi_write, 110 - .write_complete = xilinx_spi_write_complete, 111 - }; 112 - 113 156 static int xilinx_spi_probe(struct spi_device *spi) 114 157 { 115 - struct xilinx_spi_conf *conf; 116 - struct fpga_manager *mgr; 158 + struct xilinx_fpga_core *core; 117 159 118 - conf = devm_kzalloc(&spi->dev, sizeof(*conf), GFP_KERNEL); 119 - if (!conf) 160 + core = devm_kzalloc(&spi->dev, sizeof(*core), GFP_KERNEL); 161 + if (!core) 120 162 return -ENOMEM; 121 163 122 - conf->spi = spi; 164 + core->dev = &spi->dev; 165 + core->write = xilinx_spi_write; 123 166 124 - /* PROGRAM_B is active low */ 125 - conf->prog_b = devm_gpiod_get(&spi->dev, "prog_b", GPIOD_OUT_LOW); 126 - if (IS_ERR(conf->prog_b)) 127 - return dev_err_probe(&spi->dev, PTR_ERR(conf->prog_b), 128 - "Failed to get PROGRAM_B gpio\n"); 129 - 130 - conf->init_b = devm_gpiod_get_optional(&spi->dev, "init-b", GPIOD_IN); 131 - if (IS_ERR(conf->init_b)) 132 - return dev_err_probe(&spi->dev, PTR_ERR(conf->init_b), 133 - "Failed to get INIT_B gpio\n"); 134 - 135 - conf->done = devm_gpiod_get(&spi->dev, "done", GPIOD_IN); 136 - if (IS_ERR(conf->done)) 137 - return dev_err_probe(&spi->dev, PTR_ERR(conf->done), 138 - "Failed to get DONE gpio\n"); 139 - 140 - mgr = devm_fpga_mgr_register(&spi->dev, 141 - "Xilinx Slave Serial FPGA Manager", 142 - &xilinx_spi_ops, conf); 143 - return PTR_ERR_OR_ZERO(mgr); 167 + return xilinx_core_probe(core); 144 168 } 145 169 146 170 #ifdef CONFIG_OF 147 171 static const struct of_device_id xlnx_spi_of_match[] = { 148 - { .compatible = "xlnx,fpga-slave-serial", }, 172 + { 173 + .compatible = "xlnx,fpga-slave-serial", 174 + }, 149 175 {} 150 176 }; 151 177 MODULE_DEVICE_TABLE(of, xlnx_spi_of_match);
+7 -3
include/linux/fpga/fpga-bridge.h
··· 45 45 * @dev: FPGA bridge device 46 46 * @mutex: enforces exclusive reference to bridge 47 47 * @br_ops: pointer to struct of FPGA bridge ops 48 + * @br_ops_owner: module containing the br_ops 48 49 * @info: fpga image specific information 49 50 * @node: FPGA bridge list node 50 51 * @priv: low level driver private date ··· 55 54 struct device dev; 56 55 struct mutex mutex; /* for exclusive reference to bridge */ 57 56 const struct fpga_bridge_ops *br_ops; 57 + struct module *br_ops_owner; 58 58 struct fpga_image_info *info; 59 59 struct list_head node; 60 60 void *priv; ··· 81 79 struct fpga_image_info *info, 82 80 struct list_head *bridge_list); 83 81 82 + #define fpga_bridge_register(parent, name, br_ops, priv) \ 83 + __fpga_bridge_register(parent, name, br_ops, priv, THIS_MODULE) 84 84 struct fpga_bridge * 85 - fpga_bridge_register(struct device *parent, const char *name, 86 - const struct fpga_bridge_ops *br_ops, 87 - void *priv); 85 + __fpga_bridge_register(struct device *parent, const char *name, 86 + const struct fpga_bridge_ops *br_ops, void *priv, 87 + struct module *owner); 88 88 void fpga_bridge_unregister(struct fpga_bridge *br); 89 89 90 90 #endif /* _LINUX_FPGA_BRIDGE_H */
+20 -6
include/linux/fpga/fpga-mgr.h
··· 201 201 * @state: state of fpga manager 202 202 * @compat_id: FPGA manager id for compatibility check. 203 203 * @mops: pointer to struct of fpga manager ops 204 + * @mops_owner: module containing the mops 204 205 * @priv: low level driver private date 205 206 */ 206 207 struct fpga_manager { ··· 211 210 enum fpga_mgr_states state; 212 211 struct fpga_compat_id *compat_id; 213 212 const struct fpga_manager_ops *mops; 213 + struct module *mops_owner; 214 214 void *priv; 215 215 }; 216 216 ··· 232 230 233 231 void fpga_mgr_put(struct fpga_manager *mgr); 234 232 233 + #define fpga_mgr_register_full(parent, info) \ 234 + __fpga_mgr_register_full(parent, info, THIS_MODULE) 235 235 struct fpga_manager * 236 - fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info); 236 + __fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info, 237 + struct module *owner); 237 238 239 + #define fpga_mgr_register(parent, name, mops, priv) \ 240 + __fpga_mgr_register(parent, name, mops, priv, THIS_MODULE) 238 241 struct fpga_manager * 239 - fpga_mgr_register(struct device *parent, const char *name, 240 - const struct fpga_manager_ops *mops, void *priv); 242 + __fpga_mgr_register(struct device *parent, const char *name, 243 + const struct fpga_manager_ops *mops, void *priv, struct module *owner); 244 + 241 245 void fpga_mgr_unregister(struct fpga_manager *mgr); 242 246 247 + #define devm_fpga_mgr_register_full(parent, info) \ 248 + __devm_fpga_mgr_register_full(parent, info, THIS_MODULE) 243 249 struct fpga_manager * 244 - devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info); 250 + __devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info, 251 + struct module *owner); 252 + #define devm_fpga_mgr_register(parent, name, mops, priv) \ 253 + __devm_fpga_mgr_register(parent, name, mops, priv, THIS_MODULE) 245 254 struct fpga_manager * 246 - devm_fpga_mgr_register(struct device *parent, const char *name, 247 - const struct fpga_manager_ops *mops, void *priv); 255 + __devm_fpga_mgr_register(struct device *parent, const char *name, 256 + const struct fpga_manager_ops *mops, void *priv, 257 + struct module *owner); 248 258 249 259 #endif /*_LINUX_FPGA_MGR_H */
+10 -3
include/linux/fpga/fpga-region.h
··· 36 36 * @mgr: FPGA manager 37 37 * @info: FPGA image info 38 38 * @compat_id: FPGA region id for compatibility check. 39 + * @ops_owner: module containing the get_bridges function 39 40 * @priv: private data 40 41 * @get_bridges: optional function to get bridges to a list 41 42 */ ··· 47 46 struct fpga_manager *mgr; 48 47 struct fpga_image_info *info; 49 48 struct fpga_compat_id *compat_id; 49 + struct module *ops_owner; 50 50 void *priv; 51 51 int (*get_bridges)(struct fpga_region *region); 52 52 }; ··· 60 58 61 59 int fpga_region_program_fpga(struct fpga_region *region); 62 60 61 + #define fpga_region_register_full(parent, info) \ 62 + __fpga_region_register_full(parent, info, THIS_MODULE) 63 63 struct fpga_region * 64 - fpga_region_register_full(struct device *parent, const struct fpga_region_info *info); 64 + __fpga_region_register_full(struct device *parent, const struct fpga_region_info *info, 65 + struct module *owner); 65 66 67 + #define fpga_region_register(parent, mgr, get_bridges) \ 68 + __fpga_region_register(parent, mgr, get_bridges, THIS_MODULE) 66 69 struct fpga_region * 67 - fpga_region_register(struct device *parent, struct fpga_manager *mgr, 68 - int (*get_bridges)(struct fpga_region *)); 70 + __fpga_region_register(struct device *parent, struct fpga_manager *mgr, 71 + int (*get_bridges)(struct fpga_region *), struct module *owner); 69 72 void fpga_region_unregister(struct fpga_region *region); 70 73 71 74 #endif /* _FPGA_REGION_H */