1 | /* $ZEL: sis1100_sc_linux.h,v 1.5 2004/05/27 23:10:33 wuestner Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Copyright (c) 2001-2004
|
---|
5 | * Peter Wuestner. All rights reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | * 1. Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions, and the following disclaimer.
|
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | *
|
---|
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
|
---|
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
---|
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
26 | * SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef _sis1100_sc_linux_h_
|
---|
30 | #define _sis1100_sc_linux_h_
|
---|
31 |
|
---|
32 | #define SGL_SIZE 128
|
---|
33 | #define DMA_MAX (PAGE_SIZE*(SGL_SIZE-1))
|
---|
34 |
|
---|
35 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,14)
|
---|
36 | #define USE_SGL
|
---|
37 | #else
|
---|
38 | #error no USE_SGL
|
---|
39 | #endif
|
---|
40 | /*#undef USE_SGL*/
|
---|
41 |
|
---|
42 | struct sis1100_dmabuf {
|
---|
43 | size_t size;
|
---|
44 | void* cpu_addr;
|
---|
45 | dma_addr_t dma_handle;
|
---|
46 | };
|
---|
47 |
|
---|
48 | struct mmapdma {
|
---|
49 | int valid;
|
---|
50 | };
|
---|
51 |
|
---|
52 | struct handlercommand {
|
---|
53 | volatile enum handlercomm command;
|
---|
54 | spinlock_t lock;
|
---|
55 | };
|
---|
56 |
|
---|
57 | struct sis1100_softc;
|
---|
58 |
|
---|
59 | struct sis1100_fdata {
|
---|
60 | struct list_head list;
|
---|
61 | /* OS specific*/
|
---|
62 | struct sis1100_softc* sc;
|
---|
63 | /*common*/
|
---|
64 | struct mmapdma mmapdma;
|
---|
65 | size_t mindmalen_r, mindmalen_w;
|
---|
66 | enum sis1100_hw_type old_remote_hw;
|
---|
67 | enum sis1100_subdev subdev;
|
---|
68 | int32_t vmespace_am;
|
---|
69 | u_int32_t vmespace_datasize;
|
---|
70 | int fifo_mode;
|
---|
71 | int last_prot_err;
|
---|
72 | u_int32_t owned_irqs;
|
---|
73 | pid_t pid;
|
---|
74 | int sig;
|
---|
75 | };
|
---|
76 |
|
---|
77 | struct sis1100_softc {
|
---|
78 | /* OS specific*/
|
---|
79 | volatile u_int8_t *plxmembase; /* kernel virtual address */
|
---|
80 | u_int32_t plxmemlen; /* size */
|
---|
81 | u_long plx_addr; /* physical address */
|
---|
82 |
|
---|
83 | volatile u_int8_t*reg_base; /* kernel virtual address */
|
---|
84 | u_int32_t reg_size; /* size */
|
---|
85 | u_long reg_addr; /* physical address */
|
---|
86 |
|
---|
87 | volatile u_int8_t*rem_base; /* kernel virtual address */
|
---|
88 | u_int32_t rem_size; /* size */
|
---|
89 | u_long rem_addr; /* physical address */
|
---|
90 |
|
---|
91 | struct pci_dev *pcidev;
|
---|
92 | int unit;
|
---|
93 | int handler_pid;
|
---|
94 | struct completion handler_completion;
|
---|
95 | #ifndef USE_SGL
|
---|
96 | struct kiobuf* iobuf;
|
---|
97 | #endif
|
---|
98 | struct sis1100_dmabuf descbuf;
|
---|
99 | struct scatterlist sglist[SGL_SIZE];
|
---|
100 |
|
---|
101 | /* OS specific definition but common use */
|
---|
102 | struct semaphore sem_hw; /* protects hardware */
|
---|
103 | struct semaphore sem_fdata_list; /* protects fdata_list_head */
|
---|
104 | spinlock_t lock_intcsr; /* protects INTCSR of PLX */
|
---|
105 | spinlock_t lock_doorbell; /* protects sc.doorbell */
|
---|
106 | spinlock_t lock_lemo_status; /* protects sc.lemo_status */
|
---|
107 | wait_queue_head_t handler_wait;
|
---|
108 | wait_queue_head_t local_wait;
|
---|
109 | wait_queue_head_t remoteirq_wait;
|
---|
110 | struct timer_list link_up_timer;
|
---|
111 |
|
---|
112 | /* common */
|
---|
113 | struct sis1100_fdata* fdatalist[sis1100_MINORUTMASK+1];
|
---|
114 | struct list_head fdata_list_head;
|
---|
115 | u_int32_t local_ident, remote_ident;
|
---|
116 | volatile enum sis1100_hw_type remote_hw, old_remote_hw;
|
---|
117 | volatile u_int32_t doorbell;
|
---|
118 | volatile u_int32_t lemo_status;
|
---|
119 | volatile u_int32_t mbx0;
|
---|
120 | volatile int got_irqs;
|
---|
121 | struct irq_vects irq_vects[8];
|
---|
122 | u_int32_t pending_irqs, new_irqs;
|
---|
123 | struct handlercommand handlercommand;
|
---|
124 | loff_t ram_size;
|
---|
125 | int dsp_present;
|
---|
126 | int remote_endian; /* 0: little 1: big*/
|
---|
127 | int user_wants_swap;
|
---|
128 | volatile u_int32_t last_opt_csr; /* used by handlercomm_lemo */
|
---|
129 |
|
---|
130 | #if 0
|
---|
131 | int dma_dac; /* use 64bit dual address cycle for dma */
|
---|
132 | int no_dma; /* even 32bit dma not available */
|
---|
133 | #endif
|
---|
134 | };
|
---|
135 |
|
---|
136 | extern struct sis1100_softc *sis1100_devdata[sis1100_MAXCARDS];
|
---|
137 |
|
---|
138 | extern struct file_operations sis1100_fops;
|
---|
139 |
|
---|
140 | #define SIS1100FD(file) ((struct sis1100_fdata*)(file)->private_data)
|
---|
141 | #define SIS1100SC(file) (((struct sis1100_fdata*)(file)->private_data)->sc)
|
---|
142 |
|
---|
143 | #define _plxreadreg(sc, offset) readl((sc)->plxmembase+(offset))
|
---|
144 | #define _plxwritereg(sc, offset, val) writel(val, (sc)->plxmembase+(offset))
|
---|
145 | #define _plxreadbreg(sc, offset) readb((sc)->plxmembase+(offset))
|
---|
146 | #define _plxwritebreg(sc, offset, val) writeb(val, (sc)->plxmembase+(offset))
|
---|
147 |
|
---|
148 | #define plxreadlocal0(sc, offset) readl((sc)->reg_base+(offset))
|
---|
149 | #define plxreadlocal0b(sc, offset) readb((sc)->reg_base+(offset))
|
---|
150 | #define plxwritelocal0(sc, offset, val) writel(val, (sc)->reg_base+(offset))
|
---|
151 | #define plxwritelocal0b(sc, offset, val) writeb(val, (sc)->reg_base+(offset))
|
---|
152 | #define plxrawreadlocal0(sc, offset) __raw_readl((sc)->reg_base+(offset))
|
---|
153 | #define plxrawwritelocal0(sc, offset, val) __raw_writel(val, (sc)->reg_base+(offset))
|
---|
154 |
|
---|
155 | #define rmb_plx() rmb()
|
---|
156 | #define rmb_reg() rmb()
|
---|
157 | #define wmb_plx() wmb()
|
---|
158 | #define wmb_reg() wmb()
|
---|
159 | #define mb_plx() mb()
|
---|
160 | #define mb_reg() mb()
|
---|
161 |
|
---|
162 | int sis1100_open(struct inode *inode, struct file *file);
|
---|
163 | int sis1100_release(struct inode *inode, struct file *file);
|
---|
164 | int sis1100_ioctl(struct inode *inode, struct file *file,
|
---|
165 | unsigned int cmd, unsigned long arg);
|
---|
166 | loff_t sis1100_llseek(struct file* file, loff_t offset, int orig);
|
---|
167 | int sis1100_mmap(struct file * file, struct vm_area_struct * vma);
|
---|
168 | ssize_t sis1100_read(struct file* file, char* buf, size_t count,
|
---|
169 | loff_t* ppos);
|
---|
170 | ssize_t sis1100_write(struct file* file, const char* buf, size_t count,
|
---|
171 | loff_t* ppos);
|
---|
172 | unsigned int sis1100_poll(struct file* file,
|
---|
173 | struct poll_table_struct* poll_table);
|
---|
174 |
|
---|
175 | int sis1100_irq_thread(void* data);
|
---|
176 | void sis1100_link_up_handler(unsigned long data);
|
---|
177 |
|
---|
178 | irqreturn_t sis1100_intr(int irq, void *vsc, struct pt_regs *regs);
|
---|
179 | int sis1100_init(struct sis1100_softc* sc);
|
---|
180 | void sis1100_done(struct sis1100_softc* sc);
|
---|
181 |
|
---|
182 | #endif
|
---|