summaryrefslogtreecommitdiff
path: root/xpp/xpd.h
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-03 23:06:02 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-03 23:06:02 +0000
commit2dd60aaf18e98b0e9d3c06bd9dce5f1128fa55ad (patch)
tree1a1cd28888f191e6ce83bcbbe539124e2529c90b /xpp/xpd.h
parent8c4db4e3acd9a7626e709af0494055487b589719 (diff)
xpp driver release 1.1.0 (first part of commit)
* FPGA firmware now loaded from PC (for newer models) * Driver for the FXO module * Moved most userspace files to the subdirectory utils (see also next commit) * Explicit license for firmware files * Optionally avoid auto-registration * Initializations parameters to chips given from userspace * And did I mention bugfixes? git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1021 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xpd.h')
-rw-r--r--xpp/xpd.h113
1 files changed, 60 insertions, 53 deletions
diff --git a/xpp/xpd.h b/xpp/xpd.h
index 1576274..f7efaf1 100644
--- a/xpp/xpd.h
+++ b/xpp/xpd.h
@@ -3,7 +3,7 @@
/*
* Written by Oron Peled <oron@actcom.co.il>
- * Copyright (C) 2004-2005, Xorcom
+ * Copyright (C) 2004-2006, Xorcom
*
* All rights reserved.
*
@@ -28,6 +28,7 @@
#ifdef __KERNEL__
#include <linux/kernel.h>
+#include <linux/device.h>
#include <asm/atomic.h>
#include <asm/semaphore.h>
#include <linux/moduleparam.h>
@@ -61,9 +62,9 @@
#endif // __KERNEL__
-#define MAX_SPANNAME 20
-#define MAX_SPANDESC 40
-#define MAX_CHANNAME 20
+#define MAX_SPANNAME 20 /* From zaptel.h */
+#define MAX_SPANDESC 40 /* From zaptel.h */
+#define MAX_CHANNAME 40 /* From zaptel.h */
#define XPD_NAMELEN 10 /* must be <= from maximal workqueue name */
#define XPD_DESCLEN 20
@@ -100,6 +101,9 @@ struct xbus_ops {
void (*packet_free)(xbus_t *xbus, xpacket_t *p);
};
+/*
+ * XBUS statistics counters
+ */
enum {
XBUS_N_DESC_REQ,
XBUS_N_DEV_DESC,
@@ -133,30 +137,22 @@ static struct xbus_counters {
#define XBUS_COUNTER_MAX ARRAY_SIZE(xbus_counters)
-struct xpd_sim {
- bool simulated;
- bool softloop_xpd;
- int loopto;
- xpd_type_t xpd_type;
- xpp_line_t hookstate;
-};
-
-
+/*
+ * An xbus is a transport layer for Xorcom Protocol commands
+ */
struct xbus {
char busname[XBUS_NAMELEN]; /* only xbus_new set this */
char busdesc[XBUS_DESCLEN]; /* lowlevel drivers set this */
int num;
xbus_ops_t *ops;
struct xpd *xpds[MAX_XPDS];
+ int max_packet_size;
+
+ /* Device-Model */
+ struct device the_bus;
/* Simulator data */
xbus_type_t bus_type;
-#if SOFT_SIMULATOR
- struct xpd_sim sim[MAX_XPDS];
- struct workqueue_struct *sim_workqueue;
- struct work_struct sim_work; // workqueue job for running simulator
- packet_queue_t sim_packet_queue;
-#endif
spinlock_t lock;
@@ -170,10 +166,6 @@ struct xbus {
int num_xpds;
void *priv; /* Pointer to transport level data structures */
-#ifdef XPP_PACKET_LOG
- struct cyclic_buff *packet_log;
-#endif
-
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_xbus_dir;
struct proc_dir_entry *proc_xbus_summary;
@@ -181,7 +173,6 @@ struct xbus {
/* statistics */
int counters[XBUS_COUNTER_MAX];
-
};
#endif
@@ -190,15 +181,11 @@ typedef enum xpd_direction {
TO_PSTN = 1,
} xpd_direction_t;
-#define LINE_BITS (sizeof(xpp_line_t)*8)
-
-
#ifdef __KERNEL__
-#define BIT_SET(x,i) ((x) |= (1 << (i)))
-#define BIT_CLR(x,i) ((x) &= ~(1 << (i)))
-#define IS_SET(x,i) (((x) & (1 << (i))) != 0)
-#define BIT(i) (1 << (i))
+/*
+ * XPD statistics counters
+ */
enum {
XPD_N_PCM_READ,
XPD_N_PCM_WRITE,
@@ -222,55 +209,68 @@ static struct xpd_counters {
#define XPD_COUNTER_MAX (sizeof(xpd_counters)/sizeof(xpd_counters[0]))
-enum leds {
- LED_GREEN,
- LED_RED,
- LED_BLUE,
-};
+#define LED_BLINK_PERIOD (HZ/8)
-#define NUM_LEDS 3
+#define LED_ON 1
+#define LED_OFF 0
+#define LED_BLINK (-LED_BLINK_PERIOD)
+/* Values of SLIC register 0x40 */
+enum fxs_state {
+ FXS_LINE_DISABLED = 0x00,
+ FXS_LINE_ENABLED = 0x01,
+ FXS_LINE_CID = 0x02,
+ FXS_LINE_TIPOPEN = 0x03, /* For GroundStart signalling */
+ FXS_LINE_RING = 0x04,
+ FXS_LINE_REV_ACTIVE = 0x05
+};
+
+/*
+ * An XPD is a single Xorcom Protocol Device
+ */
struct xpd {
char xpdname[XPD_NAMELEN];
struct zt_span span;
struct zt_chan *chans;
int channels;
xpd_type_t type;
+ byte revision; /* Card revision */
xpd_direction_t direction; /* TO_PHONE, TO_PSTN */
xpp_line_t enabled_chans; /* hardware activation: 0 - off, 1 - on */
- xpp_line_t hookstate; /* 0 - ONHOOK, 1 - OFHOOK */
- xpp_line_t ledstate[NUM_LEDS]; /* 0 - OFF, 1 - ON */
+ xpp_line_t no_pcm; /* Temporary: disable PCM (for USB-1) */
+ xpp_line_t hookstate; /* Actual chip state: 0 - ONHOOK, 1 - OFHOOK */
xpp_line_t digital_outputs; /* 0 - no, 1 - yes */
xpp_line_t digital_inputs; /* 0 - no, 1 - yes */
- int ringing[CHANNELS_PERXPD];
- bool ringer_on[CHANNELS_PERXPD]; /* For ring toggling */
- bool led_on[CHANNELS_PERXPD]; /* For led toggling */
- int lasttxhook[CHANNELS_PERXPD];
+ int ringing[CHANNELS_PERXPD];
+ bool ringer_on[CHANNELS_PERXPD]; /* For ring toggling */
+
+ wait_queue_head_t txstateq[CHANNELS_PERXPD]; /* waiting on the tx state to change */
+ int delay_until_dialtone[CHANNELS_PERXPD];
+
+ enum fxs_state lasttxhook[CHANNELS_PERXPD];
+ int idletxhookstate[CHANNELS_PERXPD]; /* IDLE changing hook state */
+ int ohttimer[CHANNELS_PERXPD];
- struct work_struct xpd_post_init;
- xbus_t *xbus;
+ xbus_t *xbus; /* The XBUS we are connected to */
spinlock_t lock;
- atomic_t open_counter; /* Number of open channels */
+ atomic_t open_counter; /* Number of open channels */
int flags;
- unsigned int board_flags;
-#define XPD_BOARD_LOOPBACK 1
-
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_xpd_dir;
struct proc_dir_entry *proc_xpd_summary;
struct proc_dir_entry *proc_xpd_ztregister;
#endif
- // Bit numbers of board_flags
int counters[XPD_COUNTER_MAX];
- const xops_t *xops; /* Card level operations */
- void *priv; /* Card level private data */
- atomic_t card_present;
+ const xproto_table_t *xproto; /* Card level protocol table */
+ const xops_t *xops; /* Card level operations */
+ void *priv; /* Card level private data */
+ bool card_present;
unsigned int recv_errors;
unsigned int seq_errors;
@@ -285,6 +285,13 @@ struct xpd {
u_char ec_chunk2[CHANNELS_PERXPD][ZT_CHUNKSIZE];
};
+#define for_each_line(xpd,i) \
+ for((i) = 0; (i) < (xpd)->channels; (i)++)
+
+#define for_each_enabled_line(xpd,i) \
+ for((i) = 0; (i) < (xpd)->channels; (i)++) \
+ if(IS_SET((xpd)->enabled_chans,(i)))
+
#endif
#endif /* XPD_H */