1 #ifndef _INC_PMCC4_PRIVATE_H_
2 #define _INC_PMCC4_PRIVATE_H_
4 /*-----------------------------------------------------------------------------
7 * Copyright (C) 2005 SBE, Inc.
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 of the License, or
12 * (at your option) any later version.
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.
21 #include <linux/kernel.h>
22 #include <linux/sched.h>
23 #include <linux/spinlock.h>
24 #include <linux/interrupt.h> /* support for tasklets */
25 #include <linux/timer.h> /* support for timer */
26 #include <linux/workqueue.h>
27 #include <linux/hdlc.h>
30 #include "pmcc4_defs.h"
31 #include "pmcc4_cpld.h"
33 #include "sbe_promformat.h"
38 #define SBE_DRVR_INIT 0x0
39 #define SBE_DRVR_AVAILABLE 0x69734F4E
40 #define SBE_DRVR_DOWN 0x1
42 /******************************************************************************
43 * MUSYCC Message Descriptor - coupled to hardware implementation, the first
44 * three u_int32 must not be reordered.
49 volatile u_int32_t status
; /* Buffer Descriptor */
50 u_int32_t data
; /* Data Pointer */
51 u_int32_t next
; /* MUSYCC view of Next Pointer */
52 void *mem_token
; /* Data */
57 /*************************************************************************
58 * Private driver data structures, internal use only.
63 int gchan
; /* channel number within group/port 0-31 */
64 int channum
; /* absolute channel number 0-128 */
66 #define TX_RECOVERY_MASK 0x0f
67 #define TX_ONR_RECOVERY 0x01
68 #define TX_BUFF_RECOVERY 0x02
69 #define RX_RECOVERY_MASK 0xf0
70 #define RX_ONR_RECOVERY 0x10
72 unsigned char ch_start_rx
;
73 #define CH_START_RX_NOW 1
74 #define CH_START_RX_ONR 2
75 #define CH_START_RX_BUF 3
77 unsigned char ch_start_tx
;
78 #define CH_START_TX_1ST 1
79 #define CH_START_TX_ONR 2
80 #define CH_START_TX_BUF 3
82 char tx_full
; /* boolean */
83 short txd_free
; /* count of TX Desc available */
84 short txd_required
; /* count of TX Desc needed by mesg */
85 unsigned short rxd_num
; /* must support range up to 2000 */
86 unsigned short txd_num
; /* must support range up to 1000 */
91 UNASSIGNED
, /* AVAILABLE, NOTINUSE */
92 DOWN
, /* ASSIGNED, NOTINUSE */
93 UP
/* ASSIGNED and INUSE */
96 struct c4_port_info
*up
;
99 struct work_struct ch_work
;
102 struct mdesc
*txd_irq_srv
;
103 struct mdesc
*txd_usr_add
;
107 * FUTURE CODE MIGHT SEPARATE TIMESLOT MAP SETUPS INTO SINGLE IOCTL and
108 * REMOVE MAPS FROM CHANNEL PARAMETER STRUCTURE
111 * each byte in bitmask below represents one timeslot (bitmask[0] is for
112 * timeslot 0 and so on), each bit in the byte selects timeslot bits for
113 * this channel (0xff - whole timeslot, 0x7f - 56kbps mode)
116 u_int8_t ts_bitmask
[32];
118 spinlock_t ch_rxlock
;
119 spinlock_t ch_txlock
;
122 struct sbecom_chan_stats s
;
123 struct sbecom_chan_param p
;
125 typedef struct c4_chan_info mch_t
;
130 struct musycc_globalr
*reg
;
131 struct musycc_groupr
*regram
;
132 void *regram_saved
; /* Original malloc value may have non-2KB
133 * boundary. Need to save for use when
136 struct sbe_card_info
*up
;
139 * The workqueue is used for TX restart of ONR'd channels when in
143 struct workqueue_struct
*wq_port
; /* chan restart work queue */
144 struct semaphore sr_sem_busy
; /* service request exclusion
146 struct semaphore sr_sem_wait
; /* service request handshake
151 char group_is_set
; /* GROUP_INIT command issued to MUSYCC,
152 * otherwise SET_CHAN Ioctl fails */
154 mch_t
*chan
[MUSYCC_NCHANS
];
155 struct sbecom_port_param p
;
158 * The MUSYCC timeslot mappings are maintained within the driver and are
159 * modified and reloaded as each of a group's channels are configured.
161 u_int8_t tsm
[32]; /* tsm (time slot map) */
164 typedef struct c4_port_info mpi_t
;
167 #define COMET_OFFSET(x) (0x80000+(x)*0x10000)
168 #define EEPROM_OFFSET 0xC0000
169 #define ISPLD_OFFSET 0xD0000
171 /* iSPLD control chip registers */
172 #define ISPLD_MCSR 0x0
173 #define ISPLD_MCLK 0x1
174 #define ISPLD_LEDS 0x2
175 #define ISPLD_INTR 0x3
176 #define ISPLD_MAX 0x3
180 struct musycc_globalr
*reg
;
181 struct musycc_groupr
*regram
;
182 u_int32_t
*iqd_p
; /* pointer to dword aligned interrupt queue
184 void *iqd_p_saved
; /* Original malloc value may have non-dword
185 * aligned boundary. Need to save for use
187 unsigned int iqp_headx
, iqp_tailx
;
189 struct semaphore sem_wdbusy
;/* watchdog exclusion semaphore */
190 struct watchdog wd
; /* statically allocated watchdog structure */
191 atomic_t bh_pending
; /* bh queued, but not yet running */
192 u_int32_t brd_id
; /* unique PCI ID */
193 u_int16_t hdw_bid
; /* on/board hardware ID */
194 unsigned short wdcount
;
195 unsigned char max_port
;
196 unsigned char brdno
; /* our board number */
197 unsigned char wd_notify
;
198 #define WD_NOTIFY_1TX 1
199 #define WD_NOTIFY_BUF 2
200 #define WD_NOTIFY_ONR 4
201 enum /* state as regards interrupt processing */
203 C_INIT
, /* of-board-address not configured or are in
204 * process of being removed, don't access
206 C_IDLE
, /* off-board-addresses are configured, but
207 * don't service interrupts, just clear them
209 C_RUNNING
/* life is good, service away */
212 struct sbe_card_info
*next
;
213 u_int32_t
*eeprombase
; /* mapped address of board's EEPROM */
214 c4cpld_t
*cpldbase
; /* mapped address of board's CPLD hardware */
215 char *release
; /* SBE ID string w/in sbeRelease.c */
217 #ifdef CONFIG_PROC_FS
218 struct proc_dir_entry
*dir_dev
;
221 /* saved off interface assignments which bound a board */
222 hdlc_device
*first_if
;
223 hdlc_device
*last_if
;
224 short first_channum
, last_channum
;
228 u_int32_t this_status_new
;
229 u_int32_t last_status_new
;
230 u_int32_t drvr_intr_thcount
;
231 u_int32_t drvr_intr_bhcount
;
232 u_int32_t drvr_int_failure
;
235 mpi_t port
[MUSYCC_NPORTS
];
236 char devname
[SBE_IFACETMPL_SIZE
+ 1];
238 u_int32_t alarmed
[4]; /* dpm211 */
240 #if defined(SBE_ISR_TASKLET)
241 struct tasklet_struct ci_musycc_isr_tasklet
;
242 #elif defined(SBE_ISR_IMMEDIATE)
243 struct tq_struct ci_musycc_isr_tq
;
246 typedef struct sbe_card_info ci_t
;
254 u_int8_t mfg_info_sts
;
255 #define EEPROM_OK 0x00
256 #define EEPROM_CRCERR 0x01
257 char promfmt
; /* prom type, from sbe_promformat.h */
259 char devname
[SBE_IFACETMPL_SIZE
];
261 struct net_device
*ndev
;
262 struct pci_dev
*pdev
[2];
264 unsigned long addr
[2];
265 unsigned long addr_mapped
[2];
266 unsigned long len
[2];
271 FLD_TYPE1 pft1
; /* prom field, type #1 */
272 FLD_TYPE2 pft2
; /* prom field, type #2 */
275 typedef struct s_hdw_info hdw_info_t
;
277 /*****************************************************************/
282 struct sbe_card_info
*ci
;
286 /*****************************************************************/
288 extern ci_t
*c4_list
;
290 mch_t
*c4_find_chan (int);
291 int c4_set_chan (int channum
, struct sbecom_chan_param
*);
292 int c4_get_chan (int channum
, struct sbecom_chan_param
*);
293 int c4_get_chan_stats (int channum
, struct sbecom_chan_stats
*);
295 #endif /* _INC_PMCC4_PRIVATE_H_ */