2 * carl9170 firmware - used by the ar9170 wireless device
4 * Code to handle commands from the host driver.
6 * Copyright (c) 2000-2005 ZyDAS Technology Corporation
7 * Copyright (c) 2007-2009 Atheros Communications, Inc.
8 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
9 * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 void handle_cmd(struct carl9170_rsp *resp)
36 struct carl9170_cmd *cmd = &dma_mem.reserved.cmd.cmd;
39 /* copies cmd, len and extra fields */
40 resp->hdr.len = cmd->hdr.len;
41 resp->hdr.cmd = cmd->hdr.cmd;
42 resp->hdr.ext = cmd->hdr.ext;
43 resp->hdr.seq |= cmd->hdr.seq;
45 switch (cmd->hdr.cmd & ~CARL9170_CMD_ASYNC_FLAG) {
46 case CARL9170_CMD_RREG:
47 for (i = 0; i < (cmd->hdr.len / 4); i++)
48 resp->rreg_res.vals[i] = get(cmd->rreg.regs[i]);
51 case CARL9170_CMD_WREG:
53 for (i = 0; i < (cmd->hdr.len / 8); i++)
54 set(cmd->wreg.regs[i].addr, cmd->wreg.regs[i].val);
57 case CARL9170_CMD_ECHO:
58 memcpy(resp->echo.vals, cmd->echo.vals, cmd->hdr.len);
61 case CARL9170_CMD_SWRST:
62 #ifdef CONFIG_CARL9170FW_FW_MAC_RESET
64 * Command has no payload, so the response
65 * has no payload either.
68 fw.wlan.mac_reset = CARL9170_MAC_RESET_FORCE;
69 #endif /* CONFIG_CARL9170FW_FW_MAC_RESET */
72 case CARL9170_CMD_REBOOT:
79 case CARL9170_CMD_READ_TSF:
81 read_tsf((uint32_t *)resp->tsf.tsf);
84 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
85 case CARL9170_CMD_BCN_CTRL:
88 if (cmd->bcn_ctrl.mode & CARL9170_BCN_CTRL_CAB_TRIGGER) {
89 wlan_cab_modify_dtim_beacon(cmd->bcn_ctrl.vif_id,
90 cmd->bcn_ctrl.bcn_addr, cmd->bcn_ctrl.bcn_len);
91 set(AR9170_MAC_REG_BCN_ADDR, cmd->bcn_ctrl.bcn_addr);
92 set(AR9170_MAC_REG_BCN_LENGTH, cmd->bcn_ctrl.bcn_len);
93 set(AR9170_MAC_REG_BCN_CTRL, AR9170_BCN_CTRL_READY);
95 wlan_cab_flush_queue(cmd->bcn_ctrl.vif_id);
96 fw.wlan.cab_flush_trigger[i] = CARL9170_CAB_TRIGGER_EMPTY;
99 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
101 #ifdef CONFIG_CARL9170FW_SECURITY_ENGINE
102 case CARL9170_CMD_EKEY:
104 set_key(&cmd->setkey);
107 case CARL9170_CMD_DKEY:
109 disable_key(&cmd->disablekey);
111 #endif /* CONFIG_CARL9170FW_SECURIT_ENGINE */
113 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
114 case CARL9170_CMD_FREQUENCY:
115 case CARL9170_CMD_RF_INIT:
119 case CARL9170_CMD_FREQ_START:
123 rf_notify_set_channel();
126 # ifdef CONFIG_CARL9170FW_PSM
127 case CARL9170_CMD_PSM:
129 fw.phy.psm.state = le32_to_cpu(cmd->psm.state);
132 # endif /* CONFIG_CARL9170FW_PSM */
133 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIOS */
136 BUG("Unknown command %x\n", cmd->hdr.cmd);