1216ca234SAdrian Chadd /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 4216ca234SAdrian Chadd * Copyright (c) 2013 Adrian Chadd <adrian@FreeBSD.org> 5216ca234SAdrian Chadd * All rights reserved. 6216ca234SAdrian Chadd * 7216ca234SAdrian Chadd * Redistribution and use in source and binary forms, with or without 8216ca234SAdrian Chadd * modification, are permitted provided that the following conditions 9216ca234SAdrian Chadd * are met: 10216ca234SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 11216ca234SAdrian Chadd * notice, this list of conditions and the following disclaimer, 12216ca234SAdrian Chadd * without modification. 13216ca234SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer 14216ca234SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 15216ca234SAdrian Chadd * redistribution must be conditioned upon including a substantially 16216ca234SAdrian Chadd * similar Disclaimer requirement for further binary redistribution. 17216ca234SAdrian Chadd * 18216ca234SAdrian Chadd * NO WARRANTY 19216ca234SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20216ca234SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21216ca234SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 22216ca234SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23216ca234SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 24216ca234SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25216ca234SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26216ca234SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 27216ca234SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28216ca234SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29216ca234SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES. 30216ca234SAdrian Chadd */ 31216ca234SAdrian Chadd #ifndef __IF_ATH_LNA_DIV_H__ 32216ca234SAdrian Chadd #define __IF_ATH_LNA_DIV_H__ 33216ca234SAdrian Chadd 34216ca234SAdrian Chadd #define ATH_ANT_RX_CURRENT_SHIFT 4 35216ca234SAdrian Chadd #define ATH_ANT_RX_MAIN_SHIFT 2 36216ca234SAdrian Chadd #define ATH_ANT_RX_MASK 0x3 37216ca234SAdrian Chadd 38216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_SHORT_SCAN_INTR 50 39216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT 0x100 40216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_MAX_PKTCOUNT 0x200 41216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_INIT_COUNT 95 42216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_MAX_COUNT 100 43216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30 44216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20 45216ca234SAdrian Chadd 46216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1 47216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 48216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 49216ca234SAdrian Chadd #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 50216ca234SAdrian Chadd 51216ca234SAdrian Chadd struct if_ath_ant_comb_state { 52216ca234SAdrian Chadd uint16_t count; 53216ca234SAdrian Chadd uint16_t total_pkt_count; 54216ca234SAdrian Chadd HAL_BOOL scan; 55216ca234SAdrian Chadd HAL_BOOL scan_not_start; 56216ca234SAdrian Chadd int main_total_rssi; 57216ca234SAdrian Chadd int alt_total_rssi; 58216ca234SAdrian Chadd int alt_recv_cnt; 59216ca234SAdrian Chadd int main_recv_cnt; 60216ca234SAdrian Chadd int rssi_lna1; 61216ca234SAdrian Chadd int rssi_lna2; 62216ca234SAdrian Chadd int rssi_add; 63216ca234SAdrian Chadd int rssi_sub; 64216ca234SAdrian Chadd int rssi_first; 65216ca234SAdrian Chadd int rssi_second; 66216ca234SAdrian Chadd int rssi_third; 67216ca234SAdrian Chadd HAL_BOOL alt_good; 68216ca234SAdrian Chadd int quick_scan_cnt; 69216ca234SAdrian Chadd int main_conf; 70216ca234SAdrian Chadd HAL_ANT_DIV_COMB_LNA_CONF first_quick_scan_conf; 71216ca234SAdrian Chadd HAL_ANT_DIV_COMB_LNA_CONF second_quick_scan_conf; 72216ca234SAdrian Chadd int first_bias; 73216ca234SAdrian Chadd int second_bias; 74216ca234SAdrian Chadd HAL_BOOL first_ratio; 75216ca234SAdrian Chadd HAL_BOOL second_ratio; 76216ca234SAdrian Chadd unsigned long scan_start_time; 770f0eebe7SAdrian Chadd int lna1_lna2_delta; 78216ca234SAdrian Chadd }; 79216ca234SAdrian Chadd 80216ca234SAdrian Chadd extern int ath_lna_div_attach(struct ath_softc *sc); 81216ca234SAdrian Chadd extern int ath_lna_div_detach(struct ath_softc *sc); 82216ca234SAdrian Chadd extern int ath_lna_div_ioctl(struct ath_softc *sc, struct ath_diag *ad); 83216ca234SAdrian Chadd extern int ath_lna_div_enable(struct ath_softc *sc, 84216ca234SAdrian Chadd const struct ieee80211_channel *ch); 85216ca234SAdrian Chadd 86216ca234SAdrian Chadd extern void ath_lna_rx_comb_scan(struct ath_softc *sc, 87216ca234SAdrian Chadd struct ath_rx_status *rs, unsigned long ticks, int hz); 88216ca234SAdrian Chadd 89216ca234SAdrian Chadd #endif /* __IF_ATH_LNA_DIV_H__ */ 90