version 1.1.2.8, 2010/10/29 07:32:52
|
version 1.1.2.11, 2010/11/05 00:43:27
|
Line 26 Usage()
|
Line 26 Usage()
|
" athctl [-v] -r <0xoffset> <0xMemory_Address>\n" |
" athctl [-v] -r <0xoffset> <0xMemory_Address>\n" |
" athctl [-v] -w <0xoffset> <0xMemory_Address> <uint16_value>\n" |
" athctl [-v] -w <0xoffset> <0xMemory_Address> <uint16_value>\n" |
" athctl [-v] -s <file> <0xMemory_Address>\n" |
" athctl [-v] -s <file> <0xMemory_Address>\n" |
" athctl [-v] -w <file> <0xMemory_Address>\n" | " athctl [-v] -u <file> <0xMemory_Address>\n" |
| " athctl [-v] -R <0xMemory_Address> [new_regdomain]\n" |
"\n" |
"\n" |
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\n" |
"\t-t\t\tGet current Atheros maximum range in meters\n" |
"\t-t\t\tGet current Atheros maximum range in meters\n" |
"\t-i <iface_no>\tApply to this Atheros interface number (like ath0 == 0)\n" |
"\t-i <iface_no>\tApply to this Atheros interface number (like ath0 == 0)\n" |
"\t-d <distance>\tMode distance, meters to target\n" |
"\t-d <distance>\tMode distance, meters to target\n" |
"\t-c <timeout>\tMode distance, mS timeouts correction\n" |
"\t-c <timeout>\tMode distance, mS timeouts correction\n" |
|
"\t-R\t\tRead or Write EEPROM Regulatory domain\n" |
"\t-s <file>\tDump EEPROM to file\n" |
"\t-s <file>\tDump EEPROM to file\n" |
"\t-u <file>\tUpdate EEPROM from file\n" |
"\t-u <file>\tUpdate EEPROM from file\n" |
"\t-r <offset>\tRead EEPROM word from PCI mapped memory address\n" |
"\t-r <offset>\tRead EEPROM word from PCI mapped memory address\n" |
Line 176 readWord(u_char *mem, u_long offset)
|
Line 178 readWord(u_char *mem, u_long offset)
|
register int timeout = ATH_ACCESS_TIMEOUT; |
register int timeout = ATH_ACCESS_TIMEOUT; |
u_long stat; |
u_long stat; |
|
|
VERB(2) printf("Reading EEPROM memory %p+%lx ...\n", mem, offset); | VERB(9) printf("Reading EEPROM memory %p+%lx ...\n", mem, offset); |
ATH_OUT(mem, AR5211_EEPROM_CONF, 0); |
ATH_OUT(mem, AR5211_EEPROM_CONF, 0); |
usleep(ATH_ACCESS_WAIT); |
usleep(ATH_ACCESS_WAIT); |
/* enable eeprom access */ |
/* enable eeprom access */ |
Line 212 writeWord(u_char *mem, u_long offset, u_short newval)
|
Line 214 writeWord(u_char *mem, u_long offset, u_short newval)
|
{ |
{ |
register int i = ATH_WRITE_RETRY, timeout; |
register int i = ATH_WRITE_RETRY, timeout; |
u_long pcicfg, stat; |
u_long pcicfg, stat; |
u_short chk; | int chk; |
|
|
VERB(2) printf("Writing EEPROM memory %p+%lx ...\n", mem, offset); | VERB(9) printf("Writing EEPROM memory %p+%lx ...\n", mem, offset); |
/* enable pci write access */ |
/* enable pci write access */ |
pcicfg = ATH_IN(mem, AR5K_PCICFG); |
pcicfg = ATH_IN(mem, AR5K_PCICFG); |
ATH_OUT(mem, AR5K_PCICFG, (pcicfg & ~AR5K_PCICFG_SPWR_DN)); |
ATH_OUT(mem, AR5K_PCICFG, (pcicfg & ~AR5K_PCICFG_SPWR_DN)); |
Line 255 writeWord(u_char *mem, u_long offset, u_short newval)
|
Line 257 writeWord(u_char *mem, u_long offset, u_short newval)
|
chk = readWord(mem, offset); |
chk = readWord(mem, offset); |
if (chk == (u_short) -1) |
if (chk == (u_short) -1) |
return -1; |
return -1; |
if (chk == newval) | if ((u_short) (chk >> 16) == newval) |
return chk << 16; | return chk; |
else |
else |
VERB(1) printf("Write & Read don`t match 0x%04X != 0x%04X\n", newval, chk); | VERB(1) printf("Write & Read don`t match 0x%04X != 0x%04X\n", newval, (u_short) (chk >> 16)); |
if (i) |
if (i) |
printf("Warning:: Retrying EEPROM write ...\n"); |
printf("Warning:: Retrying EEPROM write ...\n"); |
} while (--i); |
} while (--i); |
Line 272 dumpFile(const char *csName, u_char *mem)
|
Line 274 dumpFile(const char *csName, u_char *mem)
|
{ |
{ |
register u_long i; |
register u_long i; |
u_short d1, d2; |
u_short d1, d2; |
u_short eeprom[ATH_EEPROM_SIZE] = { 0 }; | u_char eeprom[ATH_EEPROM_SIZE] = { 0 }; |
int f, data; |
int f, data; |
|
|
VERB(2) printf("Reading EEPROM memory %p ::\n", mem); |
VERB(2) printf("Reading EEPROM memory %p ::\n", mem); |
for (i = 0; i < ATH_EEPROM_SIZE / 2; i++) { |
for (i = 0; i < ATH_EEPROM_SIZE / 2; i++) { |
if (!(i % 0x40)) { |
if (!(i % 0x40)) { |
printf("0x%04lX [", i * 2); |
|
if (i) |
if (i) |
printf("]\n"); |
printf("]\n"); |
|
printf("0x%04lX [", i * 2); |
} |
} |
|
|
if ((data = readWord(mem, i)) == -1) |
if ((data = readWord(mem, i)) == -1) |
return -1; |
return -1; |
else { |
else { |
d1 = ((u_short) data >> 16) / 0x100; | d1 = ((u_short)(data >> 16)) / 0x100; |
d2 = ((u_short) data >> 16) % 0x100; | d2 = ((u_short)(data >> 16)) % 0x100; |
| |
| VERB(5) printf( "Current value 0x%04X on position 0x%04lX will change 0x%02X 0x%02X\n", |
| (u_short) (data >> 16), i, d1, d2); |
} |
} |
|
|
eeprom[i * 2] = d2; |
eeprom[i * 2] = d2; |
Line 321 flashFile(const char *csName, u_char *mem)
|
Line 326 flashFile(const char *csName, u_char *mem)
|
{ |
{ |
register u_long i; |
register u_long i; |
u_short d1; |
u_short d1; |
u_short eeprom[ATH_EEPROM_SIZE] = { 0 }; | u_char eeprom[ATH_EEPROM_SIZE] = { 0 }; |
int f, data; |
int f, data; |
|
|
VERB(2) printf("Reading EEPROM from file %s ... ", csName); |
VERB(2) printf("Reading EEPROM from file %s ... ", csName); |
Line 337 flashFile(const char *csName, u_char *mem)
|
Line 342 flashFile(const char *csName, u_char *mem)
|
return 0; |
return 0; |
} |
} |
close(f); |
close(f); |
printf("OK!\n"); | VERB(2) printf("OK!\n"); |
|
|
VERB(2) printf("Writing EEPROM memory %p ::\n", mem); |
VERB(2) printf("Writing EEPROM memory %p ::\n", mem); |
for (i = 0; i < ATH_EEPROM_SIZE / 2; i++) { |
for (i = 0; i < ATH_EEPROM_SIZE / 2; i++) { |
if (!(i % 0x40)) { |
if (!(i % 0x40)) { |
printf("0x%04lX [", i * 2); |
|
if (i) |
if (i) |
printf("]\n"); |
printf("]\n"); |
|
printf("0x%04lX [", i * 2); |
} |
} |
|
|
if ((data = readWord(mem, i)) == -1) |
if ((data = readWord(mem, i)) == -1) |
return -1; |
return -1; |
else |
else |
d1 = eeprom[i * 2 + 1] * 0x100 + eeprom[i * 2]; |
d1 = eeprom[i * 2 + 1] * 0x100 + eeprom[i * 2]; |
|
VERB(5) printf("eeprom_data=0x%04X read_d1=0x%04X\n", (u_char) (data >> 16), d1); |
|
|
if ((data >> 16) == d1) | if (((u_short) (data >> 16)) == d1) |
printf("."); |
printf("."); |
else { |
else { |
printf("x"); |
|
|
|
if (writeWord(mem, i, d1) < 1) |
if (writeWord(mem, i, d1) < 1) |
return -1; | printf("!"); |
| else |
| printf("x"); |
} |
} |
|
|
usleep(ATH_ACCESS_WAITDOWN); |
usleep(ATH_ACCESS_WAITDOWN); |
Line 379 main(int argc, char **argv)
|
Line 386 main(int argc, char **argv)
|
u_short newval = 0; |
u_short newval = 0; |
void *basemem = NULL; |
void *basemem = NULL; |
|
|
while ((ch = getopt(argc, argv, "hvtr:w:i:d:c:u:s:")) != -1) | while ((ch = getopt(argc, argv, "hvRtr:w:i:d:c:u:s:")) != -1) |
switch (ch) { |
switch (ch) { |
case 'v': |
case 'v': |
Verbose++; |
Verbose++; |
Line 414 main(int argc, char **argv)
|
Line 421 main(int argc, char **argv)
|
mode = 0x20; |
mode = 0x20; |
strlcpy(szName, optarg, MAXPATHLEN); |
strlcpy(szName, optarg, MAXPATHLEN); |
break; |
break; |
|
case 'R': |
|
mode = 0x40; |
|
break; |
case 'r': |
case 'r': |
mode = 4; |
mode = 4; |
offset = strtoul(optarg, NULL, 0); |
offset = strtoul(optarg, NULL, 0); |
Line 446 main(int argc, char **argv)
|
Line 456 main(int argc, char **argv)
|
} else |
} else |
newval = (u_short) strtoul(argv[1], NULL, 0); |
newval = (u_short) strtoul(argv[1], NULL, 0); |
} |
} |
|
if (mode & 0x40 && argv[1]) |
|
newval = (u_short) strtoul(argv[1], NULL, 0); |
|
|
if (mode & 1) |
if (mode & 1) |
if ((ret = calcDistance(ino, dist, cor)) < 1) |
if ((ret = calcDistance(ino, dist, cor)) < 1) |
Line 468 main(int argc, char **argv)
|
Line 480 main(int argc, char **argv)
|
devClose(basemem); |
devClose(basemem); |
return 3; |
return 3; |
} else |
} else |
printf("EEPROM readed value 0x%04X\n", (u_short) ret >> 16); | printf("EEPROM readed value 0x%04X\n", (u_short) (ret >> 16)); |
devClose(basemem); |
devClose(basemem); |
} |
} |
if (mode & 8) { |
if (mode & 8) { |
Line 478 main(int argc, char **argv)
|
Line 490 main(int argc, char **argv)
|
devClose(basemem); |
devClose(basemem); |
return 3; |
return 3; |
} else |
} else |
printf("EEPROM writed value 0x%04X\n", (u_short) ret); | printf("EEPROM writed value 0x%04X\n", (u_short) (ret >> 16)); |
devClose(basemem); |
devClose(basemem); |
} |
} |
|
|
Line 498 main(int argc, char **argv)
|
Line 510 main(int argc, char **argv)
|
devClose(basemem); |
devClose(basemem); |
return 3; |
return 3; |
} |
} |
|
devClose(basemem); |
|
} |
|
|
|
if (mode & 0x40) { |
|
if (!(basemem = devOpen(baseaddr))) |
|
return 2; |
|
/* |
|
if ((ret = regDomain(basemem, newval)) < 1) { |
|
devClose(basemem); |
|
return 3; |
|
} |
|
*/ |
devClose(basemem); |
devClose(basemem); |
} |
} |
|
|