Commit f7f26550 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Helper functions for B-Channel {read,write}_reg()

As a preparation for moving the B-Channel access functions into
a ops struct, introduce inline helper functions for using them.
parent 9f1961aa
......@@ -144,7 +144,7 @@ SelFiFo(struct IsdnCardState *cs, u_char FiFo)
}
cs->hw.hfcD.fifo = FiFo;
WaitNoBusy(cs);
cs->BC_Write_Reg(cs, HFCD_DATA, cip, 0);
WriteReg(cs, HFCD_DATA, cip, 0);
WaitForBusy(cs);
return(2);
}
......
......@@ -17,14 +17,26 @@
#include "isdnl1.h"
#include <linux/interrupt.h>
static inline u8
hfc_read_reg(struct IsdnCardState *cs, int data, u8 reg)
{
return cs->BC_Read_Reg(cs, data, reg);
}
static inline void
hfc_write_reg(struct IsdnCardState *cs, int data, u8 reg, u8 val)
{
cs->BC_Write_Reg(cs, data, reg, val);
}
static inline int
WaitForBusy(struct IsdnCardState *cs)
{
int to = 130;
u_char val;
while (!(cs->BC_Read_Reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
val = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2 |
while (!(hfc_read_reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
val = hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F2 |
(cs->hw.hfc.cip & 3));
udelay(1);
to--;
......@@ -41,7 +53,7 @@ WaitNoBusy(struct IsdnCardState *cs)
{
int to = 125;
while ((cs->BC_Read_Reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
while ((hfc_read_reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
udelay(1);
to--;
}
......@@ -72,9 +84,9 @@ ReadZReg(struct BCState *bcs, u_char reg)
int val;
WaitNoBusy(bcs->cs);
val = 256 * bcs->cs->BC_Read_Reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_HIGH);
val = 256 * hfc_read_reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_HIGH);
WaitNoBusy(bcs->cs);
val += bcs->cs->BC_Read_Reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_LOW);
val += hfc_read_reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_LOW);
return (val);
}
......@@ -91,14 +103,14 @@ hfc_clear_fifo(struct BCState *bcs)
cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
hfc_write_reg(cs, HFC_STATUS, cip, cip);
WaitForBusy(cs);
}
WaitNoBusy(cs);
f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
f1 = hfc_read_reg(cs, HFC_DATA, cip);
cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel);
WaitNoBusy(cs);
f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
f2 = hfc_read_reg(cs, HFC_DATA, cip);
z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel));
z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel));
cnt = 32;
......@@ -117,21 +129,21 @@ hfc_clear_fifo(struct BCState *bcs)
cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
idx = 0;
while ((idx < rcnt) && WaitNoBusy(cs)) {
cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
hfc_read_reg(cs, HFC_DATA_NODEB, cip);
idx++;
}
if (f1 != f2) {
WaitNoBusy(cs);
cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
HFC_CHANNEL(bcs->channel));
WaitForBusy(cs);
}
cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
WaitNoBusy(cs);
f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
f1 = hfc_read_reg(cs, HFC_DATA, cip);
cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel);
WaitNoBusy(cs);
f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
f2 = hfc_read_reg(cs, HFC_DATA, cip);
z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel));
z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel));
}
......@@ -158,9 +170,9 @@ hfc_empty_fifo(struct BCState *bcs, int count)
debugl1(cs, "hfc_empty_fifo: incoming packet too large");
cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
while ((idx++ < count) && WaitNoBusy(cs))
cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
hfc_read_reg(cs, HFC_DATA_NODEB, cip);
WaitNoBusy(cs);
stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
stat = hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
HFC_CHANNEL(bcs->channel));
WaitForBusy(cs);
return (NULL);
......@@ -170,9 +182,9 @@ hfc_empty_fifo(struct BCState *bcs, int count)
debugl1(cs, "hfc_empty_fifo: incoming packet too small");
cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
while ((idx++ < count) && WaitNoBusy(cs))
cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
hfc_read_reg(cs, HFC_DATA_NODEB, cip);
WaitNoBusy(cs);
stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
stat = hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
HFC_CHANNEL(bcs->channel));
WaitForBusy(cs);
#ifdef ERROR_STATISTIC
......@@ -191,7 +203,7 @@ hfc_empty_fifo(struct BCState *bcs, int count)
idx = 0;
cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
while ((idx < count) && WaitNoBusy(cs)) {
*ptr++ = cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
*ptr++ = hfc_read_reg(cs, HFC_DATA_NODEB, cip);
idx++;
}
if (idx != count) {
......@@ -200,7 +212,7 @@ hfc_empty_fifo(struct BCState *bcs, int count)
dev_kfree_skb_any(skb);
if (bcs->mode != L1_MODE_TRANS) {
WaitNoBusy(cs);
stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
stat = hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
HFC_CHANNEL(bcs->channel));
WaitForBusy(cs);
}
......@@ -208,11 +220,11 @@ hfc_empty_fifo(struct BCState *bcs, int count)
}
if (bcs->mode != L1_MODE_TRANS) {
WaitNoBusy(cs);
chksum = (cs->BC_Read_Reg(cs, HFC_DATA, cip) << 8);
chksum = (hfc_read_reg(cs, HFC_DATA, cip) << 8);
WaitNoBusy(cs);
chksum += cs->BC_Read_Reg(cs, HFC_DATA, cip);
chksum += hfc_read_reg(cs, HFC_DATA, cip);
WaitNoBusy(cs);
stat = cs->BC_Read_Reg(cs, HFC_DATA, cip);
stat = hfc_read_reg(cs, HFC_DATA, cip);
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hfc_empty_fifo %d chksum %x stat %x",
bcs->channel, chksum, stat);
......@@ -225,7 +237,7 @@ hfc_empty_fifo(struct BCState *bcs, int count)
#endif
}
WaitNoBusy(cs);
stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
stat = hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
HFC_CHANNEL(bcs->channel));
WaitForBusy(cs);
}
......@@ -249,15 +261,15 @@ hfc_fill_fifo(struct BCState *bcs)
cip = HFC_CIP | HFC_F1 | HFC_SEND | HFC_CHANNEL(bcs->channel);
if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
hfc_write_reg(cs, HFC_STATUS, cip, cip);
WaitForBusy(cs);
}
WaitNoBusy(cs);
if (bcs->mode != L1_MODE_TRANS) {
bcs->hw.hfc.f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
bcs->hw.hfc.f1 = hfc_read_reg(cs, HFC_DATA, cip);
cip = HFC_CIP | HFC_F2 | HFC_SEND | HFC_CHANNEL(bcs->channel);
WaitNoBusy(cs);
bcs->hw.hfc.f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
bcs->hw.hfc.f2 = hfc_read_reg(cs, HFC_DATA, cip);
bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(bcs, HFC_Z1 | HFC_SEND | HFC_CHANNEL(bcs->channel));
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hfc_fill_fifo %d f1(%d) f2(%d) z1(%x)",
......@@ -293,7 +305,7 @@ hfc_fill_fifo(struct BCState *bcs)
cip = HFC_CIP | HFC_FIFO_IN | HFC_SEND | HFC_CHANNEL(bcs->channel);
idx = 0;
while ((idx < bcs->tx_skb->len) && WaitNoBusy(cs))
cs->BC_Write_Reg(cs, HFC_DATA_NODEB, cip, bcs->tx_skb->data[idx++]);
hfc_write_reg(cs, HFC_DATA_NODEB, cip, bcs->tx_skb->data[idx++]);
if (idx != bcs->tx_skb->len) {
debugl1(cs, "FIFO Send BUSY error");
printk(KERN_WARNING "HFC S FIFO channel %d BUSY Error\n", bcs->channel);
......@@ -307,7 +319,7 @@ hfc_fill_fifo(struct BCState *bcs)
if (bcs->mode != L1_MODE_TRANS) {
WaitForBusy(cs);
WaitNoBusy(cs);
cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F1_INC | HFC_SEND | HFC_CHANNEL(bcs->channel));
hfc_read_reg(cs, HFC_DATA, HFC_CIP | HFC_F1_INC | HFC_SEND | HFC_CHANNEL(bcs->channel));
}
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
}
......@@ -327,16 +339,16 @@ main_irq_hfc(struct BCState *bcs)
count--;
cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
hfc_write_reg(cs, HFC_STATUS, cip, cip);
WaitForBusy(cs);
}
WaitNoBusy(cs);
receive = 0;
if (bcs->mode == L1_MODE_HDLC) {
f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
f1 = hfc_read_reg(cs, HFC_DATA, cip);
cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel);
WaitNoBusy(cs);
f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
f2 = hfc_read_reg(cs, HFC_DATA, cip);
if (f1 != f2) {
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hfc rec %d f1(%d) f2(%d)",
......@@ -411,7 +423,7 @@ mode_hfc(struct BCState *bcs, int mode, int bc)
break;
case (L1_MODE_TRANS):
cs->hw.hfc.ctmt &= ~(1 << bc); /* set HDLC mode */
cs->BC_Write_Reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt);
hfc_write_reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt);
hfc_clear_fifo(bcs); /* complete fifo clear */
if (bc) {
cs->hw.hfc.ctmt |= 1;
......@@ -435,7 +447,7 @@ mode_hfc(struct BCState *bcs, int mode, int bc)
}
break;
}
cs->BC_Write_Reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt);
hfc_write_reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt);
cs->writeisac(cs, ISAC_SPCR, cs->hw.hfc.isac_spcr);
if (mode == L1_MODE_HDLC)
hfc_clear_fifo(bcs);
......
......@@ -20,6 +20,18 @@ extern const char *CardType[];
static const char *hfcs_revision = "$Revision: 1.8.6.2 $";
static inline u8
hfcs_read_reg(struct IsdnCardState *cs, int data, u8 reg)
{
return cs->BC_Read_Reg(cs, data, reg);
}
static inline void
hfcs_write_reg(struct IsdnCardState *cs, int data, u8 reg, u8 val)
{
cs->BC_Write_Reg(cs, data, reg, val);
}
static void
hfcs_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
......@@ -31,8 +43,8 @@ hfcs_interrupt(int intno, void *dev_id, struct pt_regs *regs)
return;
}
if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) &
(stat = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_STAT))) {
val = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_INT_S1);
(stat = hfcs_read_reg(cs, HFCD_DATA, HFCD_STAT))) {
val = hfcs_read_reg(cs, HFCD_DATA, HFCD_INT_S1);
if (cs->debug & L1_DEB_ISAC)
debugl1(cs, "HFCS: stat(%02x) s1(%02x)", stat, val);
hfc2bds0_interrupt(cs, val);
......@@ -68,37 +80,37 @@ reset_hfcs(struct IsdnCardState *cs)
cs->hw.hfcD.cirm = HFCD_RESET;
if (cs->typ == ISDN_CTYPE_TELES3C)
cs->hw.hfcD.cirm |= HFCD_MEM8K;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset On */
hfcs_write_reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset On */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((30*HZ)/1000);
cs->hw.hfcD.cirm = 0;
if (cs->typ == ISDN_CTYPE_TELES3C)
cs->hw.hfcD.cirm |= HFCD_MEM8K;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset Off */
hfcs_write_reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset Off */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((10*HZ)/1000);
if (cs->typ == ISDN_CTYPE_TELES3C)
cs->hw.hfcD.cirm |= HFCD_INTB;
else if (cs->typ == ISDN_CTYPE_ACERP10)
cs->hw.hfcD.cirm |= HFCD_INTA;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm);
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CLKDEL, 0x0e);
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_TEST, HFCD_AUTO_AWAKE); /* S/T Auto awake */
hfcs_write_reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm);
hfcs_write_reg(cs, HFCD_DATA, HFCD_CLKDEL, 0x0e);
hfcs_write_reg(cs, HFCD_DATA, HFCD_TEST, HFCD_AUTO_AWAKE); /* S/T Auto awake */
cs->hw.hfcD.ctmt = HFCD_TIM25 | HFCD_AUTO_TIMER;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
hfcs_write_reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
cs->hw.hfcD.int_m2 = HFCD_IRQ_ENABLE;
cs->hw.hfcD.int_m1 = HFCD_INTS_B1TRANS | HFCD_INTS_B2TRANS |
HFCD_INTS_DTRANS | HFCD_INTS_B1REC | HFCD_INTS_B2REC |
HFCD_INTS_DREC | HFCD_INTS_L1STATE;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M1, cs->hw.hfcD.int_m1);
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M2, cs->hw.hfcD.int_m2);
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, HFCD_LOAD_STATE | 2); /* HFC ST 2 */
hfcs_write_reg(cs, HFCD_DATA, HFCD_INT_M1, cs->hw.hfcD.int_m1);
hfcs_write_reg(cs, HFCD_DATA, HFCD_INT_M2, cs->hw.hfcD.int_m2);
hfcs_write_reg(cs, HFCD_DATA, HFCD_STATES, HFCD_LOAD_STATE | 2); /* HFC ST 2 */
udelay(10);
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, 2); /* HFC ST 2 */
hfcs_write_reg(cs, HFCD_DATA, HFCD_STATES, 2); /* HFC ST 2 */
cs->hw.hfcD.mst_m = HFCD_MASTER;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m); /* HFC Master */
hfcs_write_reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m); /* HFC Master */
cs->hw.hfcD.sctrl = 0;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl);
hfcs_write_reg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl);
}
static int
......@@ -120,8 +132,8 @@ hfcs_card_msg(struct IsdnCardState *cs, int mt, void *arg)
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((80*HZ)/1000);
cs->hw.hfcD.ctmt |= HFCD_TIM800;
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
hfcs_write_reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
hfcs_write_reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
return(0);
case CARD_TEST:
return(0);
......
......@@ -21,6 +21,24 @@ static char *HSCXVer[] __initdata =
{"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7",
"?8", "?9", "?10", "?11", "?12", "?13", "?14", "???"};
static inline u8
hscx_read_reg(struct BCState *bcs, u8 addr)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
return cs->BC_Read_Reg(cs, hscx, addr);
}
static inline void
hscx_write_reg(struct BCState *bcs, u8 addr, u8 val)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
cs->BC_Write_Reg(cs, hscx, addr, val);
}
int __init
HscxVersion(struct IsdnCardState *cs, char *s)
{
......@@ -47,48 +65,49 @@ modehscx(struct BCState *bcs, int mode, int bc)
'A' + hscx, mode, bc);
bcs->mode = mode;
bcs->channel = bc;
cs->BC_Write_Reg(cs, hscx, HSCX_XAD1, 0xFF);
cs->BC_Write_Reg(cs, hscx, HSCX_XAD2, 0xFF);
cs->BC_Write_Reg(cs, hscx, HSCX_RAH2, 0xFF);
cs->BC_Write_Reg(cs, hscx, HSCX_XBCH, 0x0);
cs->BC_Write_Reg(cs, hscx, HSCX_RLCR, 0x0);
cs->BC_Write_Reg(cs, hscx, HSCX_CCR1,
hscx_write_reg(bcs, HSCX_XAD1, 0xFF);
hscx_write_reg(bcs, HSCX_XAD2, 0xFF);
hscx_write_reg(bcs, HSCX_RAH2, 0xFF);
hscx_write_reg(bcs, HSCX_XBCH, 0x0);
hscx_write_reg(bcs, HSCX_RLCR, 0x0);
hscx_write_reg(bcs, HSCX_CCR1,
test_bit(HW_IPAC, &cs->HW_Flags) ? 0x82 : 0x85);
cs->BC_Write_Reg(cs, hscx, HSCX_CCR2, 0x30);
cs->BC_Write_Reg(cs, hscx, HSCX_XCCR, 7);
cs->BC_Write_Reg(cs, hscx, HSCX_RCCR, 7);
hscx_write_reg(bcs, HSCX_CCR2, 0x30);
hscx_write_reg(bcs, HSCX_XCCR, 7);
hscx_write_reg(bcs, HSCX_RCCR, 7);
/* Switch IOM 1 SSI */
if (test_bit(HW_IOM1, &cs->HW_Flags) && (hscx == 0))
bc = 1 - bc;
if (bc == 0) {
cs->BC_Write_Reg(cs, hscx, HSCX_TSAX,
hscx_write_reg(bcs, HSCX_TSAX,
test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : bcs->hw.hscx.tsaxr0);
cs->BC_Write_Reg(cs, hscx, HSCX_TSAR,
hscx_write_reg(bcs, HSCX_TSAR,
test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : bcs->hw.hscx.tsaxr0);
} else {
cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, bcs->hw.hscx.tsaxr1);
cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, bcs->hw.hscx.tsaxr1);
hscx_write_reg(bcs, HSCX_TSAX, bcs->hw.hscx.tsaxr1);
hscx_write_reg(bcs, HSCX_TSAR, bcs->hw.hscx.tsaxr1);
}
switch (mode) {
case (L1_MODE_NULL):
cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, 0x1f);
cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, 0x1f);
cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x84);
break;
case (L1_MODE_TRANS):
cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0xe4);
break;
case (L1_MODE_HDLC):
cs->BC_Write_Reg(cs, hscx, HSCX_CCR1,
test_bit(HW_IPAC, &cs->HW_Flags) ? 0x8a : 0x8d);
cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x8c);
break;
case L1_MODE_NULL:
hscx_write_reg(bcs, HSCX_TSAX, 0x1f);
hscx_write_reg(bcs, HSCX_TSAR, 0x1f);
hscx_write_reg(bcs, HSCX_MODE, 0x84);
break;
case L1_MODE_TRANS:
hscx_write_reg(bcs, HSCX_MODE, 0xe4);
break;
case L1_MODE_HDLC:
hscx_write_reg(bcs, HSCX_CCR1,
test_bit(HW_IPAC, &cs->HW_Flags) ? 0x8a : 0x8d);
hscx_write_reg(bcs, HSCX_MODE, 0x8c);
break;
}
if (mode)
cs->BC_Write_Reg(cs, hscx, HSCX_CMDR, 0x41);
cs->BC_Write_Reg(cs, hscx, HSCX_ISTA, 0x00);
hscx_write_reg(bcs, HSCX_CMDR, 0x41);
hscx_write_reg(bcs, HSCX_ISTA, 0x00);
}
void
......@@ -207,32 +226,32 @@ inithscx(struct IsdnCardState *cs)
cs->bcs[1].hw.hscx.tsaxr0 = 0x2f;
cs->bcs[1].hw.hscx.tsaxr1 = 3;
val = cs->BC_Read_Reg(cs, 1, HSCX_ISTA);
val = hscx_read_reg(&cs->bcs[1], HSCX_ISTA);
debugl1(cs, "HSCX B ISTA %x", val);
if (val & 0x01) {
eval = cs->BC_Read_Reg(cs, 1, HSCX_EXIR);
eval = hscx_read_reg(&cs->bcs[1], HSCX_EXIR);
debugl1(cs, "HSCX B EXIR %x", eval);
}
if (val & 0x02) {
eval = cs->BC_Read_Reg(cs, 0, HSCX_EXIR);
eval = hscx_read_reg(&cs->bcs[0], HSCX_EXIR);
debugl1(cs, "HSCX A EXIR %x", eval);
}
val = cs->BC_Read_Reg(cs, 0, HSCX_ISTA);
val = hscx_read_reg(&cs->bcs[0], HSCX_ISTA);
debugl1(cs, "HSCX A ISTA %x", val);
val = cs->BC_Read_Reg(cs, 1, HSCX_STAR);
val = hscx_read_reg(&cs->bcs[1], HSCX_STAR);
debugl1(cs, "HSCX B STAR %x", val);
val = cs->BC_Read_Reg(cs, 0, HSCX_STAR);
val = hscx_read_reg(&cs->bcs[0], HSCX_STAR);
debugl1(cs, "HSCX A STAR %x", val);
/* disable all IRQ */
cs->BC_Write_Reg(cs, 0, HSCX_MASK, 0xFF);
cs->BC_Write_Reg(cs, 1, HSCX_MASK, 0xFF);
hscx_write_reg(&cs->bcs[0], HSCX_MASK, 0xFF);
hscx_write_reg(&cs->bcs[1], HSCX_MASK, 0xFF);
modehscx(cs->bcs, 0, 0);
modehscx(cs->bcs + 1, 0, 0);
modehscx(&cs->bcs[0], 0, 0);
modehscx(&cs->bcs[1], 0, 0);
/* Reenable all IRQ */
cs->BC_Write_Reg(cs, 0, HSCX_MASK, 0);
cs->BC_Write_Reg(cs, 1, HSCX_MASK, 0);
hscx_write_reg(&cs->bcs[0], HSCX_MASK, 0x0);
hscx_write_reg(&cs->bcs[1], HSCX_MASK, 0x0);
}
void __init
......
......@@ -53,6 +53,24 @@ static int bch_setstack(struct PStack *st, struct BCState *bcs);
static void __devinit bch_init(struct IsdnCardState *cs, int hscx);
static void __init clear_pending_ints(struct IsdnCardState *cs);
static inline u8
ipacx_bc_read_reg(struct BCState *bcs, u8 addr)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
return cs->BC_Read_Reg(cs, hscx, addr);
}
static inline void
ipacx_bc_write_reg(struct BCState *bcs, u8 addr, u8 val)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
cs->BC_Write_Reg(cs, hscx, addr, val);
}
//----------------------------------------------------------
// Issue Layer 1 command to chip
//----------------------------------------------------------
......@@ -475,7 +493,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
if (bcs->hw.hscx.rcvidx + count > HSCX_BUFMAX) {
if (cs->debug &L1_DEB_WARN)
debugl1(cs, "bch_empty_fifo() incoming packet too large");
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x80); // RMC
bcs->hw.hscx.rcvidx = 0;
return;
}
......@@ -483,8 +501,8 @@ bch_empty_fifo(struct BCState *bcs, int count)
// Read data uninterruptible
ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx;
cnt = count;
while (cnt--) *ptr++ = cs->BC_Read_Reg(cs, hscx, IPACX_RFIFOB);
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC
while (cnt--) *ptr++ = ipacx_bc_read_reg(bcs, IPACX_RFIFOB);
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x80); // RMC
ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx;
bcs->hw.hscx.rcvidx += count;
......@@ -504,9 +522,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
void
ipacx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
int more, count;
unsigned char hscx = bcs->hw.hscx.hscx;
unsigned char *p;
p = xmit_fill_fifo_b(bcs, B_FIFO_SIZE, &count, &more);
......@@ -514,9 +530,9 @@ ipacx_fill_fifo(struct BCState *bcs)
return;
while (count--)
cs->BC_Write_Reg(cs, hscx, IPACX_XFIFOB, *p++);
ipacx_bc_write_reg(bcs, IPACX_XFIFOB, *p++);
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, (more ? 0x08 : 0x0a));
ipacx_bc_write_reg(bcs, IPACX_CMDRB, (more ? 0x08 : 0x0a));
}
//----------------------------------------------------------
......@@ -526,7 +542,7 @@ ipacx_fill_fifo(struct BCState *bcs)
static void
reset_xmit(struct BCState *bcs)
{
bcs->cs->BC_Write_Reg(bcs->cs, bcs->hw.hscx.hscx, IPACX_CMDRB, 0x01); // XRES
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x01); // XRES
}
static void
......@@ -539,11 +555,11 @@ bch_int(struct IsdnCardState *cs, u_char hscx)
u_char rstab;
bcs = cs->bcs + hscx;
istab = cs->BC_Read_Reg(cs, hscx, IPACX_ISTAB);
istab = ipacx_bc_read_reg(bcs, IPACX_ISTAB);
if (!test_bit(BC_FLG_INIT, &bcs->Flag)) return;
if (istab &0x80) { // RME
rstab = cs->BC_Read_Reg(cs, hscx, IPACX_RSTAB);
rstab = ipacx_bc_read_reg(bcs, IPACX_RSTAB);
if ((rstab &0xf0) != 0xa0) { // !(VFR && !RDO && CRC && !RAB)
if (!(rstab &0x80))
if (cs->debug &L1_DEB_WARN)
......@@ -554,10 +570,10 @@ bch_int(struct IsdnCardState *cs, u_char hscx)
if (!(rstab &0x20))
if (cs->debug &L1_DEB_WARN)
debugl1(cs, "bch_int() B-%d: CRC error", hscx);
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x80); // RMC
}
else { // received frame ok
count = cs->BC_Read_Reg(cs, hscx, IPACX_RBCLB) &(B_FIFO_SIZE-1);
count = ipacx_bc_read_reg(bcs, IPACX_RBCLB) &(B_FIFO_SIZE-1);
if (count == 0) count = B_FIFO_SIZE;
bch_empty_fifo(bcs, count);
if ((count = bcs->hw.hscx.rcvidx - 1) > 0) {
......@@ -594,7 +610,7 @@ bch_int(struct IsdnCardState *cs, u_char hscx)
if (istab &0x20) { // RFO
if (cs->debug &L1_DEB_WARN)
debugl1(cs, "bch_int() B-%d: RFO error", hscx);
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x40); // RRES
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x40); // RRES
}
if (istab &0x10) { // XPR
......@@ -634,22 +650,22 @@ bch_mode(struct BCState *bcs, int mode, int bc)
switch (mode) {
case (L1_MODE_NULL):
cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0xC0); // rec off
cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x30); // std adj.
cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, 0xFF); // ints off
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments
ipacx_bc_write_reg(bcs, IPACX_MODEB, 0xC0); // rec off
ipacx_bc_write_reg(bcs, IPACX_EXMB, 0x30); // std adj.
ipacx_bc_write_reg(bcs, IPACX_MASKB, 0xFF); // ints off
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x41); // validate adjustments
break;
case (L1_MODE_TRANS):
cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0x88); // ext transp mode
cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x00); // xxx00000
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments
cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, _MASKB_IMASK);
ipacx_bc_write_reg(bcs, IPACX_MODEB, 0x88); // ext transp mode
ipacx_bc_write_reg(bcs, IPACX_EXMB, 0x00); // xxx00000
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x41); // validate adjustments
ipacx_bc_write_reg(bcs, IPACX_MASKB, _MASKB_IMASK);
break;
case (L1_MODE_HDLC):
cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0xC8); // transp mode 0
cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x01); // idle=hdlc flags crc enabled
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments
cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, _MASKB_IMASK);
ipacx_bc_write_reg(bcs, IPACX_MODEB, 0xC8); // transp mode 0
ipacx_bc_write_reg(bcs, IPACX_EXMB, 0x01); // idle=hdlc flags crc enabled
ipacx_bc_write_reg(bcs, IPACX_CMDRB, 0x41); // validate adjustments
ipacx_bc_write_reg(bcs, IPACX_MASKB, _MASKB_IMASK);
break;
}
}
......@@ -770,9 +786,9 @@ clear_pending_ints(struct IsdnCardState *cs)
// all interrupts off
cs->writeisac(cs, IPACX_MASK, 0xff);
cs->writeisac(cs, IPACX_MASKD, 0xff);
cs->BC_Write_Reg(cs, 0, IPACX_MASKB, 0xff);
cs->BC_Write_Reg(cs, 1, IPACX_MASKB, 0xff);
cs->writeisac(cs, IPACX_MASKD, 0xff);
cs->BC_Write_Reg(cs, 0, IPACX_MASKB, 0xff);
cs->BC_Write_Reg(cs, 1, IPACX_MASKB, 0xff);
ista = cs->readisac(cs, IPACX_ISTA);
if (ista &0x80) cs->BC_Read_Reg(cs, 0, IPACX_ISTAB);
......@@ -802,9 +818,9 @@ init_ipacx(struct IsdnCardState *cs, int part)
// reset HDLC Transmitters/receivers
cs->writeisac(cs, IPACX_CMDRD, 0x41);
cs->BC_Write_Reg(cs, 0, IPACX_CMDRB, 0x41);
cs->BC_Write_Reg(cs, 1, IPACX_CMDRB, 0x41);
ph_command(cs, IPACX_CMD_RES);
cs->BC_Write_Reg(cs, 0, IPACX_CMDRB, 0x41);
cs->BC_Write_Reg(cs, 1, IPACX_CMDRB, 0x41);
ph_command(cs, IPACX_CMD_RES);
}
}
......
......@@ -29,11 +29,24 @@ void isar_setup(struct IsdnCardState *cs);
static void isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para);
static inline void ll_deliver_faxstat(struct BCState *bcs, u_char status);
static spinlock_t isar_lock = SPIN_LOCK_UNLOCKED;
static inline u8
isar_read_reg(struct IsdnCardState *cs, int mode, u8 addr)
{
return cs->BC_Read_Reg(cs, mode, addr);
}
static inline void
isar_write_reg(struct IsdnCardState *cs, int mode, u8 addr, u8 val)
{
cs->BC_Write_Reg(cs, mode, addr, val);
}
static inline int
waitforHIA(struct IsdnCardState *cs, int timeout)
{
while ((cs->BC_Read_Reg(cs, 0, ISAR_HIA) & 1) && timeout) {
while ((isar_read_reg(cs, 0, ISAR_HIA) & 1) && timeout) {
udelay(1);
timeout--;
}
......@@ -57,13 +70,13 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
debugl1(cs, "sendmsg(%02x,%02x,%d)", his, creg, len);
#endif
spin_lock_irqsave(&isar_lock, flags);
cs->BC_Write_Reg(cs, 0, ISAR_CTRL_H, creg);
cs->BC_Write_Reg(cs, 0, ISAR_CTRL_L, len);
cs->BC_Write_Reg(cs, 0, ISAR_WADR, 0);
isar_write_reg(cs, 0, ISAR_CTRL_H, creg);
isar_write_reg(cs, 0, ISAR_CTRL_L, len);
isar_write_reg(cs, 0, ISAR_WADR, 0);
if (msg && len) {
cs->BC_Write_Reg(cs, 1, ISAR_MBOX, msg[0]);
isar_write_reg(cs, 1, ISAR_MBOX, msg[0]);
for (i=1; i<len; i++)
cs->BC_Write_Reg(cs, 2, ISAR_MBOX, msg[i]);
isar_write_reg(cs, 2, ISAR_MBOX, msg[i]);
#if DUMP_MBOXFRAME>1
if (cs->debug & L1_DEB_HSCX_FIFO) {
char tmp[256], *t;
......@@ -79,7 +92,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
}
#endif
}
cs->BC_Write_Reg(cs, 1, ISAR_HIS, his);
isar_write_reg(cs, 1, ISAR_HIS, his);
spin_unlock_irqrestore(&isar_lock, flags);
waitforHIA(cs, 10000);
return(1);
......@@ -91,11 +104,11 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
{
int i;
cs->BC_Write_Reg(cs, 1, ISAR_RADR, 0);
isar_write_reg(cs, 1, ISAR_RADR, 0);
if (msg && ireg->clsb) {
msg[0] = cs->BC_Read_Reg(cs, 1, ISAR_MBOX);
msg[0] = isar_read_reg(cs, 1, ISAR_MBOX);
for (i=1; i < ireg->clsb; i++)
msg[i] = cs->BC_Read_Reg(cs, 2, ISAR_MBOX);
msg[i] = isar_read_reg(cs, 2, ISAR_MBOX);
#if DUMP_MBOXFRAME>1
if (cs->debug & L1_DEB_HSCX_FIFO) {
char tmp[256], *t;
......@@ -111,16 +124,16 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
}
#endif
}
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
}
/* Call only with IRQ disabled !!! */
inline void
get_irq_infos(struct IsdnCardState *cs, struct isar_reg *ireg)
{
ireg->iis = cs->BC_Read_Reg(cs, 1, ISAR_IIS);
ireg->cmsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_H);
ireg->clsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_L);
ireg->iis = isar_read_reg(cs, 1, ISAR_IIS);
ireg->cmsb = isar_read_reg(cs, 1, ISAR_CTRL_H);
ireg->clsb = isar_read_reg(cs, 1, ISAR_CTRL_L);
#if DUMP_MBOXFRAME
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "rcv_mbox(%02x,%02x,%d)", ireg->iis, ireg->cmsb,
......@@ -137,7 +150,7 @@ waitrecmsg(struct IsdnCardState *cs, u_char *len,
struct isar_reg *ir = cs->bcs[0].hw.isar.reg;
while((!(cs->BC_Read_Reg(cs, 0, ISAR_IRQBIT) & ISAR_IRQSTA)) &&
while((!(isar_read_reg(cs, 0, ISAR_IRQBIT) & ISAR_IRQSTA)) &&
(timeout++ < maxdelay))
udelay(1);
if (timeout >= maxdelay) {
......@@ -163,7 +176,7 @@ ISARVersion(struct IsdnCardState *cs, char *s)
cs->cardmsg(cs, CARD_RESET, NULL);
/* disable ISAR IRQ */
cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0);
isar_write_reg(cs, 0, ISAR_IRQBIT, 0);
debug = cs->debug;
cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO);
if (!sendmsg(cs, ISAR_HIS_VNR, 0, 3, msg))
......@@ -223,7 +236,7 @@ isar_load_firmware(struct IsdnCardState *cs, u_char *buf)
}
cnt = 0;
/* disable ISAR IRQ */
cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0);
isar_write_reg(cs, 0, ISAR_IRQBIT, 0);
if (!(msg = kmalloc(256, GFP_KERNEL))) {
printk(KERN_ERR"isar_load_firmware no buffer\n");
return (1);
......@@ -342,7 +355,7 @@ isar_load_firmware(struct IsdnCardState *cs, u_char *buf)
printk(KERN_DEBUG"isar start dsp success\n");
/* NORMAL mode entered */
/* Enable IRQs of ISAR */
cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, ISAR_IRQSTA);
isar_write_reg(cs, 0, ISAR_IRQBIT, ISAR_IRQSTA);
cnt = 1000; /* max 1s */
while ((!ireg->bstat) && cnt) {
udelay(1000);
......@@ -413,7 +426,7 @@ isar_load_firmware(struct IsdnCardState *cs, u_char *buf)
cs->debug = debug;
if (ret)
/* disable ISAR IRQ */
cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0);
isar_write_reg(cs, 0, ISAR_IRQBIT, 0);
kfree(msg);
kfree(tmpmsg);
return(ret);
......@@ -480,7 +493,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
if (!ireg->clsb) {
debugl1(cs, "isar zero len frame");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
return;
}
switch (bcs->mode) {
......@@ -489,7 +502,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
ireg->iis, ireg->cmsb, ireg->clsb);
printk(KERN_WARNING"isar mode 0 spurious IIS_RDATA %x/%x/%x\n",
ireg->iis, ireg->cmsb, ireg->clsb);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
break;
case L1_MODE_TRANS:
case L1_MODE_V32:
......@@ -499,14 +512,14 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
sched_b_event(bcs, B_RCVBUFREADY);
} else {
printk(KERN_WARNING "HiSax: skb out of memory\n");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
}
break;
case L1_MODE_HDLC:
if ((bcs->hw.isar.rcvidx + ireg->clsb) > HSCX_BUFMAX) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar_rcv_frame: incoming packet too large");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
bcs->hw.isar.rcvidx = 0;
} else if (ireg->cmsb & HDLC_ERROR) {
if (cs->debug & L1_DEB_WARN)
......@@ -519,7 +532,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
bcs->err_crc++;
#endif
bcs->hw.isar.rcvidx = 0;
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
} else {
if (ireg->cmsb & HDLC_FSD)
bcs->hw.isar.rcvidx = 0;
......@@ -547,7 +560,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
if (bcs->hw.isar.state != STFAX_ACTIV) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar_rcv_frame: not ACTIV");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
bcs->hw.isar.rcvidx = 0;
break;
}
......@@ -566,7 +579,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
if (ireg->cmsb & SART_NMD) { /* ABORT */
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar_rcv_frame: no more data");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
bcs->hw.isar.rcvidx = 0;
send_DLE_ETX(bcs);
sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) |
......@@ -577,7 +590,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
}
} else {
printk(KERN_WARNING "HiSax: skb out of memory\n");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
}
break;
}
......@@ -585,7 +598,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar_rcv_frame: unknown fax mode %x",
bcs->hw.isar.cmd);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
bcs->hw.isar.rcvidx = 0;
break;
}
......@@ -593,14 +606,14 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
if ((bcs->hw.isar.rcvidx + ireg->clsb) > HSCX_BUFMAX) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar_rcv_frame: incoming packet too large");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
bcs->hw.isar.rcvidx = 0;
} else if (ireg->cmsb & HDLC_ERROR) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar frame error %x len %d",
ireg->cmsb, ireg->clsb);
bcs->hw.isar.rcvidx = 0;
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
} else {
if (ireg->cmsb & HDLC_FSD)
bcs->hw.isar.rcvidx = 0;
......@@ -631,7 +644,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
if (ireg->cmsb & SART_NMD) { /* ABORT */
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "isar_rcv_frame: no more data");
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
bcs->hw.isar.rcvidx = 0;
send_DLE_ETX(bcs);
sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) |
......@@ -642,7 +655,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs)
break;
default:
printk(KERN_ERR"isar_rcv_frame mode (%x)error\n", bcs->mode);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
break;
}
}
......@@ -1151,11 +1164,11 @@ isar_int_main(struct IsdnCardState *cs)
} else {
debugl1(cs, "isar spurious IIS_RDATA %x/%x/%x",
ireg->iis, ireg->cmsb, ireg->clsb);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
}
break;
case ISAR_IIS_GSTEV:
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
ireg->bstat |= ireg->cmsb;
check_send(cs, ireg->cmsb);
break;
......@@ -1171,7 +1184,7 @@ isar_int_main(struct IsdnCardState *cs)
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "Buffer STEV dpath%d msb(%x)",
ireg->iis>>6, ireg->cmsb);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
break;
case ISAR_IIS_PSTEV:
if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) {
......@@ -1188,7 +1201,7 @@ isar_int_main(struct IsdnCardState *cs)
} else {
debugl1(cs, "isar spurious IIS_PSTEV %x/%x/%x",
ireg->iis, ireg->cmsb, ireg->clsb);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
}
break;
case ISAR_IIS_PSTRSP:
......@@ -1198,7 +1211,7 @@ isar_int_main(struct IsdnCardState *cs)
} else {
debugl1(cs, "isar spurious IIS_PSTRSP %x/%x/%x",
ireg->iis, ireg->cmsb, ireg->clsb);
cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0);
isar_write_reg(cs, 1, ISAR_IIA, 0);
}
break;
case ISAR_IIS_DIAG:
......
......@@ -20,16 +20,28 @@
static spinlock_t jade_lock = SPIN_LOCK_UNLOCKED;
static inline u8
jade_read_reg(struct IsdnCardState *cs, int jade, u8 addr)
{
return cs->BC_Read_Reg(cs, jade, addr);
}
static inline void
jade_write_reg(struct IsdnCardState *cs, int jade, u8 addr, u8 val)
{
cs->BC_Write_Reg(cs, jade, addr, val);
}
int __init
JadeVersion(struct IsdnCardState *cs, char *s)
{
int ver,i;
int to = 50;
cs->BC_Write_Reg(cs, -1, 0x50, 0x19);
jade_write_reg(cs, -1, 0x50, 0x19);
i=0;
while (to) {
udelay(1);
ver = cs->BC_Read_Reg(cs, -1, 0x60);
ver = jade_read_reg(cs, -1, 0x60);
to--;
if (ver)
break;
......@@ -41,7 +53,7 @@ JadeVersion(struct IsdnCardState *cs, char *s)
/* Wait for the JADE */
udelay(10);
/* Read version */
ver = cs->BC_Read_Reg(cs, -1, 0x60);
ver = jade_read_reg(cs, -1, 0x60);
printk(KERN_INFO "%s JADE version: %d\n", s, ver);
return (1);
}
......@@ -55,14 +67,14 @@ jade_write_indirect(struct IsdnCardState *cs, u_char reg, u_char value)
u_char ret;
spin_lock_irqsave(&jade_lock, flags);
/* Write the data */
cs->BC_Write_Reg(cs, -1, COMM_JADE+1, value);
jade_write_reg(cs, -1, COMM_JADE+1, value);
/* Say JADE we wanna write indirect reg 'reg' */
cs->BC_Write_Reg(cs, -1, COMM_JADE, reg);
jade_write_reg(cs, -1, COMM_JADE, reg);
to = 50;
/* Wait for RDY goes high */
while (to) {
udelay(1);
ret = cs->BC_Read_Reg(cs, -1, COMM_JADE);
ret = jade_read_reg(cs, -1, COMM_JADE);
to--;
if (ret & 1)
/* Got acknowledge */
......@@ -93,45 +105,45 @@ modejade(struct BCState *bcs, int mode, int bc)
bcs->mode = mode;
bcs->channel = bc;
cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (mode == L1_MODE_TRANS ? jadeMODE_TMO:0x00));
cs->BC_Write_Reg(cs, jade, jade_HDLC_CCR0, (jadeCCR0_PU|jadeCCR0_ITF));
cs->BC_Write_Reg(cs, jade, jade_HDLC_CCR1, 0x00);
jade_write_reg(cs, jade, jade_HDLC_MODE, (mode == L1_MODE_TRANS ? jadeMODE_TMO:0x00));
jade_write_reg(cs, jade, jade_HDLC_CCR0, (jadeCCR0_PU|jadeCCR0_ITF));
jade_write_reg(cs, jade, jade_HDLC_CCR1, 0x00);
jade_write_indirect(cs, jade_HDLC1SERRXPATH, 0x08);
jade_write_indirect(cs, jade_HDLC2SERRXPATH, 0x08);
jade_write_indirect(cs, jade_HDLC1SERTXPATH, 0x00);
jade_write_indirect(cs, jade_HDLC2SERTXPATH, 0x00);
cs->BC_Write_Reg(cs, jade, jade_HDLC_XCCR, 0x07);
cs->BC_Write_Reg(cs, jade, jade_HDLC_RCCR, 0x07);
jade_write_reg(cs, jade, jade_HDLC_XCCR, 0x07);
jade_write_reg(cs, jade, jade_HDLC_RCCR, 0x07);
if (bc == 0) {
cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAX, 0x00);
cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAR, 0x00);
jade_write_reg(cs, jade, jade_HDLC_TSAX, 0x00);
jade_write_reg(cs, jade, jade_HDLC_TSAR, 0x00);
} else {
cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAX, 0x04);
cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAR, 0x04);
jade_write_reg(cs, jade, jade_HDLC_TSAX, 0x04);
jade_write_reg(cs, jade, jade_HDLC_TSAR, 0x04);
}
switch (mode) {
case (L1_MODE_NULL):
cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, jadeMODE_TMO);
jade_write_reg(cs, jade, jade_HDLC_MODE, jadeMODE_TMO);
break;
case (L1_MODE_TRANS):
cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (jadeMODE_TMO|jadeMODE_RAC|jadeMODE_XAC));
jade_write_reg(cs, jade, jade_HDLC_MODE, (jadeMODE_TMO|jadeMODE_RAC|jadeMODE_XAC));
break;
case (L1_MODE_HDLC):
cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (jadeMODE_RAC|jadeMODE_XAC));
jade_write_reg(cs, jade, jade_HDLC_MODE, (jadeMODE_RAC|jadeMODE_XAC));
break;
}
if (mode) {
cs->BC_Write_Reg(cs, jade, jade_HDLC_RCMD, (jadeRCMD_RRES|jadeRCMD_RMC));
cs->BC_Write_Reg(cs, jade, jade_HDLC_XCMD, jadeXCMD_XRES);
jade_write_reg(cs, jade, jade_HDLC_RCMD, (jadeRCMD_RRES|jadeRCMD_RMC));
jade_write_reg(cs, jade, jade_HDLC_XCMD, jadeXCMD_XRES);
/* Unmask ints */
cs->BC_Write_Reg(cs, jade, jade_HDLC_IMR, 0xF8);
jade_write_reg(cs, jade, jade_HDLC_IMR, 0xF8);
}
else
/* Mask ints */
cs->BC_Write_Reg(cs, jade, jade_HDLC_IMR, 0x00);
jade_write_reg(cs, jade, jade_HDLC_IMR, 0x00);
}
static void
......@@ -245,39 +257,39 @@ initjade(struct IsdnCardState *cs)
cs->bcs[0].hw.hscx.hscx = 0;
cs->bcs[1].hw.hscx.hscx = 1;
cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
jade_write_reg(cs, 0, jade_HDLC_IMR, 0x00);
jade_write_reg(cs, 1, jade_HDLC_IMR, 0x00);
val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
val = jade_read_reg(cs, 1, jade_HDLC_ISR);
debugl1(cs, "jade B ISTA %x", val);
val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
val = jade_read_reg(cs, 0, jade_HDLC_ISR);
debugl1(cs, "jade A ISTA %x", val);
val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
val = jade_read_reg(cs, 1, jade_HDLC_STAR);
debugl1(cs, "jade B STAR %x", val);
val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
val = jade_read_reg(cs, 0, jade_HDLC_STAR);
debugl1(cs, "jade A STAR %x", val);
/* Unmask ints */
cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
jade_write_reg(cs, 0, jade_HDLC_IMR, 0xF8);
jade_write_reg(cs, 1, jade_HDLC_IMR, 0xF8);
/* Stop DSP audio tx/rx */
jade_write_indirect(cs, 0x11, 0x0f);
jade_write_indirect(cs, 0x17, 0x2f);
/* Transparent Mode, RxTx inactive, No Test, No RFS/TFS */
cs->BC_Write_Reg(cs, 0, jade_HDLC_MODE, jadeMODE_TMO);
cs->BC_Write_Reg(cs, 1, jade_HDLC_MODE, jadeMODE_TMO);
jade_write_reg(cs, 0, jade_HDLC_MODE, jadeMODE_TMO);
jade_write_reg(cs, 1, jade_HDLC_MODE, jadeMODE_TMO);
/* Power down, 1-Idle, RxTx least significant bit first */
cs->BC_Write_Reg(cs, 0, jade_HDLC_CCR0, 0x00);
cs->BC_Write_Reg(cs, 1, jade_HDLC_CCR0, 0x00);
jade_write_reg(cs, 0, jade_HDLC_CCR0, 0x00);
jade_write_reg(cs, 1, jade_HDLC_CCR0, 0x00);
/* Mask all interrupts */
cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
jade_write_reg(cs, 0, jade_HDLC_IMR, 0x00);
jade_write_reg(cs, 1, jade_HDLC_IMR, 0x00);
/* Setup host access to hdlc controller */
jade_write_indirect(cs, jade_HDLCCNTRACCESS, (jadeINDIRECT_HAH1|jadeINDIRECT_HAH2));
/* Unmask HDLC int (dont forget DSP int later on)*/
cs->BC_Write_Reg(cs, -1,jade_INT, (jadeINT_HDLC1|jadeINT_HDLC2));
jade_write_reg(cs, -1,jade_INT, (jadeINT_HDLC1|jadeINT_HDLC2));
/* once again TRANSPARENT */
modejade(cs->bcs, 0, 0);
......
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