Programming the Antenna Diversity on AR5212

The AR5212 is a single-radio device which implements antenna diversity by an external antenna switch. It has a variety of hardware and software controlled mechanisms for choosing the best antenna configuration for both transmission and reception.

Setting up the Antenna Switch Table

The HAL function ar5212SetAntennaSwitchInternal() in ath_hal/ar5212/ar5212_reset.c sets up the switch table registers based on the current operating mode and diversity settings.

It writes into the ANT_SWITCH_TABLE1 (Antenna A or 1) and ANT_SWITCH_TABLE2 (Antenna B or 2) registers.

The EEPROM contains:

Controlling diversity behaviour

There are a few registers which control the transmit and receive diversity behaviour. These registers are defined in ath_hal/ar5212/ar5212reg.h and ath_hal/ar5212/ar5212phy.h .

The HAL_CAP_DIVERSITY capability API controls whether fast diversity is enabled/disabled. Look at ath_hal/ar5212/ar5212_misc.c:ar5212SetCapability() for more information.

AR_DEF_ANTENNA controls the default receive antenna configuration. The low four bits control which antenna set to use. For non-sectored operation, antenna A is value "1" and antenna B is value "2". For sectored operation, "1" and "2" are the omni directional antennas; 3->14 are the sectored antennas. 0 and 15 are not valid.

The driver can control AR_DEF_ANTENNA via the HAL methods ath_hal_getdefantenna() and ath_hal_setdefantenna().

The AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV bit in the AR_PHY_CCK_DETECT register controls whether the baseband will try the alternate antenna configuration.

If diversity is enabled, then AR_PHY_RESTART_DIV_GC in the AR_PHY_RESTART register controls the signal threshold level for which the baseband will treat a signal as too strong to bother with trying fast diversity.

The AR_STA_ID1_RTS_USE_DEF bit in AR_STA_ID1 controls whether the MAC will use the default RX antenna when sending an RTS frame, or whether it will use the AR_DEF_ANTENNA configuration.

Please note that ACK frames are always transmitted by using the value of AR_DEF_ANTENNA, but ACK reception is done using the same antenna configuration for which the frame was transmitted.

The AR_STA_ID1_UPD_DEFANT bit in AR_STA_ID1 controls whether the MAC will update the AR_DEF_ANTENNA register with the antenna the packet was last transmitted on. If it is 0 then it AR_DEF_ANTENNA is not updated.

The AR_STA_ID1_USE_DEFANT bit in AR_STA_ID1 controls whether the MAC will use the AR_DEF_ANTENNA value when transmitting a frame, or whether it will rely on the antenna configuration in the TX descriptor. If it is set to 1, it will use AR_DEF_ANTENNA.

The AR_STA_ID1_USE_DA_SG bit in AR_STA_ID1 controls whether the MAC will use the default antenna for self-generated frames like RTS/CTS.

RX descriptor antenna control

The RcvAntenna field in the RX descriptor is a 4 bit field which contains the value of the antenna configuration (ANTA->ANTD) during reception. It can be used to determine what the fast diversity choice was. It will either have a copy of AR_DEF_ANTENNA at the point of reception, or whatever the MAC/BB overrode it with (eg, in the cast of fast diversity checking.)

TX descriptor antenna control

The AntModeXmit field in the TX descriptor is a four bit field which controls the current TX antenna selection.

dev/ath_hal(4)/AntennaDiversityAR5212 (last edited 2018-03-13T20:03:44+0000 by MarkLinimon)