Commit c2cacbb4 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Share some common D-channel init code

Again, just killing some duplicated code.
parent ad7f8a9b
......@@ -758,27 +758,25 @@ static u16 initAMD[] = {
0xFFFF};
static struct dc_l1_ops amd7930_l1_ops = {
.open = setstack_Amd7930,
.open = setstack_Amd7930,
.bh_func = Amd7930_bh,
.dbusy_func = dbusy_timer_handler,
};
void __devinit
Amd7930_init(struct IsdnCardState *cs)
{
u16 *ptr;
u8 cmd, cnt;
u16 *ptr;
u8 cmd, cnt;
if (cs->debug & L1_DEB_ISAC)
debugl1(cs, "Amd7930: initamd called");
dc_l1_init(cs, &amd7930_l1_ops);
cs->dc.amd7930.tx_xmtlen = 0;
cs->dc.amd7930.old_state = 0;
cs->dc.amd7930.lmr1 = 0x40;
cs->dc.amd7930.ph_command = Amd7930_ph_command;
INIT_WORK(&cs->work, Amd7930_bh, cs);
cs->dc_l1_ops = &amd7930_l1_ops;
cs->dbusytimer.function = (void *) dbusy_timer_handler;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
/* AMD Initialisation */
for (ptr = initAMD; *ptr != 0xFFFF; ) {
......
......@@ -24,6 +24,7 @@
#include <linux/kernel_stat.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#include "isdnl1.h"
#define HISAX_STATUS_BUFSIZE 4096
#define INCLUDE_INLINE_FUNCS
......@@ -1748,6 +1749,10 @@ static void hisax_bc_close(struct BCState *bcs);
static void hisax_bh(void *data);
static void EChannel_proc_rcv(struct hisax_d_if *d_if);
static struct dc_l1_ops hisax_l1_ops = {
.bh_func = hisax_bh,
};
int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
char *name, int protocol)
{
......@@ -1778,7 +1783,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
cs->hw.hisax_d_if = hisax_d_if;
cs->cardmsg = hisax_cardmsg;
cs->iif.owner = hisax_d_if->owner; // FIXME should be done before registering
INIT_WORK(&cs->work, hisax_bh, cs);
dc_l1_init(cs, &hisax_l1_ops);
cs->channel[0].d_st->l1.l2l1 = hisax_d_l2l1;
cs->bc_l1_ops->open = hisax_bc_setstack;
cs->bc_l1_ops->close = hisax_bc_close;
......
......@@ -858,20 +858,17 @@ static struct bc_l1_ops hfcd_bc_l1_ops = {
};
static struct dc_l1_ops hfcd_dc_l1_ops = {
.fill_fifo = hfc_fill_dfifo,
.open = setstack_hfcd,
.fill_fifo = hfc_fill_dfifo,
.open = setstack_hfcd,
.bh_func = hfcd_bh,
.dbusy_func = hfc_dbusy_timer,
};
void __init
init2bds0(struct IsdnCardState *cs)
{
dc_l1_init(cs, &hfcd_dc_l1_ops);
cs->bc_l1_ops = &hfcd_bc_l1_ops;
cs->dc_l1_ops = &hfcd_dc_l1_ops;
cs->dbusytimer.function = (void *) hfc_dbusy_timer;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
INIT_WORK(&cs->work, hfcd_bh, cs);
if (!cs->hw.hfcD.send)
cs->hw.hfcD.send = init_send_hfcd(16);
if (!cs->bcs[0].hw.hfc.send)
......
......@@ -1345,8 +1345,10 @@ static struct bc_l1_ops hfcpci_bc_l1_ops = {
};
static struct dc_l1_ops hfcpci_dc_l1_ops = {
.fill_fifo = hfcpci_fill_dfifo,
.open = setstack_hfcpci,
.fill_fifo = hfcpci_fill_dfifo,
.open = setstack_hfcpci,
.bh_func = hfcpci_bh,
.dbusy_func = hfcpci_dbusy_timer,
};
/********************************/
......@@ -1355,12 +1357,8 @@ static struct dc_l1_ops hfcpci_dc_l1_ops = {
void __init
inithfcpci(struct IsdnCardState *cs)
{
cs->dbusytimer.function = (void *) hfcpci_dbusy_timer;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
INIT_WORK(&cs->work, hfcpci_bh, cs);
dc_l1_init(cs, &hfcpci_dc_l1_ops);
cs->bc_l1_ops = &hfcpci_bc_l1_ops;
cs->dc_l1_ops = &hfcpci_dc_l1_ops;
mode_hfcpci(cs->bcs, 0, 0);
mode_hfcpci(cs->bcs + 1, 0, 1);
}
......
......@@ -1121,8 +1121,10 @@ static struct bc_l1_ops hfcsx_bc_l1_ops = {
};
static struct dc_l1_ops hfcsx_dc_l1_ops = {
.fill_fifo = hfcsx_fill_dfifo,
.open = setstack_hfcsx,
.fill_fifo = hfcsx_fill_dfifo,
.open = setstack_hfcsx,
.bh_func = hfcsx_bh,
.dbusy_func = hfcsx_dbusy_timer,
};
/********************************/
......@@ -1131,12 +1133,8 @@ static struct dc_l1_ops hfcsx_dc_l1_ops = {
void __devinit
inithfcsx(struct IsdnCardState *cs)
{
cs->dbusytimer.function = (void *) hfcsx_dbusy_timer;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
INIT_WORK(&cs->work, hfcsx_bh, cs);
dc_l1_init(cs, &hfcsx_dc_l1_ops);
cs->bc_l1_ops = &hfcsx_bc_l1_ops;
cs->dc_l1_ops = &hfcsx_dc_l1_ops;
mode_hfcsx(cs->bcs, 0, 0);
mode_hfcsx(cs->bcs + 1, 0, 1);
}
......
......@@ -6,6 +6,10 @@
* of the GNU General Public License, incorporated herein by reference.
*
*/
#ifndef __HISAX_H__
#define __HISAX_H__
#include <linux/config.h>
#include <linux/errno.h>
#include <linux/fs.h>
......@@ -857,7 +861,7 @@ struct card_ops {
void (*test) (struct IsdnCardState *);
int (*reset) (struct IsdnCardState *);
void (*release) (struct IsdnCardState *);
void (*aux_ind) (struct IsdnCardState *, void *arg);
void (*aux_ind) (struct IsdnCardState *, void *);
void (*irq_func) (int, void *, struct pt_regs *);
};
......@@ -892,6 +896,9 @@ struct dc_l1_ops {
void (*fill_fifo) (struct IsdnCardState *);
int (*open) (struct PStack *, struct IsdnCardState *);
void (*close) (struct IsdnCardState *);
void (*bh_func) (void *);
void (*dbusy_func) (struct IsdnCardState *);
};
#define HW_IOM1 0
......@@ -1429,3 +1436,5 @@ L4L3(struct PStack *st, int pr, void *arg)
{
st->l3.l4l3(st, pr, arg);
}
#endif
......@@ -499,9 +499,11 @@ dbusy_timer_handler(struct IsdnCardState *cs)
}
static struct dc_l1_ops icc_l1_ops = {
.fill_fifo = icc_fill_fifo,
.open = setstack_icc,
.close = DC_Close_icc,
.fill_fifo = icc_fill_fifo,
.open = setstack_icc,
.close = DC_Close_icc,
.bh_func = icc_bh,
.dbusy_func = dbusy_timer_handler,
};
void __init
......@@ -509,13 +511,9 @@ initicc(struct IsdnCardState *cs)
{
int val, eval;
cs->dc_l1_ops = &icc_l1_ops;
INIT_WORK(&cs->work, icc_bh, cs);
dc_l1_init(cs, &icc_l1_ops);
cs->dc.icc.mon_tx = NULL;
cs->dc.icc.mon_rx = NULL;
cs->dbusytimer.function = (void *) dbusy_timer_handler;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
val = icc_read_reg(cs, ICC_STAR);
debugl1(cs, "ICC STAR %x", val);
......
......@@ -402,8 +402,10 @@ dch_setstack(struct PStack *st, struct IsdnCardState *cs)
}
static struct dc_l1_ops ipacx_dc_l1_ops = {
.fill_fifo = dch_fill_fifo,
.open = dch_setstack,
.fill_fifo = dch_fill_fifo,
.open = dch_setstack,
.bh_func = dch_bh,
.dbusy_func = dbusy_timer_handler,
};
//----------------------------------------------------------
......@@ -413,11 +415,7 @@ dch_init(struct IsdnCardState *cs)
{
printk(KERN_INFO "HiSax: IPACX ISDN driver v0.1.0\n");
cs->dc_l1_ops = &ipacx_dc_l1_ops;
INIT_WORK(&cs->work, dch_bh, cs);
cs->dbusytimer.function = (void *) dbusy_timer_handler;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
dc_l1_init(cs, &ipacx_dc_l1_ops);
ipacx_write_reg(cs, IPACX_TR_CONF0, 0x00); // clear LDD
ipacx_write_reg(cs, IPACX_TR_CONF2, 0x00); // enable transmitter
......
......@@ -497,9 +497,11 @@ dbusy_timer_handler(struct IsdnCardState *cs)
}
static struct dc_l1_ops isac_l1_ops = {
.fill_fifo = isac_fill_fifo,
.open = setstack_isac,
.close = DC_Close_isac,
.fill_fifo = isac_fill_fifo,
.open = setstack_isac,
.close = DC_Close_isac,
.bh_func = isac_bh,
.dbusy_func = dbusy_timer_handler,
};
void __devinit
......@@ -507,6 +509,8 @@ initisac(struct IsdnCardState *cs)
{
int val, eval;
dc_l1_init(cs, &isac_l1_ops);
val = isac_read(cs, ISAC_STAR);
debugl1(cs, "ISAC STAR %x", val);
val = isac_read(cs, ISAC_MODE);
......@@ -522,14 +526,8 @@ initisac(struct IsdnCardState *cs)
/* Disable all IRQ */
isac_write(cs, ISAC_MASK, 0xFF);
cs->dc_l1_ops = &isac_l1_ops;
INIT_WORK(&cs->work, isac_bh, cs);
cs->dc.isac.mon_tx = NULL;
cs->dc.isac.mon_rx = NULL;
cs->dbusytimer.function = (void *) dbusy_timer_handler;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
isac_write(cs, ISAC_MASK, 0xff);
cs->dc.isac.mocr = 0xaa;
if (test_bit(HW_IOM1, &cs->HW_Flags)) {
/* IOM 1 Mode */
......
......@@ -909,6 +909,16 @@ setstack_HiSax(struct PStack *st, struct IsdnCardState *cs)
cs->dc_l1_ops->open(st, cs);
}
void
dc_l1_init(struct IsdnCardState *cs, struct dc_l1_ops *ops)
{
cs->dc_l1_ops = ops;
INIT_WORK(&cs->work, ops->bh_func, cs);
init_timer(&cs->dbusytimer);
cs->dbusytimer.function = (void *)(unsigned long) ops->dbusy_func;
cs->dbusytimer.data = (unsigned long) cs;
}
void
setstack_l1_B(struct PStack *st)
{
......
......@@ -7,6 +7,9 @@
*
*/
#ifndef __ISDNL1_H__
#define __ISDNL1_H__
#define D_RCVBUFREADY 0
#define D_XMTBUFREADY 1
#define D_L1STATECHANGE 2
......@@ -31,6 +34,8 @@ extern void DChannel_proc_rcv(struct IsdnCardState *cs);
extern void l1_msg(struct IsdnCardState *cs, int pr, void *arg);
extern void l1_msg_b(struct PStack *st, int pr, void *arg);
void dc_l1_init(struct IsdnCardState *cs, struct dc_l1_ops *ops);
static inline void
fill_fifo_b(struct BCState *bcs)
{
......@@ -588,3 +593,5 @@ bc_close(struct BCState *bcs)
clear_bit(BC_FLG_BUSY, &bcs->Flag);
}
}
#endif
......@@ -616,10 +616,6 @@ w6692_reset(struct IsdnCardState *cs)
static void
w6692_init(struct IsdnCardState *cs)
{
INIT_WORK(&cs->work, W6692_bh, cs);
cs->dbusytimer.function = (void *) dbusy_timer_handler;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
w6692_reset(cs);
ph_command(cs, W_L1CMD_RST);
cs->dc.w6692.ph_state = W_L1CMD_RST;
......@@ -662,8 +658,10 @@ static struct card_ops w6692_ops = {
};
static struct dc_l1_ops w6692_dc_l1_ops = {
.fill_fifo = W6692_fill_fifo,
.open = setstack_W6692,
.fill_fifo = W6692_fill_fifo,
.open = setstack_W6692,
.bh_func = W6692_bh,
.dbusy_func = dbusy_timer_handler,
};
static struct bc_l1_ops w6692_bc_l1_ops = {
......@@ -762,7 +760,7 @@ setup_w6692(struct IsdnCard *card)
cs->dc_hw_ops = &w6692_dc_hw_ops;
cs->bc_hw_ops = &w6692_bc_hw_ops;
cs->dc_l1_ops = &w6692_dc_l1_ops;
dc_l1_init(cs, &w6692_dc_l1_ops);
cs->bc_l1_ops = &w6692_bc_l1_ops;
cs->cardmsg = &w6692_card_msg;
cs->irq_flags |= SA_SHIRQ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment