summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xhfc/xhfc.c76
-rw-r--r--xhfc/xhfc.h26
-rw-r--r--xhfc/xhfc_leb.h7
-rw-r--r--xhfc/xhfc_timers_state.c2
4 files changed, 39 insertions, 72 deletions
diff --git a/xhfc/xhfc.c b/xhfc/xhfc.c
index 3d881cc..9bcc849 100644
--- a/xhfc/xhfc.c
+++ b/xhfc/xhfc.c
@@ -35,14 +35,13 @@ module_param(sync_source, uint, S_IRUGO);
MODULE_PARM_DESC(debug, "Debug bitfield:\n"
"\t0: general\n"
- "\t1: (not used, DTMF)\n"
- "\t2: verbose register access, only if DEBUG is defined\n"
+ //"\t2: verbose register access, only if DEBUG is defined\n"
"\t3: file operations\n"
"\t4: (not used, echo canceller)\n"
"\t5: ST state\n"
"\t6: HDLC\n"
"\t7: HDLC (verbose)\n"
- "\t8: (not used, timing)\n"
+ "\t8: timing\n"
"\t9: alarms\n");
MODULE_PARM_DESC(dbg_spanfilter, "bitfield, filter debug info by span.");
MODULE_PARM_DESC(ntte, "bitfield, configuration of the physical ports. ex: 0x3 = 0 NT, 1 NT, 2 TE, 3 TE.");
@@ -51,8 +50,6 @@ MODULE_PARM_DESC(reset_gpio, "Reset the XHFC using this GPIO");
MODULE_PARM_DESC(exit_after_reset, "Exit after hard reset");
MODULE_PARM_DESC(sync_source, "Port used as a sync source for the PCM clock.");
-uint trigger = 0;
-
void xhfc_waitbusy(struct xhfc *xhfc)
{
while (read_xhfc(xhfc, R_STATUS) & M_BUSY)
@@ -288,7 +285,6 @@ void xhfc_config_data_flow(struct xhfc* x)
{
int i;
for(i = 0; i < SPANS_PER_CHIP; i++) {
- //XXX Only the D chan is supposed to work atm.
xhfc_config_d_chan_on_fifo(&x->spans[i]);
/* HFC chan, PCM slot, direction */
@@ -568,8 +564,7 @@ void xhfc_hdlc_hard_xmit(struct dahdi_chan *chan)
xhfc_span->sigchan, chan);
}
- /* Increment the hdlc_pending counter and trigger the bottom-half so
- * it will be picked up and sent. */
+ /* Increment the hdlc_pending counter and trigger hdlc_tx_frame */
if (xhfc_span->sigchan == chan)
atomic_inc(&xhfc_span->hdlc_pending);
}
@@ -614,12 +609,13 @@ irqreturn_t xhfc_interrupt(int irq, void *dev_id, struct pt_regs* ptregs)
if(atomic_read(&s->hdlc_pending))
while(hdlc_tx_frame(s))
break;
+#if 0
+ dahdi_receive(&s->span);
+ dahdi_transmit(&s->span);
+ dahdi_ec_span(&s->span);
+#endif
}
-#if 0 //XXX This is so wrong in so many ways, lol
- dahdi_receive(&s->span);
- dahdi_transmit(&s->span);
-#endif
}
r_su_irq = read_xhfc(xhfc, R_SU_IRQ);
@@ -737,6 +733,25 @@ void xhfc_init_and_configure(struct xhfc* x)
xhfc_config_data_flow(x);
}
+int xhfc_span_startup(struct dahdi_span* span)
+{
+ struct xhfc_span *xhfc_span = span->pvt;
+ struct xhfc *x = xhfc_span->xhfc;
+ if(!x->running)
+ enable_interrupts(x);
+
+ xhfc_span->running = 1;
+
+ return 0;
+}
+
+int xhfc_span_shutdown(struct dahdi_span* span)
+{
+ struct xhfc_span *xhfc_span = span->pvt;
+ xhfc_span->running = 0;
+ return 0;
+}
+
/* should configure the S/T interfaces, in hardware then software */
int xhfc_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc)
{
@@ -793,14 +808,6 @@ int xhfc_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc)
}
/* chanconfig for us means to configure the HDLC controller, if appropriate
- *
- * // Below is an irrelevant comment
- * NOTE: apparently the DAHDI ioctl function calls us with a interrupts
- * disabled. This means we cannot actually touch the hardware, because all
- * register accesses are wrapped up in a mutex that can sleep.
- *
- * The solution to that is to simply increment the span's "restart" flag, and
- * the driver's workqueue will do the dirty work on our behalf.
*/
int xhfc_chanconfig(struct dahdi_chan *chan, int sigtype)
{
@@ -849,25 +856,6 @@ int xhfc_chanconfig(struct dahdi_chan *chan, int sigtype)
return res;
}
-int xhfc_span_startup(struct dahdi_span* span)
-{
- struct xhfc_span *xhfc_span = span->pvt;
- struct xhfc *x = xhfc_span->xhfc;
- if(!x->running)
- enable_interrupts(x);
-
- xhfc_span->running = 1;
-
- return 0;
-}
-
-int xhfc_span_shutdown(struct dahdi_span* span)
-{
- struct xhfc_span *xhfc_span = span->pvt;
- xhfc_span->running = 0;
- return 0;
-}
-
static int xhfc_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data)
{
switch(cmd) {
@@ -941,17 +929,11 @@ void init_spans(struct xhfc* x)
xhfc_span->span.spanconfig = xhfc_spanconfig;
xhfc_span->span.chanconfig = xhfc_chanconfig;
xhfc_span->span.startup = xhfc_span_startup;
- xhfc_span->span.shutdown = xhfc_span_startup;
- // Well, now we kinda need a shutdown
+ xhfc_span->span.shutdown = xhfc_span_shutdown;
xhfc_span->span.ioctl = xhfc_ioctl;
xhfc_span->span.hdlc_hard_xmit = xhfc_hdlc_hard_xmit;
- /*
- if (vpmsupport && CARD_HAS_EC(b4)) //TODO echo canceller stuff
- xhfc_span->span.echocan_create = echocan_create;
- */
-
- init_waitqueue_head(&xhfc_span->span.maintq); //TODO understand this
+ init_waitqueue_head(&xhfc_span->span.maintq); /* kinda everyone does this */
/* now initialize each channel in the span */
for (j=0; j < CHANS_PER_SPAN; j++) {
diff --git a/xhfc/xhfc.h b/xhfc/xhfc.h
index ebc87c2..0d69588 100644
--- a/xhfc/xhfc.h
+++ b/xhfc/xhfc.h
@@ -29,10 +29,7 @@
#define XHFC_FMIN 0x00
#define XHFC_FMAX 0x07
-#define XHFC_T1 0
-#define XHFC_T2 1
-#define XHFC_T3 2
-#define XHFC_T4 3
+enum { XHFC_T1, XHFC_T2, XHFC_T3, XHFC_T4 };
#if (DAHDI_CHUNKSIZE != 8)
#error Sorry, the XHFC driver module does not support chunksize != 8
@@ -40,10 +37,8 @@
/* general debug messages */
#define DEBUG_GENERAL (1 << 0)
-/* emit DTMF detector messages */
-#define DEBUG_DTMF (1 << 1) //XXX not used
/* emit register read/write, but only if the kernel's DEBUG is defined */
-#define DEBUG_REGS (1 << 2) //XXX wut
+#define DEBUG_REGS (1 << 2) // not used
/* emit file operation messages */
#define DEBUG_FOPS (1 << 3)
#define DEBUG_ECHOCAN (1 << 4)
@@ -53,7 +48,7 @@
#define DEBUG_HDLC (1 << 6)
#define DEBUG_VERBOSE_HDLC (1 << 7)
/* Timing related changes */
-#define DEBUG_TIMING (1 << 8) //XXX not used?
+#define DEBUG_TIMING (1 << 8)
/* alarm changes */
#define DEBUG_ALARM (1 << 9)
@@ -102,7 +97,7 @@ struct xhfc_span {
struct dahdi_chan _chans[CHANS_PER_SPAN]; /* B1, B2, D, E */
unsigned char writechunk[CHANS_PER_SPAN * DAHDI_CHUNKSIZE];
unsigned char readchunk[CHANS_PER_SPAN * DAHDI_CHUNKSIZE];
- // Same as in DAHDI's for sameness reasons
+ /* Same as in DAHDI's for sameness reasons */
struct dahdi_span span;
int ts; /* PCM timeslot */
@@ -111,9 +106,6 @@ struct xhfc_span {
int port; /* (physical) S/T port number */
int nt; /* 1 if the port is nt, 0 if it's TE */
-// int rcv; /* number of received frames */
-// int crpt; /* number of corrupted reveived frames */
-
int running;
int shutdown;
@@ -123,8 +115,8 @@ struct xhfc_span {
unsigned long alarmtimer;
struct dahdi_chan* sigchan;
int sigactive;
- unsigned long hfc_timers[CHANS_PER_SPAN+1]; /* T1, T2, T3 */ //XXX WTF with this length?
- int hfc_timer_on[CHANS_PER_SPAN+1]; /* 1=timer active */
+ unsigned long hfc_timers[4]; /* T1, T2, T3, T4 */
+ int hfc_timer_on[4]; /* 1=timer active */
unsigned long non_rx_cnt;
};
@@ -136,8 +128,6 @@ struct xhfc {
struct xhfc_span spans[SPANS_PER_CHIP];
- //struct semaphore fifosem;
-
u8 r_pcm_md0;
/* from DAHDI */
@@ -162,8 +152,6 @@ struct xhfc_pi {
#define dchan_fifo(span) (span->port * 4 + 2)
void xhfc_config_d_chan_on_fifo(struct xhfc_span*);
-//void xhfc_hdlc_write_buf(struct xhfc* x, int fifo, u8* buf, int len);
-//int xhfc_hdlc_read_buf(struct xhfc* x, int fifo, u8* buf, int *len);
void xhfc_flush_fifo(struct xhfc* x, int fifo);
int xhfc_hdlc_init(struct xhfc* x);
int xhfc_hdlc_interrupt(struct xhfc* x);
@@ -185,4 +173,4 @@ void xhfc_shutdown(struct pci_dev *pdev);
extern uint debug;
extern uint dbg_spanfilter;
-#endif // __XHFC_HWTD_H__
+#endif
diff --git a/xhfc/xhfc_leb.h b/xhfc/xhfc_leb.h
index 472bc3d..0f300c6 100644
--- a/xhfc/xhfc_leb.h
+++ b/xhfc/xhfc_leb.h
@@ -35,23 +35,20 @@
#define IRQ_TLP_GPIO_30 31
-extern uint trigger;
-//extern uint debug;
-
void leb_init(struct xhfc_pi *leb);
static inline u8 read_xhfc(struct xhfc * xhfc, u8 reg_addr)
{
u8 __iomem *cs_n0 = xhfc->pi->cs_n0;
- return readb(&cs_n0[(trigger << 8) + reg_addr]);
+ return readb(&cs_n0[reg_addr]);
}
static inline void write_xhfc(struct xhfc * xhfc, u8 reg_addr, u8 value)
{
u8 __iomem *cs_n0 = xhfc->pi->cs_n0;
- writeb(value, &cs_n0[(trigger << 8) + reg_addr]);
+ writeb(value, &cs_n0[reg_addr]);
}
#if 0
diff --git a/xhfc/xhfc_timers_state.c b/xhfc/xhfc_timers_state.c
index 9646605..a9e8b42 100644
--- a/xhfc/xhfc_timers_state.c
+++ b/xhfc/xhfc_timers_state.c
@@ -242,7 +242,7 @@ void hfc_update_st_timers(struct xhfc *x)
hfc_timer_expire(s, j);
}
- if (/*s->span && XXX*/ s->newalarm != s->span.alarms &&
+ if (s->newalarm != s->span.alarms &&
time_after_eq(x->ticks, s->alarmtimer)) {
s->span.alarms = s->newalarm;
if ((!s->newalarm && bri_teignorered) || (!bri_teignorered))