23 #include <linux/module.h>
26 #include <linux/netdevice.h>
31 #define __debug_variable debug
34 #ifdef CONFIG_HISAX_DEBUG
38 static char *ISACVer[] = {
50 #define DBG_WARN 0x0001
51 #define DBG_IRQ 0x0002
52 #define DBG_L1M 0x0004
54 #define DBG_RFIFO 0x0100
55 #define DBG_RPACKET 0x0200
56 #define DBG_XFIFO 0x1000
57 #define DBG_XPACKET 0x2000
60 #define TYPE_ISAC 0x00
61 #define TYPE_ISACSX 0x01
64 #define ISAC_MASK 0x20
65 #define ISAC_ISTA 0x20
66 #define ISAC_ISTA_EXI 0x01
67 #define ISAC_ISTA_SIN 0x02
68 #define ISAC_ISTA_CISQ 0x04
69 #define ISAC_ISTA_XPR 0x10
70 #define ISAC_ISTA_RSC 0x20
71 #define ISAC_ISTA_RPF 0x40
72 #define ISAC_ISTA_RME 0x80
74 #define ISAC_STAR 0x21
75 #define ISAC_CMDR 0x21
76 #define ISAC_CMDR_XRES 0x01
77 #define ISAC_CMDR_XME 0x02
78 #define ISAC_CMDR_XTF 0x08
79 #define ISAC_CMDR_RRES 0x40
80 #define ISAC_CMDR_RMC 0x80
82 #define ISAC_EXIR 0x24
83 #define ISAC_EXIR_MOS 0x04
84 #define ISAC_EXIR_XDU 0x40
85 #define ISAC_EXIR_XMR 0x80
87 #define ISAC_ADF2 0x39
88 #define ISAC_SPCR 0x30
89 #define ISAC_ADF1 0x38
91 #define ISAC_CIR0 0x31
92 #define ISAC_CIX0 0x31
93 #define ISAC_CIR0_CIC0 0x02
94 #define ISAC_CIR0_CIC1 0x01
96 #define ISAC_CIR1 0x33
97 #define ISAC_CIX1 0x33
98 #define ISAC_STCR 0x37
99 #define ISAC_MODE 0x22
101 #define ISAC_RSTA 0x27
102 #define ISAC_RSTA_RDO 0x40
103 #define ISAC_RSTA_CRC 0x20
104 #define ISAC_RSTA_RAB 0x10
106 #define ISAC_RBCL 0x25
107 #define ISAC_RBCH 0x2A
108 #define ISAC_TIMR 0x23
109 #define ISAC_SQXR 0x3b
110 #define ISAC_MOSR 0x3a
111 #define ISAC_MOCR 0x3a
112 #define ISAC_MOR0 0x32
113 #define ISAC_MOX0 0x32
114 #define ISAC_MOR1 0x34
115 #define ISAC_MOX1 0x34
117 #define ISAC_RBCH_XAC 0x80
119 #define ISAC_CMD_TIM 0x0
120 #define ISAC_CMD_RES 0x1
121 #define ISAC_CMD_SSP 0x2
122 #define ISAC_CMD_SCP 0x3
123 #define ISAC_CMD_AR8 0x8
124 #define ISAC_CMD_AR10 0x9
125 #define ISAC_CMD_ARL 0xa
126 #define ISAC_CMD_DI 0xf
128 #define ISACSX_MASK 0x60
129 #define ISACSX_ISTA 0x60
130 #define ISACSX_ISTA_ICD 0x01
131 #define ISACSX_ISTA_CIC 0x10
133 #define ISACSX_MASKD 0x20
134 #define ISACSX_ISTAD 0x20
135 #define ISACSX_ISTAD_XDU 0x04
136 #define ISACSX_ISTAD_XMR 0x08
137 #define ISACSX_ISTAD_XPR 0x10
138 #define ISACSX_ISTAD_RFO 0x20
139 #define ISACSX_ISTAD_RPF 0x40
140 #define ISACSX_ISTAD_RME 0x80
142 #define ISACSX_CMDRD 0x21
143 #define ISACSX_CMDRD_XRES 0x01
144 #define ISACSX_CMDRD_XME 0x02
145 #define ISACSX_CMDRD_XTF 0x08
146 #define ISACSX_CMDRD_RRES 0x40
147 #define ISACSX_CMDRD_RMC 0x80
149 #define ISACSX_MODED 0x22
151 #define ISACSX_RBCLD 0x26
153 #define ISACSX_RSTAD 0x28
154 #define ISACSX_RSTAD_RAB 0x10
155 #define ISACSX_RSTAD_CRC 0x20
156 #define ISACSX_RSTAD_RDO 0x40
157 #define ISACSX_RSTAD_VFR 0x80
159 #define ISACSX_CIR0 0x2e
160 #define ISACSX_CIR0_CIC0 0x08
161 #define ISACSX_CIX0 0x2e
163 #define ISACSX_TR_CONF0 0x30
165 #define ISACSX_TR_CONF2 0x32
167 static struct Fsm l1fsm;
181 #define L1_STATE_COUNT (ST_L1_F8 + 1)
183 static char *strL1State[] =
188 "ST_L1_F3_PEND_DEACT",
218 #define L1_EVENT_COUNT (EV_TIMER3 + 1)
220 static char *strL1Event[] =
238 "EV_PH_ACTIVATE_REQ",
239 "EV_PH_DEACTIVATE_REQ",
243 static inline void D_L1L2(
struct isac *
isac,
int pr,
void *
arg)
248 ifc->
l1l2(ifc, pr, arg);
251 static void ph_command(
struct isac *isac,
unsigned int command)
254 switch (isac->
type) {
266 static void l1_di(
struct FsmInst *fi,
int event,
void *arg)
274 static void l1_di_deact_ind(
struct FsmInst *fi,
int event,
void *arg)
283 static void l1_go_f3pdown(
struct FsmInst *fi,
int event,
void *arg)
288 static void l1_go_f3pend_deact_ind(
struct FsmInst *fi,
int event,
void *arg)
297 static void l1_go_f3pend(
struct FsmInst *fi,
int event,
void *arg)
305 static void l1_go_f4(
struct FsmInst *fi,
int event,
void *arg)
310 static void l1_go_f5(
struct FsmInst *fi,
int event,
void *arg)
315 static void l1_go_f6(
struct FsmInst *fi,
int event,
void *arg)
320 static void l1_go_f6_deact_ind(
struct FsmInst *fi,
int event,
void *arg)
328 static void l1_go_f7_act_ind(
struct FsmInst *fi,
int event,
void *arg)
338 static void l1_go_f8(
struct FsmInst *fi,
int event,
void *arg)
343 static void l1_go_f8_deact_ind(
struct FsmInst *fi,
int event,
void *arg)
351 static void l1_ar8(
struct FsmInst *fi,
int event,
void *arg)
359 static void l1_timer3(
struct FsmInst *fi,
int event,
void *arg)
431 static void l1m_debug(
struct FsmInst *fi,
char *
fmt, ...)
442 static void isac_version(
struct isac *
cs)
447 DBG(1,
"ISAC version (%x): %s", val, ISACVer[(val >> 5) & 3]);
471 static void isac_fill_fifo(
struct isac *isac)
482 count = isac->
tx_skb->len;
502 static void isac_retransmit(
struct isac *isac)
513 static inline void isac_cisq_interrupt(
struct isac *isac)
529 static inline void isac_rme_interrupt(
struct isac *isac)
567 static inline void isac_xpr_interrupt(
struct isac *isac)
572 if (isac->
tx_skb->len > 0) {
573 isac_fill_fifo(isac);
582 static inline void isac_exi_interrupt(
struct isac *isac)
587 DBG(2,
"EXIR %#x", val);
591 isac_retransmit(isac);
595 isac_retransmit(isac);
600 DBG(2,
"ISAC MOSR %#x", val);
613 isac_exi_interrupt(isac);
617 isac_xpr_interrupt(isac);
621 isac_rme_interrupt(isac);
629 isac_cisq_interrupt(isac);
643 static inline void isacsx_cic_interrupt(
struct isac *isac)
655 static inline void isacsx_rme_interrupt(
struct isac *isac)
685 skb = dev_alloc_skb(count);
697 static inline void isacsx_xpr_interrupt(
struct isac *isac)
702 if (isac->
tx_skb->len > 0) {
703 isac_fill_fifo(isac);
712 static inline void isacsx_icd_interrupt(
struct isac *isac)
720 isac_retransmit(isac);
724 isac_retransmit(isac);
728 isacsx_xpr_interrupt(isac);
736 isacsx_rme_interrupt(isac);
752 isacsx_icd_interrupt(isac);
754 isacsx_cic_interrupt(isac);
760 isac->
l1m.fsm = &l1fsm;
762 #ifdef CONFIG_HISAX_DEBUG
767 isac->
l1m.userdata = isac;
768 isac->
l1m.printdebug = l1m_debug;
803 DBG(2,
"ISAC STAR %x", val);
805 DBG(2,
"ISAC MODE %x", val);
807 DBG(2,
"ISAC ADF2 %x", val);
809 DBG(2,
"ISAC ISTA %x", val);
812 DBG(2,
"ISAC EXIR %x", eval);
815 DBG(2,
"ISAC CIR0 %x", val);
841 struct isac *isac = hisax_d_if->
priv;
857 DBG(1,
"L1 wrong state %d\n", isac->
l1m.state);
864 isac_fill_fifo(isac);
869 static int __init hisax_isac_init(
void)
875 l1fsm.strState = strL1State;
876 l1fsm.strEvent = strL1Event;
880 static void __exit hisax_isac_exit(
void)