source: drsdaq/VME/struck/sis1100/V2.02/dev/pci/sis1100_sc.h@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 11.1 KB
Line 
1/* $ZEL: sis1100_sc.h,v 1.6 2004/05/27 23:10:32 wuestner Exp $ */
2
3/*
4 * Copyright (c) 2001-2004
5 * Matthias Drochner, 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_h_
30#define _sis1100_sc_h_
31
32#ifdef __NetBSD__
33# include "dev/pci/compat_netbsd.h"
34#elif __linux__
35# include "compat_linux.h"
36#else
37# error INVALID or UNKNOWN SYSTEM
38#endif
39
40
41#include "plx9054reg.h"
42#include "sis1100_map.h"
43#include "sis3100_map.h"
44#include "sis5100_map.h"
45#include "f1_map.h"
46#include "vertex_map.h"
47#include "sis1100_var.h"
48
49#ifndef PCI_VENDOR_FZJZEL
50# define PCI_VENDOR_FZJZEL 0x1796
51#endif
52#ifndef PCI_PRODUCT_FZJZEL_GIGALINK
53# define PCI_PRODUCT_FZJZEL_GIGALINK 0x0001
54#endif
55
56struct irq_vects {
57 u_int32_t vector;
58 int valid;
59};
60
61enum irqs_got {got_dma0=1, got_dma1=2, got_end=4, got_eot=8,
62 /*got_xoff=16,*/ got_sync=32, got_l_err=64};
63
64enum handlercomm {
65 handlercomm_doorbell=1,
66 handlercomm_synch=2,
67 handlercomm_lemo=4,
68 handlercomm_mbx0=8,
69 handlercomm_die=128,
70};
71
72#define SIS5100_CAMACaddr(N, A, F) \
73 (((F)&0x1f)<<11 | ((N)&0x1f)<<6 | ((A)&0xf)<<2)
74
75#ifdef __NetBSD__
76# include "dev/pci/sis1100_sc_netbsd.h"
77#elif __linux__
78# include "sis1100_sc_linux.h"
79#else
80# error INVALID or UNKNOWN SYSTEM
81#endif
82
83#define irq_pending(sc, fd, mask) \
84 ((sc->pending_irqs & (fd->owned_irqs & mask)) || \
85 (fd->old_remote_hw!=sc->remote_hw))
86
87#define ofs(what, elem) ((off_t)&(((what *)0)->elem))
88
89#define plxreadreg(sc, reg) \
90 _plxreadreg(sc, ofs(struct plx9045reg, reg))
91#define plxwritereg(sc, reg, val) \
92 _plxwritereg(sc, ofs(struct plx9045reg, reg), val)
93
94#define sis1100readreg(sc, reg) \
95 plxreadlocal0(sc, ofs(struct sis1100_reg, reg))
96#define sis1100readregb(sc, reg) \
97 plxreadlocal0b(sc, ofs(struct sis1100_reg, reg))
98#define sis1100writereg(sc, reg, val) \
99 plxwritelocal0(sc, ofs(struct sis1100_reg, reg), val)
100#define sis1100writeb(sc, reg, val) \
101 plxwritelocal0b(sc, ofs(struct sis1100_reg, reg), val)
102
103#define sis1100rawreadreg(sc, reg) \
104 plxrawreadlocal0(sc, ofs(struct sis1100_reg, reg))
105#define sis1100rawwritereg(sc, reg, val) \
106 plxrawwritelocal0(sc, ofs(struct sis1100_reg, reg), val)
107
108#define sis1100readremreg(sc, reg, val, locked) \
109 sis1100_remote_reg_read(sc, ofs(struct sis1100_reg, reg), val, locked)
110#define sis1100writeremreg(sc, reg, val, locked) \
111 sis1100_remote_reg_write(sc, ofs(struct sis1100_reg, reg), val, locked)
112
113#define sis3100readremreg(sc, reg, val, locked) \
114 sis1100_remote_reg_read(sc, ofs(struct sis3100_reg, reg), val, locked)
115#define sis3100writeremreg(sc, reg, val, locked) \
116 sis1100_remote_reg_write(sc, ofs(struct sis3100_reg, reg), val, locked)
117
118#define sis5100readremreg(sc, reg, val, locked) \
119 sis1100_remote_reg_read(sc, ofs(struct sis5100_reg, reg), val, locked)
120#define sis5100writeremreg(sc, reg, val, locked) \
121 sis1100_remote_reg_write(sc, ofs(struct sis5100_reg, reg), val, locked)
122
123#define f1_readremreg(sc, reg, val, locked) \
124 sis1100_remote_reg_read(sc, ofs(struct f1_reg, reg), val, locked)
125#define f1_writeremreg(sc, reg, val, locked) \
126 sis1100_remote_reg_write(sc, ofs(struct f1_reg, reg), val, locked)
127
128#define vertex_readremreg(sc, reg, val, locked) \
129 sis1100_remote_reg_read(sc, ofs(struct vertex_reg, reg), val, locked)
130#define vertex_writeremreg(sc, reg, val, locked) \
131 sis1100_remote_reg_write(sc, ofs(struct vertex_reg, reg), val, locked)
132
133
134int sis1100_irq_handler(void* data);
135void sis3100rem_irq_handler(struct sis1100_softc* sc);
136void sis5100rem_irq_handler(struct sis1100_softc* sc);
137void sis3100rem_enable_irqs(struct sis1100_softc*, struct sis1100_fdata*,
138 u_int32_t mask);
139void sis3100rem_disable_irqs(struct sis1100_softc*, struct sis1100_fdata*,
140 u_int32_t mask);
141void sis5100rem_enable_irqs(struct sis1100_softc*, struct sis1100_fdata*,
142 u_int32_t mask);
143void sis5100rem_disable_irqs(struct sis1100_softc*, struct sis1100_fdata*,
144 u_int32_t mask);
145void sis3100rem_irq_ack(struct sis1100_softc* sc, int irqs);
146void sis5100rem_irq_ack(struct sis1100_softc* sc, int irqs);
147void sis3100rem_get_vector(struct sis1100_softc* sc, int irqs,
148 struct sis1100_irq_get* data);
149
150int sis1100_init(struct sis1100_softc* sc);
151
152void sis1100_init_remote(struct sis1100_softc* sc);
153int sis1100rem_init(struct sis1100_softc* sc);
154int sis3100rem_init(struct sis1100_softc* sc);
155int sis5100rem_init(struct sis1100_softc* sc);
156int f1_rem_init(struct sis1100_softc* sc);
157int vertex_rem_init(struct sis1100_softc* sc);
158int sis1100_init_sdram(struct sis1100_softc* sc);
159
160void sis1100_dump_glink_status(struct sis1100_softc* sc, char* text, int locked);
161int sis1100_flush_fifo(struct sis1100_softc* sc, const char* text, int silent);
162
163int sis1100_disable_irq(struct sis1100_softc* sc,
164 u_int32_t plx_mask, u_int32_t sis_mask);
165int sis1100_enable_irq(struct sis1100_softc* sc,
166 u_int32_t plx_mask, u_int32_t sis_mask);
167int sis1100_tmp_read(struct sis1100_softc *sc,
168 u_int32_t addr, int32_t am, int size, int space, u_int32_t* data);
169int sis1100_tmp_write(struct sis1100_softc *sc,
170 u_int32_t addr, int32_t am, int size, int space, u_int32_t data);
171int sis1100_tmp_camacread(struct sis1100_softc *sc,
172 u_int32_t addr, u_int32_t* data);
173int sis1100_tmp_camacwrite(struct sis1100_softc *sc,
174 u_int32_t addr, u_int32_t data);
175int sis1100_read_dma(struct sis1100_softc *sc, struct sis1100_fdata* fd,
176 u_int32_t addr, int32_t am, int size, int space, int fifo,
177 size_t count, size_t* count_read, u_int8_t* data, int* prot_err);
178int _sis1100_read_dma(struct sis1100_softc *sc, struct sis1100_fdata* fd,
179 u_int32_t addr, int32_t am, int size, int space, int fifo,
180 size_t count, size_t* count_read, u_int8_t* data, int* prot_err, int* eot);
181int sis1100_write_dma(struct sis1100_softc *sc, struct sis1100_fdata* fd,
182 u_int32_t addr, int32_t am, int size, int space, int fifo,
183 size_t count, size_t* count_written, const u_int8_t* data, int* prot_err);
184int _sis1100_write_dma(struct sis1100_softc *sc, struct sis1100_fdata* fd,
185 u_int32_t addr, int32_t am, int size, int space, int fifo,
186 size_t count, size_t* count_written, const u_int8_t* data, int* prot_err);
187int sis1100_read_loop(struct sis1100_softc *sc, struct sis1100_fdata* fd,
188 u_int32_t addr, int32_t am, int size, int space, int fifo,
189 size_t count, size_t* count_read, u_int8_t* data, int* prot_err);
190int sis1100_write_loop(struct sis1100_softc *sc, struct sis1100_fdata* fd,
191 u_int32_t addr, int32_t am, int size, int space, int fifo,
192 size_t count, size_t* count_written, const u_int8_t* data, int* prot_err);
193int sis1100_read_pipe(struct sis1100_softc* sc, struct sis1100_pipe* control);
194int sis1100_write_pipe(struct sis1100_softc*, int32_t am, int space,
195 int num, u_int32_t* data);
196void sis1100_reset_plx(struct sis1100_softc* sc);
197int sis1100_reset(struct sis1100_softc* sc);
198
199int sis1100_read_block(struct sis1100_softc* sc, struct sis1100_fdata* fd,
200 int size, int fifo, size_t num, size_t* num_read, int space,
201 int32_t am, u_int32_t addr, u_int8_t* data, u_int32_t* error);
202int sis1100_write_block(struct sis1100_softc* sc, struct sis1100_fdata* fd,
203 int size, int fifo, size_t num, size_t* num_written, int space,
204 int32_t am, u_int32_t addr, const u_int8_t* data, u_int32_t* error);
205
206int sis1100_irq_ctl(struct sis1100_softc* sc, struct sis1100_fdata* fd,
207 struct sis1100_irq_ctl* data);
208int sis1100_irq_get(struct sis1100_softc* sc, struct sis1100_fdata* fd,
209 struct sis1100_irq_get* data);
210int sis1100_irq_ack(struct sis1100_softc* sc, struct sis1100_fdata* fd,
211 struct sis1100_irq_ack* data);
212int sis1100_irq_wait(struct sis1100_softc* sc, struct sis1100_fdata* fd,
213 struct sis1100_irq_get* data);
214int sis1100_remote_reg_read(struct sis1100_softc* sc, u_int32_t offs,
215 u_int32_t* data, int locked);
216int sis1100_remote_reg_write(struct sis1100_softc* sc, u_int32_t offs,
217 u_int32_t data, int locked);
218
219int sis1100_front_io(struct sis1100_softc* sc, u_int32_t* data, int locked);
220int sis1100_front_pulse(struct sis1100_softc* sc, u_int32_t* data, int locked);
221int sis1100_front_latch(struct sis1100_softc* sc, u_int32_t* data, int locked);
222int sis1100rem_front_io(struct sis1100_softc* sc, u_int32_t* data);
223int sis1100rem_front_pulse(struct sis1100_softc* sc, u_int32_t* data);
224int sis1100rem_front_latch(struct sis1100_softc* sc, u_int32_t* data);
225int sis3100rem_front_io(struct sis1100_softc* sc, u_int32_t* data);
226int sis3100rem_front_pulse(struct sis1100_softc* sc, u_int32_t* data);
227int sis3100rem_front_latch(struct sis1100_softc* sc, u_int32_t* data);
228int sis5100rem_front_io(struct sis1100_softc* sc, u_int32_t* data);
229int sis5100rem_front_pulse(struct sis1100_softc* sc, u_int32_t* data);
230int sis5100rem_front_latch(struct sis1100_softc* sc, u_int32_t* data);
231
232void sis1100_synch_handler(struct sis1100_softc* sc);
233void sis1100_lemo_handler(struct sis1100_softc* sc);
234void sis1100_mbox0_handler(struct sis1100_softc* sc);
235
236void sis1100_update_swapping(struct sis1100_softc* sc, const char* caller);
237int sis3100_set_timeouts(struct sis1100_softc* sc, int berr, int arb);
238int sis3100_get_timeouts(struct sis1100_softc* sc, int* berr, int* arb);
239
240int sis1100_dma_alloc(struct sis1100_softc *sc, struct sis1100_fdata* fd,
241 struct sis1100_dma_alloc* d);
242int sis1100_dma_free(struct sis1100_softc *sc, struct sis1100_fdata* fd,
243 struct sis1100_dma_alloc* d);
244
245int sis1100_check_rw_access(struct sis1100_softc*,
246 off_t, off_t, size_t, int, const char*, int);
247
248int sis1100_dsp_reset(struct sis1100_softc* sc, struct sis1100_fdata* fd);
249int sis1100_dsp_start(struct sis1100_softc* sc, struct sis1100_fdata* fd);
250int sis1100_dsp_load(struct sis1100_softc* sc, struct sis1100_fdata* fd,
251 struct sis1100_dsp_code* d);
252
253int sis1100_read_eeprom(struct sis1100_softc* sc,
254 u_int8_t num, u_int8_t addr, u_int16_t* data);
255int sis1100_write_eeprom(struct sis1100_softc* sc,
256 u_int8_t num, u_int8_t addr, u_int16_t* data);
257
258#endif
Note: See TracBrowser for help on using the repository browser.