1 /* $Id: tpam.h,v 1.1.2.3 2001/11/06 20:58:30 kai Exp $
3 * Turbo PAM ISDN driver for Linux. (Kernel Driver)
5 * Copyright 2001 Stelian Pop <stelian.pop@fr.alcove.com>, AlcĂ´ve
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
10 * For all support questions please contact: <support@auvertech.fr>
17 #include <linux/isdnif.h>
18 #include <linux/init.h>
19 #include <linux/workqueue.h>
20 #include <linux/interrupt.h>
22 /* Maximum number of channels for this board */
23 #define TPAM_NBCHANNEL 30
24 /* Maximum size of data */
25 #define TPAM_MAXBUFSIZE 2032
26 /* Size of a page of board memory */
27 #define TPAM_PAGE_SIZE 0x003ffffc /* 4 MB */
28 /* Magic number present if the board was successfully started */
29 #define TPAM_MAGICNUMBER 0x2a343242
31 /* Registers in the PCI BAR0 */
32 #define TPAM_PAGE_REGISTER 0x00400000 /* Select page */
33 #define TPAM_DSPINT_REGISTER 0x00400004 /* Interrupt board */
34 #define TPAM_RESETPAM_REGISTER 0x00400008 /* Reset board */
35 #define TPAM_HINTACK_REGISTER 0x0040000c /* Ack interrupt */
36 #define TPAM_HPIC_REGISTER 0x00400014 /* Board ready */
38 /* Registers in the board memory */
39 #define TPAM_MAGICNUMBER_REGISTER 0x80008000 /* Magic number */
40 #define TPAM_EXID_REGISTER 0x80008004 /* EXID - not used */
41 #define TPAM_UPLOADPTR_REGISTER 0x80008008 /* Upload data ptr */
42 #define TPAM_DOWNLOADPTR_REGISTER 0x8000800c /* Download data ptr */
43 #define TPAM_ACKUPLOAD_REGISTER 0x80008010 /* Ack upload */
44 #define TPAM_ACKDOWNLOAD_REGISTER 0x80008014 /* Ack download */
45 #define TPAM_INTERRUPTACK_REGISTER 0x80008018 /* Ack interrupt */
47 /* Reserved areas in the board memory */
48 #define TPAM_RESERVEDAREA1_START 0x00000000
49 #define TPAM_RESERVEDAREA1_END 0x003FFFFF
50 #define TPAM_RESERVEDAREA2_START 0x01C00000
51 #define TPAM_RESERVEDAREA2_END 0x01FFFFFF
52 #define TPAM_RESERVEDAREA3_START 0x04000000
53 #define TPAM_RESERVEDAREA3_END 0x7FFFFFFF
54 #define TPAM_RESERVEDAREA4_START 0x80010000
55 #define TPAM_RESERVEDAREA4_END 0xFFFFFFFF
58 #define TPAM_NCOID_INVALID 0xffff
59 /* channel number invalid */
60 #define TPAM_CHANNEL_INVALID 0xffff
62 /* Channel structure */
63 typedef struct tpam_channel {
64 int num; /* channel number */
65 struct tpam_card *card; /* channel's card */
66 u32 ncoid; /* ncoid */
67 u8 hdlc; /* hdlc mode (set by user level) */
68 u8 realhdlc; /* hdlc mode (negociated with peer) */
69 u32 hdlcshift; /* hdlc shift */
70 u8 readytoreceive; /* channel ready to receive data */
71 struct sk_buff_head sendq; /* Send queue */
75 typedef struct tpam_card {
76 struct tpam_card *next; /* next card in list */
77 unsigned int irq; /* IRQ used by this board */
78 unsigned long bar0; /* ioremapped bar0 */
79 int id; /* id of the board */
80 isdn_if interface; /* isdn link-level pointer */
81 int channels_used; /* number of channels actually used */
82 int channels_tested; /* number of channels being tested */
83 u8 loopmode; /* board in looptest mode */
84 tpam_channel channels[TPAM_NBCHANNEL];/* channels tab */
85 int running; /* card is running */
86 int busy; /* waiting for ack from card */
87 int roundrobin; /* round robin between channels */
88 struct sk_buff_head sendq; /* send queue */
89 struct sk_buff_head recvq; /* receive queue */
90 struct work_struct send_tq; /* send task queue */
91 struct work_struct recv_tq; /* receive task queue */
92 spinlock_t lock; /* lock for the card */
95 /* Timeout waiting for signature to become available */
96 #define SIGNATURE_TIMEOUT (5*HZ)
97 /* Timeout waiting for receiving all the ACreateNCOCnf */
98 #define NCOCREATE_TIMEOUT (30*HZ)
100 /* Maximum size of the TLV block */
101 #define MPB_MAXIMUMBLOCKTLVSIZE 128
102 /* Maximum size of the data block */
103 #define MPB_MAXIMUMDATASIZE 4904
104 /* Maximum size of a phone number */
105 #define PHONE_MAXIMUMSIZE 32
107 /* Header for a sk_buff structure */
108 typedef struct skb_header {
109 u16 size; /* size of pci_mpb block + size of tlv block */
110 u16 data_size; /* size of the data block */
111 u16 ack; /* packet needs to send ack upon send */
112 u16 ack_size; /* size of data to be acknowledged upon send */
115 /* PCI message header structure */
116 typedef struct pci_mpb {
117 u16 exID; /* exID - not used */
118 u16 flags; /* flags - not used */
119 u32 errorCode; /* errorCode - not used */
120 u16 messageID; /* message ID - one of ID_XXX */
121 u16 maximumBlockTLVSize; /* MPB_MAXIMUMBLOCKTLVSIZE */
122 u16 actualBlockTLVSize; /* size of the tlv block */
123 u16 maximumDataSize; /* MPB_MAXIMUMDATASIZE */
124 u16 actualDataSize; /* size of the data block */
125 u16 dummy; /* padding */
128 /* Types of PCI messages */
129 #define ID_ACreateNCOReq 101
130 #define ID_ACreateNCOCnf 102
131 #define ID_ADestroyNCOReq 103
132 #define ID_ADestroyNCOCnf 104
133 #define ID_CConnectReq 203
134 #define ID_CConnectInd 204
135 #define ID_CConnectRsp 205
136 #define ID_CConnectCnf 206
137 #define ID_CDisconnectReq 207
138 #define ID_CDisconnectInd 208
139 #define ID_CDisconnectRsp 209
140 #define ID_CDisconnectCnf 210
141 #define ID_U3DataReq 307
142 #define ID_U3DataInd 308
143 #define ID_U3ReadyToReceiveInd 318
145 /* Parameters for the PCI message TLV block */
146 #define PAR_BearerCap 3
147 #define PAR_CalledNumber 7
148 #define PAR_CallingNumber 11
149 #define PAR_CauseToPUF 15
150 #define PAR_Cdirection 16
151 #define PAR_CompletionStatus 19
152 #define PAR_Facility 30
155 #define PAR_NCOType 50
156 #define PAR_ReadyFlag 55
157 #define PAR_U3Protocol 62
158 #define PAR_Udirection 64
160 /* Delayed statcallb structure */
161 typedef struct tpam_statcallb_data {
162 tpam_card *card; /* card issuing the statcallb */
163 struct timer_list *timer; /* timer launching the statcallb */
164 isdn_ctrl ctrl; /* isdn command */
165 } tpam_statcallb_data;
167 /* Function prototypes from tpam_main.c */
168 extern tpam_card *tpam_findcard(int);
169 extern u32 tpam_findchannel(tpam_card *, u32);
171 /* Function prototypes from tpam_memory.c */
172 extern void copy_to_pam_dword(tpam_card *, const void *, u32);
173 extern void copy_to_pam(tpam_card *, void *, const void *, u32);
174 extern u32 copy_from_pam_dword(tpam_card *, const void *);
175 extern void copy_from_pam(tpam_card *, void *, const void *, u32);
176 extern int copy_from_pam_to_user(tpam_card *, void __user *, const void *, u32);
177 extern int copy_from_user_to_pam(tpam_card *, void *, const void __user *, u32);
178 extern int tpam_verify_area(u32, u32);
180 /* Function prototypes from tpam_nco.c */
181 extern struct sk_buff *build_ACreateNCOReq(const u8 *);
182 extern struct sk_buff *build_ADestroyNCOReq(u32);
183 extern struct sk_buff *build_CConnectReq(u32, const u8 *, u8);
184 extern struct sk_buff *build_CConnectRsp(u32);
185 extern struct sk_buff *build_CDisconnectReq(u32);
186 extern struct sk_buff *build_CDisconnectRsp(u32);
187 extern struct sk_buff *build_U3DataReq(u32, void *, u16, u16, u16);
188 extern int parse_ACreateNCOCnf(struct sk_buff *, u8 *, u32 *);
189 extern int parse_ADestroyNCOCnf(struct sk_buff *, u8 *, u32 *);
190 extern int parse_CConnectCnf(struct sk_buff *, u32 *);
191 extern int parse_CConnectInd(struct sk_buff *, u32 *, u8 *, u8 *,
193 extern int parse_CDisconnectCnf(struct sk_buff *, u32 *, u32 *);
194 extern int parse_CDisconnectInd(struct sk_buff *, u32 *, u32 *);
195 extern int parse_U3ReadyToReceiveInd(struct sk_buff *, u32 *, u8 *);
196 extern int parse_U3DataInd(struct sk_buff *, u32 *, u8 **, u16 *);
198 /* Function prototypes from tpam_queues.c */
199 extern void tpam_enqueue(tpam_card *, struct sk_buff *);
200 extern void tpam_enqueue_data(tpam_channel *, struct sk_buff *);
201 extern irqreturn_t tpam_irq(int, void *, struct pt_regs *);
202 extern void tpam_recv_tq(tpam_card *);
203 extern void tpam_send_tq(tpam_card *);
205 /* Function prototypes from tpam_commands.c */
206 extern int tpam_command(isdn_ctrl *);
207 extern int tpam_writebuf_skb(int, int, int, struct sk_buff *);
208 extern void tpam_recv_ACreateNCOCnf(tpam_card *, struct sk_buff *);
209 extern void tpam_recv_ADestroyNCOCnf(tpam_card *, struct sk_buff *);
210 extern void tpam_recv_CConnectCnf(tpam_card *, struct sk_buff *);
211 extern void tpam_recv_CConnectInd(tpam_card *, struct sk_buff *);
212 extern void tpam_recv_CDisconnectInd(tpam_card *, struct sk_buff *);
213 extern void tpam_recv_CDisconnectCnf(tpam_card *, struct sk_buff *);
214 extern void tpam_recv_U3DataInd(tpam_card *, struct sk_buff *);
215 extern void tpam_recv_U3ReadyToReceiveInd(tpam_card *, struct sk_buff *);
217 /* Function prototypes from tpam_hdlc.c */
218 extern u32 tpam_hdlc_encode(u8 *, u8 *, u32 *, u32);
219 extern u32 tpam_hdlc_decode(u8 *, u8 *, u32);
221 /* Function prototypes from tpam_crcpc.c */
222 extern void init_CRC(void);
223 extern void hdlc_encode_modem(u8 *, u32, u8 *, u32 *);
224 extern void hdlc_no_accm_encode(u8 *, u32, u8 *, u32 *);
225 extern u32 hdlc_no_accm_decode(u8 *, u32);
227 /* Define this to enable debug tracing prints */
231 #define dprintk printk
233 #define dprintk while(0) printk
236 #endif /* _TPAM_H_ */