MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / usb / net / Zydas / zddebug2.c
bloba8555e707f67c2268c589edcd0c6ca31e8bb0a25
1 #ifndef _ZD_DEBUG2_C_
2 #define _ZD_DEBUG2_C_
4 #ifdef ZDCONF_MENUDBG
5 #include "zddebug2.h"
6 #include "menu_drv_macro.h"
8 extern zd_80211Obj_t dot11Obj;
9 //for debug message show
10 extern U8 mDynKeyMode;
11 extern U8 mKeyFormat;
12 struct zd1205_private *lmacp;
13 extern struct net_device *g_dev;
15 #define CNT_MAX 64
16 static u32 CNT_TBL[CNT_MAX];
19 static void copy_cnt_tally(void)
21 struct zd1205_private *macp = (struct zd1205_private *)g_dev->priv;
23 memset(CNT_TBL,0,sizeof(CNT_TBL));
25 CNT_TBL[T_bcnCnt]=macp->bcnCnt;
26 CNT_TBL[T_txCmpCnt]=macp->txCmpCnt;
27 CNT_TBL[T_dtimCnt]=macp->dtimCnt;
28 CNT_TBL[T_rxCnt]=macp->rxCnt;
29 CNT_TBL[T_retryFailCnt]=macp->retryFailCnt;
30 CNT_TBL[T_txCnt]=macp->txCnt;
33 static void acquire_ctrl_of_phy_req(void *regp)
35 u32 tmpValue;
37 tmpValue = zd_readl(CtlReg1);
38 tmpValue &= ~0x80;
39 zd_writel(tmpValue, CtlReg1);
43 static void release_ctrl_of_phy_req(void *regp)
45 u32 tmpValue;
47 tmpValue = zd_readl(CtlReg1);
48 tmpValue |= 0x80;
49 zd_writel(tmpValue, CtlReg1);
53 int zd1205_zd_dbg2_ioctl(struct zd1205_private *macp, struct zdap_ioctl *zdreq, u32 *ret)
55 void *regp = macp->regp;
56 u16 zd_cmd;
57 u32 tmp_value;
58 u32 tmp_addr;
59 u32 CRn;
61 *ret=0;
62 zd_cmd = zdreq->cmd;
63 switch(zd_cmd) {
64 case RDCNT:
65 copy_cnt_tally();
66 if(zdreq->addr < CNT_MAX-1)
67 *ret = CNT_TBL[zdreq->addr];
68 break;
69 case RDMAC:
70 acquire_ctrl_of_phy_req(regp);
71 tmp_value = zd_readl(zdreq->addr);
72 release_ctrl_of_phy_req(regp);
73 zdreq->value = tmp_value;
75 *ret = tmp_value;
76 //if (copy_to_user(ifr->ifr_data, &zdreq, sizeof (zdreq)))
77 //return -EFAULT;
78 break;
80 case WRMAC:
81 acquire_ctrl_of_phy_req(regp);
82 zd_writel(zdreq->value, zdreq->addr);
83 release_ctrl_of_phy_req(regp);
85 if (zdreq->addr == RX_OFFSET_BYTE)
86 macp->rxOffset = zdreq->value;
87 break;
89 case RDPhy:
90 case WRPhy:
91 acquire_ctrl_of_phy_req(regp);
92 tmp_addr = zdreq->addr;
93 CRn= ((tmp_addr & 0xF00)>>8)*100+
94 ((tmp_addr & 0xF0)>>4)*10+
95 (tmp_addr & 0xF);
96 if (CRn >= 4 && CRn <= 8)//Special handling for CR4 to CR8
98 u8 cnvtbl1[]={0x20, 0x10, 0x14, 0x18, 0x1c};
99 tmp_addr = cnvtbl1[CRn-4];
101 else
103 tmp_addr = CRn*4;
105 if (zd_cmd == RDPhy)
107 zdreq->value = zd_readl(tmp_addr);
108 *ret = zdreq->value;
110 else
111 {// ZD_IOCTL_WRITE_PHY
112 zd_writel(zdreq->value, tmp_addr);
114 release_ctrl_of_phy_req(regp);
115 break;
117 default :
118 printk(KERN_ERR "zd1205: error command = %x\n", zd_cmd);
119 break;
122 return 0;
124 #endif
125 #endif