X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=carlfw%2Fsrc%2Frf.c;h=8deafb50cb167fbbe54845bbc7a583b27f0a92e5;hb=d57b31e45dca1087cefd56876a0a8064efe4e29c;hp=9bb8394dc1b246646065743bdbe1168d1aea98ce;hpb=dcad07e89b7118ec4cf85af567030b73179a4c29;p=carl9170fw.git diff --git a/carlfw/src/rf.c b/carlfw/src/rf.c index 9bb8394..8deafb5 100644 --- a/carlfw/src/rf.c +++ b/carlfw/src/rf.c @@ -6,7 +6,7 @@ * Copyright (c) 2000-2005 ZyDAS Technology Corporation * Copyright (c) 2007-2009 Atheros Communications, Inc. * Copyright 2009 Johannes Berg - * Copyright 2009, 2010 Christian Lamparter + * Copyright 2009-2011 Christian Lamparter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,16 +29,33 @@ #include "rf.h" #include "shared/phy.h" -#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS -static void set_channel_start(void) +void tally_update(void) { - /* Manipulate CCA threshold to stop transmission */ - set(AR9170_PHY_REG_CCA_THRESHOLD, 0x300); - /* Enable Virtual CCA */ - orl(AR9170_MAC_REG_QOS_PRIORITY_VIRTUAL_CCA, - AR9170_MAC_VIRTUAL_CCA_ALL); + unsigned int time; + +#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS + unsigned int main_not_free, ext_not_free; + + main_not_free = get(AR9170_MAC_REG_CHANNEL_BUSY); + ext_not_free = get(AR9170_MAC_REG_EXT_BUSY); + time = get_clock_counter(); + + if (fw.phy.state == CARL9170_PHY_ON) { + unsigned int us_delta = (time - fw.tally_clock) / max(fw.ticks_per_usec, 40u); + + fw.tally.active += us_delta; + fw.tally.main_free += main_not_free; + fw.tally.ext_free += ext_not_free; + } +#else + time = get_clock_counter(); + +#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */ + + fw.tally_clock = time; } +#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS static void set_channel_end(void) { /* Manipulate CCA threshold to resume transmission */ @@ -46,11 +63,28 @@ static void set_channel_end(void) /* Disable Virtual CCA */ andl(AR9170_MAC_REG_QOS_PRIORITY_VIRTUAL_CCA, ~AR9170_MAC_VIRTUAL_CCA_ALL); + + /* clear statistics */ + tally_update(); + + fw.phy.state = CARL9170_PHY_ON; } void rf_notify_set_channel(void) { - set_channel_start(); + tally_update(); + + /* Manipulate CCA threshold to stop transmission */ + set(AR9170_PHY_REG_CCA_THRESHOLD, 0x300); + /* Enable Virtual CCA */ + orl(AR9170_MAC_REG_QOS_PRIORITY_VIRTUAL_CCA, + AR9170_MAC_VIRTUAL_CCA_ALL); + + /* reset CCA stats */ + fw.tally.active = 0; + fw.tally.main_free = 0; + fw.tally.ext_free = 0; + fw.phy.state = CARL9170_PHY_OFF; } /* @@ -199,10 +233,13 @@ void rf_cmd(const struct carl9170_cmd *cmd, struct carl9170_rsp *resp) fw.phy.ht_settings = cmd->rf_init.ht_settings; fw.phy.frequency = cmd->rf_init.freq; + /* + * Is the clock controlled by the PHY? + */ if ((fw.phy.ht_settings & EIGHTY_FLAG) == EIGHTY_FLAG) - clock_set(true, AHB_80_88MHZ); + clock_set(AHB_80_88MHZ, true); else - clock_set(true, AHB_40_44MHZ); + clock_set(AHB_40_44MHZ, true); ret = rf_init(le32_to_cpu(cmd->rf_init.delta_slope_coeff_exp), le32_to_cpu(cmd->rf_init.delta_slope_coeff_man), @@ -215,15 +252,10 @@ void rf_cmd(const struct carl9170_cmd *cmd, struct carl9170_rsp *resp) resp->rf_init_res.ret = cpu_to_le32(ret); } -#ifdef CONFIG_CARL9170FW_PSM void rf_psm(void) { u32 bank3; - /* - * FIXME: Does not work on 5GHz band! - */ - if (fw.phy.psm.state == CARL9170_PSM_SOFTWARE) { /* not enabled by the driver */ return; @@ -244,7 +276,8 @@ void rf_psm(void) /* Synthesizer off + RX off */ bank3 = 0x00400018; - clock_set(true, AHB_20_22MHZ); + tally_update(); + fw.phy.state = CARL9170_PHY_OFF; } else { /* advance to the next PSM step */ fw.phy.psm.state--; @@ -261,20 +294,17 @@ void rf_psm(void) /* Synthesizer on + RX on */ bank3 = 0x01420098; - if ((fw.phy.ht_settings & EIGHTY_FLAG) == EIGHTY_FLAG) - clock_set(true, AHB_80_88MHZ); - else - clock_set(true, AHB_40_44MHZ); + tally_update(); + fw.phy.state = CARL9170_PHY_ON; } else { return ; } } - if (fw.phy.frequency < 30000000) + if (fw.phy.frequency < 3000000) bank3 |= 0x00800000; set(0x1c58f0, bank3); } -#endif /* CONFIG_CARL9170FW_PSM */ #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */