2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16 //-----------------------------------------------------------------------
18 // read the CMV register under Linux for Amazon
19 //-----------------------------------------------------------------------
20 //Author: Joe.Lin@infineon.com
21 //Created: 31-December-2004
22 //-----------------------------------------------------------------------
25 * 000002:tc.chen 2005/06/10 add get_adsl_rate and ifx_makeCMV api
30 #define _IFXMIPS_ADSL_APP
32 #define u32 unsigned int
33 #define u16 unsigned short
34 #define u8 unsigned char
35 #define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
44 #include <sys/types.h>
45 #include <sys/ioctl.h>
49 #include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
50 #include <asm/ifxmips/ifxmips_mei_app.h>
51 #include <asm/ifxmips/ifxmips_mei_ioctl.h>
52 #include <asm/ifxmips/ifxmips_mei.h>
54 #ifdef IFX_MULTILIB_UTIL
55 #define main cmvread_main
56 #define display_version cmvread_display_version
59 /*============================definitions======================*/
69 typedef unsigned short UINT16
;
70 typedef unsigned long UINT32
;
74 /*=============================================================*/
77 /*=============================global variables================*/
89 /*=============================================================*/
91 int ifx_makeCMV(unsigned char opcode
, unsigned char group
, unsigned short address
, unsigned short index
, int size
, unsigned short * data
, unsigned short *Message
, int msg_len
)
95 memset(Message
, 0, 16*2);
96 Message
[0]= (opcode
<<4) + (size
&0xf);
97 if(opcode
== H2D_DEBUG_WRITE_DM
)
98 Message
[1]= (group
&0x7f);
100 Message
[1]= (((index
==0)?0:1)<<7) + (group
&0x7f);
103 if((opcode
== H2D_CMV_WRITE
)||(opcode
== H2D_DEBUG_WRITE_DM
))
104 memcpy(Message
+4, data
, size
*2);
109 void display_version()
111 printf("adsl cmv reader version1.0\nby Joe Lin \nJoe.Lin@infineon.com\n");
116 void cmvreader_help()
118 printf("Usage:cmvread [options] [group name][address][index][size] ...\n");
119 printf("options:\n");
120 printf(" -h --help Display help information\n");
121 printf(" -v --version Display version information\n");
122 printf("group name: --group name of CMV to read\n");
123 printf(" OPTN --Read CMV Group 5 \n");
124 printf(" CNFG --Read CMV Group 8 \n");
125 printf(" CNTL --Read CMV Group 1 \n");
126 printf(" STAT --Read CMV Group 2 \n");
127 printf(" RATE --Read CMV Group 6 \n");
128 printf(" PLAM --Read CMV Group 7 \n");
129 printf(" INFO --Read CMV Group 3 \n");
130 printf(" TEST --REad CMV Group 4 \n");
131 printf("address --address value of CMV to read\n");
132 printf("index --index value of CMV to read\n");
133 printf("size --number of words(16bits) to read \n");
140 int main (int argc
, char** argv
) {
142 UINT16 Message
[16]; //000002:tc.chen
144 int group
=0,address
,index
,size
;
152 if (strstr(argv
[1], "-h") != NULL
){
157 if (strstr(argv
[1], "-v") != NULL
){
162 fd
=open(IFXMIPS_MEI_DEV
, O_RDWR
);
164 printf("\n\n autoboot open device fail\n");
168 if((strcmp(argv
[1],"optn")==0)||(strcmp(argv
[1],"OPTN")==0))
170 else if((strcmp(argv
[1],"cnfg")==0)||(strcmp(argv
[1],"CNFG")==0))
172 else if((strcmp(argv
[1],"cntl")==0)||(strcmp(argv
[1],"CNTL")==0))
174 else if((strcmp(argv
[1],"stat")==0)||(strcmp(argv
[1],"STAT")==0))
176 else if((strcmp(argv
[1],"rate")==0)||(strcmp(argv
[1],"RATE")==0))
178 else if((strcmp(argv
[1],"plam")==0)||(strcmp(argv
[1],"PLAM")==0))
180 else if((strcmp(argv
[1],"info")==0)||(strcmp(argv
[1],"INFO")==0))
182 else if((strcmp(argv
[1],"test")==0)||(strcmp(argv
[1],"TEST")==0))
186 printf("wrong group type!\nplease slect group:OPTN CNFG CNTL STAT RATE PLAM INFO TEST \n");
191 address
= strtoul(argv
[2], &endptr
, 0);
192 index
= strtoul(argv
[3], &endptr
, 0);
193 size
= strtoul(argv
[4], &endptr
, 0);
194 //makeCMV(H2D_CMV_READ, group, address, index, size, NULL);
195 ifx_makeCMV(H2D_CMV_READ
, group
, address
, index
, size
, NULL
,Message
,sizeof(Message
));
196 if(ioctl(fd
, IFXMIPS_MEI_CMV_WINHOST
, &Message
)<0){
197 printf("cr read %d %d %d fail",group
,address
,index
);
203 for (i
=0;i
<size
;i
++) printf ("0x%X\n",Message
[i
+4]);
206 // return Message[4];
This page took 0.053058 seconds and 5 git commands to generate.