1 /* $Id: eicon.h,v 1.11 1999/08/29 17:23:44 armin Exp $
3 * ISDN low-level module for Eicon.Diehl active ISDN-Cards.
5 * Copyright 1998 by Fritz Elfert (fritz@wuemaus.franken.de)
6 * Copyright 1998,99 by Armin Schindler (mac@melware.de)
7 * Copyright 1999 Cytronics & Melware (info@melware.de)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * Revision 1.11 1999/08/29 17:23:44 armin
26 * Bugfix if compile as not module.
28 * Revision 1.10 1999/08/22 20:26:41 calle
29 * backported changes from kernel 2.3.14:
30 * - several #include "config.h" gone, others come.
31 * - "struct device" changed to "struct net_device" in 2.3.14, added a
32 * define in isdn_compat.h for older kernel versions.
34 * Revision 1.9 1999/08/18 20:16:57 armin
35 * Added XLOG function for all cards.
36 * Bugfix of alloc_skb NULL pointer.
38 * Revision 1.8 1999/07/25 15:12:01 armin
39 * fix of some debug logs.
40 * enabled ISA-cards option.
42 * Revision 1.7 1999/07/11 17:16:23 armin
43 * Bugfixes in queue handling.
44 * Added DSP-DTMF decoder functions.
45 * Reorganized ack_handler.
47 * Revision 1.6 1999/06/09 19:31:24 armin
48 * Wrong PLX size for request_region() corrected.
49 * Added first MCA code from Erik Weber.
51 * Revision 1.5 1999/03/29 11:19:41 armin
52 * I/O stuff now in seperate file (eicon_io.c)
53 * Old ISA type cards (S,SX,SCOM,Quadro,S2M) implemented.
55 * Revision 1.4 1999/03/02 12:37:42 armin
56 * Added some important checks.
57 * Analog Modem with DSP.
58 * Channels will be added to Link-Level after loading firmware.
60 * Revision 1.3 1999/01/24 20:14:07 armin
61 * Changed and added debug stuff.
62 * Better data sending. (still problems with tty's flip buffer)
64 * Revision 1.2 1999/01/10 18:46:04 armin
65 * Bug with wrong values in HLC fixed.
66 * Bytes to send are counted and limited now.
68 * Revision 1.1 1999/01/01 18:09:41 armin
69 * First checkin of new eicon driver.
70 * DIVA-Server BRI/PCI and PRI/PCI are supported.
71 * Old diehl code is obsolete.
80 #define EICON_IOCTL_SETMMIO 0
81 #define EICON_IOCTL_GETMMIO 1
82 #define EICON_IOCTL_SETIRQ 2
83 #define EICON_IOCTL_GETIRQ 3
84 #define EICON_IOCTL_LOADBOOT 4
85 #define EICON_IOCTL_ADDCARD 5
86 #define EICON_IOCTL_GETTYPE 6
87 #define EICON_IOCTL_LOADPCI 7
88 #define EICON_IOCTL_LOADISA 8
89 #define EICON_IOCTL_GETVER 9
90 #define EICON_IOCTL_GETXLOG 10
92 #define EICON_IOCTL_MANIF 90
94 #define EICON_IOCTL_FREEIT 97
95 #define EICON_IOCTL_TEST 98
96 #define EICON_IOCTL_DEBUGVAR 99
99 #define EICON_BUS_ISA 1
100 #define EICON_BUS_MCA 2
101 #define EICON_BUS_PCI 3
103 /* Constants for describing Card-Type */
104 #define EICON_CTYPE_S 0
105 #define EICON_CTYPE_SX 1
106 #define EICON_CTYPE_SCOM 2
107 #define EICON_CTYPE_QUADRO 3
108 #define EICON_CTYPE_S2M 4
109 #define EICON_CTYPE_MAESTRA 5
110 #define EICON_CTYPE_MAESTRAQ 6
111 #define EICON_CTYPE_MAESTRAQ_U 7
112 #define EICON_CTYPE_MAESTRAP 8
113 #define EICON_CTYPE_ISABRI 0x10
114 #define EICON_CTYPE_ISAPRI 0x20
115 #define EICON_CTYPE_MASK 0x0f
116 #define EICON_CTYPE_QUADRO_NR(n) (n<<4)
118 #define MAX_HEADER_LEN 10
121 /* Struct for adding new cards */
122 typedef struct eicon_cdef
{
128 #define EICON_ISA_BOOT_MEMCHK 1
129 #define EICON_ISA_BOOT_NORMAL 2
131 /* Struct for downloading protocol via ioctl for ISA cards */
132 /* same struct for downloading protocol via ioctl for MCA cards */
134 /* start-up parameters */
138 unsigned char WatchDog
;
139 unsigned char Permanent
;
140 unsigned char XInterface
;
141 unsigned char StableL2
;
142 unsigned char NoOrderCheck
;
143 unsigned char HandsetType
;
145 unsigned char LowChannel
;
146 unsigned char ProtVersion
;
148 unsigned char Loopback
;
149 unsigned char oad
[32];
150 unsigned char osa
[32];
151 unsigned char spid
[32];
152 unsigned char boot_opt
;
153 unsigned long bootstrap_len
;
154 unsigned long firmware_len
;
155 unsigned char code
[1]; /* Rest (bootstrap- and firmware code) will be allocated */
158 /* Struct for downloading protocol via ioctl for PCI cards */
160 /* start-up parameters */
163 unsigned char WatchDog
;
164 unsigned char Permanent
;
165 unsigned char XInterface
;
166 unsigned char StableL2
;
167 unsigned char NoOrderCheck
;
168 unsigned char HandsetType
;
169 unsigned char LowChannel
;
170 unsigned char ProtVersion
;
172 unsigned char NoHscx30Mode
; /* switch PRI into No HSCX30 test mode */
173 unsigned char Loopback
; /* switch card into Loopback mode */
176 unsigned char oad
[32];
177 unsigned char osa
[32];
178 unsigned char spid
[32];
180 unsigned long protocol_len
;
181 unsigned int dsp_code_num
;
182 unsigned long dsp_code_len
[9];
183 unsigned char code
[1]; /* Rest (protocol- and dsp code) will be allocated */
186 /* Data for downloading protocol via ioctl */
188 eicon_isa_codebuf isa
;
189 eicon_isa_codebuf mca
;
190 eicon_pci_codebuf pci
;
193 /* Data for Management interface */
198 unsigned char data
[700];
204 /* Kernel includes */
205 #include <linux/config.h>
206 #include <linux/sched.h>
207 #include <linux/string.h>
208 #include <linux/tqueue.h>
209 #include <linux/interrupt.h>
210 #include <linux/skbuff.h>
211 #include <linux/errno.h>
212 #include <linux/fs.h>
213 #include <linux/major.h>
214 #include <asm/segment.h>
216 #include <linux/kernel.h>
217 #include <linux/signal.h>
218 #include <linux/malloc.h>
219 #include <linux/mm.h>
220 #include <linux/mman.h>
221 #include <linux/ioport.h>
222 #include <linux/timer.h>
223 #include <linux/wait.h>
224 #include <linux/delay.h>
225 #include <linux/ctype.h>
227 #include <linux/isdnif.h>
229 #include <linux/isdn_compat.h>
232 __u16 length
__attribute__ ((packed
)); /* length of data/parameter field */
233 __u8 P
[1]; /* data/parameter field */
236 #include "eicon_isa.h"
238 /* Macro for delay via schedule() */
240 current->state = TASK_INTERRUPTIBLE; \
241 schedule_timeout(j); \
246 #define DIVAS_SHARED_OFFSET (0x1000)
248 #define MIPS_BUFFER_SZ 128
249 #define MIPS_MAINT_OFFS 0xff00
251 #define XLOG_ERR_CARD_NUM (13)
252 #define XLOG_ERR_DONE (14)
253 #define XLOG_ERR_CMD (15)
254 #define XLOG_ERR_TIMEOUT (16)
255 #define XLOG_ERR_CARD_STATE (17)
256 #define XLOG_ERR_UNKNOWN (18)
260 __u8 Id
__attribute__ ((packed
));
261 __u8 uX
__attribute__ ((packed
));
262 __u8 listen
__attribute__ ((packed
));
263 __u8 active
__attribute__ ((packed
));
264 __u8 sin
[3] __attribute__ ((packed
));
265 __u8 bc
[6] __attribute__ ((packed
));
266 __u8 llc
[6] __attribute__ ((packed
));
267 __u8 hlc
[6] __attribute__ ((packed
));
268 __u8 oad
[20] __attribute__ ((packed
));
272 __u32 cx_b1
__attribute__ ((packed
));
273 __u32 cx_b2
__attribute__ ((packed
));
274 __u32 cr_b1
__attribute__ ((packed
));
275 __u32 cr_b2
__attribute__ ((packed
));
276 __u32 px_b1
__attribute__ ((packed
));
277 __u32 px_b2
__attribute__ ((packed
));
278 __u32 pr_b1
__attribute__ ((packed
));
279 __u32 pr_b2
__attribute__ ((packed
));
280 __u16 er_b1
__attribute__ ((packed
));
281 __u16 er_b2
__attribute__ ((packed
));
285 __u32 XTotal
__attribute__ ((packed
));
286 __u32 RTotal
__attribute__ ((packed
));
287 __u16 XError
__attribute__ ((packed
));
288 __u16 RError
__attribute__ ((packed
));
301 __u8 b
[MIPS_BUFFER_SZ
];
302 __u16 w
[MIPS_BUFFER_SZ
>>1];
303 __u16 l
[MIPS_BUFFER_SZ
>>2]; /* word is wrong, do not use! Use 'd' instead. */
304 __u32 d
[MIPS_BUFFER_SZ
>>2];
309 __u8 req
__attribute__ ((packed
));
310 __u8 rc
__attribute__ ((packed
));
311 __u8 reserved
[2] __attribute__ ((packed
)); /* R3000 alignment ... */
312 __u8
*mem
__attribute__ ((packed
));
313 __u16 length
__attribute__ ((packed
)); /* used to be short */
314 __u16 port
__attribute__ ((packed
));
315 __u8 fill
[4] __attribute__ ((packed
)); /* data at offset 16 */
316 MIPS_BUFFER data
__attribute__ ((packed
));
326 __u16 code
__attribute__ ((packed
)); /* used to be short */
327 __u16 timeh
__attribute__ ((packed
));
328 __u16 timel
__attribute__ ((packed
));
329 char buffer
[MIPS_BUFFER_SZ
- 6];
333 #define DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE 48
334 #define DSP_COMBIFILE_FORMAT_VERSION_BCD 0x0100
336 #define DSP_FILE_FORMAT_IDENTIFICATION_SIZE 48
337 #define DSP_FILE_FORMAT_VERSION_BCD 0x0100
339 typedef struct tag_dsp_combifile_header
341 char format_identification
[DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE
] __attribute__ ((packed
));
342 __u16 format_version_bcd
__attribute__ ((packed
));
343 __u16 header_size
__attribute__ ((packed
));
344 __u16 combifile_description_size
__attribute__ ((packed
));
345 __u16 directory_entries
__attribute__ ((packed
));
346 __u16 directory_size
__attribute__ ((packed
));
347 __u16 download_count
__attribute__ ((packed
));
348 __u16 usage_mask_size
__attribute__ ((packed
));
349 } t_dsp_combifile_header
;
351 typedef struct tag_dsp_combifile_directory_entry
353 __u16 card_type_number
__attribute__ ((packed
));
354 __u16 file_set_number
__attribute__ ((packed
));
355 } t_dsp_combifile_directory_entry
;
357 typedef struct tag_dsp_file_header
359 char format_identification
[DSP_FILE_FORMAT_IDENTIFICATION_SIZE
] __attribute__ ((packed
));
360 __u16 format_version_bcd
__attribute__ ((packed
));
361 __u16 download_id
__attribute__ ((packed
));
362 __u16 download_flags
__attribute__ ((packed
));
363 __u16 required_processing_power
__attribute__ ((packed
));
364 __u16 interface_channel_count
__attribute__ ((packed
));
365 __u16 header_size
__attribute__ ((packed
));
366 __u16 download_description_size
__attribute__ ((packed
));
367 __u16 memory_block_table_size
__attribute__ ((packed
));
368 __u16 memory_block_count
__attribute__ ((packed
));
369 __u16 segment_table_size
__attribute__ ((packed
));
370 __u16 segment_count
__attribute__ ((packed
));
371 __u16 symbol_table_size
__attribute__ ((packed
));
372 __u16 symbol_count
__attribute__ ((packed
));
373 __u16 total_data_size_dm
__attribute__ ((packed
));
374 __u16 data_block_count_dm
__attribute__ ((packed
));
375 __u16 total_data_size_pm
__attribute__ ((packed
));
376 __u16 data_block_count_pm
__attribute__ ((packed
));
379 typedef struct tag_dsp_memory_block_desc
381 __u16 alias_memory_block
;
384 __u16 size
; /* DSP words */
385 } t_dsp_memory_block_desc
;
387 typedef struct tag_dsp_segment_desc
393 __u16 alignment
; /* ==0 -> no other legal start address than base */
394 } t_dsp_segment_desc
;
396 typedef struct tag_dsp_symbol_desc
401 __u16 size
; /* DSP words */
404 typedef struct tag_dsp_data_block_header
409 __u16 size
; /* DSP words */
410 } t_dsp_data_block_header
;
412 typedef struct tag_dsp_download_desc
/* be sure to keep native alignment for MAESTRA's */
415 __u16 download_flags
;
416 __u16 required_processing_power
;
417 __u16 interface_channel_count
;
418 __u16 excess_header_size
;
419 __u16 memory_block_count
;
422 __u16 data_block_count_dm
;
423 __u16 data_block_count_pm
;
424 __u8
* p_excess_header_data
__attribute__ ((packed
));
425 char * p_download_description
__attribute__ ((packed
));
426 t_dsp_memory_block_desc
*p_memory_block_table
__attribute__ ((packed
));
427 t_dsp_segment_desc
*p_segment_table
__attribute__ ((packed
));
428 t_dsp_symbol_desc
*p_symbol_table
__attribute__ ((packed
));
429 __u16
* p_data_blocks_dm
__attribute__ ((packed
));
430 __u16
* p_data_blocks_pm
__attribute__ ((packed
));
431 } t_dsp_download_desc
;
437 __u8 Req
; /* pending request */
438 __u8 Rc
; /* return code received */
439 __u8 Ind
; /* indication received */
440 __u8 ReqCh
; /* channel of current Req */
441 __u8 RcCh
; /* channel of current Rc */
442 __u8 IndCh
; /* channel of current Ind */
443 __u8 D3Id
; /* ID used by this entity */
444 __u8 B2Id
; /* ID used by this entity */
445 __u8 GlobalId
; /* reserved field */
446 __u8 XNum
; /* number of X-buffers */
447 __u8 RNum
; /* number of R-buffers */
448 struct sk_buff_head X
; /* X-buffer queue */
449 struct sk_buff_head R
; /* R-buffer queue */
450 __u8 RNR
; /* receive not ready flag */
451 __u8 complete
; /* receive complete status */
452 __u8 busy
; /* busy flag */
453 __u16 ref
; /* saved reference */
456 #define FAX_MAX_SCANLINE 256
461 __u8 abLine
[FAX_MAX_SCANLINE
];
462 __u8 abFrame
[FAX_MAX_SCANLINE
];
463 unsigned int LineLen
;
464 unsigned int LineDataLen
;
466 unsigned int NullBytesPos
;
474 int No
; /* Channel Number */
475 unsigned short callref
; /* Call Reference */
476 unsigned short fsm_state
; /* Current D-Channel state */
477 unsigned short eazmask
; /* EAZ-Mask for this Channel */
478 int queued
; /* User-Data Bytes in TX queue */
479 int waitq
; /* User-Data Bytes in wait queue */
480 int waitpq
; /* User-Data Bytes in packet queue */
483 unsigned char l2prot
; /* Layer 2 protocol */
484 unsigned char l3prot
; /* Layer 3 protocol */
485 #ifdef CONFIG_ISDN_TTY_FAX
486 T30_s
*fax
; /* pointer to fax data in LL */
487 eicon_ch_fax_buf fax2
; /* fax related struct */
489 entity e
; /* Entity */
490 char cpn
[32]; /* remember cpn */
491 char oad
[32]; /* remember oad */
492 unsigned char cause
[2]; /* Last Cause */
501 #include "eicon_pci.h"
503 #define EICON_FLAGS_RUNNING 1 /* Cards driver activated */
504 #define EICON_FLAGS_PVALID 2 /* Cards port is valid */
505 #define EICON_FLAGS_IVALID 4 /* Cards irq is valid */
506 #define EICON_FLAGS_MVALID 8 /* Cards membase is valid */
507 #define EICON_FLAGS_LOADED 8 /* Firmware loaded */
509 #define EICON_BCH 2 /* # of channels per card */
511 /* D-Channel states */
512 #define EICON_STATE_NULL 0
513 #define EICON_STATE_ICALL 1
514 #define EICON_STATE_OCALL 2
515 #define EICON_STATE_IWAIT 3
516 #define EICON_STATE_OWAIT 4
517 #define EICON_STATE_IBWAIT 5
518 #define EICON_STATE_OBWAIT 6
519 #define EICON_STATE_BWAIT 7
520 #define EICON_STATE_BHWAIT 8
521 #define EICON_STATE_BHWAIT2 9
522 #define EICON_STATE_DHWAIT 10
523 #define EICON_STATE_DHWAIT2 11
524 #define EICON_STATE_BSETUP 12
525 #define EICON_STATE_ACTIVE 13
526 #define EICON_STATE_ICALLW 14
527 #define EICON_STATE_LISTEN 15
528 #define EICON_STATE_WMCONN 16
530 #define EICON_MAX_QUEUED 8000 /* 2 * maxbuff */
532 #define EICON_LOCK_TX 0
533 #define EICON_LOCK_RX 1
560 typedef struct msn_entry
{
563 struct msn_entry
* next
;
567 * Per card driver data
569 typedef struct eicon_card
{
570 eicon_hwif hwif
; /* Hardware dependant interface */
571 u_char ptype
; /* Protocol type (1TR6 or Euro) */
572 u_char bus
; /* Bustype (ISA, MCA, PCI) */
573 u_char type
; /* Cardtype (EICON_CTYPE_...) */
574 struct eicon_card
*qnext
; /* Pointer to next quadro adapter */
575 int Feature
; /* Protocol Feature Value */
576 struct eicon_card
*next
; /* Pointer to next device struct */
577 int myid
; /* Driver-Nr. assigned by linklevel */
578 unsigned long flags
; /* Statusflags */
579 unsigned long ilock
; /* Semaphores for IRQ-Routines */
580 struct sk_buff_head rcvq
; /* Receive-Message queue */
581 struct sk_buff_head sndq
; /* Send-Message queue */
582 struct sk_buff_head rackq
; /* Req-Ack-Message queue */
583 struct sk_buff_head sackq
; /* Data-Ack-Message queue */
584 u_char
*ack_msg
; /* Ptr to User Data in User skb */
585 __u16 need_b3ack
; /* Flag: Need ACK for current skb */
586 struct sk_buff
*sbuf
; /* skb which is currently sent */
587 struct tq_struct snd_tq
; /* Task struct for xmit bh */
588 struct tq_struct rcv_tq
; /* Task struct for rcv bh */
589 struct tq_struct ack_tq
; /* Task struct for ack bh */
591 unsigned short msgnum
; /* Message number for sending */
592 eicon_chan
* IdTable
[256]; /* Table to find entity */
595 int nchannels
; /* Number of B-Channels */
596 int ReadyInt
; /* Ready Interrupt */
597 eicon_chan
*bch
; /* B-Channel status/control */
598 char status_buf
[256]; /* Buffer for status messages */
599 char *status_buf_read
;
600 char *status_buf_write
;
601 char *status_buf_end
;
602 isdn_if interface
; /* Interface to upper layer */
603 char regname
[35]; /* Name used for request_region */
605 int mca_slot
; /* # of cards MCA slot */
609 /* -----------------------------------------------------------**
610 ** The PROTOCOL_FEATURE_STRING **
611 ** defines capabilities and **
612 ** features of the actual protocol code. It's used as a bit **
614 ** The following Bits are defined: **
615 ** -----------------------------------------------------------*/
616 #define PROTCAP_TELINDUS 0x0001 /* Telindus Variant of protocol code */
617 #define PROTCAP_MANIF 0x0002 /* Management interface implemented */
618 #define PROTCAP_V_42 0x0004 /* V42 implemented */
619 #define PROTCAP_V90D 0x0008 /* V.90D (implies up to 384k DSP code) */
620 #define PROTCAP_EXTD_FAX 0x0010 /* Extended FAX (ECM, 2D, T6, Polling) */
621 #define PROTCAP_FREE4 0x0020 /* not used */
622 #define PROTCAP_FREE5 0x0040 /* not used */
623 #define PROTCAP_FREE6 0x0080 /* not used */
624 #define PROTCAP_FREE7 0x0100 /* not used */
625 #define PROTCAP_FREE8 0x0200 /* not used */
626 #define PROTCAP_FREE9 0x0400 /* not used */
627 #define PROTCAP_FREE10 0x0800 /* not used */
628 #define PROTCAP_FREE11 0x1000 /* not used */
629 #define PROTCAP_FREE12 0x2000 /* not used */
630 #define PROTCAP_FREE13 0x4000 /* not used */
631 #define PROTCAP_EXTENSION 0x8000 /* used for future extentions */
633 #include "eicon_idi.h"
635 extern eicon_card
*cards
;
636 extern char *eicon_ctype_name
[];
639 extern __inline__
void eicon_schedule_tx(eicon_card
*card
)
641 queue_task(&card
->snd_tq
, &tq_immediate
);
642 mark_bh(IMMEDIATE_BH
);
645 extern __inline__
void eicon_schedule_rx(eicon_card
*card
)
647 queue_task(&card
->rcv_tq
, &tq_immediate
);
648 mark_bh(IMMEDIATE_BH
);
651 extern __inline__
void eicon_schedule_ack(eicon_card
*card
)
653 queue_task(&card
->ack_tq
, &tq_immediate
);
654 mark_bh(IMMEDIATE_BH
);
657 extern char *eicon_find_eaz(eicon_card
*, char);
658 extern int eicon_addcard(int, int, int, char *);
659 extern void eicon_io_transmit(eicon_card
*card
);
660 extern void eicon_irq(int irq
, void *dev_id
, struct pt_regs
*regs
);
661 extern void eicon_io_rcv_dispatch(eicon_card
*ccard
);
662 extern void eicon_io_ack_dispatch(eicon_card
*ccard
);
663 extern int eicon_get_xlog(eicon_card
*card
, xlogreq_t
*xlogreq
);
665 extern int eicon_mca_find_card(int, int, int, char *);
666 extern int eicon_mca_probe(int, int, int, int, char *);
667 extern int eicon_info(char *, int , void *);
668 #endif /* CONFIG_MCA */
670 extern ulong DebugVar
;
672 #endif /* __KERNEL__ */