1*b4c3e9b5SBjoern A. Zeeb /* 2*b4c3e9b5SBjoern A. Zeeb * Copyright (c) 2010 Broadcom Corporation 3*b4c3e9b5SBjoern A. Zeeb * 4*b4c3e9b5SBjoern A. Zeeb * Permission to use, copy, modify, and/or distribute this software for any 5*b4c3e9b5SBjoern A. Zeeb * purpose with or without fee is hereby granted, provided that the above 6*b4c3e9b5SBjoern A. Zeeb * copyright notice and this permission notice appear in all copies. 7*b4c3e9b5SBjoern A. Zeeb * 8*b4c3e9b5SBjoern A. Zeeb * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9*b4c3e9b5SBjoern A. Zeeb * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*b4c3e9b5SBjoern A. Zeeb * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11*b4c3e9b5SBjoern A. Zeeb * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*b4c3e9b5SBjoern A. Zeeb * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13*b4c3e9b5SBjoern A. Zeeb * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14*b4c3e9b5SBjoern A. Zeeb * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*b4c3e9b5SBjoern A. Zeeb */ 16*b4c3e9b5SBjoern A. Zeeb 17*b4c3e9b5SBjoern A. Zeeb #ifndef _BRCM_MAC80211_IF_H_ 18*b4c3e9b5SBjoern A. Zeeb #define _BRCM_MAC80211_IF_H_ 19*b4c3e9b5SBjoern A. Zeeb 20*b4c3e9b5SBjoern A. Zeeb #include <linux/timer.h> 21*b4c3e9b5SBjoern A. Zeeb #include <linux/interrupt.h> 22*b4c3e9b5SBjoern A. Zeeb #include <linux/workqueue.h> 23*b4c3e9b5SBjoern A. Zeeb #include <linux/leds.h> 24*b4c3e9b5SBjoern A. Zeeb 25*b4c3e9b5SBjoern A. Zeeb #include "ucode_loader.h" 26*b4c3e9b5SBjoern A. Zeeb #include "led.h" 27*b4c3e9b5SBjoern A. Zeeb /* 28*b4c3e9b5SBjoern A. Zeeb * Starting index for 5G rates in the 29*b4c3e9b5SBjoern A. Zeeb * legacy rate table. 30*b4c3e9b5SBjoern A. Zeeb */ 31*b4c3e9b5SBjoern A. Zeeb #define BRCMS_LEGACY_5G_RATE_OFFSET 4 32*b4c3e9b5SBjoern A. Zeeb 33*b4c3e9b5SBjoern A. Zeeb /* softmac ioctl definitions */ 34*b4c3e9b5SBjoern A. Zeeb #define BRCMS_SET_SHORTSLOT_OVERRIDE 146 35*b4c3e9b5SBjoern A. Zeeb 36*b4c3e9b5SBjoern A. Zeeb struct brcms_timer { 37*b4c3e9b5SBjoern A. Zeeb struct delayed_work dly_wrk; 38*b4c3e9b5SBjoern A. Zeeb struct brcms_info *wl; 39*b4c3e9b5SBjoern A. Zeeb void (*fn) (void *); /* function called upon expiration */ 40*b4c3e9b5SBjoern A. Zeeb void *arg; /* fixed argument provided to called function */ 41*b4c3e9b5SBjoern A. Zeeb uint ms; 42*b4c3e9b5SBjoern A. Zeeb bool periodic; 43*b4c3e9b5SBjoern A. Zeeb bool set; /* indicates if timer is active */ 44*b4c3e9b5SBjoern A. Zeeb struct brcms_timer *next; /* for freeing on unload */ 45*b4c3e9b5SBjoern A. Zeeb #ifdef DEBUG 46*b4c3e9b5SBjoern A. Zeeb char *name; /* Description of the timer */ 47*b4c3e9b5SBjoern A. Zeeb #endif 48*b4c3e9b5SBjoern A. Zeeb }; 49*b4c3e9b5SBjoern A. Zeeb 50*b4c3e9b5SBjoern A. Zeeb struct brcms_if { 51*b4c3e9b5SBjoern A. Zeeb uint subunit; /* WDS/BSS unit */ 52*b4c3e9b5SBjoern A. Zeeb struct pci_dev *pci_dev; 53*b4c3e9b5SBjoern A. Zeeb }; 54*b4c3e9b5SBjoern A. Zeeb 55*b4c3e9b5SBjoern A. Zeeb #define MAX_FW_IMAGES 4 56*b4c3e9b5SBjoern A. Zeeb struct brcms_firmware { 57*b4c3e9b5SBjoern A. Zeeb u32 fw_cnt; 58*b4c3e9b5SBjoern A. Zeeb const struct firmware *fw_bin[MAX_FW_IMAGES]; 59*b4c3e9b5SBjoern A. Zeeb const struct firmware *fw_hdr[MAX_FW_IMAGES]; 60*b4c3e9b5SBjoern A. Zeeb u32 hdr_num_entries[MAX_FW_IMAGES]; 61*b4c3e9b5SBjoern A. Zeeb }; 62*b4c3e9b5SBjoern A. Zeeb 63*b4c3e9b5SBjoern A. Zeeb struct brcms_info { 64*b4c3e9b5SBjoern A. Zeeb struct brcms_pub *pub; /* pointer to public wlc state */ 65*b4c3e9b5SBjoern A. Zeeb struct brcms_c_info *wlc; /* pointer to private common data */ 66*b4c3e9b5SBjoern A. Zeeb u32 magic; 67*b4c3e9b5SBjoern A. Zeeb 68*b4c3e9b5SBjoern A. Zeeb int irq; 69*b4c3e9b5SBjoern A. Zeeb 70*b4c3e9b5SBjoern A. Zeeb spinlock_t lock; /* per-device perimeter lock */ 71*b4c3e9b5SBjoern A. Zeeb spinlock_t isr_lock; /* per-device ISR synchronization lock */ 72*b4c3e9b5SBjoern A. Zeeb 73*b4c3e9b5SBjoern A. Zeeb /* tx flush */ 74*b4c3e9b5SBjoern A. Zeeb wait_queue_head_t tx_flush_wq; 75*b4c3e9b5SBjoern A. Zeeb 76*b4c3e9b5SBjoern A. Zeeb /* timer related fields */ 77*b4c3e9b5SBjoern A. Zeeb atomic_t callbacks; /* # outstanding callback functions */ 78*b4c3e9b5SBjoern A. Zeeb struct brcms_timer *timers; /* timer cleanup queue */ 79*b4c3e9b5SBjoern A. Zeeb 80*b4c3e9b5SBjoern A. Zeeb struct tasklet_struct tasklet; /* dpc tasklet */ 81*b4c3e9b5SBjoern A. Zeeb bool resched; /* dpc needs to be and is rescheduled */ 82*b4c3e9b5SBjoern A. Zeeb struct brcms_firmware fw; 83*b4c3e9b5SBjoern A. Zeeb struct wiphy *wiphy; 84*b4c3e9b5SBjoern A. Zeeb struct brcms_ucode ucode; 85*b4c3e9b5SBjoern A. Zeeb bool mute_tx; 86*b4c3e9b5SBjoern A. Zeeb struct brcms_led radio_led; 87*b4c3e9b5SBjoern A. Zeeb struct led_classdev led_dev; 88*b4c3e9b5SBjoern A. Zeeb }; 89*b4c3e9b5SBjoern A. Zeeb 90*b4c3e9b5SBjoern A. Zeeb /* misc callbacks */ 91*b4c3e9b5SBjoern A. Zeeb void brcms_init(struct brcms_info *wl); 92*b4c3e9b5SBjoern A. Zeeb uint brcms_reset(struct brcms_info *wl); 93*b4c3e9b5SBjoern A. Zeeb void brcms_intrson(struct brcms_info *wl); 94*b4c3e9b5SBjoern A. Zeeb u32 brcms_intrsoff(struct brcms_info *wl); 95*b4c3e9b5SBjoern A. Zeeb void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask); 96*b4c3e9b5SBjoern A. Zeeb int brcms_up(struct brcms_info *wl); 97*b4c3e9b5SBjoern A. Zeeb void brcms_down(struct brcms_info *wl); 98*b4c3e9b5SBjoern A. Zeeb void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif, 99*b4c3e9b5SBjoern A. Zeeb bool state, int prio); 100*b4c3e9b5SBjoern A. Zeeb bool brcms_rfkill_set_hw_state(struct brcms_info *wl); 101*b4c3e9b5SBjoern A. Zeeb 102*b4c3e9b5SBjoern A. Zeeb /* timer functions */ 103*b4c3e9b5SBjoern A. Zeeb struct brcms_timer *brcms_init_timer(struct brcms_info *wl, 104*b4c3e9b5SBjoern A. Zeeb void (*fn) (void *arg), void *arg, 105*b4c3e9b5SBjoern A. Zeeb const char *name); 106*b4c3e9b5SBjoern A. Zeeb void brcms_free_timer(struct brcms_timer *timer); 107*b4c3e9b5SBjoern A. Zeeb void brcms_add_timer(struct brcms_timer *timer, uint ms, int periodic); 108*b4c3e9b5SBjoern A. Zeeb bool brcms_del_timer(struct brcms_timer *timer); 109*b4c3e9b5SBjoern A. Zeeb void brcms_dpc(struct tasklet_struct *t); 110*b4c3e9b5SBjoern A. Zeeb void brcms_timer(struct brcms_timer *t); 111*b4c3e9b5SBjoern A. Zeeb void brcms_fatal_error(struct brcms_info *wl); 112*b4c3e9b5SBjoern A. Zeeb 113*b4c3e9b5SBjoern A. Zeeb #endif /* _BRCM_MAC80211_IF_H_ */ 114