14 #include <linux/list.h>
17 #define AVMB1_PORTLEN 0x1f
18 #define AVM_MAXVERSION 8
19 #define AVM_NCCI_PER_CHANNEL 4
26 #define VER_CARDTYPE 1
109 #define SEND_POLL 0x72
112 #define SEND_INIT 0x11
117 #define SEND_REGISTER 0x12
126 #define SEND_RELEASE 0x14
130 #define SEND_MESSAGE 0x15
134 #define SEND_DATA_B3_REQ 0x13
140 #define SEND_CONFIG 0x21
143 #define SEND_POLLACK 0x73
149 #define RECEIVE_POLL 0x32
152 #define RECEIVE_INIT 0x27
162 #define RECEIVE_MESSAGE 0x21
167 #define RECEIVE_DATA_B3_IND 0x22
172 #define RECEIVE_START 0x23
175 #define RECEIVE_STOP 0x24
178 #define RECEIVE_NEW_NCCI 0x25
182 #define RECEIVE_FREE_NCCI 0x26
185 #define RECEIVE_RELEASE 0x26
188 #define RECEIVE_TASK_READY 0x31
192 #define RECEIVE_DEBUGMSG 0x71
196 #define RECEIVE_POLLDWORD 0x75
198 #define WRITE_REGISTER 0x00
199 #define READ_REGISTER 0x01
206 #define B1_WRITE 0x01
207 #define B1_INSTAT 0x02
208 #define B1_OUTSTAT 0x03
209 #define B1_ANALYSE 0x04
210 #define B1_REVISION 0x05
211 #define B1_RESET 0x10
214 #define B1_STAT0(cardtype) ((cardtype) == avm_m1 ? 0x81200000l : 0x80A00000l)
215 #define B1_STAT1(cardtype) (0x80E00000l)
219 static inline unsigned char b1outp(
unsigned int base,
223 outb(value, base + offset);
228 static inline int b1_rx_full(
unsigned int base)
233 static inline unsigned char b1_get_byte(
unsigned int base)
236 while (!b1_rx_full(base) &&
time_before(jiffies, stop));
237 if (b1_rx_full(base))
243 static inline unsigned int b1_get_word(
unsigned int base)
245 unsigned int val = 0;
246 val |= b1_get_byte(base);
247 val |= (b1_get_byte(base) << 8);
248 val |= (b1_get_byte(base) << 16);
249 val |= (b1_get_byte(base) << 24);
253 static inline int b1_tx_empty(
unsigned int base)
258 static inline void b1_put_byte(
unsigned int base,
unsigned char val)
260 while (!b1_tx_empty(base));
264 static inline int b1_save_put_byte(
unsigned int base,
unsigned char val)
267 while (!b1_tx_empty(base) &&
time_before(jiffies, stop));
268 if (!b1_tx_empty(base))
return -1;
273 static inline void b1_put_word(
unsigned int base,
unsigned int val)
275 b1_put_byte(base, val & 0xff);
276 b1_put_byte(base, (val >> 8) & 0xff);
277 b1_put_byte(base, (val >> 16) & 0xff);
278 b1_put_byte(base, (val >> 24) & 0xff);
281 static inline unsigned int b1_get_slice(
unsigned int base,
286 len = i = b1_get_word(base);
287 while (i-- > 0) *dp++ = b1_get_byte(base);
291 static inline void b1_put_slice(
unsigned int base,
292 unsigned char *dp,
unsigned int len)
295 b1_put_word(base, i);
297 b1_put_byte(base, *dp++);
300 static void b1_wr_reg(
unsigned int base,
305 b1_put_word(base, reg);
306 b1_put_word(base, value);
309 static inline unsigned int b1_rd_reg(
unsigned int base,
313 b1_put_word(base, reg);
314 return b1_get_word(base);
318 static inline void b1_reset(
unsigned int base)
330 static inline unsigned char b1_disable_irq(
unsigned int base)
337 static inline void b1_set_test_bit(
unsigned int base,
341 b1_wr_reg(base,
B1_STAT0(cardtype), onoff ? 0x21 : 0x20);
344 static inline int b1_get_test_bit(
unsigned int base,
347 return (b1_rd_reg(base,
B1_STAT0(cardtype)) & 0x01) != 0;
352 #define T1_FASTLINK 0x00
353 #define T1_SLOWLINK 0x08
355 #define T1_READ B1_READ
356 #define T1_WRITE B1_WRITE
357 #define T1_INSTAT B1_INSTAT
358 #define T1_OUTSTAT B1_OUTSTAT
359 #define T1_IRQENABLE 0x05
360 #define T1_FIFOSTAT 0x06
361 #define T1_RESETLINK 0x10
362 #define T1_ANALYSE 0x11
363 #define T1_IRQMASTER 0x12
364 #define T1_IDENT 0x17
365 #define T1_RESETBOARD 0x1f
367 #define T1F_IREADY 0x01
368 #define T1F_IHALF 0x02
369 #define T1F_IFULL 0x04
370 #define T1F_IEMPTY 0x08
371 #define T1F_IFLAGS 0xF0
373 #define T1F_OREADY 0x10
374 #define T1F_OHALF 0x20
375 #define T1F_OEMPTY 0x40
376 #define T1F_OFULL 0x80
377 #define T1F_OFLAGS 0xF0
380 #define FIFO_OUTBSIZE 256
381 #define FIFO_INPBSIZE 512
383 #define HEMA_VERSION_ID 0
384 #define HEMA_PAL_ID 0
386 static inline void t1outp(
unsigned int base,
390 outb(value, base + offset);
393 static inline unsigned char t1inp(
unsigned int base,
396 return inb(base + offset);
399 static inline int t1_isfastlink(
unsigned int base)
404 static inline unsigned char t1_fifostatus(
unsigned int base)
409 static inline unsigned int t1_get_slice(
unsigned int base,
413 #ifdef FASTLINK_DEBUG
414 unsigned wcnt = 0, bcnt = 0;
417 len = i = b1_get_word(base);
418 if (t1_isfastlink(base)) {
429 #ifdef FASTLINK_DEBUG
435 #ifdef FASTLINK_DEBUG
442 *dp++ = b1_get_byte(base);
444 #ifdef FASTLINK_DEBUG
450 #ifdef FASTLINK_DEBUG
453 base, len, wcnt, bcnt);
457 *dp++ = b1_get_byte(base);
462 static inline void t1_put_slice(
unsigned int base,
463 unsigned char *dp,
unsigned int len)
466 b1_put_word(base, i);
467 if (t1_isfastlink(base)) {
484 b1_put_byte(base, *dp++);
491 b1_put_byte(base, *dp++);
495 static inline void t1_disable_irq(
unsigned int base)
500 static inline void t1_reset(
unsigned int base)
512 static inline void b1_setinterrupt(
unsigned int base,
unsigned irq,
562 long rsize,
long ssize);