1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/drivers/misc/xillybus.h
5 * Copyright 2011 Xillybus Ltd, http://xillybus.com
7 * Header file for the Xillybus FPGA/host framework.
13 #include <linux/list.h>
14 #include <linux/device.h>
15 #include <linux/dma-mapping.h>
16 #include <linux/interrupt.h>
17 #include <linux/sched.h>
18 #include <linux/cdev.h>
19 #include <linux/spinlock.h>
20 #include <linux/mutex.h>
21 #include <linux/workqueue.h>
23 struct xilly_endpoint_hardware
;
28 int end_offset
; /* Counting elements, not bytes */
31 struct xilly_idt_handle
{
32 unsigned char *chandesc
;
38 * Read-write confusion: wr_* and rd_* notation sticks to FPGA view, so
39 * wr_* buffers are those consumed by read(), since the FPGA writes to them
43 struct xilly_channel
{
44 struct xilly_endpoint
*endpoint
;
46 int log2_element_size
;
49 struct xilly_buffer
**wr_buffers
; /* FPGA writes, driver reads! */
51 unsigned int wr_buf_size
; /* In bytes */
56 int wr_ready
; /* Significant only when wr_empty == 1 */
60 spinlock_t wr_spinlock
;
61 struct mutex wr_mutex
;
62 wait_queue_head_t wr_wait
;
63 wait_queue_head_t wr_ready_wait
;
67 int wr_exclusive_open
;
68 int wr_supports_nonempty
;
70 struct xilly_buffer
**rd_buffers
; /* FPGA reads, driver writes! */
72 unsigned int rd_buf_size
; /* In bytes */
77 spinlock_t rd_spinlock
;
78 struct mutex rd_mutex
;
79 wait_queue_head_t rd_wait
;
83 int rd_exclusive_open
;
84 struct delayed_work rd_workitem
;
85 unsigned char rd_leftovers
[4];
88 struct xilly_endpoint
{
90 * One of pdev and dev is always NULL, and the other is a valid
91 * pointer, depending on the type of device
95 struct xilly_endpoint_hardware
*ephw
;
97 struct list_head ep_list
;
98 int dma_using_dac
; /* =1 if 64-bit DMA is used, =0 otherwise. */
99 __iomem
void *registers
;
102 struct mutex register_mutex
;
103 wait_queue_head_t ep_wait
;
105 /* Channels and message handling */
109 int lowest_minor
; /* Highest minor = lowest_minor + num_channels - 1 */
111 int num_channels
; /* EXCLUDING message buffer */
112 struct xilly_channel
**channels
;
118 dma_addr_t msgbuf_dma_addr
;
119 unsigned int msg_buf_size
;
122 struct xilly_endpoint_hardware
{
123 struct module
*owner
;
124 void (*hw_sync_sgl_for_cpu
)(struct xilly_endpoint
*,
128 void (*hw_sync_sgl_for_device
)(struct xilly_endpoint
*,
132 int (*map_single
)(struct xilly_endpoint
*,
139 struct xilly_mapping
{
146 irqreturn_t
xillybus_isr(int irq
, void *data
);
148 struct xilly_endpoint
*xillybus_init_endpoint(struct pci_dev
*pdev
,
150 struct xilly_endpoint_hardware
153 int xillybus_endpoint_discovery(struct xilly_endpoint
*endpoint
);
155 void xillybus_endpoint_remove(struct xilly_endpoint
*endpoint
);
157 #endif /* __XILLYBUS_H */