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
;
39 * Read-write confusion: wr_* and rd_* notation sticks to FPGA view, so
40 * wr_* buffers are those consumed by read(), since the FPGA writes to them
44 struct xilly_channel
{
45 struct xilly_endpoint
*endpoint
;
47 int log2_element_size
;
50 struct xilly_buffer
**wr_buffers
; /* FPGA writes, driver reads! */
52 unsigned int wr_buf_size
; /* In bytes */
57 int wr_ready
; /* Significant only when wr_empty == 1 */
61 spinlock_t wr_spinlock
;
62 struct mutex wr_mutex
;
63 wait_queue_head_t wr_wait
;
64 wait_queue_head_t wr_ready_wait
;
68 int wr_exclusive_open
;
69 int wr_supports_nonempty
;
71 struct xilly_buffer
**rd_buffers
; /* FPGA reads, driver writes! */
73 unsigned int rd_buf_size
; /* In bytes */
78 spinlock_t rd_spinlock
;
79 struct mutex rd_mutex
;
80 wait_queue_head_t rd_wait
;
84 int rd_exclusive_open
;
85 struct delayed_work rd_workitem
;
86 unsigned char rd_leftovers
[4];
89 struct xilly_endpoint
{
93 int dma_using_dac
; /* =1 if 64-bit DMA is used, =0 otherwise. */
94 __iomem
void *registers
;
97 struct mutex register_mutex
;
98 wait_queue_head_t ep_wait
;
100 int num_channels
; /* EXCLUDING message buffer */
101 struct xilly_channel
**channels
;
107 dma_addr_t msgbuf_dma_addr
;
108 unsigned int msg_buf_size
;
111 struct xilly_mapping
{
112 struct device
*device
;
118 irqreturn_t
xillybus_isr(int irq
, void *data
);
120 struct xilly_endpoint
*xillybus_init_endpoint(struct device
*dev
);
122 int xillybus_endpoint_discovery(struct xilly_endpoint
*endpoint
);
124 void xillybus_endpoint_remove(struct xilly_endpoint
*endpoint
);
126 #endif /* __XILLYBUS_H */