Add support to print a specific hardware family

This just follows the ar9003_initvals.h style for now.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
This commit is contained in:
Luis R. Rodriguez 2010-04-20 22:24:31 -07:00
parent d8e3d0678b
commit a6c4b83182

View file

@ -53,21 +53,77 @@
printf("0x%016llx "#_array"\n", chksum); \
} while (0)
#if 0
static u32 ath9k_hw_print_initval(const u32 *array, u32 rows, u32 columns)
//printf("/* "#_array" checksum: 0x%016llx */\n", chksum); \
#define INI_PRINT(_array, _cols) \
do { \
chksum = ath9k_hw_check_initval((const u32 *) &_array,\
ARRAY_SIZE(_array), _cols); \
printf("static const u32 "#_array"[][%d] = {\n", _cols); \
ath9k_hw_print_initval((const u32 *) _array, \
ARRAY_SIZE(_array), _cols); \
} while (0)
static void print_license(void)
{
printf("/*\n");
printf(" * Copyright (c) 2010 Atheros Communications Inc.\n");
printf(" *\n");
printf(" * Permission to use, copy, modify, and/or distribute this software for any\n");
printf(" * purpose with or without fee is hereby granted, provided that the above\n");
printf(" * copyright notice and this permission notice appear in all copies.\n");
printf(" *\n");
printf(" * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n");
printf(" * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n");
printf(" * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n");
printf(" * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n");
printf(" * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n");
printf(" * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n");
printf(" * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n");
printf(" */\n");
printf("\n");
}
static void ath9k_hw_print_initval(const u32 *array, u32 rows, u32 columns)
{
u32 chksum, col, row;
/*
* This checksum stuff is designed for columns <= 8),
* and spreads the checksum over 64 bits but since currently
* the initval max column size is 6 we only use the first 48
* bits.
*/
if (columns > 6)
return;
switch (columns) {
case 5:
printf("\t/* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */\n");
break;
case 3:
printf("\t/* Addr 5G_HT20 5G_HT40 */\n");
break;
case 2:
printf("\t/* Addr allmodes */\n");
break;
default:
break;
}
for (row = 0; row < rows; row++) {
for (col = 0; col < columns; col++) {
printf("0x%04x", array[row * columns + col]);
if (!col)
printf("\t{");
printf("0x%08x", array[row * columns + col]);
if (col + 1 < columns)
printf(", ");
}
printf("\n");
printf("},\n");
}
printf("}\n\n");
}
#endif
static u64 ath9k_hw_check_initval(const u32 *array, u32 rows, u32 columns)
{
@ -233,18 +289,184 @@ static void ar9003_hw_check_initvals(void)
INI_CHECK(ar9300PciePhy_clkreq_disable_L1_2p0, 2);
}
#ifndef ATHEROS
static void ar5008_hw_print_initvals(void)
{
u64 chksum;
INI_PRINT(ar5416Modes, 6);
INI_PRINT(ar5416Common, 2);
INI_PRINT(ar5416Bank0, 2);
INI_PRINT(ar5416BB_RfGain, 3);
INI_PRINT(ar5416Bank1, 2);
INI_PRINT(ar5416Bank2, 2);
INI_PRINT(ar5416Bank3, 3);
INI_PRINT(ar5416Bank6, 3);
INI_PRINT(ar5416Bank6TPC, 3);
INI_PRINT(ar5416Bank7, 2);
INI_PRINT(ar5416Addac, 2);
}
#else
static void ar5008_hw_print_initvals(void)
{
}
#endif /* ATHEROS */
#ifndef ATHEROS
static void ar9001_hw_print_initvals(void)
{
u64 chksum;
INI_PRINT(ar5416Modes_9100, 6);
INI_PRINT(ar5416Common_9100, 2);
INI_PRINT(ar5416Bank0_9100, 2);
INI_PRINT(ar5416BB_RfGain_9100, 3);
INI_PRINT(ar5416Bank1_9100, 2);
INI_PRINT(ar5416Bank2_9100, 2);
INI_PRINT(ar5416Bank3_9100, 3);
INI_PRINT(ar5416Bank6_9100, 3);
INI_PRINT(ar5416Bank6TPC_9100, 3);
INI_PRINT(ar5416Bank7_9100, 2);
INI_PRINT(ar5416Addac_9100, 2);
INI_PRINT(ar5416Modes_9160, 6);
INI_PRINT(ar5416Common_9160, 2);
INI_PRINT(ar5416Bank0_9160, 2);
INI_PRINT(ar5416BB_RfGain_9160, 3);
INI_PRINT(ar5416Bank1_9160, 2);
INI_PRINT(ar5416Bank2_9160, 2);
INI_PRINT(ar5416Bank3_9160, 3);
INI_PRINT(ar5416Bank6_9160, 3);
INI_PRINT(ar5416Bank6TPC_9160, 3);
INI_PRINT(ar5416Bank7_9160, 2);
INI_PRINT(ar5416Addac_9160, 2);
INI_PRINT(ar5416Addac_91601_1, 2);
}
#else
static void ar9001_hw_print_initvals(void)
{
}
#endif /* ATHEROS */
#ifndef ATHEROS
static void ar9002_hw_print_initvals(void)
{
u64 chksum;
INI_PRINT(ar9280Modes_9280, 6);
INI_PRINT(ar9280Common_9280, 2);
INI_PRINT(ar9280Modes_9280_2, 6);
INI_PRINT(ar9280Common_9280_2, 2);
INI_PRINT(ar9280Modes_fast_clock_9280_2, 3);
INI_PRINT(ar9280Modes_backoff_23db_rxgain_9280_2, 6);
INI_PRINT(ar9280Modes_original_rxgain_9280_2, 6);
INI_PRINT(ar9280Modes_backoff_13db_rxgain_9280_2, 6);
INI_PRINT(ar9280Modes_high_power_tx_gain_9280_2, 6);
INI_PRINT(ar9280Modes_original_tx_gain_9280_2, 6);
INI_PRINT(ar9280PciePhy_clkreq_off_L1_9280, 2);
INI_PRINT(ar9280PciePhy_clkreq_always_on_L1_9280, 2);
INI_PRINT(ar9285Modes_9285, 6);
INI_PRINT(ar9285Common_9285, 2);
INI_PRINT(ar9285PciePhy_clkreq_always_on_L1_9285, 2);
INI_PRINT(ar9285PciePhy_clkreq_off_L1_9285, 2);
INI_PRINT(ar9285Modes_9285_1_2, 6);
INI_PRINT(ar9285Common_9285_1_2, 2);
INI_PRINT(ar9285Modes_high_power_tx_gain_9285_1_2, 6);
INI_PRINT(ar9285Modes_original_tx_gain_9285_1_2, 6);
INI_PRINT(ar9285Modes_XE2_0_normal_power, 6);
INI_PRINT(ar9285Modes_XE2_0_high_power, 6);
INI_PRINT(ar9285PciePhy_clkreq_always_on_L1_9285_1_2, 2);
INI_PRINT(ar9285PciePhy_clkreq_off_L1_9285_1_2, 2);
INI_PRINT(ar9287Modes_9287_1_0, 6);
INI_PRINT(ar9287Common_9287_1_0, 2);
INI_PRINT(ar9287Modes_tx_gain_9287_1_0, 6);
INI_PRINT(ar9287Modes_rx_gain_9287_1_0, 6);
INI_PRINT(ar9287PciePhy_clkreq_always_on_L1_9287_1_0, 2);
INI_PRINT(ar9287PciePhy_clkreq_off_L1_9287_1_0, 2);
INI_PRINT(ar9287Modes_9287_1_1, 6);
INI_PRINT(ar9287Common_9287_1_1, 2);
INI_PRINT(ar9287Common_normal_cck_fir_coeff_92871_1, 2);
INI_PRINT(ar9287Common_japan_2484_cck_fir_coeff_92871_1, 2);
INI_PRINT(ar9287Modes_tx_gain_9287_1_1, 6);
INI_PRINT(ar9287Modes_rx_gain_9287_1_1, 6);
INI_PRINT(ar9287PciePhy_clkreq_always_on_L1_9287_1_1, 2);
INI_PRINT(ar9287PciePhy_clkreq_off_L1_9287_1_1, 2);
INI_PRINT(ar9271Modes_9271, 6);
INI_PRINT(ar9271Common_9271, 2);
INI_PRINT(ar9271Common_normal_cck_fir_coeff_9271, 2);
INI_PRINT(ar9271Common_japan_2484_cck_fir_coeff_9271, 2);
INI_PRINT(ar9271Modes_9271_1_0_only, 6);
INI_PRINT(ar9271Modes_9271_ANI_reg, 6);
INI_PRINT(ar9271Modes_normal_power_tx_gain_9271, 6);
INI_PRINT(ar9271Modes_high_power_tx_gain_9271, 6);
}
#else
static void ar9002_hw_print_initvals(void)
{
}
#endif /* ATHEROS */
static void ar9003_hw_print_initvals(void)
{
u64 chksum;
INI_PRINT(ar9300_2p0_radio_postamble, 5);
INI_PRINT(ar9300Modes_lowest_ob_db_tx_gain_table_2p0, 5);
INI_PRINT(ar9300Modes_fast_clock_2p0, 3);
INI_PRINT(ar9300_2p0_radio_core, 2);
INI_PRINT(ar9300Common_rx_gain_table_merlin_2p0, 2);
INI_PRINT(ar9300_2p0_mac_postamble, 5);
INI_PRINT(ar9300_2p0_soc_postamble, 5);
INI_PRINT(ar9200_merlin_2p0_radio_core, 2);
INI_PRINT(ar9300_2p0_baseband_postamble, 5);
INI_PRINT(ar9300_2p0_baseband_core, 2);
INI_PRINT(ar9300Modes_high_power_tx_gain_table_2p0, 5);
INI_PRINT(ar9300Modes_high_ob_db_tx_gain_table_2p0, 5);
INI_PRINT(ar9300Common_rx_gain_table_2p0, 2);
INI_PRINT(ar9300Modes_low_ob_db_tx_gain_table_2p0, 5);
INI_PRINT(ar9300_2p0_mac_core, 2);
INI_PRINT(ar9300Common_wo_xlna_rx_gain_table_2p0, 2);
INI_PRINT(ar9300_2p0_soc_preamble, 2);
INI_PRINT(ar9300PciePhy_pll_on_clkreq_disable_L1_2p0, 2);
INI_PRINT(ar9300PciePhy_clkreq_enable_L1_2p0, 2);
INI_PRINT(ar9300PciePhy_clkreq_disable_L1_2p0, 2);
}
#ifndef ATHEROS
static void usage()
{
printf("Usage: initvals [-f ar5008 | ar9001 | ar9002 | ar9003 ]\n");
printf("Usage: initvals [-w ] [-f ar5008 | ar9001 | ar9002 | ar9003 ]\n");
}
#else
static void usage()
{
printf("Usage: initvals [-f ar9003 ]\n");
printf("Usage: initvals [-w ] [-f ar9003 ]\n");
}
#endif
#ifndef ATHEROS
print_initvals_family(char *family)
{
print_license();
if (strncmp(family, "ar5008", 6) == 0)
ar5008_hw_print_initvals();
else if (strncmp(family, "ar9001", 6) == 0)
ar9001_hw_print_initvals();
else if (strncmp(family, "ar9002", 6) == 0)
ar9002_hw_print_initvals();
else if (strncmp(family, "ar9003", 6) == 0)
ar9003_hw_print_initvals();
}
#else
print_initvals_family(char *family)
{
print_license();
if (strncmp(family, "ar9003", 6) == 0)
ar9003_hw_print_initvals();
}
#endif /* ATHEROS */
#ifndef ATHEROS
check_initvals_family(char *family)
{
@ -269,11 +491,33 @@ int main(int argc, void *argv[])
{
if (argc > 1) {
if (argc != 3) {
if (argc == 2) {
if (strncmp(argv[1], "-w", 2) != 0)
return -1;
ar5008_hw_print_initvals();
ar9001_hw_print_initvals();
ar9002_hw_print_initvals();
ar9003_hw_print_initvals();
return 0;
}
if (argc != 3 && argc != 4) {
usage();
return -1;
}
check_initvals_family(argv[2]);
if (argc == 3) {
check_initvals_family(argv[2]);
return 0;
}
if (strncmp(argv[1], "-w", 2) != 0)
return -1;
print_initvals_family(argv[3]);
return 0;
}