2 * carl9170 firmware - used by the ar9170 wireless device
4 * Firmware context definition
6 * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __CARL9170FW_CARL9170_H
24 #define __CARL9170FW_CARL9170_H
26 #include "generated/autoconf.h"
37 struct carl9170_bar_ctx {
45 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
46 enum carl9170_cab_trigger {
47 CARL9170_CAB_TRIGGER_EMPTY = 0,
48 CARL9170_CAB_TRIGGER_ARMED = BIT(0),
49 CARL9170_CAB_TRIGGER_DEFER = BIT(1),
51 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
53 enum carl9170_ep0_action {
54 CARL9170_EP0_NO_ACTION = 0,
55 CARL9170_EP0_STALL = BIT(0),
56 CARL9170_EP0_TRIGGER = BIT(1),
59 enum carl9170_mac_reset_state {
60 CARL9170_MAC_RESET_OFF = 0,
61 CARL9170_MAC_RESET_ARMED,
62 CARL9170_MAC_RESET_RESET,
63 CARL9170_MAC_RESET_FORCE,
67 * This platform - being an odd 32-bit architecture - prefers to
68 * have 32-Bit variables.
71 struct firmware_context_struct {
73 unsigned int bogoclock; /* supposed to be CPU clock in KHz */
74 unsigned int counter; /* main() cycles */
77 unsigned int watchdog_enable;
80 /* Host Interface DMA queues */
81 struct dma_queue up_queue; /* used to send frames to the host */
82 struct dma_queue down_queue; /* stores incoming frames from the host */
86 /* Hardware DMA queues */
87 struct dma_queue tx_queue[__AR9170_NUM_TX_QUEUES]; /* wlan tx queue */
88 struct dma_queue rx_queue; /* wlan rx queue */
90 #ifdef CONFIG_CARL9170FW_DELAYED_TX
91 struct dma_queue tx_delay[__AR9170_NUM_TX_QUEUES];
92 struct dma_queue tx_retry;
93 unsigned int tx_trigger;
94 #endif /* CONFIG_CARL9170FW_DELAYED_TX */
96 /* Hardware DMA queue unstuck/fix detection */
97 unsigned int last_tx_desc_num[__AR9170_NUM_TX_QUEUES];
98 struct dma_desc *last_tx_desc[__AR9170_NUM_TX_QUEUES];
99 unsigned int rx_total;
100 unsigned int rx_overruns;
101 unsigned int mac_reset;
103 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
105 struct dma_queue cab_queue;
106 unsigned int cab_queue_len,
108 enum carl9170_cab_trigger cab_flush_trigger;
109 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
112 unsigned int tx_status_pending,
115 struct carl9170_tx_status tx_status_cache[CARL9170_TX_STATUS_NUM];
117 #ifdef CONFIG_CARL9170FW_HANDLE_BACK_REQ
118 /* BA(R) Request Handler */
119 struct dma_desc *ba_desc;
120 struct carl9170_bar_ctx ba_cache[CONFIG_CARL9170FW_BACK_REQS_NUM];
121 unsigned int ba_desc_available,
124 #endif /* CONFIG_CARL9170FW_HANDLE_BACK_REQ */
130 alternate_interface_setting;
131 enum carl9170_ep0_action ep0_action;
133 void *ep0_txrx_buffer;
134 unsigned int ep0_txrx_len,
137 struct ar9170_usb_config *cfg_desc;
138 struct ar9170_usb_config *os_cfg_desc;
141 * special buffers for command & response handling
143 * the firmware uses a sort of ring-buffer to communicate
146 unsigned int int_pending,
150 struct dma_desc *int_desc;
151 struct carl9170_rsp int_buf[CARL9170_INT_RQ_CACHES];
153 #ifdef CONFIG_CARL9170FW_DEBUG_USB
155 unsigned int put_index;
156 uint8_t put_buffer[CARL9170_MAX_CMD_PAYLOAD_LEN];
157 #endif /* CONFIG_CARL9170FW_DEBUG_USB */
159 #ifdef CONFIG_CARL9170FW_USB_WATCHDOG
160 struct carl9170_watchdog_cmd watchdog;
161 #endif /* CONFIG CARL9170FW_USB_WATCHDOG */
165 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
166 /* (cached) ar9170_rf_init */
169 unsigned int frequency;
170 unsigned int ht_settings;
172 #ifdef CONFIG_CARL9170FW_PSM
173 struct carl9170_psm psm;
174 #endif /* CONFIG_CARL9170FW_PSM */
175 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
178 #ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
179 struct carl9170_gpio cached_gpio_state;
180 #endif /*CONFIG_CARL9170FW_GPIO_INTERRUPT */
184 * global firmware context struct.
186 * NOTE: This struct will zeroed out in start()
188 extern struct firmware_context_struct fw;
189 #endif /* __CARL9170FW_CARL9170_H */