1 | /* $ZEL: sis1100_sc_netbsd.h,v 1.4 2004/05/27 23:10:34 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_netbsd_h_
|
---|
30 | #define _sis1100_sc_netbsd_h_
|
---|
31 |
|
---|
32 | #include "dev/pci/plx9054dma_netbsd.h"
|
---|
33 |
|
---|
34 | #define MAX_DMA_LEN 524288 /* 1/2 MByte */
|
---|
35 |
|
---|
36 | extern struct cfdriver sis1100cfdriver;
|
---|
37 |
|
---|
38 | struct sis1100_softc;
|
---|
39 |
|
---|
40 | struct mmapdma {
|
---|
41 | bus_dma_tag_t dmat;
|
---|
42 | int valid;
|
---|
43 | off_t off;
|
---|
44 | bus_size_t size;
|
---|
45 | bus_dma_segment_t segs;
|
---|
46 | bus_dmamap_t dm;
|
---|
47 | caddr_t kva; /* kva of segs */
|
---|
48 | };
|
---|
49 |
|
---|
50 | struct handlercommand {
|
---|
51 | volatile enum handlercomm command;
|
---|
52 | struct simplelock lock;
|
---|
53 | };
|
---|
54 |
|
---|
55 | struct sis1100_fdata {
|
---|
56 | struct list_head list;
|
---|
57 | /* OS specific*/
|
---|
58 | struct proc *p;
|
---|
59 | /*common*/
|
---|
60 | struct mmapdma mmapdma;
|
---|
61 | size_t mindmalen_r, mindmalen_w;
|
---|
62 | enum sis1100_hw_type old_remote_hw;
|
---|
63 | enum sis1100_subdev subdev;
|
---|
64 | int32_t vmespace_am;
|
---|
65 | u_int32_t vmespace_datasize;
|
---|
66 | int fifo_mode;
|
---|
67 | int last_prot_err;
|
---|
68 | int owned_irqs;
|
---|
69 | pid_t pid;
|
---|
70 | int sig;
|
---|
71 | };
|
---|
72 |
|
---|
73 | struct sis1100_softc {
|
---|
74 | /* OS specific*/
|
---|
75 | struct device sc_dev;
|
---|
76 | pci_chipset_tag_t sc_pc;
|
---|
77 | pcitag_t sc_pcitag;
|
---|
78 | bus_dma_tag_t sc_dmat;
|
---|
79 |
|
---|
80 | bus_space_tag_t plx_t;
|
---|
81 | bus_space_handle_t plx_h;
|
---|
82 | bus_size_t plx_size;
|
---|
83 |
|
---|
84 | bus_space_tag_t reg_t;
|
---|
85 | bus_space_handle_t reg_h;
|
---|
86 | bus_size_t reg_size;
|
---|
87 | bus_addr_t reg_addr;
|
---|
88 |
|
---|
89 | bus_space_tag_t rem_t;
|
---|
90 | bus_space_handle_t rem_h;
|
---|
91 | bus_size_t rem_size;
|
---|
92 | bus_addr_t rem_addr;
|
---|
93 |
|
---|
94 | void *sc_ih;
|
---|
95 |
|
---|
96 | struct plx9054dma sc_dma;
|
---|
97 |
|
---|
98 | struct simplelock lock_sc_inuse; /* protects sc_inuse */
|
---|
99 | struct proc* vmeirq_pp;
|
---|
100 | int sc_inuse;
|
---|
101 | struct selinfo sel;
|
---|
102 |
|
---|
103 | /* OS specific definition but common use */
|
---|
104 | struct lock sem_hw; /* protects hardware */
|
---|
105 | struct lock sem_fdata_list; /* protects fdata_list_head */
|
---|
106 | struct simplelock lock_intcsr; /* protects INTCSR of PLX */
|
---|
107 | void*/*struct simplelock*/ handler_wait; /* pending_irqs, remote_ok */
|
---|
108 | struct simplelock local_wait;
|
---|
109 | struct simplelock remoteirq_wait;
|
---|
110 | struct callout 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 | int pending_irqs, new_irqs;
|
---|
123 | struct handlercommand handlercommand;
|
---|
124 | off_t ram_size;
|
---|
125 | int dsp_present;
|
---|
126 | int remote_endian; /* 0: little 1: big*/
|
---|
127 | int user_wants_swap;
|
---|
128 | 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 | #define SIS1100CARD(dev) \
|
---|
137 | ((minor(dev)&sis1100_MINORCARDMASK)>>sis1100_MINORCARDSHIFT)
|
---|
138 | #define SIS1100SC(dev) \
|
---|
139 | ((struct sis1100_softc*)sis1100cfdriver.cd_devs[SIS1100CARD(dev)])
|
---|
140 | #define SIS1100FD(dev) \
|
---|
141 | (struct sis1100_fdata*)((SIS1100SC(dev)->fdatalist)[minor(dev)&sis1100_MINORUTMASK])
|
---|
142 |
|
---|
143 | #define _plxreadreg(sc, offset) \
|
---|
144 | bus_space_read_4(sc->plx_t, sc->plx_h, offset)
|
---|
145 |
|
---|
146 | #define _plxwritereg(sc, offset, val) \
|
---|
147 | bus_space_write_4(sc->plx_t, sc->plx_h, offset, val)
|
---|
148 |
|
---|
149 | #define plxreadlocal0(sc, offset) \
|
---|
150 | bus_space_read_4(sc->reg_t, sc->reg_h, offset)
|
---|
151 |
|
---|
152 | #define plxreadlocal0b(sc, offset) \
|
---|
153 | bus_space_read_1(sc->reg_t, sc->reg_h, offset)
|
---|
154 |
|
---|
155 | #define plxwritelocal0(sc, offset, val) \
|
---|
156 | bus_space_write_4(sc->reg_t, sc->reg_h, offset, val)
|
---|
157 |
|
---|
158 | #define plxwritelocal0b(sc, offset, val) \
|
---|
159 | bus_space_write_1(sc->reg_t, sc->reg_h, offset, val)
|
---|
160 |
|
---|
161 | #define plxrawreadlocal0(sc, offset) \
|
---|
162 | bus_space_read_stream_4(sc->reg_t, sc->reg_h, offset)
|
---|
163 |
|
---|
164 | #define plxrawwritelocal0(sc, offset, val) \
|
---|
165 | bus_space_write_stream_4(sc->reg_t, sc->reg_h, offset, val)
|
---|
166 |
|
---|
167 | #define rmb_plx() bus_space_barrier(sc->plx_t, sc->plx_h, 0, sc->plx_size, \
|
---|
168 | BUS_SPACE_BARRIER_READ)
|
---|
169 | #define rmb_reg() bus_space_barrier(sc->reg_t, sc->reg_h, 0, sc->reg_size, \
|
---|
170 | BUS_SPACE_BARRIER_READ)
|
---|
171 | #define wmb_plx() bus_space_barrier(sc->plx_t, sc->plx_h, 0, sc->plx_size, \
|
---|
172 | BUS_SPACE_BARRIER_WRITE)
|
---|
173 | #define wmb_reg() bus_space_barrier(sc->reg_t, sc->reg_h, 0, sc->reg_size, \
|
---|
174 | BUS_SPACE_BARRIER_WRITE)
|
---|
175 | #define mb_plx() bus_space_barrier(sc->plx_t, sc->plx_h, 0, sc->plx_size, \
|
---|
176 | BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
|
---|
177 | #define mb_reg() bus_space_barrier(sc->reg_t, sc->reg_h, 0, sc->reg_size, \
|
---|
178 | BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
|
---|
179 |
|
---|
180 | void sis1100_done(struct sis1100_softc*);
|
---|
181 | int sis1100_intr(void*);
|
---|
182 |
|
---|
183 | int sis1100_open(dev_t, int, int, struct proc*);
|
---|
184 | int sis1100_close(dev_t, int, int, struct proc*);
|
---|
185 | int sis1100_ioctl(dev_t, u_long, caddr_t, int, struct proc*);
|
---|
186 | int sis1100_read(dev_t dev, struct uio* uio, int f);
|
---|
187 | int sis1100_write(dev_t dev, struct uio* uio, int f);
|
---|
188 | paddr_t sis1100_mmap(dev_t dev, off_t off, int prot);
|
---|
189 | void sis1100_irq_thread(void* data);
|
---|
190 | void sis1100_link_up_handler(void*);
|
---|
191 | int sis1100_poll(dev_t dev, int events, struct proc *p);
|
---|
192 |
|
---|
193 | #endif
|
---|