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