wl12xx: Support routing FW logs to the host
[pandora-kernel.git] / drivers / net / wireless / wl12xx / cmd.c
index 69d24f3..c9a1fa5 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/crc7.h>
 #include <linux/spi/spi.h>
 #include <linux/etherdevice.h>
 #include <linux/ieee80211.h>
@@ -76,7 +75,7 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
                if (time_after(jiffies, timeout)) {
                        wl1271_error("command complete timeout");
                        ret = -ETIMEDOUT;
-                       goto out;
+                       goto fail;
                }
 
                poll_count++;
@@ -96,14 +95,17 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
        status = le16_to_cpu(cmd->status);
        if (status != CMD_STATUS_SUCCESS) {
                wl1271_error("command execute failure %d", status);
-               ieee80211_queue_work(wl->hw, &wl->recovery_work);
                ret = -EIO;
+               goto fail;
        }
 
        wl1271_write32(wl, ACX_REG_INTERRUPT_ACK,
                       WL1271_ACX_INTR_CMD_COMPLETE);
+       return 0;
 
-out:
+fail:
+       WARN_ON(1);
+       wl12xx_queue_recovery_work(wl);
        return ret;
 }
 
@@ -129,6 +131,14 @@ int wl1271_cmd_general_parms(struct wl1271 *wl)
        if (gp->tx_bip_fem_auto_detect)
                answer = true;
 
+       /* Override the REF CLK from the NVS with the one from platform data */
+       gen_parms->general_params.ref_clock = wl->ref_clock;
+
+       /* LPD mode enable (bits 6-7) in WL1271 AP mode only */
+       if (wl->quirks & WL12XX_QUIRK_LPD_MODE)
+               gen_parms->general_params.general_settings |=
+                       GENERAL_SETTINGS_DRPW_LPD;
+
        ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer);
        if (ret < 0) {
                wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
@@ -168,6 +178,10 @@ int wl128x_cmd_general_parms(struct wl1271 *wl)
        if (gp->tx_bip_fem_auto_detect)
                answer = true;
 
+       /* Replace REF and TCXO CLKs with the ones from platform data */
+       gen_parms->general_params.ref_clock = wl->ref_clock;
+       gen_parms->general_params.tcxo_ref_clock = wl->tcxo_clock;
+
        ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer);
        if (ret < 0) {
                wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
@@ -342,7 +356,7 @@ static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask)
 
        ret = wl1271_cmd_wait_for_event_or_timeout(wl, mask);
        if (ret != 0) {
-               ieee80211_queue_work(wl->hw, &wl->recovery_work);
+               wl12xx_queue_recovery_work(wl);
                return ret;
        }
 
@@ -1070,7 +1084,7 @@ int wl1271_cmd_start_bss(struct wl1271 *wl)
 
        memcpy(cmd->bssid, bss_conf->bssid, ETH_ALEN);
 
-       cmd->aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period);
+       cmd->aging_period = cpu_to_le16(WL1271_AP_DEF_INACTIV_SEC);
        cmd->bss_index = WL1271_AP_BSS_INDEX;
        cmd->global_hlid = WL1271_AP_GLOBAL_HLID;
        cmd->broadcast_hlid = WL1271_AP_BROADCAST_HLID;
@@ -1220,3 +1234,87 @@ out_free:
 out:
        return ret;
 }
+
+int wl12xx_cmd_config_fwlog(struct wl1271 *wl)
+{
+       struct wl12xx_cmd_config_fwlog *cmd;
+       int ret = 0;
+
+       wl1271_debug(DEBUG_CMD, "cmd config firmware logger");
+
+       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+       if (!cmd) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       cmd->logger_mode = wl->conf.fwlog.mode;
+       cmd->log_severity = wl->conf.fwlog.severity;
+       cmd->timestamp = wl->conf.fwlog.timestamp;
+       cmd->output = wl->conf.fwlog.output;
+       cmd->threshold = wl->conf.fwlog.threshold;
+
+       ret = wl1271_cmd_send(wl, CMD_CONFIG_FWLOGGER, cmd, sizeof(*cmd), 0);
+       if (ret < 0) {
+               wl1271_error("failed to send config firmware logger command");
+               goto out_free;
+       }
+
+out_free:
+       kfree(cmd);
+
+out:
+       return ret;
+}
+
+int wl12xx_cmd_start_fwlog(struct wl1271 *wl)
+{
+       struct wl12xx_cmd_start_fwlog *cmd;
+       int ret = 0;
+
+       wl1271_debug(DEBUG_CMD, "cmd start firmware logger");
+
+       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+       if (!cmd) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       ret = wl1271_cmd_send(wl, CMD_START_FWLOGGER, cmd, sizeof(*cmd), 0);
+       if (ret < 0) {
+               wl1271_error("failed to send start firmware logger command");
+               goto out_free;
+       }
+
+out_free:
+       kfree(cmd);
+
+out:
+       return ret;
+}
+
+int wl12xx_cmd_stop_fwlog(struct wl1271 *wl)
+{
+       struct wl12xx_cmd_stop_fwlog *cmd;
+       int ret = 0;
+
+       wl1271_debug(DEBUG_CMD, "cmd stop firmware logger");
+
+       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+       if (!cmd) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       ret = wl1271_cmd_send(wl, CMD_STOP_FWLOGGER, cmd, sizeof(*cmd), 0);
+       if (ret < 0) {
+               wl1271_error("failed to send stop firmware logger command");
+               goto out_free;
+       }
+
+out_free:
+       kfree(cmd);
+
+out:
+       return ret;
+}