carl9170 firmware: investigate 80/88MHz clock freezes
[carl9170fw.git] / carlfw / src / rf.c
index 9537c2a747f4d3d48849c4b36e45884f6ccd4e0e..5448abfe32bc5842aa6c30b84b2bd68c768962b0 100644 (file)
 #include "shared/phy.h"
 
 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
-static void set_channel_start(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);
-}
-
 static void set_channel_end(void)
 {
        /* Manipulate CCA threshold to resume transmission */
@@ -46,11 +37,23 @@ static void set_channel_end(void)
        /* Disable Virtual CCA */
        andl(AR9170_MAC_REG_QOS_PRIORITY_VIRTUAL_CCA,
             ~AR9170_MAC_VIRTUAL_CCA_ALL);
+
+       fw.phy.state = CARL9170_PHY_ON;
 }
 
 void rf_notify_set_channel(void)
 {
-       set_channel_start();
+       /* 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.cca = 0;
+       fw.tally.tx_time = 0;
+       fw.phy.state = CARL9170_PHY_OFF;
 }
 
 /*
@@ -202,10 +205,14 @@ void rf_cmd(const struct carl9170_cmd *cmd, struct carl9170_rsp *resp)
        /*
         * Is the clock controlled by the PHY?
         */
+#ifdef CONFIG_CARL9170FW_80MHZ_CLOCK
        if ((fw.phy.ht_settings & EIGHTY_FLAG) == EIGHTY_FLAG)
                clock_set(AHB_80_88MHZ, true);
        else
                clock_set(AHB_40_44MHZ, true);
+#else
+       clock_set(AHB_40_44MHZ, true);
+#endif
 
        ret = rf_init(le32_to_cpu(cmd->rf_init.delta_slope_coeff_exp),
                      le32_to_cpu(cmd->rf_init.delta_slope_coeff_man),
@@ -222,10 +229,6 @@ 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;
@@ -246,7 +249,7 @@ void rf_psm(void)
                /* Synthesizer off + RX off */
                bank3 = 0x00400018;
 
-               clock_set(AHB_20_22MHZ, false);
+               fw.phy.state = CARL9170_PHY_OFF;
        } else {
                /* advance to the next PSM step */
                fw.phy.psm.state--;
@@ -263,10 +266,7 @@ void rf_psm(void)
                        /* Synthesizer on + RX on */
                        bank3 = 0x01420098;
 
-                       if ((fw.phy.ht_settings & EIGHTY_FLAG) == EIGHTY_FLAG)
-                               clock_set(AHB_80_88MHZ, true);
-                       else
-                               clock_set(AHB_40_44MHZ, true);
+                       fw.phy.state = CARL9170_PHY_ON;
                } else {
                        return ;
                }