ath6kl: convert ar6004 hardware flags to firmware feature flags
authorKalle Valo <kvalo@qca.qualcomm.com>
Tue, 17 Jun 2014 09:40:52 +0000 (12:40 +0300)
committerKalle Valo <kvalo@qca.qualcomm.com>
Mon, 14 Jul 2014 13:02:52 +0000 (16:02 +0300)
The functionality defined through these flags were actually firmware features
which can change between firmware versions. To make it possible to support
different firmware versions with the same driver, convert the flags to firmware
feature flags.

For backwards compatibility support for old ar6004 firmware FW
API 3 or smaller images we forcefully set the feature bits in the driver.
Starting from FW API 5 the firmware image needs to set them.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/ath6kl/core.c
drivers/net/wireless/ath/ath6kl/core.h
drivers/net/wireless/ath/ath6kl/init.c
drivers/net/wireless/ath/ath6kl/usb.c
drivers/net/wireless/ath/ath6kl/wmi.c

index 0e26f4a34fda329910ecc278de9fe7bea8fa6c57..d139f2a7160a28120d423483070616529630e950 100644 (file)
@@ -2899,7 +2899,8 @@ static int ath6kl_start_ap(struct wiphy *wiphy, struct net_device *dev,
        if (info->inactivity_timeout) {
                inactivity_timeout = info->inactivity_timeout;
 
-               if (ar->hw.flags & ATH6KL_HW_AP_INACTIVITY_MINS)
+               if (test_bit(ATH6KL_FW_CAPABILITY_AP_INACTIVITY_MINS,
+                            ar->fw_capabilities))
                        inactivity_timeout = DIV_ROUND_UP(inactivity_timeout,
                                                          60);
 
@@ -3782,7 +3783,8 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
                ath6kl_band_5ghz.ht_cap.ht_supported = false;
        }
 
-       if (ar->hw.flags & ATH6KL_HW_64BIT_RATES) {
+       if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES,
+                    ar->fw_capabilities)) {
                ath6kl_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
                ath6kl_band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff;
                ath6kl_band_2ghz.ht_cap.mcs.rx_mask[1] = 0xff;
index b0b6520427600a05687e299318f78f873e3fd948..0df74b245af4c0180ea9219c8765453241aea9f0 100644 (file)
@@ -123,6 +123,22 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
 
        /* FIXME: we should free all firmwares in the error cases below */
 
+       /*
+        * Backwards compatibility support for older ar6004 firmware images
+        * which do not set these feature flags.
+        */
+       if (ar->target_type == TARGET_TYPE_AR6004 &&
+           ar->fw_api <= 4) {
+               __set_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES,
+                         ar->fw_capabilities);
+               __set_bit(ATH6KL_FW_CAPABILITY_AP_INACTIVITY_MINS,
+                         ar->fw_capabilities);
+
+               if (ar->hw.id == AR6004_HW_1_3_VERSION)
+                       __set_bit(ATH6KL_FW_CAPABILITY_MAP_LP_ENDPOINT,
+                                 ar->fw_capabilities);
+       }
+
        /* Indicate that WMI is enabled (although not ready yet) */
        set_bit(WMI_ENABLED, &ar->flag);
        ar->wmi = ath6kl_wmi_init(ar);
index 26b0f92424e16fb91beca55f3f07e9d907a9db04..bd91c446558008148e3e9e4f68a7e6e1986e2ee5 100644 (file)
@@ -136,6 +136,15 @@ enum ath6kl_fw_capability {
         */
        ATH6KL_FW_CAPABILITY_HEART_BEAT_POLL,
 
+       /* WMI_SET_TX_SELECT_RATES_CMDID uses 64 bit size rate table */
+       ATH6KL_FW_CAPABILITY_64BIT_RATES,
+
+       /* WMI_AP_CONN_INACT_CMDID uses minutes as units */
+       ATH6KL_FW_CAPABILITY_AP_INACTIVITY_MINS,
+
+       /* use low priority endpoint for all data */
+       ATH6KL_FW_CAPABILITY_MAP_LP_ENDPOINT,
+
        /* this needs to be last */
        ATH6KL_FW_CAPABILITY_MAX,
 };
@@ -149,9 +158,6 @@ struct ath6kl_fw_ie {
 };
 
 enum ath6kl_hw_flags {
-       ATH6KL_HW_64BIT_RATES           = BIT(0),
-       ATH6KL_HW_AP_INACTIVITY_MINS    = BIT(1),
-       ATH6KL_HW_MAP_LP_ENDPOINT       = BIT(2),
        ATH6KL_HW_SDIO_CRC_ERROR_WAR    = BIT(3),
 };
 
index 6e1e6995a63498b653321a3a91a1add30746e2bd..ed086ead260164496b216fbcfc91d0d17abc3576 100644 (file)
@@ -93,8 +93,7 @@ static const struct ath6kl_hw hw_list[] = {
                .board_addr                     = 0x433900,
                .refclk_hz                      = 26000000,
                .uarttx_pin                     = 11,
-               .flags                          = ATH6KL_HW_64BIT_RATES |
-                                                 ATH6KL_HW_AP_INACTIVITY_MINS,
+               .flags                          = 0,
 
                .fw = {
                        .dir            = AR6004_HW_1_0_FW_DIR,
@@ -114,8 +113,7 @@ static const struct ath6kl_hw hw_list[] = {
                .board_addr                     = 0x43d400,
                .refclk_hz                      = 40000000,
                .uarttx_pin                     = 11,
-               .flags                          = ATH6KL_HW_64BIT_RATES |
-                                                 ATH6KL_HW_AP_INACTIVITY_MINS,
+               .flags                          = 0,
                .fw = {
                        .dir            = AR6004_HW_1_1_FW_DIR,
                        .fw             = AR6004_HW_1_1_FIRMWARE_FILE,
@@ -134,8 +132,7 @@ static const struct ath6kl_hw hw_list[] = {
                .board_addr                     = 0x435c00,
                .refclk_hz                      = 40000000,
                .uarttx_pin                     = 11,
-               .flags                          = ATH6KL_HW_64BIT_RATES |
-                                                 ATH6KL_HW_AP_INACTIVITY_MINS,
+               .flags                          = 0,
 
                .fw = {
                        .dir            = AR6004_HW_1_2_FW_DIR,
@@ -154,9 +151,7 @@ static const struct ath6kl_hw hw_list[] = {
                .board_addr                     = 0x436400,
                .refclk_hz                      = 40000000,
                .uarttx_pin                     = 11,
-               .flags                          = ATH6KL_HW_64BIT_RATES |
-                                                 ATH6KL_HW_AP_INACTIVITY_MINS |
-                                                 ATH6KL_HW_MAP_LP_ENDPOINT,
+               .flags                          = 0,
 
                .fw = {
                        .dir            = AR6004_HW_1_3_FW_DIR,
@@ -1575,6 +1570,9 @@ static const struct fw_capa_str_map {
        { ATH6KL_FW_CAPABILITY_REGDOMAIN, "regdomain" },
        { ATH6KL_FW_CAPABILITY_SCHED_SCAN_V2, "sched-scan-v2" },
        { ATH6KL_FW_CAPABILITY_HEART_BEAT_POLL, "hb-poll" },
+       { ATH6KL_FW_CAPABILITY_64BIT_RATES, "64bit-rates" },
+       { ATH6KL_FW_CAPABILITY_AP_INACTIVITY_MINS, "ap-inactivity-mins" },
+       { ATH6KL_FW_CAPABILITY_MAP_LP_ENDPOINT, "map-lp-endpoint" },
 };
 
 static const char *ath6kl_init_get_fw_capa_name(unsigned int id)
index 3afc5a463d06f822f339250deecfb1cefadea592..e5a9e7fe2cea69a0f6322676451d6bd3b9476ba1 100644 (file)
@@ -802,7 +802,8 @@ static int ath6kl_usb_map_service_pipe(struct ath6kl *ar, u16 svc_id,
                break;
        case WMI_DATA_VI_SVC:
 
-               if (ar->hw.flags & ATH6KL_HW_MAP_LP_ENDPOINT)
+               if (test_bit(ATH6KL_FW_CAPABILITY_MAP_LP_ENDPOINT,
+                            ar->fw_capabilities))
                        *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_LP;
                else
                        *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_MP;
@@ -814,7 +815,8 @@ static int ath6kl_usb_map_service_pipe(struct ath6kl *ar, u16 svc_id,
                break;
        case WMI_DATA_VO_SVC:
 
-               if (ar->hw.flags & ATH6KL_HW_MAP_LP_ENDPOINT)
+               if (test_bit(ATH6KL_FW_CAPABILITY_MAP_LP_ENDPOINT,
+                            ar->fw_capabilities))
                        *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_LP;
                else
                        *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_MP;
index 4d7f9e4712e991deea8553f7505a7f79b9a6f6e7..6ecc0a419c1ac4603c27bab572ed90687330aeb4 100644 (file)
@@ -2838,7 +2838,8 @@ int ath6kl_wmi_set_bitrate_mask(struct wmi *wmi, u8 if_idx,
 {
        struct ath6kl *ar = wmi->parent_dev;
 
-       if (ar->hw.flags & ATH6KL_HW_64BIT_RATES)
+       if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES,
+                    ar->fw_capabilities))
                return ath6kl_set_bitrate_mask64(wmi, if_idx, mask);
        else
                return ath6kl_set_bitrate_mask32(wmi, if_idx, mask);