2019-06-01 08:08:17 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2013-06-24 15:55:47 +00:00
|
|
|
/*
|
|
|
|
* linux/drivers/misc/xillybus.h
|
|
|
|
*
|
|
|
|
* Copyright 2011 Xillybus Ltd, http://xillybus.com
|
|
|
|
*
|
|
|
|
* Header file for the Xillybus FPGA/host framework.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __XILLYBUS_H
|
|
|
|
#define __XILLYBUS_H
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
|
|
|
struct xilly_endpoint_hardware;
|
|
|
|
|
|
|
|
struct xilly_buffer {
|
|
|
|
void *addr;
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
int end_offset; /* Counting elements, not bytes */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct xilly_idt_handle {
|
|
|
|
unsigned char *chandesc;
|
char: xillybus: Move class-related functions to new xillybus_class.c
This patch is a preparation for adding another related driver, XillyUSB.
In order to share some code between the existing Xillybus driver and the
one to be added, some functions are moved to xillybus_class.c
XILLYBUS_CLASS is added to Kconfig and is common to all drivers in this
group. The relation with the existing XILLYBUS symbol is "select" rather
than "depends on" XILLYBUS_CLASS, or else "make olddefconfig" will silently
turn off XILLYBUS, which is currently enabled in several distributions.
XILLYBUS_CLASS doesn't depend on anything else, hence using it with
"select" poses no risk for a broken configuration.
After the future addition of the XillyUSB module, the tree of symbols
will be as follows:
XILLYBUS_CLASS --+-- XILLYBUS --+-- XILLYBUS_PCIE
| |
| +-- XILLYBUS_OF
|
+-- XILLYUSB
XILLYBUS is for drivers based upon memory registers + DMA-based interfaces,
and it's combined with XILLYBUS_PCIE and/or XILLYBUS_OF.
XILLYUSB is for the USB variant only.
Or a more detailed, bottom-up outline:
* CONFIG_XILLYBUS_PCIE -> xillybus_pcie.c: Functions related to PCIe.
* CONFIG_XILLYBUS_OF -> xillybus_of.c: Functions related to Xillybus as a
peripheral on an FPGA / Processor combo chip.
* CONFIG_XILLYBUS -> xillybus_core.c: Functions that are common to the two
above, mainly access to the peripheral with memory-mapped registers and
DMA.
* CONFIG_XILLYUSB -> xillyusb.c: The driver for the USB variant, accesses
the peripheral through the USB framework.
* CONFIG_XILLYBUS_CLASS -> xillybus_class.c: The new module, which contains
the class and API parts that would otherwise appear both in
xillybus_core.c and xillyusb.c. Contains utility functions for the two
latter.
And since I'm at it, comments on the module names are added in the
Kconfig's help part.
The functions are exported with the non-GPL EXPORT_SYMBOL (a matter of
taste).
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
Link: https://lore.kernel.org/r/20210526100311.56327-2-eli.billauer@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-26 10:03:10 +00:00
|
|
|
unsigned char *names;
|
|
|
|
int names_len;
|
2013-06-24 15:55:47 +00:00
|
|
|
int entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read-write confusion: wr_* and rd_* notation sticks to FPGA view, so
|
|
|
|
* wr_* buffers are those consumed by read(), since the FPGA writes to them
|
|
|
|
* and vice versa.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct xilly_channel {
|
|
|
|
struct xilly_endpoint *endpoint;
|
|
|
|
int chan_num;
|
|
|
|
int log2_element_size;
|
|
|
|
int seekable;
|
|
|
|
|
|
|
|
struct xilly_buffer **wr_buffers; /* FPGA writes, driver reads! */
|
|
|
|
int num_wr_buffers;
|
|
|
|
unsigned int wr_buf_size; /* In bytes */
|
|
|
|
int wr_fpga_buf_idx;
|
|
|
|
int wr_host_buf_idx;
|
|
|
|
int wr_host_buf_pos;
|
|
|
|
int wr_empty;
|
|
|
|
int wr_ready; /* Significant only when wr_empty == 1 */
|
|
|
|
int wr_sleepy;
|
|
|
|
int wr_eof;
|
|
|
|
int wr_hangup;
|
|
|
|
spinlock_t wr_spinlock;
|
|
|
|
struct mutex wr_mutex;
|
|
|
|
wait_queue_head_t wr_wait;
|
|
|
|
wait_queue_head_t wr_ready_wait;
|
|
|
|
int wr_ref_count;
|
|
|
|
int wr_synchronous;
|
|
|
|
int wr_allow_partial;
|
|
|
|
int wr_exclusive_open;
|
|
|
|
int wr_supports_nonempty;
|
|
|
|
|
|
|
|
struct xilly_buffer **rd_buffers; /* FPGA reads, driver writes! */
|
|
|
|
int num_rd_buffers;
|
|
|
|
unsigned int rd_buf_size; /* In bytes */
|
|
|
|
int rd_fpga_buf_idx;
|
|
|
|
int rd_host_buf_pos;
|
|
|
|
int rd_host_buf_idx;
|
|
|
|
int rd_full;
|
|
|
|
spinlock_t rd_spinlock;
|
|
|
|
struct mutex rd_mutex;
|
|
|
|
wait_queue_head_t rd_wait;
|
|
|
|
int rd_ref_count;
|
|
|
|
int rd_allow_partial;
|
|
|
|
int rd_synchronous;
|
|
|
|
int rd_exclusive_open;
|
|
|
|
struct delayed_work rd_workitem;
|
|
|
|
unsigned char rd_leftovers[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct xilly_endpoint {
|
|
|
|
struct device *dev;
|
2021-09-29 09:44:42 +00:00
|
|
|
struct module *owner;
|
2013-06-24 15:55:47 +00:00
|
|
|
|
|
|
|
int dma_using_dac; /* =1 if 64-bit DMA is used, =0 otherwise. */
|
2014-07-05 09:45:09 +00:00
|
|
|
__iomem void *registers;
|
2013-06-24 15:55:47 +00:00
|
|
|
int fatal_error;
|
|
|
|
|
|
|
|
struct mutex register_mutex;
|
|
|
|
wait_queue_head_t ep_wait;
|
|
|
|
|
|
|
|
int num_channels; /* EXCLUDING message buffer */
|
|
|
|
struct xilly_channel **channels;
|
|
|
|
int msg_counter;
|
|
|
|
int failed_messages;
|
|
|
|
int idtlen;
|
|
|
|
|
|
|
|
u32 *msgbuf_addr;
|
|
|
|
dma_addr_t msgbuf_dma_addr;
|
|
|
|
unsigned int msg_buf_size;
|
|
|
|
};
|
|
|
|
|
2014-06-21 11:07:12 +00:00
|
|
|
struct xilly_mapping {
|
char: xillybus: Remove usage of 'pci_unmap_single()'
'struct xilly_mapping' includes a 'void *device' field which holds,
depending of the context, a 'struct device *' or a 'struct pci_dev *'.
This field is then used with 'pci_umap_single()' in 'xillybus_pcie.c' and
with 'dma_umap_single()' in 'xillybus_of.c'.
In order to remove usage of the deprecated 'pci_unmap_single()' API, turn
the 'void *device' field from 'struct xilly_mapping', into an explicit
'struct device *device' and use 'dma_umap_single()' everywhere.
In order to update 'xillybus_pcie.c', use the 'dev' field instead of the
'pdev' field from the 'struct xilly_endpoint'.
Both fields are initialized by 'xillybus_init_endpoint()' and in
'xillybus_pcie.c', we have:
xillybus_init_endpoint(pdev, &pdev->dev, &pci_hw);
^ ^
xilly_endpoint.pdev = ___| |___ = xilly_endpoint.dev
So the modification from pci_ to dma_ function is straightforward.
While at it, remove a comment that is wrong, because in the case above,
both 'dev' and 'pdev' are not NULL.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/baa3f6c7f009d9c231ae320bf1d568268bfef089.1630083668.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-27 17:17:39 +00:00
|
|
|
struct device *device;
|
2014-06-21 11:07:12 +00:00
|
|
|
dma_addr_t dma_addr;
|
|
|
|
size_t size;
|
|
|
|
int direction;
|
|
|
|
};
|
2013-06-24 15:55:47 +00:00
|
|
|
|
2014-06-21 11:07:12 +00:00
|
|
|
irqreturn_t xillybus_isr(int irq, void *data);
|
2013-06-24 15:55:47 +00:00
|
|
|
|
2021-09-29 09:44:42 +00:00
|
|
|
struct xilly_endpoint *xillybus_init_endpoint(struct device *dev);
|
2013-06-24 15:55:47 +00:00
|
|
|
|
|
|
|
int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint);
|
|
|
|
|
|
|
|
void xillybus_endpoint_remove(struct xilly_endpoint *endpoint);
|
|
|
|
|
|
|
|
#endif /* __XILLYBUS_H */
|