ath9k_htc: Change credit limit for UB94/95
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / ath / ath9k / htc_drv_init.c
index 22736eb901cf9ae6dece2c21ec98f4215cf268f8..8657d26c126537cc26b0b70f80095bec87c2a8f1 100644 (file)
@@ -117,6 +117,21 @@ static struct ieee80211_rate ath9k_legacy_rates[] = {
        RATE(540, 0x0c, 0),
 };
 
+#ifdef CONFIG_MAC80211_LEDS
+static const struct ieee80211_tpt_blink ath9k_htc_tpt_blink[] = {
+       { .throughput = 0 * 1024, .blink_time = 334 },
+       { .throughput = 1 * 1024, .blink_time = 260 },
+       { .throughput = 5 * 1024, .blink_time = 220 },
+       { .throughput = 10 * 1024, .blink_time = 190 },
+       { .throughput = 20 * 1024, .blink_time = 170 },
+       { .throughput = 50 * 1024, .blink_time = 150 },
+       { .throughput = 70 * 1024, .blink_time = 130 },
+       { .throughput = 100 * 1024, .blink_time = 110 },
+       { .throughput = 200 * 1024, .blink_time = 80 },
+       { .throughput = 300 * 1024, .blink_time = 50 },
+};
+#endif
+
 static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
 {
        int time_left;
@@ -140,7 +155,6 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
 
 static void ath9k_deinit_priv(struct ath9k_htc_priv *priv)
 {
-       ath9k_htc_exit_debug(priv->ah);
        ath9k_hw_deinit(priv->ah);
        kfree(priv->ah);
        priv->ah = NULL;
@@ -700,12 +714,6 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv,
                goto err_hw;
        }
 
-       ret = ath9k_htc_init_debug(ah);
-       if (ret) {
-               ath_err(common, "Unable to create debugfs files\n");
-               goto err_debug;
-       }
-
        ret = ath9k_init_queues(priv);
        if (ret)
                goto err_queues;
@@ -725,8 +733,6 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv,
        return 0;
 
 err_queues:
-       ath9k_htc_exit_debug(ah);
-err_debug:
        ath9k_hw_deinit(ah);
 err_hw:
 
@@ -762,6 +768,7 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
        hw->queues = 4;
        hw->channel_change_time = 5000;
        hw->max_listen_interval = 10;
+
        hw->vif_data_size = sizeof(struct ath9k_htc_vif);
        hw->sta_data_size = sizeof(struct ath9k_htc_sta);
 
@@ -811,6 +818,17 @@ static int ath9k_init_firmware_version(struct ath9k_htc_priv *priv)
                 priv->fw_version_major,
                 priv->fw_version_minor);
 
+       /*
+        * Check if the available FW matches the driver's
+        * required version.
+        */
+       if (priv->fw_version_major != MAJOR_VERSION_REQ ||
+           priv->fw_version_minor != MINOR_VERSION_REQ) {
+               dev_err(priv->dev, "ath9k_htc: Please upgrade to FW version %d.%d\n",
+                       MAJOR_VERSION_REQ, MINOR_VERSION_REQ);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
@@ -855,6 +873,13 @@ static int ath9k_init_device(struct ath9k_htc_priv *priv,
        if (error != 0)
                goto err_rx;
 
+#ifdef CONFIG_MAC80211_LEDS
+       /* must be initialized before ieee80211_register_hw */
+       priv->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(priv->hw,
+               IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_htc_tpt_blink,
+               ARRAY_SIZE(ath9k_htc_tpt_blink));
+#endif
+
        /* Register with mac80211 */
        error = ieee80211_register_hw(hw);
        if (error)
@@ -867,6 +892,12 @@ static int ath9k_init_device(struct ath9k_htc_priv *priv,
                        goto err_world;
        }
 
+       error = ath9k_htc_init_debug(priv->ah);
+       if (error) {
+               ath_err(common, "Unable to create debugfs files\n");
+               goto err_world;
+       }
+
        ath_dbg(common, ATH_DBG_CONFIG,
                "WMI:%d, BCN:%d, CAB:%d, UAPSD:%d, MGMT:%d, "
                "BE:%d, BK:%d, VI:%d, VO:%d\n",
@@ -987,38 +1018,20 @@ int ath9k_htc_resume(struct htc_target *htc_handle)
 
 static int __init ath9k_htc_init(void)
 {
-       int error;
-
-       error = ath9k_htc_debug_create_root();
-       if (error < 0) {
-               printk(KERN_ERR
-                       "ath9k_htc: Unable to create debugfs root: %d\n",
-                       error);
-               goto err_dbg;
-       }
-
-       error = ath9k_hif_usb_init();
-       if (error < 0) {
+       if (ath9k_hif_usb_init() < 0) {
                printk(KERN_ERR
                        "ath9k_htc: No USB devices found,"
                        " driver not installed.\n");
-               error = -ENODEV;
-               goto err_usb;
+               return -ENODEV;
        }
 
        return 0;
-
-err_usb:
-       ath9k_htc_debug_remove_root();
-err_dbg:
-       return error;
 }
 module_init(ath9k_htc_init);
 
 static void __exit ath9k_htc_exit(void)
 {
        ath9k_hif_usb_exit();
-       ath9k_htc_debug_remove_root();
        printk(KERN_INFO "ath9k_htc: Driver unloaded\n");
 }
 module_exit(ath9k_htc_exit);