summaryrefslogtreecommitdiffstats
path: root/carl9170fw/carlfw/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--carl9170fw/carlfw/include/cam.h49
-rw-r--r--carl9170fw/carlfw/include/carl9170.h222
-rw-r--r--carl9170fw/carlfw/include/cmd.h55
-rw-r--r--carl9170fw/carlfw/include/config.h64
-rw-r--r--carl9170fw/carlfw/include/dma.h349
-rw-r--r--carl9170fw/carlfw/include/fwdsc.h50
-rw-r--r--carl9170fw/carlfw/include/gpio.h45
-rw-r--r--carl9170fw/carlfw/include/hostif.h47
-rw-r--r--carl9170fw/carlfw/include/io.h153
-rw-r--r--carl9170fw/carlfw/include/printf.h107
-rw-r--r--carl9170fw/carlfw/include/rf.h37
-rw-r--r--carl9170fw/carlfw/include/rom.h82
-rw-r--r--carl9170fw/carlfw/include/timer.h88
-rw-r--r--carl9170fw/carlfw/include/uart.h37
-rw-r--r--carl9170fw/carlfw/include/usb.h191
-rw-r--r--carl9170fw/carlfw/include/usb_fifo.h244
-rw-r--r--carl9170fw/carlfw/include/wl.h296
-rw-r--r--carl9170fw/carlfw/include/wol.h67
18 files changed, 2183 insertions, 0 deletions
diff --git a/carl9170fw/carlfw/include/cam.h b/carl9170fw/carlfw/include/cam.h
new file mode 100644
index 0000000..33afe03
--- /dev/null
+++ b/carl9170fw/carlfw/include/cam.h
@@ -0,0 +1,49 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * CAM (Security Engine) definitions
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_CAM_H
+#define __CARL9170FW_CAM_H
+
+#include "config.h"
+#include "cmd.h"
+
+#ifdef CONFIG_CARL9170FW_SECURITY_ENGINE
+
+#define ENCRY_TYPE_START_ADDR 24
+#define DEFAULT_ENCRY_TYPE 26
+#define KEY_START_ADDR 27
+#define STA_KEY_START_ADDR 155
+#define COUNTER_START_ADDR 163
+#define STA_COUNTER_START_ADDR 165
+
+/* CAM */
+#define MIC_FINISH 0x1
+
+void set_key(const struct carl9170_set_key_cmd *key);
+void disable_key(const struct carl9170_disable_key_cmd *key);
+
+#endif /* CONFIG_CARL9170FW_SECURITY_ENGINE */
+
+#endif /* __CARL9170FW_CAM_H */
diff --git a/carl9170fw/carlfw/include/carl9170.h b/carl9170fw/carlfw/include/carl9170.h
new file mode 100644
index 0000000..cb16415
--- /dev/null
+++ b/carl9170fw/carlfw/include/carl9170.h
@@ -0,0 +1,222 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * Firmware context definition
+ *
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_CARL9170_H
+#define __CARL9170FW_CARL9170_H
+
+#include "generated/autoconf.h"
+#include "version.h"
+#include "config.h"
+#include "types.h"
+#include "compiler.h"
+#include "fwcmd.h"
+#include "hw.h"
+#include "dma.h"
+#include "usb.h"
+#include "cmd.h"
+
+struct carl9170_bar_ctx {
+ uint8_t ta[6];
+ uint8_t ra[6];
+ __le16 start_seq_num;
+ __le16 control;
+};
+
+#ifdef CONFIG_CARL9170FW_CAB_QUEUE
+enum carl9170_cab_trigger {
+ CARL9170_CAB_TRIGGER_EMPTY = 0,
+ CARL9170_CAB_TRIGGER_ARMED = BIT(0),
+ CARL9170_CAB_TRIGGER_DEFER = BIT(1),
+};
+#endif /* CONFIG_CARL9170FW_CAB_QUEUE */
+
+enum carl9170_ep0_action {
+ CARL9170_EP0_NO_ACTION = 0,
+ CARL9170_EP0_STALL = BIT(0),
+ CARL9170_EP0_TRIGGER = BIT(1),
+};
+
+enum carl9170_mac_reset_state {
+ CARL9170_MAC_RESET_OFF = 0,
+ CARL9170_MAC_RESET_ARMED,
+ CARL9170_MAC_RESET_RESET,
+ CARL9170_MAC_RESET_FORCE,
+};
+
+enum carl9170_suspend_mode {
+ CARL9170_HOST_AWAKE = 0,
+ CARL9170_HOST_SUSPENDED,
+ CARL9170_AWAKE_HOST,
+};
+
+enum carl9170_phy_state {
+ CARL9170_PHY_OFF = 0,
+ CARL9170_PHY_ON
+};
+
+typedef void (*fw_desc_callback_t)(void *, const bool);
+
+/*
+ * This platform - being an odd 32-bit architecture - prefers to
+ * have 32-Bit variables.
+ */
+
+struct firmware_context_struct {
+ /* timer / clocks */
+ unsigned int ticks_per_usec;
+ unsigned int counter; /* main() cycles */
+
+ /* misc */
+ unsigned int watchdog_enable;
+ unsigned int reboot;
+ unsigned int suspend_mode;
+
+ struct {
+ /* Host Interface DMA queues */
+ struct dma_queue up_queue; /* used to send frames to the host */
+ struct dma_queue down_queue; /* stores incoming frames from the host */
+ } pta;
+
+ struct {
+ /* Hardware DMA queues */
+ struct dma_queue tx_queue[__AR9170_NUM_TX_QUEUES]; /* wlan tx queue */
+ struct dma_queue tx_retry;
+ struct dma_queue rx_queue; /* wlan rx queue */
+
+ /* tx aggregate scheduling */
+ struct carl9170_tx_superframe *ampdu_prev[__AR9170_NUM_TX_QUEUES];
+
+ /* Hardware DMA queue unstuck/fix detection */
+ unsigned int last_super_num[__AR9170_NUM_TX_QUEUES];
+ struct carl9170_tx_superframe *last_super[__AR9170_NUM_TX_QUEUES];
+ unsigned int mac_reset;
+ unsigned int soft_int;
+
+ /* rx filter */
+ unsigned int rx_filter;
+
+ /* tx sequence control counters */
+ unsigned int sequence[CARL9170_INTF_NUM];
+
+#ifdef CONFIG_CARL9170FW_CAB_QUEUE
+ /* CAB */
+ struct dma_queue cab_queue[CARL9170_INTF_NUM];
+ unsigned int cab_queue_len[CARL9170_INTF_NUM];
+ unsigned int cab_flush_time;
+ enum carl9170_cab_trigger cab_flush_trigger[CARL9170_INTF_NUM];
+#endif /* CONFIG_CARL9170FW_CAB_QUEUE */
+
+ /* tx status */
+ unsigned int tx_status_pending,
+ tx_status_head_idx,
+ tx_status_tail_idx;
+ struct carl9170_tx_status tx_status_cache[CARL9170_TX_STATUS_NUM];
+
+ /* internal descriptor for use within the service routines */
+ struct dma_desc *fw_desc;
+ unsigned int fw_desc_available;
+ void *fw_desc_data;
+ fw_desc_callback_t fw_desc_callback;
+
+ /* BA(R) Request Handler */
+ struct carl9170_bar_ctx ba_cache[CONFIG_CARL9170FW_BACK_REQS_NUM];
+ unsigned int ba_tail_idx,
+ ba_head_idx,
+ queued_ba;
+
+ unsigned int queued_bar;
+ } wlan;
+
+ struct {
+ unsigned int config,
+ interface_setting,
+ alternate_interface_setting,
+ device_feature;
+ enum carl9170_ep0_action ep0_action;
+
+ void *ep0_txrx_buffer;
+ unsigned int ep0_txrx_len,
+ ep0_txrx_pos;
+
+ struct ar9170_usb_config *cfg_desc;
+ struct ar9170_usb_config *os_cfg_desc;
+
+ /*
+ * special buffers for command & response handling
+ *
+ * the firmware uses a sort of ring-buffer to communicate
+ * to the host.
+ */
+ unsigned int int_pending,
+ int_desc_available,
+ int_head_index,
+ int_tail_index;
+ struct dma_desc *int_desc;
+ struct carl9170_rsp int_buf[CARL9170_INT_RQ_CACHES];
+
+#ifdef CONFIG_CARL9170FW_DEBUG_USB
+ /* USB printf */
+ unsigned int put_index;
+ uint8_t put_buffer[CARL9170_MAX_CMD_PAYLOAD_LEN];
+#endif /* CONFIG_CARL9170FW_DEBUG_USB */
+
+ } usb;
+
+ struct {
+#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
+ /* (cached) ar9170_rf_init */
+
+ /* PHY/RF state */
+ unsigned int frequency;
+ unsigned int ht_settings;
+
+ enum carl9170_phy_state state;
+ struct carl9170_psm psm;
+#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
+ } phy;
+
+ unsigned int tally_clock;
+ struct carl9170_tally_rsp tally;
+ unsigned int tx_time;
+
+#ifdef CONFIG_CARL9170FW_WOL
+ struct {
+ struct carl9170_wol_cmd cmd;
+ unsigned int last_beacon;
+ unsigned int lost_null;
+ unsigned int last_null;
+ bool wake_up;
+ } wol;
+#endif /* CONFIG_CARL9170FW_WOL */
+
+#ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
+ struct carl9170_gpio cached_gpio_state;
+#endif /*CONFIG_CARL9170FW_GPIO_INTERRUPT */
+};
+
+/*
+ * global firmware context struct.
+ *
+ * NOTE: This struct will zeroed out in start()
+ */
+extern struct firmware_context_struct fw;
+#endif /* __CARL9170FW_CARL9170_H */
diff --git a/carl9170fw/carlfw/include/cmd.h b/carl9170fw/carlfw/include/cmd.h
new file mode 100644
index 0000000..54dd350
--- /dev/null
+++ b/carl9170fw/carlfw/include/cmd.h
@@ -0,0 +1,55 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * Firmware command interface definition
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_CMD_H
+#define __CARL9170FW_CMD_H
+
+#include "config.h"
+#include "compiler.h"
+#include "types.h"
+
+#include "fwcmd.h"
+
+static inline void __check(void)
+{
+ BUILD_BUG_ON(sizeof(struct carl9170_cmd) != CARL9170_MAX_CMD_LEN);
+ BUILD_BUG_ON(sizeof(struct carl9170_rsp) != CARL9170_MAX_CMD_LEN);
+ BUILD_BUG_ON(sizeof(struct carl9170_set_key_cmd) != CARL9170_SET_KEY_CMD_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_disable_key_cmd) != CARL9170_DISABLE_KEY_CMD_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_rf_init) != CARL9170_RF_INIT_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_rf_init_result) != CARL9170_RF_INIT_RESULT_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_psm) != CARL9170_PSM_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_tsf_rsp) != CARL9170_TSF_RSP_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_bcn_ctrl_cmd) != CARL9170_BCN_CTRL_CMD_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_tx_status) != CARL9170_TX_STATUS_SIZE);
+ BUILD_BUG_ON(sizeof(struct _carl9170_tx_status) != CARL9170_TX_STATUS_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_gpio) != CARL9170_GPIO_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_rx_filter_cmd) != CARL9170_RX_FILTER_CMD_SIZE);
+ BUILD_BUG_ON(sizeof(struct carl9170_wol_cmd) != CARL9170_WOL_CMD_SIZE);
+}
+
+void handle_cmd(struct carl9170_rsp *resp);
+
+#endif /* __CARL9170FW_CMD_H */
diff --git a/carl9170fw/carlfw/include/config.h b/carl9170fw/carlfw/include/config.h
new file mode 100644
index 0000000..e7c358d
--- /dev/null
+++ b/carl9170fw/carlfw/include/config.h
@@ -0,0 +1,64 @@
+/*
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "generated/autoconf.h"
+#include "version.h"
+#include "types.h"
+#include "compiler.h"
+#include "fwcmd.h"
+#include "hw.h"
+
+#ifndef __CARL9170FW_CONFIG_H
+#define __CARL9170FW_CONFIG_H
+
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+
+#if GCC_VERSION < 40400
+# error "This firmware will not work if it is compiled with gcc versions < 4.4"
+# error "See: http://gcc.gnu.org/gcc-4.4/changes.html / Caveats No. 4"
+#endif
+
+#if ((defined CONFIG_CARL9170FW_PRINTF) && \
+ (!defined CONFIG_CARL9170FW_DEBUG_USB) && \
+ (!defined CONFIG_CARL9170FW_DEBUG_UART))
+# warning "You have disabled all debug message transports."
+# warning "However CONFIG_CARL9170FW_PRINTF is still set..."
+# warning "Which is a waste of firmware space, if you ask me."
+#endif
+
+#define CARL9170_TX_STATUS_NUM (CARL9170_RSP_TX_STATUS_NUM)
+#define CARL9170_INT_RQ_CACHES 16
+#define AR9170_INT_MAGIC_HEADER_SIZE 12
+#define CARL9170_TBTT_DELTA (CARL9170_PRETBTT_KUS + 1)
+
+#define CARL9170_GPIO_MASK (AR9170_GPIO_PORT_WPS_BUTTON_PRESSED)
+
+#ifdef CONFIG_CARL9170FW_VIFS_NUM
+#define CARL9170_INTF_NUM (1 + CONFIG_CARL9170FW_VIFS_NUM)
+#else
+#define CARL9170_INTF_NUM (1)
+#endif /* CONFIG_CARL9170FW_VIFS_NUM */
+
+#define CONFIG_CARL9170FW_BACK_REQS_NUM 4
+
+static inline void __config_check(void)
+{
+ BUILD_BUG_ON(!CARL9170_TX_STATUS_NUM);
+ BUILD_BUG_ON(CARL9170_INTF_NUM < 1);
+ BUILD_BUG_ON(CARL9170_INTF_NUM >= AR9170_MAX_VIRTUAL_MAC);
+}
+
+#endif /* __CARL9170FW_CONFIG_H */
diff --git a/carl9170fw/carlfw/include/dma.h b/carl9170fw/carlfw/include/dma.h
new file mode 100644
index 0000000..8f3a9df
--- /dev/null
+++ b/carl9170fw/carlfw/include/dma.h
@@ -0,0 +1,349 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * This module contains DMA descriptor related definitions.
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_DMA_H
+#define __CARL9170FW_DMA_H
+
+#include "config.h"
+#include "types.h"
+#include "compiler.h"
+#include "hw.h"
+#include "ieee80211.h"
+#include "wlan.h"
+
+struct dma_desc {
+ volatile uint16_t status; /* Descriptor status */
+ volatile uint16_t ctrl; /* Descriptor control */
+ volatile uint16_t dataSize; /* Data size */
+ volatile uint16_t totalLen; /* Total length */
+ struct dma_desc *lastAddr; /* Last address of this chain */
+ union {
+ uint8_t *_dataAddr; /* Data buffer address */
+ void *dataAddr;
+ } __packed;
+ struct dma_desc *nextAddr; /* Next TD address */
+} __packed __aligned(4);
+
+/* Up, Dn, 5x Tx, retry, Rx, [USB Int], (CAB), FW */
+#define AR9170_TERMINATOR_NUMBER_B 10
+
+#define AR9170_TERMINATOR_NUMBER_INT 1
+
+#ifdef CONFIG_CARL9170FW_CAB_QUEUE
+#define AR9170_TERMINATOR_NUMBER_CAB CARL9170_INTF_NUM
+#else
+#define AR9170_TERMINATOR_NUMBER_CAB 0
+#endif /* CONFIG_CARL9170FW_CAB_QUEUE */
+
+#define AR9170_TERMINATOR_NUMBER (AR9170_TERMINATOR_NUMBER_B + \
+ AR9170_TERMINATOR_NUMBER_INT + \
+ AR9170_TERMINATOR_NUMBER_CAB)
+
+#define AR9170_BLOCK_SIZE (256 + 64)
+
+#define AR9170_DESCRIPTOR_SIZE (sizeof(struct dma_desc))
+
+struct ar9170_tx_ba_frame {
+ struct ar9170_tx_hwdesc hdr;
+ struct ieee80211_ba ba;
+} __packed;
+
+struct carl9170_tx_ba_superframe {
+ struct carl9170_tx_superdesc s;
+ struct ar9170_tx_ba_frame f;
+} __packed;
+
+struct ar9170_tx_null_frame {
+ struct ar9170_tx_hwdesc hdr;
+ struct ieee80211_hdr null;
+} __packed;
+
+struct carl9170_tx_null_superframe {
+ struct carl9170_tx_superdesc s;
+ struct ar9170_tx_null_frame f;
+} __packed;
+
+#define CARL9170_BA_BUFFER_LEN (__roundup(sizeof(struct carl9170_tx_ba_superframe), 16))
+#define CARL9170_RSP_BUFFER_LEN AR9170_BLOCK_SIZE
+
+struct carl9170_sram_reserved {
+ union {
+ uint32_t buf[CARL9170_BA_BUFFER_LEN / sizeof(uint32_t)];
+ struct carl9170_tx_ba_superframe ba;
+ } ba;
+
+ union {
+ uint32_t buf[CARL9170_MAX_CMD_LEN / sizeof(uint32_t)];
+ struct carl9170_cmd cmd;
+
+#ifdef CONFIG_CARL9170FW_WOL
+ struct carl9170_tx_null_superframe null;
+#endif /* CONFIG_CARL9170FW_WOL */
+ } cmd;
+
+ union {
+ uint32_t buf[CARL9170_RSP_BUFFER_LEN / sizeof(uint32_t)];
+ struct carl9170_rsp rsp;
+ } rsp;
+
+ union {
+ uint32_t buf[CARL9170_INTF_NUM][AR9170_MAC_BCN_LENGTH_MAX / sizeof(uint32_t)];
+ } bcn;
+};
+
+/*
+ * Memory layout in RAM:
+ *
+ * 0x100000 +--
+ * | terminator descriptors (dma_desc)
+ * | - Up (to USB host)
+ * | - Down (from USB host)
+ * | - TX (5x, to wifi)
+ * | - AMPDU TX retry
+ * | - RX (from wifi)
+ * | - CAB Queue
+ * | - FW cmd & req descriptor
+ * | - BlockAck descriptor
+ * | total: AR9170_TERMINATOR_NUMBER
+ * +--
+ * | block descriptors (dma_desc)
+ * | (AR9170_BLOCK_NUMBER)
+ * AR9170_BLOCK_BUFFER_BASE +-- align to multiple of 64
+ * | block buffers (AR9170_BLOCK_SIZE each)
+ * | (AR9170_BLOCK_NUMBER)
+ * approx. 0x117c00 +--
+ * | BA buffer (128 bytes)
+ * +--
+ * | CMD buffer (128 bytes)
+ * | - used as NULLFRAME buffer (128 bytes) for WOL
+ * +--
+ * | RSP buffer (320 bytes)
+ * +--
+ * | BEACON buffer (256 bytes)
+ * +--
+ * | unaccounted space / padding
+ * +--
+ * 0x18000
+ */
+
+#define CARL9170_SRAM_RESERVED (sizeof(struct carl9170_sram_reserved))
+
+#define AR9170_FRAME_MEMORY_SIZE (AR9170_SRAM_SIZE - CARL9170_SRAM_RESERVED)
+
+#define BLOCK_ALIGNMENT 64
+
+#define NONBLOCK_DESCRIPTORS_SIZE \
+ (AR9170_DESCRIPTOR_SIZE * (AR9170_TERMINATOR_NUMBER))
+
+#define NONBLOCK_DESCRIPTORS_SIZE_ALIGNED \
+ (ALIGN(NONBLOCK_DESCRIPTORS_SIZE, BLOCK_ALIGNMENT))
+
+#define AR9170_BLOCK_NUMBER ((AR9170_FRAME_MEMORY_SIZE - NONBLOCK_DESCRIPTORS_SIZE_ALIGNED) / \
+ (AR9170_BLOCK_SIZE + AR9170_DESCRIPTOR_SIZE))
+
+struct ar9170_data_block {
+ uint8_t data[AR9170_BLOCK_SIZE];
+};
+
+struct ar9170_dma_memory {
+ struct dma_desc terminator[AR9170_TERMINATOR_NUMBER];
+ struct dma_desc block[AR9170_BLOCK_NUMBER];
+ struct ar9170_data_block data[AR9170_BLOCK_NUMBER] __aligned(BLOCK_ALIGNMENT);
+ struct carl9170_sram_reserved reserved __aligned(BLOCK_ALIGNMENT);
+};
+
+extern struct ar9170_dma_memory dma_mem;
+
+#define AR9170_DOWN_BLOCK_RATIO 2
+#define AR9170_RX_BLOCK_RATIO 1
+/* Tx 16*2 = 32 packets => 32*(5*320) */
+#define AR9170_TX_BLOCK_NUMBER (AR9170_BLOCK_NUMBER * AR9170_DOWN_BLOCK_RATIO / \
+ (AR9170_RX_BLOCK_RATIO + AR9170_DOWN_BLOCK_RATIO))
+#define AR9170_RX_BLOCK_NUMBER (AR9170_BLOCK_NUMBER - AR9170_TX_BLOCK_NUMBER)
+
+/* Error code */
+#define AR9170_ERR_FS_BIT 1
+#define AR9170_ERR_LS_BIT 2
+#define AR9170_ERR_OWN_BITS 3
+#define AR9170_ERR_DATA_SIZE 4
+#define AR9170_ERR_TOTAL_LEN 5
+#define AR9170_ERR_DATA 6
+#define AR9170_ERR_SEQ 7
+#define AR9170_ERR_LEN 8
+
+/* Status bits definitions */
+/* Own bits definitions */
+#define AR9170_OWN_BITS 0x3
+#define AR9170_OWN_BITS_S 0
+#define AR9170_OWN_BITS_SW 0x0
+#define AR9170_OWN_BITS_HW 0x1
+#define AR9170_OWN_BITS_SE 0x2
+
+/* Control bits definitions */
+#define AR9170_CTRL_TXFAIL 1
+#define AR9170_CTRL_BAFAIL 2
+#define AR9170_CTRL_FAIL (AR9170_CTRL_TXFAIL | AR9170_CTRL_BAFAIL)
+
+/* First segament bit */
+#define AR9170_CTRL_LS_BIT 0x100
+/* Last segament bit */
+#define AR9170_CTRL_FS_BIT 0x200
+
+struct dma_queue {
+ struct dma_desc *head;
+ struct dma_desc *terminator;
+};
+
+#define DESC_PAYLOAD(a) ((void *)a->dataAddr)
+#define DESC_PAYLOAD_OFF(a, offset) ((void *)((unsigned long)(a->_dataAddr) + offset))
+
+struct dma_desc *dma_unlink_head(struct dma_queue *queue);
+void dma_init_descriptors(void);
+void dma_reclaim(struct dma_queue *q, struct dma_desc *desc);
+void dma_put(struct dma_queue *q, struct dma_desc *desc);
+
+static inline __inline bool is_terminator(struct dma_queue *q, struct dma_desc *desc)
+{
+ return q->terminator == desc;
+}
+
+static inline __inline bool queue_empty(struct dma_queue *q)
+{
+ return q->head == q->terminator;
+}
+
+/*
+ * Get a completed packet with # descriptors. Return the first
+ * descriptor and pointer the head directly by lastAddr->nextAddr
+ */
+static inline __inline struct dma_desc *dma_dequeue_bits(struct dma_queue *q,
+ uint16_t bits)
+{
+ struct dma_desc *desc = NULL;
+
+ if ((q->head->status & AR9170_OWN_BITS) == bits)
+ desc = dma_unlink_head(q);
+
+ return desc;
+}
+
+static inline __inline struct dma_desc *dma_dequeue_not_bits(struct dma_queue *q,
+ uint16_t bits)
+{
+ struct dma_desc *desc = NULL;
+
+ /* AR9170_OWN_BITS_HW will be filtered out here too. */
+ if ((q->head->status & AR9170_OWN_BITS) != bits)
+ desc = dma_unlink_head(q);
+
+ return desc;
+}
+
+#define for_each_desc_bits(desc, queue, bits) \
+ while ((desc = dma_dequeue_bits(queue, bits)))
+
+#define for_each_desc_not_bits(desc, queue, bits) \
+ while ((desc = dma_dequeue_not_bits(queue, bits)))
+
+#define for_each_desc(desc, queue) \
+ while ((desc = dma_unlink_head(queue)))
+
+#define __for_each_desc_bits(desc, queue, bits) \
+ for (desc = (queue)->head; \
+ (desc != (queue)->terminator && \
+ (desc->status & AR9170_OWN_BITS) == bits); \
+ desc = desc->lastAddr->nextAddr)
+
+#define __while_desc_bits(desc, queue, bits) \
+ for (desc = (queue)->head; \
+ (!queue_empty(queue) && \
+ (desc->status & AR9170_OWN_BITS) == bits); \
+ desc = (queue)->head)
+
+#define __for_each_desc_continue(desc, queue) \
+ for (; desc != (queue)->terminator; \
+ desc = (desc)->lastAddr->nextAddr)
+
+#define __for_each_desc(desc, queue) \
+ for (desc = (queue)->head; \
+ desc != (queue)->terminator; \
+ desc = (desc)->lastAddr->nextAddr)
+
+#define __for_each_desc_safe(desc, tmp, queue) \
+ for (desc = (queue)->head, tmp = desc->lastAddr->nextAddr; \
+ desc != (queue)->terminator; \
+ desc = tmp, tmp = tmp->lastAddr->nextAddr)
+
+#define __while_subdesc(desc, queue) \
+ for (desc = (queue)->head; \
+ desc != (queue)->terminator; \
+ desc = (desc)->nextAddr)
+
+static inline __inline unsigned int queue_len(struct dma_queue *q)
+{
+ struct dma_desc *desc;
+ unsigned int i = 0;
+
+ __while_subdesc(desc, q)
+ i++;
+
+ return i;
+}
+
+/*
+ * rearm a completed packet, so it will be processed agian.
+ */
+static inline __inline void dma_rearm(struct dma_desc *desc)
+{
+ /* Set OWN bit to HW */
+ desc->status = ((desc->status & (~AR9170_OWN_BITS)) |
+ AR9170_OWN_BITS_HW);
+}
+
+static inline __inline void dma_fix_downqueue(struct dma_desc *desc)
+{
+ desc->status = AR9170_OWN_BITS_HW;
+ desc->ctrl = 0;
+ desc->dataSize = 0;
+ desc->totalLen = AR9170_BLOCK_SIZE;
+ desc->lastAddr = desc;
+}
+
+static inline void __check_desc(void)
+{
+ struct ar9170_dma_memory mem;
+ BUILD_BUG_ON(sizeof(struct ar9170_data_block) != AR9170_BLOCK_SIZE);
+ BUILD_BUG_ON(sizeof(struct dma_desc) != 20);
+
+ BUILD_BUG_ON(sizeof(mem) > AR9170_SRAM_SIZE);
+
+ BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, ba.buf) & (BLOCK_ALIGNMENT - 1));
+ BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, cmd.buf) & (BLOCK_ALIGNMENT - 1));
+ BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, rsp.buf) & (BLOCK_ALIGNMENT - 1));
+ BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, bcn.buf) & (BLOCK_ALIGNMENT - 1));
+ BUILD_BUG_ON(sizeof(struct carl9170_tx_null_superframe) > CARL9170_MAX_CMD_LEN);
+}
+
+#endif /* __CARL9170FW_DMA_H */
diff --git a/carl9170fw/carlfw/include/fwdsc.h b/carl9170fw/carlfw/include/fwdsc.h
new file mode 100644
index 0000000..936bfed
--- /dev/null
+++ b/carl9170fw/carlfw/include/fwdsc.h
@@ -0,0 +1,50 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * Firmware definition
+ *
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_FWDSC_H
+#define __CARL9170FW_FWDSC_H
+
+#include "config.h"
+#include "compiler.h"
+#include "types.h"
+#include "fwdesc.h"
+
+struct carl9170_firmware_descriptor {
+ struct carl9170fw_otus_desc otus;
+ struct carl9170fw_txsq_desc txsq;
+#ifdef CONFIG_CARL9170FW_WOL
+ struct carl9170fw_wol_desc wol;
+#endif /* CONFIG_CARL9170FW_WOL */
+ struct carl9170fw_motd_desc motd;
+ struct carl9170fw_dbg_desc dbg;
+ struct carl9170fw_last_desc last;
+} __packed;
+
+extern const struct carl9170_firmware_descriptor carl9170fw_desc;
+
+static inline void __check_fw(void)
+{
+ BUILD_BUG_ON(sizeof(carl9170fw_desc) & 0x3);
+ BUILD_BUG_ON(sizeof(carl9170fw_desc) > CARL9170FW_DESC_MAX_LENGTH);
+}
+
+#endif /* __CARL9170FW_FWDSC_H */
diff --git a/carl9170fw/carlfw/include/gpio.h b/carl9170fw/carlfw/include/gpio.h
new file mode 100644
index 0000000..97c1927
--- /dev/null
+++ b/carl9170fw/carlfw/include/gpio.h
@@ -0,0 +1,45 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * GPIO definitions
+ *
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_GPIO_H
+#define __CARL9170FW_GPIO_H
+
+#include "config.h"
+#include "hw.h"
+#include "io.h"
+
+static inline __inline void led_init(void)
+{
+ set(AR9170_GPIO_REG_PORT_TYPE, 3);
+}
+
+static inline __inline void led_set(const unsigned int ledstate)
+{
+ set(AR9170_GPIO_REG_PORT_DATA, ledstate);
+}
+
+#ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
+
+void gpio_timer(void);
+
+#endif /* CONFIG_CARL9170FW_GPIO_INTERRUPT */
+#endif /* __CARL9170FW_GPIO_H */
diff --git a/carl9170fw/carlfw/include/hostif.h b/carl9170fw/carlfw/include/hostif.h
new file mode 100644
index 0000000..8f9f139
--- /dev/null
+++ b/carl9170fw/carlfw/include/hostif.h
@@ -0,0 +1,47 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * HostIF definition
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_HOSTIF_H
+#define __CARL9170FW_HOSTIF_H
+
+#include "config.h"
+#include "compiler.h"
+#include "types.h"
+#include "hw.h"
+#include "io.h"
+
+static inline __inline void down_trigger(void)
+{
+ set(AR9170_PTA_REG_DN_DMA_TRIGGER, 1);
+}
+
+static inline __inline void up_trigger(void)
+{
+ set(AR9170_PTA_REG_UP_DMA_TRIGGER, 1);
+}
+
+void handle_host_interface(void);
+
+#endif /* __CARL9170FW_HOSTIF_H */
diff --git a/carl9170fw/carlfw/include/io.h b/carl9170fw/carlfw/include/io.h
new file mode 100644
index 0000000..4ccdc6e
--- /dev/null
+++ b/carl9170fw/carlfw/include/io.h
@@ -0,0 +1,153 @@
+/*
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_IO_H
+#define __CARL9170FW_IO_H
+
+#include "config.h"
+#include "types.h"
+#include "compiler.h"
+
+static inline __inline uint8_t readb(const volatile void *addr)
+{
+ return *(const volatile uint8_t *) addr;
+}
+
+static inline __inline uint16_t readw(const volatile void *addr)
+{
+ return *(const volatile uint16_t *) addr;
+}
+
+static inline __inline volatile void *readp(const volatile void *addr)
+{
+ return *(volatile void **) addr;
+}
+
+static inline __inline uint32_t readl(const volatile void *addr)
+{
+ return *(const volatile unsigned int *) addr;
+}
+
+static inline __inline void writeb(volatile void *addr, const volatile uint8_t val)
+{
+ *(volatile uint8_t *) addr = val;
+}
+
+static inline __inline void writew(volatile void *addr, const volatile uint16_t val)
+{
+ *(volatile uint16_t *) addr = val;
+}
+
+static inline __inline void writel(volatile void *addr, const volatile uint32_t val)
+{
+ *(volatile uint32_t *) addr = val;
+}
+
+static inline __inline void __orl(volatile void *addr, const volatile uint32_t val)
+{
+ *(volatile uint32_t *) addr |= val;
+}
+
+static inline __inline void __andl(volatile void *addr, const volatile uint32_t val)
+{
+ *(volatile uint32_t *) addr &= val;
+}
+
+static inline __inline void __xorl(volatile void *addr, const volatile uint32_t val)
+{
+ *(volatile uint32_t *) addr ^= val;
+}
+
+static inline __inline void __incl(volatile void *addr)
+{
+ (*(volatile uint32_t *)addr)++;
+}
+
+static inline __inline uint32_t readl_async(const volatile void *addr)
+{
+ uint32_t i = 0, read, tmp;
+
+ read = readl(addr);
+ do {
+ tmp = read;
+ tmp = readl(addr);
+ i++;
+ } while (tmp != read && i <= 10);
+
+ return read;
+}
+
+static inline __inline void set(const volatile uint32_t addr, const volatile uint32_t val)
+{
+ writel((volatile void *) addr, val);
+}
+
+static inline __inline void orl(volatile uint32_t addr, const volatile uint32_t val)
+{
+ __orl((volatile void *) addr, val);
+}
+
+static inline __inline void xorl(const volatile uint32_t addr, const volatile uint32_t val)
+{
+ __xorl((volatile void *) addr, val);
+}
+
+static inline __inline void andl(const volatile uint32_t addr, const volatile uint32_t val)
+{
+ __andl((volatile void *) addr, val);
+}
+
+static inline __inline void incl(const volatile uint32_t addr)
+{
+ __incl((volatile void *) addr);
+}
+
+static inline __inline uint32_t get(const volatile uint32_t addr)
+{
+ return readl((volatile void *) addr);
+}
+
+static inline __inline volatile void *getp(const volatile uint32_t addr)
+{
+ return readp((const volatile void *) addr);
+}
+
+static inline __inline uint32_t get_async(const volatile uint32_t addr)
+{
+ return readl_async((const volatile void *) addr);
+}
+
+static inline __inline void setb(const volatile uint32_t addr, const volatile uint8_t val)
+{
+ writeb((volatile void *) addr, val);
+}
+
+static inline __inline uint8_t getb(const volatile uint32_t addr)
+{
+ return readb((const volatile void *) addr);
+}
+
+static inline __inline void andb(const volatile uint32_t addr, const volatile uint8_t val)
+{
+ setb(addr, getb(addr) & val);
+}
+
+static inline __inline void orb(const volatile uint32_t addr, const volatile uint32_t val)
+{
+ setb(addr, getb(addr) | val);
+}
+
+#endif /* __CARL9170FW_IO_H */
diff --git a/carl9170fw/carlfw/include/printf.h b/carl9170fw/carlfw/include/printf.h
new file mode 100644
index 0000000..dd4559e
--- /dev/null
+++ b/carl9170fw/carlfw/include/printf.h
@@ -0,0 +1,107 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * printf and his friends...
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_PRINTF_H
+#define __CARL9170FW_PRINTF_H
+
+#include <stdarg.h>
+#include <string.h>
+#include "config.h"
+#include "carl9170.h"
+#include "uart.h"
+#include "fwcmd.h"
+
+#ifdef CONFIG_CARL9170FW_PRINTF
+void __attribute__((format (printf, 1, 2))) tfp_printf(const char *fmt, ...);
+
+#define printf tfp_printf
+
+#else
+void __attribute__((format (printf, 1, 2))) min_printf(const char *fmt, ...);
+
+#define printf min_printf
+#endif /* CONFIG_CARL9170FW_PRINTF */
+
+#define PRINT(fmt, args...) \
+ do { \
+ printf(fmt, ## args); \
+ } while (0)
+
+#define INFO(fmt, args...) PRINT(fmt, ## args)
+
+#define ERR(fmt, args...) PRINT(CARL9170_ERR_MAGIC fmt, ## args)
+
+#ifdef CONFIG_CARL9170FW_DEBUG
+#define DBG(fmt, args...) PRINT(fmt, ## args)
+#else
+#define DBG(...) do { } while (0);
+#endif
+
+/*
+ * NB: even though the MACRO is called "stall". It isn't supposed
+ * to stall since this will render the device unresponsive, until
+ * someone pulls the plug.
+ */
+#define STALL()
+
+#define BUG(fmt, args...) \
+ do { \
+ PRINT(CARL9170_BUG_MAGIC" %s()@%d \"" fmt "\"" , \
+ __func__, __LINE__, ## args); \
+ STALL() \
+ } while (0);
+
+#define BUG_ON(condition) \
+ ({ \
+ int __ret = !!(condition); \
+ if (unlikely(!!(__ret))) \
+ BUG(#condition); \
+ (__ret); \
+ })
+
+static inline __inline void putcharacter(const char c __unused)
+{
+#ifdef CONFIG_CARL9170FW_DEBUG_USB
+ usb_putc(c);
+#endif /* CONFIG_CARL9170FW_DEBUG_USB */
+
+#ifdef CONFIG_CARL9170FW_DEBUG_UART
+ uart_putc(c);
+#endif /* CONFIG_CARL9170FW_DEBUG_UART */
+}
+
+static inline __inline void print_hex_dump(const void *buf __unused, int len __unused)
+{
+#ifdef CONFIG_CARL9170FW_DEBUG_USB
+ usb_print_hex_dump(buf, len);
+#endif /* CONFIG_CARL9170FW_DEBUG_USB */
+
+#ifdef CONFIG_CARL9170FW_DEBUG_UART
+ uart_print_hex_dump(buf, len);
+#endif /* CONFIG_CARL9170FW_DEBUG_UART */
+}
+
+#endif /* __CARL9170FW_PRINTF_H */
+
diff --git a/carl9170fw/carlfw/include/rf.h b/carl9170fw/carlfw/include/rf.h
new file mode 100644
index 0000000..4419bcb
--- /dev/null
+++ b/carl9170fw/carlfw/include/rf.h
@@ -0,0 +1,37 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * RF routine definitions
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_RF_H
+#define __CARL9170FW_RF_H
+
+#include "config.h"
+
+#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
+void rf_notify_set_channel(void);
+void rf_cmd(const struct carl9170_cmd *cmd, struct carl9170_rsp *resp);
+void rf_psm(void);
+#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
+
+#endif /* __CARL9170FW_RF_H */
diff --git a/carl9170fw/carlfw/include/rom.h b/carl9170fw/carlfw/include/rom.h
new file mode 100644
index 0000000..922c5c8
--- /dev/null
+++ b/carl9170fw/carlfw/include/rom.h
@@ -0,0 +1,82 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * ROM layout
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_ROM_H
+#define __CARL9170FW_ROM_H
+
+#include "types.h"
+#include "config.h"
+#include "compiler.h"
+#include "usb.h"
+#include "eeprom.h"
+
+struct ar9170_hwtype {
+ /* 0x00001370 */
+ uint8_t data[4];
+
+ /* 0x00001374 */
+ struct ar9170_led_mode led_mode[AR9170_NUM_LEDS];
+
+ /* 0x00001378 */
+ uint8_t nulldata[2];
+
+ struct {
+ /* 0x0000137a */
+ struct usb_device_descriptor device_desc;
+
+ /* 0x0000138c */
+ uint8_t string0_desc[4];
+
+ /* 0x00001390 */
+ uint8_t string1_desc[32];
+
+ /* 0x000013b0 */
+ uint8_t string2_desc[48];
+
+ /* 0x000013e0 */
+ uint8_t string3_desc[32];
+ } usb;
+} __packed;
+
+struct ar9170_rom {
+ /* 0x00000000 */
+ uint32_t *irq_table[2];
+
+ /* 0x00000008 */
+ uint8_t bootcode[4968];
+
+ /* 0x00001370 */
+ struct ar9170_hwtype hw;
+
+ /* 0x00001400 */
+ uint8_t data[512];
+
+ /* eeprom */
+ struct ar9170_eeprom sys;
+} __packed;
+
+static const struct ar9170_rom rom __section(eeprom);
+
+#endif /* __CARL9170FW_ROM_H */
diff --git a/carl9170fw/carlfw/include/timer.h b/carl9170fw/carlfw/include/timer.h
new file mode 100644
index 0000000..1c1c6cd
--- /dev/null
+++ b/carl9170fw/carlfw/include/timer.h
@@ -0,0 +1,88 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * Clock, Timer & Timing
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_TIMER_H
+#define __CARL9170FW_TIMER_H
+
+#include "config.h"
+
+enum cpu_clock_t {
+ AHB_40MHZ_OSC = 0,
+ AHB_20_22MHZ = 1,
+ AHB_40_44MHZ = 2,
+ AHB_80_88MHZ = 3
+};
+
+static inline __inline uint32_t get_clock_counter(void)
+{
+ return (get(AR9170_TIMER_REG_CLOCK_HIGH) << 16) | get(AR9170_TIMER_REG_CLOCK_LOW);
+}
+
+/*
+ * works only up to 97 secs [44 MHz] or 107 secs for 40 MHz
+ * Also, the delay wait will be affected by 2.4GHz<->5GHz
+ * band changes.
+ */
+static inline __inline bool is_after_msecs(const uint32_t t0, const uint32_t msecs)
+{
+ return ((get_clock_counter() - t0) / 1000) > (msecs * fw.ticks_per_usec);
+}
+
+/*
+ * Note: Be careful with [u]delay. They won't service the
+ * hardware watchdog timer. It might trigger if you
+ * wait long enough. Also they don't terminate if sec is
+ * above 97 sec [44MHz] or more than 107 sec [40MHz].
+ */
+static inline __inline void delay(const uint32_t msec)
+{
+ uint32_t t1, t2, dt, wt;
+
+ wt = msec * fw.ticks_per_usec;
+
+ t1 = get_clock_counter();
+ while (1) {
+ t2 = get_clock_counter();
+ dt = (t2 - t1) / 1000;
+ if (dt >= wt)
+ break;
+ }
+}
+
+static inline __inline void udelay(const uint32_t usec)
+{
+ uint32_t t1, t2, dt;
+
+ t1 = get_clock_counter();
+ while (1) {
+ t2 = get_clock_counter();
+ dt = (t2 - t1);
+ if (dt >= (usec * fw.ticks_per_usec))
+ break;
+ }
+}
+
+void clock_set(enum cpu_clock_t _clock, bool on);
+#endif /* __CARL9170FW_TIMER_H */
diff --git a/carl9170fw/carlfw/include/uart.h b/carl9170fw/carlfw/include/uart.h
new file mode 100644
index 0000000..1cfa29d
--- /dev/null
+++ b/carl9170fw/carlfw/include/uart.h
@@ -0,0 +1,37 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * UART functions definition
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_UART_H
+#define __CARL9170FW_UART_H
+
+#include "config.h"
+
+#ifdef CONFIG_CARL9170FW_DEBUG_UART
+void uart_putc(const char c);
+void uart_print_hex_dump(const void *buf, const int len);
+void uart_init(void);
+#endif /* CONFIG_CARL9170FW_DEBUG_UART */
+
+#endif /* __CARL9170FW_UART_H */
diff --git a/carl9170fw/carlfw/include/usb.h b/carl9170fw/carlfw/include/usb.h
new file mode 100644
index 0000000..cea1d4d
--- /dev/null
+++ b/carl9170fw/carlfw/include/usb.h
@@ -0,0 +1,191 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * USB definitions
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_USB_H
+#define __CARL9170FW_USB_H
+
+#include "config.h"
+#include "types.h"
+#include "io.h"
+#include "hw.h"
+#include "ch9.h"
+
+struct ar9170_usb_config {
+ struct usb_config_descriptor cfg;
+ struct usb_interface_descriptor intf;
+ struct usb_endpoint_descriptor ep[AR9170_USB_NUM_EXTRA_EP];
+} __packed;
+
+static inline __inline bool usb_detect_highspeed(void)
+{
+ return !!(getb(AR9170_USB_REG_MAIN_CTRL) &
+ AR9170_USB_MAIN_CTRL_HIGHSPEED);
+}
+
+static inline __inline bool usb_configured(void)
+{
+ return !!(getb(AR9170_USB_REG_DEVICE_ADDRESS) &
+ AR9170_USB_DEVICE_ADDRESS_CONFIGURE);
+}
+
+static inline __inline void usb_enable_remote_wakeup(void)
+{
+ orb(AR9170_USB_REG_MAIN_CTRL, AR9170_USB_MAIN_CTRL_REMOTE_WAKEUP);
+}
+
+static inline __inline void usb_disable_remote_wakeup(void)
+{
+ andb(AR9170_USB_REG_MAIN_CTRL, ~AR9170_USB_MAIN_CTRL_REMOTE_WAKEUP);
+}
+
+static inline __inline void usb_enable_global_int(void)
+{
+ orb(AR9170_USB_REG_MAIN_CTRL, AR9170_USB_MAIN_CTRL_ENABLE_GLOBAL_INT);
+}
+
+static inline __inline void usb_trigger_out(void)
+{
+ andb(AR9170_USB_REG_INTR_MASK_BYTE_4,
+ (uint8_t) ~AR9170_USB_INTR_DISABLE_OUT_INT);
+}
+
+static inline __inline void usb_reset_out(void)
+{
+ orb(AR9170_USB_REG_INTR_MASK_BYTE_4, AR9170_USB_INTR_DISABLE_OUT_INT);
+}
+
+static inline __inline void usb_trigger_in(void)
+{
+ andb(AR9170_USB_REG_INTR_MASK_BYTE_6, ~AR9170_USB_INTR_DISABLE_IN_INT);
+}
+
+static inline __inline void usb_reset_in(void)
+{
+ orb(AR9170_USB_REG_INTR_MASK_BYTE_6, AR9170_USB_INTR_DISABLE_IN_INT);
+}
+
+static inline __inline void usb_ep3_xfer_done(void)
+{
+ orb(AR9170_USB_REG_EP3_BYTE_COUNT_HIGH, 0x08);
+}
+
+static inline __inline void usb_suspend_ack(void)
+{
+ /*
+ * uP must do-over everything it should handle
+ * and do before into the suspend mode
+ */
+ andb(AR9170_USB_REG_INTR_SOURCE_7, ~BIT(2));
+}
+
+static inline __inline void usb_resume_ack(void)
+{
+ /*
+ * uP must do-over everything it should handle
+ * and do before into the suspend mode
+ */
+
+ andb(AR9170_USB_REG_INTR_SOURCE_7, ~BIT(3));
+}
+
+static inline __inline void usb_reset_ack(void)
+{
+ andb(AR9170_USB_REG_INTR_SOURCE_7, ~BIT(1));
+}
+
+static inline __inline void usb_data_out0Byte(void)
+{
+ andb(AR9170_USB_REG_INTR_SOURCE_7, (uint8_t) ~BIT(7));
+}
+
+static inline __inline void usb_data_in0Byte(void)
+{
+ andb(AR9170_USB_REG_INTR_SOURCE_7, ~BIT(6));
+}
+
+static inline __inline void usb_stop_down_queue(void)
+{
+ andl(AR9170_USB_REG_DMA_CTL, ~AR9170_USB_DMA_CTL_ENABLE_TO_DEVICE);
+}
+
+static inline __inline void usb_start_down_queue(void)
+{
+ orl(AR9170_USB_REG_DMA_CTL, AR9170_USB_DMA_CTL_ENABLE_TO_DEVICE);
+}
+
+static inline __inline void usb_clear_input_ep_toggle(unsigned int ep)
+{
+ andl(AR9170_USB_REG_EP_IN_MAX_SIZE_HIGH + (ep << 1),
+ ~AR9170_USB_EP_IN_TOGGLE);
+}
+
+static inline __inline void usb_set_input_ep_toggle(unsigned int ep)
+{
+ orl(AR9170_USB_REG_EP_IN_MAX_SIZE_HIGH + (ep << 1),
+ AR9170_USB_EP_IN_TOGGLE);
+}
+
+static inline __inline void usb_clear_output_ep_toggle(unsigned int ep)
+{
+ andl(AR9170_USB_REG_EP_OUT_MAX_SIZE_HIGH + (ep << 1),
+ ~AR9170_USB_EP_OUT_TOGGLE);
+}
+
+static inline __inline void usb_set_output_ep_toggle(unsigned int ep)
+{
+ orl(AR9170_USB_REG_EP_OUT_MAX_SIZE_HIGH + (ep << 1),
+ AR9170_USB_EP_OUT_TOGGLE);
+}
+
+static inline void usb_structure_check(void)
+{
+ BUILD_BUG_ON(sizeof(struct usb_config_descriptor) != USB_DT_CONFIG_SIZE);
+ BUILD_BUG_ON(sizeof(struct usb_device_descriptor) != USB_DT_DEVICE_SIZE);
+ BUILD_BUG_ON(sizeof(struct usb_endpoint_descriptor) != USB_DT_ENDPOINT_SIZE);
+ BUILD_BUG_ON(sizeof(struct usb_interface_descriptor) != USB_DT_INTERFACE_SIZE);
+}
+
+void __noreturn jump_to_bootcode(void);
+
+void send_cmd_to_host(const uint8_t len, const uint8_t type,
+ const uint8_t ext, const uint8_t *body);
+
+void usb_init(void);
+void usb_ep0rx(void);
+void usb_ep0tx(void);
+void usb_ep0setup(void);
+void handle_usb(void);
+
+void usb_timer(void);
+void usb_putc(const char c);
+void usb_print_hex_dump(const void *buf, int len);
+
+void usb_init_highspeed_fifo_cfg(void);
+void usb_init_fullspeed_fifo_cfg(void);
+
+void __noreturn start(void);
+void __noreturn reboot(void);
+
+#endif /* __CARL9170FW_USB_H */
diff --git a/carl9170fw/carlfw/include/usb_fifo.h b/carl9170fw/carlfw/include/usb_fifo.h
new file mode 100644
index 0000000..5d84c88
--- /dev/null
+++ b/carl9170fw/carlfw/include/usb_fifo.h
@@ -0,0 +1,244 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * USB definitions
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_USB_FIFO_H
+#define __CARL9170FW_USB_FIFO_H
+
+#include "config.h"
+
+#define MASK_F0 0xf0
+
+/* Block Size define */
+#define BLK512BYTE 1
+#define BLK1024BYTE 2
+
+#define BLK64BYTE 1
+#define BLK128BYTE 2
+
+/* Block toggle number define */
+#define SINGLE_BLK 1
+#define DOUBLE_BLK 2
+#define TRIBLE_BLK 3
+
+/* Endpoint transfer type */
+#define TF_TYPE_ISOCHRONOUS 1
+#define TF_TYPE_BULK 2
+#define TF_TYPE_INTERRUPT 3
+
+/* Endpoint or FIFO direction define */
+#define DIRECTION_IN 0
+#define DIRECTION_OUT 1
+
+#define HS_C1_I0_A0_EP1_MAX_PACKET 512
+#define HS_C1_I0_A0_EP1_bInterval 0
+
+#define HS_C1_I0_A0_EP_NUMBER 0x04
+#define HS_C1_I0_A0_EP_LENGTH (EP_LENGTH * HS_C1_I0_A0_EP_NUMBER)
+#define HS_C1_I0_ALT_LENGTH (HS_C1_I0_A0_EP_LENGTH)
+#define HS_C1_INTERFACE_LENGTH (HS_C1_I0_ALT_LENGTH)
+
+#define HS_C1_CONFIG_TOTAL_LENGTH (CONFIG_LENGTH + INTERFACE_LENGTH + HS_C1_INTERFACE_LENGTH)
+#define FS_C1_CONFIG_TOTAL_LENGTH (CONFIG_LENGTH + INTERFACE_LENGTH + FS_C1_INTERFACE_LENGTH)
+
+#define FS_C1_I0_A0_EP1_MAX_PACKET 64
+/* #define FS_C1_I0_A0_EP1_bInterval HS_C1_I0_A0_EP1_bInterval */
+
+#define HS_CONFIGURATION_NUMBER 1
+#define FS_CONFIGURATION_NUMBER 1
+
+#define fDOUBLE_BUF 1
+#define fDOUBLE_BUF_IN 0
+
+#define fFLASH_DISK 0
+#define fENABLE_ISO 0
+
+#define HS_C1_INTERFACE_NUMBER 0x01
+#define HS_C1 0x01
+#define HS_C1_iConfiguration 0x00
+#define HS_C1_bmAttribute 0x80
+
+#define HS_C1_iMaxPower 0xFA
+
+/* Interface 0 */
+#define HS_C1_I0_ALT_NUMBER 0X01
+/* AlternateSetting 0 */
+#define HS_C1_I0_A0_bInterfaceNumber 0x00
+#define HS_C1_I0_A0_bAlternateSetting 0x00
+/* JWEI 2003/07/14 */
+#define HS_C1_I0_A0_EP_NUMBER 0x04
+#define HS_C1_I0_A0_bInterfaceClass 0xff
+#define HS_C1_I0_A0_bInterfaceSubClass 0x00
+#define HS_C1_I0_A0_bInterfaceProtocol 0x00
+#define HS_C1_I0_A0_iInterface 0x00
+
+/* EP 1 */
+#define HS_C1_I0_A0_EP1_BLKSIZE 512
+#define HS_C1_I0_A0_EP1_BLKNO DOUBLE_BLK
+#define HS_C1_I0_A0_EP1_DIRECTION DIRECTION_OUT
+#define HS_C1_I0_A0_EP1_TYPE TF_TYPE_BULK
+
+#define HS_C1_I0_A0_EP1_MAX_PACKET 512
+#define HS_C1_I0_A0_EP1_bInterval 0
+
+/* EP 2 */
+#define HS_C1_I0_A0_EP2_BLKSIZE 512
+/* JWEI 2003/08/20 */
+#define HS_C1_I0_A0_EP2_BLKNO SINGLE_BLK
+#define HS_C1_I0_A0_EP2_DIRECTION DIRECTION_IN
+#define HS_C1_I0_A0_EP2_TYPE TF_TYPE_BULK
+#define HS_C1_I0_A0_EP2_MAX_PACKET 512
+#define HS_C1_I0_A0_EP2_bInterval 0
+
+/* EP 3 */
+#define HS_C1_I0_A0_EP3_BLKSIZE 64
+#define HS_C1_I0_A0_EP3_BLKNO SINGLE_BLK
+#define HS_C1_I0_A0_EP3_DIRECTION DIRECTION_IN
+#define HS_C1_I0_A0_EP3_TYPE TF_TYPE_INTERRUPT
+#define HS_C1_I0_A0_EP3_MAX_PACKET 0x0040
+#define HS_C1_I0_A0_EP3_bInterval 01
+
+/*
+ * Note: HS Bulk type require max pkt size = 512
+ * ==> must use Interrupt type for max pkt size = 64
+ */
+
+/* EP 4 */
+#define HS_C1_I0_A0_EP4_BLKSIZE 64
+#define HS_C1_I0_A0_EP4_BLKNO SINGLE_BLK
+#define HS_C1_I0_A0_EP4_DIRECTION DIRECTION_OUT
+#define HS_C1_I0_A0_EP4_TYPE TF_TYPE_INTERRUPT
+#define HS_C1_I0_A0_EP4_MAX_PACKET 0x0040
+#define HS_C1_I0_A0_EP4_bInterval 01
+
+#define HS_C1_I0_A0_EP_LENGTH (EP_LENGTH * HS_C1_I0_A0_EP_NUMBER)
+/* EP 1 */
+#define HS_C1_I0_A0_EP1_FIFO_START 0
+#define HS_C1_I0_A0_EP1_FIFO_NO (HS_C1_I0_A0_EP1_BLKNO * HS_C1_I0_A0_EP1_BLKSIZE)
+#define HS_C1_I0_A0_EP1_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP1_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP1_BLKNO - 1) << 2) | HS_C1_I0_A0_EP1_TYPE)
+#define HS_C1_I0_A0_EP1_FIFO_MAP (((1 - HS_C1_I0_A0_EP1_DIRECTION) << 4) | 1)
+#define HS_C1_I0_A0_EP1_MAP (HS_C1_I0_A0_EP1_FIFO_START | (HS_C1_I0_A0_EP1_FIFO_START << 4) | (MASK_F0 >> (4*HS_C1_I0_A0_EP1_DIRECTION)))
+
+/* EP 2 */
+#define HS_C1_I0_A0_EP2_FIFO_START (uint8_t)(HS_C1_I0_A0_EP1_FIFO_START + HS_C1_I0_A0_EP1_FIFO_NO)
+#define HS_C1_I0_A0_EP2_FIFO_NO (uint8_t)(HS_C1_I0_A0_EP2_BLKNO * HS_C1_I0_A0_EP2_BLKSIZE)
+#define HS_C1_I0_A0_EP2_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP2_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP2_BLKNO - 1) << 2) | HS_C1_I0_A0_EP2_TYPE)
+#define HS_C1_I0_A0_EP2_FIFO_MAP (uint8_t)(((1 - HS_C1_I0_A0_EP2_DIRECTION) << 4) | 2)
+#define HS_C1_I0_A0_EP2_MAP (uint8_t)(HS_C1_I0_A0_EP2_FIFO_START | (HS_C1_I0_A0_EP2_FIFO_START << 4) | (MASK_F0 >> (4*HS_C1_I0_A0_EP2_DIRECTION)))
+
+/* EP 3 */
+#define HS_C1_I0_A0_EP3_FIFO_START 14
+#define HS_C1_I0_A0_EP3_FIFO_NO (HS_C1_I0_A0_EP3_BLKNO * HS_C1_I0_A0_EP3_BLKSIZE)
+#define HS_C1_I0_A0_EP3_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP3_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP3_BLKNO - 1) << 2) | HS_C1_I0_A0_EP3_TYPE)
+#define HS_C1_I0_A0_EP3_FIFO_MAP (uint8_t)(((1 - HS_C1_I0_A0_EP3_DIRECTION) << 4) | 3)
+#define HS_C1_I0_A0_EP3_MAP (uint8_t)(HS_C1_I0_A0_EP3_FIFO_START | (HS_C1_I0_A0_EP3_FIFO_START << 4) | (MASK_F0 >> (4*HS_C1_I0_A0_EP3_DIRECTION)))
+
+/* EP 4 */
+#define HS_C1_I0_A0_EP4_FIFO_START (HS_C1_I0_A0_EP3_FIFO_START + HS_C1_I0_A0_EP3_FIFO_NO)
+#define HS_C1_I0_A0_EP4_FIFO_NO (HS_C1_I0_A0_EP4_BLKNO * HS_C1_I0_A0_EP4_BLKSIZE)
+#define HS_C1_I0_A0_EP4_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP4_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP4_BLKNO - 1) << 2) | HS_C1_I0_A0_EP4_TYPE)
+#define HS_C1_I0_A0_EP4_FIFO_MAP (((1 - HS_C1_I0_A0_EP4_DIRECTION) << 4) | 4)
+#define HS_C1_I0_A0_EP4_MAP (uint8_t)(HS_C1_I0_A0_EP4_FIFO_START | (HS_C1_I0_A0_EP4_FIFO_START << 4) | (MASK_F0 >> (4*HS_C1_I0_A0_EP4_DIRECTION)))
+
+/* Configuration 1 */
+#define FS_C1_INTERFACE_NUMBER 0x01
+#define FS_C1 0x01
+#define FS_C1_iConfiguration 0x00
+#define FS_C1_bmAttribute 0x80
+#define FS_C1_iMaxPower 0xfa
+
+/* Interface 0 */
+#define FS_C1_I0_ALT_NUMBER 0x01
+/* AlternateSetting 0x00 */
+#define FS_C1_I0_A0_bInterfaceNumber 0x00
+#define FS_C1_I0_A0_bAlternateSetting 0x00
+#define FS_C1_I0_A0_EP_NUMBER 0x04
+#define FS_C1_I0_A0_bInterfaceClass 0xff
+#define FS_C1_I0_A0_bInterfaceSubClass 0x00
+#define FS_C1_I0_A0_bInterfaceProtocol 0x00
+
+/* EP 1 */
+#define FS_C1_I0_A0_EP1_BLKSIZE 512
+/* JWEI 2003/05/19 */
+#define FS_C1_I0_A0_EP1_BLKNO DOUBLE_BLK
+#define FS_C1_I0_A0_EP1_DIRECTION DIRECTION_OUT
+#define FS_C1_I0_A0_EP1_TYPE TF_TYPE_BULK
+#define FS_C1_I0_A0_EP1_MAX_PACKET 64
+#define FS_C1_I0_A0_EP1_bInterval 0
+
+/* EP 2 */
+#define FS_C1_I0_A0_EP2_BLKSIZE 512
+/* JWEI 2003/08/20 */
+#define FS_C1_I0_A0_EP2_BLKNO SINGLE_BLK
+#define FS_C1_I0_A0_EP2_DIRECTION DIRECTION_IN
+#define FS_C1_I0_A0_EP2_TYPE TF_TYPE_BULK
+#define FS_C1_I0_A0_EP2_MAX_PACKET 64
+#define FS_C1_I0_A0_EP2_bInterval 0
+
+/* EP 3 */
+#define FS_C1_I0_A0_EP3_BLKSIZE 64
+#define FS_C1_I0_A0_EP3_BLKNO SINGLE_BLK
+#define FS_C1_I0_A0_EP3_DIRECTION DIRECTION_IN
+#define FS_C1_I0_A0_EP3_TYPE TF_TYPE_INTERRUPT
+#define FS_C1_I0_A0_EP3_MAX_PACKET 0x0040
+#define FS_C1_I0_A0_EP3_bInterval 1
+
+/* EP 4 */
+#define FS_C1_I0_A0_EP4_BLKSIZE 64
+#define FS_C1_I0_A0_EP4_BLKNO SINGLE_BLK
+#define FS_C1_I0_A0_EP4_DIRECTION DIRECTION_OUT
+#define FS_C1_I0_A0_EP4_TYPE TF_TYPE_BULK
+#define FS_C1_I0_A0_EP4_MAX_PACKET 0x0040
+#define FS_C1_I0_A0_EP4_bInterval 0
+
+#define FS_C1_I0_A0_EP_LENGTH (EP_LENGTH * FS_C1_I0_A0_EP_NUMBER)
+/* EP 1 */
+#define FS_C1_I0_A0_EP1_FIFO_START 0
+#define FS_C1_I0_A0_EP1_FIFO_NO (uint8_t)(FS_C1_I0_A0_EP1_BLKNO * FS_C1_I0_A0_EP1_BLKSIZE)
+#define FS_C1_I0_A0_EP1_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP1_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP1_BLKNO - 1) << 2) | FS_C1_I0_A0_EP1_TYPE)
+#define FS_C1_I0_A0_EP1_FIFO_MAP (uint8_t)(((1 - FS_C1_I0_A0_EP1_DIRECTION) << 4) | 1)
+#define FS_C1_I0_A0_EP1_MAP (uint8_t)(FS_C1_I0_A0_EP1_FIFO_START | (FS_C1_I0_A0_EP1_FIFO_START << 4) | (MASK_F0 >> (4*FS_C1_I0_A0_EP1_DIRECTION)))
+
+/* EP 2 */
+#define FS_C1_I0_A0_EP2_FIFO_START (uint8_t)(FS_C1_I0_A0_EP1_FIFO_START + FS_C1_I0_A0_EP1_FIFO_NO)
+#define FS_C1_I0_A0_EP2_FIFO_NO (uint8_t)(FS_C1_I0_A0_EP2_BLKNO * FS_C1_I0_A0_EP2_BLKSIZE)
+#define FS_C1_I0_A0_EP2_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP2_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP2_BLKNO - 1) << 2) | FS_C1_I0_A0_EP2_TYPE)
+#define FS_C1_I0_A0_EP2_FIFO_MAP (uint8_t)(((1 - FS_C1_I0_A0_EP2_DIRECTION) << 4) | 2)
+#define FS_C1_I0_A0_EP2_MAP (uint8_t)(FS_C1_I0_A0_EP2_FIFO_START | (FS_C1_I0_A0_EP2_FIFO_START << 4) | (MASK_F0 >> (4*FS_C1_I0_A0_EP2_DIRECTION)))
+
+/* EP 3 */
+#define FS_C1_I0_A0_EP3_FIFO_START 14
+#define FS_C1_I0_A0_EP3_FIFO_NO (uint8_t)(FS_C1_I0_A0_EP3_BLKNO * FS_C1_I0_A0_EP3_BLKSIZE)
+#define FS_C1_I0_A0_EP3_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP3_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP3_BLKNO - 1) << 2) | FS_C1_I0_A0_EP3_TYPE)
+#define FS_C1_I0_A0_EP3_FIFO_MAP (uint8_t)(((1 - FS_C1_I0_A0_EP3_DIRECTION) << 4) | 3)
+#define FS_C1_I0_A0_EP3_MAP (uint8_t)(FS_C1_I0_A0_EP3_FIFO_START | (FS_C1_I0_A0_EP3_FIFO_START << 4) | (MASK_F0 >> (4*FS_C1_I0_A0_EP3_DIRECTION)))
+
+/* EP 4 */
+#define FS_C1_I0_A0_EP4_FIFO_START (uint8_t)(FS_C1_I0_A0_EP3_FIFO_START + FS_C1_I0_A0_EP3_FIFO_NO)
+#define FS_C1_I0_A0_EP4_FIFO_NO (uint8_t)(FS_C1_I0_A0_EP4_BLKNO * FS_C1_I0_A0_EP4_BLKSIZE)
+#define FS_C1_I0_A0_EP4_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP4_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP4_BLKNO - 1) << 2) | FS_C1_I0_A0_EP4_TYPE)
+#define FS_C1_I0_A0_EP4_FIFO_MAP (uint8_t)(((1 - FS_C1_I0_A0_EP4_DIRECTION) << 4) | 4)
+#define FS_C1_I0_A0_EP4_MAP (uint8_t)(FS_C1_I0_A0_EP4_FIFO_START | (FS_C1_I0_A0_EP4_FIFO_START << 4) | (MASK_F0 >> (4*FS_C1_I0_A0_EP4_DIRECTION)))
+
+#endif /* __CARL9170FW_USB_FIFO_H */
diff --git a/carl9170fw/carlfw/include/wl.h b/carl9170fw/carlfw/include/wl.h
new file mode 100644
index 0000000..dd5b0a8
--- /dev/null
+++ b/carl9170fw/carlfw/include/wl.h
@@ -0,0 +1,296 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * WLAN
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_WLAN_H
+#define __CARL9170FW_WLAN_H
+
+#include "config.h"
+#include "carl9170.h"
+#include "io.h"
+
+struct ieee80211_hdr;
+
+static inline __inline void set_wlan_txq_dma_addr(const unsigned int q, const uint32_t v)
+{
+ set(AR9170_MAC_REG_DMA_TXQ_ADDR + (q << 3), v);
+}
+
+static inline __inline void set_wlan_txq_dma_curr_addr(const unsigned int q, const uint32_t v)
+{
+ set(AR9170_MAC_REG_DMA_TXQ_CURR_ADDR + (q << 3), v);
+}
+
+static inline __inline volatile struct dma_desc *get_wlan_txq_dma_addr(const unsigned int q)
+{
+ return getp(AR9170_MAC_REG_DMA_TXQ_ADDR + (q << 3));
+}
+
+static inline __inline volatile struct dma_desc *get_wlan_txq_addr(const unsigned int q)
+{
+ return getp(AR9170_MAC_REG_DMA_TXQ_CURR_ADDR + (q << 3));
+}
+
+static inline __inline volatile struct dma_desc *get_wlan_txq_last_addr(const unsigned int q)
+{
+ return getp(AR9170_MAC_REG_DMA_TXQ_LAST_ADDR + (q << 2));
+}
+
+static inline __inline void wlan_trigger(const uint32_t queue_bit)
+{
+ set(AR9170_MAC_REG_DMA_TRIGGER, queue_bit);
+}
+
+static inline __inline uint8_t ar9170_get_rx_macstatus_status(struct dma_desc *desc)
+{
+ return *((uint8_t *) DESC_PAYLOAD_OFF(desc->lastAddr,
+ (unsigned int) desc->lastAddr->dataSize - 1));
+}
+
+static inline __inline uint8_t ar9170_get_rx_macstatus_error(struct dma_desc *desc)
+{
+ unsigned int offset;
+
+ if (desc->lastAddr->dataSize == 1) {
+ while (desc->lastAddr != desc->nextAddr)
+ desc = desc->nextAddr;
+
+ offset = (unsigned int) (desc->dataSize - 1);
+ } else {
+ desc = desc->lastAddr;
+ offset = desc->dataSize -
+ (sizeof(struct ar9170_rx_macstatus) -
+ offsetof(struct ar9170_rx_macstatus, error));
+ }
+
+ return *((uint8_t *) DESC_PAYLOAD_OFF(desc, offset));
+}
+
+static inline __inline struct ieee80211_hdr *ar9170_get_rx_i3e(struct dma_desc *desc)
+{
+ if (!((ar9170_get_rx_macstatus_status(desc) &
+ AR9170_RX_STATUS_MPDU) & AR9170_RX_STATUS_MPDU_LAST)) {
+ return (void *)(DESC_PAYLOAD_OFF(desc,
+ offsetof(struct ar9170_rx_frame_head, i3e)));
+ } else {
+ return (void *)(DESC_PAYLOAD_OFF(desc,
+ offsetof(struct ar9170_rx_frame_tail, i3e)));
+ }
+}
+
+static inline __inline struct ar9170_rx_head *ar9170_get_rx_head(struct dma_desc *desc)
+{
+ if (!((ar9170_get_rx_macstatus_status(desc) &
+ AR9170_RX_STATUS_MPDU) & AR9170_RX_STATUS_MPDU_LAST)) {
+ return (void *)((uint8_t *)DESC_PAYLOAD(desc) +
+ offsetof(struct ar9170_rx_frame_head, phy_head));
+ } else {
+ return (void *) NULL;
+ }
+}
+
+static inline __inline uint32_t ar9170_rx_to_phy(struct dma_desc *rx)
+{
+ struct ar9170_tx_hw_phy_control phy;
+ struct ar9170_rx_head *head;
+ uint8_t mac_status;
+
+ phy.set = 0;
+
+ head = ar9170_get_rx_head(rx);
+ if (!head)
+ return le32_to_cpu(phy.set);
+
+ mac_status = ar9170_get_rx_macstatus_status(rx);
+
+ phy.modulation = mac_status & AR9170_RX_STATUS_MODULATION;
+ phy.chains = AR9170_TX_PHY_TXCHAIN_1;
+
+ switch (phy.modulation) {
+ case AR9170_RX_STATUS_MODULATION_CCK:
+ if (mac_status & AR9170_RX_STATUS_SHORT_PREAMBLE)
+ phy.preamble = 1;
+
+ switch (head->plcp[0]) {
+ case AR9170_RX_PHY_RATE_CCK_2M:
+ phy.mcs = AR9170_TX_PHY_RATE_CCK_2M;
+ break;
+
+ case AR9170_RX_PHY_RATE_CCK_5M:
+ phy.mcs = AR9170_TX_PHY_RATE_CCK_5M;
+ break;
+
+ case AR9170_RX_PHY_RATE_CCK_11M:
+ phy.mcs = AR9170_TX_PHY_RATE_CCK_11M;
+ break;
+
+ case AR9170_RX_PHY_RATE_CCK_1M:
+ default:
+ phy.mcs = AR9170_TX_PHY_RATE_CCK_1M;
+ break;
+
+ }
+ break;
+
+ case AR9170_RX_STATUS_MODULATION_DUPOFDM:
+ case AR9170_RX_STATUS_MODULATION_OFDM:
+ phy.mcs = head->plcp[0] & 0xf;
+ break;
+
+ case AR9170_RX_STATUS_MODULATION_HT:
+ if (head->plcp[3] & 0x80)
+ phy.bandwidth = 2;
+
+ if (head->plcp[6] & 0x80)
+ phy.short_gi = 1;
+
+ /* TODO: Enable both chains for MCS > 7 */
+ phy.mcs = head->plcp[6] & 0x7;
+ break;
+ }
+
+ return le32_to_cpu(phy.set);
+}
+
+static inline __inline unsigned int ar9170_get_rx_mpdu_len(struct dma_desc *desc)
+{
+ /*
+ * WARNING: you have to check the error bits in macstatus first!
+ */
+
+ unsigned int mpdu_len = desc->totalLen;
+
+ mpdu_len -= sizeof(struct ar9170_rx_macstatus);
+
+ switch (ar9170_get_rx_macstatus_status(desc) & AR9170_RX_STATUS_MPDU) {
+ case AR9170_RX_STATUS_MPDU_LAST:
+ mpdu_len -= sizeof(struct ar9170_rx_phystatus);
+ break;
+
+ case AR9170_RX_STATUS_MPDU_SINGLE:
+ mpdu_len -= sizeof(struct ar9170_rx_phystatus);
+
+ case AR9170_RX_STATUS_MPDU_FIRST:
+ mpdu_len -= sizeof(struct ar9170_rx_head);
+ break;
+
+ case AR9170_RX_STATUS_MPDU_MIDDLE:
+ default:
+ break;
+ }
+
+ return mpdu_len;
+}
+
+static inline __inline bool ar9170_tx_length_check(const uint16_t len)
+{
+ return len > (sizeof(struct carl9170_tx_superframe) + 24 +
+ FCS_LEN);
+}
+
+static inline __inline struct carl9170_tx_superframe *get_super(struct dma_desc *desc)
+{
+ return container_of(DESC_PAYLOAD(desc), struct carl9170_tx_superframe,
+ f);
+}
+
+static inline __inline struct carl9170_tx_superframe *__get_super(struct dma_desc *desc)
+{
+ return DESC_PAYLOAD(desc);
+}
+
+static inline __inline void hide_super(struct dma_desc *desc)
+{
+ desc->dataAddr = (uint8_t *)
+ (((unsigned long)(DESC_PAYLOAD(desc)) +
+ offsetof(struct carl9170_tx_superframe, f)));
+
+ desc->dataSize -= sizeof(struct carl9170_tx_superdesc);
+ desc->totalLen -= sizeof(struct carl9170_tx_superdesc);
+}
+
+static inline __inline void unhide_super(struct dma_desc *desc)
+{
+ desc->dataAddr = (uint8_t *) get_super(desc);
+ desc->dataSize += sizeof(struct carl9170_tx_superdesc);
+ desc->totalLen += sizeof(struct carl9170_tx_superdesc);
+}
+
+static inline __inline __hot void read_tsf(uint32_t *tsf)
+{
+ /*
+ * "According to the [hardware] documentation:
+ * > when TSF_LOW is read, TSF_HI is automatically concurrently
+ * > copied into a temporary register so that an immediate read
+ * > of TSF_HI will get the value that was present when TSF_LOW
+ * > was read. "
+ *
+ * (David H. Lynch Jr. - mail from 2010-05-22)
+ * http://permalink.gmane.org/gmane.linux.kernel.wireless.general/51249
+ */
+
+ tsf[0] = get(AR9170_MAC_REG_TSF_L);
+ tsf[1] = get(AR9170_MAC_REG_TSF_H);
+}
+
+/* This function will only work on uint32_t-aligned pointers! */
+static inline bool compare_ether_address(const void *_d0, const void *_d1)
+{
+ const uint32_t *d0 = _d0;
+ const uint32_t *d1 = _d1;
+
+ /* BUG_ON((unsigned long)d0 & 3 || (unsigned long)d1 & 3)) */
+ return !((d0[0] ^ d1[0]) | (unsigned short)(d0[1] ^ d1[1]));
+}
+
+void wlan_tx(struct dma_desc *desc);
+void wlan_tx_fw(struct carl9170_tx_superdesc *super, fw_desc_callback_t cb);
+void wlan_timer(void);
+void handle_wlan(void);
+
+void wlan_cab_flush_queue(const unsigned int vif);
+void wlan_modify_beacon(const unsigned int vif,
+ const unsigned int bcn_addr,
+ const unsigned int bcn_len);
+
+void wlan_tx_complete(struct carl9170_tx_superframe *super, bool txs);
+void wlan_prepare_wol(void);
+
+static inline void __check_wlantx(void)
+{
+ BUILD_BUG_ON(CARL9170_TX_SUPERDESC_LEN & 3);
+ BUILD_BUG_ON(sizeof(struct carl9170_tx_superdesc) != CARL9170_TX_SUPERDESC_LEN);
+ BUILD_BUG_ON(sizeof(struct _carl9170_tx_superdesc) != CARL9170_TX_SUPERDESC_LEN);
+ BUILD_BUG_ON(sizeof(struct _carl9170_tx_superframe) != CARL9170_TX_SUPERFRAME_LEN);
+ BUILD_BUG_ON((offsetof(struct carl9170_tx_superframe, f) & 3) != 0);
+ BUILD_BUG_ON(offsetof(struct _carl9170_tx_superframe, f) !=
+ (offsetof(struct _carl9170_tx_superframe, f)));
+ BUILD_BUG_ON(sizeof(struct ar9170_tx_hwdesc) != AR9170_TX_HWDESC_LEN);
+ BUILD_BUG_ON(sizeof(struct _ar9170_tx_hwdesc) != AR9170_TX_HWDESC_LEN);
+ BUILD_BUG_ON(sizeof(struct ar9170_rx_head) != AR9170_RX_HEAD_LEN);
+ BUILD_BUG_ON(sizeof(struct ar9170_rx_phystatus) != AR9170_RX_PHYSTATUS_LEN);
+ BUILD_BUG_ON(sizeof(struct ar9170_rx_macstatus) != AR9170_RX_MACSTATUS_LEN);
+}
+
+#endif /* __CARL9170FW_WLAN_H */
diff --git a/carl9170fw/carlfw/include/wol.h b/carl9170fw/carlfw/include/wol.h
new file mode 100644
index 0000000..829400a
--- /dev/null
+++ b/carl9170fw/carlfw/include/wol.h
@@ -0,0 +1,67 @@
+/*
+ * carl9170 firmware - used by the ar9170 wireless device
+ *
+ * WakeUp on WLAN definitions
+ *
+ * Copyright (c) 2000-2005 ZyDAS Technology Corporation
+ * Copyright (c) 2007-2009 Atheros Communications, Inc.
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CARL9170FW_WOL_H
+#define __CARL9170FW_WOL_H
+
+#include "config.h"
+#include "compiler.h"
+#include "types.h"
+
+#include "fwcmd.h"
+
+#ifdef CONFIG_CARL9170FW_WOL
+
+struct ieee80211_hdr;
+
+void wol_prepare(void);
+void wol_janitor(void);
+void wol_rx(const unsigned int rx_filter __unused,
+ const struct ieee80211_hdr *hdr __unused,
+ const unsigned int len __unused);
+void wol_cmd(const struct carl9170_wol_cmd *cmd);
+
+#else
+
+static inline void wol_cmd(const struct carl9170_wol_cmd *cmd __unused)
+{
+}
+
+static inline void wol_prepare(void)
+{
+}
+
+static inline void wol_janitor(void)
+{
+}
+
+static inline void wol_rx(const unsigned int rx_filter __unused,
+ const struct ieee80211_hdr *hdr __unused,
+ const unsigned int len __unused)
+{
+}
+#endif /* CONFIG_CARL9170FW_WOL */
+
+#endif /* __CARL9170FW_CMD_H */