Commit 4559dc4a authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Un-virtualize D-channel access in w6692.c

The D-channel access functions are only used in w6692.c itself,
so no need to go through function pointers.
parent ce740771
...@@ -45,6 +45,30 @@ const char *w6692_revision = "$Revision: 1.12.6.6 $"; ...@@ -45,6 +45,30 @@ const char *w6692_revision = "$Revision: 1.12.6.6 $";
#define DBUSY_TIMER_VALUE 80 #define DBUSY_TIMER_VALUE 80
static inline u8
w6692_read_reg(struct IsdnCardState *cs, u8 offset)
{
return (inb(cs->hw.w6692.iobase + offset));
}
static inline void
w6692_write_reg(struct IsdnCardState *cs, u8 offset, u8 value)
{
outb(value, cs->hw.w6692.iobase + offset);
}
static inline void
w6692_read_fifo(struct IsdnCardState *cs, u8 * data, int size)
{
insb(cs->hw.w6692.iobase + W_D_RFIFO, data, size);
}
static inline void
w6692_write_fifo(struct IsdnCardState *cs, u8 * data, int size)
{
outsb(cs->hw.w6692.iobase + W_D_XFIFO, data, size);
}
static inline u8 static inline u8
w6692_bc_read_reg(struct IsdnCardState *cs, int bchan, u8 offset) w6692_bc_read_reg(struct IsdnCardState *cs, int bchan, u8 offset)
{ {
...@@ -66,7 +90,7 @@ W6692Version(struct IsdnCardState *cs, char *s) ...@@ -66,7 +90,7 @@ W6692Version(struct IsdnCardState *cs, char *s)
{ {
int val; int val;
val = cs->readW6692(cs, W_D_RBCH); val = w6692_read_reg(cs, W_D_RBCH);
printk(KERN_INFO "%s Winbond W6692 version (%x): %s\n", s, val, W6692Ver[(val >> 6) & 3]); printk(KERN_INFO "%s Winbond W6692 version (%x): %s\n", s, val, W6692Ver[(val >> 6) & 3]);
} }
...@@ -75,7 +99,7 @@ ph_command(struct IsdnCardState *cs, unsigned int command) ...@@ -75,7 +99,7 @@ ph_command(struct IsdnCardState *cs, unsigned int command)
{ {
if (cs->debug & L1_DEB_ISAC) if (cs->debug & L1_DEB_ISAC)
debugl1(cs, "ph_command %x", command); debugl1(cs, "ph_command %x", command);
cs->writeisac(cs, W_CIX, command); w6692_write_reg(cs, W_CIX, command);
} }
...@@ -156,14 +180,14 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count) ...@@ -156,14 +180,14 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
if (cs->debug & L1_DEB_WARN) if (cs->debug & L1_DEB_WARN)
debugl1(cs, "W6692_empty_fifo overrun %d", debugl1(cs, "W6692_empty_fifo overrun %d",
cs->rcvidx + count); cs->rcvidx + count);
cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK); w6692_write_reg(cs, W_D_CMDR, W_D_CMDR_RACK);
cs->rcvidx = 0; cs->rcvidx = 0;
return; return;
} }
ptr = cs->rcvbuf + cs->rcvidx; ptr = cs->rcvbuf + cs->rcvidx;
cs->rcvidx += count; cs->rcvidx += count;
cs->readW6692fifo(cs, ptr, count); w6692_read_fifo(cs, ptr, count);
cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK); w6692_write_reg(cs, W_D_CMDR, W_D_CMDR_RACK);
if (cs->debug & L1_DEB_ISAC_FIFO) { if (cs->debug & L1_DEB_ISAC_FIFO) {
char *t = cs->dlog; char *t = cs->dlog;
...@@ -183,8 +207,8 @@ W6692_fill_fifo(struct IsdnCardState *cs) ...@@ -183,8 +207,8 @@ W6692_fill_fifo(struct IsdnCardState *cs)
if (!p) if (!p)
return; return;
cs->writeW6692fifo(cs, p, count); w6692_write_fifo(cs, p, count);
cs->writeW6692(cs, W_D_CMDR, more ? W_D_CMDR_XMS : (W_D_CMDR_XMS | W_D_CMDR_XME)); w6692_write_reg(cs, W_D_CMDR, more ? W_D_CMDR_XMS : (W_D_CMDR_XMS | W_D_CMDR_XME));
if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
debugl1(cs, "W6692_fill_fifo dbusytimer running"); debugl1(cs, "W6692_fill_fifo dbusytimer running");
del_timer(&cs->dbusytimer); del_timer(&cs->dbusytimer);
...@@ -326,14 +350,14 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs) ...@@ -326,14 +350,14 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
spin_lock(&cs->lock); spin_lock(&cs->lock);
val = cs->readW6692(cs, W_ISTA); val = w6692_read_reg(cs, W_ISTA);
StartW6692: StartW6692:
if (cs->debug & L1_DEB_ISAC) if (cs->debug & L1_DEB_ISAC)
debugl1(cs, "W6692 ISTA %x", val); debugl1(cs, "W6692 ISTA %x", val);
if (val & W_INT_D_RME) { /* RME */ if (val & W_INT_D_RME) { /* RME */
exval = cs->readW6692(cs, W_D_RSTA); exval = w6692_read_reg(cs, W_D_RSTA);
if (exval & (W_D_RSTA_RDOV | W_D_RSTA_CRCE | W_D_RSTA_RMB)) { if (exval & (W_D_RSTA_RDOV | W_D_RSTA_CRCE | W_D_RSTA_RMB)) {
if (exval & W_D_RSTA_RDOV) if (exval & W_D_RSTA_RDOV)
if (cs->debug & L1_DEB_WARN) if (cs->debug & L1_DEB_WARN)
...@@ -344,9 +368,9 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs) ...@@ -344,9 +368,9 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
if (exval & W_D_RSTA_RMB) if (exval & W_D_RSTA_RMB)
if (cs->debug & L1_DEB_WARN) if (cs->debug & L1_DEB_WARN)
debugl1(cs, "W6692 D-channel ABORT"); debugl1(cs, "W6692 D-channel ABORT");
cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK | W_D_CMDR_RRST); w6692_write_reg(cs, W_D_CMDR, W_D_CMDR_RACK | W_D_CMDR_RRST);
} else { } else {
count = cs->readW6692(cs, W_D_RBCL) & (W_D_FIFO_THRESH - 1); count = w6692_read_reg(cs, W_D_RBCL) & (W_D_FIFO_THRESH - 1);
if (count == 0) if (count == 0)
count = W_D_FIFO_THRESH; count = W_D_FIFO_THRESH;
W6692_empty_fifo(cs, count); W6692_empty_fifo(cs, count);
...@@ -374,7 +398,7 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs) ...@@ -374,7 +398,7 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
debugl1(cs, "W6692 spurious XINT!"); debugl1(cs, "W6692 spurious XINT!");
} }
if (val & W_INT_D_EXI) { /* EXI */ if (val & W_INT_D_EXI) { /* EXI */
exval = cs->readW6692(cs, W_D_EXIR); exval = w6692_read_reg(cs, W_D_EXIR);
if (cs->debug & L1_DEB_WARN) if (cs->debug & L1_DEB_WARN)
debugl1(cs, "W6692 D_EXIR %02x", exval); debugl1(cs, "W6692 D_EXIR %02x", exval);
if (exval & (W_D_EXI_XDUN | W_D_EXI_XCOL)) { /* Transmit underrun/collision */ if (exval & (W_D_EXI_XDUN | W_D_EXI_XCOL)) { /* Transmit underrun/collision */
...@@ -383,18 +407,18 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs) ...@@ -383,18 +407,18 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
if (exval & W_D_EXI_RDOV) { /* RDOV */ if (exval & W_D_EXI_RDOV) { /* RDOV */
debugl1(cs, "W6692 D-channel RDOV"); debugl1(cs, "W6692 D-channel RDOV");
printk(KERN_WARNING "HiSax: W6692 D-RDOV\n"); printk(KERN_WARNING "HiSax: W6692 D-RDOV\n");
cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST); w6692_write_reg(cs, W_D_CMDR, W_D_CMDR_RRST);
} }
if (exval & W_D_EXI_TIN2) { /* TIN2 - never */ if (exval & W_D_EXI_TIN2) { /* TIN2 - never */
debugl1(cs, "W6692 spurious TIN2 interrupt"); debugl1(cs, "W6692 spurious TIN2 interrupt");
} }
if (exval & W_D_EXI_MOC) { /* MOC - not supported */ if (exval & W_D_EXI_MOC) { /* MOC - not supported */
debugl1(cs, "W6692 spurious MOC interrupt"); debugl1(cs, "W6692 spurious MOC interrupt");
v1 = cs->readW6692(cs, W_MOSR); v1 = w6692_read_reg(cs, W_MOSR);
debugl1(cs, "W6692 MOSR %02x", v1); debugl1(cs, "W6692 MOSR %02x", v1);
} }
if (exval & W_D_EXI_ISC) { /* ISC - Level1 change */ if (exval & W_D_EXI_ISC) { /* ISC - Level1 change */
v1 = cs->readW6692(cs, W_CIR); v1 = w6692_read_reg(cs, W_CIR);
if (cs->debug & L1_DEB_ISAC) if (cs->debug & L1_DEB_ISAC)
debugl1(cs, "W6692 ISC CIR=0x%02X", v1); debugl1(cs, "W6692 ISC CIR=0x%02X", v1);
if (v1 & W_CIR_ICC) { if (v1 & W_CIR_ICC) {
...@@ -404,7 +428,7 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs) ...@@ -404,7 +428,7 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
sched_d_event(cs, D_L1STATECHANGE); sched_d_event(cs, D_L1STATECHANGE);
} }
if (v1 & W_CIR_SCC) { if (v1 & W_CIR_SCC) {
v1 = cs->readW6692(cs, W_SQR); v1 = w6692_read_reg(cs, W_SQR);
debugl1(cs, "W6692 SCC SQR=0x%02X", v1); debugl1(cs, "W6692 SCC SQR=0x%02X", v1);
} }
} }
...@@ -423,14 +447,14 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs) ...@@ -423,14 +447,14 @@ W6692_interrupt(int intno, void *dev_id, struct pt_regs *regs)
debugl1(cs, "W6692 B channel 2 interrupt"); debugl1(cs, "W6692 B channel 2 interrupt");
W6692B_interrupt(cs, 1); W6692B_interrupt(cs, 1);
} }
val = cs->readW6692(cs, W_ISTA); val = w6692_read_reg(cs, W_ISTA);
if (val && icnt) { if (val && icnt) {
icnt--; icnt--;
goto StartW6692; goto StartW6692;
} }
if (!icnt) { if (!icnt) {
printk(KERN_WARNING "W6692 IRQ LOOP\n"); printk(KERN_WARNING "W6692 IRQ LOOP\n");
cs->writeW6692(cs, W_IMASK, 0xff); w6692_write_reg(cs, W_IMASK, 0xff);
} }
spin_unlock(&cs->lock); spin_unlock(&cs->lock);
} }
...@@ -512,8 +536,8 @@ dbusy_timer_handler(struct IsdnCardState *cs) ...@@ -512,8 +536,8 @@ dbusy_timer_handler(struct IsdnCardState *cs)
int rbch, star; int rbch, star;
if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
rbch = cs->readW6692(cs, W_D_RBCH); rbch = w6692_read_reg(cs, W_D_RBCH);
star = cs->readW6692(cs, W_D_STAR); star = w6692_read_reg(cs, W_D_STAR);
if (cs->debug) if (cs->debug)
debugl1(cs, "D-Channel Busy D_RBCH %02x D_STAR %02x", debugl1(cs, "D-Channel Busy D_RBCH %02x D_STAR %02x",
rbch, star); rbch, star);
...@@ -535,7 +559,7 @@ dbusy_timer_handler(struct IsdnCardState *cs) ...@@ -535,7 +559,7 @@ dbusy_timer_handler(struct IsdnCardState *cs)
printk(KERN_WARNING "HiSax: W6692 D-Channel Busy no skb\n"); printk(KERN_WARNING "HiSax: W6692 D-Channel Busy no skb\n");
debugl1(cs, "D-Channel Busy no skb"); debugl1(cs, "D-Channel Busy no skb");
} }
cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST); /* Transmitter reset */ w6692_write_reg(cs, W_D_CMDR, W_D_CMDR_XRST); /* Transmitter reset */
cs->irq_func(cs->irq, cs, NULL); cs->irq_func(cs->irq, cs, NULL);
} }
} }
...@@ -672,23 +696,23 @@ setstack_w6692(struct PStack *st, struct BCState *bcs) ...@@ -672,23 +696,23 @@ setstack_w6692(struct PStack *st, struct BCState *bcs)
void resetW6692(struct IsdnCardState *cs) void resetW6692(struct IsdnCardState *cs)
{ {
cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST); w6692_write_reg(cs, W_D_CTL, W_D_CTL_SRST);
schedule_timeout((10*HZ)/1000); schedule_timeout((10*HZ)/1000);
cs->writeW6692(cs, W_D_CTL, 0x00); w6692_write_reg(cs, W_D_CTL, 0x00);
schedule_timeout((10*HZ)/1000); schedule_timeout((10*HZ)/1000);
cs->writeW6692(cs, W_IMASK, 0xff); w6692_write_reg(cs, W_IMASK, 0xff);
cs->writeW6692(cs, W_D_SAM, 0xff); w6692_write_reg(cs, W_D_SAM, 0xff);
cs->writeW6692(cs, W_D_TAM, 0xff); w6692_write_reg(cs, W_D_TAM, 0xff);
cs->writeW6692(cs, W_D_EXIM, 0x00); w6692_write_reg(cs, W_D_EXIM, 0x00);
cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT); w6692_write_reg(cs, W_D_MODE, W_D_MODE_RACT);
cs->writeW6692(cs, W_IMASK, 0x18); w6692_write_reg(cs, W_IMASK, 0x18);
if (cs->subtyp == W6692_USR) { if (cs->subtyp == W6692_USR) {
/* seems that USR implemented some power control features /* seems that USR implemented some power control features
* Pin 79 is connected to the oscilator circuit so we * Pin 79 is connected to the oscilator circuit so we
* have to handle it here * have to handle it here
*/ */
cs->writeW6692(cs, W_PCTL, 0x80); w6692_write_reg(cs, W_PCTL, 0x80);
cs->writeW6692(cs, W_XDATA, 0x00); w6692_write_reg(cs, W_XDATA, 0x00);
} }
} }
...@@ -716,41 +740,15 @@ void __init initW6692(struct IsdnCardState *cs, int part) ...@@ -716,41 +740,15 @@ void __init initW6692(struct IsdnCardState *cs, int part)
} }
if (part & 2) { if (part & 2) {
/* Reenable all IRQ */ /* Reenable all IRQ */
cs->writeW6692(cs, W_IMASK, 0x18); w6692_write_reg(cs, W_IMASK, 0x18);
cs->writeW6692(cs, W_D_EXIM, 0x00); w6692_write_reg(cs, W_D_EXIM, 0x00);
w6692_bc_write_reg(cs, 0, W_B_EXIM, 0x00); w6692_bc_write_reg(cs, 0, W_B_EXIM, 0x00);
w6692_bc_write_reg(cs, 1, W_B_EXIM, 0x00); w6692_bc_write_reg(cs, 1, W_B_EXIM, 0x00);
/* Reset D-chan receiver and transmitter */ /* Reset D-chan receiver and transmitter */
cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST | W_D_CMDR_XRST); w6692_write_reg(cs, W_D_CMDR, W_D_CMDR_RRST | W_D_CMDR_XRST);
} }
} }
/* Interface functions */
static u_char
ReadW6692(struct IsdnCardState *cs, u_char offset)
{
return (inb(cs->hw.w6692.iobase + offset));
}
static void
WriteW6692(struct IsdnCardState *cs, u_char offset, u_char value)
{
outb(value, cs->hw.w6692.iobase + offset);
}
static void
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
insb(cs->hw.w6692.iobase + W_D_RFIFO, data, size);
}
static void
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
outsb(cs->hw.w6692.iobase + W_D_XFIFO, data, size);
}
static int static int
w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg) w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{ {
...@@ -759,10 +757,10 @@ w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg) ...@@ -759,10 +757,10 @@ w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg)
resetW6692(cs); resetW6692(cs);
return (0); return (0);
case CARD_RELEASE: case CARD_RELEASE:
cs->writeW6692(cs, W_IMASK, 0xff); w6692_write_reg(cs, W_IMASK, 0xff);
release_region(cs->hw.w6692.iobase, 256); release_region(cs->hw.w6692.iobase, 256);
if (cs->subtyp == W6692_USR) { if (cs->subtyp == W6692_USR) {
cs->writeW6692(cs, W_XDATA, 0x04); w6692_write_reg(cs, W_XDATA, 0x04);
} }
return (0); return (0);
case CARD_INIT: case CARD_INIT:
...@@ -864,20 +862,16 @@ setup_w6692(struct IsdnCard *card) ...@@ -864,20 +862,16 @@ setup_w6692(struct IsdnCard *card)
id_list[cs->subtyp].card_name, cs->irq, id_list[cs->subtyp].card_name, cs->irq,
cs->hw.w6692.iobase); cs->hw.w6692.iobase);
cs->readW6692 = &ReadW6692;
cs->writeW6692 = &WriteW6692;
cs->readisacfifo = &ReadISACfifo;
cs->writeisacfifo = &WriteISACfifo;
cs->BC_Send_Data = &W6692B_fill_fifo; cs->BC_Send_Data = &W6692B_fill_fifo;
cs->DC_Send_Data = &W6692_fill_fifo; cs->DC_Send_Data = &W6692_fill_fifo;
cs->cardmsg = &w6692_card_msg; cs->cardmsg = &w6692_card_msg;
cs->irq_func = &W6692_interrupt; cs->irq_func = &W6692_interrupt;
cs->irq_flags |= SA_SHIRQ; cs->irq_flags |= SA_SHIRQ;
W6692Version(cs, "W6692:"); W6692Version(cs, "W6692:");
printk(KERN_INFO "W6692 ISTA=0x%X\n", ReadW6692(cs, W_ISTA)); printk(KERN_INFO "W6692 ISTA=0x%X\n", w6692_read_reg(cs, W_ISTA));
printk(KERN_INFO "W6692 IMASK=0x%X\n", ReadW6692(cs, W_IMASK)); printk(KERN_INFO "W6692 IMASK=0x%X\n", w6692_read_reg(cs, W_IMASK));
printk(KERN_INFO "W6692 D_EXIR=0x%X\n", ReadW6692(cs, W_D_EXIR)); printk(KERN_INFO "W6692 D_EXIR=0x%X\n", w6692_read_reg(cs, W_D_EXIR));
printk(KERN_INFO "W6692 D_EXIM=0x%X\n", ReadW6692(cs, W_D_EXIM)); printk(KERN_INFO "W6692 D_EXIM=0x%X\n", w6692_read_reg(cs, W_D_EXIM));
printk(KERN_INFO "W6692 D_RSTA=0x%X\n", ReadW6692(cs, W_D_RSTA)); printk(KERN_INFO "W6692 D_RSTA=0x%X\n", w6692_read_reg(cs, W_D_RSTA));
return (1); return (1);
} }
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