ath_info: add support to read (-R ADDR) and write (-W ADDR VALUE) registers

Reference: madwifi-trace@3398


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3425 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
proski 2008-04-03 21:14:05 +00:00
parent b9e098b4f7
commit 67f7dd0140
1 changed files with 28 additions and 1 deletions

View File

@ -710,7 +710,7 @@ static void usage(const char *n)
{
int i;
fprintf(stderr, "%s [-w [-g N:M]] [-v] [-f] [-d] <base_address> "
fprintf(stderr, "%s [-w [-g N:M]] [-v] [-f] [-d] [-R addr] [-W addr val] <base_address> "
"[<name1> <val1> [<name2> <val2> ...]]\n\n", n);
fprintf(stderr,
"-w write values into EEPROM\n"
@ -718,6 +718,8 @@ static void usage(const char *n)
"-v verbose output\n"
"-f force; suppress question before writing\n"
"-d dump eeprom (file 'ath-eeprom-dump.bin' and screen)\n"
"-R <addr> read register at <addr> (hex)\n"
"-W <addr> <val> write <val> (hex) into register at <addr> (hex)\n"
"<base_address> device base address (see lspci output)\n\n");
fprintf(stderr,
@ -968,6 +970,9 @@ int main(int argc, char *argv[])
int timer_count = 1;
int do_keycache_dump = 0;
int keycache_copy_idx = 0;
int reg_read = 0;
int reg_write = 0;
unsigned int reg_write_val = 0;
struct {
int valid;
@ -1030,6 +1035,17 @@ int main(int argc, char *argv[])
keycache_copy_idx = atoi(argv[++anr]);
break;
case 'R':
anr++;
reg_read = strtoul(argv[anr], NULL, 16);
break;
case 'W':
anr++;
reg_write = strtoul(argv[anr++], NULL, 16);
reg_write_val = strtoul(argv[anr], NULL, 16);
break;
case 'h':
usage(argv[0]);
return 0;
@ -1089,6 +1105,17 @@ int main(int argc, char *argv[])
AR5K_REG_DISABLE_BITS(AR5K_PCICFG, AR5K_PCICFG_SPWR_DN);
usleep(500);
if (reg_read) {
printf("READ %04x = %08x\n", reg_read, AR5K_REG_READ(reg_read));
return 0;
}
if (reg_write) {
printf("WRITE %04x = %08x\n", reg_write, reg_write_val);
AR5K_REG_WRITE(reg_write, reg_write_val);
return 0;
}
srev = AR5K_REG_READ(AR5K_SREV);
mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER) << 4;