| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tcic2var.h,v 1.10 2007/07/09 21:00:39 ad Exp $ */ | | 1 | /* $NetBSD: tcic2var.h,v 1.11 2009/03/16 09:32:38 cegger Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1998, 1999 Christoph Badura. All rights reserved. | | 4 | * Copyright (c) 1998, 1999 Christoph Badura. All rights reserved. |
5 | * Copyright (c) 1997 Marc Horowitz. All rights reserved. | | 5 | * Copyright (c) 1997 Marc Horowitz. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -175,186 +175,151 @@ int tcic_chip_io_alloc(pcmcia_chipset_ha | | | @@ -175,186 +175,151 @@ int tcic_chip_io_alloc(pcmcia_chipset_ha |
175 | bus_size_t, bus_size_t, struct pcmcia_io_handle *); | | 175 | bus_size_t, bus_size_t, struct pcmcia_io_handle *); |
176 | void tcic_chip_io_free(pcmcia_chipset_handle_t, | | 176 | void tcic_chip_io_free(pcmcia_chipset_handle_t, |
177 | struct pcmcia_io_handle *); | | 177 | struct pcmcia_io_handle *); |
178 | int tcic_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t, | | 178 | int tcic_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t, |
179 | bus_size_t, struct pcmcia_io_handle *, int *); | | 179 | bus_size_t, struct pcmcia_io_handle *, int *); |
180 | void tcic_chip_io_unmap(pcmcia_chipset_handle_t, int); | | 180 | void tcic_chip_io_unmap(pcmcia_chipset_handle_t, int); |
181 | | | 181 | |
182 | void tcic_chip_socket_enable(pcmcia_chipset_handle_t); | | 182 | void tcic_chip_socket_enable(pcmcia_chipset_handle_t); |
183 | void tcic_chip_socket_disable(pcmcia_chipset_handle_t); | | 183 | void tcic_chip_socket_disable(pcmcia_chipset_handle_t); |
184 | void tcic_chip_socket_settype(pcmcia_chipset_handle_t, int); | | 184 | void tcic_chip_socket_settype(pcmcia_chipset_handle_t, int); |
185 | | | 185 | |
186 | static __inline int tcic_read_1(struct tcic_handle *, int); | | 186 | static __inline int tcic_read_1(struct tcic_handle *, int); |
187 | static __inline int | | 187 | static __inline int |
188 | tcic_read_1(h, reg) | | 188 | tcic_read_1(struct tcic_handle *h, int reg) |
189 | struct tcic_handle *h; | | | |
190 | int reg; | | | |
191 | { | | 189 | { |
192 | return (bus_space_read_1(h->sc->iot, h->sc->ioh, reg)); | | 190 | return (bus_space_read_1(h->sc->iot, h->sc->ioh, reg)); |
193 | } | | 191 | } |
194 | | | 192 | |
195 | static __inline int tcic_read_2(struct tcic_handle *, int); | | 193 | static __inline int tcic_read_2(struct tcic_handle *, int); |
196 | static __inline int | | 194 | static __inline int |
197 | tcic_read_2(h, reg) | | 195 | tcic_read_2(struct tcic_handle *h, int reg) |
198 | struct tcic_handle *h; | | | |
199 | int reg; | | | |
200 | { | | 196 | { |
201 | return (bus_space_read_2(h->sc->iot, h->sc->ioh, reg)); | | 197 | return (bus_space_read_2(h->sc->iot, h->sc->ioh, reg)); |
202 | } | | 198 | } |
203 | | | 199 | |
204 | static __inline int tcic_read_4(struct tcic_handle *, int); | | 200 | static __inline int tcic_read_4(struct tcic_handle *, int); |
205 | static __inline int | | 201 | static __inline int |
206 | tcic_read_4(h, reg) | | 202 | tcic_read_4(struct tcic_handle *h, int reg) |
207 | struct tcic_handle *h; | | | |
208 | int reg; | | | |
209 | { | | 203 | { |
210 | int val; | | 204 | int val; |
211 | val = bus_space_read_2(h->sc->iot, h->sc->ioh, reg); | | 205 | 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; | | 206 | val |= bus_space_read_2(h->sc->iot, h->sc->ioh, reg+2) << 16; |
213 | return val; | | 207 | return val; |
214 | } | | 208 | } |
215 | | | 209 | |
216 | static __inline void tcic_write_1(struct tcic_handle *, int, int); | | 210 | static __inline void tcic_write_1(struct tcic_handle *, int, int); |
217 | static __inline void | | 211 | static __inline void |
218 | tcic_write_1(h, reg, data) | | 212 | tcic_write_1(struct tcic_handle *h, int reg, int data) |
219 | struct tcic_handle *h; | | | |
220 | int reg; | | | |
221 | int data; | | | |
222 | { | | 213 | { |
223 | bus_space_write_1(h->sc->iot, h->sc->ioh, reg, (data)); | | 214 | bus_space_write_1(h->sc->iot, h->sc->ioh, reg, (data)); |
224 | } | | 215 | } |
225 | | | 216 | |
226 | static __inline void tcic_write_2(struct tcic_handle *, int, int); | | 217 | static __inline void tcic_write_2(struct tcic_handle *, int, int); |
227 | static __inline void | | 218 | static __inline void |
228 | tcic_write_2(h, reg, data) | | 219 | tcic_write_2(struct tcic_handle *h, int reg, int data) |
229 | struct tcic_handle *h; | | | |
230 | int reg; | | | |
231 | int data; | | | |
232 | { | | 220 | { |
233 | bus_space_write_2(h->sc->iot, h->sc->ioh, reg, (data)); | | 221 | bus_space_write_2(h->sc->iot, h->sc->ioh, reg, (data)); |
234 | } | | 222 | } |
235 | | | 223 | |
236 | static __inline void tcic_write_4(struct tcic_handle *, int, int); | | 224 | static __inline void tcic_write_4(struct tcic_handle *, int, int); |
237 | static __inline void | | 225 | static __inline void |
238 | tcic_write_4(h, reg, data) | | 226 | tcic_write_4(struct tcic_handle *h, int reg, int data) |
239 | struct tcic_handle *h; | | | |
240 | int reg; | | | |
241 | int data; | | | |
242 | { | | 227 | { |
243 | bus_space_write_2(h->sc->iot, h->sc->ioh, reg, (data)); | | 228 | 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); | | 229 | bus_space_write_2(h->sc->iot, h->sc->ioh, reg+2, (data)>>16); |
245 | } | | 230 | } |
246 | | | 231 | |
247 | static __inline int tcic_read_ind_2(struct tcic_handle *, int); | | 232 | static __inline int tcic_read_ind_2(struct tcic_handle *, int); |
248 | static __inline int | | 233 | static __inline int |
249 | tcic_read_ind_2(h, reg) | | 234 | tcic_read_ind_2(struct tcic_handle *h, int reg) |
250 | struct tcic_handle *h; | | | |
251 | int reg; | | | |
252 | { | | 235 | { |
253 | int r_addr, val; | | 236 | int r_addr, val; |
254 | r_addr = tcic_read_4(h, TCIC_R_ADDR); | | 237 | r_addr = tcic_read_4(h, TCIC_R_ADDR); |
255 | tcic_write_4(h, TCIC_R_ADDR, reg|TCIC_ADDR_INDREG); | | 238 | 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); | | 239 | val = bus_space_read_2(h->sc->iot, h->sc->ioh, TCIC_R_DATA); |
257 | tcic_write_4(h, TCIC_R_ADDR, r_addr); | | 240 | tcic_write_4(h, TCIC_R_ADDR, r_addr); |
258 | return val; | | 241 | return val; |
259 | } | | 242 | } |
260 | | | 243 | |
261 | static __inline void tcic_write_ind_2(struct tcic_handle *, int, int); | | 244 | static __inline void tcic_write_ind_2(struct tcic_handle *, int, int); |
262 | static __inline void | | 245 | static __inline void |
263 | tcic_write_ind_2(h, reg, data) | | 246 | tcic_write_ind_2(struct tcic_handle *h, int reg, int data) |
264 | struct tcic_handle *h; | | | |
265 | int reg; | | | |
266 | int data; | | | |
267 | { | | 247 | { |
268 | int r_addr; | | 248 | int r_addr; |
269 | r_addr = tcic_read_4(h, TCIC_R_ADDR); | | 249 | r_addr = tcic_read_4(h, TCIC_R_ADDR); |
270 | tcic_write_4(h, TCIC_R_ADDR, reg|TCIC_ADDR_INDREG); | | 250 | 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)); | | 251 | bus_space_write_2(h->sc->iot, h->sc->ioh, TCIC_R_DATA, (data)); |
272 | tcic_write_4(h, TCIC_R_ADDR, r_addr); | | 252 | tcic_write_4(h, TCIC_R_ADDR, r_addr); |
273 | } | | 253 | } |
274 | | | 254 | |
275 | static __inline void tcic_sel_sock(struct tcic_handle *); | | 255 | static __inline void tcic_sel_sock(struct tcic_handle *); |
276 | static __inline void | | 256 | static __inline void |
277 | tcic_sel_sock(h) | | 257 | tcic_sel_sock(struct tcic_handle *h) |
278 | struct tcic_handle *h; | | | |
279 | { | | 258 | { |
280 | int r_addr; | | 259 | int r_addr; |
281 | r_addr = tcic_read_2(h, TCIC_R_ADDR2); | | 260 | r_addr = tcic_read_2(h, TCIC_R_ADDR2); |
282 | tcic_write_2(h, TCIC_R_ADDR2, | | 261 | tcic_write_2(h, TCIC_R_ADDR2, |
283 | (h->sock<<TCIC_ADDR2_SS_SHFT)|(r_addr & ~TCIC_ADDR2_SS_MASK)); | | 262 | (h->sock<<TCIC_ADDR2_SS_SHFT)|(r_addr & ~TCIC_ADDR2_SS_MASK)); |
284 | } | | 263 | } |
285 | | | 264 | |
286 | static __inline void tcic_wait_ready(struct tcic_handle *); | | 265 | static __inline void tcic_wait_ready(struct tcic_handle *); |
287 | static __inline void | | 266 | static __inline void |
288 | tcic_wait_ready(h) | | 267 | tcic_wait_ready(struct tcic_handle *h) |
289 | struct tcic_handle *h; | | | |
290 | { | | 268 | { |
291 | int i; | | 269 | int i; |
292 | | | 270 | |
293 | /* XXX appropriate socket must have been selected already. */ | | 271 | /* XXX appropriate socket must have been selected already. */ |
294 | for (i = 0; i < 10000; i++) { | | 272 | for (i = 0; i < 10000; i++) { |
295 | if (tcic_read_1(h, TCIC_R_SSTAT) & TCIC_SSTAT_RDY) | | 273 | if (tcic_read_1(h, TCIC_R_SSTAT) & TCIC_SSTAT_RDY) |
296 | return; | | 274 | return; |
297 | delay(500); | | 275 | delay(500); |
298 | } | | 276 | } |
299 | | | 277 | |
300 | #ifdef DIAGNOSTIC | | 278 | #ifdef DIAGNOSTIC |
301 | printf("tcic_wait_ready ready never happened\n"); | | 279 | printf("tcic_wait_ready ready never happened\n"); |
302 | #endif | | 280 | #endif |
303 | } | | 281 | } |
304 | | | 282 | |
305 | static __inline int tcic_read_aux_1(bus_space_tag_t, bus_space_handle_t, int, int); | | 283 | static __inline int tcic_read_aux_1(bus_space_tag_t, bus_space_handle_t, int, int); |
306 | static __inline int | | 284 | static __inline int |
307 | tcic_read_aux_1(iot, ioh, auxreg, reg) | | 285 | tcic_read_aux_1(bus_space_tag_t iot, bus_space_handle_t ioh, int auxreg, int reg) |
308 | bus_space_tag_t iot; | | | |
309 | bus_space_handle_t ioh; | | | |
310 | int auxreg; | | | |
311 | int reg; | | | |
312 | { | | 286 | { |
313 | int mode, val; | | 287 | int mode, val; |
314 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); | | 288 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); |
315 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); | | 289 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); |
316 | val = bus_space_read_1(iot, ioh, reg); | | 290 | val = bus_space_read_1(iot, ioh, reg); |
317 | return val; | | 291 | return val; |
318 | } | | 292 | } |
319 | | | 293 | |
320 | static __inline int tcic_read_aux_2(bus_space_tag_t, bus_space_handle_t, int); | | 294 | static __inline int tcic_read_aux_2(bus_space_tag_t, bus_space_handle_t, int); |
321 | static __inline int | | 295 | static __inline int |
322 | tcic_read_aux_2(iot, ioh, auxreg) | | 296 | tcic_read_aux_2(bus_space_tag_t iot, bus_space_handle_t ioh, int auxreg) |
323 | bus_space_tag_t iot; | | | |
324 | bus_space_handle_t ioh; | | | |
325 | int auxreg; | | | |
326 | { | | 297 | { |
327 | int mode, val; | | 298 | int mode, val; |
328 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); | | 299 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); |
329 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); | | 300 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); |
330 | val = bus_space_read_2(iot, ioh, TCIC_R_AUX); | | 301 | val = bus_space_read_2(iot, ioh, TCIC_R_AUX); |
331 | return val; | | 302 | return val; |
332 | } | | 303 | } |
333 | | | 304 | |
334 | static __inline void tcic_write_aux_1(bus_space_tag_t, bus_space_handle_t, int, int, int); | | 305 | static __inline void tcic_write_aux_1(bus_space_tag_t, bus_space_handle_t, int, int, int); |
335 | static __inline void | | 306 | static __inline void |
336 | tcic_write_aux_1(iot, ioh, auxreg, reg, val) | | 307 | tcic_write_aux_1(bus_space_tag_t iot, bus_space_handle_t ioh, int auxreg, int reg, int val) |
337 | bus_space_tag_t iot; | | | |
338 | bus_space_handle_t ioh; | | | |
339 | int auxreg, reg, val; | | | |
340 | { | | 308 | { |
341 | int mode; | | 309 | int mode; |
342 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); | | 310 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); |
343 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); | | 311 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); |
344 | bus_space_write_1(iot, ioh, reg, val); | | 312 | bus_space_write_1(iot, ioh, reg, val); |
345 | } | | 313 | } |
346 | | | 314 | |
347 | static __inline void tcic_write_aux_2(bus_space_tag_t, bus_space_handle_t, int, int); | | 315 | static __inline void tcic_write_aux_2(bus_space_tag_t, bus_space_handle_t, int, int); |
348 | static __inline void | | 316 | static __inline void |
349 | tcic_write_aux_2(iot, ioh, auxreg, val) | | 317 | tcic_write_aux_2(bus_space_tag_t iot, bus_space_handle_t ioh, int auxreg, int val) |
350 | bus_space_tag_t iot; | | | |
351 | bus_space_handle_t ioh; | | | |
352 | int auxreg, val; | | | |
353 | { | | 318 | { |
354 | int mode; | | 319 | int mode; |
355 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); | | 320 | mode = bus_space_read_1(iot, ioh, TCIC_R_MODE); |
356 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); | | 321 | bus_space_write_1(iot, ioh, TCIC_R_MODE, (mode & ~TCIC_AR_MASK)|auxreg); |
357 | bus_space_write_2(iot, ioh, TCIC_R_AUX, val); | | 322 | bus_space_write_2(iot, ioh, TCIC_R_AUX, val); |
358 | } | | 323 | } |
359 | | | 324 | |
360 | #endif /* _TCIC2VAR_H */ | | 325 | #endif /* _TCIC2VAR_H */ |