Path: blob/main/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h
48525 views
/*1* Copyright (c) 2013 Qualcomm Atheros, Inc.2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH8* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY9* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,10* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM11* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR12* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR13* PERFORMANCE OF THIS SOFTWARE.14*/1516#ifndef _ATH_AR9300_H_17#define _ATH_AR9300_H_1819#include "ar9300_freebsd_inc.h"2021/* XXX doesn't belong here */22#define AR_EEPROM_MODAL_SPURS 52324/* Ensure that AH_BYTE_ORDER is defined */25#ifndef AH_BYTE_ORDER26#error AH_BYTE_ORDER needs to be defined!27#endif2829/*30* (a) this should be N(a),31* (b) FreeBSD does define nitems,32* (c) it doesn't have an AH_ prefix, sigh.33*/34#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))3536#include "ah_internal.h"37#include "ah_eeprom.h"38#include "ah_devid.h"39#include "ar9300eep.h" /* For Eeprom definitions */4041#define AR9300_MAGIC 0x197410144243/* MAC register values */4445#define INIT_CONFIG_STATUS 0x0000000046#define INIT_RSSI_THR 0x7 /* Missed beacon counter initialized to 0x7 (max is 0xff) */47#define INIT_RSSI_BEACON_WEIGHT 8 /* ave beacon rssi weight (0-16) */4849/*50* Various fifo fill before Tx start, in 64-byte units51* i.e. put the frame in the air while still DMAing52*/53#define MIN_TX_FIFO_THRESHOLD 0x154#define MAX_TX_FIFO_THRESHOLD (( 4096 / 64) - 1)55#define INIT_TX_FIFO_THRESHOLD MIN_TX_FIFO_THRESHOLD5657#define CHANSEL_DIV 1558#define FCLK 405960#define COEFF ((FCLK * 5) / 2)61#define CHANSEL_2G(_freq) (((_freq) * 0x10000) / CHANSEL_DIV)62#define CHANSEL_5G(_freq) (((_freq) * 0x8000) / CHANSEL_DIV)63#define CHANSEL_5G_DOT5MHZ 21886465/*66* Receive Queue Fifo depth.67*/68enum RX_FIFO_DEPTH {69HAL_HP_RXFIFO_DEPTH = 16,70HAL_LP_RXFIFO_DEPTH = 128,71};7273/*74* Gain support.75*/76#define NUM_CORNER_FIX_BITS_2133 777#define CCK_OFDM_GAIN_DELTA 157879enum GAIN_PARAMS {80GP_TXCLIP,81GP_PD90,82GP_PD84,83GP_GSEL84};8586enum GAIN_PARAMS_2133 {87GP_MIXGAIN_OVR,88GP_PWD_138,89GP_PWD_137,90GP_PWD_136,91GP_PWD_132,92GP_PWD_131,93GP_PWD_130,94};9596typedef struct _gain_opt_step {97int16_t paramVal[NUM_CORNER_FIX_BITS_2133];98int32_t stepGain;99int8_t stepName[16];100} GAIN_OPTIMIZATION_STEP;101102typedef struct {103u_int32_t numStepsInLadder;104u_int32_t defaultStepNum;105GAIN_OPTIMIZATION_STEP optStep[10];106} GAIN_OPTIMIZATION_LADDER;107108typedef struct {109u_int32_t currStepNum;110u_int32_t currGain;111u_int32_t targetGain;112u_int32_t loTrig;113u_int32_t hiTrig;114u_int32_t gainFCorrection;115u_int32_t active;116GAIN_OPTIMIZATION_STEP *curr_step;117} GAIN_VALUES;118119typedef struct {120u_int16_t synth_center;121u_int16_t ctl_center;122u_int16_t ext_center;123} CHAN_CENTERS;124125/* RF HAL structures */126typedef struct rf_hal_funcs {127HAL_BOOL (*set_channel)(struct ath_hal *, struct ieee80211_channel *);128HAL_BOOL (*get_chip_power_lim)(struct ath_hal *ah,129struct ieee80211_channel *chan);130} RF_HAL_FUNCS;131132struct ar9300_ani_default {133u_int16_t m1_thresh_low;134u_int16_t m2_thresh_low;135u_int16_t m1_thresh;136u_int16_t m2_thresh;137u_int16_t m2_count_thr;138u_int16_t m2_count_thr_low;139u_int16_t m1_thresh_low_ext;140u_int16_t m2_thresh_low_ext;141u_int16_t m1_thresh_ext;142u_int16_t m2_thresh_ext;143u_int16_t firstep;144u_int16_t firstep_low;145u_int16_t cycpwr_thr1;146u_int16_t cycpwr_thr1_ext;147};148149/*150* Per-channel ANI state private to the driver.151*/152struct ar9300_ani_state {153struct ieee80211_channel c; /* XXX ew? */154HAL_BOOL must_restore;155HAL_BOOL ofdms_turn;156u_int8_t ofdm_noise_immunity_level;157u_int8_t cck_noise_immunity_level;158u_int8_t spur_immunity_level;159u_int8_t firstep_level;160u_int8_t ofdm_weak_sig_detect_off;161u_int8_t mrc_cck_off;162163/* Thresholds */164u_int32_t listen_time;165u_int32_t ofdm_trig_high;166u_int32_t ofdm_trig_low;167int32_t cck_trig_high;168int32_t cck_trig_low;169int32_t rssi_thr_low;170int32_t rssi_thr_high;171172int32_t rssi; /* The current RSSI */173u_int32_t tx_frame_count; /* Last tx_frame_count */174u_int32_t rx_frame_count; /* Last rx Frame count */175u_int32_t rx_busy_count; /* Last rx busy count */176u_int32_t rx_ext_busy_count; /* Last rx busy count; extension channel */177u_int32_t cycle_count; /* Last cycle_count (can detect wrap-around) */178u_int32_t ofdm_phy_err_count;/* OFDM err count since last reset */179u_int32_t cck_phy_err_count; /* CCK err count since last reset */180181struct ar9300_ani_default ini_def; /* INI default values for ANI registers */182HAL_BOOL phy_noise_spur; /* based on OFDM/CCK Phy errors */183};184185#define AR9300_ANI_POLLINTERVAL 1000 /* 1000 milliseconds between ANI poll */186187#define AR9300_CHANNEL_SWITCH_TIME_USEC 1000 /* 1 millisecond needed to change channels */188189#define HAL_PROCESS_ANI 0x00000001 /* ANI state setup */190#define HAL_RADAR_EN 0x80000000 /* Radar detect is capable */191#define HAL_AR_EN 0x40000000 /* AR detect is capable */192193#define DO_ANI(ah) \194((AH9300(ah)->ah_proc_phy_err & HAL_PROCESS_ANI))195196#if 0197struct ar9300_stats {198u_int32_t ast_ani_niup; /* ANI increased noise immunity */199u_int32_t ast_ani_nidown; /* ANI decreased noise immunity */200u_int32_t ast_ani_spurup; /* ANI increased spur immunity */201u_int32_t ast_ani_spurdown;/* ANI descreased spur immunity */202u_int32_t ast_ani_ofdmon; /* ANI OFDM weak signal detect on */203u_int32_t ast_ani_ofdmoff;/* ANI OFDM weak signal detect off */204u_int32_t ast_ani_cckhigh;/* ANI CCK weak signal threshold high */205u_int32_t ast_ani_ccklow; /* ANI CCK weak signal threshold low */206u_int32_t ast_ani_stepup; /* ANI increased first step level */207u_int32_t ast_ani_stepdown;/* ANI decreased first step level */208u_int32_t ast_ani_ofdmerrs;/* ANI cumulative ofdm phy err count */209u_int32_t ast_ani_cckerrs;/* ANI cumulative cck phy err count */210u_int32_t ast_ani_reset; /* ANI parameters zero'd for non-STA */211u_int32_t ast_ani_lzero; /* ANI listen time forced to zero */212u_int32_t ast_ani_lneg; /* ANI listen time calculated < 0 */213HAL_MIB_STATS ast_mibstats; /* MIB counter stats */214HAL_NODE_STATS ast_nodestats; /* Latest rssi stats from driver */215};216#endif217218struct ar9300_rad_reader {219u_int16_t rd_index;220u_int16_t rd_expSeq;221u_int32_t rd_resetVal;222u_int8_t rd_start;223};224225struct ar9300_rad_writer {226u_int16_t wr_index;227u_int16_t wr_seq;228};229230struct ar9300_radar_event {231u_int32_t re_ts; /* 32 bit time stamp */232u_int8_t re_rssi; /* rssi of radar event */233u_int8_t re_dur; /* duration of radar pulse */234u_int8_t re_chanIndex; /* Channel of event */235};236237struct ar9300_radar_q_elem {238u_int32_t rq_seqNum;239u_int32_t rq_busy; /* 32 bit to insure atomic read/write */240struct ar9300_radar_event rq_event; /* Radar event */241};242243struct ar9300_radar_q_info {244u_int16_t ri_qsize; /* q size */245u_int16_t ri_seqSize; /* Size of sequence ring */246struct ar9300_rad_reader ri_reader; /* State for the q reader */247struct ar9300_rad_writer ri_writer; /* state for the q writer */248};249250#define HAL_MAX_ACK_RADAR_DUR 511251#define HAL_MAX_NUM_PEAKS 3252#define HAL_ARQ_SIZE 4096 /* 8K AR events for buffer size */253#define HAL_ARQ_SEQSIZE 4097 /* Sequence counter wrap for AR */254#define HAL_RADARQ_SIZE 1024 /* 1K radar events for buffer size */255#define HAL_RADARQ_SEQSIZE 1025 /* Sequence counter wrap for radar */256#define HAL_NUMRADAR_STATES 64 /* Number of radar channels we keep state for */257258struct ar9300_ar_state {259u_int16_t ar_prev_time_stamp;260u_int32_t ar_prev_width;261u_int32_t ar_phy_err_count[HAL_MAX_ACK_RADAR_DUR];262u_int32_t ar_ack_sum;263u_int16_t ar_peak_list[HAL_MAX_NUM_PEAKS];264u_int32_t ar_packet_threshold; /* Thresh to determine traffic load */265u_int32_t ar_par_threshold; /* Thresh to determine peak */266u_int32_t ar_radar_rssi; /* Rssi threshold for AR event */267};268269struct ar9300_radar_state {270struct ieee80211_channel *rs_chan; /* Channel info */271u_int8_t rs_chan_index; /* Channel index in radar structure */272u_int32_t rs_num_radar_events; /* Number of radar events */273int32_t rs_firpwr; /* Thresh to check radar sig is gone */274u_int32_t rs_radar_rssi; /* Thresh to start radar det (dB) */275u_int32_t rs_height; /* Thresh for pulse height (dB)*/276u_int32_t rs_pulse_rssi; /* Thresh to check if pulse is gone (dB) */277u_int32_t rs_inband; /* Thresh to check if pusle is inband (0.5 dB) */278};279typedef struct {280u_int8_t uc_receiver_errors;281u_int8_t uc_bad_tlp_errors;282u_int8_t uc_bad_dllp_errors;283u_int8_t uc_replay_timeout_errors;284u_int8_t uc_replay_number_rollover_errors;285} ar_pcie_error_moniter_counters;286287#define AR9300_OPFLAGS_11A 0x01 /* if set, allow 11a */288#define AR9300_OPFLAGS_11G 0x02 /* if set, allow 11g */289#define AR9300_OPFLAGS_N_5G_HT40 0x04 /* if set, disable 5G HT40 */290#define AR9300_OPFLAGS_N_2G_HT40 0x08 /* if set, disable 2G HT40 */291#define AR9300_OPFLAGS_N_5G_HT20 0x10 /* if set, disable 5G HT20 */292#define AR9300_OPFLAGS_N_2G_HT20 0x20 /* if set, disable 2G HT20 */293294/*295* For Kite and later chipsets, the following bits are not being programmed in EEPROM296* and so need to be enabled always.297* Bit 0: en_fcc_mid, Bit 1: en_jap_mid, Bit 2: en_fcc_dfs_ht40298* Bit 3: en_jap_ht40, Bit 4: en_jap_dfs_ht40299*/300#define AR9300_RDEXT_DEFAULT 0x1F301302#define AR9300_MAX_CHAINS 3303#define AR9300_NUM_CHAINS(chainmask) \304(((chainmask >> 2) & 1) + ((chainmask >> 1) & 1) + (chainmask & 1))305#define AR9300_CHAIN0_MASK 0x1306#define AR9300_CHAIN1_MASK 0x2307#define AR9300_CHAIN2_MASK 0x4308309/* Support for multiple INIs */310struct ar9300_ini_array {311const u_int32_t *ia_array;312u_int32_t ia_rows;313u_int32_t ia_columns;314};315#define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \316(iniarray)->ia_array = (const u_int32_t *)(array); \317(iniarray)->ia_rows = (rows); \318(iniarray)->ia_columns = (columns); \319} while (0)320#define INI_RA(iniarray, row, column) (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])321322#define INIT_CAL(_perCal) \323(_perCal)->cal_state = CAL_WAITING; \324(_perCal)->cal_next = AH_NULL;325326#define INSERT_CAL(_ahp, _perCal) \327do { \328if ((_ahp)->ah_cal_list_last == AH_NULL) { \329(_ahp)->ah_cal_list = (_ahp)->ah_cal_list_last = (_perCal); \330((_ahp)->ah_cal_list_last)->cal_next = (_perCal); \331} else { \332((_ahp)->ah_cal_list_last)->cal_next = (_perCal); \333(_ahp)->ah_cal_list_last = (_perCal); \334(_perCal)->cal_next = (_ahp)->ah_cal_list; \335} \336} while (0)337338typedef enum cal_types {339IQ_MISMATCH_CAL = 0x1,340TEMP_COMP_CAL = 0x2,341} HAL_CAL_TYPES;342343typedef enum cal_state {344CAL_INACTIVE,345CAL_WAITING,346CAL_RUNNING,347CAL_DONE348} HAL_CAL_STATE; /* Calibrate state */349350#define MIN_CAL_SAMPLES 1351#define MAX_CAL_SAMPLES 64352#define INIT_LOG_COUNT 5353#define PER_MIN_LOG_COUNT 2354#define PER_MAX_LOG_COUNT 10355356#define AR9300_NUM_BT_WEIGHTS 4357#define AR9300_NUM_WLAN_WEIGHTS 4358359/* Per Calibration data structure */360typedef struct per_cal_data {361HAL_CAL_TYPES cal_type; // Type of calibration362u_int32_t cal_num_samples; // Number of SW samples to collect363u_int32_t cal_count_max; // Number of HW samples to collect364void (*cal_collect)(struct ath_hal *, u_int8_t); // Accumulator func365void (*cal_post_proc)(struct ath_hal *, u_int8_t); // Post-processing func366} HAL_PERCAL_DATA;367368/* List structure for calibration data */369typedef struct cal_list {370const HAL_PERCAL_DATA *cal_data;371HAL_CAL_STATE cal_state;372struct cal_list *cal_next;373} HAL_CAL_LIST;374375#define AR9300_NUM_CAL_TYPES 2376#define AR9300_PAPRD_TABLE_SZ 24377#define AR9300_PAPRD_GAIN_TABLE_SZ 32378#define AR9382_MAX_GPIO_PIN_NUM (16)379#define AR9382_GPIO_PIN_8_RESERVED (8)380#define AR9382_GPIO_9_INPUT_ONLY (9)381#define AR9382_MAX_GPIO_INPUT_PIN_NUM (13)382#define AR9382_GPIO_PIN_11_RESERVED (11)383#define AR9382_MAX_JTAG_GPIO_PIN_NUM (3)384385/* Paprd tx power adjust data structure */386struct ar9300_paprd_pwr_adjust {387u_int32_t target_rate; // rate index388u_int32_t reg_addr; // register offset389u_int32_t reg_mask; // mask of register390u_int32_t reg_mask_offset; // mask offset of register391u_int32_t sub_db; // offset value unit of dB392};393394struct ar9300NfLimits {395int16_t max;396int16_t min;397int16_t nominal;398};399400#define AR9300_MAX_RATES 36 /* legacy(4) + ofdm(8) + HTSS(8) + HTDS(8) + HTTS(8)*/401struct ath_hal_9300 {402struct ath_hal_private ah_priv; /* base class */403404/*405* Information retrieved from EEPROM.406*/407ar9300_eeprom_t ah_eeprom;408409GAIN_VALUES ah_gain_values;410411u_int8_t ah_macaddr[IEEE80211_ADDR_LEN];412u_int8_t ah_bssid[IEEE80211_ADDR_LEN];413u_int8_t ah_bssid_mask[IEEE80211_ADDR_LEN];414u_int16_t ah_assoc_id;415416/*417* Runtime state.418*/419u_int32_t ah_mask_reg; /* copy of AR_IMR */420u_int32_t ah_mask2Reg; /* copy of AR_IMR_S2 */421u_int32_t ah_msi_reg; /* copy of AR_PCIE_MSI */422os_atomic_t ah_ier_ref_count; /* reference count for enabling interrupts */423HAL_ANI_STATS ah_stats; /* various statistics */424RF_HAL_FUNCS ah_rf_hal;425u_int32_t ah_tx_desc_mask; /* mask for TXDESC */426u_int32_t ah_tx_ok_interrupt_mask;427u_int32_t ah_tx_err_interrupt_mask;428u_int32_t ah_tx_desc_interrupt_mask;429u_int32_t ah_tx_eol_interrupt_mask;430u_int32_t ah_tx_urn_interrupt_mask;431HAL_TX_QUEUE_INFO ah_txq[HAL_NUM_TX_QUEUES];432HAL_SMPS_MODE ah_sm_power_mode;433HAL_BOOL ah_chip_full_sleep;434u_int32_t ah_atim_window;435HAL_ANT_SETTING ah_diversity_control; /* antenna setting */436u_int16_t ah_antenna_switch_swap; /* Controls mapping of OID request */437u_int8_t ah_tx_chainmask_cfg; /* chain mask config */438u_int8_t ah_rx_chainmask_cfg;439u_int32_t ah_beacon_rssi_threshold; /* cache beacon rssi threshold */440/* Calibration related fields */441HAL_CAL_TYPES ah_supp_cals;442HAL_CAL_LIST ah_iq_cal_data; /* IQ Cal Data */443HAL_CAL_LIST ah_temp_comp_cal_data; /* Temperature Compensation Cal Data */444HAL_CAL_LIST *ah_cal_list; /* ptr to first cal in list */445HAL_CAL_LIST *ah_cal_list_last; /* ptr to last cal in list */446HAL_CAL_LIST *ah_cal_list_curr; /* ptr to current cal */447// IQ Cal aliases448#define ah_total_power_meas_i ah_meas0.unsign449#define ah_total_power_meas_q ah_meas1.unsign450#define ah_total_iq_corr_meas ah_meas2.sign451union {452u_int32_t unsign[AR9300_MAX_CHAINS];453int32_t sign[AR9300_MAX_CHAINS];454} ah_meas0;455union {456u_int32_t unsign[AR9300_MAX_CHAINS];457int32_t sign[AR9300_MAX_CHAINS];458} ah_meas1;459union {460u_int32_t unsign[AR9300_MAX_CHAINS];461int32_t sign[AR9300_MAX_CHAINS];462} ah_meas2;463union {464u_int32_t unsign[AR9300_MAX_CHAINS];465int32_t sign[AR9300_MAX_CHAINS];466} ah_meas3;467u_int16_t ah_cal_samples;468/* end - Calibration related fields */469u_int32_t ah_tx6_power_in_half_dbm; /* power output for 6Mb tx */470u_int32_t ah_sta_id1_defaults; /* STA_ID1 default settings */471u_int32_t ah_misc_mode; /* MISC_MODE settings */472HAL_BOOL ah_get_plcp_hdr; /* setting about MISC_SEL_EVM */473enum {474AUTO_32KHZ, /* use it if 32kHz crystal present */475USE_32KHZ, /* do it regardless */476DONT_USE_32KHZ, /* don't use it regardless */477} ah_enable32k_hz_clock; /* whether to sleep at 32kHz */478479u_int32_t ah_ofdm_tx_power;480int16_t ah_tx_power_index_offset;481482u_int ah_slot_time; /* user-specified slot time */483u_int ah_ack_timeout; /* user-specified ack timeout */484/*485* XXX486* 11g-specific stuff; belongs in the driver.487*/488u_int8_t ah_g_beacon_rate; /* fixed rate for G beacons */489u_int32_t ah_gpio_mask; /* copy of enabled GPIO mask */490u_int32_t ah_gpio_cause; /* copy of GPIO cause (sync and async) */491/*492* RF Silent handling; setup according to the EEPROM.493*/494u_int32_t ah_gpio_select; /* GPIO pin to use */495u_int32_t ah_polarity; /* polarity to disable RF */496u_int32_t ah_gpio_bit; /* after init, prev value */497HAL_BOOL ah_eep_enabled; /* EEPROM bit for capability */498499#ifdef ATH_BT_COEX500/*501* Bluetooth coexistence static setup according to the registry502*/503HAL_BT_MODULE ah_bt_module; /* Bluetooth module identifier */504u_int8_t ah_bt_coex_config_type; /* BT coex configuration */505u_int8_t ah_bt_active_gpio_select; /* GPIO pin for BT_ACTIVE */506u_int8_t ah_bt_priority_gpio_select; /* GPIO pin for BT_PRIORITY */507u_int8_t ah_wlan_active_gpio_select; /* GPIO pin for WLAN_ACTIVE */508u_int8_t ah_bt_active_polarity; /* Polarity of BT_ACTIVE */509HAL_BOOL ah_bt_coex_single_ant; /* Single or dual antenna configuration */510u_int8_t ah_bt_wlan_isolation; /* Isolation between BT and WLAN in dB */511/*512* Bluetooth coexistence runtime settings513*/514HAL_BOOL ah_bt_coex_enabled; /* If Bluetooth coexistence is enabled */515u_int32_t ah_bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */516u_int32_t ah_bt_coex_bt_weight[AR9300_NUM_BT_WEIGHTS]; /* Register setting for AR_BT_COEX_WEIGHT */517u_int32_t ah_bt_coex_wlan_weight[AR9300_NUM_WLAN_WEIGHTS]; /* Register setting for AR_BT_COEX_WEIGHT */518u_int32_t ah_bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */519u_int32_t ah_bt_coex_flag; /* Special tuning flags for BT coex */520#endif521522/*523* Generic timer support524*/525u_int32_t ah_avail_gen_timers; /* mask of available timers */526u_int32_t ah_intr_gen_timer_trigger; /* generic timer trigger interrupt state */527u_int32_t ah_intr_gen_timer_thresh; /* generic timer trigger interrupt state */528HAL_BOOL ah_enable_tsf2; /* enable TSF2 for gen timer 8-15. */529530/*531* ANI & Radar support.532*/533u_int32_t ah_proc_phy_err; /* Process Phy errs */534u_int32_t ah_ani_period; /* ani update list period */535struct ar9300_ani_state *ah_curani; /* cached last reference */536struct ar9300_ani_state ah_ani[255]; /* per-channel state */537struct ar9300_radar_state ah_radar[HAL_NUMRADAR_STATES]; /* Per-Channel Radar detector state */538struct ar9300_radar_q_elem *ah_radarq; /* radar event queue */539struct ar9300_radar_q_info ah_radarq_info; /* radar event q read/write state */540struct ar9300_ar_state ah_ar; /* AR detector state */541struct ar9300_radar_q_elem *ah_arq; /* AR event queue */542struct ar9300_radar_q_info ah_arq_info; /* AR event q read/write state */543544/*545* Transmit power state. Note these are maintained546* here so they can be retrieved by diagnostic tools.547*/548u_int16_t ah_rates_array[16];549550/*551* Tx queue interrupt state.552*/553u_int32_t ah_intr_txqs;554555HAL_BOOL ah_intr_mitigation_rx; /* rx Interrupt Mitigation Settings */556HAL_BOOL ah_intr_mitigation_tx; /* tx Interrupt Mitigation Settings */557558/*559* Extension Channel Rx Clear State560*/561u_int32_t ah_cycle_count;562u_int32_t ah_ctl_busy;563u_int32_t ah_ext_busy;564565/* HT CWM state */566HAL_HT_EXTPROTSPACING ah_ext_prot_spacing;567u_int8_t ah_tx_chainmask; /* tx chain mask */568u_int8_t ah_rx_chainmask; /* rx chain mask */569570/* optional tx chainmask */571u_int8_t ah_tx_chainmaskopt;572573u_int8_t ah_tx_cal_chainmask; /* tx cal chain mask */574u_int8_t ah_rx_cal_chainmask; /* rx cal chain mask */575576int ah_hwp;577void *ah_cal_mem;578HAL_BOOL ah_emu_eeprom;579580HAL_ANI_CMD ah_ani_function;581HAL_BOOL ah_rifs_enabled;582u_int32_t ah_rifs_reg[11];583u_int32_t ah_rifs_sec_cnt;584585/* open-loop power control */586u_int32_t original_gain[22];587int32_t init_pdadc;588int32_t pdadc_delta;589590/* cycle counts for beacon stuck diagnostics */591u_int32_t ah_cycles;592u_int32_t ah_rx_clear;593u_int32_t ah_rx_frame;594u_int32_t ah_tx_frame;595596#define BB_HANG_SIG1 0597#define BB_HANG_SIG2 1598#define BB_HANG_SIG3 2599#define BB_HANG_SIG4 3600#define MAC_HANG_SIG1 4601#define MAC_HANG_SIG2 5602/* bb hang detection */603int ah_hang[6];604hal_hw_hangs_t ah_hang_wars;605606/*607* Keytable type table608*/609#define AR_KEYTABLE_SIZE 128 /* XXX! */610uint8_t ah_keytype[AR_KEYTABLE_SIZE];611#undef AR_KEYTABLE_SIZE612/*613* Support for ar9300 multiple INIs614*/615struct ar9300_ini_array ah_ini_pcie_serdes;616struct ar9300_ini_array ah_ini_pcie_serdes_low_power;617struct ar9300_ini_array ah_ini_modes_additional;618struct ar9300_ini_array ah_ini_modes_additional_40mhz;619struct ar9300_ini_array ah_ini_modes_rxgain;620struct ar9300_ini_array ah_ini_modes_rxgain_bounds;621struct ar9300_ini_array ah_ini_modes_txgain;622struct ar9300_ini_array ah_ini_japan2484;623struct ar9300_ini_array ah_ini_radio_post_sys2ant;624struct ar9300_ini_array ah_ini_BTCOEX_MAX_TXPWR;625struct ar9300_ini_array ah_ini_modes_rxgain_xlna;626struct ar9300_ini_array ah_ini_modes_rxgain_bb_core;627struct ar9300_ini_array ah_ini_modes_rxgain_bb_postamble;628629/*630* New INI format starting with Osprey 2.0 INI.631* Pre, core, post arrays for each sub-system (mac, bb, radio, soc)632*/633#define ATH_INI_PRE 0634#define ATH_INI_CORE 1635#define ATH_INI_POST 2636#define ATH_INI_NUM_SPLIT (ATH_INI_POST + 1)637struct ar9300_ini_array ah_ini_mac[ATH_INI_NUM_SPLIT]; /* New INI format */638struct ar9300_ini_array ah_ini_bb[ATH_INI_NUM_SPLIT]; /* New INI format */639struct ar9300_ini_array ah_ini_radio[ATH_INI_NUM_SPLIT]; /* New INI format */640struct ar9300_ini_array ah_ini_soc[ATH_INI_NUM_SPLIT]; /* New INI format */641642/*643* Added to support DFS postamble array in INI that we need to apply644* in DFS channels645*/646647struct ar9300_ini_array ah_ini_dfs;648649#if ATH_WOW650struct ar9300_ini_array ah_ini_pcie_serdes_wow; /* SerDes values during WOW sleep */651#endif652653/* To indicate EEPROM mapping used */654u_int32_t ah_immunity_vals[6];655HAL_BOOL ah_immunity_on;656/*657* snap shot of counter register for debug purposes658*/659#ifdef AH_DEBUG660u_int32_t last_tf;661u_int32_t last_rf;662u_int32_t last_rc;663u_int32_t last_cc;664#endif665HAL_BOOL ah_dma_stuck; /* Set to AH_TRUE when RX/TX DMA failed to stop. */666u_int32_t nf_tsf32; /* timestamp for NF calibration duration */667668u_int32_t reg_dmn; /* Regulatory Domain */669int16_t twice_antenna_gain; /* Antenna Gain */670u_int16_t twice_antenna_reduction; /* Antenna Gain Allowed */671672/*673* Upper limit after factoring in the regulatory max, antenna gain and674* multichain factor. No TxBF, CDD or STBC gain factored675*/676int16_t upper_limit[AR9300_MAX_CHAINS];677678/* adjusted power for descriptor-based TPC for 1, 2, or 3 chains */679int16_t txpower[AR9300_MAX_RATES][AR9300_MAX_CHAINS];680681/* adjusted power for descriptor-based TPC for 1, 2, or 3 chains with STBC*/682int16_t txpower_stbc[AR9300_MAX_RATES][AR9300_MAX_CHAINS];683684/* Transmit Status ring support */685struct ar9300_txs *ts_ring;686u_int16_t ts_tail;687u_int16_t ts_size;688u_int32_t ts_paddr_start;689u_int32_t ts_paddr_end;690691/* Receive Buffer size */692#define HAL_RXBUFSIZE_DEFAULT 0xfff693u_int16_t rx_buf_size;694695u_int32_t ah_wa_reg_val; // Store the permanent value of Reg 0x4004 so we dont have to R/M/W. (We should not be reading this register when in sleep states).696697/* Indicate the PLL source clock rate is 25Mhz or not.698* clk_25mhz = 0 by default.699*/700u_int8_t clk_25mhz;701/* For PAPRD uses */702u_int16_t small_signal_gain[AH_MAX_CHAINS];703u_int32_t pa_table[AH_MAX_CHAINS][AR9300_PAPRD_TABLE_SZ];704u_int32_t paprd_gain_table_entries[AR9300_PAPRD_GAIN_TABLE_SZ];705u_int32_t paprd_gain_table_index[AR9300_PAPRD_GAIN_TABLE_SZ];706u_int32_t ah_2g_paprd_rate_mask_ht20; /* Copy of eep->modal_header_2g.paprd_rate_mask_ht20 */707u_int32_t ah_2g_paprd_rate_mask_ht40; /* Copy of eep->modal_header_2g.paprd_rate_mask_ht40 */708u_int32_t ah_5g_paprd_rate_mask_ht20; /* Copy of eep->modal_header_5g.paprd_rate_mask_ht20 */709u_int32_t ah_5g_paprd_rate_mask_ht40; /* Copy of eep->modal_header_5g.paprd_rate_mask_ht40 */710u_int32_t paprd_training_power;711/* For GreenTx use to store the default tx power */712u_int8_t ah_default_tx_power[ar9300_rate_size];713HAL_BOOL ah_paprd_broken;714715/* To store offsets of host interface registers */716struct {717u_int32_t AR_RC;718u_int32_t AR_WA;719u_int32_t AR_PM_STATE;720u_int32_t AR_H_INFOL;721u_int32_t AR_H_INFOH;722u_int32_t AR_PCIE_PM_CTRL;723u_int32_t AR_HOST_TIMEOUT;724u_int32_t AR_EEPROM;725u_int32_t AR_SREV;726u_int32_t AR_INTR_SYNC_CAUSE;727u_int32_t AR_INTR_SYNC_CAUSE_CLR;728u_int32_t AR_INTR_SYNC_ENABLE;729u_int32_t AR_INTR_ASYNC_MASK;730u_int32_t AR_INTR_SYNC_MASK;731u_int32_t AR_INTR_ASYNC_CAUSE_CLR;732u_int32_t AR_INTR_ASYNC_CAUSE;733u_int32_t AR_INTR_ASYNC_ENABLE;734u_int32_t AR_PCIE_SERDES;735u_int32_t AR_PCIE_SERDES2;736u_int32_t AR_GPIO_OUT;737u_int32_t AR_GPIO_IN;738u_int32_t AR_GPIO_OE_OUT;739u_int32_t AR_GPIO_OE1_OUT;740u_int32_t AR_GPIO_INTR_POL;741u_int32_t AR_GPIO_INPUT_EN_VAL;742u_int32_t AR_GPIO_INPUT_MUX1;743u_int32_t AR_GPIO_INPUT_MUX2;744u_int32_t AR_GPIO_OUTPUT_MUX1;745u_int32_t AR_GPIO_OUTPUT_MUX2;746u_int32_t AR_GPIO_OUTPUT_MUX3;747u_int32_t AR_INPUT_STATE;748u_int32_t AR_SPARE;749u_int32_t AR_PCIE_CORE_RESET_EN;750u_int32_t AR_CLKRUN;751u_int32_t AR_EEPROM_STATUS_DATA;752u_int32_t AR_OBS;753u_int32_t AR_RFSILENT;754u_int32_t AR_GPIO_PDPU;755u_int32_t AR_GPIO_DS;756u_int32_t AR_MISC;757u_int32_t AR_PCIE_MSI;758u_int32_t AR_TSF_SNAPSHOT_BT_ACTIVE;759u_int32_t AR_TSF_SNAPSHOT_BT_PRIORITY;760u_int32_t AR_TSF_SNAPSHOT_BT_CNTL;761u_int32_t AR_PCIE_PHY_LATENCY_NFTS_ADJ;762u_int32_t AR_TDMA_CCA_CNTL;763u_int32_t AR_TXAPSYNC;764u_int32_t AR_TXSYNC_INIT_SYNC_TMR;765u_int32_t AR_INTR_PRIO_SYNC_CAUSE;766u_int32_t AR_INTR_PRIO_SYNC_ENABLE;767u_int32_t AR_INTR_PRIO_ASYNC_MASK;768u_int32_t AR_INTR_PRIO_SYNC_MASK;769u_int32_t AR_INTR_PRIO_ASYNC_CAUSE;770u_int32_t AR_INTR_PRIO_ASYNC_ENABLE;771} ah_hostifregs;772773u_int32_t ah_enterprise_mode;774u_int32_t ah_radar1;775u_int32_t ah_dc_offset;776HAL_BOOL ah_hw_green_tx_enable; /* 1:enalbe H/W Green Tx */777HAL_BOOL ah_smartantenna_enable; /* 1:enalbe H/W */778u_int32_t ah_disable_cck;779HAL_BOOL ah_lna_div_use_bt_ant_enable; /* 1:enable Rx(LNA) Diversity */780781782/*783* Different types of memory where the calibration data might be stored.784* All types are searched in Ar9300EepromRestore() in the order flash, eeprom, otp.785* To disable searching a type, set its parameter to 0.786*/787int try_dram;788int try_flash;789int try_eeprom;790int try_otp;791#ifdef ATH_CAL_NAND_FLASH792int try_nand;793#endif794/*795* This is where we found the calibration data.796*/797int calibration_data_source;798int calibration_data_source_address;799/*800* This is where we look for the calibration data. must be set before ath_attach() is called801*/802int calibration_data_try;803int calibration_data_try_address;804u_int8_t805tx_iq_cal_enable : 1,806tx_iq_cal_during_agc_cal : 1,807tx_cl_cal_enable : 1;808809#if ATH_SUPPORT_MCI810/* For MCI */811HAL_BOOL ah_mci_ready;812u_int32_t ah_mci_int_raw;813u_int32_t ah_mci_int_rx_msg;814u_int32_t ah_mci_rx_status;815u_int32_t ah_mci_cont_status;816u_int8_t ah_mci_bt_state;817u_int32_t ah_mci_gpm_addr;818u_int8_t *ah_mci_gpm_buf;819u_int32_t ah_mci_gpm_len;820u_int32_t ah_mci_gpm_idx;821u_int32_t ah_mci_sched_addr;822u_int8_t *ah_mci_sched_buf;823u_int8_t ah_mci_coex_major_version_wlan;824u_int8_t ah_mci_coex_minor_version_wlan;825u_int8_t ah_mci_coex_major_version_bt;826u_int8_t ah_mci_coex_minor_version_bt;827HAL_BOOL ah_mci_coex_bt_version_known;828HAL_BOOL ah_mci_coex_wlan_channels_update;829u_int32_t ah_mci_coex_wlan_channels[4];830HAL_BOOL ah_mci_coex_2g5g_update;831HAL_BOOL ah_mci_coex_is_2g;832HAL_BOOL ah_mci_query_bt;833HAL_BOOL ah_mci_unhalt_bt_gpm; /* need send UNHALT */834HAL_BOOL ah_mci_halted_bt_gpm; /* HALT sent */835HAL_BOOL ah_mci_need_flush_btinfo;836HAL_BOOL ah_mci_concur_tx_en;837u_int8_t ah_mci_stomp_low_tx_pri;838u_int8_t ah_mci_stomp_all_tx_pri;839u_int8_t ah_mci_stomp_none_tx_pri;840u_int32_t ah_mci_wlan_cal_seq;841u_int32_t ah_mci_wlan_cal_done;842#if ATH_SUPPORT_AIC843HAL_BOOL ah_aic_enabled;844u_int32_t ah_aic_sram[ATH_AIC_MAX_BT_CHANNEL];845#endif846847#endif /* ATH_SUPPORT_MCI */848u_int8_t ah_cac_quiet_enabled;849#if ATH_WOW_OFFLOAD850u_int32_t ah_mcast_filter_l32_set;851u_int32_t ah_mcast_filter_u32_set;852#endif853HAL_BOOL ah_reduced_self_gen_mask;854HAL_BOOL ah_chip_reset_done;855HAL_BOOL ah_abort_txdma_norx;856/* store previous passive RX Cal info */857HAL_BOOL ah_skip_rx_iq_cal;858HAL_BOOL ah_rx_cal_complete; /* previous rx cal completed or not */859u_int32_t ah_rx_cal_chan; /* chan on which rx cal is done */860u_int32_t ah_rx_cal_chan_flag;861u_int32_t ah_rx_cal_corr[AR9300_MAX_CHAINS];862863/* Local additions for FreeBSD */864/*865* These fields are in the top level HAL in the atheros866* codebase; here we place them in the AR9300 HAL and867* access them via accessor methods if the driver requires them.868*/869u_int32_t ah_ob_db1[3];870u_int32_t ah_db2[3];871u_int32_t ah_bb_panic_timeout_ms;872u_int32_t ah_bb_panic_last_status;873u_int32_t ah_tx_trig_level;874u_int16_t ath_hal_spur_chans[AR_EEPROM_MODAL_SPURS][2];875int16_t nf_cw_int_delta; /* diff btwn nominal NF and CW interf threshold */876int ah_phyrestart_disabled;877HAL_RSSI_TX_POWER green_tx_status;878int green_ap_ps_on;879int ah_enable_keysearch_always;880int ah_fccaifs;881int ah_reset_reason;882int ah_dcs_enable;883HAL_ANI_STATE ext_ani_state; /* FreeBSD; external facing ANI state */884885struct ar9300NfLimits nf_2GHz;886struct ar9300NfLimits nf_5GHz;887struct ar9300NfLimits *nfp;888889uint32_t ah_beaconInterval;890};891892#define AH9300(_ah) ((struct ath_hal_9300 *)(_ah))893894#define IS_9300_EMU(ah) \895(AH_PRIVATE(ah)->ah_devid == AR9300_DEVID_EMU_PCIE)896897#define ar9300_eep_data_in_flash(_ah) \898(!(AH_PRIVATE(_ah)->ah_flags & AH_USE_EEPROM))899900#ifdef notyet901// Need these additional conditions for IS_5GHZ_FAST_CLOCK_EN when we have valid eeprom contents.902&& \903((ar9300_eeprom_get(AH9300(_ah), EEP_MINOR_REV) <= AR9300_EEP_MINOR_VER_16) || \904(ar9300_eeprom_get(AH9300(_ah), EEP_FSTCLK_5G))))905#endif906907/*908* WAR for bug 6773. OS_DELAY() does a PIO READ on the PCI bus which allows909* other cards' DMA reads to complete in the middle of our reset.910*/911#define WAR_6773(x) do { \912if ((++(x) % 64) == 0) \913OS_DELAY(1); \914} while (0)915916#define REG_WRITE_ARRAY(iniarray, column, regWr) do { \917int r; \918for (r = 0; r < ((iniarray)->ia_rows); r++) { \919OS_REG_WRITE(ah, INI_RA((iniarray), (r), 0), INI_RA((iniarray), r, (column)));\920WAR_6773(regWr); \921} \922} while (0)923924#define UPPER_5G_SUB_BANDSTART 5700925#define MID_5G_SUB_BANDSTART 5400926#define TRAINPOWER_DB_OFFSET 6927928#define AH_PAPRD_GET_SCALE_FACTOR(_scale, _eep, _is2G, _channel) do{ if(_is2G) { _scale = (_eep->modal_header_2g.paprd_rate_mask_ht20>>25)&0x7; \929} else { \930if(_channel >= UPPER_5G_SUB_BANDSTART){ _scale = (_eep->modal_header_5g.paprd_rate_mask_ht20>>25)&0x7;} \931else if((UPPER_5G_SUB_BANDSTART < _channel) && (_channel >= MID_5G_SUB_BANDSTART)) \932{ _scale = (_eep->modal_header_5g.paprd_rate_mask_ht40>>28)&0x7;} \933else { _scale = (_eep->modal_header_5g.paprd_rate_mask_ht40>>25)&0x7;} } }while(0)934935#ifdef AH_ASSERT936#define ar9300FeatureNotSupported(feature, ah, func) \937ath_hal_printf(ah, # feature \938" not supported but called from %s\n", (func)), \939hal_assert(0)940#else941#define ar9300FeatureNotSupported(feature, ah, func) \942ath_hal_printf(ah, # feature \943" not supported but called from %s\n", (func))944#endif /* AH_ASSERT */945946/*947* Green Tx, Based on different RSSI of Received Beacon thresholds,948* using different tx power by modified register tx power related values.949* The thresholds are decided by system team.950*/951#define WB225_SW_GREEN_TX_THRES1_DB 56 /* in dB */952#define WB225_SW_GREEN_TX_THRES2_DB 41 /* in dB */953#define WB225_OB_CALIBRATION_VALUE 5 /* For Green Tx OLPC Delta954Calibration Offset */955#define WB225_OB_GREEN_TX_SHORT_VALUE 1 /* For Green Tx OB value956in short distance*/957#define WB225_OB_GREEN_TX_MIDDLE_VALUE 3 /* For Green Tx OB value958in middle distance */959#define WB225_OB_GREEN_TX_LONG_VALUE 5 /* For Green Tx OB value960in long distance */961#define WB225_BBPWRTXRATE9_SW_GREEN_TX_SHORT_VALUE 0x06060606 /* For SwGreen Tx962BB_powertx_rate9 reg963value in short964distance */965#define WB225_BBPWRTXRATE9_SW_GREEN_TX_MIDDLE_VALUE 0x0E0E0E0E /* For SwGreen Tx966BB_powertx_rate9 reg967value in middle968distance */969970971/* Tx power for short distacnce in SwGreenTx.*/972static const u_int8_t wb225_sw_gtx_tp_distance_short[ar9300_rate_size] = {9736, /*ALL_TARGET_LEGACY_6_24*/9746, /*ALL_TARGET_LEGACY_36*/9756, /*ALL_TARGET_LEGACY_48*/9764, /*ALL_TARGET_LEGACY_54*/9776, /*ALL_TARGET_LEGACY_1L_5L*/9786, /*ALL_TARGET_LEGACY_5S*/9796, /*ALL_TARGET_LEGACY_11L*/9806, /*ALL_TARGET_LEGACY_11S*/9816, /*ALL_TARGET_HT20_0_8_16*/9826, /*ALL_TARGET_HT20_1_3_9_11_17_19*/9834, /*ALL_TARGET_HT20_4*/9844, /*ALL_TARGET_HT20_5*/9854, /*ALL_TARGET_HT20_6*/9862, /*ALL_TARGET_HT20_7*/9870, /*ALL_TARGET_HT20_12*/9880, /*ALL_TARGET_HT20_13*/9890, /*ALL_TARGET_HT20_14*/9900, /*ALL_TARGET_HT20_15*/9910, /*ALL_TARGET_HT20_20*/9920, /*ALL_TARGET_HT20_21*/9930, /*ALL_TARGET_HT20_22*/9940, /*ALL_TARGET_HT20_23*/9956, /*ALL_TARGET_HT40_0_8_16*/9966, /*ALL_TARGET_HT40_1_3_9_11_17_19*/9974, /*ALL_TARGET_HT40_4*/9984, /*ALL_TARGET_HT40_5*/9994, /*ALL_TARGET_HT40_6*/10002, /*ALL_TARGET_HT40_7*/10010, /*ALL_TARGET_HT40_12*/10020, /*ALL_TARGET_HT40_13*/10030, /*ALL_TARGET_HT40_14*/10040, /*ALL_TARGET_HT40_15*/10050, /*ALL_TARGET_HT40_20*/10060, /*ALL_TARGET_HT40_21*/10070, /*ALL_TARGET_HT40_22*/10080 /*ALL_TARGET_HT40_23*/1009};10101011/* Tx power for middle distacnce in SwGreenTx.*/1012static const u_int8_t wb225_sw_gtx_tp_distance_middle[ar9300_rate_size] = {101314, /*ALL_TARGET_LEGACY_6_24*/101414, /*ALL_TARGET_LEGACY_36*/101514, /*ALL_TARGET_LEGACY_48*/101612, /*ALL_TARGET_LEGACY_54*/101714, /*ALL_TARGET_LEGACY_1L_5L*/101814, /*ALL_TARGET_LEGACY_5S*/101914, /*ALL_TARGET_LEGACY_11L*/102014, /*ALL_TARGET_LEGACY_11S*/102114, /*ALL_TARGET_HT20_0_8_16*/102214, /*ALL_TARGET_HT20_1_3_9_11_17_19*/102314, /*ALL_TARGET_HT20_4*/102414, /*ALL_TARGET_HT20_5*/102512, /*ALL_TARGET_HT20_6*/102610, /*ALL_TARGET_HT20_7*/10270, /*ALL_TARGET_HT20_12*/10280, /*ALL_TARGET_HT20_13*/10290, /*ALL_TARGET_HT20_14*/10300, /*ALL_TARGET_HT20_15*/10310, /*ALL_TARGET_HT20_20*/10320, /*ALL_TARGET_HT20_21*/10330, /*ALL_TARGET_HT20_22*/10340, /*ALL_TARGET_HT20_23*/103514, /*ALL_TARGET_HT40_0_8_16*/103614, /*ALL_TARGET_HT40_1_3_9_11_17_19*/103714, /*ALL_TARGET_HT40_4*/103814, /*ALL_TARGET_HT40_5*/103912, /*ALL_TARGET_HT40_6*/104010, /*ALL_TARGET_HT40_7*/10410, /*ALL_TARGET_HT40_12*/10420, /*ALL_TARGET_HT40_13*/10430, /*ALL_TARGET_HT40_14*/10440, /*ALL_TARGET_HT40_15*/10450, /*ALL_TARGET_HT40_20*/10460, /*ALL_TARGET_HT40_21*/10470, /*ALL_TARGET_HT40_22*/10480 /*ALL_TARGET_HT40_23*/1049};10501051/* OLPC DeltaCalibration Offset unit in half dB.*/1052static const u_int8_t wb225_gtx_olpc_cal_offset[6] = {10530, /* OB0*/105416, /* OB1*/10559, /* OB2*/10565, /* OB3*/10572, /* OB4*/10580, /* OB5*/1059};10601061/*1062* Definitions for HwGreenTx1063*/1064#define AR9485_HW_GREEN_TX_THRES1_DB 56 /* in dB */1065#define AR9485_HW_GREEN_TX_THRES2_DB 41 /* in dB */1066#define AR9485_BBPWRTXRATE9_HW_GREEN_TX_SHORT_VALUE 0x0C0C0A0A /* For HwGreen Tx1067BB_powertx_rate9 reg1068value in short1069distance */1070#define AR9485_BBPWRTXRATE9_HW_GREEN_TX_MIDDLE_VALUE 0x10100E0E /* For HwGreenTx1071BB_powertx_rate9 reg1072value in middle1073distance */10741075/* Tx power for short distacnce in HwGreenTx.*/1076static const u_int8_t ar9485_hw_gtx_tp_distance_short[ar9300_rate_size] = {107714, /*ALL_TARGET_LEGACY_6_24*/107814, /*ALL_TARGET_LEGACY_36*/10798, /*ALL_TARGET_LEGACY_48*/10802, /*ALL_TARGET_LEGACY_54*/108114, /*ALL_TARGET_LEGACY_1L_5L*/108214, /*ALL_TARGET_LEGACY_5S*/108314, /*ALL_TARGET_LEGACY_11L*/108414, /*ALL_TARGET_LEGACY_11S*/108512, /*ALL_TARGET_HT20_0_8_16*/108612, /*ALL_TARGET_HT20_1_3_9_11_17_19*/108712, /*ALL_TARGET_HT20_4*/108812, /*ALL_TARGET_HT20_5*/10898, /*ALL_TARGET_HT20_6*/10902, /*ALL_TARGET_HT20_7*/10910, /*ALL_TARGET_HT20_12*/10920, /*ALL_TARGET_HT20_13*/10930, /*ALL_TARGET_HT20_14*/10940, /*ALL_TARGET_HT20_15*/10950, /*ALL_TARGET_HT20_20*/10960, /*ALL_TARGET_HT20_21*/10970, /*ALL_TARGET_HT20_22*/10980, /*ALL_TARGET_HT20_23*/109910, /*ALL_TARGET_HT40_0_8_16*/110010, /*ALL_TARGET_HT40_1_3_9_11_17_19*/110110, /*ALL_TARGET_HT40_4*/110210, /*ALL_TARGET_HT40_5*/11036, /*ALL_TARGET_HT40_6*/11042, /*ALL_TARGET_HT40_7*/11050, /*ALL_TARGET_HT40_12*/11060, /*ALL_TARGET_HT40_13*/11070, /*ALL_TARGET_HT40_14*/11080, /*ALL_TARGET_HT40_15*/11090, /*ALL_TARGET_HT40_20*/11100, /*ALL_TARGET_HT40_21*/11110, /*ALL_TARGET_HT40_22*/11120 /*ALL_TARGET_HT40_23*/1113};11141115/* Tx power for middle distacnce in HwGreenTx.*/1116static const u_int8_t ar9485_hw_gtx_tp_distance_middle[ar9300_rate_size] = {111718, /*ALL_TARGET_LEGACY_6_24*/111818, /*ALL_TARGET_LEGACY_36*/111914, /*ALL_TARGET_LEGACY_48*/112012, /*ALL_TARGET_LEGACY_54*/112118, /*ALL_TARGET_LEGACY_1L_5L*/112218, /*ALL_TARGET_LEGACY_5S*/112318, /*ALL_TARGET_LEGACY_11L*/112418, /*ALL_TARGET_LEGACY_11S*/112516, /*ALL_TARGET_HT20_0_8_16*/112616, /*ALL_TARGET_HT20_1_3_9_11_17_19*/112716, /*ALL_TARGET_HT20_4*/112816, /*ALL_TARGET_HT20_5*/112914, /*ALL_TARGET_HT20_6*/113012, /*ALL_TARGET_HT20_7*/11310, /*ALL_TARGET_HT20_12*/11320, /*ALL_TARGET_HT20_13*/11330, /*ALL_TARGET_HT20_14*/11340, /*ALL_TARGET_HT20_15*/11350, /*ALL_TARGET_HT20_20*/11360, /*ALL_TARGET_HT20_21*/11370, /*ALL_TARGET_HT20_22*/11380, /*ALL_TARGET_HT20_23*/113914, /*ALL_TARGET_HT40_0_8_16*/114014, /*ALL_TARGET_HT40_1_3_9_11_17_19*/114114, /*ALL_TARGET_HT40_4*/114214, /*ALL_TARGET_HT40_5*/114314, /*ALL_TARGET_HT40_6*/114412, /*ALL_TARGET_HT40_7*/11450, /*ALL_TARGET_HT40_12*/11460, /*ALL_TARGET_HT40_13*/11470, /*ALL_TARGET_HT40_14*/11480, /*ALL_TARGET_HT40_15*/11490, /*ALL_TARGET_HT40_20*/11500, /*ALL_TARGET_HT40_21*/11510, /*ALL_TARGET_HT40_22*/11520 /*ALL_TARGET_HT40_23*/1153};11541155/* MIMO Modes used in TPC calculations */1156typedef enum {1157AR9300_DEF_MODE = 0, /* Could be CDD or Direct */1158AR9300_TXBF_MODE,1159AR9300_STBC_MODE1160} AR9300_TXMODES;1161typedef enum {1162POSEIDON_STORED_REG_OBDB = 0, /* default OB/DB setting from ini */1163POSEIDON_STORED_REG_TPC = 1, /* default txpower value in TPC reg */1164POSEIDON_STORED_REG_BB_PWRTX_RATE9 = 2, /* default txpower value in1165* BB_powertx_rate9 reg1166*/1167POSEIDON_STORED_REG_SZ /* Can not add anymore */1168} POSEIDON_STORED_REGS;11691170typedef enum {1171POSEIDON_STORED_REG_G2_OLPC_OFFSET = 0,/* default OB/DB setting from ini */1172POSEIDON_STORED_REG_G2_SZ /* should not exceed 3 */1173} POSEIDON_STORED_REGS_G2;11741175#if AH_NEED_TX_DATA_SWAP1176#if AH_NEED_RX_DATA_SWAP1177#define ar9300_init_cfg_reg(ah) OS_REG_RMW(ah, AR_CFG, AR_CFG_SWTB | AR_CFG_SWRB,0)1178#else1179#define ar9300_init_cfg_reg(ah) OS_REG_RMW(ah, AR_CFG, AR_CFG_SWTB,0)1180#endif1181#elif AH_NEED_RX_DATA_SWAP1182#define ar9300_init_cfg_reg(ah) OS_REG_RMW(ah, AR_CFG, AR_CFG_SWRB,0)1183#else1184#define ar9300_init_cfg_reg(ah) OS_REG_RMW(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD,0)1185#endif11861187extern HAL_BOOL ar9300_rf_attach(struct ath_hal *, HAL_STATUS *);11881189struct ath_hal;11901191extern struct ath_hal_9300 * ar9300_new_state(u_int16_t devid,1192HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata,1193HAL_OPS_CONFIG *ah_config,1194HAL_STATUS *status);1195extern struct ath_hal * ar9300_attach(u_int16_t devid,1196HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata,1197HAL_OPS_CONFIG *ah_config, HAL_STATUS *status);1198extern void ar9300_detach(struct ath_hal *ah);1199extern void ar9300_read_revisions(struct ath_hal *ah);1200extern HAL_BOOL ar9300_chip_test(struct ath_hal *ah);1201extern HAL_BOOL ar9300_get_channel_edges(struct ath_hal *ah,1202u_int16_t flags, u_int16_t *low, u_int16_t *high);1203extern HAL_BOOL ar9300_fill_capability_info(struct ath_hal *ah);12041205extern void ar9300_beacon_init(struct ath_hal *ah,1206u_int32_t next_beacon, u_int32_t beacon_period,1207u_int32_t beacon_period_fraction, HAL_OPMODE opmode);1208extern void ar9300_set_sta_beacon_timers(struct ath_hal *ah,1209const HAL_BEACON_STATE *);12101211extern HAL_BOOL ar9300_is_interrupt_pending(struct ath_hal *ah);1212extern HAL_BOOL ar9300_get_pending_interrupts(struct ath_hal *ah, HAL_INT *, HAL_INT_TYPE, u_int8_t, HAL_BOOL);1213extern HAL_INT ar9300_get_interrupts(struct ath_hal *ah);1214extern HAL_INT ar9300_set_interrupts(struct ath_hal *ah, HAL_INT ints, HAL_BOOL);1215extern void ar9300_set_intr_mitigation_timer(struct ath_hal* ah,1216HAL_INT_MITIGATION reg, u_int32_t value);1217extern u_int32_t ar9300_get_intr_mitigation_timer(struct ath_hal* ah,1218HAL_INT_MITIGATION reg);1219extern u_int32_t ar9300_get_key_cache_size(struct ath_hal *);1220extern HAL_BOOL ar9300_is_key_cache_entry_valid(struct ath_hal *, u_int16_t entry);1221extern HAL_BOOL ar9300_reset_key_cache_entry(struct ath_hal *ah, u_int16_t entry);1222extern HAL_CHANNEL_INTERNAL * ar9300_check_chan(struct ath_hal *ah,1223const struct ieee80211_channel *chan);12241225extern HAL_BOOL ar9300_set_key_cache_entry_mac(struct ath_hal *,1226u_int16_t entry, const u_int8_t *mac);1227extern HAL_BOOL ar9300_set_key_cache_entry(struct ath_hal *ah, u_int16_t entry,1228const HAL_KEYVAL *k, const u_int8_t *mac, int xor_key);1229extern HAL_BOOL ar9300_print_keycache(struct ath_hal *ah);1230#if ATH_SUPPORT_KEYPLUMB_WAR1231extern HAL_BOOL ar9300_check_key_cache_entry(struct ath_hal *ah, u_int16_t entry,1232const HAL_KEYVAL *k, int xorKey);1233#endif12341235extern void ar9300_get_mac_address(struct ath_hal *ah, u_int8_t *mac);1236extern HAL_BOOL ar9300_set_mac_address(struct ath_hal *ah, const u_int8_t *);1237extern void ar9300_get_bss_id_mask(struct ath_hal *ah, u_int8_t *mac);1238extern HAL_BOOL ar9300_set_bss_id_mask(struct ath_hal *, const u_int8_t *);1239extern HAL_STATUS ar9300_select_ant_config(struct ath_hal *ah, u_int32_t cfg);1240#if 01241extern u_int32_t ar9300_ant_ctrl_common_get(struct ath_hal *ah, HAL_BOOL is_2ghz);1242#endif1243extern HAL_BOOL ar9300_ant_swcom_sel(struct ath_hal *ah, u_int8_t ops,1244u_int32_t *common_tbl1, u_int32_t *common_tbl2);1245extern HAL_BOOL ar9300_set_regulatory_domain(struct ath_hal *ah,1246u_int16_t reg_domain, HAL_STATUS *stats);1247extern u_int ar9300_get_wireless_modes(struct ath_hal *ah);1248extern void ar9300_enable_rf_kill(struct ath_hal *);1249extern HAL_BOOL ar9300_gpio_cfg_output(struct ath_hal *, u_int32_t gpio, HAL_GPIO_MUX_TYPE signalType);1250extern HAL_BOOL ar9300_gpio_cfg_output_led_off(struct ath_hal *, u_int32_t gpio, HAL_GPIO_MUX_TYPE signalType);1251extern HAL_BOOL ar9300_gpio_cfg_input(struct ath_hal *, u_int32_t gpio);1252extern HAL_BOOL ar9300_gpio_set(struct ath_hal *, u_int32_t gpio, u_int32_t val);1253extern u_int32_t ar9300_gpio_get(struct ath_hal *ah, u_int32_t gpio);1254extern u_int32_t ar9300_gpio_get_intr(struct ath_hal *ah);1255extern void ar9300_gpio_set_intr(struct ath_hal *ah, u_int, u_int32_t ilevel);1256extern u_int32_t ar9300_gpio_get_polarity(struct ath_hal *ah);1257extern void ar9300_gpio_set_polarity(struct ath_hal *ah, u_int32_t, u_int32_t);1258extern u_int32_t ar9300_gpio_get_mask(struct ath_hal *ah);1259extern int ar9300_gpio_set_mask(struct ath_hal *ah, u_int32_t mask, u_int32_t pol_map);1260extern void ar9300_set_led_state(struct ath_hal *ah, HAL_LED_STATE state);1261extern void ar9300_set_power_led_state(struct ath_hal *ah, u_int8_t enable);1262extern void ar9300_set_network_led_state(struct ath_hal *ah, u_int8_t enable);1263extern void ar9300_write_associd(struct ath_hal *ah, const u_int8_t *bssid,1264u_int16_t assoc_id);1265extern u_int32_t ar9300_ppm_get_rssi_dump(struct ath_hal *);1266extern u_int32_t ar9300_ppm_arm_trigger(struct ath_hal *);1267extern int ar9300_ppm_get_trigger(struct ath_hal *);1268extern u_int32_t ar9300_ppm_force(struct ath_hal *);1269extern void ar9300_ppm_un_force(struct ath_hal *);1270extern u_int32_t ar9300_ppm_get_force_state(struct ath_hal *);1271extern void ar9300_set_dcs_mode(struct ath_hal *ah, u_int32_t);1272extern u_int32_t ar9300_get_dcs_mode(struct ath_hal *ah);1273extern u_int32_t ar9300_get_tsf32(struct ath_hal *ah);1274extern u_int64_t ar9300_get_tsf64(struct ath_hal *ah);1275extern u_int32_t ar9300_get_tsf2_32(struct ath_hal *ah);1276extern void ar9300_set_tsf64(struct ath_hal *ah, u_int64_t tsf);1277extern void ar9300_reset_tsf(struct ath_hal *ah);1278extern void ar9300_set_basic_rate(struct ath_hal *ah, HAL_RATE_SET *pSet);1279extern u_int32_t ar9300_get_random_seed(struct ath_hal *ah);1280extern HAL_BOOL ar9300_detect_card_present(struct ath_hal *ah);1281extern void ar9300_update_mib_mac_stats(struct ath_hal *ah);1282extern void ar9300_get_mib_mac_stats(struct ath_hal *ah, HAL_MIB_STATS* stats);1283extern HAL_BOOL ar9300_is_japan_channel_spread_supported(struct ath_hal *ah);1284extern u_int32_t ar9300_get_cur_rssi(struct ath_hal *ah);1285extern u_int32_t ar9300_get_rssi_chain0(struct ath_hal *ah);1286extern u_int ar9300_get_def_antenna(struct ath_hal *ah);1287extern void ar9300_set_def_antenna(struct ath_hal *ah, u_int antenna);1288extern HAL_BOOL ar9300_set_antenna_switch(struct ath_hal *ah,1289HAL_ANT_SETTING settings, const struct ieee80211_channel *chan,1290u_int8_t *, u_int8_t *, u_int8_t *);1291extern HAL_BOOL ar9300_is_sleep_after_beacon_broken(struct ath_hal *ah);1292extern HAL_BOOL ar9300_set_slot_time(struct ath_hal *, u_int);1293extern HAL_BOOL ar9300_set_ack_timeout(struct ath_hal *, u_int);1294extern u_int ar9300_get_ack_timeout(struct ath_hal *);1295extern HAL_STATUS ar9300_set_quiet(struct ath_hal *ah, u_int32_t period, u_int32_t duration,1296u_int32_t next_start, HAL_QUIET_FLAG flag);1297extern void ar9300_set_pcu_config(struct ath_hal *);1298extern HAL_STATUS ar9300_get_capability(struct ath_hal *, HAL_CAPABILITY_TYPE,1299u_int32_t, u_int32_t *);1300extern HAL_BOOL ar9300_set_capability(struct ath_hal *, HAL_CAPABILITY_TYPE,1301u_int32_t, u_int32_t, HAL_STATUS *);1302extern HAL_BOOL ar9300_get_diag_state(struct ath_hal *ah, int request,1303const void *args, u_int32_t argsize,1304void **result, u_int32_t *resultsize);1305extern void ar9300_get_desc_info(struct ath_hal *ah, HAL_DESC_INFO *desc_info);1306extern uint32_t ar9300_get_11n_ext_busy(struct ath_hal *ah);1307extern void ar9300_set_11n_mac2040(struct ath_hal *ah, HAL_HT_MACMODE mode);1308extern HAL_HT_RXCLEAR ar9300_get_11n_rx_clear(struct ath_hal *ah);1309extern void ar9300_set_11n_rx_clear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear);1310extern HAL_BOOL ar9300_set_power_mode(struct ath_hal *ah, HAL_POWER_MODE mode,1311int set_chip);1312extern HAL_POWER_MODE ar9300_get_power_mode(struct ath_hal *ah);1313extern HAL_BOOL ar9300_set_power_mode_awake(struct ath_hal *ah, int set_chip);1314extern void ar9300_set_sm_power_mode(struct ath_hal *ah, HAL_SMPS_MODE mode);13151316extern void ar9300_config_pci_power_save(struct ath_hal *ah, int restore, int power_off);13171318extern void ar9300_force_tsf_sync(struct ath_hal *ah, const u_int8_t *bssid,1319u_int16_t assoc_id);132013211322#if ATH_WOW1323extern void ar9300_wow_apply_pattern(struct ath_hal *ah, u_int8_t *p_ath_pattern,1324u_int8_t *p_ath_mask, int32_t pattern_count, u_int32_t ath_pattern_len);1325//extern u_int32_t ar9300_wow_wake_up(struct ath_hal *ah,u_int8_t *chipPatternBytes);1326extern u_int32_t ar9300_wow_wake_up(struct ath_hal *ah, HAL_BOOL offloadEnable);1327extern bool ar9300_wow_enable(struct ath_hal *ah, u_int32_t pattern_enable, u_int32_t timeout_in_seconds, int clearbssid,1328HAL_BOOL offloadEnable);1329#if ATH_WOW_OFFLOAD1330/* ARP offload */1331#define WOW_OFFLOAD_ARP_INFO_MAX 213321333struct hal_wow_offload_arp_info {1334u_int32_t valid;1335u_int32_t id;13361337u_int32_t Flags;1338union {1339u_int8_t u8[4];1340u_int32_t u32;1341} RemoteIPv4Address;1342union {1343u_int8_t u8[4];1344u_int32_t u32;1345} HostIPv4Address;1346union {1347u_int8_t u8[6];1348u_int32_t u32[2];1349} MacAddress;1350};13511352/* NS offload */1353#define WOW_OFFLOAD_NS_INFO_MAX 213541355struct hal_wow_offload_ns_info {1356u_int32_t valid;1357u_int32_t id;13581359u_int32_t Flags;1360union {1361u_int8_t u8[16];1362u_int32_t u32[4];1363} RemoteIPv6Address;1364union {1365u_int8_t u8[16];1366u_int32_t u32[4];1367} SolicitedNodeIPv6Address;1368union {1369u_int8_t u8[6];1370u_int32_t u32[2];1371} MacAddress;1372union {1373u_int8_t u8[16];1374u_int32_t u32[4];1375} TargetIPv6Addresses[2];1376};13771378extern void ar9300_wowoffload_prep(struct ath_hal *ah);1379extern void ar9300_wowoffload_post(struct ath_hal *ah);1380extern u_int32_t ar9300_wowoffload_download_rekey_data(struct ath_hal *ah, u_int32_t *data, u_int32_t size);1381extern void ar9300_wowoffload_retrieve_data(struct ath_hal *ah, void *buf, u_int32_t param);1382extern void ar9300_wowoffload_download_acer_magic(struct ath_hal *ah, HAL_BOOL valid, u_int8_t* datap, u_int32_t bytes);1383extern void ar9300_wowoffload_download_acer_swka(struct ath_hal *ah, u_int32_t id, HAL_BOOL valid, u_int32_t period, u_int32_t size, u_int32_t* datap);1384extern void ar9300_wowoffload_download_arp_info(struct ath_hal *ah, u_int32_t id, u_int32_t *data);1385extern void ar9300_wowoffload_download_ns_info(struct ath_hal *ah, u_int32_t id, u_int32_t *data);1386#endif /* ATH_WOW_OFFLOAD */1387#endif13881389extern HAL_BOOL ar9300_reset(struct ath_hal *ah, HAL_OPMODE opmode,1390struct ieee80211_channel *chan, HAL_HT_MACMODE macmode, u_int8_t txchainmask,1391u_int8_t rxchainmask, HAL_HT_EXTPROTSPACING extprotspacing,1392HAL_BOOL b_channel_change, HAL_STATUS *status, HAL_RESET_TYPE reset_type, int is_scan);1393extern HAL_BOOL ar9300_lean_channel_change(struct ath_hal *ah, HAL_OPMODE opmode, struct ieee80211_channel *chan,1394HAL_HT_MACMODE macmode, u_int8_t txchainmask, u_int8_t rxchainmask);1395extern HAL_BOOL ar9300_set_reset_reg(struct ath_hal *ah, u_int32_t type);1396extern void ar9300_init_pll(struct ath_hal *ah, struct ieee80211_channel *chan);1397extern void ar9300_green_ap_ps_on_off( struct ath_hal *ah, u_int16_t rxMask);1398extern u_int16_t ar9300_is_single_ant_power_save_possible(struct ath_hal *ah);1399extern void ar9300_set_operating_mode(struct ath_hal *ah, int opmode);1400extern HAL_BOOL ar9300_phy_disable(struct ath_hal *ah);1401extern HAL_BOOL ar9300_disable(struct ath_hal *ah);1402extern HAL_BOOL ar9300_chip_reset(struct ath_hal *ah, struct ieee80211_channel *, HAL_RESET_TYPE type);1403extern HAL_BOOL ar9300_calibration(struct ath_hal *ah, struct ieee80211_channel *chan,1404u_int8_t rxchainmask, HAL_BOOL longcal, HAL_BOOL *isIQdone, int is_scan, u_int32_t *sched_cals);1405extern void ar9300_reset_cal_valid(struct ath_hal *ah,1406const struct ieee80211_channel *chan,1407HAL_BOOL *isIQdone, u_int32_t cal_type);1408extern void ar9300_iq_cal_collect(struct ath_hal *ah, u_int8_t num_chains);1409extern void ar9300_iq_calibration(struct ath_hal *ah, u_int8_t num_chains);1410extern void ar9300_temp_comp_cal_collect(struct ath_hal *ah);1411extern void ar9300_temp_comp_calibration(struct ath_hal *ah, u_int8_t num_chains);1412extern int16_t ar9300_get_min_cca_pwr(struct ath_hal *ah);1413extern void ar9300_upload_noise_floor(struct ath_hal *ah, int is2G, int16_t nfarray[HAL_NUM_NF_READINGS]);14141415extern HAL_BOOL ar9300_set_tx_power_limit(struct ath_hal *ah, u_int32_t limit,1416u_int16_t extra_txpow, u_int16_t tpc_in_db);1417extern void ar9300_chain_noise_floor(struct ath_hal *ah, int16_t *nf_buf,1418struct ieee80211_channel *chan, int is_scan);1419extern int16_t ar9300_get_nf_from_reg(struct ath_hal *ah, struct ieee80211_channel *chan, int wait_time);1420extern int ar9300_get_rx_nf_offset(struct ath_hal *ah, struct ieee80211_channel *chan, int8_t *nf_pwr, int8_t *nf_cal);1421extern HAL_BOOL ar9300_load_nf(struct ath_hal *ah, int16_t nf[]);14221423extern HAL_RFGAIN ar9300_get_rfgain(struct ath_hal *ah);1424extern const HAL_RATE_TABLE *ar9300_get_rate_table(struct ath_hal *, u_int mode);1425extern int16_t ar9300_get_rate_txpower(struct ath_hal *ah, u_int mode,1426u_int8_t rate_index, u_int8_t chainmask, u_int8_t mimo_mode);1427extern void ar9300_init_rate_txpower(struct ath_hal *ah, u_int mode,1428const struct ieee80211_channel *chan,1429u_int8_t powerPerRate[],1430u_int8_t chainmask);1431extern void ar9300_adjust_reg_txpower_cdd(struct ath_hal *ah,1432u_int8_t powerPerRate[]);1433extern HAL_STATUS ath_hal_get_rate_power_limit_from_eeprom(struct ath_hal *ah,1434u_int16_t freq, int8_t *max_rate_power, int8_t *min_rate_power);14351436extern void ar9300_reset_tx_status_ring(struct ath_hal *ah);1437extern void ar9300_enable_mib_counters(struct ath_hal *);1438extern void ar9300_disable_mib_counters(struct ath_hal *);1439extern void ar9300_ani_attach(struct ath_hal *);1440extern void ar9300_ani_detach(struct ath_hal *);1441extern struct ar9300_ani_state *ar9300_ani_get_current_state(struct ath_hal *);1442extern HAL_ANI_STATS *ar9300_ani_get_current_stats(struct ath_hal *);1443extern HAL_BOOL ar9300_ani_control(struct ath_hal *, HAL_ANI_CMD cmd, int param);1444struct ath_rx_status;14451446extern void ar9300_process_mib_intr(struct ath_hal *, const HAL_NODE_STATS *);1447extern void ar9300_ani_ar_poll(struct ath_hal *, const HAL_NODE_STATS *,1448const struct ieee80211_channel *, HAL_ANISTATS *);1449extern void ar9300_ani_reset(struct ath_hal *, HAL_BOOL is_scanning);1450extern void ar9300_ani_init_defaults(struct ath_hal *ah, HAL_HT_MACMODE macmode);1451extern void ar9300_enable_tpc(struct ath_hal *);14521453extern HAL_BOOL ar9300_rf_gain_cap_apply(struct ath_hal *ah, int is2GHz);1454extern void ar9300_rx_gain_table_apply(struct ath_hal *ah);1455extern void ar9300_tx_gain_table_apply(struct ath_hal *ah);1456extern void ar9300_mat_enable(struct ath_hal *ah, int enable);1457extern void ar9300_dump_keycache(struct ath_hal *ah, int n, u_int32_t *entry);1458extern HAL_BOOL ar9300_ant_ctrl_set_lna_div_use_bt_ant(struct ath_hal * ah, HAL_BOOL enable, const struct ieee80211_channel * chan);14591460/* BB Panic Watchdog declarations */1461#define HAL_BB_PANIC_WD_TMO 25 /* in ms, 0 to disable */1462#define HAL_BB_PANIC_WD_TMO_HORNET 851463extern void ar9300_config_bb_panic_watchdog(struct ath_hal *);1464extern void ar9300_handle_bb_panic(struct ath_hal *);1465extern int ar9300_get_bb_panic_info(struct ath_hal *ah, struct hal_bb_panic_info *bb_panic);1466extern HAL_BOOL ar9300_handle_radar_bb_panic(struct ath_hal *ah);1467extern void ar9300_set_hal_reset_reason(struct ath_hal *ah, u_int8_t resetreason);14681469/* DFS declarations */1470extern void ar9300_check_dfs(struct ath_hal *ah, struct ieee80211_channel *chan);1471extern void ar9300_dfs_found(struct ath_hal *ah, struct ieee80211_channel *chan,1472u_int64_t nolTime);1473extern void ar9300_enable_dfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);1474extern void ar9300_get_dfs_thresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);1475extern HAL_BOOL ar9300_radar_wait(struct ath_hal *ah, struct ieee80211_channel *chan);1476extern struct dfs_pulse * ar9300_get_dfs_radars(struct ath_hal *ah,1477u_int32_t dfsdomain, int *numradars, struct dfs_bin5pulse **bin5pulses,1478int *numb5radars, HAL_PHYERR_PARAM *pe);1479extern HAL_BOOL ar9300_get_default_dfs_thresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);1480extern void ar9300_adjust_difs(struct ath_hal *ah, u_int32_t val);1481extern u_int32_t ar9300_dfs_config_fft(struct ath_hal *ah, HAL_BOOL is_enable);1482extern void ar9300_cac_tx_quiet(struct ath_hal *ah, HAL_BOOL enable);1483extern void ar9300_dfs_cac_war(struct ath_hal *ah, u_int32_t start);14841485extern struct ieee80211_channel * ar9300_get_extension_channel(struct ath_hal *ah);1486extern HAL_BOOL ar9300_is_fast_clock_enabled(struct ath_hal *ah);148714881489extern void ar9300_mark_phy_inactive(struct ath_hal *ah);14901491/* Spectral scan declarations */1492extern void ar9300_configure_spectral_scan(struct ath_hal *ah, HAL_SPECTRAL_PARAM *ss);1493extern void ar9300_set_cca_threshold(struct ath_hal *ah, u_int8_t thresh62);1494extern void ar9300_get_spectral_params(struct ath_hal *ah, HAL_SPECTRAL_PARAM *ss);1495extern HAL_BOOL ar9300_is_spectral_active(struct ath_hal *ah);1496extern HAL_BOOL ar9300_is_spectral_enabled(struct ath_hal *ah);1497extern void ar9300_start_spectral_scan(struct ath_hal *ah);1498extern void ar9300_stop_spectral_scan(struct ath_hal *ah);1499extern u_int32_t ar9300_get_spectral_config(struct ath_hal *ah);1500extern void ar9300_restore_spectral_config(struct ath_hal *ah, u_int32_t restoreval);1501int16_t ar9300_get_ctl_chan_nf(struct ath_hal *ah);1502int16_t ar9300_get_ext_chan_nf(struct ath_hal *ah);1503/* End spectral scan declarations */15041505/* Raw ADC capture functions */1506extern void ar9300_enable_test_addac_mode(struct ath_hal *ah);1507extern void ar9300_disable_test_addac_mode(struct ath_hal *ah);1508extern void ar9300_begin_adc_capture(struct ath_hal *ah, int auto_agc_gain);1509extern HAL_STATUS ar9300_retrieve_capture_data(struct ath_hal *ah, u_int16_t chain_mask, int disable_dc_filter, void *sample_buf, u_int32_t *max_samples);1510extern HAL_STATUS ar9300_calc_adc_ref_powers(struct ath_hal *ah, int freq_mhz, int16_t *sample_min, int16_t *sample_max, int32_t *chain_ref_pwr, int num_chain_ref_pwr);1511extern HAL_STATUS ar9300_get_min_agc_gain(struct ath_hal *ah, int freq_mhz, int32_t *chain_gain, int num_chain_gain);15121513extern HAL_BOOL ar9300_reset_11n(struct ath_hal *ah, HAL_OPMODE opmode,1514struct ieee80211_channel *chan, HAL_BOOL b_channel_change, HAL_STATUS *status);1515extern void ar9300_set_coverage_class(struct ath_hal *ah, u_int8_t coverageclass, int now);15161517extern void ar9300_get_channel_centers(struct ath_hal *ah,1518const struct ieee80211_channel *chan,1519CHAN_CENTERS *centers);1520extern u_int16_t ar9300_get_ctl_center(struct ath_hal *ah,1521const struct ieee80211_channel *chan);1522extern u_int16_t ar9300_get_ext_center(struct ath_hal *ah,1523const struct ieee80211_channel *chan);1524extern u_int32_t ar9300_get_mib_cycle_counts_pct(struct ath_hal *, u_int32_t*, u_int32_t*, u_int32_t*);15251526extern void ar9300_dma_reg_dump(struct ath_hal *);1527extern HAL_BOOL ar9300_set_11n_rx_rifs(struct ath_hal *ah, HAL_BOOL enable);1528extern HAL_BOOL ar9300_set_rifs_delay(struct ath_hal *ah, HAL_BOOL enable);1529extern HAL_BOOL ar9300_set_smart_antenna(struct ath_hal *ah, HAL_BOOL enable);1530extern HAL_BOOL ar9300_detect_bb_hang(struct ath_hal *ah);1531extern HAL_BOOL ar9300_detect_mac_hang(struct ath_hal *ah);15321533#ifdef ATH_BT_COEX1534extern void ar9300_set_bt_coex_info(struct ath_hal *ah, HAL_BT_COEX_INFO *btinfo);1535extern void ar9300_bt_coex_config(struct ath_hal *ah, HAL_BT_COEX_CONFIG *btconf);1536extern void ar9300_bt_coex_set_qcu_thresh(struct ath_hal *ah, int qnum);1537extern void ar9300_bt_coex_set_weights(struct ath_hal *ah, u_int32_t stomp_type);1538extern void ar9300_bt_coex_setup_bmiss_thresh(struct ath_hal *ah, u_int32_t thresh);1539extern void ar9300_bt_coex_set_parameter(struct ath_hal *ah, u_int32_t type, u_int32_t value);1540extern void ar9300_bt_coex_disable(struct ath_hal *ah);1541extern int ar9300_bt_coex_enable(struct ath_hal *ah);1542extern void ar9300_init_bt_coex(struct ath_hal *ah);1543extern u_int32_t ar9300_get_bt_active_gpio(struct ath_hal *ah, u_int32_t reg);1544extern u_int32_t ar9300_get_wlan_active_gpio(struct ath_hal *ah, u_int32_t reg,u_int32_t bOn);1545#endif1546extern int ar9300_alloc_generic_timer(struct ath_hal *ah, HAL_GEN_TIMER_DOMAIN tsf);1547extern void ar9300_free_generic_timer(struct ath_hal *ah, int index);1548extern void ar9300_start_generic_timer(struct ath_hal *ah, int index, u_int32_t timer_next,1549u_int32_t timer_period);1550extern void ar9300_stop_generic_timer(struct ath_hal *ah, int index);1551extern void ar9300_get_gen_timer_interrupts(struct ath_hal *ah, u_int32_t *trigger,1552u_int32_t *thresh);1553extern void ar9300_start_tsf2(struct ath_hal *ah);15541555extern void ar9300_chk_rssi_update_tx_pwr(struct ath_hal *ah, int rssi);1556extern HAL_BOOL ar9300_is_skip_paprd_by_greentx(struct ath_hal *ah);1557extern void ar9300_control_signals_for_green_tx_mode(struct ath_hal *ah);1558extern void ar9300_hwgreentx_set_pal_spare(struct ath_hal *ah, int value);1559extern HAL_BOOL ar9300_is_ani_noise_spur(struct ath_hal *ah);1560extern void ar9300_reset_hw_beacon_proc_crc(struct ath_hal *ah);1561extern int32_t ar9300_get_hw_beacon_rssi(struct ath_hal *ah);1562extern void ar9300_set_hw_beacon_rssi_threshold(struct ath_hal *ah,1563u_int32_t rssi_threshold);1564extern void ar9300_reset_hw_beacon_rssi(struct ath_hal *ah);1565extern void ar9300_set_hw_beacon_proc(struct ath_hal *ah, HAL_BOOL on);1566extern void ar9300_get_vow_stats(struct ath_hal *ah, HAL_VOWSTATS *p_stats,1567u_int8_t);15681569extern int ar9300_get_spur_info(struct ath_hal * ah, int *enable, int len, u_int16_t *freq);1570extern int ar9300_set_spur_info(struct ath_hal * ah, int enable, int len, u_int16_t *freq);1571extern void ar9300_wow_set_gpio_reset_low(struct ath_hal * ah);1572extern HAL_BOOL ar9300_get_mib_cycle_counts(struct ath_hal *, HAL_SURVEY_SAMPLE *);1573extern void ar9300_clear_mib_counters(struct ath_hal *ah);15741575/* EEPROM interface functions */1576/* Common Interface functions */1577extern HAL_STATUS ar9300_eeprom_attach(struct ath_hal *);1578extern u_int32_t ar9300_eeprom_get(struct ath_hal_9300 *ahp, EEPROM_PARAM param);15791580extern u_int32_t ar9300_ini_fixup(struct ath_hal *ah,1581ar9300_eeprom_t *p_eep_data,1582u_int32_t reg,1583u_int32_t val);15841585extern HAL_STATUS ar9300_eeprom_set_transmit_power(struct ath_hal *ah,1586ar9300_eeprom_t *p_eep_data, const struct ieee80211_channel *chan,1587u_int16_t cfg_ctl, u_int16_t twice_antenna_reduction,1588u_int16_t twice_max_regulatory_power, u_int16_t power_limit);1589extern void ar9300_eeprom_set_addac(struct ath_hal *, struct ieee80211_channel *);1590extern HAL_BOOL ar9300_eeprom_set_param(struct ath_hal *ah, EEPROM_PARAM param, u_int32_t value);1591extern HAL_BOOL ar9300_eeprom_set_board_values(struct ath_hal *, const struct ieee80211_channel *);1592extern HAL_BOOL ar9300_eeprom_read_word(struct ath_hal *, u_int off, u_int16_t *data);1593extern HAL_BOOL ar9300_eeprom_read(struct ath_hal *ah, long address, u_int8_t *buffer, int many);1594extern HAL_BOOL ar9300_otp_read(struct ath_hal *ah, u_int off, u_int32_t *data, HAL_BOOL is_wifi);15951596extern HAL_BOOL ar9300_flash_read(struct ath_hal *, u_int off, u_int16_t *data);1597extern HAL_BOOL ar9300_flash_write(struct ath_hal *, u_int off, u_int16_t data);1598extern u_int ar9300_eeprom_dump_support(struct ath_hal *ah, void **pp_e);1599extern u_int8_t ar9300_eeprom_get_num_ant_config(struct ath_hal_9300 *ahp, HAL_FREQ_BAND freq_band);1600extern HAL_STATUS ar9300_eeprom_get_ant_cfg(struct ath_hal_9300 *ahp, const struct ieee80211_channel *chan,1601u_int8_t index, u_int16_t *config);1602extern u_int8_t* ar9300_eeprom_get_cust_data(struct ath_hal_9300 *ahp);1603extern u_int8_t *ar9300_eeprom_get_spur_chans_ptr(struct ath_hal *ah, HAL_BOOL is_2ghz);1604extern HAL_BOOL ar9300_interference_is_present(struct ath_hal *ah);1605extern HAL_BOOL ar9300_tuning_caps_apply(struct ath_hal *ah);1606extern void ar9300_disp_tpc_tables(struct ath_hal *ah);1607extern u_int8_t *ar9300_get_tpc_tables(struct ath_hal *ah);1608extern u_int8_t ar9300_eeprom_set_tx_gain_cap(struct ath_hal *ah, int *tx_gain_max);1609extern u_int8_t ar9300_eeprom_tx_gain_table_index_max_apply(struct ath_hal *ah, u_int16_t channel);16101611/* Common EEPROM Help function */1612extern void ar9300_set_immunity(struct ath_hal *ah, HAL_BOOL enable);1613extern void ar9300_get_hw_hangs(struct ath_hal *ah, hal_hw_hangs_t *hangs);16141615extern u_int ar9300_mac_to_clks(struct ath_hal *ah, u_int clks);16161617/* tx_bf interface */1618#define ar9300_init_txbf(ah)1619#define ar9300_set_11n_txbf_sounding(ah, ds, series, cec, opt)1620#define ar9300_set_11n_txbf_cal(ah, ds, cal_pos, code_rate, cec, opt)1621#define ar9300_txbf_save_cv_from_compress( \1622ah, key_idx, mimo_control, compress_rpt) \1623false1624#define ar9300_txbf_save_cv_from_non_compress( \1625ah, key_idx, mimo_control, non_compress_rpt) \1626false1627#define ar9300_txbf_rc_update( \1628ah, rx_status, local_h, csi_frame, ness_a, ness_b, bw) \1629false1630#define ar9300_fill_csi_frame( \1631ah, rx_status, bandwidth, local_h, csi_frame_body) \163201633#define ar9300_fill_txbf_capabilities(ah)1634#define ar9300_get_txbf_capabilities(ah) NULL1635#define ar9300_txbf_set_key( \1636ah, entry, rx_staggered_sounding, channel_estimation_cap, mmss)1637#define ar9300_read_key_cache_mac(ah, entry, mac) false1638#define ar9300_txbf_get_cv_cache_nr(ah, key_idx, nr)1639#define ar9300_set_selfgenrate_limit(ah, ts_ratecode)1640#define ar9300_reset_lowest_txrate(ah)1641#define ar9300_txbf_set_basic_set(ah)16421643extern void ar9300_crdc_rx_notify(struct ath_hal *ah, struct ath_rx_status *rxs);1644extern void ar9300_chain_rssi_diff_compensation(struct ath_hal *ah);1645164616471648#if ATH_SUPPORT_MCI1649extern void ar9300_mci_bt_coex_set_weights(struct ath_hal *ah, u_int32_t stomp_type);1650extern void ar9300_mci_bt_coex_disable(struct ath_hal *ah);1651extern int ar9300_mci_bt_coex_enable(struct ath_hal *ah);1652extern void ar9300_mci_setup (struct ath_hal *ah, u_int32_t gpm_addr,1653void *gpm_buf, u_int16_t len,1654u_int32_t sched_addr);1655extern void ar9300_mci_remote_reset(struct ath_hal *ah, HAL_BOOL wait_done);1656extern void ar9300_mci_send_lna_transfer(struct ath_hal *ah, HAL_BOOL wait_done);1657extern void ar9300_mci_send_sys_waking(struct ath_hal *ah, HAL_BOOL wait_done);1658extern HAL_BOOL ar9300_mci_send_message (struct ath_hal *ah, u_int8_t header,1659u_int32_t flag, u_int32_t *payload, u_int8_t len,1660HAL_BOOL wait_done, HAL_BOOL check_bt);1661extern u_int32_t ar9300_mci_get_interrupt (struct ath_hal *ah,1662u_int32_t *mci_int,1663u_int32_t *mci_int_rx_msg);1664extern u_int32_t ar9300_mci_state (struct ath_hal *ah, u_int32_t state_type, u_int32_t *p_data);1665extern void ar9300_mci_reset (struct ath_hal *ah, HAL_BOOL en_int, HAL_BOOL is_2g, HAL_BOOL is_full_sleep);1666extern void ar9300_mci_send_coex_halt_bt_gpm(struct ath_hal *ah, HAL_BOOL halt, HAL_BOOL wait_done);1667extern void ar9300_mci_mute_bt(struct ath_hal *ah);1668extern u_int32_t ar9300_mci_wait_for_gpm(struct ath_hal *ah, u_int8_t gpm_type, u_int8_t gpm_opcode, int32_t time_out);1669extern void ar9300_mci_enable_interrupt(struct ath_hal *ah);1670extern void ar9300_mci_disable_interrupt(struct ath_hal *ah);1671extern void ar9300_mci_detach (struct ath_hal *ah);1672extern u_int32_t ar9300_mci_check_int (struct ath_hal *ah, u_int32_t ints);1673extern void ar9300_mci_sync_bt_state (struct ath_hal *ah);1674extern void ar9300_mci_2g5g_changed(struct ath_hal *ah, HAL_BOOL is_2g);1675extern void ar9300_mci_2g5g_switch(struct ath_hal *ah, HAL_BOOL wait_done);1676#if ATH_SUPPORT_AIC1677extern u_int32_t ar9300_aic_calibration (struct ath_hal *ah);1678extern u_int32_t ar9300_aic_start_normal (struct ath_hal *ah);1679#endif1680#endif16811682extern HAL_STATUS ar9300_set_proxy_sta(struct ath_hal *ah, HAL_BOOL enable);16831684extern HAL_BOOL ar9300_regulatory_domain_override(1685struct ath_hal *ah, u_int16_t regdmn);1686#if ATH_ANT_DIV_COMB1687extern void ar9300_ant_div_comb_get_config(struct ath_hal *ah, HAL_ANT_COMB_CONFIG* div_comb_conf);1688extern void ar9300_ant_div_comb_set_config(struct ath_hal *ah, HAL_ANT_COMB_CONFIG* div_comb_conf);1689#endif /* ATH_ANT_DIV_COMB */1690extern void ar9300_disable_phy_restart(struct ath_hal *ah,1691int disable_phy_restart);1692extern void ar9300_enable_keysearch_always(struct ath_hal *ah, int enable);1693extern HAL_BOOL ar9300ForceVCS( struct ath_hal *ah);1694extern HAL_BOOL ar9300SetDfs3StreamFix(struct ath_hal *ah, u_int32_t val);1695extern HAL_BOOL ar9300Get3StreamSignature( struct ath_hal *ah);16961697#ifdef ATH_TX99_DIAG1698#ifndef ATH_SUPPORT_HTC1699extern void ar9300_tx99_channel_pwr_update(struct ath_hal *ah, struct ieee80211_channel *c, u_int32_t txpower);1700extern void ar9300_tx99_chainmsk_setup(struct ath_hal *ah, int tx_chainmask);1701extern void ar9300_tx99_set_single_carrier(struct ath_hal *ah, int tx_chain_mask, int chtype);1702extern void ar9300_tx99_start(struct ath_hal *ah, u_int8_t *data);1703extern void ar9300_tx99_stop(struct ath_hal *ah);1704#endif /* ATH_SUPPORT_HTC */1705#endif /* ATH_TX99_DIAG */1706extern HAL_BOOL ar9300_set_ctl_pwr(struct ath_hal *ah, u_int8_t *ctl_array);1707extern void ar9300_set_txchainmaskopt(struct ath_hal *ah, u_int8_t mask);17081709enum {1710AR9300_COEFF_TX_TYPE = 0,1711AR9300_COEFF_RX_TYPE1712};17131714#endif /* _ATH_AR9300_H_ */171517161717