2 * linux/drivers/misc/xillybus.h
4 * Copyright 2011 Xillybus Ltd, http://xillybus.com
6 * Header file for the Xillybus FPGA/host framework.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the smems of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
16 #include <linux/list.h>
17 #include <linux/device.h>
18 #include <linux/dma-mapping.h>
19 #include <linux/interrupt.h>
20 #include <linux/sched.h>
21 #include <linux/cdev.h>
22 #include <linux/spinlock.h>
23 #include <linux/mutex.h>
24 #include <linux/workqueue.h>
26 struct xilly_endpoint_hardware
;
31 int end_offset
; /* Counting elements, not bytes */
34 struct xilly_idt_handle
{
35 unsigned char *chandesc
;
41 * Read-write confusion: wr_* and rd_* notation sticks to FPGA view, so
42 * wr_* buffers are those consumed by read(), since the FPGA writes to them
46 struct xilly_channel
{
47 struct xilly_endpoint
*endpoint
;
49 int log2_element_size
;
52 struct xilly_buffer
**wr_buffers
; /* FPGA writes, driver reads! */
54 unsigned int wr_buf_size
; /* In bytes */
59 int wr_ready
; /* Significant only when wr_empty == 1 */
63 spinlock_t wr_spinlock
;
64 struct mutex wr_mutex
;
65 wait_queue_head_t wr_wait
;
66 wait_queue_head_t wr_ready_wait
;
70 int wr_exclusive_open
;
71 int wr_supports_nonempty
;
73 struct xilly_buffer
**rd_buffers
; /* FPGA reads, driver writes! */
75 unsigned int rd_buf_size
; /* In bytes */
80 spinlock_t rd_spinlock
;
81 struct mutex rd_mutex
;
82 wait_queue_head_t rd_wait
;
86 int rd_exclusive_open
;
87 struct delayed_work rd_workitem
;
88 unsigned char rd_leftovers
[4];
91 struct xilly_endpoint
{
93 * One of pdev and dev is always NULL, and the other is a valid
94 * pointer, depending on the type of device
98 struct xilly_endpoint_hardware
*ephw
;
100 struct list_head ep_list
;
101 int dma_using_dac
; /* =1 if 64-bit DMA is used, =0 otherwise. */
102 __iomem
void *registers
;
105 struct mutex register_mutex
;
106 wait_queue_head_t ep_wait
;
108 /* Channels and message handling */
112 int lowest_minor
; /* Highest minor = lowest_minor + num_channels - 1 */
114 int num_channels
; /* EXCLUDING message buffer */
115 struct xilly_channel
**channels
;
121 dma_addr_t msgbuf_dma_addr
;
122 unsigned int msg_buf_size
;
125 struct xilly_endpoint_hardware
{
126 struct module
*owner
;
127 void (*hw_sync_sgl_for_cpu
)(struct xilly_endpoint
*,
131 void (*hw_sync_sgl_for_device
)(struct xilly_endpoint
*,
135 int (*map_single
)(struct xilly_endpoint
*,
142 struct xilly_mapping
{
149 irqreturn_t
xillybus_isr(int irq
, void *data
);
151 struct xilly_endpoint
*xillybus_init_endpoint(struct pci_dev
*pdev
,
153 struct xilly_endpoint_hardware
156 int xillybus_endpoint_discovery(struct xilly_endpoint
*endpoint
);
158 void xillybus_endpoint_remove(struct xilly_endpoint
*endpoint
);
160 #endif /* __XILLYBUS_H */