/* $Id: hfc_2bds0.c,v 1.18.2.6 2004/02/11 13:21:33 keil Exp $
*
* specific routines for CCD's HFC 2BDS0
*
* Author Karsten Keil
* Copyright by Karsten Keil <keil@isdn4linux.de>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
*/
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include "hisax.h"
#include "hfc_2bds0.h"
#include "isdnl1.h"
#include <linux/interrupt.h>
/*
#define KDEBUG_DEF
#include "kdebug.h"
*/
#define byteout(addr,val) outb(val,addr)
#define bytein(addr) inb(addr)
static void
dummyf(struct IsdnCardState *cs, u_char * data, int size)
{
printk(KERN_WARNING "HiSax: hfcd dummy fifo called\n");
}
static inline u_char
ReadReg(struct IsdnCardState *cs, int data, u_char reg)
{
register u_char ret;
if (data) {
if (cs->hw.hfcD.cip != reg) {
cs->hw.hfcD.cip = reg;
byteout(cs->hw.hfcD.addr | 1, reg);
}
ret = bytein(cs->hw.hfcD.addr);
#ifdef HFC_REG_DEBUG
if (cs->debug & L1_DEB_HSCX_FIFO && (data != 2))
debugl1(cs, "t3c RD %02x %02x", reg, ret);
#endif
} else
ret = bytein(cs->hw.hfcD.addr | 1);
return (ret);
}
static inline void
WriteReg(struct IsdnCardState *cs, int data, u_char reg, u_char value)
{
if (cs->hw.hfcD.cip != reg) {
cs->hw.hfcD.cip = reg;
byteout(cs->hw.hfcD.addr | 1, reg);
}
if (data)
byteout(cs->hw.hfcD.addr, value);
#ifdef HFC_REG_DEBUG
if (cs->debug & L1_DEB_HSCX_FIFO && (data != HFCD_DATA_NODEB))
debugl1(cs, "t3c W%c %02x %02x", data ? 'D' : 'C', reg, value);
#endif
}
/* Interface functions */
static u_char
readreghfcd(struct IsdnCardState *cs, u_char offset)
{
return(ReadReg(cs, HFCD_DATA, offset));
}
static void
writereghfcd(struct IsdnCardState *cs, u_char offset, u_char value)
{
WriteReg(cs, HFCD_DATA, offset, value);
}
static inline int
WaitForBusy(struct IsdnCardState *cs)
{
int to = 130;
while (!(ReadReg(cs, HFCD_DATA, HFCD_STAT) & HFCD_BUSY) && to) {
udelay(1);
to--;
}
if (!to)
printk(KERN_WARNING "HiSax: WaitForBusy timeout\n");
return (to);
}
static inline int
WaitNoBusy(struct IsdnCardState *cs)
{
int to = 130;
while ((ReadReg(cs, HFCD_STATUS, HFCD_STATUS) & HFCD_BUSY) && to) {
udelay(1);
to--;
}
if (!to)
printk(KERN_WARNING "HiSax: WaitNoBusy timeout\n");
return (to);
}
static int
SelFiFo(struct IsdnCardState *cs, u_char FiFo)
{
u_char cip;
if (cs->hw.hfcD.fifo == FiFo)
return(1);
switch(FiFo) {
case 0: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B1;
break;
case 1: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B1;
break;