rtlwifi: Add headers for rtl8187cu
[pandora-kernel.git] / drivers / net / wireless / rtlwifi / wifi.h
index d44d796..328fb40 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/firmware.h>
 #include <linux/version.h>
 #include <linux/etherdevice.h>
+#include <linux/usb.h>
 #include <net/mac80211.h>
 #include "debug.h"
 
@@ -113,11 +114,19 @@ enum hardware_type {
        HARDWARE_TYPE_RTL8192CU,
        HARDWARE_TYPE_RTL8192DE,
        HARDWARE_TYPE_RTL8192DU,
+       HARDWARE_TYPE_RTL8723U,
 
        /*keep it last*/
        HARDWARE_TYPE_NUM
 };
 
+#define IS_HARDWARE_TYPE_8192CE(rtlhal)                        \
+       (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE)
+#define IS_HARDWARE_TYPE_8192CU(rtlhal)                        \
+       (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU)
+#define IS_HARDWARE_TYPE_8723U(rtlhal)                 \
+       (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
+
 enum scan_operation_backup_opt {
        SCAN_OPT_BACKUP = 0,
        SCAN_OPT_RESTORE,
@@ -359,6 +368,8 @@ enum rtl_var_map {
        EFUSE_LOADER_CLK_EN,
        EFUSE_ANA8M,
        EFUSE_HWSET_MAX_SIZE,
+       EFUSE_MAX_SECTION_MAP,
+       EFUSE_REAL_CONTENT_SIZE,
 
        /*CAM map */
        RWCAM,
@@ -505,6 +516,17 @@ enum wireless_mode {
        WIRELESS_MODE_N_5G = 0x20
 };
 
+#define IS_WIRELESS_MODE_A(wirelessmode)       \
+       (wirelessmode == WIRELESS_MODE_A)
+#define IS_WIRELESS_MODE_B(wirelessmode)       \
+       (wirelessmode == WIRELESS_MODE_B)
+#define IS_WIRELESS_MODE_G(wirelessmode)       \
+       (wirelessmode == WIRELESS_MODE_G)
+#define IS_WIRELESS_MODE_N_24G(wirelessmode)   \
+       (wirelessmode == WIRELESS_MODE_N_24G)
+#define IS_WIRELESS_MODE_N_5G(wirelessmode)    \
+       (wirelessmode == WIRELESS_MODE_N_5G)
+
 enum ratr_table_mode {
        RATR_INX_WIRELESS_NGB = 0,
        RATR_INX_WIRELESS_NG = 1,
@@ -574,11 +596,11 @@ struct rtl_probe_rsp {
 struct rtl_led {
        void *hw;
        enum rtl_led_pin ledpin;
-       bool b_ledon;
+       bool ledon;
 };
 
 struct rtl_led_ctl {
-       bool bled_opendrain;
+       bool led_opendrain;
        struct rtl_led sw_led0;
        struct rtl_led sw_led1;
 };
@@ -690,6 +712,25 @@ struct rtl_rfkill {
        bool rfkill_state;      /*0 is off, 1 is on */
 };
 
+struct phy_parameters {
+       u16 length;
+       u32 *pdata;
+};
+
+enum hw_param_tab_index {
+       PHY_REG_2T,
+       PHY_REG_1T,
+       PHY_REG_PG,
+       RADIOA_2T,
+       RADIOB_2T,
+       RADIOA_1T,
+       RADIOB_1T,
+       MAC_REG,
+       AGCTAB_2T,
+       AGCTAB_1T,
+       MAX_TAB
+};
+
 struct rtl_phy {
        struct bb_reg_def phyreg_def[4];        /*Radio A/B/C/D */
        struct init_gain initgain_backup;
@@ -723,10 +764,10 @@ struct rtl_phy {
        u32 iqk_mac_backup[IQK_MAC_REG_NUM];
        u32 iqk_bb_backup[10];
 
-       bool b_rfpi_enable;
+       bool rfpi_enable;
 
        u8 pwrgroup_cnt;
-       u8 bcck_high_power;
+       u8 cck_high_power;
        /* 3 groups of pwr diff by rates*/
        u32 mcs_txpwrlevel_origoffset[4][16];
        u8 default_initialgain[4];
@@ -736,13 +777,14 @@ struct rtl_phy {
        u8 cur_ofdm24g_txpwridx;
 
        u32 rfreg_chnlval[2];
-       bool b_apk_done;
+       bool apk_done;
 
        /*fsync*/
        u8 framesync;
        u32 framesync_c34;
 
        u8 num_total_rfpath;
+       struct phy_parameters hwparam_tables[MAX_TAB];
 };
 
 #define MAX_TID_COUNT                          9
@@ -768,6 +810,7 @@ struct rtl_tid_data {
 struct rtl_priv;
 struct rtl_io {
        struct device *dev;
+       struct mutex bb_mutex;
 
        /*PCI MEM map */
        unsigned long pci_mem_end;      /*shared mem end        */
@@ -779,10 +822,14 @@ struct rtl_io {
        void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val);
        void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val);
        void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val);
+       int (*writeN_async) (struct rtl_priv *rtlpriv, u32 addr, u16 len,
+                            u8 *pdata);
 
         u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
         u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
         u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
+       int (*readN_sync) (struct rtl_priv *rtlpriv, u32 addr, u16 len,
+                           u8 *pdata);
 
 };
 
@@ -853,14 +900,16 @@ struct rtl_hal {
        enum intf_type interface;
        u16 hw_type;            /*92c or 92d or 92s and so on */
        u8 oem_id;
-       u8 version;             /*version of chip */
+       u32 version;            /*version of chip */
        u8 state;               /*stop 0, start 1 */
 
        /*firmware */
        u8 *pfirmware;
-       bool b_h2c_setinprogress;
+       u16 fw_version;
+       u16 fw_subversion;
+       bool h2c_setinprogress;
        u8 last_hmeboxnum;
-       bool bfw_ready;
+       bool fw_ready;
        /*Reserve page start offset except beacon in TxQ. */
        u8 fw_rsvdpage_startoffset;
 };
@@ -887,21 +936,21 @@ struct rtl_security {
 };
 
 struct rtl_dm {
-       /*PHY status for DM */
+       /*PHY status for DM (dynamic management) */
        long entry_min_undecoratedsmoothed_pwdb;
        long undecorated_smoothed_pwdb; /*out dm */
        long entry_max_undecoratedsmoothed_pwdb;
-       bool b_dm_initialgain_enable;
-       bool bdynamic_txpower_enable;
-       bool bcurrent_turbo_edca;
-       bool bis_any_nonbepkts; /*out dm */
-       bool bis_cur_rdlstate;
-       bool btxpower_trackingInit;
-       bool b_disable_framebursting;
-       bool b_cck_inch14;
-       bool btxpower_tracking;
-       bool b_useramask;
-       bool brfpath_rxenable[4];
+       bool dm_initialgain_enable;
+       bool dynamic_txpower_enable;
+       bool current_turbo_edca;
+       bool is_any_nonbepkts;  /*out dm */
+       bool is_cur_rdlstate;
+       bool txpower_trackingInit;
+       bool disable_framebursting;
+       bool cck_inch14;
+       bool txpower_tracking;
+       bool useramask;
+       bool rfpath_rxenable[4];
 
        u8 thermalvalue_iqk;
        u8 thermalvalue_lck;
@@ -916,10 +965,10 @@ struct rtl_dm {
        char cck_index;
 };
 
-#define        EFUSE_MAX_LOGICAL_SIZE                   128
+#define        EFUSE_MAX_LOGICAL_SIZE                   256
 
 struct rtl_efuse {
-       bool bautoLoad_ok;
+       bool autoload_ok;
        bool bootfromefuse;
        u16 max_physical_size;
        u8 contents[EFUSE_MAX_LOGICAL_SIZE];
@@ -938,10 +987,12 @@ struct rtl_efuse {
        u8 eeprom_oemid;
        u16 eeprom_channelplan;
        u8 eeprom_version;
+       u8 board_type;
+       u8 external_pa;
 
        u8 dev_addr[6];
 
-       bool b_txpwr_fromeprom;
+       bool txpwr_fromeprom;
        u8 eeprom_tssi[2];
        u8 eeprom_pwrlimit_ht20[3];
        u8 eeprom_pwrlimit_ht40[3];
@@ -965,15 +1016,15 @@ struct rtl_efuse {
        u8 thermalmeter[2];
 
        u8 legacy_ht_txpowerdiff;       /*Legacy to HT rate power diff */
-       bool b_apk_thermalmeterignore;
+       bool apk_thermalmeterignore;
 };
 
 struct rtl_ps_ctl {
        bool set_rfpowerstate_inprogress;
-       bool b_in_powersavemode;
+       bool in_powersavemode;
        bool rfchange_inprogress;
-       bool b_swrf_processing;
-       bool b_hwradiooff;
+       bool swrf_processing;
+       bool hwradiooff;
 
        u32 last_sleep_jiffies;
        u32 last_awake_jiffies;
@@ -984,23 +1035,23 @@ struct rtl_ps_ctl {
         * If it supports ASPM, Offset[560h] = 0x40,
         * otherwise Offset[560h] = 0x00.
         * */
-       bool b_support_aspm;
-       bool b_support_backdoor;
+       bool support_aspm;
+       bool support_backdoor;
 
        /*for LPS */
        enum rt_psmode dot11_psmode;    /*Power save mode configured. */
-       bool b_leisure_ps;
-       bool b_fwctrl_lps;
+       bool leisure_ps;
+       bool fwctrl_lps;
        u8 fwctrl_psmode;
        /*For Fw control LPS mode */
-       u8 b_reg_fwctrl_lps;
+       u8 reg_fwctrl_lps;
        /*Record Fw PS mode status. */
-       bool b_fw_current_inpsmode;
+       bool fw_current_inpsmode;
        u8 reg_max_lps_awakeintvl;
        bool report_linked;
 
        /*for IPS */
-       bool b_inactiveps;
+       bool inactiveps;
 
        u32 rfoff_reason;
 
@@ -1011,6 +1062,7 @@ struct rtl_ps_ctl {
        /*just for PCIE ASPM */
        u8 const_amdpci_aspm;
 
+       bool pwrdown_mode;
        enum rf_pwrstate inactive_pwrstate;
        enum rf_pwrstate rfpwr_state;   /*cur power state */
 };
@@ -1038,10 +1090,10 @@ struct rtl_stats {
        s32 recvsignalpower;
        s8 rxpower;             /*in dBm Translate from PWdB */
        u8 signalstrength;      /*in 0-100 index. */
-       u16 b_hwerror:1;
-       u16 b_crc:1;
-       u16 b_icv:1;
-       u16 b_shortpreamble:1;
+       u16 hwerror:1;
+       u16 crc:1;
+       u16 icv:1;
+       u16 shortpreamble:1;
        u16 antenna:1;
        u16 decrypted:1;
        u16 wakeup:1;
@@ -1050,15 +1102,15 @@ struct rtl_stats {
 
        u8 rx_drvinfo_size;
        u8 rx_bufshift;
-       bool b_isampdu;
+       bool isampdu;
        bool rx_is40Mhzpacket;
        u32 rx_pwdb_all;
        u8 rx_mimo_signalstrength[4];   /*in 0~100 index */
        s8 rx_mimo_signalquality[2];
-       bool b_packet_matchbssid;
-       bool b_is_cck;
-       bool b_packet_toself;
-       bool b_packet_beacon;   /*for rssi */
+       bool packet_matchbssid;
+       bool is_cck;
+       bool packet_toself;
+       bool packet_beacon;     /*for rssi */
        char cck_adc_pwdb[4];   /*for rx path selection */
 };
 
@@ -1069,23 +1121,23 @@ struct rt_link_detect {
        u32 num_tx_inperiod;
        u32 num_rx_inperiod;
 
-       bool b_busytraffic;
-       bool b_higher_busytraffic;
-       bool b_higher_busyrxtraffic;
+       bool busytraffic;
+       bool higher_busytraffic;
+       bool higher_busyrxtraffic;
 };
 
 struct rtl_tcb_desc {
-       u8 b_packet_bw:1;
-       u8 b_multicast:1;
-       u8 b_broadcast:1;
-
-       u8 b_rts_stbc:1;
-       u8 b_rts_enable:1;
-       u8 b_cts_enable:1;
-       u8 b_rts_use_shortpreamble:1;
-       u8 b_rts_use_shortgi:1;
+       u8 packet_bw:1;
+       u8 multicast:1;
+       u8 broadcast:1;
+
+       u8 rts_stbc:1;
+       u8 rts_enable:1;
+       u8 cts_enable:1;
+       u8 rts_use_shortpreamble:1;
+       u8 rts_use_shortgi:1;
        u8 rts_sc:1;
-       u8 b_rts_bw:1;
+       u8 rts_bw:1;
        u8 rts_rate;
 
        u8 use_shortgi:1;
@@ -1101,6 +1153,7 @@ struct rtl_tcb_desc {
 struct rtl_hal_ops {
        int (*init_sw_vars) (struct ieee80211_hw *hw);
        void (*deinit_sw_vars) (struct ieee80211_hw *hw);
+       void (*read_chip_version)(struct ieee80211_hw *hw);
        void (*read_eeprom_info) (struct ieee80211_hw *hw);
        void (*interrupt_recognized) (struct ieee80211_hw *hw,
                                      u32 *p_inta, u32 *p_intb);
@@ -1110,9 +1163,11 @@ struct rtl_hal_ops {
        void (*disable_interrupt) (struct ieee80211_hw *hw);
        int (*set_network_type) (struct ieee80211_hw *hw,
                                 enum nl80211_iftype type);
+       void (*set_chk_bssid)(struct ieee80211_hw *hw,
+                               bool check_bssid);
        void (*set_bw_mode) (struct ieee80211_hw *hw,
                             enum nl80211_channel_type ch_type);
-        u8(*switch_channel) (struct ieee80211_hw *hw);
+       u8 (*switch_channel) (struct ieee80211_hw *hw);
        void (*set_qos) (struct ieee80211_hw *hw, int aci);
        void (*set_bcn_reg) (struct ieee80211_hw *hw);
        void (*set_bcn_intv) (struct ieee80211_hw *hw);
@@ -1126,23 +1181,26 @@ struct rtl_hal_ops {
                              struct ieee80211_hdr *hdr, u8 *pdesc_tx,
                              struct ieee80211_tx_info *info,
                              struct sk_buff *skb, unsigned int queue_index);
+       void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 * pDesc,
+                                 u32 buffer_len, bool bIsPsPoll);
        void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
-                                bool b_firstseg, bool b_lastseg,
+                                bool firstseg, bool lastseg,
                                 struct sk_buff *skb);
-        bool(*query_rx_desc) (struct ieee80211_hw *hw,
+       bool (*cmd_send_packet)(struct ieee80211_hw *hw, struct sk_buff *skb);
+       bool (*query_rx_desc) (struct ieee80211_hw *hw,
                               struct rtl_stats *stats,
                               struct ieee80211_rx_status *rx_status,
                               u8 *pdesc, struct sk_buff *skb);
        void (*set_channel_access) (struct ieee80211_hw *hw);
-        bool(*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
+       bool (*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
        void (*dm_watchdog) (struct ieee80211_hw *hw);
        void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation);
-        bool(*set_rf_power_state) (struct ieee80211_hw *hw,
+       bool (*set_rf_power_state) (struct ieee80211_hw *hw,
                                    enum rf_pwrstate rfpwr_state);
        void (*led_control) (struct ieee80211_hw *hw,
                             enum led_ctl_mode ledaction);
        void (*set_desc) (u8 *pdesc, bool istx, u8 desc_name, u8 *val);
-        u32(*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
+       u32 (*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
        void (*tx_polling) (struct ieee80211_hw *hw, unsigned int hw_queue);
        void (*enable_hw_sec) (struct ieee80211_hw *hw);
        void (*set_key) (struct ieee80211_hw *hw, u32 key_index,
@@ -1150,10 +1208,10 @@ struct rtl_hal_ops {
                         bool is_wepkey, bool clear_all);
        void (*init_sw_leds) (struct ieee80211_hw *hw);
        void (*deinit_sw_leds) (struct ieee80211_hw *hw);
-        u32(*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
+       u32 (*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
        void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
                           u32 data);
-        u32(*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
+       u32 (*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
                          u32 regaddr, u32 bitmask);
        void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
                           u32 regaddr, u32 bitmask, u32 data);
@@ -1166,6 +1224,7 @@ struct rtl_intf_ops {
 
        int (*adapter_tx) (struct ieee80211_hw *hw, struct sk_buff *skb);
        int (*reset_trx_ring) (struct ieee80211_hw *hw);
+       bool (*waitq_insert) (struct ieee80211_hw *hw, struct sk_buff *skb);
 
        /*pci */
        void (*disable_aspm) (struct ieee80211_hw *hw);
@@ -1179,11 +1238,35 @@ struct rtl_mod_params {
        int sw_crypto;
 };
 
+struct rtl_hal_usbint_cfg {
+       /* data - rx */
+       u32 in_ep_num;
+       u32 rx_urb_num;
+       u32 rx_max_size;
+
+       /* op - rx */
+       void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
+       void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
+                                    struct sk_buff_head *);
+
+       /* tx */
+       void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
+       int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
+                              struct sk_buff *);
+       struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
+                                               struct sk_buff_head *);
+
+       /* endpoint mapping */
+       int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
+       u16 (*usb_mq_to_hwq)(u16 fc, u16 mac80211_queue_index);
+};
+
 struct rtl_hal_cfg {
        char *name;
        char *fw_name;
        struct rtl_hal_ops *ops;
        struct rtl_mod_params *mod_params;
+       struct rtl_hal_usbint_cfg *usb_interface_cfg;
 
        /*this map used for some registers or vars
           defined int HAL but used in MAIN */
@@ -1202,6 +1285,7 @@ struct rtl_locks {
        spinlock_t rf_ps_lock;
        spinlock_t rf_lock;
        spinlock_t lps_lock;
+       spinlock_t tx_urb_lock;
 };
 
 struct rtl_works {
@@ -1274,6 +1358,89 @@ struct rtl_priv {
 #define rtl_efuse(rtlpriv)     (&((rtlpriv)->efuse))
 #define rtl_psc(rtlpriv)       (&((rtlpriv)->psc))
 
+/***************************************
+    Bluetooth Co-existance Related
+****************************************/
+
+enum bt_ant_num {
+       ANT_X2 = 0,
+       ANT_X1 = 1,
+};
+
+enum bt_co_type {
+       BT_2WIRE = 0,
+       BT_ISSC_3WIRE = 1,
+       BT_ACCEL = 2,
+       BT_CSR_BC4 = 3,
+       BT_CSR_BC8 = 4,
+       BT_RTL8756 = 5,
+};
+
+enum bt_cur_state {
+       BT_OFF = 0,
+       BT_ON = 1,
+};
+
+enum bt_service_type {
+       BT_SCO = 0,
+       BT_A2DP = 1,
+       BT_HID = 2,
+       BT_HID_IDLE = 3,
+       BT_SCAN = 4,
+       BT_IDLE = 5,
+       BT_OTHER_ACTION = 6,
+       BT_BUSY = 7,
+       BT_OTHERBUSY = 8,
+       BT_PAN = 9,
+};
+
+enum bt_radio_shared {
+       BT_RADIO_SHARED = 0,
+       BT_RADIO_INDIVIDUAL = 1,
+};
+
+struct bt_coexist_info {
+
+       /* EEPROM BT info. */
+       u8 eeprom_bt_coexist;
+       u8 eeprom_bt_type;
+       u8 eeprom_bt_ant_num;
+       u8 eeprom_bt_ant_isolation;
+       u8 eeprom_bt_radio_shared;
+
+       u8 bt_coexistence;
+       u8 bt_ant_num;
+       u8 bt_coexist_type;
+       u8 bt_state;
+       u8 bt_cur_state;        /* 0:on, 1:off */
+       u8 bt_ant_isolation;    /* 0:good, 1:bad */
+       u8 bt_pape_ctrl;        /* 0:SW, 1:SW/HW dynamic */
+       u8 bt_service;
+       u8 bt_radio_shared_type;
+       u8 bt_rfreg_origin_1e;
+       u8 bt_rfreg_origin_1f;
+       u8 bt_rssi_state;
+       u32 ratio_tx;
+       u32 ratio_pri;
+       u32 bt_edca_ul;
+       u32 bt_edca_dl;
+
+       bool b_init_set;
+       bool b_bt_busy_traffic;
+       bool b_bt_traffic_mode_set;
+       bool b_bt_non_traffic_mode_set;
+
+       bool b_fw_coexist_all_off;
+       bool b_sw_coexist_all_off;
+       u32 current_state;
+       u32 previous_state;
+       u8 bt_pre_rssi_state;
+
+       u8 b_reg_bt_iso;
+       u8 b_reg_bt_sco;
+
+};
+
 /****************************************
        mem access macro define start
        Call endian free function when
@@ -1437,10 +1604,8 @@ Set subfield of little-endian 4-byte value to specified value.   */
                (_os).octet = (u8 *)(_octet);           \
                (_os).length = (_len);
 
-#define CP_MACADDR(des, src)   \
-       ((des)[0] = (src)[0], (des)[1] = (src)[1],\
-       (des)[2] = (src)[2], (des)[3] = (src)[3],\
-       (des)[4] = (src)[4], (des)[5] = (src)[5])
+#define CP_MACADDR(des, src)           \
+       memcpy((des), (src), ETH_ALEN)
 
 static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr)
 {