This source file includes following definitions.
- tcic_read_1
- tcic_read_2
- tcic_read_4
- tcic_write_1
- tcic_write_2
- tcic_write_4
- tcic_read_ind_2
- tcic_write_ind_2
- tcic_sel_sock
- tcic_wait_ready
- tcic_read_aux_1
- tcic_read_aux_2
- tcic_write_aux_1
- tcic_write_aux_2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef _TCIC2VAR_H
35 #define _TCIC2VAR_H
36
37 #include <sys/device.h>
38
39 #include <dev/pcmcia/pcmciareg.h>
40 #include <dev/pcmcia/pcmciachip.h>
41
42 #include <dev/ic/tcic2reg.h>
43
44 struct proc;
45
46 struct tcic_event {
47 SIMPLEQ_ENTRY(tcic_event) pe_q;
48 int pe_type;
49 };
50
51
52 #define TCIC_EVENT_INSERTION 0
53 #define TCIC_EVENT_REMOVAL 1
54
55
56 struct tcic_handle {
57 struct tcic_softc *sc;
58 int sock;
59 int flags;
60 int sstat;
61 int memalloc;
62 int memwins;
63 struct {
64 bus_addr_t addr;
65 bus_size_t size;
66 int size2;
67 long offset;
68 int speed;
69 int kind;
70 } mem[TCIC_MAX_MEM_WINS];
71 int ioalloc;
72 struct {
73 bus_addr_t addr;
74 bus_size_t size;
75 int width;
76 int speed;
77 } io[TCIC_IO_WINS];
78 int ih_irq;
79 struct device *pcmcia;
80
81 int shutdown;
82 struct proc *event_thread;
83 SIMPLEQ_HEAD(, tcic_event) events;
84 };
85
86 #define TCIC_FLAG_SOCKETP 0x0001
87 #define TCIC_FLAG_CARDP 0x0002
88
89
90
91
92
93
94 #define TCIC_MEM_PAGES 4
95 #define TCIC_MEMSIZE TCIC_MEM_PAGES*TCIC_MEM_PAGESIZE
96
97 #define TCIC_NSLOTS 2
98
99 struct tcic_softc {
100 struct device dev;
101
102 bus_space_tag_t memt;
103 bus_space_handle_t memh;
104 bus_space_tag_t iot;
105 bus_space_handle_t ioh;
106
107 int chipid;
108 int validirqs;
109 int pwrena;
110
111
112 void *intr_est;
113
114 pcmcia_chipset_tag_t pct;
115
116
117 int subregionmask;
118
119
120 bus_addr_t membase;
121 int memsize2;
122
123
124
125
126
127
128
129
130 bus_addr_t iobase;
131 bus_size_t iosize;
132
133 int irq;
134 void *ih;
135
136 struct tcic_handle handle[TCIC_NSLOTS];
137 };
138
139 int tcic_log2(u_int);
140 int tcic_ns2wscnt(int);
141
142 int tcic_check_reserved_bits(bus_space_tag_t, bus_space_handle_t);
143 int tcic_chipid(bus_space_tag_t, bus_space_handle_t);
144 int tcic_chipid_known(int);
145 char *tcic_chipid_to_string(int);
146 int tcic_validirqs(int);
147
148 void tcic_attach(struct tcic_softc *);
149 void tcic_attach_sockets(struct tcic_softc *);
150 int tcic_intr(void *arg);
151
152 static __inline__ int tcic_read_1(struct tcic_handle *, int);
153 static __inline__ int tcic_read_2(struct tcic_handle *, int);
154 static __inline__ int tcic_read_4(struct tcic_handle *, int);
155 static __inline__ void tcic_write_1(struct tcic_handle *, int, int);
156 static __inline__ void tcic_write_2(struct tcic_handle *, int, int);
157 static __inline__ void tcic_write_4(struct tcic_handle *, int, int);
158 static __inline__ int tcic_read_ind_2(struct tcic_handle *, int);
159 static __inline__ void tcic_write_ind_2(struct tcic_handle *, int, int);
160 static __inline__ void tcic_sel_sock(struct tcic_handle *);
161 static __inline__ void tcic_wait_ready(struct tcic_handle *);
162 static __inline__ int tcic_read_aux_1(bus_space_tag_t, bus_space_handle_t, int, int);
163 static __inline__ int tcic_read_aux_2(bus_space_tag_t, bus_space_handle_t, int);
164 static __inline__ void tcic_write_aux_1(bus_space_tag_t, bus_space_handle_t, int, int, int);
165 static __inline__ void tcic_write_aux_2(bus_space_tag_t, bus_space_handle_t, int, int);
166
167 int tcic_chip_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
168 struct pcmcia_mem_handle *);
169 void tcic_chip_mem_free(pcmcia_chipset_handle_t,
170 struct pcmcia_mem_handle *);
171 int tcic_chip_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t,
172 bus_size_t, struct pcmcia_mem_handle *, bus_size_t *, int *);
173 void tcic_chip_mem_unmap(pcmcia_chipset_handle_t, int);
174
175 int tcic_chip_io_alloc(pcmcia_chipset_handle_t, bus_addr_t,
176 bus_size_t, bus_size_t, struct pcmcia_io_handle *);
177 void tcic_chip_io_free(pcmcia_chipset_handle_t,
178 struct pcmcia_io_handle *);
179 int tcic_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t,
180 bus_size_t, struct pcmcia_io_handle *, int *);
181 void tcic_chip_io_unmap(pcmcia_chipset_handle_t, int);
182
183 void tcic_chip_socket_enable(pcmcia_chipset_handle_t);
184 void tcic_chip_socket_disable(pcmcia_chipset_handle_t);
185
186 static __inline__ int tcic_read_1(struct tcic_handle *, int);
187 static __inline__ int
188 tcic_read_1(h, reg)
189 struct tcic_handle *h;
190 int reg;
191 {
192 return (bus_space_read_1(h->sc->iot, h->sc->ioh, reg));
193 }
194
195 static __inline__ int tcic_read_2(struct tcic_handle *, int);
196 static __inline__ int
197 tcic_read_2(h, reg)
198 struct tcic_handle *h;
199 int reg;
200 {
201 return (bus_space_read_2(h->sc->iot, h->sc->ioh, reg));
202 }
203
204 static __inline__ int tcic_read_4(struct tcic_handle *, int);
205 static __inline__ int
206 tcic_read_4(h, reg)
207 struct tcic_handle *h;
208 int reg;
209 {
210 int val;
211 val = bus_space_read_2(h->sc->iot, h->sc->ioh, reg);
212 val |= bus_space_read_2(h->sc->iot, h->sc->ioh, reg+2) << 16;
213 return val;
214 }
215
216 static __inline__ void tcic_write_1(struct tcic_handle *, int, int);
217 static __inline__ void
218 tcic_write_1(h, reg, data)
219 struct tcic_handle *h;
220 int reg;
221 int data;
222 {
223 bus_space_write_1(h->sc->iot, h->sc->ioh, reg, (data));
224 }
225
226 static __inline__ void tcic_write_2(struct tcic_handle *, int, int);
227 static __inline__ void
228 tcic_write_2(h, reg, data)
229 struct tcic_handle *h;
230 int reg;
231 int data;
232 {
233 bus_space_write_2(h->sc->iot, h->sc->ioh, reg, (data));
234 }
235
236 static __inline__ void tcic_write_4(struct tcic_handle *, int, int);
237 static __inline__ void
238 tcic_write_4(h, reg, data)
239 struct tcic_handle *h;
240 int reg;
241 int data;
242 {
243 bus_space_write_2(h->sc->iot, h->sc->ioh, reg, (data));
244 bus_space_write_2(h->sc->iot, h->sc->ioh, reg+2, (data)>>16);
245 }
246
247 static __inline__ int tcic_read_ind_2(struct tcic_handle *, int);
248 static __inline__ int
249 tcic_read_ind_2(h, reg)
250 struct tcic_handle *h;
251 int reg;
252 {
253 int r_addr, val;
254 r_addr = tcic_read_4(h, TCIC_R_ADDR);
255 tcic_write_4(h, TCIC_R_ADDR, reg|TCIC_ADDR_INDREG);
256 val = bus_space_read_2(h->sc->iot, h->sc->ioh, TCIC_R_DATA);
257 tcic_write_4(h, TCIC_R_ADDR, r_addr);
258 return val;
259 }
260
261 static __inline__ void tcic_write_ind_2(struct tcic_handle *, int, int);
262 static __inline__ void
263 tcic_write_ind_2(h, reg, data)
264 struct tcic_handle *h;
265 int reg;
266 int data;
267 {
268 int r_addr;
269 r_addr = tcic_read_4(h, TCIC_R_ADDR);
270 tcic_write_4(h, TCIC_R_ADDR, reg|TCIC_ADDR_INDREG);
271 bus_space_write_2(h->sc->iot, h->sc->ioh, TCIC_R_DATA, (data));
272 tcic_write_4(h, TCIC_R_ADDR, r_addr);
273 }
274
275 static __inline__ void tcic_sel_sock(struct tcic_handle *);
276 static __inline__ void
277 tcic_sel_sock(h)
278 struct tcic_handle *h;
279 {
280 int r_addr;
281 r_addr = tcic_read_2(h, TCIC_R_ADDR2);
282 tcic_write_2(h, TCIC_R_ADDR2,
283 (h->sock<<TCIC_ADDR2_SS_SHFT)|(r_addr & ~TCIC_ADDR2_SS_MASK));
284 }
285
286 static __inline__ void tcic_wait_ready(struct tcic_handle *);
287 static __inline__ void
288 tcic_wait_ready(h)
289 struct tcic_handle *h;
290 {
291 int i;
292
293
294 for (i = 0; i < 10000; i++) {
295 if (tcic_read_1(h, TCIC_R_SSTAT) & TCIC_SSTAT_RDY)
296 return;
297 delay(500);
298 }
299
300 #ifdef DIAGNOSTIC
301 printf("tcic_wait_ready ready never happened\n");
302 #endif
303 }
304
305 static __inline__ int tcic_read_aux_1(bus_space_tag_t, bus_space_handle_t, int, int);
306 static __inline__ int
307 tcic_read_aux_1(iot, ioh, auxreg, reg)
308 bus_space_tag_t iot;
309 bus_space_handle_t ioh;
310 int auxreg, reg;
311 {
312 int mode, val;
313 mode = bus_space_read_1(iot, ioh, TCIC_R_MODE);
314 bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg);
315 val = bus_space_read_1(iot, ioh, reg);
316 return val;
317 }
318
319 static __inline__ int tcic_read_aux_2(bus_space_tag_t, bus_space_handle_t, int);
320 static __inline__ int
321 tcic_read_aux_2(iot, ioh, auxreg)
322 bus_space_tag_t iot;
323 bus_space_handle_t ioh;
324 int auxreg;
325 {
326 int mode, val;
327 mode = bus_space_read_1(iot, ioh, TCIC_R_MODE);
328 bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg);
329 val = bus_space_read_2(iot, ioh, TCIC_R_AUX);
330 return val;
331 }
332
333 static __inline__ void tcic_write_aux_1(bus_space_tag_t, bus_space_handle_t, int, int, int);
334 static __inline__ void
335 tcic_write_aux_1(iot, ioh, auxreg, reg, val)
336 bus_space_tag_t iot;
337 bus_space_handle_t ioh;
338 int auxreg, reg, val;
339 {
340 int mode;
341 mode = bus_space_read_1(iot, ioh, TCIC_R_MODE);
342 bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg);
343 bus_space_write_1(iot, ioh, reg, val);
344 }
345
346 static __inline__ void tcic_write_aux_2(bus_space_tag_t, bus_space_handle_t, int, int);
347 static __inline__ void
348 tcic_write_aux_2(iot, ioh, auxreg, val)
349 bus_space_tag_t iot;
350 bus_space_handle_t ioh;
351 int auxreg, val;
352 {
353 int mode;
354 mode = bus_space_read_1(iot, ioh, TCIC_R_MODE);
355 bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg);
356 bus_space_write_2(iot, ioh, TCIC_R_AUX, val);
357 }
358
359 #endif