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 * 507051:linmars 2005/07/5 fix makeCMV problem
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 cmvwrite_main
56 #define display_version cmvwrite_display_version
59 /*============================definitions======================*/
69 typedef unsigned short UINT16
;
70 typedef unsigned long UINT32
;
72 /*=============================================================*/
75 /*=============================global variables================*/
76 #ifdef IFX_MULTILIB_UTIL
78 extern int input_flag
;
79 extern int digit_optind
;
80 extern FILE* script_file
;
81 extern void (*func
)();
99 /*=============================================================*/
100 /*165001:henryhsu 2005/9/7 Modify some error in cmvwrite utility*/
101 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
)
105 memset(Message
, 0, 16*2);
106 Message
[0]= (opcode
<<4) + (size
&0xf);
107 if(opcode
== H2D_DEBUG_WRITE_DM
)
108 Message
[1]= (group
&0x7f);
110 Message
[1]= (((index
==0)?0:1)<<7) + (group
&0x7f);
113 if((opcode
== H2D_CMV_WRITE
)||(opcode
== H2D_DEBUG_WRITE_DM
))
114 memcpy(Message
+4, data
, size
*2);
120 void display_version()
122 printf("adsl cmv write version1.0\nby Joe Lin \nJoe.Lin@infineon.com\n");
126 //165001:henryhsu 2005/9/7 No need to check this any more
127 //#ifndef IFX_MULTILIB_UTIL
129 //void cmvreader_help()
132 printf("Usage:cmvwrite [options] [group name][address][index][data] ...\n");
133 printf("options:\n");
134 printf(" -h --help Display help information\n");
135 printf(" -v --version Display version information\n");
136 printf("group name: --group name of CMV to read\n");
137 printf(" OPTN -- CMV Group 5 \n");
138 printf(" CNFG -- CMV Group 8 \n");
139 printf(" CNTL -- CMV Group 1 \n");
140 printf(" STAT -- CMV Group 2 \n");
141 printf(" RATE -- CMV Group 6 \n");
142 printf(" PLAM -- CMV Group 7 \n");
143 printf(" INFO -- CMV Group 3 \n");
144 printf(" TEST -- CMV Group 4 \n");
145 printf("address --address value of CMV to write\n");
146 printf("index --index value of CMV to write\n");
147 printf("data --data to write in Hex.\n");
152 int main (int argc
, char** argv
) {
155 unsigned short value
;
162 if (strstr(argv
[1], "-h") != NULL
){
167 if (strstr(argv
[1], "-v") != NULL
){
173 fd
=open(IFXMIPS_MEI_DEV
, O_RDWR
);
175 printf("\n\n autoboot open device fail\n");
181 int group
=0,address
,index
,size
;
182 if((strcmp(argv
[1],"optn")==0)||(strcmp(argv
[1],"OPTN")==0))
184 else if((strcmp(argv
[1],"cnfg")==0)||(strcmp(argv
[1],"CNFG")==0))
186 else if((strcmp(argv
[1],"cntl")==0)||(strcmp(argv
[1],"CNTL")==0))
188 else if((strcmp(argv
[1],"stat")==0)||(strcmp(argv
[1],"STAT")==0))
190 else if((strcmp(argv
[1],"rate")==0)||(strcmp(argv
[1],"RATE")==0))
192 else if((strcmp(argv
[1],"plam")==0)||(strcmp(argv
[1],"PLAM")==0))
194 else if((strcmp(argv
[1],"info")==0)||(strcmp(argv
[1],"INFO")==0))
196 else if((strcmp(argv
[1],"test")==0)||(strcmp(argv
[1],"TEST")==0))
200 printf("wrong group type!\nplease slect group:OPTN CNFG CNTL STAT RATE PLAM INFO TEST \n");
205 address
= strtoul(argv
[2], &endptr
, 10);
206 index
= strtoul(argv
[3], &endptr
, 10);
208 value
= strtoul(argv
[4],NULL
,0);
209 ifx_makeCMV(H2D_CMV_WRITE
, group
, address
, index
, 1, &value
, Message
, sizeof(Message
));
210 if(ioctl(fd
, IFXMIPS_MEI_CMV_WINHOST
, &Message
)<0){
211 printf("cr read %d %d %d fail",group
,address
,index
);
216 printf ("write %s %d %d 0x%X\n",argv
[1],address
,index
,value
);
This page took 0.053092 seconds and 5 git commands to generate.