mirror of
https://github.com/proski/madwifi
synced 2024-11-28 17:23:11 +03:00
Big cleanup of tools/ath_info.c
Reformat with madwifi-indent, it was needed badly. Break some long lines. Avoid complex structure initializers that GNU indent cannot format. Avoid using macro for the names table. Remove spaces in the names, add then with formatted output. Remove spaces before punctuation signs. Fix all sparse warnings. Default to base 16 for all numbers specified on the command line. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2816 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
parent
120d309bc3
commit
25418eaa48
216
tools/ath_info.c
216
tools/ath_info.c
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/* So here is how it works:
|
||||
*
|
||||
* First compile...
|
||||
@ -90,7 +89,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -99,9 +97,14 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define dbg(fmt , __args__...) do { if (verbose) printf("#DBG %s: " fmt "\n", __FUNCTION__, ##__args__ ); } while (0)
|
||||
#define dbg(fmt, __args__...) \
|
||||
do { \
|
||||
if (verbose) \
|
||||
printf("#DBG %s: " fmt "\n", __FUNCTION__, ##__args__); \
|
||||
} while (0)
|
||||
|
||||
#define err(fmt , __args__...) fprintf(stderr, "#ERR %s: " fmt "\n", __FUNCTION__, ##__args__ )
|
||||
#define err(fmt, __args__...) \
|
||||
fprintf(stderr, "#ERR %s: " fmt "\n", __FUNCTION__, ##__args__)
|
||||
|
||||
#define AR5K_PCI_MEM_SIZE 0x10000
|
||||
#define AR5K_ELEMENTS(_array) (sizeof(_array) / sizeof(_array[0]))
|
||||
@ -113,12 +116,12 @@
|
||||
#define AR5K_GPIOCR_INT_SEL(n) ((n) << 12) /* Interrupt for GPIO pin n */
|
||||
|
||||
/*
|
||||
* "General Purpose Input/Output" (GPIO) data output register
|
||||
* GPIO (General Purpose Input/Output) data output register
|
||||
*/
|
||||
#define AR5K_GPIODO 0x4018
|
||||
|
||||
/*
|
||||
* "General Purpose Input/Output" (GPIO) data input register
|
||||
* GPIO (General Purpose Input/Output) data input register
|
||||
*/
|
||||
#define AR5K_GPIODI 0x401c
|
||||
|
||||
@ -137,35 +140,6 @@ struct ath5k_srev_name {
|
||||
u_int sr_val;
|
||||
};
|
||||
|
||||
#define AR5K_SREV_NAME { \
|
||||
{ "5210 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5210 }, \
|
||||
{ "5311 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5311 }, \
|
||||
{ "5311A", AR5K_VERSION_VER, AR5K_SREV_VER_AR5311A },\
|
||||
{ "5311B", AR5K_VERSION_VER, AR5K_SREV_VER_AR5311B },\
|
||||
{ "5211 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5211 }, \
|
||||
{ "5212 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5212 }, \
|
||||
{ "5213 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5213 }, \
|
||||
{ "5213A", AR5K_VERSION_VER, AR5K_SREV_VER_AR5213A },\
|
||||
{ "2424 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR2424 }, \
|
||||
{ "5424 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5424 }, \
|
||||
{ "5413 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5413 }, \
|
||||
{ "5414 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5414 }, \
|
||||
{ "5416 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5416 }, \
|
||||
{ "5418 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR5418 }, \
|
||||
{ "2425 ", AR5K_VERSION_VER, AR5K_SREV_VER_AR2425 }, \
|
||||
{ "xxxxx", AR5K_VERSION_VER, AR5K_SREV_UNKNOWN }, \
|
||||
{ "5110 ", AR5K_VERSION_RAD, AR5K_SREV_RAD_5110 }, \
|
||||
{ "5111 ", AR5K_VERSION_RAD, AR5K_SREV_RAD_5111 }, \
|
||||
{ "2111 ", AR5K_VERSION_RAD, AR5K_SREV_RAD_2111 }, \
|
||||
{ "5112 ", AR5K_VERSION_RAD, AR5K_SREV_RAD_5112 }, \
|
||||
{ "5112a", AR5K_VERSION_RAD, AR5K_SREV_RAD_5112A }, \
|
||||
{ "2112 ", AR5K_VERSION_RAD, AR5K_SREV_RAD_2112 }, \
|
||||
{ "2112a", AR5K_VERSION_RAD, AR5K_SREV_RAD_2112A }, \
|
||||
{ "SChip", AR5K_VERSION_RAD, AR5K_SREV_RAD_SC1 }, \
|
||||
{ "SChip", AR5K_VERSION_RAD, AR5K_SREV_RAD_SC2 }, \
|
||||
{ "5133", AR5K_VERSION_RAD, AR5K_SREV_RAD_5133 }, \
|
||||
{ "xxxxx", AR5K_VERSION_RAD, AR5K_SREV_UNKNOWN }, \
|
||||
}
|
||||
#define AR5K_SREV_UNKNOWN 0xffff
|
||||
|
||||
/* Known MAC revision numbers */
|
||||
@ -198,6 +172,36 @@ struct ath5k_srev_name {
|
||||
#define AR5K_SREV_RAD_SC2 0xa2 /* Found on 2424/5424 */
|
||||
#define AR5K_SREV_RAD_5133 0xc0 /* MIMO found on 5418 */
|
||||
|
||||
static const struct ath5k_srev_name ath5k_srev_names[] = {
|
||||
{"5210", AR5K_VERSION_VER, AR5K_SREV_VER_AR5210},
|
||||
{"5311", AR5K_VERSION_VER, AR5K_SREV_VER_AR5311},
|
||||
{"5311A", AR5K_VERSION_VER, AR5K_SREV_VER_AR5311A},
|
||||
{"5311B", AR5K_VERSION_VER, AR5K_SREV_VER_AR5311B},
|
||||
{"5211", AR5K_VERSION_VER, AR5K_SREV_VER_AR5211},
|
||||
{"5212", AR5K_VERSION_VER, AR5K_SREV_VER_AR5212},
|
||||
{"5213", AR5K_VERSION_VER, AR5K_SREV_VER_AR5213},
|
||||
{"5213A", AR5K_VERSION_VER, AR5K_SREV_VER_AR5213A},
|
||||
{"2424", AR5K_VERSION_VER, AR5K_SREV_VER_AR2424},
|
||||
{"5424", AR5K_VERSION_VER, AR5K_SREV_VER_AR5424},
|
||||
{"5413", AR5K_VERSION_VER, AR5K_SREV_VER_AR5413},
|
||||
{"5414", AR5K_VERSION_VER, AR5K_SREV_VER_AR5414},
|
||||
{"5416", AR5K_VERSION_VER, AR5K_SREV_VER_AR5416},
|
||||
{"5418", AR5K_VERSION_VER, AR5K_SREV_VER_AR5418},
|
||||
{"2425", AR5K_VERSION_VER, AR5K_SREV_VER_AR2425},
|
||||
{"xxxxx", AR5K_VERSION_VER, AR5K_SREV_UNKNOWN},
|
||||
{"5110", AR5K_VERSION_RAD, AR5K_SREV_RAD_5110},
|
||||
{"5111", AR5K_VERSION_RAD, AR5K_SREV_RAD_5111},
|
||||
{"2111", AR5K_VERSION_RAD, AR5K_SREV_RAD_2111},
|
||||
{"5112", AR5K_VERSION_RAD, AR5K_SREV_RAD_5112},
|
||||
{"5112a", AR5K_VERSION_RAD, AR5K_SREV_RAD_5112A},
|
||||
{"2112", AR5K_VERSION_RAD, AR5K_SREV_RAD_2112},
|
||||
{"2112a", AR5K_VERSION_RAD, AR5K_SREV_RAD_2112A},
|
||||
{"SChip", AR5K_VERSION_RAD, AR5K_SREV_RAD_SC1},
|
||||
{"SChip", AR5K_VERSION_RAD, AR5K_SREV_RAD_SC2},
|
||||
{"5133", AR5K_VERSION_RAD, AR5K_SREV_RAD_5133},
|
||||
{"xxxxx", AR5K_VERSION_RAD, AR5K_SREV_UNKNOWN},
|
||||
};
|
||||
|
||||
/*
|
||||
* Silicon revision register
|
||||
*/
|
||||
@ -241,7 +245,7 @@ struct ath5k_srev_name {
|
||||
#define AR5K_SLEEP_CTL_SLE_WAKE 0x00000000 /* Force chip awake */
|
||||
#define AR5K_SLEEP_CTL_SLE_SLP 0x00010000 /* Force chip sleep */
|
||||
#define AR5K_SLEEP_CTL_SLE_ALLOW 0x00020000
|
||||
#define AR5K_SLEEP_CTL_SLE_UNITS 0x00000008 /*non 5210*/
|
||||
#define AR5K_SLEEP_CTL_SLE_UNITS 0x00000008 /* not on 5210 */
|
||||
|
||||
#define AR5K_PCICFG 0x4010 /* Register Address */
|
||||
#define AR5K_PCICFG_EEAE 0x00000001 /* Eeprom access enable [5210] */
|
||||
@ -346,21 +350,22 @@ struct ath5k_srev_name {
|
||||
|
||||
#define AR5K_TUNE_REGISTER_TIMEOUT 20000
|
||||
|
||||
|
||||
/* names for eeprom fields */
|
||||
static const struct {
|
||||
struct eeprom_entry {
|
||||
const char *name;
|
||||
int addr;
|
||||
} eeprom_addr[] = {
|
||||
};
|
||||
|
||||
static const struct eeprom_entry eeprom_addr[] = {
|
||||
{"pci_dev_id", 0},
|
||||
{"pci_vendor_id", 1},
|
||||
{"pci_class", 2},
|
||||
{"pci_rev_id", 3},
|
||||
{"pci_subsys_dev_id", 7},
|
||||
{"pci_subsys_vendor_id", 8},
|
||||
|
||||
{"regdomain", AR5K_EEPROM_REG_DOMAIN},
|
||||
};
|
||||
|
||||
static const int eeprom_addr_len = sizeof(eeprom_addr) / sizeof(eeprom_addr[0]);
|
||||
|
||||
static int force_write = 0;
|
||||
@ -369,9 +374,7 @@ static int verbose=0;
|
||||
/* forward decl. */
|
||||
static void usage(const char *n);
|
||||
|
||||
|
||||
static u_int32_t
|
||||
ath5k_hw_bitswap(u_int32_t val, u_int bits)
|
||||
static u_int32_t ath5k_hw_bitswap(u_int32_t val, u_int bits)
|
||||
{
|
||||
u_int32_t retval = 0, bit, i;
|
||||
|
||||
@ -386,7 +389,7 @@ ath5k_hw_bitswap(u_int32_t val, u_int bits)
|
||||
/*
|
||||
* Get the PHY Chip revision
|
||||
*/
|
||||
u_int16_t
|
||||
static u_int16_t
|
||||
ath5k_hw_radio_revision(u_int16_t mac_version, void *mem, u_int8_t chip)
|
||||
{
|
||||
int i;
|
||||
@ -435,7 +438,7 @@ ath5k_hw_radio_revision(u_int16_t mac_version, void *mem, u_int8_t chip)
|
||||
/*
|
||||
* Write to EEPROM
|
||||
*/
|
||||
int
|
||||
static int
|
||||
ath5k_hw_eeprom_write(void *mem, u_int32_t offset, u_int16_t data,
|
||||
u_int8_t mac_version)
|
||||
{
|
||||
@ -453,7 +456,7 @@ ath5k_hw_eeprom_write(void *mem, u_int32_t offset, u_int16_t data,
|
||||
(void)AR5K_REG_WRITE(AR5K_EEPROM_BASE + (4 * offset), data);
|
||||
|
||||
} else {
|
||||
/* != 5210 */
|
||||
/* not 5210 */
|
||||
/* reset eeprom access */
|
||||
AR5K_REG_WRITE(AR5K_EEPROM_CMD, AR5K_EEPROM_CMD_RESET);
|
||||
usleep(5);
|
||||
@ -472,7 +475,8 @@ ath5k_hw_eeprom_write(void *mem, u_int32_t offset, u_int16_t data,
|
||||
status = AR5K_REG_READ(AR5K_EEPROM_STATUS);
|
||||
if (status & AR5K_EEPROM_STAT_WRDONE) {
|
||||
if (status & AR5K_EEPROM_STAT_WRERR) {
|
||||
err("eeprom write access to 0x%04x failed", offset);
|
||||
err("eeprom write access to 0x%04x failed",
|
||||
offset);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -483,11 +487,10 @@ ath5k_hw_eeprom_write(void *mem, u_int32_t offset, u_int16_t data,
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read from EEPROM
|
||||
*/
|
||||
int
|
||||
static int
|
||||
ath5k_hw_eeprom_read(void *mem, u_int32_t offset, u_int16_t *data,
|
||||
u_int8_t mac_version)
|
||||
{
|
||||
@ -501,8 +504,7 @@ ath5k_hw_eeprom_read(void *mem, u_int32_t offset, u_int16_t *data,
|
||||
(void)AR5K_REG_READ(AR5K_EEPROM_BASE + (4 * offset));
|
||||
} else {
|
||||
AR5K_REG_WRITE(AR5K_EEPROM_BASE, offset);
|
||||
AR5K_REG_ENABLE_BITS(AR5K_EEPROM_CMD,
|
||||
AR5K_EEPROM_CMD_READ);
|
||||
AR5K_REG_ENABLE_BITS(AR5K_EEPROM_CMD, AR5K_EEPROM_CMD_READ);
|
||||
}
|
||||
|
||||
for (timeout = AR5K_TUNE_REGISTER_TIMEOUT; timeout > 0; timeout--) {
|
||||
@ -520,19 +522,18 @@ ath5k_hw_eeprom_read(void *mem, u_int32_t offset, u_int16_t *data,
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *
|
||||
ath5k_hw_get_part_name(enum ath5k_srev_type type, u_int32_t val)
|
||||
static const char *ath5k_hw_get_part_name(enum ath5k_srev_type type,
|
||||
u_int32_t val)
|
||||
{
|
||||
struct ath5k_srev_name names[] = AR5K_SREV_NAME;
|
||||
const char *name = "xxxxx";
|
||||
int i;
|
||||
|
||||
for (i = 0; i < AR5K_ELEMENTS(names); i++) {
|
||||
if (names[i].sr_type != type ||
|
||||
names[i].sr_val == AR5K_SREV_UNKNOWN)
|
||||
for (i = 0; i < AR5K_ELEMENTS(ath5k_srev_names); i++) {
|
||||
if (ath5k_srev_names[i].sr_type != type ||
|
||||
ath5k_srev_names[i].sr_val == AR5K_SREV_UNKNOWN)
|
||||
continue;
|
||||
if ((val & 0xff) < names[i + 1].sr_val) {
|
||||
name = names[i].sr_name;
|
||||
if ((val & 0xff) < ath5k_srev_names[i + 1].sr_val) {
|
||||
name = ath5k_srev_names[i].sr_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -541,7 +542,7 @@ ath5k_hw_get_part_name(enum ath5k_srev_type type, u_int32_t val)
|
||||
}
|
||||
|
||||
/* returns -1 on unknown name */
|
||||
int eeprom_name2addr(const char *name)
|
||||
static int eeprom_name2addr(const char *name)
|
||||
{
|
||||
int i;
|
||||
if (!name || !name[0])
|
||||
@ -553,7 +554,7 @@ int eeprom_name2addr(const char *name)
|
||||
} /* eeprom_name2addr */
|
||||
|
||||
/* returns "<unknown>" on unknown address */
|
||||
const char *eeprom_addr2name(int addr)
|
||||
static const char *eeprom_addr2name(int addr)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < eeprom_addr_len; i++)
|
||||
@ -562,9 +563,9 @@ const char *eeprom_addr2name(int addr)
|
||||
return "<unknown>";
|
||||
} /* eeprom_addr2name */
|
||||
|
||||
|
||||
static int
|
||||
do_write_pairs(int anr, int argc, char **argv, unsigned char *mem, int mac_version)
|
||||
do_write_pairs(int anr, int argc, char **argv, unsigned char *mem,
|
||||
int mac_version)
|
||||
{
|
||||
#define MAX_NR_WRITES 16
|
||||
struct {
|
||||
@ -596,23 +597,24 @@ do_write_pairs(int anr, int argc, char **argv, unsigned char *mem, int mac_versi
|
||||
/* get the (addr,val) pairs we have to write */
|
||||
i = 0;
|
||||
while (anr < (argc - 1)) {
|
||||
wr_ops[i].addr = strtoul(argv[anr], &end, 0);
|
||||
wr_ops[i].addr = strtoul(argv[anr], &end, 16);
|
||||
if (end == argv[anr]) {
|
||||
/* maybe a symbolic name for the address? */
|
||||
if ((wr_ops[i].addr = eeprom_name2addr(argv[anr])) == -1) {
|
||||
if ((wr_ops[i].addr =
|
||||
eeprom_name2addr(argv[anr])) == -1) {
|
||||
err("pair %d: bad address %s", i, argv[anr]);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (wr_ops[i].addr >= AR5K_EEPROM_INFO_BASE) {
|
||||
err("offset 0x%04x in CRC protected area is not supported",
|
||||
wr_ops[i].addr);
|
||||
err("offset 0x%04x in CRC protected area is "
|
||||
"not supported", wr_ops[i].addr);
|
||||
return 5;
|
||||
}
|
||||
|
||||
anr++;
|
||||
wr_ops[i].val = strtoul(argv[anr], &end, 0);
|
||||
wr_ops[i].val = strtoul(argv[anr], &end, 16);
|
||||
if (end == argv[anr]) {
|
||||
err("pair %d: bad val %s", i, argv[anr]);
|
||||
return 5;
|
||||
@ -634,13 +636,14 @@ do_write_pairs(int anr, int argc, char **argv, unsigned char *mem, int mac_versi
|
||||
if (verbose || !force_write) {
|
||||
for (i = 0; i < wr_ops_len; i++)
|
||||
printf("%20s (0x%04x) := 0x%04x\n",
|
||||
eeprom_addr2name(wr_ops[i].addr), wr_ops[i].addr, wr_ops[i].val);
|
||||
eeprom_addr2name(wr_ops[i].addr), wr_ops[i].addr,
|
||||
wr_ops[i].val);
|
||||
}
|
||||
|
||||
if (!force_write) {
|
||||
int c;
|
||||
printf(
|
||||
"WARNING: The write function may easy brick your device or\n"
|
||||
printf
|
||||
("WARNING: The write function may easy brick your device or\n"
|
||||
"violate state regulation on frequency usage.\n"
|
||||
"Proceed on your own risk!\n"
|
||||
"Shall I write the above value(s)? (y/n)\n");
|
||||
@ -654,8 +657,10 @@ do_write_pairs(int anr, int argc, char **argv, unsigned char *mem, int mac_versi
|
||||
for (i = 0; i < wr_ops_len; i++) {
|
||||
u_int16_t oldval, u;
|
||||
|
||||
if (ath5k_hw_eeprom_read(mem, wr_ops[i].addr, &oldval, mac_version)) {
|
||||
err("failed to read old value from offset 0x%04x ", wr_ops[i].addr);
|
||||
if (ath5k_hw_eeprom_read
|
||||
(mem, wr_ops[i].addr, &oldval, mac_version)) {
|
||||
err("failed to read old value from offset 0x%04x ",
|
||||
wr_ops[i].addr);
|
||||
errors++;
|
||||
}
|
||||
|
||||
@ -665,18 +670,22 @@ do_write_pairs(int anr, int argc, char **argv, unsigned char *mem, int mac_versi
|
||||
}
|
||||
|
||||
dbg("writing *0x%04x := 0x%04x", wr_ops[i].addr, wr_ops[i].val);
|
||||
if (ath5k_hw_eeprom_write(mem, wr_ops[i].addr, wr_ops[i].val, mac_version)) {
|
||||
if (ath5k_hw_eeprom_write
|
||||
(mem, wr_ops[i].addr, wr_ops[i].val, mac_version)) {
|
||||
err("failed to write 0x%04x to offset 0x%04x",
|
||||
wr_ops[i].val, wr_ops[i].addr);
|
||||
errors++;
|
||||
} else {
|
||||
if (ath5k_hw_eeprom_read(mem, wr_ops[i].addr, &u, mac_version)) {
|
||||
err("failed to read offset 0x%04x for verification", wr_ops[i].addr);
|
||||
if (ath5k_hw_eeprom_read
|
||||
(mem, wr_ops[i].addr, &u, mac_version)) {
|
||||
err("failed to read offset 0x%04x for "
|
||||
"verification", wr_ops[i].addr);
|
||||
errors++;
|
||||
} else {
|
||||
if (u != wr_ops[i].val) {
|
||||
err("offset 0x%04x: wrote 0x%04x but read 0x%04x",
|
||||
wr_ops[i].addr, wr_ops[i].val, u);
|
||||
err("offset 0x%04x: wrote 0x%04x but "
|
||||
"read 0x%04x", wr_ops[i].addr,
|
||||
wr_ops[i].val, u);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -686,8 +695,7 @@ do_write_pairs(int anr, int argc, char **argv, unsigned char *mem, int mac_versi
|
||||
return errors ? 11 : 0;
|
||||
} /* do_write_pairs */
|
||||
|
||||
static void
|
||||
usage(const char *n)
|
||||
static void usage(const char *n)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -722,8 +730,7 @@ usage(const char *n)
|
||||
"unlawful radio transmissions!\n\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
u_int32_t dev_addr;
|
||||
u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;
|
||||
@ -745,7 +752,6 @@ main(int argc, char *argv[])
|
||||
for (i = 0; i < sizeof(gpio_set) / sizeof(gpio_set[0]); i++)
|
||||
gpio_set[i].valid = 0;
|
||||
|
||||
|
||||
if (argc < 2) {
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
@ -800,7 +806,7 @@ main(int argc, char *argv[])
|
||||
return 3;
|
||||
}
|
||||
|
||||
dev_addr = strtoul(argv[anr], NULL, 0);
|
||||
dev_addr = strtoul(argv[anr], NULL, 16);
|
||||
|
||||
fd = open("/dev/mem", O_RDWR);
|
||||
if (fd < 0) {
|
||||
@ -808,12 +814,12 @@ main(int argc, char *argv[])
|
||||
return -2;
|
||||
}
|
||||
|
||||
mem = mmap(0, AR5K_PCI_MEM_SIZE, PROT_READ | PROT_WRITE,
|
||||
mem = mmap(NULL, AR5K_PCI_MEM_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_FILE, fd, dev_addr);
|
||||
|
||||
if (mem == MAP_FAILED) {
|
||||
printf("Mmap of device at 0x%08X for 0x%X bytes failed - "
|
||||
"%s", dev_addr, AR5K_PCI_MEM_SIZE, strerror(errno));
|
||||
"%s\n", dev_addr, AR5K_PCI_MEM_SIZE, strerror(errno));
|
||||
return -3;
|
||||
}
|
||||
|
||||
@ -914,17 +920,16 @@ main(int argc, char *argv[])
|
||||
|
||||
printf(" -==Device Information==-\n");
|
||||
|
||||
printf("MAC Version: %s(0x%x) \n",
|
||||
printf("MAC Version: %-5s (0x%02x)\n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_VER, mac_version),
|
||||
mac_version);
|
||||
|
||||
printf("MAC Revision: %s(0x%x) \n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_VER, srev),
|
||||
srev);
|
||||
printf("MAC Revision: %-5s (0x%02x)\n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_VER, srev), srev);
|
||||
|
||||
/* Single-chip PHY with a/b/g support */
|
||||
if (has_b && !phy_rev_2ghz) {
|
||||
printf("PHY Revision: %s(0x%x) \n",
|
||||
printf("PHY Revision: %-5s (0x%02x)\n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_RAD, phy_rev_5ghz),
|
||||
phy_rev_5ghz);
|
||||
phy_rev_5ghz = 0;
|
||||
@ -932,7 +937,7 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Single-chip PHY with b/g support */
|
||||
if (!has_a) {
|
||||
printf("PHY Revision: %s(0x%x) \n",
|
||||
printf("PHY Revision: %-5s (0x%02x)\n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_RAD, phy_rev_2ghz),
|
||||
phy_rev_2ghz);
|
||||
phy_rev_2ghz = 0;
|
||||
@ -940,12 +945,12 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Different chip for 5Ghz and 2Ghz */
|
||||
if (phy_rev_5ghz) {
|
||||
printf("5Ghz PHY Revision: %s(0x%x) \n",
|
||||
printf("5Ghz PHY Revision: %-5s (0x%2x)\n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_RAD, phy_rev_5ghz),
|
||||
phy_rev_5ghz);
|
||||
}
|
||||
if (phy_rev_2ghz) {
|
||||
printf("2Ghz PHY Revision: %s(0x%x) \n",
|
||||
printf("2Ghz PHY Revision: %-5s (0x%2x)\n",
|
||||
ath5k_hw_get_part_name(AR5K_VERSION_RAD, phy_rev_2ghz),
|
||||
phy_rev_2ghz);
|
||||
}
|
||||
@ -960,16 +965,13 @@ main(int argc, char *argv[])
|
||||
if (eeprom_size == 0) {
|
||||
printf(" 4K\n");
|
||||
byte_size = 4096;
|
||||
}
|
||||
else if (eeprom_size == 1) {
|
||||
} else if (eeprom_size == 1) {
|
||||
printf(" 8K\n");
|
||||
byte_size = 8192;
|
||||
}
|
||||
else if (eeprom_size == 2) {
|
||||
} else if (eeprom_size == 2) {
|
||||
printf(" 16K\n");
|
||||
byte_size = 16384;
|
||||
}
|
||||
else
|
||||
} else
|
||||
printf(" ??\n");
|
||||
|
||||
printf("Regulatory Domain: 0x%X\n", regdomain);
|
||||
@ -1015,14 +1017,16 @@ main(int argc, char *argv[])
|
||||
AR5K_REG_READ(AR5K_GPIODI));
|
||||
|
||||
if (do_dump) {
|
||||
printf("\nEEPROM dump (%d byte)\n", byte_size);
|
||||
printf("==============================================");
|
||||
u_int16_t data;
|
||||
FILE *dumpfile = fopen("ath-eeprom-dump.bin", "w");
|
||||
|
||||
printf("\nEEPROM dump (%d byte)\n", byte_size);
|
||||
printf("==============================================");
|
||||
for (i = 1; i <= (byte_size / 2); i++) {
|
||||
error = ath5k_hw_eeprom_read(mem, i, &data, mac_version);
|
||||
error =
|
||||
ath5k_hw_eeprom_read(mem, i, &data, mac_version);
|
||||
if (error) {
|
||||
printf("\nUnable to read at %04x !\n", i);
|
||||
printf("\nUnable to read at %04x\n", i);
|
||||
continue;
|
||||
}
|
||||
if (!((i - 1) % 8))
|
||||
@ -1041,7 +1045,8 @@ main(int argc, char *argv[])
|
||||
int rc;
|
||||
|
||||
if (mac_version >= AR5K_SREV_VER_AR5213 && !nr_gpio_set) {
|
||||
dbg("new MAC %x (>= AR5213) set gpio4 to low", mac_version);
|
||||
dbg("new MAC %x (>= AR5213) set gpio4 to low",
|
||||
mac_version);
|
||||
gpio_set[4].valid = 1;
|
||||
gpio_set[4].value = 0;
|
||||
}
|
||||
@ -1098,4 +1103,3 @@ main(int argc, char *argv[])
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user