| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Shared defines for all mac80211 Prism54 code | 
|  | 3 | * | 
|  | 4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | 
|  | 5 | * | 
|  | 6 | * Based on the islsm (softmac prism54) driver, which is: | 
|  | 7 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | 
|  | 8 | * | 
|  | 9 | * This program is free software; you can redistribute it and/or modify | 
|  | 10 | * it under the terms of the GNU General Public License version 2 as | 
|  | 11 | * published by the Free Software Foundation. | 
|  | 12 | */ | 
|  | 13 |  | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 14 | #ifndef P54_H | 
|  | 15 | #define P54_H | 
|  | 16 |  | 
| Christian Lamparter | 5408281 | 2009-03-25 03:11:44 +0100 | [diff] [blame] | 17 | #ifdef CONFIG_P54_LEDS | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 18 | #include <linux/leds.h> | 
| Christian Lamparter | 5408281 | 2009-03-25 03:11:44 +0100 | [diff] [blame] | 19 | #endif /* CONFIG_P54_LEDS */ | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 20 |  | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 21 | #define ISL38XX_DEV_FIRMWARE_ADDR 0x20000 | 
|  | 22 |  | 
|  | 23 | #define BR_CODE_MIN			0x80000000 | 
|  | 24 | #define BR_CODE_COMPONENT_ID		0x80000001 | 
|  | 25 | #define BR_CODE_COMPONENT_VERSION	0x80000002 | 
|  | 26 | #define BR_CODE_DEPENDENT_IF		0x80000003 | 
|  | 27 | #define BR_CODE_EXPOSED_IF		0x80000004 | 
|  | 28 | #define BR_CODE_DESCR			0x80000101 | 
|  | 29 | #define BR_CODE_MAX			0x8FFFFFFF | 
|  | 30 | #define BR_CODE_END_OF_BRA		0xFF0000FF | 
|  | 31 | #define LEGACY_BR_CODE_END_OF_BRA	0xFFFFFFFF | 
|  | 32 |  | 
|  | 33 | struct bootrec { | 
|  | 34 | __le32 code; | 
|  | 35 | __le32 len; | 
|  | 36 | u32 data[10]; | 
|  | 37 | } __packed; | 
|  | 38 |  | 
|  | 39 | /* Interface role definitions */ | 
|  | 40 | #define BR_INTERFACE_ROLE_SERVER	0x0000 | 
|  | 41 | #define BR_INTERFACE_ROLE_CLIENT	0x8000 | 
|  | 42 |  | 
|  | 43 | #define BR_DESC_PRIV_CAP_WEP		BIT(0) | 
|  | 44 | #define BR_DESC_PRIV_CAP_TKIP		BIT(1) | 
|  | 45 | #define BR_DESC_PRIV_CAP_MICHAEL	BIT(2) | 
|  | 46 | #define BR_DESC_PRIV_CAP_CCX_CP		BIT(3) | 
|  | 47 | #define BR_DESC_PRIV_CAP_CCX_MIC	BIT(4) | 
|  | 48 | #define BR_DESC_PRIV_CAP_AESCCMP	BIT(5) | 
|  | 49 |  | 
|  | 50 | struct bootrec_desc { | 
|  | 51 | __le16 modes; | 
|  | 52 | __le16 flags; | 
|  | 53 | __le32 rx_start; | 
|  | 54 | __le32 rx_end; | 
|  | 55 | u8 headroom; | 
|  | 56 | u8 tailroom; | 
|  | 57 | u8 tx_queues; | 
|  | 58 | u8 tx_depth; | 
|  | 59 | u8 privacy_caps; | 
|  | 60 | u8 rx_keycache_size; | 
|  | 61 | u8 time_size; | 
|  | 62 | u8 padding; | 
|  | 63 | u8 rates[16]; | 
|  | 64 | u8 padding2[4]; | 
|  | 65 | __le16 rx_mtu; | 
|  | 66 | } __packed; | 
|  | 67 |  | 
|  | 68 | #define FW_FMAC 0x464d4143 | 
|  | 69 | #define FW_LM86 0x4c4d3836 | 
|  | 70 | #define FW_LM87 0x4c4d3837 | 
|  | 71 | #define FW_LM20 0x4c4d3230 | 
|  | 72 |  | 
|  | 73 | struct bootrec_comp_id { | 
|  | 74 | __le32 fw_variant; | 
|  | 75 | } __packed; | 
|  | 76 |  | 
|  | 77 | struct bootrec_comp_ver { | 
|  | 78 | char fw_version[24]; | 
|  | 79 | } __packed; | 
|  | 80 |  | 
|  | 81 | struct bootrec_end { | 
|  | 82 | __le16 crc; | 
|  | 83 | u8 padding[2]; | 
|  | 84 | u8 md5[16]; | 
|  | 85 | } __packed; | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 86 |  | 
| Christian Lamparter | 3cd08b3 | 2009-01-09 21:06:06 +0100 | [diff] [blame] | 87 | /* provide 16 bytes for the transport back-end */ | 
|  | 88 | #define P54_TX_INFO_DATA_SIZE		16 | 
|  | 89 |  | 
|  | 90 | /* stored in ieee80211_tx_info's rate_driver_data */ | 
|  | 91 | struct p54_tx_info { | 
|  | 92 | u32 start_addr; | 
|  | 93 | u32 end_addr; | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 94 | union { | 
|  | 95 | void *data[P54_TX_INFO_DATA_SIZE / sizeof(void *)]; | 
|  | 96 | struct { | 
|  | 97 | u32 extra_len; | 
|  | 98 | }; | 
|  | 99 | }; | 
| Christian Lamparter | 3cd08b3 | 2009-01-09 21:06:06 +0100 | [diff] [blame] | 100 | }; | 
|  | 101 |  | 
| Christian Lamparter | 63f2dc9 | 2009-01-09 21:05:31 +0100 | [diff] [blame] | 102 | #define P54_MAX_CTRL_FRAME_LEN		0x1000 | 
|  | 103 |  | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 104 | #define P54_SET_QUEUE(queue, ai_fs, cw_min, cw_max, _txop)	\ | 
|  | 105 | do {								\ | 
|  | 106 | queue.aifs = cpu_to_le16(ai_fs);			\ | 
|  | 107 | queue.cwmin = cpu_to_le16(cw_min);			\ | 
|  | 108 | queue.cwmax = cpu_to_le16(cw_max);			\ | 
|  | 109 | queue.txop = cpu_to_le16(_txop);			\ | 
|  | 110 | } while (0) | 
| Christian Lamparter | 0a5ec96 | 2008-12-14 15:05:42 +0100 | [diff] [blame] | 111 |  | 
| Christian Lamparter | 0fdd7c5 | 2008-10-15 03:55:37 +0200 | [diff] [blame] | 112 | struct p54_edcf_queue_param { | 
|  | 113 | __le16 aifs; | 
|  | 114 | __le16 cwmin; | 
|  | 115 | __le16 cwmax; | 
|  | 116 | __le16 txop; | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 117 | } __packed; | 
| Christian Lamparter | 0fdd7c5 | 2008-10-15 03:55:37 +0200 | [diff] [blame] | 118 |  | 
| Christian Lamparter | 7a047f4 | 2011-02-12 22:32:49 +0100 | [diff] [blame] | 119 | struct p54_rssi_db_entry { | 
|  | 120 | u16 freq; | 
| Christian Lamparter | 69ba3e5 | 2008-12-14 14:45:30 +0100 | [diff] [blame] | 121 | s16 mul; | 
|  | 122 | s16 add; | 
|  | 123 | s16 longbow_unkn; | 
|  | 124 | s16 longbow_unk2; | 
|  | 125 | }; | 
|  | 126 |  | 
| Christian Lamparter | 83cf1b6 | 2009-01-11 01:10:33 +0100 | [diff] [blame] | 127 | struct p54_cal_database { | 
|  | 128 | size_t entries; | 
|  | 129 | size_t entry_size; | 
|  | 130 | size_t offset; | 
|  | 131 | size_t len; | 
|  | 132 | u8 data[0]; | 
|  | 133 | }; | 
|  | 134 |  | 
| Christian Lamparter | 7cb7707 | 2008-09-01 22:48:51 +0200 | [diff] [blame] | 135 | #define EEPROM_READBACK_LEN 0x3fc | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 136 |  | 
| Christian Lamparter | cd8d3d3 | 2009-01-11 01:18:38 +0100 | [diff] [blame] | 137 | enum fw_state { | 
|  | 138 | FW_STATE_OFF, | 
|  | 139 | FW_STATE_BOOTING, | 
|  | 140 | FW_STATE_READY, | 
|  | 141 | FW_STATE_RESET, | 
|  | 142 | FW_STATE_RESETTING, | 
|  | 143 | }; | 
|  | 144 |  | 
| Christian Lamparter | 5408281 | 2009-03-25 03:11:44 +0100 | [diff] [blame] | 145 | #ifdef CONFIG_P54_LEDS | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 146 |  | 
|  | 147 | #define P54_LED_MAX_NAME_LEN 31 | 
|  | 148 |  | 
|  | 149 | struct p54_led_dev { | 
|  | 150 | struct ieee80211_hw *hw_dev; | 
|  | 151 | struct led_classdev led_dev; | 
|  | 152 | char name[P54_LED_MAX_NAME_LEN + 1]; | 
|  | 153 |  | 
| Christian Lamparter | dce0725 | 2009-03-25 03:12:18 +0100 | [diff] [blame] | 154 | unsigned int toggled; | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 155 | unsigned int index; | 
|  | 156 | unsigned int registered; | 
|  | 157 | }; | 
|  | 158 |  | 
| Christian Lamparter | 5408281 | 2009-03-25 03:11:44 +0100 | [diff] [blame] | 159 | #endif /* CONFIG_P54_LEDS */ | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 160 |  | 
| Kalle Valo | 97e93fc | 2010-02-07 10:21:46 +0200 | [diff] [blame] | 161 | struct p54_tx_queue_stats { | 
|  | 162 | unsigned int len; | 
|  | 163 | unsigned int limit; | 
|  | 164 | unsigned int count; | 
|  | 165 | }; | 
|  | 166 |  | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 167 | struct p54_common { | 
| Christian Lamparter | 54fdb04 | 2008-12-13 14:14:20 +0100 | [diff] [blame] | 168 | struct ieee80211_hw *hw; | 
| Christian Lamparter | f13027a | 2009-03-25 03:12:49 +0100 | [diff] [blame] | 169 | struct ieee80211_vif *vif; | 
| Christian Lamparter | 0a5ec96 | 2008-12-14 15:05:42 +0100 | [diff] [blame] | 170 | void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb); | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 171 | int (*open)(struct ieee80211_hw *dev); | 
|  | 172 | void (*stop)(struct ieee80211_hw *dev); | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 173 | struct sk_buff_head tx_pending; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 174 | struct sk_buff_head tx_queue; | 
|  | 175 | struct mutex conf_mutex; | 
| Christian Lamparter | a9b9361 | 2012-03-17 14:10:02 +0100 | [diff] [blame] | 176 | bool registered; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 177 |  | 
|  | 178 | /* memory management (as seen by the firmware) */ | 
|  | 179 | u32 rx_start; | 
|  | 180 | u32 rx_end; | 
| Christian Lamparter | 4e416a6 | 2008-09-01 22:48:41 +0200 | [diff] [blame] | 181 | u16 rx_mtu; | 
|  | 182 | u8 headroom; | 
|  | 183 | u8 tailroom; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 184 |  | 
|  | 185 | /* firmware/hardware info */ | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 186 | unsigned int tx_hdr_len; | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 187 | unsigned int fw_var; | 
| Christian Lamparter | 2b80848 | 2008-09-04 12:29:38 +0200 | [diff] [blame] | 188 | unsigned int fw_interface; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 189 | u8 version; | 
|  | 190 |  | 
|  | 191 | /* (e)DCF / QOS state */ | 
|  | 192 | bool use_short_slot; | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 193 | spinlock_t tx_stats_lock; | 
| Kalle Valo | 97e93fc | 2010-02-07 10:21:46 +0200 | [diff] [blame] | 194 | struct p54_tx_queue_stats tx_stats[8]; | 
| Christian Lamparter | 0fdd7c5 | 2008-10-15 03:55:37 +0200 | [diff] [blame] | 195 | struct p54_edcf_queue_param qos_params[8]; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 196 |  | 
|  | 197 | /* Radio data */ | 
|  | 198 | u16 rxhw; | 
|  | 199 | u8 rx_diversity_mask; | 
|  | 200 | u8 tx_diversity_mask; | 
|  | 201 | unsigned int output_power; | 
| Christian Lamparter | 7a047f4 | 2011-02-12 22:32:49 +0100 | [diff] [blame] | 202 | struct p54_rssi_db_entry *cur_rssi; | 
| Christian Lamparter | 0d78156 | 2011-08-20 01:53:59 +0200 | [diff] [blame] | 203 | struct ieee80211_channel *curchan; | 
|  | 204 | struct survey_info *survey; | 
|  | 205 | unsigned int chan_num; | 
|  | 206 | struct completion stat_comp; | 
|  | 207 | bool update_stats; | 
|  | 208 | struct { | 
|  | 209 | unsigned int timestamp; | 
|  | 210 | unsigned int cached_cca; | 
|  | 211 | unsigned int cached_tx; | 
|  | 212 | unsigned int cached_rssi; | 
|  | 213 | u64 active; | 
|  | 214 | u64 cca; | 
|  | 215 | u64 tx; | 
|  | 216 | u64 rssi; | 
|  | 217 | } survey_raw; | 
|  | 218 |  | 
| Christian Lamparter | cc6de66 | 2008-09-06 02:56:23 +0200 | [diff] [blame] | 219 | int noise; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 220 | /* calibration, output power limit and rssi<->dBm conversation data */ | 
|  | 221 | struct pda_iq_autocal_entry *iq_autocal; | 
|  | 222 | unsigned int iq_autocal_len; | 
|  | 223 | struct p54_cal_database *curve_data; | 
|  | 224 | struct p54_cal_database *output_limit; | 
| Christian Lamparter | 7a047f4 | 2011-02-12 22:32:49 +0100 | [diff] [blame] | 225 | struct p54_cal_database *rssi_db; | 
| Christian Lamparter | 1a9b667 | 2009-07-11 01:22:26 +0200 | [diff] [blame] | 226 | struct ieee80211_supported_band *band_table[IEEE80211_NUM_BANDS]; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 227 |  | 
|  | 228 | /* BBP/MAC state */ | 
|  | 229 | u8 mac_addr[ETH_ALEN]; | 
|  | 230 | u8 bssid[ETH_ALEN]; | 
| Christian Lamparter | be8d98e | 2011-04-24 17:22:59 +0200 | [diff] [blame] | 231 | u8 mc_maclist[4][ETH_ALEN]; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 232 | u16 wakeup_timer; | 
|  | 233 | unsigned int filter_flags; | 
| Christian Lamparter | be8d98e | 2011-04-24 17:22:59 +0200 | [diff] [blame] | 234 | int mc_maclist_num; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 235 | int mode; | 
|  | 236 | u32 tsf_low32, tsf_high32; | 
|  | 237 | u32 basic_rate_mask; | 
|  | 238 | u16 aid; | 
| Christian Lamparter | 3083e83 | 2011-02-24 14:12:20 +0100 | [diff] [blame] | 239 | u8 coverage_class; | 
| Christian Lamparter | 0d78156 | 2011-08-20 01:53:59 +0200 | [diff] [blame] | 240 | bool phy_idle; | 
|  | 241 | bool phy_ps; | 
| Christian Lamparter | e0f114e | 2009-07-07 19:08:07 +0200 | [diff] [blame] | 242 | bool powersave_override; | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 243 | __le32 beacon_req_id; | 
| Christian Lamparter | 46df10a | 2009-07-16 20:03:47 +0200 | [diff] [blame] | 244 | struct completion beacon_comp; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 245 |  | 
|  | 246 | /* cryptographic engine information */ | 
| Christian Lamparter | 25900ef | 2008-11-29 22:34:37 +0100 | [diff] [blame] | 247 | u8 privacy_caps; | 
|  | 248 | u8 rx_keycache_size; | 
| Christian Lamparter | 6dfe9a8 | 2009-04-11 03:58:01 +0200 | [diff] [blame] | 249 | unsigned long *used_rxkeys; | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 250 |  | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 251 | /* LED management */ | 
| John W. Linville | 83f8b47 | 2009-05-06 14:16:15 -0400 | [diff] [blame] | 252 | #ifdef CONFIG_P54_LEDS | 
| Christian Lamparter | dce0725 | 2009-03-25 03:12:18 +0100 | [diff] [blame] | 253 | struct p54_led_dev leds[4]; | 
|  | 254 | struct delayed_work led_work; | 
| John W. Linville | 83f8b47 | 2009-05-06 14:16:15 -0400 | [diff] [blame] | 255 | #endif /* CONFIG_P54_LEDS */ | 
| Christian Lamparter | d0b45ae | 2009-03-06 01:02:04 +0100 | [diff] [blame] | 256 | u16 softled_state;		/* bit field of glowing LEDs */ | 
| Christian Lamparter | cf3a957 | 2009-03-25 03:11:58 +0100 | [diff] [blame] | 257 |  | 
|  | 258 | /* statistics */ | 
|  | 259 | struct ieee80211_low_level_stats stats; | 
|  | 260 | struct delayed_work work; | 
|  | 261 |  | 
|  | 262 | /* eeprom handling */ | 
|  | 263 | void *eeprom; | 
|  | 264 | struct completion eeprom_comp; | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 265 | struct mutex eeprom_mutex; | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 266 | }; | 
|  | 267 |  | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 268 | /* interfaces for the drivers */ | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 269 | int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb); | 
| Christian Lamparter | b92f30d | 2008-10-15 04:07:16 +0200 | [diff] [blame] | 270 | void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb); | 
| Christian Lamparter | 4e416a6 | 2008-09-01 22:48:41 +0200 | [diff] [blame] | 271 | int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw); | 
| Christian Lamparter | cd8d3d3 | 2009-01-11 01:18:38 +0100 | [diff] [blame] | 272 | int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len); | 
| Christian Lamparter | 7cb7707 | 2008-09-01 22:48:51 +0200 | [diff] [blame] | 273 | int p54_read_eeprom(struct ieee80211_hw *dev); | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 274 |  | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 275 | struct ieee80211_hw *p54_init_common(size_t priv_data_len); | 
| Christian Lamparter | 2ac7107 | 2009-03-05 21:30:10 +0100 | [diff] [blame] | 276 | int p54_register_common(struct ieee80211_hw *dev, struct device *pdev); | 
| Michael Wu | eff1a59 | 2007-09-25 18:11:01 -0700 | [diff] [blame] | 277 | void p54_free_common(struct ieee80211_hw *dev); | 
|  | 278 |  | 
| Christian Lamparter | d8c9210 | 2009-06-23 10:39:45 -0500 | [diff] [blame] | 279 | void p54_unregister_common(struct ieee80211_hw *dev); | 
|  | 280 |  | 
| Christian Lamparter | 32ddf07 | 2008-08-08 21:17:37 +0200 | [diff] [blame] | 281 | #endif /* P54_H */ |